/* Daily Flyer — the reference game page. Chrome follows lib/theme.css (paper);
   the canvas world keeps its own palette. Values lifted from design/shell. */

* { box-sizing: border-box; }
[hidden] { display: none !important; }
body { margin: 0; line-height: 1.55; min-height: 100vh; }
button, a { -webkit-tap-highlight-color: transparent; touch-action: manipulation; }
button { font: inherit; cursor: pointer; }
button:disabled { cursor: not-allowed; opacity: .45; box-shadow: none; }
a { text-decoration: none; }
img { display: block; max-width: 100%; }
.sr-only { position: absolute; width: 1px; height: 1px; padding: 0; margin: -1px; overflow: hidden; clip: rect(0,0,0,0); border: 0; }

/* Focus has to read across a room, not from 60cm. */
:focus-visible { outline: 4px solid var(--focus); outline-offset: 3px; border-radius: 6px; }
.primary:focus-visible, .overlay-card :focus-visible { outline-width: 5px; outline-offset: 4px; }

/* ---- buttons: one primary per screen --------------------------------------- */
.primary, .secondary { font: 500 14px/1.2 var(--font-body); padding: 14px 21px; border-radius: var(--r-control); display: inline-flex; align-items: center; justify-content: center; gap: 9px; }
.primary { background: var(--primary); border: 1px solid var(--primary); color: var(--on-primary); box-shadow: var(--press); transition: transform .06s, box-shadow .06s; }
.primary:hover:not(:disabled) { background: var(--primary-hover); }
.primary:active:not(:disabled) { transform: translateY(3px); box-shadow: none; }
.secondary { background: var(--surface); border: 1px solid var(--border); color: var(--accent); }
.secondary:hover { background: var(--raised); }
.link-button { background: none; border: 0; padding: 4px; color: var(--accent); font-size: 13px; text-decoration: underline; text-underline-offset: 3px; }

/* ---- header ---------------------------------------------------------------- */
.site-header { display: flex; align-items: center; gap: 14px; padding: 18px max(56px, calc((100% - 1480px) / 2 + 56px)); border-bottom: 1px solid var(--border); }
.brand { display: flex; align-items: center; gap: 12px; font-family: var(--font-display); font-weight: 800; }
.brand-studio { font-size: 16px; color: var(--muted); }
.brand-sep { color: var(--border); font-size: 18px; }
.brand-game { font-size: 20px; color: var(--heading); }
.brand-dot { color: #c58248; }
.site-header nav { margin-left: auto; font-size: 13.5px; }
.site-header nav a { color: var(--muted); }
.icon-button { width: 38px; height: 38px; border-radius: 999px; border: 1px solid var(--border); background: var(--surface); color: var(--accent); display: grid; place-items: center; padding: 0; }
.sound-on { display: none; } .sound-enabled .sound-on { display: inline; } .sound-enabled .sound-off { display: none; }

/* ---- 1 · game home --------------------------------------------------------- */
main { max-width: 1480px; margin: 0 auto; }
.home { display: grid; grid-template-columns: minmax(360px, 470px) minmax(0, 1fr); gap: 48px; padding: 36px 56px; min-height: min(calc(100vh - 77px), 1000px); }
.intro { display: flex; flex-direction: column; gap: 15px; }
.intro > .eyebrow { display: flex; align-items: center; gap: 8px; }
.live-dot { width: 7px; height: 7px; border-radius: 50%; background: #89a171; }
h1 { font-size: clamp(38px, 3.6vw, 50px); line-height: 1.04; }
.lede { margin: 0; color: var(--muted); font-size: 15.5px; line-height: 1.7; }
.badge { align-self: flex-start; display: inline-flex; align-items: center; gap: 7px; padding: 9px 15px 9px 11px; border-radius: 999px; background: var(--raised); color: var(--accent); font: 600 15px/1 var(--font-body); }
.badge:empty { display: none; }

.scan-panel { background: var(--surface); border: 2px solid var(--primary); border-radius: 20px; padding: 20px 22px 16px; box-shadow: 0 16px 44px rgba(69,103,62,.14); display: flex; flex-direction: column; gap: 14px; margin-top: 4px; }
.scan-main { display: flex; gap: 20px; align-items: center; }
.scan-qr { flex: none; width: 156px; height: 156px; background: #fff; border-radius: 12px; padding: 8px; line-height: 0; border: 1px solid var(--border-soft); }
.scan-qr canvas { width: 100%; height: 100%; }
.scan-copy { display: flex; flex-direction: column; gap: 9px; }
.scan-eyebrow { color: var(--primary); }
.scan-copy h2 { font-size: 26px; }
.scan-steps { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: 9px; counter-reset: step; }
.scan-steps li { display: flex; align-items: center; gap: 10px; font-size: 14px; counter-increment: step; }
.scan-steps li::before { content: counter(step); flex: none; width: 24px; height: 24px; border-radius: 999px; background: var(--primary); color: var(--on-primary); font: 800 12px/24px var(--font-display); text-align: center; }
.scan-status { display: flex; align-items: center; gap: 10px; padding-top: 12px; border-top: 1px solid var(--border-soft); font-size: 13.5px; color: var(--muted); }
.room-code { margin-left: auto; font: 800 16px/1 var(--font-display); letter-spacing: .2em; color: var(--accent); }
.scan-help { margin: -6px 0 0; font-size: 12.5px; color: var(--muted); }
.scan-help b { color: var(--text); }
.scan-panel.is-live #scanStatus { color: var(--primary); font-weight: 600; }

.status-dot { flex: none; width: 10px; height: 10px; border-radius: 999px; background: var(--primary); }
.status-dot.wait, .status-dot.warn { background: var(--warn); box-shadow: 0 0 0 4px rgba(200,145,47,.18); }
.status-dot.wait { animation: breathe 1.8s ease-in-out infinite; }
@keyframes breathe { 50% { box-shadow: 0 0 0 7px rgba(200,145,47,.05); } }

.fallbacks { display: flex; flex-direction: column; gap: 9px; margin-top: 6px; font-size: 13px; color: var(--muted); }
.fallback-buttons { display: flex; gap: 10px; flex-wrap: wrap; }
.fallback-buttons .secondary { padding: 12px 16px; }
.setup-status { margin: 0; font-size: 13px; color: var(--danger-text); max-width: 44ch; }
.setup-status:empty { display: none; }

.stage-wrap { display: flex; flex-direction: column; gap: 16px; min-width: 0; }
.stage { position: relative; flex-grow: 1; min-height: 420px; border-radius: 22px; overflow: hidden; border: 1px solid var(--border-soft); box-shadow: 0 18px 50px rgba(90,114,56,.10); background: #cce6df; isolation: isolate; }
#world { position: absolute; inset: 0; width: 100%; height: 100%; display: block; touch-action: none; }

.guide-card { display: flex; align-items: center; gap: 20px; padding: 14px 18px; background: var(--surface); border: 1px solid var(--border-soft); border-radius: var(--r-card); box-shadow: var(--card); }
.guide-card img { flex: none; width: 112px; height: 112px; border-radius: 14px; object-fit: cover; }
.guide-moves { display: flex; flex-direction: column; gap: 10px; }
#guideMoves { display: flex; flex-direction: column; gap: 10px; }
.guide-place { margin: 0 0 0 auto; max-width: 210px; text-wrap: pretty; font-size: 12.5px; line-height: 1.5; color: var(--muted); }
.move { display: flex; align-items: center; gap: 10px; font-size: 15px; color: var(--muted); white-space: nowrap; }
.move b { font: 800 16px var(--font-display); color: var(--heading); }
.move-icon { flex: none; width: 32px; height: 32px; border-radius: 10px; background: var(--raised); color: var(--primary); display: grid; place-items: center; }

/* ---- 2 · get in position --------------------------------------------------- */
.position { display: flex; gap: 64px; padding: 48px 72px; align-items: stretch; }
.position-main { flex-grow: 1; display: flex; flex-direction: column; gap: 18px; min-width: 0; }
.position-top { display: flex; align-items: center; gap: 12px; }
.connected-pill { display: inline-flex; align-items: center; gap: 9px; padding: 9px 15px; border-radius: 999px; background: var(--primary); color: var(--on-primary); font: 600 14px/1 var(--font-body); }
.position h1 { font-size: clamp(36px, 3.4vw, 48px); }
.position .lede { font-size: 17px; max-width: 52ch; }
.position-pics { display: grid; grid-template-columns: 1.5fr 1fr 1fr; gap: 18px; margin: 10px 0 0; }
.position-pics figure { margin: 0; display: flex; flex-direction: column; gap: 9px; }
.position-pics img { width: 100%; height: 250px; object-fit: cover; border-radius: 16px; border: 1px solid var(--border-soft); }
.position-pics figcaption { font-size: 13.5px; color: var(--muted); }
.frame-pic { position: relative; }
.frame-pic img { object-fit: contain; background: #f6e5cc; }
/* The illustrated player spans x 35–65%, y 32–90% of pov-body.jpg; contain keeps that true at any width. */
.frame-outline { position: absolute; left: 50%; width: 64px; margin-left: -32px; top: 68px; height: 164px; border: 2.5px dashed var(--primary); border-radius: 16px; }
.fine { margin: 6px 0 0; font-size: 13px; color: var(--faint); }
.position-side { flex: none; width: 360px; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 24px; background: var(--surface); border: 1px solid var(--border-soft); border-radius: var(--r-large); padding: 36px 30px; box-shadow: 0 18px 50px rgba(90,114,56,.10); }
.ring { width: 170px; height: 170px; }
.ring text { font: 900 44px var(--font-display); fill: var(--heading); }
.ring .ring-sub { font: 400 14px var(--font-body); fill: var(--muted); }
#ringArc { transition: stroke-dasharray .35s ease; }
.checklist { list-style: none; margin: 0; padding: 0 0 0 26px; align-self: stretch; display: flex; flex-direction: column; gap: 14px; }
.checklist li { display: flex; align-items: center; gap: 12px; font: 800 22px/1 var(--font-display); color: var(--heading); }
.checklist .tick { flex: none; width: 30px; height: 30px; border-radius: 999px; display: grid; place-items: center; }
.checklist .ok .tick { background: var(--primary); }
.checklist .missing { color: var(--warn-strong); }
.checklist .missing .tick { border: 3px solid var(--warn); }
.checklist.small { flex-direction: row; justify-content: center; gap: 14px; padding: 0; margin: 4px 0; }
.checklist.small li { font: 600 13px/1 var(--font-body); gap: 6px; color: var(--text); }
.checklist.small .missing { color: var(--warn-strong); }
.checklist.small .tick { width: 20px; height: 20px; }
.checklist.small .missing .tick { border-width: 2.5px; }
.fix-hint { align-self: stretch; background: var(--warn-bg); border: 1px solid var(--warn-border); border-radius: 12px; padding: 11px 14px; font-size: 14px; color: var(--warn-text); text-align: center; }
.position-actions { display: flex; gap: 10px; flex-wrap: wrap; justify-content: center; }
.position-actions .secondary { padding: 11px 15px; font-size: 13px; }

/* ---- 3 · flight: fullscreen, HUD only -------------------------------------- */
body[data-screen="flight"] { overflow: hidden; }
body[data-screen="flight"] .site-header,
body[data-screen="flight"] .intro,
body[data-screen="flight"] .guide-card { display: none; }
body[data-screen="flight"] .home { display: block; padding: 0; }
/* aspect-ratio must be cleared: it outranks inset:0, and the phone layout sets one. */
body[data-screen="flight"] .stage { position: fixed; inset: 0; width: auto; height: auto; min-height: 0; aspect-ratio: auto; border: 0; border-radius: 0; box-shadow: none; z-index: 10; }

.hud { position: absolute; top: 28px; left: 32px; right: 32px; display: flex; align-items: flex-start; justify-content: space-between; pointer-events: none; z-index: 5; }
.hud-pill { background: rgba(255,252,244,.92); border-radius: 22px; box-shadow: 0 6px 18px rgba(52,79,64,.10); padding: 11px 20px; display: flex; align-items: center; gap: 9px; font: 800 23px/1.1 var(--font-display); color: var(--heading); }
.hearts { gap: 8px; padding: 12px 18px; }
.hearts svg { fill: #d77a55; }
.hearts svg.empty { fill: #dcd7c6; }
.time { gap: 12px; }
.time button { pointer-events: auto; display: grid; place-items: center; width: 34px; height: 34px; margin: -6px -10px -6px 0; border: 0; border-radius: 999px; background: var(--raised); color: var(--accent); }
.flight-progress { position: absolute; left: 32px; right: 32px; bottom: 22px; z-index: 5; pointer-events: none; }
#progress { height: 5px; border-radius: 999px; background: rgba(255,252,244,.55); overflow: hidden; }
#progress i { display: block; height: 100%; width: 0; border-radius: inherit; background: var(--primary); }
.pause-hint { position: absolute; left: 50%; bottom: 52px; transform: translateX(-50%); z-index: 2; background: rgba(255,252,244,.92); border-radius: 22px; box-shadow: 0 6px 18px rgba(52,79,64,.10); padding: 12px 22px; display: flex; align-items: center; gap: 12px; font-size: 15px; color: var(--text); color: var(--text); white-space: nowrap; animation: hint-in .35s ease-out; pointer-events: none; }
.pause-hint svg { color: var(--primary); }
@keyframes hint-in { from { opacity: 0; transform: translate(-50%, 10px); } }

/* ---- overlays: one card over the softened world ---------------------------- */
.overlay { position: absolute; inset: 0; z-index: 4; display: flex; align-items: center; justify-content: center; padding: 24px 24px 110px; background: rgba(247,242,231,.58); backdrop-filter: blur(4px) saturate(.8); -webkit-backdrop-filter: blur(4px) saturate(.8); }
.overlay-card { width: min(460px, 100%); max-height: 100%; overflow-y: auto; background: var(--surface); border: 1px solid var(--border-soft); border-radius: 20px; box-shadow: 0 24px 60px rgba(52,79,64,.16); padding: 32px 34px; display: flex; flex-direction: column; align-items: center; gap: 12px; text-align: center; }
.overlay-card h2 { font-size: 32px; }
.overlay-card p { margin: 0; font-size: 15px; line-height: 1.6; color: var(--muted); }
.card-actions { display: flex; flex-direction: column; gap: 10px; align-self: stretch; margin-top: 10px; }
.card-actions .primary { font-size: 16px; padding: 16px; }
.card-actions .secondary { font-size: 15px; }
.card-actions .link-button { align-self: center; }
.overlay[data-kind="countdown"] { background: transparent; backdrop-filter: none; -webkit-backdrop-filter: none; pointer-events: none; padding-bottom: 24px; }
.overlay[data-kind="countdown"] .overlay-card { width: auto; min-width: 280px; background: rgba(255,252,244,.94); padding: 24px 30px; }
.count { font: 900 88px/1 var(--font-display); color: var(--heading); }
.card-guide { width: 170px; height: 170px; border-radius: 16px; object-fit: cover; }
.overlay-card .moves { display: flex; flex-direction: column; gap: 8px; align-items: flex-start; }
.overlay-card .move, .overlay-card .move b { font-size: 14px; }
.card-icon { width: 96px; height: 96px; border-radius: 999px; background: var(--warn-bg); display: grid; place-items: center; }
.reconnecting { color: var(--warn-text) !important; font-size: 13px !important; display: flex; align-items: center; gap: 9px; }
.reconnecting::before { content: ''; width: 14px; height: 14px; border-radius: 999px; border: 2.5px solid var(--warn); border-right-color: transparent; animation: spin 1s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }
.stats { display: flex; gap: 22px; margin: 4px 0; }
.stats strong { display: flex; align-items: center; justify-content: center; gap: 4px; font: 800 26px var(--font-display); color: var(--heading); }
.stats span { font-size: 11px; font-weight: 600; letter-spacing: .11em; text-transform: uppercase; color: var(--muted-2); }
.overlay-card .best-note { font-size: 13px; }
.session { align-self: stretch; background: var(--bg); border: 1px solid var(--border-soft); border-radius: 12px; padding: 9px 12px; display: flex; flex-direction: column; gap: 6px; font-size: 13px; text-align: left; }
.session > div { display: flex; justify-content: space-between; color: var(--muted); }
.session > .me { color: var(--heading); font-weight: 700; }

/* Controls come back only when the game is paused or finished. */
.paused-bar { position: absolute; left: 32px; right: 32px; bottom: 44px; z-index: 5; display: flex; align-items: center; gap: 12px; }
.bar-pill { background: rgba(255,252,244,.92); border-radius: 22px; box-shadow: 0 6px 18px rgba(52,79,64,.10); padding: 10px 16px; display: flex; align-items: center; gap: 10px; font-size: 14px; color: var(--text); }
.bar-pill.guide-chip { padding: 6px 16px 6px 6px; }
.bar-pill.guide-chip.no-image { padding: 10px 16px; }
.guide-chip img { width: 40px; height: 40px; border-radius: 12px; object-fit: cover; }
.guide-chip b { font: 800 14.5px var(--font-display); color: var(--heading); }
.bar-spacer { flex-grow: 1; }
.paused-bar .secondary { padding: 12px 16px; }

#camera { position: absolute; bottom: 44px; right: 24px; width: 150px; border-radius: 14px; transform: scaleX(-1); border: 2px solid var(--surface); z-index: 3; }
body[data-phase="paused"] #camera, body[data-phase="won"] #camera, body[data-phase="lost"] #camera { bottom: 110px; }

/* ---- responsive ------------------------------------------------------------ */
@media (max-width: 1100px) {
  .site-header { padding: 16px 32px; }
  .home { min-height: 0; }
  .home { padding: 28px 32px; gap: 32px; grid-template-columns: minmax(340px, 420px) minmax(0, 1fr); }
  .position { padding: 36px 32px; gap: 32px; }
  .position-side { width: 300px; }
  .position-pics { grid-template-columns: 1fr 1fr; } .position-pics figure:last-child { display: none; }
  .guide-place { display: none; }
}
@media (max-width: 899px) {
  .site-header { padding: 14px 20px; gap: 10px; }
  .brand-studio, .brand-sep { display: none; }
  .home { grid-template-columns: 1fr; padding: 22px 20px 36px; }
  .stage { min-height: 0; aspect-ratio: 1.35; flex-grow: 0; }
  .fallback-label { display: none; }
  .guide-card { gap: 14px; padding: 12px; }
  .guide-card img { width: 84px; height: 84px; }
  .move { white-space: nowrap; font-size: 14px; } .move b { font-size: 15px; }
  .fallback-buttons .secondary:first-child { background: var(--primary); border-color: var(--primary); color: var(--on-primary); box-shadow: var(--press); }
  .position { flex-direction: column; padding: 24px 20px; }
  .position-side { width: auto; }
  .position-pics { grid-template-columns: 1fr; } .position-pics figure:not(:first-child) { display: none; }
  .hud { top: 12px; left: 12px; right: 12px; }
  .hud-pill { font-size: 18px; padding: 8px 12px; border-radius: 14px; }
  .hearts svg { width: 17px; height: 16px; }
  .pause-hint { white-space: normal; width: calc(100% - 40px); font-size: 13px; }
  .paused-bar { left: 12px; right: 12px; bottom: 36px; flex-wrap: wrap; gap: 8px; }
  .paused-bar .bar-pill.guide-chip, .bar-spacer { display: none; }
  .paused-bar .secondary { padding: 9px 12px; font-size: 12.5px; }
  .overlay { padding: 12px 12px 120px; }
  .overlay-card { padding: 22px 20px; }
  .overlay-card h2 { font-size: 25px; }
  .count { font-size: 64px; }
  .card-guide { width: 120px; height: 120px; }
  #camera { width: 96px; }
}
/* TV and short laptop screens: the whole home — scan panel and fallbacks — fits. */
@media (max-height: 800px) and (min-width: 900px) {
  .site-header { padding-top: 12px; padding-bottom: 12px; }
  .home { padding-top: 22px; padding-bottom: 22px; min-height: calc(100vh - 63px); }
  .intro { gap: 10px; }
  h1 { font-size: 40px; }
  .lede { font-size: 14.5px; }
  .scan-panel { padding: 16px 18px 12px; gap: 11px; }
  .scan-qr { width: 132px; height: 132px; }
  .scan-steps { gap: 6px; }
  .fallbacks { margin-top: 0; }
  .guide-card img { width: 88px; height: 88px; }
}
@media (max-height: 640px) and (min-width: 900px) {
  .overlay-card { padding: 18px 26px; gap: 8px; }
  .overlay-card h2 { font-size: 26px; }
  .card-guide { width: 110px; height: 110px; }
  .count { font-size: 64px; }
}
@media (prefers-reduced-motion: reduce) { *, *::before, *::after { animation: none !important; transition: none !important; } }
.frame-peek { position: relative; width: 150px; height: 180px; border-radius: 16px; overflow: hidden; background: #efe6d3; border: 1px solid var(--border-soft); }
.frame-peek img { position: absolute; left: -30px; top: -54px; width: 204px; max-width: none; }
.frame-peek span { position: absolute; left: 42px; top: 38px; width: 66px; height: 180px; border: 2.5px dashed var(--warn); border-radius: 14px; }
.overlay[data-kind="won"] .overlay-card, .overlay[data-kind="lost"] .overlay-card { padding-top: 0; overflow-x: hidden; }
.result-art { width: calc(100% + 68px); max-width: none; margin: 0 -34px 6px; height: 130px; object-fit: cover; }
@media (max-width: 899px) { .result-art { width: calc(100% + 40px); margin: 0 -20px 4px; height: 96px; } .frame-peek { width: 120px; height: 140px; } }
