/* Buttons ------------------------------------------------------------------ */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  min-height: var(--tap); padding: 12px 18px;
  border-radius: var(--radius);
  background: var(--surface-2);
  color: var(--text);
  font-weight: 600;
  border: 1px solid var(--line);
  transition: transform var(--dur) var(--ease), background var(--dur) var(--ease),
    border-color var(--dur) var(--ease);
  user-select: none; -webkit-tap-highlight-color: transparent;
}
.btn:active { transform: scale(0.97); }
.btn:disabled { opacity: 0.45; pointer-events: none; }
.btn--primary { background: var(--accent); color: var(--accent-ink); border-color: transparent; }
.btn--ghost { background: transparent; border-color: transparent; }
.btn--outline { background: transparent; }
.btn--danger { color: var(--danger); }
.btn--block { width: 100%; }
.btn--lg { min-height: 60px; font-size: var(--fs-lg); }
.btn--icon { min-width: var(--tap); padding: 10px; border-radius: var(--radius); }
.btn--pill { border-radius: var(--radius-pill); }

.icon { width: 22px; height: 22px; display: inline-block; flex: none; }
.icon--lg { width: 28px; height: 28px; }

/* Cards -------------------------------------------------------------------- */
.card {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius-lg);
  padding: var(--sp-4);
  box-shadow: var(--shadow-1);
}
.card--tap { transition: transform var(--dur) var(--ease), border-color var(--dur) var(--ease); }
.card--tap:active { transform: scale(0.985); border-color: var(--line-strong); }

/* Home tiles */
.tiles { display: grid; grid-template-columns: 1fr 1fr; gap: var(--sp-3); }
.tile {
  display: flex; flex-direction: column; gap: 8px;
  min-height: 104px; padding: var(--sp-4);
  border-radius: var(--radius-lg);
  background: var(--surface); border: 1px solid var(--line);
  text-align: left;
}
.tile__icon { width: 30px; height: 30px; color: var(--accent); }
.tile__label { font-weight: 700; font-size: var(--fs-lg); letter-spacing: -0.01em; }
.tile__sub { font-size: var(--fs-sm); color: var(--text-muted); }
.tile--primary { background: linear-gradient(150deg, var(--accent), color-mix(in srgb, var(--accent) 62%, #c07f10));
  color: var(--accent-ink); border-color: transparent; grid-column: 1 / -1; min-height: 96px; }
.tile--primary .tile__icon, .tile--primary .tile__sub { color: inherit; opacity: 0.92; }

/* Chips / colour dots ------------------------------------------------------ */
.chip {
  display: inline-flex; align-items: center; gap: 6px;
  padding: 6px 12px; border-radius: var(--radius-pill);
  background: var(--surface-2); border: 1px solid var(--line);
  font-size: var(--fs-sm); font-weight: 600;
}
.chip--active { background: var(--accent); color: var(--accent-ink); border-color: transparent; }
.dot { width: 14px; height: 14px; border-radius: 50%; flex: none; box-shadow: inset 0 0 0 2px rgba(0,0,0,.15); }
.dot--lg { width: 22px; height: 22px; }

/* List rows ---------------------------------------------------------------- */
.list { display: flex; flex-direction: column; gap: var(--sp-2); }
.list-row {
  display: flex; align-items: center; gap: var(--sp-3);
  padding: var(--sp-3) var(--sp-4);
  background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius);
}
.list-row__main { flex: 1; min-width: 0; }
.list-row__title { font-weight: 600; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.list-row__sub { font-size: var(--fs-sm); color: var(--text-muted); }

/* Empty state -------------------------------------------------------------- */
.empty {
  text-align: center; color: var(--text-muted);
  padding: var(--sp-6) var(--sp-4);
  border: 1px dashed var(--line-strong); border-radius: var(--radius-lg);
}
.empty__title { color: var(--text); font-weight: 700; margin-bottom: 4px; }

/* Form fields -------------------------------------------------------------- */
.field { display: flex; flex-direction: column; gap: 6px; }
.field > label { font-size: var(--fs-sm); font-weight: 600; color: var(--text-muted); }
.input, .select {
  min-height: var(--tap); width: 100%;
  padding: 12px 14px; border-radius: var(--radius);
  background: var(--surface-2); color: var(--text);
  border: 1px solid var(--line);
}
.input:focus, .select:focus { border-color: var(--accent); outline: none; }
.switch {
  position: relative; width: 52px; height: 30px; flex: none;
  background: var(--surface-3); border-radius: var(--radius-pill);
  border: 1px solid var(--line); transition: background var(--dur) var(--ease);
}
.switch[aria-checked="true"] { background: var(--accent); border-color: transparent; }
.switch::after {
  content: ""; position: absolute; top: 2px; left: 2px; width: 24px; height: 24px;
  border-radius: 50%; background: #fff; box-shadow: var(--shadow-1);
  transition: transform var(--dur) var(--ease);
}
.switch[aria-checked="true"]::after { transform: translateX(22px); }

/* Stepper (wizard) --------------------------------------------------------- */
.stepper { display: flex; gap: 6px; margin-bottom: var(--sp-4); }
.stepper__seg { flex: 1; height: 5px; border-radius: 3px; background: var(--surface-3); }
.stepper__seg--done { background: var(--accent); }

/* Segmented control -------------------------------------------------------- */
.segmented { display: inline-flex; background: var(--surface-2); border: 1px solid var(--line);
  border-radius: var(--radius-pill); padding: 3px; }
.segmented button { padding: 8px 14px; border-radius: var(--radius-pill); font-weight: 600; color: var(--text-muted); }
.segmented button[aria-pressed="true"] { background: var(--accent); color: var(--accent-ink); }

/* Dialog / sheet ----------------------------------------------------------- */
.scrim {
  position: fixed; inset: 0; z-index: 60; background: var(--overlay);
  display: grid; place-items: end center; animation: fade var(--dur) var(--ease);
}
@keyframes fade { from { opacity: 0; } to { opacity: 1; } }
.dialog {
  width: 100%; max-width: var(--content-max);
  background: var(--surface); border: 1px solid var(--line);
  border-radius: var(--radius-lg) var(--radius-lg) 0 0;
  padding: var(--sp-5) var(--sp-4) calc(var(--sp-5) + env(safe-area-inset-bottom));
  box-shadow: var(--shadow-2);
  animation: sheet-up 260ms var(--ease);
  max-height: 88vh; overflow: auto;
}
@media (min-width: 640px) {
  .scrim { place-items: center; }
  .dialog { border-radius: var(--radius-lg); margin: var(--sp-4); }
}
@keyframes sheet-up { from { transform: translateY(24px); opacity: 0.6; } to { transform: none; opacity: 1; } }
.dialog__title { font-size: var(--fs-lg); font-weight: 800; margin-bottom: var(--sp-3); letter-spacing: -0.02em; }
.dialog__actions { display: flex; gap: var(--sp-2); justify-content: flex-end; margin-top: var(--sp-5); }

/* Toast -------------------------------------------------------------------- */
#toast-root {
  position: fixed; left: 0; right: 0; bottom: calc(16px + env(safe-area-inset-bottom));
  z-index: 80; display: flex; flex-direction: column; align-items: center; gap: 8px;
  pointer-events: none;
}
.toast {
  background: var(--surface-3); color: var(--text);
  border: 1px solid var(--line-strong); border-radius: var(--radius-pill);
  padding: 10px 18px; box-shadow: var(--shadow-2); font-weight: 600; font-size: var(--fs-sm);
  animation: toast-in var(--dur) var(--ease); max-width: 90vw;
}
.toast--win { border-color: var(--win); color: var(--win); }
@keyframes toast-in { from { transform: translateY(10px); opacity: 0; } to { transform: none; opacity: 1; } }

/* ===== Score screen ======================================================= */
.scorebar {
  display: flex; align-items: center; gap: var(--sp-2);
  padding: var(--sp-2) var(--sp-3); background: var(--surface); border: 1px solid var(--line);
  border-radius: var(--radius); margin-bottom: var(--sp-3);
}
.scorebar .grow { text-align: center; font-weight: 700; }

/* Leaderboard of players with running totals */
.leaderboard { display: flex; flex-direction: column; gap: var(--sp-2); }
.player-row {
  display: grid; grid-template-columns: auto 1fr auto; align-items: center; gap: var(--sp-3);
  padding: var(--sp-3) var(--sp-4);
  background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius);
  border-left: 5px solid var(--pc, var(--accent));
  transition: transform var(--dur) var(--ease);
}
.player-row--leader {
  background: color-mix(in srgb, var(--win) 14%, var(--surface));
  box-shadow: inset 0 0 0 2px var(--win);
}
.player-row__name { font-weight: 700; display: flex; align-items: center; gap: 6px; min-width: 0; }
.player-row__meta { font-size: var(--fs-xs); color: var(--text-muted); }
.player-row__total {
  font-family: var(--font-score); font-variant-numeric: tabular-nums;
  font-size: var(--fs-xl); font-weight: 800;
  color: #10161A;                       /* dark ink stays readable on any bright player colour */
  background: var(--pc, var(--accent));
  padding: 4px 12px; border-radius: 10px; min-width: 58px; text-align: center;
}
.player-row--leader .player-row__total { box-shadow: 0 0 0 2px var(--win), 0 0 12px color-mix(in srgb, var(--win) 55%, transparent); }
.crown { color: var(--win); width: 18px; height: 18px; flex: none; }

.tick { animation: tick 420ms var(--ease); }
@keyframes tick { 0% { transform: scale(1); } 30% { transform: scale(1.06); } 100% { transform: scale(1); } }

/* Round entry grid */
.round-entry { display: flex; flex-direction: column; gap: var(--sp-3); }
.entry-row { display: grid; grid-template-columns: 1fr auto; align-items: center; gap: var(--sp-3); }
.stepper-input { display: inline-flex; align-items: center; gap: 8px; }
.stepper-input button {
  width: 46px; height: 46px; border-radius: var(--radius);
  background: var(--surface-2); border: 1px solid var(--line); font-size: var(--fs-lg); font-weight: 700;
}
.stepper-input input {
  width: 84px; height: 46px; text-align: center; border-radius: var(--radius);
  background: var(--surface-2); border: 1px solid var(--line);
  font-family: var(--font-score); font-size: var(--fs-lg); font-variant-numeric: tabular-nums;
}

/* Bottom action bar on the score screen */
.actionbar {
  position: sticky; bottom: 0; z-index: 15;
  display: flex; gap: var(--sp-2);
  padding: var(--sp-3) 0 calc(var(--sp-2) + env(safe-area-inset-bottom));
  background: linear-gradient(to top, var(--bg) 70%, transparent);
}

/* History rows */
.history-table { width: 100%; border-collapse: collapse; font-size: var(--fs-sm); }
.history-table th, .history-table td {
  padding: 8px 10px; text-align: right; border-bottom: 1px solid var(--line);
  font-family: var(--font-score); font-variant-numeric: tabular-nums;
}
.history-table th:first-child, .history-table td:first-child { text-align: left; font-family: var(--font-sans); }
.history-table thead th { color: var(--text-muted); font-weight: 700; position: sticky; top: 0; background: var(--surface); }

/* Charts (canvas) ---------------------------------------------------------- */
.chart-wrap { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius-lg); padding: var(--sp-4); }
canvas { display: block; width: 100%; }

/* Winner banner */
.winner-banner {
  text-align: center; padding: var(--sp-5); border-radius: var(--radius-lg);
  background: linear-gradient(150deg, color-mix(in srgb, var(--win) 22%, var(--surface)), var(--surface));
  border: 1px solid var(--win); margin-bottom: var(--sp-4);
}
.winner-banner h2 { font-size: var(--fs-2xl); letter-spacing: -0.02em; }

/* Game grid (wizard step 1) */
.game-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(104px, 1fr)); gap: var(--sp-2); }
.game-card {
  display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 6px;
  min-height: 92px; padding: var(--sp-3) var(--sp-2);
  background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); text-align: center;
  cursor: pointer;
}
.game-card[aria-pressed="true"] { border-color: var(--accent); background: color-mix(in srgb, var(--accent) 16%, var(--surface)); box-shadow: inset 0 0 0 1px var(--accent); }
.game-card__glyph { font-size: 26px; }
.game-card__name { font-weight: 700; font-size: var(--fs-sm); line-height: 1.15; }
.game-card__meta { font-size: var(--fs-xs); color: var(--text-muted); }

/* FAB spacing helper */
.spacer { height: var(--sp-6); }

/* Print — used for the PDF score sheet export */
@media print {
  .appbar, .actionbar, .btn, #toast-root, #boot { display: none !important; }
  body { background: #fff; color: #000; }
  .card, .player-row, .history-table th, .history-table td { border-color: #999 !important; }
}

.avatar {
  display: inline-grid;
  place-items: center;
  border-radius: 50%;
  background: var(--pc, var(--accent));
  color: #10161A;
  font-weight: 800;
  flex: none;
}

.bid-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 10px 0;
  border-top: 1px solid var(--line);
}
.bid-row:first-of-type { border-top: 0; }
.bid-row__controls { display: flex; gap: 14px; }
.bid-field { display: flex; flex-direction: column; gap: 4px; align-items: center; }
.bid-field__label {
  font-size: var(--fs-xs);
  color: var(--text-faint);
  text-transform: uppercase;
  letter-spacing: 0.06em;
}

.team-swatch {
  width: 30px; height: 30px; border-radius: 8px;
  flex: none; box-shadow: inset 0 0 0 2px rgba(255,255,255,0.12);
}
.member-chip {
  display: inline-flex; align-items: center; gap: 4px;
  margin-right: 8px; white-space: nowrap;
}
.member-chip:not(:last-child)::after { content: ''; }
.team-chip { --pc: var(--accent); border-color: var(--pc); color: var(--pc); font-weight: 700; }

.app-footer { text-align: center; padding: 24px 0 8px; font-size: var(--fs-xs); }

.rules__title {
  font-weight: 800;
  font-size: var(--fs-sm);
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--accent);
  margin: 16px 0 6px;
}
.rules__text { margin: 0; color: var(--text); }
.rules__list { margin: 4px 0 0; padding-left: 18px; color: var(--text); }
.rules__list li { margin: 3px 0; }
.rules-link { color: var(--accent); }

.rules__table {
  width: 100%;
  border-collapse: collapse;
  margin: 6px 0 0;
  font-size: var(--fs-sm);
}
.rules__table tr { border-bottom: 1px solid var(--line); }
.rules__table tr:last-child { border-bottom: none; }
.rules__table td { padding: 8px 4px; vertical-align: top; }
.rules__table-label { color: var(--text); }
.rules__table-points {
  text-align: right;
  font-family: var(--font-score);
  font-variant-numeric: tabular-nums;
  font-weight: 800;
  color: var(--accent);
  white-space: nowrap;
  padding-left: 12px;
}

/* Yahtzee category entry */
.entry-help {
  background: var(--surface-2);
  border: 1px solid var(--line);
  border-radius: 10px;
  padding: 8px 12px;
  margin: 4px 0 12px;
  font-size: var(--fs-sm);
  color: var(--text-muted);
}
.cat-entry {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 10px 0;
  border-top: 1px solid var(--line);
}
.cat-entry:first-of-type { border-top: 0; }
.cat-entry__control { display: flex; align-items: center; gap: 10px; }
.cat-entry__eq { display: inline-flex; align-items: center; gap: 6px; }
.entry-value {
  min-width: 34px;
  text-align: right;
  font-variant-numeric: tabular-nums;
  font-weight: 800;
  font-size: var(--fs-lg);
  color: var(--accent);
}
.pick-chips { display: inline-flex; gap: 4px; flex-wrap: wrap; }
.pick-chip {
  width: 34px; height: 40px;
  border: 1px solid var(--line-strong);
  background: var(--surface);
  color: var(--text);
  border-radius: 9px;
  font-weight: 700;
  font-size: var(--fs-md);
  cursor: pointer;
}
.pick-chip[aria-pressed="true"] {
  background: var(--accent);
  border-color: var(--accent);
  color: #10161A;
}
.pick-fixed { padding: 8px 12px; }
.pick-fixed[aria-pressed="true"] {
  background: var(--accent);
  border-color: var(--accent);
  color: #10161A;
}

/* Illustrations in rules examples */
.illus-row {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
  align-items: flex-end;
  margin: 8px 0 4px;
}
.illus-row svg { filter: drop-shadow(0 2px 4px rgba(0,0,0,0.35)); }
.rules__example {
  background: var(--surface-2);
  border: 1px solid var(--line);
  border-left: 3px solid var(--accent);
  border-radius: 10px;
  padding: 10px 14px;
  margin: 14px 0;
}
.rules__example .rules__title { margin-top: 0; }

/* Help bar above score entry */
.help-bar {
  display: flex;
  align-items: center;
  gap: 10px;
  margin-bottom: 12px;
}
.help-bar .entry-help { margin: 0; }
.help-bar__btn {
  flex: none;
  color: var(--accent);
  border: 1px solid var(--line-strong);
  padding: 8px 12px;
  white-space: nowrap;
}

.btn--sm { padding: 6px 10px; font-size: var(--fs-sm); }
.options-toggle { color: var(--text-muted); border: 1px dashed var(--line-strong); }
.options-toggle[aria-expanded="true"] { color: var(--text); }

/* Big tappable score chips (number entry) */
.score-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 8px 0;
  border-top: 1px solid var(--line);
}
.score-row:first-of-type { border-top: 0; }
.score-chip {
  display: inline-flex; align-items: center; gap: 10px;
  min-width: 104px;
  height: 56px;
  padding: 0 16px;
  border-radius: 14px;
  border: 2px solid var(--pc, var(--line-strong));
  background: color-mix(in srgb, var(--pc, var(--surface-2)) 9%, var(--surface-2));
  color: var(--text);
  cursor: pointer;
}
.score-chip__pen { color: var(--pc, var(--accent)); display: inline-flex; flex: none; }
.score-chip__pen svg { width: 18px; height: 18px; }
.score-chip__value { margin-left: auto; font-size: 26px; font-weight: 800; font-variant-numeric: tabular-nums; }
.score-chip:active { transform: scale(0.97); }

/* Keypad sheet */
.keypad { padding-bottom: max(16px, env(safe-area-inset-bottom)); }
.keypad__top { margin-bottom: 6px; }
.keypad__who { display: flex; align-items: center; gap: 10px; }
.keypad__name { font-weight: 800; font-size: var(--fs-lg); }
.keypad__value {
  font-size: 56px;
  font-weight: 800;
  font-variant-numeric: tabular-nums;
  letter-spacing: 0.02em;
  padding: 4px 2px 10px;
  line-height: 1;
}
.keypad__progress { font-size: var(--fs-sm); padding-bottom: 12px; }
.keypad__grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 10px;
}
.keypad__key {
  height: 64px;
  border-radius: 14px;
  border: 1px solid var(--line);
  background: var(--surface-2);
  color: var(--text);
  font-size: 28px;
  font-weight: 700;
  cursor: pointer;
  display: grid;
  place-items: center;
}
.keypad__key:active { background: var(--surface-3, var(--surface)); transform: scale(0.97); }
.keypad__key--fn { color: var(--accent); font-size: 24px; }
.keypad__key svg { width: 26px; height: 26px; }
.keypad__clear { flex: none; height: 56px; padding: 0 20px; }
.keypad__action { flex: 1; height: 56px; }


/* Home hero: one-tap replay */
.hero-start {
  width: 100%;
  text-align: left;
  border: 0;
  cursor: pointer;
  border-radius: 18px;
  padding: 16px 18px;
  margin-bottom: 12px;
  color: #10161A;
  background: linear-gradient(135deg, var(--accent), color-mix(in srgb, var(--accent) 70%, #F6C560));
}
.hero-start__eyebrow { font-size: var(--fs-xs); font-weight: 800; text-transform: uppercase; letter-spacing: 0.08em; opacity: 0.75; }
.hero-start__row { display: flex; align-items: center; gap: 14px; margin-top: 6px; }
.hero-start__glyph { font-size: 34px; line-height: 1; }
.hero-start__title { font-size: var(--fs-xl); font-weight: 800; }
.hero-start__players { display: flex; gap: 4px; margin-top: 6px; }
.hero-start__play { display: grid; place-items: center; width: 44px; height: 44px; border-radius: 50%; background: rgba(16,22,26,0.16); }
.hero-start__play svg { width: 24px; height: 24px; }
.hero-start:active { transform: scale(0.99); }

.btn--xl { height: 64px; font-size: var(--fs-lg); font-weight: 800; border-radius: 16px; }
.btn--xl svg { width: 24px; height: 24px; }

.home-links { display: flex; gap: var(--sp-2); margin-top: var(--sp-4); }
.home-link { flex: 1; color: var(--text); border: 1px solid var(--line); }
.home-link svg { width: 20px; height: 20px; color: var(--accent); }

/* Series ("match of N games") */
.series-bar {
  width: 100%;
  display: flex;
  align-items: center;
  gap: 10px;
  text-align: left;
  cursor: pointer;
  margin-bottom: 12px;
  padding: 12px 16px;
  border-radius: var(--radius);
  border: 1px solid var(--accent);
  background: color-mix(in srgb, var(--accent) 12%, var(--surface));
  color: var(--text);
}
.series-bar__label { font-weight: 800; }
.series-bar__sub { color: var(--text-muted); font-size: var(--fs-sm); }
.series-bar__link { margin-left: auto; color: var(--accent); font-weight: 700; font-size: var(--fs-sm); display: inline-flex; align-items: center; gap: 4px; white-space: nowrap; }
.series-bar__link svg { width: 18px; height: 18px; }
.series-count { min-width: 40px; text-align: center; font-size: var(--fs-xl); font-weight: 800; font-variant-numeric: tabular-nums; }
.series-stepper button { min-width: 44px; }

/* Table tools: big responsive dice & coin */
.dice-stage {
  display: flex; flex-wrap: nowrap; align-items: center; justify-content: center;
  gap: 8px;
  min-height: 96px;
  margin: 4px 0 10px;
}
/* Dice share one row: each die takes an equal slice of the width, capped at
   ~2.5x the old size. One or two dice come out big; six shrink to fit. */
.tool-die {
  flex: 1 1 0;
  min-width: 0;
  max-width: 168px;
  height: auto;
  aspect-ratio: 1 / 1;
  filter: drop-shadow(0 4px 8px rgba(0,0,0,0.4));
}
.dice-stage.is-rolling .tool-die { animation: die-shake 0.22s linear infinite; }
@keyframes die-shake {
  0% { transform: translateY(0) rotate(0deg); }
  25% { transform: translateY(-6px) rotate(-8deg); }
  75% { transform: translateY(4px) rotate(8deg); }
  100% { transform: translateY(0) rotate(0deg); }
}
.coin-stage { display: flex; justify-content: center; margin: 6px 0 10px; }
.tool-coin {
  width: clamp(130px, 42vw, 180px);
  height: clamp(130px, 42vw, 180px);
  filter: drop-shadow(0 6px 12px rgba(0,0,0,0.45));
}
.tool-coin-img {
  width: clamp(130px, 42vw, 180px);
  height: clamp(130px, 42vw, 180px);
  border-radius: 50%;
  object-fit: cover;
  filter: drop-shadow(0 6px 12px rgba(0,0,0,0.45));
}
.tool-coin-img.is-spinning { animation: coin-flip 0.14s linear infinite; }
.tool-coin.is-spinning { animation: coin-flip 0.14s linear infinite; }
@keyframes coin-flip { 0% { transform: scaleX(1); } 50% { transform: scaleX(0.08); } 100% { transform: scaleX(1); } }
.tool-sum { font-size: var(--fs-xl); font-weight: 800; margin-bottom: 4px; }
.tool-controls { display: flex; flex-direction: column; gap: 12px; margin-top: 8px; }
.swatch-row { display: flex; flex-wrap: wrap; gap: 10px; justify-content: center; }
.swatch {
  width: 40px; height: 40px; border-radius: 50%;
  border: 2px solid var(--line-strong); cursor: pointer; flex: none;
  box-shadow: inset 0 0 0 2px rgba(255,255,255,0.15);
}
.swatch[aria-pressed="true"] { border-color: var(--accent); box-shadow: 0 0 0 3px color-mix(in srgb, var(--accent) 55%, transparent); }
@media (prefers-reduced-motion: reduce) {
  .dice-stage.is-rolling .tool-die, .tool-coin.is-spinning { animation: none; }
}

/* --- Floating FAB (Quick Tools) ------------------------------------------- */
#fab-root {
  position: fixed;
  bottom: calc(1rem + env(safe-area-inset-bottom));
  right: calc(1rem + env(safe-area-inset-right));
  z-index: 999;
  display: flex;
  flex-direction: column-reverse;
  align-items: flex-end;
  gap: 12px;
  pointer-events: none;
}
#fab-root > * { pointer-events: auto; }

.fab {
  width: 60px;
  height: 60px;
  border-radius: 50%;
  background: var(--accent);
  color: #fff;
  border: none;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 30px;
  box-shadow: 0 6px 20px rgba(0, 0, 0, 0.5), inset 0 -2px 4px rgba(0, 0, 0, 0.1);
  transition: box-shadow 0.2s, transform 0.2s;
}
.fab:hover { box-shadow: 0 10px 28px rgba(0, 0, 0, 0.6), inset 0 -2px 4px rgba(0, 0, 0, 0.1); transform: scale(1.08); }
.fab:active { transform: scale(0.95); }
@media (prefers-reduced-motion: reduce) {
  .fab { transition: none; }
}

.fab-panel {
  display: flex;
  flex-direction: column;
  gap: 28px;
  background: var(--surface);
  border: 2px solid var(--line);
  border-radius: 16px;
  padding: 32px;
  min-width: 400px;
  max-width: calc(100vw - 2rem);
  max-height: calc(100vh - 8rem - env(safe-area-inset-bottom) - env(safe-area-inset-top));
  overflow-y: auto;
  box-shadow: 0 12px 32px rgba(0, 0, 0, 0.4);
  animation: slideUp 0.2s ease-out;
}
@keyframes slideUp {
  from {
    opacity: 0;
    transform: translateY(20px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}
@media (prefers-reduced-motion: reduce) {
  .fab-panel { animation: none; }
}

/* Mobile: reposition FAB to avoid notches */
@media (max-width: 640px) {
  #fab-root {
    bottom: calc(0.75rem + env(safe-area-inset-bottom));
    right: calc(0.75rem + env(safe-area-inset-right));
  }
  .fab {
    width: 56px;
    height: 56px;
    font-size: 28px;
  }
  .fab-panel {
    min-width: calc(100vw - 2rem);
    max-width: calc(100vw - 2rem);
    padding: 24px;
    gap: 20px;
  }
}

/* FAB Section (Dice or Coin) */
.fab-section {
  display: flex;
  flex-direction: column;
  gap: 12px;
}
.fab-section__title {
  font-size: 14px;
  font-weight: 700;
  color: var(--text);
  margin: 0;
  text-transform: uppercase;
  letter-spacing: 0.5px;
}

/* Dice Stage */
.fab-dice-stage {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  justify-content: center;
  align-items: center;
  min-height: 100px;
  padding: 12px;
  border: 2px solid var(--line);
  border-radius: 12px;
  background: var(--surface-2);
}
.fab-die {
  width: 64px;
  height: 64px;
  flex: 0 0 auto;
}
.fab-dice-stage.is-rolling .fab-die {
  animation: rollDice 0.055s infinite;
}
@keyframes rollDice {
  0%, 100% { transform: rotateX(0deg) rotateY(0deg); }
  50% { transform: rotateX(20deg) rotateY(20deg); }
}

/* Coin Stage */
.fab-coin-stage {
  display: flex;
  justify-content: center;
  align-items: center;
  min-height: 120px;
  padding: 12px;
  border: 2px solid var(--line);
  border-radius: 12px;
  background: var(--surface-2);
}
.fab-coin-img, .fab-coin {
  width: 100px;
  height: 100px;
  flex: 0 0 auto;
}
.fab-coin-stage.is-spinning .fab-coin-img,
.fab-coin-stage.is-spinning .fab-coin {
  animation: flipCoin 0.07s infinite;
}
@keyframes flipCoin {
  0%, 100% { transform: rotateY(0deg); }
  50% { transform: rotateY(90deg); }
}

/* Results & Controls */
.fab-result {
  font-size: 48px;
  font-weight: 900;
  text-align: center;
  color: var(--accent);
  min-height: 56px;
  line-height: 1;
  text-shadow: 0 2px 4px rgba(0, 0, 0, 0.2);
}

.fab-controls {
  display: flex;
  gap: 8px;
  justify-content: center;
  align-items: center;
}
.fab-btn {
  width: 36px;
  height: 36px;
  border-radius: 50%;
  background: var(--surface-2);
  border: 1px solid var(--line);
  color: var(--text);
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 18px;
  transition: background-color 0.15s, border-color 0.15s;
}
.fab-btn:hover { background: color-mix(in srgb, var(--accent) 15%, var(--surface-2)); border-color: var(--accent); }
.fab-btn:active { transform: scale(0.9); }
@media (prefers-reduced-motion: reduce) {
  .fab-btn { transition: none; }
}

.fab-coin-picker {
  display: flex;
  gap: 6px;
  justify-content: center;
  flex-wrap: wrap;
}
.fab-coin-btn {
  padding: 6px 12px;
  border: 1px solid var(--line);
  background: var(--surface-2);
  color: var(--text);
  border-radius: 6px;
  font-size: 12px;
  cursor: pointer;
  transition: all 0.15s;
}
.fab-coin-btn[aria-pressed="true"] {
  background: var(--accent);
  color: #fff;
  border-color: var(--accent);
}
.fab-coin-btn:hover:not([aria-pressed="true"]) {
  border-color: var(--accent);
  background: color-mix(in srgb, var(--accent) 12%, var(--surface-2));
}
@media (prefers-reduced-motion: reduce) {
  .fab-coin-btn { transition: none; }
}

/* Action Buttons */
.fab-action {
  padding: 16px 20px;
  background: var(--accent);
  color: #fff;
  border: none;
  border-radius: 8px;
  font-size: 16px;
  font-weight: 700;
  cursor: pointer;
  transition: all 0.2s;
  text-transform: uppercase;
  letter-spacing: 0.5px;
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.2);
  width: 100%;
}
.fab-action:hover { 
  background: color-mix(in srgb, var(--accent) 90%, #000);
  box-shadow: 0 6px 16px rgba(0, 0, 0, 0.3);
  transform: translateY(-2px);
}
.fab-action:active { transform: translateY(0) scale(0.98); }
@media (prefers-reduced-motion: reduce) {
  .fab-action { transition: none; }
}
