
    :root {
      --bg-color: #040711;
      --panel-bg: rgba(10, 16, 30, 0.96);
      --border-color: #00ffcc;
      --text-main: #e0f7fc;
      --accent-cyan: #00ffcc;
      --accent-pink: #ff77b4;
      --accent-yellow: #ffee00;
      --accent-gold: #ffd700;
      --accent-blue: #00e5ff;
      --accent-white: #ffffff;
      --accent-orange: #ff9900;
      --danger-red: #ff0044;
      --font-mono: 'Courier New', 'Consolas', 'Fira Code', monospace;
      --touch-opacity: 0.88;
      --touch-scale: 1.0;
    }

    * {
      box-sizing: border-box;
      user-select: none;
      -webkit-user-select: none;
      -webkit-touch-callout: none;
      margin: 0;
      padding: 0;
    }

    html, body {
      width: 100%;
      height: 100%;
      height: 100dvh;
      overflow: hidden;
      background-color: var(--bg-color);
      color: var(--text-main);
      font-family: var(--font-mono);
      touch-action: none;
      -webkit-font-smoothing: antialiased;
      -moz-osx-font-smoothing: grayscale;
    }

    body {
      display: flex;
      flex-direction: column;
      align-items: center;
      justify-content: center;
      position: relative;
    }

    /* CRT Scanline & Phosphor Overlay */
    .crt-overlay {
      position: fixed;
      top: 0;
      left: 0;
      width: 100vw;
      height: 100vh;
      height: 100dvh;
      background: linear-gradient(rgba(18, 16, 16, 0) 50%, rgba(0, 0, 0, 0.22) 50%), linear-gradient(90deg, rgba(255, 0, 0, 0.03), rgba(0, 255, 0, 0.01), rgba(0, 0, 255, 0.03));
      background-size: 100% 3px, 6px 100%;
      pointer-events: none;
      z-index: 100;
      transition: opacity 0.3s ease;
    }

    .crt-overlay.crt-subtle {
      opacity: 0.45;
    }

    .crt-overlay.crt-off {
      display: none;
    }

    /* Landscape Game Container with Safe Area Handling */
    #game-container {
      position: relative;
      width: 100vw;
      width: 100dvw;
      height: 100vh;
      height: 100dvh;
      max-width: 1000px;
      max-height: 560px;
      aspect-ratio: 1000 / 560;
      background-color: #02040a;
      border: 3px solid var(--accent-cyan);
      box-shadow: 0 0 30px rgba(0, 255, 204, 0.45), inset 0 0 15px rgba(0, 0, 0, 0.95);
      border-radius: 8px;
      overflow: hidden;
      display: flex;
      align-items: center;
      justify-content: center;
      touch-action: none;
    }

    @media (max-aspect-ratio: 1000/560) {
      #game-container {
        width: 100vw;
        width: 100dvw;
        height: auto;
        max-height: 100dvh;
      }
    }

    @media (min-aspect-ratio: 1000/560) {
      #game-container {
        height: 100vh;
        height: 100dvh;
        width: auto;
        max-width: 100dvw;
      }
    }

    #game-container:fullscreen,
    #game-container:-webkit-full-screen {
      width: 100vw;
      width: 100dvw;
      height: 100vh;
      height: 100dvh;
      max-width: 100vw;
      max-height: 100dvh;
      border: none;
      border-radius: 0;
      box-shadow: none;
      background-color: #000;
    }

    canvas {
      display: block;
      width: 100%;
      height: 100%;
      object-fit: contain;
      cursor: crosshair;
      image-rendering: -webkit-optimize-contrast;
      image-rendering: crisp-edges;
    }

    /* Orientation Prompt Overlay for Mobile Portrait Mode */
    #orientation-prompt {
      position: fixed;
      top: 0;
      left: 0;
      width: 100vw;
      width: 100dvw;
      height: 100vh;
      height: 100dvh;
      background: rgba(3, 6, 15, 0.97);
      backdrop-filter: blur(10px);
      z-index: 9999;
      display: none;
      flex-direction: column;
      align-items: center;
      justify-content: center;
      text-align: center;
      padding: 24px;
    }

    .rotate-device-icon {
      font-size: 54px;
      animation: rotatePhone 2.2s infinite ease-in-out;
      margin-bottom: 16px;
      filter: drop-shadow(0 0 16px var(--accent-cyan));
    }

    @keyframes rotatePhone {
      0%, 20% { transform: rotate(0deg) scale(1); }
      50%, 70% { transform: rotate(90deg) scale(1.1); }
      100% { transform: rotate(0deg) scale(1); }
    }

    #orientation-prompt h2 {
      font-size: 19px;
      color: var(--accent-cyan);
      text-shadow: 0 0 12px var(--accent-cyan);
      margin-bottom: 8px;
      letter-spacing: 2px;
    }

    #orientation-prompt p {
      font-size: 12px;
      color: #9cd4e6;
      max-width: 320px;
      line-height: 1.5;
      margin-bottom: 16px;
    }

    /* HUD Layer */
    .hud-layer {
      position: absolute;
      top: 0;
      left: 0;
      width: 100%;
      height: 100%;
      pointer-events: none;
      padding: env(safe-area-inset-top, 8px) env(safe-area-inset-right, 14px) env(safe-area-inset-bottom, 8px) env(safe-area-inset-left, 14px);
      display: flex;
      flex-direction: column;
      justify-content: space-between;
      z-index: 40;
    }

    .hud-top {
      display: flex;
      justify-content: space-between;
      align-items: flex-start;
      text-shadow: 0 0 8px rgba(0, 255, 204, 0.8);
    }

    .hud-bars {
      display: flex;
      flex-direction: column;
      gap: 3px;
    }

    .hearts-container {
      font-size: 16px;
      letter-spacing: 2px;
      filter: drop-shadow(0 0 6px #ff0044);
    }

    .bar-container {
      display: flex;
      align-items: center;
      gap: 6px;
      font-weight: bold;
      font-size: 10.5px;
    }

    .bar-bg {
      width: 110px;
      height: 8px;
      background-color: rgba(255, 255, 255, 0.1);
      border: 1px solid var(--accent-cyan);
      border-radius: 3px;
      overflow: hidden;
    }

    .bar-fill {
      height: 100%;
      transition: width 0.15s ease-out;
    }

    #stamina-fill {
      background: linear-gradient(90deg, #0088ff, #00ffcc);
      box-shadow: 0 0 8px #00ffcc;
    }

    .hud-stats {
      text-align: right;
      font-size: 11.5px;
      line-height: 1.4;
    }

    .hud-quick-buttons {
      margin-top: 4px;
      display: flex;
      gap: 5px;
      justify-content: flex-end;
      pointer-events: auto;
      flex-wrap: wrap;
    }

    .hud-btn {
      background: rgba(0, 26, 40, 0.88);
      border: 1px solid var(--accent-cyan);
      color: var(--accent-cyan);
      padding: 3px 7px;
      font-size: 10px;
      font-family: var(--font-mono);
      font-weight: bold;
      border-radius: 3px;
      cursor: pointer;
      transition: all 0.15s ease;
      touch-action: manipulation;
    }

    .hud-btn:hover, .hud-btn:active {
      background: var(--accent-cyan);
      color: #000;
      box-shadow: 0 0 10px var(--accent-cyan);
    }

    .hud-gamepad-badge {
      display: none;
      align-items: center;
      gap: 4px;
      background: rgba(0, 255, 204, 0.15);
      border: 1px solid var(--accent-cyan);
      color: var(--accent-yellow);
      padding: 2px 6px;
      border-radius: 3px;
      font-size: 9.5px;
      font-weight: bold;
      margin-top: 3px;
    }

    .hud-boss {
      position: absolute;
      top: 10px;
      left: 50%;
      transform: translateX(-50%);
      width: 400px;
      max-width: 80%;
      text-align: center;
      display: none;
    }

    .boss-name {
      font-size: 12px;
      font-weight: bold;
      color: var(--accent-pink);
      text-shadow: 0 0 10px var(--accent-pink);
      margin-bottom: 2px;
      letter-spacing: 1px;
    }

    .boss-hearts {
      font-size: 14px;
      letter-spacing: 2px;
      filter: drop-shadow(0 0 8px #ff007f);
      margin-bottom: 2px;
    }

    .boss-bar-bg {
      width: 100%;
      height: 10px;
      background-color: rgba(0, 0, 0, 0.7);
      border: 1.5px solid var(--accent-pink);
      border-radius: 4px;
      overflow: hidden;
    }

    #boss-hp-fill {
      width: 100%;
      height: 100%;
      background: linear-gradient(90deg, #ff0055, #ff00ff, #ff6600);
      box-shadow: 0 0 12px #ff0055;
      transition: width 0.1s ease-out;
    }

    /* Unlock Banner */
    .hud-banner {
      position: absolute;
      top: 65px;
      left: 50%;
      transform: translateX(-50%);
      background: rgba(10, 20, 35, 0.96);
      border: 2px solid var(--accent-yellow);
      box-shadow: 0 0 25px rgba(255, 238, 0, 0.6);
      padding: 6px 14px;
      border-radius: 6px;
      color: #fff;
      text-align: center;
      font-size: 12px;
      font-weight: bold;
      pointer-events: none;
      opacity: 0;
      transition: opacity 0.4s ease, transform 0.4s ease;
      z-index: 45;
    }

    .hud-banner.active {
      opacity: 1;
      transform: translateX(-50%) translateY(5px);
    }

    /* Gamepad Status Toast */
    #gamepad-toast {
      position: absolute;
      top: 12px;
      left: 50%;
      transform: translate(-50%, -25px);
      background: rgba(0, 255, 204, 0.95);
      color: #000;
      padding: 5px 16px;
      border-radius: 20px;
      font-weight: bold;
      font-size: 11.5px;
      letter-spacing: 1px;
      box-shadow: 0 0 20px rgba(0, 255, 204, 0.8);
      z-index: 120;
      pointer-events: none;
      transition: opacity 0.3s ease, transform 0.3s ease;
      opacity: 0;
    }
    #gamepad-toast.show {
      opacity: 1;
      transform: translate(-50%, 0);
    }

    /* Performance Tier Adjustment Toast (fires once per session, auto-adaptive only) */
    #perf-toast {
      position: absolute;
      bottom: 64px;
      left: 50%;
      transform: translate(-50%, 20px);
      background: rgba(0, 229, 255, 0.92);
      color: #000;
      padding: 4px 14px;
      border-radius: 16px;
      font-weight: bold;
      font-size: 10.5px;
      letter-spacing: 1px;
      box-shadow: 0 0 14px rgba(0, 229, 255, 0.6);
      z-index: 119;
      pointer-events: none;
      transition: opacity 0.4s ease, transform 0.4s ease;
      opacity: 0;
    }
    #perf-toast.show {
      opacity: 1;
      transform: translate(-50%, 0);
    }

    /* Narrative Cutscene Dialog Box */
    #cutscene-dialog-box {
      position: absolute;
      bottom: 20px;
      left: 50%;
      transform: translateX(-50%);
      width: 90%;
      max-width: 800px;
      background: rgba(8, 14, 28, 0.96);
      border: 2px solid var(--accent-cyan);
      box-shadow: 0 0 35px rgba(0, 255, 204, 0.5);
      padding: 14px 18px;
      border-radius: 8px;
      color: #e0f7fc;
      z-index: 60;
      display: none;
      font-size: 13px;
      line-height: 1.5;
    }

    .dialog-speaker {
      font-weight: bold;
      color: var(--accent-yellow);
      margin-bottom: 4px;
      font-size: 13.5px;
      letter-spacing: 1px;
    }

    .dialog-prompt {
      margin-top: 8px;
      text-align: right;
      font-size: 11px;
      color: var(--accent-cyan);
      animation: blink 1s infinite alternate;
    }

    @keyframes blink {
      from { opacity: 0.3; }
      to { opacity: 1; }
    }

    /* ==========================================================================
       MOBILE VIRTUAL CONTROLS HUD (DYNAMIC JOYSTICK & ACTION CLUSTER)
       ========================================================================== */
    .mobile-controls-layer {
      position: absolute;
      bottom: 0;
      left: 0;
      width: 100%;
      height: 100%;
      pointer-events: none;
      z-index: 42;
      display: flex;
      justify-content: space-between;
      align-items: flex-end;
      padding: 0 env(safe-area-inset-right, 14px) env(safe-area-inset-bottom, 12px) env(safe-area-inset-left, 14px);
      opacity: var(--touch-opacity);
      transition: opacity 0.2s ease;
    }

    /* Left Joystick & D-Pad Zone */
    .touch-left-zone {
      pointer-events: auto;
      position: relative;
      width: 170px;
      height: 170px;
      margin-bottom: 6px;
      display: flex;
      align-items: center;
      justify-content: center;
      touch-action: none;
    }

    .joystick-base {
      position: absolute;
      width: 120px;
      height: 120px;
      border-radius: 50%;
      background: radial-gradient(circle, rgba(0, 255, 204, 0.12) 0%, rgba(3, 10, 22, 0.7) 70%, rgba(0, 255, 204, 0.4) 100%);
      border: 2px solid var(--accent-cyan);
      box-shadow: 0 0 15px rgba(0, 255, 204, 0.3), inset 0 0 12px rgba(0, 255, 204, 0.2);
      display: flex;
      align-items: center;
      justify-content: center;
      transition: border-color 0.15s ease;
    }

    .joystick-base::before, .joystick-base::after {
      content: '';
      position: absolute;
      background: rgba(0, 255, 204, 0.25);
    }
    .joystick-base::before { width: 1px; height: 100%; }
    .joystick-base::after { width: 100%; height: 1px; }

    .joystick-thumb {
      position: absolute;
      width: 52px;
      height: 52px;
      border-radius: 50%;
      background: radial-gradient(circle, #00ffcc 0%, #0088aa 65%, #004455 100%);
      border: 2px solid #ffffff;
      box-shadow: 0 0 18px #00ffcc, inset 0 0 6px rgba(255, 255, 255, 0.8);
      pointer-events: none;
      transform: translate(0px, 0px);
      transition: transform 0.04s ease-out;
    }

    .joystick-thumb.active {
      box-shadow: 0 0 25px #00ffcc, 0 0 35px var(--accent-yellow);
    }

    /* Left Alternative D-Pad Mode */
    .dpad-container {
      display: none;
      grid-template-columns: 50px 50px;
      grid-template-rows: 48px 40px;
      gap: 5px;
      pointer-events: auto;
    }

    /* Right Action Cluster */
    .action-buttons-container {
      pointer-events: auto;
      display: flex;
      flex-direction: column;
      gap: 6px;
      align-items: flex-end;
      margin-bottom: 6px;
    }

    .action-row {
      display: flex;
      gap: 6px;
      align-items: center;
    }

    .touch-btn {
      background: rgba(8, 18, 36, 0.88);
      border: 2px solid var(--accent-cyan);
      color: var(--accent-cyan);
      font-family: var(--font-mono);
      font-weight: bold;
      font-size: 12px;
      border-radius: 8px;
      display: flex;
      flex-direction: column;
      align-items: center;
      justify-content: center;
      box-shadow: 0 0 10px rgba(0, 255, 204, 0.3), inset 0 0 8px rgba(0, 255, 204, 0.15);
      touch-action: none;
      user-select: none;
      -webkit-user-select: none;
      cursor: pointer;
      transition: transform 0.05s ease, background 0.05s ease, box-shadow 0.05s ease;
      line-height: 1.1;
    }

    .touch-btn:active, .touch-btn.active {
      transform: scale(0.92);
      background: var(--accent-cyan);
      color: #000;
      box-shadow: 0 0 22px var(--accent-cyan);
    }

    .touch-btn .sub-label {
      font-size: 8px;
      opacity: 0.8;
      letter-spacing: 0.5px;
    }

    .btn-fire {
      width: 66px;
      height: 52px;
      border-color: #ff0055;
      color: #ff0055;
      box-shadow: 0 0 14px rgba(255, 0, 85, 0.45);
      font-size: 12px;
    }
    .btn-fire:active, .btn-fire.active {
      background: #ff0055;
      color: #fff;
      box-shadow: 0 0 25px #ff0055;
    }

    .btn-jump {
      width: 66px;
      height: 52px;
      border-color: #ffd700;
      color: #ffd700;
      box-shadow: 0 0 14px rgba(255, 215, 0, 0.45);
      font-size: 12px;
    }
    .btn-jump:active, .btn-jump.active {
      background: #ffd700;
      color: #000;
      box-shadow: 0 0 25px #ffd700;
    }

    .btn-melee {
      width: 54px;
      height: 40px;
      border-color: #00e5ff;
      color: #00e5ff;
      font-size: 11px;
    }

    .btn-swap, .btn-interact, .btn-dash {
      width: 50px;
      height: 40px;
      font-size: 10px;
    }

    .dpad-btn {
      width: 50px;
      height: 48px;
      font-size: 16px;
    }

    .dpad-down, .dpad-sprint {
      height: 38px;
      font-size: 9.5px;
    }

    /* Modal Styling */
    .modal-overlay {
      position: absolute;
      top: 0;
      left: 0;
      width: 100%;
      height: 100%;
      background-color: rgba(4, 8, 16, 0.94);
      backdrop-filter: blur(5px);
      display: flex;
      flex-direction: column;
      align-items: center;
      justify-content: center;
      z-index: 55;
      padding: 12px;
    }

    .hidden {
      display: none !important;
    }

    /* Default panel: 90% viewport fill, capped at 920px for ultrawide. */
    .panel {
      background: var(--panel-bg);
      border: 2px solid var(--accent-cyan);
      box-shadow: 0 0 30px rgba(0, 255, 204, 0.35);
      padding: 16px 20px;
      border-radius: 8px;
      max-width: 920px;
      width: 90vw;
      max-height: 90vh;
      min-height: 60vh;
      text-align: center;
      overflow-y: auto;
    }

    /* Title screen panel: 90% of viewport in BOTH axes, fluid typography. */
    #start-modal .panel {
      width: 90vw;
      max-width: 90vw;
      height: 90vh;
      max-height: 90vh;
      min-height: 480px;
      display: flex;
      flex-direction: column;
      justify-content: center;
      padding: clamp(12px, 2.4vmin, 32px);
    }

    /* Settings / pause / menu panels: same 90% rule. */
    #settings-modal .panel,
    #leaderboard-modal .panel,
    #gameover-modal .panel,
    #victory-modal .panel,
    #pause-modal .panel {
      width: 90vw;
      max-width: 90vw;
      max-height: 90vh;
    }

    /* Responsive typography for title screen: scale with viewport. */
    #start-modal h1 {
      font-size: clamp(16px, 3.6vmin, 28px);
      letter-spacing: clamp(1px, 0.4vmin, 3px);
    }
    #start-modal p {
      font-size: clamp(10px, 1.8vmin, 14px);
      line-height: 1.4;
    }
    #start-modal .seed-badge,
    #start-modal .controls-grid > div,
    #start-modal .btn {
      font-size: clamp(9px, 1.7vmin, 13px);
    }
    #start-modal .controls-grid {
      gap: clamp(2px, 0.4vmin, 6px);
    }
    #start-modal .btn {
      padding: clamp(4px, 0.9vmin, 10px) clamp(8px, 1.6vmin, 20px);
    }

    /* Video player overlay: 90% of viewport in both axes, centered. */
    #theater-video-wrap,
    #catnip-tv-wrap {
      position: fixed;
      inset: 0;
      z-index: 9999;
      background: #000;
      pointer-events: auto;
      display: flex;
      align-items: center;
      justify-content: center;
    }
    #theater-video-wrap.hidden,
    #catnip-tv-wrap.hidden {
      display: none;
    }
    #theater-video,
    #catnip-tv-video {
      width: 90vw;
      height: 90vh;
      max-width: 90vw;
      max-height: 90vh;
      object-fit: contain;
      background: #000;
    }

    h1 {
      font-size: 19px;
      color: var(--accent-cyan);
      text-shadow: 0 0 12px var(--accent-cyan);
      margin-bottom: 4px;
      letter-spacing: 2px;
    }

    h2 {
      font-size: 15px;
      color: var(--accent-yellow);
      margin-bottom: 6px;
    }

    p {
      font-size: 11px;
      line-height: 1.4;
      color: #b0d8e6;
      margin-bottom: 6px;
    }

    .controls-grid {
      display: grid;
      grid-template-columns: repeat(2, 1fr);
      gap: 4px 10px;
      margin: 6px 0;
      text-align: left;
      background: rgba(0, 0, 0, 0.45);
      padding: 7px 10px;
      border-radius: 6px;
      border: 1px solid rgba(0, 255, 204, 0.25);
      font-size: 10.5px;
    }

    .key-badge {
      display: inline-block;
      background: #002233;
      color: var(--accent-cyan);
      border: 1px solid var(--accent-cyan);
      padding: 1px 4px;
      border-radius: 3px;
      font-weight: bold;
      font-size: 9.5px;
    }

    .seed-badge {
      display: inline-block;
      background: rgba(0, 255, 204, 0.15);
      border: 1px dashed var(--accent-cyan);
      color: var(--accent-yellow);
      padding: 2px 7px;
      border-radius: 4px;
      font-size: 11px;
      font-weight: bold;
      margin: 3px 0;
    }

    .btn {
      background: linear-gradient(135deg, #004455, #00aa99);
      color: #fff;
      border: 1px solid var(--accent-cyan);
      padding: 6px 14px;
      font-family: var(--font-mono);
      font-size: 11.5px;
      font-weight: bold;
      border-radius: 4px;
      cursor: pointer;
      box-shadow: 0 0 15px rgba(0, 255, 204, 0.4);
      transition: all 0.2s ease;
      margin: 3px;
      pointer-events: auto;
    }

    .btn:hover, .btn:active {
      background: linear-gradient(135deg, #008899, #00ffcc);
      color: #000;
      box-shadow: 0 0 25px var(--accent-cyan);
      transform: translateY(-1px);
    }

    .btn-secondary {
      background: linear-gradient(135deg, #440022, #990044);
      border-color: var(--accent-pink);
      box-shadow: 0 0 15px rgba(255, 0, 127, 0.4);
    }

    .btn-secondary:hover, .btn-secondary:active {
      background: linear-gradient(135deg, #990044, #ff007f);
      box-shadow: 0 0 25px var(--accent-pink);
    }

    .settings-section-title {
      font-size: 11px;
      font-weight: bold;
      color: var(--accent-yellow);
      letter-spacing: 1px;
      margin: 12px 0 4px 0;
      padding-bottom: 3px;
      border-bottom: 1px dashed rgba(255, 215, 0, 0.35);
      display: flex;
      align-items: center;
      gap: 5px;
    }

    .settings-grid {
      display: grid;
      grid-template-columns: repeat(2, 1fr);
      gap: 8px 12px;
      text-align: left;
      margin: 6px 0 10px 0;
    }

    .setting-item {
      background: rgba(0, 20, 36, 0.7);
      border: 1px solid rgba(0, 255, 204, 0.25);
      padding: 8px 10px;
      border-radius: 6px;
      display: flex;
      flex-direction: column;
      gap: 4px;
    }

    .setting-item label {
      font-size: 11px;
      font-weight: bold;
      color: var(--accent-cyan);
    }

    .setting-control {
      display: flex;
      align-items: center;
      gap: 6px;
    }

    select, input[type="range"] {
      width: 100%;
      background: #00121e;
      color: #00ffcc;
      border: 1px solid var(--accent-cyan);
      padding: 4px 6px;
      border-radius: 4px;
      font-family: var(--font-mono);
      font-size: 11px;
    }

    input[type="range"] {
      accent-color: var(--accent-cyan);
      cursor: pointer;
    }

    .shop-items {
      display: grid;
      grid-template-columns: repeat(2, 1fr);
      gap: 6px;
      margin: 6px 0;
      text-align: left;
    }

    .shop-card {
      background: rgba(0, 20, 35, 0.7);
      border: 1px solid var(--accent-cyan);
      padding: 6px 8px;
      border-radius: 6px;
      display: flex;
      flex-direction: column;
      justify-content: space-between;
    }

    .shop-card h3 {
      font-size: 11px;
      color: var(--accent-yellow);
    }

    .shop-card p {
      font-size: 9.5px;
      margin: 2px 0 5px 0;
      color: #90c0d0;
    }

    .leaderboard-table {
      width: 100%;
      border-collapse: collapse;
      margin: 6px 0;
      font-size: 10.5px;
    }

    .leaderboard-table th, .leaderboard-table td {
      padding: 3px 5px;
      border-bottom: 1px solid rgba(0, 255, 204, 0.2);
      text-align: left;
    }

    .leaderboard-table th {
      color: var(--accent-yellow);
      border-bottom: 2px solid var(--accent-cyan);
    }

    .rank-1 { color: #ffd700; font-weight: bold; }
    .rank-2 { color: #c0c0c0; font-weight: bold; }
    .rank-3 { color: #cd7f32; font-weight: bold; }

    input[type="text"] {
      background: #00111a;
      border: 1px solid var(--accent-cyan);
      color: #fff;
      padding: 4px 7px;
      font-family: var(--font-mono);
      border-radius: 4px;
      font-size: 11px;
      width: 180px;
      text-align: center;
      margin-bottom: 5px;
    }

    .footer-info {
      margin-top: 4px;
      font-size: 9.5px;
      color: #5588a0;
      text-align: center;
    }

    @media (max-width: 600px) {
      .settings-grid, .shop-items, .controls-grid {
        grid-template-columns: 1fr;
      }
    }
  
    /* ==========================================================================
       CATNIP TV OVERLAY — DOM video aligned to the canvas-drawn CRT screen.
       Geometry (left/top/width/height) is driven per-frame by game.js
       (updateCatnipTVOverlay); this block only supplies look & feel.
       ========================================================================== */
    #catnip-tv-wrap {
      position: fixed;
      z-index: 30;
      aspect-ratio: 4 / 3;          /* strict 4:3 — JS-set w/h already match */
      overflow: hidden;
      background: #000;
      border-radius: 6px;
      box-shadow:
        0 0 22px rgba(0, 229, 255, 0.35),
        inset 0 0 26px rgba(0, 0, 0, 0.85);
      outline: 2px solid #1a1d21;
      /* Native controls must stay clickable while the TV is visible
         (E-press #2 relies on the user gesture on the element itself). */
      pointer-events: auto;
    }
#catnip-tv-wrap.hidden {
      display: none;
    }
    #catnip-tv-video {
      width: 100%;
      height: 100%;
      object-fit: contain;          /* never crop the 1989 broadcast */
      background: #000;
      display: block;
    }

    /* MOVIE THEATER OVERLAY — 90vw/90vh (see .panel and the video overlay
       rules at the top of this file). The fullscreen Internet Archive film
       playback is shown only while gameState === 'THEATER' and a screening
       is active. */


/* ==========================================================================
   DEV EXPLORER CHROME (#dev-explorer-root)
   Overlay grid around the live game canvas: left stats column, right error
   column, bottom terminal. Center cell is pointer-events:none pass-through
   so gameplay is unaffected while the explorer is open. Dev tool only.
   ========================================================================== */
.cdev-root {
  position: fixed;
  inset: 0;
  z-index: 90000;
  display: grid;
  grid-template-columns: minmax(240px, 300px) 1fr minmax(260px, 320px);
  grid-template-rows: 30px 1fr 190px;
  grid-template-areas:
    "top top top"
    "left center right"
    "term term term";
  font-family: 'Courier New', monospace;
  color: #9fe8d8;
  pointer-events: none;
}
.cdev-root > * { pointer-events: auto; }
.cdev-center { pointer-events: none !important; }

.cdev-topbar {
  grid-area: top;
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 0 8px;
  background: #060a12;
  border-bottom: 1px solid rgba(46,230,214,0.35);
  font-size: 11px;
  letter-spacing: 1px;
}
.cdev-title { color: #2ee6d6; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.cdev-spacer { flex: 1; }
.cdev-badge { color: #ffd700; font-size: 10.5px; white-space: nowrap; }
.cdev-exit-btn {
  background: #12060a;
  color: #ff5566;
  border: 1px solid rgba(255,85,102,0.5);
  font-family: inherit;
  font-size: 10.5px;
  padding: 3px 10px;
  cursor: pointer;
}
.cdev-exit-btn:hover { background: #1e0a10; }

.cdev-panel {
  overflow-y: auto;
  padding: 6px 8px;
  background: rgba(4, 8, 16, 0.88);
  backdrop-filter: none;
}
.cdev-left  { grid-area: left;  border-right: 1px solid rgba(46,230,214,0.25); }
.cdev-right { grid-area: right; border-left: 1px solid rgba(46,230,214,0.25); }
.cdev-panel-title {
  font-size: 11px;
  letter-spacing: 2px;
  color: #ffd700;
  margin: 4px 0 4px;
  border-bottom: 1px dashed rgba(255,215,0,0.25);
  padding-bottom: 2px;
}
.cdev-stats {
  margin: 0 0 10px;
  font-size: 10.5px;
  line-height: 1.45;
  white-space: pre-wrap;
  word-break: break-word;
  color: #9fe8d8;
}
.cdev-errbox { color: #ffb08a; max-height: 40%; }

.cdev-center {
  grid-area: center;
  display: flex;
  align-items: flex-end;
  justify-content: center;
}
.cdev-center-note {
  font-size: 9.5px;
  color: rgba(159,232,216,0.35);
  padding-bottom: 4px;
  user-select: none;
}

/* Bottom terminal */
.cdev-term {
  grid-area: term;
  display: flex;
  flex-direction: column;
  background: rgba(2, 5, 10, 0.94);
  border-top: 1px solid rgba(46,230,214,0.35);
}
.cdev-term-out {
  flex: 1;
  overflow-y: auto;
  padding: 4px 8px;
  font-size: 11px;
  line-height: 1.4;
  white-space: pre-wrap;
  word-break: break-word;
}
.cdev-term-line { color: #b8ffef; }
.cdev-term-line.echo { color: #2ee6d6; }
.cdev-term-line.err  { color: #ff5566; }
.cdev-term-line.ok   { color: #7dff9f; }
.cdev-term-line.dim  { color: #5a7a74; }
.cdev-term-inrow {
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 4px 8px;
  border-top: 1px dashed rgba(46,230,214,0.25);
}
.cdev-prompt { color: #ffd700; font-size: 12px; letter-spacing: 1px; }
.cdev-term-input {
  flex: 1;
  background: transparent;
  border: none;
  outline: none;
  color: #eafffa;
  font-family: inherit;
  font-size: 12px;
  caret-color: #2ee6d6;
}

/* Passcode gate */
.cdev-gate {
  position: fixed;
  inset: 0;
  z-index: 90001;
  display: flex;
  align-items: center;
  justify-content: center;
  background: rgba(2, 4, 8, 0.92);
  font-family: 'Courier New', monospace;
}
.cdev-gate-panel {
  width: min(420px, 90vw);
  border: 1px solid rgba(46,230,214,0.5);
  background: #060a12;
  padding: 18px;
}
.cdev-dim { color: #5a7a74; font-size: 10.5px; margin: 6px 0 10px; }
.cdev-gate-row { display: flex; gap: 8px; }
.cdev-gate-input {
  flex: 1;
  background: #02050a;
  border: 1px solid rgba(46,230,214,0.35);
  color: #eafffa;
  font-family: inherit;
  font-size: 13px;
  padding: 6px 8px;
  outline: none;
}
.cdev-gate-btn {
  background: #04160f;
  border: 1px solid rgba(46,230,214,0.5);
  color: #2ee6d6;
  font-family: inherit;
  font-size: 12px;
  padding: 6px 14px;
  cursor: pointer;
}
.cdev-gate-msg { color: #ff5566; font-size: 11px; margin-top: 8px; min-height: 14px; letter-spacing: 2px; }
