/* "Slime Lab" theme, dark only. Every color is a token here; tints mix a token
   with transparency (color-mix), so changing a token carries them along. */

/* Bagel Fat One and Lexend, Latin only, served from this site (Discord blocks
   outside font hosts). SIL Open Font License; the texts are in /fonts. Lexend
   is one variable file covering every weight. */
@font-face {
  font-family: 'Bagel Fat One';
  font-style: normal;
  font-weight: 400;
  font-display: swap;
  src: url('/fonts/bagel-fat-one-latin.woff2') format('woff2');
}
@font-face {
  font-family: 'Lexend';
  font-style: normal;
  font-weight: 100 900;
  font-display: swap;
  src: url('/fonts/lexend-latin.woff2') format('woff2');
}

:root {
  color-scheme: dark;

  --slime-bg: #0E1512;        /* page background; also the manifest colors */
  --slime-surface: #17231D;   /* cards, side panel */
  --slime-raised: #213228;    /* inputs, chips, raised cards, borders, dialogs */
  --slime-primary: #7CFF6B;   /* slime green: main buttons, the title, selection, online */
  --slime-secondary: #B18CFF; /* grape: whatever is Jev's, the winning line, the story score */
  --slime-accent: #FFD23F;    /* warning yellow: timers, points, the room pill, focus outline */
  --slime-danger: #FF7A8A;    /* Leave, End the story, the urgent timer */
  --slime-text: #EAFFF0;
  --slime-muted: #8FB3A0;     /* labels, helper text, placeholders */
  --slime-on-bright: #0E1512; /* text on green, grape, yellow and pink fills */

  /* Jev's four judging qualities, in fixed order: Funny, Flows, On theme,
     Surprising. Pie slices only. Validated with the dataviz skill on the side
     panel (--slime-surface) for all pairs, since a slider at zero lets any two
     slices touch. */
  --series-1: #8267e2;
  --series-2: #3e8343;
  --series-3: #e25a98;
  --series-4: #a9912b;

  /* Bagel Fat One: headings, the title, the main button, "Jev picked". It has
     one weight, so never bold it. Lexend: everything else. */
  --font-display: 'Bagel Fat One', 'Arial Black', sans-serif;
  --font-body: 'Lexend', system-ui, -apple-system, 'Segoe UI', sans-serif;
  --text-xs: 12px;
  --text-sm: 14px;
  --text-base: 16px; /* the least an input may use, or iOS zooms in */
  --text-lg: 18px;
  --text-heading: 17px; /* Bagel Fat One headings, main buttons and titles */
  --text-2xl: 28px;
  --text-4xl: 48px;

  --radius-sm: 10px;
  --radius-md: 14px;
  --radius-lg: 18px;
  --radius-xl: 24px;
  --radius-pill: 999px;
  --border-w: 2px;
  --tap-min: 44px;

  /* Goo: a chunky offset shadow instead of a soft blur. */
  --goo: rgba(0, 0, 0, 0.45);
  --shadow-goo: 0 4px 0 0 var(--goo);
  --shadow-sunk: inset 0 4px 0 0 var(--goo);
  --glow-primary: 0 0 0 3px color-mix(in srgb, var(--slime-primary) 25%, transparent);
}

* { box-sizing: border-box; }
html, body { margin: 0; padding: 0; }
html { height: 100%; background: var(--slime-bg); }
body {
  min-height: 100dvh;
  background: var(--slime-bg);
  color: var(--slime-text);
  font-family: var(--font-body);
  font-size: var(--text-base);
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
  padding-bottom: env(safe-area-inset-bottom);
}
h1, h2, h3 {
  font-family: var(--font-display);
  font-weight: 400;
  font-synthesis: none;
  line-height: 1.1;
  letter-spacing: 0.01em;
  margin: 0 0 0.4em;
}
h1 { font-size: var(--text-4xl); color: var(--slime-primary); }
h2 { font-size: var(--text-heading); }
h3 { font-size: var(--text-heading); }
p { margin: 0 0 0.8em; }
a { color: var(--slime-accent); font-weight: 700; text-underline-offset: 3px; }
a:hover { color: var(--slime-text); }
::selection { background: var(--slime-primary); color: var(--slime-on-bright); }
:focus-visible { outline: 3px solid var(--slime-accent); outline-offset: 3px; }
button, input, select, textarea { font: inherit; color: inherit; }
button { cursor: pointer; }
[hidden] { display: none !important; }

/* ---------- layout ---------- */
#screen {
  max-width: 640px;
  margin: 0 auto;
  padding: 16px 16px 48px;
}
.card {
  background: var(--slime-surface);
  border: var(--border-w) solid var(--slime-raised);
  border-radius: var(--radius-lg);
  padding: 18px;
  margin-bottom: 14px;
}
.card.center { text-align: center; }
.row { display: flex; gap: 10px; align-items: center; flex-wrap: wrap; }
.row.between { justify-content: space-between; }
.row.end { justify-content: flex-end; }
.stack > * + * { margin-top: 10px; }
.muted { color: var(--slime-muted); }
.small { font-size: var(--text-sm); }
/* Section labels such as "Theme" and "Jev's score". */
.label {
  font-size: var(--text-xs);
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.1em;
  color: var(--slime-muted);
  margin-bottom: 4px;
}
.error { color: var(--slime-danger); min-height: 1.4em; }
#home-error { margin-bottom: 0; }
.hint { color: var(--slime-muted); font-size: 0.85rem; margin: 4px 0 0; }

/* ---------- controls ---------- */
label { display: block; }
label > span.lbl { display: block; font-size: var(--text-sm); font-weight: 700; color: var(--slime-muted); margin-bottom: 6px; }
input[type="text"], input:not([type]), select, textarea {
  width: 100%;
  background: var(--slime-raised);
  border: var(--border-w) solid var(--slime-raised);
  border-radius: var(--radius-md);
  padding: 12px 14px;
  font-size: var(--text-base);
  text-overflow: ellipsis;
  outline: none;
  transition: border-color 0.15s, box-shadow 0.15s;
}
input::placeholder, textarea::placeholder { color: var(--slime-muted); opacity: 1; }
input[type="text"]:focus, input:not([type]):focus, select:focus, textarea:focus {
  border-color: var(--slime-primary);
  box-shadow: var(--glow-primary);
}
textarea { resize: none; min-height: 92px; }
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  min-height: var(--tap-min);
  padding: 8px 20px;
  border-radius: var(--radius-pill);
  border: var(--border-w) solid var(--slime-muted);
  background: transparent;
  color: var(--slime-text);
  font-weight: 700;
  transition: transform 80ms ease, box-shadow 80ms ease, filter 120ms ease, border-color 120ms ease;
}
.btn:hover { border-color: var(--slime-text); }
.btn:active { transform: translateY(2px); box-shadow: none; }
.btn:disabled { opacity: 0.45; cursor: not-allowed; transform: none; }
.btn.primary {
  background: var(--slime-primary);
  border-color: transparent;
  color: var(--slime-on-bright);
  font-family: var(--font-display);
  font-weight: 400;
  font-synthesis: none;
  font-size: var(--text-heading);
  min-height: 52px;
  box-shadow: var(--shadow-goo);
}
.btn.danger {
  background: var(--slime-danger);
  border-color: transparent;
  color: var(--slime-on-bright);
  box-shadow: var(--shadow-goo);
}
.btn.primary:hover,
.btn.danger:hover { filter: brightness(1.08); border-color: transparent; }
.btn.primary:active,
.btn.danger:active { box-shadow: none; }
.btn.small { min-height: var(--tap-min); padding: 6px 16px; font-size: var(--text-sm); }
.btn.big { width: 100%; min-height: 56px; }
/* An inline text action: the setter's "End the story" in the reveal. */
.btn.ghost { background: none; border-color: transparent; padding-left: 4px; padding-right: 4px; color: var(--slime-accent); }
.btn.ghost:hover { border-color: transparent; color: var(--slime-text); }

.seg { display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px; }
.seg button {
  background: var(--slime-raised);
  border: var(--border-w) solid var(--slime-raised);
  border-radius: var(--radius-md);
  min-height: var(--tap-min);
  padding: 10px 6px;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 2px;
  color: var(--slime-text);
  font-weight: 700;
}
.seg button:hover { border-color: var(--slime-muted); }
.seg button small { color: var(--slime-muted); font-size: 0.75rem; font-weight: 400; }
.seg button[aria-pressed="true"] {
  border-color: var(--slime-primary);
  background: color-mix(in srgb, var(--slime-primary) 14%, var(--slime-raised));
}

input[type="range"] { width: 100%; height: var(--tap-min); margin: 0; accent-color: var(--slime-primary); }

.slider { display: grid; grid-template-columns: 8.5em 1fr 3.2em; align-items: center; gap: 10px; }
.slider .pct { text-align: right; font-variant-numeric: tabular-nums; color: var(--slime-accent); }
.slider span { font-size: 0.92rem; }

/* ---------- top bar ---------- */
#topbar {
  position: sticky;
  top: 0;
  z-index: 20;
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 8px 12px;
  padding-top: calc(8px + env(safe-area-inset-top));
  background: var(--slime-bg);
  border-bottom: var(--border-w) solid var(--slime-raised);
}
.tb-code {
  background: var(--slime-raised);
  border: 0;
  border-radius: var(--radius-pill);
  min-height: var(--tap-min);
  padding: 6px 14px;
  color: var(--slime-accent);
  font-weight: 700;
  font-variant-numeric: tabular-nums;
}
.tb-code b { font-size: var(--text-sm); }
.tb-label { color: var(--slime-muted); font-size: var(--text-xs); font-weight: 400; }
.tb-story { flex: 1; color: var(--slime-muted); font-size: var(--text-sm); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.tb-actions { display: flex; gap: 6px; flex: 0 0 auto; margin-left: auto; }
/* Long room names stay on one line; on phones the story title gives way,
   since the theme is shown at the top of the page anyway. */
#topbar .tb-code { flex: 0 1 auto; min-width: 0; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
@media (max-width: 480px) {
  .tb-story,
  #tb-count { display: none; }
}
.tb-btn {
  background: transparent;
  border: var(--border-w) solid var(--slime-raised);
  border-radius: var(--radius-pill);
  min-height: var(--tap-min);
  padding: 6px 14px;
  color: var(--slime-text);
  font-size: var(--text-sm);
  font-weight: 700;
}
.tb-btn:hover { border-color: var(--slime-muted); }
.tb-btn.danger { color: var(--slime-danger); border-color: color-mix(in srgb, var(--slime-danger) 45%, transparent); }
.tb-btn.danger:hover { border-color: var(--slime-danger); }
#conn {
  position: sticky;
  top: calc(62px + env(safe-area-inset-top));
  z-index: 19;
  text-align: center;
  background: var(--slime-accent);
  color: var(--slime-on-bright);
  font-size: var(--text-sm);
  font-weight: 700;
  padding: 6px;
}

/* ---------- home ---------- */
.hero { text-align: center; padding: 20px 0 12px; }
.hero h1 { margin: 0 0 14px; }
.tagline { color: var(--slime-muted); font-size: var(--text-lg); }
.how { margin: 22px 0 18px; }
.how ol { padding-left: 22px; color: var(--slime-muted); }
.how li { margin-bottom: 8px; }
.how li::marker { color: var(--slime-primary); font-weight: 700; }
.how b { color: var(--slime-text); }
.legal-links { text-align: center; font-size: var(--text-sm); color: var(--slime-muted); margin: 8px 0 0; }
.legal-links a { color: var(--slime-muted); font-weight: 500; }
.legal-links a:hover { color: var(--slime-text); }

/* ---------- terms and privacy pages ---------- */
.legal { max-width: 640px; margin: 0 auto; padding: 24px 16px 48px; }
.legal h1 { font-size: var(--text-2xl); margin: 8px 0 4px; }
.legal h2 { margin: 28px 0 8px; }
.legal ul { padding-left: 22px; margin: 0 0 0.8em; }
.legal li { margin-bottom: 6px; }
.legal li::marker { color: var(--slime-primary); }
.legal .legal-links { margin-top: 32px; }
.legal-home { margin: 0; font-family: var(--font-display); font-synthesis: none; font-size: var(--text-heading); }
.legal-home a { color: var(--slime-primary); font-weight: 400; text-decoration: none; }

/* ---------- player icons ---------- */
.nick-row { display: flex; gap: 10px; align-items: stretch; }
.nick-row input { flex: 1 1 auto; min-width: 0; }
.emoji-pick {
  display: inline-flex;
  align-items: center;
  flex: 0 0 auto;
  background: var(--slime-raised);
  border: var(--border-w) solid var(--slime-raised);
  border-radius: var(--radius-md);
}
.emoji-cur { justify-content: center; font-size: 1.6rem; line-height: 1; width: 52px; min-height: 48px; padding: 0; cursor: pointer; }
.emoji-cur:hover { border-color: var(--slime-primary); }
.emoji-cur:active { transform: scale(0.94); }
.av { margin-right: 5px; }
.step { display: block; font-weight: 700; font-size: var(--text-base); color: var(--slime-text); }
.stack > .step-gap { margin-top: 18px; }
.setter-actions { gap: 8px; flex-wrap: nowrap; }

/* ---------- story score ---------- */
.verdict {
  margin: 14px 0;
  padding: 12px 14px;
  background: var(--slime-bg);
  border: var(--border-w) solid var(--slime-secondary);
  border-radius: var(--radius-md);
}
.verdict.pending { display: flex; align-items: center; gap: 10px; border-color: var(--slime-raised); }
.verdict-head { display: flex; justify-content: space-between; align-items: baseline; }
.verdict-num { color: var(--slime-secondary); font-weight: 700; font-variant-numeric: tabular-nums; }
.verdict-num b { font-size: 2rem; }
.verdict .dim i { background: var(--slime-raised); }
.dims.story-dims { grid-template-columns: repeat(2, 1fr); gap: 10px; }
.dim-level { display: block; color: var(--slime-text); font-size: 0.78rem; }
.spinner.small { width: 20px; height: 20px; border-width: 3px; margin: 0; }

/* ---------- room picker ---------- */
.room-list { display: grid; gap: 12px; }
.room-card {
  display: grid;
  grid-template-columns: 1fr auto;
  align-items: center;
  gap: 12px;
  text-align: left;
  background: var(--slime-raised);
  border: var(--border-w) solid var(--slime-raised);
  border-radius: var(--radius-md);
  padding: 12px 14px;
  color: var(--slime-text);
  width: 100%;
  box-shadow: var(--shadow-goo);
  transition: transform 80ms ease, box-shadow 80ms ease, border-color 120ms ease;
}
.room-card:hover { border-color: var(--slime-primary); }
.room-card:active { transform: translateY(2px); box-shadow: none; }
.room-body { display: flex; flex-direction: column; gap: 2px; min-width: 0; }
.room-body b { font-size: 1.05rem; }
.room-tagline { color: var(--slime-muted); font-size: 0.9rem; }
.room-filters { color: var(--slime-muted); font-size: 0.78rem; }
.room-count { color: var(--slime-accent); font-size: 0.85rem; font-weight: 700; white-space: nowrap; }

/* ---------- reveal taps ---------- */
.result.tappable { cursor: pointer; transition: border-color 0.15s, transform 0.05s; }
.result.tappable:hover { border-color: var(--slime-primary); }
.result.tappable:active { transform: translateY(1px); }
.result.tapped { border-color: var(--slime-accent); box-shadow: 0 0 0 2px var(--slime-accent); }
.mypick { color: var(--slime-accent); }
.result.own { opacity: 0.9; }
.tapcount { display: block; margin-top: 8px; font-size: 0.8rem; color: var(--slime-muted); min-height: 1em; }
.tapcount.fav { color: var(--slime-accent); font-weight: 700; }
.drawer-jev { margin-top: 4px; }
.pie { display: block; width: 100%; max-width: 320px; height: auto; margin: 0 auto; }
.pie path,
.pie circle { stroke: var(--slime-surface); stroke-width: 2; stroke-linejoin: round; }
.pie-label { fill: var(--slime-muted); font-size: 12px; font-family: var(--font-body); }
.pie-value { fill: var(--slime-text); font-weight: 700; }
.pie-legend {
  list-style: none;
  padding: 0;
  margin: 2px 0 0;
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 4px 12px;
  font-size: 0.82rem;
  color: var(--slime-muted);
}
.pie-legend b { color: var(--slime-text); font-weight: 700; margin-left: 5px; }
.swatch { display: inline-block; width: 10px; height: 10px; border-radius: 3px; margin-right: 6px; vertical-align: -1px; }
.pie-note { margin: 8px 0 0; }

/* ---------- players ---------- */
.players { list-style: none; padding: 0; margin: 0; display: flex; flex-wrap: wrap; gap: 8px; }
.center .players { justify-content: center; }
.players li {
  background: var(--slime-raised);
  border-radius: var(--radius-pill);
  padding: 6px 12px;
  display: inline-flex;
  align-items: center;
  gap: 6px;
  color: var(--slime-accent);
  font-size: var(--text-sm);
  font-weight: 700;
}
.dot { width: 8px; height: 8px; border-radius: 50%; background: var(--slime-primary); display: inline-block; }
.dot.off { background: var(--slime-muted); }
.badge {
  font-size: 0.7rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  padding: 2px 7px;
  border-radius: var(--radius-pill);
  background: color-mix(in srgb, var(--slime-accent) 18%, transparent);
  color: var(--slime-accent);
}
.badge.jev { background: color-mix(in srgb, var(--slime-secondary) 20%, transparent); color: var(--slime-secondary); }
.badge.you { background: color-mix(in srgb, var(--slime-text) 12%, transparent); color: var(--slime-text); }

/* ---------- timer ---------- */
.timer {
  font-variant-numeric: tabular-nums;
  font-size: 1.6rem;
  font-weight: 700;
  line-height: 1.2;
  color: var(--slime-accent);
  min-width: 3em;
  text-align: right;
}
.timer.urgent { color: var(--slime-danger); }
.timer.inline { font-size: 1rem; display: inline; min-width: 0; }
.bar { height: 8px; background: var(--slime-bg); border-radius: var(--radius-pill); overflow: hidden; margin-top: 10px; }
.bar > i { display: block; height: 100%; background: var(--slime-accent); width: 100%; transition: width 0.25s linear; }

/* ---------- story ---------- */
/* The story so far sits in a sunken well. */
.story-panel {
  margin-bottom: 14px;
  padding: 14px 16px;
  background: var(--slime-bg);
  border: var(--border-w) solid var(--slime-raised);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-sunk);
}
.theme-line { display: flex; align-items: baseline; gap: 8px; flex-wrap: wrap; margin-bottom: 10px; }
.theme-line .label { margin-bottom: 0; }
.theme-line b { font-family: var(--font-display); font-weight: 400; font-synthesis: none; font-size: var(--text-heading); line-height: 1.15; }
.pill {
  font-size: 0.75rem;
  font-weight: 700;
  background: var(--slime-raised);
  border-radius: var(--radius-pill);
  padding: 2px 10px;
  color: var(--slime-muted);
}
.story { list-style: none; padding: 0; margin: 0; }
.story li {
  position: relative;
  padding: 10px 12px 10px 40px;
  border-left: var(--border-w) solid var(--slime-raised);
  margin-left: 12px;
}
.story li::before {
  content: attr(data-n);
  position: absolute;
  left: -14px;
  top: 8px;
  width: 26px;
  height: 26px;
  border-radius: 50%;
  background: var(--slime-raised);
  font-size: 0.75rem;
  font-weight: 700;
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--slime-muted);
}
.story li .by { display: block; font-size: 0.78rem; color: var(--slime-muted); margin-top: 2px; }
.story li.new {
  background: color-mix(in srgb, var(--slime-secondary) 12%, transparent);
  border-left-color: var(--slime-secondary);
  border-radius: 0 var(--radius-sm) var(--radius-sm) 0;
}
.story li.new::before { background: var(--slime-secondary); color: var(--slime-on-bright); }
.story.final {
  padding: 12px 12px 12px 8px;
  background: var(--slime-bg);
  border-radius: var(--radius-md);
  box-shadow: var(--shadow-sunk);
}
.story.final li { font-size: 1.05rem; }
.story-empty { color: var(--slime-muted); font-style: italic; padding: 8px 12px; margin: 0; }

/* ---------- writing ---------- */
.write textarea { font-size: 1.05rem; }
.status { color: var(--slime-primary); font-size: var(--text-sm); margin: 6px 0 0; }
.chips { display: flex; flex-wrap: wrap; gap: 6px; }
.chip {
  font-size: 0.78rem;
  font-weight: 500;
  background: var(--slime-raised);
  border-radius: var(--radius-pill);
  padding: 4px 10px;
  color: var(--slime-text);
}
.chip b { color: var(--slime-accent); font-weight: 700; }
details summary { cursor: pointer; font-weight: 700; padding: 8px 0; }
details summary::marker { color: var(--slime-primary); }
details.card { padding-top: 10px; }
details.card[open] summary { margin-bottom: 6px; }

/* ---------- judging ---------- */
.judging { text-align: center; padding: 40px 18px; }
.spinner {
  width: 64px;
  height: 64px;
  margin: 0 auto 18px;
  border-radius: 50%;
  border: 6px solid var(--slime-raised);
  border-top-color: var(--slime-secondary);
  animation: spin 1s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }

/* ---------- reveal ---------- */
.podium { display: grid; gap: 12px; }
.result {
  background: var(--slime-raised);
  border: var(--border-w) solid var(--slime-raised);
  border-radius: var(--radius-md);
  padding: 12px 14px;
}
.result .rank { font-size: var(--text-xs); font-weight: 700; text-transform: uppercase; letter-spacing: 0.1em; color: var(--slime-muted); }
.result .text { font-size: 1.05rem; margin: 4px 0 6px; }
.result .meta { display: flex; justify-content: space-between; align-items: center; gap: 10px; font-size: 0.85rem; color: var(--slime-muted); }
.result .share { color: var(--slime-secondary); font-weight: 700; font-size: 1rem; }
.result.filtered { opacity: 0.7; border-style: dashed; border-color: var(--slime-muted); }
/* Jev's pick: grape with dark ink and the goo shadow; it wobbles as it lands. */
.result.winner {
  background: var(--slime-secondary);
  border-color: var(--slime-secondary);
  color: var(--slime-on-bright);
  box-shadow: var(--shadow-goo);
}
.result.winner.tapped { border-color: var(--slime-accent); box-shadow: 0 0 0 2px var(--slime-accent), var(--shadow-goo); }
.result.winner .rank { color: var(--slime-on-bright); letter-spacing: 0.06em; }
.result.winner .rank-label {
  font-family: var(--font-display);
  font-weight: 400;
  font-synthesis: none;
  font-size: var(--text-lg);
  text-transform: none;
  letter-spacing: 0.01em;
}
.result.winner .text { font-weight: 700; font-size: 1.15rem; }
.result.winner .meta,
.result.winner .share,
.result.winner .mypick,
.result.winner .tapcount,
.result.winner .dim { color: var(--slime-on-bright); }
.result.winner .dim i { background: color-mix(in srgb, var(--slime-on-bright) 22%, transparent); }
.result.winner .dim i b { background: var(--slime-on-bright); }
.dims { display: grid; grid-template-columns: repeat(4, 1fr); gap: 6px; margin-top: 8px; }
.dim { font-size: 0.7rem; color: var(--slime-muted); }
.dim i { display: block; height: 5px; border-radius: 3px; background: var(--slime-bg); margin-top: 3px; overflow: hidden; }
.dim i b { display: block; height: 100%; background: var(--slime-secondary); }
.next { text-align: center; color: var(--slime-muted); margin-top: 14px; }
@keyframes slime-wobble {
  0% { transform: scale(0.96) rotate(-1deg); }
  40% { transform: scale(1.03) rotate(1deg); }
  70% { transform: scale(0.99) rotate(-0.5deg); }
  100% { transform: scale(1) rotate(0); }
}
.wobble { animation: slime-wobble 420ms ease-out; }

/* ---------- scores drawer ---------- */
#drawer { position: fixed; inset: 0; z-index: 30; }
.drawer-backdrop { position: absolute; inset: 0; background: color-mix(in srgb, var(--slime-bg) 78%, transparent); border: 0; }
.drawer-panel {
  position: absolute;
  top: 0;
  right: 0;
  bottom: 0;
  width: min(360px, 90vw);
  background: var(--slime-surface);
  border-left: var(--border-w) solid var(--slime-raised);
  padding: 18px;
  padding-top: calc(18px + env(safe-area-inset-top));
  overflow: auto;
}
.drawer-head { display: flex; justify-content: space-between; align-items: center; gap: 10px; }
.drawer-head h2,
.drawer-title { font-size: var(--text-heading); margin: 0; }
.drawer-title { margin: 20px 0 4px; }
.scores li.me { background: color-mix(in srgb, var(--slime-accent) 8%, transparent); border-radius: var(--radius-sm); padding-left: 10px; padding-right: 10px; }
.scores .who { display: flex; flex-direction: column; min-width: 0; }
.scores .who-name { display: flex; flex-wrap: wrap; align-items: center; gap: 4px; }
.scores .since { font-size: 0.75rem; color: var(--slime-muted); }
.scores { list-style: none; padding: 0; margin: 0; }
.scores li {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px 0;
  border-bottom: var(--border-w) solid var(--slime-raised);
}
.scores .pts { margin-left: auto; font-size: 1.3rem; font-weight: 700; font-variant-numeric: tabular-nums; color: var(--slime-accent); }

/* ---------- dialogs & toast ---------- */
dialog {
  background: var(--slime-raised);
  color: var(--slime-text);
  border: var(--border-w) solid var(--slime-primary);
  border-radius: var(--radius-xl);
  padding: 0;
  max-width: min(420px, calc(100vw - 32px));
  box-shadow: var(--shadow-goo);
}
/* Written out rather than mixed from --slime-bg: older browsers do not pass
   custom properties to ::backdrop, and the dim would vanish. */
dialog::backdrop { background: rgba(14, 21, 18, 0.78); backdrop-filter: blur(2px); }
.dialog-body { padding: 24px; }
.dialog-body h2 { font-size: var(--text-2xl); }
.dialog-body p { color: var(--slime-muted); margin: 12px 0 0; }
.dialog-body .row.end { gap: 12px; margin-top: 20px; }
.dialog-body .row.end .btn { padding-left: 16px; padding-right: 16px; }
#toast {
  position: fixed;
  left: 50%;
  bottom: calc(24px + env(safe-area-inset-bottom));
  transform: translateX(-50%) translateY(20px);
  background: var(--slime-raised);
  color: var(--slime-text);
  border: var(--border-w) solid var(--slime-primary);
  box-shadow: var(--shadow-goo);
  font-weight: 500;
  text-align: center;
  overflow-wrap: anywhere;
  padding: 10px 18px;
  border-radius: var(--radius-lg);
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.2s, transform 0.2s;
  z-index: 40;
  width: max-content;
  max-width: min(90vw, 480px);
}
#toast.show { opacity: 1; transform: translateX(-50%) translateY(0); }

@media (prefers-reduced-motion: reduce) {
  * { animation: none !important; transition: none !important; }
}
@media (max-width: 400px) {
  h1 { font-size: 40px; }
  .dialog-body { padding: 20px; }
  .slider { grid-template-columns: 6.5em 1fr 3em; }
  .dims { grid-template-columns: repeat(2, 1fr); }
}
