*, *::before, *::after { box-sizing: border-box; }

/* Self-hosted latin subsets (SIL Open Font License) so the launcher keeps the
   site's display faces under its same-origin CSP. */
@font-face {
  font-family: "Cinzel Decorative";
  font-style: normal;
  font-weight: 700;
  font-display: swap;
  src: url("/assets/fonts/cinzel-decorative-700-latin.woff2") format("woff2");
  unicode-range: U+0000-00FF, U+0131, U+0152-0153, U+02BB-02BC, U+02C6, U+02DA, U+02DC, U+0304, U+0308, U+0329, U+2000-206F, U+20AC, U+2122, U+2191, U+2193, U+2212, U+2215, U+FEFF, U+FFFD;
}
@font-face {
  font-family: "Spectral";
  font-style: normal;
  font-weight: 400;
  font-display: swap;
  src: url("/assets/fonts/spectral-400-latin.woff2") format("woff2");
  unicode-range: U+0000-00FF, U+0131, U+0152-0153, U+02BB-02BC, U+02C6, U+02DA, U+02DC, U+0304, U+0308, U+0329, U+2000-206F, U+20AC, U+2122, U+2191, U+2193, U+2212, U+2215, U+FEFF, U+FFFD;
}

/* Storybook codex theme, matching css/style.css: deep indigo ground, parchment
   card, gold and ink strokes. */
:root {
  color-scheme: dark;
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  --display: "Cinzel Decorative", "Cinzel", Georgia, "Times New Roman", serif;
  --serif: Spectral, Georgia, "Times New Roman", serif;
  --bg: #15101f;
  --bg-deep: #0f0a1a;
  --ink-dark: #1b1430;
  --ink: #ede5d0;
  --muted: #ada082;
  --paper: #ede4cc;
  --paper-2: #e3d6b1;
  --paper-line: rgba(60, 38, 18, 0.18);
  --text-on-paper: #2a1c0c;
  --text-on-paper-soft: #5a4326;
  --gold: #f2b84d;
  --gold-deep: #c49543;
  --ember: #ff6e36;
  --ember-deep: #c0431a;
  --panel: rgba(15, 10, 26, 0.96);
  --safe-top: env(safe-area-inset-top, 0px);
  --safe-right: env(safe-area-inset-right, 0px);
  --safe-bottom: env(safe-area-inset-bottom, 0px);
  --safe-left: env(safe-area-inset-left, 0px);
}

html, body, #gf-tutorial { width: 100%; height: 100%; margin: 0; overflow: hidden; }
body { color: var(--ink); background: var(--bg-deep); }
button, a { font: inherit; }
button:focus-visible, a:focus-visible { outline: 3px solid var(--gold); outline-offset: 3px; }
[hidden] { display: none !important; }

#gf-intent {
  width: 100vw;
  height: 100vh;
  height: 100dvh;
  display: grid;
  place-items: center;
  overflow: auto;
  padding: max(1.2rem, var(--safe-top)) max(1.2rem, var(--safe-right)) max(1.2rem, var(--safe-bottom)) max(1.2rem, var(--safe-left));
  background:
    radial-gradient(1200px 600px at 70% -10%, rgba(255, 110, 54, 0.14), transparent 60%),
    radial-gradient(900px 500px at -10% 20%, rgba(176, 122, 230, 0.14), transparent 60%),
    radial-gradient(1100px 700px at 110% 80%, rgba(93, 173, 226, 0.1), transparent 60%),
    var(--bg);
}

.gf-intro-card, .gf-status-card {
  border: 4px solid var(--ink-dark);
  border-radius: 20px;
  box-shadow:
    inset 0 0 0 1.5px rgba(242, 184, 77, 0.35),
    0 8px 0 var(--ink-dark),
    0 30px 70px -20px rgba(0, 0, 0, 0.85);
}
.gf-intro-card {
  width: min(700px, 100%);
  padding: clamp(1.35rem, 4vw, 2.8rem);
  text-align: center;
  color: var(--text-on-paper);
  background-color: var(--paper);
  background-image: linear-gradient(180deg, rgba(255, 255, 255, 0.45) 0%, transparent 40%);
}
.gf-status-card { width: min(570px, 100%); padding: clamp(1.4rem, 4vw, 2.5rem); text-align: center; background: var(--panel); }
.gf-mark { width: clamp(72px, 13vw, 112px); height: auto; margin: 0 auto; filter: drop-shadow(0 6px 14px rgba(0, 0, 0, 0.45)); }
.gf-kicker { margin: .6rem 0 .2rem; color: var(--gold-deep); font-size: .74rem; font-weight: 800; letter-spacing: .22em; text-transform: uppercase; }
.gf-status-card .gf-kicker { color: var(--gold); }
h1, h2 { margin: .25rem 0 .75rem; font-family: var(--display); font-weight: 700; letter-spacing: .02em; line-height: 1.05; }
h1 { font-size: clamp(2.2rem, 6.5vw, 4.2rem); color: var(--text-on-paper); text-shadow: 0 3px 0 rgba(255, 255, 255, 0.5); }
h2 { font-size: clamp(1.5rem, 4.5vw, 2.4rem); color: var(--ink); }
.gf-lede { font-family: var(--serif); font-size: 1.08rem; color: var(--text-on-paper-soft); line-height: 1.55; }
.gf-poc-note { margin: 1rem 0; padding: .8rem 1rem; border: 2px solid rgba(192, 67, 26, .5); border-radius: 12px; color: var(--text-on-paper-soft); background: rgba(255, 110, 54, .08); font-family: var(--serif); line-height: 1.4; }
.gf-poc-note strong { color: var(--text-on-paper); }
#gf-loading-copy, #gf-error-copy { font-family: var(--serif); color: rgba(237, 229, 208, 0.9); line-height: 1.55; }
.gf-facts { display: grid; gap: .55rem; margin: 1.25rem 0; text-align: left; }
.gf-facts div { display: grid; grid-template-columns: minmax(125px, .42fr) 1fr; gap: .8rem; padding-top: .55rem; border-top: 2px solid var(--paper-line); }
.gf-facts dt { color: var(--text-on-paper); font-weight: 800; letter-spacing: .04em; }
.gf-facts dd { margin: 0; color: var(--text-on-paper-soft); font-family: var(--serif); }
.gf-note { margin: .9rem 0 0; color: var(--text-on-paper-soft); font-size: .86rem; }
.gf-home { display: inline-block; margin-top: 1.1rem; color: var(--text-on-paper-soft); font-size: .8rem; font-weight: 700; letter-spacing: .16em; text-transform: uppercase; text-decoration: none; border-bottom: 2px solid var(--ink-dark); padding-bottom: 2px; }
.gf-home:hover { color: var(--ember-deep); }

.gf-primary, .gf-secondary, #gf-controls button, #gf-controls a {
  min-height: 48px;
  border-radius: 999px;
  cursor: pointer;
  font-weight: 800;
  letter-spacing: .12em;
  text-transform: uppercase;
  text-decoration: none;
}
.gf-primary {
  min-width: 200px;
  padding: .8rem 1.6rem;
  border: 3px solid var(--ink-dark);
  color: #fff;
  background: linear-gradient(135deg, var(--ember), var(--ember-deep));
  text-shadow: 0 2px 0 var(--ember-deep);
  box-shadow: 0 5px 0 var(--ink-dark), 0 14px 24px -10px rgba(255, 110, 54, 0.6);
  transition: transform .15s ease, box-shadow .15s ease, background .15s ease;
}
.gf-primary:hover { transform: translateY(-2px); box-shadow: 0 7px 0 var(--ink-dark), 0 18px 28px -10px var(--gold-deep); background: linear-gradient(135deg, var(--gold), var(--gold-deep)); color: var(--text-on-paper); text-shadow: none; }
.gf-primary:disabled { cursor: wait; opacity: .62; filter: grayscale(.45); transform: none; }
.gf-secondary { display: inline-grid; place-items: center; padding: .72rem 1.2rem; border: 2px solid var(--muted); color: var(--ink); background: transparent; }
.gf-secondary:hover { background: var(--paper); color: var(--text-on-paper); border-color: var(--ink-dark); }
.gf-status-card .gf-primary { color: #fff; }

#gf-stage { position: fixed; inset: 0; background: var(--bg-deep); }
#gf-canvas { display: block; width: 100%; height: 100%; border: 0; outline: 0; background: var(--bg-deep); touch-action: none; }
.gf-overlay { position: absolute; z-index: 20; inset: 0; display: grid; place-items: center; padding: max(1rem, var(--safe-top)) max(1rem, var(--safe-right)) max(1rem, var(--safe-bottom)) max(1rem, var(--safe-left)); background: rgba(12, 8, 32, 0.92); }
.gf-error-card { border-color: var(--ember-deep); }
.gf-error-actions { display: flex; flex-wrap: wrap; justify-content: center; gap: .8rem; margin-top: 1.25rem; }

#gf-progress { height: 10px; margin: 1.35rem 0 .65rem; overflow: hidden; border: 2px solid var(--ink-dark); border-radius: 999px; background: rgba(255, 255, 255, 0.08); }
#gf-progress-fill { display: block; width: 0; height: 100%; background: linear-gradient(90deg, var(--ember-deep), var(--gold)); transition: width .16s ease-out; }
#gf-progress-label { margin: 0; color: var(--muted); font-variant-numeric: tabular-nums; }

#gf-controls {
  position: absolute;
  z-index: 12;
  top: max(.6rem, var(--safe-top));
  right: max(.6rem, var(--safe-right));
  display: flex;
  gap: .45rem;
  opacity: .32;
  transition: opacity .2s ease;
}
#gf-controls:hover, #gf-controls:focus-within { opacity: 1; }
/* A touch device has no hover to reveal the chrome, and the orientation switch
   lives here — keep it legible without covering the board. */
@media (hover: none), (pointer: coarse) { #gf-controls { opacity: .78; } }
#gf-controls button, #gf-controls a {
  min-height: 42px; display: inline-grid; place-items: center;
  padding: .45rem .8rem; font-size: .78rem;
  border: 2px solid var(--gold-deep); color: var(--ink);
  background: rgba(15, 10, 26, 0.92);
}
#gf-controls #gf-audio-recover {
  border-color: var(--gold);
  color: var(--gold);
  background: rgba(36, 24, 6, 0.95);
  box-shadow: 0 0 0 1px rgba(242, 184, 77, 0.3), 0 8px 24px rgba(0, 0, 0, 0.6);
  animation: gf-sound-pulse 1.8s ease-in-out infinite;
}
#gf-controls #gf-audio-recover:disabled { cursor: wait; opacity: .72; animation: none; }
@keyframes gf-sound-pulse { 50% { border-color: var(--ember); box-shadow: 0 0 0 3px rgba(255, 110, 54, 0.2), 0 8px 24px rgba(0, 0, 0, 0.6); } }

#gf-rotate { position: fixed; z-index: 100; inset: 0; flex-direction: column; align-items: center; justify-content: center; gap: .8rem; padding: max(1.5rem, var(--safe-top)) max(1.5rem, var(--safe-right)) max(1.5rem, var(--safe-bottom)) max(1.5rem, var(--safe-left)); text-align: center; background: rgba(12, 8, 32, 0.97); }
#gf-rotate.gf-visible { display: flex !important; }
#gf-rotate .gf-secondary { margin-top: .5rem; }
.gf-rotate-icon { font-size: 4rem; color: var(--gold); animation: gf-turn 1.5s ease-in-out infinite; }
@keyframes gf-turn { 50% { transform: rotate(90deg); } }

.gf-sr-only { position: absolute; width: 1px; height: 1px; padding: 0; margin: -1px; overflow: hidden; clip: rect(0, 0, 0, 0); white-space: nowrap; border: 0; }
.gf-noscript { position: fixed; z-index: 200; inset: auto 1rem 1rem; padding: 1rem; border: 2px solid var(--ember-deep); background: var(--bg-deep); }

@media (max-width: 900px), (max-height: 520px) {
  .gf-intro-card { width: min(760px, 100%); padding: .8rem 1.15rem; }
  .gf-mark { width: 58px; }
  h1 { font-size: clamp(1.7rem, 10vh, 2.8rem); }
  .gf-lede { margin: .35rem 0; font-size: .88rem; line-height: 1.35; }
  .gf-poc-note { margin: .55rem 0; padding: .5rem .7rem; font-size: .78rem; line-height: 1.3; }
  .gf-facts { grid-template-columns: repeat(3, 1fr); gap: .55rem; margin: .7rem 0; }
  .gf-facts div { display: block; padding-top: .35rem; font-size: .76rem; }
  .gf-facts dd { margin-top: .2rem; }
  .gf-note, .gf-home { display: none; }
  #gf-controls { top: max(.3rem, var(--safe-top)); right: max(.3rem, var(--safe-right)); }
  #gf-controls button, #gf-controls a { min-height: 38px; padding: .3rem .55rem; font-size: .72rem; }
}

/* Portrait fills the width with the board, docks the shop across the bottom,
   and puts the settings gear top-right. The one band that stays chrome-free is
   above the player rail on the left — the bottom corners cover Ready, and the
   centre covers the coach panel. Must outrank the compact block above: that one
   re-sets `top`, and an absolutely positioned element given both `top` and
   `bottom` stretches to fill, which turned this bar into full-height columns
   over the board. */
@media (orientation: portrait) and (pointer: coarse) {
  #gf-controls {
    top: max(.25rem, var(--safe-top));
    bottom: auto;
    left: max(.25rem, var(--safe-left));
    right: auto;
    gap: .25rem;
  }
  #gf-controls button, #gf-controls a { min-height: 34px; padding: .25rem .45rem; font-size: .68rem; }
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation-duration: .01ms !important; animation-iteration-count: 1 !important; transition-duration: .01ms !important; }
}
