/* Wrong Button — Game CMB (gamecmb.com)
   Neon Arcade / Modern Brain Game visual style. */

@font-face {
  font-family: 'Sora';
  src: local('Sora');
  font-display: swap;
}

:root {
  --bg-0: #080b14;
  --bg-1: #0d1120;
  --panel: rgba(18, 23, 42, 0.72);
  --panel-border: rgba(140, 160, 255, 0.16);
  --text: #eef1ff;
  --text-dim: #97a0c2;
  --accent: #7c5cff;
  --accent-2: #37e0ff;
  --danger: #ff4266;
  --success: #33e6a0;
  --warning: #ffd23b;
  --radius-lg: 22px;
  --radius-md: 16px;
  --font-display: 'Sora', 'Segoe UI', system-ui, -apple-system, sans-serif;
  --font-body: 'Inter', 'Segoe UI', system-ui, -apple-system, sans-serif;
}

* { box-sizing: border-box; }
[hidden] { display: none !important; }

html, body {
  margin: 0;
  padding: 0;
  background: var(--bg-0);
  color: var(--text);
  font-family: var(--font-body);
  -webkit-tap-highlight-color: transparent;
  overscroll-behavior: none;
}

body {
  min-height: 100vh;
  background:
    radial-gradient(1200px 800px at 20% -10%, rgba(124, 92, 255, 0.18), transparent 60%),
    radial-gradient(1000px 700px at 100% 110%, rgba(55, 224, 255, 0.12), transparent 55%),
    var(--bg-0);
}

a { color: var(--accent-2); }

.wrap {
  max-width: 980px;
  margin: 0 auto;
  padding: 16px 16px 56px;
}

/* ---------------------------------------------------------------- HUD */
.hud {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 10px 14px;
  border-radius: var(--radius-md);
  background: var(--panel);
  border: 1px solid var(--panel-border);
  backdrop-filter: blur(10px);
  margin-bottom: 14px;
  flex-wrap: wrap;
}

.hud-group { display: flex; align-items: center; gap: 14px; }

.hud-stat { display: flex; flex-direction: column; align-items: flex-start; min-width: 46px; }
.hud-stat .label { font-size: 10px; letter-spacing: 0.08em; color: var(--text-dim); text-transform: uppercase; }
.hud-stat .value { font-family: var(--font-display); font-weight: 700; font-size: 20px; line-height: 1.1; }

.hearts { display: flex; gap: 4px; font-size: 18px; }
.hearts .lost { opacity: 0.28; filter: grayscale(1); }

.combo-badge {
  font-family: var(--font-display);
  font-weight: 800;
  font-size: 14px;
  padding: 4px 10px;
  border-radius: 999px;
  background: linear-gradient(135deg, var(--accent), var(--accent-2));
  color: #0a0e1c;
  opacity: 0;
  transform: scale(0.8);
  transition: opacity 0.15s ease, transform 0.15s ease;
}
.combo-badge.show { opacity: 1; transform: scale(1); }

.icon-btn {
  width: 38px; height: 38px;
  display: grid; place-items: center;
  border-radius: 12px;
  border: 1px solid var(--panel-border);
  background: rgba(255,255,255,0.03);
  color: var(--text);
  cursor: pointer;
  font-size: 16px;
  transition: transform 0.12s ease, background 0.12s ease;
}
.icon-btn:hover { background: rgba(255,255,255,0.08); }
.icon-btn:active { transform: scale(0.92); }
.icon-btn.off { color: var(--text-dim); }

/* ---------------------------------------------------------------- STAGE */
#gameStage {
  position: relative;
  border-radius: var(--radius-lg);
  background: linear-gradient(180deg, rgba(255,255,255,0.02), rgba(0,0,0,0.15)), var(--bg-1);
  border: 1px solid var(--panel-border);
  overflow: hidden;
  min-height: 640px;
  display: flex;
  flex-direction: column;
  align-items: stretch;
}
#gameStage:fullscreen { min-height: 100vh; border-radius: 0; }
#gameStage:fullscreen .board-area { flex: 1; }

.stage-bg-grid {
  position: absolute;
  inset: 0;
  background-image:
    linear-gradient(rgba(140,160,255,0.05) 1px, transparent 1px),
    linear-gradient(90deg, rgba(140,160,255,0.05) 1px, transparent 1px);
  background-size: 34px 34px;
  pointer-events: none;
  mask-image: radial-gradient(circle at 50% 40%, black, transparent 85%);
}

.challenge-bar {
  position: relative;
  z-index: 2;
  padding: 18px 16px 10px;
  text-align: center;
}

.challenge-text {
  font-family: var(--font-display);
  font-weight: 800;
  font-size: clamp(16px, 4.4vw, 26px);
  letter-spacing: 0.01em;
  text-shadow: 0 0 18px rgba(124,92,255,0.55);
  min-height: 1.3em;
}

.challenge-rule {
  margin-top: 4px;
  font-size: 12px;
  color: var(--text-dim);
  letter-spacing: 0.04em;
}

.timer-track {
  position: relative;
  height: 6px;
  border-radius: 999px;
  background: rgba(255,255,255,0.08);
  margin: 10px auto 0;
  max-width: 420px;
  overflow: hidden;
}
.timer-fill {
  height: 100%;
  width: 100%;
  border-radius: 999px;
  background: linear-gradient(90deg, var(--accent-2), var(--accent));
  transform-origin: left;
}
.timer-fill.running { transition: width linear; }
.timer-fill.danger { background: linear-gradient(90deg, var(--warning), var(--danger)); }

.board-area {
  position: relative;
  flex: 1;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 14px 16px 22px;
  z-index: 2;
}

#particleCanvas {
  position: absolute;
  inset: 0;
  z-index: 3;
  pointer-events: none;
  width: 100%;
  height: 100%;
}

.btn-grid {
  display: grid;
  gap: 12px;
  width: 100%;
  max-width: 560px;
  margin: 0 auto;
}

.btn-grid.moving .game-btn { animation: jitter 2.6s ease-in-out infinite; }
.btn-grid.delayed .game-btn { animation: revealColor 0.9s ease-out; }

@keyframes jitter {
  0%, 100% { transform: translate(0, 0); }
  25% { transform: translate(1.5px, -1.5px); }
  50% { transform: translate(-1.5px, 1px); }
  75% { transform: translate(1px, 1.5px); }
}

@keyframes revealColor {
  0% { filter: grayscale(1) brightness(0.6); }
  100% { filter: grayscale(0) brightness(1); }
}

.game-btn {
  position: relative;
  aspect-ratio: 3 / 2;
  border: 2px solid rgba(255,255,255,0.22);
  border-radius: 18px;
  font-family: var(--font-display);
  font-weight: 800;
  font-size: clamp(12px, 3vw, 18px);
  letter-spacing: 0.02em;
  color: var(--btn-fg, #0a0e1c);
  background: var(--btn-bg, #ccc);
  cursor: pointer;
  box-shadow: 0 6px 18px rgba(0,0,0,0.35), inset 0 1px 0 rgba(255,255,255,0.35), 0 0 0 rgba(255,255,255,0);
  transition: transform 0.1s ease, box-shadow 0.15s ease;
  -webkit-user-select: none;
  user-select: none;
  touch-action: manipulation;
}

@media (hover: hover) {
  .game-btn:hover { transform: scale(1.035); box-shadow: 0 8px 22px rgba(0,0,0,0.4), inset 0 1px 0 rgba(255,255,255,0.4), 0 0 26px rgba(255,255,255,0.25); }
}
.game-btn:active { transform: scale(0.94); }

.game-btn.pulsing { animation: pulseLoud 0.65s ease-in-out infinite; }
@keyframes pulseLoud {
  0%, 100% { box-shadow: 0 6px 18px rgba(0,0,0,0.35), 0 0 0 rgba(255,255,255,0.5); transform: scale(1); }
  50% { box-shadow: 0 10px 28px rgba(0,0,0,0.4), 0 0 34px rgba(255,255,255,0.85); transform: scale(1.05); }
}

.game-btn.hidden-label { color: transparent; background: #232a45 !important; border-color: rgba(140,160,255,0.3); }
.game-btn.hidden-label::after {
  content: '????';
  position: absolute;
  inset: 0;
  display: grid;
  place-items: center;
  color: var(--text-dim);
  font-size: 13px;
  letter-spacing: 0.15em;
}

.game-btn.flash-correct { animation: flashCorrect 0.42s ease-out; }
@keyframes flashCorrect {
  0% { transform: scale(1); }
  30% { transform: scale(1.12); box-shadow: 0 0 0 6px rgba(51,230,160,0.35), 0 0 40px rgba(51,230,160,0.7); }
  100% { transform: scale(1); }
}

.game-btn.flash-wrong { animation: flashWrong 0.42s ease-out; }
@keyframes flashWrong {
  0% { transform: scale(1); }
  25% { transform: scale(0.92) rotate(-1deg); box-shadow: 0 0 0 6px rgba(255,66,102,0.4); }
  50% { transform: scale(0.96) rotate(1deg); }
  100% { transform: scale(1) rotate(0); }
}

.game-btn.mark-correct-reveal { outline: 3px solid var(--success); outline-offset: 2px; }

.stage-shake { animation: shake 0.32s ease-in-out; }
@keyframes shake {
  0%, 100% { transform: translate(0, 0); }
  20% { transform: translate(-6px, 2px); }
  40% { transform: translate(5px, -2px); }
  60% { transform: translate(-4px, 1px); }
  80% { transform: translate(3px, -1px); }
}

.float-score {
  position: absolute;
  z-index: 5;
  font-family: var(--font-display);
  font-weight: 800;
  font-size: 18px;
  color: var(--success);
  text-shadow: 0 0 12px rgba(51,230,160,0.7);
  pointer-events: none;
  animation: floatUp 0.75s ease-out forwards;
}
@keyframes floatUp {
  0% { opacity: 0; transform: translate(-50%, 0) scale(0.8); }
  15% { opacity: 1; transform: translate(-50%, -6px) scale(1.05); }
  100% { opacity: 0; transform: translate(-50%, -46px) scale(1); }
}

.toast {
  position: absolute;
  top: 14px;
  left: 50%;
  transform: translate(-50%, -8px);
  z-index: 6;
  font-family: var(--font-display);
  font-weight: 800;
  font-size: 15px;
  padding: 6px 16px;
  border-radius: 999px;
  background: rgba(124,92,255,0.22);
  border: 1px solid rgba(124,92,255,0.5);
  color: #fff;
  opacity: 0;
  transition: opacity 0.18s ease, transform 0.18s ease;
  white-space: nowrap;
}
.toast.show { opacity: 1; transform: translate(-50%, 0); }
.toast.perfect { background: rgba(255,210,59,0.2); border-color: rgba(255,210,59,0.6); color: var(--warning); }

.arrow-wrap {
  position: absolute;
  inset: 0;
  display: grid;
  place-items: center;
  pointer-events: none;
  z-index: 4;
}
.arrow-glyph {
  font-size: 64px;
  color: var(--accent-2);
  text-shadow: 0 0 24px rgba(55,224,255,0.7);
  transition: transform 0.18s ease;
}

/* ---------------------------------------------------------------- SCREENS */
.screen-overlay {
  position: absolute;
  inset: 0;
  z-index: 10;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 18px;
  background: rgba(4, 6, 13, 0.72);
  backdrop-filter: blur(6px);
}

.screen-panel {
  width: 100%;
  max-width: 420px;
  max-height: 100%;
  overflow-y: auto;
  border-radius: var(--radius-lg);
  border: 1px solid var(--panel-border);
  background: var(--panel);
  padding: 22px 22px 18px;
  text-align: center;
  box-shadow: 0 20px 60px rgba(0,0,0,0.5);
}

.logo {
  font-family: var(--font-display);
  font-weight: 800;
  font-size: clamp(28px, 8vw, 40px);
  background: linear-gradient(135deg, var(--accent-2), var(--accent));
  -webkit-background-clip: text;
  background-clip: text;
  color: transparent;
  margin: 0 0 6px;
}
.tagline { color: var(--text-dim); font-size: 14px; margin: 0 0 20px; line-height: 1.5; }

.btn-primary {
  display: block;
  width: 100%;
  padding: 13px 18px;
  border: none;
  border-radius: 16px;
  font-family: var(--font-display);
  font-weight: 800;
  font-size: 16px;
  letter-spacing: 0.02em;
  color: #0a0e1c;
  background: linear-gradient(135deg, var(--accent-2), var(--accent));
  cursor: pointer;
  box-shadow: 0 10px 26px rgba(124,92,255,0.35);
  transition: transform 0.1s ease;
  margin-bottom: 8px;
}
.btn-primary:active { transform: scale(0.97); }

.btn-secondary {
  display: block;
  width: 100%;
  padding: 10px 18px;
  border-radius: 14px;
  border: 1px solid var(--panel-border);
  background: rgba(255,255,255,0.04);
  color: var(--text);
  font-family: var(--font-display);
  font-weight: 700;
  font-size: 13px;
  cursor: pointer;
  margin-bottom: 6px;
  transition: transform 0.1s ease, background 0.12s ease;
}
.btn-secondary:hover { background: rgba(255,255,255,0.08); }
.btn-secondary:active { transform: scale(0.97); }

.best-line { font-size: 13px; color: var(--text-dim); margin-bottom: 18px; }
.best-line b { color: var(--warning); }

.go-score { font-family: var(--font-display); font-weight: 800; font-size: 42px; margin: 2px 0 0; text-shadow: 0 0 24px rgba(124,92,255,0.6); }
.go-score-label { font-size: 12px; letter-spacing: 0.1em; color: var(--text-dim); text-transform: uppercase; }
.go-stats { display: flex; justify-content: center; gap: 22px; margin: 10px 0 12px; }
.go-stat { display: flex; flex-direction: column; }
.go-stat .v { font-family: var(--font-display); font-weight: 700; font-size: 18px; }
.go-stat .l { font-size: 10px; color: var(--text-dim); text-transform: uppercase; letter-spacing: 0.08em; }
.go-new-best { color: var(--warning); font-weight: 700; font-size: 13px; margin: -6px 0 10px; }
.go-hype { font-size: 13px; color: var(--text-dim); margin: 2px 0 12px; }

.nickname-row { display: flex; gap: 8px; margin: 6px 0 6px; }
.nickname-input {
  flex: 1;
  padding: 12px 14px;
  border-radius: 12px;
  border: 1px solid var(--panel-border);
  background: rgba(0,0,0,0.25);
  color: var(--text);
  font-family: var(--font-body);
  font-size: 15px;
}
.nickname-input:focus { outline: 2px solid var(--accent-2); }
.field-error { color: var(--danger); font-size: 12px; min-height: 16px; margin-bottom: 8px; }
.submit-status { font-size: 12px; color: var(--text-dim); min-height: 16px; margin-top: 4px; }

.tabs { display: flex; gap: 6px; margin-bottom: 12px; }
.tab {
  flex: 1;
  padding: 8px;
  border-radius: 10px;
  border: 1px solid var(--panel-border);
  background: rgba(255,255,255,0.03);
  color: var(--text-dim);
  font-family: var(--font-display);
  font-weight: 700;
  font-size: 12px;
  cursor: pointer;
}
.tab.active { background: linear-gradient(135deg, var(--accent-2), var(--accent)); color: #0a0e1c; border-color: transparent; }

.lb-list { list-style: none; margin: 0 0 14px; padding: 0; text-align: left; max-height: 300px; overflow-y: auto; }
.lb-row { display: flex; align-items: center; gap: 10px; padding: 8px 10px; border-radius: 10px; font-size: 13px; }
.lb-row.you { background: rgba(124,92,255,0.18); border: 1px solid rgba(124,92,255,0.4); }
.lb-rank { width: 26px; font-weight: 800; color: var(--text-dim); }
.lb-rank.top1 { color: #ffd23b; }
.lb-rank.top2 { color: #d8dcf0; }
.lb-rank.top3 { color: #ff9f43; }
.lb-name { flex: 1; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.lb-score { font-weight: 800; font-family: var(--font-display); }
.lb-empty { color: var(--text-dim); font-size: 13px; padding: 20px 0; }

.countdown-num {
  font-family: var(--font-display);
  font-weight: 800;
  font-size: 88px;
  text-shadow: 0 0 40px rgba(124,92,255,0.7);
  animation: countPop 0.9s ease-out;
}
@keyframes countPop {
  0% { transform: scale(0.5); opacity: 0; }
  30% { transform: scale(1.15); opacity: 1; }
  100% { transform: scale(1); opacity: 1; }
}

.seo-copy {
  margin-top: 28px;
  padding: 20px 22px;
  border-radius: var(--radius-lg);
  background: var(--panel);
  border: 1px solid var(--panel-border);
}
.seo-copy h2 { font-family: var(--font-display); font-size: 18px; margin: 0 0 8px; }
.seo-copy h3 { font-family: var(--font-display); font-size: 15px; margin: 18px 0 6px; }
.seo-copy p, .seo-copy li { color: var(--text-dim); font-size: 14px; line-height: 1.7; }

.ad-slot { margin: 14px 0; min-height: 90px; display: flex; align-items: center; justify-content: center; border: 1px dashed var(--panel-border); border-radius: 12px; color: var(--text-dim); font-size: 12px; }

.footer-note { text-align: center; color: var(--text-dim); font-size: 12px; margin-top: 22px; }
.footer-note a { color: var(--text-dim); }

@media (max-width: 480px) {
  .btn-grid { gap: 8px; }
  .game-btn { border-radius: 14px; }
  .go-stats { gap: 14px; }
  /* Keep the stage tall enough that the game-over panel's buttons (incl.
     LEADERBOARD, the last one) don't need an internal scroll on common
     mobile viewport heights — a shorter stage here clipped it below the
     fold with no visible scroll affordance. */
  #gameStage { min-height: 600px; }
}

@media (prefers-reduced-motion: reduce) {
  .btn-grid.moving .game-btn,
  .btn-grid.delayed .game-btn,
  .game-btn.pulsing,
  .countdown-num { animation: none !important; }
}
