@font-face { font-family: 'Tilt Neon'; src: url('fonts/tiltneon-latin.woff2') format('woff2'); font-display: swap; }
@font-face { font-family: 'Rajdhani'; src: url('fonts/rajdhani-500-latin.woff2') format('woff2'); font-weight: 500; font-display: swap; }
@font-face { font-family: 'Rajdhani'; src: url('fonts/rajdhani-600-latin.woff2') format('woff2'); font-weight: 600; font-display: swap; }
@font-face { font-family: 'Rajdhani'; src: url('fonts/rajdhani-700-latin.woff2') format('woff2'); font-weight: 700; font-display: swap; }

:root {
  --cyan: #2ef2ff;
  --magenta: #ff3df0;
  --ink: #eef1ff;
  --mute: rgba(230, 235, 255, 0.62);
  --glass: rgba(14, 10, 30, 0.88);
  --line: rgba(160, 170, 255, 0.2);
  --sat: env(safe-area-inset-top, 0px);
  --sab: env(safe-area-inset-bottom, 0px);
  --neon: 'Tilt Neon', 'Rajdhani', system-ui, sans-serif;
  --ui: 'Rajdhani', system-ui, -apple-system, sans-serif;
}

* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }
html, body { margin: 0; height: 100%; }
body { background: #04030b; color: var(--ink); font: 500 17px/1.4 var(--ui); overflow: hidden; overscroll-behavior: none; user-select: none; -webkit-user-select: none; -webkit-touch-callout: none; }
[hidden] { display: none !important; }
button { font: inherit; color: inherit; cursor: pointer; }

#table { position: fixed; inset: 0; width: 100%; height: 100%; touch-action: none; display: block; }

.pause {
  position: fixed; z-index: 10; left: calc(env(safe-area-inset-left, 0px) + 6px); top: 50%; transform: translateY(-50%);
  width: 44px; height: 44px; border-radius: 50%; display: grid; place-items: center;
  background: rgba(10, 8, 24, 0.7); border: 1px solid var(--line);
}
.pause svg { width: 20px; height: 20px; fill: var(--ink); }

/* ---------- home ---------- */
.home {
  position: fixed; inset: 0; z-index: 5; display: flex; flex-direction: column; justify-content: space-between; align-items: center;
  padding: calc(var(--sat) + 40px) 18px calc(var(--sab) + 22px);
  background: radial-gradient(120% 70% at 50% 40%, rgba(4, 3, 11, 0.25), rgba(4, 3, 11, 0.8));
}
.brand { text-align: center; }
.logo { margin: 0; font: 400 clamp(64px, 20vw, 120px)/0.9 var(--neon); letter-spacing: 0.02em; text-transform: uppercase; }
.logo span { display: block; }
.l1 { color: #e9fdff; text-shadow: 0 0 6px var(--cyan), 0 0 18px var(--cyan), 0 0 42px var(--cyan); animation: flicker 5s infinite; }
.l2 { color: #ffe9fd; text-shadow: 0 0 6px var(--magenta), 0 0 18px var(--magenta), 0 0 42px var(--magenta); animation: flicker 6.5s 1.3s infinite; }
@keyframes flicker { 0%, 18%, 20%, 52%, 54%, 100% { opacity: 1; } 19%, 53% { opacity: 0.45; } }
.tagline { margin: 14px 0 0; color: var(--mute); letter-spacing: 0.12em; text-transform: uppercase; font-size: 14px; font-weight: 600; }
.menu { width: min(100%, 420px); display: flex; flex-direction: column; gap: 12px; }

.btn {
  min-height: 48px; padding: 10px 18px; border-radius: 14px; border: 1px solid var(--line);
  background: rgba(20, 16, 44, 0.75); font-weight: 700; letter-spacing: 0.04em; text-transform: uppercase;
  transition: transform 0.1s ease, box-shadow 0.2s;
}
.btn:active { transform: scale(0.97); }
.btn.big { min-height: 72px; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 2px; }
.btn.big b { font: 400 26px/1 var(--neon); letter-spacing: 0.05em; }
.btn.big small { font-weight: 600; font-size: 13px; color: var(--mute); text-transform: none; letter-spacing: 0.02em; }
.btn.cyan { border-color: rgba(46, 242, 255, 0.7); box-shadow: 0 0 18px rgba(46, 242, 255, 0.35), inset 0 0 18px rgba(46, 242, 255, 0.15); }
.btn.cyan b, .btn.cyan:not(.big) { color: #dffcff; text-shadow: 0 0 10px var(--cyan); }
.btn.magenta { border-color: rgba(255, 61, 240, 0.7); box-shadow: 0 0 18px rgba(255, 61, 240, 0.3), inset 0 0 18px rgba(255, 61, 240, 0.12); }
.btn.magenta b { color: #ffe2fc; text-shadow: 0 0 10px var(--magenta); }
.btn.ghost { background: transparent; border-color: transparent; color: var(--mute); }
.btn.small { min-height: 36px; padding: 4px 12px; font-size: 13px; }

.levels { display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px; }
.lvl { min-height: 44px; border-radius: 12px; border: 1px solid var(--line); background: rgba(20, 16, 44, 0.6); font-weight: 700; letter-spacing: 0.06em; text-transform: uppercase; font-size: 14px; }
.lvl[aria-checked='true'] { border-color: var(--magenta); color: #ffe2fc; box-shadow: 0 0 12px rgba(255, 61, 240, 0.35); }
.modes { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; }
.mode { min-height: 44px; border-radius: 12px; border: 1px solid var(--line); background: rgba(20, 16, 44, 0.6); font-weight: 700; letter-spacing: 0.06em; text-transform: uppercase; font-size: 14px; }
.mode[aria-checked='true'] { border-color: var(--cyan); color: #dffcff; box-shadow: 0 0 12px rgba(46, 242, 255, 0.35); }
.picks { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; }
.pick { min-height: 54px; border-radius: 12px; border: 1px solid var(--line); background: rgba(20, 16, 44, 0.6); display: flex; flex-direction: column; align-items: flex-start; justify-content: center; padding: 6px 14px; text-align: left; position: relative; }
.pick::after { content: '›'; position: absolute; right: 12px; top: 50%; transform: translateY(-52%); font-size: 26px; color: var(--mute); }
.pick small { color: var(--mute); font-weight: 600; font-size: 12px; letter-spacing: 0.08em; text-transform: uppercase; }
.pick b { font: 400 19px/1.1 var(--neon); color: #fff; }
.pick .new { position: absolute; top: -7px; right: 8px; padding: 1px 7px; border-radius: 999px; background: #78ffaa; color: #04030b; font-size: 11px; font-weight: 700; letter-spacing: 0.06em; }
.links { display: flex; justify-content: space-around; }
.links button { background: none; border: 0; min-height: 44px; color: var(--mute); font-weight: 600; letter-spacing: 0.04em; }
.ver { opacity: 0.7; }

/* ---------- sheets ---------- */
.scrim { position: fixed; inset: 0; z-index: 20; background: rgba(2, 1, 8, 0.55); }
.sheet {
  position: fixed; z-index: 21; left: 50%; top: 50%; transform: translate(-50%, -50%);
  width: min(calc(100% - 28px), 460px); max-height: calc(100% - 40px); overflow: auto;
  padding: 22px 20px 18px; border-radius: 22px; background: var(--glass); border: 1px solid var(--line);
  -webkit-backdrop-filter: blur(16px); backdrop-filter: blur(16px);
  box-shadow: 0 0 40px rgba(120, 80, 255, 0.25);
  animation: pop 0.28s cubic-bezier(.2, 1.4, .4, 1) both;
}
@keyframes pop { from { opacity: 0; transform: translate(-50%, -50%) scale(0.92); } }
.sheet h2 { margin: 0 0 12px; font: 400 32px/1.05 var(--neon); text-align: center; }
.sheet h3 { margin: 18px 0 8px; font-size: 16px; color: var(--mute); text-transform: uppercase; letter-spacing: 0.08em; }
.actions { display: flex; flex-direction: column; gap: 10px; margin-top: 16px; }
.actions.row { flex-direction: row; }
.actions.row .btn { flex: 1; }
.muted { color: var(--mute); }

.over { text-align: center; }
.over-top { margin: 0 0 6px; transform: rotate(180deg); font: 400 22px var(--neon); opacity: 0.85; }
.over-score { margin: 0; font: 400 46px/1.1 var(--neon); }
.over-note { margin: 6px 0 0; color: var(--mute); }
.over-sparks { margin: 10px 0 0; font-weight: 700; color: #ffe27a; letter-spacing: 0.04em; }
.over-unlock { margin: 12px 0 0; padding: 10px 12px; border-radius: 14px; border: 1px solid rgba(120, 255, 170, 0.7); background: rgba(120, 255, 170, 0.08); box-shadow: 0 0 18px rgba(120, 255, 170, 0.25); color: #d8ffe6; font-weight: 600; }
.over-unlock b { display: block; font: 400 22px var(--neon); color: #78ffaa; }

/* ---------- table and puck picker ---------- */
.pick-sheet { width: min(calc(100% - 20px), 520px); }
.pick-sheet .actions { position: sticky; bottom: -18px; margin: 12px -20px -18px; padding: 14px 20px 16px; background: linear-gradient(rgba(14, 10, 30, 0), rgba(14, 10, 30, 0.97) 35%); }
.pick-sparks { margin: -4px 0 12px; text-align: center; color: #ffe27a; font-weight: 700; }
.pick-list { display: flex; flex-direction: column; gap: 10px; }
.card { display: grid; grid-template-columns: 76px 1fr; gap: 12px; align-items: center; padding: 10px; border-radius: 16px; border: 1px solid var(--line); background: rgba(20, 16, 44, 0.6); text-align: left; width: 100%; }
.card canvas { width: 76px; height: 108px; border-radius: 10px; background: #070614; }
.card.puck canvas { height: 76px; }
.card h4 { margin: 0; font: 400 21px/1.15 var(--neon); color: #fff; }
.card p { margin: 3px 0 0; font-size: 14px; color: var(--mute); line-height: 1.3; }
.card .chips { display: flex; flex-wrap: wrap; gap: 4px; margin-top: 6px; }
.card .chips span { padding: 1px 8px; border-radius: 999px; border: 1px solid rgba(160, 170, 255, 0.35); font-size: 12px; font-weight: 600; color: #cfd6ff; }
.card[aria-checked='true'] { border-color: var(--cyan); box-shadow: 0 0 16px rgba(46, 242, 255, 0.35), inset 0 0 14px rgba(46, 242, 255, 0.1); }
.card.locked { opacity: 0.55; }
.card.locked h4::after { content: ' 🔒'; font-size: 15px; }
.card .need { color: #ffe27a; font-weight: 700; }

/* Measures the safe areas for the canvas, which cannot read env() itself. */
.insets { position: fixed; left: 0; top: 0; width: 0; height: 0; visibility: hidden; padding-top: env(safe-area-inset-top, 0px); padding-bottom: env(safe-area-inset-bottom, 0px); }

@media (max-height: 740px) {
  .home { padding-top: calc(var(--sat) + 18px); }
  .logo { font-size: clamp(50px, 15vw, 90px); }
  .tagline { margin-top: 8px; font-size: 12px; }
  .menu { gap: 9px; }
  .btn.big { min-height: 60px; }
}

.help { margin: 0; padding-left: 20px; display: flex; flex-direction: column; gap: 10px; color: var(--mute); }
.help b { color: var(--ink); }

.seg-row { display: flex; align-items: center; justify-content: space-between; padding: 10px 0; border-bottom: 1px solid var(--line); }
.seg-row.stack > span { display: flex; flex-direction: column; font-weight: 600; gap: 2px; padding-right: 10px; }
.seg-row.stack small { font-size: 13px; font-weight: 500; }
.seg { display: flex; gap: 6px; }
.seg button { min-width: 48px; min-height: 40px; border-radius: 10px; border: 1px solid var(--line); background: transparent; font-weight: 700; }
.seg button[aria-checked='true'] { border-color: var(--cyan); box-shadow: 0 0 10px rgba(46, 242, 255, 0.35); }
.toggle { display: flex; align-items: center; justify-content: space-between; gap: 10px; padding: 12px 0; border-bottom: 1px solid var(--line); cursor: pointer; }
.toggle span { display: flex; flex-direction: column; font-weight: 600; }
.toggle small { color: var(--mute); font-weight: 500; font-size: 13px; }
.toggle input { position: absolute; opacity: 0; pointer-events: none; }
.toggle i { flex: none; width: 50px; height: 30px; border-radius: 999px; background: rgba(255, 255, 255, 0.14); position: relative; transition: background 0.2s; }
.toggle i::after { content: ''; position: absolute; top: 3px; left: 3px; width: 24px; height: 24px; border-radius: 50%; background: #fff; transition: transform 0.2s; }
.toggle input:checked + i { background: var(--cyan); box-shadow: 0 0 12px rgba(46, 242, 255, 0.5); }
.toggle input:checked + i::after { transform: translateX(20px); }

.ver-box { padding: 12px; border-radius: 14px; background: rgba(255, 255, 255, 0.04); display: flex; flex-direction: column; gap: 8px; }
.upd { display: flex; align-items: center; justify-content: space-between; gap: 10px; }
.changelog { display: flex; flex-direction: column; gap: 10px; font-size: 15px; color: var(--mute); }
.changelog h4 { margin: 0; color: var(--ink); font-size: 15px; }
.changelog ul { margin: 2px 0 0; padding-left: 18px; }
.about-links { display: flex; gap: 18px; margin: 16px 0 0; }
.about-links a { color: var(--cyan); text-decoration: none; }

.toast {
  position: fixed; z-index: 30; left: 50%; bottom: calc(var(--sab) + 20px); transform: translateX(-50%);
  padding: 10px 16px; border-radius: 14px; background: var(--glass); border: 1px solid var(--line); font-weight: 600; pointer-events: none;
}
button:focus-visible { outline: 2px solid var(--cyan); outline-offset: 2px; }
@media (prefers-reduced-motion: reduce) { *, *::before, *::after { animation: none !important; transition: none !important; } }

/* ==========================================================================
   Joined phones (js/multi-ui.js). Everything here is under .mp, plus the
   menu button .mp-menu.
   ========================================================================== */
.btn.mp-menu { display: flex; align-items: baseline; justify-content: center; gap: 10px; border-color: rgba(180, 255, 57, 0.55); box-shadow: 0 0 14px rgba(180, 255, 57, 0.22), inset 0 0 14px rgba(255, 154, 31, 0.1); }
.btn.mp-menu b { white-space: nowrap; font: 400 21px/1 var(--neon); letter-spacing: 0.05em; color: #f1ffd9; text-shadow: 0 0 10px #b4ff39; }
.btn.mp-menu small { font-weight: 600; font-size: 12px; color: var(--mute); text-transform: none; letter-spacing: 0.02em; }
.mp { position: fixed; inset: 0; z-index: 15; background: #04030b; touch-action: none; overflow: hidden; }
.mp-canvas { position: absolute; inset: 0; width: 100%; height: 100%; display: block; touch-action: none; }
.mp-screen { position: absolute; inset: 0; }
.mp-panel {
  overflow-y: auto; touch-action: pan-y; display: flex; flex-direction: column; align-items: center; gap: 12px;
  padding: calc(var(--sat) + 26px) 16px calc(var(--sab) + 22px);
  background: radial-gradient(120% 70% at 50% 30%, rgba(30, 20, 70, 0.55), rgba(4, 3, 11, 0.96));
}
.mp-panel > * { width: min(100%, 420px); }
.mp-title { margin: 0; font: 400 34px/1.05 var(--neon); text-align: center; color: #f1ffd9; text-shadow: 0 0 8px #b4ff39, 0 0 22px rgba(180, 255, 57, 0.6); }
.mp-lede { margin: 0; color: var(--mute); text-align: center; }
.mp-note { margin: 0; color: var(--mute); font-size: 14px; text-align: center; }
.mp-col { display: flex; flex-direction: column; gap: 10px; }
.mp-row { display: flex; gap: 8px; }
.mp-row > * { flex: 1; }
.mp-join { display: flex; flex-direction: column; gap: 6px; padding: 12px; border-radius: 16px; border: 1px solid var(--line); background: rgba(20, 16, 44, 0.6); }
.mp-join label { font-weight: 700; letter-spacing: 0.08em; text-transform: uppercase; font-size: 13px; color: var(--mute); }
.mp-code-in { flex: 2; min-width: 0; min-height: 48px; border-radius: 12px; border: 1px solid var(--line); background: rgba(0, 0, 0, 0.35); color: #fff; font: 400 28px/1 var(--neon); letter-spacing: 0.3em; text-align: center; text-transform: uppercase; user-select: text; -webkit-user-select: text; }
.mp-err { margin: 0; min-height: 1.2em; color: #ff8a9a; font-weight: 600; font-size: 14px; }
.mp-codebox { display: flex; align-items: center; justify-content: center; gap: 14px; }
.mp-letters { display: flex; gap: 6px; }
.mp-letters span { width: 44px; height: 58px; display: grid; place-items: center; border-radius: 12px; border: 1px solid rgba(180, 255, 57, 0.6); background: rgba(180, 255, 57, 0.08); font: 400 36px/1 var(--neon); color: #f1ffd9; text-shadow: 0 0 10px #b4ff39; }
#mp-qr { border-radius: 10px; flex: none; }
.mp-phones, .mp-standings { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: 6px; }
.mp-phones li, .mp-standings li { display: flex; align-items: center; gap: 10px; padding: 8px 12px; border-radius: 12px; border: 1px solid var(--line); background: rgba(20, 16, 44, 0.6); }
.mp-phones li b, .mp-standings li b { color: var(--pc); flex: 1; }
.mp-phones li span:last-child, .mp-standings li span:last-child { color: var(--mute); font-size: 14px; font-weight: 600; }
.mp-disc { width: 16px; height: 16px; border-radius: 50%; background: var(--pc); box-shadow: 0 0 10px var(--pc); flex: none; }
.mp-disc.big { width: 46px; height: 46px; }
.mp-place { width: 22px; font: 400 20px var(--neon); color: #fff; text-align: center; }
.mp-shape { margin: 0; text-align: center; font-weight: 600; color: #d8deff; }
.mp-settings { display: flex; flex-direction: column; gap: 4px; }
.mp-settings .seg { justify-content: center; flex-wrap: wrap; }
.mp-settings .seg button { padding: 0 10px; }
.mp-badge { display: flex; flex-direction: column; align-items: center; gap: 10px; margin-top: 10vh; }
.mp-badge b { font: 400 30px var(--neon); }
.mp-status { margin: 0; text-align: center; color: var(--mute); }
.mp-status .ok { color: #78ffaa; font-weight: 700; }
.mp-status .warn { color: #ffd27a; font-weight: 700; }
.mp-lineup { display: flex; align-items: flex-end; justify-content: center; padding: 0 22px calc(var(--sab) + 14px); }
.mp-lu {
  width: min(100%, 380px); max-height: 64%; overflow-y: auto; touch-action: none;
  padding: 14px; border-radius: 18px; background: rgba(10, 8, 24, 0.82); border: 1px solid var(--line);
  -webkit-backdrop-filter: blur(6px); backdrop-filter: blur(6px); display: flex; flex-direction: column; gap: 8px;
}
.mp-lu-head { display: flex; gap: 12px; align-items: center; }
.mp-lu-head h3 { margin: 0; font: 400 22px/1.1 var(--neon); }
.mp-lu-head p { margin: 4px 0 0; font-size: 14px; color: var(--mute); }
.mp-diagram { width: 92px; height: 92px; flex: none; }
.mp-lu-how { margin: 0; font-size: 14px; color: var(--mute); }
.mp-lu-how b { color: var(--ink); }
.mp-lu-progress { margin: 0; font-size: 14px; font-weight: 700; color: #ffe27a; }
.mp-nudge { display: grid; grid-template-columns: repeat(3, 1fr); gap: 6px; }
.mp-nudge .btn { min-height: 40px; padding: 4px 6px; }
.mp-hud { pointer-events: none; }
.mp-pause {
  pointer-events: auto; position: absolute; right: calc(env(safe-area-inset-right, 0px) + 8px); top: calc(var(--sat) + 8px);
  width: 44px; height: 44px; border-radius: 50%; display: grid; place-items: center; background: rgba(10, 8, 24, 0.7); border: 1px solid var(--line);
}
.mp-pause svg { width: 20px; height: 20px; fill: var(--ink); }
.mp-pill { position: absolute; left: 10px; top: calc(var(--sat) + 16px); padding: 3px 10px; border-radius: 999px; background: rgba(255, 210, 122, 0.14); border: 1px solid rgba(255, 210, 122, 0.6); color: #ffe2a8; font-size: 12px; font-weight: 700; letter-spacing: 0.04em; }
.mp-sheet {
  position: absolute; z-index: 2; left: 50%; top: 42%; transform: translate(-50%, -50%);
  width: min(calc(100% - 28px), 420px); max-height: calc(100% - 140px); overflow: auto; padding: 20px 18px 16px; border-radius: 22px;
  background: var(--glass); border: 1px solid var(--line); -webkit-backdrop-filter: blur(16px); backdrop-filter: blur(16px); box-shadow: 0 0 40px rgba(120, 80, 255, 0.25);
}
.mp-sheet h2 { margin: 0 0 12px; font: 400 32px/1.05 var(--neon); text-align: center; }
.mp-sheet .mp-col { margin-top: 14px; }
.mp-toast { z-index: 40; top: calc(var(--sat) + 64px); bottom: auto; max-width: calc(100% - 32px); text-align: center; }
