/* Puerto Rico scorer. Built on the site's design: brand/tokens.css (colours,
   type, spacing, buttons, cards, badges, light and dark), brand/components.css
   (header) and shared/scorer.css (the scorer shell). Only Puerto Rico's own
   pieces are here. The goods colours are the game's, the same in both themes. */

:root {
  --violet: #6d4c8f;
  --indigo: #3a55a4;
  --sugar: #9aa0a6;
  --tobacco: #8a5a2b;
  --coffee: #4a3022;
  --corn: #d8b13a;
  --ok: var(--color-success);
  --err: var(--color-danger);
}

button, input, textarea { font: inherit; color: inherit; }
button { cursor: pointer; }
.muted { color: var(--color-ink-muted); }
.small { font-size: var(--text-sm); }
h3 { margin: var(--space-5) 0 var(--space-2); font-size: var(--text-lg); display: flex; gap: var(--space-2); align-items: baseline; }
h4 { margin: var(--space-3) 0 6px; font: var(--weight-semibold) var(--text-xs)/1.3 var(--font-display); text-transform: uppercase; letter-spacing: var(--tracking-caps); color: var(--color-ink-muted); }
.card { padding: var(--space-4); margin-bottom: var(--space-4); }
.card h2 { margin: 0 0 var(--space-2); font-size: var(--text-xl); }

/* ---- Buttons: the site's. .primary is the marigold one, .ghost the outlined one. */
button.primary, button.ghost, a.button {
  display: inline-flex; align-items: center; justify-content: center; gap: var(--space-2);
  min-height: 48px; padding: var(--space-2) var(--space-5);
  border: var(--border-width) solid var(--color-line-strong); border-radius: var(--radius-pill);
  font: var(--weight-semibold) var(--text-base)/1.1 var(--font-display); text-decoration: none; text-align: center;
  box-shadow: var(--shadow-pop-sm); transition: transform var(--dur-fast) var(--ease-out), box-shadow var(--dur-fast) var(--ease-out);
}
button.primary { background: var(--color-accent); color: var(--color-accent-ink); }
button.ghost { background: var(--color-surface); color: var(--color-ink); }
button.primary:active, button.ghost:active { transform: translate(2px, 2px); box-shadow: none; }
button.primary:disabled { opacity: 0.6; box-shadow: none; }
button.danger { color: var(--err); margin-top: var(--space-4); background: none; border: var(--border-width) solid var(--color-control-edge); border-radius: var(--radius-pill); min-height: 44px; padding: 0 var(--space-4); }
.linkish { color: inherit; }

/* ---- The round card: the photo, and what it read */
.round-card { margin-bottom: var(--space-4); }
.round-card > h2 { margin: 0 0 var(--space-3); font-size: var(--text-3xl); font-weight: var(--weight-bold); }
.round-card > .snap-art { margin: 0 auto var(--space-4); }
/* A sample game (#demo): only its reading and its one next step */
body.is-demo :is(#round-title, #snap, #snap-art, .round-card > .reading-actions, #beta-card, #dataset-card, #whats-new, .add-player) { display: none !important; }
.demo-bar { position: fixed; left: 0; right: 0; bottom: 0; z-index: 10; padding: var(--space-3) var(--gutter) calc(var(--space-3) + env(safe-area-inset-bottom)); background: var(--color-bg); }
.demo-bar::before { content: ""; position: absolute; left: 0; right: 0; top: -14px; height: 14px; background: linear-gradient(transparent, var(--color-bg)); pointer-events: none; } /* the same fade as Flip 7's round bar */
body.is-demo main.app { padding-bottom: 156px; } /* the bar's two buttons, stacked on a phone: the last of the result scrolls clear of it */
@media (min-width: 560px) { body.is-demo main.app { padding-bottom: 100px; } } /* (side by side: one row) */
.app-version { flex-basis: 100%; text-align: center; }
.snap-more { display: flex; flex-wrap: wrap; justify-content: center; gap: 0 var(--space-4); }
.round-card.busy .snap { opacity: 0.5; pointer-events: none; }
.prompts { display: grid; gap: var(--space-2); margin-top: var(--space-3); }
.prompts:empty { display: none; }
.prompt { display: flex; gap: var(--space-3); align-items: flex-start; padding: var(--space-3); border-radius: var(--radius-md); background: var(--color-accent-soft); border: 1px solid var(--color-warning); }
.prompt strong { color: var(--color-ink); }
.round-canvas { display: block; width: 100%; height: auto; margin-top: var(--space-2); border-radius: var(--radius-sm); }
.status { min-height: 1.2em; margin: var(--space-2) 0 0; }
.status:empty { display: none; }
.status.error { color: var(--err); font-weight: var(--weight-semibold); }
.status.ok { color: var(--ok); }
.reading-now { display: flex; align-items: center; gap: var(--space-3); font-weight: var(--weight-semibold); }
.spinner { width: 20px; height: 20px; border-radius: 50%; border: 3px solid var(--color-line); border-top-color: var(--color-ink); animation: spin 0.8s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }
@media (prefers-reduced-motion: reduce) { .spinner { animation: none; border-top-color: var(--color-line); border-right-color: var(--color-ink); } }
.reading-actions { display: flex; gap: var(--space-2); flex-wrap: wrap; margin-top: var(--space-3); }
.reading-actions:not(:has(> :not([hidden]))) { display: none; }

/* The list: one block per player (app.js playerBlock): place, name and tag, score; their
   board cut from the photo right under it; what to check or fix. Then any board with no
   tag (whoseBlock). Nothing else lists the players. */
.results { display: flex; flex-direction: column; gap: var(--space-3); margin: var(--space-3) 0; }
.result {
  display: flex; flex-direction: column; gap: 2px; width: 100%; text-align: left;
  padding: var(--space-3); border: var(--border-width) solid var(--color-line-strong); border-left-width: 8px;
  border-radius: var(--radius-lg); background: var(--color-surface); color: var(--color-ink); box-shadow: var(--shadow-pop-sm);
}
.result.open { box-shadow: 0 0 0 3px var(--color-focus); }
.result-head { display: flex; align-items: center; gap: var(--space-2); margin-bottom: 6px; }
.result-name { flex: 1; min-width: 0; font: var(--weight-semibold) var(--text-lg)/1.2 var(--font-display); overflow-wrap: anywhere; }
.pb-place { flex: 0 0 auto; display: inline-grid; place-items: center; min-width: 40px; height: 28px; padding: 0 8px; border-radius: var(--radius-pill); border: var(--border-width) solid var(--color-line-strong); font: var(--weight-bold) var(--text-sm)/1 var(--font-display); font-variant-numeric: tabular-nums; }
.snap-tip:empty { display: none; }
.pb-place:empty { display: none; }
.pb-tag { font: var(--weight-medium) var(--text-sm) var(--font-body); color: var(--color-ink-muted); white-space: nowrap; }
.player-block .needs-name { display: block; margin: 4px 0; }
.pb-checks { margin-top: var(--space-2); }
.pb-checks .end-chips { margin-top: 0; }
.unmatched { border-left-color: var(--color-control-edge); border-left-style: dashed; }
.list-foot { display: grid; gap: var(--space-2); justify-items: start; }
.list-foot p { margin: 0; }
.add-player { min-height: 44px; font-weight: var(--weight-semibold); text-decoration: underline; text-underline-offset: 3px; background: none; border: 0; padding: 0; }
.game-actions { margin: 0 0 var(--space-4); }
.game-actions .reading-actions { margin-top: 0; }
.result-score { font: var(--weight-bold) 2rem/1 var(--font-display); font-variant-numeric: tabular-nums; }
.result-detail { font-size: var(--text-sm); color: var(--color-ink-muted); }
.result-fix { font-size: var(--text-sm); font-weight: var(--weight-semibold); color: var(--color-link); }
.result-crop { display: block; width: auto; max-width: 100%; height: auto; max-height: 360px; margin: 0 auto 6px; border-radius: var(--radius-sm); cursor: pointer; } /* the board at its own shape, no letterbox */
.result-crop[hidden] { display: none; }
.result-crop.static { cursor: default; }
.result-crop.tab-crop { cursor: default; max-height: 320px; margin: 6px 0 10px; }
.result-items { display: flex; flex-wrap: wrap; gap: 6px; align-items: center; margin: 4px 0; }
.result-actions { display: flex; gap: var(--space-2); align-items: center; justify-content: space-between; margin-top: 6px; flex-wrap: wrap; }
.result-actions button { white-space: nowrap; }
.pill { min-height: 44px; border: var(--border-width) solid var(--color-control-edge); border-radius: var(--radius-pill); background: var(--color-surface); color: var(--color-ink); padding: 6px var(--space-3); font: var(--weight-semibold) var(--text-sm)/1.1 var(--font-display); }
.pill.on { border-color: var(--color-line-strong); box-shadow: 0 0 0 2px var(--color-accent) inset; }
.pill.static { cursor: default; background: none; border-style: dashed; font-weight: var(--weight-medium); min-height: 0; }
.quick-fix { margin: var(--space-2) 0; padding: var(--space-3); border: 1px solid var(--color-line); border-radius: var(--radius-md); background: var(--color-bg); }
.quick-fix h4 { margin-top: 0; text-transform: none; letter-spacing: 0; font-size: var(--text-base); color: var(--color-ink); }
.slot-picks { display: grid; grid-template-columns: repeat(3, 1fr); gap: 6px; margin: var(--space-2) 0; }
.slot-picks .bld { min-width: 0; padding: 6px; min-height: 44px; overflow-wrap: anywhere; }
.join-link { color: var(--color-link); font-size: var(--text-sm); font-weight: var(--weight-semibold); align-self: center; flex: 1 1 10em; }
.reading { width: 100%; border-collapse: collapse; margin-top: var(--space-3); font-size: var(--text-sm); }
.reading th, .reading td { padding: 6px 4px; border-bottom: 1px solid var(--color-line); text-align: left; vertical-align: top; }
.reading td.num, .reading th.num { text-align: right; }
.reading .swatch { display: inline-block; width: 10px; height: 10px; border-radius: 50%; margin-right: 6px; }
.reading td:first-child { white-space: nowrap; }
.reading-row { cursor: pointer; }
.reading-row.open td { background: var(--color-accent-soft); }
.estimate { color: var(--color-ink-muted); font-weight: var(--weight-medium); }
.fix-cell { text-align: right; white-space: nowrap; }
.fix-link { color: var(--color-link); font-weight: var(--weight-semibold); font-size: var(--text-sm); }
.labelled { color: var(--ok); font-weight: var(--weight-bold); }
.fix-panel { margin-top: var(--space-3); padding: var(--space-3); border: var(--border-width) solid var(--color-line); border-radius: var(--radius-md); background: var(--color-surface); }
.fix-panel h4 { margin-top: 0; text-transform: none; letter-spacing: 0; font-size: var(--text-base); color: var(--color-ink); }
.fix-prod { display: grid; grid-template-columns: repeat(3, 1fr); gap: 6px; margin-top: var(--space-2); }
details.teach summary { cursor: pointer; list-style: none; }
details.teach summary::-webkit-details-marker { display: none; }
details.teach summary h2 { display: inline; }
details.teach summary::after { content: ' ▸'; color: var(--color-ink-muted); }
details.teach[open] summary::after { content: ' ▾'; }

/* ---- A player's score sheet, opened inside their block ("Everything ›") */
.editor { margin-top: var(--space-3); padding-top: var(--space-3); border-top: 1px solid var(--color-line); }
.editor h3:first-of-type { margin-top: var(--space-4); }

.editor-head { display: flex; gap: var(--space-3); align-items: center; }
.editor-head .name { flex: 1; min-width: 0; min-height: 48px; font: var(--weight-semibold) var(--text-lg) var(--font-display); padding: var(--space-2) var(--space-3); border: var(--border-width) solid var(--color-control-edge); border-radius: var(--radius-md); background: var(--color-surface); color: var(--color-ink); }
.total { text-align: right; }
.total span { font: var(--weight-bold) 2.25rem/1 var(--font-display); }
.total small { margin-left: 3px; color: var(--color-ink-muted); }

/* close-up photos on a tab */
.photo-row { display: flex; flex-wrap: wrap; gap: var(--space-2); align-items: center; }
.thumb { position: relative; margin: 0; width: 84px; height: 84px; border-radius: var(--radius-sm); overflow: hidden; background: var(--color-line); }
.thumb img { width: 100%; height: 100%; object-fit: cover; display: block; }
.thumb-x { position: absolute; top: 2px; right: 2px; width: 28px; height: 28px; border-radius: 50%; border: 0; background: rgb(0 0 0 / 0.6); color: #fff; line-height: 1; }
.thumb-sent { position: absolute; bottom: 2px; left: 4px; color: #fff; text-shadow: 0 0 3px #000; font-weight: 700; }
.photo-button { display: inline-flex; align-items: center; justify-content: center; min-height: 44px; padding: var(--space-2) var(--space-4); border-radius: var(--radius-pill); cursor: pointer; font: var(--weight-semibold) var(--text-base) var(--font-display); }
.photo-button.alt { background: none; color: var(--color-ink); border: var(--border-width) solid var(--color-control-edge); }
.closeup-button { margin-top: var(--space-2); width: 100%; justify-content: center; }

/* number fields */
.field { display: flex; align-items: center; justify-content: space-between; gap: var(--space-3); margin: var(--space-2) 0; }
.field-label { flex: 1; }
.stepper { display: flex; align-items: center; }
.stepper button { width: 44px; height: 44px; border: var(--border-width) solid var(--color-control-edge); background: var(--color-surface); color: var(--color-ink); font: var(--weight-bold) 1.25rem/1 var(--font-display); }
.stepper button:first-child { border-radius: var(--radius-md) 0 0 var(--radius-md); }
.stepper button:last-child { border-radius: 0 var(--radius-md) var(--radius-md) 0; }
.stepper input { width: 56px; height: 44px; text-align: center; border: var(--border-width) solid var(--color-control-edge); border-left: 0; border-right: 0; background: var(--color-surface); color: var(--color-ink); font: var(--weight-semibold) var(--text-lg) var(--font-display); -moz-appearance: textfield; }
.stepper input::-webkit-outer-spin-button, .stepper input::-webkit-inner-spin-button { -webkit-appearance: none; margin: 0; }
.field.small .stepper button { width: 44px; height: 44px; } /* the small steppers too: 44 px to tap */
.field.small .stepper input { width: 48px; height: 44px; }
.island { display: grid; grid-template-columns: repeat(auto-fill, minmax(190px, 1fr)); column-gap: 18px; }
.pair { display: grid; grid-template-columns: 1fr 1fr; column-gap: 18px; }
@media (max-width: 420px) { .pair { grid-template-columns: 1fr; } }

/* buildings: the goods colour down the left, like the tiles */
.tiles { display: grid; grid-template-columns: repeat(auto-fill, minmax(100px, 1fr)); gap: 6px; }
.large-tiles { grid-template-columns: repeat(auto-fill, minmax(130px, 1fr)); }
.bld { display: flex; flex-direction: column; align-items: flex-start; gap: 2px; width: 100%; padding: var(--space-2); border: 1px solid var(--color-line); border-left: 6px solid var(--violet); border-radius: var(--radius-sm); background: var(--color-surface); color: var(--color-ink); text-align: left; min-height: 52px; }
.bld.good-indigo { border-left-color: var(--indigo); }
.bld.good-sugar { border-left-color: var(--sugar); }
.bld.good-tobacco { border-left-color: var(--tobacco); }
.bld.good-coffee { border-left-color: var(--coffee); }
.bld-name { font-weight: var(--weight-semibold); font-size: var(--text-sm); line-height: 1.15; }
.bld-meta { font-size: 0.72rem; color: var(--color-ink-muted); }
.bld[aria-pressed="true"] { background: var(--color-ink); color: var(--color-bg); border-color: var(--color-ink); }
.bld[aria-pressed="true"] .bld-meta { color: var(--color-bg); opacity: 0.8; }
.bld.gone { opacity: 0.45; }
.large-wrap { display: flex; flex-direction: column; gap: 4px; }
.manned { min-height: 44px; border: var(--border-width) solid var(--color-line); border-radius: var(--radius-sm); background: var(--color-surface); color: var(--color-ink); padding: 6px; font-size: var(--text-sm); }
.manned[aria-pressed="true"] { border-color: var(--ok); color: var(--ok); font-weight: var(--weight-semibold); }
.manned[aria-pressed="false"] { border-color: var(--err); color: var(--err); }

/* score */
.breakdown { width: 100%; border-collapse: collapse; }
.breakdown td { padding: 6px 4px; border-bottom: 1px solid var(--color-line); vertical-align: top; }
.breakdown .vp { text-align: right; font-weight: var(--weight-semibold); width: 4em; }
.breakdown tfoot td { font: var(--weight-bold) var(--text-lg) var(--font-display); border-bottom: 0; }
.play { display: flex; flex-direction: column; }

/* a tab is the latest photo, corrected (app.js fromPhoto) */
.ok-mark { color: var(--ok); font-weight: var(--weight-semibold); white-space: nowrap; }
.closeup { margin-top: 18px; }
.needs-name { color: var(--err); }

/* round by round (app.js historyTable) */
.history { margin: var(--space-3) 0; }
.history summary { display: flex; align-items: center; min-height: 44px; cursor: pointer; font: var(--weight-semibold) var(--text-base) var(--font-display); }
.history-table { width: 100%; border-collapse: collapse; margin-top: var(--space-2); font-size: var(--text-sm); }
.history-table th, .history-table td { padding: 6px 4px; border-bottom: 1px solid var(--color-line); text-align: left; }
.history-table .num { text-align: right; font-variant-numeric: tabular-nums; }

/* end of game: what's still missing, a tap away; chips first */
.end-checks h3 { color: var(--err); }
.end-checks .large-head { color: var(--color-ink); }
.end-checks .check { display: flex; gap: var(--space-3); align-items: center; width: 100%; min-height: 48px; text-align: left; margin: 0 0 6px; padding: var(--space-3); border: 1px solid var(--err); border-radius: var(--radius-md); background: none; color: var(--color-ink); }
.end-checks .check span:first-child { flex: 1; }
.large-check { display: flex; gap: var(--space-3); align-items: center; padding: var(--space-2) 0; border-top: 1px solid var(--color-line); }
.large-check > span { flex: 1; }
.large-check .manned { flex: 0 0 auto; min-width: 128px; }
.fortress-colonists { margin-top: var(--space-3); padding: var(--space-2) var(--space-3); border-radius: var(--radius-md); border: 1px solid var(--color-line); }
.fortress-colonists.needs { border: var(--border-width) solid var(--err); background: var(--color-danger-soft); }
.end-chips { margin: 6px 0 10px; padding: var(--space-3); border: var(--border-width) solid var(--err); border-radius: var(--radius-md); background: var(--color-danger-soft); }
.end-chips.checked { border-color: var(--ok); background: none; }
.end-chips-head { display: flex; justify-content: space-between; gap: var(--space-2); flex-wrap: wrap; }
.end-chips .primary { width: 100%; margin-top: 6px; }

/* player tags (app.js renderTagList, tagNote) */
.swatch { display: inline-block; width: 12px; height: 12px; border-radius: 3px; }

/* dataset, and the beta (infra/beta): the join card for non-testers */
.notes { display: block; margin: var(--space-2) 0 var(--space-3); }
.notes textarea { display: block; width: 100%; margin-top: 4px; padding: var(--space-2); border: var(--border-width) solid var(--color-control-edge); border-radius: var(--radius-md); background: var(--color-surface); color: var(--color-ink); }
.beta-card { border: var(--border-width) dashed var(--color-control-edge); box-shadow: none; }
.beta-card .reading-actions { flex-wrap: wrap; }
.card h2 .badge { vertical-align: middle; margin-left: var(--space-1); }
.how-to ul, .how-to ol { margin: 6px 0 var(--space-3); padding-left: 20px; }
.how-to li { margin: 6px 0; }

/* Join the beta? (app.js maybeAskBeta) */
.beta-prompt { max-width: 420px; }
.beta-prompt h2 { margin: var(--space-2) 0 var(--space-3); font-size: var(--text-2xl); }
.beta-prompt h2:focus { outline: none; }
.beta-facts { margin: 0 0 var(--space-3); padding-left: 1.2em; }
.beta-facts li { margin: 0 0 var(--space-2); }
.beta-never { display: flex; align-items: center; gap: var(--space-2); min-height: 44px; margin: 0 0 var(--space-2); font-weight: var(--weight-semibold); }
.beta-never input { width: 22px; height: 22px; accent-color: var(--color-ink); }
.beta-prompt__actions { display: grid; gap: var(--space-2); margin-top: var(--space-3); }
.beta-prompt__actions .btn { width: 100%; }

/* dialogs: the owner passcode */
.plain-dialog { border: var(--border-width) solid var(--color-line-strong); border-radius: var(--radius-lg); padding: var(--space-5); max-width: 380px; width: calc(100% - 32px); background: var(--color-surface); color: var(--color-ink); box-shadow: var(--shadow-pop-lg); }
.plain-dialog::backdrop { background: rgb(27 23 18 / 0.55); }
.plain-dialog h2 { margin-top: 0; font-size: var(--text-xl); }
.passcode-field input { display: block; width: 100%; min-height: 44px; margin-top: 4px; padding: var(--space-2); border: var(--border-width) solid var(--color-control-edge); border-radius: var(--radius-md); background: var(--color-surface); }
.actions { display: flex; justify-content: flex-end; gap: var(--space-2); margin-top: var(--space-3); }
.actions button:not(.btn) { min-height: 48px; background: none; border: var(--border-width) solid var(--color-control-edge); border-radius: var(--radius-pill); padding: 0 var(--space-4); font: var(--weight-semibold) var(--text-base) var(--font-display); }

/* a new version is live (app.js checkForUpdate): a bar at the bottom, in thumb reach */
.update-banner { position: fixed; left: 0; right: 0; bottom: 0; z-index: 20; display: flex; gap: var(--space-3); align-items: center; padding: var(--space-3) var(--space-4); padding-bottom: max(12px, env(safe-area-inset-bottom)); background: var(--color-ink); color: var(--color-bg); box-shadow: 0 -4px 16px rgb(0 0 0 / 0.25); }
.update-banner[hidden] { display: none; }
.update-banner span { flex: 1; font-size: var(--text-sm); }

/* the in-app camera (app.js openInAppCamera): full screen, the guide frame, the level */
dialog.camera { position: fixed; inset: 0; width: 100vw; height: 100dvh; max-width: none; max-height: none; margin: 0; padding: 0; border: 0; background: #000; color: #fff; }
dialog.camera::backdrop { background: #000; }
.camera video { position: absolute; inset: 0; width: 100%; height: 100%; object-fit: cover; }
.camera-guide { position: absolute; inset: 0; display: flex; align-items: center; justify-content: center; pointer-events: none; }
.camera-frame { width: 86%; height: 62%; border: 3px dashed rgb(255 255 255 / 0.8); border-radius: 18px; box-shadow: 0 0 0 100vmax rgb(0 0 0 / 0.25); }
.camera-hint { position: absolute; left: 16px; right: 16px; top: max(16px, env(safe-area-inset-top)); margin: 0; padding: 10px 12px; border-radius: 12px; background: rgb(0 0 0 / 0.55); font-size: 0.95rem; text-align: center; }
.camera-level { position: absolute; left: 50%; top: calc(max(16px, env(safe-area-inset-top)) + 64px); transform: translateX(-50%); display: flex; gap: 8px; align-items: center; padding: 6px 12px; border-radius: 999px; background: rgb(179 38 30 / 0.85); font-weight: 600; white-space: nowrap; }
.camera-level[hidden] { display: none; }
.camera-level.flat { background: rgb(47 122 62 / 0.9); }
.camera-level .bubble { width: 12px; height: 12px; border-radius: 50%; background: #fff; }
.camera-error { position: absolute; left: 16px; right: 16px; top: 45%; margin: 0; padding: 12px; border-radius: 12px; background: rgb(0 0 0 / 0.75); text-align: center; }
.camera-error[hidden] { display: none; }
.camera-bar { position: absolute; left: 0; right: 0; bottom: 0; display: flex; align-items: center; justify-content: space-between; gap: 12px; padding: 16px; padding-bottom: max(20px, env(safe-area-inset-bottom)); background: linear-gradient(transparent, rgb(0 0 0 / 0.6)); }
.camera-bar .ghost { background: none; color: #fff; border-color: rgb(255 255 255 / 0.6); box-shadow: none; min-width: 92px; }
.camera-bar .photo-button.alt { min-width: 92px; justify-content: center; color: #fff; border-color: rgb(255 255 255 / 0.6); }
.shutter { width: 76px; height: 76px; border-radius: 50%; border: 5px solid #fff; background: rgb(255 255 255 / 0.35); }
.shutter:disabled { opacity: 0.4; }
