/* ============================================================
   NUTTY RETRO — styles.css

   Table of contents:
   1.  CSS Reset
   2.  CSS Custom Properties — all 4 colorways
   3.  Base typography
   4.  Stage layout (desktop + mobile)
   5.  Console sizing
   6.  Screen overlay
   7.  Pager sizing
   8.  Device controls (color swap + mute)
   9.  Background surfaces (wood desk / near-black)
   10. Mobile tab toggle
   11. Contact popup (shell — filled Phase 10)
   12. Phase 1 placeholders (removed in Phase 2/11)
   13. Utility classes
   ============================================================ */


/* ============================================================
   1. CSS RESET
   ============================================================ */

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

/* Ensure [hidden] always wins regardless of display rules */
[hidden] { display: none !important; }

html {
  font-size: 16px;
  -webkit-text-size-adjust: 100%;
  scroll-behavior: auto; /* no smooth scroll — this isn't a scrolling site */
}

body {
  min-height: 100vh;
  line-height: 1.4;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  background-color: #0d0d0d;
  background-image: url('assets/background/jay-pattern.png');
  background-repeat: repeat;
  background-size: 520px auto;
  background-attachment: fixed;
  /* Dim the pattern so it reads as texture, not wallpaper */
  position: relative;
}

body::before {
  content: '';
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.62);
  z-index: 0;
  pointer-events: none;
}

img, svg {
  display: block;
  max-width: 100%;
}

button {
  cursor: pointer;
  border: none;
  background: none;
  font: inherit;
  -webkit-tap-highlight-color: transparent;
}

ul, ol {
  list-style: none;
}


/* ============================================================
   2. CSS CUSTOM PROPERTIES — COLORWAYS
   All device theming flows through these.
   Applied via data-colorway attribute on <html>.
   Inline script in <head> reads localStorage before first paint
   to prevent flash of wrong color.
   ============================================================ */

/* DMG Gray — default, the 1989 original */
:root,
:root[data-colorway="dmg"] {
  --device-body:    #C5C2BC;
  --device-shadow:  #9F9C97;
  --device-outline: #1A1A1A;
  --button-ab:      #C13C5E;
  --button-label:   #ffffff;
  --button-cross:   #2A2A2A;
  --screen-border:  #5D5D5D;
  --screen-bg:      #9BBC0F;
  --screen-text:    #0F380F;
  --pager-body:     #A8A39B;
  --pager-screen:   #F4B942;
  --pager-text:     #1A1A1A;
}

/* Atomic Purple — translucent, max 90s energy */
:root[data-colorway="atomic"] {
  --device-body:    #7E5BB5;
  --device-shadow:  #5A3F8C;
  --device-outline: #1A1A1A;
  --button-ab:      #D63384;
  --button-label:   #ffffff;
  --button-cross:   #2A2A2A;
  --screen-border:  #3F2E5C;
  --screen-bg:      #9BBC0F;
  --screen-text:    #0F380F;
  --pager-body:     #5A3F8C;
  --pager-screen:   #F4B942;
  --pager-text:     #1A1A1A;
}

/* Berry Pink — translucent, pure Nutty energy */
:root[data-colorway="berry"] {
  --device-body:    #E5447F;
  --device-shadow:  #B22962;
  --device-outline: #1A1A1A;
  --button-ab:      #FFD700;
  --button-label:   #1A1A1A;
  --button-cross:   #2A2A2A;
  --screen-border:  #7A1E42;
  --screen-bg:      #9BBC0F;
  --screen-text:    #0F380F;
  --pager-body:     #B22962;
  --pager-screen:   #F4B942;
  --pager-text:     #1A1A1A;
}

/* Pocket Silver — cool minimal alt */
:root[data-colorway="silver"] {
  --device-body:    #A8ADB5;
  --device-shadow:  #7A7F87;
  --device-outline: #1A1A1A;
  --button-ab:      #1A1A1A;
  --button-label:   #ffffff;
  --button-cross:   #1A1A1A;
  --screen-border:  #5D5D5D;
  --screen-bg:      #9BBC0F;
  --screen-text:    #0F380F;
  --pager-body:     #7A7F87;
  --pager-screen:   #F4B942;
  --pager-text:     #1A1A1A;
}


/* ============================================================
   3. BASE TYPOGRAPHY
   Press Start 2P — pixel art moments (menus, labels, buttons)
   VT323          — longer text (dialogue, pager messages, forms)
   Both loaded via <link> in <head>.
   ============================================================ */

.font-pixel {
  font-family: 'Press Start 2P', monospace;
  letter-spacing: 1px;
}

.font-vt {
  font-family: 'VT323', monospace;
}

/* Enforce pixel grid sizes only — never below 8px */
.text-8  { font-size: 8px; }
.text-10 { font-size: 10px; }
.text-12 { font-size: 12px; }
.text-16 { font-size: 16px; }
.text-24 { font-size: 24px; }

/* VT323 sizes */
.text-14 { font-size: 14px; }
.text-18 { font-size: 18px; }
.text-22 { font-size: 22px; }
.text-28 { font-size: 28px; }


/* ============================================================
   4. STAGE LAYOUT
   Desktop (≥1024px): both devices side-by-side, centered
   Mobile (<1024px):  stacked, one visible at a time via tabs
   ============================================================ */

.stage {
  position: relative;
  z-index: 1;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 48px;
  min-height: 100vh;
  padding: 32px 16px;
}

@media (max-width: 1023px) {
  .stage {
    flex-direction: column;
    align-items: center;
    gap: 24px;
    padding: 8px 12px 24px;
  }
}

@media (max-width: 374px) {
  .stage {
    padding: 6px 8px 24px;
  }
}


/* ============================================================
   5. CONSOLE SIZING + SVG
   Mobile-first: 280px wide. Desktop: 360px.
   SVG sets the wrap height via its viewBox aspect ratio (280×480).
   ============================================================ */

.console-wrap {
  position: relative;
  width: min(calc(100vw - 24px), 340px);
  flex-shrink: 0;
}

@media (min-width: 1024px) {
  .console-wrap {
    width: 360px;
  }
}

/* SVG fills wrap width, height follows viewBox ratio automatically */
.device-svg {
  display: block;
  width: 100%;
  height: auto;
}

/* Colorway transitions on SVG fill elements */
.device-svg .body-fill,
.device-svg .ab-btn,
.device-svg .sys-btn {
  transition: fill 300ms ease;
}

/* D-pad hit zones — instant tap response on mobile */
.dpad-hit {
  cursor: pointer;
  touch-action: manipulation;
  -webkit-tap-highlight-color: transparent;
}

/* Button press feedback — JS adds .is-pressed for 80ms */
.device-svg .is-pressed {
  transform-box: fill-box;
  transform-origin: center;
  transform: scale(0.9);
  transition: transform 80ms ease !important;
}

/* Focus ring on SVG interactive elements */
.device-svg [role="button"]:focus-visible {
  outline: 3px solid var(--screen-bg);
  outline-offset: 3px;
}


/* ============================================================
   6. SCREEN OVERLAY
   Matches SVG screen rect: x=36 y=36 w=208 h=168 / 280×480 vB.
   left  = 36/280  = 12.86%
   top   = 36/480  =  7.5%
   width = 208/280 = 74.29%
   height= 168/480 = 35%
   Percentages are relative to console-wrap (position:relative),
   so this scales correctly at 280px mobile and 360px desktop.
   ============================================================ */

.screen-overlay {
  position: absolute;
  left:   17.86%;
  top:    10%;
  width:  64.29%;
  height: 32.92%;
  border-radius: 4px;
  overflow: hidden;
  background-color: var(--screen-bg);
  color: var(--screen-text);
  font-family: 'Press Start 2P', monospace;
  /* CRT scanlines — alternating transparent / dark every 4px */
  background-image: linear-gradient(
    to bottom,
    transparent 50%,
    rgba(0, 0, 0, 0.08) 50%
  );
  background-size: 100% 4px;
  transition: background-color 300ms ease, color 300ms ease;
}

/* Dot-matrix grain layer */
.screen-overlay::after {
  content: '';
  position: absolute;
  inset: 0;
  pointer-events: none;
  background-image: radial-gradient(circle, rgba(0,0,0,0.06) 1px, transparent 1px);
  background-size: 3px 3px;
}


/* ============================================================
   7. PAGER SIZING + SVG
   Mobile-first: 240px wide base
   Desktop: 300px wide
   SVG viewBox 260×380 — height follows aspect ratio automatically.
   ============================================================ */

.pager-wrap {
  position: relative;
  width: 280px;
  flex-shrink: 0;
}

@media (min-width: 1024px) {
  .pager-wrap {
    width: 340px;
  }
}

@media (max-width: 374px) {
  .pager-wrap {
    width: 240px;
  }
}

/* SVG fills wrap width, height follows viewBox 260×420 ratio */
.pager-svg {
  display: block;
  width: 100%;
  height: auto;
}

/* Colorway transitions on pager SVG fill elements */
.pager-svg .pager-body-fill,
.pager-svg .pager-send-btn {
  transition: fill 300ms ease;
}

/* SEND button — suppress click focus ring, allow keyboard ring */
.pager-send-btn {
  outline: none;
}

.pager-send-btn:focus-visible {
  outline: 2px solid var(--pager-screen);
  outline-offset: 2px;
}

/* Online LED — slow pulse */
@keyframes pagerLedPulse {
  0%, 100% { opacity: 1; }
  50%       { opacity: 0.2; }
}

.pager-led {
  animation: pagerLedPulse 2.4s ease-in-out infinite;
}

/* Screen overlay — matches SVG screen LCD rect.
   x=18 y=58 w=224 h=220 in 260×420 viewBox.
   left  = 18/260  =  6.92%
   top   = 58/420  = 13.81%
   width = 224/260 = 86.15%
   height= 220/420 = 52.38% */
.pager-screen-overlay {
  position: absolute;
  left:   6.92%;
  top:    13.81%;
  width:  86.15%;
  height: 52.38%;
  border-radius: 3px;
  overflow: hidden;
  background-color: var(--pager-screen);
  color: var(--pager-text);
  font-family: 'VT323', monospace;
  /* CRT scanlines matching console screen */
  background-image: linear-gradient(
    to bottom,
    transparent 50%,
    rgba(0, 0, 0, 0.07) 50%
  );
  background-size: 100% 4px;
  transition: background-color 300ms ease, color 300ms ease;
}

/* ── Phase 12: Chat UI ──────────────────────────────── */

.pager-chat {
  display: flex;
  flex-direction: column;
  height: 100%;
}

/* Scrollable message list — fills the entire pager-screen-overlay */
.pager-messages {
  flex: 1;
  overflow-y: auto;
  padding: 5px 7px 3px;
  display: flex;
  flex-direction: column;
  gap: 5px;
  scrollbar-width: none; /* Firefox */
}
.pager-messages::-webkit-scrollbar { display: none; }

/* Base message bubble */
.pager-msg {
  font-family: 'VT323', monospace;
  font-size: 14px;
  line-height: 1.25;
  max-width: 95%;
  word-break: break-word;
  color: var(--pager-text);
}

/* PIXEL replies — left-aligned */
.pager-msg--pixel { align-self: flex-start; }

/* User messages — right-aligned, slightly dimmed */
.pager-msg--user {
  align-self: flex-end;
  text-align: right;
  opacity: 0.72;
}
.pager-msg--user::before { content: '> '; }

/* "PIXEL" label above each bot reply */
.pager-msg-name {
  font-family: 'Press Start 2P', monospace;
  font-size: 5px;
  opacity: 0.5;
  display: block;
  margin-bottom: 2px;
  letter-spacing: 0.3px;
}

/* Typing indicator dots */
.pager-dots span {
  display: inline-block;
  animation: pagerDotPulse 1s ease-in-out infinite;
}
.pager-dots span:nth-child(2) { animation-delay: 0.2s; }
.pager-dots span:nth-child(3) { animation-delay: 0.4s; }

@keyframes pagerDotPulse {
  0%, 100% { opacity: 0.25; transform: translateY(0); }
  50%       { opacity: 1;    transform: translateY(-2px); }
}

/* HTML input overlaid over SVG input bar
   SVG rect: x=18 y=282 w=166 h=26 in 260×420 viewBox */
.pager-input-field {
  position: absolute;
  left:   6.92%;
  top:    67.14%;
  width:  63.85%;
  height: 6.19%;
  background: transparent;
  border: none;
  outline: none;
  padding: 0 5px;
  font-family: 'VT323', monospace;
  font-size: 14px;
  color: var(--pager-text);
  caret-color: var(--pager-text);
  z-index: 2;
}
.pager-input-field::placeholder {
  color: var(--pager-text);
  opacity: 0.3;
  font-size: 12px;
}

/* CONTACT shortcut button — appears inline in PIXEL replies */
.pager-contact-btn {
  display: block;
  margin-top: 5px;
  background: var(--pager-text);
  color: var(--pager-screen);
  border: none;
  font-family: 'Press Start 2P', monospace;
  font-size: 5px;
  padding: 4px 6px;
  letter-spacing: 0.4px;
  cursor: pointer;
  width: 100%;
  text-align: center;
}


/* ============================================================
   8. DEVICE CONTROLS — Color swap + mute
   Styled as physical side buttons extruding from the right
   edge of the console body — part of the hardware, not a UI.
   ============================================================ */

.device-controls {
  position: absolute;
  right: -14px;   /* protrude past the console edge */
  top: 42%;
  display: flex;
  flex-direction: column;
  gap: 6px;
  z-index: 10;
}

.device-btn {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 14px;
  height: 34px;
  padding: 6px 2px;
  color: var(--device-outline);
  background: var(--device-shadow);
  border: 1.5px solid var(--device-outline);
  border-left: none; /* flush against console body */
  border-radius: 0 5px 5px 0;
  transition: transform 80ms ease, background-color 300ms ease;
  box-shadow: 2px 2px 0 rgba(0,0,0,0.3);
  outline-offset: 2px;
}

.device-btn:active {
  transform: translateX(2px);
  box-shadow: none;
}

.device-btn:focus-visible {
  outline: 2px solid var(--screen-bg);
}

/* Hide sound waves when muted — toggled via JS */
.device-btn--mute.is-muted .mute-waves {
  display: none;
}

/* SVG interactive elements — suppress click focus ring, allow keyboard ring */
.dpad-hit,
.ab-btn,
.sys-btn {
  outline: none;
}

.dpad-hit:focus-visible,
.ab-btn:focus-visible,
.sys-btn:focus-visible {
  outline: 2px solid var(--screen-bg);
  outline-offset: 2px;
}


/* ============================================================
   9. BACKGROUND SURFACES
   Mobile / default: solid near-black #1A1A1A
   Desktop (≥1024px): dark wood #2C1810 with noise texture
   ============================================================ */

/* Jay pattern background — set in base body block above */



/* ============================================================
   10. MOBILE PAGER — Phase 13
   On <1024px the pager leaves the stage and becomes a floating
   chat widget (bottom-left corner). Tap to open a full-screen
   overlay; tap X or backdrop to close.
   Tab bar nav kept in HTML but permanently hidden.
   ============================================================ */

/* Tab bar: replaced by floating bubble — permanently hidden */
.mobile-tabs { display: none !important; }

/* Backdrop — separate element so pager-wrap keeps correct dimensions.
   Tapping it closes the overlay. */
.pager-backdrop {
  display: none;
}

@media (max-width: 1023px) {
  .pager-backdrop.is-open {
    display: block;
    position: fixed;
    inset: 0;
    z-index: 249;
    background: rgba(0, 0, 0, 0.88);
    animation: pagerOverlayIn 0.18s ease both;
  }
}

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

/* Pager: hidden from stage flow on mobile */
@media (max-width: 1023px) {
  .pager-wrap {
    display: none;
  }

  /* Overlay state — centered over backdrop, retains correct width
     so pager-screen-overlay percentage positions stay accurate */
  .pager-wrap.is-open {
    display: block;
    position: fixed;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    z-index: 250;
    width: min(280px, calc(100vw - 48px));
    flex-shrink: unset;
    animation: pagerOverlayIn 0.18s ease both;
  }
}

/* Floating PIXEL bubble — fixed bottom-right, mobile only.
   Transparent wrapper: the mini SVG pager IS the visual. */
.pager-bubble {
  display: none;
}

@media (max-width: 1023px) {
  .pager-bubble {
    display: block;
    position: fixed;
    bottom: 20px;
    right: 32px;
    z-index: 240;
    background: transparent;
    border: none;
    padding: 0;
    cursor: pointer;
    -webkit-tap-highlight-color: transparent;
    transition: transform 80ms ease;
    filter: drop-shadow(0 4px 16px rgba(0, 0, 0, 0.7));
  }

  .pager-bubble:active {
    transform: scale(0.91);
  }

  /* Bring bubble above overlay when open so it acts as close button */
  .pager-bubble.is-open {
    z-index: 260;
  }
}

/* Mini pager SVG — 64px wide, height follows 60:86 aspect ratio */
.pager-bubble-svg {
  display: block;
  width: 64px;
  height: auto;
}

/* LED on the mini pager — same pulse as the full device */
.pager-bubble-led {
  animation: pagerLedPulse 2.4s ease-in-out infinite;
}

/* Colorway transitions on mini pager fills */
.pager-bubble-svg rect,
.pager-bubble-svg circle {
  transition: fill 300ms ease;
}

/* ============================================================
   PIXEL BUBBLE — ATTENTION ANIMATION
   Nudge + notification dot + "PST..." callout
   ============================================================ */

/* Dot — hidden by default, only relevant on mobile */
.pager-bubble-dot {
  display: none;
}

@media (max-width: 1023px) {
  /* Unread count badge — top-right corner of bubble */
  .pager-bubble-dot {
    display: flex;
    align-items: center;
    justify-content: center;
    position: absolute;
    top: -5px;
    right: -5px;
    width: 16px;
    height: 16px;
    background: #ff3b30;
    border-radius: 50%;
    border: 2px solid #0d0d0d;
    font-family: 'Press Start 2P', monospace;
    font-size: 7px;
    color: #fff;
    line-height: 1;
    opacity: 0;
    transition: opacity 0.25s ease;
    animation: dotPulse 1.1s ease-in-out infinite;
    pointer-events: none;
  }

  .pager-bubble.is-notifying .pager-bubble-dot {
    opacity: 1;
  }

  /* Shake animation on nudge */
  .pager-bubble.is-nudging {
    animation: bubbleNudge 0.65s ease forwards;
  }

  /* "PST..." speech callout — pops out the LEFT side of the bubble */
  .pager-callout {
    position: absolute;
    top: 50%;
    right: calc(100% + 12px);
    transform: translateY(-50%) translateX(6px);
    background: var(--pager-screen);
    color: var(--pager-text);
    font-family: 'Press Start 2P', monospace;
    font-size: 10px;
    padding: 8px 12px;
    border: 2px solid var(--device-outline);
    white-space: nowrap;
    opacity: 0;
    transition: opacity 0.25s ease, transform 0.25s ease;
    pointer-events: none;
    z-index: 1;
  }

  /* Rightward arrow pointing at bubble */
  .pager-callout::after {
    content: '';
    position: absolute;
    top: 50%;
    right: -8px;
    transform: translateY(-50%);
    border-top: 6px solid transparent;
    border-bottom: 6px solid transparent;
    border-left: 7px solid var(--device-outline);
  }

  .pager-callout.is-visible {
    opacity: 1;
    transform: translateY(-50%) translateX(0);
  }
}

@keyframes bubbleNudge {
  0%   { transform: rotate(0deg) scale(1); }
  15%  { transform: rotate(-12deg) scale(1.08); }
  30%  { transform: rotate(10deg) scale(1.08); }
  45%  { transform: rotate(-7deg) scale(1.03); }
  60%  { transform: rotate(5deg) scale(1.03); }
  78%  { transform: rotate(-2deg) scale(1); }
  100% { transform: rotate(0deg) scale(1); }
}

@keyframes dotPulse {
  0%, 100% { transform: scale(1); box-shadow: 0 0 0 0 rgba(255,59,48,0.5); }
  50%       { transform: scale(1.25); box-shadow: 0 0 0 4px rgba(255,59,48,0); }
}


/* ============================================================
   11. CONTACT POPUP SHELL
   Full CSS lives in section 15.
   ============================================================ */


/* ============================================================
   12. PHASE 1 PLACEHOLDERS
   Visible only during Phase 1. Removed when SVG devices land.
   ============================================================ */

.placeholder-screen {
  display: flex;
  align-items: center;
  justify-content: center;
  border: 2px dashed rgba(155, 188, 15, 0.25);
  border-radius: 4px;
  padding: 48px 16px;
  text-align: center;
}

.placeholder-label {
  font-family: 'Press Start 2P', monospace;
  font-size: 8px;
  color: rgba(155, 188, 15, 0.35);
  line-height: 2;
  letter-spacing: 1px;
}

/* Give placeholders approximate device proportions */
.console-wrap .placeholder-screen {
  min-height: 460px;
}

.pager-wrap .placeholder-screen {
  min-height: 260px;
}


/* ============================================================
   13. UTILITY CLASSES
   ============================================================ */

/* Visually hidden but accessible to screen readers */
.sr-only {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  white-space: nowrap;
  border: 0;
}

/* Global focus ring — chunky pixel style */
:focus-visible {
  outline: 3px solid var(--screen-bg);
  outline-offset: 2px;
}

/* Button press feedback — applied via JS on interaction */
.is-pressed {
  transform: scale(0.95) !important;
  transition: transform 80ms ease !important;
}


/* ============================================================
   14. BOOT SEQUENCE — Phase 3
   ============================================================ */

.boot-screen {
  position: absolute;
  inset: 0;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 8px;
  padding: 10px 8px;
  cursor: pointer;
}

/* Logo image — drops in from above.
   max-height is % of .boot-screen which has a definite height (inset:0).
   object-fit:contain keeps aspect ratio within the capped box. */
.boot-logo {
  max-width: 86%;
  max-height: 58%;
  width: auto;
  height: auto;
  object-fit: contain;
  image-rendering: pixelated;
  animation: bootLogoDrop 0.45s cubic-bezier(0.22, 1, 0.36, 1) both;
}

/* Text fallback if image fails */
.boot-title {
  font-family: 'Press Start 2P', monospace;
  font-size: 12px;
  color: var(--screen-text);
  letter-spacing: 1px;
  text-align: center;
  animation: bootLogoDrop 0.45s cubic-bezier(0.22, 1, 0.36, 1) both;
}

@keyframes bootLogoDrop {
  from { transform: translateY(-48px); opacity: 0; }
  to   { transform: translateY(0);     opacity: 1; }
}

/* PRESS START — fades in after logo lands, then blinks */
.boot-press-start {
  font-family: 'Press Start 2P', monospace;
  font-size: 8px;
  color: var(--screen-text);
  letter-spacing: 1px;
  opacity: 0;
  animation:
    bootReveal 0.2s ease 0.7s forwards,
    bootBlink  1s step-end 0.9s infinite;
}

@keyframes bootReveal {
  to { opacity: 1; }
}

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

/* Exit — triggered by .is-launching class */
.boot-screen.is-launching .boot-press-start {
  animation: none;
  opacity: 0;
}

.boot-screen.is-launching .boot-logo,
.boot-screen.is-launching .boot-title {
  animation: bootExit 0.3s ease-in forwards;
}

@keyframes bootExit {
  to { transform: scale(0.9) translateY(6px); opacity: 0; }
}

/* Returning-visitor screen flicker */
.screen-overlay.boot-flicker {
  animation: bootFlicker 0.22s steps(1) forwards;
}

@keyframes bootFlicker {
  0%   { opacity: 1; }
  20%  { opacity: 0; }
  45%  { opacity: 1; }
  65%  { opacity: 0; }
  100% { opacity: 1; }
}


/* ============================================================
   15. HERO SCREEN
   ============================================================ */

.hero-screen {
  position: absolute;
  inset: 0;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 7px;
  padding: 6px 8px;
  cursor: pointer;
  animation: menuFadeIn 0.25s ease both;
}

.hero-logo {
  max-width: 94%;
  max-height: 38%;
  width: auto;
  height: auto;
  object-fit: contain;
}

.hero-heading {
  font-family: 'Press Start 2P', monospace;
  font-size: 10px;
  color: var(--screen-text);
  text-align: center;
  line-height: 1.6;
  letter-spacing: 0.5px;
  margin: 0;
}

.hero-sub {
  font-family: 'VT323', monospace;
  font-size: 16px;
  color: var(--screen-text);
  text-align: center;
  line-height: 1.25;
  opacity: 0.85;
}

.hero-cta {
  font-family: 'Press Start 2P', monospace;
  font-size: 8px;
  color: var(--screen-text);
  letter-spacing: 1px;
  animation: bootBlink 1s step-end infinite;
}

.hero-screen.is-leaving {
  animation: heroLeave 0.2s ease-in forwards;
}

@keyframes heroLeave {
  to { opacity: 0; transform: scale(0.97); }
}


/* ============================================================
   16. MAIN MENU — Phase 4
   ============================================================ */

.menu-screen {
  position: absolute;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 5px;
  animation: menuFadeIn 0.18s ease both;
}

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

.menu-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 5px;
  width: 100%;
  height: 100%;
}

.menu-item {
  display: flex;
  flex-direction: column;
  align-items: stretch;
  padding: 0;
  border: 1.5px solid rgba(15, 56, 15, 0.4);
  border-radius: 2px;
  overflow: hidden;
  background: transparent;
  color: var(--screen-text);
  cursor: pointer;
  -webkit-tap-highlight-color: transparent;
  transition: none;
}

.menu-item-icon {
  flex: 1;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 6px;
  min-height: 0;
}

.menu-item-icon svg {
  width: 26px;
  height: 26px;
  display: block;
  flex-shrink: 0;
}

.menu-item-label {
  font-family: 'Press Start 2P', monospace;
  font-size: 8px;
  color: var(--screen-text);
  text-align: center;
  padding: 3px 2px 4px;
  letter-spacing: 0.5px;
  border-top: 1px solid rgba(15, 56, 15, 0.3);
}

/* Selected cartridge — full color inversion */
.menu-item.is-active {
  border: 2px solid var(--screen-text);
}

.menu-item.is-active .menu-item-icon {
  background: var(--screen-text);
  color: var(--screen-bg);
}

.menu-item.is-active .menu-item-label {
  background: var(--screen-text);
  color: var(--screen-bg);
  border-top-color: var(--screen-text);
}

/* Stub screen — shows while cartridge not yet built */
.cart-stub {
  position: absolute;
  inset: 0;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 12px;
  padding: 8px;
}

.cart-stub-title {
  font-family: 'Press Start 2P', monospace;
  font-size: 8px;
  color: var(--screen-text);
  text-align: center;
  letter-spacing: 0.5px;
  line-height: 1.8;
}

.cart-stub-hint {
  font-family: 'Press Start 2P', monospace;
  font-size: 8px;
  color: var(--screen-text);
  opacity: 0.45;
  letter-spacing: 0.5px;
  animation: bootBlink 1.4s step-end infinite;
}


/* ============================================================
   15. WHO WE WORK WITH CARTRIDGE — Phase 7
   ============================================================ */

.who-screen {
  position: absolute;
  inset: 0;
  display: flex;
  flex-direction: column;
  overflow: hidden;
  animation: menuFadeIn 0.18s ease both;
}

.who-header {
  font-family: 'Press Start 2P', monospace;
  font-size: 7px;
  color: var(--screen-bg);
  background: var(--screen-text);
  padding: 4px 6px;
  letter-spacing: 0.4px;
  flex-shrink: 0;
}

.who-list {
  flex: 1;
  padding: 4px 6px 2px;
  display: flex;
  flex-direction: column;
  gap: 2px;
}

.who-screen.is-expanded .who-list {
  flex: 0 0 auto;
  padding-bottom: 0;
}

.who-screen.is-expanded .who-item:not(.is-active) {
  display: none;
}

.who-item {
  display: flex;
  align-items: center;
  gap: 4px;
  cursor: pointer;
  min-height: 22px;
  -webkit-tap-highlight-color: transparent;
}

.who-cursor {
  font-family: 'Press Start 2P', monospace;
  font-size: 8px;
  color: var(--screen-text);
  width: 10px;
  flex-shrink: 0;
  line-height: 1;
}

.who-label {
  font-family: 'VT323', monospace;
  font-size: 14px;
  color: var(--screen-text);
  line-height: 1.2;
}

.who-item.is-active .who-label {
  text-decoration: underline;
  text-underline-offset: 2px;
}

.who-copy {
  flex: 0;
  font-family: 'VT323', monospace;
  font-size: 13px;
  color: var(--screen-text);
  padding: 0 8px;
  line-height: 1.3;
  overflow: hidden;
}

.who-copy.is-visible {
  flex: 1;
  padding: 6px 8px 2px;
  animation: menuFadeIn 0.2s ease both;
}

.who-hint {
  font-family: 'Press Start 2P', monospace;
  font-size: 6px;
  color: var(--screen-text);
  opacity: 0.5;
  padding: 2px 6px 4px;
  letter-spacing: 0.3px;
  flex-shrink: 0;
}



/* ============================================================
   15. CONTACT POPUP — Phase 10
   HIGH SCORE ENTRY style form over the console.
   ============================================================ */

.popup-backdrop {
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,0.78);
  z-index: 300;
}

.popup-backdrop[hidden],
.contact-popup[hidden] {
  display: none;
}

.contact-popup {
  position: fixed;
  inset: 0;
  z-index: 310;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 20px 16px;
  overflow-y: auto;
}

.contact-box {
  width: 100%;
  max-width: 400px;
  max-height: calc(100vh - 40px);
  background: var(--device-body);
  border: 3px solid var(--device-outline);
  box-shadow: 6px 6px 0 var(--device-outline);
  overflow-y: auto;
  overflow-x: hidden;
}

.contact-header {
  background: var(--device-outline);
  color: var(--device-body);
  font-family: 'Press Start 2P', monospace;
  font-size: 10px;
  padding: 10px 14px;
  letter-spacing: 1px;
  display: flex;
  justify-content: space-between;
  align-items: center;
}

.contact-close-btn {
  background: transparent;
  border: none;
  color: var(--device-body);
  font-size: 16px;
  cursor: pointer;
  line-height: 1;
  padding: 0;
  opacity: 0.65;
  -webkit-tap-highlight-color: transparent;
}

.contact-close-btn:hover { opacity: 1; }

.contact-form {
  padding: 18px 16px 16px;
  display: flex;
  flex-direction: column;
  gap: 14px;
}

.contact-field {
  display: flex;
  flex-direction: column;
  gap: 5px;
}

.contact-label {
  font-family: 'Press Start 2P', monospace;
  font-size: 8px;
  color: var(--device-outline);
  letter-spacing: 0.5px;
}

.contact-input {
  background: var(--screen-bg);
  color: var(--screen-text);
  border: 2px solid var(--device-outline);
  padding: 10px 12px;
  font-family: 'VT323', monospace;
  font-size: 20px;
  outline: none;
  width: 100%;
  box-sizing: border-box;
  line-height: 1.2;
  -webkit-appearance: none;
}

.contact-input:focus {
  border-color: var(--button-ab);
  box-shadow: 0 0 0 2px var(--button-ab);
}

.contact-textarea {
  resize: none;
  height: 88px;
  line-height: 1.5;
}

.contact-error {
  font-family: 'Press Start 2P', monospace;
  font-size: 7px;
  color: #ff3b30;
  min-height: 12px;
  letter-spacing: 0.3px;
}

.contact-actions {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  padding-top: 2px;
}

.contact-submit {
  background: var(--button-ab);
  color: var(--button-label);
  border: 2px solid var(--device-outline);
  font-family: 'Press Start 2P', monospace;
  font-size: 8px;
  padding: 10px 22px;
  cursor: pointer;
  letter-spacing: 0.5px;
  box-shadow: 3px 3px 0 var(--device-outline);
  -webkit-tap-highlight-color: transparent;
}

.contact-submit:hover  { transform: translate(1px,1px); box-shadow: 2px 2px 0 var(--device-outline); }
.contact-submit:active { transform: translate(3px,3px); box-shadow: none; }
.contact-submit:disabled { opacity: 0.45; cursor: not-allowed; transform: none; box-shadow: 3px 3px 0 var(--device-outline); }

.contact-cancel {
  background: transparent;
  border: none;
  font-family: 'Press Start 2P', monospace;
  font-size: 7px;
  color: var(--device-outline);
  opacity: 0.55;
  cursor: pointer;
  letter-spacing: 0.3px;
  -webkit-tap-highlight-color: transparent;
}

.contact-cancel:hover { opacity: 1; }

/* Success state */
.contact-success {
  padding: 36px 20px;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 14px;
}

.contact-success-title {
  font-family: 'Press Start 2P', monospace;
  font-size: 12px;
  color: var(--screen-text);
  background: var(--screen-bg);
  padding: 12px 20px;
  letter-spacing: 1px;
  text-align: center;
  animation: bootBlink 0.8s step-end infinite;
}

.contact-success-sub {
  font-family: 'VT323', monospace;
  font-size: 20px;
  color: var(--device-outline);
  opacity: 0.65;
  letter-spacing: 0.5px;
  text-align: center;
}


/* ============================================================
   16. COLOR SWAPPER TOAST — Phase 5
   ============================================================ */


/* ============================================================
   COLOR SWAPPER TOAST
   ============================================================ */

.colorway-toast {
  position: absolute;
  bottom: 8px;
  left: 50%;
  transform: translateX(-50%);
  font-family: 'Press Start 2P', monospace;
  font-size: 7px;
  color: var(--screen-bg);
  background: var(--screen-text);
  padding: 4px 7px;
  letter-spacing: 0.5px;
  white-space: nowrap;
  pointer-events: none;
  z-index: 20;
  animation: toastFade 1.4s ease forwards;
}

@keyframes toastFade {
  0%   { opacity: 0; }
  12%  { opacity: 1; }
  72%  { opacity: 1; }
  100% { opacity: 0; }
}


/* ============================================================
   17. ABOUT JAY CARTRIDGE — Phase 9
   RPG dialogue-box style. Portrait floats right inside the
   dialogue area so text wraps around it naturally.
   ============================================================ */

.about-screen {
  position: absolute;
  inset: 0;
  display: flex;
  flex-direction: column;
  overflow: hidden;
  animation: menuFadeIn 0.18s ease both;
}

.about-header {
  font-family: 'Press Start 2P', monospace;
  font-size: 7px;
  color: var(--screen-bg);
  background: var(--screen-text);
  padding: 4px 6px;
  letter-spacing: 0.4px;
  flex-shrink: 0;
}

/* Portrait floats right — text flows around it */
.about-portrait {
  float: right;
  height: 56px;
  width: auto;
  margin: 0 0 4px 5px;
  flex-shrink: 0;
}

.about-dialogue {
  flex: 1;
  min-height: 0;
  font-family: 'VT323', monospace;
  font-size: 14px;
  color: var(--screen-text);
  padding: 4px 5px 2px;
  line-height: 1.2;
  overflow: hidden;
}

.about-hint {
  font-family: 'Press Start 2P', monospace;
  font-size: 6px;
  color: var(--screen-text);
  padding: 2px 6px 4px;
  display: flex;
  justify-content: space-between;
  align-items: center;
  letter-spacing: 0.3px;
  flex-shrink: 0;
}

/* A hint hidden until typing finishes, then blinks */
.about-hint-a {
  opacity: 0;
}

.about-hint-a.is-ready {
  opacity: 1;
  animation: bootBlink 1s step-end infinite;
}

.about-hint-b {
  opacity: 0.5;
}


/* ============================================================
   18. BUILDS CARTRIDGE — Phase 8
   ============================================================ */

.builds-screen {
  position: absolute;
  inset: 0;
  display: flex;
  flex-direction: column;
  overflow: hidden;
  animation: menuFadeIn 0.18s ease both;
}

.builds-header {
  font-family: 'Press Start 2P', monospace;
  font-size: 7px;
  color: var(--screen-bg);
  background: var(--screen-text);
  padding: 4px 6px;
  letter-spacing: 0.4px;
  flex-shrink: 0;
}

.builds-grid {
  flex: 1;
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 2px;
  padding: 2px;
  overflow: hidden;
}

.build-tile {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 3px;
  padding: 4px 2px;
  border: 1px solid rgba(15, 56, 15, 0.4);
  cursor: pointer;
  -webkit-tap-highlight-color: transparent;
  color: var(--screen-text);
}

.build-tile.is-active {
  background: var(--screen-text);
  color: var(--screen-bg);
  border-color: var(--screen-text);
}

.build-tile-icon {
  width: 22px;
  height: 22px;
  flex-shrink: 0;
}

.build-tile-icon svg {
  width: 100%;
  height: 100%;
  display: block;
}

.build-tile-label {
  font-family: 'Press Start 2P', monospace;
  font-size: 5px;
  text-align: center;
  line-height: 1.5;
  letter-spacing: 0.3px;
}

/* Build detail view */

.build-detail {
  position: absolute;
  inset: 0;
  display: flex;
  flex-direction: column;
  overflow: hidden;
  animation: menuFadeIn 0.18s ease both;
}

.build-screenshot {
  width: 100%;
  height: 148px;
  object-fit: cover;
  object-position: top;
  display: block;
  flex-shrink: 0;
}

.build-detail-info {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 4px;
}

.build-detail-title {
  font-family: 'Press Start 2P', monospace;
  font-size: 7px;
  color: var(--screen-text);
  letter-spacing: 0.4px;
  text-align: center;
}

.build-detail-desc {
  flex: 1;
  font-family: 'VT323', monospace;
  font-size: 12px;
  color: var(--screen-text);
  padding: 0 6px;
  line-height: 1.3;
  overflow: hidden;
}

.build-detail-hint {
  font-family: 'Press Start 2P', monospace;
  font-size: 6px;
  color: var(--screen-text);
  opacity: 0.5;
  letter-spacing: 0.3px;
  text-align: center;
}

/* ============================================================
   19. BUILD POPUP OVERLAY
   ============================================================ */

.build-popup-overlay {
  position: fixed;
  inset: 0;
  z-index: 9999;
  display: flex;
  align-items: center;
  justify-content: center;
  background: rgba(15, 56, 15, 0.88);
  padding: 16px;
}

.build-popup-card {
  width: 300px;
  max-height: 88vh;
  display: flex;
  flex-direction: column;
  background: var(--screen-bg);
  border: 3px solid var(--screen-text);
  box-shadow:
    0 0 0 2px var(--screen-bg),
    0 0 0 5px var(--screen-text),
    10px 10px 0 rgba(15, 56, 15, 0.6);
  overflow: hidden;
}

.build-popup-titlebar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  background: var(--screen-text);
  color: var(--screen-bg);
  padding: 7px 8px;
  flex-shrink: 0;
}

.build-popup-title {
  font-family: 'Press Start 2P', monospace;
  font-size: 6px;
  letter-spacing: 0.3px;
  line-height: 1.5;
  color: var(--screen-bg);
}

.build-popup-close {
  background: none;
  border: 2px solid var(--screen-bg);
  color: var(--screen-bg);
  font-family: 'Press Start 2P', monospace;
  font-size: 7px;
  cursor: pointer;
  padding: 2px 5px;
  line-height: 1;
  flex-shrink: 0;
  -webkit-tap-highlight-color: transparent;
}

.build-popup-close:hover {
  background: var(--screen-bg);
  color: var(--screen-text);
}

.build-popup-media {
  flex: 1;
  overflow-y: auto;
  overflow-x: hidden;
  -webkit-overflow-scrolling: touch;
}

.build-popup-img,
.build-popup-video {
  display: block;
  width: 100%;
  height: auto;
}

.build-popup-hint {
  font-family: 'Press Start 2P', monospace;
  font-size: 5px;
  color: var(--screen-text);
  opacity: 0.5;
  text-align: center;
  padding: 6px;
  flex-shrink: 0;
  letter-spacing: 0.3px;
}
