:root {
  --bg: #08080a;
  --fg: #f6f6f7;
  --g1: #b6b6bb;
  --g2: #74747a;
  --g3: #3a3a41;
  --line: #222227;
  --panel: rgba(14, 14, 17, 0.82);
  --acc: #f6f6f7;
  --display: "Syne", system-ui, sans-serif;
  --mono: "Space Mono", ui-monospace, "SF Mono", Menlo, monospace;
}

* {
  box-sizing: border-box;
  -webkit-tap-highlight-color: transparent;
}
html,
body {
  height: 100%;
  margin: 0;
  overscroll-behavior: none; /* no pull-to-refresh / rubber-band scroll-chaining */
}
body {
  background: var(--bg);
  color: var(--fg);
  font-family: var(--mono);
  display: flex;
  flex-direction: column;
  /* lock the viewport so the page can't be panned/dragged on mobile */
  position: fixed;
  inset: 0;
  overflow: hidden;
  -webkit-font-smoothing: antialiased;
  user-select: none;
  -webkit-user-select: none;
  -webkit-touch-callout: none; /* no iOS long-press selection/callout */
  touch-action: manipulation; /* no double-tap zoom (still lets the hub scroll) */
}
/* the only place typing/selection is wanted: the score-entry fields */
input {
  user-select: text;
  -webkit-user-select: text;
  -webkit-touch-callout: default;
}
.hidden {
  display: none !important;
}

/* ---------- 80s ambience ---------- */
.scanlines {
  position: fixed;
  inset: 0;
  z-index: 100;
  pointer-events: none;
  background: repeating-linear-gradient(
    to bottom,
    rgba(255, 255, 255, 0.035) 0,
    rgba(255, 255, 255, 0.035) 1px,
    transparent 1px,
    transparent 3px
  );
  mix-blend-mode: overlay;
}
body::after {
  /* vignette */
  content: "";
  position: fixed;
  inset: 0;
  z-index: 99;
  pointer-events: none;
  background: radial-gradient(120% 80% at 50% 30%, transparent 55%, rgba(0, 0, 0, 0.55) 100%);
}

.floor {
  position: fixed;
  left: 0;
  right: 0;
  bottom: 0;
  height: 46vh;
  z-index: 0;
  pointer-events: none;
  overflow: hidden;
  opacity: 0.55;
  -webkit-mask-image: linear-gradient(to top, #000 0%, transparent 92%);
  mask-image: linear-gradient(to top, #000 0%, transparent 92%);
  transition: opacity 0.5s;
}
.floor span {
  position: absolute;
  left: -60%;
  right: -60%;
  top: -10%;
  bottom: -30%;
  background-image: repeating-linear-gradient(to right, rgba(255, 255, 255, 0.11) 0 1px, transparent 1px 46px),
    repeating-linear-gradient(to bottom, rgba(255, 255, 255, 0.11) 0 1px, transparent 1px 46px);
  transform: perspective(240px) rotateX(76deg);
  transform-origin: bottom center;
  animation: floorscroll 5.5s linear infinite;
}
@keyframes floorscroll {
  from {
    background-position: 0 0, 0 0;
  }
  to {
    background-position: 0 0, 0 46px;
  }
}
body.in-game .floor {
  opacity: 0.12;
}

/* print registration marks */
.marks i {
  position: fixed;
  width: 13px;
  height: 13px;
  z-index: 60;
  pointer-events: none;
  border: 0 solid var(--g3);
}
.marks i:nth-child(1) {
  top: 12px;
  left: 12px;
  border-top-width: 1px;
  border-left-width: 1px;
}
.marks i:nth-child(2) {
  top: 12px;
  right: 12px;
  border-top-width: 1px;
  border-right-width: 1px;
}
.marks i:nth-child(3) {
  bottom: 12px;
  left: 12px;
  border-bottom-width: 1px;
  border-left-width: 1px;
}
.marks i:nth-child(4) {
  bottom: 12px;
  right: 12px;
  border-bottom-width: 1px;
  border-right-width: 1px;
}

/* ---------- top bar ---------- */
.topbar {
  position: relative;
  z-index: 10;
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: max(16px, env(safe-area-inset-top)) 22px 0;
  height: 60px;
  flex: 0 0 auto;
}
.brand {
  text-align: left;
  background: none;
  border: 0;
  cursor: pointer;
  padding: 4px 0;
  line-height: 1.1;
}
.brand .bw {
  display: block;
  font-family: var(--display);
  font-weight: 800;
  font-size: 15px;
  letter-spacing: 1px;
  color: var(--fg);
}
.brand .sub {
  display: block;
  font-family: var(--mono);
  font-size: 9px;
  letter-spacing: 2.5px;
  color: var(--g2);
  margin-top: 2px;
}
.icon-btn {
  width: 42px;
  height: 42px;
  border-radius: 2px;
  border: 1px solid var(--line);
  background: transparent;
  color: var(--fg);
  font-size: 16px;
  cursor: pointer;
  display: grid;
  place-items: center;
  transition: background 0.15s, color 0.15s, border-color 0.15s;
}
.icon-btn:hover {
  border-color: var(--g2);
}
.icon-btn.off {
  color: var(--g3);
}

main {
  position: relative;
  z-index: 10;
  flex: 1 1 auto;
  min-height: 0;
  display: flex;
  flex-direction: column;
}
.view {
  flex: 1 1 auto;
  min-height: 0;
  display: flex;
  flex-direction: column;
}

/* ---------- hub ---------- */
#hub {
  justify-content: center;
  gap: clamp(24px, 5vh, 56px);
  padding: 16px 22px 28px;
  overflow-y: auto;
}
.hero {
  text-align: left;
  max-width: 760px;
  width: 100%;
  margin: 0 auto;
}
.hero-title {
  font-family: var(--display);
  font-weight: 800;
  font-size: clamp(38px, 12vw, 116px);
  line-height: 0.86;
  letter-spacing: -0.03em;
  margin: 0;
  text-transform: uppercase;
}
.hero-title span {
  display: block;
  color: transparent;
  -webkit-text-stroke: 1.5px var(--fg);
}
.tagline {
  font-family: var(--mono);
  font-size: 11px;
  letter-spacing: 1.5px;
  color: var(--g2);
  margin: 18px 0 0;
}

.grid {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 12px;
  width: 100%;
  max-width: 760px;
  margin: 0 auto;
}
.hubfoot {
  max-width: 760px;
  width: 100%;
  margin: 18px auto 0;
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  align-items: center;
  font-family: var(--mono);
  font-size: 10px;
  letter-spacing: 1px;
  color: var(--g3);
}
.hubfoot a {
  color: var(--g2);
  text-decoration: none;
}
.hubfoot a:hover {
  color: var(--fg);
}
.card {
  position: relative;
  aspect-ratio: 1 / 1;
  border: 1px solid var(--line);
  border-color: color-mix(in srgb, var(--acc, #fff) 22%, var(--line));
  border-radius: 3px;
  background: #0a0a0d center / cover no-repeat;
  color: var(--fg);
  cursor: pointer;
  overflow: hidden;
  padding: 0;
  transition: transform 0.2s ease, box-shadow 0.2s ease, border-color 0.2s ease;
}
.card::after {
  content: "";
  position: absolute;
  inset: 0;
  background: linear-gradient(to top, rgba(6, 6, 9, 0.92) 0%, rgba(6, 6, 9, 0.2) 44%, rgba(6, 6, 9, 0.38) 100%);
}
.card:hover {
  transform: translateY(-3px);
  box-shadow: 0 14px 44px -22px var(--acc, #000);
  border-color: color-mix(in srgb, var(--acc, #fff) 55%, var(--line));
}
.card.flip {
  transform: scale(0.98);
}
.card .idx {
  position: absolute;
  z-index: 1;
  top: 12px;
  left: 13px;
  font-family: var(--mono);
  font-size: 11px;
  letter-spacing: 1px;
  color: var(--fg);
  opacity: 0.72;
}
.card .kind {
  position: absolute;
  z-index: 1;
  top: 13px;
  right: 13px;
  font-family: var(--mono);
  font-size: 8.5px;
  letter-spacing: 2px;
  color: var(--acc, var(--fg));
  opacity: 0.85;
}
.card .cardfoot {
  position: absolute;
  z-index: 1;
  left: 13px;
  right: 13px;
  bottom: 12px;
  display: flex;
  flex-direction: column;
  gap: 2px;
}
.card .nm {
  font-family: var(--display);
  font-weight: 700;
  font-size: 18px;
  letter-spacing: 0.5px;
  text-shadow: 0 1px 10px rgba(0, 0, 0, 0.6);
}
.card .bst {
  font-family: var(--mono);
  font-size: 10px;
  letter-spacing: 0.5px;
  color: var(--acc, var(--g2));
  white-space: nowrap;
}

/* ---------- game ---------- */
.gamebar {
  flex: 0 0 auto;
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 8px 18px;
  height: 52px;
}
.gtitle {
  font-family: var(--display);
  font-weight: 700;
  font-size: 16px;
  letter-spacing: 1px;
  flex: 1;
}
.gstats {
  display: flex;
  align-items: baseline;
  gap: 12px;
  font-family: var(--mono);
}
.gextra {
  font-size: 9px;
  color: var(--g2);
  letter-spacing: 1.5px;
}
.gscore {
  font-size: 22px;
  font-weight: 700;
  min-width: 1.5em;
  text-align: right;
  font-variant-numeric: tabular-nums;
  color: var(--acc);
}

.stage-wrap {
  flex: 1 1 auto;
  min-height: 0;
  display: flex;
  flex-direction: column;
  padding: 6px 16px 14px;
  gap: 12px;
}
.stage {
  position: relative;
  flex: 1 1 auto;
  min-height: 0;
  width: 100%;
  max-width: 540px;
  margin: 0 auto;
  border: 1px solid var(--line);
  border-color: color-mix(in srgb, var(--acc) 26%, var(--line));
  border-radius: 2px;
  box-shadow: 0 0 60px -22px var(--acc);
}
#cv {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  touch-action: none;
  display: block;
}

/* ---------- overlays ---------- */
.overlay {
  position: absolute;
  inset: 0;
  display: grid;
  place-items: center;
  background: rgba(8, 8, 10, 0.74);
  backdrop-filter: blur(7px);
  -webkit-backdrop-filter: blur(7px);
  z-index: 5;
  padding: 16px;
}
.panel {
  width: 100%;
  max-width: 330px;
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 3px;
  padding: 28px 24px;
  text-align: center;
  display: flex;
  flex-direction: column;
  gap: 14px;
}
.kicker {
  font-family: var(--mono);
  font-size: 9px;
  letter-spacing: 4px;
  color: var(--acc);
}
.panel h2 {
  font-family: var(--display);
  font-weight: 800;
  letter-spacing: 1px;
  font-size: 26px;
  margin: 0;
  text-transform: uppercase;
}
.hint {
  font-family: var(--mono);
  font-size: 11px;
  color: var(--g1);
  line-height: 1.6;
  margin: 0;
}
.bigscore {
  font-family: var(--display);
  font-size: 64px;
  font-weight: 800;
  line-height: 1;
  font-variant-numeric: tabular-nums;
}
.best {
  font-family: var(--mono);
  font-size: 11px;
  color: var(--g2);
  letter-spacing: 1px;
  margin-top: -8px;
}
.btn {
  font-family: var(--mono);
  letter-spacing: 2px;
  font-size: 12px;
  font-weight: 700;
  padding: 13px 18px;
  border-radius: 2px;
  cursor: pointer;
  border: 1px solid var(--fg);
  transition: opacity 0.15s, transform 0.08s, background 0.15s;
  text-transform: uppercase;
}
.btn:active {
  transform: scale(0.97);
}
.btn.primary {
  background: var(--fg);
  color: var(--bg);
}
.btn.primary:hover {
  opacity: 0.88;
}
.btn.ghost {
  background: transparent;
  color: var(--fg);
  border-color: var(--line);
}
.btn.ghost:hover {
  border-color: var(--g2);
}
.row {
  display: flex;
  gap: 10px;
}
.row .btn {
  flex: 1;
}
.submit {
  display: flex;
  flex-direction: column;
  gap: 10px;
}
.field {
  display: flex;
  flex-direction: column;
  gap: 4px;
  text-align: left;
}
.flabel {
  font-family: var(--mono);
  font-size: 9px;
  letter-spacing: 2.5px;
  color: var(--g2);
  padding-left: 1px;
}
.submit input {
  flex: 0 0 auto;
  width: 100%;
  min-width: 0;
  font-family: var(--mono);
  letter-spacing: 2px;
  text-transform: uppercase;
  font-size: 14px;
  padding: 11px 12px;
  background: var(--bg);
  border: 1px solid var(--line);
  border-radius: 2px;
  color: var(--fg);
  outline: none;
}
.submit input:focus {
  border-color: var(--g2);
}
.submit input::placeholder {
  color: var(--g2);
}
.submit .btn {
  padding: 11px 14px;
}
.rank {
  font-family: var(--mono);
  font-size: 12px;
  letter-spacing: 0.5px;
  color: var(--fg);
}
.board {
  list-style: none;
  margin: 2px 0 0;
  padding: 12px 0 0;
  border-top: 1px solid var(--line);
  display: flex;
  flex-direction: column;
  gap: 7px;
  max-height: 160px;
  overflow-y: auto;
}
.board li {
  display: flex;
  justify-content: space-between;
  font-family: var(--mono);
  font-size: 12px;
  color: var(--g2);
  font-variant-numeric: tabular-nums;
}
.board li .nm {
  color: var(--fg);
  letter-spacing: 1px;
}
.board li .ct {
  color: var(--g2);
}
.board li.me .nm {
  text-decoration: underline;
  color: var(--acc);
}
.board .empty {
  color: var(--g2);
  justify-content: center;
}
.board.tall {
  max-height: 280px;
}

/* ---------- touch controls (80s 3D console pad) ---------- */
.touch {
  flex: 0 0 auto;
  display: flex;
  flex-direction: row;
  align-items: flex-end;
  justify-content: space-between;
  gap: 14px;
  padding: 2px 8px max(14px, env(safe-area-inset-bottom));
  max-width: 540px;
  margin: 0 auto;
  width: 100%;
  touch-action: none;
}
.pad-cluster {
  display: flex;
  align-items: flex-end;
  gap: 14px;
}
/* a lone cross (no action buttons, e.g. SERPENT) sits centered */
.touch.solo {
  justify-content: center;
}

/* directional cross — raised, beveled plastic */
.dpad {
  position: relative;
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  grid-template-rows: repeat(3, 1fr);
  width: clamp(128px, 39vw, 158px);
  aspect-ratio: 1 / 1;
  touch-action: none;
  user-select: none;
  -webkit-user-select: none;
  filter: drop-shadow(0 6px 9px rgba(0, 0, 0, 0.55));
}
.dpad .arm,
.dpad .hub {
  background: linear-gradient(180deg, #3a3a43 0%, #222228 52%, #16161b 100%);
  border: 1px solid #0c0c0f;
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.18), inset 0 -3px 5px rgba(0, 0, 0, 0.5), 0 2px 0 #0a0a0d;
  transition: transform 0.05s, box-shadow 0.05s, background 0.1s;
}
.dpad .hub {
  grid-area: 2 / 2;
  border-radius: 50%;
  background: radial-gradient(circle at 50% 34%, #303037 0%, #18181d 100%);
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.14), inset 0 -2px 5px rgba(0, 0, 0, 0.55);
}
.arm.up {
  grid-area: 1 / 2;
  border-radius: 14px 14px 0 0;
}
.arm.down {
  grid-area: 3 / 2;
  border-radius: 0 0 14px 14px;
}
.arm.left {
  grid-area: 2 / 1;
  border-radius: 14px 0 0 14px;
}
.arm.right {
  grid-area: 2 / 3;
  border-radius: 0 14px 14px 0;
}
.arm.on {
  transform: translateY(2px);
  background: linear-gradient(180deg, color-mix(in srgb, var(--acc) 78%, #000) 0%, var(--acc) 100%);
  border-color: color-mix(in srgb, var(--acc) 60%, #000);
  box-shadow: inset 0 2px 6px rgba(0, 0, 0, 0.45), 0 0 18px -2px var(--acc);
}

/* round action buttons — chunky 80s arcade A / B */
.tbtn.round {
  width: clamp(64px, 18vw, 80px);
  height: clamp(64px, 18vw, 80px);
  border-radius: 50%;
  border: 1px solid #09090c;
  color: var(--acc);
  font-family: var(--display);
  font-weight: 800;
  font-size: clamp(21px, 6vw, 27px);
  line-height: 1;
  cursor: pointer;
  display: grid;
  place-items: center;
  user-select: none;
  -webkit-user-select: none;
  touch-action: none;
  background: radial-gradient(circle at 50% 32%, #3c3c45 0%, #232329 46%, #141418 100%);
  box-shadow: 0 5px 0 #0a0a0d, 0 8px 14px rgba(0, 0, 0, 0.6), inset 0 2px 2px rgba(255, 255, 255, 0.22),
    inset 0 -4px 7px rgba(0, 0, 0, 0.55);
  text-shadow: 0 1px 1px rgba(0, 0, 0, 0.6);
  transition: transform 0.05s, box-shadow 0.05s, background 0.1s, color 0.1s;
}
.tbtn.round.on {
  transform: translateY(4px);
  color: var(--bg);
  background: radial-gradient(circle at 50% 36%, color-mix(in srgb, var(--acc) 86%, #fff) 0%, var(--acc) 72%);
  box-shadow: 0 1px 0 #0a0a0d, 0 2px 5px rgba(0, 0, 0, 0.5), inset 0 2px 8px rgba(0, 0, 0, 0.32),
    0 0 22px -2px var(--acc);
  text-shadow: none;
}
/* Game-Boy diagonal: A (first / left) sits low, B (second / right) sits higher */
.pad-cluster.right .tbtn.round {
  margin-bottom: clamp(2px, 1.5vw, 10px);
}
.pad-cluster.right .tbtn.round + .tbtn.round {
  margin-bottom: clamp(22px, 7vw, 40px);
}

@media (min-width: 720px) {
  .grid {
    grid-template-columns: repeat(4, 1fr);
  }
}

/* ---------- web landing (native-app gate) ----------
   Standalone from #hub/.hero on purpose: the real in-app hub keeps its own
   left-aligned, phone-only layout untouched. This is a wide-viewport-aware,
   fully centered "attract screen" for browsers. */
.web-landing {
  flex: 1 1 auto;
  min-height: 0;
  padding: clamp(32px, 9vh, 108px) 22px 56px;
  overflow-y: auto;
}
.wl-inner {
  max-width: 620px;
  margin: 0 auto;
  text-align: center;
}
.wl-inner .kicker,
.wl-inner .hero-title {
  text-align: center;
}
.wl-pitch {
  font-family: var(--display);
  font-weight: 800;
  font-size: clamp(19px, 3.4vw, 26px);
  line-height: 1.35;
  letter-spacing: -0.01em;
  color: var(--fg);
  margin: 20px auto 0;
  max-width: 540px;
}
.wl-sub {
  font-family: var(--mono);
  font-size: 11px;
  letter-spacing: 1.5px;
  color: var(--g2);
  margin: 12px auto 0;
  max-width: 460px;
  text-transform: uppercase;
}
.preview-grid {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 10px;
  max-width: 392px;
  margin: 30px auto 0;
  padding: 0;
  list-style: none;
}
.preview-grid figure {
  margin: 0;
  aspect-ratio: 1 / 1;
  border-radius: 3px;
  overflow: hidden;
  border: 1px solid color-mix(in srgb, var(--pacc, var(--line)) 40%, var(--line));
  box-shadow: 0 10px 26px -16px color-mix(in srgb, var(--pacc, transparent) 70%, transparent);
  transition: transform 0.2s ease, box-shadow 0.2s ease;
}
.preview-grid img {
  display: block;
  width: 100%;
  height: 100%;
  object-fit: cover;
}
.preview-grid figure:hover {
  transform: translateY(-2px);
  box-shadow: 0 16px 32px -16px color-mix(in srgb, var(--pacc, transparent) 85%, transparent);
}
.p-serpent {
  --pacc: #46d17e;
}
.p-swarm {
  --pacc: #ff5d5d;
}
.p-volley {
  --pacc: #3ed0e6;
}
.p-cascade {
  --pacc: #f2b03a;
}
.wl-cta {
  margin: 40px auto 0;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 12px;
}
.wl-cta-label {
  font-family: var(--mono);
  font-size: 11px;
  font-weight: 700;
  letter-spacing: 4px;
  color: var(--fg);
}
.wl-cta-label::before {
  content: "▸ ";
  color: var(--g2);
}
.appstore-badge {
  display: inline-flex;
  align-items: center;
  border-radius: 10px;
}
.appstore-badge img {
  /* the source SVG is Apple's official black badge; inverting it swaps
     black<->white to render as the light variant that reads on our
     near-black background — same pixel-for-pixel shapes, no distortion. */
  height: 64px;
  width: auto;
  filter: invert(1) drop-shadow(0 0 0 rgba(246, 246, 247, 0));
  animation: wl-badge-pulse 2.6s ease-in-out infinite;
}
@keyframes wl-badge-pulse {
  0%,
  100% {
    filter: invert(1) drop-shadow(0 0 0 rgba(246, 246, 247, 0));
    transform: scale(1);
  }
  50% {
    filter: invert(1) drop-shadow(0 0 16px rgba(246, 246, 247, 0.45));
    transform: scale(1.03);
  }
}
.wl-inner .hubfoot {
  justify-content: center;
  margin: 48px auto 0;
}
@media (min-width: 720px) {
  .preview-grid {
    max-width: 460px;
  }
}

/* ---------- VHS overlay (web landing only, native app untouched) ----------
   Real captured VHS noise footage (assets/video/vhs-noise.mp4, transcoded
   down from a 4K/17MB source to a 720p/~200KB loop — full res is wasted on
   a blended background texture). Muted/autoplay/loop/playsinline so it
   starts without a user gesture on every browser that allows autoplay. */
.vhs-video {
  position: fixed;
  inset: 0;
  z-index: 90;
  width: 100%;
  height: 100%;
  object-fit: cover;
  pointer-events: none;
  opacity: 0.5;
  mix-blend-mode: screen;
}
@media (prefers-reduced-motion: reduce) {
  .floor span {
    animation: none;
  }
  .appstore-badge img {
    animation: none;
  }
}
