/* ═══════════════════════════════════════════════════════════════
   x402 ORIGINS: THE PAYMENT QUEST
   Mac OS 8 Chrome + Game UI
   ═══════════════════════════════════════════════════════════════ */

/* ─── 1. TOKENS ─── */

:root {
  --platinum: #c0c0c0;
  --platinum-light: #dfdfdf;
  --platinum-lighter: #eeeeee;
  --platinum-dark: #808080;
  --platinum-darker: #404040;
  --desktop-bg: #5583a4;
  --desktop-bg-alt: #3d6d8e;
  --window-bg: #ffffff;
  --titlebar-from: #6677cc;
  --titlebar-to: #2a3a88;
  --text: #000000;
  --text-dim: #666666;
  --accent: #0052ff;
  --error-red: #cc0000;
  --success-green: #008800;
  --gold: #ffd700;
  --term-bg: #0d1117;
  --term-fg: #c9d1d9;
  --term-muted: #8b949e;
  --term-command: #f0f6fc;
  --term-key: #79c0ff;
  --term-string: #a5d6ff;
  --term-number: #d2a8ff;
  --term-error: #ff7b72;
  --term-success: #7ee787;
  --term-payment: #e3b341;
  --term-separator: #30363d;
  --font-system: 'Silkscreen', monospace;
  --font-doc: 'IBM Plex Mono', 'Geneva', monospace;
  --font-term: 'VT323', monospace;
  --font-mono: 'Space Mono', monospace;
  --menubar-h: 26px;
  --titlebar-h: 22px;
}


/* ─── 2. RESET ─── */

*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }
body {
  background: #1a1a1a;
  overflow: hidden;
  -webkit-font-smoothing: none;
  -moz-osx-font-smoothing: unset;
}
::selection { background: #336; color: #fff; }


/* ─── 3. GAME CONTAINER ─── */

#game {
  width: 100vw;
  height: 100vh;
  height: 100dvh;
  position: relative;
  overflow: hidden;
  font-family: var(--font-system);
  font-size: 12px;
  color: var(--text);
  image-rendering: pixelated;
  touch-action: manipulation;
  -webkit-tap-highlight-color: transparent;
}


/* ─── 4. DESKTOP ─── */

.desktop {
  position: absolute;
  inset: 0;
  background:
    linear-gradient(170deg, var(--desktop-bg) 0%, var(--desktop-bg-alt) 100%);
  padding-top: var(--menubar-h);
}

.desktop-icons {
  position: absolute;
  top: calc(var(--menubar-h) + 20px);
  right: 24px;
  display: flex;
  flex-direction: column;
  gap: 28px;
  align-items: center;
  z-index: 2;
}


/* ─── 5. MENU BAR ─── */

.menubar {
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  height: var(--menubar-h);
  background: linear-gradient(180deg, #f0ece4 0%, #d8d4cc 100%);
  border-bottom: 1px solid var(--platinum-dark);
  box-shadow: 0 1px 0 rgba(255,255,255,0.45) inset;
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 0.75rem;
  z-index: 300;
  font-family: var(--font-doc);
  font-size: 0.75rem;
  font-weight: 500;
  color: #000;
  user-select: none;
}

.menubar-left {
  display: flex;
  align-items: center;
  gap: 0;
}

.menubar-logo {
  width: 14px;
  height: 14px;
  background: var(--accent);
  border-radius: 50%;
  flex-shrink: 0;
  margin-right: 0.625rem;
}

.menubar-item {
  cursor: default;
  padding: 0.125rem 0.625rem;
  border-radius: 3px;
  white-space: nowrap;
}
.menubar-item:hover { background: var(--accent); color: #fff; }
.menubar-item.bold { font-weight: 700; }

.menubar-right {
  display: flex;
  align-items: center;
  gap: 1rem;
  color: #555;
  font-family: var(--font-doc);
  font-size: 0.6875rem;
}

.menubar-clock {
  letter-spacing: 0.5px;
  font-variant-numeric: tabular-nums;
}

.menubar-mute {
  cursor: pointer;
  font-size: 13px;
  padding: 1px 5px;
  border-radius: 2px;
  color: var(--text);
  transition: opacity 0.15s;
  position: relative;
}
.menubar-mute:hover { background: var(--accent); color: #fff; }
.menubar-mute.muted { opacity: 0.45; }
.menubar-mute.muted::after {
  content: '';
  position: absolute;
  top: 50%;
  left: 2px;
  right: 2px;
  height: 1px;
  background: var(--text);
  transform: rotate(-20deg);
}


/* ─── 6. DESKTOP ICONS ─── */

.icon {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 4px;
  cursor: pointer;
  padding: 4px;
  border-radius: 2px;
  transition: background 0.1s;
}
.icon:hover { background: rgba(255,255,255,0.15); }
.icon:active { background: rgba(0,0,0,0.1); }
.icon.disabled {
  opacity: 0.4;
  cursor: not-allowed;
  pointer-events: none;
}
.icon.pulse .icon-img {
  animation: iconPulse 1.2s ease-in-out infinite;
  will-change: transform, box-shadow;
}

.icon-img {
  width: 48px;
  height: 48px;
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: 4px;
  position: relative;
}

.icon-label {
  font-family: var(--font-system);
  font-size: 10px;
  color: #fff;
  text-shadow: 0 1px 2px rgba(0,0,0,0.7);
  text-align: center;
  max-width: 80px;
  word-break: break-word;
  line-height: 1.3;
}


/* ─── 6b. AGENT SPRITE ─── */

.agent {
  position: absolute;
  top: auto;
  bottom: 32px;
  left: 32px;
  width: 48px;
  height: 72px;
  image-rendering: pixelated;
  z-index: 350;
  pointer-events: none;
  transition: opacity 0.3s ease;
}
.agent.hidden { opacity: 0; pointer-events: none; }

.agent.moving {
  transition: top 0.5s cubic-bezier(.4,0,.2,1), left 0.5s cubic-bezier(.4,0,.2,1), opacity 0.3s ease;
  bottom: auto;
}
.agent.facing-right .agent-body { transform: translateX(-50%) scaleX(1); }
.agent.facing-left .agent-body { transform: translateX(-50%) scaleX(-1); }

.agent-body {
  position: absolute;
  bottom: 0;
  left: 50%;
  transform: translateX(-50%);
  width: 36px;
  height: 52px;
  animation: agentBob 1.8s ease-in-out infinite;
}

/* ── walking ── */
.agent.walking .agent-body { animation: agentWalk 0.45s ease-in-out infinite; }
.agent.walking .agent-leg--l { animation: agentLegL 0.45s ease-in-out infinite; }
.agent.walking .agent-leg--r { animation: agentLegR 0.45s ease-in-out infinite; }

/* ── head ── */
.agent-head {
  position: absolute;
  top: 0;
  left: 50%;
  transform: translateX(-50%);
  width: 20px;
  height: 16px;
  background: #0052FF;
  border: 2px solid #003ecb;
  border-radius: 4px 4px 2px 2px;
}

.agent-eye {
  position: absolute;
  top: 5px;
  right: 4px;
  width: 4px;
  height: 4px;
  background: #fff;
  animation: agentBlink 3s steps(1) infinite;
}

.agent-mouth {
  position: absolute;
  bottom: 2px;
  right: 5px;
  width: 6px;
  height: 0;
  border-bottom: 2px solid rgba(255,255,255,0.4);
  border-radius: 0 0 2px 2px;
  transition: height 0.2s, width 0.2s;
}

/* ── torso ── */
.agent-torso {
  position: absolute;
  top: 16px;
  left: 50%;
  transform: translateX(-50%);
  width: 16px;
  height: 14px;
  background: #0052FF;
  border: 2px solid #003ecb;
  border-radius: 2px;
}

/* ── arms ── */
.agent-arm {
  position: absolute;
  top: 18px;
  width: 4px;
  height: 12px;
  background: #003ecb;
  border-radius: 2px;
  transform-origin: top center;
  transition: transform 0.3s ease, height 0.3s ease;
}
.agent-arm--l { left: 2px;  transform: rotate(8deg); }
.agent-arm--r { right: 2px; transform: rotate(-8deg); }

.agent-hand {
  position: absolute;
  bottom: -2px;
  left: 50%;
  transform: translateX(-50%);
  width: 5px;
  height: 4px;
  background: #4D8DFF;
  border-radius: 50%;
}

/* ── briefcase on right arm by default ── */
.agent-case {
  position: absolute;
  bottom: -8px;
  left: 50%;
  transform: translateX(-50%);
  width: 10px;
  height: 8px;
  background: #8B6914;
  border: 1px solid #6B4F10;
  border-radius: 1px;
  transition: opacity 0.2s;
}
.agent-case::after {
  content: '';
  position: absolute;
  top: -2px;
  left: 3px;
  width: 4px;
  height: 3px;
  border: 1px solid #6B4F10;
  border-bottom: none;
  border-radius: 2px 2px 0 0;
}
/* default: case on right arm only */
.agent-case.on-left { display: none; }
.agent.case-left .agent-case.on-left { display: block; }
.agent.case-left .agent-case.on-right { display: none; }

/* ── legs ── */
.agent-legs {
  position: absolute;
  bottom: 0;
  left: 50%;
  transform: translateX(-50%);
  width: 14px;
  height: 16px;
}

.agent-leg {
  position: absolute;
  bottom: 0;
  width: 4px;
  height: 16px;
  background: #003ecb;
  border-radius: 0 0 2px 2px;
}
.agent-leg--l { left: 0; }
.agent-leg--r { right: 0; }

.agent-knee {
  position: absolute;
  top: 7px;
  left: 50%;
  transform: translateX(-50%);
  width: 6px;
  height: 4px;
  background: #4D8DFF;
  border: 1px solid #003ecb;
  border-radius: 2px;
}

/* feet */
.agent-foot {
  position: absolute;
  bottom: -1px;
  left: -1px;
  width: 6px;
  height: 3px;
  background: #002299;
  border-radius: 1px 1px 2px 2px;
}

/* ── bubble ── */
.agent-bubble {
  position: absolute;
  top: -22px;
  left: 50%;
  transform: translateX(-50%);
  font-family: var(--font-system);
  font-size: 14px;
  color: #fff;
  text-shadow: 0 1px 2px rgba(0,0,0,0.5);
  opacity: 0;
  transition: opacity 0.3s ease;
  white-space: nowrap;
}
.agent-bubble.visible { opacity: 1; }


/* ─── 6c. AGENT EMOTIONS ─── */

/* yawn/stretch: arms go up, mouth opens */
.agent.yawning .agent-arm--l { transform: rotate(-140deg); height: 14px; }
.agent.yawning .agent-arm--r { transform: rotate(140deg); height: 14px; }
.agent.yawning .agent-mouth { height: 4px; width: 5px; border-radius: 50%; border-bottom-width: 3px; }
.agent.yawning .agent-body { animation: agentStretch 1.2s ease-in-out; }

/* confused: head tilts */
.agent.confused .agent-head { transform: translateX(-50%) rotate(-8deg); }
.agent.confused .agent-arm--l { transform: rotate(-30deg); }

/* surprised: arms fly up */
.agent.surprised .agent-arm--l { transform: rotate(-80deg); height: 10px; }
.agent.surprised .agent-arm--r { transform: rotate(80deg); height: 10px; }
.agent.surprised .agent-eye { width: 5px; height: 5px; }

/* happy: arms slightly out, relaxed */
.agent.happy .agent-arm--l { transform: rotate(-25deg); }
.agent.happy .agent-arm--r { transform: rotate(25deg); }
.agent.happy .agent-mouth { border-bottom-color: #fff; height: 3px; width: 6px; }

/* annoyed: flip upside-down, stomp and wave */
.agent.annoyed .agent-body {
  animation: agentTantrum 0.55s ease-in-out infinite;
  transform-origin: center center;
}
.agent.annoyed .agent-arm--l { animation: agentWaveL 0.25s ease-in-out infinite alternate; }
.agent.annoyed .agent-arm--r { animation: agentWaveR 0.25s ease-in-out infinite alternate; }
.agent.annoyed .agent-leg--l { animation: agentStompL 0.35s ease-in-out infinite; }
.agent.annoyed .agent-leg--r { animation: agentStompR 0.35s ease-in-out infinite; }

/* case swap: hide on right, show on left */
.agent.case-left .agent-arm--r .agent-case { display: none; }
.agent.case-left .agent-arm--l .agent-case { display: block; }


/* ─── 6d. AGENT KEYFRAMES ─── */

@keyframes agentBob {
  0%, 100% { transform: translateX(-50%) translateY(0); }
  50% { transform: translateX(-50%) translateY(-3px); }
}

@keyframes agentStretch {
  0% { transform: translateX(-50%) translateY(0) scaleY(1); }
  30% { transform: translateX(-50%) translateY(-6px) scaleY(1.08); }
  60% { transform: translateX(-50%) translateY(-4px) scaleY(1.04); }
  100% { transform: translateX(-50%) translateY(0) scaleY(1); }
}

@keyframes agentWalk {
  0% { transform: translateX(-50%) translateY(0); }
  50% { transform: translateX(-50%) translateY(-4px); }
}

@keyframes agentLegL {
  0% { transform: translateX(0) rotate(0); }
  50% { transform: translateX(-3px) rotate(-12deg); }
}
@keyframes agentLegR {
  0% { transform: translateX(0) rotate(0); }
  50% { transform: translateX(3px) rotate(12deg); }
}

@keyframes agentTantrum {
  0% { transform: translateX(-50%) rotate(180deg) translateY(2px); }
  50% { transform: translateX(-50%) rotate(180deg) translateY(-3px); }
}

@keyframes agentWaveL {
  from { transform: rotate(-120deg); }
  to { transform: rotate(-40deg); }
}
@keyframes agentWaveR {
  from { transform: rotate(40deg); }
  to { transform: rotate(120deg); }
}

@keyframes agentStompL {
  0% { transform: translateY(0); }
  50% { transform: translateY(-4px); }
}
@keyframes agentStompR {
  0% { transform: translateY(-4px); }
  50% { transform: translateY(0); }
}

@keyframes agentBlink {
  0%, 85% { opacity: 1; }
  86%, 92% { opacity: 0; }
  93%, 100% { opacity: 1; }
}


/* ─── 7. ICON GRAPHICS (SVG/CSS) ─── */

.icon-floppy {
  background: linear-gradient(180deg, #b0b0b0 0%, #888 100%);
  border: 2px solid #666;
  border-radius: 3px;
  box-shadow: inset 0 1px 0 rgba(255,255,255,0.3);
}
.icon-floppy::before {
  content: '';
  position: absolute;
  top: 3px;
  left: 50%;
  transform: translateX(-50%);
  width: 18px;
  height: 10px;
  background: #666;
  border-radius: 1px;
}
.icon-floppy::after {
  content: '';
  position: absolute;
  bottom: 4px;
  left: 50%;
  transform: translateX(-50%);
  width: 22px;
  height: 14px;
  background: #f0f0f0;
  border: 1px solid #aaa;
  border-radius: 2px;
  box-shadow: inset 0 0 0 2px #ddd, inset 6px 0 0 #ccc;
}

.icon-folder {
  background: linear-gradient(180deg, #f0d860 0%, #d4a820 100%);
  border: 2px solid #b89018;
  border-radius: 2px 6px 4px 4px;
  position: relative;
  box-shadow:
    inset 0 1px 0 rgba(255,255,255,0.4),
    inset 0 -1px 0 rgba(0,0,0,0.1);
}
.icon-folder::before {
  content: '';
  position: absolute;
  top: -7px;
  left: 3px;
  width: 20px;
  height: 8px;
  background: linear-gradient(180deg, #e8c030 0%, #d4a820 100%);
  border: 2px solid #b89018;
  border-bottom: none;
  border-radius: 4px 4px 0 0;
}

.icon-trash {
  background: linear-gradient(180deg, #e0e0e0 0%, #c0c0c0 100%);
  border: 2px solid #999;
  border-radius: 2px 2px 4px 4px;
  width: 36px !important;
  height: 44px !important;
  box-shadow: inset 0 1px 0 rgba(255,255,255,0.5);
}
.icon-trash::before {
  content: '';
  position: absolute;
  top: -6px;
  left: 50%;
  transform: translateX(-50%);
  width: 30px;
  height: 5px;
  background: linear-gradient(180deg, #d0d0d0 0%, #aaa 100%);
  border: 1px solid #999;
  border-radius: 2px;
}
.icon-trash::after {
  content: '';
  position: absolute;
  top: 6px;
  left: 50%;
  transform: translateX(-50%);
  width: 2px;
  height: 22px;
  background: #999;
  box-shadow: -6px 0 0 #999, 6px 0 0 #999;
}

.icon-globe {
  background: radial-gradient(circle at 35% 35%, #88bbee, #2255aa 60%, #113366);
  border: 2px solid #1a4477;
  border-radius: 50%;
  box-shadow: inset -2px -2px 4px rgba(0,0,0,0.3), inset 2px 2px 4px rgba(255,255,255,0.2);
}
.icon-globe::before {
  content: '';
  position: absolute;
  top: 50%;
  left: 2px;
  right: 2px;
  height: 1px;
  background: rgba(255,255,255,0.25);
  box-shadow: 0 -8px 0 rgba(255,255,255,0.15), 0 8px 0 rgba(255,255,255,0.15);
}
.icon-globe::after {
  content: '';
  position: absolute;
  top: 2px;
  bottom: 2px;
  left: 50%;
  width: 18px;
  transform: translateX(-50%);
  border: 1px solid rgba(255,255,255,0.2);
  border-radius: 50%;
}

.icon-doc {
  background: linear-gradient(180deg, #fff 0%, #f0f0f0 100%);
  border: 2px solid #999;
  border-radius: 2px;
  box-shadow: inset 0 0 0 1px rgba(255,255,255,0.5);
}
.icon-doc::before {
  content: '';
  position: absolute;
  top: 0;
  right: 0;
  width: 0;
  height: 0;
  border-style: solid;
  border-width: 0 12px 12px 0;
  border-color: transparent var(--platinum) transparent transparent;
  filter: drop-shadow(-1px 1px 0 #999);
}
.icon-doc::after {
  content: '';
  position: absolute;
  top: 16px;
  left: 6px;
  right: 6px;
  height: 2px;
  background: #ccc;
  box-shadow: 0 4px 0 #ccc, 0 8px 0 #ccc, 0 12px 0 #ddd;
}

.icon-app {
  background: linear-gradient(135deg, #1a6dff 0%, var(--accent) 50%, #003ecb 100%);
  border: 2px solid #002299;
  border-radius: 10px;
  box-shadow:
    inset 0 1px 0 rgba(255,255,255,0.3),
    inset 0 -1px 0 rgba(0,0,0,0.2),
    0 2px 4px rgba(0,0,0,0.3);
}
.icon-app::before {
  content: '';
  position: absolute;
  top: 3px;
  left: 3px;
  right: 3px;
  height: 40%;
  background: linear-gradient(180deg, rgba(255,255,255,0.25), transparent);
  border-radius: 8px 8px 50% 50%;
}
.icon-app::after {
  content: '402';
  color: #fff;
  font-family: var(--font-system);
  font-size: 12px;
  font-weight: 700;
  text-shadow: 0 1px 2px rgba(0,0,0,0.4);
  letter-spacing: 1px;
}


/* ─── 8. WINDOW CHROME ─── */

.window {
  position: absolute;
  background: var(--platinum);
  border-top: 2px solid #fff;
  border-left: 2px solid #fff;
  border-right: 2px solid #555;
  border-bottom: 2px solid #555;
  box-shadow: 3px 3px 12px rgba(0,0,0,0.35);
  z-index: 10;
  display: flex;
  flex-direction: column;
  min-width: 280px;
  opacity: 0;
  transform: scale(0.96);
  transition: opacity 0.2s ease, transform 0.2s ease;
  will-change: opacity, transform;
}
.window.open {
  opacity: 1;
  transform: scale(1);
}
.window.closing {
  opacity: 0;
  transform: scale(0.96);
  transition: opacity 0.15s ease, transform 0.15s ease;
}

.window-titlebar {
  height: var(--titlebar-h);
  display: flex;
  align-items: center;
  padding: 0 6px;
  gap: 6px;
  background:
    repeating-linear-gradient(
      180deg,
      transparent 0,
      transparent 1px,
      rgba(255,255,255,0.18) 1px,
      rgba(255,255,255,0.18) 2px
    ),
    linear-gradient(180deg, var(--titlebar-from), var(--titlebar-to));
  border-bottom: 1px solid var(--platinum-dark);
  flex-shrink: 0;
  user-select: none;
}

.window-close {
  width: 13px;
  height: 11px;
  border: 1px solid rgba(0,0,0,0.5);
  background: var(--platinum-light);
  flex-shrink: 0;
  cursor: pointer;
  border-radius: 1px;
  position: relative;
}
.window-close::after {
  content: '';
  position: absolute;
  top: 2px;
  left: 5px;
  width: 1px;
  height: 7px;
  background: #333;
  transform: rotate(45deg);
}
.window-close::before {
  content: '';
  position: absolute;
  top: 2px;
  left: 5px;
  width: 1px;
  height: 7px;
  background: #333;
  transform: rotate(-45deg);
}
.window-close:hover { background: var(--platinum-lighter); }
.window-close:active { background: var(--platinum); }

.window-title {
  flex: 1;
  text-align: center;
  font-family: var(--font-system);
  font-size: 11px;
  font-weight: 700;
  color: #fff;
  text-shadow: 0 1px 1px rgba(0,0,0,0.6);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.window-body {
  flex: 1;
  background: var(--window-bg);
  border-top: 1px solid var(--platinum-dark);
  border-left: 1px solid var(--platinum-dark);
  border-right: 1px solid #fff;
  border-bottom: 1px solid #fff;
  margin: 3px;
  overflow: auto;
  position: relative;
}


/* ─── 9. WINDOW VARIANT: DOCUMENT (SimpleText) ─── */

.window--document .window-body {
  padding: 12px 16px;
  font-family: var(--font-doc);
  font-size: 13px;
  line-height: 1.65;
  white-space: pre-wrap;
  color: var(--text);
}


/* ─── 10. WINDOW VARIANT: FINDER ─── */

.window--finder .window-body {
  padding: 16px;
  display: flex;
  gap: 32px;
  flex-wrap: wrap;
  justify-content: flex-start;
  align-items: flex-start;
  background: #fff;
}

.finder-item {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 4px;
  cursor: pointer;
  padding: 8px;
  border-radius: 3px;
  width: 80px;
  text-align: center;
}
.finder-item:hover { background: #ddeeff; }
.finder-item:active { background: #bbccee; }
.finder-item.disabled {
  opacity: 0.35;
  cursor: not-allowed;
}
.finder-item.disabled:hover { background: transparent; }
.finder-item.visited { opacity: 0.55; }
.finder-item.visited .finder-label::after { content: ' ✓'; color: var(--success-green); font-weight: 700; }

.folder-footer {
  width: 100%;
  padding: 8px 16px 4px;
  display: flex;
  justify-content: flex-end;
  border-top: 1px solid #ddd;
  margin-top: 8px;
}

.finder-icon {
  width: 40px;
  height: 40px;
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: 3px;
  position: relative;
}

.finder-label {
  font-family: var(--font-system);
  font-size: 10px;
  line-height: 1.3;
  word-break: break-word;
}


/* ─── 11. WINDOW VARIANT: BROWSER ─── */

.window--browser .window-toolbar {
  background: var(--platinum-light);
  border-bottom: 1px solid var(--platinum-dark);
  padding: 4px 8px;
  display: flex;
  gap: 8px;
  font-family: var(--font-system);
  font-size: 10px;
}

.browser-btn {
  padding: 2px 8px;
  background: var(--platinum);
  border-top: 1px solid #fff;
  border-left: 1px solid #fff;
  border-right: 1px solid #888;
  border-bottom: 1px solid #888;
  cursor: default;
  color: var(--text-dim);
}

.window--browser .window-urlbar {
  background: #fff;
  border-top: 1px solid #888;
  border-left: 1px solid #888;
  border-right: 1px solid #fff;
  border-bottom: 1px solid #fff;
  margin: 3px 6px;
  padding: 3px 6px;
  font-family: var(--font-doc);
  font-size: 12px;
  color: var(--text);
  display: flex;
  align-items: center;
  gap: 6px;
}

.urlbar-label {
  font-family: var(--font-system);
  font-size: 10px;
  color: var(--text-dim);
  flex-shrink: 0;
}

.urlbar-text {
  flex: 1;
  white-space: nowrap;
  overflow: hidden;
}

.window--browser .window-body {
  font-family: var(--font-doc);
  font-size: 13px;
  line-height: 1.6;
  padding: 16px;
  color: var(--text);
}

.browser-link {
  color: #0000cc;
  text-decoration: underline;
  cursor: pointer;
}
.browser-link:hover { color: #cc0000; }
.browser-link.pulse {
  display: inline-block;
  animation: linkPulse 1s ease-in-out infinite;
  will-change: transform, text-shadow;
}
.browser-link.dead {
  color: #999;
  text-decoration: line-through;
  cursor: default;
}

.status-tag {
  display: inline-block;
  font-size: 10px;
  font-family: var(--font-system);
  padding: 1px 6px;
  border-radius: 2px;
  margin-left: 6px;
}
.status-tag.ok { background: #dfd; color: #060; }
.status-tag.err { background: #fdd; color: #900; }
.status-tag.pay { background: #ffd; color: #960; }


/* ─── 12. WINDOW VARIANT: TERMINAL ─── */

.window--terminal .window-titlebar {
  background:
    repeating-linear-gradient(
      180deg,
      transparent 0,
      transparent 1px,
      rgba(77,141,255,0.1) 1px,
      rgba(77,141,255,0.1) 2px
    ),
    linear-gradient(180deg, #1a2844, #0d1626);
}

.window--terminal .window-body {
  background: var(--term-bg);
  padding: 12px 16px;
  font-family: var(--font-term);
  font-size: 18px;
  line-height: 1.5;
  color: var(--term-fg);
}

/* ─── WINDOW VARIANT: IRC ─── */

.window--irc .window-titlebar {
  background:
    repeating-linear-gradient(180deg, transparent 0, transparent 1px, rgba(255,255,255,0.1) 1px, rgba(255,255,255,0.1) 2px),
    linear-gradient(180deg, #5a3a7a, #2d1a4a);
}
.window--irc .window-body {
  background: #1a0a2a;
  padding: 12px 16px;
  font-family: var(--font-doc);
  font-size: 13px;
  line-height: 1.6;
  color: #ccc;
}
.irc-system { color: #666; font-style: italic; }
.irc-nick { font-weight: 700; }
.irc-nick.self { color: #4d8dff; }
.irc-nick.crawl { color: #ff8844; }
.irc-nick.indexer { color: #44cc44; }
.irc-nick.mystery { color: #ffd700; }
.irc-msg { color: #ddd; }

/* ─── WINDOW VARIANT: MAP ─── */

.window--map .window-body {
  background: #f8f4e8;
  padding: 20px;
  font-family: var(--font-doc);
  font-size: 12px;
  line-height: 1.5;
  color: var(--text);
}
.map-node {
  display: inline-block;
  border: 2px solid #999;
  background: #fff;
  padding: 8px 14px;
  border-radius: 4px;
  margin: 6px;
  cursor: pointer;
  font-family: var(--font-system);
  font-size: 11px;
  transition: border-color 0.2s, background 0.2s;
}
.map-node:hover { border-color: var(--accent); background: #eef4ff; }
.map-node.visited { border-color: #ccc; background: #eee; color: #999; cursor: default; }
.map-node.visited::after { content: ' ✗'; color: var(--error-red); }
.map-result {
  margin-top: 8px;
  padding: 8px 12px;
  background: #fff8e0;
  border-left: 3px solid #cc8800;
  font-size: 12px;
  line-height: 1.5;
  animation: fadeInUp 0.3s ease;
}

.term-cmd,
.term-command { color: var(--term-command); }
.term-output { color: var(--term-fg); }
.term-comment { color: var(--term-muted); font-style: normal; }
.term-separator { color: var(--term-separator); }
.term-402 { color: var(--term-error); }
.term-200 { color: var(--term-success); }
.term-key,
.term-json-key { color: var(--term-key); }
.term-val,
.term-json-string { color: var(--term-string); }
.term-json-number { color: var(--term-number); }
.term-gold,
.term-payment { color: var(--term-payment); }
.term-prompt { color: var(--term-muted); }


/* ─── 13. DIALOG ─── */

.dialog-overlay {
  position: absolute;
  inset: 0;
  background: rgba(0,0,0,0.3);
  z-index: 100;
  display: flex;
  align-items: center;
  justify-content: center;
  animation: fadeIn 0.2s ease;
}

.dialog {
  position: relative;
  background: var(--platinum-light);
  border-top: 2px solid #fff;
  border-left: 2px solid #fff;
  border-right: 2px solid #555;
  border-bottom: 2px solid #555;
  box-shadow: 4px 4px 16px rgba(0,0,0,0.4);
  padding: 20px 24px;
  max-width: 420px;
  width: 90%;
  display: flex;
  gap: 16px;
  align-items: flex-start;
}

.dialog-icon {
  font-size: 32px;
  flex-shrink: 0;
  line-height: 1;
}

.dialog-content {
  flex: 1;
}

.dialog-title {
  font-family: var(--font-system);
  font-size: 13px;
  font-weight: 700;
  margin-bottom: 8px;
}

.dialog-text {
  font-family: var(--font-doc);
  font-size: 12px;
  line-height: 1.5;
  margin-bottom: 16px;
  color: #333;
}

.dialog-buttons {
  display: flex;
  gap: 8px;
  justify-content: flex-end;
}

.dialog-close {
  position: absolute;
  top: 8px;
  left: 8px;
  width: 14px;
  height: 14px;
  border: 1px solid #888;
  background: var(--platinum);
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 9px;
  line-height: 1;
  color: #555;
  padding: 0;
}
.dialog-close:hover { background: #ddd; }


/* ─── 14. BUTTONS ─── */

.btn {
  font-family: var(--font-system);
  font-size: 12px;
  padding: 5px 20px;
  background: var(--platinum);
  border-top: 2px solid #fff;
  border-left: 2px solid #fff;
  border-right: 2px solid #555;
  border-bottom: 2px solid #555;
  cursor: pointer;
  color: var(--text);
  white-space: nowrap;
}
.btn:active {
  border-top-color: #555;
  border-left-color: #555;
  border-right-color: #fff;
  border-bottom-color: #fff;
}
.btn:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
}
.btn--default {
  outline: 3px solid #000;
  outline-offset: -1px;
  animation: btnPulse 2s ease-in-out infinite;
}

.btn--primary {
  background: var(--accent);
  color: #fff;
  border-top-color: #4d8dff;
  border-left-color: #4d8dff;
  border-right-color: #002299;
  border-bottom-color: #002299;
}
.btn--primary:active {
  border-top-color: #002299;
  border-left-color: #002299;
  border-right-color: #4d8dff;
  border-bottom-color: #4d8dff;
}

.btn--cta {
  font-size: 14px;
  padding: 10px 32px;
  border-radius: 2px;
}


/* ─── 15. NARRATION BAR ─── */

.narration {
  position: absolute;
  bottom: 20px;
  left: 50%;
  transform: translateX(-50%);
  background: rgba(0,0,0,0.82);
  color: #eee;
  font-family: var(--font-doc);
  font-size: 14px;
  line-height: 1.6;
  padding: 12px 24px;
  border-radius: 6px;
  max-width: 560px;
  width: 90%;
  z-index: 200;
  backdrop-filter: blur(4px);
  box-shadow: 0 4px 24px rgba(0,0,0,0.4);
  opacity: 0;
  transition: opacity 0.3s ease;
  will-change: opacity;
}
.narration.visible { opacity: 1; }

.narration-line {
  min-height: 1.6em;
}
.narration-line::before {
  content: '> ';
  color: var(--accent);
  font-weight: 700;
}


/* ─── 16. BOOT SCREEN ─── */

.boot-overlay {
  position: absolute;
  inset: 0;
  background: #000;
  z-index: 500;
  display: flex;
  flex-direction: column;
  justify-content: center;
  padding: 10vh 10vw;
  font-family: var(--font-term);
  font-size: 20px;
  line-height: 1.6;
  color: #33ff66;
  overflow: hidden;
}

.boot-text div {
  white-space: pre;
  min-height: 1.6em;
}
.boot-text .boot-ok { color: #33ff66; }
.boot-text .boot-warn { color: #ffaa00; }
.boot-text .boot-ready { color: #fff; font-weight: bold; }

.boot-cursor {
  display: inline-block;
  width: 0.6em;
  height: 1.1em;
  background: #33ff66;
  vertical-align: text-bottom;
  animation: blink 0.6s step-end infinite;
}


/* ─── 17. TIME JUMP OVERLAY ─── */

.timejump-overlay {
  position: absolute;
  inset: 0;
  background: #000;
  z-index: 400;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-direction: column;
  overflow: hidden;
}

.timejump-bar {
  position: absolute;
  left: 0;
  width: 100%;
  height: 3px;
  background: rgba(255,255,255,0.15);
  animation: timejumpBar 0.2s linear infinite;
  z-index: 3;
  pointer-events: none;
}

@keyframes timejumpBar {
  0% { top: -3px; }
  100% { top: 100%; }
}

.timejump-chromatic {
  text-shadow:
    -2px 0 #ff0044,
    2px 0 #00ccff;
}

.timejump-date {
  font-family: var(--font-term);
  font-size: clamp(48px, 10vw, 96px);
  color: #fff;
  text-align: center;
  z-index: 1;
  will-change: transform;
}

.timejump-glitch {
  animation: vhsGlitch 0.15s steps(2) infinite;
}

.timejump-scanlines {
  position: absolute;
  inset: 0;
  background: repeating-linear-gradient(
    0deg,
    transparent 0,
    transparent 2px,
    rgba(255,255,255,0.03) 2px,
    rgba(255,255,255,0.03) 4px
  );
  pointer-events: none;
  z-index: 2;
}

.timejump-text {
  font-family: var(--font-doc);
  font-size: clamp(14px, 2.5vw, 18px);
  color: #aaa;
  text-align: center;
  margin-top: 24px;
  z-index: 1;
  opacity: 0;
  transition: opacity 0.6s ease;
}
.timejump-text.visible { opacity: 1; }


/* ─── 18. FINALE ─── */

.finale-overlay {
  position: absolute;
  inset: 0;
  background: #060810;
  z-index: 400;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: 10vh 8vw;
  text-align: center;
  opacity: 0;
  transition: opacity 0.8s ease;
}
.finale-overlay.visible { opacity: 1; }

.finale-headline {
  font-family: var(--font-mono);
  font-size: clamp(calc(18px * 0.85), calc(3.5vw * 0.85), calc(32px * 0.85));
  line-height: 1.6;
  color: #fff;
  max-width: 720px;
  margin-bottom: 40px;
}

.finale-headline em {
  font-style: normal;
  color: var(--accent);
}

.finale-sub {
  font-family: var(--font-doc);
  font-size: clamp(12px, 2vw, 16px);
  color: #888;
  max-width: 640px;
  line-height: 1.5;
  margin-bottom: 48px;
}

.finale-buttons {
  display: flex;
  gap: 16px;
  flex-wrap: wrap;
  justify-content: center;
}

.finale-replay {
  margin-top: 28px;
  background: none;
  border: none;
  color: #666;
  font-family: var(--font-mono);
  font-size: 22px;
  cursor: pointer;
  text-decoration: underline;
  text-underline-offset: 3px;
  display: block;
  text-align: center;
}
.finale-replay:hover { color: #aaa; }


/* ─── 19. TYPEWRITER CURSOR ─── */

.tw-cursor {
  display: inline-block;
  width: 0.55em;
  height: 1.05em;
  background: currentColor;
  vertical-align: text-bottom;
  margin-left: 1px;
  animation: blink 0.6s step-end infinite;
}


/* ─── 20. HIGHLIGHTED TEXT ─── */

.highlight {
  background: rgba(255,215,0,0.25);
  color: #000;
  padding: 2px 4px;
  border-radius: 2px;
}

.highlight-strong {
  background: rgba(255,215,0,0.4);
  color: #000;
  padding: 2px 6px;
  border-radius: 2px;
  font-weight: 700;
}

.text-gold { color: var(--gold); }
.text-green { color: var(--success-green); }
.text-red { color: var(--error-red); }
.text-dim { color: #999; }
.text-accent { color: var(--accent); }
.paragraph-break {
  min-height: 1.2em;
}


/* ─── 21. JSON FORMATTING (in browser/terminal) ─── */

.json-block {
  font-family: var(--font-doc);
  font-size: 12px;
  line-height: 1.5;
  white-space: pre;
  background: #f5f5f0;
  border: 1px solid #ddd;
  padding: 12px;
  margin: 8px 0;
  border-radius: 2px;
  overflow-x: auto;
}

.json-key { color: #8a2be2; }
.json-str { color: #a31515; }
.json-num { color: #098658; }


/* ─── 22. SAD MAC ─── */

.sadmac-overlay {
  position: absolute;
  inset: 0;
  background: #000;
  z-index: 450;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 24px;
}

.sadmac-face {
  width: 80px;
  height: 80px;
  border: 3px solid #fff;
  border-radius: 8px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 40px;
}

.sadmac-text {
  font-family: var(--font-system);
  font-size: 14px;
  color: #fff;
  text-align: center;
  line-height: 1.6;
}


/* ─── 23. MISSION COMPLETE CHECKMARKS ─── */

.check { color: var(--success-green); font-weight: 700; }
.cross { color: var(--error-red); }


/* ─── 24. SCREEN SHAKE ─── */

.shake { animation: screenShake 0.3s ease; }


/* ─── 25. CLICK PROMPT ─── */

.click-prompt {
  font-family: var(--font-system);
  font-size: 10px;
  color: #999;
  text-align: center;
  margin-top: 12px;
  animation: fadeInUp 0.4s ease;
}
.click-prompt::before { content: '▸ '; color: var(--accent); }


/* ─── 26. KEYFRAMES ─── */

@keyframes blink {
  0%, 100% { opacity: 1; }
  50% { opacity: 0; }
}

@keyframes fadeIn {
  from { opacity: 0; }
  to { opacity: 1; }
}

@keyframes fadeInUp {
  from { opacity: 0; transform: translateY(6px); }
  to { opacity: 1; transform: translateY(0); }
}

@keyframes iconPulse {
  0%, 100% { transform: scale(1); box-shadow: none; }
  50% { transform: scale(1.06); box-shadow: 0 0 10px rgba(255,255,255,0.45); }
}

@keyframes linkPulse {
  0%, 100% { transform: translateY(0); text-shadow: none; }
  50% { transform: translateY(-1px); text-shadow: 0 0 6px rgba(204,0,0,0.35); }
}

@keyframes btnPulse {
  0%, 100% { outline-color: #000; }
  50% { outline-color: #666; }
}

@keyframes screenShake {
  0%, 100% { transform: translate(0,0); }
  10% { transform: translate(-4px, 2px); }
  20% { transform: translate(4px, -2px); }
  30% { transform: translate(-3px, -1px); }
  40% { transform: translate(3px, 1px); }
  50% { transform: translate(-2px, 2px); }
  60% { transform: translate(2px, -1px); }
  70% { transform: translate(-1px, 1px); }
  80% { transform: translate(1px, -1px); }
  90% { transform: translate(-1px, 0); }
}

@keyframes vhsGlitch {
  0% { transform: translate(0,0) skewX(0); }
  25% { transform: translate(-3px, 1px) skewX(-0.5deg); }
  50% { transform: translate(2px, -1px) skewX(0.5deg); }
  75% { transform: translate(-1px, 2px) skewX(-0.3deg); }
  100% { transform: translate(1px, -1px) skewX(0.2deg); }
}

@keyframes scanDown {
  0% { transform: translateY(-100%); }
  100% { transform: translateY(100vh); }
}

@keyframes goldFlash {
  0% { box-shadow: none; }
  50% { box-shadow: 0 0 40px rgba(255,215,0,0.5); }
  100% { box-shadow: none; }
}


/* ─── 27. RESPONSIVE ─── */

@media (max-width: 640px) {
  :root {
    --mobile-edge-x: max(10px, env(safe-area-inset-left), env(safe-area-inset-right));
    --mobile-edge-bottom: max(10px, env(safe-area-inset-bottom));
  }

  .desktop {
    padding-top: calc(var(--menubar-h) + env(safe-area-inset-top));
  }

  .menubar {
    height: calc(var(--menubar-h) + env(safe-area-inset-top));
    padding: env(safe-area-inset-top) var(--mobile-edge-x) 0;
  }

  .menubar-item {
    padding: 5px 7px;
  }

  .menubar-right {
    gap: 8px;
  }

  .menubar-mute {
    min-width: 36px;
    min-height: 32px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
  }

  .desktop-icons {
    top: calc(var(--menubar-h) + env(safe-area-inset-top) + 14px);
    right: var(--mobile-edge-x);
    gap: 18px;
  }
  .icon {
    min-width: 64px;
    min-height: 64px;
    padding: 7px 5px;
  }
  .icon-img {
    width: 40px;
    height: 40px;
  }
  .icon:hover,
  .menubar-item:hover,
  .finder-item:hover,
  .browser-link:hover,
  .map-node:hover {
    background: inherit;
  }
  .window {
    min-width: 0;
    max-width: calc(100vw - (var(--mobile-edge-x) * 2));
    max-height: calc(100dvh - var(--menubar-h) - env(safe-area-inset-top) - var(--mobile-edge-bottom) - 16px);
  }
  .window-titlebar {
    min-height: 32px;
    padding: 0 8px;
  }
  .window-close {
    width: 28px;
    height: 26px;
  }
  .window-close::before,
  .window-close::after {
    top: 6px;
    left: 13px;
    height: 12px;
  }
  .window-body {
    -webkit-overflow-scrolling: touch;
    overflow-wrap: anywhere;
  }
  .window--document .window-body,
  .window--browser .window-body,
  .window--terminal .window-body,
  .window--irc .window-body,
  .window--map .window-body {
    padding: 12px;
  }
  .window--browser .window-urlbar {
    overflow: hidden;
  }
  .urlbar-text {
    text-overflow: ellipsis;
  }
  table {
    min-width: 360px;
  }
  td,
  th {
    min-height: 44px;
  }
  .finder-item {
    min-width: 88px;
    min-height: 76px;
    padding: 10px 8px;
  }
  .finder-icon {
    width: 44px;
    height: 44px;
  }
  .browser-link {
    display: inline-block;
    min-height: 32px;
    padding: 4px 0;
  }
  .map-node {
    min-width: 44px;
    min-height: 44px;
    padding: 12px 14px;
    margin: 5px;
  }
  .dialog-overlay,
  .finale-overlay,
  .boot-overlay {
    padding-left: calc(6vw + env(safe-area-inset-left));
    padding-right: calc(6vw + env(safe-area-inset-right));
  }
  .dialog-close {
    width: 32px;
    height: 32px;
    font-size: 13px;
  }
  .btn {
    min-height: 44px;
    padding: 9px 18px;
    white-space: normal;
    line-height: 1.25;
  }
  .narration {
    bottom: var(--mobile-edge-bottom);
    font-size: 13px;
    padding: 10px 16px;
    width: calc(100% - (var(--mobile-edge-x) * 2));
  }
  .boot-overlay {
    padding: 8vh 6vw;
    font-size: 16px;
    overflow: auto;
  }
  .dialog {
    flex-direction: column;
    align-items: center;
    text-align: center;
    max-height: calc(100dvh - 32px - env(safe-area-inset-top) - env(safe-area-inset-bottom));
    overflow: auto;
  }
  .dialog-buttons {
    justify-content: center;
    flex-wrap: wrap;
  }
  .finale-buttons {
    flex-direction: column;
    align-items: center;
    width: min(100%, 320px);
  }
  .finale-buttons .btn {
    width: 100%;
  }
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after {
    animation-duration: 0.01ms !important;
    transition-duration: 0.01ms !important;
  }
}
