/* boardrecord UI — shared design model with the sibling lifting/faster apps:
   data-theme (system/light/dark) + data-accent tokens via color-mix, a blurred
   sticky top bar with round icon buttons, and a floating pill tab bar. */

:root {
  --accent-base: #2fae66;
  --bg: #f3f7f4;
  --surface: #ffffff;
  --surface-2: #e9f1ec;
  --fg: #17211b;
  --muted: #647569;
  --border: #dbe6df;
  --danger: #c0392b;
  --danger-soft: #fbe9e7;
  --ok: #2f9e63;
  --warn: #a8770a;
  --alt: #3d8bfd;
  --accent: var(--accent-base);
  --accent-fg: #ffffff;
  --accent-soft: color-mix(in srgb, var(--accent-base) 14%, var(--surface));
  --radius: 16px;
  --radius-sm: 10px;
  --shadow: 0 1px 2px rgba(15, 40, 28, .06);
  --shadow-lg: 0 8px 30px rgba(15, 40, 28, .18);
  --card: var(--surface);
}

html[data-accent="purple"] { --accent-base: #7c5cff; }
html[data-accent="blue"] { --accent-base: #3d8bfd; }
html[data-accent="red"] { --accent-base: #e0503f; }
html[data-accent="orange"] { --accent-base: #e08a2e; }

html[data-theme="dark"] {
  --bg: #0e0e12;
  --surface: #1a1a22;
  --surface-2: #23232e;
  --fg: #e9e8f0;
  --muted: #9a98ab;
  --border: #2b2b37;
  --danger: #e07a70;
  --danger-soft: #3a1d1a;
  --ok: #4fc98a;
  --warn: #d3a63a;
  --alt: #63a8e8;
  --accent: color-mix(in srgb, var(--accent-base) 72%, white);
  --accent-fg: #14121a;
  --accent-soft: color-mix(in srgb, var(--accent-base) 26%, var(--surface));
  --shadow: none;
  --shadow-lg: 0 10px 34px rgba(0, 0, 0, .5);
}

@media (prefers-color-scheme: dark) {
  html[data-theme="system"] {
    --bg: #0e0e12;
    --surface: #1a1a22;
    --surface-2: #23232e;
    --fg: #e9e8f0;
    --muted: #9a98ab;
    --border: #2b2b37;
    --danger: #e07a70;
    --danger-soft: #3a1d1a;
    --ok: #4fc98a;
    --warn: #d3a63a;
    --alt: #63a8e8;
    --accent: color-mix(in srgb, var(--accent-base) 72%, white);
    --accent-fg: #14121a;
    --accent-soft: color-mix(in srgb, var(--accent-base) 26%, var(--surface));
    --shadow: none;
    --shadow-lg: 0 10px 34px rgba(0, 0, 0, .5);
  }
}

* { box-sizing: border-box; }

/* Author display rules (e.g. .list-row { display: flex }) win over the UA
   [hidden] rule, so make the hidden attribute authoritative. */
[hidden] { display: none !important; }

body {
  margin: 0;
  padding-bottom: 104px;
  background: var(--bg);
  color: var(--fg);
  font: 15px/1.45 system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  -webkit-tap-highlight-color: transparent;
}

a { color: var(--accent); text-decoration: none; }
a:hover { text-decoration: none; }
h1 { font-size: 1.55rem; margin: 0; letter-spacing: -.01em; }
h2 { font-size: 1.05rem; margin: 0; }
h3 { font-size: .95rem; margin: 0; }
code { background: var(--accent-soft); padding: 1px 5px; border-radius: 5px; font-size: .85em; }

/* top bar */
.topbar {
  position: sticky;
  top: 0;
  z-index: 20;
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 12px 16px;
  background: color-mix(in srgb, var(--surface) 88%, transparent);
  backdrop-filter: blur(12px);
  border-bottom: 1px solid var(--border);
}
.brand { font-weight: 800; letter-spacing: .3px; color: var(--fg); font-size: 1.1rem; }
.brand:hover { text-decoration: none; }
.topbar-actions { margin-left: auto; display: flex; gap: 8px; align-items: center; }
.topbar-actions form { margin: 0; }
.icon-btn {
  width: 38px; height: 38px;
  display: grid; place-items: center;
  border-radius: 50%;
  background: var(--surface-2);
  color: var(--fg);
  font-size: 1.1rem;
  line-height: 1;
  border: none;
  cursor: pointer;
}
.icon-btn:hover { background: var(--accent-soft); color: var(--accent); }

/* dark-mode switch: show the sun while dark, the moon otherwise */
.theme-switch { margin: 0; }
.theme-ico { line-height: 1; }
.theme-ico-dark { display: none; }
html[data-theme="dark"] .theme-ico-light { display: none; }
html[data-theme="dark"] .theme-ico-dark { display: inline; }
@media (prefers-color-scheme: dark) {
  html[data-theme="system"] .theme-ico-light { display: none; }
  html[data-theme="system"] .theme-ico-dark { display: inline; }
}

.timer-chip {
  display: inline-flex;
  align-items: center;
  gap: 7px;
  padding: 5px 13px;
  border-radius: 999px;
  background: var(--accent-soft);
  color: var(--accent);
  font-size: .82rem;
  font-weight: 600;
  max-width: 55%;
  overflow: hidden;
  white-space: nowrap;
  font-variant-numeric: tabular-nums;
}
.timer-chip:hover { text-decoration: none; }
.timer-chip strong { font-weight: 700; }
.pulse { width: 8px; height: 8px; border-radius: 50%; background: var(--accent); animation: pulse 1.4s infinite; flex: none; }
@keyframes pulse { 50% { opacity: .25; } }

/* layout */
main { max-width: 780px; margin: 0 auto; padding: 16px 16px 32px; }
.page-head { display: flex; align-items: flex-start; justify-content: space-between; gap: 12px; margin: 4px 0 16px; }
.page-head h1 { margin-top: 2px; }
.page-head .muted { margin: 4px 0 0; }
.muted { color: var(--muted); }
.small { font-size: .82rem; }
.count { font-size: .85rem; margin: 0 0 12px; }
.back { display: inline-block; color: var(--muted); font-size: .85rem; margin-bottom: 4px; }
.empty { color: var(--muted); padding: 16px 4px; }
.link { font-size: .85rem; font-weight: 600; }

.card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 16px;
  margin-bottom: 16px;
}
.card-head { display: flex; align-items: center; justify-content: space-between; gap: 10px; margin-bottom: 12px; }
.card-head h2 { flex: 1; }
details.card > summary, details > summary { cursor: pointer; font-weight: 600; list-style: none; }
details > summary::-webkit-details-marker { display: none; }
.danger-zone { border-color: var(--danger); }

/* flash */
.flash {
  max-width: 780px;
  margin: 12px auto 0;
  padding: 10px 16px;
  border-radius: var(--radius-sm);
  background: var(--accent-soft);
  color: var(--fg);
  border: 1px solid var(--border);
  font-size: .9rem;
}
.flash.error { background: var(--danger-soft); border-color: var(--danger); }
.flash a { font-weight: 600; }

/* auth pages */
.auth-wrap { max-width: 420px; margin: 6vh auto 0; padding: 0 16px; }
.auth-card h1 { margin-bottom: 6px; }
.auth-card form { margin-top: 14px; }
.auth-alt { margin-bottom: 0; }
.btn-block { width: 100%; text-align: center; margin-top: 4px; }

/* stats */
.stat-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(140px, 1fr));
  gap: 10px;
  margin-bottom: 16px;
}
.stat {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 12px 14px;
  display: flex;
  flex-direction: column;
  gap: 2px;
}
.stat-value { font-size: 1.3rem; font-weight: 700; font-variant-numeric: tabular-nums; }
.stat-label { color: var(--muted); font-size: .78rem; }

/* lists */
.list { list-style: none; margin: 0; padding: 0; }
.list-row {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 12px 0;
  border-bottom: 1px solid var(--border);
}
.list-row:last-child { border-bottom: none; }
.list-row.ignored { opacity: .55; }
.row-main { flex: 1; display: flex; flex-direction: column; gap: 2px; color: inherit; min-width: 0; }
.row-main:hover { text-decoration: none; }
.row-main > span { min-width: 0; }
.row-main.with-thumb { flex-direction: row; align-items: center; gap: 12px; }
.row-main.with-thumb > span:last-child { flex: 1; }
.row-title { font-weight: 600; display: block; }
.row-sub { color: var(--muted); font-size: .82rem; display: block; }
.row-side { color: var(--muted); font-size: .82rem; white-space: nowrap; font-variant-numeric: tabular-nums; text-align: right; }
.row-actions { display: flex; flex-wrap: wrap; justify-content: flex-end; gap: 6px; }
.avatar {
  flex: none;
  width: 34px; height: 34px;
  border-radius: 50%;
  background: var(--accent-soft);
  color: var(--accent);
  display: grid;
  place-items: center;
  font-weight: 700;
}
.thumb { width: 44px; height: 44px; border-radius: 10px; object-fit: cover; flex: none; background: var(--surface-2); }
.thumb.placeholder { display: grid; place-items: center; font-weight: 700; color: var(--accent); }
.hero-thumb { width: 64px; border-radius: 12px; }

/* badges */
.badge {
  display: inline-block;
  padding: 1px 8px;
  border-radius: 999px;
  font-size: .7rem;
  font-weight: 600;
  background: var(--accent-soft);
  color: var(--accent);
  vertical-align: middle;
}
.badge-alt { background: color-mix(in srgb, var(--alt) 16%, var(--surface)); color: var(--alt); }
.badge-warn { background: transparent; border: 1px solid var(--warn); color: var(--warn); }

/* buttons */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  padding: 9px 16px;
  border-radius: 999px;
  border: 1px solid var(--border);
  background: var(--surface);
  color: var(--fg);
  font: inherit;
  font-size: .9rem;
  font-weight: 500;
  cursor: pointer;
  white-space: nowrap;
}
.btn:hover { border-color: var(--accent); color: var(--accent); text-decoration: none; }
.btn-primary { background: var(--accent); border-color: var(--accent); color: var(--accent-fg); font-weight: 600; }
.btn-primary:hover { filter: brightness(1.06); color: var(--accent-fg); }
.btn-danger { color: var(--danger); border-color: var(--danger); background: transparent; }
.btn-danger:hover { background: var(--danger-soft); color: var(--danger); }
.btn-small { padding: 5px 12px; font-size: .8rem; }
.btn-row { display: flex; gap: 8px; flex-wrap: wrap; align-items: center; }
.quick { display: flex; gap: 8px; flex-wrap: wrap; }

/* forms */
label { display: block; margin-bottom: 12px; font-size: .85rem; color: var(--muted); }
input[type="text"], input[type="search"], input[type="number"], input[type="date"],
input[type="time"], input[type="email"], input[type="url"], input[type="password"], input[type="file"],
select, textarea {
  display: block;
  width: 100%;
  margin-top: 5px;
  padding: 10px 12px;
  border-radius: var(--radius-sm);
  border: 1px solid var(--border);
  background: var(--surface-2);
  color: var(--fg);
  font: inherit;
}
textarea { resize: vertical; }
input:focus, select:focus, textarea:focus { outline: 2px solid var(--accent); outline-offset: 1px; border-color: transparent; }
fieldset { border: 1px solid var(--border); border-radius: var(--radius); margin: 0 0 14px; padding: 12px; }
legend { padding: 0 6px; font-size: .8rem; color: var(--muted); }
.form-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(180px, 1fr)); gap: 0 14px; }
.inline-form { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; margin: 0; }
.inline-form input, .inline-form select { margin-top: 0; width: auto; flex: 1; min-width: 120px; }
.board-rename { flex: 1 1 230px; justify-content: flex-end; }
.board-rename input { max-width: 180px; }
.check { display: flex; align-items: center; gap: 8px; margin-bottom: 10px; color: var(--fg); }
.check input { margin: 0; width: auto; }

/* check chips (players) */
.chips { display: flex; flex-wrap: wrap; gap: 8px; margin-bottom: 10px; }
.chip {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  margin: 0;
  padding: 7px 13px;
  border: 1px solid var(--border);
  border-radius: 999px;
  font-size: .85rem;
  color: var(--fg);
  cursor: pointer;
}
.chip input { margin: 0; width: auto; }
.chip em { color: var(--muted); font-style: normal; font-size: .78rem; }
.chip-static { cursor: default; background: var(--surface-2); }

/* player selection sheet */
.player-summary { align-items: center; min-height: 32px; }
.player-option {
  display: flex;
  align-items: center;
  gap: 10px;
  margin: 0;
  padding: 11px 2px;
  border-bottom: 1px solid var(--border);
  font-size: .9rem;
  color: var(--fg);
  cursor: pointer;
}
.player-option:last-child { border-bottom: 0; }
.player-option input { width: auto; margin: 0; }
.player-option em { color: var(--muted); font-style: normal; font-size: .78rem; }
.player-sheet {
  position: fixed;
  inset: auto 0 0 0;
  margin: 0 auto;
  width: min(520px, 100%);
  max-height: min(82vh, 640px);
  overflow: auto;
  padding: 16px;
  padding-bottom: calc(16px + env(safe-area-inset-bottom));
  border: 1px solid var(--border);
  border-bottom: none;
  border-radius: var(--radius) var(--radius) 0 0;
  background: var(--surface);
  color: var(--fg);
  box-shadow: var(--shadow-lg);
}
.player-sheet::backdrop { background: rgba(6, 12, 9, .48); }
.player-sheet-head { display: flex; align-items: center; justify-content: space-between; margin-bottom: 6px; }
.player-sheet-head h2 { margin: 0; font-size: 1.05rem; }
.player-options { margin-bottom: 12px; }

/* filter bar */
.filter-bar { display: flex; gap: 10px; align-items: center; flex-wrap: wrap; margin-bottom: 14px; }
.filter-bar label { margin: 0; }
.filter-bar input[type="search"] { width: auto; flex: 1; min-width: 160px; margin: 0; }
.filter-bar select { width: auto; margin: 0; }

/* segmented */
.segmented { display: inline-flex; border: 1px solid var(--border); border-radius: 999px; overflow: hidden; }
.segmented a { padding: 8px 16px; font-size: .85rem; color: var(--muted); }
.segmented a.active { background: var(--accent); color: var(--accent-fg); font-weight: 600; }
.segmented a:hover { text-decoration: none; }

/* tables */
.table { width: 100%; border-collapse: collapse; font-size: .88rem; }
.table th, .table td { text-align: left; padding: 7px 8px; border-bottom: 1px solid var(--border); }
.table th { color: var(--muted); font-size: .75rem; text-transform: uppercase; letter-spacing: .03em; }
.table tr:last-child td { border-bottom: none; }
.table tr.winner td { background: var(--accent-soft); }

/* player scores */
.scores .score-input { width: 90px; margin: 0; }
.scores .player-select { width: 100%; margin: 0; padding: 6px 8px; font-size: .85rem; }
.scores .roles-cell { min-width: 130px; }
.scores .role-select { width: 100%; margin: 0 0 4px; padding: 4px; font-size: .85rem; }
.scores .new-role-input { width: 100%; margin: 0; padding: 6px 8px; font-size: .85rem; }
.scores input[type="checkbox"] { margin: 0; width: auto; }

/* score sheets */
.sheet-title { margin: 18px 0 8px; font-size: .95rem; }
.sheet-round + .sheet-round { margin-top: 16px; }
.sheet-round-title { margin: 0 0 8px; font-size: .9rem; }
.sheet-grand { margin-top: 16px; }
.sheet-scroll { overflow-x: auto; }
.sheet-grid th, .sheet-grid td { text-align: center; white-space: nowrap; }
.sheet-grid th:first-child, .sheet-grid td:first-child { text-align: left; }
.sheet-grid input[type="text"] { width: 80px; margin: 0; padding: 6px 8px; text-align: right; }
.sheet-grid input[type="checkbox"] { margin: 0; width: auto; }
.sheet-grid tfoot th, .sheet-grid tfoot td { font-weight: 700; border-top: 2px solid var(--border); }
.sheet-editor input[type="text"] { width: 100%; }
.sheet-editor input[type="number"] { width: 80px; }
.sheet-editor select { width: auto; }
.sheet-editor th, .sheet-editor td { padding: 5px 6px; vertical-align: middle; }

/* photos */
.photo-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(120px, 1fr)); gap: 10px; margin-bottom: 12px; }
.photo { margin: 0; display: flex; flex-direction: column; gap: 6px; }
.photo img { width: 100%; aspect-ratio: 4 / 3; object-fit: cover; border-radius: var(--radius-sm); border: 1px solid var(--border); }
.photo form { margin: 0; }

/* timer */
.timer-card { border-color: var(--accent); }
.timer-row { display: flex; align-items: center; justify-content: space-between; gap: 12px; }
.timer-clock { font-variant-numeric: tabular-nums; font-size: 2rem; font-weight: 700; color: var(--accent); }
.timer-clock small { display: block; text-align: right; font-size: .7rem; color: var(--muted); font-weight: 400; }

/* tab bar */
.tabbar {
  position: fixed;
  bottom: max(14px, env(safe-area-inset-bottom));
  left: 50%;
  transform: translateX(-50%);
  z-index: 20;
  display: flex;
  gap: 4px;
  padding: 6px;
  width: min(560px, calc(100% - 24px));
  background: color-mix(in srgb, var(--surface) 92%, transparent);
  backdrop-filter: blur(14px);
  border: 1px solid var(--border);
  border-radius: 999px;
  box-shadow: var(--shadow-lg);
}
.tabbar a {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 2px;
  padding: 8px 4px;
  border-radius: 999px;
  color: var(--muted);
  font-size: .72rem;
  font-weight: 600;
  min-width: 0;
  white-space: nowrap;
}
.tabbar a.active { background: var(--accent-soft); color: var(--accent); }
.tabbar a:hover { text-decoration: none; }
.tab-ico { font-size: 1.15rem; line-height: 1; }

/* floating action button: log a play */
.fab {
  position: fixed;
  right: max(18px, env(safe-area-inset-right));
  bottom: calc(max(14px, env(safe-area-inset-bottom)) + 80px);
  z-index: 21;
  width: 56px;
  height: 56px;
  display: grid;
  place-items: center;
  border-radius: 50%;
  background: var(--accent);
  color: var(--accent-fg);
  font-size: 1.9rem;
  font-weight: 400;
  line-height: 1;
  box-shadow: var(--shadow-lg);
  transition: transform .12s ease, filter .12s ease;
}
.fab:hover { color: var(--accent-fg); filter: brightness(1.06); }
.fab:active { transform: scale(.94); }

/* secondary floating action: dice roller, stacked above the log-a-play + */
.fab-secondary {
  bottom: calc(max(14px, env(safe-area-inset-bottom)) + 146px);
  width: 48px;
  height: 48px;
  background: var(--surface);
  border: 1px solid var(--border);
  color: var(--accent);
  font-size: 1.5rem;
}
.fab-secondary:hover { background: var(--accent-soft); color: var(--accent); filter: none; }

/* shared modal dialog */
.app-dialog {
  width: min(420px, calc(100% - 32px));
  max-height: calc(100% - 32px);
  overflow: auto;
  padding: 16px;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: var(--surface);
  color: var(--fg);
  box-shadow: var(--shadow-lg);
}
.app-dialog::backdrop { background: rgba(6, 12, 9, .48); }
.app-dialog form { margin: 0; }
.app-dialog .card-head { margin-bottom: 12px; }

/* game cover zoom */
img.game-cover { cursor: zoom-in; }
.cover-dialog {
  width: min(94vw, 86vh);
  max-height: calc(100% - 32px);
  padding: 0;
  place-items: center;
  overflow: hidden;
  background: var(--bg);
}
.cover-dialog[open] { display: grid; }
.cover-dialog img {
  display: block;
  width: auto;
  height: auto;
  max-width: 100%;
  max-height: 86vh;
}
.cover-dialog-close {
  position: absolute;
  top: 8px;
  right: 8px;
  background: color-mix(in srgb, var(--surface) 86%, transparent);
  border: 1px solid var(--border);
}

/* dice roller dialog */
.dice-picker { display: flex; flex-wrap: wrap; gap: 6px; margin-bottom: 14px; }
.dice-die {
  padding: 7px 12px;
  border: 1px solid var(--border);
  border-radius: 999px;
  background: var(--surface-2);
  color: var(--fg);
  font: inherit;
  font-size: .84rem;
  font-weight: 600;
  cursor: pointer;
}
.dice-die[aria-pressed="true"] { background: var(--accent); border-color: var(--accent); color: var(--accent-fg); }
.dice-controls { display: flex; gap: 10px; }
.dice-controls label { flex: 1; margin-bottom: 0; }
.dice-result {
  display: block;
  margin: 14px 0 4px;
  text-align: center;
  font-size: 2.6rem;
  font-weight: 800;
  line-height: 1.1;
  color: var(--accent);
  font-variant-numeric: tabular-nums;
}
.dice-rolls {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: center;
  gap: 8px;
  min-height: 40px;
  margin-bottom: 4px;
}
.dice-face {
  display: grid;
  place-items: center;
  min-width: 40px;
  height: 40px;
  padding: 0 8px;
  border-radius: var(--radius-sm);
  border: 1px solid color-mix(in srgb, var(--accent) 35%, var(--border));
  background: var(--accent-soft);
  color: var(--fg);
  font-size: 1.3rem;
  font-weight: 700;
  font-variant-numeric: tabular-nums;
  animation: dice-pop .18s ease-out;
}
.dice-face-mod { background: var(--surface-2); color: var(--muted); font-size: 1rem; border-color: var(--border); }
.dice-detail { text-align: center; margin: 0 0 14px; min-height: 1.2em; }
@keyframes dice-pop {
  from { transform: scale(.6); opacity: 0; }
  to { transform: none; opacity: 1; }
}
@keyframes dice-tumble {
  0% { transform: rotate(-7deg) scale(.95); opacity: .7; }
  50% { transform: rotate(6deg) scale(1.05); }
  100% { transform: none; opacity: 1; }
}
.dice-dialog[data-rolling] .dice-result { animation: dice-tumble .2s ease-in-out 2; }

/* first-player slot machine */
.scores-tools { margin-bottom: 10px; }
.slot-dialog { text-align: center; }
.slot-dialog .btn-row { justify-content: center; }
.slot-window {
  position: relative;
  height: 56px;
  margin: 14px 0 6px;
  overflow: hidden;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  background: var(--surface-2);
  box-shadow: inset 0 10px 12px -14px rgba(0, 0, 0, .55), inset 0 -10px 12px -14px rgba(0, 0, 0, .55);
}
.slot-strip { display: flex; flex-direction: column; }
.slot-item {
  flex: none;
  height: 56px;
  display: grid;
  place-items: center;
  padding: 0 12px;
  font-size: 1.35rem;
  font-weight: 700;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.slot-dialog[data-winner] .slot-window { border-color: var(--accent); background: var(--accent-soft); }
.slot-dialog[data-winner] .slot-item.is-winner { color: var(--accent); }
.slot-status { margin: 0 0 14px; min-height: 1.3em; }

@media (max-width: 480px) {
  .page-head { flex-wrap: wrap; }
  .row-side { white-space: normal; }
  .timer-clock { font-size: 1.5rem; }
  .tabbar a { font-size: .68rem; }
}
