:root {
  --orange: #ff6600;
  --orange-hot: #ff8533;
  --orange-dim: #cc5200;
  --black: #0a0a0a;
  --ink: #121212;
  --panel: #1a1a1a;
  --panel-2: #222;
  --white: #f5f5f5;
  --muted: #9a9a9a;
  --good: #3ddc84;
  --bad: #ff4466;
  --combo: #ffd166;
  --shadow: 0 8px 32px rgba(0,0,0,.55);
  --radius: 16px;
  --font: "Segoe UI", system-ui, -apple-system, Roboto, Ubuntu, sans-serif;
}

* { box-sizing: border-box; margin: 0; padding: 0; }
html, body, * {
  -webkit-user-select: none;
  user-select: none;
  -webkit-touch-callout: none;
}
input, textarea {
  -webkit-user-select: text;
  user-select: text;
}
html, body {
  height: 100%;
  background: var(--black);
  color: var(--white);
  font-family: var(--font);
  overflow-x: hidden;
  -webkit-tap-highlight-color: transparent;
  user-select: none;
}

body {
  background:
    radial-gradient(ellipse 80% 50% at 50% -10%, rgba(255,102,0,.18), transparent 60%),
    radial-gradient(ellipse 60% 40% at 100% 100%, rgba(255,102,0,.08), transparent 50%),
    var(--black);
  min-height: 100dvh;
}

.app {
  max-width: 920px;
  margin: 0 auto;
  padding: 12px 14px 28px;
  min-height: 100dvh;
  display: flex;
  flex-direction: column;
  gap: 12px;
}

/* Top bar */
.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  flex-wrap: wrap;
}

.brand {
  display: flex;
  align-items: center;
  gap: 10px;
}
.brand img {
  width: 44px; height: 44px;
  filter: drop-shadow(0 2px 8px rgba(255,102,0,.45));
}
.brand h1 {
  font-size: 1.05rem;
  letter-spacing: .04em;
  font-weight: 800;
  line-height: 1.15;
}
.brand h1 span { color: var(--orange); display: block; font-size: .72rem; font-weight: 600; letter-spacing: .12em; text-transform: uppercase; }

.hud {
  display: flex;
  gap: 8px;
  align-items: center;
  flex-wrap: wrap;
  justify-content: flex-end;
}
.stat {
  background: var(--panel);
  border: 1px solid #333;
  border-radius: 999px;
  padding: 6px 12px;
  font-size: .82rem;
  font-variant-numeric: tabular-nums;
  display: flex; align-items: center; gap: 6px;
}
.stat strong { color: var(--orange); font-size: 1rem; }
.stat.combo strong { color: var(--combo); }
.mult-badge {
  display: flex; align-items: center; gap: 6px;
  background: linear-gradient(135deg, #2a1608, #1a1a1a);
  border: 1px solid var(--orange-dim);
  border-radius: 999px;
  padding: 4px 10px 4px 4px;
  font-size: .78rem;
  font-weight: 700;
}
.mult-badge img { width: 28px; height: 28px; }
.logo-link { display: inline-flex; line-height: 0; border-radius: 10px; }
.logo-link:hover { outline: 2px solid var(--orange); outline-offset: 2px; }
.logo-link.hero { display: flex; width: fit-content; margin: 0 auto; }
.multiplier-logo { border-radius: 6px; }
.end-card-link { display: block; line-height: 0; width: fit-content; margin: 0 auto 14px; }
.end-card-link:hover { outline: 2px solid var(--orange); outline-offset: 3px; border-radius: 8px; }
.mult-badge span { color: var(--orange-hot); }

.icon-btn {
  width: 40px; height: 40px;
  border-radius: 50%;
  border: 1px solid #444;
  background: var(--panel);
  color: var(--white);
  cursor: pointer;
  font-size: 1.1rem;
  display: grid; place-items: center;
  transition: background .15s, border-color .15s, transform .1s;
}
.icon-btn:hover { border-color: var(--orange); background: #2a1a10; }
.icon-btn:active { transform: scale(.94); }
.icon-btn.muted { opacity: .55; }

/* Judges row */
.judges {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 10px;
}
.judge {
  background: var(--panel);
  border: 1px solid #2e2e2e;
  border-radius: var(--radius);
  padding: 10px;
  display: flex;
  gap: 10px;
  align-items: center;
  box-shadow: var(--shadow);
  min-height: 88px;
  transition: border-color .2s, box-shadow .2s;
}
.judge.react-good {
  border-color: var(--good);
  box-shadow: 0 0 0 1px rgba(61,220,132,.35), var(--shadow);
}
.judge.react-bad {
  border-color: var(--bad);
  box-shadow: 0 0 0 1px rgba(255,68,102,.3), var(--shadow);
}
.judge img {
  width: 64px; height: 64px;
  border-radius: 50%;
  flex-shrink: 0;
  object-fit: cover;
}
.judge .meta { min-width: 0; flex: 1; }
.judge .name {
  font-size: .72rem;
  text-transform: uppercase;
  letter-spacing: .1em;
  color: var(--orange);
  font-weight: 700;
  margin-bottom: 4px;
}
.judge .line {
  font-size: .92rem;
  line-height: 1.35;
  color: var(--white);
  font-weight: 600;
}
.judge .line.flat { color: #ddd; font-weight: 500; }
.judge.ed .line { color: #ffe0c2; font-style: italic; font-weight: 500; }

/* Stage */
.stage {
  flex: 1;
  display: flex;
  flex-direction: column;
  gap: 12px;
  position: relative;
}

.prompt-bar {
  text-align: center;
  color: var(--muted);
  font-size: .85rem;
  letter-spacing: .02em;
}
.prompt-bar b { color: var(--orange-hot); }

.quote-lane {
  position: relative;
  background: linear-gradient(180deg, #161616, #101010);
  border: 1px solid #333;
  border-radius: 20px;
  padding: 22px 16px 18px;
  min-height: 160px;
  overflow: hidden;
  box-shadow: inset 0 0 40px rgba(255,102,0,.05), var(--shadow);
}
.quote-lane::before {
  content: "";
  position: absolute;
  inset: 0;
  background: repeating-linear-gradient(
    90deg,
    transparent,
    transparent 40px,
    rgba(255,102,0,.03) 40px,
    rgba(255,102,0,.03) 41px
  );
  pointer-events: none;
}

.timer-track {
  height: 6px;
  background: #2a2a2a;
  border-radius: 999px;
  overflow: hidden;
  margin-bottom: 16px;
}
.timer-fill {
  height: 100%;
  width: 100%;
  background: linear-gradient(90deg, var(--orange-dim), var(--orange-hot));
  transform-origin: left center;
  transition: none;
}

.quote-words {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  justify-content: center;
  align-items: center;
  min-height: 72px;
  position: relative;
  z-index: 1;
}
.word {
  font-size: clamp(1.15rem, 4.2vw, 1.7rem);
  font-weight: 700;
  padding: 8px 12px;
  border-radius: 10px;
  background: #1e1e1e;
  border: 1.5px solid #3a3a3a;
  color: var(--white);
  cursor: pointer;
  transition: transform .12s, border-color .12s, background .12s, color .12s, box-shadow .12s;
  line-height: 1.2;
  touch-action: manipulation;
}
.word:hover, .word:focus, .word:focus-visible, .word:active {
  /* Sentence words must never show an orange browser/focus ring. */
  border-color: #3a3a3a;
  outline: none !important;
  box-shadow: none !important;
  -webkit-tap-highlight-color: transparent;
  transform: translateY(-2px);
}
.word.selected {
  /* Selection is neutral; orange is reserved for the surrounding UI. */
  background: #2a2a2a;
  border-color: #555;
  color: var(--white);
  outline: none !important;
  box-shadow: none !important;
}
.quote-words .word,
.quote-words .word:hover,
.quote-words .word:focus,
.quote-words .word:focus-visible,
.quote-words .word:active,
.quote-words .word.selected {
  outline: none !important;
  box-shadow: none !important;
}
.word.correct {
  background: var(--good);
  border-color: #2fba6e;
  color: #062;
  animation: pop .35s ease;
}
.word.wrong {
  background: var(--bad);
  border-color: #cc3350;
  color: #fff;
  animation: shake .35s ease;
}
.word.dim { opacity: .45; }
.word.punct {
  background: transparent;
  border-color: transparent;
  cursor: default;
  padding: 8px 2px;
  pointer-events: none;
}

@keyframes pop {
  0% { transform: scale(1); }
  40% { transform: scale(1.12); }
  100% { transform: scale(1); }
}
@keyframes shake {
  0%,100% { transform: translateX(0); }
  25% { transform: translateX(-6px); }
  75% { transform: translateX(6px); }
}
@keyframes floatIn {
  from { opacity: 0; transform: translateY(18px) scale(.98); }
  to { opacity: 1; transform: translateY(0) scale(1); }
}
.quote-words.enter { animation: floatIn .35s ease; }

.feedback {
  text-align: center;
  min-height: 28px;
  font-weight: 700;
  font-size: 1rem;
  letter-spacing: .02em;
}
.feedback.good { color: var(--good); }
.feedback.bad { color: var(--bad); }
.feedback.combo { color: var(--combo); }

/* Input / actions */
.actions {
  display: flex;
  flex-direction: column;
  gap: 10px;
}
.type-row {
  display: flex;
  gap: 8px;
}
.type-row input {
  flex: 1;
  background: var(--panel-2);
  border: 1px solid #3a3a3a;
  border-radius: 12px;
  color: var(--white);
  font-size: 1rem;
  padding: 12px 14px;
  outline: none;
  font-family: inherit;
}
.type-row input:focus { border-color: var(--orange); }
.type-row input::placeholder { color: #666; }
.btn {
  border: none;
  border-radius: 12px;
  padding: 12px 18px;
  font-weight: 800;
  font-size: .95rem;
  cursor: pointer;
  font-family: inherit;
  letter-spacing: .03em;
  transition: transform .1s, filter .15s, background .15s;
  touch-action: manipulation;
}
.btn:active { transform: scale(.97); }
.btn-primary {
  background: linear-gradient(135deg, var(--orange), var(--orange-dim));
  color: #111;
  box-shadow: 0 4px 16px rgba(255,102,0,.35);
}
.btn-primary:hover { filter: brightness(1.08); }
.btn-ghost {
  background: transparent;
  border: 1px solid #444;
  color: var(--white);
}
.btn-ghost:hover { border-color: var(--orange); color: var(--orange-hot); }
.btn-swap {
  background: #2a2a2a;
  color: var(--orange-hot);
  border: 1px solid var(--orange-dim);
  white-space: nowrap;
}
.hint {
  text-align: center;
  font-size: .78rem;
  color: var(--muted);
}

/* Overlays */
.overlay {
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,.82);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 50;
  padding: 16px;
  backdrop-filter: blur(6px);
}
.overlay.hidden { display: none; }
.card {
  width: min(440px, 100%);
  background: #0d0d0d;
  border: 1px solid #333;
  border-radius: 22px;
  padding: 28px 22px 22px;
  text-align: center;
  box-shadow: 0 20px 60px rgba(0,0,0,.7);
}
.card.end-card {
  background: #000;
  border-color: #222;
  padding: 18px 16px 20px;
}
.card.end-card .end-art {
  width: 100%;
  max-width: 340px;
  border-radius: 8px;
  margin: 0;
  display: block;
}
.card img.logo-hero {
  width: 96px; height: 96px;
  margin: 0 auto 12px;
  display: block;
  filter: drop-shadow(0 4px 16px rgba(255,102,0,.4));
}
.card h2 {
  font-size: 1.55rem;
  margin-bottom: 8px;
  letter-spacing: .04em;
}
.card h2 .dollar { color: var(--orange); }
.card p {
  color: #bbb;
  font-size: .95rem;
  line-height: 1.45;
  margin-bottom: 10px;
}
.card .how {
  text-align: left;
  background: #151515;
  border-radius: 12px;
  padding: 12px 14px;
  margin: 14px 0 18px;
  font-size: .88rem;
  color: #ccc;
}
.card .how li { margin: 6px 0 6px 18px; }
.card .scores {
  display: flex;
  justify-content: center;
  gap: 16px;
  margin: 12px 0 18px;
  flex-wrap: wrap;
}
.card .scores div {
  background: #151515;
  border-radius: 12px;
  padding: 10px 16px;
  min-width: 100px;
}
.card .scores b { display: block; color: var(--orange); font-size: 1.4rem; }
.card .scores span { font-size: .72rem; color: var(--muted); text-transform: uppercase; letter-spacing: .08em; }
.card .wallet {
  font-size: .62rem;
  color: #555;
  word-break: break-all;
  margin-top: 10px;
  font-family: ui-monospace, monospace;
}
.card .btn { width: 100%; margin-top: 6px; }

.round-chip {
  align-self: center;
  background: #1a1a1a;
  border: 1px solid #333;
  border-radius: 999px;
  padding: 4px 12px;
  font-size: .75rem;
  color: var(--muted);
}
.round-chip b { color: var(--orange-hot); }

@media (max-width: 560px) {
  .judges { grid-template-columns: 1fr; }
  .judge img { width: 56px; height: 56px; }
  .brand h1 { font-size: .95rem; }
  .stat { padding: 5px 10px; font-size: .75rem; }
  .quote-lane { min-height: 140px; padding: 16px 12px; }
}

/* ---- Leaderboard / score submit ---- */
.score-submit {
  margin: 8px 0 10px;
  text-align: left;
}
.name-label {
  display: block;
  font-size: .72rem;
  text-transform: uppercase;
  letter-spacing: .1em;
  color: var(--orange);
  font-weight: 700;
  margin-bottom: 6px;
}
.name-row {
  display: flex;
  gap: 8px;
  align-items: stretch;
  flex-wrap: wrap;
}
.name-row input {
  flex: 1 1 140px;
  min-width: 0;
  appearance: none;
  border: 1px solid #444;
  border-radius: 999px;
  background: #151515;
  color: var(--white);
  padding: 10px 14px;
  font-size: .95rem;
  font-family: inherit;
  outline: none;
}
.name-row input:focus {
  border-color: var(--orange);
  box-shadow: 0 0 0 2px rgba(255,102,0,.25);
}
.name-row .btn.btn-primary {
  width: auto;
  flex: 0 0 auto;
  padding: 10px 18px;
  font-size: .9rem;
  margin-top: 0;
}
.name-row .btn.btn-primary:disabled {
  opacity: .55;
  cursor: not-allowed;
  filter: none;
}
.submit-status {
  margin-top: 8px !important;
  margin-bottom: 0 !important;
  font-size: .8rem !important;
  color: var(--muted) !important;
}
.submit-status.ok { color: var(--good) !important; }
.submit-status.err { color: var(--bad) !important; }

.again-below { display: block; width: 100%; margin-top: 10px; }

.leaderboard {
  margin: 10px 0 8px;
  text-align: left;
  background: #121212;
  border: 1px solid #2a2a2a;
  border-radius: 14px;
  padding: 12px 14px;
  /* Keep the board compact while allowing every score to be reached. */
  max-height: 240px;
  overflow-y: auto;
  overscroll-behavior: contain;
  -webkit-overflow-scrolling: touch;
  scrollbar-gutter: stable;
  scrollbar-width: auto;
  scrollbar-color: var(--orange) #2a2a2a;
}
.leaderboard h3 {
  font-size: .78rem;
  text-transform: uppercase;
  letter-spacing: .12em;
  color: var(--orange);
  margin-bottom: 8px;
}
.lb-list {
  list-style: none;
  margin: 0;
  padding: 0;
  display: grid;
  gap: 4px;
}
.lb-list li {
  display: grid;
  grid-template-columns: 28px 1fr auto auto;
  gap: 8px;
  align-items: center;
  font-size: .86rem;
  padding: 6px 8px;
  border-radius: 8px;
  background: #181818;
  color: #ddd;
}
.lb-list li .rank { color: var(--muted); font-variant-numeric: tabular-nums; }
.lb-list li .lb-name {
  font-weight: 700;
  color: var(--white);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.lb-list li .lb-score { color: var(--orange); font-weight: 800; font-variant-numeric: tabular-nums; }
.lb-list li .lb-combo { color: var(--muted); font-size: .78rem; font-variant-numeric: tabular-nums; }
.lb-list li.empty {
  display: block;
  text-align: center;
  color: var(--muted);
  background: transparent;
}
.leaderboard .lb-list, .leaderboard ol {
  /* The containing leaderboard is the only scroll region. */
  max-height: none !important;
  overflow: visible;
}
.leaderboard::-webkit-scrollbar { width: 12px; }
.leaderboard::-webkit-scrollbar-track { background: #2a2a2a; border-radius: 999px; }
.leaderboard::-webkit-scrollbar-thumb {
  background: var(--orange);
  border: 2px solid #2a2a2a;
  border-radius: 999px;
}
.leaderboard::-webkit-scrollbar-thumb:hover { background: var(--orange-hot); }

.card.end-card {
  max-height: min(86vh, 640px);
  overflow-y: auto;
}
.card.end-card .end-art {
  max-height: 90px;
  width: auto;
  margin-bottom: 0;
}

#startOverlay .start-leaderboard {
  margin: 0 0 12px;
  padding: 8px 10px;
  max-height: 154px;
  overflow-y: auto;
  overscroll-behavior: contain;
  -webkit-overflow-scrolling: touch;
  scrollbar-gutter: stable;
  scrollbar-width: auto;
  scrollbar-color: var(--orange) #2a2a2a;
  border-radius: 12px;
}
#startOverlay .board-heading {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 8px;
  margin-bottom: 6px;
}
#startOverlay .board-heading h3 { margin: 0; font-size: .78rem; text-transform: uppercase; letter-spacing: .12em; color: var(--orange); }
#startOverlay .board-heading span {
  color: var(--muted);
  font-size: .68rem;
}
#startOverlay .start-leaderboard .lb-list { gap: 3px; max-height: none !important; }
#startOverlay .start-leaderboard .lb-list li {
  grid-template-columns: 22px minmax(0, 1fr) auto 40px;
  gap: 6px;
  padding: 5px 6px;
  font-size: .76rem;
}
#startOverlay .start-leaderboard .lb-list li .lb-combo {
  font-size: .68rem;
  text-align: right;
}
#startOverlay .start-leaderboard .lb-list li.empty {
  display: block;
  padding: 5px 2px;
}

img, a { -webkit-user-drag: none; user-drag: none; }

/* Compact start/instructions card: keep the full board reachable and Play prominent. */
#startOverlay .start-card {
  padding: 20px 18px 16px;
  max-height: calc(100dvh - 24px);
  overflow-y: auto;
}
#startOverlay .start-card .logo-hero {
  width: 72px;
  height: 72px;
  margin-bottom: 8px;
}
#startOverlay .start-card h2 {
  font-size: 1.3rem;
  margin-bottom: 6px;
}
#startOverlay .start-card > p:not(.hint) {
  font-size: .86rem;
  line-height: 1.35;
  margin-bottom: 8px;
}
#startOverlay .start-card .how {
  padding: 8px 10px;
  margin: 10px 0 12px;
  font-size: .8rem;
}
#startOverlay .start-card .how li { margin: 4px 0 4px 16px; }
#startOverlay .start-card .start-leaderboard {
  margin-bottom: 8px;
  padding: 6px 8px;
}
#startOverlay .start-card .board-heading { margin-bottom: 4px; }
#startOverlay .start-card .start-leaderboard .lb-list { gap: 2px; }
#startOverlay .start-card .start-leaderboard .lb-list li {
  gap: 5px;
  padding: 4px 5px;
  font-size: .72rem;
}
#startOverlay .start-card .start-leaderboard .lb-list li .lb-combo { font-size: .64rem; }
#startOverlay .start-card > .btn-primary {
  padding: 10px 16px;
  font-size: .9rem;
  margin-top: 4px;
}
#startOverlay .start-card .start-hint {
  margin-top: 8px !important;
  margin-bottom: 0;
  font-size: .72rem;
}
