:root {
  --ink: #e8eef6;
  --mute: #93a7bb;
  --wood: #3d2819;
  --wood-lite: #6a4428;
  --ash: #16110d;
  --ember: #e07a3a;
  --flame: #ffc978;
  --ice: #b7d6ee;
  --danger: #d46a5a;
  --ok: #7ec8a3;
  --shadow: rgba(4, 6, 10, 0.78);
  --paper: #1a1714;
}

* { box-sizing: border-box; margin: 0; padding: 0; }

html, body {
  height: 100%;
  overflow: hidden;
  background: #07090d;
  color: var(--ink);
  font-family: "Noto Serif SC", "Songti SC", "Source Han Serif SC", Georgia, serif;
}

#snow {
  position: fixed;
  inset: 0;
  z-index: 45;
  pointer-events: none;
}

.grain {
  position: fixed;
  inset: 0;
  z-index: 44;
  pointer-events: none;
  opacity: 0.09;
  background-image: url("data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' width='140' height='140'><filter id='n'><feTurbulence type='fractalNoise' baseFrequency='.85' numOctaves='2' stitchTiles='stitch'/></filter><rect width='100%' height='100%' filter='url(%23n)' opacity='.55'/></svg>");
  mix-blend-mode: overlay;
}

.screen {
  position: fixed;
  inset: 0;
  display: none;
  z-index: 2;
}
.screen.active { display: flex; }

/* ---------- Title ---------- */
#screen-title,
#screen-howto,
#screen-end {
  align-items: center;
  justify-content: center;
  background: #070b12;
}

.title-scene {
  position: absolute;
  inset: 0;
  overflow: hidden;
}
.ts-sky {
  position: absolute;
  inset: 0;
  background:
    radial-gradient(900px 420px at 70% 8%, rgba(90, 130, 180, 0.28), transparent 60%),
    linear-gradient(180deg, #0b1422 0%, #162033 38%, #2a3344 70%, #d8e4ef 100%);
}
.ts-aurora {
  position: absolute;
  left: 8%; right: 20%; top: 4%;
  height: 28%;
  background: linear-gradient(90deg, transparent, rgba(90, 190, 160, 0.22), rgba(120, 150, 220, 0.18), transparent);
  filter: blur(18px);
  animation: aurora 8s ease-in-out infinite alternate;
}
.ts-moon {
  position: absolute;
  right: 16%;
  top: 10%;
  width: 54px;
  height: 54px;
  border-radius: 50%;
  background: radial-gradient(circle at 35% 35%, #f4f1e4, #c9d3df 70%);
  box-shadow: 0 0 40px rgba(230, 236, 245, 0.45);
}
.ts-hill {
  position: absolute;
  left: -8%;
  right: -8%;
  bottom: 0;
  height: 42%;
  background: #dce6ef;
  border-radius: 50% 50% 0 0;
}
.ts-hill.far { height: 48%; background: #c5d3e0; opacity: 0.85; }
.ts-hill.near { height: 28%; background: #eef4f8; }
.ts-trees {
  position: absolute;
  left: 0; right: 0; bottom: 18%;
  height: 34%;
  background:
    radial-gradient(18px 70px at 8% 100%, #1b242c 99%, transparent 100%),
    radial-gradient(14px 56px at 14% 100%, #22303a 99%, transparent 100%),
    radial-gradient(22px 90px at 78% 100%, #1a222a 99%, transparent 100%),
    radial-gradient(16px 64px at 88% 100%, #24323c 99%, transparent 100%),
    radial-gradient(12px 48px at 94% 100%, #1c2830 99%, transparent 100%);
}
.ts-trees.far { bottom: 26%; opacity: 0.55; filter: blur(0.4px); }
.ts-cabin {
  position: absolute;
  left: 50%;
  bottom: 16%;
  width: 210px;
  height: 140px;
  transform: translateX(-52%);
}
.ts-body {
  position: absolute;
  left: 18px; right: 18px; bottom: 0;
  height: 78px;
  background: linear-gradient(180deg, #5a3a26, #3a2418);
  border: 3px solid #24160e;
  box-shadow: inset 0 0 0 6px rgba(90, 58, 36, 0.35);
}
.ts-roof {
  position: absolute;
  left: 0; right: 0; top: 12px;
  height: 54px;
  background: #2b1c14;
  clip-path: polygon(50% 0, 100% 100%, 0 100%);
  filter: drop-shadow(0 -2px 0 #eef4f8);
}
.ts-glow {
  position: absolute;
  left: 78px; bottom: 22px;
  width: 34px; height: 26px;
  background: #ffb45a;
  box-shadow: 0 0 28px 10px rgba(255, 170, 70, 0.55);
  animation: winpulse 1.8s ease-in-out infinite;
}
.ts-win {
  position: absolute;
  left: 78px; bottom: 22px;
  width: 34px; height: 26px;
  border: 3px solid #24160e;
  background: linear-gradient(180deg, rgba(255, 196, 110, 0.9), rgba(180, 80, 20, 0.7));
}
.ts-door {
  position: absolute;
  left: 38px; bottom: 0;
  width: 22px; height: 38px;
  background: #2a1a12;
  border: 2px solid #1a100c;
}
.ts-chimney {
  position: absolute;
  right: 42px; top: 18px;
  width: 16px; height: 28px;
  background: #3a2a22;
}
.ts-smoke {
  position: absolute;
  right: 38px; top: -8px;
  width: 24px; height: 36px;
  background: radial-gradient(circle at 50% 80%, rgba(220,228,236,0.55), transparent 70%);
  animation: smoke 3.4s ease-in-out infinite;
}
.ts-ground {
  position: absolute;
  left: 0; right: 0; bottom: 0; height: 18%;
  background: linear-gradient(180deg, #f4f8fb, #d5e0ea);
}

@keyframes aurora { from { transform: translateX(-4%); opacity: 0.55; } to { transform: translateX(6%); opacity: 0.9; } }
@keyframes winpulse { from { opacity: 0.7; } to { opacity: 1; } }
@keyframes smoke { from { transform: translateY(6px) scale(0.8); opacity: 0.2; } to { transform: translateY(-16px) scale(1.2); opacity: 0; } }

.title-card, .howto-card, .end-card {
  position: relative;
  width: min(540px, 92vw);
  padding: 44px 38px 36px;
  background: linear-gradient(180deg, rgba(14, 16, 22, 0.78), rgba(10, 10, 14, 0.9));
  border: 1px solid rgba(210, 224, 238, 0.16);
  box-shadow: 0 30px 90px var(--shadow);
  backdrop-filter: blur(8px);
}
.title-card::before,
.howto-card::before,
.end-card::before {
  content: "";
  position: absolute;
  inset: 10px;
  border: 1px solid rgba(255, 201, 120, 0.12);
  pointer-events: none;
}

.kicker {
  letter-spacing: 0.42em;
  font-size: 11px;
  color: var(--mute);
}
h1 {
  font-family: "ZCOOL XiaoWei", "Noto Serif SC", serif;
  font-size: 78px;
  font-weight: 400;
  letter-spacing: 0.34em;
  margin: 10px 0 16px 0.18em;
  text-shadow: 0 8px 30px rgba(0,0,0,0.45);
}
h2 {
  font-family: "ZCOOL XiaoWei", "Noto Serif SC", serif;
  font-size: 34px;
  font-weight: 400;
  margin: 10px 0 16px;
  letter-spacing: 0.16em;
}
.lead { color: var(--mute); line-height: 1.85; margin-bottom: 22px; }
.best { color: var(--ice); font-size: 13px; margin-bottom: 26px; }

.title-actions { display: flex; gap: 12px; }
.howto-card ol {
  margin: 0 0 28px 18px;
  color: var(--mute);
  line-height: 2;
}

.btn {
  appearance: none;
  border: 1px solid rgba(220, 230, 240, 0.22);
  background: transparent;
  color: var(--ink);
  padding: 11px 20px;
  cursor: pointer;
  font: inherit;
  letter-spacing: 0.14em;
  transition: 0.2s ease;
}
.btn:hover { border-color: var(--flame); color: var(--flame); transform: translateY(-1px); }
.btn.primary {
  background: linear-gradient(180deg, #4a2a18, #2a160e);
  border-color: #c97840;
  color: #ffe0b8;
  box-shadow: 0 8px 24px rgba(180, 80, 20, 0.22);
}
.btn.primary:hover { background: linear-gradient(180deg, #5a3420, #32180e); }
.btn.danger { border-color: var(--danger); color: #f0b0a4; }
.btn:disabled { opacity: 0.4; cursor: not-allowed; transform: none; }

/* ---------- Game HUD ---------- */
#screen-game {
  flex-direction: column;
  background: #08090c;
}

.hud {
  flex: 0 0 auto;
  padding: 10px 18px 10px;
  display: grid;
  gap: 8px;
  background: linear-gradient(180deg, #12141c, #0e1016);
  border-bottom: 1px solid rgba(255,255,255,0.06);
  z-index: 5;
}
.hud-meta {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}
.chip {
  font-size: 12px;
  letter-spacing: 0.08em;
  padding: 4px 10px;
  border: 1px solid rgba(255,255,255,0.08);
  background: rgba(255,255,255,0.03);
  color: var(--mute);
}
.chip.day { color: #e8eef6; }
.chip.weather { color: var(--ice); }
.hud-stats {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 12px;
}
.stat {
  display: grid;
  grid-template-columns: 16px 36px 1fr 32px;
  align-items: center;
  gap: 6px;
  font-size: 12px;
}
.stat-ico {
  width: 10px; height: 10px;
  border-radius: 50%;
  background: currentColor;
  box-shadow: 0 0 8px currentColor;
}
[data-stat="warmth"] .stat-ico { color: #e07a3a; }
[data-stat="hunger"] .stat-ico { color: #d4b06a; }
[data-stat="health"] .stat-ico { color: #c45a4a; }
[data-stat="energy"] .stat-ico { color: #7ec8a3; }
.stat-name { color: var(--mute); }
.stat b { text-align: right; font-weight: 600; }
.bar {
  height: 8px;
  background: #1b1e26;
  border: 1px solid rgba(255,255,255,0.06);
  overflow: hidden;
  border-radius: 99px;
}
.bar i {
  display: block;
  height: 100%;
  width: 50%;
  transition: width 0.45s ease;
}
[data-stat="warmth"] .bar i { background: linear-gradient(90deg, #8a3a22, #e07a3a); }
[data-stat="hunger"] .bar i { background: linear-gradient(90deg, #6a4a18, #d4b06a); }
[data-stat="health"] .bar i { background: linear-gradient(90deg, #4a1a1a, #c45a4a); }
[data-stat="energy"] .bar i { background: linear-gradient(90deg, #1a4a3a, #7ec8a3); }
.stat.low { color: var(--danger); }
.stat.low .bar { box-shadow: 0 0 0 1px rgba(212, 106, 90, 0.45); }

.hud-res { display: flex; flex-wrap: wrap; gap: 8px; }
.pill {
  font-size: 12px;
  color: var(--mute);
  padding: 4px 10px;
  border: 1px solid rgba(255,255,255,0.08);
  background: rgba(255,255,255,0.03);
}
.pill b { color: var(--ink); font-weight: 600; margin-left: 4px; }
.pill.fire b { color: #ffc978; }
.pill.wood b { color: #d4b06a; }

/* ---------- Room ---------- */
.stage {
  flex: 1;
  position: relative;
  min-height: 0;
}
.hint {
  position: absolute;
  left: 50%;
  bottom: 10px;
  transform: translateX(-50%);
  z-index: 12;
  font-size: 12px;
  letter-spacing: 0.18em;
  color: rgba(232, 238, 246, 0.55);
  pointer-events: none;
  text-shadow: 0 2px 8px #000;
}
.room {
  position: absolute;
  inset: 10px 14px 28px;
  overflow: hidden;
  background: #1a120e;
  border: 3px solid #2c1c14;
  box-shadow:
    0 18px 50px rgba(0,0,0,0.45),
    inset 0 0 90px rgba(0,0,0,0.35);
}

.ceiling {
  position: absolute;
  left: 0; right: 0; top: 0; height: 16%;
  background: linear-gradient(180deg, #1a120e, #2a1c14);
}
.beam {
  position: absolute;
  top: 8%;
  height: 14px;
  background: linear-gradient(#4a3224, #2a1a12);
  box-shadow: 0 6px 0 rgba(0,0,0,0.25);
  z-index: 1;
}
.b1 { left: 8%; width: 26%; transform: rotate(-2deg); }
.b2 { left: 38%; width: 28%; }
.b3 { right: 8%; width: 24%; transform: rotate(2deg); }

.cabin-wall {
  position: absolute;
  left: 0; right: 0; top: 14%; bottom: 20%;
  background:
    repeating-linear-gradient(90deg, #4a3222 0 22px, #3a2618 22px 24px),
    linear-gradient(180deg, #5a3e2a, #2e1c12);
}
.planks {
  position: absolute;
  inset: 14% 0 20%;
  background: repeating-linear-gradient(180deg, transparent 0 52px, rgba(0,0,0,0.18) 52px 54px);
  pointer-events: none;
}
.nail-row {
  position: absolute;
  left: 0; right: 0; top: 28%;
  height: 4px;
  background: repeating-linear-gradient(90deg, #c9a46a 0 3px, transparent 3px 28px);
  opacity: 0.25;
  pointer-events: none;
}
.floor {
  position: absolute;
  left: 0; right: 0; bottom: 0; height: 24%;
  background:
    linear-gradient(180deg, rgba(0,0,0,0.25), transparent 18%),
    repeating-linear-gradient(90deg, #2c1c14 0 34px, #241610 34px 36px);
}
.rug {
  position: absolute;
  left: 26%; right: 22%; bottom: 7%;
  height: 11%;
  background:
    repeating-linear-gradient(90deg, #5a2e26 0 10px, #3e1e1a 10px 12px);
  border: 4px solid #2a1612;
  opacity: 0.82;
  box-shadow: 0 8px 16px rgba(0,0,0,0.25);
}
.crack {
  position: absolute;
  width: 3px;
  background: linear-gradient(#0a0806, transparent);
  opacity: 0.5;
  pointer-events: none;
  z-index: 2;
}
.crack-a { left: 17%; top: 30%; height: 32%; transform: rotate(8deg); }
.crack-b { right: 31%; top: 34%; height: 24%; transform: rotate(-6deg); }
.room[data-cabin="good"] .crack { opacity: 0.08; }
.room[data-cabin="poor"] .crack { opacity: 0.95; width: 5px; }
.draft {
  position: absolute;
  left: 16%; top: 32%;
  width: 40px; height: 120px;
  background: linear-gradient(180deg, rgba(190,220,245,0.18), transparent);
  filter: blur(6px);
  opacity: 0;
  animation: draft 2.8s ease-in-out infinite;
}
.room[data-cabin="poor"] .draft { opacity: 0.7; }
@keyframes draft { from { transform: translateX(0); } to { transform: translateX(16px); } }

.frost-edge, .vignette, .firelight {
  position: absolute;
  inset: 0;
  pointer-events: none;
  z-index: 6;
}
.frost-edge { box-shadow: inset 0 0 90px rgba(180, 210, 235, 0.08); }
.vignette { box-shadow: inset 0 0 120px rgba(0,0,0,0.45); }
.firelight {
  background: radial-gradient(420px 280px at 88% 72%, rgba(224, 122, 58, 0.22), transparent 70%);
  mix-blend-mode: screen;
  opacity: 0.45;
  transition: opacity 0.4s ease;
}
.room[data-fire="0"] .firelight { opacity: 0; }
.room[data-fire="1"] .firelight { opacity: 0.18; }
.room[data-fire="2"] .firelight { opacity: 0.3; }
.room[data-fire="3"] .firelight { opacity: 0.48; }
.room[data-fire="4"] .firelight { opacity: 0.62; }
.room[data-fire="5"] .firelight { opacity: 0.8; }

.room[data-phase="dawn"] { --sky: linear-gradient(180deg, #7a93ad, #c9d6e4 55%, #eef3f7); }
.room[data-phase="day"] { --sky: linear-gradient(180deg, #8aa4b8, #d5e0ea 60%, #f4f7fb); }
.room[data-phase="dusk"] { --sky: linear-gradient(180deg, #3a2a38, #8a5a48 60%, #c48a62); }
.room[data-phase="night"] { --sky: linear-gradient(180deg, #070910, #141822 70%, #1c2430); }
.room[data-night="1"] .frost-edge { box-shadow: inset 0 0 140px rgba(20, 30, 50, 0.6); }
.room.asleep { filter: brightness(0.58) saturate(0.72); }
.room.leaving .door-panel { transform: rotateY(-62deg); }

/* ---------- Hotspots ---------- */
.hotspot {
  position: absolute;
  z-index: 8;
  background: transparent;
  border: 1px solid transparent;
  cursor: pointer;
}
.hs-tag {
  position: absolute;
  left: 50%;
  top: -18px;
  transform: translateX(-50%) translateY(6px);
  opacity: 0;
  pointer-events: none;
  white-space: nowrap;
  font-size: 12px;
  letter-spacing: 0.16em;
  color: #ffe0b8;
  background: rgba(12, 10, 8, 0.78);
  padding: 3px 8px;
  border: 1px solid rgba(255, 201, 120, 0.28);
  transition: 0.18s ease;
}
.hotspot:hover,
.hotspot:focus-visible {
  background: rgba(255, 201, 120, 0.07);
  border-color: rgba(255, 201, 120, 0.35);
  outline: none;
}
.hotspot:hover .hs-tag,
.hotspot:focus-visible .hs-tag {
  opacity: 1;
  transform: translateX(-50%) translateY(0);
}
.hs-door { left: 3.5%; top: 28%; width: 13%; height: 52%; }
.hs-bed { left: 17%; top: 46%; width: 23%; height: 36%; }
.hs-window { left: 41%; top: 24%; width: 17%; height: 30%; }
.hs-radio { left: 59%; top: 40%; width: 13%; height: 28%; }
.hs-repair { left: 72%; top: 30%; width: 8%; height: 34%; }
.hs-table { left: 50%; top: 56%; width: 20%; height: 26%; }
.hs-fire { right: 2%; top: 34%; width: 17%; height: 50%; }

.prop { position: absolute; pointer-events: none; }

/* coat */
.coat { left: 15.5%; top: 32%; width: 6%; height: 22%; z-index: 2; }
.peg { position: absolute; left: 20%; top: 0; width: 10px; height: 8px; background: #c9a46a; border-radius: 2px; }
.coat-body {
  position: absolute; left: 8%; top: 8%; right: 8%; bottom: 0;
  background: linear-gradient(#3a2a22, #1e1410);
  border-radius: 8px 8px 18px 18px;
}

/* door */
.door { left: 4.2%; top: 28%; width: 12%; height: 52%; }
.door-frame { position: absolute; inset: -6px; border: 8px solid #2a1a12; }
.door-panel {
  position: absolute; inset: 0;
  background: linear-gradient(90deg, #2a1a12, #533624 42%, #2e1e14);
  border: 3px solid #1a100c;
  transform-origin: left center;
  transition: transform 0.7s ease;
  overflow: hidden;
}
.door-plank {
  position: absolute; left: 10%; right: 10%; top: 12%; height: 8px;
  background: #6a4428; opacity: 0.4;
}
.door-plank.mid { top: 48%; }
.door-frost {
  position: absolute; inset: 0;
  background: linear-gradient(135deg, rgba(220,235,250,0.18), transparent 40%);
}
.door-knob {
  position: absolute; right: 12%; top: 52%; width: 11px; height: 11px;
  border-radius: 50%; background: radial-gradient(circle at 30% 30%, #f0d49a, #a07838);
}

/* bed */
.bed { left: 17%; bottom: 14%; width: 23%; height: 32%; }
.bed-frame { position: absolute; inset: 22% 0 0; background: #2a1a12; }
.mattress { position: absolute; inset: 28% 5% 10%; background: #4a342a; border: 2px solid #1a100c; }
.pillow { position: absolute; left: 8%; top: 16%; width: 30%; height: 20%; background: #e4d4bc; border-radius: 6px; }
.quilt {
  position: absolute; left: 32%; right: 7%; top: 26%; bottom: 12%;
  background:
    repeating-linear-gradient(90deg, #6a3e34 0 12px, #5a322a 12px 24px);
}
.bed-post { position: absolute; top: 0; width: 9px; bottom: 0; background: #2a1a12; }
.bed-post.left { left: 0; }
.bed-post.right { right: 0; height: 46%; top: auto; bottom: 0; }

/* window */
.window { left: 41.5%; top: 24%; width: 16.5%; height: 30%; }
.win-view { position: absolute; inset: 8px; overflow: hidden; background: #9aacbc; }
.win-sky { position: absolute; inset: 0; background: var(--sky, linear-gradient(180deg, #8aa4b8, #e8eef4)); }
.win-moon {
  position: absolute; right: 18%; top: 12%; width: 14px; height: 14px; border-radius: 50%;
  background: #f2efe4; opacity: 0;
}
.room[data-phase="night"] .win-moon, .room[data-night="1"] .win-moon { opacity: 1; }
.win-hill {
  position: absolute; left: -10%; right: -10%; bottom: 0; height: 42%;
  background: #d7e2ec; border-radius: 50% 50% 0 0;
}
.room[data-phase="night"] .win-hill { background: #1c2430; }
.win-tree {
  position: absolute; bottom: 18%; width: 8px;
  background: #1c2830;
  clip-path: polygon(50% 0, 100% 100%, 0 100%);
}
.t1 { left: 18%; height: 46%; }
.t2 { left: 48%; height: 58%; }
.t3 { right: 16%; height: 40%; }
.win-flakes {
  position: absolute; inset: 0;
  background-image: radial-gradient(circle, #fff 1px, transparent 1.6px);
  background-size: 18px 22px;
  opacity: 0.35;
  animation: flakes 4s linear infinite;
}
@keyframes flakes { from { background-position: 0 0; } to { background-position: 18px 44px; } }
.sash { position: absolute; inset: 0; border: 7px solid #2a1a12; background: transparent; }
.pane { position: absolute; top: 10%; bottom: 16%; width: 40%; background: linear-gradient(180deg, rgba(255,255,255,0.18), transparent); }
.pane-l { left: 8%; }
.pane-r { right: 8%; }
.sill { position: absolute; left: -8%; right: -8%; bottom: -2px; height: 12px; background: #4a3224; box-shadow: 0 4px 0 #2a1a12; }
.icicles {
  position: absolute; left: 10%; right: 10%; top: 0; height: 18%;
  background: linear-gradient(180deg, rgba(230,240,250,0.8), transparent);
  clip-path: polygon(0 0, 100% 0, 92% 100%, 70% 40%, 50% 90%, 30% 35%, 8% 100%);
  opacity: 0.6;
}
.win-frost {
  position: absolute; inset: 8px;
  background: radial-gradient(circle at 10% 90%, rgba(230,240,250,0.28), transparent 40%);
  mix-blend-mode: screen;
}
.room[data-weather="blizzard"] .win-flakes { opacity: 0.7; animation-duration: 1.6s; }
.room[data-weather="whiteout"] .win-sky { background: #f4f7fb; }
.room[data-weather="calm"] .win-flakes { opacity: 0.12; }

/* radio */
.radio { left: 60%; top: 42%; width: 12%; height: 24%; }
.crate { position: absolute; left: 4%; right: 4%; bottom: 0; height: 28%; background: #4a3224; }
.radio-box { position: absolute; left: 10%; right: 10%; bottom: 18%; height: 52%; background: linear-gradient(#2a2420, #141210); border: 2px solid #0c0a08; }
.radio-grill {
  position: absolute; left: 22%; right: 22%; bottom: 28%; height: 18%;
  background: repeating-linear-gradient(90deg, #3a342e 0 3px, #1a1614 3px 6px);
}
.radio-dial { position: absolute; left: 24%; bottom: 28%; width: 14px; height: 14px; border-radius: 50%; background: #8a6a3a; }
.radio-lamp { position: absolute; right: 22%; bottom: 30%; width: 8px; height: 8px; border-radius: 50%; background: #3a2010; }
.hs-radio.ready .radio-lamp,
.room[data-antenna="3"] .radio-lamp {
  background: #7ec86a;
  box-shadow: 0 0 12px #7ec86a;
  animation: blink 1.4s ease-in-out infinite;
}
@keyframes blink { 50% { opacity: 0.45; } }
.antenna-mast {
  position: absolute; width: 3px; background: #b7c0c8; left: 50%; bottom: 70%;
  transform: translateX(-50%); opacity: 0;
  transition: opacity 0.3s ease, height 0.4s ease;
}
.a1 { height: 16%; }
.a2 { height: 28%; }
.a3 { height: 42%; }
.room[data-antenna="1"] .a1,
.room[data-antenna="2"] .a1,
.room[data-antenna="2"] .a2,
.room[data-antenna="3"] .a1,
.room[data-antenna="3"] .a2,
.room[data-antenna="3"] .a3 { opacity: 1; }

.tools { left: 73%; top: 46%; width: 7%; height: 24%; }
.plank-stack { position: absolute; inset: 42% 8% 8%; background: #5a3a24; box-shadow: 0 -8px 0 #4a2e1c, 0 -16px 0 #3a2418; }
.hammer { position: absolute; left: 42%; top: 0; width: 6px; height: 52%; background: #2a1a12; }
.hammer::after {
  content: "";
  position: absolute; left: -7px; top: 0; width: 20px; height: 8px; background: #6a6a6a;
}
.nail-box { position: absolute; right: 4%; bottom: 8%; width: 16px; height: 10px; background: #3a2a22; }

/* table */
.table { left: 51%; bottom: 13%; width: 19%; height: 28%; }
.table-top { position: absolute; left: 0; right: 0; top: 30%; height: 14px; background: linear-gradient(#6a4a30, #4a3224); box-shadow: 0 4px 0 #2a1a12; }
.table-leg { position: absolute; top: 42%; bottom: 0; width: 7px; background: #2a1a12; }
.table-leg.l { left: 12%; }
.table-leg.r { right: 12%; }
.can {
  position: absolute; top: 8%; width: 15px; height: 24px;
  background: linear-gradient(90deg, #7a5230, #4a321c);
  border: 1px solid #2a1a12;
  border-radius: 2px 2px 1px 1px;
}
.c1 { left: 16%; }
.c2 { left: 36%; }
.c3 { left: 56%; }
.medkit { position: absolute; right: 14%; top: 12%; width: 24px; height: 16px; background: #7a2a2a; box-shadow: inset 0 0 0 2px #f0d0d0; }
.lantern { position: absolute; right: 6%; top: -6%; width: 12px; height: 18px; background: #2a1a12; }
.lantern-glow {
  position: absolute; inset: 4px 2px 2px;
  background: #ffc978;
  box-shadow: 0 0 16px #e07a3a;
  opacity: 0.55;
}
.room[data-food="0"] .can { display: none; }
.room[data-food="1"] .c2, .room[data-food="1"] .c3 { display: none; }
.room[data-food="2"] .c3 { display: none; }
.room[data-med="0"] .medkit { display: none; }
.room[data-eating="1"] .can.c1 { transform: translateY(-12px); }

/* stove */
.stove { right: 3%; bottom: 12%; width: 16%; height: 50%; }
.stove-pipe { position: absolute; left: 46%; top: 0; width: 12px; height: 42%; background: linear-gradient(90deg, #3a322e, #1c1816); }
.stove-pipe-bend { position: absolute; left: 46%; top: 0; width: 28px; height: 12px; background: #2a2220; }
.stove-body {
  position: absolute; left: 16%; right: 16%; bottom: 10%; height: 48%;
  background: linear-gradient(90deg, #1c1614, #2a2220 40%, #141110);
  border: 3px solid #0c0a08;
  border-radius: 4px 4px 2px 2px;
}
.stove-door { position: absolute; left: 32%; right: 32%; bottom: 20%; height: 20%; background: #2a1a12; border: 2px solid #0c0a08; }
.stove-feet { position: absolute; left: 20%; right: 20%; bottom: 4%; height: 8px; background: #1a1210; }
.glow {
  position: absolute; left: 8%; right: 8%; bottom: 12%; height: 42%;
  background: radial-gradient(circle at 50% 80%, rgba(224,122,58,0.7), transparent 70%);
  opacity: 0.2;
  filter: blur(8px);
}
.flame {
  position: absolute; bottom: 30%; width: 10px; border-radius: 50% 50% 20% 20%;
  background: linear-gradient(#fff3c8, #ffc978 40%, #e07a3a);
  opacity: 0;
  animation: flicker 0.7s infinite alternate;
  filter: blur(0.3px);
}
.f1 { left: 36%; height: 14%; }
.f2 { left: 46%; height: 22%; animation-delay: 0.15s; }
.f3 { left: 55%; height: 16%; animation-delay: 0.3s; }
.f4 { left: 42%; height: 10%; width: 7px; animation-delay: 0.45s; }
.room[data-fire="0"] .glow { opacity: 0; }
.room[data-fire="1"] .glow { opacity: 0.22; }
.room[data-fire="1"] .f2 { opacity: 0.7; }
.room[data-fire="2"] .glow { opacity: 0.4; }
.room[data-fire="2"] .f1, .room[data-fire="2"] .f2 { opacity: 0.85; }
.room[data-fire="3"] .glow { opacity: 0.62; }
.room[data-fire="3"] .flame { opacity: 0.92; }
.room[data-fire="4"] .glow, .room[data-fire="5"] .glow { opacity: 0.88; }
.room[data-fire="4"] .flame, .room[data-fire="5"] .flame { opacity: 1; }
.room[data-fire="5"] .glow { filter: blur(12px); }
@keyframes flicker { from { transform: scaleY(0.82) translateY(2px); } to { transform: scaleY(1.12); } }

.embers { position: absolute; left: 28%; right: 28%; bottom: 28%; height: 24%; overflow: hidden; }
.embers i {
  position: absolute;
  width: 3px; height: 3px; border-radius: 50%;
  background: #ffc978;
  opacity: 0;
}
.room[data-fire="3"] .embers i,
.room[data-fire="4"] .embers i,
.room[data-fire="5"] .embers i {
  animation: ember 2.4s linear infinite;
}
.embers i:nth-child(1) { left: 10%; animation-delay: 0s; }
.embers i:nth-child(2) { left: 30%; animation-delay: 0.4s; }
.embers i:nth-child(3) { left: 50%; animation-delay: 0.8s; }
.embers i:nth-child(4) { left: 70%; animation-delay: 1.1s; }
.embers i:nth-child(5) { left: 20%; animation-delay: 1.5s; }
.embers i:nth-child(6) { left: 62%; animation-delay: 1.9s; }
@keyframes ember {
  0% { transform: translateY(10px); opacity: 0; }
  20% { opacity: 1; }
  100% { transform: translateY(-28px); opacity: 0; }
}

.woodpile {
  position: absolute; bottom: 6%; height: 11px; background: #5a3a24; border: 1px solid #2a1a12; opacity: 0;
}
.w1 { left: 0; width: 30%; }
.w2 { left: 8%; width: 32%; bottom: 12%; }
.w3 { left: 4%; width: 28%; bottom: 18%; }
.w4 { left: 10%; width: 26%; bottom: 24%; }
.room[data-wood="1"] .w1,
.room[data-wood="2"] .w1, .room[data-wood="2"] .w2,
.room[data-wood="3"] .w1, .room[data-wood="3"] .w2, .room[data-wood="3"] .w3,
.room[data-wood="4"] .woodpile { opacity: 1; }

/* ---------- Survivor ---------- */
.survivor {
  position: absolute;
  width: 58px;
  height: 128px;
  z-index: 7;
  transition: left 0.7s ease, bottom 0.7s ease, opacity 0.35s ease;
  left: 40%;
  bottom: 15%;
}
.survivor.hidden { opacity: 0; pointer-events: none; }
.survivor.flip { transform: scaleX(-1); }
.survivor.flip .sv-caption,
.survivor.flip .sv-face { transform: scaleX(-1); }
.survivor[data-spot="door"] { left: 7%; bottom: 17%; }
.survivor[data-spot="bed"] { left: 24%; bottom: 17%; }
.survivor[data-spot="window"] { left: 45%; bottom: 27%; }
.survivor[data-spot="radio"] { left: 61%; bottom: 19%; }
.survivor[data-spot="repair"] { left: 71%; bottom: 19%; }
.survivor[data-spot="idle"] { left: 39%; bottom: 15%; }
.survivor[data-spot="table"] { left: 53%; bottom: 15%; }
.survivor[data-spot="fire"] { left: 77%; bottom: 15%; }

.sv-shadow {
  position: absolute; left: 8px; right: 8px; bottom: -8px; height: 12px;
  background: rgba(0,0,0,0.38); border-radius: 50%; filter: blur(2px);
}
.sv-boot {
  position: absolute; bottom: 0; width: 14px; height: 10px; background: #1a1210; border-radius: 2px;
}
.sv-boot.left { left: 12px; }
.sv-boot.right { right: 12px; }
.sv-leg {
  position: absolute; bottom: 8px; width: 11px; height: 34px; background: #1e1614; border-radius: 2px;
}
.sv-leg.left { left: 14px; }
.sv-leg.right { right: 14px; }
.sv-coat {
  position: absolute; left: 8px; right: 8px; top: 30px; height: 62px;
  background: linear-gradient(#4a3428, #241810);
  border-radius: 10px 10px 6px 6px;
  box-shadow: inset 0 0 0 1px rgba(255,255,255,0.05);
}
.sv-scarf {
  position: absolute; left: 14px; right: 14px; top: 28px; height: 10px;
  background: #7a2e28; border-radius: 4px;
}
.sv-arm {
  position: absolute; top: 36px; width: 10px; height: 40px; background: #2e2018; border-radius: 5px;
  transform-origin: top center;
}
.sv-arm.left { left: 1px; }
.sv-arm.right { right: 1px; }
.sv-head { position: absolute; left: 15px; top: 4px; width: 28px; height: 28px; }
.sv-hood {
  position: absolute; inset: -5px -3px 3px; background: #2a1c16; border-radius: 14px 14px 6px 6px;
}
.sv-face {
  position: absolute; left: 6px; top: 7px; width: 16px; height: 16px;
  background: #cbb39a; border-radius: 50%;
}
.eye {
  position: absolute; top: 6px; width: 3px; height: 3px; background: #1a1210; border-radius: 50%;
}
.eye.l { left: 3px; }
.eye.r { right: 3px; }
.sv-breath {
  position: absolute; right: -6px; top: 16px; width: 16px; height: 10px;
  background: radial-gradient(circle, rgba(230,240,250,0.45), transparent 70%);
  opacity: 0;
}
.survivor[data-cond="cold"] .sv-breath,
.room[data-night="1"] .sv-breath {
  opacity: 0.8;
  animation: breath 1.8s ease-in-out infinite;
}
@keyframes breath { from { transform: scale(0.6); opacity: 0.15; } to { transform: translateX(8px) scale(1.3); opacity: 0; } }
.sv-caption {
  position: absolute; top: -24px; left: 50%; transform: translateX(-50%);
  white-space: nowrap; font-size: 12px; color: #ffd9b0;
  opacity: 0; background: rgba(10,8,6,0.78); padding: 2px 8px;
  border: 1px solid rgba(255,201,120,0.2);
}
.survivor.show-cap .sv-caption { opacity: 1; }

.survivor.walking .sv-leg.left { animation: step 0.34s infinite alternate; }
.survivor.walking .sv-leg.right { animation: step 0.34s infinite alternate-reverse; }
@keyframes step { from { transform: rotate(-14deg); } to { transform: rotate(14deg); } }

.survivor[data-pose="warm"] .sv-arm.right,
.survivor[data-pose="stoke"] .sv-arm.right { transform: rotate(-55deg); }
.survivor[data-pose="eat"] .sv-arm.right { transform: rotate(-72deg); }
.survivor[data-pose="bandage"] .sv-arm.left { transform: rotate(28deg); }
.survivor[data-pose="look"] { transform: translateY(-6px); }
.survivor.flip[data-pose="look"] { transform: scaleX(-1) translateY(-6px); }
.survivor[data-pose="radio"] .sv-arm.left { transform: rotate(-42deg); }
.survivor[data-pose="repair"] .sv-arm.right { transform: rotate(-78deg); }
.survivor[data-pose="shiver"] { animation: shiver 0.16s infinite alternate; }
.survivor[data-pose="sleep"] { opacity: 0; }
@keyframes shiver { from { transform: translateX(-1px); } to { transform: translateX(1px); } }
.survivor.flip[data-pose="shiver"] { animation: shiver-flip 0.16s infinite alternate; }
@keyframes shiver-flip { from { transform: scaleX(-1) translateX(-1px); } to { transform: scaleX(-1) translateX(1px); } }

.survivor[data-cond="cold"] .sv-face { background: #9ab0c4; }
.survivor[data-cond="hurt"] .sv-coat { box-shadow: inset 8px 12px 0 -8px #6a2424; }
.survivor[data-cond="weak"] { filter: grayscale(0.28) brightness(0.9); }

.floats { position: absolute; inset: 0; pointer-events: none; z-index: 9; }
.float-item {
  position: absolute;
  font-size: 13px;
  color: #ffd9b0;
  animation: rise 1.4s ease forwards;
  white-space: nowrap;
  text-shadow: 0 2px 8px #000;
}
.float-item.plus { color: #7ec8a3; }
.float-item.minus { color: #f0b0a4; }
.float-item[data-spot="door"] { left: 8%; top: 38%; }
.float-item[data-spot="bed"] { left: 24%; top: 46%; }
.float-item[data-spot="window"] { left: 45%; top: 26%; }
.float-item[data-spot="radio"] { left: 61%; top: 36%; }
.float-item[data-spot="repair"] { left: 71%; top: 34%; }
.float-item[data-spot="table"] { left: 53%; top: 48%; }
.float-item[data-spot="fire"] { left: 79%; top: 38%; }
@keyframes rise { from { opacity: 1; transform: translateY(0); } to { opacity: 0; transform: translateY(-30px); } }

.log {
  flex: 0 0 96px;
  overflow: hidden;
  padding: 10px 18px;
  background: #0b0d12;
  border-top: 1px solid rgba(255,255,255,0.06);
  font-size: 13px;
  color: var(--mute);
  line-height: 1.6;
  z-index: 5;
}
.log p { margin: 0 0 2px; }
.log p:last-child { color: #dce7f2; }

.modal {
  position: fixed; inset: 0; z-index: 30;
  display: flex; align-items: center; justify-content: center;
  background: rgba(6, 8, 12, 0.62);
  backdrop-filter: blur(3px);
}
.modal[hidden] { display: none !important; }
.modal-card {
  width: min(440px, 90vw);
  padding: 26px;
  background: linear-gradient(180deg, #1c1916, #121014);
  border: 1px solid rgba(220,230,240,0.16);
  box-shadow: 0 24px 70px rgba(0,0,0,0.5);
}
.modal-card h3 { margin-bottom: 10px; letter-spacing: 0.16em; font-weight: 600; }
.modal-card p { color: var(--mute); line-height: 1.8; margin-bottom: 18px; }
.modal-actions { display: flex; flex-wrap: wrap; gap: 8px; }

.cutscene {
  position: fixed; inset: 0; z-index: 35;
  display: flex; flex-direction: column; align-items: center; justify-content: flex-end;
  background: #0a0c12;
}
.cutscene[hidden] { display: none !important; }
.cs-art { position: absolute; inset: 0; overflow: hidden; }
.cs-sky { position: absolute; inset: 0; background: linear-gradient(180deg, #1a2430, #d8e2ea); }
.cs-moon { position: absolute; right: 18%; top: 12%; width: 36px; height: 36px; border-radius: 50%; background: #f2efe4; opacity: 0; }
.cs-layer { position: absolute; left: -6%; right: -6%; bottom: 0; }
.cs-layer.far { height: 46%; background: #b7c6d4; border-radius: 50% 50% 0 0; }
.cs-layer.mid { height: 34%; background: repeating-linear-gradient(90deg, transparent 0 40px, #1c2830 40px 52px); }
.cs-layer.near { height: 22%; background: #e8eef4; }
.cs-ground { position: absolute; left: 0; right: 0; bottom: 0; height: 16%; background: #f4f8fb; }
.cutscene[data-kind="woods"] .cs-layer.mid {
  background:
    radial-gradient(20px 90px at 12% 100%, #1a222a 99%, transparent 100%),
    radial-gradient(16px 70px at 28% 100%, #24323c 99%, transparent 100%),
    radial-gradient(22px 110px at 48% 100%, #1c2830 99%, transparent 100%),
    radial-gradient(14px 64px at 68% 100%, #22303a 99%, transparent 100%),
    radial-gradient(18px 84px at 86% 100%, #1a222a 99%, transparent 100%);
}
.cutscene[data-kind="town"] .cs-sky { background: linear-gradient(180deg, #3a2e2c, #1a1412); }
.cutscene[data-kind="town"] .cs-layer.far { background: #2a2220; border-radius: 0; height: 48%; clip-path: polygon(0 100%, 0 40%, 12% 28%, 18% 40%, 30% 18%, 42% 40%, 58% 22%, 70% 46%, 82% 16%, 100% 38%, 100% 100%); }
.cutscene[data-kind="town"] .cs-layer.near { background: #1a1412; }
.cutscene[data-kind="night"] .cs-sky { background: radial-gradient(circle at 70% 18%, #2a3448, #07090d 58%); }
.cutscene[data-kind="night"] .cs-moon { opacity: 1; }
.cutscene[data-kind="night"] .cs-layer.far { background: #121820; }
.cutscene[data-kind="night"] .cs-layer.near, .cutscene[data-kind="night"] .cs-ground { background: #0c1016; }
#cs-line {
  position: relative;
  z-index: 1;
  margin: 0 0 52px;
  padding: 12px 22px;
  background: rgba(8,8,10,0.72);
  letter-spacing: 0.1em;
  border: 1px solid rgba(255,255,255,0.08);
}

body.dead #screen-game { filter: grayscale(0.72) brightness(0.68); }
body.win #screen-end { background: linear-gradient(180deg, #1a2430, #2a2018); }

@media (max-width: 820px) {
  h1 { font-size: 48px; letter-spacing: 0.2em; }
  .hud-stats { grid-template-columns: 1fr 1fr; }
  .survivor { transform-origin: bottom center; }
  .hint { display: none; }
  .room { inset: 6px 6px 8px; }
}
