:root {
  --ink: #0e1422;
  --panel: rgba(12, 18, 31, 0.62);
  --line: rgba(255, 255, 255, 0.14);
  --text: #f3eee4;
  --muted: rgba(243, 238, 228, 0.64);
  --gold: #d6b26a;
  --aqua: #8de8de;
  --serif: 'Cormorant Garamond', 'Times New Roman', serif;
  --sans: 'Inter', system-ui, -apple-system, sans-serif;
}
* { box-sizing: border-box; }
html, body { margin: 0; background: var(--ink); color: var(--text); font-family: var(--sans); font-size: 14px; -webkit-font-smoothing: antialiased; }
/* The game fills the viewport above a reserved footer row. Short screens scroll
   the document instead of squeezing the terrace below a playable height. */
body { min-height: 100vh; min-height: 100dvh; display: flex; flex-direction: column; }
#stage { position: relative; flex: 1 0 auto; min-height: 420px; overflow: hidden; isolation: isolate; -webkit-user-select: none; user-select: none; }
canvas#c { position: absolute; inset: 0; width: 100%; height: 100%; display: block; touch-action: none; outline: none; }
canvas#c:focus-visible { outline: 2px solid var(--gold); outline-offset: -2px; }
.hidden { display: none !important; }
.screen { position: absolute; inset: 0; display: flex; z-index: 10; transition: opacity .9s ease; }
.fade { opacity: 0; pointer-events: none; }
button { font-family: var(--sans); cursor: pointer; color: inherit; }
button:focus-visible, .site-header a:focus-visible, .exploration-bar a:focus-visible { outline: 2px solid var(--gold); outline-offset: 2px; }
kbd { font-family: var(--sans); font-size: 11px; font-weight: 500; color: var(--text); border: 1px solid var(--line); border-radius: 3px; padding: 1px 5px; margin-right: 2px; }

.eyebrow { font-size: 11px; font-weight: 600; letter-spacing: .32em; text-transform: uppercase; color: var(--gold); }
.rule { width: 48px; height: 1px; background: var(--gold); margin: 18px 0 20px; opacity: .8; }
h1, h2 { font-family: var(--serif); font-weight: 500; line-height: .95; margin: 10px 0 0; letter-spacing: .005em; }
h1 { font-size: clamp(46px, 6.4vw, 84px); }
h2 { font-size: clamp(36px, 4.8vw, 60px); }
.story { font-size: 15px; line-height: 1.65; color: var(--muted); margin: 0 0 28px; max-width: 460px; }

.primary { font-size: 12px; font-weight: 600; letter-spacing: .24em; text-transform: uppercase; padding: 14px 34px; min-height: 44px; background: transparent; color: var(--gold); border: 1px solid var(--gold); border-radius: 2px; transition: background .2s ease, color .2s ease; }
.primary:hover { background: var(--gold); color: var(--ink); }

/* loader */
#loader { align-items: center; justify-content: center; background: var(--ink); }
.loader-inner { text-align: center; }
.loader-title { font-family: var(--serif); font-size: 34px; margin: 10px 0 22px; }
.bar { width: min(260px, 60vw); height: 1px; background: var(--line); margin: 0 auto; }
#bar-fill { width: 0; height: 100%; background: var(--gold); transition: width .3s ease; }

/* title + finale */
#title { align-items: center; padding: 64px 7vw 24px; overflow-y: auto; background: linear-gradient(90deg, rgba(10,14,24,.88) 0%, rgba(10,14,24,.62) 34%, rgba(10,14,24,0) 64%); }
.title-card { max-width: 500px; }
.title-card.center { margin: auto; text-align: center; padding: 0 16px; }
.title-card.center .rule, .title-card.center .story { margin-left: auto; margin-right: auto; }
.controls { display: grid; grid-template-columns: auto 1fr; gap: 7px 18px; margin: 30px 0 0; font-size: 12.5px; }
.controls dt { color: var(--text); font-weight: 500; }
.controls dd { margin: 0; color: var(--muted); }
.quality { margin-top: 22px; display: flex; gap: 4px; align-items: center; font-size: 11px; letter-spacing: .14em; text-transform: uppercase; color: var(--muted); }
.quality span { margin-right: 8px; }
.q { font-size: 11px; letter-spacing: .08em; text-transform: uppercase; padding: 4px 9px; min-height: 28px; background: none; border: 1px solid transparent; border-radius: 2px; color: var(--muted); }
.q.active { border-color: var(--line); color: var(--text); }
#finale { background: radial-gradient(ellipse at center, rgba(10,12,30,.45), rgba(10,12,30,.78)); }
#halt { z-index: 25; align-items: center; background: radial-gradient(ellipse at center, #182038 0%, #0a0e18 75%); }
.noscript { position: absolute; inset: auto 0 40% 0; text-align: center; font-family: var(--serif); font-size: 22px; font-style: italic; padding: 0 20px; }

/* HUD: sits below the site header */
#hud { position: absolute; inset: 0; pointer-events: none; z-index: 5; }
.panel { position: absolute; display: flex; align-items: center; gap: 10px; background: var(--panel); border: 1px solid var(--line); border-radius: 4px; -webkit-backdrop-filter: blur(10px); backdrop-filter: blur(10px); }
.sep { width: 1px; height: 16px; background: var(--line); }
#status { top: 60px; left: 16px; padding: 9px 14px; }
.game-name { font-family: var(--serif); font-size: 17px; }
.lilies-label { font-size: 10.5px; letter-spacing: .22em; text-transform: uppercase; color: var(--muted); }
.lily { width: 9px; height: 9px; transform: rotate(45deg); border: 1px solid rgba(243,238,228,.45); transition: all .5s ease; }
.lily.lit { background: var(--aqua); border-color: var(--aqua); box-shadow: 0 0 10px rgba(141,232,222,.9); }
#tools { top: 60px; right: 16px; padding: 4px 6px; gap: 2px; pointer-events: auto; }
#tools button, #view button { background: none; border: 0; border-radius: 3px; transition: background .15s ease; }
#tools button { font-size: 11px; font-weight: 600; letter-spacing: .18em; text-transform: uppercase; padding: 8px 12px; min-height: 36px; }
#tools button:hover, #view button:hover { background: rgba(255,255,255,.08); }
#hint-btn { color: var(--gold); }
#tools button:disabled { opacity: .35; cursor: default; background: none; }
#view { right: 16px; bottom: 16px; padding: 4px; gap: 2px; pointer-events: auto; }
#view button { width: 40px; height: 40px; display: grid; place-items: center; }
#view svg { width: 20px; height: 20px; fill: none; stroke: var(--text); stroke-width: 1.5; stroke-linecap: round; stroke-linejoin: round; }
.touch-only { display: none !important; }
body.touch .touch-only { display: grid !important; }
#hint { left: 50%; bottom: 16px; transform: translateX(-50%); padding: 9px 16px; font-size: 12px; color: var(--muted); width: max-content; max-width: calc(100% - 330px); text-align: center; }
#toast { position: absolute; top: 116px; left: 50%; transform: translate(-50%, -6px); z-index: 6; font-family: var(--serif); font-style: italic; font-size: 25px; color: var(--text); text-shadow: 0 2px 14px rgba(0,0,0,.65), 0 0 2px rgba(0,0,0,.5); opacity: 0; transition: all .5s ease; pointer-events: none; text-align: center; padding: 0 16px; width: max-content; max-width: calc(100% - 32px); }
#toast.show { opacity: 1; transform: translate(-50%, 0); }

/* sound toggles: a slash appears and the icon dims when off */
#view .toggle .slash { display: none; stroke: var(--gold); }
#view .toggle.off svg { stroke: var(--muted); }
#view .toggle.off .slash { display: inline; }

/* Site shell: gallery navigation, signup and the shared footer */
.site-header { position: absolute; top: 0; left: 0; right: 0; z-index: 30; display: flex; justify-content: space-between; align-items: center; gap: 12px; padding: max(12px, env(safe-area-inset-top)) max(16px, env(safe-area-inset-right)) 0 max(16px, env(safe-area-inset-left)); pointer-events: none; }
.site-header a { pointer-events: auto; font-size: 11px; font-weight: 600; letter-spacing: .16em; text-transform: uppercase; color: var(--text); text-decoration: none; padding: 8px 12px; min-height: 34px; display: inline-flex; align-items: center; gap: 6px; background: var(--panel); border: 1px solid var(--line); border-radius: 4px; -webkit-backdrop-filter: blur(10px); backdrop-filter: blur(10px); white-space: nowrap; }
.site-header a:hover { border-color: var(--gold); }
.site-header .create-yours { color: var(--ink); background: var(--gold); border-color: var(--gold); }
.site-header .create-yours:hover { background: #e4c689; }

.exploration-bar { --exploration-footer-bg: #0a0e18; --exploration-footer-ink: rgba(243, 238, 228, 0.72); --exploration-footer-border: rgba(214, 178, 106, 0.22); flex: none; display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: 4px 22px; padding: 8px max(24px, env(safe-area-inset-right)) max(8px, env(safe-area-inset-bottom)) max(24px, env(safe-area-inset-left)); background: #0a0e18; color: rgba(243, 238, 228, 0.72); border-top: 1px solid rgba(214, 178, 106, 0.22); font: 12px/1.4 var(--sans); }
.exploration-credit { display: flex; align-items: baseline; gap: 12px; }
.exploration-credit strong { font-family: var(--serif); font-weight: 600; font-size: 17px; color: var(--text); }
.exploration-credit span { font-size: 12px; color: var(--muted); }
.exploration-bar a { color: var(--text); }
.exploration-bar .making-links { display: flex; flex-wrap: wrap; align-items: baseline; gap: 0 20px; }
.exploration-bar .making-of { font-size: 11px; font-weight: 600; letter-spacing: .14em; text-transform: uppercase; text-decoration: none; border-bottom: 1px solid rgba(214, 178, 106, 0.5); padding: 8px 0 2px; }
.exploration-bar .making-of:hover { color: #fff; border-color: var(--gold); }
[data-exploration-controls].exploration-bar #scenario-exploration-analytics .scenario-exploration-controls { background: transparent; color: rgba(243, 238, 228, 0.72); border: 0; padding: 0; gap: 18px; }

@media (max-width: 720px) {
  /* margin-top:auto (not flex-end) so a card taller than the stage scrolls instead of clipping its top */
  #title { flex-direction: column; align-items: stretch; padding: 64px 16px 4vh; background: linear-gradient(0deg, rgba(10,14,24,.92) 0%, rgba(10,14,24,.7) 50%, rgba(10,14,24,0) 80%); }
  #title .title-card { margin-top: auto; }
  h1 { font-size: clamp(40px, 12vw, 56px); }
  .story { font-size: 14px; line-height: 1.55; margin-bottom: 20px; }
  .controls { display: none; }
  .game-name, #status .sep { display: none; }
  #hint { display: none; }
  #status { top: 56px; }
  #tools { top: 56px; }
  #toast { top: 108px; font-size: 21px; }
  .site-header a { letter-spacing: .1em; padding: 7px 10px; }
  .exploration-bar { padding-left: 16px; padding-right: 16px; gap: 2px 16px; }
  .exploration-bar #scenario-exploration-analytics { width: 100%; }
}
/* phones narrower than both panels side by side: the tools drop under the lily count */
@media (max-width: 420px) {
  #tools { top: 96px; }
  #toast { top: 150px; }
}
@media (max-height: 520px) {
  #title { align-items: flex-start; padding-top: 60px; }
  #title .title-card { margin-top: 0; }
  .story { margin-bottom: 16px; }
  .controls { margin-top: 16px; }
  #toast { top: 100px; font-size: 20px; }
}
@media (prefers-reduced-motion: reduce) {
  .screen, #toast, .lily, .primary, #bar-fill { transition: none; }
}
