:root {
  color-scheme: light;
  --ink: #101112;
  --paper: #f5f3ee;
  --surface: #fff;
  --line: #d8d5cd;
  --muted: #575b61;
  --red: #922c34;
  --red-dark: #78242b;
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  background: var(--paper);
  color: var(--ink);
}
* { box-sizing: border-box; }
[hidden] { display: none !important; }
body { margin: 0; min-width: 280px; }
h1, h2, p { margin: 0; }
h1 { font-size: clamp(1.8rem, 7vw, 2.6rem); line-height: 1.08; letter-spacing: -.035em; overflow-wrap: anywhere; }
h2 { font-size: 1.15rem; }
p, summary { line-height: 1.4; }
button, input, textarea, select { font: inherit; }
button { cursor: pointer; touch-action: manipulation; }
button:disabled { opacity: .45; cursor: default; }
:focus-visible { outline: 3px solid var(--red); outline-offset: 3px; }
.top { background: var(--ink); color: white; padding-top: env(safe-area-inset-top); }
.top-inner { max-width: 44rem; margin: auto; padding: .6rem 1rem; display: flex; justify-content: space-between; align-items: center; gap: .6rem; }
.site-brand { color: inherit; text-decoration: none; }
.site-brand:hover, .site-brand:focus-visible { text-decoration: underline; text-underline-offset: .18em; }
.site-brand-arrow { display: inline-block; position: relative; width: .55em; height: .55em; opacity: .75; }
.site-brand-arrow::before { content: ""; position: absolute; top: 0; right: 0; width: .32em; height: .32em; border: solid currentColor; border-width: 1px 1px 0 0; }
.site-brand-arrow::after { content: ""; position: absolute; top: 50%; left: -.1em; width: .74em; border-top: 1px solid currentColor; transform: rotate(-45deg); }
.brand { display: flex; align-items: center; gap: .6rem; min-width: 0; min-height: 44px; font-size: clamp(.84rem, 3.7vw, 1.05rem); font-weight: 750; line-height: 1.2; }
.brand:focus-visible { outline-color: white; }
.brand img { flex: none; width: 37px; height: 30px; object-fit: contain; }
.app-status { display: flex; flex-wrap: wrap; justify-content: flex-end; align-items: center; gap: .3rem .55rem; font-size: .82rem; text-align: right; }
.app-status button { min-height: 44px; padding: 0 .55rem; border: 1px solid #f5f3ee; border-radius: 8px; background: var(--ink); color: white; }
main { max-width: 44rem; margin: auto; padding: 1rem 1rem calc(1.25rem + env(safe-area-inset-bottom)); }
.stack { display: grid; gap: .9rem; min-width: 0; }
.line { display: flex; align-items: center; justify-content: space-between; gap: .65rem; }
.wrap { flex-wrap: wrap; }
.small { font-size: .875rem; color: var(--muted); }
.link, .primary, .secondary { min-height: 44px; border-radius: 10px; padding: .55rem .8rem; font-weight: 700; }
.link { color: var(--ink); background: transparent; border: 0; text-decoration: underline; text-underline-offset: .15em; }
.link.danger { color: var(--red-dark); }
.primary { background: var(--red); color: white; border: 1px solid var(--red); }
.secondary { background: var(--surface); color: var(--ink); border: 1px solid #9b9891; }
.block { width: 100%; min-height: 52px; }
.home { padding-top: clamp(1.2rem, 8vw, 3rem); }
.home-actions { margin-block-top: .35rem; gap: .65rem; }
.card { padding: .85rem; background: var(--surface); border: 1px solid var(--line); border-radius: 12px; min-width: 0; }
details > summary { cursor: pointer; font-weight: 680; }
details[open] > summary { margin-bottom: .75rem; }
.field { display: grid; gap: .3rem; min-width: 0; font-size: .9rem; font-weight: 650; }
.field input, .field textarea, .field select { margin: 0; min-width: 0; width: 100%; min-height: 44px; padding: .45rem .55rem; border: 1px solid #8b8983; border-radius: 8px; color: var(--ink); background: white; font-size: 1rem; }
.field textarea { resize: vertical; }
.columns { display: grid; grid-template-columns: 1fr 1fr; gap: .65rem; }
.roster { max-height: 11.5rem; overflow-y: auto; }
.roster label { display: flex; gap: .55rem; align-items: center; min-height: 42px; }
.roster input { accent-color: var(--red); width: 20px; height: 20px; }
.scoring { gap: .65rem; }
.scoring .context { display: grid; gap: .3rem; }
.station { font-size: 1.1rem; font-weight: 780; color: var(--red-dark); }
.score-target { display: grid; gap: .12rem; padding: .45rem .55rem; }
.score-target strong { font-size: 1.18rem; }
.score-summary { display: flex; gap: .55rem; }
.score-summary div { flex: 1 1 0; padding: .6rem .55rem; background: white; border: 1px solid var(--line); border-radius: 9px; }
.score-summary strong { display: block; font-size: clamp(1rem, 4.2vw, 1.3rem); font-variant-numeric: tabular-nums; }
.marks { display: grid; grid-template-columns: 1fr 1fr; gap: .55rem; }
.mark { min-height: clamp(82px, 17vh, 145px); border: 1px solid var(--ink); border-radius: 13px; background: var(--ink); color: white; font-size: clamp(1.45rem, 7vw, 2.6rem); font-weight: 780; }
.mark.miss { background: var(--red); border-color: var(--red); }
.mark span { display: inline-block; margin-right: .12em; }
.score-next .primary { flex: 1 1 auto; min-height: 50px; }
.error { color: var(--red-dark); padding-block: .25rem; }
.result-row { display: flex; justify-content: space-between; align-items: center; gap: .6rem; min-height: 48px; font-variant-numeric: tabular-nums; overflow-wrap: anywhere; }
.result-row + .result-row { border-top: 1px solid var(--line); }
.result-row strong, .result-row small { display: block; }
.result-button { width: 100%; text-align: left; background: transparent; border: 0; color: inherit; padding: .45rem 0; }
.result-number { flex: 0 0 auto; text-align: right; }
.sheet, .paper-sheet { border-collapse: collapse; table-layout: fixed; width: 100%; text-align: center; }
.sheet { font-size: .82rem; overflow-wrap: anywhere; }
.sheet th, .sheet td { padding: .16rem; border: 1px solid var(--line); }
.sheet th { background: var(--paper); }
.sheet .box { width: 100%; max-width: 44px; min-height: 44px; padding: 0; background: white; border: 1px solid #8b8983; border-radius: 6px; font-weight: 800; }
.sheet .box[data-mark="Hit"] { background: var(--ink); border-color: var(--ink); color: white; }
.sheet .box[data-mark="Miss"] { background: var(--red); border-color: var(--red); color: white; }
.sheet .student-col { width: 25%; padding: .3rem .35rem; }
.legend button[aria-pressed="true"] { background: var(--red); color: white; border-color: var(--red); }
.history-list { margin: 0; padding: 0; list-style: none; }
.station-trends section + section { margin-top: 1.25rem; }
.station-trend { padding-top: .55rem; border-top: 1px solid var(--line); }
.station-trend .line strong:last-child { color: var(--red-dark); font-variant-numeric: tabular-nums; }
@media (max-width: 360px) { main { padding-inline: .7rem; } .mark { min-height: 82px; } }
.card-overview { gap: .5rem; }
.scorecard-site { display: none; }
.scorecard-overview main { max-width: 68rem; }
.card-key { flex-wrap: wrap; gap: .2rem 1rem; }
.card-key .link { padding: .2rem .35rem; }
.card-table { min-width: 0; container-type: inline-size; }
.paper-sheet { --paper-rule: #99968f; --paper-heading: #ebe8e0; background: white; color: var(--ink); border: 2px solid var(--ink); font-variant-numeric: tabular-nums; }
.paper-sheet th, .paper-sheet td { border: 1px solid var(--paper-rule); padding: 0; }
.paper-sheet thead th { background: var(--paper-heading); font-size: clamp(.5rem, 2vw, .78rem); font-weight: 750; white-space: nowrap; }
.paper-sheet thead tr:first-child th { height: 32px; }
.paper-sheet thead tr:last-child th { height: 18px; border-bottom: 2px solid var(--ink); }
.paper-sheet th[rowspan] { border-bottom: 2px solid var(--ink); }
.paper-sheet tbody tr { height: 38px; }
.paper-sheet .paper-group { border-left: 2px solid var(--ink); }
.paper-sheet .paper-name { width: clamp(3.25rem, 15vw, 9rem); }
.paper-sheet .paper-option { width: clamp(1rem, 6vw, 2.25rem); }
.paper-sheet .paper-total { width: clamp(1.5rem, 8vw, 3.5rem); }
.paper-station { display: block; width: calc(100% - 2px); height: 100%; margin-inline: auto; padding: 0; border: 0; background: transparent; color: inherit; font-weight: inherit; }
.paper-station:focus-visible { outline-offset: -3px; }
.paper-long { display: none; }
.paper-sheet th[scope="row"] { text-align: left; padding-inline: .18rem; background: white; }
.paper-shooter { display: -webkit-box; overflow: hidden; overflow-wrap: anywhere; -webkit-box-orient: vertical; -webkit-line-clamp: 2; font-size: clamp(.62rem, 2.5vw, .88rem); }
.paper-mark { position: relative; font: 750 clamp(.53rem, 2.6vw, 1rem)/1 ui-monospace, monospace; }
.paper-mark[data-mark="Miss"] { color: var(--red-dark); }
.paper-box { position: absolute; inset: 0; width: 100%; height: 100%; padding: 0; border: 0; color: inherit; background: transparent; }
.paper-box:focus-visible { outline-offset: -2px; }
.paper-option-station { display: block; margin-top: .1rem; color: var(--muted); font: 650 clamp(.45rem, 1.8vw, .68rem)/1 -apple-system, BlinkMacSystemFont, sans-serif; }
.paper-score { font-size: clamp(.53rem, 2.35vw, .9rem); font-weight: 750; overflow-wrap: anywhere; }
.paper-editor { position: fixed; inset: auto 0 0; width: min(100%, 28rem); max-width: 100%; margin: 0 auto;
  padding: .9rem .85rem calc(.9rem + env(safe-area-inset-bottom)); border: 1px solid var(--line);
  border-radius: 14px 14px 0 0; background: var(--surface); color: var(--ink); }
.paper-editor::backdrop { background: #10111255; }
.paper-editor h2 { overflow-wrap: anywhere; }
.paper-editor-marks { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: .5rem; }
@media (min-width: 760px) and (min-height: 440px) {
  .paper-sheet thead th { font-size: .62rem; }
  .paper-long { display: inline; }
  .paper-short { display: none; }
}
@media (max-width: 600px), (max-height: 600px) {
  .scorecard-overview .top { display: none; }
  .scorecard-overview main {
    padding: calc(.4rem + env(safe-area-inset-top)) max(.3rem, env(safe-area-inset-right))
      calc(.4rem + env(safe-area-inset-bottom)) max(.3rem, env(safe-area-inset-left));
  }
  .card-overview {
    display: flex; flex-direction: column; gap: .3rem;
    height: min(37rem, calc(100vh - .8rem - env(safe-area-inset-top) - env(safe-area-inset-bottom)));
    height: min(37rem, calc(100dvh - .8rem - env(safe-area-inset-top) - env(safe-area-inset-bottom)));
  }
  .card-overview > :not(.card-table) { flex: 0 0 auto; }
  .card-overview h1 { font-size: clamp(1.35rem, 5.6vw, 1.85rem); }
  .card-title { display: grid; gap: .12rem; min-width: 0; }
  .scorecard-site { display: block; justify-self: start; color: var(--muted); font-size: .72rem; font-weight: 700; line-height: 1.2; }
  .card-overview .small { font-size: .76rem; }
  .card-table { flex: 1 1 0; min-height: 0; max-height: calc(3.125rem + var(--shooter-rows) * 3rem); container-type: size; }
  .paper-sheet { height: 100%; }
  .paper-sheet tbody tr { height: auto; }
  .enlarged .paper-sheet { height: 100cqh; }
}
@media (min-width: 500px) and (max-height: 390px) {
  .card-title { display: flex; align-items: baseline; gap: .65rem; }
  .scorecard-site { order: 1; }
}
@media (max-height: 390px) {
  .card-overview { gap: .15rem; }
  .card-overview .link, .card-overview .primary, .card-overview .secondary { min-height: 32px; padding-block: .25rem; }
  .paper-sheet thead tr:first-child th { height: 24px; }
  .paper-sheet thead tr:last-child th { height: 13px; }
  .paper-shooter { display: block; white-space: nowrap; text-overflow: ellipsis; }
  .paper-option-station { display: inline; margin-inline-start: .12rem; }
}
.card-overview.enlarged .card-table { overflow: auto; overscroll-behavior-x: contain; }
@media (min-width: 601px) and (min-height: 601px) {
  .card-overview.enlarged .card-table { max-height: 68vh; }
}
.enlarged .paper-sheet { width: 100cqw; zoom: 2; }
.enlarged .paper-sheet thead { position: sticky; top: 0; z-index: 2; background: var(--paper-heading); }
.card-overview.enlarged .paper-sheet thead th {
  /* Collapsed borders can sit behind the sticky header. Paint its dividers on the cells. */
  border-color: transparent;
  box-shadow: inset var(--heading-left, 1px) 0 var(--heading-left-color, var(--paper-rule)),
    inset 0 var(--heading-bottom, -1px) var(--heading-bottom-color, var(--paper-rule));
}
.enlarged .paper-sheet thead .paper-group {
  --heading-left: 2px;
  --heading-left-color: var(--ink);
}
.enlarged .paper-sheet thead :is(th[rowspan], tr:last-child th) {
  --heading-bottom: -2px;
  --heading-bottom-color: var(--ink);
}
.enlarged .paper-sheet th[scope="row"], .enlarged .paper-sheet th[scope="col"]:first-child[rowspan],
.enlarged .station-sheet thead th:first-child {
  position: sticky; left: 0; z-index: 1;
}
.station-sheet thead tr:first-child th { height: 32px; }
.trap-sheet thead th, .issf-skeet-sheet thead tr:last-child th { font-size: clamp(.43rem, 1.6vw, .78rem); }
.station-count { position: relative; font-size: clamp(.55rem, 2.5vw, .9rem); font-weight: 650; overflow-wrap: anywhere; }
.card-new { display: flex; align-items: center; gap: .5rem; min-height: 44px; font-weight: 650; }
.card-new input { width: 20px; height: 20px; accent-color: var(--red); }
.sheet th small { display: block; font-weight: 500; }
