/* ================================================================
   ROOT & RESET
================================================================ */
:root {
  --accent: #10B981;
  --bg: #0F0F0F;
  --bg2: #1A1A1A;
  --bg3: #242424;
  --border: #2E2E2E;
  --text: #F0F0F0;
  --text2: #A0A0A0;
  --danger: #EF4444;
  --green: #10B981;
  --radius: 16px;
  --radius-sm: 10px;
  --font: 'Inter', system-ui, sans-serif;
  --transition: 0.2s ease;
}

*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

html { height: 100%; scroll-behavior: smooth; }

body {
  font-family: var(--font);
  background: var(--bg);
  color: var(--text);
  min-height: 100%;
  overflow-x: hidden;
  -webkit-tap-highlight-color: transparent;
  user-select: none;
}

/* ================================================================
   NAVBAR
================================================================ */
.navbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 12px 20px;
  background: var(--bg2);
  border-bottom: 1px solid var(--border);
  position: sticky;
  top: 0;
  z-index: 100;
}

.nav-back {
  color: var(--accent);
  text-decoration: none;
  font-size: 13px;
  font-weight: 600;
  letter-spacing: 0.02em;
  transition: opacity var(--transition);
}
.nav-back:hover { opacity: 0.75; }

.nav-title {
  font-size: 14px;
  font-weight: 700;
  color: var(--text2);
}

/* ================================================================
   SCREENS
================================================================ */
.screen {
  display: none;
  min-height: calc(100vh - 49px);
  padding: 24px 20px 40px;
  max-width: 480px;
  margin: 0 auto;
}
.screen.active { display: block; }

/* ================================================================
   BUTTONS
================================================================ */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  border: none;
  border-radius: var(--radius-sm);
  font-family: var(--font);
  font-weight: 700;
  cursor: pointer;
  transition: all var(--transition);
  padding: 12px 24px;
  font-size: 15px;
  letter-spacing: 0.01em;
  touch-action: manipulation;
}

.btn-primary {
  background: var(--accent);
  color: #fff;
  box-shadow: 0 0 20px color-mix(in srgb, var(--accent) 40%, transparent);
}
.btn-primary:hover {
  filter: brightness(1.1);
  transform: translateY(-1px);
  box-shadow: 0 4px 24px color-mix(in srgb, var(--accent) 50%, transparent);
}
.btn-primary:active { transform: translateY(0); filter: brightness(0.95); }

.btn-secondary {
  background: var(--bg3);
  color: var(--text);
  border: 1px solid var(--border);
}
.btn-secondary:hover { background: #2e2e2e; }

.btn-outline {
  background: transparent;
  color: var(--accent);
  border: 2px solid var(--accent);
}
.btn-outline:hover { background: color-mix(in srgb, var(--accent) 12%, transparent); }

.btn-ghost {
  background: transparent;
  color: var(--text2);
  border: 1px solid var(--border);
  font-size: 13px;
  padding: 8px 14px;
}
.btn-ghost:hover { background: var(--bg3); color: var(--text); }

.btn-sm { padding: 8px 14px; font-size: 13px; }
.btn-lg { padding: 16px 36px; font-size: 17px; width: 100%; }
.btn-xl { padding: 18px 48px; font-size: 20px; width: 100%; max-width: 300px; }

@keyframes pulse-glow {
  0%, 100% { box-shadow: 0 0 20px color-mix(in srgb, var(--accent) 40%, transparent); }
  50% { box-shadow: 0 0 40px color-mix(in srgb, var(--accent) 70%, transparent), 0 0 60px color-mix(in srgb, var(--accent) 30%, transparent); }
}
.pulse-btn { animation: pulse-glow 2s infinite; }

/* ================================================================
   START SCREEN
================================================================ */
.start-hero {
  text-align: center;
  padding: 40px 0 32px;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 16px;
}

@keyframes float {
  0%, 100% { transform: translateY(0); }
  50% { transform: translateY(-10px); }
}

.hero-icon {
  font-size: 72px;
  animation: float 3s ease-in-out infinite;
  line-height: 1;
}

.game-title {
  font-size: clamp(28px, 7vw, 40px);
  font-weight: 900;
  letter-spacing: -0.03em;
  background: linear-gradient(135deg, var(--text) 30%, var(--accent));
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  background-clip: text;
}

.game-subtitle {
  font-size: clamp(14px, 4vw, 17px);
  color: var(--text2);
  font-weight: 500;
  line-height: 1.5;
}

.level-preview {
  font-size: 12px;
  color: #555;
  margin-top: -8px;
}

/* ================================================================
   LEADERBOARD
================================================================ */
.leaderboard-section { margin-top: 8px; }

.lb-header-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 12px;
}

.lb-title {
  font-size: 16px;
  font-weight: 700;
  color: var(--text);
}

.lb-container {
  background: var(--bg2);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  overflow: hidden;
}

.lb-compact { max-height: 260px; overflow-y: auto; }

.lb-loading, .lb-empty {
  text-align: center;
  padding: 32px;
  color: var(--text2);
  font-size: 14px;
}

.lb-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 14px;
}

.lb-table thead tr {
  background: var(--bg3);
  border-bottom: 1px solid var(--border);
}

.lb-table th {
  padding: 10px 14px;
  text-align: left;
  color: var(--text2);
  font-size: 12px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.05em;
}

.lb-table td {
  padding: 10px 14px;
  border-bottom: 1px solid var(--border);
}

.lb-table tr:last-child td { border-bottom: none; }

.lb-table tr:hover td { background: var(--bg3); }

.lb-table .my-row td {
  background: color-mix(in srgb, var(--accent) 12%, transparent);
  color: var(--accent);
  font-weight: 700;
}

.lb-challenge {
  text-align: center;
  padding: 12px;
  font-size: 13px;
  color: var(--text2);
  border-top: 1px solid var(--border);
  background: var(--bg3);
}

/* ================================================================
   GAME SCREEN
================================================================ */
.game-top-bar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 16px;
}

.level-badge {
  display: inline-block;
  background: color-mix(in srgb, var(--accent) 20%, transparent);
  color: var(--accent);
  border: 1px solid color-mix(in srgb, var(--accent) 40%, transparent);
  padding: 6px 14px;
  border-radius: 100px;
  font-size: 13px;
  font-weight: 700;
  letter-spacing: 0.02em;
  transition: all 0.4s ease;
}

.round-info {
  font-size: 13px;
  color: var(--text2);
  font-weight: 600;
}

.lives-display {
  display: flex;
  gap: 8px;
  justify-content: center;
  font-size: 24px;
  margin-bottom: 12px;
  min-height: 32px;
  transition: all 0.3s;
}

.status-text {
  text-align: center;
  font-size: clamp(18px, 5vw, 24px);
  font-weight: 700;
  padding: 12px 0;
  min-height: 56px;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: all 0.2s;
}

.status-ready { color: var(--text2); }
.status-go { color: var(--green); font-size: clamp(22px, 6vw, 30px); }
.status-result { color: var(--accent); }
.status-early { color: var(--danger); }
.status-penalty { color: #F97316; }
.status-fail { color: var(--danger); }

/* ================================================================
   GAME AREA
================================================================ */
.game-area {
  position: relative;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-direction: column;
  min-height: 340px;
  background: var(--bg2);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  overflow: hidden;
}

/* ----------------------------------------------------------------
   CIRCLES
---------------------------------------------------------------- */
.circle {
  width: 140px;
  height: 140px;
  border-radius: 50%;
  cursor: pointer;
  transition: background-color 0.08s ease, transform 0.1s, box-shadow 0.2s;
  touch-action: manipulation;
  position: relative;
  flex-shrink: 0;
}

.circle-wait {
  background: var(--bg3);
  border: 3px solid var(--border);
  box-shadow: none;
}

.circle-green {
  background: var(--green) !important;
  border: 3px solid transparent !important;
  box-shadow: 0 0 40px rgba(16,185,129,0.6), 0 0 80px rgba(16,185,129,0.2);
  animation: pop-in 0.08s ease;
}

@keyframes pop-in {
  0% { transform: scale(0.9); }
  100% { transform: scale(1); }
}

.circle-red {
  background: var(--danger) !important;
  border: 3px solid transparent !important;
  box-shadow: 0 0 30px rgba(239,68,68,0.5);
  animation: flash-red 0.08s ease;
}

@keyframes flash-red {
  0% { transform: scale(1); }
  50% { transform: scale(1.05); }
  100% { transform: scale(1); }
}

.circle-hidden {
  opacity: 0;
  pointer-events: none;
}

.circle:active { transform: scale(0.92); }

/* Level 3 — 4-circle grid */
.circles-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 24px;
  padding: 24px;
}

.circle-sm {
  width: 110px;
  height: 110px;
}

/* Distraction hint */
.distraction-hint {
  position: absolute;
  top: 12px;
  left: 50%;
  transform: translateX(-50%);
  font-size: 12px;
  color: var(--text2);
  background: var(--bg3);
  padding: 4px 12px;
  border-radius: 100px;
  border: 1px solid var(--border);
  white-space: nowrap;
}

/* ----------------------------------------------------------------
   LEVEL 4 — TIMER BAR
---------------------------------------------------------------- */
.timer-bar-container {
  position: absolute;
  bottom: 0;
  left: 0;
  right: 0;
  height: 6px;
  background: var(--bg3);
}

.timer-bar {
  height: 100%;
  width: 100%;
  background: var(--accent);
  transition: width 0.3s linear;
  border-radius: 0 3px 3px 0;
}

/* Level 4 circle — positioned absolutely in game area */
#screen-game .game-area.level-4 .circle {
  width: 120px;
  height: 120px;
  position: absolute;
}

/* ----------------------------------------------------------------
   LEVEL 5 — ELITE
---------------------------------------------------------------- */
.l5-target-row {
  position: absolute;
  top: 12px;
  left: 50%;
  transform: translateX(-50%);
  display: flex;
  align-items: center;
  gap: 10px;
  background: var(--bg3);
  padding: 8px 16px;
  border-radius: 100px;
  border: 1px solid var(--border);
  white-space: nowrap;
  z-index: 10;
  font-size: 13px;
  font-weight: 600;
  color: var(--text2);
}

.l5-swatch {
  width: 28px;
  height: 28px;
  border-radius: 50%;
  border: 2px solid rgba(255,255,255,0.3);
  flex-shrink: 0;
  box-shadow: 0 0 12px currentColor;
}

.l5-arena {
  position: absolute;
  inset: 60px 0 0 0;
}

.circle-l5 {
  position: absolute;
  width: 90px;
  height: 90px;
  cursor: pointer;
  border-radius: 50%;
  border: 3px solid rgba(255,255,255,0.2);
  animation: circle-pop 0.12s ease;
  box-shadow: 0 0 20px rgba(255,255,255,0.1);
}

@keyframes circle-pop {
  from { transform: scale(0.5); opacity: 0; }
  to { transform: scale(1); opacity: 1; }
}

/* ================================================================
   BETWEEN LEVELS SCREEN
================================================================ */
.between-wrap {
  display: flex;
  flex-direction: column;
  align-items: center;
  text-align: center;
  padding: 48px 0 32px;
  gap: 16px;
}

@keyframes bounce {
  0%, 100% { transform: translateY(0) scale(1); }
  40% { transform: translateY(-20px) scale(1.1); }
  60% { transform: translateY(-10px) scale(1.05); }
}

.between-icon {
  font-size: 80px;
  animation: bounce 0.8s ease;
}

.between-title {
  font-size: clamp(24px, 6vw, 34px);
  font-weight: 900;
  letter-spacing: -0.03em;
  color: var(--accent);
}

.between-avg {
  font-size: 22px;
  font-weight: 700;
  color: var(--text);
  background: var(--bg2);
  padding: 10px 28px;
  border-radius: var(--radius-sm);
  border: 1px solid var(--border);
}

.between-enc {
  font-size: 16px;
  color: var(--text2);
  font-weight: 500;
}

/* ================================================================
   GAME OVER SCREEN
================================================================ */
.gameover-wrap {
  display: flex;
  flex-direction: column;
  gap: 20px;
  padding: 24px 0 40px;
}

.go-title {
  font-size: clamp(28px, 7vw, 38px);
  font-weight: 900;
  letter-spacing: -0.03em;
  text-align: center;
}

.go-best {
  text-align: center;
  font-size: clamp(52px, 13vw, 72px);
  font-weight: 900;
  color: var(--accent);
  letter-spacing: -0.04em;
  line-height: 1;
  text-shadow: 0 0 40px color-mix(in srgb, var(--accent) 50%, transparent);
}

.go-level-reached {
  text-align: center;
  font-size: 16px;
  color: var(--text2);
  font-weight: 600;
}

.go-funny {
  text-align: center;
  font-size: clamp(15px, 4vw, 18px);
  color: var(--text);
  font-weight: 600;
  padding: 16px;
  background: var(--bg2);
  border-radius: var(--radius);
  border: 1px solid var(--border);
  line-height: 1.5;
}

.elite-badge {
  text-align: center;
  font-size: 18px;
  font-weight: 800;
  color: #8B5CF6;
  padding: 16px;
  background: color-mix(in srgb, #8B5CF6 12%, transparent);
  border: 2px solid color-mix(in srgb, #8B5CF6 40%, transparent);
  border-radius: var(--radius);
  box-shadow: 0 0 30px color-mix(in srgb, #8B5CF6 25%, transparent);
  animation: elite-glow 2s infinite;
}

@keyframes elite-glow {
  0%, 100% { box-shadow: 0 0 20px color-mix(in srgb, #8B5CF6 25%, transparent); }
  50% { box-shadow: 0 0 40px color-mix(in srgb, #8B5CF6 50%, transparent); }
}

.hidden { display: none !important; }

/* ================================================================
   SUBMIT SECTION
================================================================ */
.submit-box {
  background: var(--bg2);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 20px;
}

.submit-title {
  font-size: 16px;
  font-weight: 700;
  margin-bottom: 14px;
  color: var(--text);
}

.submit-row {
  display: flex;
  gap: 10px;
}

.nickname-input {
  flex: 1;
  background: var(--bg3);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  color: var(--text);
  font-family: var(--font);
  font-size: 15px;
  font-weight: 600;
  padding: 12px 16px;
  outline: none;
  transition: border-color var(--transition);
}
.nickname-input::placeholder { color: #555; font-weight: 400; }
.nickname-input:focus { border-color: var(--accent); }

.submit-msg {
  margin-top: 10px;
  font-size: 14px;
  font-weight: 600;
  min-height: 20px;
  color: var(--green);
}

/* ================================================================
   SHARE SECTION
================================================================ */
.share-box {
  background: var(--bg2);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 20px;
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.share-preview {
  font-size: 14px;
  color: var(--text2);
  line-height: 1.6;
  background: var(--bg3);
  padding: 14px;
  border-radius: var(--radius-sm);
  white-space: pre-line;
  border: 1px solid var(--border);
}

.copy-msg {
  font-size: 13px;
  color: var(--green);
  font-weight: 600;
  min-height: 18px;
}

/* ================================================================
   TOAST
================================================================ */
.toast {
  position: fixed;
  bottom: 30px;
  left: 50%;
  transform: translateX(-50%) translateY(80px);
  background: #1e1e1e;
  border: 1px solid var(--border);
  color: var(--text);
  font-size: 14px;
  font-weight: 600;
  padding: 12px 24px;
  border-radius: 100px;
  z-index: 9999;
  opacity: 0;
  transition: transform 0.3s ease, opacity 0.3s ease;
  pointer-events: none;
  white-space: nowrap;
  max-width: calc(100vw - 40px);
  text-align: center;
}

.toast.show {
  opacity: 1;
  transform: translateX(-50%) translateY(0);
}

/* ================================================================
   SCROLLBAR
================================================================ */
::-webkit-scrollbar { width: 4px; }
::-webkit-scrollbar-track { background: var(--bg); }
::-webkit-scrollbar-thumb { background: var(--border); border-radius: 2px; }

/* ================================================================
   RESPONSIVE TWEAKS
================================================================ */
@media (max-width: 360px) {
  .circle { width: 120px; height: 120px; }
  .circle-sm { width: 90px; height: 90px; }
  .circles-grid { gap: 16px; padding: 16px; }
}
