/* OP Games. The look comes from SoSFight's cover: a dusk sky, a low sun, kid-drawn fighters and a
   fat yellow title. The home page is a row of arcade cabinets standing on that horizon. */

@font-face { font-family: "Lilita One"; src: url("/fonts/lilita-one.woff2") format("woff2"); font-display: swap; }
@font-face { font-family: "Atkinson"; src: url("/fonts/atkinson-400.woff2") format("woff2"); font-weight: 400; font-display: swap; }
@font-face { font-family: "Atkinson"; src: url("/fonts/atkinson-700.woff2") format("woff2"); font-weight: 700; font-display: swap; }

:root {
  --night: #1b1936;      /* top of the sky */
  --dusk: #3d3468;       /* mid sky, cabinet bodies */
  --haze: #7d5b8e;       /* the horizon */
  --ground: #2a2547;
  --marquee: #ffd84d;    /* the title yellow */
  --ember: #f2803a;      /* the sun, the play button */
  --chalk: #f6f1ff;
  --chalk-dim: #c9c1e6;
  --ink: #120f26;
  --display: "Lilita One", "Arial Rounded MT Bold", "Trebuchet MS", sans-serif;
  --body: "Atkinson", "Segoe UI", system-ui, sans-serif;
  --gutter: clamp(16px, 4vw, 48px);
  --measure: 62ch;
}

*, *::before, *::after { box-sizing: border-box; }
html { color-scheme: dark; }
body {
  margin: 0;
  background: var(--night);
  color: var(--chalk);
  font: 400 1.0625rem/1.55 var(--body);
  min-height: 100vh;
  display: flex;
  flex-direction: column;
}
main { flex: 1; }
img { max-width: 100%; height: auto; display: block; }
a { color: var(--marquee); text-underline-offset: 0.18em; }
a:hover { color: #fff; }
:focus-visible { outline: 3px solid var(--marquee); outline-offset: 3px; border-radius: 4px; }
h1, h2, h3 { font-family: var(--display); font-weight: 400; line-height: 1.08; margin: 0; text-wrap: balance; }
h1 { font-size: clamp(2.25rem, 5.2vw, 4rem); color: var(--marquee); text-shadow: 0 0.06em 0 #6b1d12; letter-spacing: 0.005em; }
h2 { font-size: clamp(1.5rem, 2.6vw, 2rem); }
h3 { font-size: 1.3125rem; }
p { margin: 0; }
.lede { font-size: 1.1875rem; color: var(--chalk-dim); max-width: var(--measure); }

.skip { position: absolute; left: -999px; top: 8px; background: var(--marquee); color: var(--ink); padding: 8px 12px; border-radius: 6px; z-index: 10; }
.skip:focus { left: 8px; }

/* Header and footer */
.top { display: flex; align-items: center; justify-content: space-between; gap: 16px; padding: 18px var(--gutter); }
.wordmark { font-family: var(--display); font-size: 1.625rem; color: var(--chalk); text-decoration: none; }
.top nav { display: flex; gap: clamp(14px, 3vw, 28px); }
.top nav a { color: var(--chalk-dim); text-decoration: none; font-weight: 700; padding: 6px 0; border-bottom: 3px solid transparent; }
.top nav a:hover { color: var(--chalk); }
.top nav a[aria-current="page"] { color: var(--chalk); border-bottom-color: var(--marquee); }
.foot { padding: 28px var(--gutter) 36px; background: var(--ink); color: var(--chalk-dim); font-size: 0.9375rem; display: flex; flex-wrap: wrap; gap: 8px 32px; justify-content: space-between; }

/* Home: the sky, then the cabinets on the horizon */
.hero { padding: clamp(28px, 6vw, 72px) var(--gutter) clamp(28px, 4vw, 48px); display: grid; gap: 16px; max-width: 1240px; margin: 0 auto; width: 100%; }
.hero h1 { max-width: 16ch; }
.hero p { font-size: 1.1875rem; color: var(--chalk-dim); max-width: 46ch; }

.floor {
  position: relative;
  padding: 0 var(--gutter) clamp(40px, 6vw, 72px);
  background:
    linear-gradient(to bottom, transparent calc(100% - 180px), var(--ground) calc(100% - 180px)),
    linear-gradient(to bottom, transparent 0, var(--haze) calc(100% - 180px));
}
.floor::before {            /* a few stars, as on the cover */
  content: "";
  position: absolute; inset: -260px 0 55% 0; pointer-events: none;
  background:
    radial-gradient(1.5px 1.5px at 8% 30%, #fff8 99%, transparent),
    radial-gradient(1.5px 1.5px at 23% 62%, #fff6 99%, transparent),
    radial-gradient(2px 2px at 41% 18%, #fff7 99%, transparent),
    radial-gradient(1.5px 1.5px at 58% 48%, #fff5 99%, transparent),
    radial-gradient(2px 2px at 72% 12%, #fff8 99%, transparent),
    radial-gradient(1.5px 1.5px at 86% 55%, #fff6 99%, transparent),
    radial-gradient(1.5px 1.5px at 94% 26%, #fff7 99%, transparent);
}
.cabs { list-style: none; margin: 0 auto; padding: 0; max-width: 1240px; position: relative; display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: clamp(14px, 2.4vw, 32px); align-items: start; }
.cabs li { display: grid; gap: 14px; }
.cab__blurb { color: var(--chalk-dim); font-size: 0.9875rem; max-width: 30ch; }

.cab { display: grid; text-decoration: none; color: inherit; }
.cab__marquee {
  font-family: var(--display); font-size: clamp(1.125rem, 1.9vw, 1.625rem); line-height: 1; text-align: center;
  padding: 0.7em 0.4em; border-radius: 14px 14px 0 0; border: 4px solid var(--ink); border-bottom: 0;
  background: #5a4f8a; color: #1b193699;
}
.cab__screen { display: grid; place-items: center; aspect-ratio: 4 / 3; overflow: hidden; background: var(--ink); border: 4px solid var(--ink); border-width: 14px 12px; }
.cab__screen img { width: 100%; height: 100%; object-fit: cover; }
.cab__panel { display: flex; align-items: center; gap: 9%; padding: 12px 14% 14px; background: #4c4280; border-inline: 4px solid var(--ink); transform: perspective(300px) rotateX(18deg); transform-origin: top; }
.cab__panel .stick { width: 18px; height: 18px; border-radius: 50%; background: #e6584a; box-shadow: 0 5px 0 -2px #0006; margin-right: auto; }
.cab__panel .dot { width: 13px; height: 13px; border-radius: 50%; background: var(--chalk-dim); }
.cab__base { min-height: 96px; display: grid; place-items: center; background: var(--dusk); border: 4px solid var(--ink); border-top: 0; border-radius: 0 0 6px 6px; }

.cab--open .cab__marquee { background: var(--marquee); color: var(--ink); box-shadow: 0 0 34px #ffd84d66; animation: lights-on 1.1s steps(1) 0.25s both; }
.cab--open .cab__panel .dot { background: var(--marquee); }
.cab__play { font-family: var(--display); font-size: 1.375rem; background: var(--ember); color: var(--ink); padding: 0.35em 1.3em; border-radius: 999px; border: 3px solid var(--ink); box-shadow: 0 4px 0 var(--ink); }
.cab--open:hover .cab__play, .cab--open:focus-visible .cab__play { background: var(--marquee); transform: translateY(2px); box-shadow: 0 2px 0 var(--ink); }
.cab--open:hover .cab__screen img { transform: scale(1.04); }
.cab__screen img { transition: transform 0.2s; }

.cab--building .cab__screen { background: repeating-linear-gradient(0deg, #17142e 0 3px, #1e1a3a 3px 6px); }
.cab__note { font-family: var(--display); font-size: clamp(0.9375rem, 1.5vw, 1.1875rem); color: var(--ink); background: #f3ecd2; padding: 0.55em 0.9em; transform: rotate(-4deg); box-shadow: 0 3px 0 #0005; position: relative; }
.cab__note::before { content: ""; position: absolute; left: 50%; top: -9px; width: 46px; height: 16px; translate: -50% 0; background: #ffd84d99; rotate: 3deg; }

@keyframes lights-on {
  0% { background: #5a4f8a; box-shadow: none; }
  30% { background: var(--marquee); }
  40% { background: #5a4f8a; box-shadow: none; }
  55%, 100% { background: var(--marquee); box-shadow: 0 0 34px #ffd84d66; }
}

/* A game's page */
.game, .block, .prose { padding: 0 var(--gutter); max-width: 1240px; margin: 0 auto; width: 100%; }
.game { padding-top: clamp(20px, 3vw, 40px); display: grid; gap: 14px; }
.block { margin-top: clamp(44px, 6vw, 80px); display: grid; gap: 18px; }
.block:last-of-type { margin-bottom: clamp(48px, 7vw, 96px); }

.stage { position: relative; aspect-ratio: 16 / 9; width: 100%; max-height: 78vh; margin-top: 10px; background: #000; border: 4px solid var(--ink); border-radius: 12px; overflow: hidden; display: grid; place-items: center; box-shadow: 0 0 0 4px var(--dusk); }
.stage__poster { position: absolute; inset: 0; width: 100%; height: 100%; object-fit: cover; filter: brightness(0.55); }
.stage__start { position: relative; font: 400 clamp(1.375rem, 3vw, 2.125rem) var(--display); background: var(--ember); color: var(--ink); border: 4px solid var(--ink); border-radius: 999px; padding: 0.5em 1.5em; box-shadow: 0 6px 0 var(--ink); cursor: pointer; }
.stage__start:hover { background: var(--marquee); }
.stage__start:active { transform: translateY(4px); box-shadow: 0 2px 0 var(--ink); }
.stage iframe { position: absolute; inset: 0; width: 100%; height: 100%; border: 0; }
.stage:fullscreen { border: 0; border-radius: 0; max-height: none; }
.stage--empty { padding: 24px; text-align: center; color: var(--chalk-dim); }
.stage__bar { display: flex; flex-wrap: wrap; gap: 8px 24px; justify-content: space-between; align-items: center; color: var(--chalk-dim); font-size: 0.9875rem; }
.plain { font: 700 0.9875rem var(--body); background: none; color: var(--marquee); border: 2px solid currentColor; border-radius: 999px; padding: 6px 16px; cursor: pointer; }
.plain:hover { color: #fff; }

.fighters { list-style: none; margin: 0; padding: 0; display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: clamp(16px, 2.5vw, 32px); }
.fighters li { display: grid; gap: 6px; align-content: start; }
.fighters img { height: 190px; width: 100%; object-fit: contain; object-position: center bottom; margin-bottom: 8px; border-bottom: 3px solid var(--haze); }
.fighters p { color: var(--chalk-dim); font-size: 0.9875rem; }

.table-wrap { overflow-x: auto; border: 3px solid var(--dusk); border-radius: 10px; }
table { border-collapse: collapse; width: 100%; min-width: 620px; }
th, td { text-align: left; padding: 12px 16px; border-bottom: 2px solid var(--dusk); vertical-align: middle; }
tbody tr:last-child > * { border-bottom: 0; }
thead th { background: var(--dusk); font-weight: 700; }
tbody th { font-weight: 700; }
kbd { font: 700 0.875rem var(--body); display: inline-block; min-width: 1.9em; text-align: center; padding: 3px 7px; background: var(--chalk); color: var(--ink); border-radius: 6px; box-shadow: 0 3px 0 #8f86b5; }

.modes { margin: 0; display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 18px 40px; max-width: 900px; }
.modes dt { font-family: var(--display); font-size: 1.1875rem; color: var(--marquee); }
.modes dd { margin: 2px 0 0; color: var(--chalk-dim); }

/* Plain reading pages */
.prose { max-width: calc(var(--measure) + 2 * var(--gutter)); padding-top: clamp(24px, 4vw, 56px); padding-bottom: clamp(48px, 7vw, 96px); }
.prose > * + * { margin-top: 16px; }
.prose h2 { margin-top: 44px; color: var(--marquee); }
.prose ul { padding-left: 1.2em; margin-bottom: 0; }
.prose li + li { margin-top: 8px; }

@media (max-width: 860px) {
  .cabs { grid-template-columns: repeat(2, minmax(0, 1fr)); row-gap: 40px; }
  .fighters { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .floor { background: linear-gradient(to bottom, transparent 0, var(--haze) 60%, var(--ground) 60%); }
}
@media (max-width: 520px) {
  .modes { grid-template-columns: 1fr; }
  .cab__base { min-height: 64px; }
  .cab__play { font-size: 1.125rem; }
  .fighters img { height: 140px; }
}
@media (prefers-reduced-motion: reduce) {
  .cab--open .cab__marquee { animation: none; }
  .cab__screen img { transition: none; }
}

/* The 3D arcade floor (lobby.js). Hidden until the room is up, so a browser without WebGL just
   sees the list of games. */
.lobby { position: relative; display: none; height: clamp(380px, calc(100vh - 150px), 760px); background: var(--night); overflow: hidden; }
.lobby--on { display: block; }
.lobby__view, .lobby__view canvas { position: absolute; inset: 0; width: 100%; height: 100%; display: block; }
.lobby__view canvas { cursor: pointer; touch-action: none; }
.lobby__view canvas:focus-visible { outline: 3px solid var(--marquee); outline-offset: -3px; border-radius: 0; }
.lobby__how { position: absolute; left: var(--gutter); bottom: 14px; color: var(--chalk-dim); font-size: 0.875rem; background: #120f26b3; padding: 4px 12px; border-radius: 999px; pointer-events: none; }
.lobby__crowd { position: absolute; right: var(--gutter); bottom: 14px; color: var(--chalk); font-size: 0.875rem; font-weight: 700; background: #120f26b3; padding: 4px 12px; border-radius: 999px; pointer-events: none; }
.lobby__crowd[hidden] { display: none; }
.lobby__prompt { position: absolute; left: 50%; bottom: 64px; translate: -50% 0; display: flex; flex-direction: column; align-items: center; gap: 6px; text-align: center; max-width: min(92vw, 520px); background: #120f26e6; border: 3px solid var(--dusk); border-radius: 18px; padding: 14px 22px 12px; color: var(--chalk-dim); font-size: 0.9375rem; }
.lobby__prompt[hidden] { display: none; }
.lobby__prompt strong { font: 400 1.375rem var(--display); color: var(--chalk); }
.lobby__go { font: 400 1.5rem var(--display); background: var(--ember); color: var(--ink); text-decoration: none; padding: 0.3em 1.3em; border-radius: 999px; border: 3px solid var(--ink); box-shadow: 0 4px 0 #000; }
.lobby__go:hover { background: var(--marquee); color: var(--ink); }
.has-lobby .hero { padding-top: clamp(28px, 4vw, 48px); }
.has-lobby .hero h1 { font-size: clamp(1.75rem, 3.4vw, 2.5rem); max-width: none; }

/* The player's name in the header, and the name picker */
.player { font: 700 0.9375rem var(--body); background: var(--dusk); color: var(--chalk); border: 2px solid var(--haze); border-radius: 999px; padding: 6px 14px; cursor: pointer; }
.player:hover:not(:disabled) { border-color: var(--marquee); }
.player:disabled { opacity: 0.6; cursor: default; }
.player[hidden] { display: none; }
.top nav { align-items: center; }
.solid { font: 400 1.125rem var(--display); background: var(--ember); color: var(--ink); border: 3px solid var(--ink); border-radius: 999px; padding: 6px 20px; cursor: pointer; box-shadow: 0 3px 0 #000; }
.solid:hover { background: var(--marquee); }
.solid:disabled { opacity: 0.6; }
.namer { background: var(--night); color: var(--chalk); border: 4px solid var(--dusk); border-radius: 18px; padding: 24px; width: min(94vw, 460px); }
.namer::backdrop { background: #0a0818cc; }
.namer > * + * { margin-top: 12px; }
.namer h2 { color: var(--marquee); }
.namer__reels { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
.namer__reel { height: 200px; overflow-y: auto; border: 3px solid var(--dusk); border-radius: 12px; padding: 6px; display: grid; gap: 2px; align-content: start; scrollbar-color: var(--haze) transparent; }
.namer__reel label { display: block; padding: 7px 10px; border-radius: 8px; cursor: pointer; font-weight: 700; }
.namer__reel input { position: absolute; opacity: 0; pointer-events: none; }
.namer__reel label:has(input:checked) { background: var(--marquee); color: var(--ink); }
.namer__reel label:has(input:focus-visible) { outline: 3px solid var(--chalk); outline-offset: -3px; }
.namer__preview { font: 400 1.75rem var(--display); color: var(--marquee); text-align: center; min-height: 1.2em; }
.namer__preview:not(:empty)::after { content: " + a number"; font: 400 0.9375rem var(--body); color: var(--chalk-dim); }
.namer__note { color: #ffb4a8; min-height: 1.2em; margin-top: 4px; }
.namer__note:empty { display: none; }
.namer__buttons { display: flex; flex-wrap: wrap; gap: 10px; align-items: center; }

@media (max-width: 520px) {
  .top { flex-wrap: wrap; }
  .lobby__how { display: none; }
  .lobby__crowd { right: auto; left: var(--gutter); bottom: auto; top: 12px; }
  .lobby__prompt { bottom: 20px; }
}
