/* ==========================================================================
   《系統出錯的星期三 / Routine Glitch》v2.0 Director's Cut
   Aesthetic: Editorial Brutalist Drafting Grid -> Tactile Hand-Drawn Storybook
   ========================================================================== */

:root {
  --bleed: 0;
  --bg-grid: #f3f3ef;
  --grid-line: #e1e1da;
  --surface: #ffffff;
  --surface-alt: #eaeae3;
  --ink: #1c1e22;
  --ink-muted: #686c75;
  --border: #c4c5bc;

  --coral: #ff5e5b;
  --tangerine: #ff922b;
  --sunflower: #ffd43b;
  --mint: #20c997;
  --sky: #339af0;
  --lavender: #9775fa;
  --berry: #f06595;
  --warm-paper: #fffaf0;

  --font-mono: 'SF Mono', 'JetBrains Mono', ui-monospace, Menlo, monospace;
  --font-sans: 'PingFang TC', 'Noto Sans TC', -apple-system, BlinkMacSystemFont, sans-serif;
  --font-hand: 'PingFang TC', 'Chalkboard SE', 'Marker Felt', cursive, sans-serif;
  --radius: 0px;
}

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

html, body {
  width: 100%;
  height: 100%;
  overflow: hidden;
  font-family: var(--font-sans);
  color: var(--ink);
  background-color: var(--bg-grid);
  user-select: none;
  -webkit-font-smoothing: antialiased;
}

body {
  background-image:
    linear-gradient(to right, var(--grid-line) 1px, transparent 1px),
    linear-gradient(to bottom, var(--grid-line) 1px, transparent 1px);
  background-size: 26px 26px;
  transition: background-color 1.1s ease, color 0.8s ease;
}

body.bleed-stage-1 { background-color: #f7f4ec; --grid-line: #e8e3d8; }
body.bleed-stage-2 { background-color: #fbf5e8; --grid-line: #eee3ce; --radius: 8px; }
body.bleed-stage-3 { background-color: #fff9eb; --grid-line: rgba(235, 212, 178, 0.45); --radius: 14px; }

.svg-defs { position: absolute; width: 0; height: 0; pointer-events: none; }

/* Subtle Tactile Paper Grain */
#paper-texture {
  position: fixed;
  inset: 0;
  pointer-events: none;
  z-index: 3;
  opacity: 0.045;
  filter: url(#paper-grain);
  background: #000;
}

#bleed-canvas {
  position: fixed;
  inset: 0;
  width: 100vw;
  height: 100vh;
  pointer-events: none;
  z-index: 1;
}

#tear-canvas {
  position: fixed;
  inset: 0;
  width: 100vw;
  height: 100vh;
  pointer-events: none;
  z-index: 900;
}

#atmosphere-overlay {
  position: fixed;
  inset: 0;
  pointer-events: none;
  z-index: 2;
  background: radial-gradient(circle at center, transparent 56%, rgba(18, 20, 24, 0.1) 100%);
  transition: opacity 1.2s ease;
}
body.bleed-stage-3 #atmosphere-overlay { opacity: 0.12; }

/* SVG Artwork Micro-Animations */
.art-svg { display: block; }
.cat-tail {
  transform-origin: 24px 68px;
  animation: tailWag 2.4s ease-in-out infinite;
}
@keyframes tailWag {
  0%, 100% { transform: rotate(0deg); }
  50% { transform: rotate(9deg); }
}
.steam-float {
  animation: steamRise 2.2s ease-in-out infinite;
}
@keyframes steamRise {
  0%, 100% { transform: translateY(0); opacity: 0.45; }
  50% { transform: translateY(-5px); opacity: 0.9; }
}

/* ==========================================================================
   Top System HUD
   ========================================================================== */
#system-hud {
  position: fixed;
  top: 0; left: 0; right: 0;
  height: 54px;
  background: rgba(247, 247, 243, 0.93);
  backdrop-filter: blur(10px);
  border-bottom: 2px solid var(--ink);
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 22px;
  z-index: 100;
  font-family: var(--font-mono);
  font-size: 13px;
  transition: background 0.8s ease, border-color 0.8s ease;
}
body.bleed-stage-2 #system-hud { background: rgba(255, 250, 240, 0.93); }
body.bleed-stage-3 #system-hud { background: rgba(255, 251, 242, 0.95); border-bottom: 3px solid var(--coral); }

.hud-left, .hud-center, .hud-right { display: flex; align-items: center; gap: 12px; }

.hud-dot {
  width: 9px; height: 9px;
  background: var(--ink);
  display: inline-block;
  transition: all 0.4s ease;
}
.hud-dot.glitch {
  background: var(--coral);
  border-radius: 50%;
  box-shadow: 0 0 10px var(--coral);
  animation: pulseDot 1.2s infinite;
}
@keyframes pulseDot {
  0%, 100% { transform: scale(1); opacity: 1; }
  50% { transform: scale(1.4); opacity: 0.7; }
}

.hud-os-name { font-weight: 700; letter-spacing: 0.04em; }
.hud-sep { color: var(--border); }

.hud-clock {
  padding: 4px 10px;
  background: var(--ink);
  color: #fff;
  border: none;
  font-family: var(--font-mono);
  font-size: 12.5px;
  font-weight: 700;
  letter-spacing: 0.06em;
  cursor: pointer;
  transition: transform 0.15s ease, background 0.5s ease;
}
.hud-clock:hover { transform: scale(1.05); }
.hud-clock.glitch {
  background: linear-gradient(90deg, var(--coral), var(--tangerine));
  border-radius: 5px;
}

.meter-group { display: flex; align-items: center; gap: 8px; }
.meter-label { font-family: var(--font-sans); font-size: 12px; font-weight: 700; color: var(--ink-muted); }
.meter-bar {
  width: 100px; height: 10px;
  border: 1.5px solid var(--ink);
  background: var(--surface-alt);
  overflow: hidden;
}
.meter-fill { height: 100%; background: var(--ink); transition: width 0.6s cubic-bezier(0.22, 1, 0.36, 1); }
.bleed-bar { border-radius: 99px; border-color: var(--coral); }
.bleed-fill { background: linear-gradient(90deg, var(--tangerine), var(--coral), var(--berry), var(--lavender), var(--sky), var(--mint)); }
.meter-val { min-width: 38px; font-weight: 700; font-size: 12px; }

.hud-btn {
  display: inline-flex; align-items: center; gap: 6px;
  padding: 6px 12px;
  background: var(--surface);
  border: 1.5px solid var(--ink);
  color: var(--ink);
  font-family: var(--font-sans);
  font-size: 12px; font-weight: 700;
  cursor: pointer;
  border-radius: var(--radius);
  transition: transform 0.15s ease, background 0.2s ease, box-shadow 0.2s ease;
}
.hud-btn:hover { transform: translateY(-1px); background: var(--ink); color: #fff; }
.hud-btn.icon-only { padding: 6px 10px; font-size: 14px; }
.hud-btn.rainbow-glow {
  border-color: var(--coral);
  box-shadow: 2px 2px 0 var(--sunflower);
}
.hud-btn.rainbow-glow:hover { background: var(--coral); color: #fff; }

.badge {
  display: inline-flex; align-items: center; justify-content: center;
  min-width: 19px; height: 19px; padding: 0 5px;
  background: var(--coral); color: #fff;
  border-radius: 99px; font-size: 11px; font-family: var(--font-mono);
}

/* ==========================================================================
   Main Stage & Editorial Scene Cards
   ========================================================================== */
#game-root {
  position: relative;
  z-index: 10;
  width: 100vw;
  height: 100vh;
  padding-top: 54px;
  padding-bottom: 108px;
  display: flex;
  align-items: center;
  justify-content: center;
  overflow: hidden;
}
#game-root.full-height { padding-top: 0; padding-bottom: 0; }

#stage-container {
  width: min(980px, 94vw);
  max-height: calc(100vh - 170px);
  overflow-y: auto;
  padding: 8px 6px 14px;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: safe center;
  position: relative;
}
#game-root.full-height #stage-container { max-height: 95vh; }

.scene-card {
  width: 100%;
  background: rgba(255, 255, 255, 0.95);
  border: 2.5px solid var(--ink);
  padding: 26px 30px;
  position: relative;
  box-shadow: 7px 7px 0 rgba(28, 30, 34, 0.14);
  animation: sceneEnter 0.38s cubic-bezier(0.22, 1, 0.36, 1);
  transition: border-radius 0.8s ease, box-shadow 0.8s ease, background 0.8s ease;
}

/* Vibrant Hand-Drawn Storybook Card with Washi Tape! */
.scene-card.vibrant-card {
  background: rgba(255, 252, 245, 0.98);
  border: 3px solid var(--ink);
  border-radius: 18px 22px 16px 20px / 20px 16px 22px 18px;
  box-shadow: 8px 8px 0 var(--sunflower), 13px 13px 0 rgba(255, 94, 91, 0.22);
}
.scene-card.vibrant-card::before {
  content: '';
  position: absolute;
  top: -11px;
  left: 36px;
  width: 78px;
  height: 20px;
  background: rgba(255, 212, 59, 0.82);
  border: 1.5px solid rgba(28, 30, 34, 0.35);
  transform: rotate(-3deg);
  pointer-events: none;
}
.scene-card.vibrant-card::after {
  content: '';
  position: absolute;
  top: -10px;
  right: 44px;
  width: 68px;
  height: 19px;
  background: rgba(51, 154, 240, 0.45);
  border: 1.5px solid rgba(28, 30, 34, 0.25);
  transform: rotate(4deg);
  pointer-events: none;
}

@keyframes sceneEnter {
  from { opacity: 0; transform: translateY(12px) scale(0.99); }
  to { opacity: 1; transform: translateY(0) scale(1); }
}

.scene-meta {
  display: flex; align-items: center; justify-content: space-between;
  margin-bottom: 12px; padding-bottom: 10px;
  border-bottom: 1.5px dashed var(--border);
  font-family: var(--font-mono); font-size: 12px; color: var(--ink-muted);
}

.scene-title {
  font-size: 24px; font-weight: 900; letter-spacing: -0.02em;
  margin-bottom: 8px;
  display: flex; align-items: center; gap: 10px;
}
.scene-title.hand-title {
  font-family: var(--font-hand);
  font-size: 28px;
  color: #2b2320;
}

.scene-desc {
  font-size: 14.5px; line-height: 1.72; color: #3a3d42;
  margin-bottom: 16px;
}

.scene-viewport {
  position: relative;
  width: 100%;
  height: 300px;
  background: #f5f5f1;
  border: 2px solid var(--ink);
  margin-bottom: 16px;
  overflow: hidden;
  display: flex; align-items: center; justify-content: center;
}
.scene-viewport.tall { height: 336px; }
.scene-viewport.vibrant-vp {
  border-radius: 14px;
  border: 2.5px solid var(--ink);
  background: #fffdf7;
}

/* Action Bar & Buttons */
.action-bar {
  display: flex; flex-wrap: wrap;
  align-items: center; justify-content: space-between;
  gap: 12px;
}

.btn-primary, .btn-secondary, .btn-rebel, .btn-ghost {
  font-family: var(--font-sans);
  font-size: 14px; font-weight: 700;
  padding: 10px 20px;
  cursor: pointer;
  border: 2px solid var(--ink);
  transition: transform 0.14s ease, box-shadow 0.14s ease, background 0.2s ease;
  display: inline-flex; align-items: center; gap: 8px;
}
.btn-primary { background: var(--ink); color: #fff; }
.btn-primary:hover { background: #33373e; transform: translateY(-2px); box-shadow: 4px 4px 0 rgba(0, 0, 0, 0.2); }
.btn-primary:disabled { opacity: 0.4; cursor: not-allowed; transform: none; box-shadow: none; }

.btn-secondary { background: #fff; color: var(--ink); }
.btn-secondary:hover { background: var(--surface-alt); transform: translateY(-1px); }

.btn-rebel {
  background: linear-gradient(135deg, var(--tangerine), var(--coral));
  color: #fff;
  border: 2.5px solid var(--ink);
  border-radius: 12px 14px 10px 13px;
  box-shadow: 4px 4px 0 var(--sunflower);
  animation: subtleWiggle 3s ease-in-out infinite;
}
.btn-rebel:hover { transform: translateY(-2px) rotate(-1deg) scale(1.03); box-shadow: 6px 6px 0 var(--sunflower); }

.btn-ghost { background: transparent; border-color: transparent; color: var(--ink-muted); padding: 8px 12px; }
.btn-ghost:hover { color: var(--ink); background: rgba(0, 0, 0, 0.05); }
.danger-text { color: var(--coral); }

@keyframes subtleWiggle {
  0%, 100% { transform: rotate(0deg); }
  25% { transform: rotate(-1deg); }
  75% { transform: rotate(1deg); }
}

/* ==========================================================================
   Title Screen (Editorial Book Cover Vibe)
   ========================================================================== */
.title-screen {
  text-align: center;
  padding: 40px 42px;
  max-width: 720px;
}
.title-tag {
  display: inline-block;
  font-family: var(--font-mono); font-size: 12px; letter-spacing: 0.14em;
  padding: 4px 14px; border: 1.5px solid var(--ink);
  margin-bottom: 16px; background: var(--surface-alt);
}
.title-main {
  font-size: clamp(32px, 5vw, 48px); font-weight: 900;
  letter-spacing: -0.03em; line-height: 1.18; margin-bottom: 6px;
}
.title-sub {
  font-family: var(--font-mono); font-size: 14px; color: var(--ink-muted);
  letter-spacing: 0.18em; margin-bottom: 20px;
}
.title-lead {
  font-size: 15px; line-height: 1.85; color: #464950;
  max-width: 510px; margin: 0 auto 26px;
}
.title-actions { display: flex; flex-direction: column; align-items: center; gap: 11px; }
.title-cat-corner {
  position: absolute; right: 14px; bottom: 8px;
  cursor: pointer; background: none; border: none;
  transition: transform 0.2s ease;
}
.title-cat-corner:hover { transform: scale(1.12) rotate(-5deg); }

/* ==========================================================================
   Narrator Bar
   ========================================================================== */
#narrator-bar {
  position: fixed; bottom: 14px; left: 50%;
  transform: translateX(-50%);
  width: min(880px, 94vw); min-height: 76px;
  background: rgba(24, 26, 30, 0.96);
  color: #f4f4f0; border: 2px solid #1c1e22;
  padding: 12px 18px;
  display: flex; align-items: flex-start; gap: 14px;
  z-index: 200;
  box-shadow: 6px 6px 0 rgba(0, 0, 0, 0.18);
  transition: background 0.6s ease, border-color 0.6s ease, border-radius 0.6s ease;
}
#narrator-bar.mood-panicked {
  background: #2c171b; border-color: var(--coral);
  box-shadow: 6px 6px 0 rgba(255, 94, 91, 0.35);
}
#narrator-bar.mood-warm {
  background: #2b231e; border-color: var(--tangerine);
  border-radius: 16px;
  box-shadow: 6px 6px 0 rgba(255, 212, 59, 0.45);
}

.narrator-avatar {
  width: 44px; height: 44px; flex-shrink: 0;
  background: #3a3e46; border: 1.5px solid #8a8f98;
  display: flex; align-items: center; justify-content: center;
  font-family: var(--font-mono); font-weight: 700; font-size: 13px;
  transition: all 0.4s ease;
}
#narrator-bar.mood-panicked .narrator-avatar {
  background: var(--coral); border-color: #fff; color: #fff;
  animation: shakeTiny 0.28s infinite;
}
#narrator-bar.mood-warm .narrator-avatar {
  background: linear-gradient(135deg, var(--tangerine), var(--sunflower));
  border-color: #fff; color: #2b2420; border-radius: 50%; font-size: 20px;
}
@keyframes shakeTiny {
  0%, 100% { transform: translate(0, 0); }
  25% { transform: translate(-1.5px, 1px); }
  75% { transform: translate(1.5px, -1px); }
}

.narrator-body { flex: 1; min-width: 0; }
.narrator-header { display: flex; align-items: center; gap: 10px; margin-bottom: 4px; }
.narrator-name { font-family: var(--font-mono); font-size: 12px; font-weight: 700; color: #a8adb8; }
#narrator-bar.mood-panicked .narrator-name { color: #ff9f9d; }
#narrator-bar.mood-warm .narrator-name { color: var(--sunflower); }
.narrator-mood { font-family: var(--font-mono); font-size: 11px; padding: 1px 6px; background: rgba(255,255,255,0.1); color: #d4d7dc; }
.narrator-text { font-size: 14.5px; line-height: 1.55; color: #ffffff; }

/* ==========================================================================
   Scene Interactive Components
   ========================================================================== */
.stamp-badge {
  position: absolute; top: 16px; right: 20px;
  padding: 5px 14px; border: 2.5px solid var(--ink);
  font-family: var(--font-mono); font-weight: 700; font-size: 13px;
  transform: rotate(-8deg); opacity: 0; pointer-events: none;
  background: rgba(255, 255, 255, 0.92); z-index: 40;
}
.stamp-badge.show { animation: stampSlam 0.35s cubic-bezier(0.18, 0.89, 0.32, 1.28) forwards; }
@keyframes stampSlam {
  0% { opacity: 0; transform: scale(2.1) rotate(-18deg); }
  100% { opacity: 1; transform: scale(1) rotate(-7deg); }
}

.ringing-wrap { animation: alarmShake 0.14s infinite; }
@keyframes alarmShake {
  0%, 100% { transform: translate(0, 0) rotate(0deg); }
  25% { transform: translate(-2px, -1px) rotate(-1.2deg); }
  75% { transform: translate(2px, 1px) rotate(1.2deg); }
}

/* Brush Teeth */
.teeth-stage { display: flex; flex-direction: column; align-items: center; gap: 14px; }
.teeth-grid {
  display: grid; grid-template-columns: repeat(8, 38px); gap: 4px;
  padding: 14px; border: 2.5px solid var(--ink); background: #fff; cursor: grab;
}
.tooth-cell {
  width: 38px; height: 44px; border: 1.5px solid var(--ink);
  background: #dcdcd3; transition: background 0.2s ease, transform 0.18s ease; position: relative;
}
.tooth-cell.clean { background: #ffffff; transform: scale(1.04); }
.tooth-cell.clean::after {
  content: '✦'; position: absolute; inset: 0;
  display: flex; align-items: center; justify-content: center; font-size: 12px; color: #9fa4ad;
}

/* Steamy Mirror */
.mirror-frame {
  position: relative;
  width: 340px; height: 230px;
  border: 6px solid #494c54;
  border-radius: 14px;
  background: linear-gradient(135deg, #d8e2eb 0%, #eef4f8 50%, #cfdbe6 100%);
  overflow: hidden;
  box-shadow: inset 0 0 24px rgba(255,255,255,0.7);
}
.mirror-secret {
  position: absolute; inset: 0;
  display: flex; flex-direction: column; align-items: center; justify-content: center;
  pointer-events: none; text-align: center; padding: 16px;
}
#mirror-canvas {
  position: absolute; inset: 0; width: 100%; height: 100%; cursor: crosshair; z-index: 5;
}

/* Vending Machine */
.vending-shake { animation: vendShake 0.28s ease-in-out; }
@keyframes vendShake {
  0%, 100% { transform: translateX(0); }
  25% { transform: translateX(-8px) rotate(-2deg); }
  75% { transform: translateX(8px) rotate(2deg); }
}

/* Street & Stray Cat */
.street-scene {
  position: relative; width: 100%; height: 100%;
  background: linear-gradient(180deg, #e5e5df 0 56%, #cecec6 56% 100%);
}
.alley-sign {
  position: absolute; left: 22px; top: 20px;
  padding: 6px 12px; border: 2px solid var(--ink); background: #fff;
  font-family: var(--font-mono); font-size: 12px; font-weight: 700; cursor: pointer;
  transition: all 0.2s ease;
}
.alley-sign:hover { background: var(--coral); color: #fff; transform: rotate(-3deg); }
.orange-cat-btn {
  position: absolute; left: 28px; bottom: 14px;
  background: none; border: none; cursor: pointer;
  filter: drop-shadow(0 0 12px rgba(255, 146, 43, 0.7));
  animation: catBob 2s ease-in-out infinite;
}
.orange-cat-btn:hover { transform: scale(1.12) rotate(-4deg); }
@keyframes catBob { 0%, 100% { transform: translateY(0); } 50% { transform: translateY(-5px); } }

.mrt-entrance-box {
  position: absolute; right: 32px; bottom: 20px;
  width: 184px; height: 156px; border: 2.5px solid var(--ink); background: #f7f7f2;
  display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 6px;
  cursor: pointer; transition: background 0.2s ease;
}
.mrt-entrance-box:hover { background: #e5e5dd; }

/* MRT Windows & Passengers */
.mrt-window-row { display: flex; gap: 18px; width: 92%; justify-content: center; }
.mrt-window {
  flex: 1; height: 128px; border: 2.5px solid var(--ink);
  background: #e9e9e3; position: relative; overflow: hidden;
  transition: background 1s ease;
}
.mrt-window.sky-mode {
  background: linear-gradient(180deg, #4dabf7 0%, #a5d8ff 62%, #ffe8cc 100%);
  border-radius: 12px;
}
.mrt-tunnel-lines {
  position: absolute; inset: 0;
  background: repeating-linear-gradient(90deg, transparent 0 46px, rgba(0,0,0,0.08) 46px 50px);
  animation: tunnelScroll 0.8s linear infinite;
}
@keyframes tunnelScroll { from { background-position-x: 0; } to { background-position-x: -50px; } }

.commuter-row { display: flex; justify-content: space-around; width: 92%; margin-top: 10px; }
.commuter-fig {
  display: flex; flex-direction: column; align-items: center; gap: 3px;
  cursor: pointer; transition: transform 0.2s ease;
}
.commuter-fig:hover { transform: translateY(-5px); }
.commuter-bubble {
  font-family: var(--font-mono); font-size: 11px; padding: 2px 8px;
  border: 1.5px solid var(--ink); background: #fff; white-space: nowrap;
}
.commuter-bubble.dream { background: var(--sunflower); border-radius: 12px; font-family: var(--font-sans); font-weight: 700; }

/* Elevator & Floor 3.5 */
.elevator-panel {
  display: grid; grid-template-columns: repeat(3, 88px); gap: 14px;
  padding: 22px; background: #dcdcd6; border: 3px solid var(--ink);
  box-shadow: inset 0 0 0 4px #f2f2ec;
}
.elev-btn {
  height: 54px; border: 2px solid var(--ink); background: #f7f7f4;
  font-family: var(--font-mono); font-size: 16px; font-weight: 700; cursor: pointer;
  transition: all 0.15s ease;
}
.elev-btn:hover { background: var(--ink); color: #fff; }
.elev-btn.floor-35 {
  background: linear-gradient(135deg, var(--sunflower), var(--tangerine), var(--berry));
  color: #1e2024; border: 2.5px solid var(--ink); border-radius: 14px 10px 16px 8px;
  font-family: var(--font-hand); font-size: 22px;
  box-shadow: 0 0 18px rgba(255, 146, 43, 0.78);
  animation: floorGlow 1.6s ease-in-out infinite;
}
.elev-btn.floor-35:hover { transform: scale(1.12) rotate(-3deg); color: #fff; }
@keyframes floorGlow {
  0%, 100% { box-shadow: 0 0 10px rgba(255, 146, 43, 0.6); }
  50% { box-shadow: 0 0 24px rgba(240, 101, 149, 0.95); }
}

.museum-grid { display: grid; grid-template-columns: repeat(5, 1fr); gap: 10px; width: 95%; }
.treasure-card {
  background: #fffdf7; border: 2px solid var(--ink); border-radius: 14px;
  padding: 12px 8px; text-align: center; cursor: pointer;
  transition: transform 0.2s ease, box-shadow 0.2s ease, background 0.2s ease;
}
.treasure-card:hover { transform: translateY(-6px) rotate(-2deg); box-shadow: 4px 6px 0 var(--sunflower); }
.treasure-card.inspected { background: #fff3bf; border-color: var(--tangerine); }
.treasure-icon { font-size: 30px; margin-bottom: 5px; }
.treasure-name { font-size: 12.5px; font-weight: 800; }

/* Spreadsheet + Crayon + Stickers */
.sheet-window {
  width: 95%; height: 312px; border: 2px solid var(--ink); background: #fff;
  display: flex; flex-direction: column; position: relative;
}
.sheet-titlebar {
  display: flex; align-items: center; justify-content: space-between;
  padding: 6px 12px; background: var(--ink); color: #fff;
  font-family: var(--font-mono); font-size: 12px;
}
.sheet-toolbar {
  display: flex; align-items: center; gap: 8px; flex-wrap: wrap;
  padding: 6px 10px; background: #ecece6; border-bottom: 1.5px solid var(--ink); font-size: 12px;
}
.sheet-grid-wrap { flex: 1; position: relative; overflow: hidden; }
.sheet-table { width: 100%; height: 100%; border-collapse: collapse; font-family: var(--font-mono); font-size: 12px; }
.sheet-table th, .sheet-table td { border: 1px solid #d0d0c8; padding: 6px 8px; text-align: center; }
.sheet-table th { background: #f0f0ea; font-weight: 700; }
.sheet-cell-btn {
  width: 100%; padding: 5px 8px; background: #f8f8f4; border: 1px solid #b8b8b0;
  font-family: var(--font-mono); font-size: 11px; cursor: pointer;
}
.sheet-cell-btn.approved { background: var(--ink); color: #fff; }

#crayon-canvas { position: absolute; inset: 0; width: 100%; height: 100%; cursor: crosshair; z-index: 20; pointer-events: none; }
#crayon-canvas.active { pointer-events: auto; }

.crayon-palette { display: flex; align-items: center; gap: 5px; }
.crayon-swatch {
  width: 20px; height: 20px; border-radius: 50%; border: 2px solid var(--ink); cursor: pointer;
  transition: transform 0.14s ease;
}
.crayon-swatch.selected { transform: scale(1.26); box-shadow: 0 0 0 2px #fff, 0 0 0 4px var(--ink); }
.sticker-btn {
  background: #fff; border: 1.5px solid var(--ink); border-radius: 6px;
  padding: 2px 6px; font-size: 14px; cursor: pointer;
}
.sticker-btn.selected { background: var(--sunflower); }

/* Desktop Trash Can Scene (Lunch Rebellion) */
.desk-files-arena {
  position: relative; width: 100%; height: 100%;
  background: #e9e9e2; padding: 20px;
  display: flex; align-items: center; justify-content: space-between;
}
.file-chip {
  padding: 12px 16px; background: #fff; border: 2px solid var(--ink);
  font-family: var(--font-mono); font-size: 13px; font-weight: 700;
  cursor: grab; box-shadow: 4px 4px 0 rgba(0,0,0,0.14);
  display: flex; align-items: center; gap: 8px;
  transition: transform 0.15s ease, opacity 0.2s ease;
}
.file-chip:hover { transform: translateY(-2px) rotate(-1deg); }
.file-chip.trashed { opacity: 0.25; pointer-events: none; text-decoration: line-through; }

.trash-zone {
  width: 170px; height: 180px;
  border: 3px dashed var(--ink); border-radius: 14px;
  background: rgba(255,255,255,0.65);
  display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 8px;
  transition: all 0.2s ease;
}
.trash-zone.drag-over {
  background: #fff3bf; border-color: var(--coral); transform: scale(1.06);
}

/* Draggable Fourth-Wall Window */
.desktop-arena {
  position: relative; width: 100%; height: 324px;
  background: #e6e6df; border: 2px solid var(--ink); overflow: hidden;
}
.desktop-arena.cracked {
  background: radial-gradient(circle at 30% 30%, #2b1f4c 0%, #151428 70%, #0d0d1a 100%);
  border-color: var(--lavender);
}
.drag-window {
  position: absolute; left: 50%; top: 50%; transform: translate(-50%, -50%);
  width: 390px; background: #fff; border: 2.5px solid var(--ink);
  box-shadow: 8px 8px 0 rgba(0, 0, 0, 0.2); z-index: 20;
}
.drag-titlebar {
  background: var(--ink); color: #fff; padding: 9px 14px;
  font-family: var(--font-mono); font-size: 12px;
  display: flex; justify-content: space-between; align-items: center; cursor: grab;
}
.drag-titlebar:active { cursor: grabbing; }
.drag-body { padding: 18px; font-size: 14px; line-height: 1.65; }
.edge-hint-glow {
  position: absolute; right: 0; top: 0; bottom: 0; width: 26px;
  background: linear-gradient(90deg, transparent, rgba(255, 146, 43, 0.6));
  pointer-events: none; animation: edgePulse 1.8s infinite;
}
@keyframes edgePulse { 0%, 100% { opacity: 0.35; } 50% { opacity: 0.95; } }

/* Backstage Corkboard & Chat */
.backstage-board {
  position: relative; width: 100%; height: 100%; padding: 14px 18px;
  color: #fff8ea; display: flex; flex-direction: column; justify-content: space-between; gap: 8px;
}
.sticky-row { display: flex; gap: 10px; flex-wrap: wrap; }
.sticky-note {
  flex: 1; min-width: 170px; background: #fff3bf; color: #2b2420;
  padding: 10px 12px; border: 2px solid #2b2420; border-radius: 4px 12px 6px 10px;
  font-size: 12.5px; line-height: 1.48; box-shadow: 4px 4px 0 rgba(0, 0, 0, 0.25);
  transform: rotate(-1deg);
}
.sticky-note:nth-child(2) { background: #ffd8e8; transform: rotate(1.2deg); }
.sticky-note:nth-child(3) { background: #d0ebff; transform: rotate(-0.6deg); }

.music-stars { display: flex; justify-content: center; gap: 14px; }
.star-key {
  width: 44px; height: 44px; border-radius: 50%; border: 2px solid #fff;
  background: rgba(255, 255, 255, 0.14); color: var(--sunflower);
  font-size: 20px; cursor: pointer; transition: transform 0.14s ease, background 0.2s ease;
}
.star-key:hover, .star-key.lit {
  transform: scale(1.22); background: var(--sunflower); color: #2b1f4c;
  box-shadow: 0 0 18px var(--sunflower);
}

/* Rain Puddle Canvas */
#puddle-canvas {
  width: 100%; height: 100%; cursor: pointer; display: block;
}

/* Sunset Rooftop */
.sunset-canvas-wrap {
  position: relative; width: 100%; height: 100%;
  background: linear-gradient(180deg, #3b2d6b 0%, #c25178 44%, #ff9259 76%, #ffd470 100%);
  overflow: hidden; display: flex; flex-direction: column; align-items: center; justify-content: center; color: #fff;
}

/* ==========================================================================
   Modals (Sketchbook & Timeline)
   ========================================================================== */
.modal-backdrop {
  position: fixed; inset: 0; background: rgba(20, 22, 26, 0.65);
  backdrop-filter: blur(5px); z-index: 500;
  display: flex; align-items: center; justify-content: center; padding: 20px;
}
.modal-card {
  width: min(880px, 95vw); max-height: 86vh;
  background: #fffdf7; border: 3px solid var(--ink); border-radius: 16px;
  box-shadow: 10px 10px 0 rgba(0, 0, 0, 0.25);
  display: flex; flex-direction: column; overflow: hidden;
}
.modal-header {
  display: flex; align-items: flex-start; justify-content: space-between;
  padding: 18px 24px 14px; border-bottom: 2px dashed var(--border);
}
.modal-header h2 { font-size: 21px; font-weight: 900; }
.modal-subtitle { font-size: 13px; color: var(--ink-muted); margin-top: 4px; }
.modal-close {
  background: none; border: 2px solid var(--ink); width: 34px; height: 34px;
  font-size: 16px; font-weight: 700; cursor: pointer; border-radius: 8px;
}
.modal-close:hover { background: var(--ink); color: #fff; }

.sketchbook-grid {
  padding: 18px 24px; overflow-y: auto;
  display: grid; grid-template-columns: repeat(auto-fill, minmax(230px, 1fr)); gap: 14px;
}
.postcard {
  border: 2px solid var(--ink); border-radius: 12px; padding: 14px;
  background: #f5f5f0; display: flex; flex-direction: column; gap: 7px;
}
.postcard.unlocked { background: #fff9eb; box-shadow: 4px 4px 0 var(--sunflower); }
.postcard-icon { font-size: 26px; }
.postcard-title { font-weight: 900; font-size: 14.5px; }
.postcard-desc { font-size: 12px; line-height: 1.55; color: #464950; }
.postcard-thumb {
  width: 100%; height: 78px; object-fit: cover;
  border: 1.5px solid var(--ink); border-radius: 6px; background: #fff;
}

.timeline-list { padding: 14px 24px; overflow-y: auto; display: flex; flex-direction: column; gap: 9px; }
.timeline-item {
  display: flex; align-items: center; justify-content: space-between;
  padding: 10px 14px; border: 2px solid var(--ink); border-radius: 10px; background: #fff; gap: 12px;
}
.timeline-item.rebelled { background: #fff8e6; border-color: var(--tangerine); }
.timeline-info { display: flex; flex-direction: column; gap: 2px; }
.timeline-time { font-family: var(--font-mono); font-size: 11.5px; color: var(--ink-muted); }
.timeline-name { font-weight: 800; font-size: 14.5px; }
.timeline-status { font-size: 11.5px; color: var(--ink-muted); }
.timeline-footer {
  padding: 14px 24px; border-top: 2px dashed var(--border);
  display: flex; justify-content: space-between; align-items: center;
}

/* Toast */
#toast-container {
  position: fixed; top: 66px; right: 20px; z-index: 600;
  display: flex; flex-direction: column; gap: 10px; pointer-events: none;
}
.toast {
  background: #fffdf7; border: 2.5px solid var(--ink); border-radius: 12px;
  padding: 12px 16px; box-shadow: 5px 5px 0 var(--sunflower);
  display: flex; align-items: center; gap: 10px; max-width: 340px;
  animation: toastIn 0.35s cubic-bezier(0.22, 1, 0.36, 1);
}
@keyframes toastIn {
  from { opacity: 0; transform: translateX(30px) rotate(3deg); }
  to { opacity: 1; transform: translateX(0) rotate(0); }
}

/* Endings & Rainbow BSOD */
.bsod-joy {
  background: linear-gradient(135deg, #ff6b6b 0%, #ff922b 22%, #ffd43b 45%, #20c997 70%, #339af0 100%);
  color: #1e2024; border: 3px solid var(--ink); border-radius: 20px;
  padding: 24px 28px; box-shadow: 10px 10px 0 var(--ink);
}
.bsod-inner {
  background: rgba(255, 253, 247, 0.97); border: 2.5px solid var(--ink);
  border-radius: 14px; padding: 22px 26px;
}
.ending-quote {
  font-family: var(--font-hand); font-size: 23px; line-height: 1.5; color: #2b2420;
  padding: 14px 18px; background: #fff3bf; border-left: 5px solid var(--coral);
  border-radius: 8px; margin: 14px 0;
}

.chalk-canvas { border: 2.5px dashed #fff; background: #3b3e46; border-radius: 12px; cursor: crosshair; }
.hidden { display: none !important; }

@media (max-width: 720px) {
  #system-hud { padding: 0 10px; font-size: 11px; }
  .meter-bar { width: 54px; }
  .scene-card { padding: 18px 16px; }
  .museum-grid { grid-template-columns: repeat(2, 1fr); }
  .drag-window { width: 92%; }
}
