/* Palette: cozy overgrown forest. Moss greens, bark, cream paper, mushroom red, flower pinks. */
:root {
  --ink: #1d2a1c; --plum: #5e3b48; --berry: #c2554d; --orange: #e8955a; --sun: #ffd66e; --lime: #b5e06a;
  --green: #5fa043; --teal: #4f7f3a; --navy: #34552f; --blue: #4f8fa8; --sky: #8fc8d8; --cyan: #a8e0d8;
  --white: #f6f1dc; --fog: #c9d6b0; --slate: #6f8a63; --deep: #2b3f2a; --pink: #f2a7b8; --rose: #d9707f;
  --cream: #fbf3d9; --wood: #b07a4f; --bark: #5b3a29; --moss: #78b356; --moss-d: #3b6e33;
  --font: 'Vazirmatn', Tahoma, sans-serif;
  --display: 'Lalezar', 'Vazirmatn', Tahoma, sans-serif;
  --mono: 'Cascadia Mono', Consolas, 'Courier New', 'Vazirmatn', monospace;
}

* { box-sizing: border-box; }
html, body { margin: 0; height: 100%; background: var(--ink); color: var(--white); font-family: var(--font); }
body { overflow: hidden; -webkit-tap-highlight-color: transparent; }
button { font-family: inherit; }
canvas.pix, .pix { image-rendering: pixelated; image-rendering: crisp-edges; }

/* The whole game lives in one fixed-size screen (see js/core/screen.js). Nothing scrolls outside it. */
html, body { overscroll-behavior: none; touch-action: manipulation; }
body {
  background: #101810;
  background-image: radial-gradient(circle at 50% 40%, #1f3020 0, #0c130c 70%);
}
#screen {
  position: fixed; left: 50%; top: 50%; width: 1280px; height: 720px; transform-origin: center; overflow: hidden; z-index: 1;
  box-shadow: 0 0 0 4px #1d2a1c, 0 0 0 7px #6f8a63, 0 0 0 10px #1d2a1c, 0 30px 80px rgba(0,0,0,.6);
  /* fixed-position children (modals, dialogue) are positioned relative to this transformed box */
  contain: layout paint;
}
#bg { position: absolute; inset: 0; width: 100%; height: 100%; z-index: 0; image-rendering: pixelated; }
#app { position: absolute; inset: 0; z-index: 1; overflow: hidden; }
#overlay { position: absolute; inset: 0; z-index: 50; pointer-events: none; }
#overlay > * { pointer-events: auto; }
#toasts { position: absolute; top: 18px; left: 50%; transform: translateX(-50%); z-index: 90; display: flex; flex-direction: column; gap: 8px; align-items: center; pointer-events: none; width: 560px; max-width: 90%; }
#fx { position: fixed; inset: 0; z-index: 80; pointer-events: none; }

/* ---------- Pixel boxes & buttons ---------- */
.px-box {
  --bd: var(--white); --bg: var(--ink);
  background: var(--bg);
  box-shadow: 0 -4px 0 0 var(--bd), 0 4px 0 0 var(--bd), -4px 0 0 0 var(--bd), 4px 0 0 0 var(--bd), 0 10px 0 0 rgba(0,0,0,.35);
}
.btn {
  --c: var(--sun); --t: var(--ink); --sh: #c9933f;
  appearance: none; border: 0; cursor: pointer; font-weight: 900; font-size: 16px;
  background: var(--c); color: var(--t); padding: 10px 18px; margin: 4px;
  box-shadow: 0 -3px 0 0 var(--ink), 0 3px 0 0 var(--ink), -3px 0 0 0 var(--ink), 3px 0 0 0 var(--ink), inset 0 -5px 0 0 var(--sh), 0 6px 0 0 rgba(0,0,0,.35);
  transition: transform .06s;
}
.btn:hover { filter: brightness(1.07); }
.btn:active { transform: translateY(3px); }
.btn:disabled { filter: grayscale(1) brightness(.7); cursor: not-allowed; }
.btn:focus-visible { outline: 3px dashed var(--cyan); outline-offset: 5px; }
.btn-pink { --c: var(--pink); --sh: var(--rose); }
.btn-blue { --c: var(--sky); --sh: var(--blue); --t: var(--ink); }
.btn-green { --c: var(--lime); --sh: var(--green); }
.btn-ghost { --c: var(--deep); --t: var(--white); --sh: var(--ink); }
.btn-small { font-size: 14px; padding: 7px 12px; }
.btn-big { font-size: 22px; padding: 14px 28px; }

/* ---------- Toasts ---------- */
.toast {
  background: var(--ink); color: var(--white); padding: 10px 16px; font-size: 15px; font-weight: 700; text-align: center;
  box-shadow: 0 -3px 0 0 var(--sun), 0 3px 0 0 var(--sun), -3px 0 0 0 var(--sun), 3px 0 0 0 var(--sun);
  animation: toastIn .25s steps(4) both; transition: opacity .3s, transform .3s;
}
.toast.ok { box-shadow: 0 -3px 0 0 var(--lime), 0 3px 0 0 var(--lime), -3px 0 0 0 var(--lime), 3px 0 0 0 var(--lime); }
.toast.warn { box-shadow: 0 -3px 0 0 var(--orange), 0 3px 0 0 var(--orange), -3px 0 0 0 var(--orange), 3px 0 0 0 var(--orange); }
.toast.bad { box-shadow: 0 -3px 0 0 var(--berry), 0 3px 0 0 var(--berry), -3px 0 0 0 var(--berry), 3px 0 0 0 var(--berry); }
.toast.out { opacity: 0; transform: translateY(-10px); }
@keyframes toastIn { from { transform: translateY(-16px); opacity: 0; } }

/* ---------- Modal ---------- */
.modal-wrap {
  position: fixed; inset: 0; display: flex; align-items: center; justify-content: center; padding: 16px;
  background: rgba(14, 22, 14, .86); backdrop-filter: blur(3px); animation: fadeIn .2s both; overflow-y: auto;
}
.modal-wrap.out { animation: fadeOut .22s both; }
@keyframes fadeIn { from { opacity: 0; } }
@keyframes fadeOut { to { opacity: 0; } }
.modal { width: min(560px, 100%); padding: 22px; animation: popIn .25s steps(5) both; max-height: calc(100vh - 40px); overflow-y: auto; }
@keyframes popIn { from { transform: scale(.85); } }
.modal-title { margin: 0 0 12px; font-family: var(--display); font-weight: 400; font-size: 28px; color: var(--sun); }
.modal-body { line-height: 1.9; font-size: 16px; }
.modal-actions { display: flex; flex-wrap: wrap; gap: 6px; justify-content: center; margin-top: 18px; }

/* ---------- Pixel wipe ---------- */
.wipe { position: fixed; inset: 0; z-index: 100; display: grid; pointer-events: all; }
.wipe i { background: var(--ink); transform: scale(0); transition: transform .18s steps(3); }
.wipe.in i { transform: scale(1.02); }

/* ---------- Effects ---------- */
.shake { animation: shake .45s steps(2) both; }
@keyframes shake { 0%,100% { transform: none; } 20% { transform: translate(-6px, 2px); } 40% { transform: translate(6px, -2px); } 60% { transform: translate(-4px, 0); } 80% { transform: translate(4px, 1px); } }
.flash { position: fixed; inset: 0; z-index: 95; pointer-events: none; animation: flash .45s both; }
@keyframes flash { from { opacity: .85; } to { opacity: 0; } }
.bob { animation: bob 1.2s steps(2) infinite; }
@keyframes bob { 50% { transform: translateY(-4px); } }
.blink { animation: blink 1s steps(1) infinite; }
@keyframes blink { 50% { opacity: 0; } }

/* ---------- Dialogue ---------- */
.dlg-shield { position: fixed; inset: 0; background: rgba(10,10,20,.25); }
.dlg {
  position: fixed; left: 50%; bottom: max(18px, env(safe-area-inset-bottom)); transform: translateX(-50%);
  width: min(760px, calc(100% - 32px)); min-height: 130px; padding: 16px 18px; display: flex; gap: 16px; align-items: flex-start;
  animation: dlgIn .2s steps(4) both; cursor: pointer; user-select: none;
}
.dlg.out { animation: fadeOut .2s both; }
@keyframes dlgIn { from { transform: translate(-50%, 30px); opacity: 0; } }
.dlg-portrait { flex: 0 0 auto; width: 84px; height: 84px; display: grid; place-items: center; background: var(--deep); box-shadow: 0 0 0 3px var(--slate); }
.dlg-portrait canvas { max-width: 76px; max-height: 76px; }
.dlg.no-portrait .dlg-portrait { display: none; }
.dlg-main { flex: 1; min-width: 0; }
.dlg-name { display: inline-block; background: var(--sun); color: var(--ink); font-weight: 900; padding: 2px 10px; margin-bottom: 8px; font-size: 14px; }
.dlg-text { font-size: 18px; line-height: 1.95; min-height: 3.8em; white-space: pre-wrap; }
.dlg.narrator .dlg-text { color: var(--fog); font-style: normal; text-align: center; }
.dlg-more { position: absolute; left: 14px; bottom: 8px; color: var(--sun); animation: blink 0.8s steps(1) infinite; }
.dlg-choices { display: flex; flex-wrap: wrap; gap: 4px; margin-top: 6px; }
@media (max-width: 1px) {
  .dlg { padding: 12px; gap: 10px; min-height: 110px; }
  .dlg-portrait { width: 58px; height: 58px; }
  .dlg-portrait canvas { max-width: 52px; max-height: 52px; }
  .dlg-text { font-size: 16px; }
}

/* ---------- Generic scene layout ---------- */
.scene { min-height: 100%; display: flex; flex-direction: column; align-items: center; padding: 16px; padding-bottom: 170px; }
.scene.center { justify-content: center; padding-bottom: 16px; }

/* ---------- Title ---------- */
.title-scene { text-align: center; gap: 10px; }
.title-logo { font-family: var(--display); font-weight: 400; font-size: 104px; line-height: 1.05; margin: 0; color: var(--cream);
  -webkit-text-stroke: 3px var(--ink); paint-order: stroke fill;
  text-shadow: 0 6px 0 var(--moss-d), 0 12px 0 var(--ink), 0 20px 30px rgba(0,0,0,.35); letter-spacing: 0; }
.title-sub { display: inline-block; font-size: 22px; color: var(--cream); font-weight: 900; margin: 22px 0 6px; padding: 6px 18px; background: var(--bark); box-shadow: 0 0 0 3px var(--ink), 0 6px 0 rgba(0,0,0,.3); transform: rotate(-1.5deg); }
.title-card { padding: 18px 22px 22px; background: rgba(29,42,28,.82); box-shadow: 0 0 0 4px var(--cream), 0 0 0 8px var(--ink); width: min(460px, 100%); display: flex; flex-direction: column; align-items: center; gap: 6px; }
.stage-panel { width: min(860px, 100%); margin: 18px auto 0; padding: 18px; background: rgba(29,42,28,.88); box-shadow: 0 -4px 0 0 var(--cream), 0 4px 0 0 var(--cream), -4px 0 0 0 var(--cream), 4px 0 0 0 var(--cream), 0 12px 0 0 rgba(0,0,0,.25); display: flex; flex-direction: column; align-items: center; gap: 14px; }
.stage-panel > .stage-body { margin-top: 0; }
.title-hero { display: flex; gap: 18px; align-items: flex-end; justify-content: center; margin: 18px 0; min-height: 110px; }
.title-hero .env-ico { animation: floaty 2.4s ease-in-out infinite; }
.title-hero .env-ico:nth-child(3) { animation-delay: -1.2s; }
@keyframes floaty { 50% { transform: translateY(-12px) rotate(-6deg); } }
.title-btns { display: flex; flex-direction: column; align-items: center; gap: 10px; position: relative; min-height: 170px; width: min(420px, 100%); }
.runaway-btn { position: relative; transition: left .18s steps(3), top .18s steps(3); }
.speech-pop { position: absolute; background: var(--white); color: var(--ink); font-weight: 900; padding: 6px 10px; font-size: 14px; white-space: nowrap; animation: popIn .2s steps(4) both; }
.title-foot { color: var(--fog); font-size: 13px; margin-top: 20px; }
.stamp { display: inline-block; border: 3px solid var(--berry); color: var(--berry); padding: 2px 10px; font-weight: 900; transform: rotate(-6deg); background: rgba(255,243,214,.92); font-size: 14px; }

/* ---------- Intro ---------- */
.intro-stage { position: relative; width: min(640px, 100%); height: 300px; margin-top: 40px; overflow: hidden; }
.intro-stage .actor { position: absolute; bottom: 20px; transition: left 1s steps(10), bottom 1s steps(10), opacity .5s; }
.intro-stage .fly-env { position: absolute; transition: left .9s cubic-bezier(.5,0,.5,1), top .9s cubic-bezier(.5,0,.5,1), transform .9s, opacity .4s; }
.intro-ground { position: absolute; bottom: 0; left: 0; right: 0; height: 20px; background: repeating-linear-gradient(90deg, var(--deep) 0 16px, var(--slate) 16px 32px); }

/* ---------- Tower map ---------- */
.map-head {
  position: sticky; top: 0; z-index: 5; width: 100%; display: flex; align-items: center; justify-content: space-between; gap: 8px; flex-wrap: wrap;
  padding: 10px 12px; background: rgba(26,28,44,.92); box-shadow: 0 4px 0 0 var(--deep);
}
.map-title { font-family: var(--display); font-size: 26px; color: var(--sun); }
.map-stats { display: flex; gap: 10px; font-weight: 900; font-size: 14px; color: var(--fog); }
.map-actions { display: flex; gap: 2px; flex-wrap: wrap; }
.tower-wrap { width: min(560px, 100%); margin: 10px auto 40px; position: relative; }
/* The giant tree growing out of the roof is a canvas drawn in map.js */
.roof { position: relative; display: flex; justify-content: center; margin-bottom: -6px; z-index: 2; pointer-events: none; }
.roof canvas { width: 100%; height: auto; display: block; }
.roof-sign {
  position: absolute; bottom: 26%; left: 50%; transform: translateX(-50%) rotate(-3deg); pointer-events: auto;
  font-family: var(--display); font-size: 26px; color: var(--cream); background: var(--bark); padding: 0 16px;
  box-shadow: 0 0 0 3px var(--ink), 0 6px 0 0 rgba(0,0,0,.35); animation: sway 3.4s ease-in-out infinite; transform-origin: top center;
}
.roof-sign::before, .roof-sign::after { content: ''; position: absolute; top: -26px; width: 3px; height: 26px; background: #8a6a3a; }
.roof-sign::before { left: 14px; } .roof-sign::after { right: 14px; }
@keyframes sway { 50% { transform: translateX(-50%) rotate(2deg); } }
.tower {
  position: relative; padding: 14px 14px 4px;
  background: #cfc3a0; background-image: repeating-linear-gradient(0deg, transparent 0 18px, rgba(91,58,41,.18) 18px 20px), repeating-linear-gradient(90deg, transparent 0 34px, rgba(91,58,41,.12) 34px 36px);
  box-shadow: 0 0 0 4px var(--ink), 10px 12px 0 0 rgba(0,0,0,.25);
}
.tower::before, .tower::after {
  /* hanging vines on both sides of the building */
  content: ''; position: absolute; top: 0; width: 18px; height: 70%; pointer-events: none;
  background: radial-gradient(circle at 50% 50%, var(--moss) 0 4px, transparent 5px) 0 0 / 18px 22px, linear-gradient(90deg, transparent 7px, var(--moss-d) 7px 11px, transparent 11px);
}
.tower::before { left: -10px; } .tower::after { right: -10px; height: 46%; }
.floor {
  position: relative; display: flex; align-items: center; gap: 12px; min-height: 80px; margin: 0 0 22px; padding: 10px 12px 10px 14px;
  background: var(--navy); color: var(--white); cursor: pointer; width: 100%; border: 0; font: inherit; text-align: right;
  box-shadow: 0 0 0 4px var(--ink), inset 0 -6px 0 0 rgba(0,0,0,.25);
}
/* moss growing on top of each floor */
.floor::before {
  content: ''; position: absolute; left: -6px; right: -6px; top: -12px; height: 14px; pointer-events: none;
  background: radial-gradient(circle at 50% 100%, var(--moss) 0 7px, transparent 8px) 0 0 / 16px 14px, linear-gradient(transparent 8px, var(--moss) 8px);
}
.floor:nth-child(3n)::after {
  content: '🌿'; position: absolute; right: 8px; top: 64%; font-size: 18px; transform: rotate(160deg); pointer-events: none; opacity: .9;
}
.floor:hover:not(.locked) { filter: brightness(1.1); }
.floor .fl-num { flex: 0 0 auto; width: 42px; height: 42px; display: grid; place-items: center; background: var(--cream); color: var(--bark); font-weight: 900; font-size: 18px; box-shadow: 0 0 0 3px var(--ink); }
.floor .fl-icon { font-size: 26px; flex: 0 0 auto; }
.floor .fl-text { flex: 1; min-width: 0; }
.floor .fl-name { font-size: 13px; color: var(--fog); font-weight: 700; }
.floor .fl-title { font-size: 17px; font-weight: 900; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.floor .fl-state { flex: 0 0 auto; font-size: 13px; font-weight: 900; padding: 4px 8px; background: var(--ink); }
.floor .fl-pot { position: absolute; bottom: calc(100% - 2px); font-size: 16px; pointer-events: none; }
.floor.boss { background: linear-gradient(90deg, var(--plum), #3e3a2a); }
.floor.boss .fl-state { color: var(--pink); }
.floor.cleared { background: var(--teal); }
.floor.cleared .fl-state { color: var(--lime); }
.floor.current { box-shadow: 0 0 0 4px var(--sun), inset 0 -6px 0 0 rgba(0,0,0,.25); animation: pulseGlow 1.4s steps(2) infinite; }
@keyframes pulseGlow { 50% { box-shadow: 0 0 0 4px var(--orange), inset 0 -6px 0 0 rgba(0,0,0,.25); } }
.floor.locked { background: #3d4a37; color: #8f9c86; cursor: not-allowed; }
.floor.locked .fl-icon { filter: grayscale(1) brightness(.7); }
.floor .fl-hero { position: absolute; left: 96px; bottom: 6px; z-index: 3; animation: bob 1.2s steps(2) infinite; }
@media (max-width: 1px) { .floor .fl-hero { left: 84px; } .floor .fl-title { font-size: 15px; } }
.ground { position: relative; height: 70px; display: flex; align-items: flex-end; justify-content: center; gap: 12px; }
.ground-door { width: 84px; height: 60px; background: var(--bark); box-shadow: 0 0 0 4px var(--ink); display: grid; place-items: center; color: var(--cream); font-weight: 900; font-size: 13px; border-radius: 40px 40px 0 0; }
.street { height: 30px; background: var(--moss); box-shadow: 0 -4px 0 0 var(--moss-d), 0 4px 0 0 var(--ink); background-image: radial-gradient(circle, var(--lime) 0 2px, transparent 3px); background-size: 22px 12px; }
.ground-npc { display: flex; align-items: flex-end; gap: 6px; }
.map-foot { color: var(--ink); font-weight: 700; font-size: 13px; text-align: center; margin-bottom: 30px; background: rgba(251,243,217,.8); padding: 6px 12px; }

/* ---------- Stage shell ---------- */
.stage-head {
  position: sticky; top: 0; z-index: 5; width: 100%; display: flex; align-items: center; gap: 10px; padding: 8px 12px;
  background: rgba(26,28,44,.94); box-shadow: 0 4px 0 0 var(--deep);
}
.stage-title { flex: 1; min-width: 0; font-family: var(--display); font-size: 22px; color: var(--sun); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.stage-title small { font-family: var(--font); font-size: 13px; color: var(--fog); margin-inline-start: 6px; }
.stage-body { width: min(820px, 100%); margin: 20px auto 0; display: flex; flex-direction: column; align-items: center; gap: 16px; }
.card { width: 100%; padding: 18px; }
.card h3 { margin: 0 0 10px; color: var(--sun); font-size: 18px; }
.muted { color: var(--fog); }
.center-txt { text-align: center; }
.row { display: flex; gap: 10px; align-items: center; justify-content: center; flex-wrap: wrap; }
.input {
  font: inherit; font-size: 18px; padding: 10px 12px; background: var(--white); color: var(--ink); border: 0; outline: 0; width: min(320px, 100%);
  box-shadow: 0 0 0 3px var(--ink), 0 0 0 6px var(--slate);
}
.input:focus { box-shadow: 0 0 0 3px var(--ink), 0 0 0 6px var(--sun); }

/* ---------- Envelope / letters ---------- */
.letter-wrap { z-index: 60; }
.letter-modal { width: min(600px, 100%); display: flex; flex-direction: column; align-items: center; }
.letter-title { font-family: var(--display); color: var(--sun); font-size: 30px; margin-bottom: 10px; text-shadow: 0 4px 0 var(--berry); }
.letter-content { width: 100%; display: flex; flex-direction: column; align-items: center; gap: 10px; }
.env-stage { padding: 110px 0 10px; display: grid; place-items: center; }
.env { --s: 1; position: relative; width: calc(240px * var(--s)); height: calc(160px * var(--s)); cursor: pointer; animation: wiggle 1.6s ease-in-out infinite; transform-style: preserve-3d; perspective: 600px; }
.env:hover { animation-duration: .5s; }
@keyframes wiggle { 0%, 100% { transform: rotate(-3deg); } 50% { transform: rotate(3deg) translateY(-4px); } }
.env-back { position: absolute; inset: 0; background: #e9cf9f; box-shadow: 0 0 0 4px var(--ink); }
.env-paper { position: absolute; left: 8%; right: 8%; top: 8%; height: 80%; background: var(--cream); transition: transform .7s .25s steps(7); background-image: repeating-linear-gradient(0deg, transparent 0 12px, #e6d4ae 12px 14px); }
.env-front { position: absolute; inset: 0; background: linear-gradient(to top right, #f7dfb2 50%, transparent 50.5%) left/50% 100% no-repeat, linear-gradient(to top left, #f2d6a2 50%, transparent 50.5%) right/50% 100% no-repeat; }
.env-flap { position: absolute; left: 0; right: 0; top: 0; height: 60%; background: #ecc98d; clip-path: polygon(0 0, 100% 0, 50% 100%); transform-origin: top; transition: transform .35s steps(4); z-index: 2; }
.env-seal { position: absolute; left: 50%; top: 52%; transform: translate(-50%, -50%); z-index: 3; width: calc(40px * var(--s)); height: calc(40px * var(--s)); border-radius: 50%; background: var(--berry); color: var(--cream); display: grid; place-items: center; font-size: calc(18px * var(--s)); box-shadow: 0 0 0 3px #7c2338; transition: opacity .2s; }
.env.open { animation: none; }
.env.open .env-flap { transform: rotateX(180deg); z-index: 0; }
.env.open .env-seal { opacity: 0; }
.env.open .env-paper { transform: translateY(-70%); }
.env-caption { color: var(--fog); font-weight: 700; margin: 6px 0; text-align: center; min-height: 1.6em; }
.paper {
  width: 100%; background: var(--cream); color: #3a2a1c; padding: 28px 26px 22px; position: relative; animation: paperIn .45s steps(6) both;
  background-image: repeating-linear-gradient(180deg, transparent 0 33px, #ead9b8 33px 35px);
  box-shadow: 0 0 0 4px var(--ink), 8px 10px 0 0 rgba(0,0,0,.35); max-height: 56vh; overflow-y: auto;
}
.paper::before { content: '💌'; position: absolute; top: -18px; right: 18px; font-size: 28px; }
@keyframes paperIn { from { transform: translateY(40px) rotate(-2deg); opacity: 0; } }
.paper-text { white-space: pre-wrap; font-size: 18px; line-height: 35px; font-weight: 500; }
.paper-sign { margin-top: 16px; text-align: left; font-weight: 900; color: var(--berry); }
.guess { width: 100%; text-align: center; margin-top: 8px; }
.guess-q { font-weight: 900; color: var(--sun); margin: 6px 0 10px; font-size: 17px; }
.chips { display: flex; flex-wrap: wrap; gap: 8px; justify-content: center; }
.chip { border: 0; cursor: pointer; font: inherit; font-weight: 700; padding: 6px 12px; background: var(--deep); color: var(--white); box-shadow: 0 0 0 2px var(--slate); }
.chip:hover { background: var(--navy); }
.chip.on { background: var(--pink); color: var(--ink); box-shadow: 0 0 0 3px var(--white); }

.loading-box { width: 100%; padding: 22px; text-align: center; }
.load-msg { font-weight: 700; margin-bottom: 12px; }
.load-bar { height: 22px; background: var(--deep); box-shadow: 0 0 0 3px var(--slate); }
.load-bar i { display: block; height: 100%; width: 0; background: repeating-linear-gradient(90deg, var(--lime) 0 10px, var(--green) 10px 20px); transition: width .12s steps(2); }
.load-pct { margin-top: 10px; font-weight: 900; font-size: 22px; color: var(--sun); direction: ltr; }
.ticket { width: 100%; padding: 18px; --bg: #f4f5f7; --bd: #0052cc; color: #172b4d; direction: rtl; }
.tk-id { color: #0052cc; font-weight: 900; font-family: var(--mono); direction: ltr; text-align: right; }
.tk-title { font-size: 19px; font-weight: 900; margin: 6px 0 12px; }
.tk-row { display: flex; gap: 10px; margin: 6px 0; align-items: center; direction: ltr; justify-content: flex-end; }
.tk-row span { color: #5e6c84; }
.tk-status { border: 0; cursor: pointer; font: inherit; font-weight: 900; padding: 3px 10px; background: #dfe1e6; color: #42526e; }
.tk-comment { background: #fff; padding: 8px 10px; margin-top: 8px; box-shadow: 0 0 0 1px #dfe1e6; }
.runaway-arena { position: relative; width: 100%; height: 260px; background: var(--deep); box-shadow: 0 0 0 3px var(--slate); overflow: hidden; }
.runaway-paper { position: absolute; padding: 12px 14px; background: var(--cream); color: var(--ink); font-weight: 900; cursor: pointer; transition: left .15s steps(3), top .15s steps(3); box-shadow: 0 0 0 3px var(--ink); user-select: none; touch-action: none; }
.runaway-paper.tired { animation: wiggle .4s infinite; background: var(--sun); }
.scratch-box { position: relative; width: min(300px, 100%); aspect-ratio: 300 / 180; box-shadow: 0 0 0 4px var(--ink); }
.scratch-under { position: absolute; inset: 0; background: var(--cream); color: var(--berry); font-weight: 900; display: grid; place-items: center; text-align: center; white-space: pre-wrap; padding: 12px; line-height: 1.8; }
.scratch { position: absolute; inset: 0; width: 100%; height: 100%; touch-action: none; cursor: crosshair; }

.mail-stat { color: var(--fog); text-align: center; margin: 0 0 10px; }
.mail-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(118px, 1fr)); gap: 12px; width: 100%; background: var(--ink); padding: 14px; box-shadow: 0 0 0 4px var(--slate); max-height: 60vh; overflow-y: auto; }
.mail-cell { border: 0; cursor: pointer; font: inherit; color: var(--white); background: var(--navy); padding: 10px 6px; display: flex; flex-direction: column; align-items: center; gap: 6px; box-shadow: inset 0 -4px 0 rgba(0,0,0,.3); }
.mail-cell:hover { filter: brightness(1.15); }
.mail-cell.locked { background: #22253a; color: var(--slate); }
.mail-cell.prank { background: var(--plum); }
.mail-q { font-size: 34px; font-weight: 900; height: 36px; line-height: 36px; }
.mail-floor { font-size: 12px; color: var(--fog); }
.mail-state { font-size: 12px; font-weight: 900; }

/* ---------- Battle ---------- */
.battle { width: min(600px, 100%); margin: 0 auto; display: flex; flex-direction: column; align-items: center; gap: 10px; padding-top: 6px; touch-action: none; user-select: none; }
.b-enemy { position: relative; height: 170px; width: 100%; display: flex; align-items: flex-end; justify-content: center; }
.b-sprite-wrap { position: relative; animation: bob 1.4s steps(2) infinite; }
.b-sprite { display: block; max-height: 150px; }
.b-sprite-wrap.hurt { animation: shake .4s steps(2); filter: brightness(2.2) saturate(.3); }
.b-sprite-wrap.spared { opacity: .45; filter: grayscale(.6); animation: none; }
.b-sprite-wrap.dead { animation: dust 1s steps(8) forwards; }
@keyframes dust { to { opacity: 0; transform: translateY(-20px) scale(1.1); filter: blur(2px); } }
.b-slash { position: absolute; inset: 0; display: grid; place-items: center; font-size: 80px; color: var(--berry); animation: slash .45s steps(5) forwards; pointer-events: none; }
@keyframes slash { from { transform: translate(30px, -30px) rotate(-30deg) scale(.4); opacity: 1; } to { transform: translate(-30px, 30px) rotate(-30deg) scale(1.2); opacity: 0; } }
.b-dmg { position: absolute; top: -12px; left: 50%; transform: translateX(-50%); font-weight: 900; font-size: 28px; color: var(--berry); text-shadow: 0 3px 0 var(--ink); animation: dmg .9s steps(6) forwards; pointer-events: none; white-space: nowrap; }
.b-dmg.miss { color: var(--fog); }
@keyframes dmg { 0% { transform: translate(-50%, 10px); opacity: 0; } 20% { opacity: 1; transform: translate(-50%, -10px); } 100% { opacity: 0; transform: translate(-50%, -30px); } }
.b-ehp { position: absolute; bottom: -14px; left: 50%; transform: translateX(-50%); width: 120px; height: 10px; background: var(--berry); box-shadow: 0 0 0 2px var(--ink); opacity: 0; transition: opacity .2s; }
.b-ehp.show { opacity: 1; }
.b-ehp i { display: block; height: 100%; background: var(--lime); transition: width .5s steps(5); }
.b-speech { position: absolute; top: 4px; right: calc(50% + 90px); width: 220px; background: var(--white); color: var(--ink); padding: 10px 12px; font-weight: 700; font-size: 15px; line-height: 1.7; box-shadow: 0 0 0 3px var(--ink); }
.b-speech::after { content: ''; position: absolute; left: -12px; top: 20px; border: 6px solid transparent; border-right-color: var(--white); }
@media (max-width: 1px) { .b-speech { right: auto; left: 8px; top: -6px; font-size: 13px; } .b-speech::after { display: none; } .b-enemy { justify-content: flex-start; padding-inline-start: 8%; } }
.b-arena { position: relative; width: 100%; }
.b-canvas { display: block; width: 100%; aspect-ratio: 320 / 180; background: #000; }
.b-text { position: absolute; inset: 7% 5%; font-size: 19px; line-height: 1.9; white-space: pre-wrap; color: var(--white); overflow: hidden; }
.b-text .opts { display: grid; grid-template-columns: 1fr 1fr; gap: 4px 14px; }
.b-text .opt { cursor: pointer; padding: 2px 6px; }
.b-text .opt::before { content: '* '; }
.b-text .opt.sel { color: var(--sun); }
.b-text .opt.sel::before { content: '♥ '; color: #ff3b5c; }
.b-text .opt.yellow { color: #ffe14d; }
.b-text .opt.dim { color: var(--slate); }
.b-stats { width: 100%; display: flex; align-items: center; gap: 10px; font-weight: 900; font-size: 15px; padding: 0 4px; direction: rtl; }
.b-stats .b-lv { color: var(--fog); }
.b-hp { flex: 0 0 120px; height: 14px; background: var(--berry); box-shadow: 0 0 0 2px var(--ink); }
.b-hp i { display: block; height: 100%; background: var(--sun); transition: width .25s steps(4); }
.b-menu { width: 100%; display: grid; grid-template-columns: repeat(4, 1fr); gap: 8px; }
.b-menu button { border: 0; cursor: pointer; font: inherit; font-weight: 900; font-size: 17px; padding: 10px 4px; background: transparent; color: var(--orange); box-shadow: 0 0 0 3px var(--orange); }
.b-menu button.sel { color: var(--sun); box-shadow: 0 0 0 3px var(--sun); background: rgba(255,205,117,.08); }
.b-menu button:disabled { opacity: .35; cursor: default; }
.b-help { color: var(--slate); font-size: 12px; text-align: center; }
.b-over { position: absolute; inset: 0; z-index: 4; background: #000; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 14px; text-align: center; padding: 16px; animation: fadeIn 1s both; }
.b-over h2 { font-family: var(--display); font-weight: 400; font-size: 80px; color: var(--white); margin: 0; letter-spacing: 2px; }
.b-over p { color: var(--fog); font-size: 18px; margin: 0; }

/* ---------- Stage: captcha ---------- */
.captcha { width: min(420px, 100%); background: #f9f9f9; color: #222; padding: 18px; box-shadow: 0 0 0 4px var(--ink), 8px 10px 0 rgba(0,0,0,.35); }
.captcha-head { background: #4a90e2; color: #fff; padding: 12px 14px; margin: -18px -18px 14px; font-weight: 900; }
.captcha-head small { display: block; font-weight: 500; opacity: .85; }
.robot-row { display: flex; align-items: center; gap: 12px; padding: 14px; background: #fff; box-shadow: 0 0 0 1px #ddd; position: relative; min-height: 70px; }
.robot-box { width: 30px; height: 30px; background: #fff; box-shadow: 0 0 0 2px #888; cursor: pointer; position: relative; transition: transform .15s steps(3); flex: 0 0 auto; }
.robot-box.checked::after { content: '✔'; position: absolute; inset: 0; display: grid; place-items: center; color: #2a9d2a; font-size: 24px; font-weight: 900; }
.cap-grid { display: grid; grid-template-columns: repeat(3, 1fr); gap: 4px; }
.cap-tile { position: relative; aspect-ratio: 1; cursor: pointer; overflow: hidden; background: #ddd; }
.cap-tile canvas { width: 100%; height: 100%; display: block; }
.cap-tile.on { outline: 4px solid #4a90e2; outline-offset: -4px; }
.cap-tile.on::after { content: '✔'; position: absolute; top: 4px; right: 4px; width: 22px; height: 22px; background: #4a90e2; color: #fff; display: grid; place-items: center; font-size: 13px; border-radius: 50%; }
.cap-word { width: 100%; background: #eee; display: block; margin-bottom: 10px; }
.cap-actions { display: flex; justify-content: space-between; align-items: center; margin-top: 12px; gap: 10px; }
.cap-btn { border: 0; background: #4a90e2; color: #fff; font: inherit; font-weight: 900; padding: 8px 18px; cursor: pointer; }
.cap-input { width: 100%; font: inherit; font-size: 17px; padding: 8px 10px; border: 2px solid #bbb; }
.cap-err { color: #c0392b; font-weight: 700; min-height: 1.6em; font-size: 14px; }
.cap-step { color: #888; font-size: 13px; }

/* ---------- Stage: envelopes ---------- */
.env-cards { display: flex; flex-wrap: wrap; gap: 14px; justify-content: center; width: 100%; }
.lie-card { width: 170px; min-height: 170px; border: 0; cursor: pointer; font: inherit; color: #3a2a1c; background: var(--cream); padding: 30px 12px 14px; position: relative; text-align: center; font-weight: 700; line-height: 1.8; font-size: 15px;
  box-shadow: 0 0 0 4px var(--ink), 6px 8px 0 rgba(0,0,0,.35); transition: transform .12s steps(2); }
.lie-card:hover { transform: translateY(-6px) rotate(-1deg); }
.lie-card .num { position: absolute; top: -14px; right: 50%; transform: translateX(50%); width: 34px; height: 34px; display: grid; place-items: center; background: var(--berry); color: var(--cream); font-weight: 900; box-shadow: 0 0 0 3px var(--ink); }
.lie-card.wrong { animation: shake .4s steps(2); background: #f3c0c0; }
.rule { background: var(--ink); padding: 10px 16px; font-weight: 900; color: var(--sun); text-align: center; box-shadow: 0 0 0 3px var(--sun); }

/* ---------- Stage: coffee ---------- */
.coffee-arena { position: relative; width: 100%; height: 420px; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 14px; }
.coffee-timer { font-size: 54px; font-weight: 900; color: var(--sun); text-shadow: 0 4px 0 var(--berry); }
.coffee-bar { width: min(340px, 90%); height: 18px; background: var(--deep); box-shadow: 0 0 0 3px var(--slate); }
.coffee-bar i { display: block; height: 100%; width: 0; background: repeating-linear-gradient(90deg, var(--wood) 0 10px, #8a5a44 10px 20px); }
.coffee-say { min-height: 2em; color: var(--fog); font-weight: 700; text-align: center; }
.steam { font-size: 26px; animation: floaty 1.6s infinite; opacity: .7; }
.tempt { position: absolute; z-index: 3; animation: popIn .2s steps(4) both; }
.tempt-note { background: var(--white); color: var(--ink); padding: 12px 14px; width: 250px; box-shadow: 0 0 0 3px var(--ink), 6px 6px 0 rgba(0,0,0,.4); font-size: 14px; }
.tempt-note b { display: block; margin-bottom: 6px; }
.tempt-fly { font-size: 34px; cursor: pointer; transition: left .5s, top .5s; }
.tempt-crash { position: fixed; inset: 0; z-index: 70; background: #0a3db8; color: #fff; display: flex; flex-direction: column; justify-content: center; padding: 120px; gap: 18px; font-size: 20px; direction: ltr; text-align: left; font-family: var(--mono); }
.tempt-crash h1 { font-size: 90px; margin: 0; font-weight: 400; }

/* ---------- Stage: terminal ---------- */
.term { width: 100%; height: min(480px, 64vh); background: #0d0f17; color: #c8f7c5; font-family: var(--mono); font-size: 15px; padding: 14px; overflow-y: auto; box-shadow: 0 0 0 4px var(--slate), 8px 10px 0 rgba(0,0,0,.35); cursor: text; direction: ltr; text-align: left; }
.term-line { white-space: pre-wrap; word-break: break-word; line-height: 1.6; unicode-bidi: plaintext; }
.term-line.err { color: #ff6b81; }
.term-line.dim { color: #6b7a99; }
.term-line.ok { color: var(--sun); }
.term-in { display: flex; gap: 8px; align-items: center; }
.term-in span { color: var(--sky); white-space: nowrap; }
.term-in input { flex: 1; background: transparent; border: 0; outline: 0; color: #fff; font: inherit; caret-color: var(--lime); direction: ltr; min-width: 0; }
.term-bar { width: 100%; display: flex; gap: 4px; flex-wrap: wrap; justify-content: center; }

/* ---------- Stage: portfolio ---------- */
.browser { width: 100%; background: #fff; color: #222; box-shadow: 0 0 0 4px var(--ink), 8px 10px 0 rgba(0,0,0,.35); }
.browser-bar { background: #dfe3ea; padding: 8px 10px; display: flex; gap: 8px; align-items: center; direction: ltr; }
.browser-bar i { width: 12px; height: 12px; border-radius: 50%; background: #ff5f57; display: inline-block; }
.browser-bar i:nth-child(2) { background: #febc2e; } .browser-bar i:nth-child(3) { background: #28c840; }
.browser-url { flex: 1; background: #fff; padding: 3px 10px; font-size: 13px; color: #555; font-family: var(--mono); }
.pf { padding: 18px; position: relative; overflow: hidden; }
.pf [data-bug] { cursor: pointer; transition: all .35s steps(4); }
.pf .fixed { cursor: default; }
.pf-marquee { background: #ff00ff; color: #ffff00; font-family: 'Comic Sans MS', cursive; font-weight: 900; white-space: nowrap; overflow: hidden; padding: 4px 0; margin: -18px -18px 14px; }
.pf-marquee span { display: inline-block; animation: marq 6s linear infinite; padding-left: 100%; }
@keyframes marq { to { transform: translateX(-100%); } }
.pf-marquee.fixed { height: 0; padding: 0; margin-bottom: 0; }
.pf-hero { display: flex; gap: 16px; align-items: center; flex-wrap: wrap; }
.pf-avatar { width: 84px; height: 84px; background: #ffe8f1; display: grid; place-items: center; transform: rotate(180deg); border-radius: 50%; }
.pf-avatar.fixed { transform: none; }
.pf-name { font-family: 'Comic Sans MS', cursive; font-size: 28px; margin: 0; color: #e000e0; }
.pf-name.fixed { font-family: var(--display); font-weight: 400; color: #222; }
.pf-title { margin: 4px 0 0; direction: ltr; text-align: right; font-weight: 900; }
.pf-hire { border: 0; background: #ccc; color: #999; padding: 8px 18px; font: inherit; font-weight: 900; cursor: not-allowed; }
.pf-hire.fixed { background: var(--berry); color: #fff; cursor: default; }
.pf-about { margin: 14px 0; line-height: 1.9; color: #444; direction: ltr; text-align: left; font-family: Georgia, serif; }
.pf-about.fixed { direction: rtl; text-align: right; font-family: var(--font); }
.pf-skills { display: grid; gap: 8px; margin: 12px 0; }
.pf-skill { font-size: 13px; font-weight: 700; direction: ltr; }
.pf-skill .bar { height: 10px; background: #eee; position: relative; }
.pf-skill .bar i { display: block; height: 100%; background: #6c5ce7; }
.pf-skill .bar i.over { width: 135% !important; background: #e84393; }
.pf-skill .bar i.fixed { width: 95% !important; background: #6c5ce7; }
.pf-projects { position: relative; display: grid; grid-template-columns: repeat(3, 1fr); gap: 10px; margin: 12px 0; }
.pf-proj { background: #f3f3f7; padding: 10px; text-align: center; font-size: 13px; font-weight: 700; }
.pf-proj .img { height: 60px; display: grid; place-items: center; font-size: 30px; background: #e4e4ee; margin-bottom: 6px; }
.pf-proj.tilt { transform: rotate(2.2deg) translateY(3px); }
.pf-proj.tilt.fixed { transform: none; }
.pf-broken { font-size: 13px !important; color: #999; }
.pf-soon { position: absolute; inset: 0; background: repeating-linear-gradient(45deg, #ffd000 0 18px, #222 18px 36px); color: #fff; display: grid; place-items: center; font-weight: 900; font-size: 22px; text-shadow: 0 2px 0 #000; opacity: .93; }
.pf-soon.fixed { opacity: 0; pointer-events: none; }
.pf-foot { display: flex; justify-content: space-between; flex-wrap: wrap; gap: 8px; font-size: 13px; color: #666; border-top: 1px solid #eee; padding-top: 10px; margin-top: 12px; }
.pf-mail { color: #f3f3f3; }
.pf-mail.fixed { color: #3b5dc9; }
.pf-counter { font-family: var(--mono); background: #000; color: #0f0; padding: 0 6px; }
.pf-progress { font-weight: 900; color: var(--sun); font-size: 20px; }
.pf-spark { position: absolute; pointer-events: none; font-size: 22px; animation: dmg .8s forwards; }

/* ---------- Stage: bugs ---------- */
.bugs-wrap { position: relative; width: 100%; }
.bugs-code { position: absolute; inset: 0; background: #11131f; color: #3d4766; font-family: var(--mono); font-size: 13px; line-height: 1.7; padding: 12px; overflow: hidden; direction: ltr; text-align: left; white-space: pre; }
.bugs-canvas { position: relative; display: block; width: 100%; aspect-ratio: 16 / 10; cursor: crosshair; touch-action: none; box-shadow: 0 0 0 4px var(--slate); }
.hud { width: 100%; display: flex; justify-content: space-between; font-weight: 900; font-size: 18px; gap: 10px; flex-wrap: wrap; }
.hud b { color: var(--sun); }

/* ---------- Stage: calendar (rush hour) ---------- */
.rh-wrap { position: relative; width: 440px; aspect-ratio: 1; background: var(--cream); box-shadow: 0 0 0 6px var(--ink), 0 0 0 10px var(--slate), 10px 14px 0 rgba(0,0,0,.35); touch-action: none; }
.rh-grid { position: absolute; inset: 0; background-image: linear-gradient(#e2cfa6 2px, transparent 2px), linear-gradient(90deg, #e2cfa6 2px, transparent 2px); background-size: calc(100% / 6) calc(100% / 6); }
.rh-exit { position: absolute; left: -22px; top: calc(100% / 6 * 2); height: calc(100% / 6); width: 18px; background: var(--lime); display: grid; place-items: center; color: var(--ink); font-weight: 900; animation: blink 1s steps(1) infinite; }
.rh-car { position: absolute; display: grid; place-items: center; text-align: center; font-weight: 900; font-size: 14px; color: var(--white); cursor: grab; transition: left .12s, top .12s; box-shadow: inset 0 0 0 3px rgba(0,0,0,.25), inset 0 -6px 0 rgba(0,0,0,.2); padding: 4px; line-height: 1.3; user-select: none; touch-action: none; }
.rh-car.dragging { transition: none; cursor: grabbing; z-index: 3; filter: brightness(1.15); }
.rh-car.target { background: var(--berry) !important; font-size: 17px; }
.rh-car.hint { animation: pulseGlow2 .6s steps(2) infinite; }
@keyframes pulseGlow2 { 50% { box-shadow: 0 0 0 4px var(--sun); } }
.rh-moves { font-weight: 900; color: var(--fog); }

/* ---------- Stage: keyboard ---------- */
.kb-target { font-size: 22px; font-weight: 900; color: var(--fog); text-align: center; }
.kb-typed { min-height: 56px; width: 100%; font-size: 30px; font-weight: 900; text-align: center; background: var(--ink); padding: 8px; box-shadow: 0 0 0 3px var(--slate); color: var(--sun); }
.kb-typed .caret { animation: blink .8s steps(1) infinite; color: var(--white); }
.kb { display: grid; grid-template-columns: repeat(8, 1fr); gap: 6px; width: min(560px, 100%); }
.kb-key { border: 0; cursor: pointer; font: inherit; font-size: 24px; font-weight: 900; padding: 8px 0; background: var(--white); color: var(--ink); box-shadow: inset 0 -5px 0 var(--fog), 0 0 0 2px var(--ink); transition: transform .2s steps(2); }
.kb-key:active { transform: translateY(2px); }
.kb-key.flip { animation: flip .25s steps(3); }
@keyframes flip { 50% { transform: rotateX(90deg); } }
.kb-key.space { grid-column: span 4; font-size: 14px; }

/* ---------- Stage: door ---------- */
.corridor { position: relative; width: 100%; height: 170px; background: var(--deep); overflow: hidden; box-shadow: 0 0 0 4px var(--slate); }
.corridor .wall { position: absolute; top: 0; bottom: 0; background: repeating-linear-gradient(0deg, #4a5578 0 14px, #3d4766 14px 28px); width: 40%; transition: width .3s; }
.corridor .wall.l { left: 0; } .corridor .wall.r { right: 0; }
.corridor .hero { position: absolute; bottom: 14px; left: 50%; transform: translateX(-50%); transition: bottom .8s steps(8); }
.width-meter { font-family: var(--mono); font-weight: 900; color: var(--sun); direction: ltr; }
.door-panel { width: 100%; background: var(--wood); color: var(--wood); padding: 20px; box-shadow: 0 0 0 4px var(--ink), inset 0 0 0 10px #a46d42; line-height: 2; user-select: text; -webkit-user-select: text; }
.door-panel ::selection, .door-panel::selection { background: var(--ink); color: var(--sun); }
.door-panel .visible { color: var(--ink); font-weight: 900; }

/* ---------- Ending ---------- */
.end-scene { text-align: center; }
.end-title { font-family: var(--display); font-size: 84px; color: var(--sun); margin: 10px 0; text-shadow: 0 5px 0 var(--berry), 0 10px 0 var(--plum); }
.cake-wrap { position: relative; display: inline-block; margin: 40px auto 10px; }
.candles { position: absolute; left: 6%; right: 6%; top: -46px; display: flex; flex-wrap: wrap; justify-content: center; gap: 4px 6px; }
.candle { width: 7px; height: 26px; background: repeating-linear-gradient(180deg, var(--sky) 0 5px, var(--white) 5px 10px); position: relative; }
.candle::before { content: ''; position: absolute; left: 50%; top: -12px; width: 7px; height: 11px; transform: translateX(-50%); background: var(--sun); box-shadow: 0 0 10px 3px rgba(255,205,117,.7); border-radius: 50% 50% 40% 40%; animation: flame .3s steps(2) infinite; }
.candle.out::before { background: transparent; box-shadow: none; animation: none; }
.candle.out::after { content: '~'; position: absolute; left: -2px; top: -26px; color: var(--fog); font-weight: 900; animation: dmg 1.2s forwards; }
@keyframes flame { 50% { transform: translateX(-50%) scaleY(1.2) skewX(6deg); } }
.blow-meter { width: min(260px, 80%); height: 14px; margin: 8px auto; background: var(--deep); box-shadow: 0 0 0 3px var(--slate); }
.blow-meter i { display: block; height: 100%; width: 0; background: var(--cyan); }
.reveal-list { width: min(620px, 100%); display: flex; flex-direction: column; gap: 10px; margin: 0 auto; }
.reveal-card { display: flex; align-items: center; gap: 12px; padding: 12px 14px; background: var(--navy); text-align: right; animation: paperIn .4s steps(5) both; flex-wrap: wrap; }
.reveal-card .who { flex: 1; font-weight: 900; font-size: 17px; }
.reveal-card .snip { flex-basis: 100%; color: var(--fog); font-size: 13px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.reveal-card .res { font-size: 22px; }
.reveal-card.ok { background: var(--teal); }
.reveal-card.no { background: var(--plum); }
.score-big { font-family: var(--display); font-size: 46px; color: var(--sun); margin: 14px 0 0; }
.credits { height: 70vh; overflow: hidden; position: relative; width: min(560px, 100%); margin: 0 auto; mask-image: linear-gradient(transparent, #000 15%, #000 85%, transparent); -webkit-mask-image: linear-gradient(transparent, #000 15%, #000 85%, transparent); }
.credits-roll { position: absolute; left: 0; right: 0; top: 100%; animation: roll 38s linear forwards; text-align: center; }
@keyframes roll { to { transform: translateY(calc(-100% - 70vh)); } }
.credits-roll h4 { color: var(--fog); margin: 30px 0 6px; font-size: 14px; letter-spacing: 1px; }
.credits-roll p { margin: 4px 0; font-size: 20px; font-weight: 900; }
.credits-roll .big { font-family: var(--display); font-size: 48px; color: var(--sun); font-weight: 400; }

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

/* =====================================================================
   Fixed-screen layout. Every scene fits the 1280x720 (or 720x1280) screen.
   ===================================================================== */
.scene { height: 100%; min-height: 0; overflow: hidden; padding: 20px 24px 24px; }
.scene.center { justify-content: center; }
.title-scene { gap: 6px; }
.title-btns { min-height: 150px; }

/* ---------- Tower map ---------- */
.map-scene { height: 100%; display: flex; align-items: center; justify-content: center; gap: 36px; padding: 20px 40px; }
.portrait .map-scene { flex-direction: column-reverse; gap: 14px; padding: 16px; }
.tower-box { position: relative; width: 580px; height: 660px; flex: 0 0 auto; }
.tower-cv { width: 580px; height: 660px; display: block; }
.fl-hit { position: absolute; border: 0; background: transparent; cursor: pointer; padding: 0; }
.fl-hit:hover { background: rgba(255, 246, 207, .12); }
.fl-hit:focus-visible { outline: 3px dashed var(--sun); }
.fl-plate {
  position: absolute; display: flex; align-items: center; gap: 4px; height: 30px; padding: 0 8px 0 6px; pointer-events: none;
  background: var(--cream); color: var(--bark); font-weight: 900; font-size: 15px; box-shadow: 0 0 0 2px var(--ink), 2px 3px 0 rgba(0,0,0,.3);
}
.fl-plate span { font-size: 14px; }
.fl-plate.done { background: #d9ecb8; }
.fl-plate.boss { background: #f3c6c0; }
.fl-plate.locked { background: #b9b39a; color: #5d5a48; }
.map-hero { position: absolute; z-index: 3; cursor: pointer; animation: bob 1.2s steps(2) infinite; }
.map-hero canvas { display: block; filter: drop-shadow(0 2px 0 rgba(0,0,0,.35)); }
.tower-box .roof-sign { position: absolute; left: 50%; bottom: auto; font-size: 22px; padding: 0 14px; z-index: 2; }

.board {
  width: 500px; flex: 0 0 auto; padding: 22px 24px; display: flex; flex-direction: column; gap: 14px;
  background: #e9dcb6; color: var(--ink);
  background-image: repeating-linear-gradient(0deg, transparent 0 22px, rgba(91,58,41,.08) 22px 24px);
  box-shadow: 0 0 0 4px var(--bark), 0 0 0 8px var(--ink), 10px 14px 0 4px rgba(0,0,0,.3);
  position: relative;
}
.board::before, .board::after { content: ''; position: absolute; top: -26px; width: 6px; height: 26px; background: var(--bark); box-shadow: 0 0 0 2px var(--ink); }
.board::before { right: 60px; } .board::after { left: 60px; }
.portrait .board { width: 660px; }
.board-title { font-family: var(--display); font-size: 46px; color: var(--moss-d); line-height: 1; text-shadow: 0 3px 0 rgba(255,255,255,.6); }
.board-progress { display: flex; align-items: center; gap: 10px; font-weight: 900; font-size: 14px; color: var(--bark); }
.board-progress .bar { flex: 1; height: 14px; background: #c8b98f; box-shadow: 0 0 0 2px var(--ink); }
.board-progress .bar i { display: block; height: 100%; background: repeating-linear-gradient(90deg, var(--moss) 0 8px, var(--green) 8px 16px); }
.fl-card { background: var(--cream); padding: 16px; box-shadow: 0 0 0 3px var(--ink), 0 5px 0 0 rgba(0,0,0,.15); display: flex; flex-direction: column; gap: 10px; min-height: 230px; }
.fl-card-top { display: flex; gap: 14px; align-items: center; }
.fl-card-icon { font-size: 44px; width: 70px; height: 70px; display: grid; place-items: center; background: #f3e7c4; box-shadow: 0 0 0 3px var(--ink); flex: 0 0 auto; }
.fl-card-sub { font-size: 14px; font-weight: 700; color: var(--slate); }
.fl-card-title { font-size: 24px; font-weight: 900; color: var(--ink); }
.fl-card-state { align-self: flex-start; font-weight: 900; font-size: 13px; padding: 3px 10px; color: var(--cream); background: var(--slate); }
.fl-card-state.done { background: var(--green); }
.fl-card-state.now { background: var(--berry); }
.fl-card-teaser { margin: 0; color: #4a3b2c; line-height: 1.8; font-size: 15px; min-height: 3.6em; }
.fl-card .btn { align-self: flex-start; }
.board-stats { display: flex; gap: 18px; font-weight: 900; font-size: 16px; color: var(--bark); }
.board-actions { display: flex; gap: 4px; flex-wrap: wrap; }
.board-note { font-size: 12px; color: var(--slate); font-weight: 700; }

/* ---------- Stage shell fits the screen ---------- */
.scene:has(> .stage-panel) { padding: 0; display: flex; flex-direction: column; }
.stage-head { position: relative; flex: 0 0 auto; padding: 10px 18px; }
.stage-panel { flex: 1 1 auto; min-height: 0; width: calc(100% - 48px); max-width: 1180px; margin: 16px auto 18px; overflow: hidden; justify-content: center; }
.stage-panel > .stage-body { width: 100%; max-width: 900px; max-height: 100%; }
.term { height: 400px; }
.browser { max-height: 520px; display: flex; flex-direction: column; }
.browser .pf { overflow-y: auto; flex: 1; }
.bugs-wrap { max-width: 760px; }
.rh-wrap { width: 420px; }
.coffee-arena { height: 500px; }
.battle { width: 640px; gap: 8px; padding-top: 0; }
.b-enemy { height: 168px; }
.b-sprite { max-height: 160px; }
.portrait .battle { width: 640px; }
.letter-modal { max-height: 680px; }
.portrait .letter-modal { max-height: 1180px; }
.paper { max-height: 380px; }
.mail-grid { max-height: 440px; }
.reveal-list { max-height: 420px; overflow-y: auto; padding: 4px; }
.end-scene { justify-content: center; gap: 6px; }
.end-scene .cake-wrap { margin-top: 30px; }
.credits { height: 520px; }
.title-scene { padding-top: 26px; }
.title-hero { margin: 8px 0 14px; min-height: 0; }
.title-btns { min-height: 130px; }
.title-sub { margin-top: 14px; }

/* ---------- Detail pass: wooden header, mossy stage frame ---------- */
.stage-head {
  background: #6b4632; box-shadow: 0 4px 0 0 #3f2a1d, 0 8px 0 0 rgba(0,0,0,.25);
  background-image: repeating-linear-gradient(0deg, transparent 0 14px, rgba(0,0,0,.12) 14px 16px), linear-gradient(90deg, #6b4632, #7a5038 50%, #6b4632);
}
.stage-head::after {
  content: ''; position: absolute; left: 0; right: 0; bottom: -12px; height: 12px; pointer-events: none; z-index: 2;
  background: radial-gradient(circle at 50% 0, var(--moss) 0 6px, transparent 7px) 0 0 / 22px 12px;
}
.stage-title { color: var(--cream); text-shadow: 0 2px 0 #3f2a1d; }
.stage-title small { color: #e9dcb6; }
.stage-panel { position: relative; overflow: visible; background: rgba(20, 32, 20, .9); background-image: radial-gradient(circle at 50% 0, rgba(255, 230, 160, .07), transparent 60%); }
.stage-panel::before, .stage-panel::after {
  content: ''; position: absolute; top: -6px; width: 26px; height: 60%; pointer-events: none;
  background: radial-gradient(circle at 50% 50%, var(--moss) 0 5px, transparent 6px) 0 0 / 26px 24px, linear-gradient(90deg, transparent 11px, var(--moss-d) 11px 15px, transparent 15px);
}
.stage-panel::before { right: -14px; } .stage-panel::after { left: -14px; height: 38%; }
.portrait .b-text { font-size: 22px; }
.portrait .b-menu button { font-size: 20px; padding: 14px 4px; }
.portrait .battle { width: 680px; }
.portrait .b-enemy { height: 220px; }
.portrait .b-sprite { max-height: 210px; }
/* Keep the subtitle plaque clear of Zahra's head */
.title-sub { position: relative; z-index: 2; margin-bottom: 4px; }
.title-hero { margin-top: 18px; }
.title-scene > * { flex-shrink: 0; }
.title-scene { padding-top: 14px; gap: 4px; }
.title-btns { min-height: 0; gap: 6px; }
.title-card { padding: 14px 22px 16px; }
.title-foot { margin-top: 8px; }
/* Subtitle plaque pinned to the logo's bottom-left corner */
.title-block { position: relative; padding: 0 30px 26px; }
.title-block .title-sub { position: absolute; left: -6px; bottom: 0; margin: 0; transform: rotate(-4deg); font-size: 19px; z-index: 2; white-space: nowrap; }
.title-hero { margin-top: 14px; }

/* Friends */
.b-text .opts.many { font-size: 15px; line-height: 1.55; gap: 0 10px; }
.portrait .b-text .opts.many { font-size: 18px; }
.map-friend { position: absolute; z-index: 3; cursor: pointer; animation: bob 1.6s steps(2) infinite; }
.map-friend:nth-child(odd) { animation-delay: -.8s; }
.map-friend canvas { width: 27px; height: 34px; display: block; filter: drop-shadow(0 2px 0 rgba(0,0,0,.35)); }
.map-friend:hover canvas { transform: translateY(-3px); }
.party-row { display: flex; flex-wrap: wrap; justify-content: center; align-items: flex-end; gap: 6px 10px; max-width: 1100px; }
.party-row canvas { width: 54px; height: 68px; }
.portrait .party-row canvas { width: 46px; height: 58px; }
.meet-badge { display: inline-block; background: #1f3a2a; color: var(--lime); font-weight: 900; padding: 4px 12px; box-shadow: 0 0 0 3px var(--ink); font-size: 15px; }
.end-scene .end-title { font-size: 56px; margin: 0; }
.end-scene .cake-wrap { margin-top: 46px; }
.end-scene .party-row { margin-bottom: 18px; }
.end-scene .cake-wrap { margin-top: 64px; }

/* Roshangara burning at the party */
.burning { position: relative; display: inline-block; animation: shake .5s steps(2) infinite; }
.burning canvas { width: 96px; height: 110px; filter: sepia(.5) saturate(2) hue-rotate(-15deg); }
.burning .flames { position: absolute; left: -10px; right: -10px; top: -40px; display: flex; justify-content: space-between; pointer-events: none; }
.burning .flames span { font-size: 40px; animation: burn .25s steps(2) infinite; display: inline-block; }
.burning .flames span:nth-child(2) { font-size: 52px; margin-top: -14px; animation-delay: -.12s; }
@keyframes burn { 50% { transform: scaleY(1.25) translateY(-3px) rotate(6deg); } }

/* Sahar whips Roshangara */
.whipper { position: relative; display: inline-block; margin-inline-start: 10px; align-self: flex-end; }
.whipper canvas { width: 54px; height: 68px; }
.whip { position: absolute; top: 26px; right: 38px; width: 120px; height: 5px; transform-origin: right center; background: linear-gradient(90deg, #3a2314, #8a5a34 40%, #c89a5c); border-radius: 3px; transform: rotate(-70deg); pointer-events: none; }
.whip::after { content: ''; position: absolute; left: -6px; top: -2px; width: 8px; height: 9px; background: #f6e7b0; border-radius: 50%; }
.whipper.crack .whip { animation: crack .45s steps(6) both; }
@keyframes crack { 0% { transform: rotate(-70deg); } 35% { transform: rotate(-70deg) scaleX(.6); } 55% { transform: rotate(18deg) scaleX(1.25); } 100% { transform: rotate(-70deg); } }
.lash-fx { position: absolute; left: 0; right: 0; top: 40px; height: 0; pointer-events: none; }
.lash-fx span { position: absolute; font-weight: 900; font-size: 22px; color: #fff3a8; text-shadow: 0 2px 0 #b13e53, 0 0 8px #ff3b5c; animation: dmg .9s steps(6) forwards; white-space: nowrap; }
.whip { right: auto; left: 40px; top: 24px; transform-origin: left center; transform: rotate(-75deg); background: linear-gradient(270deg, #3a2314, #8a5a34 40%, #c89a5c); }
.whip::after { left: auto; right: -6px; }
.whipper.crack .whip { animation: crack2 .45s steps(6) both; }
@keyframes crack2 { 0% { transform: rotate(-75deg); } 35% { transform: rotate(-110deg) scaleX(.6); } 55% { transform: rotate(8deg) scaleX(1.3); } 100% { transform: rotate(-75deg); } }
.decode-note { margin-top: 10px; font-weight: 900; color: var(--berry); font-size: 14px; }
.paper .btn { margin-inline-start: 0; }

/* No cut-off emoji above the letter paper */
.paper::before { content: none; }

/* Themed scrollbars: moss thumb on a dark forest track, with pixel-style square ends */
* { scrollbar-width: thin; scrollbar-color: #78b356 #1d2a1c; }
*::-webkit-scrollbar { width: 12px; height: 12px; }
*::-webkit-scrollbar-track { background: #1d2a1c; box-shadow: inset 0 0 0 2px #2b3f2a; }
*::-webkit-scrollbar-thumb { background: #78b356; box-shadow: inset 0 0 0 2px #1d2a1c, inset 3px 3px 0 #a7d36e, inset -3px -3px 0 #3b6e33; }
*::-webkit-scrollbar-thumb:hover { background: #8fc769; }
*::-webkit-scrollbar-corner { background: #1d2a1c; }
/* Scrollbars on the cream paper and parchment panels match their paper */
.paper { scrollbar-color: #b07a4f #ead9b8; }
.paper::-webkit-scrollbar-track { background: #ead9b8; box-shadow: inset 0 0 0 2px #d9c59a; }
.paper::-webkit-scrollbar-thumb { background: #b07a4f; box-shadow: inset 0 0 0 2px #ead9b8, inset 3px 3px 0 #cf9a6a, inset -3px -3px 0 #8a5a34; }
.board, .fl-card { scrollbar-color: #b07a4f #e9dcb6; }
.paper-link { color: #2f6fb3; font-weight: 700; word-break: break-all; font-size: 15px; }
.paper-link:hover { color: var(--berry); }
