  :root {
    --bg: #07080c;
    --bg-2: #0d1018;
    --ink: #e8ecf2;
    --ink-dim: #6b7689;
    --accent: #ff3864;        /* hot magenta */
    --accent-2: #2de2e6;      /* cool cyan */
    --accent-3: #f9c80e;      /* warning amber */
    --danger: #ff3864;
    --grid: rgba(45, 226, 230, 0.06);
  }

  * { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }

  html, body {
    margin: 0;
    padding: 0;
    width: 100%;
    height: 100%;
    overflow: hidden;
    background: var(--bg);
    color: var(--ink);
    font-family: 'JetBrains Mono', ui-monospace, monospace;
    user-select: none;
    -webkit-user-select: none;
    overscroll-behavior: none;
    touch-action: none;
  }

  #game {
    position: fixed;
    inset: 0;
    width: 100%;
    height: 100%;
  }

  canvas {
    display: block;
    width: 100%;
    height: 100%;
    background:
      radial-gradient(ellipse at center, #0f1320 0%, #07080c 60%, #04050a 100%);
  }

  /* ───── HUD ───── */
  .hud {
    position: fixed;
    top: 0; left: 0; right: 0;
    padding: 18px 18px 0;
    padding-top: max(18px, env(safe-area-inset-top));
    display: flex;
    justify-content: space-between;
    align-items: flex-start;
    pointer-events: none;
    z-index: 10;
    font-family: 'JetBrains Mono', monospace;
  }

  .hud-block {
    background: rgba(7, 8, 12, 0.55);
    backdrop-filter: blur(6px);
    -webkit-backdrop-filter: blur(6px);
    border: 1px solid rgba(232, 236, 242, 0.08);
    padding: 8px 12px;
    border-radius: 2px;
  }

  .label {
    font-size: 9px;
    letter-spacing: 0.22em;
    text-transform: uppercase;
    color: var(--ink-dim);
    margin-bottom: 4px;
  }

  .value {
    font-size: 18px;
    font-weight: 700;
    letter-spacing: 0.05em;
    line-height: 1;
  }

  .value.accent { color: var(--accent-2); }
  .value.warn { color: var(--accent-3); }
  .value.strike { color: #c060ff; }

  .hud-center { text-align: center; }

  /* Energy bar (strike) */
  .energy-bar {
    width: 80px;
    height: 4px;
    background: rgba(192, 96, 255, 0.15);
    margin-top: 6px;
    overflow: hidden;
    position: relative;
  }
  .energy-fill {
    height: 100%;
    background: linear-gradient(90deg, #c060ff, #e0a0ff);
    transition: width 0.15s ease;
    box-shadow: 0 0 8px rgba(192, 96, 255, 0.6);
  }

  /* HP bar */
  .hp-bar {
    width: 110px;
    height: 4px;
    background: rgba(255, 56, 100, 0.15);
    margin-top: 6px;
    overflow: hidden;
    position: relative;
  }
  .hp-fill {
    height: 100%;
    background: linear-gradient(90deg, var(--accent), #ff7a99);
    transition: width 0.2s ease;
    box-shadow: 0 0 8px rgba(255, 56, 100, 0.6);
  }

  /* ───── Upgrade modal ───── */
  .modal-bg {
    position: fixed;
    inset: 0;
    background: rgba(4, 5, 10, 0.78);
    backdrop-filter: blur(8px);
    -webkit-backdrop-filter: blur(8px);
    display: none;
    align-items: center;
    justify-content: center;
    z-index: 20;
    padding: 24px;
    animation: fadeIn 0.3s ease;
  }
  .modal-bg.show { display: flex; }

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

  .modal {
    width: 100%;
    max-width: 380px;
    display: flex;
    flex-direction: column;
    gap: 14px;
  }

  .modal-title {
    font-family: 'Major Mono Display', monospace;
    font-size: 28px;
    text-align: center;
    color: var(--ink);
    letter-spacing: 0.05em;
    margin-bottom: 4px;
  }

  .modal-sub {
    font-size: 10px;
    letter-spacing: 0.3em;
    text-transform: uppercase;
    color: var(--ink-dim);
    text-align: center;
    margin-bottom: 16px;
  }

  .upgrade {
    background: linear-gradient(180deg, rgba(45, 226, 230, 0.04), rgba(45, 226, 230, 0.01));
    border: 1px solid rgba(232, 236, 242, 0.1);
    padding: 16px 18px;
    cursor: pointer;
    position: relative;
    transition: all 0.18s ease;
    overflow: hidden;
  }

  .upgrade::before {
    content: '';
    position: absolute;
    left: 0; top: 0; bottom: 0;
    width: 3px;
    background: var(--accent-2);
    transform: scaleY(0);
    transform-origin: bottom;
    transition: transform 0.2s ease;
  }

  .upgrade:active {
    background: rgba(45, 226, 230, 0.08);
    transform: scale(0.98);
  }
  .upgrade:active::before { transform: scaleY(1); }

  .upgrade-name {
    font-weight: 700;
    font-size: 14px;
    letter-spacing: 0.08em;
    text-transform: uppercase;
    color: var(--ink);
    margin-bottom: 4px;
  }

  .upgrade-desc {
    font-size: 12px;
    color: var(--ink-dim);
    line-height: 1.4;
  }

  .upgrade-tag {
    position: absolute;
    top: 12px;
    right: 14px;
    font-size: 9px;
    letter-spacing: 0.2em;
    color: var(--accent-3);
    text-transform: uppercase;
  }

  /* Tag color variants by category */
  .upgrade[data-cat="fire"] .upgrade-tag { color: #ff7a3c; }
  .upgrade[data-cat="ice"] .upgrade-tag { color: #6ecfff; }
  .upgrade[data-cat="shock"] .upgrade-tag { color: #f9c80e; }
  .upgrade[data-cat="strike"] .upgrade-tag { color: #c060ff; }
  .upgrade[data-cat="core"] .upgrade-tag { color: var(--accent-2); }

  /* ───── Title screen / game over ───── */
  .overlay {
    position: fixed;
    inset: 0;
    background: var(--bg);
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    z-index: 30;
    gap: 24px;
    padding: 32px;
    text-align: center;
  }
  .overlay.hidden { display: none; }

  .title {
    font-family: 'Major Mono Display', monospace;
    font-size: 44px;
    letter-spacing: 0.08em;
    line-height: 0.95;
    color: var(--ink);
    text-shadow:
      0 0 24px rgba(45, 226, 230, 0.3),
      0 0 60px rgba(45, 226, 230, 0.15);
  }

  .subtitle {
    font-size: 11px;
    letter-spacing: 0.4em;
    text-transform: uppercase;
    color: var(--ink-dim);
    max-width: 260px;
    line-height: 1.8;
  }

  .btn {
    background: transparent;
    border: 1px solid var(--ink);
    color: var(--ink);
    font-family: 'JetBrains Mono', monospace;
    font-size: 12px;
    letter-spacing: 0.3em;
    text-transform: uppercase;
    padding: 14px 32px;
    cursor: pointer;
    font-weight: 500;
    transition: all 0.18s ease;
  }
  .btn:active {
    background: var(--ink);
    color: var(--bg);
    transform: scale(0.97);
  }

  /* Secondary / ghost button */
  .btn.ghost {
    border-color: rgba(232, 236, 242, 0.25);
    color: var(--ink-dim);
    padding: 12px 26px;
    font-size: 11px;
    text-decoration: none;
  }
  .btn.ghost:active {
    background: rgba(232, 236, 242, 0.06);
    color: var(--ink);
    border-color: var(--ink-dim);
  }

  .stats-line {
    font-size: 11px;
    letter-spacing: 0.2em;
    text-transform: uppercase;
    color: var(--ink-dim);
  }
  .stats-line strong {
    color: var(--accent-2);
    font-weight: 700;
  }

  /* Wave announcement */
  .wave-announce {
    position: fixed;
    top: 38%;
    left: 50%;
    transform: translate(-50%, -50%);
    pointer-events: none;
    z-index: 15;
    text-align: center;
    opacity: 0;
  }
  .wave-announce.show {
    animation: waveAnnounce 1.6s ease forwards;
  }
  @keyframes waveAnnounce {
    0%   { opacity: 0; transform: translate(-50%, -50%) scale(0.9); }
    20%  { opacity: 1; transform: translate(-50%, -50%) scale(1); }
    80%  { opacity: 1; transform: translate(-50%, -50%) scale(1); }
    100% { opacity: 0; transform: translate(-50%, -50%) scale(1.05); }
  }
  .wave-announce .wa-label {
    font-size: 10px;
    letter-spacing: 0.5em;
    color: var(--ink-dim);
    margin-bottom: 6px;
  }
  .wave-announce .wa-num {
    font-family: 'Major Mono Display', monospace;
    font-size: 64px;
    color: var(--accent-2);
    letter-spacing: 0.05em;
    text-shadow: 0 0 30px rgba(45, 226, 230, 0.5);
  }

  /* Pause button */
  .pause-btn {
    position: fixed;
    bottom: 24px;
    right: 24px;
    bottom: max(24px, env(safe-area-inset-bottom));
    width: 52px;
    height: 52px;
    background: rgba(7, 8, 12, 0.65);
    backdrop-filter: blur(6px);
    -webkit-backdrop-filter: blur(6px);
    border: 1px solid rgba(232, 236, 242, 0.12);
    color: var(--ink);
    cursor: pointer;
    z-index: 12;
    display: none;
    align-items: center;
    justify-content: center;
    padding: 0;
    transition: all 0.15s ease;
  }
  .pause-btn.visible { display: flex; }
  .pause-btn:active {
    background: rgba(45, 226, 230, 0.15);
    transform: scale(0.94);
  }
  .pause-btn svg {
    width: 18px;
    height: 18px;
  }

  /* Pause overlay */
  .pause-overlay {
    position: fixed;
    inset: 0;
    background: rgba(4, 5, 10, 0.75);
    backdrop-filter: blur(8px);
    -webkit-backdrop-filter: blur(8px);
    display: none;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 28px;
    z-index: 25;
    animation: fadeIn 0.25s ease;
  }
  .pause-overlay.show { display: flex; }
  .pause-title {
    font-family: 'Major Mono Display', monospace;
    font-size: 48px;
    letter-spacing: 0.12em;
    color: var(--ink);
    text-shadow: 0 0 30px rgba(45, 226, 230, 0.3);
  }

  /* Crosshair watermark */
  .corner {
    position: fixed;
    bottom: 14px;
    left: 50%;
    transform: translateX(-50%);
    font-size: 9px;
    letter-spacing: 0.4em;
    color: var(--ink-dim);
    opacity: 0.5;
    pointer-events: none;
    z-index: 5;
  }
