:root {
  color-scheme: light;
  --ink: #12110f;
  --paper: #f3ecdd;
  --frame: #e9dfcc;
  --acid: #c9ed17;
  --red: #e63a2e;
  --line: rgba(18, 17, 15, 0.2);
  --ui: "Arial Narrow", "Helvetica Neue", Arial, sans-serif;
  --display: Impact, Haettenschweiler, "Arial Black", sans-serif;
}

* { box-sizing: border-box; }

html {
  background: var(--paper);
  scroll-behavior: smooth;
}

body {
  margin: 0;
  min-width: 320px;
  overflow-x: hidden;
  background: var(--paper);
  color: var(--ink);
  font-family: var(--ui);
  text-rendering: geometricPrecision;
}

button, a { font: inherit; }

button { color: inherit; }

.topbar {
  position: fixed;
  inset: 0 0 auto;
  z-index: 200;
  display: flex;
  min-height: 72px;
  align-items: stretch;
  justify-content: space-between;
  border-bottom: 4px solid var(--ink);
  background: rgba(243, 236, 221, 0.96);
}

.brand {
  display: flex;
  align-items: center;
  padding: 0 24px;
  color: var(--ink);
  font-family: var(--display);
  font-size: clamp(1.45rem, 2.4vw, 2.3rem);
  letter-spacing: -0.035em;
  line-height: 1;
  text-decoration: none;
}

.brand-baam { color: var(--red); }
.brand-dot { color: var(--ink); }

.topbar-controls { display: flex; align-items: stretch; }

.speed-meter {
  --meter-color: var(--red);
  position: relative;
  display: grid;
  min-width: 132px;
  place-content: center;
  gap: 3px;
  padding: 0 18px 7px;
  overflow: hidden;
  border: 0;
  border-left: 4px solid var(--ink);
  background: var(--acid);
  color: var(--ink);
  text-align: left;
  transition: background 120ms ease, color 120ms ease;
}

.speed-meter::after {
  position: absolute;
  top: 7px;
  right: 7px;
  width: 7px;
  height: 7px;
  border: 2px solid currentColor;
  content: "";
  transform: rotate(45deg);
}

.speed-meter__label {
  font-size: 0.54rem;
  font-weight: 900;
  letter-spacing: 0.15em;
}

.speed-meter strong {
  font: 400 1.32rem/0.95 var(--display);
  letter-spacing: 0.04em;
}

.speed-meter__track {
  position: absolute;
  inset: auto 8px 6px;
  height: 4px;
  background: repeating-linear-gradient(90deg, rgba(18, 17, 15, 0.25) 0 9px, transparent 9px 12px);
}

.speed-meter__track i {
  position: absolute;
  inset: 0;
  background: repeating-linear-gradient(90deg, var(--red) 0 9px, transparent 9px 12px);
  transform: scaleX(0.18);
  transform-origin: left center;
  transition: transform 160ms cubic-bezier(0.2, 0.8, 0.2, 1);
}

.speed-meter.is-changing {
  background: var(--red);
  color: var(--paper);
}

.speed-meter.is-changing .speed-meter__track i { background: var(--acid); }

.control {
  position: relative;
  display: grid;
  min-width: 82px;
  place-content: center;
  gap: 4px;
  border: 0;
  border-left: 1px solid var(--line);
  background: transparent;
  cursor: pointer;
  transition: background 150ms ease, color 150ms ease;
}

.control span {
  font-size: 0.57rem;
  font-weight: 800;
  letter-spacing: 0.16em;
}

.control strong {
  font-family: var(--display);
  font-size: 1.1rem;
  font-weight: 400;
  letter-spacing: 0.04em;
}

.control:hover, .control:focus-visible {
  outline: none;
  background: var(--ink);
  color: var(--paper);
}

.control--gravity:hover, .control--gravity:focus-visible { background: var(--acid); }
.control--gravity { border-left-width: 4px; }
.control--sound:hover, .control--sound:focus-visible { background: #00dfe9; }
.control--sound[aria-pressed="false"] strong { opacity: 0.38; }
.control--motion:hover, .control--motion:focus-visible { background: var(--red); }
.control--motion[aria-pressed="true"] { background: var(--ink); color: var(--paper); }
.control--motion[aria-pressed="true"] strong { color: var(--acid); }
.control--seed { min-width: 112px; background: var(--red); color: var(--paper); }

.game-stage {
  position: relative;
  min-height: max(100svh, 850px);
  padding-top: 72px;
  overflow: hidden;
  isolation: isolate;
  background:
    linear-gradient(90deg, transparent 0 49.94%, rgba(18, 17, 15, 0.055) 49.94% 50.06%, transparent 50.06%),
    var(--paper);
}

.stage-grid {
  position: absolute;
  inset: 0;
  z-index: 0;
  opacity: 0.13;
  background-image:
    linear-gradient(rgba(18, 17, 15, 0.26) 1px, transparent 1px),
    linear-gradient(90deg, rgba(18, 17, 15, 0.26) 1px, transparent 1px);
  background-size: 28px 28px;
}

.stage-copy {
  position: absolute;
  top: 112px;
  left: clamp(20px, 4vw, 68px);
  z-index: 20;
  max-width: min(43vw, 610px);
  pointer-events: none;
}

.eyebrow {
  margin: 0 0 10px;
  color: var(--red);
  font-size: 0.68rem;
  font-weight: 900;
  letter-spacing: 0.18em;
}

.stage-copy h1 {
  margin: 0;
  font: 400 clamp(3.8rem, 8vw, 8.8rem)/0.78 var(--display);
  letter-spacing: -0.055em;
  text-transform: uppercase;
  text-shadow: 4px 4px 0 var(--paper);
}

.stage-copy h1 em {
  color: var(--red);
  font-style: normal;
}

.stage-intro {
  width: min(370px, 100%);
  margin: 22px 0 0;
  font-size: clamp(0.82rem, 1.15vw, 1.05rem);
  font-weight: 700;
  line-height: 1.25;
  text-transform: uppercase;
}

.arena {
  position: absolute;
  inset: 72px 0 0;
  z-index: 5;
  overflow: hidden;
  touch-action: none;
}

.arena::before {
  display: none;
}

.world-layer {
  position: absolute;
  top: 50%;
  left: 50%;
  width: calc(100% - 36px);
  height: calc(100% - 36px);
  overflow: hidden;
  border: 6px solid var(--ink);
  background: var(--frame);
  box-shadow: 14px 16px 0 var(--red), 26px 28px 0 rgba(18, 17, 15, 0.16);
  transform: translate(-50%, -50%);
  transform-origin: center;
  will-change: transform;
}

.arena-canvas, .card-layer {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
}

.arena-canvas { z-index: 1; pointer-events: none; }
.card-layer { z-index: 2; pointer-events: none; }

.world-stamp {
  position: absolute;
  right: 10px;
  bottom: 8px;
  z-index: 4;
  display: flex;
  gap: 12px;
  color: rgba(18, 17, 15, 0.48);
  font-size: 0.54rem;
  font-weight: 900;
  letter-spacing: 0.16em;
  pointer-events: none;
}

.drop-marker {
  position: absolute;
  top: 18px;
  right: 18px;
  display: flex;
  width: 82px;
  height: 82px;
  align-items: center;
  justify-content: center;
  z-index: 18;
  border: 2px dashed rgba(18, 17, 15, 0.3);
  border-radius: 50%;
  background: rgba(243, 236, 221, 0.8);
  color: rgba(18, 17, 15, 0.58);
  font-size: 0.52rem;
  font-weight: 900;
  letter-spacing: 0.12em;
  text-align: center;
}

.drop-marker::before, .drop-marker::after {
  display: none;
}
.gravity-arrow {
  position: absolute;
  top: 13px;
  color: var(--red);
  font-family: var(--display);
  font-size: 1.7rem;
  font-weight: 400;
  line-height: 1;
}
.drop-marker span {
  position: absolute;
  bottom: 15px;
}

.floor-label {
  position: absolute;
  inset: auto 18px 12px;
  display: flex;
  justify-content: space-between;
  z-index: 18;
  border-top: 2px solid var(--ink);
  padding-top: 8px;
  color: rgba(18, 17, 15, 0.55);
  font-size: 0.59rem;
  font-weight: 900;
  letter-spacing: 0.2em;
  pointer-events: none;
}

.stage-status {
  position: absolute;
  right: 24px;
  bottom: 43px;
  z-index: 8;
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 7px 9px;
  border: 2px solid var(--ink);
  background: var(--paper);
  color: rgba(18, 17, 15, 0.72);
  font-size: 0.56rem;
  font-weight: 800;
  letter-spacing: 0.12em;
  pointer-events: none;
}

.live-dot {
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: var(--red);
  box-shadow: 0 0 11px var(--red);
}

.game-card {
  --accent: var(--acid);
  position: absolute;
  top: 0;
  left: 0;
  display: block;
  width: 300px;
  height: 200px;
  overflow: hidden;
  border: 4px solid var(--paper);
  outline: 1px solid rgba(12, 12, 12, 0.65);
  background: color-mix(in srgb, var(--accent) 84%, #101010);
  color: var(--ink);
  box-shadow: 12px 14px 0 rgba(0, 0, 0, 0.62);
  cursor: grab;
  pointer-events: auto;
  transform-origin: center;
  will-change: transform, width, height;
  user-select: none;
}

.card-interface {
  --interface-angle: 0rad;
  position: absolute;
  top: 50%;
  left: 50%;
  z-index: 2;
  display: flex;
  width: 100%;
  height: 100%;
  flex-direction: column;
  transform: translate(-50%, -50%) rotate(var(--interface-angle));
  transform-origin: center;
  transition: transform 360ms cubic-bezier(.2, .85, .2, 1);
}

.game-card:nth-child(even) { color: var(--paper); }
.game-card:active, .game-card.is-dragging { cursor: grabbing; box-shadow: 18px 24px 0 rgba(0, 0, 0, 0.48); }
.game-card:hover { border-color: var(--accent); }
.game-card:focus-visible { outline: 4px solid var(--accent); outline-offset: 3px; }
.game-card.is-open { border-width: 6px; cursor: grab; }

.card-sim {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  opacity: 0.58;
  mix-blend-mode: multiply;
  pointer-events: none;
}

.game-card:nth-child(even) .card-sim { mix-blend-mode: screen; opacity: 0.66; }

.card-wash {
  position: absolute;
  inset: 0;
  background:
    linear-gradient(120deg, rgba(255, 255, 255, 0.2), transparent 32%),
    repeating-linear-gradient(0deg, transparent 0 5px, rgba(0, 0, 0, 0.055) 5px 6px);
  pointer-events: none;
}

.card-head {
  position: relative;
  z-index: 2;
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  padding: 13px 14px 0;
  font-size: 0.59rem;
  font-weight: 900;
  letter-spacing: 0.16em;
  text-transform: uppercase;
}

.card-index {
  display: grid;
  width: 32px;
  height: 32px;
  place-items: center;
  border: 2px solid currentColor;
  font-family: var(--display);
  font-size: 1.05rem;
  letter-spacing: 0;
}

.card-status {
  padding: 5px 7px;
  border: 1px solid currentColor;
  background: color-mix(in srgb, var(--accent) 70%, transparent);
}

.card-core {
  position: relative;
  z-index: 2;
  display: flex;
  flex: 1;
  flex-direction: column;
  justify-content: flex-end;
  padding: 12px 14px 14px;
}

.card-type {
  margin: 0 0 4px;
  font-size: 0.58rem;
  font-weight: 900;
  letter-spacing: 0.16em;
  text-transform: uppercase;
}

.card-title {
  max-width: 92%;
  margin: 0;
  font: 400 clamp(2.05rem, 3.2vw, 3.9rem)/0.82 var(--display);
  letter-spacing: -0.045em;
  text-transform: uppercase;
}

.card-summary {
  display: none;
  max-width: 540px;
  margin: 14px 0 0;
  font-size: clamp(0.87rem, 1.25vw, 1.08rem);
  font-weight: 700;
  line-height: 1.25;
}

.card-details {
  position: relative;
  z-index: 2;
  display: none;
  align-items: flex-end;
  justify-content: space-between;
  gap: 18px;
  padding: 0 16px 16px;
}

.is-open .card-summary, .is-open .card-details { display: flex; }
.is-open .card-core { justify-content: flex-end; }
.is-open .card-title { max-width: 76%; font-size: clamp(3rem, 6vw, 6.4rem); }

.card-tags { display: flex; max-width: 54%; flex-wrap: wrap; gap: 4px; }

.card-tags span {
  padding: 4px 7px;
  border: 1px solid currentColor;
  font-size: 0.58rem;
  font-weight: 900;
  letter-spacing: 0.09em;
  text-transform: uppercase;
}

.card-links { display: flex; gap: 7px; }

.card-link {
  display: inline-flex;
  min-height: 34px;
  align-items: center;
  justify-content: center;
  padding: 0 11px;
  border: 2px solid currentColor;
  background: var(--ink);
  color: var(--paper);
  font-size: 0.63rem;
  font-weight: 900;
  letter-spacing: 0.11em;
  text-decoration: none;
  text-transform: uppercase;
}

.card-link:hover, .card-link:focus-visible { background: var(--paper); color: var(--ink); outline: none; }
.card-link.is-disabled { cursor: default; opacity: 0.6; }

.card-close {
  position: absolute;
  top: 10px;
  right: 10px;
  z-index: 5;
  display: none;
  width: 34px;
  height: 34px;
  place-items: center;
  border: 2px solid currentColor;
  background: transparent;
  color: inherit;
  font-size: 1.35rem;
  line-height: 1;
  cursor: pointer;
}

.is-open .card-close { display: grid; }
.is-open .card-status { margin-right: 42px; }

.card-corner {
  position: absolute;
  z-index: 4;
  width: 13px;
  height: 13px;
  pointer-events: none;
}

.card-corner--tl { top: 5px; left: 5px; border-top: 2px solid currentColor; border-left: 2px solid currentColor; }
.card-corner--br { right: 5px; bottom: 5px; border-right: 2px solid currentColor; border-bottom: 2px solid currentColor; }

.game-card[data-game="asymmetric-wars"] { background: #ff5038; }
.game-card[data-game="doctrine-engine"] { background: #dfff00; }
.game-card[data-game="ninja-worms"] { background: #00dfe9; }
.game-card[data-game="spider-vs-ants"] { background: #a85bef; }

.game-card[data-game="doctrine-engine"],
.game-card[data-game="spider-vs-ants"] { color: var(--ink); }

@media (max-width: 820px) {
  .topbar { min-height: 62px; }
  .brand { padding: 0 14px; }
  .speed-meter { min-width: 104px; padding-inline: 12px; }
  .control { min-width: 60px; }
  .control--seed { min-width: 85px; }
  .game-stage { min-height: 1080px; padding-top: 62px; }
  .arena { inset: 62px 0 0; }
  .stage-copy { top: 90px; left: 16px; max-width: 80vw; }
  .stage-copy h1 { font-size: clamp(3.4rem, 16vw, 6.4rem); }
  .stage-intro { max-width: 260px; }
  .world-layer {
    top: 50%;
    left: 50%;
    width: calc(100% - 24px);
    height: calc(100% - 28px);
  }
  .floor-label { inset-inline: 12px; }
  .stage-status { right: 12px; bottom: 41px; }
  .drop-marker { display: none; }
  .card-title { font-size: clamp(1.85rem, 9vw, 3.3rem); }
  .is-open .card-title { font-size: clamp(2.6rem, 13vw, 4.4rem); }
  .card-details { align-items: flex-start; flex-direction: column; }
  .card-tags { max-width: 100%; }
}

@media (max-width: 480px) {
  .control--gravity { display: none; }
  .speed-meter { min-width: 82px; padding-inline: 8px; }
  .speed-meter__label { font-size: 0.47rem; letter-spacing: 0.1em; }
  .speed-meter strong { font-size: 1.12rem; }
  .brand { font-size: 1.5rem; }
  .stage-copy h1 { font-size: 3.8rem; }
  .stage-copy { top: 84px; }
  .game-stage { min-height: 1180px; }
}

@media (prefers-reduced-motion: reduce) {
  html { scroll-behavior: auto; }
  .arena { touch-action: auto; }
  .game-card { transition: none; }
}
