:root {
  color-scheme: dark;
  --ink: #fff7d7;
  --muted: #b9c3d6;
  --bg: #090917;
  --panel: #161731;
  --panel-2: #242648;
  --line: #59607d;
  --black: #05050c;
  --red: #ff5c6c;
  --yellow: #ffd45c;
  --cyan: #38d8ff;
  --green: #69e889;
  --violet: #9d7cff;
  --shadow: 0 24px 0 #05050c;
  font-family:
    "Courier New", Courier, ui-monospace, SFMono-Regular, Menlo, Consolas,
    monospace;
}

* {
  box-sizing: border-box;
}

html {
  scroll-behavior: smooth;
}

body {
  margin: 0;
  min-width: 320px;
  background:
    linear-gradient(transparent 23px, rgba(255, 255, 255, 0.04) 24px),
    linear-gradient(90deg, transparent 23px, rgba(255, 255, 255, 0.035) 24px),
    linear-gradient(135deg, rgba(255, 92, 108, 0.16) 0 12%, transparent 12% 62%, rgba(56, 216, 255, 0.12) 62% 72%, transparent 72%),
    var(--bg);
  background-size:
    24px 24px,
    24px 24px,
    100% 100%;
  color: var(--ink);
  line-height: 1.5;
}

body::before {
  content: "";
  position: fixed;
  inset: 0;
  z-index: -1;
  background: linear-gradient(rgba(255, 255, 255, 0.03) 50%, transparent 50%);
  background-size: 100% 4px;
  pointer-events: none;
}

a {
  color: inherit;
  text-decoration: none;
}

button {
  font: inherit;
}

.topbar {
  position: sticky;
  z-index: 20;
  top: 0;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 18px;
  padding: 16px clamp(16px, 4vw, 48px);
  background: var(--bg);
  border-bottom: 4px solid var(--black);
  box-shadow: inset 0 -1px 0 var(--line);
}

.brand,
.topbar {
  display: flex;
  align-items: center;
}

.brand {
  gap: 12px;
  color: var(--yellow);
  font-size: clamp(1rem, 2.4vw, 1.35rem);
  font-weight: 900;
}

.brand-mark {
  width: 26px;
  height: 26px;
  background: var(--red);
  box-shadow:
    8px 0 0 var(--yellow),
    16px 0 0 var(--cyan),
    0 8px 0 var(--violet),
    8px 8px 0 var(--green),
    16px 8px 0 var(--red),
    0 16px 0 var(--cyan),
    8px 16px 0 var(--violet),
    16px 16px 0 var(--yellow);
  image-rendering: pixelated;
  transform: scale(0.72);
  transform-origin: left top;
}

.game-shell {
  padding: clamp(18px, 3vw, 30px) clamp(24px, 5vw, 56px);
}

.game-layout {
  height: calc(100svh - 132px);
  display: grid;
  grid-template-rows: minmax(0, 1fr) auto;
  gap: clamp(12px, 1.8vw, 18px);
  width: min(1180px, 100%);
  margin: 0 auto;
}

.game-screen-area,
.game-picker {
  background: var(--panel);
  border: 4px solid var(--line);
  box-shadow:
    inset 0 0 0 4px rgba(255, 255, 255, 0.05),
    var(--shadow);
}

.game-screen-area {
  display: grid;
  min-height: 0;
}

.screen-bezel {
  position: relative;
  width: 100%;
  height: 100%;
  min-height: 0;
  background: #03030a;
  border: 8px solid #393d59;
  box-shadow:
    inset 0 0 0 8px #111225,
    inset 0 0 36px rgba(0, 0, 0, 0.86);
  overflow: hidden;
}

#game-screen {
  width: 100%;
  height: 100%;
  display: block;
  image-rendering: pixelated;
}

.scanlines {
  position: absolute;
  inset: 0;
  background: linear-gradient(rgba(255, 255, 255, 0.08) 50%, rgba(0, 0, 0, 0.08) 50%);
  background-size: 100% 6px;
  mix-blend-mode: screen;
  opacity: 0.34;
  pointer-events: none;
}

.game-picker {
  padding: 12px;
}

.game-list {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
  gap: 12px;
}

.game-card {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 100%;
  min-height: 76px;
  padding: 10px 12px;
  background: var(--panel-2);
  color: var(--ink);
  border: 3px solid #72799b;
  border-radius: 0;
  box-shadow: 5px 5px 0 var(--black);
  text-align: left;
  cursor: pointer;
}

.game-card:hover,
.game-card:focus-visible {
  border-color: var(--cyan);
  transform: translate(-2px, -2px);
}

.game-card.is-active {
  background: #31264f;
  border-color: var(--yellow);
  color: var(--yellow);
}

.game-card strong {
  display: block;
  font-size: 1rem;
  line-height: 1.1;
  overflow-wrap: anywhere;
  text-align: center;
}

@media (max-width: 640px) {
  .topbar {
    align-items: center;
  }

  .game-shell {
    padding: 18px;
  }

  .game-picker {
    padding: 12px;
  }

  .screen-bezel {
    border-width: 6px;
  }

  .game-list {
    grid-auto-columns: minmax(170px, 70vw);
    grid-auto-flow: column;
    grid-template-columns: none;
    overflow-x: auto;
    padding-bottom: 8px;
    scroll-snap-type: x proximity;
  }

  .game-card {
    scroll-snap-align: start;
  }
}

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