/* VANTA SHIFT — menus, screens, overlays. No external requests: fonts are self-hosted subsets. */
@font-face { font-family: 'VS Display'; src: url('../fonts/anton.woff2') format('woff2'); font-display: swap; font-weight: 400; }
@font-face { font-family: 'VS Brand'; src: url('../fonts/brand.woff2') format('woff2'); font-display: swap; font-weight: 800; }

:root {
  --bg: #050506;
  --ink: #e4e1da;
  --ink-dim: #8d8a84;
  --line: rgba(228, 225, 218, 0.16);
  --line-2: rgba(228, 225, 218, 0.32);
  --red: #e0261b;
  --amber: #e9b45a;
  --panel: rgba(10, 10, 12, 0.82);
  --mono: ui-monospace, 'SFMono-Regular', 'Cascadia Mono', Menlo, Consolas, 'DejaVu Sans Mono', 'Liberation Mono', monospace;
  --disp: 'VS Display', 'Anton', Impact, 'Arial Narrow', 'Helvetica Neue', sans-serif;
  --sa-t: env(safe-area-inset-top, 0px);
  --sa-r: env(safe-area-inset-right, 0px);
  --sa-b: env(safe-area-inset-bottom, 0px);
  --sa-l: env(safe-area-inset-left, 0px);
}
*, *::before, *::after { box-sizing: border-box; }
html, body {
  margin: 0; padding: 0; width: 100%; height: 100%; overflow: hidden;
  background: var(--bg); color: var(--ink);
  font-family: var(--mono); font-size: 14px; line-height: 1.35;
  -webkit-font-smoothing: antialiased; -webkit-text-size-adjust: 100%;
  overscroll-behavior: none; touch-action: manipulation;
  -webkit-tap-highlight-color: transparent;
}
body.in-game { touch-action: none; -webkit-user-select: none; user-select: none; -webkit-touch-callout: none; cursor: default; }
button, input { font: inherit; color: inherit; }
button { cursor: pointer; -webkit-user-select: none; user-select: none; -webkit-touch-callout: none; }
[hidden] { display: none !important; }
.mono { font-family: var(--mono); }
.dim { color: var(--ink-dim); }
.small { font-size: 12px; }
.row { display: flex; gap: 8px; flex-wrap: wrap; align-items: center; }
.stack { display: flex; flex-direction: column; gap: 8px; }

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

/* ?debug badge (scores are never submitted in this mode) */
#debug-badge {
  position: fixed; z-index: 60; left: 50%; top: calc(4px + var(--sa-t)); transform: translateX(-50%); pointer-events: none;
  padding: 1px 7px; border: 1px solid rgba(233,180,90,0.7); border-radius: 2px; background: rgba(0,0,0,0.6);
  color: var(--amber); font-size: 10px; letter-spacing: 0.2em; line-height: 1.5;
}

/* Menu VHS overlay (noise, scanlines, vignette) */
#fx-overlay { position: fixed; inset: 0; pointer-events: none; z-index: 1; }
body.in-game #fx-overlay { display: none; }
#fx-overlay .noise {
  position: absolute; inset: -50%; opacity: 0.045; mix-blend-mode: screen;
  background-image: url("data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' width='160' height='160'><filter id='n'><feTurbulence type='fractalNoise' baseFrequency='0.9' numOctaves='2' stitchTiles='stitch'/><feColorMatrix values='0 0 0 0 1  0 0 0 0 1  0 0 0 0 1  0 0 0 1.4 -0.2'/></filter><rect width='100%' height='100%' filter='url(%23n)'/></svg>");
  animation: noise 0.9s steps(6) infinite;
}
#fx-overlay .scan { position: absolute; inset: 0; background: repeating-linear-gradient(0deg, rgba(0,0,0,0.22) 0 1px, transparent 1px 3px); opacity: 0.5; }
#fx-overlay .vig { position: absolute; inset: 0; background: radial-gradient(ellipse at 50% 45%, transparent 35%, rgba(0,0,0,0.55) 75%, rgba(0,0,0,0.9) 100%); }
@keyframes noise { 0% { transform: translate(0,0); } 20% { transform: translate(-6%,4%); } 40% { transform: translate(5%,-7%); } 60% { transform: translate(-3%,8%); } 80% { transform: translate(7%,2%); } 100% { transform: translate(0,0); } }

/* Screens */
.screen { position: fixed; inset: 0; z-index: 10; display: none; }
.screen.on { display: block; animation: screenIn 0.35s ease-out; }
@keyframes screenIn { from { opacity: 0; } to { opacity: 1; } }

/* Logo */
.logo {
  font-family: var(--disp); font-weight: 400; margin: 0; line-height: 0.9; letter-spacing: 0.06em; white-space: nowrap;
  font-size: clamp(46px, 8.4vw, 118px); color: #ece9e2; display: flex;
  text-shadow: 0 0 18px rgba(255, 245, 225, 0.18), 0 0 2px rgba(255,255,255,0.4);
  animation: logoGlitch 7s infinite steps(1);
}
.logo span { display: inline-block; }
.logo .gap { flex: 0 0 0.3em; width: 0.3em; }
.logo .flick { animation: flick 4.2s infinite; }
.logo-sm { font-size: clamp(34px, 6vw, 64px); justify-content: center; }
@keyframes flick {
  0%, 18%, 22%, 25%, 53%, 57%, 100% { opacity: 1; text-shadow: 0 0 22px rgba(255,240,210,0.55), 0 0 2px #fff; }
  20%, 24%, 55% { opacity: 0.12; text-shadow: none; }
  70% { opacity: 0.85; } 71% { opacity: 0.25; } 72% { opacity: 1; }
}
@keyframes logoGlitch {
  0%, 91%, 100% { transform: none; text-shadow: 0 0 18px rgba(255,245,225,0.18), 0 0 2px rgba(255,255,255,0.4); }
  92% { transform: translateX(3px) skewX(-6deg); text-shadow: -3px 0 rgba(224,38,27,0.75), 3px 0 rgba(80,180,255,0.6); }
  93% { transform: translateX(-2px); text-shadow: 2px 0 rgba(224,38,27,0.75), -2px 0 rgba(80,180,255,0.6); }
  94% { transform: none; }
}
.tagline { margin: 10px 0 0; color: var(--ink-dim); letter-spacing: 0.18em; text-transform: uppercase; font-size: clamp(11px, 1.1vw, 13px); }

/* Boot */
#boot { background: #000; z-index: 30; }
.boot-inner { position: absolute; left: 50%; top: 50%; transform: translate(-50%, -50%); width: min(420px, 86vw); text-align: center; }
.boot-bar { margin: 26px auto 12px; height: 2px; background: rgba(255,255,255,0.1); overflow: hidden; }
.boot-bar i { display: block; height: 100%; width: 0; background: var(--ink); box-shadow: 0 0 12px rgba(255,255,255,0.6); transition: width 0.25s ease; }
#boot-text { font-size: 11px; letter-spacing: 0.2em; min-height: 1.4em; }

/* Bodycam frame on the menu */
.cam-frame { position: absolute; inset: calc(14px + var(--sa-t)) calc(14px + var(--sa-r)) calc(14px + var(--sa-b)) calc(14px + var(--sa-l)); pointer-events: none; }
.cf { position: absolute; width: 26px; height: 26px; border-color: rgba(255,255,255,0.5); border-style: solid; border-width: 0; }
.cf.tl { left: 0; top: 0; border-left-width: 2px; border-top-width: 2px; }
.cf.tr { right: 0; top: 0; border-right-width: 2px; border-top-width: 2px; }
.cf.bl { left: 0; bottom: 0; border-left-width: 2px; border-bottom-width: 2px; }
.cf.br { right: 0; bottom: 0; border-right-width: 2px; border-bottom-width: 2px; }
/* REC / camera line: in normal flow above the menu so it can never overlap the form */
.menu-top {
  flex: 0 0 auto; display: flex; flex-direction: column; align-items: flex-end; gap: 4px; pointer-events: none;
  padding: calc(22px + var(--sa-t)) calc(50px + var(--sa-r)) 0 calc(50px + var(--sa-l));
}
.cam-meta { font-size: 12px; letter-spacing: 0.08em; display: flex; align-items: center; gap: 6px; white-space: nowrap; line-height: 16px; }
.cam-meta2 { font-size: 11px; color: var(--ink-dim); letter-spacing: 0.08em; white-space: nowrap; line-height: 14px; }
.rec-dot { display: inline-block; width: 9px; height: 9px; border-radius: 50%; background: var(--red); box-shadow: 0 0 8px var(--red); animation: rec 1.2s steps(1) infinite; }
@keyframes rec { 0%, 60% { opacity: 1; } 61%, 100% { opacity: 0.15; } }

/* Main menu layout */
#menu { background: linear-gradient(90deg, rgba(0,0,0,0.78) 0%, rgba(0,0,0,0.35) 45%, rgba(0,0,0,0) 70%); overflow-x: hidden; overflow-y: auto; }
/* Menu = column: REC line / form (centred in the free space) / brand. Nothing is absolutely positioned
   over the form, so at no viewport size can these overlap; if space runs out the screen scrolls. */
#menu.on { display: flex; flex-direction: column; }
.menu-wrap {
  position: relative; flex: 0 0 auto; margin: auto 0 auto calc(max(5.5vw, 28px) + var(--sa-l));
  width: min(460px, calc(100vw - 56px - var(--sa-l) - var(--sa-r)));
  display: flex; flex-direction: column; gap: 24px; padding: 12px 0;
}
.menu-bottom { flex: 0 0 auto; display: flex; justify-content: flex-end; padding: 0 calc(28px + var(--sa-r)) calc(22px + var(--sa-b)) calc(28px + var(--sa-l)); }
.menu-body { display: flex; flex-direction: column; gap: 14px; }
.field { display: flex; flex-direction: column; gap: 6px; }
.field-label { font-size: 10.5px; letter-spacing: 0.22em; color: var(--ink-dim); text-transform: uppercase; }
.field-label b { color: var(--ink); font-weight: 600; letter-spacing: 0.05em; margin-left: 6px; }
.name-field input, .code-input {
  height: 42px; padding: 0 14px; background: rgba(0,0,0,0.5); border: 1px solid var(--line-2); border-radius: 2px;
  outline: none; font-size: 15px; letter-spacing: 0.08em; transition: border-color 0.2s, box-shadow 0.2s; width: 100%; min-width: 0;
}
.name-field input:focus, .code-input:focus { border-color: var(--ink); box-shadow: 0 0 0 3px rgba(255,255,255,0.06); }
.menu-list { display: flex; flex-direction: column; gap: 6px; }
.mbtn {
  position: relative; overflow: hidden; display: flex; align-items: baseline; justify-content: space-between; gap: 12px;
  min-height: 46px; padding: 10px 16px 10px 18px; text-align: left; border: 1px solid var(--line); border-radius: 2px;
  background: linear-gradient(90deg, rgba(255,255,255,0.045), rgba(255,255,255,0.01)); transition: border-color 0.2s, background 0.2s, transform 0.15s;
}
.mbtn::before { content: ''; position: absolute; left: 0; top: 0; bottom: 0; width: 2px; background: var(--ink-dim); transition: background 0.2s, box-shadow 0.2s; }
.mbtn::after {
  content: ''; position: absolute; top: 0; bottom: 0; left: -40%; width: 40%;
  background: linear-gradient(90deg, transparent, rgba(255,248,230,0.12), transparent); transform: skewX(-20deg); opacity: 0; transition: none;
}
.mbtn:hover, .mbtn:focus-visible { border-color: var(--line-2); background: linear-gradient(90deg, rgba(255,255,255,0.09), rgba(255,255,255,0.02)); outline: none; }
.mbtn:hover::before, .mbtn:focus-visible::before { background: var(--ink); box-shadow: 0 0 10px rgba(255,255,255,0.6); }
.mbtn:hover::after { opacity: 1; animation: sweep 0.9s ease-out; }
.mbtn:active { transform: translateX(2px); }
@keyframes sweep { from { left: -40%; } to { left: 120%; } }
.mbtn b { font-family: var(--disp); font-weight: 400; font-size: 21px; letter-spacing: 0.06em; text-transform: uppercase; white-space: nowrap; }
.mbtn small { font-size: 11px; color: var(--ink-dim); letter-spacing: 0.05em; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; min-width: 0; }
.mbtn.primary { border-color: rgba(224,38,27,0.55); background: linear-gradient(90deg, rgba(224,38,27,0.2), rgba(224,38,27,0.03)); }
.mbtn.primary::before { background: var(--red); box-shadow: 0 0 10px rgba(224,38,27,0.8); }
.mbtn.danger b { color: #ff8c84; }
.mbtn[disabled] { opacity: 0.5; pointer-events: none; }
.menu-foot { display: flex; align-items: center; gap: 14px; flex-wrap: wrap; min-height: 24px; }
.link-btn { background: none; border: 0; padding: 4px 0; color: var(--ink-dim); font-size: 12px; letter-spacing: 0.12em; text-transform: uppercase; border-bottom: 1px solid transparent; }
.link-btn:hover { color: var(--ink); border-bottom-color: var(--ink-dim); }
.install-btn { color: var(--amber); }
.ios-hint { font-size: 11.5px; color: var(--ink-dim); }
.ios-hint b { color: var(--ink); font-weight: 600; }
.ver { margin-left: auto; font-size: 10.5px; color: rgba(255,255,255,0.3); }

/* Brand signature: </> code by dagasan */
.brand {
  display: inline-flex; align-items: center; gap: 9px; text-decoration: none; color: var(--ink);
  padding: 6px 10px 6px 6px; border-radius: 8px; opacity: 0.9; transition: opacity 0.2s, background 0.2s;
}
.brand:hover { opacity: 1; background: rgba(255,255,255,0.04); }
.b-mark {
  display: inline-grid; place-items: center; width: 30px; height: 30px; border-radius: 8px;
  background: linear-gradient(145deg, #17181c, #0b0b0d); border: 1px solid rgba(255,255,255,0.14);
  font-family: 'VS Brand', var(--mono); font-weight: 800; font-size: 12px; letter-spacing: -0.04em; color: #fff;
  box-shadow: inset 0 1px 0 rgba(255,255,255,0.08), 0 4px 14px rgba(0,0,0,0.5);
  animation: markIn 0.7s cubic-bezier(.2,.8,.2,1) both;
}
.b-txt { display: inline-flex; flex-direction: column; line-height: 1; }
.b-small { font-size: 9px; letter-spacing: 0.24em; color: var(--ink-dim); text-transform: uppercase; animation: fadeUp 0.6s 0.2s both; }
.b-name {
  position: relative; font-family: 'VS Brand', var(--mono); font-weight: 800; font-size: 17px; letter-spacing: 0.01em; margin-top: 3px;
}
.b-name i { font-style: normal; display: inline-block; opacity: 0; transform: translateY(6px); filter: blur(3px); animation: letterIn 0.5s cubic-bezier(.2,.8,.2,1) forwards; animation-delay: calc(0.35s + var(--i) * 0.07s); }
.b-name::after {
  content: attr(data-text); position: absolute; inset: 0; color: transparent; pointer-events: none;
  background: linear-gradient(100deg, transparent 0%, transparent 40%, rgba(255,255,255,0.95) 50%, transparent 60%, transparent 100%);
  background-size: 250% 100%; -webkit-background-clip: text; background-clip: text;
  animation: lightSweep 4.5s 1.3s ease-in-out infinite;
}
.b-cursor { width: 2px; height: 18px; background: var(--red); align-self: flex-end; margin-bottom: 1px; animation: blink 1s steps(1) infinite, fadeUp 0.3s 0.9s both; box-shadow: 0 0 6px rgba(224,38,27,0.8); }
@keyframes letterIn { to { opacity: 1; transform: none; filter: none; } }
@keyframes markIn { from { opacity: 0; transform: scale(0.6) rotate(-12deg); } to { opacity: 1; transform: none; } }
@keyframes fadeUp { from { opacity: 0; transform: translateY(4px); } to { opacity: 1; transform: none; } }
@keyframes lightSweep { 0% { background-position: 120% 0; } 45%, 100% { background-position: -120% 0; } }
@keyframes blink { 0%, 50% { opacity: 1; } 51%, 100% { opacity: 0; } }
.brand-menu { position: relative; }

/* Panels / modals */
.panel, .modal-card {
  position: absolute; left: 50%; top: 50%; transform: translate(-50%, -50%);
  width: min(640px, calc(100vw - 24px - var(--sa-l) - var(--sa-r))); max-height: calc(100dvh - 24px - var(--sa-t) - var(--sa-b));
  overflow-x: hidden; overflow-y: auto; overscroll-behavior: contain;
  background: var(--panel); border: 1px solid var(--line); border-radius: 3px; padding: 22px 24px;
  box-shadow: 0 30px 80px rgba(0,0,0,0.7); -webkit-backdrop-filter: blur(6px); backdrop-filter: blur(6px);
}
.panel h2, .modal-card h2 { font-family: var(--disp); font-weight: 400; font-size: 28px; letter-spacing: 0.08em; margin: 0; }
.panel-head { display: flex; align-items: center; justify-content: space-between; gap: 12px; margin-bottom: 16px; }
.x-btn { width: 36px; height: 36px; flex: 0 0 36px; border: 1px solid var(--line); background: rgba(255,255,255,0.03); border-radius: 2px; font-size: 14px; }
.x-btn:hover { border-color: var(--line-2); }
.sbtn { min-height: 36px; padding: 6px 14px; border: 1px solid var(--line-2); background: rgba(255,255,255,0.05); border-radius: 2px; font-size: 12.5px; letter-spacing: 0.04em; }
.sbtn:hover { background: rgba(255,255,255,0.1); }
.modal { position: fixed; inset: 0; z-index: 40; background: rgba(0,0,0,0.55); animation: screenIn 0.2s ease-out; }
.modal-card { width: min(760px, calc(100vw - 24px - var(--sa-l) - var(--sa-r))); }
.modal-card.narrow { width: min(420px, calc(100vw - 24px - var(--sa-l) - var(--sa-r))); }

/* Lobby */
#lobby { background: rgba(0,0,0,0.45); }
.lobby-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 22px; }
.lobby-code-box { display: flex; flex-direction: column; gap: 10px; min-width: 0; }
.lobby-code { font-size: clamp(34px, 6vw, 50px); letter-spacing: 0.18em; font-weight: 700; color: #fff; text-shadow: 0 0 16px rgba(255,255,255,0.25); white-space: nowrap; }
.lobby-players { min-width: 0; }
#lobby-list { list-style: none; margin: 10px 0 0; padding: 0; display: flex; flex-direction: column; gap: 6px; }
#lobby-list li { display: flex; align-items: center; justify-content: space-between; gap: 10px; padding: 9px 12px; border: 1px solid var(--line); background: rgba(255,255,255,0.03); min-width: 0; }
#lobby-list li span { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; min-width: 0; }
#lobby-list li em { font-style: normal; font-size: 11px; letter-spacing: 0.15em; color: var(--ink-dim); flex: 0 0 auto; }
#lobby-list li.ready em { color: #7dff9a; }
#lobby-list li.you span::after { content: ' (sen)'; color: var(--ink-dim); }
.lobby-actions { display: flex; align-items: center; gap: 16px; margin-top: 20px; flex-wrap: wrap; }
.ready-btn { min-width: 180px; justify-content: center; }
.ready-btn.on { border-color: rgba(125,255,154,0.6); background: linear-gradient(90deg, rgba(60,200,100,0.22), rgba(60,200,100,0.04)); }
.ready-btn.on::before { background: #7dff9a; box-shadow: 0 0 10px rgba(125,255,154,0.8); }

/* Pause / over */
#pause, #over { background: rgba(0,0,0,0.6); }
.pause-panel { width: min(380px, calc(100vw - 24px)); }
.pause-panel h2 { margin-bottom: 6px; }
.pause-panel .stack { margin-top: 16px; }
.over-panel { width: min(720px, calc(100vw - 24px - var(--sa-l) - var(--sa-r))); }
.over-head { margin-bottom: 14px; }
.over-head .mono { font-size: 11px; letter-spacing: 0.2em; }
.over-title { color: #fff; font-size: clamp(30px, 5vw, 46px) !important; text-shadow: -2px 0 rgba(224,38,27,0.6), 2px 0 rgba(80,180,255,0.4); }
.over-stats { display: grid; grid-template-columns: repeat(4, 1fr); gap: 8px; margin-bottom: 16px; }
.over-stats div { border: 1px solid var(--line); padding: 10px 12px; background: rgba(255,255,255,0.03); min-width: 0; }
.over-stats span { display: block; font-size: 10px; letter-spacing: 0.2em; color: var(--ink-dim); }
.over-stats b { font-family: var(--disp); font-weight: 400; font-size: 28px; letter-spacing: 0.04em; }
.table-wrap { width: 100%; overflow: hidden; }
.ptable { width: 100%; border-collapse: collapse; table-layout: fixed; font-size: 12.5px; }
.ptable th { font-size: 10px; letter-spacing: 0.16em; color: var(--ink-dim); text-align: right; font-weight: 500; padding: 6px 8px; border-bottom: 1px solid var(--line); }
.ptable th:first-child, .ptable td:first-child { text-align: left; width: 36%; }
.ptable td { text-align: right; padding: 8px; border-bottom: 1px solid rgba(255,255,255,0.05); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.ptable tr.you td { color: #fff; }
.over-actions { margin-top: 18px; }
.over-actions .mbtn { flex: 1 1 180px; justify-content: center; }

/* Join */
.join-form { display: flex; flex-direction: column; gap: 10px; }
.code-input { font-size: 28px; height: 58px; text-align: center; letter-spacing: 0.4em; text-transform: uppercase; }
.join-form .mbtn { justify-content: center; margin-top: 4px; }

/* Settings */
.settings { display: grid; grid-template-columns: 1fr 1fr; gap: 6px 28px; }
.set-col { display: flex; flex-direction: column; gap: 14px; min-width: 0; }
body:not(.is-touch) .touch-only { display: none; }
.set-touch { margin-top: 18px; padding-top: 16px; border-top: 1px solid rgba(255,255,255,0.1); }
.set-edit { align-self: flex-start; }
.set-row { display: flex; flex-direction: column; gap: 8px; min-width: 0; }
.seg { display: grid; grid-template-columns: repeat(4, 1fr); border: 1px solid var(--line-2); border-radius: 2px; overflow: hidden; }
.seg button { padding: 9px 4px; background: transparent; border: 0; border-right: 1px solid var(--line); font-size: 12px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; min-width: 0; }
.seg button:last-child { border-right: 0; }
.seg button.on { background: rgba(255,255,255,0.14); color: #fff; }
input[type=range] { -webkit-appearance: none; appearance: none; width: 100%; height: 22px; background: transparent; margin: 0; }
input[type=range]::-webkit-slider-runnable-track { height: 2px; background: var(--line-2); }
input[type=range]::-moz-range-track { height: 2px; background: var(--line-2); }
input[type=range]::-webkit-slider-thumb { -webkit-appearance: none; width: 16px; height: 16px; margin-top: -7px; border-radius: 50%; background: var(--ink); box-shadow: 0 0 8px rgba(255,255,255,0.4); }
input[type=range]::-moz-range-thumb { width: 16px; height: 16px; border-radius: 50%; border: 0; background: var(--ink); }
.toggle { flex-direction: row; align-items: center; justify-content: space-between; cursor: pointer; gap: 12px; }
.toggle > span { font-size: 13px; min-width: 0; }
.toggle input { position: absolute; opacity: 0; pointer-events: none; }
.toggle i { flex: 0 0 38px; width: 38px; height: 20px; border-radius: 10px; background: rgba(255,255,255,0.14); position: relative; transition: background 0.2s; }
.toggle i::after { content: ''; position: absolute; left: 3px; top: 3px; width: 14px; height: 14px; border-radius: 50%; background: #bbb; transition: transform 0.2s, background 0.2s; }
.toggle input:checked + i { background: rgba(224,38,27,0.55); }
.toggle input:checked + i::after { transform: translateX(18px); background: #fff; }
.set-note { margin: 16px 0 0; }
.set-brand { display: flex; justify-content: flex-end; margin-top: 10px; }

/* Help */
.help { display: grid; grid-template-columns: 1fr 1fr; gap: 24px; }
.help h3 { font-family: var(--disp); font-weight: 400; letter-spacing: 0.1em; font-size: 16px; margin: 0 0 10px; color: var(--ink); }
.help dl { display: grid; grid-template-columns: auto 1fr; gap: 6px 14px; margin: 0 0 16px; font-size: 12.5px; }
.help dt { color: #fff; white-space: nowrap; }
.help dd { margin: 0; color: var(--ink-dim); }
.help p { color: var(--ink-dim); margin: 0; }
.help p b { color: var(--ink); }

/* Leaderboard */
.lb-tabs { display: grid; grid-template-columns: 1fr 1fr; margin-bottom: 12px; }
.lb-empty { padding: 26px 0; text-align: center; color: var(--ink-dim); }

/* Overlays */
.overlay { position: fixed; inset: 0; z-index: 35; display: grid; place-items: center; background: rgba(0,0,0,0.55); }
#clickplay { cursor: pointer; background: rgba(0,0,0,0.35); }
.cp-inner, .rot-inner, .busy-inner { display: flex; flex-direction: column; align-items: center; gap: 8px; text-align: center; padding: 22px 28px; background: var(--panel); border: 1px solid var(--line); max-width: calc(100vw - 32px); }
.cp-inner b, .rot-inner b { font-family: var(--disp); font-weight: 400; letter-spacing: 0.08em; font-size: 26px; }
#rotate { z-index: 45; background: rgba(0,0,0,0.88); }
.rot-icon { width: 38px; height: 62px; border: 2px solid var(--ink); border-radius: 7px; animation: rot 2.2s ease-in-out infinite; margin-bottom: 8px; }
@keyframes rot { 0%, 30% { transform: rotate(0); } 60%, 100% { transform: rotate(-90deg); } }
#busy { z-index: 50; }
.busy-inner { flex-direction: row; gap: 14px; font-size: 12px; letter-spacing: 0.16em; }
.spinner { width: 14px; height: 14px; border: 2px solid var(--line-2); border-top-color: var(--ink); border-radius: 50%; animation: spin 0.8s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }

/* Toasts */
#toasts { position: fixed; left: 50%; top: calc(16px + var(--sa-t)); transform: translateX(-50%); z-index: 60; display: flex; flex-direction: column; align-items: center; gap: 8px; pointer-events: none; width: min(460px, calc(100vw - 24px)); }
.toast { padding: 9px 14px; background: rgba(8,8,10,0.92); border: 1px solid var(--line-2); border-left: 2px solid var(--amber); font-size: 12.5px; letter-spacing: 0.03em; animation: toastIn 0.25s ease-out; max-width: 100%; pointer-events: auto; display: flex; gap: 12px; align-items: center; }
.toast.err { border-left-color: var(--red); }
.toast button { flex: 0 0 auto; }
.toast.out { opacity: 0; transform: translateY(-6px); transition: opacity 0.3s, transform 0.3s; }
@keyframes toastIn { from { opacity: 0; transform: translateY(-8px); } to { opacity: 1; transform: none; } }
.noscript { position: fixed; inset: 0; display: grid; place-items: center; z-index: 100; background: #000; }

/* ---------- Responsive ---------- */
@media (max-width: 700px) {
  #menu { background: linear-gradient(180deg, rgba(0,0,0,0.55), rgba(0,0,0,0.7)); }
  .menu-wrap { margin: auto; width: calc(100vw - 40px - var(--sa-l) - var(--sa-r)); gap: 16px; }
  .menu-top { align-items: center; padding-top: calc(20px + var(--sa-t)); }
  .menu-head { text-align: center; }
  .logo:not(.logo-sm) { justify-content: center; font-size: clamp(40px, 13vw, 64px); }
  .mbtn { min-height: 42px; padding: 8px 14px; }
  .mbtn b { font-size: 18px; }
  .menu-bottom { justify-content: center; padding-bottom: calc(12px + var(--sa-b)); }
  .cam-meta2 { display: none; }
  .lobby-grid, .settings, .help { grid-template-columns: 1fr; }
  .over-stats { grid-template-columns: repeat(2, 1fr); }
  .ptable th:nth-child(3), .ptable td:nth-child(3), .ptable th:nth-child(5), .ptable td:nth-child(5) { display: none; }
  .panel, .modal-card { padding: 18px 16px; }
}
@media (max-width: 380px) {
  .mbtn small { display: none; }
}
/* laptops (768–960 px tall): the whole menu, Ayarlar and the brand included, fits without scrolling */
@media (min-height: 561px) and (max-height: 960px) and (min-width: 701px) {
  .menu-wrap { gap: 16px; padding: 6px 0; }
  .logo:not(.logo-sm) { font-size: clamp(56px, 10.5vh, 96px); }
  .menu-body { gap: 10px; }
  .menu-list { display: grid; grid-template-columns: 1fr 1fr; gap: 6px; }
  .menu-list .mbtn.primary { grid-column: 1 / -1; }
  .menu-wrap { width: min(560px, calc(100vw - 56px - var(--sa-l) - var(--sa-r))); }
  .mbtn { min-height: 42px; padding: 7px 12px 7px 14px; flex-direction: column; align-items: flex-start; gap: 0; justify-content: center; }
  .mbtn b { font-size: 18px; }
  .mbtn small { font-size: 10px; max-width: 100%; }
  .name-field input { height: 38px; }
}
@media (max-height: 560px) and (min-width: 560px) {
  .menu-wrap {
    display: grid; grid-template-columns: minmax(0, 0.9fr) minmax(0, 1.1fr); align-items: center; gap: 28px;
    width: min(920px, calc(100vw - 64px - var(--sa-l) - var(--sa-r))); margin: auto; padding: 6px 0;
  }
  .menu-head { text-align: left; }
  .logo:not(.logo-sm) { font-size: clamp(40px, 7vw, 76px); justify-content: flex-start; }
  .menu-body { gap: 10px; }
  .menu-list { display: grid; grid-template-columns: 1fr 1fr; gap: 6px; }
  .mbtn { min-height: 40px; padding: 7px 12px; flex-direction: column; align-items: flex-start; gap: 0; justify-content: center; }
  .mbtn b { font-size: 17px; }
  .mbtn small { font-size: 10px; max-width: 100%; }
  .name-field input { height: 36px; }
  .menu-top { padding-top: calc(16px + var(--sa-t)); align-items: flex-end; }
  .menu-bottom { padding: 0 calc(16px + var(--sa-r)) calc(8px + var(--sa-b)) calc(16px + var(--sa-l)); justify-content: flex-end; }
  .brand-menu { padding: 2px 8px 2px 4px; }
  .brand-menu .b-mark { width: 26px; height: 26px; }
  .cam-meta2 { display: none; }
  .settings, .help { grid-template-columns: 1fr 1fr; }
  .lobby-grid { grid-template-columns: 1fr 1fr; }
  .panel, .modal-card { padding: 14px 18px; }
  .panel-head { margin-bottom: 10px; }
  .over-stats { grid-template-columns: repeat(4, 1fr); }
  .over-stats b { font-size: 22px; }
}
@media (max-height: 420px) and (min-width: 560px) {
  .tagline { display: none; }
  .menu-foot { min-height: 0; }
  .menu-top { padding-top: calc(14px + var(--sa-t)); }
  .menu-wrap { gap: 18px; padding: 2px 0; }
  .menu-body { gap: 8px; }
  .mbtn { min-height: 36px; padding: 5px 12px; }
  .mbtn b { font-size: 16px; }
  .menu-list { grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 5px; }
  .mbtn small { display: none; }
  .mbtn b { font-size: 14px; letter-spacing: 0.02em; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; max-width: 100%; }
  .name-field { gap: 4px; }
  .name-field input { height: 34px; }
  .menu-foot { gap: 10px; flex-wrap: nowrap; min-width: 0; }
  .ios-hint { min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; font-size: 10.5px; }
  .menu-foot .link-btn { padding: 2px 0; }
}
@media (max-height: 340px) and (min-width: 560px) {
  .menu-top { padding-top: calc(10px + var(--sa-t)); }
  .mbtn { min-height: 34px; padding: 4px 12px; }
  .mbtn b { font-size: 15px; }
  .mbtn small { font-size: 9.5px; }
  .menu-wrap { gap: 14px; }
  .menu-bottom { padding-bottom: calc(4px + var(--sa-b)); }
}
@media (prefers-reduced-motion: reduce) {
  .logo, .logo .flick, #fx-overlay .noise, .b-name::after { animation: none !important; }
}

/* Readable menu over a bright scene (phones get a brighter world) */
.mbtn { background: linear-gradient(90deg, rgba(8,8,10,0.78), rgba(8,8,10,0.55)); -webkit-backdrop-filter: blur(3px); backdrop-filter: blur(3px); }
.mbtn b { text-shadow: 0 1px 2px rgba(0,0,0,0.7); }
.mbtn small { color: rgba(235,235,235,0.72); }
.mbtn.primary { background: linear-gradient(90deg, rgba(120,16,10,0.78), rgba(30,8,8,0.6)); }
.arena-btn { background: linear-gradient(90deg, rgba(70,52,10,0.78), rgba(20,16,8,0.6)); }
.name-field input { background: rgba(0,0,0,0.72); }
.field-label, .menu-foot .link-btn, .ver { text-shadow: 0 1px 2px rgba(0,0,0,0.9); }
body.is-touch #menu { background: linear-gradient(90deg, rgba(0,0,0,0.82) 0%, rgba(0,0,0,0.6) 50%, rgba(0,0,0,0.45) 100%); }

/* Lobby on short (landscape phone) screens: everything incl. HAZIRIM fits without scrolling */
@media (max-height: 460px) {
  #lobby .panel { padding: 12px 16px; }
  #lobby .panel-head { margin-bottom: 6px; }
  #lobby .panel h2 { font-size: 22px; }
  .lobby-grid { gap: 14px; }
  .lobby-code-box { gap: 6px; }
  .lobby-code { font-size: 30px; }
  .lobby-code-box .row { display: flex; flex-wrap: wrap; gap: 6px; }
  #lobby-hint { display: none; }
  #lobby-list { margin-top: 6px; gap: 4px; }
  #lobby-list li { padding: 5px 10px; }
  .lobby-actions { margin-top: 10px; }
  .ready-btn { min-height: 38px; }
}
