:root {
  color-scheme: light;
  --sand: #f3e6c8;
  --sand-deep: #e7d3a4;
  --paper: #fffaf1;
  --ink: #2c2416;
  --muted: #6d604f;
  --purple: #6e3d86;
  --purple-deep: #4c2462;
  --line: #e6d3ae;
  --good: #1c7a4d;
  --mid: #a86b10;
  --low: #1f5f8a;
  --zero: #5e564c;
  --danger: #8d2e2e;
  --shadow: 0 16px 40px rgba(74, 42, 18, 0.08);
  --radius: 20px;
  --tab: 64px;
  font-family: "Avenir Next", "Segoe UI", "Helvetica Neue", sans-serif;
}

* { box-sizing: border-box; }

html { scroll-behavior: smooth; }

body {
  margin: 0;
  min-height: 100vh;
  min-height: 100dvh;
  display: flex;
  flex-direction: column;
  color: var(--ink);
  background:
    radial-gradient(circle at 110% -10%, rgba(110, 61, 134, 0.16), transparent 36%),
    radial-gradient(circle at -10% 20%, rgba(226, 179, 64, 0.35), transparent 32%),
    var(--sand);
}

body.page-sheet { padding-bottom: 168px; }

h1, h2, h3 {
  font-family: Palatino, "Palatino Linotype", "Iowan Old Style", Georgia, serif;
  font-weight: 700;
  letter-spacing: -0.02em;
  line-height: 1.15;
}

h1 { font-size: clamp(2rem, 4vw, 3.4rem); margin: 0 0 0.4rem; }
h2 { font-size: 1.45rem; margin: 0 0 0.6rem; }
h3 { font-size: 1.2rem; margin: 0 0 0.4rem; }

p { line-height: 1.5; }

a { color: var(--purple-deep); }
a:hover { color: var(--purple); }

img { max-width: 100%; height: auto; }

button, input { font: inherit; color: inherit; }

.skip {
  position: absolute;
  left: 12px;
  top: -40px;
  background: var(--ink);
  color: white;
  padding: 8px 12px;
  z-index: 20;
}
.skip:focus { top: 12px; }

.install-banner {
  width: min(1120px, calc(100% - 28px));
  margin: 12px auto 0;
  padding: 14px 16px;
  border-radius: 18px;
  background: #4c2462;
  color: #fffaf1;
  box-shadow: var(--shadow);
  display: grid;
  gap: 12px;
}
.install-banner[hidden],
.install-help[hidden],
[data-install-done][hidden],
[data-install-howto][hidden],
[data-install-ios][hidden],
[data-install-android][hidden] {
  display: none !important;
}
.install-banner p { margin: 6px 0 0; }
.install-banner .muted { color: #e8d7ff; }
.install-actions { display: flex; flex-wrap: wrap; gap: 8px; }
.install-banner .button.ghost {
  color: #fffaf1;
  border-color: rgba(255, 250, 241, 0.45);
}
.install-banner .button.ghost:hover {
  background: rgba(255, 250, 241, 0.12);
  color: #fffaf1;
}
.install-card { margin-top: 16px; }
.install-card p { margin: 0 0 10px; }

html.is-standalone body {
  padding-top: env(safe-area-inset-top);
}
html.is-standalone .top {
  padding-top: calc(14px + env(safe-area-inset-top));
}
html.is-standalone .install-banner {
  display: none !important;
}

.top {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 14px 18px;
  position: sticky;
  top: 0;
  z-index: 10;
  background: rgba(243, 230, 200, 0.92);
  backdrop-filter: blur(10px);
  border-bottom: 1px solid rgba(110, 61, 134, 0.08);
}

.brand {
  display: flex;
  align-items: center;
  gap: 8px;
  color: var(--purple-deep);
  text-decoration: none;
  font-family: Palatino, Georgia, serif;
  font-size: 1.35rem;
  font-weight: 700;
}

.mark { width: 28px; height: 28px; }

.topnav { display: none; gap: 6px; }
.topnav a {
  text-decoration: none;
  color: var(--ink);
  padding: 8px 10px;
  border-radius: 999px;
}
.topnav a[aria-current="page"] {
  background: white;
  color: var(--purple-deep);
}

.tools { display: flex; align-items: center; gap: 8px; }

.langs { display: flex; gap: 2px; }
.langs a {
  text-decoration: none;
  font-size: 0.78rem;
  font-weight: 700;
  letter-spacing: 0.04em;
  color: var(--muted);
  padding: 6px 7px;
  border-radius: 8px;
}
.langs a[aria-current="true"] {
  background: var(--purple);
  color: white;
}

.account-link {
  display: grid;
  place-items: center;
  width: 36px;
  height: 36px;
  color: var(--purple-deep);
}
.account-link svg { width: 22px; height: 22px; }

.linkish {
  background: none;
  border: 0;
  padding: 6px 0;
  color: var(--purple-deep);
  text-decoration: underline;
  cursor: pointer;
}

main {
  width: min(1120px, calc(100% - 28px));
  margin: 0 auto;
  padding: 22px 0 36px;
  flex: 1 0 auto;
}

.flashes { width: min(1120px, calc(100% - 28px)); margin: 12px auto 0; }
.flash {
  margin: 0 0 8px;
  padding: 12px 14px;
  border-radius: 12px;
  background: white;
  border: 1px solid var(--line);
}
.flash.error { background: #fdecec; border-color: #e4b4b4; }
.flash.success { background: #e8f6ee; border-color: #b7dfc8; }

.hero, .narrow, .panel, .card, .prose {
  position: relative;
}

.hero { padding: 12px 0 8px; }
.hero.slim { padding-bottom: 0; }
.lead { font-size: 1.12rem; max-width: 42rem; color: var(--ink); }
.subtitle { margin: 0 0 0.6rem; color: var(--purple-deep); font-weight: 700; }
.kicker {
  margin: 0 0 0.35rem;
  color: var(--purple);
  font-weight: 700;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  font-size: 0.78rem;
}
.kicker a { color: inherit; text-decoration: none; }

.muted { color: var(--muted); }
.footnote { color: var(--muted); font-size: 0.92rem; }

.hero-photo, .sheet-photo, .diagram {
  display: block;
  background: white;
  border-radius: 16px;
  border: 1px solid var(--line);
}
.hero-photo { margin-top: 18px; }
.diagram { width: min(100%, 280px); margin: 4px auto 12px; }
.diagram.wide { width: min(100%, 820px); margin: 8px 0 14px; }
.sheet-photo { width: 100%; margin-top: 8px; }

figure { margin: 0 0 18px; }
figcaption { color: var(--muted); font-size: 0.92rem; margin-top: 6px; }

.actions { display: flex; flex-wrap: wrap; gap: 10px; align-items: center; margin: 14px 0; }

.button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 48px;
  padding: 0 18px;
  border-radius: 999px;
  border: 1.5px solid var(--purple);
  background: var(--purple);
  color: white;
  text-decoration: none;
  font-weight: 700;
  cursor: pointer;
}
.button:hover { background: var(--purple-deep); color: white; }
.button.ghost { background: transparent; color: var(--purple-deep); }
.button.ghost:hover { background: white; color: var(--purple-deep); }
.button.danger { background: transparent; color: var(--danger); border-color: #e4b4b4; }
.button.danger:hover { background: #fdecec; color: var(--danger); }

.cards { display: grid; gap: 14px; margin: 18px 0; }
.cards.three { grid-template-columns: 1fr; }

.card, .panel {
  background: var(--paper);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 16px 16px 18px;
}
.panel { margin: 14px 0; }
.panel-head, .setup-head {
  display: flex;
  justify-content: space-between;
  gap: 12px;
  align-items: baseline;
}
.setup-head { align-items: center; justify-content: flex-start; margin-bottom: 8px; }
.setup-head h2 { margin: 0; font-size: 1.25rem; }

.card.stat .big, .detail-head h1 {
  font-variant-numeric: tabular-nums;
}
.big {
  font-family: Palatino, Georgia, serif;
  font-size: 2.6rem;
  margin: 0;
  line-height: 1;
}
.big a { text-decoration: none; color: inherit; }
.big small, .scorelink small, .series-list strong small, .detail-head h1 small, .bars b small {
  font-family: "Avenir Next", "Segoe UI", sans-serif;
  font-size: 0.95rem;
  color: var(--muted);
  font-weight: 600;
  margin-left: 4px;
}

.badge {
  flex: 0 0 auto;
  width: 32px;
  height: 32px;
  display: grid;
  place-items: center;
  border-radius: 50%;
  background: var(--purple);
  color: white;
  font-weight: 700;
}

.figures { display: grid; gap: 14px; }
.note { color: var(--ink); background: #fff6e4; border-radius: 12px; padding: 10px 12px; }
.legend { color: var(--muted); font-size: 0.92rem; margin-top: 0; }
.note-block {
  background: white;
  border-radius: 12px;
  padding: 10px 12px;
  border: 1px solid var(--line);
}

.narrow { width: min(520px, 100%); margin: 0 auto; }
.narrow.wide { width: min(760px, 100%); }
.stack { display: grid; gap: 12px; }
label { display: grid; gap: 6px; font-weight: 700; }
label small { font-weight: 500; color: var(--muted); }
input[type="text"], input[type="email"], input[type="password"], input[type="date"] {
  width: 100%;
  min-height: 48px;
  padding: 10px 12px;
  border-radius: 12px;
  border: 1.5px solid var(--line);
  background: white;
}
input:focus-visible, button:focus-visible, a:focus-visible {
  outline: 3px solid var(--purple);
  outline-offset: 2px;
}
.switch { color: var(--muted); }

.sheet-meta { display: grid; gap: 12px; margin-bottom: 14px; }
.dist-row {
  display: grid;
  grid-template-columns: 52px 1fr;
  gap: 8px;
  align-items: center;
  margin: 8px 0;
}
.dist-group-split + .dist-group-split {
  margin-top: 12px;
  padding-top: 12px;
  border-top: 1.5px solid var(--line);
}
.dist { font-weight: 700; }
.scores { display: grid; grid-template-columns: repeat(4, 1fr); gap: 6px; }
.scores.three { grid-template-columns: repeat(3, 1fr); }
.score { position: relative; }
.score input {
  position: absolute;
  opacity: 0;
  width: 1px;
  height: 1px;
}
.score span {
  display: grid;
  place-items: center;
  min-height: 52px;
  border-radius: 12px;
  border: 1.5px solid var(--line);
  background: white;
  font-weight: 800;
  font-size: 1.15rem;
  cursor: pointer;
}
.score input:focus-visible + span { outline: 3px solid var(--purple); outline-offset: 2px; }
.score input:checked + span { color: white; border-color: transparent; }
.score.p0 input:checked + span, .pill.p0, .chips .p0 { background: var(--zero); color: white; }
.score.p1 input:checked + span, .pill.p1, .chips .p1 { background: var(--low); color: white; }
.score.p3 input:checked + span, .pill.p3, .chips .p3 { background: var(--mid); color: white; }
.score.p5 input:checked + span, .pill.p5, .chips .p5 { background: var(--good); color: white; }

.subtotal { display: flex; justify-content: flex-end; gap: 6px; align-items: baseline; margin-bottom: 0; }
.subtotal strong { font-size: 1.3rem; font-variant-numeric: tabular-nums; }
.subtotal span, .subtotal { color: var(--muted); }

.totalbar {
  position: fixed;
  z-index: 15;
  left: 12px;
  right: 12px;
  bottom: calc(var(--tab) + env(safe-area-inset-bottom));
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 12px;
  padding: 10px 12px;
  background: var(--ink);
  color: white;
  border-radius: 18px;
  box-shadow: var(--shadow);
}
.totalbar strong {
  font-family: Palatino, Georgia, serif;
  font-size: 1.8rem;
  margin: 0 4px;
}
.totalbar small { display: block; color: #efe4cf; font-size: 0.82rem; }
.total-label { color: #efe4cf; font-size: 0.82rem; }
.totalbar .button { background: white; color: var(--purple-deep); border-color: white; }
.danger-form { margin: 18px 0 80px; }

.chips { display: flex; flex-wrap: wrap; gap: 8px; padding: 0; list-style: none; }
.chips li {
  display: flex;
  gap: 6px;
  align-items: baseline;
  border-radius: 999px;
  padding: 6px 12px;
  font-weight: 700;
}
.readout { list-style: none; padding: 0; margin: 0; display: grid; gap: 8px; }
.readout li { display: flex; justify-content: space-between; align-items: center; }
.pill {
  display: inline-grid;
  place-items: center;
  min-width: 44px;
  height: 44px;
  border-radius: 12px;
  font-size: 1.1rem;
}

.board, .series-list, .friend-list, .friend-pick, .setup-best, .bars, .mix-legend {
  list-style: none;
  padding: 0;
  margin: 0;
}
.board li, .friend-list li, .setup-best li {
  display: flex;
  gap: 12px;
  align-items: center;
  padding: 10px 0;
  border-top: 1px solid var(--line);
}
.board li:first-child, .friend-list li:first-child, .setup-best li:first-child { border-top: 0; }
.rank {
  width: 32px;
  height: 32px;
  flex: 0 0 auto;
  display: grid;
  place-items: center;
  border-radius: 50%;
  background: #f4e8ff;
  color: var(--purple-deep);
  font-weight: 800;
}
.board li div, .friend-list li div, .setup-best li div { flex: 1; min-width: 0; }
.board small, .friend-list small, .setup-best small { display: block; color: var(--muted); }
.board em {
  font-style: normal;
  font-size: 0.75rem;
  font-weight: 700;
  color: var(--purple);
  margin-left: 6px;
}
.scorelink, .setup-best a {
  font-family: Palatino, Georgia, serif;
  font-size: 1.7rem;
  text-decoration: none;
  color: var(--ink);
  font-variant-numeric: tabular-nums;
}
.setup-best img {
  width: 64px;
  height: 64px;
  border-radius: 12px;
  background: white;
  border: 1px solid var(--line);
}
.series-list li { padding: 8px 0; border-top: 1px solid var(--line); }
.series-list a {
  display: grid;
  grid-template-columns: minmax(110px, 1fr) minmax(60px, 2fr) auto;
  gap: 10px;
  align-items: center;
  text-decoration: none;
  color: inherit;
}
.series-list strong { font-variant-numeric: tabular-nums; }
.snip { margin: 4px 0 0; color: var(--muted); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }

.tabs { display: flex; gap: 6px; margin-top: 12px; }
.tabs a {
  text-decoration: none;
  color: var(--ink);
  background: transparent;
  border-radius: 999px;
  padding: 8px 14px;
  border: 1px solid transparent;
}
.tabs a[aria-current="page"] { background: white; border-color: var(--line); color: var(--purple-deep); font-weight: 700; }

.mix { display: flex; height: 16px; border-radius: 999px; overflow: hidden; background: var(--sand-deep); }
.mix i { display: block; height: 100%; }
.mix .p5, .mix-legend .p5 { background: var(--good); }
.mix .p3, .mix-legend .p3 { background: var(--mid); }
.mix .p1, .mix-legend .p1 { background: var(--low); }
.mix .p0, .mix-legend .p0 { background: #cfc3b0; }
.mix-legend { display: flex; flex-wrap: wrap; gap: 12px; margin-top: 10px; }
.mix-legend i { width: 12px; height: 12px; border-radius: 50%; display: inline-block; margin-right: 4px; }

.bars li { display: grid; grid-template-columns: 88px 1fr auto; gap: 8px; align-items: center; margin: 8px 0; }
.track { display: block; height: 10px; background: #efe2c6; border-radius: 99px; overflow: hidden; }
.track > span { display: block; height: 100%; background: var(--purple); border-radius: 99px; }
.track.slim { height: 8px; }
.split { display: grid; gap: 14px; }
.tie { font-size: 0.92rem; }

.friend-pick a {
  display: block;
  padding: 12px 0;
  border-top: 1px solid var(--line);
  text-decoration: none;
  font-weight: 700;
}
.link-row { display: flex; gap: 8px; flex-wrap: wrap; align-items: flex-start; }
.link-row input { flex: 1 1 220px; }
.invite-link {
  flex: 1 1 220px;
  display: block;
  padding: 12px 14px;
  border: 1.5px solid var(--purple);
  border-radius: 14px;
  background: white;
  color: var(--purple-deep);
  text-decoration: none;
  word-break: break-all;
  overflow-wrap: anywhere;
  font-weight: 600;
  line-height: 1.35;
}
.invite-link:hover { color: var(--purple); }
.score-explain { display: grid; gap: 12px; }
.source { color: var(--muted); }

.scope-panel { margin-top: 8px; }
.scope-pills {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin: 10px 0 14px;
}
.scope-pill {
  display: inline-flex;
  align-items: center;
  min-height: 44px;
  padding: 0 16px;
  border-radius: 999px;
  border: 1.5px solid var(--line);
  background: white;
  color: var(--ink);
  text-decoration: none;
  font-weight: 700;
}
.scope-pill.is-active {
  border-color: var(--purple);
  background: #f7eefc;
  color: var(--purple-deep);
}
.practice-filters {
  display: grid;
  gap: 14px;
  margin-top: 14px;
}
.practice-filters label {
  display: grid;
  gap: 8px;
  font-weight: 700;
  font-size: 1.05rem;
}
.practice-filters select {
  border: 1.5px solid var(--purple);
  border-radius: 16px;
  padding: 16px 18px;
  background: white;
  width: 100%;
  min-height: 56px;
  font-size: 1.05rem;
  font-weight: 600;
  color: var(--ink);
}
.practice-filters-large {
  padding: 16px;
  border-radius: 18px;
  background: #f7eefc;
  border: 1.5px solid #e2cceb;
}
.progress-chart {
  display: block;
  width: 100%;
  height: auto;
  margin-top: 10px;
  border: 1px solid var(--line);
  border-radius: 16px;
}
@media (min-width: 800px) {
  .practice-filters {
    grid-template-columns: 1fr 1fr auto;
    align-items: end;
  }
}
.friends-invite {
  margin-bottom: 36px;
}
.page-friends .friends-invite + h2 {
  margin-top: 8px;
}
.site-footer {
  width: min(1120px, calc(100% - 28px));
  margin: auto auto 0;
  padding: 18px 0 calc(18px + env(safe-area-inset-bottom));
  color: var(--muted);
  font-size: 0.92rem;
  line-height: 1.45;
  flex: 0 0 auto;
}
.site-footer p { margin: 0 0 6px; }
.site-footer .credit {
  color: var(--ink);
  font-weight: 600;
}
.custom-figure-list {
  display: grid;
  gap: 8px;
}
.custom-figure-option {
  display: grid;
  grid-template-columns: auto 1fr;
  gap: 10px;
  align-items: start;
  margin: 0;
  padding: 10px 12px;
  border: 1px solid var(--line);
  border-radius: 14px;
  background: white;
  cursor: pointer;
}
.custom-figure-option input { margin-top: 4px; }
.custom-figure-option span {
  display: grid;
  gap: 2px;
}
.custom-figure-option small {
  color: var(--muted);
  font-weight: 500;
}
.readout-attempts {
  display: inline-flex;
  flex-wrap: wrap;
  gap: 6px;
  justify-content: flex-end;
}
.dist small {
  display: block;
  color: var(--muted);
  font-weight: 600;
  font-size: 0.8rem;
}
.game-setup {
  display: grid;
  gap: 14px;
  margin: 18px 0 24px;
}
.game-setup select {
  border: 1px solid var(--line);
  border-radius: 14px;
  padding: 12px 14px;
  background: var(--paper);
  width: 100%;
  max-width: 180px;
}
.custom-tries {
  margin-top: 8px;
  padding: 14px;
  border-radius: 16px;
  background: #f7eefc;
  border: 1.5px solid #e2cceb;
}
.custom-tries legend {
  font-size: 1.05rem;
  color: var(--purple-deep);
}
.custom-tries .game-format-option span {
  min-width: 44px;
  justify-content: center;
  font-size: 1.05rem;
  font-weight: 800;
}
.game-setup[hidden],
.game-board[hidden],
.game-intro[hidden],
.game-lineups[hidden],
.game-history[hidden] {
  display: none !important;
}
.game-page.is-playing .game-intro,
.game-page.is-playing .game-setup,
.game-page.is-playing .game-lineups,
.game-page.is-playing .game-history {
  display: none !important;
}
.game-setup label { display: grid; gap: 6px; font-weight: 700; }
.game-setup input {
  border: 1px solid var(--line);
  border-radius: 14px;
  padding: 12px 14px;
  background: var(--paper);
}
.game-target { text-align: center; margin: 0 0 8px; font-weight: 700; }
.game-winner {
  text-align: center;
  font-family: Palatino, "Palatino Linotype", Georgia, serif;
  font-size: clamp(1.4rem, 4vw, 2rem);
  font-weight: 700;
  color: var(--purple-deep);
  margin: 0 0 12px;
}
.game-result {
  position: fixed;
  inset: 0;
  z-index: 40;
  display: grid;
  place-items: center;
  padding: 24px;
  background: rgba(44, 36, 22, 0.45);
  backdrop-filter: blur(4px);
}
.game-result[hidden] { display: none !important; }
.game-result-card {
  width: min(360px, 100%);
  text-align: center;
  padding: 28px 22px;
  border-radius: 28px;
  background: var(--paper);
  box-shadow: var(--shadow);
  animation: game-result-pop 0.45s ease-out;
}
.game-result.is-win .game-result-card {
  outline: 3px solid #6e3d86;
  background: linear-gradient(180deg, #f7eefc, #fffaf1);
}
.game-result.is-lose .game-result-card {
  outline: 3px solid #b7a88d;
  background: linear-gradient(180deg, #efe8da, #fffaf1);
}
.game-result.is-draw .game-result-card {
  outline: 3px solid var(--purple);
  background: linear-gradient(180deg, #f7eefc, #fffaf1);
}
.game-result-emoji {
  font-size: clamp(3.5rem, 16vw, 5rem);
  line-height: 1;
  margin: 0 0 12px;
}
.game-result.is-win .game-result-emoji { animation: game-happy 0.9s ease-in-out infinite; }
.game-result.is-lose .game-result-emoji { animation: game-sad 1.2s ease-in-out infinite; }
.game-result-text {
  margin: 0;
  font-family: Palatino, "Palatino Linotype", Georgia, serif;
  font-size: clamp(1.4rem, 5vw, 1.9rem);
  font-weight: 700;
  color: var(--purple-deep);
  line-height: 1.25;
}
@keyframes game-result-pop {
  from { opacity: 0; transform: scale(0.86) translateY(12px); }
  to { opacity: 1; transform: scale(1) translateY(0); }
}
@keyframes game-happy {
  0%, 100% { transform: translateY(0) rotate(-4deg) scale(1); }
  50% { transform: translateY(-10px) rotate(4deg) scale(1.08); }
}
@keyframes game-sad {
  0%, 100% { transform: translateY(0); opacity: 1; }
  50% { transform: translateY(8px); opacity: 0.85; }
}
@media (prefers-reduced-motion: reduce) {
  .game-result-card,
  .game-result.is-win .game-result-emoji,
  .game-result.is-lose .game-result-emoji {
    animation: none;
  }
}
.game-teams {
  display: grid;
  gap: 14px;
}
.game-team { text-align: center; }
.game-team.is-winner {
  outline: 2px solid var(--purple);
  background: #f7eefc;
}
.game-score {
  font-size: clamp(3.4rem, 14vw, 5.5rem);
  font-weight: 800;
  line-height: 1;
  margin: 8px 0 16px;
  color: var(--purple-deep);
}
.game-adds {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  justify-content: center;
}
.game-actions {
  justify-content: center;
  margin-top: 18px;
  flex-wrap: wrap;
}
.game-actions .button.danger {
  color: var(--danger);
  border-color: #e4b4b4;
}
.game-format {
  border: 0;
  margin: 0 0 16px;
  padding: 0;
}
.game-format legend {
  font-weight: 700;
  margin-bottom: 8px;
}
.game-format-options {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}
.game-format-option {
  display: inline-flex;
  align-items: center;
  gap: 0;
  margin: 0;
  cursor: pointer;
}
.game-format-option input {
  position: absolute;
  opacity: 0;
  pointer-events: none;
}
.game-format-option span {
  display: inline-flex;
  align-items: center;
  min-height: 40px;
  padding: 0 14px;
  border-radius: 999px;
  border: 1.5px solid var(--line);
  background: white;
  color: var(--ink);
  font-weight: 600;
}
.game-format-option input:checked + span {
  border-color: var(--purple);
  background: #f7eefc;
  color: var(--purple-deep);
}
.game-format-option input:focus-visible + span {
  outline: 2px solid var(--purple);
  outline-offset: 2px;
}
.game-free-names,
.game-rosters {
  display: grid;
  gap: 12px;
  margin-bottom: 16px;
}
.game-roster h3 {
  margin: 0 0 8px;
  font-size: 1rem;
}
.game-roster-fields {
  display: grid;
  gap: 10px;
}
.game-player-field {
  display: grid;
  gap: 6px;
  margin: 0;
}
.game-player-field > span {
  font-size: 0.92rem;
  color: var(--muted);
}
.game-player-box {
  position: relative;
}
.game-player-box input {
  width: 100%;
}
.game-suggest {
  position: absolute;
  z-index: 5;
  left: 0;
  right: 0;
  top: calc(100% + 4px);
  margin: 0;
  padding: 6px;
  border: 1px solid var(--line);
  border-radius: 12px;
  background: white;
  box-shadow: var(--shadow);
  max-height: 220px;
  overflow: auto;
}
.game-suggest-item {
  display: block;
  width: 100%;
  text-align: left;
  border: 0;
  background: transparent;
  color: var(--ink);
  padding: 10px 12px;
  border-radius: 8px;
  cursor: pointer;
  font: inherit;
}
.game-suggest-item:hover,
.game-suggest-item:focus {
  background: #f7eefc;
  color: var(--purple-deep);
  outline: none;
}
.game-format-badge {
  display: inline-block;
  margin: 0 0 10px;
  padding: 4px 12px;
  border-radius: 999px;
  background: #f7eefc;
  color: var(--purple-deep);
  font-weight: 700;
  font-size: 0.92rem;
}
.game-lineups { margin-top: 28px; }
.game-lineup-list {
  list-style: none;
  margin: 0;
  padding: 0;
}
.game-lineup-list li {
  display: grid;
  gap: 4px;
  padding: 12px 0;
  border-top: 1px solid var(--line);
}
.game-lineup-list li:first-child { border-top: 0; }
.game-lineup-format {
  color: var(--muted);
  font-size: 0.9rem;
  font-weight: 700;
}
.game-lineup-list em {
  color: var(--purple-deep);
  font-style: normal;
  font-weight: 600;
}
.game-history { margin-top: 28px; }
.game-history-list {
  list-style: none;
  margin: 0;
  padding: 0;
}
.game-history-list li {
  display: flex;
  flex-direction: column;
  align-items: stretch;
  gap: 10px;
  padding: 14px 0;
  border-top: 1px solid var(--line);
}
.game-history-list li:first-child { border-top: 0; }
.game-history-info {
  display: grid;
  gap: 4px;
  min-width: 0;
}
.game-history-link {
  display: grid;
  gap: 4px;
  text-decoration: none;
  color: inherit;
}
.game-history-info span {
  color: var(--muted);
  font-size: 0.92rem;
}
.game-history-info strong {
  display: block;
  line-height: 1.35;
  overflow-wrap: anywhere;
  word-break: break-word;
  font-variant-numeric: tabular-nums;
}
.game-history-actions {
  display: flex;
  flex-direction: row;
  flex-wrap: nowrap;
  gap: 8px;
  align-items: center;
  justify-content: flex-start;
  width: auto;
  align-self: flex-start;
}
.game-btn-open-form,
.game-btn-delete-form {
  margin: 0;
  flex: 0 0 auto;
  width: auto;
  display: inline-block;
}
.game-history-actions .button.game-history-btn {
  display: inline-flex !important;
  align-items: center;
  justify-content: center;
  width: 96px !important;
  min-width: 96px !important;
  max-width: 96px !important;
  min-height: 40px;
  padding: 8px 10px !important;
  font-size: 0.92rem;
  box-sizing: border-box;
  flex: none !important;
}
.game-history em {
  font-style: normal;
  font-weight: 700;
  line-height: 1.3;
  overflow-wrap: anywhere;
}
.game-history .game-winner-me,
.game-winner.game-winner-me { color: var(--good); }
.game-history .game-winner-them,
.game-winner.game-winner-them { color: var(--danger); }
.game-timeline {
  list-style: none;
  margin: 0;
  padding: 0;
}
.game-step {
  display: grid;
  grid-template-columns: 36px 1fr auto;
  gap: 12px;
  align-items: center;
  padding: 10px 0;
  border-top: 1px solid var(--line);
}
.game-step:first-child { border-top: 0; }
.game-step-index {
  width: 36px;
  height: 36px;
  border-radius: 50%;
  display: grid;
  place-items: center;
  background: var(--sand-deep);
  font-weight: 700;
}
.game-step.side-me .game-step-index { background: #e7d5f3; color: var(--purple-deep); }
.game-step.side-opponent .game-step-index { background: #f0e2b8; color: #6a4c12; }
.game-step div { display: grid; gap: 2px; }
.game-step span { color: var(--muted); }
.game-step-score {
  font-variant-numeric: tabular-nums;
  font-weight: 800;
  color: var(--purple-deep);
}

.tabbar {
  position: fixed;
  left: 0;
  right: 0;
  bottom: 0;
  z-index: 12;
  display: grid;
  grid-template-columns: repeat(5, 1fr);
  background: #fffaf1;
  border-top: 1px solid var(--line);
  padding: 6px 6px calc(6px + env(safe-area-inset-bottom));
}
.tabbar.tabbar-guest { grid-template-columns: repeat(2, 1fr); }
.tabbar a {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 2px;
  text-decoration: none;
  color: var(--muted);
  font-size: 0.72rem;
  font-weight: 700;
  min-height: 48px;
  justify-content: center;
}
.tabbar svg { width: 22px; height: 22px; }
.tabbar a[aria-current="page"] { color: var(--purple-deep); }

@media (min-width: 800px) {
  .cards.three { grid-template-columns: repeat(3, 1fr); }
  .figures { grid-template-columns: 1fr 1fr; }
  .split { grid-template-columns: 1fr 1fr; }
  .sheet-meta { grid-template-columns: 200px 1fr; }
  .topnav { display: flex; }
  .account-link { display: none; }
  .tabbar { display: none; }
  body.page-sheet { padding-bottom: 96px; }
  .totalbar {
    left: 50%;
    right: auto;
    transform: translateX(-50%);
    width: min(720px, calc(100% - 32px));
    bottom: 16px;
  }
  .score-explain { grid-template-columns: 1fr 1fr; }
  .game-teams { grid-template-columns: 1fr 1fr; }
  .game-history-list li {
    flex-direction: row;
    align-items: center;
    gap: 16px;
  }
  .game-history-info { flex: 1; }
  .game-history-actions { flex: 0 0 auto; }
  .game-history-actions .button.game-history-btn {
    min-height: 36px;
  }
}

@media (max-width: 799px) {
  .tools form, .tools > .linkish { display: none; }
  body { padding-bottom: calc(var(--tab) + env(safe-area-inset-bottom)); }
  .page-landing, .page-login, .page-register, .page-join, .page-error { padding-bottom: calc(var(--tab) + env(safe-area-inset-bottom)); }
  .site-footer {
    padding-bottom: 18px;
  }
}

@media (prefers-reduced-motion: reduce) {
  html { scroll-behavior: auto; }
}
