:root {
  --ink: #e9f1ff;
  --muted: #9fb0cc;
  --panel: rgba(9, 13, 24, 0.82);
  --line: rgba(134, 217, 255, 0.28);
  --cy: #86d9ff;
  --pink: #ff7ab6;
  --good: #6dffa6;
  --bad: #ff5d7c;
  --gold: #ffe28a;
  --head: "Orbitron", "Segoe UI", system-ui, sans-serif;
  --body: "Exo 2", "Segoe UI", system-ui, sans-serif;
}
* { box-sizing: border-box; }
html, body { margin: 0; height: 100%; background: #04060c; color: var(--ink); font-family: var(--body); overflow: hidden; overscroll-behavior: none; }
body { -webkit-user-select: none; user-select: none; -webkit-tap-highlight-color: transparent; }
#app { position: fixed; inset: 0; }
#cv { position: absolute; inset: 0; width: 100%; height: 100%; display: block; touch-action: none; }
body.playing #cv { cursor: none; }

/* ---------- overlay screens */
.ui { position: absolute; inset: 0; display: flex; align-items: center; justify-content: center; padding: max(16px, env(safe-area-inset-top)) max(16px, env(safe-area-inset-right)) max(16px, env(safe-area-inset-bottom)) max(16px, env(safe-area-inset-left)); overflow-y: auto; background: radial-gradient(ellipse at center, rgba(4,6,12,0.25), rgba(4,6,12,0.7)); }
.ui[hidden] { display: none; }
.panel { width: min(560px, 100%); max-height: 100%; overflow-y: auto; background: var(--panel); border: 1px solid var(--line); border-radius: 18px; padding: 26px 28px; box-shadow: 0 20px 60px rgba(0,0,0,0.5), inset 0 1px 0 rgba(255,255,255,0.06); backdrop-filter: blur(8px); -webkit-backdrop-filter: blur(8px); animation: rise 0.35s ease-out; }
.panel.wide { width: min(860px, 100%); }
.panel.small { width: min(420px, 100%); text-align: center; }
@keyframes rise { from { opacity: 0; transform: translateY(14px); } to { opacity: 1; transform: none; } }
.kicker { font: 700 12px/1.2 var(--head); letter-spacing: 0.18em; color: var(--cy); margin-bottom: 6px; }
.kicker.good { color: var(--good); } .kicker.bad { color: var(--bad); }
h1, h2, h3 { font-family: var(--head); margin: 0 0 12px; letter-spacing: 0.04em; }
h2 { font-size: clamp(22px, 4vw, 30px); }
h2.big { font-size: clamp(34px, 7vw, 52px); color: var(--gold); }
h3 { font-size: 14px; color: var(--cy); margin-top: 16px; }
p { line-height: 1.5; margin: 0 0 10px; }
.muted { color: var(--muted); } .small { font-size: 13px; }
.good { color: var(--good); } .cy { color: var(--cy); }

/* title */
.title { text-align: center; width: min(500px, 100%); }
.logo { font-size: clamp(40px, 9vw, 68px); line-height: 0.95; margin: 4px 0 12px; font-weight: 900; display: flex; flex-direction: column; align-items: center; }
.logo span { background: linear-gradient(180deg, #ffffff, #9fdcff 60%, #4aa8ff); -webkit-background-clip: text; background-clip: text; color: transparent; filter: drop-shadow(0 0 18px rgba(80,180,255,0.45)); }
.logo .b { background: linear-gradient(180deg, #ffe0ef, #ff8fc4 60%, #ff4f9a); -webkit-background-clip: text; background-clip: text; filter: drop-shadow(0 0 18px rgba(255,90,160,0.45)); letter-spacing: 0.12em; }
.tag { color: var(--muted); margin-bottom: 18px; }
.note { color: var(--muted); font-size: 13px; margin-top: 8px; }
.hint-rotate { display: none; color: var(--gold); font-size: 13px; }
@media (orientation: portrait) and (pointer: coarse) { .hint-rotate { display: block; } }

/* buttons */
.menu { display: flex; flex-direction: column; gap: 10px; margin-top: 14px; }
.menu.row { flex-direction: row; flex-wrap: wrap; justify-content: center; }
.menu.row button { flex: 1 1 160px; }
.menu.grid2 { display: grid; grid-template-columns: 1fr 1fr; }
button { font: 600 16px var(--body); color: var(--ink); background: rgba(255,255,255,0.06); border: 1px solid rgba(255,255,255,0.14); border-radius: 12px; padding: 12px 16px; cursor: pointer; transition: transform 0.08s, background 0.15s, border-color 0.15s; min-height: 46px; }
button:hover:not([disabled]) { background: rgba(134,217,255,0.12); border-color: rgba(134,217,255,0.5); }
button:focus-visible { outline: 3px solid var(--gold); outline-offset: 2px; }
button:active:not([disabled]) { transform: scale(0.98); }
button.primary { background: linear-gradient(180deg, #4cc3ff, #1f7fd6); border-color: #7fd6ff; color: #fff; font-weight: 700; box-shadow: 0 6px 22px rgba(40,150,255,0.35); }
button.primary:hover { background: linear-gradient(180deg, #6fd0ff, #2b8fe6); }
button.danger { border-color: rgba(255,93,124,0.5); color: #ffb3c2; }
button[disabled] { opacity: 0.4; cursor: not-allowed; }
.diff { display: flex; gap: 6px; justify-content: center; margin-top: 18px; }
.diff button { flex: 1; padding: 9px 8px; min-height: 40px; font-size: 14px; }
.diff button.sel, .tog.sel, .skin.sel { border-color: var(--gold); background: rgba(255,226,138,0.12); }

/* story / radio */
.story p { font-size: 17px; min-height: 1.5em; }
.radio { background: rgba(255,122,182,0.07); border: 1px solid rgba(255,122,182,0.35); border-radius: 12px; padding: 12px 14px; margin: 14px 0; }
.radio.ctl { background: rgba(134,217,255,0.06); border-color: rgba(134,217,255,0.3); }
.radio .who { font: 700 11px var(--head); letter-spacing: 0.14em; color: var(--pink); margin-bottom: 6px; }
.radio.ctl .who { color: var(--cy); }
.radio p { margin: 0; min-height: 3em; font-size: 16px; }
.tip { font-size: 14px; color: var(--gold); }
.runline { text-align: center; color: var(--muted); margin: 10px 0 4px; }
.runline b { color: var(--ink); }
.unlock { text-align: center; padding: 10px; border-radius: 10px; background: rgba(255,226,138,0.1); border: 1px solid rgba(255,226,138,0.4); margin: 10px 0; }

/* depth meter */
.depth { margin: 14px 0 6px; }
.depth .track { position: relative; height: 12px; border-radius: 6px; background: rgba(255,255,255,0.08); display: flex; justify-content: space-between; align-items: center; padding: 0 3px; overflow: hidden; }
.depth .fill { position: absolute; left: 0; top: 0; bottom: 0; background: linear-gradient(90deg, #2b8fe6, #ff7ab6); border-radius: 6px; transition: width 0.8s ease; }
.depth i { position: relative; width: 3px; height: 6px; background: rgba(255,255,255,0.25); border-radius: 1px; }
.depth i.on { background: rgba(255,255,255,0.85); }
.depth .ends { display: flex; justify-content: space-between; font-size: 12px; color: var(--muted); margin-top: 6px; align-items: center; }
.depth .ends b { color: var(--pink); }
.depth .heart { color: var(--pink); font-size: 16px; }

/* tables */
.tally { width: 100%; border-collapse: collapse; margin: 10px 0; font-size: 15px; }
.tally td { padding: 5px 2px; border-bottom: 1px solid rgba(255,255,255,0.07); }
.tally td:last-child { text-align: right; font-family: var(--head); font-size: 14px; }
.tally tr.zero td { color: var(--muted); }
.tally tr.tot td { color: var(--gold); font-weight: 700; border-bottom: 0; }
.scores { width: 100%; border-collapse: collapse; font-size: 15px; margin-bottom: 10px; }
.scores th { text-align: left; color: var(--muted); font-weight: 600; font-size: 12px; padding: 4px; }
.scores td { padding: 7px 4px; border-top: 1px solid rgba(255,255,255,0.07); }
.scores td:nth-child(3) { font-family: var(--head); color: var(--gold); }
.scores tr.me td { background: rgba(255,226,138,0.12); }

/* name entry */
.namebox { margin: 14px 0; }
.namebox label { display: block; color: var(--gold); margin-bottom: 8px; font-weight: 700; }
.namebox .row { display: flex; gap: 8px; }
.namebox input { flex: 1; min-width: 0; font: 700 18px var(--head); letter-spacing: 0.06em; color: var(--ink); background: rgba(0,0,0,0.35); border: 1px solid var(--line); border-radius: 10px; padding: 10px 12px; -webkit-user-select: text; user-select: text; }
.namebox input:focus { outline: 2px solid var(--gold); }

/* missions grid */
.mgrid { display: grid; grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); gap: 8px; }
.mcard { display: flex; flex-direction: column; align-items: flex-start; text-align: left; gap: 2px; padding: 10px 12px; }
.mcard .n { font: 900 18px var(--head); color: var(--cy); }
.mcard .nm { font-size: 14px; }
.mcard .st { font-size: 12px; color: var(--gold); min-height: 1em; }

/* how-to */
.cols { display: grid; grid-template-columns: repeat(auto-fit, minmax(220px, 1fr)); gap: 6px 22px; }
.cols p { font-size: 14px; }
kbd { display: inline-block; min-width: 24px; padding: 1px 6px; margin: 0 2px 2px 0; font: 700 12px var(--head); color: var(--ink); background: rgba(255,255,255,0.08); border: 1px solid rgba(255,255,255,0.2); border-bottom-width: 3px; border-radius: 6px; text-align: center; }

/* settings */
.slider { display: flex; align-items: center; gap: 12px; margin: 6px 0 10px; }
.slider input { flex: 1; accent-color: var(--cy); }
.skins { display: flex; flex-wrap: wrap; gap: 8px; }
.skin { display: flex; align-items: center; gap: 8px; padding: 8px 12px; font-size: 14px; min-height: 40px; }
.skin .sw { width: 18px; height: 18px; border-radius: 50%; border: 3px solid; }

/* ---------- touch controls */
.touch { position: absolute; inset: auto 0 0 0; height: 46%; pointer-events: auto; touch-action: none; }
.touch[hidden] { display: none; }
.touch .tl, .touch .tr { position: absolute; bottom: max(16px, env(safe-area-inset-bottom)); display: flex; gap: 12px; align-items: flex-end; }
.touch .tl { left: max(16px, env(safe-area-inset-left)); }
.touch .tr { right: max(16px, env(safe-area-inset-right)); }
.tb { width: 76px; height: 76px; border-radius: 50%; padding: 0; font: 700 22px var(--head); color: rgba(255,255,255,0.85); background: rgba(255,255,255,0.08); border: 2px solid rgba(255,255,255,0.25); touch-action: none; min-height: 0; }
.tb.sm { width: 62px; height: 62px; font-size: 10px; letter-spacing: 0.05em; margin-bottom: 30px; }
.tb.big { width: 96px; height: 96px; font-size: 12px; background: rgba(76,195,255,0.14); border-color: rgba(134,217,255,0.55); }
.tb.on { background: rgba(134,217,255,0.4); border-color: #fff; transform: scale(0.95); }
.pausebtn { position: absolute; top: max(10px, env(safe-area-inset-top)); left: 50%; transform: translateX(-50%); margin-top: 52px; width: 40px; height: 34px; min-height: 0; padding: 0; font: 900 13px var(--head); background: rgba(0,0,0,0.3); border-radius: 8px; opacity: 0.7; }
.pausebtn[hidden] { display: none; }
@media (pointer: fine) { .pausebtn { opacity: 0.35; } .pausebtn:hover { opacity: 1; } }
@media (max-height: 420px) { .tb { width: 64px; height: 64px; } .tb.big { width: 80px; height: 80px; } .tb.sm { width: 54px; height: 54px; margin-bottom: 22px; } .panel { padding: 18px 20px; } }
