:root {
  color-scheme: light;
  --paper: #f5f1e7;
  --panel: #fffdf7;
  --ink: #182a24;
  --muted: #4d6258;
  --felt: #15372d;
  --green: #23543f;
  --rust: #88402e;
  --line: #d6d9cb;
  --a: #e2ede3;
  --b: #f5e7da;
  font: 16px/1.5 "Instrument Sans", system-ui, sans-serif;
  color: var(--ink);
  background: var(--paper);
}
*, *::before, *::after { box-sizing: border-box; }
body { margin: 0; }
.skip-link { position: fixed; z-index: 1; top: 8px; left: 8px; padding: 10px; color: var(--ink); background: var(--panel); }
.skip-link:not(:focus) { clip-path: inset(50%); }
.masthead { background: var(--felt); color: var(--panel); border-bottom: 4px solid #b39154; }
.masthead-inner, main { width: min(100% - 28px, 44rem); margin-inline: auto; }
.masthead-inner { display: flex; gap: 12px; align-items: center; min-height: 76px; }
.masthead img { border-radius: 10px; }
h1, h2, h3, p { margin: 0; }
h1, h2, h3 { text-wrap: balance; }
h1 { font: 700 clamp(1.3rem, 5vw, 1.65rem)/1.16 Georgia, serif; }
h1 span { font: 500 .75em/1.2 "Instrument Sans", system-ui, sans-serif; color: #e1d8bd; }
h2, h3 { line-height: 1.2; }
h2 { font-size: 1.3rem; }
h3 { font-size: 1.05rem; }
main { padding-block: 22px max(24px, env(safe-area-inset-bottom)); }
.app-nav {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 4px;
  margin-bottom: 16px;
  padding: 4px;
  border: 1px solid var(--line);
  border-radius: 12px;
  background: var(--panel);
}
.app-nav a {
  display: grid;
  place-items: center;
  min-height: 44px;
  border-radius: 8px;
  color: var(--green);
  font-weight: 680;
  text-decoration: none;
}
.app-nav a[aria-current="page"] { color: var(--panel); background: var(--felt); }
.hint a { color: var(--green); font-weight: 680; }
#workspace, .stack { display: grid; gap: 16px; }
.panel, dialog { background: var(--panel); padding: clamp(13px, 3vw, 20px); border: 1px solid var(--line); border-radius: 14px; }
.hint { color: var(--muted); font-size: .9rem; }
.actions { display: flex; flex-wrap: wrap; align-items: center; gap: 8px; }
.add-player { display: grid; grid-template-columns: minmax(0, 1fr) auto; gap: 8px; align-items: end; }
label { display: grid; gap: 4px; min-width: 0; font-weight: 650; font-size: .875rem; }
input, select, button { font: inherit; }
input:not([type=checkbox]), select, button { min-height: 44px; padding: 7px 10px; border: 1px solid var(--line); border-radius: 8px; }
input:not([type=checkbox]), select { width: 100%; background: var(--panel); color: var(--ink); }
input:not([type=checkbox]), select { font-size: 1rem; }
input[type=checkbox] { accent-color: var(--green); width: 1.15em; height: 1.15em; }
button { cursor: pointer; color: white; background: var(--green); border-color: transparent; font-weight: 680; }
button.secondary { color: var(--green); background: var(--panel); border-color: var(--line); }
button:disabled { cursor: default; opacity: .58; }
button, a, summary { touch-action: manipulation; }
@media (hover: hover) {
  button:not(:disabled):hover { box-shadow: inset 0 0 0 2px currentColor; }
  summary:hover { text-decoration: underline; }
}
.rules-icon {
  flex: 0 0 44px;
  margin-inline-start: auto;
  padding: 0;
  border-color: #b39154;
  background: transparent;
  font-size: 1.15rem;
}
.add-icon { width: 44px; padding: 0; font-size: 1.65rem; line-height: 1; }
:focus-visible { outline: 3px solid #ad631d; outline-offset: 2px; }
.pool { display: flex; flex-wrap: wrap; gap: 6px; padding: 0; margin: 0; list-style: none; }
.pool li { min-width: 0; padding: 3px 10px; border-radius: 20px; background: var(--a); overflow-wrap: anywhere; }
.teams { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 8px; }
fieldset { display: grid; gap: 10px; padding: 10px; margin: 0; min-width: 0; border: 1px solid var(--line); border-radius: 10px; }
legend { font-weight: 750; }
.team-a { background: var(--a); }
.team-b { background: var(--b); }
.match-score { display: grid; gap: 8px; padding: 8px; background: var(--felt); border-radius: 14px; }
.match-score h2 { color: var(--panel); text-align: center; }
.net-score { display: flex; align-items: center; justify-content: space-between; gap: 10px; padding: 6px 10px; background: var(--paper); border-radius: 8px; }
.net-score span { font-weight: 700; }
.net-score small { display: block; color: var(--muted); overflow-wrap: anywhere; }
.net-score strong { font-size: 1.55rem; line-height: 1; font-variant-numeric: tabular-nums; }
.round-panel { padding-inline: clamp(9px, 2vw, 20px); }
.call-controls { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 8px; }
.call-controls select { min-width: 0; }
.round-table {
  position: relative;
  isolation: isolate;
  display: grid;
  align-items: center;
  grid-template-columns: minmax(0, 1fr) minmax(64px, .75fr) minmax(0, 1fr);
  grid-template-areas: ". north ." "west center east" ". south .";
  gap: 6px;
  max-width: 32rem;
  width: 100%;
  margin-inline: auto;
}
.round-table::before {
  content: "";
  position: absolute;
  z-index: -1;
  inset: 9% 5%;
  border-radius: 50%;
  border: 5px solid #9a763b;
  background: var(--felt);
  box-shadow: inset 0 0 0 3px #3d6252;
}
.table-center {
  grid-area: center;
  text-align: center;
  color: #f0dba9;
  font-size: clamp(.78rem, 3.1vw, 1.125rem);
  font-weight: 750;
  font-variant-numeric: tabular-nums;
}
.seat { display: grid; align-content: start; gap: 4px; min-width: 0; padding: 6px; border: 1px solid var(--line); border-radius: 10px; overflow-wrap: anywhere; }
.seat[data-position="0"], .seat[data-position="2"] { width: clamp(78px, 30vw, 142px); justify-self: center; }
.seat[data-position="0"] { grid-area: north; }
.seat[data-position="1"] { grid-area: east; }
.seat[data-position="2"] { grid-area: south; }
.seat[data-position="3"] { grid-area: west; }
.seat p { font-size: .875rem; font-weight: 740; }
.seat-name, .role-tags { display: flex; align-items: center; flex-wrap: wrap; gap: 3px; }
.role-tag { padding: 1px 4px; border-radius: 4px; font-size: .67rem; font-weight: 750; text-decoration: none; white-space: nowrap; }
.role-call { color: #183f2d; background: #c4e1c9; }
.role-with { color: #334365; background: #dfebff; }
.role-risk { color: #742a16; background: #fbd7ad; }
.seat-check { display: flex; align-items: center; min-height: 44px; }
.seat-swap { padding-top: 10px; border-top: 1px solid var(--line); }
.seat-swap form { margin-top: 8px; }
[hidden] { display: none !important; }
#feedback, #storage-warning { color: var(--rust); font-weight: 650; margin-top: 12px; }
#feedback:empty { display: none; }
.round-feedback { color: var(--rust); font-weight: 650; }
.round-feedback:not(:empty) { margin-block-start: 8px; }
.trick-total { font-variant-numeric: tabular-nums; }
dialog { width: min(28rem, calc(100% - 28px)); color: var(--ink); overscroll-behavior: contain; }
dialog p { margin-block: 10px 16px; }
dialog::backdrop { background: #101e19a8; }
#score-rules { max-height: 85dvh; }
.rules-header { display: flex; align-items: center; justify-content: space-between; gap: 8px; margin-bottom: 14px; }
#score-rules ul { margin-block: 6px 14px; padding-inline-start: 1.25em; }
#score-rules li + li { margin-top: 4px; }
summary { cursor: pointer; font-weight: 710; }
.history-heading span { float: inline-end; color: var(--muted); font-size: .85rem; }
.history-round { padding: 9px; margin-top: 9px; border: 1px solid var(--line); border-radius: 10px; }
.history-round summary { display: flex; align-items: center; justify-content: space-between; gap: 7px; list-style: none; }
.history-round summary::-webkit-details-marker { display: none; }
.history-title::before { content: "▸"; display: inline-block; margin-inline-end: 5px; }
.history-round[open] .history-title::before { transform: rotate(90deg); }
.history-title small { display: block; color: var(--rust); }
.history-totals { display: flex; gap: 4px; font-variant-numeric: tabular-nums; }
.history-totals span { padding: 2px 6px; border-radius: 5px; text-align: center; }
.history-bonus {
  display: inline-block;
  padding: 0 4px;
  border-radius: 4px;
  color: #583506;
  background: #f6d48b;
  font-size: .8rem;
}
.round-outcomes { display: grid; gap: 7px; list-style: none; margin: 0; padding: 0; }
.couple-highlight { overflow-wrap: anywhere; }
.round-outcomes li {
  display: grid;
  grid-template-columns: minmax(70px, .6fr) minmax(0, 1.4fr);
  gap: 8px;
  padding-top: 7px;
  border-top: 1px solid var(--line);
  font-size: .9rem;
  overflow-wrap: anywhere;
}
.history-round .net-score { margin-block: 10px 5px; }
.history table { width: 100%; border-collapse: collapse; font-size: .85rem; table-layout: fixed; }
.history th, .history td { text-align: start; padding: 4px; overflow-wrap: anywhere; }
.history th:first-child { width: 38%; }
.history td:nth-child(n+2), .history th:nth-child(n+2) { text-align: end; }
.history thead th { white-space: nowrap; }
