:root {
  --ink: #0f1d36;
  --paper: #e9f2ff;
  --line: #9cc4ff;
  --gold: #ffd166;
  --red: #ff5c6c;
  --green: #7be0a2;
  --mono: ui-monospace, "SF Mono", Menlo, Consolas, monospace;
  --sans: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, system-ui, sans-serif;
}
* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }
html, body { margin: 0; height: 100%; overflow: hidden; background: var(--ink); color: var(--paper); font-family: var(--sans); overscroll-behavior: none; -webkit-user-select: none; user-select: none; -webkit-touch-callout: none; }
canvas { position: fixed; inset: 0; width: 100%; height: 100%; display: block; touch-action: none; }
button { font: inherit; color: inherit; cursor: pointer; }
.hidden { display: none !important; }

/* ---------- HUD ---------- */
#hud { position: fixed; left: 0; right: 0; top: 0; max-width: 560px; margin: 0 auto; padding: calc(env(safe-area-inset-top) + 8px) 12px 0; pointer-events: none; }
#hud .row { display: flex; align-items: center; gap: 8px; justify-content: space-between; }
#hud button, #hud .chip { pointer-events: auto; }
.title { display: flex; flex-direction: column; min-width: 0; font-family: var(--mono); }
.title b { font-size: 17px; letter-spacing: .02em; }
.title span { font-size: 12px; opacity: .7; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.btns { display: flex; gap: 6px; }
.btns button { width: 44px; height: 44px; border-radius: 12px; border: 1px solid rgba(156,196,255,.35); background: rgba(15,29,54,.7); font-size: 18px; font-weight: 700; }
.stats { margin-top: 6px; }
#noise { flex: 1; display: flex; align-items: center; gap: 8px; font: 12px var(--mono); min-width: 0; }
#noise .lbl { opacity: .75; }
#noise i { flex: 1; height: 12px; display: flex; gap: 2px; }
#noise i b { flex: 1; border-radius: 2px; background: rgba(156,196,255,.16); transition: background .2s; }
#noise-n { min-width: 36px; text-align: right; }
#noise.pulse i { animation: pulse .35s; }
@keyframes pulse { 50% { transform: scaleY(1.6); } }
.chip { font: 12px var(--mono); padding: 5px 8px; border-radius: 8px; background: rgba(156,196,255,.1); white-space: nowrap; }
#goal { margin: 6px auto 0; width: fit-content; max-width: 100%; font: 600 13px var(--sans); padding: 5px 12px; border-radius: 99px; background: rgba(255,209,102,.14); color: var(--gold); border: 1px solid rgba(255,209,102,.35); }
#goal.out { background: rgba(123,224,162,.14); color: var(--green); border-color: rgba(123,224,162,.4); }

/* ---------- action bar ---------- */
#bar { position: fixed; left: 0; right: 0; bottom: 0; padding: 8px 12px calc(env(safe-area-inset-bottom) + 10px); display: flex; gap: 8px; justify-content: center; }
.modes { display: flex; background: rgba(15,29,54,.85); border: 1px solid rgba(156,196,255,.3); border-radius: 14px; padding: 3px; }
.mode, #wait { min-width: 70px; height: 52px; border: 0; border-radius: 11px; background: transparent; display: flex; flex-direction: column; align-items: center; justify-content: center; font-size: 18px; line-height: 1.1; }
.mode span, #wait span { font: 600 11px var(--sans); letter-spacing: .02em; opacity: .85; }
.mode.on { background: var(--paper); color: var(--ink); }
.mode[data-mode=tackle].on { background: #ff9f5a; }
.mode[data-mode=mark].on { background: #ff8591; }
#wait { background: rgba(15,29,54,.85); border: 1px solid rgba(156,196,255,.3); border-radius: 14px; }
.desk { display: none; }
body:not(.touch) .desk { display: inline; }

/* ---------- toast ---------- */
#toast { position: fixed; left: 50%; bottom: calc(env(safe-area-inset-bottom) + 84px); transform: translate(-50%, 20px); opacity: 0; transition: .25s; background: rgba(8,16,30,.94); border: 1px solid rgba(156,196,255,.35); padding: 9px 14px; border-radius: 12px; font-size: 14px; max-width: min(92vw, 420px); text-align: center; pointer-events: none; }
#toast.show { opacity: 1; transform: translate(-50%, 0); }

/* ---------- panels ---------- */
#panel { position: fixed; inset: 0; display: flex; align-items: center; justify-content: center; padding: 16px; background: rgba(6,12,24,.55); backdrop-filter: blur(3px); -webkit-backdrop-filter: blur(3px); overflow-y: auto; }
.card { width: min(100%, 420px); max-height: calc(100% - 8px); overflow-y: auto; background: #f3efe4; color: #1c2230; border-radius: 16px; padding: 20px 20px 18px; box-shadow: 0 20px 60px rgba(0,0,0,.5); position: relative; font-size: 15px; line-height: 1.45; }
.card::before { content: ""; position: absolute; top: 0; left: 0; right: 0; height: 6px; border-radius: 16px 16px 0 0; background: repeating-linear-gradient(45deg, #1c2230 0 10px, var(--gold) 10px 20px); }
.card .tag { font: 700 11px var(--mono); letter-spacing: .14em; text-transform: uppercase; color: #a3462f; }
.card h1 { font: 800 30px/1.05 var(--mono); margin: 6px 0 2px; letter-spacing: -.01em; }
.card h2 { font: 800 22px/1.15 var(--mono); margin: 6px 0 4px; }
.card .sub { color: #525b6b; margin: 0 0 12px; }
.card ul { padding-left: 0; margin: 10px 0 14px; list-style: none; }
.card li { display: flex; gap: 10px; margin: 7px 0; }
.card li > span:first-child { flex: 0 0 26px; text-align: center; font-size: 18px; }
.card .btn { display: block; width: 100%; min-height: 48px; margin-top: 8px; border: 0; border-radius: 12px; background: #1c2230; color: #fff; font: 700 16px var(--sans); }
.card .btn.alt { background: transparent; color: #1c2230; border: 1.5px solid #1c2230; }
.card .btn.gold { background: var(--gold); color: #1c2230; }
.card .row2 { display: flex; gap: 8px; }
.card .row2 .btn { flex: 1; }
.card .dossier { font: 13px var(--mono); background: #e6e0d0; border-radius: 10px; padding: 10px 12px; margin: 10px 0; }
.card .dossier div { display: flex; justify-content: space-between; gap: 8px; }
.card .stars { font-size: 30px; letter-spacing: 4px; margin: 4px 0; }
.card .share { white-space: pre-wrap; font: 13px var(--mono); background: #e6e0d0; border-radius: 10px; padding: 10px 12px; margin: 10px 0 0; }
.card .foot { margin-top: 12px; font-size: 13px; color: #525b6b; text-align: center; }
.card .foot a { color: #a3462f; font-weight: 600; }
.card .statrow { display: flex; justify-content: space-around; text-align: center; margin: 12px 0 4px; font: 12px var(--mono); color: #525b6b; }
.card .statrow b { display: block; font-size: 22px; color: #1c2230; }
.card small { color: #6a7282; }
