    /* Global mobile-first viewport lock + high-performance gesture capture */
    :root {
      color-scheme: dark;
      font-family: Inter, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
      background: #02020a;
      touch-action: none;
      overscroll-behavior: none;
      user-select: none;
    }

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

    html, body {
      width: 100%;
      height: 100%;
      overflow: hidden;
      background: #02020a;
    }

    body {
      display: flex;
      justify-content: center;
      align-items: center;
    }

    #gameCanvas {
      display: block;
      width: 100vw;
      height: 100vh;
      background: #070714;
    }

    .hud {
      position: absolute;
      top: 0;
      left: 0;
      width: 100%;
      padding: 16px 18px 24px;
      pointer-events: none;
      z-index: 10;
      /* Scrim so the stats stay readable over bright biomes (sky, lava) */
      background: linear-gradient(to bottom, rgba(2, 2, 10, 0.65), rgba(2, 2, 10, 0));
    }

    .status-row {
      display: flex;
      justify-content: space-between;
      gap: 12px;
      align-items: center;
      flex-wrap: wrap;
    }

    .label {
      color: rgba(255,255,255,0.88);
      font-size: 0.8rem;
      font-weight: 600;
      letter-spacing: 0.15em;
      text-transform: uppercase;
      text-shadow: 0 1px 4px rgba(0,0,0,0.8);
    }

    .value {
      margin-top: 2px;
      color: #fff;
      font-size: 1.3rem;
      font-weight: 700;
      line-height: 1.1;
      text-shadow: 0 1px 3px rgba(0,0,0,0.85), 0 0 14px rgba(0,0,0,0.6);
    }

    /* No backdrop-filter on in-game HUD chrome: blurring over a canvas
       that repaints every frame forces a per-frame GPU re-blur. */
    .combo-badge {
      min-width: 90px;
      padding: 8px 12px;
      border-radius: 16px;
      background: rgba(20, 20, 34, 0.55);
      border: 1px solid rgba(255,255,255,0.12);
      text-align: center;
      box-shadow: 0 16px 40px rgba(0,0,0,0.28);
    }

    .combo-badge span {
      display: block;
      color: #fff;
      font-size: 1.05rem;
      font-weight: 700;
    }

    #pauseButton {
      border: none;
      background: rgba(20, 20, 34, 0.55);
      color: #ffffff;
      padding: 10px 16px;
      border-radius: 16px;
      border: 1px solid rgba(255, 255, 255, 0.12);
      box-shadow: 0 16px 40px rgba(0,0,0,0.28);
      font-weight: 700;
      font-size: 0.8rem;
      letter-spacing: 0.1em;
      cursor: pointer;
      transition: transform 0.16s ease, background 0.16s ease, box-shadow 0.16s ease;
      pointer-events: auto;
    }

    #pauseButton:hover {
      transform: translateY(-1px);
      background: rgba(255, 255, 255, 0.16);
      box-shadow: 0 0 15px rgba(255, 255, 255, 0.15);
    }

    .hud-side-buttons {
      position: absolute;
      right: 18px;
      top: 50%;
      transform: translateY(-50%);
      display: flex;
      flex-direction: column;
      gap: 16px;
      z-index: 10;
      pointer-events: none;
    }

    .hud-side-btn {
      pointer-events: auto;
      background: rgba(20, 20, 34, 0.55);
      border: 1px solid rgba(255, 255, 255, 0.12);
      color: #fff;
      width: 52px;
      height: 52px;
      display: flex;
      justify-content: center;
      align-items: center;
      border-radius: 16px;
      box-shadow: 0 16px 40px rgba(0,0,0,0.28);
      cursor: pointer;
      transition: transform 0.16s ease, background 0.16s ease, box-shadow 0.16s ease;
    }

    .hud-side-btn svg {
      filter: drop-shadow(0 2px 4px rgba(0,0,0,0.5));
    }

    .hud-side-btn:hover {
      transform: translateX(-3px);
      background: rgba(255, 255, 255, 0.16);
      box-shadow: 0 0 15px rgba(255, 255, 255, 0.15);
    }

    /* Dark Market side button: deep purple, slightly shady */
    .hud-side-btn.market {
      background: linear-gradient(135deg, rgba(43, 8, 69, 0.92), rgba(75, 0, 130, 0.8));
      border-color: rgba(213, 0, 249, 0.45);
      color: #e9c6ff;
    }

    .hud-side-btn.market:hover {
      background: linear-gradient(135deg, rgba(64, 14, 100, 0.95), rgba(98, 0, 170, 0.85));
      box-shadow: 0 0 18px rgba(213, 0, 249, 0.35);
    }

    .hint {
      position: absolute;
      bottom: 18px;
      left: 50%;
      transform: translateX(-50%);
      color: rgba(255,255,255,0.9);
      font-size: 1rem;
      pointer-events: none;
      text-shadow: 0 1px 3px rgba(0,0,0,0.8);
      background: rgba(2, 2, 10, 0.55);
      border: 1px solid rgba(255, 255, 255, 0.1);
      border-radius: 999px;
      padding: 8px 18px;
      white-space: nowrap;
      max-width: 92vw;
      transition: opacity 0.3s ease;
    }

    .overlay {
      position: absolute;
      top: 0;
      left: 0;
      width: 100%;
      height: 100%;
      display: flex;
      justify-content: center;
      align-items: center;
      pointer-events: auto;
      background: rgba(1, 1, 8, 0.72);
      backdrop-filter: blur(18px);
      z-index: 12;
    }

    .menu-panel {
      width: min(92vw, 420px);
      padding: 26px;
      border-radius: 28px;
      background: rgba(6, 5, 18, 0.95);
      border: 1px solid rgba(255, 255, 255, 0.12);
      box-shadow: 0 32px 90px rgba(0, 0, 0, 0.35);
    }

    .menu-title {
      margin-bottom: 16px;
      color: #ffe8ff;
      font-size: 2rem;
      font-weight: 900;
      letter-spacing: 0.18em;
      text-transform: uppercase;
      text-align: center;
      text-shadow: 0 0 28px rgba(255, 85, 255, 0.32);
    }

    .menu-info {
      color: rgba(255, 255, 255, 0.82);
      font-size: 0.98rem;
      line-height: 1.6;
      margin-bottom: 18px;
      text-align: center;
    }

    .menu-buttons {
      display: flex;
      flex-direction: column;
      gap: 14px;
    }

    .menu-button {
      width: 100%;
      padding: 16px 18px;
      border: none;
      border-radius: 999px;
      font-size: 1rem;
      font-weight: 800;
      letter-spacing: 0.06em;
      cursor: pointer;
      transition: transform 0.18s ease, box-shadow 0.18s ease, background 0.18s ease;
      background: linear-gradient(135deg, #7d4cff, #14ffe9);
      color: #060712;
      box-shadow: 0 14px 32px rgba(124, 94, 255, 0.28);
    }

    .menu-button:hover,
    .menu-button:focus {
      transform: translateY(-1px);
      box-shadow: 0 18px 40px rgba(124, 94, 255, 0.36);
    }

    .menu-button.secondary {
      background: linear-gradient(135deg, #282f5d, #3e2b76);
      color: #f8f8ff;
      box-shadow: 0 14px 30px rgba(0, 0, 0, 0.22);
    }

    .shop-list {
      display: grid;
      gap: 12px;
      margin-bottom: 22px;
    }

    .shop-item {
      padding: 14px 16px;
      border-radius: 18px;
      background: rgba(255, 255, 255, 0.04);
      border: 1px solid rgba(255, 255, 255, 0.1);
      color: #edf5ff;
      font-size: 0.98rem;
      line-height: 1.45;
    }

    .shop-item strong {
      display: block;
      margin-bottom: 6px;
      color: #ffffff;
    }

    .shop-footer {
      margin-top: 10px;
      color: rgba(255, 255, 255, 0.78);
      font-size: 0.9rem;
      text-align: center;
    }

    .zen-mode-row {
      display: flex;
      justify-content: space-between;
      align-items: center;
      padding: 14px 18px;
      margin-bottom: 20px;
      background: rgba(255, 255, 255, 0.05);
      border: 1px solid rgba(255, 255, 255, 0.12);
      border-radius: 12px;
      color: #ffe8ff;
      font-weight: 700;
      letter-spacing: 0.05em;
    }

    .switch {
      position: relative;
      display: inline-block;
      width: 48px;
      height: 26px;
    }

    .switch input { 
      opacity: 0;
      width: 0;
      height: 0;
    }

    .slider {
      position: absolute;
      cursor: pointer;
      top: 0; left: 0; right: 0; bottom: 0;
      background-color: rgba(0, 0, 0, 0.4);
      border-radius: 26px;
      border: 1px solid rgba(255, 255, 255, 0.2);
      transition: .3s ease;
    }

    .slider:before {
      position: absolute;
      content: "";
      height: 18px;
      width: 18px;
      left: 3px;
      bottom: 3px;
      background-color: rgba(255, 255, 255, 0.7);
      border-radius: 50%;
      transition: .3s ease;
      box-shadow: 0 2px 4px rgba(0,0,0,0.5);
    }

    input:checked + .slider {
      background-color: rgba(20, 255, 233, 0.15);
      border-color: #14ffe9;
      box-shadow: 0 0 12px rgba(20, 255, 233, 0.3);
    }

    input:checked + .slider:before {
      transform: translateX(22px);
      background-color: #14ffe9;
    }

    .overdrive-container {
      position: absolute;
      bottom: 24px;
      right: 24px;
      display: none;
      flex-direction: column;
      align-items: center;
      z-index: 100;
      pointer-events: none;
    }
    .overdrive-timer-text {
      color: #ffea00;
      font-weight: 800;
      margin-bottom: 6px;
      font-size: 0.9rem;
      text-shadow: 0 0 10px #ff9800;
      opacity: 0;
      transition: opacity 0.2s;
    }
    .overdrive-progress-bg {
      width: 100%;
      height: 8px;
      background: rgba(0, 0, 0, 0.6);
      border: 1px solid rgba(255, 255, 255, 0.2);
      border-radius: 4px;
      margin-bottom: 8px;
      overflow: hidden;
    }
    .overdrive-progress-fill {
      width: 0%;
      height: 100%;
      background: linear-gradient(90deg, #ff9800, #ffea00);
      transition: width 0.2s ease-out;
    }
    .overdrive-btn {
      pointer-events: auto;
      padding: 12px 20px;
      border: 2px solid rgba(255, 234, 0, 0.2);
      border-radius: 999px;
      background: rgba(0, 0, 0, 0.6);
      color: rgba(255, 255, 255, 0.4);
      font-weight: 800;
      letter-spacing: 0.08em;
      font-size: 0.85rem;
      cursor: not-allowed;
      transition: 0.3s;
      box-shadow: 0 4px 12px rgba(0, 0, 0, 0.5);
    }
    .overdrive-btn.ready {
      border-color: #ffea00;
      background: linear-gradient(135deg, #ff9800, #ffea00);
      color: #000;
      cursor: pointer;
      box-shadow: 0 0 20px rgba(255, 234, 0, 0.6), inset 0 0 10px rgba(255, 255, 255, 0.5);
      animation: pulse-overdrive 1.5s infinite;
    }
    .overdrive-btn.active {
      background: #ffffff;
      color: #ff9800;
      box-shadow: 0 0 30px rgba(255, 234, 0, 1);
      cursor: not-allowed;
    }
    @keyframes pulse-overdrive {
      0% { box-shadow: 0 0 15px rgba(255, 234, 0, 0.4); }
      50% { box-shadow: 0 0 30px rgba(255, 234, 0, 0.8); }
      100% { box-shadow: 0 0 15px rgba(255, 234, 0, 0.4); }
    }
    .overdrive-vignette {
      position: absolute;
      top: 0; left: 0; right: 0; bottom: 0;
      box-shadow: inset 0 0 80px 20px rgba(255, 234, 0, 0.4);
      pointer-events: none;
      z-index: 50;
      opacity: 0;
      transition: opacity 0.3s;
    }

/* Artifact Grid & Items */
.artifact-grid {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 12px;
  margin-top: 16px;
}
.artifact-item {
  aspect-ratio: 1;
  background: rgba(255, 255, 255, 0.05);
  border: 1px solid rgba(255, 255, 255, 0.1);
  border-radius: 12px;
  position: relative;
  cursor: pointer;
  display: flex;
  justify-content: center;
  align-items: center;
  transition: transform 0.2s;
}
.artifact-item:hover { transform: scale(1.05); }

/* Locked Silhouette */
.artifact-item.locked .artifact-img svg {
  filter: brightness(0) contrast(0.15);
  opacity: 0.4;
}

/* Rarity Glows */
.artifact-item.Common { box-shadow: 0 0 10px rgba(76, 175, 80, 0.4); border-color: #4caf50; }
.artifact-item.Rare { box-shadow: 0 0 12px rgba(33, 150, 243, 0.6); border-color: #2196f3; }
.artifact-item.Legendary { box-shadow: 0 0 20px rgba(156, 39, 176, 0.8); border-color: #9c27b0; }

/* Scratch Overlay */
.scratch-overlay {
  position: absolute;
  top: 0; left: 0; width: 100%; height: 100%;
  background: repeating-linear-gradient(45deg, #444, #444 10px, #333 10px, #333 20px);
  cursor: pointer;
  border-radius: 12px;
  z-index: 5;
  transition: opacity 0.5s;
}
.scratch-overlay.revealed { opacity: 0; pointer-events: none; }

/* One-time shop guide coach-mark (anchored beside the HUD side buttons) */
.guide-popup {
  position: absolute;
  right: 88px;
  top: 50%;
  transform: translateY(-50%);
  z-index: 60;
  display: flex;
  align-items: center;
  gap: 10px;
  max-width: min(62vw, 270px);
  padding: 12px 14px;
  border-radius: 14px;
  background: rgba(10, 8, 24, 0.94);
  border: 1px solid rgba(20, 255, 233, 0.55);
  color: #fff;
  font-size: 0.9rem;
  line-height: 1.4;
  box-shadow: 0 12px 30px rgba(0, 0, 0, 0.45);
  animation: guide-in 0.35s ease;
}
.guide-popup[hidden] { display: none; }
.guide-popup::after {
  content: "";
  position: absolute;
  right: -8px;
  top: 50%;
  transform: translateY(-50%);
  border-left: 8px solid rgba(20, 255, 233, 0.55);
  border-top: 8px solid transparent;
  border-bottom: 8px solid transparent;
}
@keyframes guide-in {
  from { opacity: 0; transform: translateY(-50%) translateX(12px); }
  to { opacity: 1; transform: translateY(-50%); }
}
.guide-dismiss {
  flex: none;
  width: 28px;
  height: 28px;
  border-radius: 50%;
  border: 1px solid rgba(255, 255, 255, 0.25);
  background: rgba(255, 255, 255, 0.08);
  color: #fff;
  font: inherit;
  line-height: 1;
  cursor: pointer;
}
.guide-pulse {
  border-color: #14ffe9 !important;
  animation: guide-pulse 1.2s ease-in-out infinite;
}
@keyframes guide-pulse {
  0%, 100% { box-shadow: 0 0 0 0 rgba(20, 255, 233, 0.5); }
  50% { box-shadow: 0 0 0 10px rgba(20, 255, 233, 0); }
}

/* Locked Museum / Dark Market entry points (until the first artifact) */
.hud-side-btn,
.menu-button,
.shop-tab {
  position: relative;
}
.lock-badge {
  display: none;
  position: absolute;
  right: -6px;
  top: -6px;
  font-size: 0.85rem;
  filter: drop-shadow(0 2px 3px rgba(0, 0, 0, 0.7));
}
.locked .lock-badge { display: block; }
.hud-side-btn.locked,
.menu-button.locked,
.shop-tab.locked {
  opacity: 0.5;
  filter: grayscale(0.7);
  cursor: not-allowed;
}
.hud-side-btn.locked:hover {
  transform: none;
  background: rgba(20, 20, 34, 0.55);
  box-shadow: 0 16px 40px rgba(0,0,0,0.28);
}
.menu-button.locked:hover,
.menu-button.locked:focus {
  transform: none;
}

/* Shop tab row (Upgrades / Heads / Dark Market) */
.shop-tabs {
  display: flex;
  gap: 8px;
  margin-bottom: 16px;
}
.shop-tab {
  flex: 1;
  padding: 9px 6px;
  border-radius: 999px;
  border: 1px solid rgba(255, 255, 255, 0.2);
  background: rgba(0, 0, 0, 0.4);
  color: rgba(255, 255, 255, 0.6);
  font: inherit;
  font-size: 0.8rem;
  font-weight: 700;
  letter-spacing: 0.05em;
  cursor: pointer;
  transition: 0.2s ease;
  white-space: nowrap;
}
.shop-tab.active {
  background: rgba(20, 255, 233, 0.15);
  border-color: #14ffe9;
  color: #14ffe9;
  box-shadow: 0 0 12px rgba(20, 255, 233, 0.3);
}
.shop-tab.market.active {
  background: rgba(255, 0, 85, 0.12);
  border-color: #ff0055;
  color: #ff6d9a;
  box-shadow: 0 0 12px rgba(255, 0, 85, 0.3);
}

/* Dark Market items: same shop-item bones, shadier accent */
button.shop-item.market-item {
  cursor: pointer;
  transition: 0.2s;
  display: flex;
  flex-direction: column;
  align-items: center;
  text-align: center;
  background: rgba(255, 0, 85, 0.07);
  border-color: rgba(255, 0, 85, 0.35);
  margin-bottom: 12px;
}
button.shop-item.market-item:disabled {
  cursor: default;
  opacity: 0.75;
}

/* Back link to the game portal */
.portal-link {
  display: block;
  margin-top: 16px;
  text-align: center;
  color: rgba(255, 255, 255, 0.5);
  font-size: 0.85rem;
  text-decoration: none;
  transition: color 0.2s ease;
}
.portal-link:hover,
.portal-link:focus-visible {
  color: #14ffe9;
}

/* ?fps=1 debug overlay */
.fps-overlay {
  position: absolute;
  top: 8px;
  left: 50%;
  transform: translateX(-50%);
  z-index: 999;
  padding: 4px 10px;
  border-radius: 8px;
  background: rgba(0, 0, 0, 0.7);
  color: #4dff4d;
  font-family: Consolas, monospace;
  font-size: 12px;
  pointer-events: none;
}
.fps-overlay[hidden] { display: none; }

/* Language toggle (top-right corner of the menu overlay) */
.lang-toggle {
  display: flex;
  gap: 6px;
}
.corner-lang {
  position: absolute;
  top: 18px;
  right: 18px;
  z-index: 5;
}
.lang-btn {
  padding: 6px 16px;
  border-radius: 999px;
  border: 1px solid rgba(255, 255, 255, 0.2);
  background: rgba(0, 0, 0, 0.4);
  color: rgba(255, 255, 255, 0.6);
  font: inherit;
  font-weight: 700;
  letter-spacing: 0.05em;
  cursor: pointer;
  transition: 0.2s ease;
}
.lang-btn.active {
  background: rgba(20, 255, 233, 0.15);
  border-color: #14ffe9;
  color: #14ffe9;
  box-shadow: 0 0 12px rgba(20, 255, 233, 0.3);
}

/* Native <button> resets for interactive shop/museum items */
button.shop-item {
  width: 100%;
  font: inherit;
  color: #edf5ff;
}
button.artifact-item {
  padding: 0;
  font: inherit;
  color: inherit;
}

/* Keyboard focus must be visible on every interactive element */
button:focus-visible,
[role="button"]:focus-visible {
  outline: 3px solid #14ffe9;
  outline-offset: 2px;
}
.switch input:focus-visible + .slider {
  outline: 3px solid #14ffe9;
  outline-offset: 2px;
}

@media (prefers-reduced-motion: reduce) {
  * {
    animation-duration: 0.01ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.01ms !important;
  }
}
