/* VerbBreaker: 16-bit inspired UI. Hard edges, chunky borders, pixel fonts. */

:root {
  --bg-deep: #0a0d26;
  --bg-mid: #1c1d52;
  --ink: #0a0d26;
  --frame: #e9eefc;
  --win-top: #2b3fa8;
  --win-bot: #141d5c;
  --gold: #ffd84a;
  --gold-dark: #c97a12;
  --orange: #ff8a3d;
  --pink: #ff4f7a;
  --mint: #7dffd0;
  --cyan: #7fe3ff;
  --danger: #ff3d5e;
  --text: #f4f7ff;
  --subtle: #b9c6f2;
  --font-pixel: "Press Start 2P", "Courier New", monospace;
  --font-body: "Nunito", "Trebuchet MS", "Segoe UI", sans-serif;
  /* 9-slice pixel window frame: ink outline, white frame, ink inner line, notched corners */
  /* 9-slice chrome window frame (Arkanoid metal), notched corners */
  --pixel-frame: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' shape-rendering='crispEdges'%3E%3Cpath fill='%2305060f' d='M1 0h10v12H1zM0 1h12v10H0z'/%3E%3Cpath fill='%23f4f6ff' d='M2 1h8v10H2zM1 2h10v8H1z'/%3E%3Cpath fill='%23a8b0c8' d='M2 2h8v8H2z'/%3E%3Cpath fill='%235a6284' d='M3 3h6v6H3z'/%3E%3Cpath fill='%2305060f' d='M4 4h4v4H4z'/%3E%3C/svg%3E");
  --pixel-frame-gold: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' shape-rendering='crispEdges'%3E%3Cpath fill='%2305060f' d='M1 0h10v12H1zM0 1h12v10H0z'/%3E%3Cpath fill='%23fff7c0' d='M2 1h8v10H2zM1 2h10v8H1z'/%3E%3Cpath fill='%23ffcf3a' d='M2 2h8v8H2z'/%3E%3Cpath fill='%23b8781a' d='M3 3h6v6H3z'/%3E%3Cpath fill='%2305060f' d='M4 4h4v4H4z'/%3E%3C/svg%3E");
}

* {
  box-sizing: border-box;
}

button,
input {
  font-family: var(--font-body);
  touch-action: manipulation;
}

html {
  -webkit-text-size-adjust: 100%;
  text-size-adjust: 100%;
}

html,
body {
  margin: 0;
  height: 100%;
  min-height: 100%;
  min-height: 100dvh;
  font-family: var(--font-body);
  color: var(--text);
  background: #000;
  /* app feel on phones: no rubber-band scroll, no text selection, no
     long-press callout, no grey tap flash */
  overscroll-behavior: none;
  touch-action: manipulation;
  -webkit-user-select: none;
  user-select: none;
  -webkit-touch-callout: none;
  -webkit-tap-highlight-color: transparent;
}

input {
  -webkit-user-select: text;
  user-select: text;
}

/* Probe the game reads to keep the paddle above the iOS home indicator. */
.safe-area-probe {
  position: fixed;
  left: 0;
  bottom: 0;
  width: 0;
  height: 0;
  padding-bottom: env(safe-area-inset-bottom, 0px);
  visibility: hidden;
  pointer-events: none;
}

.visually-hidden {
  position: absolute !important;
  width: 1px;
  height: 1px;
  overflow: hidden;
  clip: rect(0 0 0 0);
  white-space: nowrap;
}

.game-shell {
  width: 100vw;
  margin: 0 auto;
  height: 100dvh;
  height: 100svh;
  min-height: 100dvh;
  /* notch / status bar / rounded corners (viewport-fit=cover) */
  padding: max(4px, env(safe-area-inset-top, 0px)) env(safe-area-inset-right, 0px) 0 env(safe-area-inset-left, 0px);
  display: flex;
  flex-direction: column;
  position: relative;
}

/* ---------------------------------------------------------------- HUD */

.hud {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 18px;
  padding: 6px 12px 4px;
  background: #000;
}

.hud-logo {
  flex: 0 0 auto;
  image-rendering: pixelated;
}

h1 {
  margin: 0;
  font-family: var(--font-pixel);
  font-weight: 400;
  font-size: 0.8rem;
  color: var(--gold);
}

/* Arkanoid style score line: red labels, white digits on black */
.stats {
  display: flex;
  gap: 18px;
  flex-wrap: wrap;
  justify-content: center;
}

.stat {
  margin: 0;
  display: grid;
  grid-template-columns: auto auto;
  grid-template-rows: auto auto;
  column-gap: 6px;
  align-items: center;
  user-select: none;
}

.stat::before {
  content: "";
  grid-row: 1 / span 2;
  width: 20px;
  height: 20px;
  background: var(--icon-gem) center / contain no-repeat;
  image-rendering: pixelated;
}

.stat-coins::before { background-image: var(--icon-coin); }
.stat-lives::before { background-image: var(--icon-heart); }
.stat-level::before { background-image: var(--icon-flag); }

.stat-label {
  font-family: var(--font-pixel);
  font-size: 0.5rem;
  line-height: 1.4;
  color: #ff3a3a;
  text-transform: uppercase;
}

.stat-value {
  font-family: var(--font-pixel);
  font-size: 0.8rem;
  line-height: 1.3;
  color: #fff;
  letter-spacing: 0.04em;
}

/* ---------------------------------------------------------------- Arena */

.arena-wrap {
  position: relative;
  margin-top: 4px;
  overflow: hidden;
  touch-action: none;
  flex: 1 1 auto;
  min-height: 200px;
  display: flex;
  align-items: stretch;
  background: #000;
}

canvas {
  display: block;
  width: 100%;
  height: 100%;
  flex: 1 1 auto;
  background: var(--bg-deep);
  image-rendering: pixelated;
  image-rendering: crisp-edges;
}

.pixel-logo {
  display: block;
  width: min(520px, 90%);
  height: auto;
  image-rendering: pixelated;
  animation: logo-bob 1.6s steps(2, jump-none) infinite;
}

.pixel-logo[hidden] {
  display: none;
}

@keyframes logo-bob {
  0% { transform: translateY(0); }
  100% { transform: translateY(-4px); }
}

/* ---------------------------------------------------------------- Overlays & windows */

.overlay {
  position: absolute;
  inset: 0;
  background: rgba(4, 6, 22, 0.62);
  display: grid;
  place-items: center;
  z-index: 4;
  padding: 16px;
}

.overlay.hidden {
  visibility: hidden;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.15s steps(3);
}

.overlay.visible {
  visibility: visible;
  opacity: 1;
}

#championOverlay {
  background: transparent;
  pointer-events: none;
  z-index: 5;
}

.panel {
  width: min(780px, 95%);
  text-align: center;
  padding: 16px;
  background:
    linear-gradient(180deg, #161b3e 0 20%, #11163a 20% 45%, #0d1130 45% 70%, #090c24 70%) padding-box;
  border: 15px solid transparent;
  border-image: var(--pixel-frame) 5 / 15px stretch;
  filter: drop-shadow(6px 6px 0 rgba(0, 0, 0, 0.5));
  image-rendering: pixelated;
}

.menu-panel {
  position: relative;
  width: min(640px, 96%);
  max-height: calc(100% - 24px);
  overflow-y: auto;
  padding: 20px 18px;
  scrollbar-color: var(--gold) var(--win-bot);
}

/* Menus own the screen: hide the in-game pause button meanwhile. */
body.menu-open .hud-btn {
  visibility: hidden;
  pointer-events: none;
}

/* Settings: two columns on wide screens so everything fits at once. */
#menuSettingsView {
  display: grid;
  grid-template-columns: 1fr;
  justify-items: center;
  gap: 10px;
}

#menuSettingsView.hidden {
  display: none;
}

#menuSettingsView > h2,
#menuSettingsView .settings-credit,
#menuSettingsView .settings-footer {
  grid-column: 1 / -1;
}

.menu-panel:has(#menuSettingsView:not(.hidden)) {
  width: min(900px, 96%);
}

@media (min-width: 760px) {
  #menuSettingsView {
    grid-template-columns: 1fr 1fr;
    align-items: start;
    column-gap: 16px;
  }

  #menuSettingsView {
    grid-template-areas:
      "title title"
      "diff retro"
      "psy retro"
      "upd upd"
      "credit credit"
      "foot foot";
  }

  #menuSettingsView > h2 { grid-area: title; }
  #menuSettingsView .diff-box { grid-area: diff; }
  #menuSettingsView .psychedelic-box { grid-area: psy; }
  #menuSettingsView .retro-box { grid-area: retro; }
  #menuSettingsView .update-box { grid-area: upd; }
  #menuSettingsView .settings-credit { grid-area: credit; }
  #menuSettingsView .settings-footer { grid-area: foot; }

  #menuSettingsView .difficulty-box {
    width: 100%;
    margin: 0;
  }
}

/* Back button stays visible at the bottom; a fade + arrow says "scroll". */
.settings-footer {
  position: sticky;
  bottom: -20px;
  width: calc(100% + 36px);
  margin: 0 -18px -20px;
  padding: 26px 18px 18px;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 2px;
  background: linear-gradient(180deg, rgba(9, 12, 36, 0) 0, rgba(9, 12, 36, 0.92) 26px, #090c24 100%);
}

.scroll-hint {
  font-size: 0.9rem;
  color: var(--gold);
  animation: hint-bob 0.9s steps(2, jump-none) infinite;
}

.menu-panel.at-bottom .scroll-hint,
.menu-panel.no-scroll .scroll-hint {
  visibility: hidden;
}

@keyframes hint-bob {
  100% { transform: translateY(3px); }
}

.menu-view.hidden {
  display: none;
}

.menu-view {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 10px;
}

.menu-actions {
  margin: 12px 0 10px;
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 18px;
}

.home-actions {
  width: min(360px, 100%);
  grid-template-columns: 1fr;
}

.leaderboard-actions {
  width: min(380px, 100%);
  grid-template-columns: 1fr 1fr;
}

.menu-title {
  margin: 0;
  font-family: var(--font-pixel);
  font-weight: 400;
  font-size: clamp(1.1rem, 4vw, 1.9rem);
  line-height: 1.3;
  color: var(--gold);
  text-shadow: 3px 3px 0 var(--ink), 6px 6px 0 #5a1a6a;
}

#nextLevelCountdownText {
  font-size: clamp(0.9rem, 3vw, 1.4rem);
  text-shadow: 3px 3px 0 var(--ink);
}

.menu-subtitle {
  margin: 0;
  max-width: 530px;
  color: #dfe7ff;
  font-weight: 500;
  font-size: 1.1rem;
  line-height: 1.35;
}

.panel h2 {
  margin: 0 0 6px;
  font-family: var(--font-pixel);
  font-weight: 400;
  font-size: clamp(0.7rem, 2.2vw, 0.95rem);
  line-height: 1.5;
  color: var(--gold);
  text-shadow: 2px 2px 0 var(--ink);
}

/* ---------------------------------------------------------------- Buttons */
/* 16-bit button: banded face, bevel, notched pixel outline, physical depth.
   Each role only swaps the colour variables. */

.main-btn,
.difficulty-btn,
.choice-btn,
.shop-card-btn {
  --btn-hi: #fff6c4;
  --btn-top: #ffd84a;
  --btn-mid: #ffb83a;
  --btn-bot: #f6912c;
  --btn-shade: #b85a18;
  --btn-ink: #1a0b04;
  --btn-text: #2a1206;
  --btn-glow: rgba(255, 255, 255, 0.55);
  position: relative;
  overflow: hidden;
  cursor: pointer;
  border: 0;
  border-radius: 0;
  color: var(--btn-text);
  font-family: var(--font-body);
  font-weight: 900;
  background: linear-gradient(
    180deg,
    var(--btn-hi) 0 3px,
    var(--btn-top) 3px 36%,
    var(--btn-mid) 36% 68%,
    var(--btn-bot) 68% calc(100% - 4px),
    var(--btn-shade) calc(100% - 4px)
  );
  box-shadow:
    inset 3px 0 0 rgba(255, 255, 255, 0.3),
    inset -3px 0 0 rgba(0, 0, 0, 0.16),
    0 -3px 0 0 var(--btn-ink),
    -3px 0 0 0 var(--btn-ink),
    3px 0 0 0 var(--btn-ink),
    0 3px 0 0 var(--btn-ink),
    0 6px 0 0 var(--btn-shade),
    0 9px 0 0 var(--btn-ink);
  text-shadow: 0 2px 0 var(--btn-glow);
  transition: transform 0.08s steps(2), filter 0.12s;
}

/* light sweep on hover */
.main-btn::after,
.difficulty-btn::after,
.choice-btn::after,
.shop-card-btn::after {
  content: "";
  position: absolute;
  top: -4px;
  bottom: -4px;
  left: -45%;
  width: 22%;
  background: linear-gradient(90deg, transparent 0 20%, rgba(255, 255, 255, 0.45) 20% 60%, rgba(255, 255, 255, 0.2) 60% 80%, transparent 80%);
  transform: skewX(-22deg);
  pointer-events: none;
  opacity: 0;
}

.main-btn:hover::after,
.difficulty-btn:hover::after,
.choice-btn:hover::after,
.shop-card-btn:hover::after,
.main-btn:focus-visible::after,
.choice-btn.selected::after {
  opacity: 1;
  animation: btn-shine 0.55s steps(7) forwards;
}

@keyframes btn-shine {
  from { left: -45%; }
  to { left: 125%; }
}

.main-btn:hover,
.difficulty-btn:hover,
.choice-btn:hover,
.shop-card-btn:hover {
  transform: translateY(-2px);
  filter: brightness(1.08) saturate(1.05);
}

.main-btn:active,
.difficulty-btn:active,
.choice-btn:active,
.shop-card-btn:active {
  transform: translateY(6px);
  box-shadow:
    inset 3px 0 0 rgba(255, 255, 255, 0.3),
    inset -3px 0 0 rgba(0, 0, 0, 0.16),
    0 -3px 0 0 var(--btn-ink),
    -3px 0 0 0 var(--btn-ink),
    3px 0 0 0 var(--btn-ink),
    0 3px 0 0 var(--btn-ink);
}

.main-btn:focus-visible,
.difficulty-btn:focus-visible,
.choice-btn:focus-visible,
.shop-card-btn:focus-visible {
  outline: 3px dashed var(--mint);
  outline-offset: 6px;
}

/* roles */
.alt-btn,
.pause-btn,
.difficulty-btn,
.choice-btn {
  --btn-hi: #d4ddff;
  --btn-top: #7f97ff;
  --btn-mid: #5f78f2;
  --btn-bot: #4a5ed8;
  --btn-shade: #2b37a2;
  --btn-ink: #070a24;
  --btn-text: #ffffff;
  --btn-glow: rgba(8, 12, 60, 0.75);
}

.end-btn {
  --btn-hi: #ffd0d6;
  --btn-top: #ff7486;
  --btn-mid: #f4475e;
  --btn-bot: #d82e48;
  --btn-shade: #8a142a;
  --btn-ink: #1e0408;
  --btn-text: #ffffff;
  --btn-glow: rgba(60, 4, 14, 0.75);
}

.difficulty-btn.active,
.choice-btn.selected {
  --btn-hi: #fff6c4;
  --btn-top: #ffd84a;
  --btn-mid: #ffb83a;
  --btn-bot: #f6912c;
  --btn-shade: #b85a18;
  --btn-ink: #1a0b04;
  --btn-text: #2a1206;
  --btn-glow: rgba(255, 255, 255, 0.55);
}

.toggle-btn.active,
.shop-card-btn.current {
  --btn-hi: #e4fff5;
  --btn-top: #8dffda;
  --btn-mid: #4fe8b6;
  --btn-bot: #2fca98;
  --btn-shade: #188a62;
  --btn-ink: #03180f;
  --btn-text: #06281c;
  --btn-glow: rgba(255, 255, 255, 0.5);
}

/* primary menu buttons: pixel font + pixel icon */
.main-btn {
  font-family: var(--font-pixel);
  font-weight: 400;
  font-size: 0.72rem;
  line-height: 1.4;
  text-transform: uppercase;
  min-height: 48px;
  padding: 12px 18px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 12px;
}

.main-btn::before {
  content: none;
  flex: 0 0 auto;
  width: 22px;
  height: 22px;
  background: var(--btn-icon) center / contain no-repeat;
  image-rendering: pixelated;
  filter: drop-shadow(0 2px 0 rgba(0, 0, 0, 0.35));
}

#startBtn::before,
#playFromLeaderboardBtn::before,
#openSettingsBtn::before,
#openLeaderboardBtn::before,
#openShopBtn::before,
#backFromSettingsBtn::before,
#backFromLeaderboardBtn::before,
#backFromShopBtn::before,
#saveScoreBtn::before,
#pauseBtn::before,
#endBtn::before {
  content: "";
}

#startBtn,
#playFromLeaderboardBtn { --btn-icon: var(--icon-play); }
#openSettingsBtn { --btn-icon: var(--icon-gear); }
#openLeaderboardBtn { --btn-icon: var(--icon-trophy); }
#openShopBtn { --btn-icon: var(--icon-coin); }
#backFromSettingsBtn,
#backFromLeaderboardBtn,
#backFromShopBtn { --btn-icon: var(--icon-back); }
#saveScoreBtn { --btn-icon: var(--icon-star); }
#pauseBtn { --btn-icon: var(--icon-pause); }
#endBtn { --btn-icon: var(--icon-stop); }

#menuHomeView #startBtn,
#playFromLeaderboardBtn {
  font-size: 0.9rem;
  min-height: 58px;
}

#menuHomeView #startBtn {
  animation: start-pulse 1.2s steps(2, jump-none) infinite;
}

@keyframes start-pulse {
  50% { filter: brightness(1.12); }
}

.small-btn {
  font-size: 0.64rem;
  min-height: 42px;
  padding: 10px 16px;
}

/* Compact icon-only pause button in the top bar */
.hud-btn {
  flex: 0 0 auto;
  width: 40px;
  min-width: 0;
  min-height: 40px;
  height: 40px;
  padding: 0;
  gap: 0;
  font-size: 0;
}

.hud-btn::before {
  width: 20px;
  height: 20px;
}

#pauseBtn.is-paused { --btn-icon: var(--icon-play); }

.pause-panel {
  width: min(360px, 92%);
}

.pause-actions {
  grid-template-columns: 1fr;
}

#resumeBtn { --btn-icon: var(--icon-play); }
#resumeBtn::before { content: ""; }

.hint {
  margin: 8px 0 0;
  color: var(--subtle);
  font-size: 0.95rem;
}

/* ---------------------------------------------------------------- Settings */

.difficulty-box {
  margin: 4px 0;
  width: min(480px, 100%);
  padding: 12px 10px;
  background: rgba(5, 8, 32, 0.55);
  border: 3px solid var(--ink);
  box-shadow: inset 0 0 0 2px #3b4aa0;
}

.difficulty-box > p:first-child {
  margin: 0;
  font-family: var(--font-pixel);
  font-size: 0.62rem;
  line-height: 1.6;
  color: var(--cyan);
  text-transform: uppercase;
}

.difficulty-buttons,
.theme-buttons {
  margin: 12px 4px 10px;
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 14px 12px;
}

.theme-buttons {
  grid-template-columns: repeat(2, minmax(0, 1fr));
}

.toggle-grid {
  margin: 12px 4px 10px;
  display: grid;
  grid-template-columns: 1fr;
  gap: 16px;
}

.difficulty-btn {
  font-size: 1rem;
  padding: 9px 6px 10px;
}

.psychedelic-toggle,
.update-btn {
  margin-top: 10px;
  width: min(320px, 100%);
}

.difficulty-hint {
  margin: 8px 0 0 !important;
  color: var(--subtle);
  font-size: 0.95rem;
}

.settings-credit {
  margin: 4px 0 8px;
  font-size: 0.95rem;
  color: var(--subtle);
}

/* ---------------------------------------------------------------- Leaderboard */

.name-entry {
  margin-top: 6px;
  width: min(420px, 100%);
  padding: 10px;
  background: rgba(5, 8, 32, 0.55);
  border: 3px solid var(--ink);
  box-shadow: inset 0 0 0 2px var(--gold-dark);
}

.name-entry.hidden {
  display: none;
}

.name-entry p {
  margin: 0 0 8px;
  font-size: 1.05rem;
}

.name-entry input {
  width: min(240px, 100%);
  margin: 0 8px 8px 0;
  padding: 9px 10px;
  font-family: var(--font-pixel);
  /* 16px or more, or iOS zooms the page when the field gets focus */
  font-size: 1rem;
  text-transform: uppercase;
  color: var(--gold);
  background: var(--ink);
  border: 3px solid var(--frame);
  border-radius: 0;
  caret-color: var(--gold);
}

.leaderboard-box {
  margin-top: 6px;
  width: min(440px, 100%);
  text-align: left;
  padding: 10px 12px;
  background: rgba(5, 8, 32, 0.55);
  border: 3px solid var(--ink);
  box-shadow: inset 0 0 0 2px #3b4aa0;
}

.leaderboard-box h3 {
  margin: 0 0 8px;
  font-family: var(--font-pixel);
  font-weight: 400;
  font-size: 0.66rem;
  line-height: 1.6;
  color: var(--gold);
}

.errors-box h3 {
  color: var(--cyan);
}

#leaderboardList,
#errorStatsList {
  margin: 0;
  padding-left: 26px;
  max-height: 220px;
  overflow-y: auto;
  color: #e6edff;
}

#leaderboardList {
  font-size: 1.05rem;
}

#leaderboardList li::marker {
  font-family: var(--font-pixel);
  font-size: 0.6rem;
  color: var(--gold);
}

#errorStatsList {
  /* own scroller with an always-visible bar so all 15 rows are reachable */
  max-height: 300px;
  overflow-y: scroll;
  padding-right: 6px;
  font-size: 0.9rem;
  line-height: 1.25;
  scrollbar-width: thin;
  scrollbar-color: var(--cyan) rgba(255, 255, 255, 0.08);
}

/* iOS hides scrollbars: fade the bottom and show an arrow while rows remain */
#errorStatsList.has-more {
  -webkit-mask-image: linear-gradient(to bottom, #000 78%, transparent);
  mask-image: linear-gradient(to bottom, #000 78%, transparent);
}

.errors-box {
  position: relative;
}

.errors-box .list-more {
  position: absolute;
  left: 50%;
  bottom: 6px;
  transform: translateX(-50%);
  font-family: var(--font-pixel);
  font-size: 0.6rem;
  color: var(--cyan);
  pointer-events: none;
  animation: hint-bob 1.2s ease-in-out infinite;
}

.errors-box .list-more[hidden] {
  display: none;
}

#errorStatsList::-webkit-scrollbar {
  width: 10px;
}

#errorStatsList::-webkit-scrollbar-track {
  background: rgba(255, 255, 255, 0.08);
}

#errorStatsList::-webkit-scrollbar-thumb {
  background: var(--cyan);
  border: 2px solid var(--ink);
}

#leaderboardList li,
#errorStatsList li {
  margin: 3px 0;
}

/* ---------------------------------------------------------------- Quiz */

.quiz-panel {
  max-width: 820px;
}

.quiz-capsule.vector {
  width: 64px;
  image-rendering: auto;
}

.quiz-capsule {
  display: block;
  width: 80px;
  height: auto;
  margin: 0 auto 6px;
  image-rendering: pixelated;
}

#quizPrompt {
  margin: 4px 0 10px;
  font-size: clamp(1.5rem, 3vw, 2.4rem);
  font-weight: 900;
  letter-spacing: 0.01em;
  line-height: 1.25;
  color: #fff7d6;
  text-shadow: 3px 3px 0 var(--ink);
}

.prompt-answer {
  font: inherit;
}

.prompt-answer.wrong {
  color: #ff6b80;
}

.prompt-answer.correct {
  color: var(--mint);
}

.quiz-timer {
  margin: 0 0 6px;
  font-family: var(--font-pixel);
  font-size: 0.72rem;
  color: var(--gold);
}

.quiz-timebar {
  width: min(360px, 90%);
  height: 16px;
  margin: 0 auto 6px;
  padding: 2px;
  background: var(--ink);
  border: 3px solid var(--frame);
}

.quiz-timebar.hidden {
  display: none;
}

.quiz-timebar span {
  display: block;
  height: 100%;
  width: 100%;
  background: repeating-linear-gradient(90deg, var(--mint) 0 10px, #2fd39a 10px 12px);
}

.quiz-timebar.low span {
  background: repeating-linear-gradient(90deg, #ff6b80 0 10px, var(--danger) 10px 12px);
  animation: cursor-blink 0.4s steps(1) infinite;
}

.choices {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 10px;
  margin-top: 12px;
}

.choice-btn {
  font-size: 1.35rem;
  letter-spacing: 0.01em;
  padding: 14px 8px 15px;
  white-space: nowrap;
}

/* key number badge (1, 2, 3) */
.choice-btn::before {
  position: absolute;
  top: 5px;
  left: 6px;
  min-width: 16px;
  padding: 1px 3px;
  font-family: var(--font-pixel);
  font-size: 0.48rem;
  line-height: 1.4;
  color: var(--btn-text);
  background: rgba(0, 0, 0, 0.22);
  text-shadow: none;
}

.choice-btn:nth-child(1)::before { content: "1"; }
.choice-btn:nth-child(2)::before { content: "2"; }
.choice-btn:nth-child(3)::before { content: "3"; }

.choice-btn:disabled {
  cursor: default;
  transform: none;
  filter: saturate(0.7) brightness(0.92);
}

.feedback {
  min-height: 0;
  font-size: 0;
  margin: 0;
  display: none;
}

.feedback.ok {
  color: var(--mint);
}

.feedback.bad {
  color: #ff9eaa;
}

/* ---------------------------------------------------------------- Champion */

.champion-panel {
  width: min(760px, 92%);
  border-image-source: var(--pixel-frame-gold);
}

#championTitle {
  margin: 0;
  font-family: var(--font-pixel);
  font-size: clamp(0.9rem, 3vw, 1.6rem);
  line-height: 1.5;
  color: var(--gold);
  text-shadow: 3px 3px 0 var(--ink), 6px 6px 0 #5a1a6a;
  animation: cursor-blink 0.9s steps(1) infinite;
}

/* ---------------------------------------------------------------- Shop */

.shop-grid {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 12px;
  width: min(540px, 100%);
  margin: 0 auto;
  padding: 10px 6px 8px 4px;
}

.shop-card {
  padding: 6px 6px 10px;
  text-align: center;
  background: rgba(5, 8, 32, 0.55);
  border: 3px solid var(--ink);
  box-shadow: inset 0 0 0 2px #3b4aa0, 0 4px 0 var(--ink);
}

.shop-card.active {
  box-shadow: inset 0 0 0 3px var(--gold), 0 4px 0 var(--ink);
}

.shop-card-preview {
  display: block;
  width: 100%;
  aspect-ratio: 16 / 9;
  margin-bottom: 6px;
  border: 3px solid var(--ink);
  image-rendering: pixelated;
}

.shop-card-name {
  margin: 4px 0;
  font-family: var(--font-pixel);
  font-size: 0.58rem;
  line-height: 1.5;
  color: #fff;
}

.shop-card-desc {
  margin: 0;
  font-size: 0.9rem;
  line-height: 1.2;
  color: var(--subtle);
}

.shop-card-btn {
  margin: 10px 0 8px;
  padding: 7px 14px 8px;
  font-family: var(--font-pixel);
  font-weight: 400;
  font-size: 0.55rem;
  text-transform: uppercase;
}

.shop-card-btn.current {
  cursor: default;
}

.shop-wallet {
  margin: 0 0 10px;
  display: grid;
  gap: 4px;
}

.shop-wallet-coins {
  font-family: var(--font-pixel);
  font-size: 0.7rem;
  color: var(--gold);
}

.shop-wallet-coins::before {
  content: "";
  display: inline-block;
  width: 16px;
  height: 16px;
  margin-right: 6px;
  vertical-align: -3px;
  background: var(--icon-coin) center / contain no-repeat;
  image-rendering: pixelated;
}

.shop-wallet-hint {
  font-size: 0.85rem;
  color: var(--subtle);
}

.shop-card {
  position: relative;
}

.shop-card.locked .shop-card-preview {
  filter: grayscale(0.75) brightness(0.7);
}

.shop-card.next {
  box-shadow: inset 0 0 0 3px var(--cyan), 0 4px 0 var(--ink);
}

.shop-badge {
  position: absolute;
  top: -8px;
  right: -6px;
  z-index: 1;
  padding: 3px 6px;
  font-family: var(--font-pixel);
  font-size: 0.45rem;
  color: var(--ink);
  background: var(--cyan);
  border: 2px solid var(--ink);
  animation: start-pulse 1.2s steps(2, jump-none) infinite;
}

.shop-progress {
  height: 8px;
  margin: 8px 4px 4px;
  background: rgba(255, 255, 255, 0.1);
  border: 2px solid var(--ink);
}

.shop-progress > span {
  display: block;
  height: 100%;
  background: linear-gradient(var(--gold), #f6912c);
}

.shop-card-goal {
  margin: 0;
  font-size: 0.82rem;
  line-height: 1.2;
  color: #e6edff;
}

.shop-card-btn:disabled {
  cursor: default;
  filter: grayscale(0.6) brightness(0.85);
}

.shop-card-btn.buy {
  animation: start-pulse 1.2s steps(2, jump-none) infinite;
}

.level-reward {
  color: var(--gold);
}

/* ---------------------------------------------------------------- Small screens */

@media (max-width: 700px) {
  .hud-logo {
    display: none;
  }

  .hud {
    gap: 10px;
    padding: 6px 8px 4px;
  }

  .stats {
    gap: 10px;
    flex-wrap: nowrap;
    min-width: 0;
  }

  .stat {
    column-gap: 4px;
  }

  .stat::before {
    width: 16px;
    height: 16px;
  }

  .hud-btn {
    width: 36px;
    height: 36px;
    min-height: 36px;
  }

  .stat-value {
    font-size: 0.66rem;
  }

  .panel {
    padding: 12px 10px;
    border-width: 10px;
    border-image-width: 10px;
  }

  .menu-actions {
    grid-template-columns: 1fr;
    gap: 10px;
  }

  .arena-wrap {
    min-height: 170px;
  }

  .choices {
    gap: 8px;
  }

  .choice-btn {
    font-size: 1.15rem;
    padding: 14px 4px 13px;
  }

  .main-btn {
    font-size: 0.62rem;
    gap: 8px;
  }

  .difficulty-buttons,
  .theme-buttons {
    gap: 6px;
  }

  .difficulty-btn {
    font-size: 0.9rem;
    padding: 8px 4px;
  }

  .shop-grid {
    gap: 8px;
  }

  .shop-card-name {
    font-size: 0.5rem;
  }

  .shop-card-desc {
    font-size: 0.8rem;
  }
}

/* Phones: one answer per row so even long verbs ("understood") read in full */
@media (max-width: 560px) {
  .choices {
    grid-template-columns: 1fr;
    gap: 16px;
    margin: 14px 6px 8px;
  }

  .choice-btn {
    font-size: 1.4rem;
    padding: 12px 10px 13px 40px;
    text-align: left;
  }

  .choice-btn::before {
    top: 50%;
    left: 10px;
    transform: translateY(-50%);
    font-size: 0.6rem;
    padding: 3px 5px;
  }

  #quizPrompt {
    font-size: 1.45rem;
  }

  .quiz-panel {
    padding: 12px 10px 16px;
  }
}

@media (prefers-reduced-motion: reduce) {
  .pixel-logo,
  #championTitle,
  .quiz-timebar.low span {
    animation: none;
  }
}

/* Native app builds update through the store: no update box. */
.native-app .update-box {
  display: none;
}
