:root {
  --bg: #07080c;
  --panel: #10131a;
  --ink: #e7ecf6;
  --muted: #8b93a7;
  --accent: #7ad0ff;
  --accent-2: #ffb14a;
  --blood: #ff4d4d;
  --line: #2a3142;
  --common: #c5c9d3;
  --uncommon: #3ddc7a;
  --rare: #4aa3ff;
  --epic: #c060ff;
  --legendary: #ffb020;
}

* { box-sizing: border-box; margin: 0; padding: 0; }
html, body { width: 100%; height: 100%; overflow: hidden; background: var(--bg); color: var(--ink); font-family: "Share Tech Mono", ui-monospace, monospace; }
#app { position: relative; width: 100%; height: 100%; }
canvas { display: block; width: 100%; height: 100%; cursor: crosshair; background: #0b0e14; }
.hidden { display: none !important; }

.overlay {
  position: absolute; inset: 0;
  background: radial-gradient(ellipse at center, rgba(10,14,22,0.84), rgba(5,6,10,0.95));
  display: flex; align-items: center; justify-content: center;
  z-index: 20;
}
.menu-inner { text-align: center; padding: 24px; max-width: 760px; }
.title-mark { letter-spacing: 0.5em; font-size: 11px; color: var(--accent); margin-bottom: 10px; }
h1 {
  font-family: "Bebas Neue", Impact, sans-serif;
  font-size: clamp(64px, 12vw, 128px);
  line-height: 0.85; letter-spacing: 0.04em;
}
h1 span { color: var(--accent); }
.tagline { color: var(--muted); margin: 16px 0 28px; font-size: 14px; }
.menu-stats { display: grid; grid-template-columns: repeat(4, 1fr); gap: 10px; margin-bottom: 28px; }
.ms { border: 1px solid var(--line); padding: 12px 8px; background: rgba(16,19,26,0.75); }
.ms b { display: block; font-family: "Bebas Neue", sans-serif; font-size: 28px; color: var(--accent); }
.ms span { font-size: 10px; color: var(--muted); letter-spacing: 0.12em; }
.menu-actions { display: flex; gap: 10px; justify-content: center; flex-wrap: wrap; }
.menu-actions.col { flex-direction: column; align-items: stretch; }
.fine { margin-top: 22px; color: #5c6478; font-size: 11px; }

.btn {
  font-family: inherit; font-size: 12px; letter-spacing: 0.16em;
  padding: 11px 18px; cursor: pointer;
  background: transparent; color: var(--ink);
  border: 1px solid var(--line);
  transition: 0.15s background, 0.15s border, 0.15s color;
}
.btn:hover { border-color: var(--accent); color: var(--accent); }
.btn.primary { background: var(--accent); color: #071018; border-color: var(--accent); font-weight: 700; }
.btn.primary:hover { filter: brightness(1.08); color: #071018; }
.btn.ghost { border-style: dashed; }
.btn.danger:hover { border-color: var(--blood); color: var(--blood); }
.btn:disabled { opacity: 0.38; cursor: not-allowed; }

.panel {
  background: var(--panel);
  border: 1px solid var(--line);
  padding: 28px 32px;
  max-width: 560px;
  width: min(92vw, 560px);
  max-height: 86vh;
  overflow: auto;
  box-shadow: 0 20px 80px rgba(0,0,0,0.45);
}
.panel.wide { max-width: 900px; width: min(94vw, 900px); }
.panel h2 { font-family: "Bebas Neue", sans-serif; font-size: 36px; letter-spacing: 0.06em; margin-bottom: 8px; }
.panel h3 { font-size: 12px; letter-spacing: 0.16em; color: var(--muted); margin-bottom: 10px; }
.panel .sub { color: var(--muted); font-size: 12px; margin-bottom: 16px; line-height: 1.45; }
.kicker { color: var(--accent); letter-spacing: 0.28em; font-size: 11px; margin-bottom: 6px; }
.reason { margin: 14px 0; padding: 10px 12px; border-left: 2px solid var(--accent-2); color: #d7c7a2; font-size: 12px; line-height: 1.45; }
.manual { list-style: none; text-align: left; margin: 16px 0 24px; }
.manual li { padding: 10px 0; border-bottom: 1px solid var(--line); font-size: 13px; line-height: 1.5; color: #c5ccda; }
.manual b { color: var(--accent); }

#hud { position: absolute; inset: 0; pointer-events: none; z-index: 10; }
.hud-top { display: flex; justify-content: space-between; align-items: flex-start; padding: 16px 20px; }
.hud-block { min-width: 220px; }
.hud-block.right { text-align: right; }
.label { font-size: 10px; letter-spacing: 0.2em; color: var(--muted); margin-bottom: 6px; }
#hud-hp-wrap { width: 220px; height: 10px; background: #241016; border: 1px solid #5a2a36; }
#hud-hp { height: 100%; width: 100%; background: linear-gradient(90deg, #8b1e30, #ff4d4d); }
#hud-hp-text { font-size: 11px; margin-top: 4px; color: #e8b4b8; }
#hud-statuses { display: flex; gap: 6px; margin-top: 6px; flex-wrap: wrap; }
.st-pill { font-size: 9px; letter-spacing: 0.08em; padding: 2px 6px; border: 1px solid var(--line); color: var(--accent-2); }
.hud-center { text-align: center; }
.wave-chip { font-family: "Bebas Neue", sans-serif; font-size: 42px; letter-spacing: 0.08em; line-height: 1; text-shadow: 0 2px 0 #000; }
.alive-chip { font-size: 11px; color: var(--muted); letter-spacing: 0.16em; }
.stat-row { font-size: 13px; }
.stat-row .k { color: var(--muted); margin-right: 10px; font-size: 10px; letter-spacing: 0.14em; }
.hud-bottom {
  position: absolute; left: 0; right: 0; bottom: 18px;
  display: flex; flex-direction: column; align-items: center; gap: 8px;
}
#weapon-chip {
  background: rgba(8,10,16,0.78);
  border: 1px solid var(--line);
  padding: 8px 14px;
  display: flex; align-items: center; gap: 12px;
  font-size: 12px;
}
#weapon-tags { display: flex; gap: 6px; }
.tag { font-size: 9px; letter-spacing: 0.08em; border: 1px solid var(--line); padding: 2px 6px; color: var(--muted); }
#weapon-stats { color: var(--muted); font-size: 11px; }
.hint { font-size: 10px; color: #5c6478; letter-spacing: 0.04em; }
#xp-bar { position: absolute; left: 0; right: 0; bottom: 0; height: 4px; background: #161a24; }
#xp-fill { height: 100%; width: 0%; background: var(--accent); }

#pickup-prompt {
  position: absolute; left: 50%; bottom: 92px; transform: translateX(-50%);
  background: rgba(8,10,16,0.9); border: 1px solid var(--accent);
  padding: 8px 14px; font-size: 12px; z-index: 12; color: var(--accent);
  pointer-events: none;
}
kbd { border: 1px solid currentColor; padding: 0 5px; }

#toasts {
  position: absolute; right: 16px; top: 88px; z-index: 18;
  display: flex; flex-direction: column; gap: 8px; pointer-events: none;
  width: min(320px, 40vw);
}
.toast {
  background: rgba(10,13,20,0.92); border: 1px solid var(--line);
  padding: 10px 12px; font-size: 12px; animation: toastIn 0.25s ease both;
}
.toast b { display: block; margin-bottom: 3px; }
.toast.rare { border-color: var(--rare); }
.toast.epic { border-color: var(--epic); }
.toast.legendary { border-color: var(--legendary); }
@keyframes toastIn { from { opacity: 0; transform: translateX(12px); } to { opacity: 1; transform: none; } }

#loot-pop {
  position: absolute; left: 50%; top: 48%; transform: translate(-50%, -50%);
  z-index: 20; pointer-events: auto; width: min(520px, 94vw);
}
#loot-force { margin-top: 8px; width: 100%; }
.pop-card {
  width: 100%;
  max-height: 72vh;
  overflow: auto;
  background: linear-gradient(180deg, #161b26, #0d1118);
  border: 1px solid #3a4c68;
  padding: 14px 16px;
  box-shadow: 0 18px 50px rgba(0,0,0,0.55);
}
.holster { border: 1px solid #2a384c; padding: 8px; margin: 6px 0; background: #0c1018; }
.holster b { letter-spacing: 0.08em; }
.offer { background: linear-gradient(180deg, #182033, #10151e); border-color: #4d6d94; min-height: 150px; }
.offer-kicker { font-size: 10px; letter-spacing: 0.16em; color: #7ad0ff; }
.offer-val { font-family: "Bebas Neue", sans-serif; font-size: 26px; color: #ffe08a; line-height: 1; margin: 8px 0; }
.pop-card header { display: flex; justify-content: space-between; gap: 10px; margin-bottom: 8px; }
.pop-card .why { font-size: 11px; color: #d7c7a2; line-height: 1.4; margin: 8px 0; }
.pop-card .stats { font-size: 12px; color: #c5ccda; }
.pop-card .cmp { margin-top: 8px; font-size: 11px; color: var(--muted); }
.pop-card .cmp em { font-style: normal; color: var(--uncommon); }
.pop-card .cmp i { font-style: normal; color: var(--blood); }
.pop-actions { display: flex; gap: 8px; margin-top: 12px; flex-wrap: wrap; }

#wave-banner {
  position: absolute; left: 50%; top: 28%; transform: translate(-50%, -50%);
  z-index: 15; pointer-events: none;
  font-family: "Bebas Neue", sans-serif;
  font-size: 72px; letter-spacing: 0.12em;
  text-shadow: 0 4px 0 #000, 0 0 30px rgba(122,208,255,0.35);
  animation: bannerIn 1.6s ease both;
}
@keyframes bannerIn {
  0% { opacity: 0; transform: translate(-50%, -40%) scale(0.86); }
  18% { opacity: 1; transform: translate(-50%, -50%) scale(1); }
  75% { opacity: 1; }
  100% { opacity: 0; transform: translate(-50%, -58%) scale(1.04); }
}

.shop-gold { margin-bottom: 14px; color: var(--accent); letter-spacing: 0.12em; }
.shop-grid, .armory-grid, .inv-grid, .choice-grid {
  display: grid; grid-template-columns: repeat(auto-fill, minmax(210px, 1fr));
  gap: 10px; margin-bottom: 18px;
}
.choice-grid { grid-template-columns: repeat(3, 1fr); }
.shop-card, .armory-card, .inv-card, .eq-card, .choice-card {
  border: 1px solid var(--line); padding: 12px; background: #0c0f16; text-align: left;
}
.choice-card { cursor: pointer; }
.choice-card:hover, .eq-card:hover, .inv-card:hover, .shop-card:hover { border-color: var(--accent); }
.shop-card h4, .armory-card h4, .choice-card h4 { font-size: 13px; margin-bottom: 4px; letter-spacing: 0.08em; }
.shop-card p, .armory-card p, .choice-card p { font-size: 11px; color: var(--muted); margin-bottom: 8px; min-height: 28px; line-height: 1.35; }
.shop-card .cost { color: var(--accent); font-size: 12px; margin-bottom: 8px; }
.delta { border: 1px solid var(--line); padding: 12px; font-size: 13px; line-height: 1.5; margin-bottom: 16px; }
.delta b { color: var(--uncommon); }

.rarity-common { color: var(--common); }
.rarity-uncommon { color: var(--uncommon); }
.rarity-rare { color: var(--rare); }
.rarity-epic { color: var(--epic); }
.rarity-legendary { color: var(--legendary); }
.rarity-pip { width: 8px; height: 8px; display: inline-block; background: var(--common); }
.rarity-pip.uncommon { background: var(--uncommon); }
.rarity-pip.rare { background: var(--rare); }
.rarity-pip.epic { background: var(--epic); }
.rarity-pip.legendary { background: var(--legendary); box-shadow: 0 0 8px var(--legendary); }

.inv-cols { display: grid; grid-template-columns: 260px 1fr; gap: 18px; }
#eq-slots { display: flex; flex-direction: column; gap: 8px; }
.eq-card, .inv-card { cursor: pointer; }
.item-detail {
  min-height: 64px; border-top: 1px solid var(--line); padding-top: 12px;
  font-size: 12px; color: #c5ccda; line-height: 1.45;
}
.go-kicker { color: var(--blood); letter-spacing: 0.3em; font-size: 11px; }
.go-stats { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; margin: 16px 0 22px; }
.go-stats div { border: 1px solid var(--line); padding: 10px; }
.go-stats b { display: block; font-family: "Bebas Neue", sans-serif; font-size: 26px; color: var(--accent); }
.go-stats span { font-size: 10px; color: var(--muted); letter-spacing: 0.12em; }

.redacted { opacity: 0.45; }
.trait-row { display: flex; flex-wrap: wrap; gap: 6px; margin: 8px 0; }
.trait { font-size: 10px; letter-spacing: 0.08em; border: 1px solid var(--line); padding: 2px 6px; color: var(--accent); }

@media (max-width: 800px) {
  .menu-stats { grid-template-columns: 1fr 1fr; }
  .inv-cols, .choice-grid { grid-template-columns: 1fr; }
  .hint { display: none; }
  h1 { font-size: 64px; }
  .wave-chip { font-size: 28px; }
}

.audio-panel {
  margin: 18px auto 0;
  max-width: 420px;
  border: 1px solid var(--line);
  padding: 12px 14px;
  text-align: left;
  background: rgba(8,10,16,0.55);
}
.audio-panel .alabel {
  font-size: 10px; letter-spacing: 0.18em; color: var(--muted); margin-bottom: 8px;
}
.audio-row { display: flex; align-items: center; gap: 10px; margin: 8px 0; font-size: 11px; }
.audio-row span { width: 64px; color: var(--muted); letter-spacing: 0.08em; }
.audio-row input[type="range"] { flex: 1; accent-color: var(--accent); }
.audio-row .pct { width: 36px; text-align: right; color: var(--accent); }
.hud-tools {
  position: absolute; left: 20px; bottom: 28px;
  display: flex; gap: 8px; z-index: 11; pointer-events: auto;
}
#hud-mute, #hud-aim {
  pointer-events: auto;
  position: static;
  border: 1px solid var(--line); background: rgba(8,10,16,0.78);
  color: var(--ink); font-family: inherit; font-size: 10px;
  letter-spacing: 0.12em; padding: 6px 10px; cursor: pointer;
}
#hud-mute.on { color: var(--blood); border-color: var(--blood); }
#hud-aim.on { color: var(--accent); border-color: var(--accent); }
.choice-card { min-height: 140px; }
.choice-card h4 { font-family: "Bebas Neue", sans-serif; font-size: 22px; letter-spacing: 0.04em; }
#upgrade-pop .delta, #up-delta { font-size: 15px; line-height: 1.55; }

.cmp-head { margin-bottom: 6px; color: var(--ink); }
.cmp i { font-style: normal; color: var(--blood); }
.cmp em { font-style: normal; color: var(--uncommon); }

.shop-card.on { border-color: var(--accent); }
.menu-stats { grid-template-columns: repeat(5, 1fr); }
@media (max-width: 800px) { .menu-stats { grid-template-columns: 1fr 1fr; } }
#hud-aim.on { color: var(--accent); border-color: var(--accent); }



/* visual pass */
.overlay { background: radial-gradient(ellipse at 50% 30%, rgba(18,28,44,0.78), rgba(4,6,10,0.94)); }
.panel, .ms, #weapon-chip {
  background: linear-gradient(180deg, rgba(22,28,40,0.92), rgba(10,13,20,0.94));
  border: 1px solid rgba(122,208,255,0.18);
  box-shadow: 0 18px 50px rgba(0,0,0,0.45), inset 0 1px 0 rgba(255,255,255,0.04);
}
h1 { text-shadow: 0 8px 30px rgba(122,208,255,0.18); }
.btn { border-radius: 2px; }
.btn.primary { box-shadow: 0 0 18px rgba(122,208,255,0.25); }
.wave-chip { text-shadow: 0 0 18px rgba(122,208,255,0.35), 0 2px 0 #000; }
#hud-hp-wrap { border-radius: 2px; box-shadow: inset 0 0 8px rgba(0,0,0,0.45); }
#hud-hp { background: linear-gradient(90deg, #6a1830, #ff5a6a 70%, #ffd0d4); box-shadow: 0 0 10px rgba(255,77,77,0.35); }
.shop-card, .armory-card, .inv-card, .eq-card, .choice-card, .pop-card, .toast {
  background: linear-gradient(180deg, rgba(20,26,38,0.96), rgba(8,11,18,0.96));
  border-color: rgba(122,208,255,0.16);
}
.stat-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(140px, 1fr)); gap: 8px; margin: 10px 0 16px; }
.stat-grid div { border: 1px solid rgba(122,208,255,0.16); padding: 8px; font-size: 12px; }
.stat-grid b { display: block; font-size: 16px; color: #d7e6ff; }
.stat-grid span { color: var(--muted); letter-spacing: 0.08em; font-size: 10px; }
#stat-sheet summary { cursor: pointer; letter-spacing: 0.14em; color: var(--accent); }
.cmp-cols > div { border: 1px solid rgba(122,208,255,0.2); padding: 8px; }
.alive-chip.sick { color: #8ed45a; }
#xp-bar { height: 5px; background: #0c1018; }
#xp-fill { background: linear-gradient(90deg, #3a8ab8, #7ad0ff); box-shadow: 0 0 8px rgba(122,208,255,0.4); }
#weapon-chip { backdrop-filter: blur(6px); }
.title-mark { text-shadow: 0 0 12px rgba(122,208,255,0.35); }
.glyph { width: 28px; height: 28px; margin-right: 6px; vertical-align: middle; background: #10151e; border: 1px solid rgba(122,208,255,0.25); }

/* site links + touch notice */
.site-links { margin-top: 22px; display: flex; flex-wrap: wrap; gap: 6px 18px; justify-content: center; font-size: 12px; letter-spacing: 0.08em; text-transform: uppercase; }
.site-links a { color: var(--muted); text-decoration: none; border-bottom: 1px solid transparent; }
.site-links a:hover, .site-links a:focus { color: var(--ink); border-bottom-color: var(--accent); }
#touch-note { position: fixed; inset: 0; z-index: 200; display: flex; align-items: center; justify-content: center; background: rgba(5, 7, 11, 0.94); padding: 18px; }
#touch-note.hidden { display: none; }
#touch-note .btn { text-decoration: none; display: inline-block; }

/* comparison colouring: green = better, red = worse */
.up { color: #3ddc7a; font-weight: 700; }
.down { color: #ff5a5a; font-weight: 700; }
.even { color: #9aa3b5; }
.pop-card .cmp .up, .toast .up { color: #3ddc7a; }
.pop-card .cmp .down, .toast .down { color: #ff5a5a; }
.cmp-head .up, .cmp-head .down { font-size: 1.15em; }

/* ---- weapon swapped notice ---- */
#swap-note { position: absolute; left: 50%; top: 64%; transform: translateX(-50%); text-align: center; pointer-events: none; z-index: 14;
  font-size: 12px; letter-spacing: 0.32em; color: #cfe9ff; text-shadow: 0 0 10px rgba(122,208,255,0.6); white-space: nowrap; }
#swap-note span { display: block; margin-top: 4px; font-size: 15px; letter-spacing: 0.12em; }
#swap-note.show { animation: swapfade 1.5s ease-out forwards; }
@keyframes swapfade { 0% { opacity: 0; transform: translate(-50%, 8px); } 12% { opacity: 1; transform: translate(-50%, 0); } 70% { opacity: 1; } 100% { opacity: 0; transform: translate(-50%, -6px); } }
#weapon-chip.swapflash { animation: chipflash 0.7s ease-out; }
@keyframes chipflash { 0% { border-color: var(--accent); box-shadow: 0 0 14px rgba(122,208,255,0.7); } 100% { box-shadow: none; } }

/* ---- aim: HUD never swallows pointer movement ---- */
.hud-top, .hud-bottom, #weapon-chip, .hint, #swap-note { pointer-events: none; }

/* ---- adverts: static placements, shown only when Google actually fills them ---- */
.ad-banner { display: none; margin: 22px auto 0; width: 100%; max-width: 728px; text-align: center; }
.ad-banner.ad-pending { display: block; visibility: hidden; height: 0; overflow: hidden; margin: 0 auto; }
.ad-banner.ad-filled { display: block; visibility: visible; height: auto; min-height: 50px; margin: 22px auto 0; }
.ad-banner.ad-filled::before { content: "ADVERTISEMENT"; display: block; font-size: 9px; letter-spacing: 0.3em; color: #5c6478; margin-bottom: 4px; }
.ad-banner.ad-empty { display: none; }
#ad-break { z-index: 40; }
#ad-break.ad-loading { opacity: 0; pointer-events: none; }
.ad-panel { text-align: center; min-width: 380px; }
.ad-kicker { letter-spacing: 0.28em; font-size: 11px; color: var(--accent); margin-bottom: 8px; }
.ad-slot { min-height: 280px; min-width: 336px; display: flex; align-items: center; justify-content: center; margin: 16px 0; background: #0a0d14; border: 1px solid var(--line); }
#ad-skip:disabled { opacity: 0.45; }

/* tall screens (menu + banner) must scroll instead of clipping on short windows */
#menu, #pause, #gameover, #shop, #ad-break { overflow-y: auto; align-items: safe center; }
.stat-grid small { display: block; margin-top: 3px; font-size: 10px; color: #7fb99a; letter-spacing: 0.02em; line-height: 1.3; }

/* four level-up choices */
#level-choices { grid-template-columns: repeat(4, 1fr); }
@media (max-width: 1100px) { #level-choices { grid-template-columns: repeat(2, 1fr); } }
@media (max-width: 600px) { #level-choices { grid-template-columns: 1fr; } }
.btn.ghost { opacity: 0.85; }
#fatal { z-index: 60; }

/* ================= leaderboard v2 ================= */
.board-panel { width: min(900px, 94vw); max-height: 92vh; overflow-y: auto; }
.board-head { display: flex; align-items: baseline; justify-content: space-between; gap: 12px; flex-wrap: wrap; }
.board-head h2 { margin: 0; }
.board-players, .global-count { font-size: 12px; letter-spacing: 0.06em; color: var(--muted); }
.board-players b, .global-count b { color: var(--accent); font-size: 1.15em; }
.global-count { margin: 4px 0 12px; text-align: center; }
.global-count .dot { opacity: 0.5; }
.you-card { border: 1px solid rgba(122,208,255,0.3); background: linear-gradient(180deg, rgba(122,208,255,0.07), rgba(122,208,255,0.02)); padding: 12px 14px; margin: 12px 0; }
.you-top { display: flex; align-items: center; gap: 10px; }
.you-label { font-size: 10px; letter-spacing: 0.25em; background: var(--accent); color: #06121c; padding: 2px 7px; font-weight: 700; }
.you-name { font-size: 18px; letter-spacing: 0.05em; color: #e7ecf6; }
.you-stats { display: flex; flex-wrap: wrap; gap: 8px 22px; align-items: flex-end; margin: 10px 0; min-height: 40px; }
.you-stat b { display: block; font-size: 20px; color: #d7e6ff; line-height: 1; }
.you-stat.big b { font-size: 30px; color: var(--accent); }
.you-stat span { font-size: 10px; letter-spacing: 0.14em; color: var(--muted); }
.you-note { font-size: 12px; color: var(--muted); align-self: center; }
.you-edit, .go-join-row { display: flex; gap: 8px; flex-wrap: wrap; }
.you-edit input, .go-join-row input { flex: 1; min-width: 160px; background: #0a0d14; border: 1px solid var(--line); color: #e7ecf6; padding: 9px 10px; font: inherit; letter-spacing: 0.05em; }
.you-edit input:focus, .go-join-row input:focus { outline: none; border-color: var(--accent); }
.board-msg { min-height: 16px; margin-top: 6px; font-size: 12px; color: var(--muted); }
.board-msg.good { color: #3ddc7a; } .board-msg.bad { color: #ff7a7a; }
.lb-tabs { display: flex; gap: 6px; flex-wrap: wrap; margin: 14px 0 8px; border-bottom: 1px solid var(--line); }
.lb-tab { background: none; border: 0; border-bottom: 2px solid transparent; color: var(--muted); padding: 9px 14px; font: inherit; font-size: 12px; letter-spacing: 0.14em; cursor: pointer; }
.lb-tab:hover { color: #e7ecf6; } .lb-tab.on { color: var(--accent); border-bottom-color: var(--accent); }
.lb-chips { display: flex; flex-wrap: wrap; gap: 6px; margin: 6px 0 10px; }
.lb-chip { background: transparent; border: 1px solid var(--line); color: var(--muted); padding: 5px 10px; font: inherit; font-size: 11px; letter-spacing: 0.08em; cursor: pointer; }
.lb-chip.on { border-color: var(--accent); color: var(--accent); background: rgba(122,208,255,0.08); }
.lb-table { margin: 6px 0 12px; }
.lb-row { display: grid; grid-template-columns: 46px minmax(0, 1fr) 150px 64px 84px 60px; gap: 8px; align-items: center; padding: 8px 10px; border-bottom: 1px solid rgba(122,208,255,0.1); font-size: 13px; }
.lb-row:not(.lb-head):hover { background: rgba(122,208,255,0.05); }
.lb-head { font-size: 10px; letter-spacing: 0.16em; color: var(--muted); border-bottom: 1px solid var(--line); }
.lb-rank { font-size: 16px; color: var(--muted); text-align: center; }
.lb-row.gold .lb-rank { color: #ffd166; } .lb-row.silver .lb-rank { color: #cfd8e6; } .lb-row.bronze .lb-rank { color: #d08a52; }
.lb-row.gold { background: linear-gradient(90deg, rgba(255,209,102,0.10), transparent 60%); }
.lb-row.silver { background: linear-gradient(90deg, rgba(207,216,230,0.07), transparent 60%); }
.lb-row.bronze { background: linear-gradient(90deg, rgba(208,138,82,0.08), transparent 60%); }
.lb-name { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; color: #e7ecf6; letter-spacing: 0.03em; }
.lb-name i { font-style: normal; font-size: 9px; letter-spacing: 0.18em; background: var(--accent); color: #06121c; padding: 1px 5px; margin-left: 8px; font-weight: 700; vertical-align: middle; }
.lb-rig { color: var(--muted); font-size: 11px; letter-spacing: 0.05em; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.lb-num { text-align: right; color: #b9c4d8; } .lb-num.hi { color: #e7ecf6; font-size: 15px; }
.lb-time { text-align: right; color: var(--muted); font-size: 12px; }
.lb-row.me { background: rgba(122,208,255,0.12); box-shadow: inset 3px 0 0 var(--accent); }
.lb-gap { text-align: center; color: var(--muted); letter-spacing: 0.4em; padding: 4px 0; }
.lb-foot { font-size: 11px; color: var(--muted); padding: 10px 10px 0; }
.lb-state { padding: 36px 12px; text-align: center; color: var(--muted); font-size: 13px; line-height: 1.8; }
.lb-spin { display: inline-block; width: 12px; height: 12px; border: 2px solid var(--line); border-top-color: var(--accent); border-radius: 50%; animation: lbspin 0.8s linear infinite; margin-right: 8px; vertical-align: -2px; }
@keyframes lbspin { to { transform: rotate(360deg); } }
.board-fine { font-size: 11px; opacity: 0.8; }
@media (max-width: 760px) { .lb-row { grid-template-columns: 34px minmax(0, 1fr) 52px 70px; } .lb-rig, .lb-time { display: none; } }

/* game-over rank / join panel */
.go-board { margin: 12px 0 6px; }
.go-rank { display: flex; align-items: center; gap: 18px; flex-wrap: wrap; border: 1px solid rgba(122,208,255,0.3); background: rgba(122,208,255,0.06); padding: 12px 14px; }
.go-rank-main b { display: block; font-size: 34px; color: var(--accent); line-height: 1; }
.go-rank-main span { font-size: 10px; letter-spacing: 0.14em; color: var(--muted); }
.go-rank-side { flex: 1; font-size: 12px; color: #b9c4d8; line-height: 1.7; min-width: 150px; }
.go-rank-side b { color: #e7ecf6; }
.go-rank-side em { display: inline-block; font-style: normal; font-size: 10px; letter-spacing: 0.14em; background: #3ddc7a; color: #06210f; padding: 1px 7px; margin: 4px 6px 0 0; font-weight: 700; }
.go-join { border: 1px dashed rgba(122,208,255,0.35); padding: 12px 14px; }
.go-join-title { font-size: 12px; letter-spacing: 0.06em; color: #c9d2e3; margin-bottom: 8px; }
.go-join-fine { font-size: 10px; color: var(--muted); margin-top: 6px; }

/* ================= tutorial coach ================= */
#coach { position: absolute; left: 16px; top: 96px; width: min(350px, 44vw); z-index: 45; background: rgba(10,13,20,0.94); border: 1px solid rgba(122,208,255,0.45); box-shadow: 0 12px 40px rgba(0,0,0,0.55); padding: 0 16px 14px; pointer-events: auto; }
#coach.hidden { display: none; }
.coach-bar { height: 3px; margin: 0 -16px 10px; background: rgba(122,208,255,0.12); }
#coach-progress { height: 100%; width: 0; background: var(--accent); transition: width 0.4s ease; }
.coach-top { display: flex; justify-content: space-between; align-items: center; font-size: 10px; letter-spacing: 0.2em; color: var(--accent); }
.coach-skip { background: none; border: 0; color: var(--muted); font: inherit; font-size: 10px; letter-spacing: 0.14em; cursor: pointer; text-decoration: underline; padding: 2px; }
.coach-skip:hover { color: #ff9a9a; }
#coach h3 { margin: 8px 0 6px; font-size: 19px; letter-spacing: 0.08em; color: #e7ecf6; }
#coach-body { font-size: 12.5px; line-height: 1.6; color: #c3cbdc; }
#coach-body kbd { border: 1px solid rgba(122,208,255,0.5); padding: 0 6px; margin: 0 1px; color: #e7ecf6; background: rgba(122,208,255,0.1); }
#coach-tasks { list-style: none; margin: 10px 0 4px; padding: 0; }
#coach-tasks:empty { display: none; }
#coach-tasks li { font-size: 12px; padding: 4px 0 4px 24px; position: relative; color: #e7ecf6; }
#coach-tasks li::before { content: ""; position: absolute; left: 0; top: 6px; width: 12px; height: 12px; border: 1px solid var(--accent); }
#coach-tasks li.done { color: #3ddc7a; }
#coach-tasks li.done::before { background: #3ddc7a; border-color: #3ddc7a; box-shadow: 0 0 8px rgba(61,220,122,0.6); }
#coach-tasks li.done::after { content: ""; position: absolute; left: 4px; top: 8px; width: 4px; height: 7px; border: solid #06210f; border-width: 0 2px 2px 0; transform: rotate(45deg) translate(-1px, -1px); }
#coach-next { margin-top: 10px; width: 100%; }
@media (max-width: 800px) { #coach { top: auto; bottom: 60px; width: calc(100% - 32px); } }

.go-board { margin-bottom: 16px; }

/* ================= accessibility ================= */
.sr-only { position: absolute !important; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }
:focus-visible { outline: 3px solid #ffd166; outline-offset: 2px; }
canvas:focus, canvas:focus-visible { outline: none; }
.btn small { font-size: 9px; opacity: 0.65; letter-spacing: 0.1em; margin-left: 6px; border: 1px solid currentColor; padding: 0 4px; }
#hud-fire, #hud-status, #hud-pause { background: rgba(8,11,17,0.8); border: 1px solid rgba(122,208,255,0.3); color: var(--ink, #e7ecf6); font: inherit; font-size: 11px; letter-spacing: 0.12em; padding: 6px 10px; cursor: pointer; }
#hud-fire:hover, #hud-status:hover, #hud-pause:hover { border-color: var(--accent); }
.hud-tools { flex-wrap: wrap; max-width: 60vw; }
#pickup-prompt { pointer-events: auto; }
#pickup-prompt .pk { cursor: pointer; }
#pickup-prompt .pk:hover { text-decoration: underline; }
.offer-kicker { letter-spacing: 0.18em; }

.access-panel { width: min(940px, 95vw); max-height: 92vh; overflow-y: auto; }
.access-panel h3 { margin: 22px 0 6px; font-size: 13px; letter-spacing: 0.22em; color: var(--accent); border-bottom: 1px solid var(--line); padding-bottom: 6px; }
.acc-presets { display: flex; flex-wrap: wrap; gap: 8px; margin: 10px 0 4px; }
.acc-row { display: flex; gap: 16px; align-items: center; justify-content: space-between; flex-wrap: wrap; padding: 10px 0; border-bottom: 1px solid rgba(122,208,255,0.1); }
.acc-text { flex: 1 1 320px; min-width: 0; }
.acc-text b { display: block; color: #e7ecf6; font-size: 14px; letter-spacing: 0.05em; margin-bottom: 2px; }
.acc-text span { color: var(--muted); font-size: 12px; line-height: 1.5; display: block; }
.seg { display: inline-flex; flex-wrap: wrap; border: 1px solid var(--line); }
.segbtn { background: transparent; border: 0; border-right: 1px solid var(--line); color: var(--muted); padding: 9px 13px; font: inherit; font-size: 11px; letter-spacing: 0.1em; cursor: pointer; }
.segbtn:last-child { border-right: 0; }
.segbtn:hover { color: #e7ecf6; background: rgba(122,208,255,0.07); }
.segbtn.on { background: var(--accent); color: #06121c; font-weight: 700; }
.acc-note { font-size: 12px; color: var(--muted); line-height: 1.6; margin: 4px 0 10px; }
.kb-table { display: grid; grid-template-columns: repeat(auto-fill, minmax(380px, 1fr)); gap: 6px 18px; }
.kb-row { display: grid; grid-template-columns: 1fr repeat(3, 84px); gap: 6px; align-items: center; }
.kb-name { font-size: 12px; color: #c3cbdc; }
.kb-slot { background: #0a0d14; border: 1px solid var(--line); color: #e7ecf6; padding: 7px 4px; font: inherit; font-size: 11px; cursor: pointer; min-height: 32px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.kb-slot:hover { border-color: var(--accent); }
.kb-slot.listening { border-color: #ffd166; color: #ffd166; animation: kbpulse 1s ease-in-out infinite; }
@keyframes kbpulse { 50% { box-shadow: 0 0 0 3px rgba(255,209,102,0.25); } }
@media (max-width: 700px) { .kb-table { grid-template-columns: 1fr; } .kb-row { grid-template-columns: 1fr repeat(3, 70px); } }

/* interface size */
html[data-ui="125"] .panel, html[data-ui="125"] #coach, html[data-ui="125"] .hud-top, html[data-ui="125"] .hud-bottom, html[data-ui="125"] .hud-tools, html[data-ui="125"] #toasts, html[data-ui="125"] #pickup-prompt, html[data-ui="125"] #swap-note, html[data-ui="125"] .menu-inner { zoom: 1.25; }
html[data-ui="150"] .panel, html[data-ui="150"] #coach, html[data-ui="150"] .hud-top, html[data-ui="150"] .hud-bottom, html[data-ui="150"] .hud-tools, html[data-ui="150"] #toasts, html[data-ui="150"] #pickup-prompt, html[data-ui="150"] #swap-note, html[data-ui="150"] .menu-inner { zoom: 1.5; }

/* high contrast */
body.hc { --muted: #d6dded; --line: #8fb4e0; }
body.hc .panel, body.hc #coach, body.hc #weapon-chip, body.hc .toast { background: #000 !important; border: 2px solid #fff !important; }
body.hc .overlay { background: rgba(0,0,0,0.92) !important; }
body.hc, body.hc .sub, body.hc .fine, body.hc .hint, body.hc .acc-text span, body.hc #coach-body, body.hc .lb-rig, body.hc .lb-time, body.hc .go-join-fine { color: #fff !important; }
body.hc .btn, body.hc .segbtn, body.hc .kb-slot, body.hc #hud-mute, body.hc #hud-aim, body.hc #hud-fire, body.hc #hud-status, body.hc #hud-pause { border: 2px solid #fff !important; color: #fff; background: #000; }
body.hc .btn.primary, body.hc .segbtn.on { background: #ffee00 !important; color: #000 !important; border-color: #ffee00 !important; }
body.hc #hud-hp-wrap { border: 2px solid #fff; }
body.hc :focus-visible { outline: 4px solid #ffee00; }

/* colour-blind safe: blue / orange plus arrows instead of green / red */
body.cb .up { color: #4aa8ff !important; } body.cb .down { color: #ff9f1c !important; }
body.cb .up::before { content: "\25B2 "; } body.cb .down::before { content: "\25BC "; }
body.cb #coach-tasks li.done { color: #4aa8ff; } body.cb #coach-tasks li.done::before { background: #4aa8ff; border-color: #4aa8ff; }
body.cb .board-msg.good { color: #4aa8ff; } body.cb .board-msg.bad { color: #ff9f1c; }
body.cb .go-rank-side em { background: #4aa8ff; color: #021424; }

/* reduce motion */
body.reduce *, body.reduce *::before, body.reduce *::after { animation-duration: 0.001s !important; animation-iteration-count: 1 !important; transition-duration: 0.001s !important; scroll-behavior: auto !important; }
@media (prefers-reduced-motion: reduce) { *, *::before, *::after { animation-duration: 0.001s !important; animation-iteration-count: 1 !important; transition-duration: 0.001s !important; } }

/* larger interface sizes: keep the bottom row from colliding */
html[data-ui="125"] .hud-tools { bottom: 96px; } html[data-ui="150"] .hud-tools { bottom: 128px; }
html[data-ui="125"] .hint, html[data-ui="150"] .hint { display: none; }
