:root {
    --bg:    #f6c70c;
    --ink:   #2a1c08;
    --ink-2: #5a4418;
    --paper: #fffaeb;
    --line:  #1a1208;
    --hi:    #ffe45c;
  }

  * { box-sizing: border-box; }

  html, body {
    margin: 0;
    padding: 0;
    background: var(--bg);
    color: var(--ink);
    font-family: "DotGothic16", "Hiragino Maru Gothic ProN", system-ui, sans-serif;
    -webkit-font-smoothing: antialiased;
  }
  body {
    min-height: 100vh;
    padding-bottom: clamp(80px, 10vh, 140px);
    overflow-x: hidden;
  }
  a { color: inherit; }

  /* ── Header ────────────────────────────────────── */
  .header {
    position: sticky;
    top: 0;
    z-index: 20;
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: clamp(16px, 2.4vw, 32px) clamp(20px, 3vw, 44px);
    background: linear-gradient(180deg, var(--bg) 0%, var(--bg) 70%, rgba(246,199,12,0) 100%);
  }
  .site-brand {
    display: flex;
    align-items: center;
    gap: clamp(10px, 1.1vw, 18px);
    text-decoration: none;
    filter: drop-shadow(0 4px 0 rgba(0,0,0,0.12));
    transition: transform 0.15s ease;
  }
  .site-brand:hover { transform: translate(-1px, -1px); }
  .site-brand-logo {
    height: clamp(40px, 4.4vw, 62px);
    width: auto;
    display: block;
  }
  .nav {
    display: flex;
    align-items: center;
    gap: clamp(10px, 1vw, 18px);
    font-family: "Press Start 2P", system-ui, sans-serif;
    font-size: clamp(12px, 1.2vw, 19px);
    letter-spacing: 0.06em;
    color: #fff;
  }
  .nav a {
    color: #fff;
    text-decoration: none;
    text-shadow: 2px 2px 0 rgba(0,0,0,0.20);
    padding: 4px 2px;
    transition: transform 0.15s ease, color 0.15s ease;
  }
  .nav a:hover { transform: translate(-1px,-1px); color: #fff8d4; }
  .nav a.active { color: #96580b; text-shadow: 2px 2px 0 var(--hi); }
  .nav .sep { opacity: 0.85; }

  /* ── Page ──────────────────────────────────────── */
  .page {
    max-width: 1280px;
    margin: 0 auto;
    padding: clamp(20px, 4vw, 56px) clamp(20px, 4vw, 32px) 0;
  }
  .page-head {
    margin: clamp(16px, 4vw, 36px) 0 clamp(18px, 3vw, 28px);
    display: flex;
    align-items: end;
    justify-content: space-between;
    flex-wrap: wrap;
    gap: 20px;
  }
  .page-title {
    font-family: "Press Start 2P", system-ui, sans-serif;
    font-size: clamp(46px, 8.5vw, 80px);
    line-height: 0.95;
    color: #fff;
    text-shadow: 2px 2px 0 rgba(0, 0, 0, 0.20);
    letter-spacing: 0.02em;
    margin: 0;
  }
  .scoreboard { display: none; }

  /* Score (inside arena, top-right) */
  .score-pip {
    position: absolute;
    top: clamp(10px, 1.2vw, 18px);
    right: clamp(14px, 1.6vw, 22px);
    z-index: 8;
    font-family: "Press Start 2P", system-ui, sans-serif;
    font-size: clamp(12px, 1.2vw, 16px);
    letter-spacing: 0.10em;
    color: #fff;
    text-shadow: 3px 3px 0 rgba(0,0,0,0.35);
    pointer-events: none;
    display: flex;
    align-items: baseline;
    gap: 0.7em;
  }
  .score-pip .v {
    display: inline-block;
    min-width: 4ch;
    text-align: right;
    transition: transform 0.18s ease-out;
  }
  .score-pip .v.bump { animation: scoreBump 0.32s ease-out; }
  @keyframes scoreBump {
    0%   { transform: scale(1); }
    45%  { transform: scale(1.28); color: #fff8d4; }
    100% { transform: scale(1); }
  }

  .category-filter {
    position: absolute;
    top: clamp(10px, 1.2vw, 18px);
    left: clamp(12px, 1.5vw, 22px);
    z-index: 8;
    display: flex;
    align-items: center;
    flex-wrap: wrap;
    gap: 6px;
    max-width: min(520px, calc(100% - 190px));
  }
  .category-filter button {
    appearance: none;
    border: 2px solid var(--line);
    border-radius: 4px;
    background: var(--bg);
    color: var(--line);
    box-shadow: 3px 3px 0 var(--line);
    cursor: pointer;
    font-family: "Press Start 2P", system-ui, sans-serif;
    font-size: clamp(8px, 0.8vw, 11px);
    letter-spacing: 0;
    line-height: 1;
    padding: 7px 8px 6px;
    transition: transform 0.12s ease, background 0.12s ease, box-shadow 0.12s ease;
  }
  .category-filter button:hover,
  .category-filter button:focus-visible {
    background: var(--hi);
    outline: none;
    transform: translate(-1px, -1px);
  }
  .category-filter button.active {
    background: var(--line);
    color: var(--hi);
    box-shadow: 2px 2px 0 rgba(26, 18, 8, 0.55);
  }

  /* ── Arena ─────────────────────────────────────── */
  .arena {
    position: relative;
    width: 100%;
    height: clamp(430px, 62vh, 680px);
    background: var(--bg);
    border: 4px solid var(--line);
    border-radius: 10px;
    box-shadow: 8px 8px 0 var(--line);
    overflow: hidden;
    cursor: crosshair;
    touch-action: pan-y;
  }
  .arena.touch { cursor: default; }

  /* Parallax dot field */
  .stars, .stars2 {
    position: absolute;
    inset: 0;
    pointer-events: none;
    background-image:
      radial-gradient(circle, rgba(26,18,8,0.18) 1.4px, transparent 1.8px);
    background-size: 56px 80px;
    background-repeat: repeat;
    opacity: 0.6;
  }
  .stars2 {
    background-size: 90px 130px;
    background-position: 30px 40px;
    opacity: 0.35;
  }

  /* Subtle row rails (horizontal) */
  .lane-line {
    position: absolute;
    left: 0; right: 0;
    height: 2px;
    background: repeating-linear-gradient(90deg,
      rgba(26,18,8,0.18) 0, rgba(26,18,8,0.18) 8px,
      transparent 8px, transparent 16px);
    pointer-events: none;
  }

  /* Targets (work cards on rails) */
  .track {
    position: absolute;
    left: 0;
    right: 0;
    top: 0;
    height: 68%;
  }

  .target {
    position: absolute;
    width: 160px;
    height: 168px;
    background: var(--bg);
    border: 3.5px solid var(--line);
    border-radius: 8px;
    box-shadow: 4px 4px 0 var(--line);
    cursor: pointer;
    display: grid;
    grid-template-rows: 1fr auto;
    padding: 12px 10px 10px;
    text-align: center;
    font: inherit;
    color: inherit;
    transition: transform 0.12s ease, background 0.12s ease, box-shadow 0.12s ease;
    will-change: transform;
  }
  .target:hover, .target:focus-visible {
    background: var(--hi);
    outline: none;
  }
  .target .cat-badge {
    position: absolute;
    top: 6px;
    left: 6px;
    font-family: "Press Start 2P", system-ui, sans-serif;
    font-size: 7px;
    background: var(--line);
    color: var(--hi);
    padding: 3px 5px;
    border-radius: 3px;
    letter-spacing: 0.06em;
  }
  .target.featured::after {
    content: "★";
    position: absolute;
    top: -10px;
    right: -10px;
    width: 22px;
    height: 22px;
    background: var(--hi);
    color: var(--line);
    border: 2px solid var(--line);
    border-radius: 50%;
    display: grid;
    place-items: center;
    font-family: "Press Start 2P", system-ui, sans-serif;
    font-size: 10px;
  }
  .target .glyph {
    place-self: center;
    font-size: 56px;
    line-height: 1;
    filter: drop-shadow(0 2px 0 rgba(0,0,0,0.10));
  }
  .target .label {
    font-family: "Press Start 2P", system-ui, sans-serif;
    font-size: 9px;
    letter-spacing: 0.04em;
    color: var(--line);
    line-height: 1.5;
    text-transform: uppercase;
  }
  .target.hit { animation: hitFlash 0.4s ease-out; }
  @keyframes hitFlash {
    0%   { background: var(--hi); box-shadow: 0 0 0 rgba(0,0,0,0), 4px 4px 0 var(--line); }
    25%  { background: #fff;       box-shadow: 0 0 0 6px rgba(255,255,255,0.5), 4px 4px 0 var(--line); }
    100% { background: var(--bg);  box-shadow: 0 0 0 rgba(0,0,0,0), 4px 4px 0 var(--line); }
  }

  /* Ship */
  .ship {
    position: absolute;
    width: 64px;
    height: 64px;
    --x: 0px; --y: 0px;
    transform: translate(var(--x), var(--y));
    z-index: 5;
    pointer-events: none;
    image-rendering: pixelated;
    filter: drop-shadow(0 4px 0 rgba(0,0,0,0.28));
    will-change: transform;
  }
  .arena.touch .ship { display: none; }
  .ship .thruster {
    position: absolute;
    left: 50%;
    bottom: -22px;
    transform: translateX(-50%);
    width: 18px;
    height: 22px;
    background: linear-gradient(180deg, rgba(255,228,92,0.0), rgba(255,228,92,0.0), rgba(255,228,92,0.85));
    border-radius: 4px;
    animation: thrust 0.12s linear infinite;
    opacity: 0.85;
  }
  @keyframes thrust {
    0%, 100% { transform: translateX(-50%) scaleY(1); }
    50%      { transform: translateX(-50%) scaleY(0.55); }
  }

  /* Bullet (🍢) */
  .bullet {
    position: absolute;
    font-size: 28px;
    line-height: 1;
    z-index: 4;
    pointer-events: none;
    will-change: transform;
    filter: drop-shadow(0 2px 0 rgba(0,0,0,0.30));
  }
  .bullet.cpu { opacity: 0.55; }

  /* Controls hint (page, bottom-left) */
  .controls-hint {
    position: fixed;
    left: clamp(20px, 3vw, 44px);
    bottom: clamp(20px, 3vw, 40px);
    z-index: 11;
    font-family: "Press Start 2P", system-ui, sans-serif;
    font-size: 9px;
    line-height: 1.7;
    letter-spacing: 0.04em;
    color: rgba(255,255,255,0.95);
    text-shadow: 2px 2px 0 rgba(0,0,0,0.20);
    pointer-events: none;
    text-align: left;
  }
  .controls-hint .kbd {
    display: inline-block;
    border: 2px solid rgba(255,255,255,0.92);
    padding: 2px 5px;
    margin: 0 1px;
    border-radius: 3px;
    font-size: 8px;
  }
  @media (max-width: 720px) {
    .controls-hint { display: none; }
  }

  /* HUD (now unused but kept harmless) */
  .hud { display: none; }

  .paused-banner {
    position: absolute;
    top: 50%; left: 50%;
    transform: translate(-50%, -50%);
    font-family: "Press Start 2P", system-ui, sans-serif;
    font-size: clamp(20px, 3vw, 38px);
    letter-spacing: 0.14em;
    color: #fff;
    text-shadow: 4px 4px 0 rgba(0,0,0,0.40);
    opacity: 0;
    transition: opacity 0.18s ease;
    pointer-events: none;
    z-index: 20;
  }
  .arena.paused .paused-banner { opacity: 1; }

  /* ── Modal ─────────────────────────────────────── */
  .modal-overlay {
    position: fixed;
    inset: 0;
    background: rgba(20, 14, 4, 0.66);
    backdrop-filter: blur(4px);
    -webkit-backdrop-filter: blur(4px);
    display: grid;
    place-items: center;
    padding: clamp(16px, 3vw, 40px);
    z-index: 100;
    opacity: 0;
    pointer-events: none;
    transition: opacity 0.18s ease;
  }
  .modal-overlay.open { opacity: 1; pointer-events: auto; }
  .modal {
    width: min(720px, 100%);
    max-height: 88vh;
    overflow-y: auto;
    background: var(--paper);
    border: 4px solid var(--line);
    border-radius: 10px;
    box-shadow: 10px 10px 0 var(--line);
    transform: translateY(20px) scale(0.96);
    transition: transform 0.22s cubic-bezier(.2,.7,.3,1);
    position: relative;
  }
  .modal-overlay.open .modal { transform: translateY(0) scale(1); }
  .modal-head {
    display: flex;
    align-items: start;
    justify-content: space-between;
    gap: 16px;
    padding: clamp(20px, 2.6vw, 32px) clamp(22px, 3vw, 36px) 16px;
    border-bottom: 3px solid var(--line);
    background: var(--hi);
    border-radius: 6px 6px 0 0;
  }
  .modal-cat {
    font-family: "Press Start 2P", system-ui, sans-serif;
    font-size: 10px;
    letter-spacing: 0.06em;
    background: var(--line);
    color: var(--hi);
    padding: 5px 8px;
    border-radius: 3px;
    display: inline-block;
    margin-bottom: 10px;
  }
  .modal-title {
    font-family: "Press Start 2P", system-ui, sans-serif;
    font-size: clamp(18px, 2.2vw, 28px);
    line-height: 1.2;
    color: var(--line);
    margin: 0;
    letter-spacing: 0.02em;
  }
  .modal-close {
    flex: 0 0 auto;
    width: 36px;
    height: 36px;
    background: var(--line);
    color: var(--hi);
    border: 0;
    border-radius: 4px;
    font-family: "Press Start 2P", system-ui, sans-serif;
    font-size: 14px;
    cursor: pointer;
    box-shadow: 3px 3px 0 rgba(0,0,0,0.30);
  }
  .modal-close:hover { transform: translate(-1px,-1px); }
  .modal-body {
    padding: clamp(18px, 2.6vw, 30px) clamp(22px, 3vw, 36px) clamp(22px, 3vw, 36px);
  }
  .modal-hero {
    aspect-ratio: 16 / 9;
    background:
      radial-gradient(circle at 1px 1px, rgba(26,18,8,0.18) 1px, transparent 1.6px) 0 0 / 14px 14px,
      var(--bg);
    border: 3px solid var(--line);
    border-radius: 6px;
    display: grid;
    place-items: center;
    margin-bottom: 18px;
    color: var(--line);
    font-family: "Press Start 2P", system-ui, sans-serif;
    font-size: clamp(28px, 5vw, 52px);
    overflow: hidden;
  }
  .modal-desc {
    font-size: clamp(14px, 1.3vw, 17px);
    line-height: 1.9;
    color: var(--ink);
    margin: 0 0 18px;
    text-wrap: pretty;
  }
  .modal-meta {
    display: grid;
    grid-template-columns: max-content 1fr;
    gap: 8px clamp(16px, 2vw, 28px);
    font-size: 14px;
    line-height: 1.7;
    margin-bottom: 18px;
  }
  .modal-meta dt {
    font-family: "Press Start 2P", system-ui, sans-serif;
    font-size: 10px;
    letter-spacing: 0.06em;
    color: var(--line);
    padding-top: 4px;
    white-space: nowrap;
  }
  .modal-meta dd { margin: 0; color: var(--ink); }
  .modal-tags { display: flex; flex-wrap: wrap; gap: 6px; }
  .modal-tags span {
    font-family: "Press Start 2P", system-ui, sans-serif;
    font-size: 9px;
    background: var(--bg);
    border: 2px solid var(--line);
    color: var(--line);
    padding: 4px 8px;
    border-radius: 3px;
    letter-spacing: 0.06em;
  }
  .modal-link {
    display: inline-block;
    margin-top: 6px;
    font-family: "Press Start 2P", system-ui, sans-serif;
    font-size: 11px;
    letter-spacing: 0.06em;
    color: var(--hi);
    background: var(--line);
    padding: 10px 16px;
    border-radius: 4px;
    text-decoration: none;
    box-shadow: 4px 4px 0 rgba(0,0,0,0.20);
    transition: transform 0.12s ease;
  }
  .modal-link:hover { transform: translate(-1px, -1px); }

  /* ── SNS ───────────────────────────────────────── */
  .sns {
    position: fixed;
    bottom: clamp(25px, 3vw, 40px);
    right: clamp(25px, 3vw, 44px);
    z-index: 10;
    display: flex;
    align-items: center;
    gap: clamp(14px, 1.6vw, 26px);
  }
  .sns a {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    color: #fff;
    text-decoration: none;
    transition: transform 0.2s ease;
  }
  .sns a:hover { transform: translateY(-3px); }
  .sns svg {
    height: clamp(26px, 2.4vw, 38px);
    width: auto;
    fill: #fff;
    display: block;
    filter: drop-shadow(0 2px 0 rgba(0,0,0,0.18));
  }

  @media (max-width: 720px) {
    .nav { font-size: 11px; gap: 8px; }
    .modal-meta { grid-template-columns: 1fr; gap: 2px 0; }
    .modal-meta dt { padding-top: 10px; }
    .target { width: 130px; height: 138px; }
    .target .glyph { font-size: 44px; }
    .hud { font-size: 8px; }
  }
