body{margin:0;background:#f3f5f2;color:#18332b}main{max-width:560px;margin:auto;padding:20px}header{border-bottom:2px solid #c6d7cc;padding-bottom:16px}.eyebrow{font-size:.75rem;font-weight:700;letter-spacing:.1em}h1{font-size:1.8rem}label{display:block;margin:12px 0}input,select,button{font:inherit;min-height:48px;border-radius:8px}input,select{width:100%;box-sizing:border-box;padding:10px}button{padding:10px 16px;cursor:pointer}button:disabled{opacity:.55;cursor:default}.hole-nav,.stroke-control{display:flex;gap:12px;align-items:center;justify-content:center}.hole-nav label{flex:1}.stroke-control label{width:150px;text-align:center}.stroke-control input{font-size:2rem;text-align:center}.stroke-control button{font-size:1.5rem;min-width:48px}#save,#login button{width:100%;background:#175b43;color:white;border:0;margin:12px 0}#message{min-height:24px;padding:12px;background:#e3eee7}.error{color:#8a1c1c!important}#groupScores{list-style:none;padding:0}#groupScores li{display:flex;justify-content:space-between;padding:14px;border-bottom:1px solid #c6d7cc}#history li{margin-bottom:12px;overflow-wrap:anywhere}[hidden]{display:none!important}@media(max-width:360px){main{padding:12px}.stroke-control{gap:8px}}

#leaderboard{list-style:none;padding:0}#leaderboard li{padding:12px 0;border-bottom:1px solid #c6d7cc;overflow-wrap:anywhere}

/* Override the shared review layout only on the tournament page. */
main {
  width: 100%;
  box-sizing: border-box;
  grid-template-columns: minmax(0, 1fr);
}
main > *, header > *, form, label { min-width: 0; }
header {
  display: grid;
  grid-template-columns: minmax(0, 1fr);
  justify-items: start;
  gap: 8px;
  overflow-wrap: anywhere;
}
header p, header h1 { margin: 0; }
input, select, button { max-width: 100%; }
input, select { min-width: 0; font-size: 16px; }
button { min-width: 48px; white-space: normal; }
.hole-nav {
  display: grid;
  grid-template-columns: 48px minmax(0, 1fr) 48px;
}
.stroke-control {
  display: grid;
  grid-template-columns: 48px minmax(0, 150px) 48px;
}
.stroke-control label { width: auto; }
#message, #round, #saved, #groupScores li, #leaderboard li, .muted {
  overflow-wrap: anywhere;
}
summary {
  display: flex;
  align-items: center;
  min-height: 48px;
  overflow-wrap: anywhere;
}

.championship-tabs {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 8px;
  margin: 12px 0 18px;
}
.championship-tabs button {
  border: 1px solid #789889;
  background: #fff;
  color: #18332b;
  font-weight: 700;
  padding: 8px;
}
.championship-tabs button[aria-current="page"] {
  background: #175b43;
  color: #fff;
}
#cupView, #beltView { min-width: 0; overflow-wrap: anywhere; }
#cupSchedule, #cupBlockers, #beltBlockers { padding-left: 1.25rem; }
#cupSchedule li, #cupBlockers li, #beltBlockers li { margin: 8px 0; }
#cupMatches, #beltStandings { padding-left: 1.25rem; }
#cupMatches li, #beltStandings li { margin: 8px 0; overflow-wrap: anywhere; }
#scrambleEntry { margin-top: 20px; padding: 14px; border: 1px solid #c6d7cc; border-radius: 10px; }
#scrambleForm button { width: 100%; background: #175b43; color: #fff; border: 0; }
#scrambleSaved { min-height: 24px; }

/* Outrank shared input:not([type=checkbox]) font inheritance at login. */
#password { font-size: 16px; }

/* Mobile scoring: primary action stays in the score card; Mayhem never writes. */
main { padding: 12px; }
header { padding: 12px; gap: 4px; border-radius: 12px; }
header h1 { font-size: 1.4rem; }
header #modeExplanation { font-size: .85rem; }
#message { margin: 8px 0; padding: 8px; }
.championship-tabs { display: flex; margin: 8px 0; }
.championship-tabs button { flex: 1; }
#scoreForm { margin: 8px 0; padding: 14px; border-radius: 16px; }
#scoreContext { margin: 0 0 8px; font-size: 1.25rem; overflow-wrap: anywhere; }
#scoreForm label, .hole-nav label { margin: 4px 0; }
.hole-nav { gap: 8px; }
.stroke-control { grid-template-columns: 64px minmax(0, 1fr) 64px; gap: 12px; }
.stroke-control button { min-height: 72px; font-size: 2.25rem; touch-action: manipulation; }
#strokes { font-size: 2.75rem; font-weight: 700; min-height: 76px; padding: 4px; }
#saved { margin: 8px 0; min-height: 20px; }
#save { min-height: 56px; margin: 0; font-size: 1.15rem; font-weight: 700; }
#mayhem { margin: 8px 0; padding: 0 12px; border: 1px solid #c6d7cc; border-radius: 10px; }
#mayhem summary { font-weight: 600; cursor: pointer; }
#mayhem p { overflow-wrap: anywhere; }
button:focus-visible, summary:focus-visible, select:focus-visible, input:focus-visible { outline: 3px solid #ba7400; outline-offset: 3px; }
@media (orientation: landscape) and (min-width: 640px) {
  main { max-width: 820px; }
  #scoreForm { display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 1fr); gap: 8px 20px; align-items: center; }
  #scoreContext { grid-column: 1 / -1; }
  .stroke-control { grid-column: 2; grid-row: 2 / 4; }
  #saved { grid-column: 1; }
  #save { grid-column: 1 / -1; }
}

main { gap: 4px; }
header { grid-template-columns: minmax(0, 1fr) auto; }
header > * { grid-column: 1; }
#logout { grid-column: 2; grid-row: 2 / 4; }
#modeLabel, #modeExplanation { grid-column: 1 / -1; }
#round { margin: 4px 0; font-size: .85rem; }

/* V3 scorecard-first interface: one golfer-by-hole paper card for every orientation. */
:root { --card-paper:#fbf6e8; --card-ink:#203c32; --card-green:#245b46; --card-rule:#b7c2a8; }
body { background:#f4f5ef; color:var(--card-ink); }
main { width:100%; max-width:920px; margin:auto; padding:8px; gap:2px; }
header { display:flex; align-items:center; justify-content:space-between; gap:8px; padding:5px 8px; border-bottom:1px solid #cbd4c8; }
header > * { margin:0; }
header #modeLabel, header #modeExplanation, header #tournamentName { display:none; }
header h1 { font-size:18px; letter-spacing:0; }
header #identity { font-size:11px; }
#message { min-height:18px; margin:0; padding:2px 6px; font-size:12px; }
.championship-tabs { gap:4px; margin:2px 0 4px; }
.championship-tabs button { min-height:30px; padding:3px 6px; font-size:12px; }
#scoreView { min-width:0; }
#rapidCard { min-width:0; margin:0; padding:5px; background:var(--card-paper); border:1px solid #d0c5a7; border-radius:8px; box-shadow:0 1px 4px #23382b18; }
.rapid-card-heading { display:flex; align-items:baseline; justify-content:space-between; gap:8px; }
.rapid-card-heading h2 { margin:0; font:600 15px Georgia,serif; }
#draftStatus { margin:0; font-size:10px; text-align:right; }
.paper-scorecard-wrap { position:sticky; top:0; z-index:5; min-width:0; overflow:hidden; background:var(--card-paper); }
.scorecard-table { width:100%; table-layout:fixed; border-collapse:collapse; color:var(--card-ink); background:var(--card-paper); font-family:Georgia,'Times New Roman',serif; font-variant-numeric:tabular-nums; }
.scorecard-table th,.scorecard-table td { border:1px solid var(--card-rule); text-align:center; padding:1px; overflow:hidden; }
.scorecard-table thead tr:first-child { height:19px; background:var(--card-green); color:#fffdf4; font-size:9px; letter-spacing:.04em; }
.scorecard-table thead tr:nth-child(2) { height:18px; background:#e8eadc; font:600 10px system-ui,sans-serif; }
.scorecard-table thead tr:first-child th:first-child { width:72px; }
.scorecard-table thead [data-full-total] { width:39px; }
.scorecard-table thead [data-portrait-total] { width:31px; }
.scorecard-table tbody tr { height:39px; }
.scorecard-table tbody th { width:72px; padding:2px; text-align:left; font:600 10px system-ui,sans-serif; line-height:1.05; overflow-wrap:anywhere; }
.scorecard-table tbody td { font:600 10px system-ui,sans-serif; }
.scorecard-table tbody tr.par-row { height:22px; background:#eeeedf; color:#4f6254; }
.scorecard-table td[data-full-total] { width:39px; font-weight:700; }
.scorecard-table td[data-portrait-total] { width:31px; font-weight:700; }
.scorecard-table [data-half="back"] { border-left:2px solid #74836d; }
.scorecard-table [data-hole="10"] { border-left:2px solid #74836d; }
.score-cell { position:relative; display:flex; width:100%; min-width:0; min-height:35px; align-items:center; justify-content:center; padding:0; border:1px solid transparent; border-radius:4px; background:transparent; color:inherit; touch-action:manipulation; }
.score-cell.selected { outline:3px solid var(--card-green); outline-offset:-3px; background:#e8efd9; }
.score-cell.draft { border-style:dashed; background:#fff0c2; }
.cell-state { position:absolute; right:1px; bottom:0; font:600 6px/1 system-ui,sans-serif; color:#586450; }
.score-mark { display:inline-flex; width:24px; height:24px; flex:none; align-items:center; justify-content:center; border:1.5px solid transparent; border-radius:0; font:700 16px/1 Georgia,serif; }
.score-mark.circle,.score-mark.double-circle { border-color:currentColor; border-radius:50%; }
.score-mark.square,.score-mark.double-square { border-color:currentColor; }
.score-mark.double-circle,.score-mark.double-square { outline:1px solid currentColor; outline-offset:1px; }
#rapidCard[data-nine="front"] [data-half="back"], #rapidCard[data-nine="back"] [data-half="front"] { display:none; }
.scorecard-table [data-full-total] { display:none; }
.scorecard-table [data-portrait-total] { display:table-cell; }
.nine-nav { display:flex; gap:5px; margin:4px 0 0; }
.nine-nav button { min-width:0; min-height:29px; flex:1; padding:3px 6px; border:1px solid #a7b49f; background:#f9f5e9; color:var(--card-ink); font-size:11px; }
#cameraStatus { display:inline; margin:0 0 0 4px; font-size:8px; color:#606b5b; }
#rapidKeypad { display:block; margin:3px 0 0; padding:3px 0; border:0; background:transparent; }
.keypad-context { display:flex; align-items:baseline; justify-content:space-between; gap:6px; }
#rapidContext { margin:0; font:600 13px Georgia,serif; }
#parContext { margin:0; font-size:10px; }
.number-keys { display:grid; grid-template-columns:repeat(3,minmax(0,1fr)); gap:3px; }
.number-keys button { display:flex; min-width:0; min-height:46px; align-items:center; justify-content:center; gap:4px; padding:2px; border:1px solid #a9b5a5; background:#fffdf7; color:var(--card-ink); touch-action:manipulation; }
.number-keys .score-mark { width:30px; height:30px; font-size:20px; }
.number-keys small { font-size:9px; }
.rapid-actions { display:flex; gap:4px; margin-top:3px; }
.rapid-actions button { min-width:0; min-height:29px; flex:1; padding:2px 6px; }
#doubleEntry { display:flex; align-items:end; gap:6px; }
#doubleEntry label { flex:1; margin:3px 0; }
#doubleEntry input { min-height:38px; }
#useDouble { min-height:38px; }
#rapidNotice { min-height:14px; max-height:26px; margin:2px 0; overflow:hidden; font-size:10px; line-height:1.2; }
.save-actions { display:grid; grid-template-columns:minmax(0,1fr) auto; gap:5px; }
#saveNine { width:100%; min-width:0; min-height:44px; margin:0; background:var(--card-green); color:white; font-size:15px; font-weight:700; }
#retryNine,#discardDrafts { min-width:0; min-height:34px; padding:3px 7px; font-size:10px; }
.rapid-help { display:none; }
#singleEntry[hidden] { display:none !important; }
#roundNavigation { margin:3px 0; }
#roundNavigation summary { min-height:28px; font-size:11px; }
#roundNavigation .hole-nav { grid-template-columns:40px minmax(0,1fr) 40px; }
#roundNavigation button { min-width:0; min-height:36px; }
#mayhem { margin:3px 0; }
#mayhem summary { min-height:30px; }
#refresh { min-height:36px; }
@media (max-width:360px) and (orientation:portrait) {
  main { padding:3px; }
  header { padding:2px 4px; }
  header h1 { font-size:16px; }
  header #identity { max-width:145px; overflow:hidden; text-overflow:ellipsis; white-space:nowrap; }
  #message { min-height:15px; padding:1px 3px; font-size:10px; }
  .championship-tabs { margin:1px 0 2px; }
  .championship-tabs button { min-height:25px; padding:1px 2px; font-size:10px; }
  #rapidCard { padding:3px; border-radius:5px; }
  .rapid-card-heading h2 { font-size:13px; }
  #draftStatus { font-size:8px; }
  .scorecard-table thead tr:first-child { height:15px; font-size:8px; }
  .scorecard-table thead tr:nth-child(2) { height:15px; font-size:9px; }
  .scorecard-table thead tr:first-child th:first-child,.scorecard-table tbody th { width:54px; }
  .scorecard-table thead [data-portrait-total],.scorecard-table td[data-portrait-total] { width:26px; }
  .scorecard-table tbody tr { height:34px; }
  .scorecard-table tbody tr.par-row { height:17px; }
  .scorecard-table tbody th { font-size:8px; }
  .scorecard-table tbody td { font-size:9px; }
  .score-cell { min-height:31px; }
  .score-mark { width:20px; height:20px; font-size:14px; }
  .cell-state { font-size:5px; }
  .nine-nav { margin-top:2px; gap:3px; }
  .nine-nav button { min-height:25px; font-size:10px; }
  #cameraStatus { font-size:7px; }
  #rapidKeypad { margin-top:1px; padding:1px 0; }
  #rapidContext { font-size:12px; }
  #parContext { font-size:9px; }
  .number-keys { gap:2px; }
  .number-keys button { min-height:39px; gap:2px; }
  .number-keys .score-mark { width:26px; height:26px; font-size:17px; }
  .number-keys small { font-size:8px; }
  .rapid-actions { margin-top:2px; }
  .rapid-actions button { min-height:24px; font-size:10px; }
  #rapidNotice { min-height:10px; max-height:18px; margin:1px 0; font-size:8px; }
  #saveNine { min-height:39px; font-size:13px; }
  #retryNine,#discardDrafts { min-height:28px; font-size:9px; }
}
@media (orientation:landscape) and (min-width:640px) {
  main { max-width:none; padding:3px 6px; gap:0; }
  header { min-height:24px; padding:1px 4px; }
  header h1 { font-size:15px; }
  header #identity { font-size:9px; }
  #message { min-height:12px; padding:0 3px; font-size:9px; }
  .championship-tabs { display:none; }
  #rapidCard { padding:3px 5px; border-radius:4px; }
  .rapid-card-heading h2 { font-size:13px; }
  .scorecard-table thead tr:first-child { height:16px; font-size:8px; }
  .scorecard-table thead tr:nth-child(2) { height:15px; font-size:9px; }
  .scorecard-table thead tr:first-child th:first-child,.scorecard-table tbody th { width:80px; }
  .scorecard-table thead [data-full-total],.scorecard-table td[data-full-total] { display:table-cell; width:40px; }
  .scorecard-table [data-portrait-total] { display:none; }
  #rapidCard[data-nine="front"] [data-half="back"], #rapidCard[data-nine="back"] [data-half="front"] { display:table-cell; }
  .scorecard-table tbody tr { height:29px; }
  .scorecard-table tbody tr.par-row { height:18px; }
  .scorecard-table tbody th { font-size:9px; }
  .score-cell { min-height:27px; }
  .score-mark { width:21px; height:21px; font-size:14px; }
  .cell-state { font-size:5px; }
  .nine-nav { display:none; }
  #cameraStatus { position:absolute; right:8px; top:4px; font-size:8px; }
  #rapidKeypad { margin-top:1px; padding:0; }
  .keypad-context { justify-content:flex-start; gap:16px; }
  #rapidContext { font-size:11px; }
  #parContext { font-size:9px; }
  .number-keys { grid-template-columns:repeat(9,minmax(0,1fr)); gap:3px; }
  .number-keys button { min-height:36px; }
  .number-keys .score-mark { width:24px; height:24px; font-size:16px; }
  .number-keys small { font-size:8px; }
  .rapid-actions { display:none; }
  #rapidNotice { min-height:10px; max-height:14px; font-size:8px; }
  .save-actions { grid-template-columns:minmax(0,1fr) auto auto; }
  #saveNine { min-height:32px; font-size:12px; }
  #retryNine,#discardDrafts { min-height:28px; }
  #roundNavigation,#mayhem,#refresh,#scoringHelp,#leaderboard,#groupScores,#history { display:none; }
}

/* Beta visual pass: quiet paper grid, clear round context, and explicit save state. */
:root { --card-paper:#fffdf5; --card-ink:#20352d; --card-green:#1d5a43; --card-rule:#d8ddd2; --active-cell:#dbeadd; --draft-fill:#fff0c2; }
body { font-family:system-ui,-apple-system,BlinkMacSystemFont,"Segoe UI",sans-serif; background:#f3f5f1; color:var(--card-ink); }
main { max-width:1040px; gap:8px; padding:12px; }
header { border:0; padding:8px 4px; }
header h1 { font-size:clamp(1.2rem,4vw,1.7rem); font-weight:650; letter-spacing:-.025em; }
#message { border-radius:8px; }
#courseOrientation { display:grid; grid-template-columns:repeat(2,minmax(0,1fr)); gap:6px; padding:8px; border:1px solid #e1e5dd; border-radius:12px; background:#fff; }
#courseOrientation div { min-width:0; display:flex; flex-direction:column; gap:2px; padding:4px 6px; }
#courseOrientation span { color:#65746c; font-size:10px; font-weight:700; letter-spacing:.055em; text-transform:uppercase; }
#courseOrientation strong { overflow-wrap:anywhere; font-size:12px; line-height:1.2; font-weight:650; }
.championship-tabs { display:grid; grid-template-columns:repeat(2,minmax(0,1fr)); gap:6px; margin:4px 0 6px; }
.championship-tabs button { min-height:40px; border:1px solid #d6ddd4; border-radius:9px; background:#fff; color:var(--card-ink); font-size:12px; font-weight:650; }
.championship-tabs button[aria-current="page"] { border-color:var(--card-green); background:var(--card-green); color:#fff; box-shadow:0 2px 5px #173d2b24; }
#rapidCard { border:1px solid #e6e1d2; border-radius:12px; box-shadow:0 2px 8px #263a2b0c; }
.scorecard-table th,.scorecard-table td { border:0; border-bottom:1px solid #e3e5dc; }
.scorecard-table thead tr:first-child { border-bottom:0; }
.scorecard-table thead tr:nth-child(2),.scorecard-table tbody tr.par-row { background:#f0f1e8; }
.scorecard-table thead [data-half="back"],.scorecard-table tbody [data-half="back"],.scorecard-table [data-hole="10"] { border-left:1px solid #9aa998; }
.scorecard-table [data-full-total] { border-left:1px solid #ccd4c9; }
.scorecard-table tbody tr:not(.par-row) th { font-size:11px; }
.score-cell { border:1px solid transparent; border-radius:6px; }
.score-cell.selected { outline:2px solid var(--card-green); outline-offset:-2px; background:var(--active-cell); box-shadow:inset 0 0 0 1px #fff; }
.score-cell.draft { border:1px dashed #b87913; background:var(--draft-fill); }
.cell-state { right:1px; bottom:0; padding:0 1px; border-radius:3px; font-size:5px; }
.cell-state.is-draft { color:#764700; background:#ffe4a2; }
.cell-state.is-saved { color:#15563d; background:#e1efe5; }
#draftStatus { flex:none; padding:4px 8px; border-radius:999px; background:#e1efe5; color:#16573d; font-size:10px; font-weight:800; letter-spacing:.035em; }
#draftStatus[data-state="saved"] { background:#e1efe5; color:#16573d; }
#draftStatus[data-state="draft"] { background:#fff0c2; color:#714500; }
#draftStatus[data-state="saving"] { background:#e5edf8; color:#284c75; }
.rapid-card-heading { gap:6px; }
.rapid-card-heading h2 { font-size:16px; }
.number-keys button { border:1px solid #d6ddd4; border-radius:10px; background:#fff; }
.number-keys button:active,.nine-nav button:active { transform:translateY(1px); }
#saveNine { border-radius:10px; background:#1d5a43; box-shadow:0 2px 5px #173d2b24; }
#retryNine,#discardDrafts { border:1px solid #d6ddd4; border-radius:9px; background:#fff; }
#rulesView { padding:4px 2px 20px; }
#rulesView h2 { margin:8px 0 4px; font-size:1.35rem; letter-spacing:-.02em; }
#rulesView > section { margin:10px 0; padding:12px; border:1px solid #e1e5dd; border-radius:12px; background:#fff; }
#rulesView h3 { margin:0 0 6px; font-size:1rem; }
#rulesView ul { margin:0; padding-left:1.2rem; }
#rulesView li { margin:7px 0; line-height:1.45; }
#rulesView section:last-of-type { border-color:#ead8b3; background:#fffaf0; }
#rulesSource { font-size:12px; }
#rulesLoadStatus { min-height:20px; color:#4e6257; font-size:12px; }
button:focus-visible,summary:focus-visible,select:focus-visible,input:focus-visible { outline:3px solid #bd7a15; outline-offset:2px; }
@media (min-width:680px) and (orientation:portrait) {
  #courseOrientation { grid-template-columns:repeat(5,minmax(0,1fr)); }
  .championship-tabs { grid-template-columns:repeat(4,minmax(0,1fr)); }
}
@media (max-width:360px) and (orientation:portrait) {
  main { padding:4px; gap:5px; }
  #courseOrientation { gap:2px; padding:5px; border-radius:8px; }
  #courseOrientation div { padding:3px; }
  #courseOrientation span { font-size:8px; }
  #courseOrientation strong { font-size:10px; }
  .championship-tabs button { min-height:34px; font-size:11px; }
  #draftStatus { padding:3px 5px; font-size:8px; }
  .scorecard-table tbody tr:not(.par-row) th { font-size:9px; }
}
@media (orientation:landscape) and (min-width:640px) {
  .championship-tabs { display:grid; grid-template-columns:repeat(2,minmax(0,130px)); justify-content:start; margin:2px 0 4px; }
  .championship-tabs button { min-height:28px; padding:2px 6px; font-size:10px; }
  #courseOrientation { grid-template-columns:repeat(5,minmax(0,1fr)); gap:4px; padding:4px 8px; }
  #courseOrientation div { padding:1px 4px; }
  #courseOrientation span { font-size:8px; }
  #courseOrientation strong { font-size:10px; }
}

/* P1 mobile pass: keep identity, hole, par, scores, and save action in the first view. */
@media (max-width: 679px) {
  main { padding: 4px; gap: 3px; }
  header { min-height: 32px; padding: 1px 4px; gap: 6px; border: 0; background: transparent; color: var(--card-ink); }
  header h1 { font-size: 16px; }
  header #identity { margin-left: auto; font-size: 10px; }
  #logout { min-height: 30px; padding: 3px 8px; font-size: 11px; }
  #message:empty { display: none; }
  #message { min-height: 0; margin: 1px 0; padding: 3px 6px; border-radius: 6px; font-size: 10px; line-height: 1.2; }
  #courseOrientation { display: grid; grid-template-columns: repeat(2,minmax(0,1fr)); }
  #roundInfo { margin: 4px 0; }
  #roundInfo summary { min-height: 28px; font-size: 11px; }
  .championship-tabs { display: grid; grid-template-columns: repeat(4,minmax(0,1fr)); gap: 3px; margin: 1px 0 3px; }
  .championship-tabs button { min-height: 34px; padding: 2px 3px; font-size: 9px; line-height: 1.1; }
  #rapidCard { padding: 3px; border-radius: 8px; }
  .rapid-card-heading { min-height: 18px; justify-content: flex-end; gap: 3px; }
  .rapid-card-heading h2 { display: none; }
  #draftStatus { margin: 0; padding: 2px 7px; font-size: 9px; }
  .keypad-context { min-height: 35px; align-items: center; gap: 5px; padding: 1px 3px 3px; }
  #rapidContext { font: 700 17px/1.1 system-ui,-apple-system,sans-serif; letter-spacing: -.02em; }
  #parContext { font-size: 11px; font-weight: 700; text-align: right; }
  .paper-scorecard-wrap { overflow-x: auto; overflow-y: hidden; -webkit-overflow-scrolling: touch; }
  .scorecard-table { width: 100%; min-width: 0; }
  .scorecard-table thead tr:first-child { height: 17px; font-size: 8px; }
  .scorecard-table thead tr:nth-child(2) { height: 17px; font-size: 9px; }
  .scorecard-table thead tr:first-child th:first-child,.scorecard-table tbody th { width: 58px; }
  .scorecard-table thead [data-portrait-total],.scorecard-table td[data-portrait-total] { width: 28px; }
  .scorecard-table tbody tr { height: 34px; }
  .scorecard-table tbody tr.par-row { height: 18px; }
  .scorecard-table tbody th { padding: 1px 2px; font-size: 9px; }
  .scorecard-table tbody td { font-size: 9px; }
  .score-cell { min-height: 31px; border-radius: 4px; }
  .score-mark { width: 22px; height: 22px; font: 700 14px/1 system-ui,-apple-system,sans-serif; }
  .score-mark.double-circle { color: #fff; background: #1d5a43; }
  .score-mark.circle { color: #15563d; background: #dceee3; }
  .score-mark.square { color: #684700; background: #fff0c2; }
  .score-mark.double-square { color: #842d22; background: #f5dfd9; }
  .score-mark:not(.double-circle):not(.circle):not(.square):not(.double-square) { color: inherit; background: transparent; }
  .cell-state { display: none; }
  .nine-nav { gap: 4px; margin: 3px 0 0; }
  .nine-nav button { min-height: 28px; padding: 2px 4px; font-size: 10px; }
  #cameraStatus { display: none; }
  #rapidKeypad { margin: 1px 0 0; padding: 0; }
  .number-keys { gap: 4px; }
  .number-keys button { min-height: 48px; flex-direction: column; gap: 0; padding: 1px; border-radius: 8px; }
  .number-keys .score-mark { width: 26px; height: 25px; font-size: 18px; }
  .number-keys small { font-size: 8px; line-height: 1; letter-spacing: .015em; }
  .rapid-actions { gap: 4px; margin-top: 2px; }
  .rapid-actions button { min-height: 28px; padding: 1px 5px; font-size: 11px; }
  #rapidNotice { min-height: 12px; max-height: 22px; margin: 1px 0; font-size: 9px; line-height: 1.1; }
  .save-actions { grid-template-columns: minmax(0,1fr) auto; gap: 4px; }
  #saveNine { min-height: 46px; border-radius: 8px; font-size: 14px; }
  #discardDrafts,#retryNine { min-height: 32px; padding: 2px 6px; font-size: 9px; }
  #roundNavigation { margin: 2px 0; }
}
@media (max-width: 360px) and (orientation: portrait) {
  main { padding: 2px; gap: 2px; }
  header { min-height: 29px; padding: 0 3px; gap: 4px; }
  header h1 { font-size: 15px; }
  header #identity { max-width: 122px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
  header #logout { min-height: 28px; padding: 2px 6px; }
  .championship-tabs button { min-height: 31px; padding: 1px 2px; font-size: 8px; }
  #rapidCard { padding: 2px; }
  #rapidContext { font-size: 15px; }
  #parContext { font-size: 10px; }
  .scorecard-table thead tr:first-child th:first-child,.scorecard-table tbody th { width: 49px; }
  .scorecard-table thead [data-portrait-total],.scorecard-table td[data-portrait-total] { width: 25px; }
  .scorecard-table tbody tr { height: 31px; }
  .score-cell { min-height: 28px; }
  .score-mark { width: 20px; height: 20px; font-size: 13px; }
  .nine-nav button { min-height: 26px; font-size: 9px; }
  .number-keys { gap: 3px; }
  .number-keys button { min-height: 46px; }
  .number-keys .score-mark { width: 23px; height: 22px; font-size: 16px; }
  .number-keys small { font-size: 7px; }
  #rapidNotice { min-height: 11px; max-height: 18px; font-size: 8px; }
  #saveNine { min-height: 43px; font-size: 13px; }
}
@media (orientation: landscape) and (min-width: 640px) and (max-height: 500px) {
  main { max-width: none; padding: 3px 6px; gap: 1px; }
  header { min-height: 27px; padding: 0 4px; border: 0; background: transparent; color: var(--card-ink); }
  header h1 { font-size: 15px; }
  header #identity { color: var(--card-ink); font-size: 9px; }
  header #logout { min-height: 27px; padding: 1px 8px; font-size: 10px; }
  #message:empty { display: none; }
  #message { min-height: 0; margin: 0; padding: 1px 4px; font-size: 9px; }
  .championship-tabs { grid-template-columns: repeat(2,minmax(0,110px)); gap: 3px; margin: 1px 0 2px; }
  .championship-tabs button { min-height: 25px; padding: 1px 4px; font-size: 9px; }
  #rapidCard { padding: 2px 4px; border-radius: 6px; }
  .rapid-card-heading { min-height: 15px; }
  .rapid-card-heading h2 { display: none; }
  #draftStatus { padding: 1px 6px; font-size: 8px; }
  .keypad-context { min-height: 22px; padding: 0 2px 2px; }
  #rapidContext { font: 700 13px/1.1 system-ui,-apple-system,sans-serif; }
  #parContext { font-size: 9px; }
  .scorecard-table thead tr:first-child { height: 13px; font-size: 7px; }
  .scorecard-table thead tr:nth-child(2) { height: 13px; font-size: 8px; }
  .scorecard-table thead tr:first-child th:first-child,.scorecard-table tbody th { width: 65px; }
  .scorecard-table tbody tr { height: 22px; }
  .scorecard-table tbody tr.par-row { height: 13px; }
  .scorecard-table tbody th,.scorecard-table tbody td { font-size: 8px; }
  .score-cell { min-height: 20px; }
  .score-mark { width: 18px; height: 18px; font: 700 12px/1 system-ui,-apple-system,sans-serif; }
  .score-mark.double-circle { color: #fff; background: #1d5a43; }
  .score-mark.circle { color: #15563d; background: #dceee3; }
  .score-mark.square { color: #684700; background: #fff0c2; }
  .score-mark.double-square { color: #842d22; background: #f5dfd9; }
  .score-mark:not(.double-circle):not(.circle):not(.square):not(.double-square) { color: inherit; background: transparent; }
  .cell-state { display: none; }
  .number-keys { grid-template-columns: repeat(9,minmax(0,1fr)); gap: 3px; }
  .number-keys button { min-height: 35px; flex-direction: column; gap: 0; padding: 0; border-radius: 6px; }
  .number-keys .score-mark { width: 18px; height: 17px; font-size: 12px; }
  .number-keys small { font-size: 7px; line-height: 1; }
  .rapid-actions { display: flex; margin-top: 1px; }
  .rapid-actions button { min-height: 24px; font-size: 9px; }
  #rapidNotice { min-height: 9px; max-height: 12px; margin: 0; font-size: 7px; }
  .save-actions { grid-template-columns: minmax(0,1fr) auto; gap: 3px; }
  #saveNine { min-height: 31px; font-size: 11px; }
  #discardDrafts,#retryNine { min-height: 25px; font-size: 8px; }
  #roundNavigation,#roundInfo,#mayhem,#refresh,#scoringHelp,#leaderboard,#groupScores,#history { display: none; }
}

/* P1 mobile header polish: make the grouped labels legible and keep them
   centered over the same columns as their score cells. */
.scorecard-table thead tr:first-child th {
  box-sizing: border-box;
  color: #fffdf5;
  text-align: center;
  vertical-align: middle;
  padding: 0;
  line-height: 1;
}
.scorecard-table thead tr:first-child th[data-half],
.scorecard-table thead tr:first-child th[data-full-total],
.scorecard-table thead tr:first-child th[data-portrait-total] {
  text-align: center;
}
@media (max-width: 679px) {
  .scorecard-table thead tr:first-child { height: 13px; }
}
@media (orientation: landscape) and (min-width: 640px) and (max-height: 500px) {
  .scorecard-table thead tr:first-child { height: 11px; }
}
