@font-face {
  font-family: 'Press Start 2P';
  src: url('../fonts/press-start-2p-latin.woff2') format('woff2');
  font-weight: 400;
  font-style: normal;
  font-display: swap;
}

:root {
  --bg: #11131e;
  --bg-grid: rgba(54, 64, 105, 0.28);
  --surface: #1a1e30;
  --surface-elevated: #232942;
  --border: #364069;
  --border-strong: #506099;
  --text: #edf2ff;
  --text-muted: #a2afd4;
  --accent: #00f5d4;
  --accent-ink: #081c1a;
  --gold: #ffd166;
  --danger: #ff4d6d;
  --success: #38e54d;
  --shadow-hard: #070910;

  --font-display: 'Press Start 2P', ui-monospace, SFMono-Regular, Menlo, monospace;
  --font-body: system-ui, -apple-system, 'Segoe UI', Roboto, Helvetica, Arial, sans-serif;

  /* Strictly 3 body font sizes below the hero */
  --text-heading: 1.25rem;
  --text-body: 1rem;
  --text-sm: 0.875rem;

  --max-width: 1120px;
  --radius: 6px;
}

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

html {
  background-color: var(--bg);
  color: var(--text);
  font-family: var(--font-body);
  font-size: 16px;
  line-height: 1.6;
  -webkit-text-size-adjust: 100%;
  scroll-behavior: smooth;
}

body {
  margin: 0;
  min-block-size: 100dvh;
  display: flex;
  flex-direction: column;
  background-color: var(--bg);
  background-image: radial-gradient(var(--bg-grid) 1.5px, transparent 1.5px);
  background-size: 24px 24px;
  color: var(--text);
  font-size: var(--text-body);
  font-variant-numeric: tabular-nums;
}

img {
  display: block;
  max-inline-size: 100%;
  block-size: auto;
}

a {
  color: var(--accent);
  text-decoration: none;
  transition: color 160ms cubic-bezier(0.22, 1, 0.36, 1);
}

a:hover {
  color: var(--gold);
}

:where(a:any-link, button, summary, input, [tabindex]):focus-visible {
  outline: 3px solid var(--accent);
  outline-offset: 3px;
}

/* Visually hidden utility */
.visually-hidden:where(:not(:focus-within, :active)) {
  position: absolute !important;
  clip-path: inset(50%) !important;
  overflow: hidden !important;
  width: 1px !important;
  height: 1px !important;
  margin: -1px !important;
  padding: 0 !important;
  border: 0 !important;
  white-space: nowrap !important;
}

.skip-link:focus-visible {
  position: fixed;
  inset-block-start: 12px;
  inset-inline-start: 12px;
  z-index: 10000;
  padding: 10px 14px;
  background: var(--gold);
  color: var(--bg);
  font-family: var(--font-display);
  font-size: var(--text-sm);
}

.container {
  inline-size: min(100% - 2rem, var(--max-width));
  margin-inline: auto;
}

/* Header */
.site-header {
  position: sticky;
  inset-block-start: 0;
  z-index: 100;
  background-color: rgba(17, 19, 30, 0.94);
  backdrop-filter: blur(8px);
  border-block-end: 2px solid var(--border);
}

.header-inner {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
  min-block-size: 64px;
  padding-block: 0.625rem;
}

.brand-link {
  display: inline-flex;
  align-items: center;
  gap: 0.75rem;
  color: var(--text);
  font-family: var(--font-display);
  font-size: 1.05rem;
  letter-spacing: 0.02em;
  white-space: nowrap;
}

.brand-link:hover {
  color: var(--accent);
}

.brand-mark {
  flex-shrink: 0;
  border: 2px solid var(--border-strong);
  border-radius: 4px;
}

.header-nav {
  display: flex;
  align-items: center;
  gap: 0.75rem;
}

.header-nav-links {
  display: flex;
  align-items: center;
  gap: 1.25rem;
  list-style: none;
  margin: 0;
  padding: 0;
}

.header-nav-links a {
  color: var(--text-muted);
  font-size: var(--text-sm);
  font-weight: 600;
  white-space: nowrap;
}

.header-nav-links a:hover,
.header-nav-links a[aria-current="page"] {
  color: var(--text);
}

.header-actions {
  display: flex;
  align-items: center;
  gap: 0.5rem;
}

.shell-page-title {
  color: var(--text-muted);
  font-size: var(--text-sm);
  font-weight: 600;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  max-inline-size: 26ch;
}

/* Tactile arcade buttons */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 0.5rem;
  min-block-size: 40px;
  min-inline-size: 40px;
  padding: 0.55rem 1rem;
  border: 2px solid var(--border-strong);
  border-radius: var(--radius);
  background-color: var(--surface-elevated);
  color: var(--text);
  font-family: var(--font-body);
  font-size: var(--text-sm);
  font-weight: 700;
  line-height: 1.2;
  cursor: pointer;
  box-shadow: 0 4px 0 var(--shadow-hard);
  transition: transform 140ms cubic-bezier(0.22, 1, 0.36, 1),
              background-color 140ms cubic-bezier(0.22, 1, 0.36, 1),
              border-color 140ms cubic-bezier(0.22, 1, 0.36, 1),
              box-shadow 140ms cubic-bezier(0.22, 1, 0.36, 1);
  user-select: none;
}

.btn:hover {
  border-color: var(--accent);
  color: var(--accent);
}

.btn:active {
  transform: translateY(2px);
  box-shadow: 0 2px 0 var(--shadow-hard);
}

.btn-primary {
  background-color: var(--accent);
  border-color: #70fff0;
  color: var(--accent-ink);
}

.btn-primary:hover {
  background-color: #36ffe4;
  border-color: #a8fff5;
  color: var(--accent-ink);
}

.btn-gold {
  background-color: var(--gold);
  border-color: #ffe5a3;
  color: var(--accent-ink);
}

.btn-gold:hover {
  background-color: #ffdc85;
  color: var(--accent-ink);
}

.btn[aria-pressed="true"] {
  border-color: var(--gold);
  color: var(--gold);
}

.btn-compact {
  min-block-size: 36px;
  padding: 0.4rem 0.75rem;
}

@media (pointer: coarse) {
  .btn,
  .segmented-option {
    min-block-size: 44px;
    min-inline-size: 44px;
  }
}

/* Main content */
main {
  flex: 1 0 auto;
  padding-block: 1.75rem 3.5rem;
}

/* Lobby Masthead (immediate play grid, no 100vh hero) */
.lobby-head {
  display: flex;
  flex-wrap: wrap;
  align-items: flex-end;
  justify-content: space-between;
  gap: 1.25rem;
  padding-block-end: 1.5rem;
  border-block-end: 2px solid var(--border);
  margin-block-end: 1.75rem;
}

.lobby-head h1 {
  margin: 0 0 0.5rem;
  font-family: var(--font-display);
  font-size: clamp(1.35rem, 3vw, 2rem);
  line-height: 1.3;
  letter-spacing: -0.02em;
  color: var(--text);
}

.lobby-lead {
  margin: 0;
  max-inline-size: 56ch;
  color: var(--text-muted);
  font-size: var(--text-body);
}

/* Segmented non-button filter control */
.segmented-group {
  display: inline-flex;
  align-items: center;
  padding: 3px;
  border: 2px solid var(--border);
  border-radius: var(--radius);
  background-color: var(--surface);
  gap: 2px;
}

.segmented-group input[type="radio"] {
  position: absolute;
  opacity: 0;
  inline-size: 1px;
  block-size: 1px;
  margin: 0;
}

.segmented-option {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  padding: 0.4rem 0.85rem;
  border-radius: 4px;
  color: var(--text-muted);
  font-size: var(--text-sm);
  font-weight: 700;
  cursor: pointer;
  user-select: none;
  transition: background-color 140ms cubic-bezier(0.22, 1, 0.36, 1),
              color 140ms cubic-bezier(0.22, 1, 0.36, 1);
}

.segmented-group input[type="radio"]:checked + .segmented-option {
  background-color: var(--accent);
  color: var(--accent-ink);
}

.segmented-group input[type="radio"]:focus-visible + .segmented-option {
  outline: 3px solid var(--gold);
  outline-offset: 2px;
}

/* Lobby Game Grid */
.game-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(290px, 1fr));
  gap: 1.5rem;
}

.game-card {
  display: flex;
  flex-direction: column;
  background-color: var(--surface);
  border: 2px solid var(--border);
  border-radius: var(--radius);
  overflow: hidden;
  box-shadow: 0 6px 0 var(--shadow-hard);
  transition: transform 160ms cubic-bezier(0.22, 1, 0.36, 1),
              border-color 160ms cubic-bezier(0.22, 1, 0.36, 1);
}

.game-card:hover {
  transform: translateY(-3px);
  border-color: var(--accent);
}

.game-card[hidden] {
  display: none;
}

.game-card-cover {
  display: block;
  aspect-ratio: 16 / 9;
  inline-size: 100%;
  object-fit: cover;
  background-color: var(--bg);
  border-block-end: 2px solid var(--border);
  image-rendering: pixelated;
}

.game-card-body {
  display: flex;
  flex-direction: column;
  flex: 1 0 auto;
  padding: 1.15rem 1.25rem 1.25rem;
  gap: 0.6rem;
}

.game-card-meta {
  font-size: var(--text-sm);
  color: var(--gold);
  font-weight: 700;
}

.game-card-title {
  margin: 0;
  font-family: var(--font-display);
  font-size: var(--text-heading);
  line-height: 1.35;
  color: var(--text);
}

.game-card-desc {
  margin: 0;
  color: var(--text-muted);
  font-size: var(--text-body);
  flex: 1 0 auto;
}

.game-card-footer {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.75rem;
  padding-block-start: 0.75rem;
  border-block-start: 1px solid var(--border);
}

.best-readout {
  font-size: var(--text-sm);
  color: var(--text-muted);
  font-weight: 600;
}

.best-readout strong {
  color: var(--accent);
}

/* Upcoming roadmap section on lobby */
.upcoming-section {
  margin-block-start: 3.25rem;
  padding-block-start: 2rem;
  border-block-start: 2px solid var(--border);
}

.upcoming-section h2 {
  margin: 0 0 0.5rem;
  font-family: var(--font-display);
  font-size: var(--text-heading);
  line-height: 1.4;
}

.upcoming-intro {
  margin: 0 0 1.25rem;
  color: var(--text-muted);
  max-inline-size: 65ch;
}

.upcoming-list {
  list-style: none;
  margin: 0;
  padding: 0;
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(230px, 1fr));
  gap: 1rem;
}

.upcoming-item {
  padding: 1rem 1.15rem;
  border-block-start: 3px solid var(--border-strong);
  background-color: var(--surface);
}

.upcoming-item h3 {
  margin: 0 0 0.35rem;
  font-size: var(--text-body);
  color: var(--text);
}

.upcoming-item p {
  margin: 0;
  font-size: var(--text-sm);
  color: var(--text-muted);
}

/* Game Shell & Stage */
.game-hero-header {
  display: flex;
  flex-wrap: wrap;
  align-items: baseline;
  justify-content: space-between;
  gap: 0.75rem;
  margin-block-end: 1rem;
}

.game-hero-header h1 {
  margin: 0;
  font-family: var(--font-display);
  font-size: clamp(1.25rem, 2.8vw, 1.8rem);
  line-height: 1.35;
  letter-spacing: -0.02em;
}

.game-tagline {
  margin: 0;
  color: var(--text-muted);
  font-size: var(--text-body);
}

.game-stage {
  position: relative;
  display: flex;
  flex-direction: column;
  background-color: var(--surface);
  border: 2px solid var(--border-strong);
  border-radius: var(--radius);
  box-shadow: 0 8px 0 var(--shadow-hard);
  overflow: hidden;
  margin-block-end: 3rem;
}

.game-stage:fullscreen {
  border-radius: 0;
  border: 0;
  background-color: var(--bg);
  padding: 1rem;
  justify-content: center;
}

.game-stage.is-pseudo-fullscreen {
  position: fixed;
  inset: 0;
  z-index: 9999;
  margin: 0;
  border-radius: 0;
  border: 0;
  background-color: var(--bg);
  overflow-y: auto;
  padding: 0.75rem;
}

.game-hud {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 0.75rem;
  padding: 0.85rem 1.15rem;
  background-color: var(--surface-elevated);
  border-block-end: 2px solid var(--border);
}

.hud-metrics {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 1.25rem;
}

.hud-stat {
  display: flex;
  align-items: baseline;
  gap: 0.45rem;
  font-size: var(--text-sm);
  color: var(--text-muted);
  font-weight: 600;
}

.hud-stat strong {
  color: var(--text);
  font-family: var(--font-display);
  font-size: var(--text-sm);
}

.hud-controls {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 0.5rem;
}

.game-play-area {
  position: relative;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: 1.25rem;
  min-block-size: 420px;
}

/* Native <dialog> modal rules (scoped to dialog[open]!) */
dialog.arcade-dialog {
  margin: auto;
  padding: 0;
  inline-size: min(calc(100% - 2rem), 480px);
  max-block-size: calc(100dvh - 2rem);
  overflow-y: auto;
  border: 2px solid var(--accent);
  border-radius: var(--radius);
  background-color: var(--surface);
  color: var(--text);
  box-shadow: 0 12px 0 var(--shadow-hard);
}

dialog.arcade-dialog[open] {
  display: block;
}

dialog.arcade-dialog:modal {
  overscroll-behavior: contain;
}

dialog.arcade-dialog::backdrop {
  background-color: rgba(7, 9, 16, 0.82);
  overflow: hidden;
  overscroll-behavior: contain;
}

.dialog-inner {
  padding: 1.5rem;
  display: flex;
  flex-direction: column;
  gap: 1rem;
}

.dialog-header {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 1rem;
}

.dialog-header h1 {
  margin: 0;
  font-family: var(--font-display);
  font-size: var(--text-heading);
  line-height: 1.4;
  color: var(--gold);
}

.dialog-score-box {
  padding: 1rem;
  background-color: var(--surface-elevated);
  border: 2px solid var(--border);
  border-radius: var(--radius);
  text-align: center;
}

.dialog-primary-metric {
  margin: 0 0 0.25rem;
  font-family: var(--font-display);
  font-size: clamp(1.5rem, 4vw, 2rem);
  color: var(--accent);
}

.dialog-rank-line {
  margin: 0;
  font-size: var(--text-body);
  font-weight: 700;
  color: var(--text);
}

.dialog-meta-grid {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 0.75rem;
  margin: 0;
}

.dialog-meta-item {
  padding: 0.65rem 0.75rem;
  background-color: var(--bg);
  border: 1px solid var(--border);
  border-radius: 4px;
}

.dialog-meta-item dt {
  font-size: var(--text-sm);
  color: var(--text-muted);
}

.dialog-meta-item dd {
  margin: 0.2rem 0 0;
  font-weight: 700;
  font-size: var(--text-body);
  color: var(--text);
}

.dialog-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 0.65rem;
}

.dialog-actions .btn {
  flex: 1 1 140px;
}

.dialog-next-link {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 0.45rem 0.75rem;
  padding: 0.85rem 1rem;
  border-block-start: 2px solid var(--border);
  background-color: var(--bg);
  color: var(--text);
  font-weight: 700;
  font-size: var(--text-sm);
}

.dialog-next-link span:last-child {
  color: var(--accent);
  white-space: nowrap;
}

.dialog-next-link:hover {
  color: var(--gold);
}

/* SEO Strategy Guide, Tables & Native FAQ Accordion (clear separation from stage) */
.guide-section {
  padding-block-start: 2rem;
  border-block-start: 2px solid var(--border);
}

.guide-layout {
  display: grid;
  grid-template-columns: minmax(0, 1fr);
  gap: 2.25rem;
}

.guide-prose {
  max-inline-size: 65ch;
}

.guide-prose h2 {
  margin: 0 0 0.75rem;
  font-family: var(--font-display);
  font-size: var(--text-heading);
  line-height: 1.45;
  color: var(--text);
}

.guide-prose h3 {
  margin: 1.75rem 0 0.5rem;
  font-size: var(--text-heading);
  line-height: 1.35;
  color: var(--gold);
}

.guide-prose p,
.guide-prose ul,
.guide-prose ol {
  margin: 0 0 1rem;
  font-size: var(--text-body);
  color: var(--text-muted);
}

.guide-prose li + li {
  margin-block-start: 0.45rem;
}

.guide-prose strong {
  color: var(--text);
}

/* Accessible Data Tables */
.table-wrap {
  overflow-x: auto;
  margin-block: 1.25rem 1.75rem;
  border: 2px solid var(--border);
  border-radius: var(--radius);
  background-color: var(--surface);
  max-inline-size: 65ch;
}

.arcade-table {
  inline-size: 100%;
  border-collapse: collapse;
  text-align: start;
  font-size: var(--text-sm);
}

.arcade-table caption {
  padding: 0.75rem 1rem;
  text-align: start;
  font-weight: 700;
  color: var(--text);
  background-color: var(--surface-elevated);
  border-block-end: 2px solid var(--border);
}

.arcade-table th,
.arcade-table td {
  padding: 0.65rem 1rem;
  border-block-end: 1px solid var(--border);
}

.arcade-table th {
  color: var(--accent);
  font-weight: 700;
}

.arcade-table td {
  color: var(--text-muted);
}

.arcade-table tbody tr:last-child td {
  border-block-end: 0;
}

/* Native <details name="faq"> Accordion */
.faq-list {
  display: flex;
  flex-direction: column;
  gap: 0.65rem;
  max-inline-size: 65ch;
}

.faq-item {
  border: 2px solid var(--border);
  border-radius: var(--radius);
  background-color: var(--surface);
}

.faq-item[open] {
  border-color: var(--border-strong);
}

.faq-item summary {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
  padding: 0.85rem 1rem;
  font-weight: 700;
  color: var(--text);
  cursor: pointer;
  list-style: none;
}

.faq-item summary::-webkit-details-marker {
  display: none;
}

.faq-item summary::after {
  content: '+';
  font-family: var(--font-display);
  font-size: var(--text-sm);
  color: var(--accent);
  flex-shrink: 0;
}

.faq-item[open] summary::after {
  content: '-';
  color: var(--gold);
}

.faq-item p {
  margin: 0;
  padding: 0 1rem 1rem;
  color: var(--text-muted);
  font-size: var(--text-body);
}

/* Compliance / Legal Pages */
.doc-page {
  max-inline-size: 65ch;
}

.doc-page h1 {
  margin: 0 0 1rem;
  font-family: var(--font-display);
  font-size: clamp(1.3rem, 3vw, 1.75rem);
  line-height: 1.4;
}

.doc-page h2 {
  margin: 1.75rem 0 0.5rem;
  font-size: var(--text-heading);
  color: var(--gold);
}

.doc-page p,
.doc-page ul {
  margin: 0 0 1rem;
  color: var(--text-muted);
  font-size: var(--text-body);
}

/* Centralized Toast Region */
.toast-region {
  position: fixed;
  inset-block-end: 1.25rem;
  inset-inline-start: 50%;
  transform: translateX(-50%);
  z-index: 10001;
  pointer-events: none;
}

.toast-pill {
  padding: 0.65rem 1.15rem;
  border: 2px solid var(--accent);
  border-radius: var(--radius);
  background-color: var(--surface-elevated);
  color: var(--text);
  font-size: var(--text-sm);
  font-weight: 700;
  box-shadow: 0 4px 0 var(--shadow-hard);
}

/* Footer */
.site-footer {
  border-block-start: 2px solid var(--border);
  background-color: var(--surface);
  padding-block: 1.75rem;
}

.footer-inner {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
}

.footer-brand {
  font-size: var(--text-sm);
  color: var(--text-muted);
}

.footer-brand strong {
  font-family: var(--font-display);
  color: var(--text);
  font-size: var(--text-sm);
}

.footer-links {
  display: flex;
  flex-wrap: wrap;
  gap: 1.25rem;
  list-style: none;
  margin: 0;
  padding: 0;
}

.footer-links a {
  font-size: var(--text-sm);
  color: var(--text-muted);
}

.footer-links a:hover {
  color: var(--accent);
}

/* Responsive tweaks */
@media (max-width: 720px) {
  .header-nav-links {
    display: none;
  }

  .shell-page-title {
    display: none;
  }

  .game-play-area {
    padding: 0.85rem;
    min-block-size: 360px;
  }

  .dialog-meta-grid {
    grid-template-columns: 1fr;
  }
}

@media (max-width: 520px) {
  .header-inner {
    gap: 0.5rem;
  }

  .brand-link {
    gap: 0.45rem;
    font-size: 0.875rem;
  }

  .brand-mark {
    inline-size: 24px;
    block-size: 24px;
  }

  .header-actions {
    gap: 0.35rem;
  }

  .header-actions .btn-compact {
    min-inline-size: auto;
    padding: 0.4rem 0.55rem;
    font-size: 0.8125rem;
  }
}

/* Reduced motion */
@media (prefers-reduced-motion: reduce) {
  html {
    scroll-behavior: auto;
  }

  *,
  *::before,
  *::after {
    animation-duration: 0.01ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.01ms !important;
  }
}
