:root {
  --bg: #f6f4ef;
  --panel: #ffffff;
  --ink: #1d1d1b;
  --muted: #6b6a66;
  --line: #dedbd3;
  --accent: #2f6f4f;
  --accent-ink: #ffffff;
  --mover: #e8f1ec;
  --die: #ffffff;
  --pip: #1d1d1b;
  --held: #f2c94c;
  --good: #2f6f4f;
  --bad: #b3432f;
  --die-edge: var(--line);
  --font: system-ui, -apple-system, "Segoe UI", sans-serif;
  --title-font: var(--font);
  --name-font: var(--font);     /* names and totals */
  --title: var(--ink);
  --radius: 10px;
  --field: var(--bg);           /* inputs, selects and plain buttons */
  --pattern: none;
  --pattern-size: auto;
  --page-ink: var(--ink);       /* text straight on the page, outside the cards */
  --page-muted: var(--muted);
  --mark: "";                   /* before the name of whoever is to move */
}
/* Standard follows the system's dark mode; the other themes (themes.css) are fixed. */
@media (prefers-color-scheme: dark) {
  :root:not([data-theme]), :root[data-theme="standard"] {
    --bg: #181a19;
    --panel: #212423;
    --ink: #ecebe6;
    --muted: #9b9a94;
    --line: #34383a;
    --accent: #5fae86;
    --accent-ink: #0f1311;
    --mover: #24322b;
    --die: #f4f3ee;
    --pip: #1d1d1b;
    --held: #e0b53a;
    --good: #79c79c;
    --bad: #e2836f;
  }
}

* { box-sizing: border-box; }
[hidden] { display: none !important; }
body {
  margin: 0 auto;
  max-width: 1040px;
  padding: 16px;
  background: var(--bg);
  background-image: var(--pattern);
  background-size: var(--pattern-size);
  background-attachment: fixed;
  color: var(--ink);
  font: 15px/1.45 var(--font);
}
header { display: flex; justify-content: space-between; align-items: start; gap: 12px; flex-wrap: wrap; position: relative; z-index: 1; }
h1 { margin: 0; font-size: 28px; font-family: var(--title-font); color: var(--title); line-height: 1.15; }
h1 .icon:empty { display: none; }
h1 .icon { margin-right: .3em; display: inline-block; }
h2 { font-size: 16px; margin: 0 0 8px; font-family: var(--name-font); }
.sub, .about, .status { color: var(--page-muted); margin: 4px 0 12px; position: relative; z-index: 1; }
.status:empty, .about:empty { display: none; }
.prefs { display: flex; gap: 10px; align-items: end; }
.pref { display: flex; flex-direction: column; gap: 4px; font-size: 12px; color: var(--page-muted); }
button.sound { font-size: 18px; padding: 3px 10px; }

.card {
  background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius); padding: 12px;
  position: relative; z-index: 1;
}
.setup { display: flex; flex-wrap: wrap; gap: 10px 18px; align-items: end; }
.seat-setup { display: flex; flex-wrap: wrap; gap: 10px 14px; }
.field { display: flex; flex-direction: column; gap: 4px; }
.field > label:first-child { font-size: 12px; color: var(--muted); }
.field label.check { color: var(--ink); font-size: 14px; display: flex; gap: 6px; align-items: center; min-height: 34px; }
.seat-field select { max-width: 13em; }
.seat-name { width: 9em; }
select, input, button { font: inherit; color: var(--ink); }
select, input:not([type]), input[inputmode] {
  background: var(--field); border: 1px solid var(--line); border-radius: 6px; padding: 5px 8px;
}
button {
  background: var(--field); border: 1px solid var(--line); border-radius: 6px; padding: 6px 14px; cursor: pointer;
}
button:disabled { opacity: .45; cursor: default; }
button.primary { background: var(--accent); color: var(--accent-ink); border-color: var(--accent); }
button.link { background: none; border: none; padding: 0 4px; color: var(--accent); font-size: 13px; }

/* ---- the table: a tray per Seat, then the shared sheet ---------------------------- */
#board { margin-top: 8px; }
.trays { display: grid; gap: 12px; grid-template-columns: repeat(2, 1fr); }
.trays.seats-3 { grid-template-columns: repeat(3, 1fr); }
.trays.seats-4 { grid-template-columns: repeat(4, 1fr); }
@media (max-width: 900px) { .trays.seats-3, .trays.seats-4 { grid-template-columns: repeat(2, 1fr); } }
@media (max-width: 560px) { .trays, .trays.seats-3, .trays.seats-4 { grid-template-columns: 1fr; } }
.tray { padding: 10px 12px; transition: background .2s, border-color .2s, box-shadow .2s; }
.tray.mover { background: var(--mover); border-color: var(--accent); }
.tray-head { display: flex; justify-content: space-between; align-items: baseline; gap: 8px; }
.tray-head .name { font-weight: 600; font-size: 17px; font-family: var(--name-font); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.tray.mover .tray-head .name::before { content: var(--mark); margin-right: .25em; }
.tray-head .total { font-size: 24px; font-weight: 700; font-variant-numeric: tabular-nums; font-family: var(--name-font); }
.tray-sub { color: var(--muted); font-size: 12px; }
.tray-note { color: var(--muted); font-size: 13px; min-height: 1.4em; }
.tray-note .lost { color: var(--bad); }
.tray-note .given { font-size: 12px; }

.dice { display: flex; gap: 7px; margin: 8px 0; min-height: 50px; flex-wrap: wrap; }
.die {
  width: 46px; height: 46px; border-radius: 9px; background: var(--die); border: 2px solid var(--die-edge);
  display: grid; grid-template: repeat(3, 1fr) / repeat(3, 1fr); padding: 6px; cursor: default;
  transition: transform .15s, box-shadow .15s;
}
.die.blank { background: transparent; border-style: dashed; }
.die.clickable { cursor: pointer; }
.die.clickable:hover { transform: translateY(-2px); }
.die.held { border-color: var(--held); box-shadow: 0 0 0 3px var(--held); transform: translateY(-4px); }
.die.fresh { animation: tumble .45s cubic-bezier(.2, .8, .3, 1.2); }
@keyframes tumble {
  0% { transform: translate(-14px, -18px) rotate(var(--tumble, 300deg)) scale(.7); opacity: .3; }
  70% { transform: translate(0, 2px) rotate(-6deg) scale(1.04); opacity: 1; }
  100% { transform: none; }
}
.pip { width: 8px; height: 8px; border-radius: 50%; background: var(--pip); place-self: center; }
.controls { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; min-height: 34px; }
.hint { color: var(--muted); font-size: 13px; }
.hint .good { color: var(--good); }
.hint .bad { color: var(--bad); }

.sheet-card { margin-top: 12px; overflow-x: auto; padding: 8px 10px; }
table.sheet { width: 100%; border-collapse: collapse; font-variant-numeric: tabular-nums; }
.sheet th, .sheet td { padding: 4px 8px; border-top: 1px solid var(--line); }
.sheet thead th { border-top: none; font-family: var(--name-font); font-size: 14px; text-align: center; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; max-width: 9em; }
.sheet tbody th { text-align: left; font-weight: 400; white-space: nowrap; }
.sheet td { text-align: center; width: 18%; }
/* Every other row lightly shaded, and the row under the mouse marked, to follow a box
   across to its points; the cells' own colours lie over it. */
.sheet tbody tr:nth-child(even) { background: color-mix(in srgb, var(--ink) 6%, transparent); }
@media (hover: hover) { .sheet tbody tr:hover { background: color-mix(in srgb, var(--accent) 12%, transparent); } }
.sheet .mover { background: color-mix(in srgb, var(--accent) 9%, transparent); }
.sheet thead th.mover { color: var(--accent); }
.sheet tr.end-upper th, .sheet tr.end-upper td { border-bottom: 2px solid var(--line); }
.sheet tr.sum th, .sheet tr.sum td { font-weight: 700; }
.sheet tr.total th, .sheet tr.total td { border-top: 2px solid var(--line); font-size: 17px; font-family: var(--name-font); }
.sheet td.won { color: var(--good); }
.sheet td.scratch { color: var(--muted); }
.sheet .togo { color: var(--muted); font-size: 11px; font-weight: 400; white-space: nowrap; }
.sheet td.just { background: color-mix(in srgb, var(--held) 40%, transparent); }
/* Filled boxes are written in ink; boxes that can be filled now are tinted and framed,
   their points in the theme's colour, the ones that would give nothing greyed. */
.sheet td.filled { font-weight: 700; color: var(--ink); }
.sheet td.choice {
  cursor: pointer; background: color-mix(in srgb, var(--accent) 16%, var(--panel));
  outline: 2px dashed var(--accent); outline-offset: -3px; border-radius: 6px;
}
.sheet td.choice .pts { font-weight: 700; color: var(--accent); }
.sheet td.choice.nothing { background: color-mix(in srgb, var(--muted) 10%, var(--panel)); outline-color: color-mix(in srgb, var(--muted) 55%, transparent); }
.sheet td.choice.nothing .pts { color: var(--muted); font-weight: 600; }
.sheet td.choice:hover, .sheet td.choice:focus { background: color-mix(in srgb, var(--accent) 32%, var(--panel)); outline-style: solid; }
.sheet td.choice .ev { display: block; font-size: 11px; color: var(--muted); line-height: 1.1; }
.sheet td.choice.best .ev { color: var(--good); font-weight: 700; }
.sheet td.choice.best { background: color-mix(in srgb, var(--good) 22%, var(--panel)); outline: 2px solid var(--good); }
.sheet td.choice.best .pts { color: var(--good); }

.game-bar {
  display: flex; flex-wrap: wrap; justify-content: space-between; align-items: center; gap: 8px;
  margin: 0 0 8px; position: relative; z-index: 1;
}
.game-bar .watch-only, .game-bar .game-actions { display: flex; flex-wrap: wrap; align-items: center; gap: 6px; }
.game-bar #pause { min-width: 5.5em; }
.game-bar .where { color: var(--page-muted); font-size: 13px; font-variant-numeric: tabular-nums; margin-left: 4px; }

.log { margin-top: 16px; }
.log ol { margin: 0; padding-left: 2.6em; max-height: 240px; overflow: auto; font-size: 13px; position: relative; }
.log .lost { color: var(--bad); }
.log li.future { opacity: .35; }
.log li.current { font-weight: 600; background: color-mix(in srgb, var(--held) 30%, transparent); border-radius: 4px; }
#log.watching li { cursor: pointer; }
.result { font-size: 18px; font-weight: 600; color: var(--page-ink); }

/* ---- flourishes ---------------------------------------------------------------------- */
.toast {
  position: fixed; left: 50%; top: 38%; z-index: 30; pointer-events: none;
  transform: translate(-50%, -50%); padding: 14px 26px; border-radius: 16px;
  background: var(--accent); color: var(--accent-ink); font: 700 24px/1.2 var(--title-font);
  box-shadow: 0 10px 30px rgba(0, 0, 0, .25); white-space: nowrap;
  animation: toast 2.3s ease-out forwards;
}
.toast.yatzy, .toast.win { font-size: 40px; padding: 18px 34px; }
.toast.win { animation-duration: 3.1s; }
.zero-pop {
  position: fixed; z-index: 28; pointer-events: none; transform: translate(-50%, -100%);
  padding: 3px 10px; border-radius: 999px; white-space: nowrap;
  background: var(--panel); color: var(--bad); border: 1px solid var(--line);
  font: 600 14px/1.3 var(--name-font); box-shadow: 0 4px 14px rgba(0, 0, 0, .18);
  animation: zero-pop 1.9s ease-out forwards;
}
@keyframes zero-pop {
  0% { transform: translate(-50%, -60%) scale(.6); opacity: 0; }
  15% { transform: translate(-50%, -110%) scale(1.05); opacity: 1; }
  75% { opacity: 1; }
  100% { transform: translate(-50%, -260%) scale(.95); opacity: 0; }
}
@keyframes toast {
  0% { transform: translate(-50%, -50%) scale(.3) rotate(-8deg); opacity: 0; }
  14% { transform: translate(-50%, -50%) scale(1.12) rotate(2deg); opacity: 1; }
  24% { transform: translate(-50%, -50%) scale(1) rotate(0); }
  80% { opacity: 1; }
  100% { transform: translate(-50%, -80%) scale(.96); opacity: 0; }
}
.party { position: fixed; inset: 0; pointer-events: none; overflow: hidden; z-index: 20; }
.party span { position: absolute; top: -10vh; animation: party-fall 2.8s ease-in forwards; }
@keyframes party-fall {
  to { transform: translate(var(--drift, 0px), 115vh) rotate(var(--spin, 360deg)); opacity: .9; }
}
.ambient { position: fixed; inset: 0; pointer-events: none; overflow: hidden; z-index: 0; }
.ambient span { position: absolute; display: none; }
@media (prefers-reduced-motion: reduce) {
  .die.fresh, .toast { animation: none; }
  .ambient { display: none; }
}

/* ---- options drawer, help, results ----------------------------------------------- */
button.round { font-size: 17px; padding: 3px 10px; border-radius: 999px; }
details.more { flex-basis: 100%; }
details.more summary { cursor: pointer; color: var(--muted); font-size: 13px; width: fit-content; }
.more-body { display: flex; flex-wrap: wrap; gap: 10px 18px; align-items: end; margin-top: 8px; }
.places { display: block; font-size: 14px; font-weight: 400; color: var(--page-muted); margin-top: 2px; }
dialog {
  max-width: min(520px, calc(100vw - 32px)); border: 1px solid var(--line); border-radius: var(--radius);
  background: var(--panel); color: var(--ink); padding: 18px 22px; font-family: var(--font);
}
dialog::backdrop { background: rgba(0, 0, 0, .45); }
dialog { max-height: 86vh; overflow: auto; max-width: min(600px, calc(100vw - 24px)); }
dialog p { margin: 0 0 10px; }
dialog ol, dialog ul { padding-left: 1.4em; margin: 0 0 14px; }
dialog li { margin-bottom: 7px; line-height: 1.4; }
dialog h3 { font-size: 16px; margin: 14px 0 6px; font-family: var(--name-font); }
.help-steps li::marker { font-weight: 700; color: var(--accent); }
.help-boxes { width: 100%; border-collapse: collapse; font-size: 14px; margin-bottom: 8px; }
.help-boxes th { text-align: left; white-space: nowrap; padding: 4px 10px 4px 0; vertical-align: top; }
.help-boxes td { padding: 4px 0; color: var(--muted); }
.help-boxes tr + tr th, .help-boxes tr + tr td { border-top: 1px solid var(--line); }
.help-boxes tr.bonus th { color: var(--good); }
dialog form { position: sticky; bottom: -18px; background: var(--panel); padding: 8px 0 0; text-align: right; }
dialog h2 { font-family: var(--title-font); font-size: 22px; }
.sheet tbody th[title] { cursor: help; text-decoration: underline dotted color-mix(in srgb, var(--muted) 60%, transparent); text-underline-offset: 3px; }

/* ---- while a game is on, the setup folds to its buttons ---------------------------- */
.edit-setup { display: none; }
.setup.playing .edit-setup { display: inline-block; }
.setup.playing:not(.editing) > :not(#new-game):not(#edit-setup) { display: none; }
.setup.playing:not(.editing) { padding: 8px 12px; }
body.playing:not(.editing) .about { display: none; }

.tray-guide { display: none; }

/* ---- every choice and its expected score ---------------------------------------- */
.options { position: relative; display: inline-block; }
.options-toggle { font-size: 12.5px; padding: 3px 10px; }
.options-pop {
  display: none; position: absolute; z-index: 25; top: calc(100% + 6px); left: 0;
  width: min(330px, 88vw); max-height: 360px; overflow: auto;
  background: var(--panel); color: var(--ink); border: 1px solid var(--line); border-radius: 10px;
  box-shadow: 0 10px 30px rgba(0, 0, 0, .28); padding: 8px 10px; font: 13px/1.3 var(--font); text-align: left;
}
.options.open .options-pop { display: block; }
@media (hover: hover) { .options:hover .options-pop { display: block; } }
.card:has(.options) { z-index: 5; }
.options-pop p { margin: 0 0 6px; color: var(--muted); font-size: 12px; }
.options-pop table { width: 100%; border-collapse: collapse; font-variant-numeric: tabular-nums; }
.options-pop th { font-size: 11px; color: var(--muted); font-weight: 600; padding: 2px 4px; text-align: left; }
.options-pop td { padding: 3px 4px; border-top: 1px solid var(--line); }
.options-pop th:not(:first-child), .options-pop td:not(:first-child) { text-align: right; white-space: nowrap; }
.options-pop tr.top td { color: var(--good); font-weight: 700; }
.options-pop tr.yours td { background: color-mix(in srgb, var(--held) 32%, transparent); }
.options-pop tr.pick { cursor: pointer; }
.options-pop tr.pick:hover td { background: color-mix(in srgb, var(--accent) 16%, transparent); }

/* ---- phones: one screen's height holds the sheet, with the dice pinned below ------- */
@media (max-width: 600px) {
  body { padding: 8px 8px 12px; font-size: 14px; }
  h1 { font-size: 24px; }
  .sub { font-size: 13px; margin-bottom: 8px; }
  .prefs { gap: 6px; flex-wrap: wrap; }
  .setup { gap: 8px 12px; }
  .seat-field select { max-width: 11em; }
  .seat-name { width: 7em; }

  /* Playing, the header shrinks to the title and its round buttons. */
  body.playing:not(.editing) header { align-items: center; }
  body.playing:not(.editing) .sub, body.playing:not(.editing) .pref { display: none; }
  body.playing:not(.editing) h1 { font-size: 22px; }
  body.playing #status:not(.result) { display: none; }
  .setup.playing:not(.editing) { padding: 6px 8px; margin-bottom: 6px; }
  .setup.playing:not(.editing) button { padding: 4px 12px; font-size: 14px; }

  /* Everyone not pinned gets a compact tray, two a row: name and score, then the dice
     beside the last move. */
  .tray:not(.dock) { display: grid; grid-template-columns: auto 1fr; grid-template-areas: "head head" "dice note"; column-gap: 6px; align-items: center; }
  .tray:not(.dock) .tray-head { grid-area: head; }
  .tray:not(.dock) .dice { grid-area: dice; }
  .tray:not(.dock) .tray-note { grid-area: note; }
  .tray:not(.dock) .tray-sub { display: none; }
  #board { margin-top: 4px; }
  .trays, .trays.seats-3, .trays.seats-4 { grid-template-columns: 1fr 1fr; gap: 6px; }
  .tray { padding: 6px 8px; }
  .tray-head .name { font-size: 14px; }
  .tray-head .total { font-size: 18px; }
  .tray-sub { font-size: 11px; }
  .tray:not(.dock) .dice { gap: 3px; min-height: 24px; margin: 3px 0 0; flex-wrap: nowrap; }
  [data-theme] .tray:not(.dock) .die, .tray:not(.dock) .die {
    width: 22px; height: 22px; padding: 2px; border-radius: 5px; border-width: 1.5px;
  }
  .tray:not(.dock) .pip { width: 4px; height: 4px; }
  .tray:not(.dock) .die::before, .tray:not(.dock) .die::after { display: none; }
  .tray:not(.dock) .tray-note .given, .tray:not(.dock) .controls { display: none; }
  .tray:not(.dock) .tray-note { font-size: 11.5px; min-height: 0; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
  [data-theme="christmas"] .tray:not(.dock)::after { display: none; }

  /* The pinned tray: a person's dice and buttons, always in reach. */
  .tray.dock {
    position: fixed; left: 0; right: 0; bottom: 0; z-index: 15; margin: 0;
    border-radius: 18px 18px 0 0; border-bottom: none;
    padding: 8px 12px calc(10px + env(safe-area-inset-bottom));
    box-shadow: 0 -6px 22px rgba(0, 0, 0, .2);
  }
  .tray.dock .tray-sub { display: none; }
  .tray.dock .tray-note { display: none; }
  .tray.dock .tray-guide { display: block; font-weight: 600; font-size: 13px; margin-top: 2px; }
  .tray.dock .dice { margin: 5px 0; gap: 8px; min-height: 42px; justify-content: center; }
  .tray.dock .die { width: 42px; height: 42px; }
  [data-theme="kids"] .tray.dock .die { width: 44px; height: 44px; }
  .tray.dock .controls { min-height: 0; justify-content: center; }
  .tray.dock .controls .hint { flex-basis: 100%; text-align: center; font-size: 11.5px; line-height: 1.25; }
  .tray.dock .tray-head .name { font-size: 15px; }
  /* On a phone the list opens upwards from the pinned tray, across the screen. */
  .tray.dock .options-pop {
    position: fixed; left: 8px; right: 8px; width: auto; top: auto;
    bottom: calc(var(--dock-h, 180px) + 6px); max-height: 55vh;
  }
  [data-theme="christmas"] .tray.dock::after { display: none; }

  /* Watching, the controls are pinned instead. */
  body.watching .game-bar {
    position: fixed; left: 0; right: 0; bottom: 0; z-index: 15; margin: 0;
    background: var(--panel); border-top: 1px solid var(--line);
    padding: 8px 10px calc(8px + env(safe-area-inset-bottom)); justify-content: center;
    box-shadow: 0 -6px 22px rgba(0, 0, 0, .15);
  }
  .game-bar { margin-bottom: 4px; }
  .game-bar button { padding: 4px 10px; }

  /* The sheet: fixed columns, tight rows, the names cut short. */
  .sheet-card { padding: 4px 4px; margin-top: 6px; }
  table.sheet { table-layout: fixed; font-size: 12.5px; line-height: 1.15; }
  .sheet th, .sheet td { padding: 1.5px 3px; }
  .sheet tbody th { width: 31%; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; font-size: 12px; }
  .sheet td { width: auto; }
  .sheet thead th { font-size: 11px; max-width: none; padding-bottom: 3px; }
  .sheet tr.total th, .sheet tr.total td { font-size: 14px; }
  .sheet .togo { font-size: 9px; white-space: nowrap; }
  .sheet td.choice .ev { display: none; }

  .log { margin-top: 10px; }
  .log ol { max-height: 160px; }
  .toast { font-size: 20px; }
  .toast.yatzy, .toast.win { font-size: 26px; white-space: normal; text-align: center; width: max-content; max-width: 92vw; }
  [data-theme="kids"] h1, [data-theme="halloween"] h1, [data-theme="christmas"] h1 { font-size: 30px; }
  [data-theme="kids"] body, [data-theme="christmas"] body { padding-top: 30px; }
}

/* ---- boxes as dice ----------------------------------------------------------------- */
.box-dice { display: inline-flex; gap: 2px; vertical-align: middle; }
.mini-die {
  width: 15px; height: 15px; padding: 1.5px; border-radius: 3px; flex: none;
  background: var(--mini-die, var(--die)); border: 1.5px solid var(--mini-edge, var(--die-edge));
  display: inline-grid; grid-template: repeat(3, 1fr) / repeat(3, 1fr);
  font: 700 10px/1 var(--font); color: var(--mini-pip, var(--pip)); place-items: center;
}
.mini-die:not(:has(span)) { display: inline-flex; justify-content: center; align-items: center; }
.mini-die .pip { width: 3px; height: 3px; background: var(--mini-pip, var(--pip)); }
[data-theme="large"] .mini-die { width: 22px; height: 22px; } [data-theme="large"] .mini-die .pip { width: 4.5px; height: 4.5px; }
@media (max-width: 600px) { .mini-die { width: 13px; height: 13px; padding: 1px; } .mini-die .pip { width: 2.5px; height: 2.5px; } .box-dice { gap: 1px; } }
/* Dice in words — a move, a hint, a choice — a little larger than in the sheet. */
.tray-note .mini-die, .hint .mini-die, .options-pop .mini-die { width: 17px; height: 17px; }
.tray-note .mini-die .pip, .hint .mini-die .pip, .options-pop .mini-die .pip { width: 3.5px; height: 3.5px; }
.tray-note .box-dice, .hint .box-dice, .options-pop .box-dice, .log .box-dice { margin: 0 2px; vertical-align: -3px; }
button.undo { font-weight: 600; }
.tray .controls .undo { padding: 4px 12px; }

/* ---- asking before a box is filled in -------------------------------------------- */
dialog.confirm { max-width: min(440px, calc(100vw - 24px)); text-align: center; }
.confirm-head { display: flex; align-items: center; justify-content: center; gap: 12px; flex-wrap: wrap; }
.confirm-head h2 { margin: 0; font-size: 26px; font-family: var(--title-font); color: var(--accent); }
.confirm-head .mini-die { width: 22px; height: 22px; padding: 2.5px; }
.confirm-head .mini-die .pip { width: 4.5px; height: 4.5px; }
.confirm-rule { color: var(--muted); margin: 8px 0 12px; }
.confirm-label { font-size: 12px; text-transform: uppercase; letter-spacing: .5px; color: var(--muted); margin: 0; }
.confirm-dice { justify-content: center; margin: 6px 0 10px; }
.confirm-dice .die.counts { border-color: var(--good); box-shadow: 0 0 0 3px var(--good); transform: translateY(-3px); }
.confirm-dice .die.idle { opacity: .35; }
.confirm-points { font-size: 20px; font-weight: 700; margin: 4px 0; }
.confirm-points.zero { color: var(--bad); font-size: 17px; }
.confirm-bonus { color: var(--good); font-weight: 700; margin: 4px 0; }
.confirm-early { color: var(--muted); font-size: 14px; margin: 6px 0 0; }
.confirm-buttons { display: flex; gap: 10px; justify-content: center; margin-top: 14px; position: static; background: none; padding: 0; }
.confirm-buttons button { font-size: 16px; padding: 9px 16px; }

/* ---- cheat mode ------------------------------------------------------------------- */
.die.cheatable { -webkit-touch-callout: none; user-select: none; -webkit-user-select: none; touch-action: manipulation; }
.cheat-pop {
  position: fixed; z-index: 40; background: var(--panel); color: var(--ink); border: 2px solid var(--accent);
  border-radius: 12px; padding: 8px 10px; box-shadow: 0 10px 30px rgba(0, 0, 0, .3); text-align: center;
  font: 600 13px/1.3 var(--font);
}
.cheat-faces { display: flex; gap: 6px; margin: 6px 0 8px; }
.cheat-faces button { padding: 4px; line-height: 0; }
.cheat-faces .mini-die { width: 30px; height: 30px; padding: 4px; }
.cheat-faces .mini-die .pip { width: 6px; height: 6px; }

/* ---- the first visit's tutorial ---------------------------------------------------- */
.tutorial {
  position: fixed; z-index: 45; max-width: min(300px, calc(100vw - 16px));
  background: var(--accent); color: var(--accent-ink); border-radius: 14px; padding: 10px 14px;
  box-shadow: 0 10px 30px rgba(0, 0, 0, .3); font: 600 15px/1.35 var(--font);
  animation: tut-in .3s ease-out;
}
.tutorial p { margin: 0 0 8px; }
.tutorial::after {
  content: ""; position: absolute; left: calc(var(--arrow, 50%) - 8px); bottom: -8px;
  border: 8px solid transparent; border-bottom: 0; border-top-color: var(--accent);
}
.tutorial.below::after { bottom: auto; top: -8px; border: 8px solid transparent; border-top: 0; border-bottom-color: var(--accent); }
.tutorial-buttons { display: flex; gap: 10px; justify-content: flex-end; align-items: center; }
.tutorial button { background: var(--accent-ink); color: var(--accent); border: none; font-weight: 700; padding: 5px 14px; }
.tutorial button.link { background: none; color: var(--accent-ink); opacity: .85; text-decoration: underline; padding: 0; }
.tut-target { outline: 3px solid var(--accent) !important; outline-offset: 3px; border-radius: 8px; animation: tut-pulse 1.4s ease-in-out infinite; }
@keyframes tut-in { from { opacity: 0; transform: translateY(6px); } }
@keyframes tut-pulse { 50% { outline-offset: 7px; } }
@media (prefers-reduced-motion: reduce) { .tutorial, .tut-target { animation: none; } }

/* ---- the mascot, and the background's secrets ---------------------------------------- */
.mascot {
  position: fixed; right: 14px; bottom: 14px; z-index: 16; font-size: 44px; line-height: 1;
  background: none; border: none; padding: 0; cursor: pointer; filter: drop-shadow(0 4px 6px rgba(0, 0, 0, .25));
  animation: mascot-idle 3s ease-in-out infinite; transform-origin: 50% 100%;
}
@keyframes mascot-idle { 50% { transform: translateY(-4px) rotate(-3deg); } }
.mascot.cheer { animation: mascot-cheer .8s ease-out 2; }
@keyframes mascot-cheer { 30% { transform: translateY(-26px) rotate(-12deg) scale(1.15); } 60% { transform: translateY(0) rotate(8deg); } }
.mascot.droop { animation: mascot-droop 1.4s ease-in-out; }
@keyframes mascot-droop { 30%, 70% { transform: translateY(6px) rotate(14deg) scale(.92); filter: grayscale(.6); } }
.mascot.sleep { animation: mascot-sleep 3s ease-in-out infinite; opacity: .75; }
@keyframes mascot-sleep { 50% { transform: rotate(10deg) translateY(3px); } }
.mascot-says {
  position: fixed; right: 18px; bottom: 76px; z-index: 17; max-width: min(260px, 70vw);
  background: var(--panel); color: var(--ink); border: 2px solid var(--accent); border-radius: 14px 14px 4px 14px;
  padding: 7px 12px; font: 600 14px/1.35 var(--font); box-shadow: 0 6px 18px rgba(0, 0, 0, .25);
  opacity: 0; transform: translateY(8px) scale(.95); transition: opacity .25s, transform .25s; pointer-events: none;
}
.mascot-says.shown { opacity: 1; transform: none; }
.ambient span { pointer-events: auto; cursor: pointer; }
.ambient span.poked::before, .ambient span.poked::after { animation: poked .7s ease-out !important; display: inline-block; }
@keyframes poked { 30% { transform: scale(1.6) rotate(-15deg); } 60% { transform: scale(.8) rotate(10deg); } }
.burst { position: fixed; z-index: 30; pointer-events: none; font-size: 22px; transform: translate(-50%, -50%); animation: burst .85s ease-out forwards; }
@keyframes burst { to { transform: translate(calc(-50% + var(--bx)), calc(-50% + var(--by))) scale(.6); opacity: 0; } }

/* ---- the journey ------------------------------------------------------------------- */
.journey { position: relative; height: 30px; margin: 0 4px 8px; z-index: 1; }
.journey .track { position: absolute; left: 14px; right: 18px; top: 50%; border-top: 3px dotted color-mix(in srgb, var(--page-muted) 70%, transparent); }
.journey .goal { position: absolute; right: 0; top: 50%; transform: translateY(-50%); font-size: 24px; }
.journey .traveler {
  position: absolute; top: 50%; font-size: 24px; left: calc(var(--at, 0) * (100% - 58px));
  transform: translateY(-50%); transition: left .8s ease-in-out;
}
.journey.arrived .goal { animation: goal-hop .6s ease-in-out 3; }
@keyframes goal-hop { 50% { transform: translateY(-80%) scale(1.25); } }

/* ---- themed rolls ------------------------------------------------------------------ */
.dice { position: relative; }
.roll-from {
  position: absolute; left: 50%; top: -6px; font-size: 30px; pointer-events: none; z-index: 2;
  animation: roll-from .75s ease-out forwards;
}
.roll-from i { position: absolute; left: 30%; top: 30%; font-style: normal; font-size: 16px; animation: roll-bit .7s ease-out forwards; }
@keyframes roll-from {
  0% { transform: translate(-50%, -20px) scale(.3); opacity: 0; }
  25% { transform: translate(-50%, -26px) scale(1.15) rotate(-20deg); opacity: 1; }
  55% { transform: translate(-50%, -26px) rotate(25deg); opacity: 1; }
  100% { transform: translate(-50%, -40px) scale(.6); opacity: 0; }
}
@keyframes roll-bit { from { transform: translate(0, 0); opacity: 1; } to { transform: translate(var(--dx), 26px); opacity: 0; } }

/* ---- the sheet's light theme touch ---------------------------------------------------- */
.sheet-card[data-mark]::after {
  content: attr(data-mark); position: absolute; right: 10px; bottom: 6px; font-size: 72px; line-height: 1;
  opacity: .07; pointer-events: none;
}
.sheet thead tr { background: color-mix(in srgb, var(--accent) 10%, transparent); }
.sheet tr.total { background: color-mix(in srgb, var(--accent) 10%, transparent) !important; }

/* ---- the end of a game ------------------------------------------------------------ */
dialog.ending { max-width: min(460px, calc(100vw - 24px)); text-align: center; }
.end-head { display: flex; flex-direction: column; align-items: center; gap: 4px; }
.end-icon { font-size: 54px; animation: end-icon 1.2s ease-in-out infinite; }
@keyframes end-icon { 50% { transform: translateY(-8px) rotate(-6deg) scale(1.08); } }
.end-head h2 { margin: 0; font-family: var(--title-font); font-size: 26px; color: var(--accent); }
.end-line { margin: 6px 0 10px; font-weight: 600; }
.end-places { list-style: none; padding: 0; margin: 0 0 12px; text-align: left; }
.end-places li { display: grid; grid-template-columns: 32px 1fr auto; grid-template-areas: "medal who score" "medal good good"; align-items: center; column-gap: 8px; padding: 6px 8px; border-radius: 10px; }
.end-places li + li { margin-top: 4px; }
.end-places li.first { background: color-mix(in srgb, var(--held) 25%, transparent); }
.end-places .medal { grid-area: medal; font-size: 26px; }
.end-places .who { grid-area: who; font-weight: 700; font-family: var(--name-font); }
.end-places .score { grid-area: score; font-weight: 700; font-size: 20px; font-family: var(--name-font); }
.end-places .good { grid-area: good; font-size: 13px; color: var(--muted); }
.end-buttons { display: flex; flex-wrap: wrap; gap: 8px; justify-content: center; position: static; background: none; padding: 0; }
.end-buttons button { font-size: 15px; padding: 8px 14px; }

/* On a phone the mascot sits on the pinned tray, and says its piece above it. */
@media (max-width: 600px) {
  .mascot { font-size: 32px; right: 10px; bottom: calc(var(--dock-h, 0px) - 6px); }
  .mascot-says { right: 10px; bottom: calc(var(--dock-h, 0px) + 34px); font-size: 13px; }
  .journey { height: 24px; margin-bottom: 4px; }
  .journey .goal, .journey .traveler { font-size: 19px; }
  .sheet-card[data-mark]::after { font-size: 54px; }
}
@media (prefers-reduced-motion: reduce) {
  .mascot, .mascot.cheer, .mascot.droop, .mascot.sleep, .roll-from, .end-icon, .journey.arrived .goal { animation: none; }
}
.scene { position: fixed; inset: 0; z-index: 0; pointer-events: none; }

/* ---- party mode (an easter egg) ----------------------------------------------------- */
body.party-mode .die:not(.blank) { animation: party-spin .9s linear infinite !important; }
body.party-mode .card { animation: party-hue 1.5s linear infinite; }
@keyframes party-spin { to { transform: rotate(360deg); } }
@keyframes party-hue { to { filter: hue-rotate(360deg); } }
@media (prefers-reduced-motion: reduce) { body.party-mode .die, body.party-mode .card { animation: none !important; } }
h1 { cursor: default; user-select: none; }
