:root {
  color-scheme: light;
  font-family: system-ui, sans-serif;
  color: #1a2f38;
  background: #f3f7f8;
  line-height: 1.5;
}

* { box-sizing: border-box; }
[hidden] { display: none !important; }
main { max-width: 820px; margin: 0 auto; padding: 24px 20px 48px; }
h1, h2, h3, p { margin: 0 0 10px; }
h1 { font-size: clamp(2rem, 7vw, 3.25rem); line-height: 1; }
h2 { font-size: clamp(1.45rem, 4vw, 2rem); line-height: 1.15; }
.masthead { display: flex; align-items: flex-start; justify-content: space-between; gap: 12px; border-bottom: 1px solid #c9d8dc; margin-bottom: 24px; padding-bottom: 20px; }
.brand { min-width: 0; }
.brand h1 { margin: 0; }
.host-tools { display: flex; flex-shrink: 0; align-items: center; gap: 8px; }
.icon-button { display: inline-flex; align-items: center; justify-content: center; width: 44px; min-width: 44px; height: 44px; padding: 10px; }
.icon-button svg { width: 22px; height: 22px; fill: none; stroke: currentColor; stroke-width: 2; }
.icon-button .dots-icon { fill: currentColor; stroke: none; }
.icon-button[aria-pressed="true"] { background: #d2e8df; }
.host-actions { position: relative; }
.player-actions { position: relative; justify-self: end; }
.player-actions-panel { min-width: 168px; padding: 6px; }
.player-actions-panel.opens-up { top: auto; bottom: calc(100% + 8px); }
.player-actions-panel button { display: block; width: 100%; white-space: nowrap; text-align: left; color: #a33131; }
.dropdown-panel { position: absolute; z-index: 20; right: 0; top: calc(100% + 8px); padding: 16px; border: 1px solid #bccfd6; border-radius: 12px; background: #fff; box-shadow: 0 8px 28px #18394026; }
.host-actions-panel { width: min(340px, calc(100vw - 32px)); max-height: min(70vh, calc(100dvh - 96px)); overflow-y: auto; }
.host-actions-items { display: grid; gap: 8px; }
.host-actions-items button, .host-actions-items a { text-align: left; justify-content: flex-start; }
.host-actions-panel .legend { margin-top: 12px; }
.host-actions-panel .invitations { margin: 12px 0 0; padding-top: 12px; border-top: 1px solid #d8e3e3; }
.host-actions-panel .invitation-content { grid-template-columns: 1fr; gap: 12px; }
.host-actions-panel .join-qr { margin-inline: auto; }
.host-actions-panel #invite-code { font-size: 1.7rem; }
.eyebrow { color: #375f60; font-size: .78rem; font-weight: 750; letter-spacing: .09em; text-transform: uppercase; }
.home-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(min(100%, 250px), 1fr)); gap: 16px; margin-top: 20px; }
.panel { background: #fff; border: 1px solid #c9d8dc; border-radius: 16px; padding: 20px; }
form { display: grid; align-content: start; gap: 8px; }
label { font-weight: 650; }
input, button, select { font: inherit; min-height: 44px; border-radius: 8px; }
input, select { width: 100%; border: 1px solid #82989d; padding: 8px 10px; color: inherit; background: white; }
input + label { margin-top: 4px; }
button { border: 1px solid #174b52; background: #174b52; color: white; padding: 8px 14px; font-weight: 700; cursor: pointer; }
button.secondary { background: #fff; color: #174b52; }
.download-link { display: inline-flex; align-items: center; min-height: 44px; border: 1px solid #174b52; border-radius: 8px; background: #fff; color: #174b52; padding: 8px 14px; font-weight: 700; }
button:disabled { opacity: .55; cursor: default; }
form button { margin-top: 8px; justify-self: start; }
#notice { background: #fff4e3; border: 1px solid #e1bd81; border-radius: 8px; padding: 10px 12px; color: #683818; }
.room-code, .timer, .standings { font-variant-numeric: tabular-nums; }
.room-code { font-size: clamp(1.7rem, 5vw, 2.75rem); letter-spacing: .07em; }
.roster { display: flex; flex-wrap: wrap; gap: 8px; padding: 0; list-style: none; }
.roster li { border-radius: 6px; padding: 4px 9px; background: #eaf3f0; overflow-wrap: anywhere; }
.roster button { margin-left: 8px; }
.round-header, .actions { display: flex; align-items: center; justify-content: space-between; gap: 10px; flex-wrap: wrap; }
.actions { justify-content: flex-start; margin-top: 12px; }
.timer { color: #1a4f61; font-weight: 800; font-size: 1.4rem; }
#board { display: block; width: 100%; height: auto; max-height: 55vh; background: #e4eff4; border: 1px solid #bccfd6; border-radius: 12px; }
#host-map-svg { display: block; width: 100%; height: auto; max-height: 55vh; background: #e4eff4; border: 1px solid #bccfd6; border-radius: 12px; }
#host-outline { fill: #d2e8df; stroke: #315e58; stroke-width: 2; }
#your-round { margin: 12px 0 20px; }
#your-round-map { display: block; width: 100%; max-height: 55vh; background: #e4eff4; border: 1px solid #bccfd6; border-radius: 12px; }
#your-round-outline { fill: #d2e8df; stroke: #315e58; stroke-width: 2; }
#your-round-guess, #your-round-answer { fill: none; stroke-linecap: round; stroke-linejoin: round; stroke-width: 3; vector-effect: non-scaling-stroke; pointer-events: none; }
#your-round-guess { stroke: #1552b6; }
#your-round-answer { stroke: #197146; }
#board.drawing { cursor: crosshair; touch-action: none; }
#outline { fill: #d2e8df; stroke: #315e58; stroke-width: 2; }
#guess, #answer { fill: none; stroke-linecap: round; stroke-linejoin: round; stroke-width: 3; vector-effect: non-scaling-stroke; pointer-events: none; }
#guess { stroke: #1552b6; }
#answer { stroke: #197146; }
#results { margin-top: 12px; }
.legend, #progress, #results-wait { color: #395962; font-size: .94rem; }
.standings-scroll { overflow-x: auto; }
.standings { width: 100%; min-width: 540px; border-collapse: collapse; text-align: left; }
.standings th, .standings td { padding: 6px 7px; border-bottom: 1px solid #c9d8dc; overflow-wrap: anywhere; }
.standings th:nth-child(4), .standings td:nth-child(4),
.standings th:nth-child(5), .standings td:nth-child(5) { text-align: right; }
.rank-up { color: #176b3a; font-weight: 700; }
.rank-down { color: #a33131; font-weight: 700; }
.score-breakdown { display: grid; grid-template-columns: repeat(auto-fit, minmax(min(100%, 220px), 1fr)); gap: 12px; margin: 12px 0; }
.score-breakdown div { padding: 12px; background: #e6f3ed; border: 1px solid #bfd5ce; border-radius: 8px; }
.score-breakdown dt { display: flex; justify-content: space-between; gap: 12px; font-weight: 700; }
.score-breakdown dd { margin: 4px 0 0; }
.highlight-toggle { display: flex; align-items: center; gap: 8px; margin-bottom: 8px; }
.highlight-toggle input { width: auto; margin: 0; }
#accuracy-highlights polyline { fill: none; stroke-width: 5; pointer-events: none; }
#accuracy-highlights .missed-border { stroke: #995000; stroke-dasharray: 14 7; }
#accuracy-highlights .off-target { stroke: #b42335; stroke-dasharray: 4 5; }
.gallery-cards { display: grid; grid-template-columns: repeat(auto-fit, minmax(min(100%, 178px), 1fr)); gap: 12px; margin: 12px 0 22px; }
#round-gallery { margin-top: 16px; }
.gallery-card { margin: 0; padding: 8px; background: #fff; border: 1px solid #cedad6; border-radius: 10px; }
.gallery-card figcaption { display: flex; flex-wrap: wrap; justify-content: space-between; gap: 4px 10px; overflow-wrap: anywhere; margin-bottom: 6px; }
.gallery-card svg { display: block; width: 100%; background: #f1f6f3; border-radius: 6px; }
.gallery-card path { fill: #dcece4; stroke: #426657; stroke-width: 2; }
.gallery-card polyline { fill: none; stroke-width: 2; stroke-linecap: round; stroke-linejoin: round; vector-effect: non-scaling-stroke; }
.gallery-answer { stroke: #197146; }
.gallery-guess { stroke: #1552b6; stroke-dasharray: 5 3; }
.gallery-open { width: 100%; padding: 0; border: 0; background: transparent; }
.gallery-open:hover svg { background: #e3eeea; }
#map-dialog { width: min(94vw, 780px); padding: 18px; border: 1px solid #cedad6; border-radius: 14px; color: inherit; }
#map-dialog::backdrop { background: #162e37ad; }
#map-dialog-map svg { max-height: 58vh; }
#rematch-form { margin: 14px 0; }
#rematch-form select { width: auto; max-width: 100%; }
#rematch-form button { margin-top: 0; }
#results-title { margin-top: 14px; }
.presenting main { max-width: 1440px; }
.presenting .room-code { font-size: clamp(3rem, 11vw, 8rem); display: block; line-height: 1.05; }
.presenting .timer { font-size: clamp(2.4rem, 7vw, 5.5rem); }
.presenting .gallery-cards { grid-template-columns: repeat(auto-fit, minmax(min(100%, 225px), 1fr)); }
.presenting .gallery-card figcaption { font-size: 1.15rem; }

.hosting main { max-width: 1160px; }
.hosting.presenting main { max-width: 1440px; }
.host-progress { color: #174b52; font-size: 1.2rem; font-weight: 750; }
.host-primary-controls { margin: 16px 0; }
.host-primary-controls .actions:first-child { margin-top: 0; }
summary { cursor: pointer; font-weight: 700; }
summary:focus-visible, a:focus-visible, button:focus-visible, input:focus-visible, select:focus-visible { outline: 3px solid #176b9b; outline-offset: 3px; }
.invitations { margin: 16px 0; }
.invitations summary .room-code { font-size: 1rem; letter-spacing: .08em; }
.invitation-content { display: grid; grid-template-columns: minmax(120px, 210px) minmax(0, 1fr); align-items: center; gap: 20px; padding-top: 16px; }
.join-qr { background: #fff; max-width: 210px; width: 100%; }
.join-qr svg { display: block; width: 100%; height: auto; }
.join-link { color: #175f75; overflow-wrap: anywhere; }
.host-participants { margin: 18px 0; }
.section-heading { display: flex; align-items: baseline; justify-content: space-between; gap: 12px; }
.host-roster { list-style: none; margin: 8px 0 0; padding: 0; }
.host-roster li { display: grid; grid-template-columns: minmax(0, 1fr) minmax(100px, 1fr) auto; gap: 12px; align-items: center; padding: 10px 0; border-top: 1px solid #d8e3e3; }
.roster-name, .submission-status { overflow-wrap: anywhere; }
.submission-status { font-size: .94rem; color: #4b6269; }
[data-status="submitted"] .submission-status { color: #176b3a; font-weight: 700; }
[data-status="pending"] .submission-status { color: #815000; }
[data-status="left"] { color: #617176; }
.ranking-section { margin: 20px 0; }
.your-standing { background: #e2f1ed; font-weight: 650; }
.player-note { display: block; color: #536b71; font-size: .76rem; font-weight: 500; }
.best-rounds { margin: 18px 0; }
.best-rounds li { margin: 8px 0; overflow-wrap: anywhere; }
.waiting-panel { margin: 16px 0; background: #eaf3f0; }
.visually-hidden { position: absolute; width: 1px; height: 1px; padding: 0; margin: -1px; overflow: hidden; clip-path: inset(50%); white-space: nowrap; border: 0; }
@media (max-width: 560px) {
  main { padding: 20px 16px 36px; }
  .panel { padding: 16px; }
  .invitation-content { grid-template-columns: 1fr; gap: 12px; }
  .join-qr { max-width: 190px; }
  .host-roster li { grid-template-columns: minmax(0, 1fr) auto; gap: 6px 12px; }
  .host-roster .roster-name { grid-column: 1; }
  .host-roster .submission-status { grid-column: 1; }
  .host-roster .remove-player { grid-column: 2; grid-row: 1 / 3; }
  .host-roster .player-actions { grid-column: 2; grid-row: 1 / 3; }
  .standings { min-width: 0; font-size: .85rem; }
  .standings th, .standings td { padding: 7px 4px; }
  .standings th { white-space: nowrap; }
  .standings th:first-child, .standings td:first-child { width: 44px; }
  .standings th:nth-child(2), .standings td:nth-child(2) { width: 46px; white-space: nowrap; }
  .standings th:nth-child(4), .standings td:nth-child(4) { width: 52px; }
  .standings th:nth-child(5), .standings td:nth-child(5) { width: 44px; }
}

.result-map-card { position: relative; }
.map-score { position: absolute; z-index: 1; top: 10px; right: 10px; margin: 0; padding: 6px 12px; border: 1px solid #bfd5ce; border-radius: 8px; background: #fff; color: #143c42; font-size: 1.2rem; font-weight: 800; font-variant-numeric: tabular-nums; }
#your-round-guess { stroke-dasharray: 6 3; }
.map-key { margin-top: 6px; font-size: .86rem; }
.score-details { margin-top: 10px; }
.score-details summary { color: #375f60; font-size: .94rem; }
