:root {
  --orange: #ff6600;
  --orange-hot: #ff8533;
  --orange-dim: #cc5200;
  --black: #0a0a0a;
  --ink: #121212;
  --panel: #1a1a1a;
  --white: #f5f5f5;
  --muted: #9a9a9a;
  --good: #3ddc84;
  --bad: #ff4466;
  --combo: #ffd166;
  --sea: #0b2740;
  --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, 
html, body, * {
  -webkit-user-select: none;
  user-select: none;
  -webkit-touch-callout: none;
}
input, textarea {
  -webkit-user-select: text;
  user-select: text;
}

body {
  height: 100%;
  background: var(--black);
  color: var(--white);
  font-family: var(--font);
  overflow-x: hidden;
  -webkit-tap-highlight-color: transparent;
  user-select: none;
  touch-action: manipulation;
}
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: 1100px;
  margin: 0 auto;
  padding: 8px 12px 12px;
  min-height: 100dvh;
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.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: .7rem;
  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: .8rem;
  font-variant-numeric: tabular-nums;
  display: flex; align-items: center; gap: 6px;
}
.stat strong { color: var(--orange); font-size: .95rem; }
.stat.flood strong { color: #5eb8ff; }
.stat.flood.danger strong { color: var(--bad); }

.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; }

.crew {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 8px;
}
.crew-card {
  display: flex;
  align-items: center;
  gap: 10px;
  background: linear-gradient(135deg, #1c1208, #151515);
  border: 1px solid #333;
  border-radius: var(--radius);
  padding: 8px 12px;
  min-height: 72px;
}
.crew-card.greta { border-color: #3a2810; }
.crew-card.ed { border-color: #2a2a18; }
.crew-card img {
  width: 56px; height: 56px;
  border-radius: 12px;
  object-fit: cover;
  border: 2px solid var(--orange-dim);
  background: #111;
}
.crew-card .name {
  font-size: .72rem;
  text-transform: uppercase;
  letter-spacing: .1em;
  color: var(--orange);
  font-weight: 700;
  margin-bottom: 2px;
}
.crew-card .line {
  font-size: .85rem;
  color: var(--white);
  line-height: 1.25;
  min-height: 2.2em;
}

.stage-wrap {
  position: relative;
  border-radius: 18px;
  overflow: hidden;
  border: 2px solid #2a2a2a;
  box-shadow: var(--shadow), inset 0 0 0 1px rgba(255,102,0,.15);
  background: var(--sea);
  aspect-ratio: 16 / 9;
  max-height: min(62vh, 540px);
  margin-top: 6px;
}
#game {
  display: block;
  width: 100%;
  height: 100%;
  background: #0b2740;
}

.touch-pad {
  display: none;
  position: relative;
  inset: auto;
  margin-top: 4px;
  padding: 6px 10px;
  background: rgba(0,0,0,.55);
  border-radius: 12px;
  justify-content: space-between;
  align-items: center;
  gap: 10px;
  pointer-events: none;
  z-index: 5;
  width: 100%;
  max-width: 720px;
  margin-left: auto;
  margin-right: auto;
  min-height: 0;
  /* wider than tall */
  aspect-ratio: auto;
}
.touch-pad .dpad {
  pointer-events: auto;
  display: flex;
  flex-direction: row;
  align-items: center;
  justify-content: center;
  gap: 4px;
  flex: 1 1 auto;
}
.touch-pad .pad-vert {
  display: flex;
  flex-direction: column;
  gap: 4px;
}
.touch-pad .actions {
  pointer-events: auto;
  display: flex;
  flex-direction: row;
  gap: 6px;
  align-items: stretch;
  flex: 1 1 auto;
  justify-content: flex-end;
}
.touch-pad .mid { display: flex; gap: 6px; }
.touch-pad button {
  user-select: none;
  -webkit-user-select: none;
  -webkit-touch-callout: none;
  -webkit-tap-highlight-color: transparent;
  touch-action: manipulation;
  width: 56px;
  height: 48px;
  border-radius: 10px;
  border: 1px solid #555;
  background: rgba(20,20,20,.85);
  color: var(--white);
  font-size: 1rem;
  font-weight: 700;
  cursor: pointer;
  touch-action: none;
}
.touch-pad .pad-left,
.touch-pad .pad-right {
  height: 100px; /* span both 48px vert buttons + gap */
  width: 52px;
}
.touch-pad button.act {
  width: auto;
  flex: 1 1 0;
  min-width: 0;
  max-width: 160px;
  height: 84px;
  min-height: 0;
  padding: 6px 10px;
  font-size: .8rem;
  border-color: var(--orange-dim);
  background: rgba(40,22,8,.9);
  color: var(--orange-hot);
  display: flex;
  flex-direction: column;
  justify-content: center;
  gap: 2px;
  line-height: 1.1;
}
.touch-pad button.act .btn-title { font-weight: 800; font-size: .82rem; }
.touch-pad button.act .btn-sub { font-weight: 600; font-size: .62rem; opacity: .85; color: #ccc;
}
.touch-pad button.act.guitar { border-color: #665522; color: var(--combo); }
.touch-pad button:active { transform: scale(.94); background: #2a1608; }

.controls-hint {
  text-align: center;
  color: var(--muted);
  font-size: .78rem;
  line-height: 1.4;
  padding: 0 4px 6px;
}
.controls-hint b { color: var(--orange-hot); }

.overlay {
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,.82);
  display: grid;
  place-items: center;
  padding: 16px;
  z-index: 40;
  backdrop-filter: blur(6px);
}
.overlay.hidden { display: none; }
.card {
  width: min(440px, 100%);
  background: linear-gradient(160deg, #1a1208 0%, #121212 45%, #0a0a0a 100%);
  border: 1px solid var(--orange-dim);
  border-radius: 20px;
  padding: 22px 20px 20px;
  box-shadow: var(--shadow), 0 0 40px rgba(255,102,0,.12);
  text-align: center;
}
.card.endish { width: min(520px, 100%); }
.logo-hero {
  width: 88px; height: 88px;
  margin: 0 auto 10px;
  filter: drop-shadow(0 4px 16px rgba(255,102,0,.5));
}
.card h2 {
  font-size: 1.45rem;
  margin-bottom: 8px;
  letter-spacing: .02em;
}
.dollar { color: var(--orange); }
.card p {
  color: var(--muted);
  font-size: .92rem;
  line-height: 1.45;
  margin-bottom: 12px;
}
.card p b { color: var(--white); }
.how {
  text-align: left;
  list-style: none;
  margin: 0 0 16px;
  padding: 0;
  display: grid;
  gap: 8px;
}
.how li {
  background: #151515;
  border: 1px solid #2a2a2a;
  border-radius: 12px;
  padding: 8px 12px;
  font-size: .86rem;
  color: #ddd;
}
.how li b { color: var(--orange); }
.btn {
  appearance: none;
  border: none;
  cursor: pointer;
  border-radius: 999px;
  padding: 12px 28px;
  font-weight: 800;
  font-size: 1rem;
  letter-spacing: .04em;
  transition: transform .12s, filter .12s;
}
.btn.primary {
  background: linear-gradient(135deg, var(--orange-hot), var(--orange));
  color: #0a0a0a;
  box-shadow: 0 6px 20px rgba(255,102,0,.35);
  width: 100%;
}
.btn.primary:hover { filter: brightness(1.08); }
.btn.primary:active { transform: scale(.97); }
.fine {
  margin-top: 12px !important;
  font-size: .72rem !important;
  color: #666 !important;
}
.end-card {
  width: 100%;
  border-radius: 12px;
  margin-bottom: 12px;
  border: 1px solid #333;
  display: block;
}
.score-big {
  font-size: 1.1rem !important;
  color: var(--white) !important;
}
.score-big strong { color: var(--orange); font-size: 1.5rem; }

@media (max-width: 720px) {
  .crew { grid-template-columns: 1fr; }
  .crew-card { min-height: 64px; }
  .crew-card img { width: 48px; height: 48px; }
  .brand h1 { font-size: .95rem; }
  .controls-hint { display: none; }
  .touch-pad { display: flex; }
  .stage-wrap { max-height: min(48vh, 420px); }
}
@media (pointer: coarse) {
  .touch-pad { display: flex; }
  .controls-hint { font-size: .7rem; }
}

.action-legend {
  display: flex;
  flex-wrap: wrap;
  gap: 8px 14px;
  margin: 6px 0 0;
  font-size: .78rem;
  color: #bbb;
}
.action-legend b { color: var(--orange-hot); }
.stat.buff-hud strong { color: var(--combo); }

.toast {
  position: absolute;
  left: 50%;
  bottom: 8px;
  top: auto;
  transform: translateX(-50%);
  z-index: 8;
  padding: 5px 10px;
  border-radius: 8px;
  background: rgba(10,10,10,.42);
  border: 1px solid rgba(255,102,0,.35);
  color: rgba(255,255,255,.88);
  font-weight: 650;
  font-size: .72rem;
  pointer-events: none;
  box-shadow: none;
  max-width: min(88%, 320px);
  text-align: center;
  letter-spacing: .02em;
}
.toast.good { border-color: rgba(62,207,142,.4); color: rgba(184,255,217,.9); }

.collect-score {
  position: absolute;
  z-index: 7;
  pointer-events: none;
  color: #63f09b;
  font-size: .78rem;
  font-weight: 800;
  line-height: 1;
  text-shadow: 0 1px 4px rgba(0,0,0,.8);
  transform: translate(-50%, -65%);
  animation: collectScoreFloat .6s ease-out forwards;
}
@keyframes collectScoreFloat {
  0% { opacity: 0; transform: translate(-50%, -55%) scale(.9); }
  18% { opacity: 1; }
  100% { opacity: 0; transform: translate(-50%, -175%) scale(1); }
}
.toast.bad { border-color: rgba(255,80,80,.45); color: rgba(255,200,200,.92); font-size: .72rem; letter-spacing: .03em; text-transform: uppercase; }
.action-legend { display:flex; flex-wrap:wrap; gap:8px 14px; margin:6px 0 0; font-size:.78rem; color:#bbb; }
.action-legend b { color: var(--orange-hot); }
.flash-bail { animation: bailPulse .35s ease; }
@keyframes bailPulse { from { filter: brightness(1.4) hue-rotate(-20deg);} to { filter:none; } }
.flash-buff { animation: buffPulse .45s ease; }
@keyframes buffPulse { 0%{ box-shadow:0 0 0 0 rgba(255,209,102,.8);} 100%{ box-shadow:0 0 0 18px rgba(255,209,102,0);} }

.flood-overlay {
  position: absolute;
  top: 10px;
  right: 10px;
  z-index: 6;
  padding: 6px 12px;
  border-radius: 10px;
  background: rgba(0,0,0,.72);
  border: 1px solid #3a6a8a;
  color: #9fd9ff;
  font-weight: 800;
  font-size: .9rem;
  pointer-events: none;
  letter-spacing: .02em;
}
.flood-overlay.danger {
  border-color: var(--bad);
  color: #ff8a8a;
  background: rgba(40,0,0,.8);
}
.flood-overlay strong { color: inherit; }

.flash-kyc { animation: kycPulse .5s ease; }
@keyframes kycPulse {
  0% { box-shadow: inset 0 0 0 0 rgba(255,60,60,.0), 0 0 0 0 rgba(255,60,60,.6); filter: brightness(1.2); }
  40% { box-shadow: inset 0 0 60px 8px rgba(255,40,40,.35), 0 0 0 3px rgba(255,80,80,.8); filter: brightness(1.35); }
  100% { box-shadow: inset 0 0 0 0 rgba(255,60,60,0), 0 0 0 0 rgba(255,60,60,0); filter: none; }
}
.toast.bad { border-color: rgba(255,80,80,.45); color: rgba(255,200,200,.92); font-size: .72rem; letter-spacing: .03em; text-transform: uppercase; }

/* ---- Leaderboard / score submit ---- */
.score-submit {
  margin: 8px 0 14px;
  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.primary {
  width: auto;
  flex: 0 0 auto;
  padding: 10px 18px;
  font-size: .9rem;
}
.name-row .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; }

.leaderboard {
  margin: 4px 0 16px;
  text-align: left;
  background: #121212;
  border: 1px solid #2a2a2a;
  border-radius: 14px;
  padding: 12px 14px;
  max-height: 220px;
  overflow-y: auto;
}
.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-level { color: var(--muted); font-size: .78rem; font-variant-numeric: tabular-nums; }
.lb-list li.you { border: 1px solid rgba(255,102,0,.45); background: #1c140a; }
.lb-list li.empty {
  display: block;
  text-align: center;
  color: var(--muted);
  background: transparent;
}
.card.endish .btn.primary#againBtn { margin-top: 4px; }

.lives-overlay {
  position: absolute;
  top: 10px;
  left: 10px;
  z-index: 6;
  padding: 6px 10px;
  border-radius: 10px;
  background: rgba(0,0,0,.72);
  border: 1px solid #663344;
  color: #ff6b8a;
  font-weight: 800;
  font-size: 1rem;
  pointer-events: none;
  letter-spacing: .08em;
}

.again-below { display:block; width:100%; margin-top:10px; }
.leaderboard { margin-top:10px; }
.leaderboard .lb-list, .leaderboard ol { max-height: 110px !important; overflow:auto; }
.card.endish { max-height: min(78vh, 520px); overflow:auto; padding-top:14px; padding-bottom:14px; }
.card.endish .end-card { max-height: 72px; width:auto; margin-bottom:8px; }
.card.endish h2 { font-size:1.15rem; margin:4px 0; }
.card.endish p { margin:4px 0; }

.logo-link { display:inline-flex; line-height:0; border-radius:10px; }
.logo-link:hover { outline:2px solid var(--orange-hot); outline-offset:2px; }
.logo-link.hero { display:inline-block; }

.end-card-link { display:inline-block; line-height:0; }
.end-card-link:hover { outline:2px solid var(--orange-hot); outline-offset:3px; border-radius:8px; }

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

.pause-card { text-align:center; max-width:320px; }
.pause-card h2 { color: var(--orange-hot); margin-bottom:8px; }
.pause-card p { color: var(--muted); margin-bottom:16px; font-size:.9rem; }

.speech-bar {
  display: flex;
  justify-content: space-between;
  align-items: stretch;
  gap: 10px;
  width: 100%;
  max-width: 960px;
  margin: 6px auto 0;
  padding: 0 4px;
  min-height: 48px;
  pointer-events: none;
  box-sizing: border-box;
}
.speech-bar .speech.greta { margin-right: auto; }
.speech-bar .speech.ed { margin-left: auto; }
.speech {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 4px 8px 4px 4px;
  border-radius: 12px;
  background: rgba(0,0,0,.45);
  border: 1px solid rgba(255,255,255,.12);
  animation: speechIn .22s ease;
  max-width: 48%;
}
.speech[hidden] { display: none !important; }
.speech img {
  width: 40px;
  height: 40px;
  border-radius: 10px;
  object-fit: cover;
  flex-shrink: 0;
  border: 1px solid rgba(255,102,0,.55);
  background: #111;
}
.speech.ed img { border-color: rgba(255,209,102,.55); }
.speech-text {
  color: rgba(255,255,255,.78);
  font-size: .78rem;
  font-weight: 600;
  line-height: 1.25;
  text-shadow: 0 1px 2px rgba(0,0,0,.65);
}
@keyframes speechIn {
  from { opacity: 0; transform: translateX(-10px); }
  to { opacity: 1; transform: translateX(0); }
}

.speech-text.dim { opacity: .45; font-weight: 500; }
.speech.speaking { border-color: rgba(255,102,0,.55); background: rgba(0,0,0,.55); }
.speech.ed.speaking { border-color: rgba(255,209,102,.55); }
.speech[hidden] { display: none !important; }

.crew { display: none !important; }

#startOverlay .card {
  padding: 14px 16px 16px;
  max-width: 360px;
}
#startOverlay .logo-hero { width: 56px; height: 56px; margin-bottom: 6px; }
#startOverlay h2 { font-size: 1.15rem; margin: 0 0 6px; }
#startOverlay .fine.compact { font-size: .78rem; line-height: 1.35; margin: 0 0 8px; }
#startOverlay .how.compact { margin: 0 0 12px; padding-left: 1.1em; font-size: .8rem; }
#startOverlay .how.compact li { margin: 0; }
#startOverlay .start-leaderboard {
  margin: 0 0 12px;
  padding: 8px 10px;
  max-height: none;
  overflow: visible;
  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; }
#startOverlay .board-heading span {
  color: var(--muted);
  font-size: .68rem;
}
#startOverlay .start-leaderboard .lb-list { gap: 3px; }
#startOverlay .start-leaderboard .lb-list li {
  grid-template-columns: 22px minmax(0, 1fr) auto 34px;
  gap: 6px;
  padding: 5px 6px;
  font-size: .76rem;
}
#startOverlay .start-leaderboard .lb-list li .lb-level {
  font-size: .68rem;
  text-align: right;
}
#startOverlay .start-leaderboard .lb-list li.empty {
  display: block;
  padding: 5px 2px;
}
