:root { --bg: #070914; --panel: #151a33; --line: #2b3360; --text: #f4f6ff; --muted: #9aa4d6; --gold: #ffd166; --ig: #FF3D8B; --yt: #FF3B30; --tt: #25F4EE; }
* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }
html, body { margin: 0; height: 100%; background: var(--bg); color: var(--text); font: 16px/1.4 system-ui, -apple-system, "Segoe UI", Roboto, sans-serif; overscroll-behavior: none; }
a { color: var(--gold); }
button { font: inherit; color: inherit; cursor: pointer; }
.hidden { display: none !important; }
.screen { min-height: 100%; max-width: 520px; margin: 0 auto; padding: max(16px, env(safe-area-inset-top)) 16px max(20px, env(safe-area-inset-bottom)); }
.brand { text-align: center; padding: 18px 0 8px; background: radial-gradient(circle at 50% 0, #2c2f73 0, transparent 70%); }
.brand h1 { margin: 0; font-size: 46px; letter-spacing: 3px; font-weight: 900; background: linear-gradient(90deg, var(--ig), var(--gold), var(--tt)); -webkit-background-clip: text; background-clip: text; color: transparent; }
.brand p { margin: 4px 0 0; color: var(--muted); }
h2 { margin: 8px 0 12px; }
.card { background: var(--panel); border: 1px solid var(--line); border-radius: 18px; padding: 14px; margin: 12px 0; }
.card h3 { margin: 0 0 8px; font-size: 15px; text-transform: uppercase; letter-spacing: 1px; color: var(--gold); }
.muted { color: var(--muted); font-size: 14px; }
.err { color: #ff8080; min-height: 1.4em; }
.actions { display: grid; gap: 10px; margin: 14px 0; }
.btn { background: linear-gradient(180deg, #ffd166, #f0a830); color: #241500; border: 0; border-radius: 14px; padding: 12px 16px; font-weight: 800; }
.btn.alt { background: #252c55; color: var(--text); border: 1px solid var(--line); }
.btn.big { width: 100%; padding: 16px; font-size: 18px; }
.btn:disabled { opacity: .5; }
.link { background: none; border: 0; color: var(--muted); text-decoration: underline; padding: 8px 0; }
.back { background: none; border: 0; color: var(--muted); padding: 4px 0; font-size: 16px; }
.foot { text-align: center; color: var(--muted); font-size: 13px; margin-top: 24px; }
.field { display: block; margin: 14px 0; font-weight: 700; }
.field input { display: block; width: 100%; margin-top: 6px; padding: 14px; border-radius: 12px; border: 1px solid var(--line); background: #0d1126; color: var(--text); font-size: 18px; }
.check { display: flex; gap: 10px; align-items: flex-start; margin: 10px 0; font-size: 14px; }
.check input { width: 22px; height: 22px; flex: none; margin: 0; }
.ships { display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px; }
.ship { border: 2px solid var(--line); background: #0d1126; border-radius: 14px; padding: 12px 6px; text-align: center; font-weight: 800; }
.ship.on { border-color: currentColor; box-shadow: 0 0 0 2px currentColor inset; }
.ship small { display: block; font-weight: 500; color: var(--muted); font-size: 12px; }
#tsBox { margin: 12px 0; min-height: 65px; }
.code { font: 900 44px/1 ui-monospace, Menlo, monospace; letter-spacing: 3px; text-align: center; padding: 18px; margin: 12px 0; border-radius: 16px; background: #0d1126; border: 2px dashed var(--gold); color: var(--gold); user-select: all; }
.spinner { width: 28px; height: 28px; margin: 14px auto 0; border: 4px solid var(--line); border-top-color: var(--gold); border-radius: 50%; animation: spin 1s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }
.meline { display: flex; gap: 12px; align-items: center; }
.meline .av { width: 72px; flex: none; }
.meline .av svg { width: 72px; height: auto; display: block; }
.xpbar { height: 8px; background: #0d1126; border-radius: 4px; overflow: hidden; margin-top: 6px; }
.xpbar i { display: block; height: 100%; background: var(--gold); }
.mbar { position: relative; height: 26px; background: #0d1126; border-radius: 13px; overflow: hidden; border: 1px solid var(--line); }
.mbar i { position: absolute; inset: 0 auto 0 0; background: linear-gradient(90deg, #25f4ee, #3fa9ff); transition: width .4s; }
.mbar .tick80 { position: absolute; top: 0; bottom: 0; left: 80%; width: 2px; background: #fff6; }
.mbar span { position: relative; display: block; text-align: center; font-weight: 800; font-size: 14px; line-height: 26px; text-shadow: 0 1px 2px #000; }
.lane { display: grid; grid-template-columns: 34px 1fr 64px; align-items: center; gap: 8px; margin: 8px 0; font-weight: 800; font-size: 14px; }
.lane .track { position: relative; height: 12px; border-radius: 6px; background: #0d1126; }
.lane .track i { position: absolute; inset: 0 auto 0 0; border-radius: 6px; }
.lane .track b { position: absolute; top: 50%; width: 18px; height: 18px; margin: -9px 0 0 -9px; border-radius: 50%; border: 2px solid #fff; }
.lane small { color: var(--muted); font-weight: 600; text-align: right; }
.builder .preview { display: flex; justify-content: center; background: radial-gradient(circle, #2b3170, transparent 70%); border-radius: 18px; }
.builder .preview svg { width: 170px; height: auto; }
.tabs { display: flex; gap: 6px; overflow-x: auto; margin: 10px 0; }
.tabs button { flex: none; padding: 8px 14px; border-radius: 20px; border: 1px solid var(--line); background: #0d1126; font-weight: 700; }
.tabs button.on { background: var(--gold); color: #241500; border-color: var(--gold); }
.opts { display: grid; grid-template-columns: repeat(4, 1fr); gap: 8px; }
.opt { position: relative; border: 2px solid var(--line); background: #0d1126; border-radius: 14px; padding: 4px; font-size: 11px; text-align: center; }
.opt svg { width: 100%; height: auto; display: block; }
.opt.on { border-color: var(--gold); }
.opt.locked { opacity: .45; }
.opt .lock { position: absolute; top: 4px; right: 6px; font-size: 14px; }
.opt.job { padding: 14px 4px; font-size: 13px; font-weight: 700; }

/* deck */
#deck { position: fixed; inset: 0; max-width: none; padding: 0; overflow: hidden; touch-action: none; user-select: none; -webkit-user-select: none; }
#stage { position: absolute; inset: 0; }
#stage canvas { display: block; }
.hud-top { position: absolute; left: 0; right: 0; top: 0; padding: max(10px, env(safe-area-inset-top)) 10px 0; display: flex; gap: 8px; align-items: center; pointer-events: none; }
.hud-top > * { pointer-events: auto; }
.icon { width: 44px; height: 44px; flex: none; border-radius: 14px; border: 1px solid var(--line); background: #151a33e6; font-size: 22px; }
.bar { position: relative; flex: 1; height: 44px; background: #0d1126e6; border: 1px solid var(--line); border-radius: 14px; overflow: hidden; }
.bar .fill { position: absolute; inset: 0 auto 0 0; width: 0; background: linear-gradient(90deg, #25f4ee, #3fa9ff); transition: width .35s; }
.bar.crisis .fill { background: linear-gradient(90deg, #ff5d5d, #ffb347); }
.bar .label { position: relative; display: flex; height: 100%; align-items: center; justify-content: center; font-weight: 800; font-size: 13px; text-shadow: 0 1px 2px #000; text-align: center; padding: 0 6px; line-height: 1.15; }
.hud-sub { position: absolute; top: calc(max(10px, env(safe-area-inset-top)) + 50px); left: 10px; right: 10px; text-align: center; font-size: 12px; color: #dfe4ff; text-shadow: 0 1px 2px #000; pointer-events: none; }
.vote { position: absolute; top: calc(max(10px, env(safe-area-inset-top)) + 80px); left: 10px; right: 10px; display: grid; grid-template-columns: 1fr 1fr; gap: 8px; }
.vote p { grid-column: 1 / -1; margin: 0; text-align: center; font-weight: 800; text-shadow: 0 1px 2px #000; }
.work { position: absolute; left: 50%; bottom: calc(max(16px, env(safe-area-inset-bottom)) + 74px); transform: translateX(-50%); width: 64%; max-width: 300px; padding: 18px; border-radius: 22px; border: 0; font-weight: 900; font-size: 18px; color: #241500; background: linear-gradient(180deg, #ffd166, #f0a830); box-shadow: 0 6px 0 #a86d10, 0 10px 24px #0008; touch-action: none; }
.work:active, .work.holding { transform: translateX(-50%) translateY(3px); box-shadow: 0 3px 0 #a86d10; }
.hud-bottom { position: absolute; left: 0; right: 0; bottom: 0; padding: 0 10px max(12px, env(safe-area-inset-bottom)); display: flex; gap: 8px; align-items: center; }
.emotes { flex: 1; display: flex; gap: 6px; overflow-x: auto; }
.emotes button { flex: none; width: 44px; height: 44px; border-radius: 50%; border: 1px solid var(--line); background: #151a33e6; font-size: 22px; }
.conn { position: absolute; left: 50%; top: 45%; transform: translate(-50%, -50%); background: #000a; padding: 10px 16px; border-radius: 12px; pointer-events: none; }
.conn:empty { display: none; }

.sheet { position: fixed; inset: 0; background: #0008; display: flex; align-items: flex-end; justify-content: center; z-index: 10; }
.sheet-body { width: 100%; max-width: 520px; max-height: 86vh; overflow-y: auto; background: var(--panel); border-radius: 22px 22px 0 0; padding: 16px 16px max(18px, env(safe-area-inset-bottom)); border: 1px solid var(--line); }
.sheet-body h3 { margin: 0 0 10px; }
.presets { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; }
.presets button { padding: 12px 8px; border-radius: 12px; border: 1px solid var(--line); background: #0d1126; font-weight: 600; font-size: 14px; }
.freechat { display: flex; gap: 8px; margin-top: 12px; }
.freechat input { flex: 1; padding: 12px; border-radius: 12px; border: 1px solid var(--line); background: #0d1126; color: var(--text); font-size: 16px; }
.cardimg { display: block; width: 100%; max-width: 300px; margin: 0 auto 12px; border-radius: 14px; aspect-ratio: 9 / 16; background: #0d1126; object-fit: cover; }
.row { display: flex; gap: 8px; }
.row > * { flex: 1; }
.toast { position: fixed; left: 50%; bottom: 120px; transform: translateX(-50%) translateY(20px); opacity: 0; background: #000d; border: 1px solid var(--line); padding: 10px 16px; border-radius: 14px; transition: .25s; pointer-events: none; z-index: 20; max-width: 90vw; text-align: center; }
.toast.on { opacity: 1; transform: translateX(-50%); }
table.race { width: 100%; border-collapse: collapse; font-size: 14px; }
table.race td, table.race th { padding: 6px 4px; border-bottom: 1px solid var(--line); text-align: left; }

/* [S1-v2] gear */
.drop { border-color: var(--gold); background: linear-gradient(135deg, #2a1f55, #151a33); }
.drop h3 { color: var(--gold); }
.lane > b { font-weight: 700; }
/* companion animation hooks from @illustrator's art (HTML previews; the deck uses still images) */
@media (prefers-reduced-motion: no-preference) {
  .preview svg .hover, .meline svg .hover { animation: gear-bob 2.4s ease-in-out infinite; }
  .preview svg .rotor { transform-box: fill-box; transform-origin: center; animation: gear-rotor .25s linear infinite alternate; }
  .preview svg .blink { animation: gear-blink 4s infinite; }
  .preview svg .key { transform-box: fill-box; transform-origin: center; animation: gear-spin 3s linear infinite; }
  .preview svg .spark { animation: gear-flicker .6s steps(2) infinite; }
  .preview svg .prism { animation: gear-prism 6s linear infinite; }
}
@keyframes gear-bob { 50% { transform: translateY(-2px); } }
@keyframes gear-rotor { to { transform: scaleX(.35); } }
@keyframes gear-blink { 0%, 92%, 100% { opacity: 1; } 95% { opacity: 0; } }
@keyframes gear-spin { to { transform: rotate(360deg); } }
@keyframes gear-flicker { 50% { opacity: .35; } }
@keyframes gear-prism { to { filter: hue-rotate(360deg); } }
