:root {
  --ink: #1b1b2f;
  --paper: #fffaf0;
  --panel: rgba(255, 250, 240, 0.97);
  --accent: #ff4fa3;
  --accent-2: #33d6ff;
  --accent-ink: #7a0f4a;
  --hud-bg: rgba(20, 18, 36, 0.72);
  --hud-ink: #fffaf0;
  --focus: #ffd23f;
  --radius: 14px;
  --gutter: 16px;
  --transition: 180ms ease;
  color-scheme: dark;
}

@media (prefers-reduced-motion: reduce) {
  :root { --transition: 0ms; }
}
:root[data-reduced-motion='true'] { --transition: 0ms; }

*, *::before, *::after { box-sizing: border-box; }

html, body {
  margin: 0;
  height: 100%;
  overflow: hidden;
  background: #1c1a2b;
  color: var(--hud-ink);
  font: 16px/1.45 system-ui, -apple-system, 'Segoe UI', Roboto, sans-serif;
  overscroll-behavior: none;
}

#game {
  position: fixed;
  inset: 0;
  width: 100vw;
  height: 100dvh;
  display: block;
  touch-action: none;
  transition: filter var(--transition);
}
#game:focus { outline: none; }
#game:focus-visible { outline: 3px solid var(--focus); outline-offset: -3px; }

body.card-open #game,
body.panel-open #game { filter: blur(3px) saturate(0.6) brightness(0.8); }

:focus-visible { outline: 3px solid var(--focus); outline-offset: 2px; }

.visually-hidden {
  position: absolute !important;
  width: 1px; height: 1px;
  overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap;
}
.skip-link {
  position: absolute; left: var(--gutter); top: -100px; z-index: 50;
  background: var(--paper); color: var(--ink); padding: 8px 12px; border-radius: 8px;
}
.skip-link:focus { top: var(--gutter); }

/* Crosshair */
#crosshair {
  position: fixed; left: 50%; top: 50%;
  width: 22px; height: 22px; margin: -11px 0 0 -11px;
  border: 3px solid var(--hud-ink); border-radius: 50%;
  box-shadow: 0 0 0 2px rgba(0, 0, 0, 0.45);
  pointer-events: none;
}
#crosshair::after {
  content: ''; position: absolute; left: 50%; top: 50%;
  width: 4px; height: 4px; margin: -2px; border-radius: 50%; background: var(--accent);
}
body.panel-open #crosshair, body.card-open #crosshair { display: none; }

/* HUD */
.hud {
  position: fixed; left: 0; right: 0;
  display: flex; align-items: center; justify-content: space-between; gap: 12px;
  padding: 10px var(--gutter);
  pointer-events: none;
}
.hud p { margin: 0; }
.hud--top { top: 0; padding-top: max(10px, env(safe-area-inset-top)); }
.hud--bottom { bottom: 0; padding-bottom: max(10px, env(safe-area-inset-bottom)); flex-wrap: wrap; }
.hud__brand, .hud__right, .hud__paint, .hud__hint {
  background: var(--hud-bg); border-radius: 999px; padding: 6px 12px;
}
.hud__brand { display: flex; align-items: center; gap: 8px; }
.hud__title { font-weight: 800; letter-spacing: 0.06em; }
.hud__right { text-align: right; border-radius: 12px; }
.hud__tags strong { font-size: 1.25rem; color: var(--focus); }
.hud__edition { font-size: 0.8rem; opacity: 0.9; }
.badge {
  background: var(--accent-2); color: var(--ink);
  font-size: 0.72rem; font-weight: 700; padding: 2px 8px; border-radius: 999px;
}
.hud__paint { display: flex; align-items: center; gap: 8px; }
.swatch {
  --paint: #ff4fa3;
  display: inline-block; width: 18px; height: 18px; border-radius: 50%;
  background: var(--paint); border: 2px solid var(--hud-ink);
}
.small-button {
  pointer-events: auto;
  background: var(--hud-bg); color: var(--hud-ink);
  border: 2px solid var(--hud-ink); border-radius: 999px; padding: 6px 12px; font: inherit; font-size: 0.85rem;
  min-height: 44px;
}
.small-button[aria-pressed='true'] { background: var(--accent-2); color: var(--ink); }

/* Touch controls */
.touch {
  position: fixed; left: 0; right: 0; bottom: 64px;
  display: none; justify-content: space-between; align-items: flex-end;
  padding: 0 var(--gutter) max(8px, env(safe-area-inset-bottom));
  pointer-events: none;
}
@media (pointer: coarse) { .touch { display: flex; } .hud__hint { display: none; } }
body.touch-on .touch { display: flex; }
body.touch-off .touch { display: none; }
body.panel-open .touch, body.card-open .touch { visibility: hidden; }
.touch button {
  pointer-events: auto; touch-action: none; user-select: none; -webkit-user-select: none;
  font: inherit; color: var(--ink); background: rgba(255, 250, 240, 0.85);
  border: 3px solid var(--ink); border-radius: 14px;
  min-width: 56px; min-height: 56px; font-size: 1.3rem;
}
.touch button:active { background: var(--accent-2); }
.touch__pad {
  display: grid; grid-template-columns: repeat(3, 56px); grid-template-rows: repeat(2, 56px); gap: 6px;
}
.touch__pad [data-hold='forward'] { grid-column: 2; grid-row: 1; }
.touch__pad [data-hold='turnLeft'] { grid-column: 1; grid-row: 2; }
.touch__pad [data-hold='back'] { grid-column: 2; grid-row: 2; }
.touch__pad [data-hold='turnRight'] { grid-column: 3; grid-row: 2; }
.touch__fire {
  width: 96px; height: 96px; border-radius: 50% !important;
  background: var(--accent) !important; color: #fff !important; font-weight: 800;
}

/* Panels */
.panel {
  position: fixed; left: 50%; top: 50%; transform: translate(-50%, -50%);
  width: min(34rem, calc(100vw - 2 * var(--gutter)));
  max-height: calc(100dvh - 2 * var(--gutter)); overflow: auto;
  background: var(--panel); color: var(--ink);
  border: 4px solid var(--ink); border-radius: var(--radius);
  box-shadow: 8px 8px 0 var(--accent);
  padding: 20px; z-index: 20;
}
.panel[hidden] { display: none; }
.panel h1, .panel h2 { margin: 0 0 8px; line-height: 1.15; }
.panel h1 { font-size: clamp(1.6rem, 6vw, 2.4rem); letter-spacing: 0.03em; }
.panel__notes { padding-left: 1.1rem; margin: 12px 0; font-size: 0.95rem; }
.panel__notes li { margin-bottom: 6px; }
.panel__option { display: flex; align-items: center; gap: 8px; margin: 10px 0 14px; min-height: 44px; }
.panel__option input { width: 22px; height: 22px; }

.primary {
  font: inherit; font-weight: 800; font-size: 1.05rem;
  background: var(--accent); color: #fff;
  border: 3px solid var(--ink); border-radius: 999px;
  padding: 10px 22px; min-height: 48px; cursor: pointer;
  box-shadow: 3px 3px 0 var(--ink);
}
.primary:active { transform: translate(2px, 2px); box-shadow: 1px 1px 0 var(--ink); }

/* News card */
.news-card {
  width: min(32rem, calc(100vw - 2 * var(--gutter)));
  max-height: calc(100dvh - 2 * var(--gutter));
  overflow: auto;
  padding: 0;
  border: 4px solid var(--ink); border-radius: var(--radius);
  background: var(--paper); color: var(--ink);
  box-shadow: 8px 8px 0 var(--accent-2);
}
.news-card::backdrop { background: rgba(10, 8, 20, 0.45); }
.news-card[open] { animation: card-in var(--transition) ease-out; }
@keyframes card-in { from { opacity: 0; transform: scale(0.96); } to { opacity: 1; transform: none; } }
@media (prefers-reduced-motion: reduce) { .news-card[open] { animation: none; } }
:root[data-reduced-motion='true'] .news-card[open] { animation: none; }
.news-card article { padding: 18px 20px 20px; }
.news-card h2 { font-size: clamp(1.15rem, 4.5vw, 1.45rem); line-height: 1.2; margin: 6px 0 10px; overflow-wrap: anywhere; }
.news-card p { margin: 0 0 10px; overflow-wrap: anywhere; }
.news-card__kicker { display: flex; flex-wrap: wrap; gap: 6px 12px; align-items: center; font-size: 0.85rem; font-weight: 700; }
.news-card__splat {
  background: var(--accent); color: #fff; padding: 2px 10px; border-radius: 999px;
  transform: rotate(-4deg); letter-spacing: 0.05em;
}
.news-card__topic { font-weight: 500; }
.news-card__depicts { font-size: 0.85rem; font-style: italic; color: #4a4a5e; }
.news-card__meta { display: flex; flex-wrap: wrap; gap: 4px 14px; font-size: 0.85rem; color: #4a4a5e; }
.news-card__link a { color: #0b5aa8; font-weight: 700; }
.news-card__disclaimer {
  font-size: 0.82rem; background: #fff3b0; border-left: 5px solid var(--focus);
  padding: 8px 10px; border-radius: 6px;
}
.news-card__actions { display: flex; justify-content: flex-end; }

.hud__title, .hud__tags { white-space: nowrap; }

@media (max-width: 480px) {
  .hud--top { align-items: flex-start; }
  .hud__hint { display: none; }
  .hud__brand { flex-direction: column; align-items: flex-start; gap: 2px; border-radius: 12px; }
  .hud__title { font-size: 0.8rem; }
  .hud__tags strong { font-size: 1.05rem; }
  .hud__edition { font-size: 0.7rem; max-width: 40vw; }
  .news-card__actions .primary { width: 100%; }
}
