/* ==========================================================================
   Design-system components
   ========================================================================== */

/* ---- labels / tags ---- */
.label {
  font-family: var(--font-mono);
  font-size: 11px;
  font-weight: 700;
  letter-spacing: 0.22em;
  color: var(--text-dim);
  text-transform: uppercase;
}
.tag {
  display: inline-flex;
  align-items: center;
  height: 18px;
  padding: 0 6px;
  font-family: var(--font-mono);
  font-size: 10px;
  font-weight: 700;
  letter-spacing: 0.12em;
  border: 1px solid currentColor;
  line-height: 1;
  white-space: nowrap;
}
.tag-host { color: var(--yellow); }
.tag-you { color: var(--cyan); }
.tag-lost { color: var(--red); animation: blink 1.2s steps(2) infinite; }
.tag-dim { color: var(--text-dim); border-color: var(--line-2); }
@keyframes blink { 50% { opacity: 0.35; } }

/* ---- buttons (chamfered) ---- */
.btn {
  --b: var(--accent);
  position: relative;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 10px;
  min-height: 48px;
  padding: 0 22px;
  font-family: var(--font-display);
  font-weight: 700;
  font-size: 14px;
  letter-spacing: 0.16em;
  text-transform: uppercase;
  clip-path: polygon(var(--cut) 0, 100% 0, 100% calc(100% - var(--cut)), calc(100% - var(--cut)) 100%, 0 100%, 0 var(--cut));
  transition: transform 0.12s var(--ease), opacity 0.2s;
  isolation: isolate;
}
.btn:active { transform: scale(0.97); }
.btn-primary {
  color: var(--accent-ink);
  background: var(--b);
  box-shadow: 0 0 24px var(--accent-glow);
}
.btn-primary::after {     /* moving sheen — transform only */
  content: '';
  position: absolute;
  inset: 0;
  background: linear-gradient(100deg, transparent 30%, rgba(255, 255, 255, 0.55) 50%, transparent 70%);
  transform: translateX(-120%);
  animation: sheen 3.6s var(--ease) infinite;
  z-index: -1;
  mix-blend-mode: soft-light;
}
@keyframes sheen { 0%, 60% { transform: translateX(-120%); } 100% { transform: translateX(120%); } }
.btn-ghost {
  color: var(--b);
  background: var(--b);
}
.btn-ghost::before {     /* inner fill leaves a 1.5px chamfered border */
  content: '';
  position: absolute;
  inset: 1.5px;
  background: var(--bg-1);
  clip-path: inherit;
  z-index: -1;
}
.btn-text {
  min-height: 44px;
  color: var(--text-dim);
  font-size: 12px;
  clip-path: none;
}
.btn-xl { min-height: 60px; font-size: 16px; }
.btn-sm { min-height: 40px; padding: 0 14px; font-size: 11px; letter-spacing: 0.12em; --cut: 8px; }
.btn-block { width: 100%; }
.btn.is-busy { opacity: 0.7; pointer-events: none; }
.btn.is-busy span::after { content: ''; display: inline-block; width: 0.6em; animation: blink 0.6s steps(2) infinite; }
.btn:disabled { opacity: 0.4; pointer-events: none; }

.icon-btn {
  display: grid;
  place-items: center;
  width: 44px;
  height: 44px;
  font-size: 26px;
  line-height: 1;
  color: var(--text);
  border: 1px solid var(--line-2);
  background: rgba(255, 255, 255, 0.02);
}
.icon-btn:active { transform: scale(0.94); }

/* ---- inputs ---- */
.input {
  width: 100%;
  height: 56px;
  padding: 0 16px;
  font-family: var(--font-display);
  font-size: 18px;       /* >=16px: iOS won't zoom */
  font-weight: 700;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  color: var(--text);
  background: rgba(4, 8, 22, 0.7);
  border: 1px solid var(--line-2);
  border-radius: 0;
  outline: none;
  caret-color: var(--accent);
  -webkit-appearance: none;
  appearance: none;
  transition: border-color 0.2s;
}
.input::placeholder { color: var(--text-faint); }
.input:focus { border-color: var(--accent); }
.input-code {
  height: 76px;
  font-size: 40px;
  text-align: center;
  letter-spacing: 0.5em;
  padding-left: 0.5em;
  color: var(--accent);
}

/* ---- panels ---- */
.panel {
  position: relative;
  background: var(--panel);
  border: 1px solid var(--line);
  padding: 16px;
}
.panel::before, .panel::after {
  content: '';
  position: absolute;
  width: 14px;
  height: 14px;
  border: 2px solid var(--accent);
  pointer-events: none;
}
.panel::before { top: -1px; left: -1px; border-right: 0; border-bottom: 0; }
.panel::after { bottom: -1px; right: -1px; border-left: 0; border-top: 0; }

/* ---- avatar + chip ---- */
.avatar {
  --s: 40px;
  position: relative;
  flex: none;
  display: block;
  width: var(--s);
  height: var(--s);
  color: var(--c);
}
/* the emblem (js/ui/components.js#avatar): its glow reaches a little past the box */
.avatar svg { display: block; width: 100%; height: 100%; overflow: visible; }

.chip {
  display: flex;
  align-items: center;
  gap: 12px;
  min-height: 60px;
  padding: 10px 12px;
  background: linear-gradient(90deg, color-mix(in srgb, var(--c) 10%, transparent), rgba(10, 15, 38, 0.6) 60%);
  border: 1px solid var(--line);
  border-left: 3px solid var(--c);
  transition: opacity 0.3s;
}
.chip-body { flex: 1; min-width: 0; }
.chip-name {
  font-family: var(--font-display);
  font-size: 15px;
  font-weight: 700;
  letter-spacing: 0.08em;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.chip-tags { display: flex; gap: 6px; margin-top: 4px; flex-wrap: wrap; }
.chip-tags:empty { display: none; }
.chip.is-offline { opacity: 0.55; }
.chip.is-offline .avatar { filter: grayscale(1); }

/* ---- timer ---- */
.timer { display: flex; align-items: center; gap: 10px; }
.timer-track {
  position: relative;
  flex: 1;
  height: 6px;
  background: rgba(255, 255, 255, 0.06);
  overflow: hidden;
}
.timer-fill {
  position: absolute;
  inset: 0;
  background: linear-gradient(90deg, var(--accent-2), var(--accent));
  transform-origin: 0 50%;
  box-shadow: 0 0 10px var(--accent-glow);
}
.timer-num {
  min-width: 3.2ch;
  font-family: var(--font-mono);
  font-weight: 700;
  font-size: 15px;
  text-align: right;
  font-variant-numeric: tabular-nums;
}
.timer.is-warn .timer-fill { background: var(--red); }
.timer.is-warn .timer-num { color: var(--red); animation: blink 0.5s steps(2) infinite; }
.timer.is-zero .timer-num { color: var(--text-faint); }

/* ---- toasts ---- */
.toasts {
  position: fixed;
  z-index: 100;
  top: calc(var(--safe-t) + 10px);
  left: 50%;
  width: min(92vw, 460px);
  transform: translateX(-50%);
  display: flex;
  flex-direction: column;
  gap: 8px;
  pointer-events: none;
}
.toast {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 12px 14px;
  font-family: var(--font-mono);
  font-size: 13px;
  font-weight: 700;
  letter-spacing: 0.06em;
  background: rgba(6, 10, 28, 0.94);
  border: 1px solid var(--line-2);
  border-left: 3px solid var(--cyan);
  animation: toast-in 0.32s var(--ease-back) both;
}
.toast-glyph { color: var(--cyan); }
.toast-ok { border-left-color: var(--green); } .toast-ok .toast-glyph { color: var(--green); }
.toast-warn { border-left-color: var(--yellow); } .toast-warn .toast-glyph { color: var(--yellow); }
.toast-err { border-left-color: var(--red); } .toast-err .toast-glyph { color: var(--red); }
.toast.out { opacity: 0; transform: translateY(-8px); transition: opacity 0.25s, transform 0.25s; }
@keyframes toast-in { from { opacity: 0; transform: translateY(-14px) scale(0.96); } }

/* ---- connection banner ---- */
.net {
  position: fixed;
  z-index: 95;
  left: 50%;
  top: calc(var(--safe-t) + 62px); /* below the gear button */
  display: flex;
  align-items: center;
  gap: 10px;
  max-width: calc(100vw - 32px);
  padding: 10px 16px;
  font-family: var(--font-mono);
  font-size: 12px;
  font-weight: 700;
  letter-spacing: 0.12em;
  white-space: nowrap;
  color: var(--text);
  background: rgba(20, 6, 14, 0.94);
  border: 1px solid rgba(255, 51, 85, 0.6);
  box-shadow: 0 10px 30px rgba(0, 0, 0, 0.5);
  transform: translate(-50%, -180%);
  opacity: 0;
  transition: transform 0.35s var(--ease), opacity 0.3s, border-color 0.3s;
  pointer-events: none;
}
.net.is-on { transform: translate(-50%, 0); opacity: 1; }
.net-dot { width: 8px; height: 8px; border-radius: 50%; background: var(--red); box-shadow: 0 0 10px var(--red); animation: blink 0.8s steps(2) infinite; }
.net.is-back { border-color: rgba(61, 255, 139, 0.6); background: rgba(4, 20, 12, 0.94); }
.net.is-back .net-dot { background: var(--green); box-shadow: 0 0 10px var(--green); animation: none; }

/* ---- segmented control ---- */
.seg { display: flex; gap: 6px; }
.seg-btn {
  flex: 1;
  min-height: 48px;
  font-family: var(--font-num);
  font-size: 18px;
  font-weight: 700;
  letter-spacing: 0.06em;
  color: var(--text-dim);
  border: 1px solid var(--line-2);
  background: rgba(255, 255, 255, 0.02);
  transition: transform 0.12s, color 0.15s, background-color 0.15s;
}
.seg-btn:active { transform: scale(0.96); }
.seg-btn.is-on { color: var(--accent-ink); background: var(--accent); border-color: var(--accent); }

/* ---- modal bottom sheet ---- */
.modal {
  position: fixed;
  inset: 0;
  z-index: 75; /* above the gear button */
  display: flex;
  align-items: flex-end;
  justify-content: center;
  background: rgba(2, 3, 10, 0.72);
  animation: fade-in 0.25s both;
}
.modal.out { opacity: 0; transition: opacity 0.25s; }
.modal .sheet { animation: sheet-up 0.38s var(--ease) both; }
.modal.out .sheet { transform: translateY(40px); transition: transform 0.25s; }
@keyframes fade-in { from { opacity: 0; } }
@keyframes sheet-up { from { transform: translateY(100%); } }
/* A sheet never grows past the screen (short phones, browser bars, extra room rows): it scrolls inside
   instead, so its top (and close button) can't end up above the screen edge. */
.modal > .sheet:not(.chat-sheet):not(.help) {
  max-height: calc(100dvh - var(--safe-t) - 10px);
  overflow-y: auto;
  overscroll-behavior: contain;
  -webkit-overflow-scrolling: touch;
}
.sheet {
  position: relative;
  width: 100%;
  max-width: var(--maxw);
  padding: 14px var(--gutter) calc(var(--safe-b) + 18px);
  background: linear-gradient(180deg, var(--bg-2), var(--bg-1));
  border-top: 2px solid var(--accent);
  box-shadow: 0 -10px 40px var(--accent-soft);
  display: flex;
  flex-direction: column;
  gap: 14px;
}
.sheet-grip { width: 44px; height: 4px; margin: 0 auto 4px; background: var(--line-2); }
.sheet-kicker {
  font-family: var(--font-mono);
  font-size: 11px;
  font-weight: 700;
  letter-spacing: 0.28em;
  color: var(--accent);
}
.sheet-title {
  font-family: var(--font-display);
  font-weight: 900;
  font-size: 26px;
  letter-spacing: 0.06em;
  line-height: 1.05;
}
.sheet-text { color: var(--text-dim); font-size: 15px; }
.options-meta { display: flex; justify-content: space-between; align-items: center; padding: 4px 0; }
.est { font-family: var(--font-num); font-weight: 700; color: var(--accent); letter-spacing: 0.1em; }
.field { display: flex; flex-direction: column; gap: 8px; }

/* ---- leaderboard ---- */
.board-list { display: flex; flex-direction: column; gap: 6px; counter-reset: lb; }
.lb-row {
  display: flex;
  align-items: center;
  gap: 10px;
  min-height: 50px;
  padding: 8px 12px;
  background: rgba(10, 15, 38, 0.72);
  border: 1px solid var(--line);
  border-left: 3px solid var(--c);
  animation: row-in 0.45s var(--ease) both;
}
.lb-row.is-me { background: linear-gradient(90deg, color-mix(in srgb, var(--c) 16%, transparent), rgba(10, 15, 38, 0.72)); }
.lb-row.is-first { border-color: color-mix(in srgb, var(--yellow) 50%, transparent); border-left-color: var(--c); }
.lb-rank { font-family: var(--font-mono); font-weight: 700; color: var(--text-dim); width: 2ch; }
.is-first .lb-rank { color: var(--yellow); }
.lb-name {
  flex: 1;
  min-width: 0;
  font-family: var(--font-display);
  font-weight: 700;
  font-size: 14px;
  letter-spacing: 0.06em;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.lb-lost { color: var(--red); }
.lb-delta { font-family: var(--font-mono); font-size: 12px; font-weight: 700; color: var(--green); }
.lb-move { font-size: 10px; }
.move-up .lb-move { color: var(--green); }
.move-down .lb-move { color: var(--red); }
.lb-score {
  min-width: 4ch;
  text-align: right;
  font-family: var(--font-num);
  font-weight: 700;
  font-size: 20px;
  font-variant-numeric: tabular-nums;
}
@keyframes row-in { from { opacity: 0; transform: translateX(-24px); } }

/* ---- particle burst ---- */
.burst { position: absolute; left: 50%; top: 45%; width: 0; height: 0; pointer-events: none; z-index: 5; }
.burst i {
  position: absolute;
  width: 6px;
  height: 10px;
  left: -3px;
  top: -5px;
  opacity: 0;
  animation: burst 1.2s var(--ease) forwards;
}
@keyframes burst {
  0% { opacity: 1; transform: translate(0, 0) rotate(0) scale(1); }
  100% { opacity: 0; transform: translate(var(--x), var(--y)) rotate(var(--r)) scale(0.4); }
}

/* ---- glitch transition flash ---- */
.glitch-flash { position: fixed; inset: 0; z-index: 80; pointer-events: none; }
.glitch-flash i {
  position: absolute;
  left: -10%;
  right: -10%;
  height: 9%;
  background: var(--accent);
  opacity: 0;
  mix-blend-mode: screen;
  animation: slice 0.38s steps(3) forwards;
}
.glitch-flash i:nth-child(1) { top: 18%; animation-delay: 0s; }
.glitch-flash i:nth-child(2) { top: 52%; height: 4%; background: var(--accent-2); animation-delay: 0.05s; }
.glitch-flash i:nth-child(3) { top: 74%; height: 6%; animation-delay: 0.1s; }
@keyframes slice {
  0% { opacity: 0.6; transform: translateX(-12%) scaleY(1); }
  50% { opacity: 0.35; transform: translateX(9%) scaleY(0.4); }
  100% { opacity: 0; transform: translateX(0) scaleY(0.1); }
}

/* ---- ACCESS GRANTED (room join) ---- */
.access {
  position: fixed;
  inset: 0;
  z-index: 85;
  display: grid;
  place-items: center;
  background: rgba(2, 3, 10, 0.86);
  pointer-events: none;
  animation: fade-in 0.2s both;
}
.access.out { opacity: 0; transition: opacity 0.45s; }
.access-ring {
  position: absolute;
  width: 160px;
  height: 160px;
  border: 2px solid var(--accent);
  border-radius: 50%;
  opacity: 0;
  animation: ring 1.2s var(--ease) forwards;
}
.access-ring.r2 { border-color: var(--accent-2); animation-delay: 0.12s; }
.access-ring.r3 { animation-delay: 0.26s; border-style: dashed; }
@keyframes ring {
  0% { opacity: 1; transform: scale(0.2); }
  100% { opacity: 0; transform: scale(3.2); }
}
.access-text {
  position: relative;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 6px;
  text-align: center;
  animation: access-text 0.6s var(--ease-back) both 0.1s;
}
.access-text small { font-family: var(--font-mono); font-size: 11px; letter-spacing: 0.3em; color: var(--text-dim); }
.access-text strong {
  font-family: var(--font-display);
  font-weight: 900;
  font-size: clamp(26px, 8vw, 40px);
  letter-spacing: 0.1em;
  color: var(--accent);
  text-shadow: 0 0 18px var(--accent-glow), 3px 0 0 rgba(255, 43, 214, 0.5), -3px 0 0 rgba(0, 240, 255, 0.5);
}
@keyframes access-text {
  0% { opacity: 0; transform: scale(1.4); }
  60% { opacity: 1; transform: scale(0.97); }
}

/* ---- shared full-screen game panels (standings / final) ---- */
.panel-full {
  position: absolute;
  inset: 0;
  padding: calc(var(--safe-t) + 18px) calc(var(--safe-r) + var(--gutter)) calc(var(--safe-b) + 18px) calc(var(--safe-l) + var(--gutter));
  display: flex;
  flex-direction: column;
  gap: 16px;
  overflow-y: auto;
  background: linear-gradient(180deg, rgba(5, 8, 22, 0.98), rgba(3, 5, 14, 0.98));
  animation: fade-in 0.35s both;
}
.panel-full.standings, .panel-full.oc-standings { justify-content: center; }
.next-up { margin-top: 10px; text-align: center; font-family: var(--font-mono); font-size: 12px; letter-spacing: 0.12em; color: var(--text-dim); }
.next-up b { color: var(--accent-2); }

/* ---- final / winner reveal ---- */
.final { gap: 18px; }
.final::before {
  content: '';
  position: fixed;
  inset: 0;
  background: var(--accent);
  opacity: 0;
  pointer-events: none;
}
.final.crowned::before { animation: flash 0.6s ease-out; }
@keyframes flash { 0% { opacity: 0.55; } 100% { opacity: 0; } }
.winner { text-align: center; min-height: 92px; }
.winner-title {
  position: relative;
  display: inline-block;
  font-family: var(--font-display);
  font-weight: 900;
  font-size: clamp(42px, 14vw, 66px);
  letter-spacing: 0.12em;
  color: var(--yellow);
  text-shadow: 0 0 26px rgba(243, 255, 58, 0.55);
  opacity: 0;
}
.winner-title::before, .winner-title::after {
  content: attr(data-text);
  position: absolute;
  inset: 0;
  opacity: 0;
}
.winner-title::before { color: var(--cyan); clip-path: inset(0 0 55% 0); }
.winner-title::after { color: var(--magenta); clip-path: inset(55% 0 0 0); }
.crowned .winner-title { animation: winner-in 0.9s var(--ease) both; }
.crowned .winner-title::before { animation: glitch-a 2.6s steps(1) infinite 0.9s; }
.crowned .winner-title::after { animation: glitch-b 2.6s steps(1) infinite 0.95s; }
@keyframes winner-in {
  0% { opacity: 0; transform: scale(2.4); }
  30% { opacity: 1; transform: scale(0.92) skewX(-8deg); }
  45% { transform: translateX(6px) skewX(6deg); }
  60% { transform: translateX(-4px); }
  100% { opacity: 1; transform: none; }
}
.winner-name { font-family: var(--font-mono); font-size: 12px; font-weight: 700; letter-spacing: 0.16em; color: var(--text-dim); }
.final:not(.crowned) .winner-name { opacity: 0; }
.crowned .winner-name { animation: rise 0.5s var(--ease) both 0.4s; }

.podium { display: grid; grid-template-columns: 1fr 1.2fr 1fr; align-items: end; gap: 8px; min-height: 240px; }
.pod { display: flex; flex-direction: column; align-items: center; gap: 8px; min-width: 0; }
.pod-who { display: flex; flex-direction: column; align-items: center; gap: 4px; min-width: 0; max-width: 100%; animation: pod-in 0.7s var(--ease-back) both; animation-delay: calc(var(--d) + 0.35s); }
.pod-name { max-width: 100%; font-family: var(--font-display); font-weight: 700; font-size: 12px; letter-spacing: 0.06em; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.pod-1 .pod-name { font-size: 15px; color: var(--c); }
.pod-score-wrap { display: flex; align-items: baseline; gap: 4px; }
.pod-score-wrap small { font-family: var(--font-mono); font-size: 9px; letter-spacing: 0.14em; color: var(--text-faint); }
.pod-score { font-family: var(--font-num); font-weight: 700; font-size: 15px; color: var(--text-dim); font-variant-numeric: tabular-nums; }
.pod-1 .pod-score { font-size: 20px; color: var(--yellow); }
.pod-block {
  width: 100%;
  display: flex;
  justify-content: center;
  padding-top: 8px;
  font-family: var(--font-num);
  font-weight: 700;
  font-size: 30px;
  color: var(--c);
  background: linear-gradient(180deg, color-mix(in srgb, var(--c) 30%, transparent), rgba(8, 12, 30, 0.4));
  border-top: 3px solid var(--c);
  transform-origin: 50% 100%;
  animation: pod-rise 0.8s var(--ease) both;
  animation-delay: var(--d);
}
.pod-1 .pod-block { height: 130px; box-shadow: 0 0 30px color-mix(in srgb, var(--c) 35%, transparent); }
.pod-2 .pod-block { height: 92px; }
.pod-3 .pod-block { height: 64px; }
.pod-1 .avatar { animation: float 2.4s ease-in-out infinite 3.2s; }
@keyframes pod-rise { from { transform: scaleY(0); } }
@keyframes pod-in { from { opacity: 0; transform: translateY(-30px) scale(0.6); } }
@keyframes float { 50% { transform: translateY(-6px); } }
.wait-note { text-align: center; font-family: var(--font-mono); font-size: 12px; letter-spacing: 0.12em; color: var(--text-dim); animation: blink 1.6s steps(2) infinite; }


/* ---- game header (leaves room for the fixed gear button) ---- */
.game-head { display: flex; justify-content: space-between; align-items: center; gap: 10px; flex: none; min-height: 44px; padding-right: 52px; }
.lb-note { display: block; font-family: var(--font-mono); font-size: 10px; font-weight: 700; letter-spacing: 0.1em; color: var(--text-dim); margin-top: 2px; }

/* ---- settings: gear + sheet ---- */
.gear {
  position: fixed;
  z-index: 70;
  top: calc(var(--safe-t) + 10px);
  right: max(calc(var(--safe-r) + 12px), calc((100vw - var(--maxw)) / 2 + 12px));
  width: 42px;
  height: 42px;
  display: grid;
  place-items: center;
  color: var(--text-dim);
  background: rgba(6, 10, 28, 0.72);
  border: 1px solid var(--line-2);
  transition: transform 0.2s var(--ease), color 0.2s;
}
.gear svg { width: 20px; height: 20px; fill: none; stroke: currentColor; stroke-width: 1.6; stroke-linecap: round; stroke-linejoin: round; }
.gear:active { transform: rotate(40deg) scale(0.94); }
.gear.is-muted { color: var(--red); border-color: rgba(255, 51, 85, 0.5); }
.gear.is-muted::after { content: ''; position: absolute; width: 26px; height: 2px; background: currentColor; transform: rotate(-45deg); }

/* one-tap music on/off beside the gear — menus only (in a game the HUD owns that corner; use the sheet) */
.music-btn {
  position: fixed;
  z-index: 70;
  top: calc(var(--safe-t) + 10px);
  right: max(calc(var(--safe-r) + 62px), calc((100vw - var(--maxw)) / 2 + 62px));
  width: 42px;
  height: 42px;
  display: grid;
  place-items: center;
  color: var(--text-dim);
  background: rgba(6, 10, 28, 0.72);
  border: 1px solid var(--line-2);
  transition: transform 0.12s var(--ease), color 0.2s, opacity 0.2s;
}
.music-btn svg { width: 20px; height: 20px; fill: none; stroke: currentColor; stroke-width: 1.6; stroke-linecap: round; stroke-linejoin: round; }
.music-btn .slash { opacity: 0; }
.music-btn.is-off { color: var(--red); border-color: rgba(255, 51, 85, 0.5); }
.music-btn.is-off .slash { opacity: 1; }
.music-btn:active { transform: scale(0.92); }
body[data-theme]:not([data-theme='']) .music-btn { display: none; }

.sheet.settings { gap: 18px; }
.set-head { display: flex; justify-content: space-between; align-items: flex-start; }
/* settings: the title row (with ×) stays pinned while the sheet scrolls */
.sheet.settings > .set-head { position: sticky; top: -14px; z-index: 2; margin: -10px calc(-1 * var(--gutter)) 0; padding: 10px var(--gutter) 10px; background: var(--bg-2); box-shadow: 0 10px 12px -10px rgba(0, 0, 0, 0.7); }
.set-head .icon-btn { font-size: 28px; }
.set-row { display: grid; grid-template-columns: 1fr auto; align-items: center; gap: 10px 12px; }
.set-row .range { grid-column: 1 / -1; }
.set-row.set-seg .seg { justify-self: end; min-width: 0; }
.set-row.set-seg .seg-btn { padding: 0 12px; }
.set-val { font-family: var(--font-num); font-weight: 700; font-size: 16px; color: var(--accent); font-variant-numeric: tabular-nums; }
.set-toggle { grid-template-columns: 1fr auto; min-height: 44px; }
.set-room { display: flex; justify-content: space-between; align-items: center; padding: 12px 0 0; border-top: 1px solid var(--line); }
.set-room strong { font-family: var(--font-display); font-weight: 900; letter-spacing: 0.24em; color: var(--accent); }
.set-foot { text-align: center; font-size: 10px; color: var(--text-faint); letter-spacing: 0.2em; }
.btn-danger { --b: var(--red); }

.range {
  --p: 50%;
  width: 100%;
  height: 32px;
  background: transparent;
  -webkit-appearance: none;
  appearance: none;
  touch-action: pan-x;
}
.range::-webkit-slider-runnable-track {
  height: 4px;
  background: linear-gradient(90deg, var(--accent-2), var(--accent) var(--p), rgba(255, 255, 255, 0.1) var(--p));
}
.range::-moz-range-track { height: 4px; background: rgba(255, 255, 255, 0.1); }
.range::-moz-range-progress { height: 4px; background: linear-gradient(90deg, var(--accent-2), var(--accent)); }
.range::-webkit-slider-thumb {
  -webkit-appearance: none;
  width: 22px;
  height: 22px;
  margin-top: -9px;
  background: var(--bg-0);
  border: 2px solid var(--accent);
  transform: rotate(45deg);
  box-shadow: 0 0 12px var(--accent-glow);
}
.range::-moz-range-thumb { width: 18px; height: 18px; background: var(--bg-0); border: 2px solid var(--accent); border-radius: 0; transform: rotate(45deg); }

.switch {
  position: relative;
  width: 56px;
  height: 30px;
  border: 1px solid var(--line-2);
  background: rgba(255, 255, 255, 0.04);
  transition: background-color 0.2s, border-color 0.2s;
}
.switch i {
  position: absolute;
  top: 4px;
  left: 4px;
  width: 20px;
  height: 20px;
  background: var(--text-dim);
  transition: transform 0.22s var(--ease-back), background-color 0.2s;
}
.switch[aria-checked='true'] { background: var(--accent-soft); border-color: var(--accent); }
.switch[aria-checked='true'] i { transform: translateX(26px); background: var(--accent); }

/* ---- multi-select chips ---- */
.chips { display: flex; flex-wrap: wrap; gap: 6px; }
.chip-btn {
  min-height: 40px;
  padding: 0 12px;
  font-family: var(--font-mono);
  font-size: 12px;
  font-weight: 700;
  letter-spacing: 0.08em;
  color: var(--text-dim);
  border: 1px solid var(--line-2);
  background: rgba(255, 255, 255, 0.02);
  transition: color 0.15s, background-color 0.15s, border-color 0.15s, transform 0.1s;
}
.chip-btn:active { transform: scale(0.95); }
.chip-btn[aria-pressed='true'] { color: var(--accent-ink); background: var(--accent); border-color: var(--accent); }
.field-hint { font-size: 10px; letter-spacing: 0.1em; color: var(--text-faint); }
.sheet.options { max-height: 92dvh; overflow-y: auto; }

.final-actions { display: flex; flex-direction: column; gap: 10px; }

/* "DEADLOCK" is longer than "WINNER": keep it inside a phone-width screen */
.winner-title.is-tied { font-size: clamp(30px, 10.5vw, 54px); letter-spacing: 0.08em; }
.winner { overflow: hidden; }

/* ---- how to play ---- */
.sheet.help { max-height: 92dvh; gap: 14px; }
.help-tabs { display: grid; grid-template-columns: repeat(6, 1fr); gap: 6px; }
.help-tab {
  min-height: 44px;
  font-family: var(--font-display);
  font-weight: 900;
  font-size: 15px;
  letter-spacing: 0.12em;
  color: var(--text-dim);
  border: 1px solid var(--line-2);
  background: rgba(255, 255, 255, 0.02);
  transition: color 0.15s, background-color 0.15s, border-color 0.15s;
}
.help-tab[aria-selected='true'] { color: var(--accent-ink); background: var(--accent); border-color: var(--accent); }
/* tabs show each game's lobby artwork; the selected one lights up in its colour */
.help-tab:has(svg) { padding: 3px; aspect-ratio: 1; min-height: 44px; overflow: hidden; background: #05060f; }
.help-tab svg { display: block; width: 100%; height: 100%; opacity: 0.5; transition: opacity 0.15s; }
.help-tab[aria-selected='true']:has(svg) { background: #05060f; border-color: var(--accent); box-shadow: 0 0 0 1px var(--accent), 0 0 12px var(--accent-glow); }
.help-tab[aria-selected='true'] svg { opacity: 1; }
.help-body { flex: 1 1 auto; min-height: 0; overflow-y: auto; display: flex; flex-direction: column; gap: 16px; padding-right: 4px; }
.help-goal { font-size: 17px; line-height: 1.4; font-weight: 600; color: var(--text); padding-left: 12px; border-left: 3px solid var(--accent); }
.help-section { display: flex; flex-direction: column; gap: 8px; }
.help-h { font-family: var(--font-mono); font-size: 11px; font-weight: 700; letter-spacing: 0.22em; color: var(--accent); }
.help-list { display: flex; flex-direction: column; gap: 6px; }
.help-list li { position: relative; padding-left: 18px; font-size: 15px; line-height: 1.4; color: var(--text-dim); }
.help-list li::before { content: '▸'; position: absolute; left: 0; color: var(--accent); }
.help-legend { display: flex; flex-direction: column; gap: 8px; }
.help-legend li { display: flex; align-items: center; gap: 12px; font-size: 15px; color: var(--text-dim); }
.help-tile { display: grid; place-items: center; width: 34px; height: 34px; font-family: var(--font-display); font-weight: 900; font-size: 16px; }
.help-tile[data-s='2'] { background: #3dff8b; color: #00200d; }
.help-tile[data-s='1'] { background: #ffc21a; color: #1d1300; }
.help-tile[data-s='0'] { background: #1b2139; color: #8b9cc4; }
.help-link { align-self: flex-start; min-height: 36px; padding: 0; color: var(--accent); }
.title-help { align-self: center; color: var(--text-dim); letter-spacing: 0.24em; }
.help-body {
  -webkit-mask-image: linear-gradient(to bottom, #000 calc(100% - 28px), transparent);
  mask-image: linear-gradient(to bottom, #000 calc(100% - 28px), transparent);
  padding-bottom: 24px;
}

/* phones: keep toasts clear of the fixed gear button (top-right) */
@media (max-width: 560px) {
  .toasts { left: calc(var(--safe-l) + 12px); width: calc(100vw - var(--safe-l) - var(--safe-r) - 78px); transform: none; }
}
.set-sub { margin-top: 6px; font-family: var(--font-mono); font-size: 10px; font-weight: 700; letter-spacing: 0.3em; color: var(--text-faint); border-top: 1px solid var(--line-2); padding-top: 12px; }

/* ---- corner buttons (settings, music, chat): small frosted-glass circles that catch the light behind them ---- */
.gear, .music-btn, .chat-fab {
  border-radius: 50%;
  color: rgba(236, 240, 255, 0.88);
  background:
    radial-gradient(120% 90% at 30% 15%, rgba(255, 255, 255, 0.16), rgba(255, 255, 255, 0) 60%),
    rgba(12, 14, 34, 0.42);
  border: 1px solid rgba(255, 255, 255, 0.16);
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.14), 0 6px 18px rgba(0, 0, 0, 0.32);
  -webkit-backdrop-filter: blur(12px) saturate(140%);
  backdrop-filter: blur(12px) saturate(140%);
  -webkit-tap-highlight-color: transparent;
}
.gear svg, .music-btn svg { width: 19px; height: 19px; stroke-width: 1.5; }
.gear:active, .music-btn:active, .chat-fab:active { background-color: rgba(255, 255, 255, 0.14); }
.gear.is-muted, .music-btn.is-off { color: #ff9db4; border-color: rgba(255, 140, 170, 0.34); }
.gear.is-muted::after { width: 22px; height: 1.5px; border-radius: 1px; }
.chat-fab.is-locked { color: rgba(236, 240, 255, 0.5); opacity: 0.7; }
.cf-lock { border-radius: 4px; background: rgba(12, 14, 34, 0.9); }
