:root {
  --blue: #0a3d91;
  --blue-dark: #072c6b;
  --blue-bright: #1e6fe0;
  --ice: #e8f1fc;
  --white: #ffffff;
  --ink: #0e2244;
  --line: #c5d7f2;
  --muted: #4d648a;
  --finish: #0c8a38;
  --bogey: #d21b28;
}

* { box-sizing: border-box; }

html {
  -webkit-text-size-adjust: 100%;
  text-size-adjust: 100%;
}
html, body {
  margin: 0;
  min-height: 100%;
  background: var(--ice);
  color: var(--ink);
  font-family: system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
}

a { color: var(--blue); }

h1, h2, h3 { font-weight: 700; letter-spacing: -0.02em; }

.top {
  display: flex;
  justify-content: space-between;
  gap: 16px;
  align-items: center;
  padding: calc(14px + env(safe-area-inset-top)) calc(132px + env(safe-area-inset-right)) 14px calc(20px + env(safe-area-inset-left));
  background: var(--white);
  border-bottom: 4px solid var(--blue);
}

.brand {
  display: inline-flex;
  align-items: center;
  gap: 10px;
  color: var(--blue);
  font-weight: 800;
  font-size: 1.25rem;
  text-decoration: none;
  letter-spacing: -0.03em;
}
.brand-logo {
  width: 52px;
  height: 52px;
  object-fit: contain;
  flex: 0 0 auto;
}
.watermark {
  position: fixed;
  z-index: 0;
  left: 50%;
  top: 46%;
  width: min(92vmin, 860px);
  height: auto;
  transform: translate(-50%, -50%);
  opacity: 0.22;
  pointer-events: none;
  user-select: none;
}
.top,
main,
.fullscreen-btn {
  position: relative;
  z-index: 1;
}
body.login main {
  min-height: calc(100dvh - 92px);
  display: grid;
  align-content: center;
  justify-items: center;
}
body.login .narrow {
  width: min(520px, 100%);
  background: rgba(255, 255, 255, 0.9);
  border: 1px solid var(--line);
  border-radius: 12px;
  padding: 28px 28px 24px;
}

.top-actions { display: flex; flex-wrap: wrap; gap: 8px 14px; align-items: center; justify-content: flex-end; }
nav { display: flex; flex-wrap: wrap; gap: 4px 14px; align-items: center; }
nav a, nav .linkish { text-decoration: none; font-weight: 650; }

.inline { margin: 0; }

.linkish {
  background: none;
  border: 0;
  color: var(--blue);
  font: inherit;
  font-weight: 650;
  padding: 0;
  cursor: pointer;
}

main {
  padding: 24px max(16px, env(safe-area-inset-right)) calc(64px + env(safe-area-inset-bottom)) max(16px, env(safe-area-inset-left));
}
.page main { max-width: 1100px; margin: 0 auto; }
body.roster-page { background: #f3f3f3; }
body.roster-page main { max-width: 1180px; }
.roster {
  list-style: none;
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 34px 28px;
  margin: 8px 0 0;
  padding: 0;
}
.roster li { margin: 0; background: transparent; border: 0; padding: 0; }
.roster a {
  display: grid;
  gap: 14px;
  color: #161616;
  text-decoration: none;
  text-align: center;
}
.roster img, .roster .shot {
  width: 100%;
  aspect-ratio: 4 / 4.15;
  object-fit: cover;
  object-position: center 18%;
  background: #ececec;
  display: grid;
  place-items: center;
  color: #8a8a8a;
  font-size: 3rem;
  font-weight: 650;
}
.roster .name { font-size: 1.55rem; font-weight: 500; letter-spacing: 0; }
.roster li.off { opacity: 0.45; }
.roster-divider {
  display: flex;
  align-items: center;
  gap: 16px;
  margin: 44px 0 8px;
  color: #8a8a8a;
  font-weight: 650;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  font-size: 0.85rem;
}
.roster-divider::before, .roster-divider::after { content: ""; flex: 1; border-top: 2px solid #cfcfcf; }
.tournament main { max-width: 1440px; }
body.board,
body.board.immersive {
  position: fixed;
  inset: 0;
  width: 100%;
  height: auto;
  max-height: none;
  min-height: 0;
  overflow: hidden;
  overflow-anchor: none;
  display: flex;
  flex-direction: column;
  background: var(--ice);
}
html.keyboard-open body.board {
  top: var(--board-shift, 0px);
  height: var(--board-height, 100%);
  bottom: auto;
  min-height: 0;
}
.board main {
  max-width: none;
  margin: 0;
  flex: 1 1 auto;
  min-height: 0;
  height: auto;
  overflow: hidden;
  display: flex;
  flex-direction: column;
  box-sizing: border-box;
  padding: 8px 8px calc(12px + env(safe-area-inset-bottom));
}
.board .desk { margin-top: 4px; flex: 1; min-height: 0; display: flex; flex-direction: column; }
.board .kicker { margin: 0 0 6px; }

.lead { color: var(--muted); max-width: 62ch; }
.muted { color: var(--muted); }
.kicker { color: var(--blue); font-weight: 700; margin-top: 0; }

.flash {
  max-width: 1100px;
  margin: 12px auto 0;
  padding: 12px 16px;
  background: var(--white);
  border-left: 6px solid var(--blue);
  font-weight: 650;
}
.flash.warn { border-left-color: var(--blue-dark); background: #d7e6fa; }
.flash.ok { border-left-color: var(--finish); background: #d9f5e3; color: #085c26; }
.flash.bad { border-left-color: var(--bogey); background: #ffd9dc; color: #8d1018; }

.flash-layer {
  position: fixed;
  inset: 0;
  z-index: 70;
  display: grid;
  place-items: center;
  padding: 16px;
  background: rgba(7, 22, 56, 0.45);
}
.flash-window {
  width: min(560px, 100%);
  background: var(--white);
  color: var(--ink);
  border: 6px solid var(--blue);
  border-radius: 10px;
  padding: 22px 24px 20px;
  box-shadow: 0 22px 60px rgba(0, 0, 0, 0.35);
  display: grid;
  gap: 16px;
  justify-items: center;
  text-align: center;
}
.flash-window p {
  margin: 0;
  font-size: clamp(1.2rem, 2.4vw, 1.6rem);
  font-weight: 700;
  color: var(--blue);
  overflow-wrap: anywhere;
}
.flash-window button {
  min-width: 10rem;
  min-height: 52px;
  font-size: 1.2rem;
  background: var(--blue);
  color: var(--white);
  border-color: var(--blue);
}
.flash-window.warn { border-color: var(--blue-dark); background: #e9f1fc; }
.flash-window.ok { border-color: var(--finish); }
.flash-window.ok p { color: #085c26; }
.flash-window.ok button { background: var(--finish); border-color: var(--finish); }
.flash-window.bad { border-color: var(--bogey); background: #fff1f2; }
.flash-window.bad p { color: #8d1018; }
.flash-window.bad button { background: var(--bogey); border-color: var(--bogey); }

.menu, .split { display: grid; gap: 16px; }
.menu { grid-template-columns: repeat(auto-fit, minmax(160px, 1fr)); margin: 20px 0 32px; }
.menu a, .panel, .pairing, .statgrid article {
  background: var(--white);
  border: 1px solid var(--line);
  border-radius: 8px;
}
.menu a {
  display: block;
  padding: 22px 16px;
  text-decoration: none;
  font-size: 1.15rem;
  font-weight: 750;
  color: var(--blue-dark);
}
.menu a:hover { border-color: var(--blue); }

.split { grid-template-columns: 1.3fr 0.9fr; align-items: start; }
.narrow { max-width: 520px; }
.settings { max-width: 760px; }
.club-logo {
  width: 112px;
  height: 112px;
  object-fit: contain;
  display: block;
  margin: 0 0 12px;
}
.logo-form { margin-bottom: 8px; }
.mode-line {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 12px;
}
.hotkeys {
  display: grid;
  grid-template-columns: repeat(6, minmax(0, 1fr));
  gap: 12px 10px;
}
.bull-line {
  display: grid;
  grid-template-columns: auto minmax(8rem, 14rem);
  gap: 12px 18px;
  align-items: end;
}
.hotkeys label { gap: 4px; }
.stat-picks {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(9rem, 1fr));
  gap: 8px 16px;
}
@media (max-width: 520px) {
  .stat-picks { grid-template-columns: 1fr 1fr; }
}
.hotkeys .fixed-key span {
  display: flex;
  align-items: center;
  justify-content: center;
  min-height: 2.6rem;
  border: 1px solid var(--line);
  border-radius: 6px;
  background: #f4f7fb;
  text-align: center;
}
.hotkeys input {
  padding: 8px 4px;
  text-align: center;
  font-variant-numeric: tabular-nums;
  font-weight: 750;
}
.panel { padding: 16px 18px 20px; }

label, .seed { display: grid; gap: 6px; font-weight: 650; }
.stack { display: grid; gap: 14px; }
input, select, button {
  font: inherit;
  color: var(--ink);
}
input, select {
  border: 1px solid var(--line);
  border-radius: 6px;
  padding: 10px 12px;
  background: var(--white);
  max-width: 100%;
}
.stack input, .stack select { width: 100%; min-width: 0; }
.stack input[type="checkbox"], .stack input[type="radio"] {
  width: 1.15rem;
  height: 1.15rem;
  padding: 0;
  flex: none;
}
.abort { margin: 0 0 16px; }
button.danger { background: var(--bogey); }
button, .ghost, .action {
  border-radius: 6px;
  border: 0;
  background: var(--blue);
  color: var(--white);
  padding: 10px 14px;
  font-weight: 700;
  cursor: pointer;
  text-decoration: none;
  display: inline-block;
}
.ghost {
  background: var(--white);
  color: var(--blue);
  border: 1px solid var(--blue);
}
.ghost.off { color: var(--muted); border-color: var(--line); }
.new-tournament { margin: 0 0 18px; }
.new-tournament > summary { list-style: none; width: fit-content; }
.new-tournament > summary::-webkit-details-marker { display: none; }
.new-tournament[open] > summary { margin-bottom: 14px; }
.tournament-create[open] > summary { display: none; }
.new-tournament .panel { max-width: 760px; }

.people, .matchlist { list-style: none; padding: 0; margin: 16px 0; }
.people li, .matchlist li {
  display: flex;
  justify-content: space-between;
  gap: 12px;
  align-items: center;
  background: var(--white);
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 12px 14px;
  margin-bottom: 8px;
}
.matchlist a {
  display: grid;
  grid-template-columns: 1fr auto 1fr;
  gap: 12px;
  flex: 1;
  text-decoration: none;
  color: var(--ink);
  align-items: center;
}
.matchlist a span { color: var(--blue); font-weight: 800; text-align: center; }
.matchlist small, .people a { color: var(--muted); }
.matchlist li.done { background: #ececec; border-color: #d5d5d5; }
.matchlist li.done a,
.matchlist li.done strong,
.matchlist li.done a span,
.matchlist li.done small { color: #8b8b8b; }
.matchlist li.done .done-mark { color: #0c8a38; font-weight: 800; }
.people a.ghost, .people a.person { color: var(--blue); }
.people a.person { color: var(--ink); }
.person-actions { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; }
.person-actions form { margin: 0; }

.seed {
  grid-template-columns: auto 1fr 88px;
  align-items: center;
  font-weight: 550;
}
fieldset { border: 1px solid var(--line); border-radius: 8px; display: grid; gap: 8px; }
legend { padding: 0 6px; color: var(--blue); font-weight: 700; }

.scoreboard {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 12px;
}
.scoreboard article {
  background: var(--white);
  border: 1px solid var(--line);
  border-radius: 10px;
  padding: 16px 18px 12px;
  min-height: 240px;
  min-width: 0;
}
.scoreboard article.turn {
  background: var(--blue);
  color: var(--white);
  border-color: var(--blue-dark);
}
.scoreboard header { display: flex; flex-wrap: wrap; justify-content: space-between; gap: 8px 12px; align-items: start; }
.who { display: flex; align-items: center; gap: 10px; min-width: 0; }
.who p { margin: 2px 0 0; }
.who h2 a { color: inherit; text-decoration: none; }
.person {
  display: flex;
  align-items: center;
  gap: 12px;
  min-width: 0;
  color: var(--ink);
  font-weight: 800;
  text-decoration: none;
}
.avatar {
  width: 48px;
  height: 48px;
  border-radius: 50%;
  object-fit: cover;
  background: var(--ice);
  flex: none;
  display: grid;
  place-items: center;
  color: var(--blue);
  font-weight: 800;
}
.portrait {
  width: 112px;
  height: 112px;
  border-radius: 12px;
  object-fit: cover;
  background: var(--ice);
}
.profile {
  max-width: 520px;
  margin: 0 auto 28px;
  background: #fff;
  border-radius: 22px;
  padding: 22px 16px 18px;
  box-shadow: 0 10px 30px rgba(10, 40, 90, 0.06);
}
.profile h1 { margin: 0 0 8px; font-size: 2.6rem; letter-spacing: -0.04em; }
.profile-photo {
  display: block;
  width: min(100%, 340px);
  max-height: 320px;
  margin: 8px auto 12px;
  object-fit: contain;
}
.profile-links { margin: 0 0 16px; color: var(--muted); font-size: 0.92rem; }
.profile-links a { font-weight: 700; }
.profile-links form.inline { display: inline; }
.profile-links button.linkish { min-height: 0; padding: 0; font-weight: 700; }
.profile-card, .profile-trio section, .profile-rivals section {
  background: #f4f6f8;
  border-radius: 16px;
}
.profile-card { margin: 0 0 12px; padding: 0; }
.profile-card summary {
  list-style: none;
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 14px 16px;
  cursor: pointer;
}
.profile-card summary::-webkit-details-marker { display: none; }
.profile-card summary::after {
  content: "";
  width: 8px;
  height: 8px;
  margin-left: auto;
  border-right: 2px solid #9aa3af;
  border-bottom: 2px solid #9aa3af;
  transform: rotate(45deg);
}
.profile-card[open] summary::after { transform: rotate(225deg); margin-top: 6px; }
.profile-copy { display: grid; }
.profile-copy small, .profile-trio small, .profile-card .hint {
  color: #8b93a0;
  font-size: 0.82rem;
  font-weight: 650;
}
.profile-copy strong { font-size: 1.7rem; line-height: 1.1; color: #111; }
.profile-card dl, .profile-card ul, .profile-card p, .profile-card form {
  margin: 0 16px 14px;
}
.profile-card dl { display: grid; gap: 8px; }
.profile-card dl div { display: flex; justify-content: space-between; gap: 12px; }
.profile-card dt { color: #8b93a0; }
.profile-card dd { margin: 0; font-weight: 800; }
.profile-card ul { list-style: none; padding: 0; display: grid; gap: 8px; }
.profile-card li { display: flex; justify-content: space-between; gap: 10px; }
.profile-card li span { color: #8b93a0; font-size: 0.82rem; }
.profile-trio { display: grid; grid-template-columns: 1fr 1fr 1.2fr; gap: 10px; margin-bottom: 18px; }
.profile-trio section { position: relative; min-height: 92px; padding: 12px 12px 28px; }
.profile-trio strong { display: block; font-size: 1.7rem; line-height: 1.1; }
.profile-trio em { display: block; color: #8b93a0; font-style: normal; font-size: 0.78rem; font-weight: 700; }
.profile h2 { margin: 8px 0 12px; font-size: 1.35rem; }
.profile-ico {
  width: 34px;
  height: 34px;
  border-radius: 999px;
  display: grid;
  place-items: center;
  flex: none;
  background: #fff;
}
.profile-trio .profile-ico { position: absolute; right: 10px; bottom: 10px; width: 28px; height: 28px; }
.profile-ico.target { box-shadow: inset 0 0 0 6px #ff4d6d, inset 0 0 0 10px #fff, inset 0 0 0 14px #ff4d6d; }
.profile-ico.trophy { background: #f5b942; }
.profile-ico.pad { background: #7c5cfc; }
.profile-ico.chart { background: #3ddc6a; }
.profile-ico.score { background: #ff4d6d; color: #fff; font-size: 0.72rem; font-weight: 800; }
.profile-ico.bolt { background: #ffb020; }
.profile-rivals { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; margin-top: 8px; }
.profile-rivals section { padding: 12px; }
.profile-rivals h3 { margin: 0 0 10px; font-size: 0.72rem; letter-spacing: 0.04em; text-transform: uppercase; color: #667; }
.profile-rivals ol { list-style: none; margin: 0; padding: 0; display: grid; gap: 8px; }
.profile-rivals li { display: flex; align-items: center; gap: 8px; }
.profile-rivals b { font-weight: 750; }
.profile-rivals em { margin-left: auto; font-style: normal; color: #667; font-weight: 700; }
.rank {
  width: 28px;
  height: 28px;
  border-radius: 999px;
  display: grid;
  place-items: center;
  color: #fff;
  font-size: 0.75rem;
  font-weight: 800;
  flex: none;
}
.rank.win { background: #22c55e; }
.rank.loss { background: #fb7185; }
.photo-fold form { display: grid; gap: 8px; }
.photo-fold button { justify-self: start; }
.player-head { display: flex; align-items: center; gap: 16px; margin-bottom: 8px; }
.player-head h1 { margin: 0 0 8px; }
.photo-form { max-width: 420px; margin: 8px 0 18px; }
.badges { display: flex; gap: 6px; flex-wrap: wrap; justify-content: flex-end; }
.scoreboard h2 { margin: 0; min-width: 0; overflow-wrap: anywhere; font-size: 1.6rem; }
.scoreboard header p { margin: 4px 0 0; opacity: 0.8; }
.badge {
  background: var(--white);
  color: var(--blue);
  border-radius: 999px;
  padding: 4px 10px;
  font-size: 0.85rem;
  font-weight: 800;
}
.badge.quiet {
  background: var(--blue);
  color: var(--white);
}
.scoreboard article.turn .badge.quiet {
  background: var(--white);
  color: var(--blue);
}
.checkline {
  display: flex;
  align-items: center;
  justify-content: flex-start;
  gap: 8px;
  font-weight: 700;
  text-align: left;
}
fieldset .checkline { justify-self: start; }
.remain {
  margin: 8px 0 0;
  font-family: "Arial Narrow", "Segoe UI", sans-serif;
  font-size: clamp(4.2rem, 10vw, 8rem);
  line-height: 0.9;
  font-weight: 700;
  letter-spacing: -0.04em;
  font-variant-numeric: tabular-nums;
}
.remain.small { font-size: 4rem; }
.legs { margin: 0; font-weight: 750; }
.stats {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 8px 12px;
  margin: 14px 0 0;
}
.stats div { display: grid; }
.stats dt { font-size: 0.75rem; text-transform: uppercase; letter-spacing: 0.04em; opacity: 0.75; }
.stats dd { margin: 0; font-size: 1.25rem; font-weight: 800; font-variant-numeric: tabular-nums; }
.stats.plain { background: var(--white); border: 1px solid var(--line); border-radius: 8px; padding: 12px; }
.stats.plain.big { grid-template-columns: repeat(auto-fit, minmax(140px, 1fr)); margin: 16px 0; }
.stats.plain dd { color: var(--blue); font-size: 1.6rem; }

.board .player-main {
  display: grid;
  grid-template-columns: 1fr;
  gap: 12px;
  margin-top: 6px;
}
.board .score-alone { text-align: center; }
.board .score-alone .remain { margin: 0; font-size: clamp(6.4rem, 13vw, 10.5rem); }
.board .remain.finish { color: var(--finish); }
.board .remain.bogey { color: var(--bogey); }
.scoreboard article.turn .remain.finish { color: #8cffb0; }
.scoreboard article.turn .remain.bogey { color: #ff9b9b; }
.board .score-alone .legs {
  margin-top: 4px;
  font-size: clamp(2.4rem, 6vw, 4.2rem);
  letter-spacing: -0.03em;
  font-variant-numeric: tabular-nums;
}
.board .stats.side {
  margin: 0;
  padding-top: 10px;
  border-top: 1px solid var(--line);
  grid-template-columns: repeat(4, minmax(0, 1fr));
}
.scoreboard article.turn .stats.side { border-top-color: rgba(255, 255, 255, 0.35); }
.protocol {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto minmax(0, 1fr);
  gap: 10px clamp(6px, 2vw, 14px);
  align-items: center;
}
.leg-name { margin: 0; font-weight: 800; color: var(--blue); text-align: center; overflow-wrap: break-word; }
.proto {
  container-type: inline-size;
  display: flex;
  align-items: baseline;
  justify-content: center;
  gap: 8px;
  gap: clamp(4px, 4cqi, 16px);
  min-width: 0;
  min-height: 4.6rem;
  padding: 6px 8px;
  padding: clamp(4px, 3cqi, 8px) clamp(4px, 4cqi, 16px);
  border-radius: 10px;
  background: var(--ice);
  font-weight: 800;
  font-variant-numeric: tabular-nums;
}
.proto.slot {
  background: rgba(10, 61, 145, 0.04);
  border: 1px dashed var(--line);
}
.proto form { width: 100%; margin: 0; }
.proto .score {
  font-size: clamp(1.6rem, 6vw, 4.8rem);
  font-size: clamp(1.5rem, 30cqi, 4.8rem);
  line-height: 0.95;
  white-space: nowrap;
}
.proto .rest {
  font-size: clamp(1.15rem, 3.6vw, 2.7rem);
  font-size: clamp(1.05rem, 18cqi, 2.7rem);
  font-weight: 700;
  opacity: 0.72;
  white-space: nowrap;
}
.board .scoreboard article { min-height: 0; }

.desk { display: grid; grid-template-columns: 1fr; gap: 16px; margin-top: 16px; }
.shortcut-row { display: flex; flex-wrap: wrap; gap: 8px; margin: 0 0 14px; }
.shortcut-row button {
  min-width: 58px;
  min-height: 40px;
  padding: 3px 6px;
  background: var(--white);
  color: var(--blue-dark);
  border: 1px solid var(--line);
  display: grid;
  justify-items: center;
  align-content: center;
  line-height: 1.05;
}
.shortcut-row small { font-size: 0.62rem; letter-spacing: 0.04em; opacity: 0.7; }
.shortcut-row span { font-size: 0.95rem; }

.legboard {
  background: var(--white);
  border: 1px solid var(--line);
  border-radius: 10px;
  padding: 14px;
}
.legboard h3 { margin: 0 0 12px; }
.visit-input {
  width: 100%;
  max-width: 8.5rem;
  height: clamp(3.4rem, 16vw, 5.2rem);
  margin: 0 auto;
  display: block;
  padding: 0 8px;
  border: 2px solid var(--blue);
  border-radius: 10px;
  background: var(--white);
  text-align: center;
  font-size: clamp(1.35rem, 6vw, 2.6rem);
  font-weight: 800;
  font-variant-numeric: tabular-nums;
}
.proto .rest.finish { color: var(--finish); opacity: 1; }
.proto .rest.bogey { color: var(--bogey); opacity: 1; }
.proto.bust .score { color: var(--bogey); text-decoration: line-through; }
.proto.checkout { color: var(--blue); background: #d7e6fa; }
.proto-darts {
  text-align: center;
  font-size: 1.45rem;
  font-weight: 800;
  color: var(--blue);
  font-variant-numeric: tabular-nums;
}
.proto-darts.head {
  font-size: 0.72rem;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: var(--muted);
}
.visit-input:focus { outline: 2px solid var(--blue-bright); outline-offset: 1px; }

.sheet {
  background: #d5d5d5;
  border: 1px solid #b7b7b7;
  border-radius: 0;
  overflow: hidden;
  flex: 1;
  min-height: 0;
  display: grid;
  grid-template-columns: 19.2rem minmax(0, 1.15fr) minmax(0, 1.15fr) auto minmax(0, 1.15fr) minmax(0, 1.15fr) 19.2rem;
  grid-template-rows: auto minmax(0, 1fr) auto auto auto;
  column-gap: 1px;
}
.sheet-top {
  grid-column: 1 / -1;
  display: grid;
  grid-template-columns: subgrid;
  align-items: center;
  background: var(--blue);
  color: var(--white);
  padding: 4px 0;
}
.sheet-top h2 {
  grid-column: 1;
  margin: 0;
  min-width: 0;
  padding-left: 18px;
  font-size: clamp(2.2rem, 4vw, 3.8rem);
  font-weight: 800;
  overflow-wrap: anywhere;
}
.sheet-top h2.end { grid-column: 7; padding-left: 0; padding-right: 18px; text-align: right; }
.sheet-top a { color: inherit; text-decoration: none; }
.sheet-top .stand {
  color: #3ddc6a;
  justify-self: center;
  font-size: clamp(3.6rem, 6.4vw, 6rem);
  font-weight: 800;
  line-height: 0.9;
  font-variant-numeric: tabular-nums;
}
.sheet-top .stand.p1 { grid-column: 3; }
.sheet-top .stand.p2 { grid-column: 5; }
.sheet > .sheet-foot,
.sheet > .shortcut-row,
.sheet > .sheet-tools { grid-column: 1 / -1; background: #fff; }
.sheet-body {
  grid-column: 1 / -1;
  min-height: 0;
  display: grid;
  grid-template-columns: subgrid;
  grid-template-rows: minmax(0, 1fr);
  align-items: stretch;
}
.sheet-body > .rail:first-of-type { grid-column: 1; }
.sheet-body > .rail:last-of-type { grid-column: 7; }
.sheet-center {
  grid-column: 2 / 7;
  min-width: 0;
  min-height: 0;
  height: 100%;
  display: grid;
  grid-template-columns: subgrid;
  grid-template-rows: auto minmax(0, 1fr);
  background: #fff;
}
.rail {
  background: #e6e6e6;
  color: #111;
  padding: 8px 8px 12px;
}
.rail-mark {
  margin: 0 0 4px;
  min-height: 1.35rem;
  color: #163f93;
  font-weight: 800;
  font-style: italic;
}
.rail h3 {
  margin: 8px 0 2px;
  color: #163f93;
  font-size: 1.45rem;
  font-weight: 800;
}
.rail dl { margin: 0; }
.rail dl div {
  display: flex;
  justify-content: space-between;
  gap: 6px;
  padding: 1px 0;
  font-size: 1.15rem;
}
.rail dt, .rail dd { white-space: nowrap; }
.rail dt { font-weight: 650; }
.rail dd { margin: 0; font-weight: 800; font-variant-numeric: tabular-nums; }
.sheet .lead, .sheet .prompt { margin: 12px 14px; }
.sheet .shortcut-row {
  display: grid;
  grid-template-columns: repeat(6, minmax(0, 1fr));
  gap: 8px;
  margin: 8px 6px 10px;
}
.sheet .shortcut-row button {
  width: 100%;
  min-width: 0;
  display: flex;
  flex-direction: row;
  justify-content: center;
  gap: 8px;
  align-items: baseline;
}
.sheet-center > .lead { grid-column: 1 / -1; }
.sheet-grid {
  --row: 3.9rem;
  --list-size: clamp(1.9rem, 2.7vw, 2.5rem);
  grid-column: 1 / -1;
  grid-row: 2;
  display: grid;
  grid-template-columns: subgrid;
  row-gap: 1px;
  flex: 1 1 auto;
  min-height: 0;
  grid-auto-rows: minmax(var(--row), 1fr);
  overflow-y: auto;
  background: #d5d5d5;
  border-top: 1px solid #d5d5d5;
}
.sheet-grid > * {
  display: flex;
  align-items: center;
  justify-content: center;
  min-width: 0;
  height: auto;
  min-height: 0;
  background: #fff;
  font-size: var(--list-size);
  font-weight: 800;
  font-variant-numeric: tabular-nums;
}
.sheet-grid .h {
  position: sticky;
  top: 0;
  z-index: 2;
  min-height: var(--row);
  background: #e6e6e6;
  color: #1c1c1c;
  font-size: var(--list-size);
  font-weight: 800;
}
.sheet-grid .mid {
  padding: 0 0.75rem;
  background: #f3f3f3;
  color: #1c1c1c;
  font-size: var(--list-size);
  font-weight: 800;
  white-space: nowrap;
}
.sheet-grid .h.mid { background: #e6e6e6; }
.sheet-grid .mute { background: #ececec; }
.sheet-grid .live { background: #fff176; padding: 0; }
.sheet-grid .scored { font-size: var(--list-size); font-weight: 800; }
.sheet-grid .togo { font-size: var(--list-size); font-weight: 800; }
.sheet-grid .togo.open { min-height: var(--row); font-size: var(--list-size); font-weight: 800; }
.sheet-grid .togo.finish { color: var(--finish); }
.sheet-grid .togo.bogey { color: var(--bogey); }
.sheet-grid .bust { color: var(--bogey); text-decoration: line-through; }
.sheet-grid .edit { padding: 0; }
.sheet-grid .score-fix {
  width: 100%;
  height: 100%;
  min-height: 0;
  border: 0;
  border-radius: 0;
  background: transparent;
  text-align: center;
  font: inherit;
  font-size: var(--list-size);
  font-weight: 800;
  color: inherit;
  padding: 0;
}
.sheet-grid .score-fix:focus {
  background: #fff176;
  outline: 3px solid var(--blue);
  outline-offset: -3px;
}
.sheet-grid .bust .score-fix { text-decoration: line-through; }
.sheet-grid .checkout { background: #d7e6fa; color: var(--blue); }
.sheet-grid form { width: 100%; height: 100%; margin: 0; }
.sheet-grid .live .visit-input {
  width: 100%;
  max-width: none;
  height: 100%;
  min-height: 0;
  border: 0;
  border-radius: 0;
  background: transparent;
  font-size: var(--list-size);
}
.sheet-grid .live .visit-input:focus { outline: none; }
@keyframes score-over {
  0%, 49% { color: var(--bogey); box-shadow: inset 0 0 0 5px var(--bogey); }
  50%, 100% { color: #ff8a93; box-shadow: inset 0 0 0 5px transparent; }
}
.sheet-grid .live .visit-input.over,
.sheet-grid .score-fix.over,
.sheet-grid .score-fix.over:focus {
  color: var(--bogey);
  background: #fff;
  border-radius: 999px;
  outline: none;
  animation: score-over 0.7s step-end infinite;
}
.sheet-tools {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 8px 16px;
  margin: 4px 8px 8px;
}
.sheet-tools .share { margin: 0; word-break: normal; }
.board-qr {
  display: flex;
  align-items: center;
  gap: 10px;
  margin-right: auto;
  color: var(--blue);
  font-weight: 800;
  text-decoration: none;
}
.board-qr img {
  width: 112px;
  height: 112px;
  background: #fff;
  border: 1px solid #c8c8c8;
}
.sheet-tools form { margin: 0; }
.sheet-tools .sim-row { display: flex; flex-wrap: wrap; align-items: center; gap: 8px; }
.sheet-tools .sim-row span { color: var(--blue); font-weight: 800; }
.sheet-tools .sim-row button { background: var(--blue); color: var(--white); border-color: var(--blue); }
.sheet-foot {
  display: grid;
  grid-template-columns: 1fr 1fr;
  align-items: center;
  flex: 0 0 auto;
  gap: 8px;
  background: #fff;
  padding: 8px 8px 6px;
  border-top: 1px solid #c8c8c8;
}
.sheet-foot .big {
  margin: 0;
  color: #111;
  background: #fff;
  text-align: center;
  font-size: clamp(6.4rem, 16vw, 13rem);
  line-height: 0.86;
  font-weight: 800;
  font-variant-numeric: tabular-nums;
  border: 7px solid transparent;
}
.sheet-foot .big.box { border-color: var(--blue); }
.sheet-foot .big.finish,
.sheet-foot .big.box.finish { color: var(--finish); }
.sheet-foot .big.bogey,
.sheet-foot .big.box.bogey { color: var(--bogey); }
.sheet .actions-row, .sheet .share { margin-left: 8px; margin-right: 8px; }
.history, .entry {
  background: var(--white);
  border: 1px solid var(--line);
  border-radius: 10px;
  padding: 14px;
}
.history ol { list-style: none; padding: 0; margin: 0; max-height: 320px; overflow: auto; }
.history li {
  display: flex;
  justify-content: space-between;
  gap: 8px;
  padding: 7px 0;
  border-bottom: 1px solid var(--ice);
}
.history li.bust strong { color: var(--bogey); text-decoration: line-through; }
.history li.checkout strong { color: var(--blue); }
.share { word-break: break-all; }
.actions-row { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; }

.choices { display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px; margin-top: 12px; }
.keys button, .choices button {
  min-height: 72px;
  font-size: 1.6rem;
  background: var(--ice);
  color: var(--blue-dark);
}
.keys button.ok, .prompt button { background: var(--blue); color: var(--white); }
.prompt h3 { margin-top: 0; }
.numhint { color: var(--muted); margin: 8px 0; }
.ask-layer {
  position: fixed;
  inset: 0;
  z-index: 60;
  display: grid;
  place-items: center;
  padding: 16px;
  background: rgba(7, 22, 56, 0.55);
}
.ask-window.end-window { width: min(1100px, 100%); max-height: calc(100dvh - 32px); overflow: auto; }
.end-stats { display: grid; grid-template-columns: 1fr 1fr; gap: 28px; margin-top: 8px; }
.end-stats h4 { margin: 0 0 12px; color: var(--blue); font-size: clamp(2rem, 3.4vw, 2.8rem); }
.end-stats h4.win::after { content: " · Sieger"; font-size: 0.72em; }
.end-stats dl { display: grid; gap: 8px; margin: 0; }
.end-stats dl div {
  display: flex;
  justify-content: space-between;
  gap: 16px;
  border-bottom: 1px solid var(--ice);
  padding-bottom: 6px;
}
.end-stats dt, .end-stats dd { font-size: clamp(1.45rem, 2.6vw, 2rem); }
.end-stats dt { color: var(--muted); font-weight: 700; }
.end-stats dd { margin: 0; font-weight: 800; color: var(--blue); font-variant-numeric: tabular-nums; }
.ask-window .choices a {
  display: grid;
  place-items: center;
  min-height: 84px;
  padding: 10px 12px;
  border-radius: 6px;
  background: var(--blue);
  color: var(--white);
  text-decoration: none;
  font-weight: 800;
  text-align: center;
}
.ask-window .choices a.ghost {
  background: var(--white);
  color: var(--blue);
  border: 1px solid var(--blue);
}
.ask-window.warn-window {
  border-color: var(--bogey);
  background: #fff1f2;
}
.ask-window.warn-window h3 {
  color: var(--bogey);
  font-size: clamp(1.7rem, 3.2vw, 2.4rem);
}
.ask-window.warn-window p {
  color: #8d1018;
  font-size: 1.25rem;
  font-weight: 700;
}
.ask-window.warn-window .choices button {
  background: var(--bogey);
  color: var(--white);
  min-height: 64px;
  font-size: 1.3rem;
}
.ask-window {
  width: min(640px, 100%);
  margin: 0;
  background: var(--white);
  color: var(--ink);
  border: 6px solid var(--blue);
  border-radius: 10px;
  padding: 22px 24px 20px;
  box-shadow: 0 22px 60px rgba(0, 0, 0, 0.35);
}
.ask-window h3 {
  margin: 0 0 8px;
  color: var(--blue);
  font-size: clamp(1.6rem, 3vw, 2.2rem);
}
.ask-window p { margin: 0 0 10px; font-size: 1.15rem; }
.ask-window .choices { margin-top: 16px; }
.ask-window .choices.quad { grid-template-columns: repeat(4, minmax(0, 1fr)); }
.ask-window .choices button { min-height: 84px; font-size: 1.4rem; }
.ask-field { display: grid; gap: 6px; margin: 12px 0 4px; font-weight: 700; }
.ask-field select { font-size: 1.25rem; min-height: 52px; width: 100%; }

.banner {
  background: var(--blue);
  color: var(--white);
  border-radius: 8px;
  padding: 12px 16px;
  font-size: 1.4rem;
  font-weight: 800;
}
.banner:empty { display: none; }
.banner.ok { background: var(--finish); }
.banner.bad { background: var(--bogey); }
.choices.pair { grid-template-columns: 1fr 1fr; }
.board-tag { color: var(--blue); font-weight: 800; margin: 8px 0 0; }
.keyline {
  font-family: ui-monospace, Consolas, monospace;
  background: var(--white);
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 12px 14px;
  word-break: break-all;
}
.state-frei { color: var(--finish); font-weight: 800; }
.state-spielt { color: var(--blue); font-weight: 800; }
.state-offline { color: var(--muted); font-weight: 800; }

.tablewrap { max-width: 100%; overflow-x: auto; -webkit-overflow-scrolling: touch; background: var(--white); border: 1px solid var(--line); border-radius: 8px; }
table { width: 100%; border-collapse: collapse; }
th, td { padding: 10px 12px; text-align: right; white-space: nowrap; font-variant-numeric: tabular-nums; }
th:first-child, td:first-child { text-align: left; }
th { background: var(--blue); color: var(--white); font-weight: 700; }
th a { color: var(--white); text-decoration: none; }
tbody tr:nth-child(even) { background: var(--ice); }

.plan-desk { display: grid; grid-template-columns: minmax(0, 1fr); gap: 28px; align-items: start; }
.plan-desk.has-groups { grid-template-columns: minmax(0, 1fr) minmax(34rem, 46rem); }
.group-grid { display: flex; flex-direction: column; gap: 18px; margin: 0; }
.group-grid th, .group-grid td { padding: 8px 10px; }
.group-grid th:nth-child(2), .group-grid td:nth-child(2) { text-align: left; white-space: normal; }
.group-grid td.plus { color: var(--finish); font-weight: 800; }
.group-grid td.minus { color: var(--bogey); font-weight: 800; }
.group-grid h3, .plan h3 { margin: 18px 0 8px; }
.plan { display: grid; gap: 8px; }
.plan-row {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 3.4rem minmax(0, 1fr) minmax(0, 8.2rem);
  gap: 6px 8px;
  align-items: center;
  background: var(--white);
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 10px 14px;
}
.plan-row p { margin: 0; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.plan-row p:first-child { text-align: right; }
.plan-row .legs-line { text-align: center; margin: 0; }
.plan-row.live { border-color: var(--blue); background: #f3f7ff; }
.plan-state { min-width: 0; }
.plan-state p { margin: 0; white-space: normal; overflow: visible; text-overflow: unset; }
.plan-state button { min-height: 40px; padding: 6px 12px; }
.plan-state .send-row { display: flex; flex-wrap: wrap; align-items: center; gap: 6px; margin: 0; }
.plan-state .send-row select { min-height: 40px; }
.plan-state .inline { margin-top: 4px; }
.plan-state button.linkish { min-height: 0; padding: 0; }
.sortable tbody.inactive tr.off td { color: var(--muted); }
.sortable tbody.inactive tr.off a { color: var(--muted); }
.sortable tr.divider td {
  text-align: left;
  padding: 8px 12px;
  background: var(--white);
  border-top: 3px solid var(--blue);
  color: var(--muted);
  font-size: 0.8rem;
  font-weight: 800;
  text-transform: uppercase;
  letter-spacing: 0.06em;
}
.sortable tbody.inactive tr:nth-child(odd) { background: var(--ice); }
.sortable tbody.inactive tr:nth-child(even) { background: var(--white); }
.sortable th a { display: inline-flex; align-items: center; gap: 4px; }
.sortable th .dir { font-size: 0.8em; opacity: 0.55; }
.sortable th.sorted .dir { opacity: 1; }
.sortable th a:hover .dir { opacity: 1; }
.db-wrap { margin: 0 0 18px; }
.db-table { background: var(--white); }
.db-table tr.active td { background: #f3f7ff; }
.db-table td:first-child { white-space: normal; }
.db-table .tag { display: inline-block; margin-left: 6px; padding: 1px 8px; border-radius: 999px; background: var(--blue); color: var(--white); font-size: 0.8rem; font-weight: 800; }
.db-actions { text-align: right; white-space: normal; }
.db-actions form { display: flex; flex-direction: column; align-items: flex-end; gap: 6px; margin: 0 0 8px; }
.db-actions form:last-child { margin-bottom: 0; }
.db-actions button { min-height: 36px; padding: 4px 12px; }
.db-actions button.linkish { min-height: 0; padding: 0; background: none; border: 0; color: var(--bogey); text-decoration: underline; cursor: pointer; }
.db-actions .checkline.small { font-weight: 600; font-size: 0.85rem; color: var(--muted); }
.db-new { margin-top: 8px; }
.highlights { margin: 6px 0 0; }
.highlights h2 { margin: 0 0 10px; }
.highlight-grid { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 10px; align-items: start; }
.highlight-card { background: var(--white); border-radius: 12px; padding: 10px 12px; box-shadow: 0 1px 2px rgba(0, 32, 96, 0.08); border-top: 3px solid var(--blue); min-width: 0; }
.highlight-card.max { border-top-color: #ff4d6d; }
.highlight-card.hf { border-top-color: #3ddc6a; }
.highlight-card.short { border-top-color: #ffb020; }
.highlight-card h3 { margin: 0; display: flex; align-items: baseline; gap: 6px; font-size: 0.95rem; }
.highlight-card h3 em { font-style: normal; font-size: 0.78rem; color: var(--muted); font-weight: 700; }
.highlight-card .hint { margin: 0 0 8px; font-size: 0.72rem; color: var(--muted); }
.highlight-card ol { list-style: none; margin: 0; padding: 0; display: grid; gap: 2px; }
.highlight-card li { display: grid; grid-template-columns: auto minmax(0, 1fr); grid-template-areas: "value name" "value opp"; align-items: center; column-gap: 8px; padding: 4px 0; border-bottom: 1px solid var(--line); min-width: 0; }
.highlight-card li:last-child { border-bottom: 0; }
.highlight-card li b { grid-area: value; min-width: 2.4rem; white-space: nowrap; font-size: 0.98rem; font-weight: 800; color: var(--blue); }
.highlight-card li a { grid-area: name; font-weight: 700; font-size: 0.85rem; text-decoration: none; color: var(--ink); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.highlight-card li a:hover { text-decoration: underline; color: var(--blue); }
.highlight-card li small { grid-area: opp; color: var(--muted); font-size: 0.72rem; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.highlight-card .muted { margin: 6px 0 0; font-size: 0.78rem; }
.assign-mode { display: flex; flex-wrap: wrap; align-items: center; gap: 8px 12px; margin: 0 0 12px; }
.assign-mode span { font-weight: 800; color: var(--blue); }
.assign-mode button.on { background: var(--blue); color: var(--white); border-color: var(--blue); }
.bracket { display: flex; gap: 16px; max-width: 100%; overflow-x: auto; -webkit-overflow-scrolling: touch; padding-bottom: 12px; }
.bracket section { min-width: 240px; display: grid; gap: 12px; align-content: start; }
.pairing { padding: 12px; display: grid; gap: 4px; }
.pairing .win { color: var(--blue); font-weight: 800; }
.legs-line { color: var(--blue); font-weight: 800; margin: 4px 0; }

.statgrid { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
.statgrid article, .leg { padding: 14px; }
.statgrid.compact { grid-template-columns: 1fr 1fr; }
.leg { margin-bottom: 10px; }

.last { font-weight: 700; }

body.overlay {
  margin: 0;
  min-height: 100vh;
  min-height: 100dvh;
  background: var(--blue);
  color: var(--white);
  padding: calc(12px + env(safe-area-inset-top)) calc(18px + env(safe-area-inset-right)) calc(12px + env(safe-area-inset-bottom)) calc(18px + env(safe-area-inset-left));
  display: grid;
  align-content: center;
}
.ov-kicker { margin: 0 0 8px; font-weight: 700; opacity: 0.85; overflow-wrap: anywhere; }
.ov-bar { display: grid; grid-template-columns: 1fr 1fr; gap: 18px; }
.ov-bar section { min-width: 0; padding: 8px 12px; border-radius: 8px; }
.ov-bar section p { overflow-wrap: anywhere; }
.ov-bar section.turn { background: var(--white); color: var(--blue); }
.ov-bar h2 { margin: 0; font-size: clamp(1.4rem, 4vw, 2.4rem); }
.ov-remain {
  margin: 0;
  font-size: clamp(3rem, 10vw, 7rem);
  line-height: 0.9;
  font-weight: 800;
  font-variant-numeric: tabular-nums;
}
.ov-last { margin: 8px 0 0; font-size: 1.1rem; }

@media (max-width: 860px) {
  .split, .desk, .scoreboard, .statgrid, .statgrid.compact, .board .player-main, .end-stats { grid-template-columns: 1fr; }
  .roster { grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 22px 16px; }
  .roster .name { font-size: 1.2rem; }
  .stats, .board .stats.side { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .board .stats.side dd, .stats dd { font-size: 1.05rem; }
  .top { align-items: flex-start; flex-direction: column; }
  nav a, nav .linkish { display: inline-flex; align-items: center; min-height: 44px; }
  .shortcut-row button { min-height: 44px; }
  .people li, .matchlist li { flex-direction: column; align-items: stretch; }
  .person-actions { width: 100%; }
  .board .score-alone .remain { font-size: clamp(4.8rem, 24vw, 8rem); }
  .board main {
    padding: 4px calc(6px + env(safe-area-inset-right)) calc(8px + env(safe-area-inset-bottom)) calc(6px + env(safe-area-inset-left));
  }
  .board .kicker {
    margin: 0 0 4px;
    font-size: 0.85rem;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
  }
  body.board .sheet {
    display: flex;
    flex-direction: column;
    grid-template-columns: none;
    min-height: 0;
    background: #fff;
  }
  .sheet-top {
    display: grid;
    grid-template-columns: minmax(0, 1fr) auto auto minmax(0, 1fr);
    flex: none;
    padding: 8px 10px;
    column-gap: 6px;
  }
  .sheet-top h2, .sheet-top h2.end {
    grid-column: auto;
    padding: 0;
    text-align: left;
    font-size: clamp(1.05rem, 4.4vw, 1.7rem);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
  }
  .sheet-top h2.end { text-align: right; }
  .sheet-top .stand, .sheet-top .stand.p1, .sheet-top .stand.p2 {
    grid-column: auto;
    font-size: clamp(1.7rem, 7vw, 2.6rem);
    padding: 0 2px;
  }
  body.board .sheet-body {
    display: grid;
    grid-template-columns: minmax(0, 1fr) minmax(0, 1fr);
    grid-template-rows: minmax(0, 1fr) auto;
    flex: 1 1 auto;
    min-height: 0;
    min-width: 0;
    overflow: hidden;
  }
  body.board .sheet-body > .rail:first-of-type,
  body.board .sheet-body > .rail:last-of-type { grid-column: auto; grid-row: 2; }
  body.board .sheet-center {
    display: flex;
    flex-direction: column;
    grid-column: 1 / -1;
    grid-row: 1;
    width: auto;
    min-width: 0;
    min-height: 0;
    order: 0;
  }
  body.board .sheet-grid {
    width: auto;
    grid-column: 1 / -1;
    grid-template-columns: minmax(0, 1fr) minmax(0, 1fr) auto minmax(0, 1fr) minmax(0, 1fr);
    grid-row: auto;
    column-gap: 1px;
    flex: 1 1 auto;
    min-height: 0;
    --row: 2.55rem;
    --list-size: clamp(1rem, 3.5vw, 1.35rem);
  }
  .sheet-grid .h { font-size: clamp(0.72rem, 2.5vw, 1rem); }
  .sheet-grid .mid { padding: 0 0.4rem; }
  .sheet-grid .live .visit-input,
  .sheet-grid .score-fix { font-size: max(16px, var(--list-size)); }
  body.board .rail {
    grid-row: 2;
    flex: none;
    width: auto;
    min-width: 0;
    max-height: 6.4rem;
    overflow: auto;
    padding: 4px 8px 6px;
    order: 0;
  }
  .rail h3 { margin: 4px 0 0; font-size: 0.82rem; }
  .rail dl div { font-size: 0.78rem; padding: 0; }
  .sheet-foot { padding: 4px 6px 2px; gap: 6px; }
  .sheet-foot .big {
    font-size: clamp(3rem, 14vw, 5.4rem);
    line-height: 1;
    overflow: hidden;
    border-width: 4px;
  }
  .sheet .shortcut-row {
    grid-template-columns: repeat(4, minmax(0, 1fr));
    gap: 6px;
    margin: 4px 6px 6px;
  }
  .sheet .shortcut-row button {
    min-height: 48px;
    flex-direction: column;
    gap: 0;
    padding: 4px 2px;
  }
  .sheet-tools { margin: 0 6px 6px; }
  .sheet-tools .ghost, .sheet-tools button { min-height: 44px; }
  body.board.immersive .sheet-tools { padding-right: 6.5rem; }
  .mode-line { grid-template-columns: 1fr 1fr; }
  .plan-desk.has-groups { grid-template-columns: 1fr; }
  .highlight-grid { grid-template-columns: 1fr; }
}
@media (max-width: 1280px) and (min-width: 861px) {
  .sheet {
    grid-template-columns: minmax(9rem, 13rem) minmax(0, 1.15fr) minmax(0, 1.15fr) auto minmax(0, 1.15fr) minmax(0, 1.15fr) minmax(9rem, 13rem);
  }
  .sheet-top h2 {
    padding-left: 10px;
    font-size: clamp(1.25rem, 2.1vw, 2rem);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
  }
  .sheet-top h2.end { padding-right: 10px; }
  .sheet-top .stand { font-size: clamp(2.2rem, 4vw, 3.4rem); }
  .sheet-foot .big { font-size: clamp(3.8rem, 8vw, 6.6rem); border-width: 5px; }
  .rail { padding: 6px 8px; }
  .rail h3 { font-size: 1rem; }
  .rail dl div { font-size: 0.92rem; }
  .sheet-grid { --row: 2.7rem; --list-size: clamp(1.05rem, 1.7vw, 1.55rem); }
  .sheet .shortcut-row button { min-height: 48px; }
}
@media (max-width: 860px) and (max-height: 500px) {
  .board .kicker { display: none; }
  .rail { display: none; }
  .sheet-body { align-content: stretch; }
  .sheet-foot .big { font-size: clamp(2.1rem, 16vh, 3.4rem); }
  .sheet .shortcut-row { grid-template-columns: repeat(6, minmax(0, 1fr)); }
  .sheet .shortcut-row button { min-height: 40px; flex-direction: row; gap: 4px; }
}
@media (max-width: 860px) {
  .plan-row { grid-template-columns: 1fr auto; }
  .plan-row p:first-child, .plan-row .legs-line { text-align: left; }
  .plan-state { grid-column: 1 / -1; }
}
@media (max-width: 520px) {
  .brand-logo { width: 40px; height: 40px; }
  .bull-line { grid-template-columns: 1fr; }
  .choices, .ask-window .choices.quad { grid-template-columns: 1fr 1fr; }
  .choices button, .keys button { min-height: 56px; font-size: 1.2rem; }
  .ov-bar { grid-template-columns: 1fr; gap: 10px; }
  .legboard { padding: 10px; }
}
@media (min-width: 861px) {
  .board .stats.side > div:nth-child(8) { grid-column: 1; }
}

.fullscreen-btn {
  position: fixed;
  z-index: 45;
  top: calc(12px + env(safe-area-inset-top));
  right: calc(16px + env(safe-area-inset-right));
}
html:fullscreen,
html:-webkit-full-screen {
  background: var(--ice);
}
html:fullscreen::backdrop,
html:-webkit-full-screen::backdrop {
  background: var(--ice);
}
html.is-fullscreen .top,
html:fullscreen .top,
html:-webkit-full-screen .top,
:fullscreen .top,
body.immersive .top {
  display: none !important;
}
html.is-fullscreen main,
html:fullscreen main,
html:-webkit-full-screen main,
body.immersive main {
  max-width: none;
  width: 100%;
  min-height: 100dvh;
  padding-top: 8px;
}
body.board.immersive main,
html.is-fullscreen body.board main,
html:fullscreen body.board main {
  min-height: 0;
  flex: 1 1 auto;
}
html.is-fullscreen .fullscreen-btn,
html:fullscreen .fullscreen-btn,
html:-webkit-full-screen .fullscreen-btn,
body.immersive .fullscreen-btn {
  top: auto;
  bottom: max(8px, env(safe-area-inset-bottom));
}
body.immersive {
  min-height: 100dvh;
  overflow: auto;
}
.overlay .fullscreen-btn {
  color: var(--white);
  border-color: rgba(255, 255, 255, 0.85);
  background: transparent;
}
