/* Hand Me the Rule Book — shared design system.
   Theme: light by default, dark from the system setting, and either can be
   forced with <html data-theme="light|dark"> (set by the theme toggle).
   Always colour with the custom properties below so both themes work. */

:root {
  --bg: #f6f0e4;            /* cream table cloth */
  --surface: #fffdf9;       /* card stock */
  --surface-2: #f1e9d9;     /* inset areas */
  --text: #2b2420;
  --muted: #6a5d52;
  --border: #e2d7c3;
  --border-strong: #96887a; /* control outlines, 3:1 on surfaces */
  --accent: #1f6b54;        /* felt green */
  --accent-text: #ffffff;
  --accent-soft: #dcede5;
  --gold: #c97a1e;
  --logo-gold: #f3c06b;
  --danger: #b3261e;
  --danger-soft: #fbe6e3;
  --winner: #fde7a3;
  --radius: 14px;
  --shadow: 0 1px 2px rgb(60 40 20 / 0.06), 0 6px 18px rgb(60 40 20 / 0.06);
  --dots: rgb(90 60 30 / 0.07);
  --font-body: system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", sans-serif;
  --font-display: "Iowan Old Style", "Palatino Linotype", Palatino, "Book Antiqua", Georgia, serif;
  --nav-h: 64px;
  --ring: color-mix(in srgb, var(--accent) 32%, transparent);
  --glass: color-mix(in srgb, var(--surface) 86%, transparent);
  --ease: cubic-bezier(0.2, 0.7, 0.2, 1);
  color-scheme: light;
}
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --bg: #1b1816;
    --surface: #262220;
    --surface-2: #312c28;
    --text: #f2ece2;
    --muted: #b5a99b;
    --border: #3f3833;
    --border-strong: #84786c;
    --accent: #74d1b1;
    --accent-text: #0e2a21;
    --accent-soft: #1f3d33;
    --gold: #e9a54a;
    --logo-gold: #8a4a00;
    --danger: #ff9c90;
    --danger-soft: #4a2420;
    --winner: #5a4812;
    --shadow: 0 1px 2px rgb(0 0 0 / 0.3), 0 6px 18px rgb(0 0 0 / 0.25);
    --dots: rgb(255 240 220 / 0.045);
    color-scheme: dark;
  }
}
:root[data-theme="dark"] {
  --bg: #1b1816;
  --surface: #262220;
  --surface-2: #312c28;
  --text: #f2ece2;
  --muted: #b5a99b;
  --border: #3f3833;
  --border-strong: #84786c;
  --accent: #74d1b1;
  --accent-text: #0e2a21;
  --accent-soft: #1f3d33;
  --gold: #e9a54a;
  --logo-gold: #8a4a00;
  --danger: #ff9c90;
  --danger-soft: #4a2420;
  --winner: #5a4812;
  --shadow: 0 1px 2px rgb(0 0 0 / 0.3), 0 6px 18px rgb(0 0 0 / 0.25);
  --dots: rgb(255 240 220 / 0.045);
  color-scheme: dark;
}

/* ---- Base ---- */
*, *::before, *::after { box-sizing: border-box; }
[hidden] { display: none !important; }
html { -webkit-text-size-adjust: 100%; scroll-padding-top: 72px; }
body {
  margin: 0;
  min-height: 100vh;
  min-height: 100dvh;
  font: 16px/1.55 var(--font-body);
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
  background-color: var(--bg);
  background-image: radial-gradient(var(--dots) 1.5px, transparent 1.5px);
  background-size: 22px 22px;
  color: var(--text);
  overflow-wrap: break-word;
}
a { color: var(--accent); text-underline-offset: 2px; }
a:hover { text-decoration-thickness: 2px; }
h1, h2, h3 { font-family: var(--font-display); line-height: 1.2; letter-spacing: -0.01em; text-wrap: balance; }
p { margin: 0 0 12px; text-wrap: pretty; }
::selection { background: var(--ring); }
p:last-child { margin-bottom: 0; }
strong { font-weight: 650; }

:focus-visible {
  outline: 3px solid var(--accent);
  outline-offset: 2px;
  border-radius: 6px;
}
#view:focus { outline: none; }

.sr-only {
  position: absolute; width: 1px; height: 1px; margin: -1px; padding: 0;
  overflow: hidden; clip-path: inset(50%); white-space: nowrap; border: 0;
}
.skip-link {
  position: absolute; left: 8px; top: -60px; z-index: 30;
  padding: 10px 14px; border-radius: 10px;
  background: var(--accent); color: var(--accent-text); font-weight: 600;
}
.skip-link:focus { top: 8px; }

/* ---- Header and navigation ---- */
.app-header {
  position: sticky; top: 0; z-index: 20;
  background: var(--surface); /* no backdrop-filter here on phones: it would trap the fixed tab bar */
  border-bottom: 1px solid var(--border);
  padding-top: env(safe-area-inset-top);
}
.app-header-inner {
  display: flex; align-items: center; gap: 8px 20px;
  max-width: 1080px; margin: 0 auto;
  padding: 8px max(16px, env(safe-area-inset-right)) 8px max(16px, env(safe-area-inset-left));
}
.app-brand {
  display: flex; align-items: center; gap: 10px; min-width: 0;
  color: var(--text); text-decoration: none; border-radius: 10px;
}
.app-logo { flex: none; border-radius: 9px; box-shadow: 0 1px 2px rgb(0 0 0 / 0.18); }
.app-logo .logo-r { fill: var(--logo-gold); }
.app-title { font-size: 1.15rem; margin: 0; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }

.theme-toggle {
  flex: none; margin-left: auto;
  display: inline-grid; place-items: center; width: 44px; height: 44px;
  border: 1px solid var(--border); border-radius: 50%;
  background: var(--surface); color: var(--text); cursor: pointer;
  transition: background-color 150ms var(--ease), transform 150ms var(--ease);
}
.theme-toggle:hover { background: var(--surface-2); }
.theme-toggle:active { transform: scale(0.94); }
.theme-toggle svg { transition: transform 300ms var(--ease); }
.theme-toggle:hover svg { transform: rotate(18deg); }
.theme-toggle svg, .app-nav svg {
  width: 22px; height: 22px; fill: none; stroke: currentColor;
  stroke-width: 1.8; stroke-linecap: round; stroke-linejoin: round;
}
.app-nav svg .fill { fill: currentColor; stroke: none; }
.theme-toggle .icon-sun,
.theme-toggle[data-mode="dark"] .icon-moon { display: none; }
.theme-toggle[data-mode="dark"] .icon-sun { display: block; }

/* Mobile first: the nav is a bottom tab bar. */
.app-nav {
  position: fixed; left: 0; right: 0; bottom: 0; z-index: 20;
  display: grid; grid-auto-flow: column; grid-auto-columns: minmax(0, 1fr);
  padding: 6px max(4px, env(safe-area-inset-right)) calc(6px + env(safe-area-inset-bottom)) max(4px, env(safe-area-inset-left));
  background: var(--glass);
  -webkit-backdrop-filter: saturate(1.4) blur(14px); backdrop-filter: saturate(1.4) blur(14px);
  border-top: 1px solid var(--border);
  box-shadow: 0 -4px 16px rgb(0 0 0 / 0.06);
}
.app-nav a {
  display: grid; justify-items: center; gap: 2px;
  min-height: 52px; padding: 5px 2px 3px;
  border-radius: 12px;
  color: var(--muted); text-decoration: none;
  font-size: 0.6875rem; font-weight: 600; letter-spacing: 0.01em;
  -webkit-tap-highlight-color: transparent;
}
.app-nav a svg {
  width: 46px; height: 28px; padding: 3px 12px; border-radius: 999px;
  transition: background-color 200ms var(--ease), color 200ms var(--ease), transform 200ms var(--ease);
}
.app-nav a:active svg { transform: scale(0.92); }
.app-nav a:hover { color: var(--text); }
.app-nav a.active { color: var(--text); }
.app-nav a.active svg { background: var(--accent); color: var(--accent-text); }

.app-main {
  max-width: 820px; margin: 0 auto;
  padding: 16px max(16px, env(safe-area-inset-right)) calc(var(--nav-h) + 32px + env(safe-area-inset-bottom)) max(16px, env(safe-area-inset-left));
  display: grid; gap: 16px;
  grid-template-columns: minmax(0, 1fr);
}

@media (min-width: 900px) {
  .app-header {
    background: var(--glass);
    -webkit-backdrop-filter: saturate(1.4) blur(14px); backdrop-filter: saturate(1.4) blur(14px);
  }
  .app-title { font-size: 1.25rem; }
  .app-header-inner { padding-top: 10px; padding-bottom: 10px; }
  .app-nav {
    position: static; display: flex; gap: 2px; padding: 0; margin-left: auto;
    background: none; border: 0; box-shadow: none;
    -webkit-backdrop-filter: none; backdrop-filter: none;
  }
  .theme-toggle { margin-left: 0; }
  .app-nav a {
    display: inline-flex; align-items: center; gap: 6px;
    min-height: 40px; padding: 6px 14px;
    border-radius: 999px; font-size: 0.9375rem;
    transition: background-color 150ms var(--ease), color 150ms var(--ease);
  }
  .app-nav a svg { display: none; width: 20px; height: 20px; padding: 0; border-radius: 0; }
  .app-nav a:hover { background: var(--surface-2); }
  .app-nav a.active { background: var(--accent); color: var(--accent-text); }
  .app-nav a.active svg { background: none; color: inherit; }
  .app-main { padding-top: 28px; padding-bottom: 56px; gap: 20px; }
}
@media (min-width: 1080px) {
  .app-nav a { padding-left: 10px; }
  .app-nav a svg { display: block; }
}
/* Wide screens: the add form sits beside the list on Games and Players. */
@media (min-width: 1000px) {
  .app-main[data-route="games"], .app-main[data-route="players"] {
    max-width: 1080px; grid-template-columns: 340px minmax(0, 1fr); align-items: start;
  }
  .app-main[data-route="games"] > .steps, .app-main[data-route="players"] > .steps { grid-column: 1 / -1; }
  .app-main[data-route="games"] > .card:first-of-type,
  .app-main[data-route="players"] > .card:first-of-type { position: sticky; top: 88px; }
  .app-main[data-route="games"] > .card:first-of-type .field-grid.game { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .app-main[data-route="games"] > .card:first-of-type .field-grid.game > .span-2 { grid-column: 1 / -1; }
  .app-main[data-route="players"] > .card:first-of-type .row-form > * { flex-basis: 100%; }
}

/* ---- Cards ---- */
.card {
  background: var(--surface); border: 1px solid var(--border);
  border-radius: var(--radius); padding: 16px;
  box-shadow: var(--shadow);
  min-width: 0;
}
.card h2 { margin: 0 0 12px; font-size: 1.3rem; }
.card h3 { margin: 16px 0 8px; font-size: 1.05rem; }
.card-head {
  display: flex; flex-wrap: wrap; align-items: baseline; gap: 4px 12px; margin-bottom: 12px;
}
.card-head h2 { margin: 0; }
.card-head .muted { font-size: 0.9rem; }
@media (min-width: 720px) { .card { padding: 22px 24px; } }

/* ---- Forms ---- */
input, select, textarea, button { font: inherit; color: inherit; }
input, select, textarea {
  min-height: 44px; padding: 9px 12px;
  border: 1px solid var(--border-strong); border-radius: 10px;
  background: var(--surface); color: var(--text); max-width: 100%;
  box-shadow: inset 0 1px 2px rgb(60 40 20 / 0.05);
  transition: border-color 150ms var(--ease), box-shadow 150ms var(--ease);
}
input:hover, select:hover, textarea:hover { border-color: var(--muted); }
select {
  -webkit-appearance: none; appearance: none; padding-right: 38px; cursor: pointer; text-overflow: ellipsis;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='%238a7d70' stroke-width='2.4' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='m6 9 6 6 6-6'/%3E%3C/svg%3E");
  background-repeat: no-repeat; background-position: right 12px center; background-size: 16px;
}
input[type="search"] {
  -webkit-appearance: none; appearance: none; padding-left: 38px;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='%238a7d70' stroke-width='2.2' stroke-linecap='round'%3E%3Ccircle cx='11' cy='11' r='6.5'/%3E%3Cpath d='m16 16 4.5 4.5'/%3E%3C/svg%3E");
  background-repeat: no-repeat; background-position: 12px center; background-size: 16px;
}
input[type="number"] { -moz-appearance: textfield; appearance: textfield; font-variant-numeric: tabular-nums; }
input[type="number"]::-webkit-inner-spin-button,
input[type="number"]::-webkit-outer-spin-button { -webkit-appearance: none; margin: 0; }
input[type="checkbox"], input[type="radio"] {
  min-height: 0; width: 20px; height: 20px; padding: 0; flex: none;
  accent-color: var(--accent); box-shadow: none; cursor: pointer;
}
input[type="color"] {
  -webkit-appearance: none; appearance: none;
  min-height: 0; width: 40px; height: 40px; padding: 0; border-radius: 50%;
  border: 2px solid var(--surface); box-shadow: 0 0 0 1px var(--border-strong);
  background: none; cursor: pointer; overflow: hidden;
}
input[type="color"]::-webkit-color-swatch-wrapper { padding: 0; }
input[type="color"]::-webkit-color-swatch { border: 0; border-radius: 50%; }
input[type="color"]::-moz-color-swatch { border: 0; border-radius: 50%; }
input[type="color"][data-chosen] { box-shadow: 0 0 0 3px var(--text); }
input[type="file"] { border-style: dashed; }
input::placeholder, textarea::placeholder { color: var(--muted); opacity: 1; }
input:focus-visible, select:focus-visible, textarea:focus-visible {
  outline: 2px solid var(--accent); outline-offset: 0; border-color: var(--accent);
  box-shadow: 0 0 0 4px var(--ring); border-radius: 10px;
}
input[type="checkbox"]:focus-visible, input[type="radio"]:focus-visible { outline-offset: 2px; border-radius: 4px; box-shadow: none; }
input[type="color"]:focus-visible { border-radius: 50%; outline-offset: 3px; }
label { display: grid; gap: 5px; font-size: 0.875rem; color: var(--muted); font-weight: 600; letter-spacing: 0.005em; }
label.block { margin: 12px 0; }
label.block textarea, label.block input, label.block select { width: 100%; }
label.check {
  display: flex; align-items: center; gap: 8px; min-height: 36px;
  color: var(--text); font-size: 1rem; font-weight: 400; cursor: pointer;
}
.row-form { display: flex; flex-wrap: wrap; align-items: end; gap: 12px; }
.row-form > label { flex: 1 1 150px; min-width: 0; }
.row-form > label.narrow { flex: 1 1 84px; }
.row-form > label > input:not([type="checkbox"]):not([type="radio"]):not([type="color"]),
.row-form > label > select { width: 100%; }
fieldset { min-width: 0; }

.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 6px;
  min-height: 44px; padding: 8px 16px; cursor: pointer;
  border: 1px solid var(--border-strong); border-radius: 10px; background: var(--surface);
  color: var(--text); font-size: 1rem; font-weight: 600; line-height: 1.2;
  text-decoration: none; white-space: nowrap; user-select: none;
  box-shadow: 0 1px 1px rgb(60 40 20 / 0.06);
  -webkit-tap-highlight-color: transparent;
  transition: background-color 150ms var(--ease), border-color 150ms var(--ease), box-shadow 150ms var(--ease),
    filter 150ms var(--ease), transform 100ms var(--ease);
}
.btn:hover { background: var(--surface-2); border-color: var(--muted); }
.btn:active { transform: translateY(1px) scale(0.985); box-shadow: none; }
.btn.primary {
  background: var(--accent); border-color: var(--accent); color: var(--accent-text);
  box-shadow: inset 0 1px 0 rgb(255 255 255 / 0.16), 0 1px 2px rgb(20 60 45 / 0.25), 0 4px 12px -4px var(--ring);
}
.btn.primary:hover { filter: brightness(1.08); background: var(--accent); border-color: var(--accent); }
.btn.danger { color: var(--danger); border-color: currentColor; }
.btn.danger:hover { background: var(--danger-soft); }
.btn.danger.solid { background: var(--danger); border-color: var(--danger); color: var(--surface); }
.btn.danger.solid:hover { filter: brightness(1.08); background: var(--danger); }
.btn.small { min-height: 36px; padding: 5px 12px; font-size: 0.875rem; border-radius: 8px; }
.btn:disabled, .btn[aria-disabled="true"] { opacity: 0.5; cursor: not-allowed; transform: none; box-shadow: none; filter: none; }

.error { color: var(--danger); margin: 8px 0 0; min-height: 1.5em; font-weight: 500; }
.error:empty { min-height: 0; margin: 0; }
.empty, .muted { color: var(--muted); }
.dot { display: inline-block; width: 12px; height: 12px; border-radius: 50%; margin-right: 6px; flex: none; }

.notice {
  padding: 12px 14px; border-radius: 10px;
  background: var(--accent-soft); color: var(--text);
  border-left: 4px solid var(--accent);
}
.notice[tabindex="-1"]:focus, .preview:focus { outline: none; }
.notice.warn { background: var(--winner); border-left-color: var(--gold); }
.notice.bad { background: var(--danger-soft); border-left-color: var(--danger); }
.badge {
  display: inline-block; padding: 1px 8px; border-radius: 999px;
  background: var(--surface-2); color: var(--text); font-size: 0.8rem; font-weight: 600;
}
.toolbar { display: flex; flex-wrap: wrap; align-items: end; gap: 8px 12px; margin-bottom: 4px; }
.toolbar > label { flex: 1 1 140px; min-width: 0; }
.toolbar > label > input, .toolbar > label > select { width: 100%; }
.actions { display: flex; flex-wrap: wrap; align-items: center; gap: 8px; }
.actions .spacer { flex: 1; }

/* ---- Lists (games, players) ---- */
.item-list, .play-list { list-style: none; margin: 0; padding: 0; }
.item-list li {
  display: flex; align-items: center; gap: 12px; padding: 12px 0;
  border-top: 1px solid var(--border);
}
.item-list li:first-child { border-top: 0; }
.item-list li.editing {
  display: block; margin: 4px -8px; padding: 14px;
  border: 1px solid var(--border); border-radius: 12px; background: var(--surface-2);
  box-shadow: inset 0 1px 3px rgb(60 40 20 / 0.06);
}
.item-list li.editing + li { border-top: 0; }
.item-main { flex: 1; min-width: 0; display: grid; gap: 1px; }
.item-name { flex: 1; font-weight: 600; }
.item-meta { font-size: 0.875rem; color: var(--muted); }
.item-stats { text-align: right; font-size: 0.875rem; color: var(--muted); white-space: nowrap; font-variant-numeric: tabular-nums; }
.item-stats strong { display: block; color: var(--text); font-size: 0.95rem; }
.avatar, .monogram {
  flex: none; display: inline-grid; place-items: center;
  width: 40px; height: 40px;
  font-weight: 700; font-size: 0.95rem; line-height: 1; user-select: none;
}
.avatar { border-radius: 50%; }
.monogram {
  border-radius: 9px; color: #fff;
  background: hsl(var(--hue, 160) 42% 34%);
  font-family: var(--font-display); font-size: 1.15rem;
  box-shadow: inset 0 -3px 0 rgb(0 0 0 / 0.18);
}
@media (max-width: 420px) {
  .item-list li { gap: 10px; }
  .item-list li:not(.editing) .btn.small { padding-left: 10px; padding-right: 10px; }
}

.edit-form { display: grid; gap: 12px; }
.field-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 12px; }
.field-grid > .span-2 { grid-column: 1 / -1; }
.field-grid input:not([type="checkbox"]):not([type="radio"]):not([type="color"]),
.field-grid select { width: 100%; }
@media (min-width: 560px) {
  .field-grid.game { grid-template-columns: 2fr 2fr 1fr 1fr; }
  .field-grid.game > .span-2 { grid-column: auto; }
}

.swatches { border: 0; margin: 0; padding: 0; }
.swatches legend { padding: 0; margin-bottom: 6px; font-size: 0.9rem; color: var(--muted); font-weight: 500; }
.swatch-row { display: flex; flex-wrap: wrap; align-items: center; gap: 8px; }
.swatch { position: relative; display: block; width: 40px; height: 40px; cursor: pointer; }
.swatch input { position: absolute; inset: 0; width: 100%; height: 100%; margin: 0; opacity: 0; cursor: pointer; }
.swatch span {
  display: block; width: 100%; height: 100%; border-radius: 50%;
  background: var(--c); border: 2px solid var(--surface);
  box-shadow: 0 0 0 1px var(--border-strong);
  transition: transform 150ms var(--ease), box-shadow 150ms var(--ease);
}
.swatch:hover span { transform: scale(1.08); }
.swatch input:checked + span { box-shadow: 0 0 0 3px var(--text); }
.swatch input:focus-visible + span { outline: 3px solid var(--accent); outline-offset: 4px; }
.swatch-custom { display: flex; align-items: center; gap: 8px; color: var(--muted); font-size: 0.9rem; }

/* ---- Empty states and first-run guide ---- */
.empty-state { display: grid; justify-items: center; gap: 6px; padding: 20px 8px 12px; text-align: center; }
.empty-state .empty-art {
  display: grid; place-items: center; width: 72px; height: 72px; margin-bottom: 4px;
  border-radius: 20px; background: var(--accent-soft); color: var(--accent); font-size: 2rem; transform: rotate(-5deg);
  box-shadow: inset 0 -4px 0 rgb(0 0 0 / 0.06);
}
.empty-art svg {
  width: 44px; height: 44px; fill: none; stroke: currentColor;
  stroke-width: 1.6; stroke-linecap: round; stroke-linejoin: round;
}
.empty-art svg[viewBox="0 0 48 48"] { stroke-width: 2.6; }
.empty-art svg .fill { fill: currentColor; stroke: none; }
.empty-state h3 { margin: 0; font-size: 1.15rem; }
.empty-state p { margin: 0; color: var(--muted); max-width: 36ch; }
.empty-state .btn { margin-top: 8px; }

.steps {
  padding: 14px 16px; border-radius: var(--radius);
  background: var(--accent-soft); border: 1px solid var(--border);
}
.steps-title { margin: 0 0 10px; font-family: var(--font-display); font-weight: 700; font-size: 1.1rem; }
.steps ol { list-style: none; margin: 0; padding: 0; display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 8px; }
.steps li a {
  display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 4px;
  height: 100%; min-height: 44px; padding: 8px 4px;
  border-radius: 12px; background: var(--surface); border: 1px solid var(--border);
  color: var(--text); text-decoration: none; font-weight: 600; font-size: 0.85rem; text-align: center;
  transition: border-color 150ms var(--ease), transform 150ms var(--ease);
}
.steps li a:hover { border-color: var(--accent); transform: translateY(-1px); }
@media (min-width: 560px) {
  .steps li a { flex-direction: row; gap: 8px; padding: 6px 12px; border-radius: 999px; font-size: 0.95rem; }
}
.steps li a[aria-current="step"] { border-color: var(--accent); box-shadow: 0 0 0 1px var(--accent); }
.step-num {
  display: inline-grid; place-items: center; width: 26px; height: 26px; border-radius: 50%; flex: none;
  background: var(--surface-2); color: var(--text); font-size: 0.85rem; font-weight: 700;
}
.steps li.done .step-num, .steps li.next .step-num { background: var(--accent); color: var(--accent-text); }
.steps li.done a { color: var(--muted); }
.steps-hint { margin: 10px 0 0; font-size: 0.95rem; }
.steps-hint:empty { display: none; }

/* ---- Data tab ---- */
.summary { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 8px; margin: 12px 0; }
.summary > div {
  display: grid; padding: 10px 12px; border-radius: 10px;
  background: var(--surface-2); text-align: center;
}
.summary b { font-family: var(--font-display); font-size: 1.5rem; line-height: 1.2; font-variant-numeric: tabular-nums; }
.summary span { color: var(--muted); font-size: 0.85rem; }
.preview {
  margin-top: 14px; padding: 14px; border-radius: 12px;
  border: 1px dashed var(--border-strong); background: var(--bg);
}
.preview h3 { margin: 0 0 4px; font-size: 1.05rem; }
.preview .summary > div { background: var(--surface); }
.preview dl { margin: 0 0 12px; display: grid; gap: 4px; font-size: 0.95rem; }
.preview dt { color: var(--muted); font-size: 0.85rem; }
.preview dd { margin: 0 0 4px; }
.file-drop {
  position: relative; display: grid; justify-items: center; gap: 2px; padding: 22px 16px; text-align: center;
  border: 1.5px dashed var(--border-strong); border-radius: 12px; background: var(--bg);
  color: var(--text); font-size: 0.95rem; font-weight: 400; cursor: pointer;
  transition: border-color 150ms var(--ease), background-color 150ms var(--ease);
}
.file-drop:hover { border-color: var(--accent); background: var(--accent-soft); }
.file-drop svg {
  width: 28px; height: 28px; margin-bottom: 4px; fill: none; stroke: var(--accent);
  stroke-width: 1.8; stroke-linecap: round; stroke-linejoin: round;
}
.file-drop .muted { font-size: 0.85rem; }
.file-drop input[type="file"] { position: absolute; inset: 0; width: 100%; height: 100%; opacity: 0; cursor: pointer; }
.file-drop:focus-within { outline: 2px solid var(--accent); outline-offset: 2px; box-shadow: 0 0 0 4px var(--ring); }
.segmented { display: inline-flex; padding: 3px; gap: 2px; border-radius: 12px; background: var(--surface-2); border: 1px solid var(--border); }
.segmented button {
  min-height: 40px; padding: 6px 16px; border: 0; border-radius: 9px;
  background: none; color: var(--muted); font-weight: 600; cursor: pointer;
  transition: background-color 150ms var(--ease), color 150ms var(--ease), box-shadow 150ms var(--ease);
}
.segmented button:hover { color: var(--text); }
.segmented button[aria-pressed="true"] { background: var(--surface); color: var(--text); box-shadow: var(--shadow); }
.danger-zone { border-color: color-mix(in srgb, var(--danger) 45%, var(--border)); }

/* ---- Plays (base styles; css/plays.css refines) ---- */
.player-picker { border: 1px solid var(--border); border-radius: 10px; margin: 12px 0 0; padding: 8px 12px; }
.player-picker legend { font-size: 0.9rem; color: var(--muted); padding: 0 4px; }
.player-row { display: flex; flex-wrap: wrap; align-items: center; gap: 12px; padding: 6px 0; }
.player-row > .check:first-child { flex: 1; min-width: 140px; }
.player-row input[type="number"] { width: 110px; }

.play-list li { padding: 12px 0; border-top: 1px solid var(--border); }
.play-list li:first-child { border-top: 0; }
.play-head { display: flex; flex-wrap: wrap; align-items: center; gap: 8px; }
.play-head .muted { flex: 1; }
.play-results { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 8px; }
.chip {
  display: inline-flex; align-items: center; padding: 2px 10px;
  border: 1px solid var(--border); border-radius: 999px; font-size: 0.9rem;
  background: var(--surface);
}
.chip.winner { background: var(--winner); border-color: var(--gold); font-weight: 600; }

/* ---- Stats (base styles; css/stats.css refines) ---- */
.stat-tiles { display: grid; grid-template-columns: repeat(auto-fit, minmax(130px, 1fr)); gap: 12px; }
.tile {
  background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius);
  padding: 14px; display: grid; box-shadow: var(--shadow);
}
.tile-value { font-family: var(--font-display); font-size: 1.9rem; font-weight: 700; line-height: 1.2; font-variant-numeric: tabular-nums; }
.tile-label { color: var(--muted); font-size: 0.9rem; }

.table { width: 100%; border-collapse: collapse; }
.table th, .table td { text-align: left; padding: 10px 6px; border-top: 1px solid var(--border); }
.table thead th { border-top: 0; color: var(--muted); font-size: 0.8rem; font-weight: 600; text-transform: uppercase; letter-spacing: 0.04em; }
.table .num { text-align: right; font-variant-numeric: tabular-nums; }

/* ---- Motion ---- */
@media (prefers-reduced-motion: no-preference) {
  .item-list li.editing, .preview, .confirm, .notice[role="status"] { animation: rise 200ms var(--ease); }
  .app-main.view-enter > * { animation: rise 280ms var(--ease) both; }
  .app-main.view-enter > :nth-child(2) { animation-delay: 40ms; }
  .app-main.view-enter > :nth-child(3) { animation-delay: 80ms; }
  .app-main.view-enter > :nth-child(n + 4) { animation-delay: 120ms; }
  @keyframes rise { from { opacity: 0; transform: translateY(6px); } }
}
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after {
    animation-duration: 0.01ms !important; animation-iteration-count: 1 !important;
    transition-duration: 0.01ms !important; scroll-behavior: auto !important;
  }
}

@media print {
  .app-nav, .theme-toggle, .skip-link { display: none; }
  .app-header { position: static; }
  body { background: #fff; }
}
