/* v1.2.3: one presentation layer. No historical logo or locale overrides. */
:root {
  color-scheme: dark;
  --ink: #ffedbe;
  --muted: #afc2c5;
  --mint: #abd4c0;
  --yellow: #ffc16b;
  --navy: #101c2c;
  --rule: #aec7c02c;
  --platform-top: 0px;
  --platform-bottom: 0px;
  font-family: ui-sans-serif, system-ui, -apple-system, "Segoe UI", Arial, sans-serif;
  font-synthesis: weight;
}
* { box-sizing: border-box; }
html, body { margin: 0; width: 100%; height: 100%; overflow: hidden; }
body { color: var(--ink); background: radial-gradient(ellipse at 50% 30%, #304452, #111c2b 75%); }
button, input, select { font: inherit; }
button { border: 0; cursor: pointer; touch-action: manipulation; color: inherit; -webkit-tap-highlight-color: transparent; }
button:disabled { opacity: .48; cursor: default; }
button:focus-visible, summary:focus-visible, canvas:focus-visible, select:focus-visible, input:focus-visible { outline: 2px solid var(--yellow); outline-offset: 3px; }
button:hover:not(:disabled) { filter: brightness(1.08); }
button:active:not(:disabled) { transform: translateY(1px); }
button svg { flex-shrink: 0; }
[hidden] { display: none !important; }
h1, h2, h3, p { margin: 0; }
#app { height: 100dvh; display: flex; align-items: center; justify-content: center; padding: 22px; }
.stage { position: relative; flex-shrink: 0; width: min(420px, calc((100dvh - 44px) * .52)); height: calc(100dvh - 44px); max-height: 910px; overflow: hidden; isolation: isolate; border: 2px solid #101b29; border-radius: 22px; background: #111d30; box-shadow: 0 0 0 1px #7f999433, 9px 13px 0 #08121c7a, 0 30px 100px #030b1780; }
canvas { display: block; width: 100%; height: 100%; touch-action: none; }
.hud { position: absolute; inset: 0; pointer-events: none; }
.hud button { pointer-events: auto; }
.icon-button { display: grid; place-items: center; width: 48px; height: 48px; min-width: 48px; border-radius: 50%; background: transparent; color: #c4d5cf; }
/* Live HUD: state, not narration. Canvas geometry and hit testing are unchanged. */
.topbar { position: absolute; top: 3px; left: 16px; right: 11px; height: 44px; display: flex; align-items: center; gap: 8px; }
.night-meta { flex: 0 0 56px; min-width: 0; }
.night-meta span { display: block; line-height: 1.5; font-size: 9px; color: #c4d2cd; letter-spacing: 1.2px; font-weight: 750; font-variant-numeric: tabular-nums; }
.night-meta #story-time { color: var(--ink); font-size: 11px; letter-spacing: .4px; }
.remaining { display: flex; gap: 5px; align-items: center; color: var(--mint); padding: 5px 9px; background: #10203598; border: 1px solid var(--rule); border-radius: 16px; }
.remaining b { font-size: 15px; }
.topbar .icon-button { width: 44px; height: 44px; min-width: 44px; border: 1px solid var(--rule); background: #10203588; }
.time-row { display: flex; flex: 1; min-width: 0; align-items: center; gap: 4px; height: 25px; }
.time-row > span { color: var(--yellow); font-size: 10px; font-weight: 750; font-variant-numeric: tabular-nums; }
.time-row > span:empty { display: none; }
.night-arc { flex: 1; height: 21px; min-width: 0; }
.sleep-row { position: absolute; top: calc(61px * var(--ui-scale,1)); left: 16px; right: 16px; display: flex; align-items: center; gap: 7px; }
.sleep-row > span { display: grid; place-items: center; width: 16px; color: var(--mint); }
.sleep-row > b { font-size: 10px; min-width: 20px; text-align: right; color: #c8d8ce; font-variant-numeric: tabular-nums; }
.meter { height: 4px; flex: 1; overflow: hidden; border-radius: 4px; background: #d4ddce22; }
.meter i { display: block; height: 100%; width: 100%; border-radius: inherit; background: var(--mint); transition: width .1s linear; }
.meter i.low { background: #eea586; }
.bottom-hud { position: absolute; left: 16px; right: 16px; bottom: 16px; }
.controls { display: flex; align-items: center; gap: 15px; }
.controls.left-hand { flex-direction: row-reverse; }
.light-button { position: relative; display: grid; place-items: center; flex: 0 0 60px; width: 60px; height: 60px; border-radius: 50%; border: 2px solid #b4c5be3b; background: #1c3044ee; color: var(--mint); box-shadow: 0 5px 0 #071321aa; }
.light-button.on { color: #203446; background: var(--yellow); border-color: #ffe6b4; }
.light-button span { position: absolute; width: 1px; height: 1px; overflow: hidden; clip-path: inset(50%); white-space: nowrap; }
.control-info { flex: 1; min-width: 0; pointer-events: none; user-select: none; }
.tap-guide { display: flex; align-items: center; gap: 8px; margin-bottom: 8px; color: #ffe0ad; pointer-events: none; }
.tap-guide * { pointer-events: none; }
.tap-glyph { position: relative; display: grid; place-items: center; width: 27px; flex: 0 0 27px; height: 30px; }
.tap-glyph i { position: absolute; width: 13px; height: 13px; border: 1px solid currentColor; border-radius: 50%; top: 0; left: 6px; opacity: 0; }
.tap-guide[data-state=discover] .tap-glyph i { animation: tap-once 2.2s ease-out 3; }
.tap-copy { min-width: 0; }
.tap-copy strong { display: block; font-size: 14px; line-height: 1.5; font-weight: 850; }
.tap-copy small { display: block; color: var(--muted); font-size: 9px; line-height: 1.55; white-space: nowrap; }
@keyframes tap-once { 0%,48%,100% { opacity: 0; transform: scale(.7); } 12% { opacity: .7; transform: scale(1); } 38% { opacity: 0; transform: scale(2); } }
.energy { display: flex; align-items: center; gap: 7px; width: 155px; max-width: 100%; color: #c7d6c6; }
.energy > div:first-child { display: flex; align-items: center; gap: 5px; }
.energy > div:first-child span { display: grid; place-items: center; }
.energy b { font-size: 10px; font-weight: 750; min-width: 18px; font-variant-numeric: tabular-nums; }
.energy .meter { height: 4px; min-width: 35px; }
.energy .meter i { background: #d4c694; }
#assist-status { display: grid; place-items: center; color: var(--mint); }
.controls.left-hand .control-info { display: flex; flex-direction: column; align-items: flex-end; }
.hint { position: absolute; left: 0; right: 0; bottom: 78px; margin: 0 auto; max-width: 290px; padding: 6px 10px; color: #e0e7d5; font-size: 11px; line-height: 1.5; font-weight: 650; text-align: center; border-radius: 8px; background: #102035dc; text-shadow: 0 2px 5px #071321; }
.toast { position: absolute; left: 18px; right: 18px; bottom: 100px; z-index: 15; pointer-events: none; padding: 10px 12px; text-align: center; font-size: 12px; line-height: 1.5; font-weight: 750; background: #21374bf5; color: var(--ink); border: 1px solid #dfc59b8f; border-radius: 9px; box-shadow: 3px 4px 0 #061222aa; }
/* Shared panels. Secondary explanations belong in folds, never stacked slogans. */
.overlay { position: absolute; inset: 0; z-index: 10; display: flex; align-items: center; justify-content: center; padding: 22px; background: #0d1a2acc; backdrop-filter: blur(7px); }
.panel { position: relative; width: 100%; max-height: 100%; overflow: auto; padding: 25px 21px; border: 2px solid #101e2d; border-radius: 18px; background: linear-gradient(145deg,#273e4e,#1b3043); box-shadow: 5px 7px 0 #071422ab,inset 0 0 0 1px #b4c0b720; scrollbar-width: thin; scrollbar-color: #abc0b644 transparent; overscroll-behavior: contain; }
.panel h2 { font-size: 30px; line-height: 1.15; letter-spacing: -.8px; font-weight: 950; margin: 7px 0 22px; color: var(--ink); text-wrap: balance; text-shadow: 2px 3px 0 #102031; }
.panel p { line-height: 1.65; }
.panel-top { display: flex; align-items: center; gap: 9px; margin: -14px -10px 8px; }
.eyebrow { color: var(--mint); font-size: 10px; font-weight: 750; letter-spacing: 1.2px; line-height: 1.6; }
.primary, .secondary { display: flex; justify-content: center; align-items: center; gap: 10px; width: 100%; min-height: 50px; padding: 12px 15px; margin-top: 13px; border-radius: 12px; font-size: 14px; line-height: 1.35; font-weight: 850; }
.primary { border: 2px solid #152439; background: var(--yellow); color: #14283a; box-shadow: 0 4px 0 #ad774b; }
.primary svg { margin-left: auto; }
.secondary { background: #21374b; border: 1px solid #bed0c738; color: #d2dfd3; }
.menu-row { display: flex; gap: 8px; margin-top: 14px; }
.menu-row button { flex: 1; min-width: 0; min-height: 48px; padding: 7px; border-radius: 10px; background: #21384b9c; border: 1px solid #b5c5c229; color: #c1d2cd; font-size: 12px; line-height: 1.3; }
.text-button { display: flex; align-items: center; justify-content: center; gap: 8px; width: 100%; min-height: 46px; padding: 8px 4px; background: transparent; color: #b8ceca; font-size: 12px; line-height: 1.45; }
.subtle, .failure-tip { color: #c3d4cc; font-size: 13px; line-height: 1.7; margin: 5px 0 17px; }
.help-copy { color: #b8cbd0; font-size: 12px; line-height: 1.6; margin: 8px 0 12px; }
.storage-note { color: #ffe0b0; font-size: 12px; line-height: 1.6; padding: 8px 0; }
.fold { margin-top: 12px; border-top: 1px solid var(--rule); }
.fold summary { min-height: 44px; padding: 12px 3px; color: #c3d5cd; font-size: 12px; font-weight: 650; cursor: pointer; }
.fold[open] { padding-bottom: 4px; }
.input-reminder { display: flex; align-items: center; gap: 10px; margin: 10px 0; color: var(--yellow); pointer-events: none; }
.input-reminder svg { flex-shrink: 0; }
.input-reminder strong { display: block; font-size: 14px; line-height: 1.6; }
.input-reminder small { display: block; color: var(--muted); font-size: 10px; line-height: 1.6; }
/* One wordmark, one punchline, one main action. */
.overlay[data-mode=intro] { padding: 26px 24px 23px; background: linear-gradient(180deg,#102032b8 0%,#13243a24 48%,#10203319 65%,#102031eb 86%); backdrop-filter: none; }
.overlay[data-mode=intro] .panel { height: 100%; display: flex; flex-direction: column; border: 0; border-radius: 0; padding: 14px 0 2px; background: none; box-shadow: none; scrollbar-width: none; }
.brand-hero { flex: 0 0 auto; position: relative; padding-top: 18px; text-align: center; }
.brand-wordmark { display: block; width: 100%; height: auto; overflow: visible; pointer-events: none; user-select: none; filter: drop-shadow(0 9px 0 #07132166); }
.brand-mascot { transform-box: fill-box; transform-origin: center; animation: bug-bob 4.8s ease-in-out infinite; }
.mascot-wings { transform-box: fill-box; transform-origin: bottom center; animation: wing-fidget .32s ease-in-out infinite alternate; }
@keyframes bug-bob { 0%,100% { translate: 0 0; } 50% { translate: 0 -4px; } }
@keyframes wing-fidget { from { scale: 1 1; } to { scale: 1.035 .96; } }
.panel .hero-tagline { margin-top: 15px; font-size: 14px; font-weight: 700; letter-spacing: .3px; text-shadow: 0 3px 6px #08141d; }
.intro-space { flex: 1 1 70px; min-height: 30px; }
.continue-chip { display: flex; align-items: center; gap: 9px; flex: 0 0 auto; min-height: 43px; padding: 9px 11px; border: 1px dashed #abd4c03d; border-radius: 10px; background: #102433c9; margin-bottom: 10px; }
.continue-chip span { flex-shrink: 0; color: var(--yellow); font-size: 11px; font-weight: 850; }
.continue-chip strong { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; font-size: 12px; font-weight: 650; color: #c6d9cf; }
.continue-chip small { font-size: 10px; color: #a5babb; }
.overlay[data-mode=intro] .hero-play { flex: 0 0 auto; margin: 0 0 7px; min-height: 63px; border: 2px solid #11253a; border-radius: 14px 11px 14px 12px; background: #ffc66f; font-size: 19px; letter-spacing: .5px; box-shadow: 0 5px 0 #af7550,0 0 0 2px #ead9b4; transform: rotate(-.8deg); }
.overlay[data-mode=intro] .hero-play:active { transform: translateY(2px) rotate(-.8deg); }
.icon-menu { flex: 0 0 auto; }
.icon-menu button { display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 7px; min-height: 58px; padding: 8px 5px; background: #1c3140c9; }
.icon-menu button span { font-size: 11px; font-weight: 650; }
/* Timeline, briefing, tools and settings. */
.overlay[data-mode=levels], .overlay[data-mode=settings], .overlay[data-mode=tools] { padding: 17px; }
.stage-grid { display: grid; grid-template-columns: repeat(2,minmax(0,1fr)); gap: 8px; }
.stage-card { min-height: 78px; padding: 11px 9px; text-align: left; border: 1px solid var(--rule); border-radius: 10px; background: #152b3d62; }
.stage-card.selected { border-color: #abd4c096; background: #aecbb718; }
.stage-card small { display: flex; align-items: center; justify-content: space-between; font-size: 10px; color: #b3c7c5; font-weight: 650; }
.stage-card strong { display: block; margin: 6px 0 0; font-size: 12px; line-height: 1.4; font-weight: 750; }
.stars { display: block; font-size: 11px; color: var(--yellow); letter-spacing: 2px; margin-top: 6px; }
.badges { font-size: 10px; color: var(--mint); line-height: 1.6; margin-top: 15px; }
.brief-numbers { display: flex; align-items: center; gap: 20px; padding-bottom: 14px; margin-bottom: 18px; border-bottom: 1px solid var(--rule); color: var(--mint); font-size: 14px; font-weight: 750; }
.brief-numbers span { display: inline-flex; align-items: center; gap: 6px; }
.brief-tip { color: #d2ddd0; font-size: 15px; line-height: 1.65; margin-bottom: 23px; }
.coin-total { font-size: 28px; font-weight: 850; color: var(--yellow); margin: -4px 0 18px; }
.coin-total span { font-size: 11px; color: var(--muted); letter-spacing: 1px; }
.tool-card { display: flex; gap: 9px; align-items: center; padding: 16px 0; border-top: 1px solid var(--rule); }
.tool-icon { display: grid; place-items: center; width: 34px; color: var(--mint); flex: 0 0 34px; }
.tool-card > div:nth-child(2) { flex: 1; min-width: 0; }
.tool-card h3 { font-size: 14px; font-weight: 800; }
.tool-card small { color: var(--muted); font-size: 11px; line-height: 1.5; }
.tool-card p { font-size: 12px; color: #d1dcce; }
.tool-card button { min-height: 48px; padding: 8px; min-width: 70px; border-radius: 9px; font-size: 12px; font-weight: 750; background: #385464; color: #d7e1d0; border: 1px solid var(--rule); }
.setting-list { border-top: 1px solid var(--rule); }
.setting { display: flex; align-items: center; gap: 8px; min-height: 47px; border-bottom: 1px solid var(--rule); font-size: 12px; color: #c1d4cd; }
.setting > span { flex: 1; min-width: 0; line-height: 1.4; }
.setting > input[type=range] { width: 86px; min-height: 40px; accent-color: var(--mint); }
.setting > output { width: 32px; font-size: 10px; text-align: right; color: #b9cac8; }
.setting input[type=checkbox] { appearance: none; flex: 0 0 39px; width: 39px; height: 23px; border: 1px solid #839da56a; border-radius: 14px; background: #152639; position: relative; cursor: pointer; }
.setting input[type=checkbox]:after { content: ''; position: absolute; width: 15px; height: 15px; border-radius: 50%; left: 3px; top: 3px; background: #8babb4; }
.setting input[type=checkbox]:checked { background: #93b8a0; }
.setting input[type=checkbox]:checked:after { left: 19px; background: #203b43; }
.setting select { max-width: 132px; border: 1px solid #abc0b54a; border-radius: 7px; color: #d4dfd3; background: #1b3143; min-height: 40px; padding: 5px; font-size: 11px; }
/* Results: one verdict, real statistics, optional accounting. */
.result-stars { font-size: 28px; letter-spacing: 7px; color: var(--yellow); margin: 17px 0; }
.result-stars.lost { letter-spacing: 0; color: var(--mint); }
.result-stats { display: grid; grid-template-columns: repeat(3,minmax(0,1fr)); gap: 10px; border-block: 1px solid var(--rule); padding: 15px 0; margin: 15px 0; }
.result-stats b { display: block; font-size: 26px; font-weight: 850; color: var(--ink); font-variant-numeric: tabular-nums; }
.result-stats span { display: block; margin-top: 5px; font-size: 10px; letter-spacing: .3px; color: #b0c5c9; }
.result-line { display: flex; align-items: center; justify-content: space-between; gap: 9px; margin: 13px 0; color: #b9cdcc; font-size: 12px; font-variant-numeric: tabular-nums; }
.result-line strong { color: var(--yellow); font-size: 16px; }
.night-grade { display: grid; place-items: center; width: 68px; height: 72px; margin: 17px 0 23px; transform: rotate(-7deg); border: 3px solid #102234; border-radius: 14px; background: var(--mint); color: #16333e; font-size: 54px; line-height: 1; font-weight: 950; box-shadow: 4px 5px 0 #091a2b; }
.night-report { display: grid; grid-template-columns: repeat(3,minmax(0,1fr)); gap: 9px 7px; margin: 20px 0 15px; }
.night-report > div { display: flex; align-items: center; flex-direction: column; gap: 6px; padding: 11px 2px; background: #132b3b40; border: 1px dashed #b2cab025; border-radius: 10px; }
.night-report b { font-size: 27px; font-weight: 850; font-variant-numeric: tabular-nums; }
.night-report span { font-size: 9px; color: #b0c5c8; line-height: 1.5; text-align: center; }
.overlay[data-mode=pause], .overlay[data-mode=preparing] { background: #0e1c2bdc; backdrop-filter: blur(12px); }
.listening-cue { display: flex; gap: 12px; align-items: center; justify-content: center; color: var(--mint); font-size: 15px; padding: 6px; }
#overlay[data-mode=transition] { background: transparent; backdrop-filter: none; }
#overlay[data-mode=transition] #panel { background: transparent; border: 0; box-shadow: none; text-align: center; }
.beat-transition h2 { font-size: 29px; margin: 12px 0; text-shadow: 0 3px 12px #081529; }
.overlay[data-mode=ending] { background: transparent; backdrop-filter: none; align-items: flex-end; padding-bottom: 100px; }
.overlay[data-mode=ending] .panel { background: linear-gradient(0deg,#172a3ce0,#233a5060); text-align: center; border: 0; box-shadow: none; }
.ending-copy h2 { margin: 16px 0; }
#debug-badge { position: absolute; top: 105px; left: 16px; z-index: 11; font-size: 9px; padding: 6px; background: #193045; color: var(--yellow); pointer-events: none; }
@media(max-width:900px) { #app { padding: 16px; } .stage { width: min(440px,100%); height: calc(100dvh - 32px); } }
@media(max-width:540px) {
  #app { padding: 0; padding-top: max(env(safe-area-inset-top,0px),var(--platform-top)); padding-bottom: max(env(safe-area-inset-bottom,0px),var(--platform-bottom)); }
  .stage { width: 100%; height: 100%; max-height: none; border: 0; border-radius: 0; box-shadow: none; }
}
@media(max-height:700px) {
  .overlay[data-mode=intro] { padding: 19px 22px; }
  .brand-hero { padding-top: 8px; }
  .panel .hero-tagline { font-size: 13px; margin-top: 10px; }
  .panel h2 { font-size: 27px; margin-bottom: 18px; }
  .night-grade { width: 55px; height: 59px; font-size: 43px; margin: 12px 0 19px; }
  .night-report { margin: 13px 0; gap: 6px; }
  .night-report > div { padding: 8px 1px; }
  .night-report b { font-size: 24px; }
}
@media(max-width:350px) {
  .overlay { padding: 17px; } .panel { padding: 23px 16px; }
  .overlay[data-mode=intro] { padding: 17px 20px; }
  .panel .hero-tagline { font-size: 12px; }
  .continue-chip { gap: 6px; padding: 9px; }
  .continue-chip strong { font-size: 10px; }
  .continue-chip small { font-size: 9px; }
  .overlay[data-mode=intro] .hero-play { font-size: 17px; }
  .tap-copy small { font-size: 8px; }
  .controls { gap: 10px; }
  .setting select { max-width: 114px; }
}
@media(max-height:500px) {
  .overlay[data-mode=intro] { padding: 10px 22px; }
  .overlay[data-mode=intro] .panel { padding-top: 2px; }
  .brand-hero { max-width: 230px; align-self: center; width: 100%; padding-top: 3px; }
  .panel .hero-tagline { font-size: 12px; margin-top: 7px; }
  .intro-space { min-height: 15px; flex-basis: 15px; }
  .overlay[data-mode=intro] .hero-play { min-height: 52px; font-size: 17px; }
  .icon-menu button { min-height: 50px; gap: 5px; }
}
@media(prefers-reduced-motion:reduce){.brand-mascot,.mascot-wings{animation:none!important;translate:none!important;scale:none!important}.tap-glyph i{animation:none!important}.meter i{transition:none!important}}
.reduced-motion .brand-mascot, .reduced-motion .mascot-wings { animation: none !important; translate: none !important; scale: none !important; }
.reduced-motion * { animation: none !important; transition: none !important; }
.reduced-motion .night-grade { transform: none; }

/* v1.3.0: platform chrome is absent during play unless an SDK ad owns focus. */
.ad-gate { position: absolute; inset: 0; z-index: 80; display: grid; place-items: center; padding: 24px; background: #101b2cf5; color: #f2e1bd; text-align: center; }
.ad-gate[hidden] { display: none; }
.ad-gate > div { max-width: 300px; }
.ad-gate strong { font-size: 23px; }
.ad-gate p { font-size: 14px; line-height: 1.55; }
.ad-caption,.night-coins { text-align: center; font-size: 12px; line-height: 1.4; color: #c2d0c2; margin: 8px 0 12px; }
.ad-choice { font-size: 15px !important; min-height: 52px; }
@media(max-width:540px) {
 #app { padding-left: max(env(safe-area-inset-left,0px),var(--platform-left,0px)); padding-right: max(env(safe-area-inset-right,0px),var(--platform-right,0px)); }
}
