:root {
  --ink: #f7f2e7; --muted: #c9c2d9; --dim: #7d72b5;
  --gold: #ffc866; --ember: #ff8a3d; --cyan: #35e0e6; --violet: #8b7fd4;
  --panel: rgba(11, 16, 38, 0.82); --line: rgba(139, 127, 212, 0.28);
  --safe-t: env(safe-area-inset-top, 0px); --safe-b: env(safe-area-inset-bottom, 0px);
}
* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }
html, body { margin: 0; height: 100%; overflow: hidden; background: #0b1026; color: var(--ink);
  font-family: ui-rounded, "SF Pro Rounded", "Segoe UI", system-ui, -apple-system, Roboto, sans-serif;
  -webkit-user-select: none; user-select: none; touch-action: none; overscroll-behavior: none; }
canvas#game { position: fixed; inset: 0; display: block; }
.hidden { display: none !important; }

.screen { position: fixed; inset: 0; display: flex; flex-direction: column; align-items: center; justify-content: center;
  padding: calc(24px + var(--safe-t)) 16px calc(24px + var(--safe-b)); gap: 14px; text-align: center;
  background: radial-gradient(ellipse at 50% 40%, rgba(11,16,38,0.15), rgba(11,16,38,0.7) 75%); animation: fade .35s ease both; overflow-y: auto; }
@keyframes fade { from { opacity: 0; transform: translateY(6px); } to { opacity: 1; transform: none; } }

.logo-lantern { width: 64px; height: 80px; filter: drop-shadow(0 0 24px rgba(255,170,80,.75)); animation: bob 3.2s ease-in-out infinite; }
@keyframes bob { 50% { transform: translateY(-6px) rotate(2deg); } }
h1 { margin: 0; font-size: clamp(44px, 12vw, 76px); font-weight: 800; letter-spacing: 0.04em; line-height: 1;
  background: linear-gradient(180deg, #fff6dc 0%, var(--gold) 55%, var(--ember) 100%); -webkit-background-clip: text; background-clip: text; color: transparent;
  filter: drop-shadow(0 4px 30px rgba(255,150,60,.35)); }
h2 { margin: 0 0 8px; font-size: 26px; color: var(--gold); letter-spacing: .02em; }
.tag { margin: 0 0 8px; color: var(--muted); font-size: 16px; }
.fine { margin: 6px 0 0; color: var(--dim); font-size: 13px; }

.menu { display: flex; flex-direction: column; gap: 10px; width: min(360px, 100%); }
button { font: inherit; color: var(--ink); background: rgba(37, 26, 92, 0.72); border: 1px solid var(--line); border-radius: 16px;
  padding: 12px 16px; cursor: pointer; transition: transform .12s ease, background .2s ease, border-color .2s ease; min-height: 44px; }
button:hover { border-color: rgba(197,155,255,.55); background: rgba(52, 38, 124, 0.82); }
button:active { transform: scale(.97); }
button:focus-visible, select:focus-visible, input:focus-visible { outline: 2px solid var(--violet); outline-offset: 2px; }
button.big { display: flex; flex-direction: column; align-items: center; font-size: 19px; font-weight: 700; padding: 14px 16px; backdrop-filter: blur(6px); }
button.big small { font-size: 12.5px; font-weight: 500; color: var(--muted); margin-top: 3px; }
button.primary { background: linear-gradient(180deg, #ffcf70, #ff8a3d); color: #2a1206; border: none; box-shadow: 0 8px 30px rgba(255,138,61,.35); }
button.primary small { color: #5b2a0d; }
button.hot { background: linear-gradient(180deg, #8b7fd4, #5b4a9e); color: #f7f2e7; border: none; box-shadow: 0 8px 30px rgba(139,127,212,.35); }
button.hot small { color: #d9d2f2; }
button.ghostbtn { background: transparent; border-color: transparent; color: var(--muted); }
button.ghostbtn:hover { color: var(--ink); border-color: var(--line); }
.row { display: flex; gap: 8px; flex-wrap: wrap; justify-content: center; }
.row button { flex: 1 1 auto; font-size: 14.5px; }
.banner { background: rgba(139, 127, 212, .16); border: 1px solid rgba(139,127,212,.45); color: #f7f2e7; padding: 10px 14px; border-radius: 12px; max-width: 360px; font-size: 14.5px; }

.panel { background: var(--panel); border: 1px solid var(--line); border-radius: 22px; padding: 22px 18px; width: min(400px, 100%);
  display: flex; flex-direction: column; gap: 10px; backdrop-filter: blur(10px); box-shadow: 0 20px 60px rgba(0,0,0,.45); }
.panel.wide { width: min(560px, 100%); }
.card .eyebrow { margin: 0; color: var(--violet); font-size: 13px; letter-spacing: .14em; text-transform: uppercase; }
.card .score { margin: 0; font-size: clamp(54px, 16vw, 78px); font-weight: 800; line-height: 1; color: #fff; text-shadow: 0 0 30px rgba(255,200,110,.45); font-variant-numeric: tabular-nums; }
.meta { margin: 0; color: var(--muted); font-size: 14.5px; }
.bands { margin: 2px 0; font-size: 20px; letter-spacing: 1px; line-height: 1.2; word-break: break-all; }
.vs { margin: 0; color: var(--gold); font-weight: 600; }
.best { margin: 0; color: var(--gold); font-weight: 600; font-size: 14.5px; }
.star { margin: 0; color: #ffe9b8; font-size: 14px; min-height: 1em; }
#skyCanvas { width: 100%; aspect-ratio: 4 / 3; border-radius: 14px; border: 1px solid var(--line); }
.how { text-align: left; margin: 0; padding-left: 20px; color: var(--muted); line-height: 1.5; font-size: 15px; }
.how li { margin-bottom: 8px; } .how b { color: var(--ink); }
.opt { display: flex; align-items: center; justify-content: space-between; gap: 12px; padding: 8px 4px; border-bottom: 1px solid rgba(197,155,255,.1); font-size: 15.5px; text-align: left; }
.opt input[type=checkbox] { width: 22px; height: 22px; accent-color: var(--ember); }
.opt select, .opt input[type=text] { font: inherit; font-size: 14.5px; color: var(--ink); background: rgba(37,26,92,.8); border: 1px solid var(--line); border-radius: 10px; padding: 6px 8px; max-width: 160px; user-select: text; -webkit-user-select: text; }

#hud { position: fixed; inset: 0; pointer-events: none; padding: calc(12px + var(--safe-t)) 16px 0; display: grid; grid-template-columns: 1fr auto 1fr; align-items: start; font-variant-numeric: tabular-nums; }
.hud-l { display: flex; flex-direction: column; gap: 2px; font-size: 15px; color: var(--muted); }
#hudGhost { font-size: 12px; color: var(--muted); letter-spacing: .04em; }
#hudGhost.ghosting { color: var(--cyan); }
.hud-c { font-size: 34px; font-weight: 800; color: #fff; text-shadow: 0 2px 18px rgba(0,0,0,.6); }
.hud-r { justify-self: end; font-size: 24px; font-weight: 800; transition: transform .15s ease; }
.hud-r.hot { transform: scale(1.18); }
.coach { grid-column: 1 / -1; justify-self: center; margin-top: 18vh; max-width: 320px; font-size: 17px; font-weight: 600; color: #fff4d6;
  background: rgba(14,10,38,.7); border: 1px solid var(--line); padding: 10px 16px; border-radius: 14px; }
.coach.pop { animation: pop .45s ease both; }
@keyframes pop { from { opacity: 0; transform: translateY(8px) scale(.96); } to { opacity: 1; transform: none; } }

#toast { position: fixed; left: 50%; bottom: calc(28px + var(--safe-b)); transform: translate(-50%, 20px); opacity: 0; background: rgba(14,10,38,.92);
  border: 1px solid var(--line); color: var(--ink); padding: 10px 16px; border-radius: 12px; font-size: 14.5px; transition: all .25s ease; pointer-events: none; max-width: calc(100% - 32px); }
#toast.on { opacity: 1; transform: translate(-50%, 0); }

@media (prefers-reduced-motion: reduce) { .screen, .coach.pop, .logo-lantern { animation: none; } }
@media (max-height: 560px) { .logo { display: none; } h1 { font-size: 40px; } .tag { display: none; } button.big { padding: 10px 14px; } }
.gate { position: fixed; left: 50%; bottom: calc(14vh + var(--safe-b)); transform: translateX(-50%); font-size: 20px; font-weight: 700; color: #fff4d6;
  padding: 12px 22px; border-radius: 999px; background: rgba(14,10,38,.7); border: 1px solid rgba(255,200,110,.45); animation: breathe 1.6s ease-in-out infinite; white-space: nowrap; }
@keyframes breathe { 50% { opacity: .55; } }
@media (prefers-reduced-motion: reduce) { .gate { animation: none; } }
