/* Pinball Duo — the page around the table. The table itself is a canvas
   (render.js); the in-match panels and each player's pause button sit in a
   layer that turns with it, so each player's panel faces them. Colours that
   change with the table look are custom properties under [data-theme]. */

:root {
  --round: "SF Pro Rounded", ui-rounded, "Nunito", "Arial Rounded MT Bold", system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  --sans: -apple-system, BlinkMacSystemFont, "SF Pro Text", "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
  --ease: cubic-bezier(0.4, 0.1, 0.2, 1);
  --spring: cubic-bezier(0.25, 0.8, 0.3, 1);
  --p1: #2ee6ff;
  --p2: #ff3fa4;
  --p1-ink: #7ff0ff;
  --p2-ink: #ff8cc8;
  --fx: 50%;
  --fy: 50%;
  --fw: 300px;
  --fh: 520px;
  --rot: 0deg;
  --u: 300px;
}

/* ------------------------------------------------------------- themes */
/* Carnival: varnished wood and circus colours (light) */
:root,
[data-theme="carnival"] {
  color-scheme: light;
  --bg-a: #f6ead2;
  --bg-b: #d9b98a;
  --glow-1: rgba(255, 250, 235, 0.9);
  --glow-2: rgba(224, 54, 43, 0.14);
  --ink: #2a160a;
  --ink-soft: #6f5440;
  --paper: #fffaf1;
  --paper-2: #f4e8d4;
  --glass: rgba(255, 250, 241, 0.88);
  --line: rgba(80, 40, 10, 0.14);
  --accent: #c7332a;
  --accent-soft: rgba(199, 51, 42, 0.2);
  --btn-bg: rgba(255, 255, 255, 0.62);
  --btn-hover: rgba(255, 255, 255, 0.92);
  --btn-line: rgba(80, 40, 10, 0.16);
  --primary-a: #e0463a;
  --primary-b: #b3271e;
  --primary-line: #8e1d16;
  --primary-ink: #ffffff;
  --backdrop: rgba(40, 20, 8, 0.38);
  --toast: rgba(42, 22, 10, 0.92);
  --scrim-top: rgba(246, 234, 210, 0.92);
  --scrim-bottom: rgba(217, 185, 138, 0.55);
  --pause-bg: rgba(255, 250, 241, 0.86);
  --pause-ink: #2a160a;
}

/* Neon: an 80s night (dark) */
[data-theme="neon"] {
  color-scheme: dark;
  --bg-a: #1a0d33;
  --bg-b: #06030d;
  --glow-1: rgba(255, 63, 164, 0.16);
  --glow-2: rgba(46, 230, 255, 0.12);
  --ink: #f4eeff;
  --ink-soft: rgba(244, 238, 255, 0.68);
  --paper: #170d2c;
  --paper-2: #24163f;
  --glass: rgba(23, 13, 44, 0.86);
  --line: rgba(220, 170, 255, 0.17);
  --accent: #ff5fc0;
  --accent-soft: rgba(255, 95, 192, 0.24);
  --btn-bg: rgba(255, 255, 255, 0.06);
  --btn-hover: rgba(255, 255, 255, 0.12);
  --btn-line: rgba(220, 170, 255, 0.22);
  --primary-a: #ff4fae;
  --primary-b: #b8247a;
  --primary-line: #7d1653;
  --primary-ink: #ffffff;
  --backdrop: rgba(4, 2, 10, 0.62);
  --toast: rgba(36, 22, 63, 0.95);
  --scrim-top: rgba(11, 7, 22, 0.9);
  --scrim-bottom: rgba(6, 3, 13, 0.55);
  --pause-bg: rgba(23, 13, 44, 0.8);
  --pause-ink: #f4eeff;
}

/* Cosmos: deep space (dark) */
[data-theme="cosmos"] {
  color-scheme: dark;
  --bg-a: #0c1530;
  --bg-b: #02040b;
  --glow-1: rgba(120, 90, 255, 0.16);
  --glow-2: rgba(63, 242, 196, 0.1);
  --ink: #eaf1ff;
  --ink-soft: rgba(234, 241, 255, 0.66);
  --paper: #0e1730;
  --paper-2: #18233f;
  --glass: rgba(14, 23, 48, 0.86);
  --line: rgba(160, 190, 255, 0.16);
  --accent: #ffb23e;
  --accent-soft: rgba(255, 178, 62, 0.22);
  --btn-bg: rgba(255, 255, 255, 0.06);
  --btn-hover: rgba(255, 255, 255, 0.12);
  --btn-line: rgba(160, 190, 255, 0.2);
  --primary-a: #ffb23e;
  --primary-b: #d0801a;
  --primary-line: #95580c;
  --primary-ink: #1d1203;
  --backdrop: rgba(1, 3, 10, 0.62);
  --toast: rgba(24, 35, 63, 0.95);
  --scrim-top: rgba(5, 10, 24, 0.9);
  --scrim-bottom: rgba(2, 4, 11, 0.55);
  --pause-bg: rgba(14, 23, 48, 0.8);
  --pause-ink: #eaf1ff;
}

/* before the script runs, a dark device starts on Neon (no flash) */
@media (prefers-color-scheme: dark) {
  :root:not([data-theme]) {
    color-scheme: dark;
    --bg-a: #1a0d33;
    --bg-b: #06030d;
    --ink: #f4eeff;
    --ink-soft: rgba(244, 238, 255, 0.68);
    --glow-1: rgba(255, 63, 164, 0.16);
    --glow-2: rgba(46, 230, 255, 0.12);
  }
}

* { box-sizing: border-box; }
[hidden] { display: none !important; }

html, body {
  height: 100%;
  margin: 0;
  overflow: hidden;
  overscroll-behavior: none;
}

body {
  font-family: var(--sans);
  color: var(--ink);
  background: linear-gradient(165deg, var(--bg-a), var(--bg-b)) fixed;
  -webkit-user-select: none;
  user-select: none;
  -webkit-tap-highlight-color: transparent;
  -webkit-touch-callout: none;
  -webkit-text-size-adjust: 100%;
}

button { font: inherit; color: inherit; }
:focus-visible { outline: 2.5px solid var(--accent); outline-offset: 2px; }

.sr-only {
  position: absolute;
  width: 1px;
  height: 1px;
  overflow: hidden;
  clip: rect(0 0 0 0);
  clip-path: inset(50%);
  white-space: nowrap;
}

/* ---------------------------------------------------------- background */
.bg { position: fixed; inset: 0; overflow: hidden; z-index: 0; pointer-events: none; }
.bg .glow { position: absolute; border-radius: 50%; filter: blur(70px); will-change: transform; }
.bg .g1 { width: 70vmax; height: 70vmax; left: -25vmax; top: -30vmax; background: var(--glow-1); animation: drift 60s ease-in-out infinite alternate; }
.bg .g2 { width: 60vmax; height: 60vmax; right: -25vmax; bottom: -25vmax; background: var(--glow-2); animation: drift 74s ease-in-out infinite alternate-reverse; }
@keyframes drift { to { transform: translate(7vmax, 5vmax) scale(1.1); } }

/* --------------------------------------------------------------- stage */
.stage {
  position: fixed;
  inset: 0;
  z-index: 1;
  touch-action: none;
  -webkit-user-select: none;
  user-select: none;
  -webkit-touch-callout: none;
  /* the safe-area insets, read by the layout */
  padding: env(safe-area-inset-top) env(safe-area-inset-right) env(safe-area-inset-bottom) env(safe-area-inset-left);
}
.stage canvas {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  display: block;
  touch-action: none;
  transition: opacity 0.35s var(--ease);
}
.stage.dimmed canvas { opacity: 0.4; }
.stage.no-cursor { cursor: none; }

/* the layer over the table: same place, same turn */
.frame {
  position: absolute;
  left: var(--fx);
  top: var(--fy);
  width: var(--fw);
  height: var(--fh);
  transform: translate(-50%, -50%) rotate(var(--rot));
  pointer-events: none;
}
.half {
  position: absolute;
  left: 0;
  right: 0;
  height: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 10px;
}
.half.near { bottom: 0; }
.half.far { top: 0; transform: rotate(180deg); }
.upright {
  position: absolute;
  inset: 0;
  display: grid;
  place-items: center;
  pointer-events: none;
  padding: max(12px, env(safe-area-inset-top)) max(12px, env(safe-area-inset-right)) max(12px, env(safe-area-inset-bottom)) max(12px, env(safe-area-inset-left));
}

/* each player's pause button sits on their apron, right of the display */
.pause-btn {
  position: absolute;
  left: 50%;
  top: 50%;
  width: 40px;
  height: 40px;
  margin: -20px 0 0 -20px;
  border-radius: 50%;
  border: 1px solid var(--btn-line);
  background: var(--pause-bg);
  color: var(--pause-ink);
  display: grid;
  place-items: center;
  pointer-events: auto;
  cursor: pointer;
  opacity: 0.8;
  -webkit-backdrop-filter: blur(6px);
  backdrop-filter: blur(6px);
  box-shadow: 0 4px 14px -6px rgba(0, 0, 0, 0.5);
  transition: opacity 0.2s, transform 0.15s;
  touch-action: manipulation;
}
.pause-btn.near { transform: translate(calc(0.405 * var(--u)), calc(0.968 * var(--u))); }
.pause-btn.far { transform: translate(calc(-0.405 * var(--u)), calc(-0.968 * var(--u))) rotate(180deg); }
.pause-btn:hover, .pause-btn:focus-visible { opacity: 1; }
.pause-btn:active { scale: 0.92; }
.pause-btn svg { width: 20px; height: 20px; fill: none; stroke: currentColor; stroke-width: 2.4; stroke-linecap: round; }
/* against the computer everything reads upright, also when the table is turned */
.frame.turned.solo .pause-btn svg { transform: rotate(90deg); }
@media (max-width: 380px), (max-height: 380px) {
  .pause-btn { width: 36px; height: 36px; margin: -18px 0 0 -18px; }
}

/* ------------------------------------------------------------- panels */
.panel {
  position: relative;
  pointer-events: auto;
  width: min(100%, 340px);
  max-height: 100%;
  overflow: hidden;
  background: var(--glass);
  color: var(--ink);
  border: 1px solid var(--line);
  border-radius: 22px;
  padding: 16px 16px 14px;
  text-align: center;
  box-shadow: 0 18px 50px -18px rgba(0, 0, 0, 0.55);
  -webkit-backdrop-filter: blur(14px) saturate(1.15);
  backdrop-filter: blur(14px) saturate(1.15);
  animation: pop 0.3s var(--spring);
}
.upright .panel { width: min(100%, 380px); padding: 22px 20px 18px; }
@keyframes pop { from { opacity: 0; transform: scale(0.94); } }
.panel[data-side="0"] { --me: var(--p1); --me-ink: var(--p1-ink); --them: var(--p2); }
.panel[data-side="1"] { --me: var(--p2); --me-ink: var(--p2-ink); --them: var(--p1); }
.panel .glow {
  position: absolute;
  inset: -50% -20% auto;
  height: 80%;
  background: radial-gradient(ellipse at 50% 45%, color-mix(in oklab, var(--me) 32%, transparent), transparent 68%);
  pointer-events: none;
}
.panel h2 { position: relative; margin: 0; font: 700 23px/1.15 var(--round); letter-spacing: 0.01em; }
.panel.won h2 { color: var(--me-ink); }
.panel p { position: relative; margin: 4px 0 10px; font-size: 14px; color: var(--ink-soft); line-height: 1.4; }
.panel .score {
  position: relative;
  display: flex;
  align-items: baseline;
  justify-content: center;
  gap: 12px;
  margin: 6px 0 2px;
  font: 800 40px/1 var(--round);
  font-variant-numeric: tabular-nums;
}
.panel .score .mine { color: var(--me-ink); }
.panel .score .dash { font-size: 24px; color: var(--ink-soft); }
.panel .chips { position: relative; display: flex; justify-content: center; flex-wrap: wrap; gap: 6px; margin: 8px 0 12px; }
.panel .chips span {
  display: inline-flex;
  align-items: baseline;
  gap: 5px;
  padding: 4px 10px;
  border-radius: 999px;
  background: var(--paper-2);
  font-size: 10.5px;
  letter-spacing: 0.07em;
  text-transform: uppercase;
  color: var(--ink-soft);
}
.panel .chips b { font: 700 14px var(--round); letter-spacing: 0; text-transform: none; color: var(--ink); }
.panel .row { position: relative; display: flex; gap: 8px; }
.panel .row + .row { margin-top: 8px; }
.panel .row .btn { min-width: 0; }
.panel .tools { position: relative; display: flex; justify-content: center; gap: 6px; margin-top: 8px; }
.panel .tools .icon-btn { width: 44px; height: 44px; border: 1px solid var(--btn-line); background: var(--btn-bg); }
@media (max-height: 640px) and (orientation: portrait), (max-width: 640px) and (orientation: landscape) {
  .half .panel { padding: 12px 12px 10px; border-radius: 18px; }
  .half .panel h2 { font-size: 20px; }
  .half .panel .score { font-size: 32px; margin-top: 2px; }
  .half .panel p { margin: 2px 0 6px; font-size: 13px; }
  .half .panel .chips { margin: 4px 0 8px; }
  .half .panel .btn { min-height: 44px; padding: 8px 10px; }
}

/* --------------------------------------------------------------- menu */
.menu {
  position: fixed;
  inset: 0;
  z-index: 5;
  display: flex;
  flex-direction: column;
  padding: env(safe-area-inset-top) env(safe-area-inset-right) env(safe-area-inset-bottom) env(safe-area-inset-left);
  background: linear-gradient(180deg, var(--scrim-top) 0, transparent 22%, transparent 40%, var(--scrim-bottom) 100%);
  animation: fade 0.35s var(--ease);
}
@keyframes fade { from { opacity: 0; } }
.top {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  width: 100%;
  max-width: 720px;
  margin: 0 auto;
  padding: 10px 10px 4px 16px;
}
.brand { display: flex; align-items: center; gap: 10px; min-width: 0; flex: 1 1 auto; }
.brand img { width: 40px; height: 40px; flex: 0 0 auto; filter: drop-shadow(0 2px 4px rgba(0, 0, 0, 0.3)); }
.brand span { display: flex; flex-direction: column; line-height: 1.1; min-width: 0; }
.brand b { font: 700 22px var(--round); letter-spacing: 0.01em; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.brand small { font-size: 11px; color: var(--ink-soft); letter-spacing: 0.08em; text-transform: uppercase; margin-top: 2px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.nav { display: flex; align-items: center; gap: 2px; flex: 0 0 auto; }
.account-chip { display: flex; align-items: center; margin-left: 4px; }
.account-chip:empty { display: none; }

.icon-btn {
  appearance: none;
  border: 0;
  background: transparent;
  color: var(--ink);
  width: 44px;
  height: 44px;
  border-radius: 50%;
  display: grid;
  place-items: center;
  cursor: pointer;
  transition: background 0.2s, transform 0.15s;
}
.icon-btn:hover { background: var(--btn-bg); }
.icon-btn:active { transform: scale(0.92); }
.icon-btn svg, .btn svg { width: 22px; height: 22px; fill: none; stroke: currentColor; stroke-width: 1.7; stroke-linecap: round; stroke-linejoin: round; }

.card {
  width: min(100% - 20px, 540px);
  margin: auto auto 12px;
  padding: 16px 16px 12px;
  background: var(--glass);
  border: 1px solid var(--line);
  border-radius: 26px;
  box-shadow: 0 24px 60px -24px rgba(0, 0, 0, 0.5);
  -webkit-backdrop-filter: blur(18px) saturate(1.2);
  backdrop-filter: blur(18px) saturate(1.2);
}
.card .label, .opt-row h3 {
  margin: 0 0 8px 2px;
  font: 700 11px var(--sans);
  letter-spacing: 0.1em;
  text-transform: uppercase;
  color: var(--ink-soft);
}
.modes { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; }
.mode {
  appearance: none;
  display: grid;
  grid-template-columns: auto 1fr;
  grid-template-rows: auto auto;
  column-gap: 10px;
  align-items: center;
  text-align: left;
  padding: 10px 12px;
  min-height: 64px;
  border-radius: 16px;
  border: 1.5px solid var(--line);
  background: var(--paper-2);
  cursor: pointer;
  transition: border-color 0.2s, background 0.2s, box-shadow 0.2s, transform 0.15s;
}
.mode svg { grid-row: 1 / 3; width: 34px; height: 34px; fill: none; stroke: currentColor; stroke-width: 1.6; stroke-linejoin: round; color: var(--accent); }
.mode b { font: 700 16px var(--round); }
.mode small { font-size: 12.5px; color: var(--ink-soft); line-height: 1.25; }
.mode:active { transform: scale(0.98); }
.mode[aria-checked="true"] { border-color: var(--accent); background: var(--paper); box-shadow: 0 0 0 3px var(--accent-soft); }

.opts-grid { display: grid; gap: 10px; margin: 12px 0 14px; }
.opt-row { display: grid; grid-template-columns: 92px 1fr; align-items: center; gap: 8px; }
.opt-row h3 { margin: 0; }
.opts { display: flex; flex-wrap: wrap; gap: 6px; }
.opt {
  appearance: none;
  border: 1.5px solid var(--line);
  background: var(--paper-2);
  color: var(--ink);
  font: 600 14px var(--sans);
  padding: 7px 14px;
  min-height: 44px;
  border-radius: 999px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  cursor: pointer;
  transition: border-color 0.2s, background 0.2s, transform 0.15s, box-shadow 0.2s;
}
.opt:active { transform: scale(0.97); }
.opt[aria-checked="true"] { border-color: var(--accent); background: var(--paper); box-shadow: 0 0 0 3px var(--accent-soft); }
.hint { margin: 10px 4px 2px; font-size: 12.5px; line-height: 1.4; color: var(--ink-soft); text-align: center; }

.btn {
  appearance: none;
  flex: 1;
  border: 1px solid var(--btn-line);
  background: var(--btn-bg);
  color: var(--ink);
  font: 600 15px var(--sans);
  padding: 10px 14px;
  min-height: 46px;
  border-radius: 14px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  cursor: pointer;
  transition: transform 0.15s, background 0.2s, box-shadow 0.2s, filter 0.2s;
}
.btn svg { width: 19px; height: 19px; }
.btn:hover { background: var(--btn-hover); }
.btn:active { transform: scale(0.97); }
.btn.primary {
  background: linear-gradient(180deg, var(--primary-a), var(--primary-b));
  color: var(--primary-ink);
  border-color: var(--primary-line);
  box-shadow: 0 6px 16px -6px rgba(0, 0, 0, 0.45), inset 0 1px 0 rgba(255, 255, 255, 0.22);
  text-shadow: 0 1px 1px rgba(0, 0, 0, 0.2);
}
.btn.primary:hover { filter: brightness(1.06); }
.btn.play { width: 100%; min-height: 54px; font: 700 18px var(--round); border-radius: 16px; }
.btn.play svg { width: 20px; height: 20px; }

/* short landscape: the card goes wide, two columns */
@media (orientation: landscape) and (max-height: 560px) {
  .top { padding-top: 4px; }
  .brand img { width: 34px; height: 34px; }
  .brand b { font-size: 19px; }
  .card {
    width: min(100% - 24px, 760px);
    margin-bottom: 8px;
    display: grid;
    grid-template-columns: 1fr 1.25fr;
    grid-template-areas: "label label" "modes opts" "play play" "hint hint";
    column-gap: 16px;
    padding: 12px 14px 8px;
  }
  .card .label { grid-area: label; }
  .modes { grid-area: modes; grid-template-columns: 1fr; align-content: start; }
  .mode { min-height: 56px; padding: 8px 10px; }
  .opts-grid { grid-area: opts; margin: 0; gap: 6px; }
  .opt-row { grid-template-columns: 74px 1fr; }
  .opt { min-height: 40px; padding: 5px 12px; }
  .btn.play { grid-area: play; margin-top: 10px; min-height: 46px; }
  .hint { grid-area: hint; margin-top: 6px; }
}
@media (orientation: landscape) and (max-height: 420px) {
  .hint { display: none; }
  .brand small { display: none; }
}
@media (max-width: 400px) {
  .brand small { letter-spacing: 0.03em; font-size: 10.5px; }
  .top { padding-left: 10px; padding-right: 4px; }
  .brand { gap: 7px; }
  .brand img { width: 32px; height: 32px; }
  .brand b { font-size: 18px; letter-spacing: 0; }
  .nav { gap: 0; }
}
@media (max-width: 440px) and (orientation: portrait) {
  .opt-row { grid-template-columns: 1fr; gap: 5px; }
  .opts .opt { flex: 1 1 0; padding-left: 8px; padding-right: 8px; }
  .mode { column-gap: 8px; padding: 9px 10px; }
  .mode svg { width: 28px; height: 28px; }
}
@media (max-width: 370px) {
  .opt-row { grid-template-columns: 1fr; gap: 4px; }
  .opt { padding: 6px 11px; font-size: 13.5px; }
  .mode { grid-template-columns: 1fr; }
  .mode svg { display: none; }
}

/* -------------------------------------------------------- sheets, dialogs */
.backdrop {
  position: fixed;
  inset: 0;
  z-index: 20;
  background: var(--backdrop);
  -webkit-backdrop-filter: blur(3px);
  backdrop-filter: blur(3px);
  animation: fade 0.25s;
}
.sheet {
  position: fixed;
  left: 0;
  right: 0;
  bottom: 0;
  margin: 0 auto;
  z-index: 21;
  max-width: 560px;
  max-height: 88dvh;
  display: flex;
  flex-direction: column;
  background: var(--paper);
  color: var(--ink);
  border-radius: 24px 24px 0 0;
  box-shadow: 0 -10px 40px rgba(0, 0, 0, 0.3);
  padding-bottom: env(safe-area-inset-bottom);
  animation: rise 0.32s var(--ease);
}
@keyframes rise { from { transform: translateY(40px); opacity: 0; } }
.sheet header { display: flex; align-items: center; justify-content: space-between; padding: 14px 12px 6px 22px; flex: 0 0 auto; }
.sheet h2 { font: 700 23px var(--round); margin: 0; letter-spacing: 0.01em; }
.sheet-body {
  overflow: auto;
  overscroll-behavior: contain;
  -webkit-overflow-scrolling: touch;
  padding: 2px 22px 26px;
  font-size: 15px;
  line-height: 1.55;
  -webkit-user-select: text;
  user-select: text;
  touch-action: pan-y;
}
.sheet-body h3 { font: 700 16px var(--round); margin: 20px 0 8px; color: var(--ink); }
.sheet-body h3:first-child { margin-top: 6px; }
.prose p { margin: 0 0 12px; }
.prose ul { margin: 0; padding-left: 20px; }
.prose li { margin: 4px 0; }
.prose li b { font-weight: 600; }
.muted { color: var(--ink-soft); }
.about { font-size: 13px; margin-top: 22px; text-align: center; }
.about b { display: block; font-weight: 600; color: var(--ink); }
@media (min-width: 700px) and (min-height: 560px) {
  .sheet { bottom: auto; top: 50%; transform: translateY(-50%); border-radius: 24px; max-height: 84dvh; animation: popm 0.28s var(--ease); }
}
@media (orientation: landscape) and (max-height: 560px) {
  .sheet { max-height: 94dvh; }
}
@keyframes popm { from { opacity: 0; transform: translateY(-50%) scale(0.96); } }

/* ------------------------------------------------------------- results */
.tiles { display: grid; grid-template-columns: repeat(auto-fit, minmax(118px, 1fr)); gap: 8px; margin: 4px 0 6px; }
.tile { background: var(--paper-2); border-radius: 16px; padding: 10px 12px; display: flex; flex-direction: column; gap: 2px; }
.tile small { font-size: 10.5px; letter-spacing: 0.08em; text-transform: uppercase; color: var(--ink-soft); }
.tile b { font: 800 22px var(--round); font-variant-numeric: tabular-nums; }
table { width: 100%; border-collapse: collapse; font-size: 13.5px; font-variant-numeric: tabular-nums; }
th { text-align: left; vertical-align: bottom; font-weight: 600; color: var(--ink-soft); font-size: 10.5px; letter-spacing: 0.06em; text-transform: uppercase; padding: 4px; border-bottom: 1px solid var(--line); }
td { padding: 7px 4px; border-bottom: 1px solid var(--line); white-space: nowrap; vertical-align: middle; }
th.num, td.num { text-align: right; }
td.name { font-weight: 600; max-width: 9em; overflow: hidden; text-overflow: ellipsis; }
td.score { font: 700 14px var(--round); }
td.score .w { color: var(--accent); }
td.who { max-width: 11em; overflow: hidden; text-overflow: ellipsis; color: var(--ink-soft); }
.dot { display: inline-block; width: 9px; height: 9px; border-radius: 50%; margin-right: 6px; vertical-align: 0; }
.dot.p1 { background: var(--p1); }
.dot.p2 { background: var(--p2); }
.note { font-size: 12.5px; color: var(--ink-soft); margin: 16px 0 0; }
@media (max-width: 420px) {
  table.recent { font-size: 12.5px; }
  table.recent td, table.recent th { padding-left: 2px; padding-right: 2px; }
}

/* ------------------------------------------------------------- settings */
.swatch {
  display: inline-block;
  width: 26px;
  height: 26px;
  border-radius: 7px;
  flex: 0 0 auto;
  position: relative;
  background: radial-gradient(circle at 50% 50%, var(--sl) 0 22%, transparent 24%), var(--sb);
  box-shadow: inset 0 0 0 1px rgba(0, 0, 0, 0.2);
  overflow: hidden;
}
.swatch::before, .swatch::after { content: ""; position: absolute; left: 50%; width: 9px; height: 9px; margin-left: -4.5px; border-radius: 50%; }
.swatch::before { top: 2.5px; background: var(--sbb); }
.swatch::after { bottom: 2.5px; background: var(--sba); }
.swatch.auto { background: linear-gradient(135deg, #140a2e 50%, #e8c48a 50%); }
.swatch.auto::before, .swatch.auto::after { display: none; }
.toggle { display: flex; align-items: center; gap: 12px; margin-top: 16px; cursor: pointer; font-size: 15px; line-height: 1.35; min-height: 32px; }
.toggle input { position: absolute; opacity: 0; width: 0; height: 0; }
.toggle .track { flex: 0 0 auto; width: 46px; height: 28px; border-radius: 999px; background: var(--line); position: relative; transition: background 0.25s; box-shadow: inset 0 0 0 1px var(--line); }
.toggle .track::after { content: ""; position: absolute; top: 3px; left: 3px; width: 22px; height: 22px; border-radius: 50%; background: #fff; box-shadow: 0 1px 3px rgba(0, 0, 0, 0.3); transition: transform 0.25s var(--ease); }
.toggle input:checked + .track { background: var(--accent); }
.toggle input:checked + .track::after { transform: translateX(18px); }
.toggle input:focus-visible + .track { outline: 2px solid var(--accent); outline-offset: 2px; }
.field { display: grid; gap: 4px; margin-top: 10px; }
.field span { font-size: 12.5px; color: var(--ink-soft); display: flex; align-items: center; }
.field input {
  appearance: none;
  font: 500 16px var(--sans);
  color: var(--ink);
  background: var(--paper-2);
  border: 1.5px solid var(--line);
  border-radius: 12px;
  padding: 10px 12px;
  min-height: 44px;
  -webkit-user-select: text;
  user-select: text;
}
.field input:focus { outline: none; border-color: var(--accent); box-shadow: 0 0 0 3px var(--accent-soft); }

/* ---------------------------------------------------------------- toast */
.toast {
  position: fixed;
  left: 50%;
  top: calc(50% - 22px);
  transform: translate(-50%, -50%) translateY(6px);
  z-index: 15;
  background: var(--toast);
  color: #fff;
  padding: 10px 16px;
  border-radius: 999px;
  font-size: 14px;
  width: max-content;
  max-width: min(88vw, 420px);
  text-align: center;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.25s, transform 0.25s;
  box-shadow: 0 8px 24px rgba(0, 0, 0, 0.25);
}
.toast.show { opacity: 1; transform: translate(-50%, -50%); }

@media (prefers-reduced-motion: reduce) {
  .bg .glow { animation: none; }
  .panel, .sheet, .backdrop, .menu { animation: none; }
  .stage canvas { transition: none; }
}

/* ------------------------------------------------------- friends' boards */
.friends { margin-top: 18px; }
.friends-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(220px, 1fr)); gap: 10px; }
.friends-board { background: var(--paper-2); border-radius: 16px; padding: 8px 12px 10px; min-height: 64px; }
.btn.wide { width: 100%; flex: none; }

/* the table's own surface: no selection, no callouts, no zoom */
.stage, .stage canvas, .frame, .half, .upright {
  -webkit-user-select: none;
  user-select: none;
  -webkit-touch-callout: none;
  -webkit-tap-highlight-color: transparent;
}
