/* The scorers' shell: the site's header, the game bar under it, the menu, and
   the photo button. Shared by the Flip 7 and Puerto Rico scorers.
   One source: apps/shared/scorer.css, copied into each app by
   scripts/sync-brand.sh. Load order:
     brand/tokens.css, brand/components.css, shared/scorer.css,
     shared/walkthrough.css, then the app's own styles.css. */

[hidden] { display: none !important; }
html { scroll-padding-top: 76px; }
body { min-height: 100dvh; padding-bottom: env(safe-area-inset-bottom); }
:root { --app-width: 46rem; }

/* ---- Header: the site's (components.css 1b), with the menu button on the right */
.hdr { padding-top: env(safe-area-inset-top); }
.hdr__menu-btn {
  width: 44px; height: 44px; flex: none; display: grid; place-items: center;
  padding: 0; border-radius: 12px; border: 1px solid var(--color-line);
  background: var(--color-surface); color: var(--color-ink); cursor: pointer;
}
.hdr__menu-btn:focus-visible { outline: 3px solid var(--color-focus); outline-offset: 2px; }
.hdr__burger.is-x { background: transparent; }
.hdr__burger.is-x::before { transform: translateY(6px) rotate(45deg); }
.hdr__burger.is-x::after { transform: translateY(-6px) rotate(-45deg); }
@media (max-width: 359px) { .hdr .brand { font-size: var(--text-lg); } }

/* ---- The game bar: which scorer this is (the site's game tile), and its status */
.game-bar {
  display: flex; align-items: center; gap: var(--space-3);
  width: 100%; max-width: calc(var(--app-width) + 2 * var(--gutter));
  margin: 0 auto; padding: var(--space-4) var(--gutter) 0;
}
.game-bar .hdr__tile { width: 40px; height: 40px; border-radius: 11px; font-size: 17px; box-shadow: var(--shadow-pop-sm); }
.game-bar__title { margin: 0; font-size: var(--text-2xl); font-weight: var(--weight-bold); line-height: 1.05; }
.game-bar__sub { display: block; font: var(--weight-medium) var(--text-sm)/1.3 var(--font-body); color: var(--color-ink-muted); letter-spacing: 0; }
.game-bar__status { margin-left: auto; text-align: right; font-size: var(--text-xs); color: var(--color-ink-muted); max-width: 9rem; line-height: 1.3; }
.game-bar__status:empty { display: none; }
.game-bar__status.error { color: var(--color-danger); font-weight: var(--weight-semibold); }

main.app { width: 100%; max-width: calc(var(--app-width) + 2 * var(--gutter)); margin: 0 auto; padding: var(--space-4) var(--gutter) var(--space-7); }

/* ---- The menu: the site's mobile menu sheet, as a dialog */
.menu-sheet {
  position: fixed; inset: 0 0 auto 0; width: 100%; max-width: none; max-height: 100dvh;
  margin: 0; padding: 0 0 env(safe-area-inset-bottom); border: 0; border-bottom: 1px solid var(--color-line);
  background: var(--color-bg); color: var(--color-ink); box-shadow: var(--shadow-lg); overflow: auto; overscroll-behavior: contain;
}
.menu-sheet::backdrop { background: rgb(27 23 18 / 0.45); }
.menu-sheet .hdr { position: sticky; }
.menu-sheet__body { max-width: calc(var(--container-narrow) + 2 * var(--gutter)); margin: 0 auto; padding: var(--space-2) var(--gutter) var(--space-5); }
.menu-link {
  display: flex; align-items: center; justify-content: space-between; gap: var(--space-3);
  width: 100%; min-height: 56px; padding: var(--space-2) 0; margin: 0;
  border: 0; border-bottom: 1px solid var(--color-line); border-radius: 0; background: none; box-shadow: none;
  color: var(--color-ink); text-align: left; text-decoration: none; cursor: pointer;
  font: var(--weight-semibold) var(--text-xl)/1.15 var(--font-display);
}
.menu-link > span:first-child { min-width: 0; }
.menu-link small { display: block; margin-top: 3px; font: var(--weight-medium) var(--text-sm)/1.35 var(--font-body); color: var(--color-ink-muted); }
.menu-link .arrow { flex: none; }
.menu-link:focus-visible { outline: 3px solid var(--color-focus); outline-offset: 2px; border-radius: var(--radius-xs); }
.menu-group { display: grid; gap: var(--space-3); padding: var(--space-3) 0 var(--space-4); border-bottom: 1px solid var(--color-line); }
.menu-group label { display: grid; gap: var(--space-1); font-weight: var(--weight-semibold); }
.menu-group select { min-height: 48px; padding: 0 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); font: inherit; font-weight: var(--weight-regular); }
.menu-group label.check { display: flex; align-items: center; gap: var(--space-2); font-weight: var(--weight-regular); }
.menu-group input[type="checkbox"], .menu-fine input[type="checkbox"] { width: 22px; height: 22px; flex: none; accent-color: var(--color-ink); }
.menu-title { margin: var(--space-5) 0 0; }
.menu-play { display: grid; grid-template-columns: repeat(auto-fit, minmax(13rem, 1fr)); gap: 10px; margin: var(--space-4) 0 var(--space-2); }
.menu-play .btn { min-height: 52px; }
.menu-mail { display: block; padding: var(--space-4) 0 0; color: var(--color-ink-muted); font-size: var(--text-sm); }
.menu-fine { display: flex; gap: var(--space-2); align-items: flex-start; margin: var(--space-4) 0 0; font-size: var(--text-sm); color: var(--color-ink-muted); }
@media (prefers-reduced-motion: no-preference) {
  .menu-sheet[open] { animation: menu-in var(--dur) var(--ease-out); }
  @keyframes menu-in { from { opacity: 0; transform: translateY(-6px); } }
}

/* ---- The photo button: the one way into a round */
.snap { display: grid; gap: var(--space-2); justify-items: center; margin: 0 0 var(--space-4); }
.snap-art { width: min(100%, 300px); aspect-ratio: 8 / 5; margin: 0 0 var(--space-3); border-radius: var(--radius-md); background: var(--color-felt); overflow: hidden; box-shadow: inset 0 0 0 1px rgb(0 0 0 / 0.12); }
.snap-art svg { display: block; width: 100%; height: 100%; }
.snap-button { width: 100%; min-height: 68px; font-size: var(--text-xl); border-radius: var(--radius-pill); box-shadow: var(--shadow-pop); }
.snap-button svg { width: 1.45em; height: 1.45em; }
.snap-alt {
  display: inline-flex; align-items: center; min-height: 44px; padding: 0 var(--space-3);
  color: var(--color-ink); font: var(--weight-semibold) var(--text-base) var(--font-display);
  text-decoration: underline; text-underline-offset: 0.2em; cursor: pointer;
}
.snap-alt:focus-within { outline: 3px solid var(--color-focus); outline-offset: 2px; border-radius: var(--radius-xs); }
.snap-tip { margin: 0; text-align: center; color: var(--color-ink-muted); font-size: var(--text-sm); max-width: 30em; }

/* ---- Small shared pieces */
.linkish { min-height: 0; padding: 0; border: 0; background: none; box-shadow: none; color: inherit; font: inherit; text-decoration: underline; text-underline-offset: 0.18em; cursor: pointer; }
.app-footer {
  display: flex; flex-wrap: wrap; justify-content: center; align-items: center; gap: var(--space-2) var(--space-3);
  margin: var(--space-6) 0 0; padding-top: var(--space-4); border-top: 1px solid var(--color-line);
  color: var(--color-ink-muted); font-size: var(--text-sm);
}
.app-footer a, .app-footer .linkish { display: inline-flex; align-items: center; min-height: 44px; color: var(--color-ink-muted); } /* tap targets, not just text */

/* ---- "Save it for game night" (save-sheet.js): a sheet from the bottom, in thumb reach */
.save-sheet {
  position: fixed; inset: auto 0 0 0; width: 100%; max-width: 32rem; max-height: calc(100dvh - 24px);
  margin: 0 auto; padding: var(--space-4) var(--space-4) calc(var(--space-5) + env(safe-area-inset-bottom));
  border: var(--border-width) solid var(--color-line-strong); border-bottom: 0; border-radius: var(--radius-lg) var(--radius-lg) 0 0;
  background: var(--color-surface); color: var(--color-ink); box-shadow: var(--shadow-lg); overflow: auto;
}
.save-sheet::backdrop { background: rgb(27 23 18 / 0.55); }
.save-sheet__head { display: flex; align-items: center; justify-content: space-between; gap: var(--space-3); }
.save-sheet h2 { margin: 0; font-size: var(--text-2xl); font-weight: var(--weight-bold); }
.save-sheet__lede { margin: var(--space-2) 0 var(--space-4); color: var(--color-ink-muted); }
.save-sheet__options { display: grid; gap: var(--space-3); }
.save-option {
  display: flex; align-items: center; gap: var(--space-4); width: 100%; min-height: 68px; padding: var(--space-3) var(--space-4);
  border: var(--border-width) solid var(--color-line-strong); border-radius: var(--radius-md);
  background: var(--color-surface); color: var(--color-ink); box-shadow: var(--shadow-pop-sm); text-align: left; cursor: pointer; font: inherit;
}
.save-option:active { transform: translate(2px, 2px); box-shadow: none; }
.save-option svg { width: 30px; height: 30px; flex: none; }
.save-option strong { display: block; font: var(--weight-semibold) var(--text-lg)/1.2 var(--font-display); }
.save-option small { display: block; margin-top: 2px; color: var(--color-ink-muted); font-size: var(--text-sm); }
.save-steps { margin: calc(-1 * var(--space-1)) 0 0; padding: var(--space-3) var(--space-4); border-radius: var(--radius-sm); background: var(--color-accent-soft); }
.save-done { margin: 0; color: var(--color-success); font-weight: var(--weight-semibold); }
.save-done:empty { display: none; }
@media (prefers-reduced-motion: no-preference) {
  .save-sheet[open] { animation: save-in var(--dur) var(--ease-out); }
  @keyframes save-in { from { transform: translateY(24px); opacity: 0; } }
}

/* ---- A sample game (#demo): marked as a sample, one next step */
.demo-banner { margin: 0 0 var(--space-4); padding: var(--space-4); }
.demo-head { display: flex; align-items: center; justify-content: space-between; margin: calc(-1 * var(--space-1)) calc(-1 * var(--space-1)) 0 0; }
.demo-banner h2 { margin: var(--space-1) 0 var(--space-1); font-size: var(--text-3xl); font-weight: var(--weight-bold); }
.demo-banner p { margin: 0; max-width: 36em; color: var(--color-ink-muted); font-size: var(--text-sm); }
/* The sample's two next steps, in the bar at the bottom: score your own game (primary), or save the
   scorer for game night (secondary: the save sheet, from 'demo'). One size; side by side when both fit,
   else primary over secondary at full width, like the site's game cards. Shown only in the sample. */
.demo-actions { display: grid; grid-template-columns: repeat(auto-fit, minmax(min(100%, 15rem), 1fr)); gap: var(--space-2); width: 100%; max-width: var(--app-width); margin: 0 auto; }
.demo-actions .btn { width: 100%; }
.demo-actions .btn svg { width: 1.3em; height: 1.3em; }
body:not(.is-demo) .demo-actions { display: none; }
.snap-demo { min-height: 44px; color: var(--color-ink-muted); font-size: var(--text-sm); }
