    :root {
      --bg-deep: #0a0c10;
      --surface: rgba(18, 20, 28, 0.82);
      --surface-strong: rgba(24, 26, 36, 0.94);
      --border: rgba(255, 214, 140, 0.22);
      --border-bright: rgba(255, 226, 160, 0.55);
      --text: #f4f0e6;
      --text-muted: rgba(244, 240, 230, 0.62);
      --gold: #f5c842;
      --gold-soft: #ffe28c;
      --accent: #6ec4ff;
      --danger: #ff5c5c;
      --danger-glow: rgba(255, 92, 92, 0.35);
      --mineral: #7dd3fc;
      --radius-sm: 10px;
      --radius-md: 14px;
      --radius-lg: 18px;
      --shadow: 0 12px 40px rgba(0, 0, 0, 0.45);
      --font: "DM Sans", system-ui, -apple-system, sans-serif;
      --mono: "JetBrains Mono", ui-monospace, monospace;
      --pixel: "Press Start 2P", monospace;
      --pixel-body: "VT323", monospace;
      --pixel-bg: #120f1a;
      --pixel-panel: #1e1830;
      --pixel-panel-light: #2a2240;
      --pixel-border: #f5c842;
      --pixel-border-dark: #8a6420;
      --pixel-shadow: #0a0812;
      --pixel-text: #fff3c9;
      --pixel-muted: #b8a888;
    }
    *, *::before, *::after { box-sizing: border-box; }
    html, body {
      margin: 0;
      width: 100%;
      height: 100%;
      overflow: hidden;
      background: var(--bg-deep);
      font-family: var(--font);
      color: var(--text);
      -webkit-font-smoothing: antialiased;
      touch-action: manipulation;
      overscroll-behavior: none;
    }
    #app {
      position: relative;
      width: 100%;
      height: 100%;
    }
    canvas {
      display: block;
      width: 100vw;
      height: 100vh;
      image-rendering: pixelated;
      cursor: crosshair;
      touch-action: none;
    }
    #ui {
      position: absolute;
      inset: 0;
      pointer-events: none;
      z-index: 2;
    }
    #game-modals {
      position: fixed;
      inset: 0;
      z-index: 900;
      pointer-events: none;
    }
    body.modal-open #ui {
      pointer-events: none !important;
    }
    body.modal-open #ui * {
      pointer-events: none !important;
    }
    .hud-bar {
      display: flex;
      align-items: flex-start;
      justify-content: space-between;
      gap: 12px;
      padding: 16px;
      flex-wrap: wrap;
    }
    .hud-brand {
      padding: 4px 8px 6px;
      display: flex;
      align-items: center;
      justify-content: center;
      background: transparent;
      border: none;
      box-shadow: none;
      backdrop-filter: none;
      -webkit-backdrop-filter: none;
    }
    .brand-logo {
      display: block;
      width: 100%;
      max-width: 100%;
      height: auto;
      object-fit: contain;
      image-rendering: auto;
      filter: drop-shadow(0 6px 18px rgba(0, 0, 0, 0.55));
    }
    .hud-brand .brand-logo,
    .brand-logo.hud-brand-logo {
      width: auto;
      height: clamp(36px, 5vw, 48px);
      max-width: min(160px, 42vw);
      filter: drop-shadow(0 2px 8px rgba(0, 0, 0, 0.45));
    }
    .pixel-loader-brand {
      display: flex;
      justify-content: center;
      margin-bottom: 14px;
      background: transparent;
    }
    .loader-logo {
      max-width: min(260px, 72vw);
    }
    .menu-logo {
      max-width: min(300px, 100%);
      margin: 0 auto 8px;
    }
    .hud-card {
      pointer-events: auto;
      background: linear-gradient(165deg, rgba(38, 34, 48, 0.92), rgba(14, 14, 20, 0.88));
      border: 1px solid var(--border);
      border-radius: var(--radius-md);
      box-shadow: var(--shadow), inset 0 1px 0 rgba(255, 255, 255, 0.06);
      backdrop-filter: blur(14px);
      -webkit-backdrop-filter: blur(14px);
    }
    .hud-health {
      min-width: 220px;
      padding: 12px 16px 14px;
    }
    .hud-health-top {
      display: flex;
      align-items: center;
      justify-content: space-between;
      gap: 10px;
      margin-bottom: 8px;
    }
    .hud-label {
      font-size: 11px;
      font-weight: 600;
      letter-spacing: 0.08em;
      text-transform: uppercase;
      color: var(--text-muted);
    }
    .hud-value {
      font-family: var(--mono);
      font-size: 13px;
      font-weight: 600;
      color: var(--gold-soft);
    }
    .hp-track {
      height: 10px;
      border-radius: 999px;
      background: rgba(255, 92, 92, 0.14);
      overflow: hidden;
      border: 1px solid rgba(255, 92, 92, 0.18);
    }
    .hp-fill {
      height: 100%;
      width: 100%;
      border-radius: inherit;
      background: linear-gradient(90deg, #c92a2a, var(--danger));
      box-shadow: 0 0 12px var(--danger-glow);
      transition: width 0.25s ease;
    }
    .hud-day {
      margin-top: 8px;
      font-size: 13px;
      color: var(--text-muted);
    }
    .hud-day strong {
      color: var(--text);
      font-weight: 600;
    }
    .hud-status {
      flex: 1 1 280px;
      max-width: 560px;
      padding: 12px 18px;
      text-align: center;
    }
    #status-text {
      margin: 0;
      font-size: 13px;
      line-height: 1.45;
      color: var(--gold-soft);
      white-space: nowrap;
      overflow: hidden;
      text-overflow: ellipsis;
    }
    .hud-wallet {
      display: flex;
      flex-direction: column;
      gap: 8px;
      min-width: 168px;
      padding: 10px;
    }
    .wallet-item {
      display: flex;
      align-items: center;
      justify-content: space-between;
      gap: 12px;
      padding: 10px 12px;
      border-radius: var(--radius-sm);
      border: 1px solid rgba(255, 255, 255, 0.06);
      background: rgba(255, 255, 255, 0.03);
    }
    .wallet-item .label {
      display: flex;
      align-items: center;
      gap: 8px;
      font-size: 12px;
      font-weight: 600;
      color: var(--text-muted);
    }
    .wallet-item .amount {
      font-family: var(--mono);
      font-size: 15px;
      font-weight: 600;
    }
    .wallet-item.coins .amount { color: var(--gold); }
    .wallet-item.minerals {
      cursor: pointer;
      border: 1px solid rgba(125, 211, 252, 0.22);
      background: linear-gradient(135deg, rgba(56, 120, 170, 0.18), rgba(20, 40, 60, 0.22));
      transition: border-color 0.2s, transform 0.15s, box-shadow 0.2s;
      font: inherit;
      color: inherit;
      width: 100%;
      text-align: left;
    }
    .wallet-item.minerals:hover {
      border-color: rgba(125, 211, 252, 0.45);
      box-shadow: 0 0 0 1px rgba(125, 211, 252, 0.12);
      transform: translateY(-1px);
    }
    .wallet-item.minerals:active { transform: translateY(0); }
    .wallet-item.minerals .amount { color: var(--mineral); }
    .wallet-icon {
      width: 18px;
      height: 18px;
      border-radius: 5px;
      display: inline-grid;
      place-items: center;
      font-size: 10px;
    }
    .wallet-icon.coin {
      background: linear-gradient(145deg, #ffe08b, #c89437);
      color: #3b2a10;
      font-weight: 700;
    }
    .wallet-icon.gem {
      background: linear-gradient(145deg, #9be7ff, #3b82c4);
      color: #0f2740;
      font-weight: 700;
    }
    .hud-prompt {
      position: absolute;
      left: 50%;
      bottom: 108px;
      transform: translateX(-50%);
      pointer-events: none;
      padding: 12px 22px;
      border-radius: 999px;
      background: linear-gradient(165deg, rgba(32, 28, 40, 0.94), rgba(12, 12, 18, 0.92));
      border: 1px solid var(--border-bright);
      box-shadow: var(--shadow);
      font-size: 14px;
      font-weight: 500;
      color: var(--text);
      white-space: nowrap;
      max-width: calc(100% - 32px);
      overflow: hidden;
      text-overflow: ellipsis;
    }
    .hud-prompt.hidden { display: none; }
    .inventory-dock {
      position: fixed;
      left: 50%;
      bottom: 18px;
      transform: translateX(-50%);
      z-index: 4;
      display: flex;
      gap: 8px;
      padding: 10px 12px;
      border-radius: var(--radius-lg);
      background: linear-gradient(180deg, rgba(34, 30, 40, 0.92), rgba(12, 11, 16, 0.94));
      border: 1px solid var(--border);
      box-shadow: var(--shadow);
      backdrop-filter: blur(12px);
      -webkit-backdrop-filter: blur(12px);
      pointer-events: auto;
    }
    .inv-slot {
      position: relative;
      width: 56px;
      height: 56px;
      border: none;
      border-radius: var(--radius-sm);
      background: linear-gradient(180deg, rgba(52, 46, 58, 0.9), rgba(18, 16, 22, 0.95));
      box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.05);
      cursor: pointer;
      padding: 0;
      transition: transform 0.12s, box-shadow 0.15s, border-color 0.15s;
      border: 1px solid rgba(255, 255, 255, 0.06);
    }
    .inv-slot:hover { transform: translateY(-2px); }
    .inv-slot.selected {
      border-color: var(--border-bright);
      box-shadow: 0 0 0 1px rgba(255, 226, 160, 0.25), inset 0 1px 0 rgba(255, 255, 255, 0.12);
      background: linear-gradient(180deg, rgba(120, 90, 42, 0.55), rgba(40, 30, 18, 0.92));
    }
    .inv-slot .icon {
      position: absolute;
      left: 50%;
      top: 50%;
      width: 28px;
      height: 28px;
      transform: translate(-50%, -58%);
      border-radius: 6px;
      box-shadow: inset 0 2px 6px rgba(255, 255, 255, 0.18);
    }
    .inv-slot .icon.icon-pickaxe {
      background: linear-gradient(145deg, #cbd5e1, #64748b) !important;
      border-radius: 6px 6px 4px 4px;
    }
    .inv-slot .icon.icon-pickaxe::after {
      content: "⛏";
      position: absolute;
      inset: 0;
      display: flex;
      align-items: center;
      justify-content: center;
      font-size: 16px;
      line-height: 1;
      filter: drop-shadow(0 1px 2px rgba(0, 0, 0, 0.45));
    }
    .inv-slot .count {
      position: absolute;
      right: 6px;
      bottom: 4px;
      font-family: var(--mono);
      font-size: 11px;
      font-weight: 600;
      color: #fff;
      text-shadow: 0 1px 3px rgba(0, 0, 0, 0.8);
    }
    .inv-slot .key {
      position: absolute;
      left: 6px;
      top: 4px;
      font-family: var(--mono);
      font-size: 10px;
      font-weight: 600;
      color: rgba(255, 255, 255, 0.35);
      line-height: 1;
    }
    .drive-hud {
      position: fixed;
      left: 50%;
      bottom: 20px;
      transform: translateX(-50%);
      z-index: 5;
      display: flex;
      align-items: center;
      gap: 14px;
      padding: 10px 16px;
      border-radius: var(--radius-lg);
      background: linear-gradient(180deg, rgba(34, 30, 40, 0.96), rgba(12, 11, 16, 0.98));
      border: 1px solid rgba(245, 200, 66, 0.35);
      box-shadow: var(--shadow);
      backdrop-filter: blur(12px);
      -webkit-backdrop-filter: blur(12px);
      font-family: var(--font);
      pointer-events: none;
    }
    .drive-hud.hidden { display: none; }
    body.station-open .inventory-dock,
    body.station-open .drive-hud {
      visibility: hidden;
      pointer-events: none;
    }
    body.station-open .hud-prompt { display: none !important; }

    /* ---- Touch controls (mobile) ---- */
    .touch-controls {
      position: fixed;
      left: 0;
      right: 0;
      bottom: 0;
      z-index: 6;
      pointer-events: none;
      display: none;
    }
    .touch-controls.visible {
      display: flex;
      align-items: flex-end;
      justify-content: space-between;
      gap: 10px;
      padding: 8px 10px calc(8px + env(safe-area-inset-bottom));
      background: linear-gradient(0deg, rgba(8, 10, 14, 0.94) 0%, rgba(8, 10, 14, 0.72) 55%, transparent 100%);
    }
    .touch-cluster {
      display: grid;
      gap: 6px;
      pointer-events: none;
      flex-shrink: 0;
    }
    .touch-move {
      grid-template-columns: 46px 46px 46px;
      grid-template-rows: 46px 46px;
      grid-template-areas:
        ". up ."
        "left down right";
    }
    .touch-left { grid-area: left; }
    .touch-up { grid-area: up; }
    .touch-right { grid-area: right; }
    .touch-down { grid-area: down; }
    .touch-actions {
      grid-template-columns: 46px;
      grid-auto-rows: 46px;
      align-self: flex-end;
    }
    .touch-btn {
      width: 46px;
      height: 46px;
      border-radius: 12px;
      border: 1px solid rgba(255, 214, 140, 0.35);
      background: linear-gradient(165deg, rgba(38, 34, 48, 0.92), rgba(14, 14, 20, 0.9));
      color: var(--gold-soft);
      font-size: 20px;
      font-weight: 700;
      line-height: 1;
      box-shadow: 0 6px 18px rgba(0, 0, 0, 0.35);
      backdrop-filter: blur(10px);
      -webkit-backdrop-filter: blur(10px);
      pointer-events: auto;
      touch-action: manipulation;
      user-select: none;
      -webkit-user-select: none;
      cursor: pointer;
      transition: transform 0.08s ease, background 0.08s ease;
    }
    .touch-btn.pressed,
    .touch-btn:active {
      transform: scale(0.94);
      background: linear-gradient(165deg, rgba(245, 200, 66, 0.24), rgba(24, 20, 28, 0.95));
    }
    .touch-btn.gold {
      color: #1a1208;
      background: linear-gradient(180deg, #ffd86b, #c9971e);
      border-color: #e8b830;
      font-size: 16px;
      font-family: var(--mono);
      font-weight: 800;
    }
    .touch-btn.touch-mine { font-size: 22px; }

    /* Compact mobile HUD + layout zones */
    html.mobile-viewport body.game-active {
      --mobile-touch-h: calc(96px + env(safe-area-inset-bottom));
      --mobile-inv-h: 42px;
    }
    html.mobile-viewport body.game-active .hud-bar {
      display: grid;
      grid-template-columns: minmax(0, 1fr);
      grid-template-areas:
        "stats"
        "wallet";
      padding: calc(6px + env(safe-area-inset-top)) 8px 4px;
      gap: 4px;
      align-items: stretch;
    }
    html.mobile-viewport body.game-active .hud-brand {
      display: none;
    }
    html.mobile-viewport body.game-active .hud-health {
      grid-area: stats;
      min-width: 0;
      padding: 5px 10px 4px;
    }
    html.mobile-viewport body.game-active .hud-health-top {
      margin-bottom: 3px;
    }
    html.mobile-viewport body.game-active .hud-health-top .hud-label {
      font-size: 9px;
      letter-spacing: 0.06em;
    }
    html.mobile-viewport body.game-active .hud-value {
      font-size: 11px;
    }
    html.mobile-viewport body.game-active .hp-track {
      height: 5px;
    }
    html.mobile-viewport body.game-active .hud-day {
      margin-top: 2px;
      font-size: 10px;
    }
    html.mobile-viewport body.game-active .hud-status {
      display: none !important;
    }
    html.mobile-viewport body.game-active .hud-wallet {
      grid-area: wallet;
      flex-direction: row;
      flex-wrap: nowrap;
      min-width: 0;
      width: 100%;
      padding: 2px;
      gap: 4px;
    }
    html.mobile-viewport body.game-active .wallet-item {
      flex: 1 1 0;
      min-width: 0;
      padding: 4px 5px;
      gap: 2px;
      flex-direction: row;
      align-items: center;
      justify-content: center;
    }
    html.mobile-viewport body.game-active .wallet-item .label {
      font-size: 0;
      gap: 0;
      line-height: 0;
    }
    html.mobile-viewport body.game-active .wallet-item .label .wallet-icon {
      font-size: 9px;
    }
    html.mobile-viewport body.game-active .wallet-item .amount {
      font-size: 11px;
      line-height: 1.1;
    }
    html.mobile-viewport body.game-active .wallet-icon {
      width: 16px;
      height: 16px;
      font-size: 9px;
      border-radius: 4px;
      flex-shrink: 0;
    }
    html.mobile-viewport body.game-active .inventory-dock {
      left: 8px;
      right: 8px;
      bottom: var(--mobile-touch-h);
      transform: none;
      width: auto;
      max-width: none;
      justify-content: flex-start;
      padding: 3px 5px;
      gap: 4px;
      border-radius: 12px;
      overflow-x: auto;
      -webkit-overflow-scrolling: touch;
    }
    html.mobile-viewport body.game-active .inv-slot {
      width: 34px;
      height: 34px;
      min-width: 34px;
      flex-shrink: 0;
    }
    html.mobile-viewport body.game-active .inv-slot .icon {
      width: 18px;
      height: 18px;
    }
    html.mobile-viewport body.game-active .inv-slot .count {
      font-size: 8px;
      right: 2px;
      bottom: 1px;
    }
    html.mobile-viewport body.game-active .inv-slot .key {
      display: none;
    }
    html.mobile-viewport body.game-active .hud-prompt {
      bottom: calc(var(--mobile-touch-h) + var(--mobile-inv-h) + 8px);
      font-size: 11px;
      padding: 6px 12px;
      white-space: normal;
      text-align: center;
      line-height: 1.35;
      max-width: min(88vw, 280px);
      border-radius: 12px;
    }
    html.mobile-viewport body.game-active .drive-hud {
      bottom: calc(var(--mobile-touch-h) + 6px);
      padding: 6px 10px;
      gap: 8px;
      font-size: 11px;
      max-width: calc(100vw - 16px);
      flex-wrap: wrap;
      justify-content: center;
    }
    html.mobile-viewport body.game-active .drive-hud-keys {
      font-size: 10px;
      gap: 4px;
    }
    html.mobile-viewport body.game-active .drive-hud-keys kbd {
      display: none;
    }
    html.mobile-viewport body.game-active .drive-hud-keys span:not(.drive-hud-label) {
      display: none;
    }
    html.mobile-viewport body.game-active.is-driving .touch-move .touch-up,
    html.mobile-viewport body.game-active.is-driving .touch-move .touch-down,
    html.mobile-viewport body.game-active.is-driving .touch-actions {
      display: none;
    }
    html.mobile-viewport body.game-active.is-driving .touch-move {
      grid-template-columns: 48px 48px;
      grid-template-rows: 48px;
      grid-template-areas: "left right";
      gap: 8px;
    }
    html.mobile-viewport body.game-active.is-driving .touch-btn {
      width: 48px;
      height: 48px;
    }
    body.modal-open .touch-controls { display: none !important; }

    .drive-hud-keys {
      display: flex;
      align-items: center;
      gap: 6px;
      font-size: 12px;
      color: var(--text-muted);
    }
    .drive-hud-keys span:not(.drive-hud-label) {
      font-size: 10px;
      text-transform: uppercase;
      letter-spacing: 0.04em;
    }
    .drive-hud-label { color: var(--text); font-weight: 600; }
    .drive-hud-exit {
      padding-left: 12px;
      border-left: 1px solid rgba(255, 255, 255, 0.1);
    }
    .drive-hud kbd {
      display: inline-flex;
      align-items: center;
      justify-content: center;
      min-width: 26px;
      height: 26px;
      padding: 0 7px;
      border-radius: 7px;
      border: 1px solid rgba(255, 255, 255, 0.14);
      background: linear-gradient(180deg, rgba(60, 54, 68, 0.95), rgba(24, 20, 28, 0.98));
      box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.08);
      font-family: var(--mono);
      font-size: 12px;
      font-weight: 700;
      color: var(--gold-soft);
    }
    .dialog-backdrop {
      position: fixed;
      inset: 0;
      z-index: 1;
      background: rgba(4, 6, 10, 0.62);
      backdrop-filter: blur(6px);
      -webkit-backdrop-filter: blur(6px);
      opacity: 0;
      pointer-events: none;
      transition: opacity 0.22s ease;
    }
    .dialog-backdrop.open {
      opacity: 1;
      pointer-events: auto;
    }
    .minerals-dialog {
      position: fixed;
      left: 50%;
      top: 50%;
      z-index: 2;
      width: min(420px, calc(100vw - 32px));
      max-height: min(78vh, 560px);
      margin: 0;
      padding: 0;
      border: 1px solid var(--border-bright);
      border-radius: var(--radius-lg);
      background: linear-gradient(165deg, rgba(28, 26, 38, 0.98), rgba(10, 10, 16, 0.98));
      box-shadow: 0 24px 64px rgba(0, 0, 0, 0.55);
      color: var(--text);
      transform: translate(-50%, -48%) scale(0.96);
      opacity: 0;
      pointer-events: none;
      transition: opacity 0.22s ease, transform 0.22s ease;
      overflow: hidden;
      font-family: var(--font);
    }
    .minerals-dialog.open {
      opacity: 1;
      pointer-events: auto;
      transform: translate(-50%, -50%) scale(1);
    }
    .minerals-dialog::backdrop { display: none; }
    .dialog-header {
      display: flex;
      align-items: center;
      justify-content: space-between;
      gap: 12px;
      padding: 18px 20px 14px;
      border-bottom: 1px solid rgba(255, 255, 255, 0.06);
    }
    .dialog-header h2 {
      margin: 0;
      font-size: 18px;
      font-weight: 700;
      letter-spacing: -0.02em;
      color: var(--gold-soft);
    }
    .dialog-close {
      width: 36px;
      height: 36px;
      border: 1px solid rgba(255, 255, 255, 0.1);
      border-radius: 10px;
      background: rgba(255, 255, 255, 0.04);
      color: var(--text-muted);
      font-size: 18px;
      line-height: 1;
      cursor: pointer;
      transition: background 0.15s, color 0.15s;
    }
    .dialog-close:hover {
      background: rgba(255, 255, 255, 0.08);
      color: var(--text);
    }
    .dialog-summary {
      display: flex;
      align-items: center;
      justify-content: space-between;
      padding: 14px 20px;
      background: rgba(125, 211, 252, 0.08);
      border-bottom: 1px solid rgba(125, 211, 252, 0.12);
    }
    .dialog-summary span { font-size: 13px; color: var(--text-muted); }
    .dialog-summary strong {
      font-family: var(--mono);
      font-size: 22px;
      color: var(--mineral);
    }
    .minerals-list {
      padding: 10px 12px 16px;
      overflow-y: auto;
      max-height: calc(78vh - 180px);
    }
    .mineral-row {
      display: flex;
      align-items: center;
      gap: 12px;
      padding: 10px 10px;
      border-radius: var(--radius-sm);
      transition: background 0.15s;
    }
    .mineral-row:hover { background: rgba(255, 255, 255, 0.04); }
    .mineral-row .swatch {
      width: 34px;
      height: 34px;
      border-radius: 8px;
      flex-shrink: 0;
      box-shadow: inset 0 2px 6px rgba(255, 255, 255, 0.2);
    }
    .mineral-row .info { flex: 1; min-width: 0; }
    .mineral-row .name {
      font-size: 14px;
      font-weight: 600;
      margin: 0 0 2px;
    }
    .mineral-row .price {
      font-size: 12px;
      color: var(--text-muted);
      margin: 0;
    }
    .mineral-row .qty {
      font-family: var(--mono);
      font-size: 16px;
      font-weight: 600;
      color: var(--mineral);
    }
    .minerals-empty {
      padding: 28px 20px;
      text-align: center;
      color: var(--text-muted);
      font-size: 14px;
      line-height: 1.5;
    }
    .dialog-footer {
      padding: 12px 20px 18px;
      border-top: 1px solid rgba(255, 255, 255, 0.06);
      font-size: 12px;
      color: var(--text-muted);
      text-align: center;
    }
    .shop-dialog {
      position: fixed;
      left: 0;
      top: 0;
      z-index: 2;
      width: min(440px, calc(100vw - 24px));
      max-height: min(72vh, 540px);
      margin: 0;
      padding: 0;
      border: 1px solid var(--border-bright);
      border-radius: var(--radius-lg);
      background: linear-gradient(165deg, rgba(28, 26, 38, 0.98), rgba(10, 10, 16, 0.98));
      box-shadow: 0 24px 64px rgba(0, 0, 0, 0.55);
      color: var(--text);
      transform: scale(0.94);
      transform-origin: bottom center;
      opacity: 0;
      pointer-events: none;
      transition: opacity 0.2s ease, transform 0.2s ease;
      overflow: hidden;
      font-family: var(--font);
      display: flex;
      flex-direction: column;
    }
    .shop-dialog.open {
      opacity: 1;
      pointer-events: auto;
      transform: scale(1);
    }
    .shop-summary {
      background: rgba(245, 200, 66, 0.08);
      border-bottom-color: rgba(245, 200, 66, 0.12);
    }
    .shop-summary strong { color: var(--gold-soft); }
    .shop-pickaxe {
      margin: 0;
      padding: 10px 20px;
      font-size: 13px;
      border-bottom: 1px solid rgba(255, 255, 255, 0.06);
    }
    .shop-pickaxe.ok { color: var(--mineral); }
    .shop-pickaxe.warn { color: #ffb4b4; }
    .shop-minerals-list {
      flex: 1;
      padding: 8px 10px 10px;
      overflow-y: auto;
      max-height: min(52vh, 360px);
    }
    .shop-mineral-row {
      display: grid;
      grid-template-columns: 36px 1fr auto;
      grid-template-rows: auto auto;
      gap: 4px 10px;
      align-items: center;
      padding: 10px;
      margin-bottom: 6px;
      border-radius: var(--radius-sm);
      border: 1px solid rgba(255, 255, 255, 0.06);
      background: rgba(255, 255, 255, 0.02);
    }
    .shop-mineral-row .swatch {
      grid-row: 1 / span 2;
      width: 36px;
      height: 36px;
      border-radius: 8px;
      box-shadow: inset 0 2px 6px rgba(255, 255, 255, 0.2);
    }
    .shop-mineral-row .info { min-width: 0; }
    .shop-mineral-row .name-row {
      display: flex;
      align-items: center;
      gap: 8px;
      flex-wrap: wrap;
    }
    .shop-mineral-row .name {
      margin: 0;
      font-size: 14px;
      font-weight: 600;
    }
    .rarity-badge {
      font-size: 10px;
      font-weight: 600;
      letter-spacing: 0.04em;
      text-transform: uppercase;
      padding: 2px 7px;
      border-radius: 999px;
      border: 1px solid currentColor;
    }
    .rarity-common .rarity-badge { color: #9ca3af; background: rgba(156, 163, 175, 0.12); }
    .rarity-uncommon .rarity-badge { color: #34d399; background: rgba(52, 211, 153, 0.12); }
    .rarity-rare .rarity-badge { color: #60a5fa; background: rgba(96, 165, 250, 0.12); }
    .rarity-epic .rarity-badge { color: #c084fc; background: rgba(192, 132, 252, 0.12); }
    .rarity-legendary .rarity-badge { color: #fbbf24; background: rgba(251, 191, 36, 0.14); }
    .shop-mineral-row .price {
      margin: 0;
      font-size: 12px;
      color: var(--text-muted);
    }
    .shop-mineral-row .price .coin { color: var(--gold-soft); font-weight: 600; }
    .shop-mineral-row .owned {
      grid-column: 3;
      grid-row: 1;
      text-align: right;
    }
    .shop-mineral-row .qty-label {
      display: block;
      font-size: 10px;
      color: var(--text-muted);
      text-transform: uppercase;
      letter-spacing: 0.04em;
    }
    .shop-mineral-row .qty {
      font-family: var(--mono);
      font-size: 16px;
      font-weight: 600;
      color: var(--mineral);
    }
    .shop-mineral-row .sell-actions {
      grid-column: 2 / span 2;
      display: flex;
      gap: 6px;
      flex-wrap: wrap;
    }
    .sell-btn {
      flex: 1;
      min-width: 72px;
      padding: 7px 10px;
      border-radius: 8px;
      border: 1px solid rgba(255, 255, 255, 0.12);
      background: rgba(125, 211, 252, 0.1);
      color: var(--text);
      font-size: 12px;
      font-weight: 600;
      cursor: pointer;
      transition: background 0.15s, opacity 0.15s;
    }
    .sell-btn:hover:not(:disabled) { background: rgba(125, 211, 252, 0.2); }
    .sell-btn:disabled { opacity: 0.35; cursor: not-allowed; }
    .sell-btn.sell-all {
      background: rgba(245, 200, 66, 0.12);
      border-color: rgba(245, 200, 66, 0.25);
    }
    .sell-btn.sell-all:hover:not(:disabled) { background: rgba(245, 200, 66, 0.22); }
    .shop-footer {
      display: flex;
      flex-direction: column;
      gap: 8px;
      padding-top: 10px;
    }
    .shop-buy-btn {
      width: 100%;
      padding: 11px 16px;
      border-radius: 10px;
      border: 1px solid rgba(245, 200, 66, 0.35);
      background: linear-gradient(180deg, rgba(245, 200, 66, 0.22), rgba(245, 200, 66, 0.1));
      color: var(--gold-soft);
      font-size: 14px;
      font-weight: 700;
      cursor: pointer;
      transition: background 0.15s, opacity 0.15s;
    }
    .shop-buy-btn:hover:not(:disabled) { background: linear-gradient(180deg, rgba(245, 200, 66, 0.32), rgba(245, 200, 66, 0.16)); }
    .shop-buy-btn:disabled { opacity: 0.4; cursor: not-allowed; }
    .shop-hint { margin: 0; font-size: 11px; line-height: 1.4; }
    .dealer-dialog {
      max-height: min(78vh, 640px);
      z-index: 2;
    }
    .dealer-dialog.open .dealer-buy-btn { pointer-events: auto; }
    .dealer-cars-list { max-height: min(52vh, 480px); overflow-y: auto; }
    .dealer-car-row, .car-inv-row {
      display: grid;
      grid-template-columns: 44px minmax(0, 1fr) auto;
      gap: 10px;
      align-items: center;
      padding: 10px 12px;
      border-radius: var(--radius-sm);
      background: rgba(255, 255, 255, 0.03);
      border: 1px solid rgba(255, 255, 255, 0.06);
      margin-bottom: 8px;
      position: relative;
    }
    .car-swatch {
      width: 44px;
      height: 32px;
      border-radius: 6px;
      overflow: hidden;
      background: rgba(12, 14, 20, 0.85);
      border: 1px solid rgba(0, 0, 0, 0.14);
      flex-shrink: 0;
      box-shadow: inset 0 2px 6px rgba(255, 255, 255, 0.12);
    }
    .car-swatch img {
      display: block;
      width: 100%;
      height: 100%;
      object-fit: contain;
      image-rendering: pixelated;
    }
    .dealer-car-info .name-row, .car-inv-info .name-row {
      display: flex;
      align-items: center;
      gap: 8px;
      flex-wrap: wrap;
    }
    .dealer-car-info .name, .car-inv-info .name {
      margin: 0;
      font-size: 14px;
      font-weight: 600;
      color: #fff3c9;
    }
    .dealer-car-info .meta, .car-inv-info .meta {
      margin: 2px 0 0;
      font-size: 11px;
      color: var(--text-muted);
    }
    .dealer-car-info .price {
      margin: 4px 0 0;
      font-family: var(--mono);
      font-size: 13px;
      color: var(--gold-soft);
    }
    .dealer-buy-btn { min-width: 88px; white-space: nowrap; }
    .tier-common { border-color: rgba(156, 163, 175, 0.2); }
    .tier-standard { border-color: rgba(52, 211, 153, 0.22); }
    .tier-sport { border-color: rgba(96, 165, 250, 0.24); }
    .tier-luxury { border-color: rgba(192, 132, 252, 0.24); }
    .tier-super { border-color: rgba(251, 191, 36, 0.28); }
    .tier-hyper { border-color: rgba(255, 120, 120, 0.32); box-shadow: 0 0 12px rgba(255, 180, 80, 0.08); }
    .car-inv-list {
      display: grid;
      gap: 8px;
      margin-bottom: 8px;
      max-height: min(300px, 42vh);
      overflow-y: auto;
      overscroll-behavior: contain;
      padding-right: 6px;
      -webkit-overflow-scrolling: touch;
    }
    .car-inv-list::-webkit-scrollbar { width: 6px; }
    .car-inv-list::-webkit-scrollbar-thumb {
      background: rgba(245, 200, 66, 0.35);
      border-radius: 999px;
    }
    .inv-scroll-hint {
      font-size: 10px;
      font-weight: 600;
      letter-spacing: 0.04em;
      text-transform: uppercase;
      color: var(--text-muted);
    }
    .inv-station-layout {
      display: flex;
      flex-direction: column;
      min-height: 0;
      flex: 1;
    }
    .station-dialog.inventory-mode {
      max-height: min(82vh, 680px);
      width: min(580px, calc(100vw - 20px));
    }
    .station-dialog.inventory-mode.open {
      transform-origin: center center;
    }
    .station-dialog.inventory-mode .station-body {
      display: flex;
      flex-direction: column;
      overflow: hidden;
      max-height: min(68vh, 560px);
      padding-bottom: 10px;
    }
    .inv-items-grid { margin-bottom: 8px; flex-shrink: 0; }
    .car-inv-info { min-width: 0; }
    .car-inv-actions {
      display: flex;
      flex-direction: column;
      gap: 6px;
      align-items: stretch;
      position: relative;
      z-index: 4;
      pointer-events: auto;
      flex-shrink: 0;
    }
    .spawn-car-btn, .recall-car-btn, .sell-car-btn {
      min-width: 100px;
      font-size: 12px;
      padding: 8px 10px;
      position: relative;
      z-index: 5;
      pointer-events: auto;
      cursor: pointer;
      touch-action: manipulation;
    }
    .inv-section-title {
      margin: 12px 0 8px;
      font-size: 12px;
      font-weight: 700;
      letter-spacing: 0.06em;
      text-transform: uppercase;
      color: var(--gold-soft);
    }
    .inv-section-title:first-child { margin-top: 0; }
    .wallet-item.inventory-btn {
      cursor: pointer;
      border: none;
      font: inherit;
      color: inherit;
      text-align: left;
    }
    .wallet-icon.inv { color: #c4b5fd; }
    .purchase-dialog {
      position: fixed;
      left: 50%;
      top: 50%;
      z-index: 3;
      width: min(460px, calc(100vw - 24px));
      margin: 0;
      padding: 0;
      border: 1px solid rgba(245, 200, 66, 0.45);
      border-radius: var(--radius-lg);
      background: linear-gradient(165deg, rgba(36, 30, 22, 0.98), rgba(12, 10, 14, 0.98));
      box-shadow: 0 28px 72px rgba(0, 0, 0, 0.6), 0 0 40px rgba(245, 200, 66, 0.12);
      color: var(--text);
      transform: translate(-50%, -48%) scale(0.94);
      opacity: 0;
      pointer-events: none;
      transition: opacity 0.22s ease, transform 0.22s ease;
      overflow: hidden;
      font-family: var(--font);
    }
    .purchase-dialog.open {
      opacity: 1;
      pointer-events: auto;
      transform: translate(-50%, -50%) scale(1);
    }
    .purchase-glow {
      position: absolute;
      inset: -30% -10% auto;
      height: 55%;
      background: radial-gradient(ellipse at 50% 0%, rgba(245, 200, 66, 0.22), transparent 70%);
      pointer-events: none;
    }
    .purchase-header {
      position: relative;
      flex-direction: column;
      align-items: flex-start;
      gap: 4px;
      padding-bottom: 12px;
      background: linear-gradient(180deg, rgba(245, 200, 66, 0.1), transparent);
    }
    .purchase-header h2 { color: var(--gold-soft); font-size: 22px; }
    .purchase-badge {
      font-size: 10px;
      font-weight: 700;
      letter-spacing: 0.12em;
      text-transform: uppercase;
      color: #ffd56e;
    }
    .purchase-body { padding: 16px 20px 8px; position: relative; }
    .purchase-hero {
      display: flex;
      gap: 14px;
      align-items: center;
      margin-bottom: 16px;
      padding: 12px;
      border-radius: var(--radius-md);
      background: rgba(255, 255, 255, 0.04);
      border: 1px solid rgba(245, 200, 66, 0.15);
    }
    .purchase-hero img {
      width: 120px;
      height: auto;
      image-rendering: pixelated;
      filter: drop-shadow(0 6px 12px rgba(0, 0, 0, 0.35));
    }
    .purchase-car-name {
      margin: 0 0 4px;
      font-size: 18px;
      font-weight: 700;
      color: var(--gold-soft);
    }
    .purchase-car-sub {
      margin: 0;
      font-size: 13px;
      color: var(--text-muted);
    }
    .purchase-steps {
      margin: 0;
      padding-left: 20px;
      display: grid;
      gap: 10px;
      font-size: 14px;
      line-height: 1.45;
      color: var(--text);
    }
    .purchase-steps strong { color: var(--gold-soft); }
    .purchase-footer {
      display: flex;
      gap: 10px;
      padding: 14px 16px 18px;
      border-top: 1px solid rgba(255, 255, 255, 0.06);
    }
    .purchase-footer .action-btn { flex: 1; min-width: 0; }
    .station-dialog {
      position: fixed;
      left: 0;
      top: 0;
      z-index: 2;
      width: min(460px, calc(100vw - 24px));
      max-height: min(74vh, 560px);
      margin: 0;
      padding: 0;
      border: 1px solid var(--border-bright);
      border-radius: var(--radius-lg);
      background: linear-gradient(165deg, rgba(28, 26, 38, 0.98), rgba(10, 10, 16, 0.98));
      box-shadow: 0 24px 64px rgba(0, 0, 0, 0.55);
      color: var(--text);
      transform: scale(0.94);
      transform-origin: bottom center;
      opacity: 0;
      pointer-events: none;
      transition: opacity 0.2s ease, transform 0.2s ease;
      overflow: hidden;
      font-family: var(--font);
      display: flex;
      flex-direction: column;
    }
    .station-dialog.open {
      opacity: 1;
      pointer-events: auto;
      transform: scale(1);
    }
    .station-dialog.wide { width: min(560px, calc(100vw - 24px)); }
    .station-body {
      flex: 1;
      padding: 14px 16px 16px;
      overflow-y: auto;
      max-height: min(62vh, 480px);
    }
    .station-summary {
      display: flex;
      align-items: center;
      justify-content: space-between;
      gap: 12px;
      padding: 12px 16px;
      background: rgba(255, 255, 255, 0.04);
      border-bottom: 1px solid rgba(255, 255, 255, 0.06);
      font-size: 13px;
    }
    .station-summary strong {
      font-family: var(--mono);
      font-size: 18px;
      color: var(--gold-soft);
    }
    .station-note {
      margin: 0 0 12px;
      font-size: 13px;
      color: var(--text-muted);
      line-height: 1.45;
    }
    .station-note.warn { color: #ffb4b4; }
    .station-note.ok { color: var(--mineral); }
    .station-actions {
      display: flex;
      flex-wrap: wrap;
      gap: 8px;
      margin-top: 12px;
    }
    .station-dialog.open,
    .shop-dialog.open,
    .dealer-dialog.open,
    .minerals-dialog.open,
    .purchase-dialog.open {
      pointer-events: auto;
    }
    .station-dialog:not(.open),
    .shop-dialog:not(.open),
    .dealer-dialog:not(.open),
    .minerals-dialog:not(.open),
    .purchase-dialog:not(.open) {
      pointer-events: none;
    }
    .dialog-header,
    .dialog-footer,
    .station-body,
    .station-actions,
    .shop-minerals-list,
    .dealer-cars-list,
    .purchase-body {
      position: relative;
      z-index: 1;
    }
    .action-btn,
    .shop-buy-btn,
    .shop-sell-btn,
    .sell-btn,
    .dealer-buy-btn,
    .dialog-close,
    .spawn-car-btn,
    .recall-car-btn,
    .sell-car-btn {
      position: relative;
      z-index: 2;
      pointer-events: auto;
      touch-action: manipulation;
    }
    .action-btn {
      flex: 1;
      min-width: 120px;
      padding: 10px 14px;
      border-radius: 10px;
      border: 1px solid rgba(255, 255, 255, 0.12);
      background: rgba(125, 211, 252, 0.1);
      color: var(--text);
      font-size: 13px;
      font-weight: 600;
      cursor: pointer;
      transition: background 0.15s, opacity 0.15s;
    }
    .action-btn:hover:not(:disabled) { background: rgba(125, 211, 252, 0.2); }
    .action-btn:disabled { opacity: 0.35; cursor: not-allowed; }
    .action-btn.gold {
      background: rgba(245, 200, 66, 0.12);
      border-color: rgba(245, 200, 66, 0.25);
      color: var(--gold-soft);
    }
    .action-btn.gold:hover:not(:disabled) { background: rgba(245, 200, 66, 0.22); }
    .inv-grid, .market-grid {
      display: grid;
      gap: 8px;
    }
    .inv-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
    .inv-item, .market-row, .furnace-row {
      display: flex;
      align-items: center;
      gap: 10px;
      padding: 10px;
      border-radius: var(--radius-sm);
      border: 1px solid rgba(255, 255, 255, 0.06);
      background: rgba(255, 255, 255, 0.02);
    }
    .inv-item .swatch, .market-row .swatch {
      width: 28px;
      height: 28px;
      border-radius: 7px;
      flex-shrink: 0;
    }
    .inv-item .name, .market-row .info { flex: 1; min-width: 0; }
    .inv-item .name, .market-row .name {
      margin: 0;
      font-size: 13px;
      font-weight: 600;
    }
    .market-row .meta {
      margin: 0;
      font-size: 11px;
      color: var(--text-muted);
    }
    .market-row .sell-actions { display: flex; gap: 6px; flex-wrap: wrap; }
    .craft-grid {
      display: grid;
      grid-template-columns: repeat(2, minmax(0, 1fr));
      gap: 10px;
    }
    .craft-card {
      padding: 12px;
      border-radius: var(--radius-sm);
      border: 1px solid rgba(120, 112, 102, 0.35);
      background: rgba(36, 34, 40, 0.78);
    }
    .craft-card.ready {
      border-color: rgba(255, 218, 128, 0.55);
      background: rgba(82, 63, 43, 0.55);
    }
    .craft-card h3 {
      margin: 0 0 4px;
      font-size: 14px;
      color: var(--gold-soft);
    }
    .craft-card p {
      margin: 0 0 6px;
      font-size: 12px;
      color: var(--text-muted);
      line-height: 1.35;
    }
    .craft-card .yield { color: #fff3c9; }
    .craft-card .action-btn { width: 100%; margin-top: 8px; min-width: 0; }
    .station-footer {
      padding: 12px 16px 16px;
      border-top: 1px solid rgba(255, 255, 255, 0.06);
      font-size: 11px;
      color: var(--text-muted);
      text-align: center;
    }
    body.is-loading #app,
    body.menu-open #app {
      visibility: hidden;
      pointer-events: none;
    }
    body.game-active #app {
      visibility: visible;
    }

    /* ---- Pixel UI (loader + menu) ---- */
    .pixel-screen {
      position: fixed;
      inset: 0;
      z-index: 9998;
      display: flex;
      align-items: flex-end;
      justify-content: center;
      padding: clamp(12px, 3vw, 28px);
      overflow: hidden;
      background: var(--pixel-bg);
      font-family: var(--pixel-body);
      color: var(--pixel-text);
    }
    #loading-screen { z-index: 9999; }
    .pixel-screen.hidden { display: none; }
    #loading-screen.loading-out,
    #main-menu.menu-out {
      opacity: 0;
      transform: scale(1.015);
      pointer-events: none;
      transition: opacity 0.55s ease, transform 0.55s ease;
    }
    #main-menu.menu-in {
      animation: menuFadeIn 0.55s ease forwards;
    }
    @keyframes menuFadeIn {
      from { opacity: 0; transform: translateY(12px); }
      to { opacity: 1; transform: translateY(0); }
    }

    .pixel-screen-bg {
      position: absolute;
      inset: 0;
      z-index: 0;
    }
    .pixel-hero-art {
      width: 100%;
      height: 100%;
      object-fit: cover;
      object-position: center 42%;
      image-rendering: auto;
      filter: saturate(1.08) contrast(1.04);
    }
    .pixel-scanlines {
      position: absolute;
      inset: 0;
      pointer-events: none;
      opacity: 0.12;
      background: repeating-linear-gradient(
        0deg,
        transparent,
        transparent 2px,
        rgba(0, 0, 0, 0.35) 2px,
        rgba(0, 0, 0, 0.35) 4px
      );
    }
    .pixel-vignette {
      position: absolute;
      inset: 0;
      pointer-events: none;
      background:
        linear-gradient(180deg, rgba(18, 15, 26, 0.35) 0%, transparent 30%, rgba(18, 15, 26, 0.88) 100%),
        radial-gradient(ellipse 80% 60% at 50% 40%, transparent 20%, rgba(0, 0, 0, 0.5) 100%);
    }
    .pixel-vignette-menu {
      background:
        linear-gradient(180deg, rgba(18, 15, 26, 0.5) 0%, rgba(18, 15, 26, 0.15) 40%, rgba(18, 15, 26, 0.92) 100%),
        radial-gradient(ellipse 90% 70% at 50% 35%, transparent 15%, rgba(0, 0, 0, 0.55) 100%);
    }

    .pixel-frame {
      position: relative;
      z-index: 1;
      background: linear-gradient(180deg, var(--pixel-panel-light) 0%, var(--pixel-panel) 100%);
      border: 4px solid var(--pixel-border);
      box-shadow:
        0 0 0 2px var(--pixel-shadow),
        0 0 0 6px var(--pixel-border-dark),
        0 8px 0 6px var(--pixel-shadow),
        0 16px 40px rgba(0, 0, 0, 0.55),
        inset 0 2px 0 rgba(255, 255, 255, 0.08),
        inset 0 -4px 0 rgba(0, 0, 0, 0.25);
    }

    .pixel-kicker {
      margin: 0 0 6px;
      font-family: var(--pixel);
      font-size: clamp(7px, 1.6vw, 9px);
      letter-spacing: 0.12em;
      color: var(--gold-soft);
      text-shadow: 2px 2px 0 var(--pixel-shadow);
    }
    .pixel-logo {
      margin: 0;
      font-family: var(--pixel);
      font-size: clamp(14px, 3.8vw, 22px);
      line-height: 1.45;
      color: #fff7dc;
      text-shadow:
        3px 3px 0 var(--pixel-shadow),
        0 0 24px rgba(245, 200, 66, 0.35);
    }
    .pixel-badge {
      flex: 0 0 auto;
      width: 52px;
      height: 52px;
      display: grid;
      place-items: center;
      font-size: 24px;
      background: var(--pixel-panel);
      border: 3px solid var(--pixel-border);
      box-shadow: 3px 3px 0 var(--pixel-shadow);
    }

    /* ---- Loader panel ---- */
    .pixel-loader-panel {
      width: min(520px, 100%);
      padding: 16px 18px 14px;
      margin-bottom: clamp(8px, 2vh, 24px);
    }
    .pixel-loader-top {
      display: flex;
      align-items: center;
      gap: 14px;
      margin-bottom: 16px;
    }
    .pixel-progress-block {
      padding: 12px;
      background: rgba(0, 0, 0, 0.28);
      border: 3px solid rgba(245, 200, 66, 0.35);
      box-shadow: inset 0 2px 8px rgba(0, 0, 0, 0.35);
    }
    .pixel-progress-head {
      display: flex;
      justify-content: space-between;
      align-items: center;
      gap: 10px;
      margin-bottom: 10px;
      font-family: var(--pixel);
      font-size: 8px;
      color: var(--pixel-muted);
      text-shadow: 1px 1px 0 var(--pixel-shadow);
    }
    .pixel-percent {
      color: var(--gold-soft);
    }
    .pixel-progress-track {
      position: relative;
      height: 16px;
      background: #0c0a12;
      border: 3px solid #3a3050;
      box-shadow: inset 0 2px 6px rgba(0, 0, 0, 0.6);
      overflow: hidden;
    }
    .pixel-progress-fill {
      width: 0%;
      height: 100%;
      background: repeating-linear-gradient(
        90deg,
        #c8942a 0px,
        #f5c842 8px,
        #ffe28c 8px,
        #f5c842 16px
      );
      box-shadow: 0 0 12px rgba(245, 200, 66, 0.5);
      transition: width 0.3s steps(6);
    }
    .pixel-segments {
      display: flex;
      gap: 3px;
      margin-top: 8px;
    }
    .pixel-seg {
      flex: 1;
      height: 6px;
      background: #2a2238;
      border: 1px solid #3a3050;
      transition: background 0.15s, box-shadow 0.15s;
    }
    .pixel-seg.on {
      background: var(--gold);
      box-shadow: 0 0 6px rgba(245, 200, 66, 0.6);
      border-color: #ffe28c;
    }
    .pixel-status {
      margin: 10px 0 0;
      font-size: clamp(18px, 4vw, 22px);
      letter-spacing: 0.04em;
      color: var(--pixel-muted);
      text-transform: uppercase;
    }
    .pixel-loot-row {
      display: flex;
      flex-wrap: wrap;
      gap: 6px;
      margin-top: 12px;
    }
    .pixel-loot-row span {
      padding: 4px 8px;
      font-family: var(--pixel);
      font-size: 7px;
      color: var(--gold-soft);
      background: rgba(245, 200, 66, 0.08);
      border: 2px solid rgba(245, 200, 66, 0.28);
      box-shadow: 2px 2px 0 var(--pixel-shadow);
    }

    /* ---- Main menu ---- */
    #main-menu {
      align-items: center;
      justify-content: center;
      padding: clamp(12px, 2.5vw, 24px);
    }
    .menu-shell {
      position: relative;
      z-index: 1;
      display: grid;
      grid-template-columns: 1.1fr 0.9fr;
      gap: clamp(12px, 2vw, 20px);
      width: min(980px, 100%);
      max-height: min(92vh, 720px);
    }
    .menu-art-frame {
      position: relative;
      overflow: hidden;
      padding: 0;
      min-height: 280px;
    }
    .menu-art-logo {
      position: absolute;
      left: 50%;
      top: 50%;
      transform: translate(-50%, -50%);
      max-width: min(68%, 240px);
      z-index: 2;
      filter: drop-shadow(0 8px 24px rgba(0, 0, 0, 0.65));
    }
    .menu-art {
      display: block;
      width: 100%;
      height: 100%;
      min-height: 280px;
      object-fit: cover;
      object-position: center 40%;
    }
    .menu-art-caption {
      position: absolute;
      left: 12px;
      bottom: 12px;
      padding: 6px 10px;
      background: rgba(18, 15, 26, 0.82);
      border: 2px solid var(--pixel-border);
      box-shadow: 3px 3px 0 var(--pixel-shadow);
    }
    .menu-panel {
      display: flex;
      flex-direction: column;
      justify-content: center;
      align-items: center;
      text-align: center;
      padding: clamp(18px, 3vw, 28px);
      gap: 8px;
    }
    .menu-welcome { margin-bottom: 2px; }
    .menu-title {
      font-size: clamp(16px, 3.2vw, 24px);
      margin-bottom: 6px;
    }
    .menu-tagline {
      margin: 0 0 18px;
      font-size: clamp(20px, 3.5vw, 26px);
      color: var(--pixel-muted);
      letter-spacing: 0.06em;
    }
    .menu-nav {
      display: grid;
      gap: 10px;
    }
    .menu-version {
      margin: 16px 0 0;
      font-family: var(--pixel);
      font-size: 7px;
      color: rgba(184, 168, 136, 0.7);
      text-align: center;
      letter-spacing: 0.1em;
    }

    /* ---- Pixel buttons ---- */
    .pixel-btn {
      display: flex;
      align-items: center;
      justify-content: center;
      gap: 10px;
      width: 100%;
      padding: 14px 16px;
      font-family: var(--pixel);
      font-size: clamp(9px, 2vw, 11px);
      line-height: 1.4;
      color: var(--pixel-text);
      text-transform: uppercase;
      letter-spacing: 0.06em;
      cursor: pointer;
      background: linear-gradient(180deg, #3a3050 0%, #2a2240 100%);
      border: none;
      box-shadow:
        0 0 0 2px var(--pixel-shadow),
        0 0 0 4px #6a5890,
        0 5px 0 4px var(--pixel-shadow),
        inset 0 2px 0 rgba(255, 255, 255, 0.1),
        inset 0 -3px 0 rgba(0, 0, 0, 0.25);
      transition: transform 0.1s, filter 0.12s, box-shadow 0.1s;
    }
    .pixel-btn .btn-icon {
      font-size: 12px;
      color: var(--gold-soft);
    }
    .pixel-btn:hover {
      filter: brightness(1.12);
      transform: translateY(-2px);
    }
    .pixel-btn:active {
      transform: translateY(3px);
      box-shadow:
        0 0 0 2px var(--pixel-shadow),
        0 0 0 4px #6a5890,
        0 1px 0 4px var(--pixel-shadow),
        inset 0 2px 0 rgba(255, 255, 255, 0.06);
    }
    .pixel-btn-gold {
      color: #2a1a08;
      background: linear-gradient(180deg, #ffe28c 0%, #f5c842 45%, #c8942a 100%);
      box-shadow:
        0 0 0 2px var(--pixel-shadow),
        0 0 0 4px #ffe28c,
        0 5px 0 4px var(--pixel-shadow),
        0 0 20px rgba(245, 200, 66, 0.35),
        inset 0 2px 0 rgba(255, 255, 255, 0.35);
    }
    .pixel-btn-gold .btn-icon { color: #5a3a10; }
    .pixel-btn-gold:hover {
      filter: brightness(1.06);
      box-shadow:
        0 0 0 2px var(--pixel-shadow),
        0 0 0 4px #fff1a8,
        0 6px 0 4px var(--pixel-shadow),
        0 0 28px rgba(245, 200, 66, 0.5),
        inset 0 2px 0 rgba(255, 255, 255, 0.4);
    }

    /* ---- Menu modal ---- */
    .pixel-modal {
      position: fixed;
      inset: 0;
      z-index: 10000;
      display: grid;
      place-items: center;
      padding: 16px;
      opacity: 0;
      pointer-events: none;
      transition: opacity 0.22s ease;
    }
    .pixel-modal.hidden { display: none; }
    .pixel-modal.modal-in {
      opacity: 1;
      pointer-events: auto;
    }
    .pixel-modal-backdrop {
      position: absolute;
      inset: 0;
      background: rgba(6, 5, 10, 0.72);
    }
    .pixel-modal-card {
      position: relative;
      width: min(480px, 100%);
      max-height: min(80vh, 560px);
      display: flex;
      flex-direction: column;
      transform: translateY(8px) scale(0.98);
      transition: transform 0.22s ease;
    }
    .pixel-modal.modal-in .pixel-modal-card {
      transform: translateY(0) scale(1);
    }
    .pixel-modal-header {
      display: flex;
      align-items: center;
      justify-content: space-between;
      gap: 12px;
      padding: 14px 16px 10px;
      border-bottom: 3px solid rgba(245, 200, 66, 0.25);
    }
    .pixel-modal-title {
      margin: 0;
      font-family: var(--pixel);
      font-size: 11px;
      color: var(--gold-soft);
      text-shadow: 2px 2px 0 var(--pixel-shadow);
    }
    .pixel-icon-btn {
      width: 36px;
      height: 36px;
      padding: 0;
      font-family: var(--pixel);
      font-size: 14px;
      line-height: 1;
      color: var(--pixel-text);
      cursor: pointer;
      background: #2a2240;
      border: 3px solid #6a5890;
      box-shadow: 2px 2px 0 var(--pixel-shadow);
    }
    .pixel-modal-body {
      padding: 16px 18px;
      overflow-y: auto;
      font-size: clamp(20px, 3.5vw, 24px);
      line-height: 1.35;
      color: var(--pixel-muted);
    }
    .pixel-modal-body p { margin: 0 0 12px; }
    .pixel-modal-body strong { color: var(--gold-soft); }
    .pixel-list {
      margin: 0 0 12px;
      padding-left: 20px;
    }
    .pixel-list li { margin-bottom: 6px; }
    .pixel-note {
      padding: 10px 12px;
      font-size: clamp(18px, 3vw, 22px);
      color: var(--gold-soft);
      background: rgba(245, 200, 66, 0.08);
      border: 2px dashed rgba(245, 200, 66, 0.35);
    }
    .pixel-modal-footer {
      padding: 12px 16px 16px;
      border-top: 3px solid rgba(245, 200, 66, 0.18);
    }
    .pixel-modal-back { max-width: 200px; margin: 0 auto; }

    @media (max-width: 820px) {
      .menu-shell {
        grid-template-columns: 1fr;
        max-height: none;
      }
      .menu-art-frame {
        min-height: 180px;
        max-height: 34vh;
      }
      .menu-art { min-height: 180px; max-height: 34vh; }
      .menu-panel { padding: 16px; }
      .pixel-loader-panel { margin-bottom: 8px; }
    }
    @media (max-width: 720px) {
      .craft-grid, .inv-grid { grid-template-columns: 1fr; }
      .station-dialog, .station-dialog.wide,
      .shop-dialog, .dealer-dialog, .minerals-dialog {
        width: calc(100vw - 16px) !important;
        max-height: min(86vh, 640px);
        left: 50% !important;
        top: 50% !important;
        transform: translate(-50%, -50%) scale(1) !important;
        transform-origin: center center !important;
      }
      .station-dialog.inventory-mode {
        width: calc(100vw - 12px) !important;
        max-height: min(88vh, 680px);
      }
      .dialog-header { padding: 14px 14px 10px; }
      .dialog-header h2 { font-size: 16px; }
      .action-btn, .shop-buy-btn, .sell-btn {
        min-height: 44px;
        font-size: 14px;
      }
      .menu-nav { width: 100%; }
      .pixel-btn { min-height: 48px; width: 100%; }
    }
    @media (max-width: 720px) and (orientation: portrait) {
      .pixel-screen {
        align-items: flex-end;
        padding: 10px 10px calc(10px + env(safe-area-inset-bottom));
      }
      .pixel-loader-panel {
        width: 100%;
        padding: 12px 14px 10px;
        margin-bottom: 0;
      }
      .loader-logo {
        max-width: min(180px, 52vw);
      }
      .pixel-status {
        font-size: 16px;
      }
      #main-menu {
        padding: 10px 10px calc(10px + env(safe-area-inset-bottom));
        align-items: stretch;
        justify-content: flex-end;
      }
      .menu-shell {
        width: 100%;
        gap: 10px;
      }
      .menu-art-frame {
        min-height: 140px;
        max-height: 28vh;
      }
      .menu-art {
        min-height: 140px;
        max-height: 28vh;
      }
      .menu-art-logo {
        max-width: min(140px, 40vw);
      }
      html.mobile-viewport body.game-active .touch-move {
        grid-template-columns: 40px 40px 40px;
        grid-template-rows: 40px 40px;
      }
      html.mobile-viewport body.game-active .touch-actions {
        grid-template-columns: 40px;
        grid-auto-rows: 40px;
      }
      html.mobile-viewport body.game-active .touch-btn {
        width: 40px;
        height: 40px;
        font-size: 17px;
        border-radius: 10px;
      }
      html.mobile-viewport body.game-active .touch-btn.touch-mine { font-size: 18px; }
      html.mobile-viewport body.game-active .touch-btn.gold { font-size: 14px; }
      html.mobile-viewport body.game-active {
        --mobile-touch-h: calc(88px + env(safe-area-inset-bottom));
        --mobile-inv-h: 40px;
      }
      html.mobile-viewport body.game-active .touch-controls.visible {
        padding: 6px 8px calc(6px + env(safe-area-inset-bottom));
        gap: 8px;
      }
    }
    @media (prefers-reduced-motion: reduce) {
      *, *::before, *::after {
        animation-duration: 0.01ms !important;
        transition-duration: 0.01ms !important;
      }
    }
