@font-face { font-family: 'Pixelify Sans'; src: url(fonts/pixelify-sans.woff2) format('woff2'); font-weight: 400 700; font-display: swap; }
@font-face { font-family: Lora; src: url(fonts/lora.woff2) format('woff2'); font-weight: 400 700; font-style: normal; font-display: swap; }
@font-face { font-family: Lora; src: url(fonts/lora-italic.woff2) format('woff2'); font-weight: 400 700; font-style: italic; font-display: swap; }

/* The Dangerous Game. Dark ground, storm blue for what she has, the Den's
   violet for doors, bronze for names. The game world is a 144x192 canvas
   scaled up with crisp pixels; all text is real text, outside it. */
:root {
  --ground: #0b0c10;
  --panel: #16181f;
  --panel-edge: #2c2f3a;
  --ink: #ece9e2;
  --ink-mute: #a7a39b;
  --storm: #3fa0ff;
  --storm-lift: #6fc3ff;
  --violet: #a668b8;
  --bronze: #c48a4a;
  --danger: #ff8a7a;
  --px: 2px;
  color-scheme: dark;
}
* { box-sizing: border-box; }
html, body { margin: 0; height: 100%; background: var(--ground); color: var(--ink); }
body {
  font-family: Lora, Georgia, serif;
  font-variant-ligatures: none;
  -webkit-tap-highlight-color: transparent;
  overscroll-behavior: none;
  touch-action: manipulation;
}
#game {
  min-height: 100%;
  display: flex; flex-direction: column; align-items: center;
  padding: max(8px, env(safe-area-inset-top)) 8px max(8px, env(safe-area-inset-bottom));
  user-select: none; -webkit-user-select: none;
}

/* ---------------------------------------------------------------- HUD */
.hud { width: 100%; max-width: 560px; display: flex; align-items: center; justify-content: space-between; gap: 12px; height: 32px; }
.menu .hud { visibility: hidden; }
.cap { display: flex; align-items: center; gap: 8px; flex: 1; max-width: 240px; }
.cap-label { font: 600 12px/1 'Pixelify Sans', monospace; letter-spacing: .06em; text-transform: uppercase; color: var(--ink-mute); }
.cap-track { position: relative; flex: 1; height: 12px; background: #0f1016; border: 2px solid var(--panel-edge); }
.cap-track::after { content: ''; position: absolute; inset: 0 0 0 var(--max, 100%); background: repeating-linear-gradient(45deg, #1d1f27 0 3px, #0f1016 3px 6px); }
.cap-fill { position: absolute; inset: 0 auto 0 0; width: 100%; background: var(--storm); transition: width .15s linear; }
.cap.low .cap-fill { background: var(--danger); animation: pulse .8s steps(2) infinite; }
.cap.emp .cap-track { border-color: var(--storm-lift); box-shadow: 0 0 0 1px var(--storm); }
.hud-level { margin: 0; font: 600 13px/1.2 Lora, Georgia, serif; color: var(--bronze); text-align: right; }
@keyframes pulse { 50% { opacity: .55; } }

/* -------------------------------------------------------------- stage */
.stage { position: relative; margin-top: 4px; background: #000; outline: 2px solid var(--panel-edge); }
#world { display: block; width: 100%; height: 100%; image-rendering: pixelated; image-rendering: crisp-edges; }

.fade { position: absolute; inset: 0; background: #000; opacity: 0; pointer-events: none; transition: opacity .25s; }
.fade.on { opacity: 1; }

.hint {
  position: absolute; left: 8px; right: 8px; top: 8px; margin: 0;
  padding: 6px 10px; background: rgba(11,12,16,.82); border-left: 3px solid var(--storm);
  font: 400 15px/1.3 'Pixelify Sans', monospace; color: var(--ink);
  opacity: 0; transform: translateY(-4px); transition: opacity .2s, transform .2s; pointer-events: none;
}
.hint.on { opacity: 1; transform: none; }

/* ------------------------------------------------------------ dialogue */
.dialog {
  position: absolute; left: 6px; right: 6px; bottom: 6px;
  display: flex; gap: 10px; align-items: flex-start;
  padding: 10px 12px; min-height: 84px;
  background: rgba(18,19,25,.95); border: 2px solid #4a4438; box-shadow: inset 0 0 0 2px #1f1c17;
  cursor: pointer;
}
.dialog[hidden] { display: none; }
#dlg-portrait { width: 56px; height: 42px; flex: none; image-rendering: pixelated; background: #0b0c10; border: 2px solid #4a4438; }
#dlg-portrait[hidden] { display: none; }
.dlg-body { flex: 1; min-width: 0; position: relative; }
.dlg-name { margin: 0 0 4px; font: 600 13px/1 'Pixelify Sans', monospace; letter-spacing: .05em; text-transform: uppercase; color: var(--bronze); }
.dlg-name[hidden] { display: none; }
.dlg-text { margin: 0; font-size: 17px; line-height: 1.35; min-height: 2.7em; }
.who-narr .dlg-text { font-style: italic; color: #d9d4ca; }
.who-rune .dlg-text { color: var(--storm-lift); font-family: 'Pixelify Sans', monospace; font-size: 18px; }
.who-wolf .dlg-name, .who-celeste .dlg-name { color: #cfd3d8; }
.dlg-more { position: absolute; right: 0; bottom: -4px; color: var(--bronze); animation: pulse 1s steps(2) infinite; }

/* ------------------------------------------------------------ overlays */
.overlay {
  position: fixed; inset: 0; z-index: 10; overflow-y: auto;
  display: flex; align-items: center; justify-content: center;
  padding: 20px 18px;
  background: radial-gradient(ellipse at 50% 30%, rgba(30,34,46,.9), rgba(8,9,12,.96));
  text-align: center;
}
.overlay[hidden] { display: none; }
.overlay.title { background: linear-gradient(180deg, rgba(11,12,16,.35), rgba(11,12,16,.7) 40%, rgba(11,12,16,.94) 75%); }
.overlay > div, .overlay > form { width: 100%; max-width: 420px; }
.eyebrow { margin: 0 0 6px; font: 600 12px/1 'Pixelify Sans', monospace; letter-spacing: .12em; text-transform: uppercase; color: var(--bronze); }
.overlay h1 { margin: 0 0 10px; font: 600 clamp(30px, 9vw, 44px)/1 'Pixelify Sans', monospace; color: #f3efe6; text-shadow: 3px 3px 0 #2a2e3a; }
.overlay h2 { margin: 0 0 12px; font: 600 24px/1.15 'Pixelify Sans', monospace; color: #f3efe6; }
.overlay p { margin: 0 0 12px; font-size: 17px; line-height: 1.45; }
.lede { color: var(--ink-mute); font-style: italic; }
.small { font-size: 14px !important; color: var(--ink-mute); margin-top: 16px !important; }
.actions { display: flex; flex-direction: column; gap: 10px; margin: 18px 0 6px; }

.btn {
  display: block; width: 100%; padding: 12px 16px; min-height: 48px;
  font: 600 17px/1.2 'Pixelify Sans', monospace; color: var(--ink); text-decoration: none;
  background: #1f222b; border: 2px solid #3a3e4b; box-shadow: 0 3px 0 #08090c; cursor: pointer;
}
.btn:hover { background: #262a35; }
.btn:active { transform: translateY(2px); box-shadow: 0 1px 0 #08090c; }
.btn.primary { background: #e8c878; border-color: #f3dc9c; color: #1b1d24; }
.btn.primary:hover { background: #f3dc9c; }
.btn.ghost { background: transparent; }
.btn.small { display: inline-block; width: auto; min-height: 0; padding: 6px 12px; font-size: 14px; }
.btn:focus-visible, .link:focus-visible, input:focus-visible, .mute:focus-visible { outline: 3px solid var(--violet); outline-offset: 2px; }
.link, .mute { background: none; border: 0; color: var(--ink-mute); font: inherit; font-size: 15px; text-decoration: underline; cursor: pointer; padding: 10px; }
.mute { margin-top: 4px; font-size: 13px; }

.namecard input {
  width: 100%; min-height: 48px; padding: 10px 12px; font: 17px Lora, Georgia, serif;
  color: var(--ink); background: #0d0e13; border: 2px solid #3a3e4b;
}
.namecard input { text-align: center; font-family: 'Pixelify Sans', monospace; font-size: 22px; }
.namecard label h2 { margin-bottom: 16px; }

.waystone { padding: 22px 18px; background: #14151a; border: 3px solid #5a5650; box-shadow: inset 0 0 0 3px #2a2824, 0 0 0 3px #0b0c10; }

.regions { list-style: none; margin: 0; padding: 0; text-align: left; }
.regions .r { display: grid; grid-template-columns: 28px 1fr auto; gap: 10px; align-items: center; padding: 9px 4px; border-bottom: 1px solid #262833; }
.regions .n { font: 600 14px 'Pixelify Sans', monospace; color: var(--ink-mute); text-align: center; }
.regions .nm { font-size: 16px; }
.regions .st { font-size: 13px; color: var(--ink-mute); }
.regions .soon .nm, .regions .den .nm { color: #77746d; }
.regions .clear .n { color: var(--storm); }
.regions .clear .st { color: var(--storm-lift); }

/* ------------------------------------------------------------ controls */
.controls { display: flex; width: 100%; max-width: 560px; margin-top: 12px; align-items: center; justify-content: space-between; gap: 8px; }
.controls .dpad, .controls .buttons { display: none; }
.touch .controls .dpad, .touch .controls .buttons { display: flex; }
.touch .controls .dpad { display: block; }
.menu .controls { visibility: hidden; }
.dpad {
  position: relative; width: 140px; height: 140px; flex: none; touch-action: none;
  border-radius: 50%; background: rgba(255,255,255,.05); border: 2px solid rgba(255,255,255,.14);
}
.dpad::before, .dpad::after { content: ''; position: absolute; left: 50%; top: 50%; background: rgba(255,255,255,.09); transform: translate(-50%,-50%); }
.dpad::before { width: 44px; height: 116px; }
.dpad::after { width: 116px; height: 44px; }
.dpad-knob { position: absolute; left: 50%; top: 50%; width: 52px; height: 52px; margin: -26px 0 0 -26px; border-radius: 50%; background: rgba(255,255,255,.2); border: 2px solid rgba(255,255,255,.32); z-index: 1; }
.hud-ability { flex: 1; margin: 0; font: 400 12px/1.3 'Pixelify Sans', monospace; color: var(--ink-mute); text-align: center; }
.touch .hud-ability { font-size: 0; }
.buttons { display: flex; gap: 12px; align-items: flex-end; flex: none; }
.pad-btn {
  width: 76px; height: 76px; border-radius: 50%; touch-action: none;
  font: 600 13px/1 'Pixelify Sans', monospace; color: var(--ink);
  background: rgba(255,255,255,.08); border: 2px solid rgba(255,255,255,.25);
}
.pad-btn.strike { width: 88px; height: 88px; background: rgba(63,160,255,.22); border-color: var(--storm); margin-bottom: 24px; }
.pad-btn.abil[data-label]:not([data-label=""])::after { content: attr(data-label); display: block; margin-top: 3px; font-size: 10px; color: var(--storm-lift); }
.pad-btn.abil { font-size: 0; }
.pad-btn.abil::before { content: 'Hold'; font-size: 13px; }
.pad-btn.locked { opacity: .35; }
.pad-btn.down { background: rgba(255,255,255,.25); }

@media (prefers-reduced-motion: reduce) {
  .cap.low .cap-fill, .dlg-more { animation: none; }
}

/* ------------------------------------------------ the Marches and the Sigil */
.marches { display: block; width: 100%; max-width: 320px; margin: 6px auto 4px; }
.regions .st { display: flex; gap: 6px; justify-content: flex-end; flex-wrap: wrap; }
.btn.small.taken { border-color: var(--storm); color: var(--storm-lift); }
.shard { font: 600 15px/1.2 'Pixelify Sans', monospace; color: var(--storm-lift); }
.sigil-art { display: block; width: 220px; max-width: 70%; margin: 4px auto 12px; }
.preview { display: flex; gap: 14px; align-items: center; justify-content: center; margin: 6px 0 4px; text-align: left; }
.preview img { image-rendering: pixelated; flex: none; }
.preview ol { list-style: none; margin: 0; padding: 0; font-size: 14px; color: var(--ink-mute); }
.preview li { padding: 2px 0; }
.preview li span { color: var(--violet); margin-right: 4px; }

/* ======================================================= v2: the fable */
.hud { justify-content: flex-start; }
.stage { touch-action: none; }

/* The silhouette: an empty outline that fills, a gold piece per clearing. */
.silhouette { position: absolute; top: 6px; right: 6px; width: 34px; height: 64px; z-index: 3; pointer-events: none; transition: transform 1.6s ease, opacity 1.6s ease; }
.silhouette svg { width: 100%; height: 100%; display: block; }
.silhouette .ol { fill: none; stroke: rgba(232,200,120,0.25); stroke-width: 1.5; }
.silhouette .ol.on { stroke: rgba(232,200,120,0.85); }
.silhouette .pc { fill: rgba(255,255,255,0.04); transition: fill 0.8s; }
.silhouette .pc.on { fill: #e8c878; }
.silhouette.pulse { animation: sil-pulse 1s ease; }
.silhouette.glow svg { filter: drop-shadow(0 0 4px #e8c878); }
.silhouette.fly { transform: translate(calc(-50% - var(--stage-half, 100px) + 50%), 30%) scale(2.2); opacity: 0.2; }
@keyframes sil-pulse { 40% { transform: scale(1.25); } }

/* "Which is you?" choices: stacked cards, tap to choose. */
.choices { position: absolute; left: 6px; right: 6px; bottom: 6px; z-index: 6; display: flex; flex-direction: column; gap: 6px; padding: 10px; background: rgba(14,15,20,0.94); border: 2px solid #4a4438; }
.choices[hidden] { display: none; }
.ch-prompt { margin: 0 0 4px; font-size: 16px; line-height: 1.35; color: #f3efe6; }
.ch { display: flex; gap: 10px; align-items: baseline; text-align: left; padding: 10px 12px; min-height: 44px; font: 15px/1.35 Lora, Georgia, serif; color: var(--ink); background: #1f222b; border: 2px solid #3a3e4b; cursor: pointer; }
.ch:hover, .ch:focus-visible { border-color: #e8c878; outline: none; }
.ch-n { font: 600 12px/1 'Pixelify Sans', monospace; color: #e8c878; }
.who-screen .dlg-text { font-family: 'Pixelify Sans', monospace; font-size: 18px; color: #e8c878; text-align: center; }

/* Chapter cards. */
.card { position: absolute; inset: 0; z-index: 7; display: flex; flex-direction: column; align-items: center; justify-content: center; text-align: center; background: rgba(8,9,12,0.9); transition: opacity 0.6s; }
.card[hidden] { display: none; }
.card.out { opacity: 0; }
.card h2 { margin: 6px 16px 0; font: 600 26px/1.15 'Pixelify Sans', monospace; color: #f3efe6; }

/* The reveal: her own face, more lived in. */
.reveal { position: absolute; left: 50%; top: 14%; width: 78%; transform: translateX(-50%); z-index: 5; border: 3px solid #e8c878; box-shadow: 0 0 24px rgba(232,200,120,0.5); }
.reveal[hidden] { display: none; }
.reveal canvas { display: block; width: 100%; image-rendering: pixelated; }

/* The ending pages. */
.overlay.endscreen { align-items: flex-start; }
.ending { max-width: 440px; width: 100%; padding: 8px 0 24px; text-align: left; }
.ending .voice { font-size: 18px; font-style: italic; color: #f3efe6; margin: 0 0 10px; }
.ending .picture { margin: 0 auto 14px; max-width: 288px; }
.ending .pix { display: block; width: 100%; image-rendering: pixelated; border: 2px solid #3a3e4b; }
.ending .road { display: block; width: 100%; margin: 4px 0 12px; }
.ending .reading { padding: 14px 16px; margin: 12px 0; background: rgba(0,0,0,0.35); border-left: 3px solid #e8c878; }
/* The parchment frame round her reading. */
.ending .reading { border: 20px solid #6a4528; border-image: url(assets/reading-frame.png) 38 round; background: #14110d; background-clip: padding-box; }
.ending .reading h3 { margin: 0 0 8px; font: 600 14px/1.2 'Pixelify Sans', monospace; letter-spacing: 0.06em; text-transform: uppercase; color: #e8c878; }
.ending .reading p { font-size: 15px; margin: 0 0 8px; }
.ending .reading ol { margin: 4px 0 0; padding-left: 20px; font-size: 15px; line-height: 1.45; }
.ending .move-h { font-weight: 600; }
.ending .offer h2 { text-align: left; }
.ending .offer p { font-size: 15px; }
.ending .actions { align-items: stretch; }

/* The painted silhouette: seven layers stacked; the gold pieces fade in. */
.silhouette .sil-art { position: relative; width: 100%; height: 100%; }
.silhouette .sil-art img { position: absolute; inset: 0; width: 100%; height: 100%; object-fit: contain; image-rendering: auto; }
.silhouette .sil-art .ol { opacity: 0.9; }
.silhouette .sil-art .pc { opacity: 0; transition: opacity 0.8s; }
.silhouette .sil-art .pc.on { opacity: 1; }
.ending img.pix { image-rendering: auto; }
.card .card-pic { display: block; width: calc(100% - 32px); max-width: 520px; margin: 0 auto 14px; border: 2px solid #3a3e4b; }

/* ---------------------------------------------------------------- comic */
.comic { position: absolute; inset: 0; z-index: 6; background: #0b0c10; padding: 8px; cursor: pointer; display: flex; flex-direction: column; }
.comic[hidden] { display: none; }
.comic-page { flex: 1; display: grid; gap: 8px; min-height: 0; }
.comic-page.n1 { grid-template-rows: 1fr; }
.comic-page.n2 { grid-template-rows: 1fr 1fr; }
.comic-page.n3 { grid-template-rows: 1fr 1fr 1fr; }
.panel { position: relative; overflow: hidden; min-height: 0; border: 3px solid #e9e2cf; background: #1a1c24; opacity: 0; transform: translateY(8px); transition: opacity .45s, transform .45s; display: flex; flex-direction: column; justify-content: space-between; align-items: flex-start; padding: 7px; }
.panel.on { opacity: 1; transform: none; }
.panel-art { position: absolute; inset: 0; width: 100%; height: 100%; object-fit: cover; background: #1a1c24; }
.cc-cap { position: relative; margin: 0; max-width: 82%; padding: 4px 7px; background: #f2e8cf; color: #1b1d24; border: 2px solid #1b1d24; box-shadow: 2px 2px 0 rgba(0,0,0,.55); font: 400 13px/1.3 Lora, Georgia, serif; }
.cc-cap + .cc-cap { align-self: flex-end; }
.cc-bubble { position: relative; margin: 0 0 0 auto; padding: 6px 10px; background: #fff; color: #111; border: 2px solid #111; border-radius: 14px; font: 600 13px/1.3 Lora, Georgia, serif; }
.comic-next { margin: 6px 0 0; text-align: center; font: 400 13px/1 'Pixelify Sans', monospace; color: #e8c878; animation: comic-blink 1.4s infinite; }
@keyframes comic-blink { 50% { opacity: .35; } }

/* Instructions: big, gold-edged, impossible to miss. */
.hint { top: auto; bottom: 10px; left: 10px; right: 10px; padding: 10px 14px; font-size: 18px; line-height: 1.3; text-align: center; background: rgba(11,12,16,.9); border: 2px solid #e8c878; border-left-width: 2px; border-radius: 6px; box-shadow: 0 0 0 3px rgba(232,200,120,.18); }
.hint.on { animation: hint-in .35s ease; }
@keyframes hint-in { from { transform: scale(.96); } to { transform: none; } }

/* A short note that pauses play (the first ember). */
.overlay.note { background: rgba(8,9,12,.78); }
.note-card { max-width: 340px; margin: auto; padding: 16px 18px; background: #f2e8cf; color: #1b1d24; border: 3px solid #1b1d24; box-shadow: 4px 4px 0 rgba(0,0,0,.6); font: 400 15px/1.45 Lora, Georgia, serif; }
.note-card .eyebrow { color: #7a4a12; margin: 0 0 8px; }
.note-card p { margin: 0 0 10px; }
.note-card .actions { margin-top: 12px; }

/* The ember count, top left of the stage. */
.embers { position: absolute; top: 6px; left: 6px; z-index: 3; display: flex; align-items: center; gap: 5px; padding: 4px 9px 4px 7px; background: rgba(11,12,16,.78); border: 2px solid #ff9d3a; border-radius: 14px; color: #ffe2b8; font: 600 14px/1 'Pixelify Sans', monospace; cursor: pointer; }
.embers[hidden] { display: none; }
.menu .embers { visibility: hidden; }
.embers small { font-size: 11px; color: #c9a27a; }
.ember-dot { width: 10px; height: 10px; border-radius: 50%; background: radial-gradient(circle at 40% 40%, #fff1b0, #ffb347 40%, #ff7a2a 70%, #8a2a0a); box-shadow: 0 0 6px #ff9d3a; }
.ember-key { color: #e8c878; margin-left: 2px; }
.embers.pulse { animation: sil-pulse 1s ease; }

/* The embers' bonus training, on the ending screens. */
.ending .bonus { margin: 14px 0; padding: 12px 14px; border: 2px dashed #6a5a44; border-radius: 6px; }
.ending .bonus.on { border: 2px solid #ff9d3a; background: rgba(255,157,58,.08); box-shadow: 0 0 12px rgba(255,157,58,.25); }
.ending .bonus p { margin: 0 0 8px; }

/* Compact enough not to hide her: the instruction box sits low and lets the scene show through. */
.hint { bottom: 6px; left: 12px; right: 12px; padding: 7px 10px; font-size: 15px; background: rgba(11,12,16,.72); }

/* When she (or where she's going) is low on the screen, the instructions move up out of the way. */
.hint.top { top: 44px; bottom: auto; }

/* Phones with room to spare: the instructions sit just below the game, never over it. */
.roomy .hint { top: calc(100% + 10px); bottom: auto; left: 0; right: 0; }
.roomy #game, .roomy { touch-action: none; }
.roomy .stage::after { content: 'Tap or hold here too'; position: absolute; left: 0; right: 0; top: calc(100% + 92px); text-align: center; font: 400 12px/1 Lora, Georgia, serif; color: #6a6250; pointer-events: none; }
.menu.roomy .stage::after { display: none; }

/* The title sits low, so the wolf in the painting stays in view. */
.overlay.title { align-items: flex-end; padding-bottom: max(28px, env(safe-area-inset-bottom)); background: linear-gradient(180deg, rgba(11,12,16,0) 0%, rgba(11,12,16,.15) 35%, rgba(11,12,16,.85) 62%, rgba(11,12,16,.96) 80%); }

/* The gold armour banner, beside the silhouette; it stays while the story goes on. */
.armour-note { position: absolute; top: 6px; right: 46px; left: 90px; z-index: 8; margin: 0; padding: 8px 10px; background: rgba(27,24,16,.92); border: 2px solid #e8c878; border-radius: 6px; color: #f3e6c4; font: 400 14px/1.35 Lora, Georgia, serif; box-shadow: 0 0 10px rgba(232,200,120,.35); transition: opacity .6s; pointer-events: none; }
.armour-note[hidden] { display: none; }
.armour-note.out { opacity: 0; }
.armour-note b { color: #e8c878; }

/* The workshop, played inside the game. */
.video-modal { position: fixed; inset: 0; z-index: 20; display: flex; align-items: center; justify-content: center; padding: 16px; background: rgba(5,6,9,.9); }
.video-box { width: 100%; max-width: 860px; text-align: center; }
.video-frame { position: relative; width: 100%; aspect-ratio: 16 / 9; margin: 0 0 14px; background: #000; border: 2px solid #e8c878; }
.video-frame iframe { position: absolute; inset: 0; width: 100%; height: 100%; border: 0; }

/* The title screen's gold line sits on the pale mist: a darker gold so it reads. */
.title-card .eyebrow { margin: 2px 0 14px; color: #b8822a; font-size: 14px; font-weight: 700; text-shadow: 0 1px 0 #000, 1px 0 0 #000, -1px 0 0 #000, 0 -1px 0 #000, 0 0 10px rgba(0,0,0,.95); }
.title-card .eyebrow.subtitle { line-height: 1.5; letter-spacing: .08em; }
