:root {
  --ink: #16151A;
  --ink-2: #1E1D23;
  --ink-3: #2A2830;
  --line: #35333B;
  --line-2: #26242C;
  --paper: #EFE9DD;
  --muted: #9A98A0;
  --muted-2: #78767E;
  --faint: #4A484F;
  --text-2: #C4C1CA;
  --on-accent: #16151A;

  --headsup: #3E8FB0;
  --imposter: #6C63A6;
  --imposter-glow: #6C63A622;
  --rules: #4C9A6A;
  --score: #D9A441;
  --dice: #5CBFB3;
  --fishbowl: #F2545B;
  --settings: #9A98A0;
  --flash-correct: #4C9A6A;
  --flash-pass: #F2545B;

  --font-display: Georgia, 'Iowan Old Style', 'Times New Roman', serif;
  --font-body: -apple-system, BlinkMacSystemFont, 'Segoe UI', Helvetica, Arial, sans-serif;
  --font-mono: 'SF Mono', 'JetBrains Mono', Menlo, Consolas, monospace;

  --safe-top: env(safe-area-inset-top, 0px);
  --safe-bottom: env(safe-area-inset-bottom, 0px);

  color-scheme: dark;
}

/* Dark stays the default; only an explicit light preference switches. */
@media (prefers-color-scheme: light) {
  :root {
    --ink: #F6F3EC;
    --ink-2: #FFFFFF;
    --ink-3: #ECE7DE;
    --line: #D8D2C7;
    --line-2: #E6E1D8;
    --paper: #1C1B20;
    --muted: #5E5C64;
    --muted-2: #73717A;
    --faint: #8C8992;
    --text-2: #3A3840;
    /* Deeper accents so they hold up as text on the pale ground. */
    --rules: #3B7F55;
    --score: #A87512;
    --dice: #2B8378;
    --settings: #6E6C74;
    color-scheme: light;
  }
  .exit-btn:not(.hu-exit-btn) {
    background: var(--ink-2);
    border-color: var(--line);
    color: var(--paper);
  }
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  padding: 0;
  height: 100%;
  background: var(--ink);
  color: var(--paper);
  font-family: var(--font-body);
  -webkit-tap-highlight-color: transparent;
  overscroll-behavior: none;
  user-select: none;
  /* Kills double-tap-to-zoom (and the 300ms tap delay that comes with it)
     while leaving scrolling alone. Pinch is blocked separately in app.js,
     because iOS ignores user-scalable=no in the viewport meta. */
  touch-action: manipulation;
}

button, input { font-family: inherit; }

#app {
  position: fixed;
  inset: 0;
  overflow: hidden;
}

.view {
  position: absolute;
  inset: 0;
  display: none;
  flex-direction: column;
  overflow-y: auto;
  padding-top: var(--safe-top);
  padding-bottom: var(--safe-bottom);
}
.view.active { display: flex; }

/* ---------- Home ---------- */
#view-home { padding: 24px 20px; }
.home-header { padding: 24px 8px 8px; }
.home-title {
  font-family: var(--font-display);
  font-size: 30px;
  font-weight: 700;
  margin: 0;
}
.home-sub {
  color: var(--muted-2);
  font-size: 13px;
  margin: 4px 0 0;
}
.divider { border: none; border-top: 1px solid var(--line); margin: 20px 8px; }

.mode-card {
  display: flex;
  align-items: center;
  gap: 16px;
  background: var(--ink-2);
  border: 1.5px solid var(--card-accent, var(--line));
  border-radius: 18px;
  border-color: var(--line);
  padding: 20px;
  margin: 0 0 16px;
  cursor: pointer;
  text-align: left;
  width: 100%;
  color: var(--paper);
}
.mode-icon {
  flex: none;
  width: 40px; height: 40px;
  display: flex; align-items: center; justify-content: center;
  color: var(--card-accent);
}
.mode-icon svg { width: 100%; height: 100%; display: block; }
.mode-body { flex: 1; min-width: 0; }
.mode-name {
  font-family: var(--font-display);
  font-size: 20px;
  font-weight: 700;
  margin: 0 0 2px;
  color: var(--card-accent);
}
.mode-desc { font-size: 13px; color: var(--muted); margin: 0; }
.mode-arrow { font-size: 13px; color: var(--card-accent); flex: none; }

.footnote {
  text-align: center;
  color: var(--faint);
  font-size: 11px;
  margin-top: 8px;
}

/* ---------- Shared top bar ---------- */
.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 16px 20px;
}
.back-btn {
  background: none; border: none;
  color: var(--muted);
  font-size: 15px;
  padding: 8px 4px;
  cursor: pointer;
}
.topbar-title {
  font-family: var(--font-display);
  font-size: 17px;
  font-weight: 700;
}

/* ---------- Buttons ---------- */
.btn {
  display: block;
  width: 100%;
  border: none;
  border-radius: 14px;
  padding: 16px;
  font-size: 15px;
  font-weight: 700;
  cursor: pointer;
  text-align: center;
}
.btn-primary { background: var(--accent, var(--paper)); color: var(--on-accent); }
.btn-outline {
  background: transparent;
  border: 1.5px solid var(--line);
  color: var(--paper);
}
.chip {
  display: inline-flex;
  align-items: center;
  padding: 10px 16px;
  border-radius: 999px;
  border: 1.5px solid var(--line);
  color: var(--muted);
  font-size: 14px;
  margin: 0 8px 8px 0;
  cursor: pointer;
  background: transparent;
}
.chip.selected {
  border-color: var(--accent);
  color: var(--paper);
  background: color-mix(in srgb, var(--accent) 18%, transparent);
}
.chip.chip-empty {
  border-style: dashed;
  color: var(--muted-2);
}

/* ---------- Resume card (score keeper, fishbowl) ---------- */
.resume-card {
  background: color-mix(in srgb, var(--accent) 12%, var(--ink-2));
  border: 1.5px solid color-mix(in srgb, var(--accent) 45%, transparent);
  border-radius: 16px;
  padding: 16px;
  margin-bottom: 24px;
}
.resume-eyebrow {
  font-size: 11px; font-weight: 700; letter-spacing: 0.06em;
  color: var(--accent); margin: 0 0 8px;
}
.resume-where { font-size: 15px; font-weight: 600; margin: 0 0 2px; }
.resume-when { font-size: 12.5px; color: var(--muted-2); margin: 0 0 14px; }
.resume-actions { display: flex; align-items: center; gap: 14px; }
.resume-actions .btn { flex: 1; padding: 13px; }
.resume-actions .link-btn { flex: none; padding: 8px 4px; }

/* ---------- Setup screens (generic) ---------- */
.setup-body { padding: 8px 20px 24px; flex: 1; }
.setup-section { margin-bottom: 28px; }
.setup-label {
  font-size: 12px;
  font-weight: 700;
  letter-spacing: 0.04em;
  color: var(--accent);
  margin-bottom: 10px;
}
.setup-footer { padding: 16px 20px 24px; }

.stepper {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 24px;
  padding: 12px 0;
}
.stepper-btn {
  width: 48px; height: 48px;
  border-radius: 50%;
  border: 1.5px solid var(--line);
  background: var(--ink-2);
  color: var(--paper);
  font-size: 22px;
  cursor: pointer;
}
.stepper-value {
  font-family: var(--font-display);
  font-size: 40px;
  font-weight: 700;
  min-width: 64px;
  text-align: center;
}

/* ---------- Heads Up gameplay (landscape only) ---------- */
#view-headsup-play {
  background: var(--headsup);
  flex-direction: row;
}
.hu-flash-overlay {
  position: absolute; inset: 0; z-index: 6;
  display: none; align-items: center; justify-content: center;
}
.hu-flash-overlay.active { display: flex; }
.hu-flash-overlay.flash-correct { background: var(--flash-correct); }
.hu-flash-overlay.flash-pass { background: var(--flash-pass); }
.hu-flash-label {
  font-family: var(--font-display); font-size: 40px; font-weight: 700;
  color: #fff;
}
.hu-zone {
  flex: none;
  width: 110px;
  display: flex; align-items: center; justify-content: center;
  cursor: pointer;
}
.hu-zone-pass { background: rgba(0,0,0,0.15); }
.hu-zone-correct { background: rgba(255,255,255,0.15); }
.hu-zone-label {
  font-weight: 700;
  font-size: 14px;
  color: #fff;
  writing-mode: vertical-rl;
  text-orientation: mixed;
}
.hu-zone-pass .hu-zone-label { transform: rotate(180deg); }

.hu-center {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: 16px;
  min-width: 0;
}
.hu-category { color: rgba(255,255,255,0.85); font-size: 13px; margin-bottom: 4px; }
.hu-timer {
  font-family: var(--font-mono);
  font-size: 22px;
  font-weight: 700;
  color: #fff;
  margin-bottom: 16px;
}
.hu-word {
  font-family: var(--font-display);
  font-weight: 700;
  font-size: clamp(28px, 7vw, 52px);
  color: #fff;
  text-align: center;
  margin: 0;
  word-break: break-word;
}
.hu-hint { color: rgba(255,255,255,0.8); font-size: 13px; margin-top: 16px; }

#view-headsup-rotate {
  align-items: center;
  justify-content: center;
  text-align: center;
  padding: 24px;
}
.rotate-icon { margin-bottom: 24px; }
.rotate-title { font-family: var(--font-display); font-size: 22px; font-weight: 700; }
.rotate-sub { color: var(--muted); font-size: 14px; margin-top: 8px; line-height: 1.5; }

#view-headsup-summary { padding: 24px 20px; align-items: center; text-align: center; justify-content: center; }
.summary-head { flex: none; }
.summary-eyebrow { color: var(--muted-2); font-size: 13px; }
.summary-score { font-family: var(--font-display); font-size: 72px; font-weight: 700; color: var(--headsup); margin: 8px 0; }
.summary-caption { color: var(--muted); font-size: 14px; }
.summary-skipped { color: var(--muted-2); font-size: 13px; margin-top: 2px; }
.summary-list { text-align: left; width: 100%; max-width: 320px; margin: 20px auto; max-height: 30vh; overflow-y: auto; }
.summary-row { display: flex; justify-content: space-between; padding: 8px 4px; border-bottom: 1px solid var(--line-2); font-size: 14px; }
.summary-mark { color: var(--muted-2); }
.summary-mark-correct { color: var(--headsup); }
.summary-actions { width: 100%; max-width: 280px; flex: none; }
.summary-actions .btn + .btn { margin-top: 10px; }

/* The round is played sideways, so the summary lands in landscape: split it
   into score-and-buttons beside a full-height word list rather than letting
   a portrait column squeeze the list down to a couple of visible rows. */
@media (orientation: landscape) {
  #view-headsup-summary.active {
    display: grid;
    grid-template-columns: minmax(0, 1fr) minmax(0, 1fr);
    grid-template-areas: "head list" "actions list";
    align-content: center;
    column-gap: 28px;
    padding: 16px 24px;
    overflow: hidden;
  }
  .summary-head { grid-area: head; align-self: end; }
  .summary-actions { grid-area: actions; align-self: start; max-width: none; margin-top: 16px; }
  .summary-list {
    grid-area: list;
    margin: 0;
    max-width: none;
    max-height: none;
    min-height: 0;
    align-self: stretch;
    overflow-y: auto;
  }
  .summary-score { font-size: 52px; margin: 2px 0; }
}

/* ---------- Imposter ---------- */
#view-imposter-reveal { align-items: center; justify-content: center; text-align: center; padding: 24px; }
.imp-player-count { color: var(--muted-2); font-size: 13px; letter-spacing: 0.04em; }
.imp-pass-to { font-family: var(--font-display); font-size: 30px; font-weight: 700; margin: 16px 0 4px; }
.imp-instruction { color: var(--muted-2); font-size: 14px; margin-bottom: 40px; }

.hold-btn {
  -webkit-appearance: none;
  appearance: none;
  width: 176px; height: 176px;
  margin: 0 auto;
  padding: 0;
  border-radius: 50%;
  border: 2px dashed var(--imposter);
  background: var(--imposter-glow);
  display: flex; flex-direction: column; align-items: center; justify-content: center;
  cursor: pointer;
  color: var(--paper);
  -webkit-user-select: none;
  user-select: none;
  -webkit-touch-callout: none;
  touch-action: manipulation;
}
.hold-btn.pressed {
  background: color-mix(in srgb, var(--imposter) 30%, transparent);
  border-style: solid;
}
.hold-label { font-size: 14px; font-weight: 700; }
.hold-sub { font-size: 12px; color: var(--muted); margin-top: 4px; }

.reveal-card {
  /* Covers the screen rather than replacing the pass screen, so the button
     being held stays mounted underneath and keeps its pointer capture. */
  display: none;
  position: absolute;
  inset: 0;
  z-index: 5;
  background: var(--ink);
  flex-direction: column;
  align-items: center;
  justify-content: center;
}
.reveal-card.showing { display: flex; }
.reveal-role { font-size: 13px; color: var(--imposter); letter-spacing: 0.04em; margin-bottom: 8px; }
.reveal-word { font-family: var(--font-display); font-size: 40px; font-weight: 700; }

.imp-footer { padding: 20px; }
#view-imposter-discuss { align-items: center; justify-content: center; text-align: center; padding: 24px; }
#view-imposter-result { padding: 24px 20px; align-items: center; text-align: center; }

/* ---------- Game Rules ---------- */
#view-rules { padding: 0; }
.rules-search-wrap { padding: 16px 20px 8px; }
.rules-search {
  width: 100%;
  background: var(--ink-2);
  border: 1px solid var(--line);
  border-radius: 10px;
  padding: 12px 14px;
  color: var(--paper);
  font-size: 14px;
}
.rules-search::placeholder { color: var(--muted-2); }
.rules-list { padding: 8px 20px 40px; }
.rule-item {
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  padding: 16px 0;
  border-bottom: 1px solid var(--line);
  cursor: pointer;
}
.rule-label { display: flex; align-items: center; gap: 10px; min-width: 0; }
.rule-icon { flex: none; display: block; width: 20px; height: 20px; color: var(--rules); }
.rule-icon svg { display: block; width: 100%; height: 100%; }
.rule-name { font-size: 17px; font-weight: 600; }
.rule-meta { font-size: 12px; color: var(--rules); }
.rules-empty { text-align: center; color: var(--muted-2); padding: 40px 20px; font-size: 14px; }

#view-rule-detail { padding: 0; }
.rule-detail-header { padding: 20px 20px 12px; }
.rule-detail-name {
  font-family: var(--font-display); font-size: 24px; font-weight: 700; margin: 0;
  display: flex; align-items: center; gap: 10px;
}
.rule-detail-name .rule-icon { width: 22px; height: 22px; }
.rule-detail-tags { color: var(--muted-2); font-size: 13px; margin-top: 4px; }
.rule-detail-body { padding: 0 20px 40px; }
.rule-section { margin-bottom: 22px; }
.rule-section-title {
  font-size: 12px; font-weight: 700; letter-spacing: 0.04em;
  color: var(--rules); margin-bottom: 6px;
}
.rule-section p { margin: 0 0 4px; font-size: 14px; color: var(--text-2); line-height: 1.5; }

/* ---------- Score Keeper ---------- */
#view-score-setup { padding: 16px 20px 24px; }
.player-row {
  display: flex; align-items: center; gap: 10px;
  background: var(--ink-2);
  border-radius: 12px;
  padding: 10px 12px;
  margin-bottom: 8px;
}
.player-dot { width: 10px; height: 10px; border-radius: 50%; flex: none; }
.player-row input {
  flex: 1; background: transparent; border: none; color: var(--paper);
  font-size: 15px; outline: none;
}
.player-remove { background: none; border: none; color: var(--muted-2); font-size: 18px; cursor: pointer; padding: 4px 8px; }
.add-player-btn {
  width: 100%; padding: 14px; border-radius: 12px;
  border: 1.5px dashed var(--line); background: transparent;
  color: var(--muted); font-size: 14px; cursor: pointer; margin-bottom: 20px;
}

.mode-toggle { display: flex; gap: 10px; margin-bottom: 24px; }
.mode-toggle-btn {
  flex: 1; padding: 14px; border-radius: 12px;
  border: 1.5px solid var(--line); background: transparent;
  color: var(--muted); cursor: pointer; font-size: 14px; font-weight: 600;
}
.mode-toggle-btn.selected { --toggle: var(--accent, var(--score)); border-color: var(--toggle); color: var(--paper); background: color-mix(in srgb, var(--toggle) 15%, transparent); }

#view-score-increment, #view-score-rounds { padding: 16px 0 24px; }
.score-topbar { display: flex; justify-content: space-between; align-items: center; padding: 8px 20px 12px; }
.score-mode-label { font-size: 12px; font-weight: 700; letter-spacing: 0.04em; color: var(--score); }
.link-btn { background: none; border: none; color: var(--muted-2); font-size: 13px; cursor: pointer; }

.inc-cards { padding: 0 20px; flex: 1; overflow-y: auto; }
.inc-card {
  background: var(--ink-2);
  border: 1px solid var(--line);
  border-radius: 18px;
  padding: 18px;
  margin-bottom: 14px;
}
.inc-name { display: flex; align-items: center; gap: 8px; font-weight: 600; font-size: 15px; margin-bottom: 8px; }
.inc-value-row { display: flex; align-items: center; justify-content: center; gap: 28px; }
.inc-value {
  font-family: var(--font-display); font-size: 56px; font-weight: 700;
  min-width: 90px; text-align: center;
}
.inc-btn {
  width: 52px; height: 52px; border-radius: 50%;
  background: var(--ink-3); border: none; color: var(--score);
  font-size: 26px; cursor: pointer;
}
.inc-hint { text-align: center; color: var(--faint); font-size: 12px; margin: 4px 0 16px; }

.rounds-wrap { padding: 0 20px; flex: 1; overflow: hidden; display: flex; flex-direction: column; }
.rounds-table-scroll { overflow-x: auto; flex: 1; }
.rounds-table { width: 100%; border-collapse: collapse; min-width: 100%; }
.rounds-table th, .rounds-table td {
  padding: 10px 8px; text-align: center; font-size: 14px; white-space: nowrap;
}
.rounds-table thead th {
  position: sticky; top: 0; z-index: 2;
  background: color-mix(in srgb, var(--score) 14%, var(--ink));
  border-bottom: 1.5px solid var(--score);
}
.rounds-total-label { font-size: 11px; color: var(--score); font-weight: 700; display: block; }
.rounds-total-value { font-family: var(--font-display); font-size: 20px; font-weight: 700; }
.rounds-table tbody th {
  text-align: left; color: var(--muted-2); font-weight: 400; position: sticky; left: 0;
  background: var(--ink);
}
.rounds-table tbody tr:nth-child(odd) { background: rgba(255,255,255,0.02); }
.round-cell {
  border: none; background: var(--ink-3); color: var(--paper);
  border-radius: 8px; width: 100%; padding: 8px 4px;
  font-size: 14px; text-align: center;
}
.round-row-name { display: flex; align-items: center; gap: 6px; padding: 0 4px 0 20px; }
.rounds-footer { padding: 12px 0; }

.modal-backdrop {
  position: fixed; inset: 0; background: rgba(0,0,0,0.6);
  display: none; align-items: flex-end; justify-content: center; z-index: 50;
}
.modal-backdrop.open { display: flex; }
.modal-sheet {
  background: var(--ink-2); border-radius: 20px 20px 0 0;
  padding: 20px; width: 100%; max-width: 480px;
}
.modal-title { font-family: var(--font-display); font-size: 17px; font-weight: 700; margin-bottom: 16px; text-align: center; }
.quick-add-row { display: flex; gap: 8px; margin-bottom: 16px; flex-wrap: wrap; }
.quick-add-btn {
  flex: 1; min-width: 60px; padding: 12px; border-radius: 10px;
  border: 1px solid var(--line); background: var(--ink-3);
  color: var(--paper); cursor: pointer; font-size: 14px;
}

@media (max-width: 340px) {
  .inc-value { font-size: 44px; }
}

/* ---------- Shared: settings gear, exit button, instructions ---------- */
.settings-gear-btn {
  position: absolute;
  top: calc(var(--safe-top) + 20px);
  right: 20px;
  width: 36px; height: 36px;
  border-radius: 50%;
  border: 1.5px solid var(--line);
  background: var(--ink-2);
  color: var(--muted);
  font-size: 16px;
  cursor: pointer;
}

.exit-btn {
  position: absolute;
  top: calc(var(--safe-top) + 16px);
  right: 16px;
  z-index: 10;
  background: rgba(0,0,0,0.25);
  border: 1.5px solid rgba(255,255,255,0.3);
  color: #fff;
  font-size: 13px;
  font-weight: 600;
  padding: 8px 14px;
  border-radius: 999px;
  cursor: pointer;
}
.hu-exit-btn { position: fixed; top: calc(var(--safe-top) + 12px); right: 12px; }

.hu-countdown {
  position: absolute; inset: 0; z-index: 5;
  display: none; align-items: center; justify-content: center;
  background: var(--ink);
}
.hu-countdown.active { display: flex; }
.hu-countdown-num {
  font-family: var(--font-display); font-size: 96px; font-weight: 700;
  color: var(--headsup);
}

.instructions-box {
  background: color-mix(in srgb, var(--accent) 10%, var(--ink-2));
  border: 1px solid color-mix(in srgb, var(--accent) 35%, transparent);
  border-radius: 14px;
  padding: 14px 16px;
  margin-bottom: 24px;
}
.instructions-title {
  font-size: 12px; font-weight: 700; letter-spacing: 0.04em;
  color: var(--accent); margin: 0 0 6px;
}
.instructions-box p { margin: 0; font-size: 13.5px; color: var(--text-2); line-height: 1.5; }
.instructions-box p + p { margin-top: 8px; }

/* ---------- Settings ---------- */
.settings-hint { color: var(--muted-2); font-size: 13px; line-height: 1.4; margin: 0 0 12px; }
.word-add-row { display: flex; gap: 8px; margin-bottom: 12px; }
.word-add-row input {
  flex: 1; background: var(--ink-2); border: 1px solid var(--line); border-radius: 10px;
  padding: 12px 14px; color: var(--paper); font-size: 14px;
}
.btn-small {
  border: none; border-radius: 10px; background: var(--settings); color: var(--on-accent);
  font-weight: 700; font-size: 14px; padding: 0 18px; cursor: pointer;
}
.word-chip-list { display: flex; flex-wrap: wrap; gap: 8px; margin-bottom: 16px; }
.word-chip {
  display: inline-flex; align-items: center; gap: 6px;
  background: var(--ink-2); border: 1px solid var(--line); border-radius: 999px;
  padding: 6px 6px 6px 14px; font-size: 13px; color: var(--paper);
}
.word-chip button {
  background: none; border: none; color: var(--muted-2); font-size: 16px;
  cursor: pointer; padding: 2px 6px; line-height: 1;
}
.settings-io-row { display: flex; gap: 10px; }
.settings-io-row .btn { padding: 12px; font-size: 13px; }

.toggle-row { display: flex; align-items: center; justify-content: space-between; gap: 16px; }
.toggle-row-title { font-size: 15px; font-weight: 600; margin: 0 0 2px; }
.toggle-row-sub { font-size: 12.5px; color: var(--muted-2); margin: 0; line-height: 1.4; }
.switch {
  flex: none; width: 50px; height: 30px; border-radius: 999px;
  background: var(--ink-3); border: 1.5px solid var(--line);
  position: relative; cursor: pointer; padding: 0;
}
.switch-knob {
  position: absolute; top: 2px; left: 2px;
  width: 22px; height: 22px; border-radius: 50%;
  background: var(--muted); transition: left 0.15s ease, background 0.15s ease;
}
.switch.on { border-color: var(--settings); background: color-mix(in srgb, var(--settings) 30%, var(--ink-3)); }
.switch.on .switch-knob { left: 22px; background: var(--settings); }
.switch-headsup.on { border-color: var(--headsup); background: color-mix(in srgb, var(--headsup) 30%, var(--ink-3)); }
.switch-headsup.on .switch-knob { background: var(--headsup); }

/* ---------- Fishbowl ---------- */
.fb-center { align-items: center; justify-content: center; text-align: center; padding: 24px; position: relative; }
.fb-round-label { font-size: 12px; font-weight: 700; letter-spacing: 0.04em; color: var(--fishbowl); margin-bottom: 8px; }
.fb-round-rule { color: var(--muted); font-size: 14px; max-width: 300px; margin: 0 auto 24px; line-height: 1.5; }
.fb-team-turn { font-family: var(--font-display); font-size: 28px; font-weight: 700; margin: 0 0 32px; }

#view-fishbowl-collect .setup-body { padding-top: 8px; }
.fb-collect-title { font-family: var(--font-display); font-size: 22px; font-weight: 700; text-align: center; margin: 0 0 6px; }
#fb-collect-inputs { display: flex; flex-direction: column; gap: 10px; margin-top: 16px; }
#fb-collect-inputs input {
  background: var(--ink-2); border: 1px solid var(--line); border-radius: 10px;
  padding: 14px; color: var(--paper); font-size: 15px;
}

#view-fishbowl-play .hu-word { color: var(--paper); margin: 8px 0 28px; }
#view-fishbowl-play .hu-timer { color: var(--fishbowl); margin-bottom: 4px; }
.fb-action-row { display: flex; gap: 10px; width: 100%; max-width: 320px; margin-bottom: 12px; }
.fb-action-row .btn { flex: 1; }
.fb-broke-btn { border-color: var(--fishbowl); color: var(--fishbowl); }
.fb-correct-btn { max-width: 320px; }

.fb-penalty-overlay {
  display: none;
  position: absolute; inset: 0;
  background: var(--ink);
  flex-direction: column; align-items: center; justify-content: center;
  z-index: 20;
}
.fb-penalty-overlay.active { display: flex; }
.fb-penalty-title { font-family: var(--font-display); font-size: 22px; font-weight: 700; color: var(--fishbowl); margin: 0 0 12px; }
.fb-penalty-count { font-family: var(--font-display); font-size: 64px; font-weight: 700; color: var(--fishbowl); }
.fb-penalty-sub { color: var(--muted); font-size: 13px; margin-top: 8px; }

.fb-score-list { width: 100%; max-width: 320px; margin: 16px auto 28px; }
.fb-score-row {
  display: flex; justify-content: space-between; align-items: center;
  background: var(--ink-2); border: 1px solid var(--line); border-radius: 12px;
  padding: 14px 16px; margin-bottom: 8px; font-size: 15px;
}
.fb-score-row.leader { border-color: var(--fishbowl); }
.fb-score-name { font-weight: 600; }
.fb-score-value { font-family: var(--font-display); font-size: 20px; font-weight: 700; color: var(--fishbowl); }

/* ---------- Dice ---------- */
#view-dice { padding: 0; }

.dice-tray-wrap {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: 8px 20px;
  min-height: 0;
  overflow-y: auto;
}
/* Three columns keeps a die comfortably tappable on the narrowest phone while
   letting a table of six land as two even rows. auto-fit collapses the unused
   tracks, so one or two dice grow to fill instead of hugging the left edge. */
.dice-tray {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(88px, 1fr));
  gap: 14px 12px;
  width: 100%;
  max-width: 300px;
}
/* A lone die gets the whole stage rather than a third of it. */
.dice-tray:has(.die-cell:only-child) { grid-template-columns: minmax(0, 190px); justify-content: center; }

.die-cell { display: flex; flex-direction: column; gap: 4px; min-width: 0; }

/* The name and the × ride above the die. In the corners of the face they sat
   on top of a d6's corner pips, which made both harder to read. */
.die-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 4px;
  padding-left: 2px;
  min-width: 0;
}
.die-label {
  font-size: 11px;
  font-weight: 700;
  letter-spacing: 0.04em;
  color: var(--dice);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
/* A hit area wider than the glyph, pulled tight against the edge so it does
   not steal room from the label beside it. */
.die-remove {
  flex: none;
  width: 34px; height: 34px;
  margin: -8px -8px -8px 0;
  padding: 0;
  border: none;
  background: none;
  color: var(--muted-2);
  font-size: 17px;
  line-height: 1;
  cursor: pointer;
}
.die-remove:active { color: var(--paper); }

.die {
  position: relative;
  aspect-ratio: 1;
  border-radius: 16px;
  border: 1.5px solid var(--line);
  background: var(--ink-2);
  color: var(--paper);
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
}
.die:active { border-color: var(--dice); }

.die-face {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 100%;
  height: 100%;
  padding: 14%;
}
.die-pips {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  grid-template-rows: repeat(3, 1fr);
  gap: 8%;
  width: 100%;
  height: 100%;
}
.pip { border-radius: 50%; }
.pip.on { background: var(--paper); }

.die-num {
  font-family: var(--font-display);
  font-size: clamp(26px, 8vw, 46px);
  font-weight: 700;
  line-height: 1;
}
/* d100 and friends: three digits at the full size would overflow the face. */
.die-num-long { font-size: clamp(20px, 6vw, 34px); }
.die-word {
  font-family: var(--font-display);
  font-size: clamp(13px, 4vw, 19px);
  font-weight: 700;
  line-height: 1.1;
  text-align: center;
}

/* Decoration over a value that is already settled — the roll never waits on
   this, so it can be swapped or dropped with nothing else to change. */
@keyframes die-roll {
  0%   { transform: rotate(0deg) scale(1); }
  35%  { transform: rotate(-14deg) scale(1.1); }
  70%  { transform: rotate(10deg) scale(1.04); }
  100% { transform: rotate(0deg) scale(1); }
}
.die.rolling { animation: die-roll 380ms ease-out; }

@keyframes die-settle {
  0%   { opacity: 0.3; border-color: var(--dice); }
  60%  { opacity: 1; border-color: var(--dice); }
  100% { opacity: 1; border-color: var(--line); }
}
@media (prefers-reduced-motion: reduce) {
  .die.rolling { animation: die-settle 200ms ease-out; }
}

.dice-summary {
  font-size: 14px;
  color: var(--muted);
  margin: 20px 0 0;
  min-height: 18px;
}
.dice-hint { color: var(--faint); font-size: 12px; margin: 6px 0 0; }

/* Both actions get the same 72px target. Rolling everything is the thing
   you do most often after tapping individual dice, and it was fiddly as a
   text link under a button four times its size. */
.dice-footer {
  flex: none;
  display: flex;
  align-items: stretch;
  gap: 12px;
  padding: 8px 20px calc(24px + var(--safe-bottom));
}
.dice-big-btn {
  height: 72px;
  border-radius: 20px;
  border: none;
  font-weight: 700;
  line-height: 1;
  cursor: pointer;
  padding: 0;
}
.dice-big-btn:disabled { opacity: 0.4; }

.dice-roll-all {
  flex: 1;
  background: color-mix(in srgb, var(--dice) 16%, var(--ink-2));
  border: 1.5px solid color-mix(in srgb, var(--dice) 55%, transparent);
  color: var(--paper);
  font-size: 17px;
}
.dice-add {
  flex: none;
  width: 72px;
  background: var(--dice);
  color: var(--on-accent);
  font-size: 36px;
  padding-bottom: 4px;
}

.dice-custom-row { display: flex; gap: 8px; margin-bottom: 8px; }
.dice-custom-row input {
  flex: 1; min-width: 0;
  background: var(--ink-3);
  border: 1px solid var(--line);
  border-radius: 10px;
  padding: 12px;
  color: var(--paper);
  font-size: 15px;
}
.dice-custom-row input::placeholder { color: var(--muted-2); }
.dice-custom-error {
  color: var(--fishbowl);
  font-size: 12.5px;
  margin: 0 0 12px;
  min-height: 16px;
  text-align: center;
}

/* ---------- Print ---------- */
@media print {
  :root {
    --ink: #FFFFFF;
    --ink-2: #FFFFFF;
    --ink-3: #FFFFFF;
    --line: #CCCCCC;
    --line-2: #DDDDDD;
    --paper: #000000;
    --muted: #444444;
    --muted-2: #555555;
    --text-2: #111111;
    --rules: #2F6B45;
    color-scheme: light;
  }
  html, body { height: auto; background: #FFFFFF; color: #000000; }
  /* The app is a fixed, clipped viewport on screen; let it flow onto pages. */
  #app, .view { position: static; overflow: visible; padding: 0; }
  .topbar, .back-btn, .exit-btn { display: none !important; }
  .rule-detail-header { padding: 0 0 12px; }
  .rule-detail-body { padding: 0; }
  .rule-section { break-inside: avoid; }
  .rule-section p { font-size: 11pt; }
}
