/* ───────────── Tokarcade · shared styles ───────────── */
:root {
  --bg: #050b1e;
  --panel: #091533;
  --line: #16285a;
  --line2: #243f86;
  --grid: rgba(80, 120, 255, 0.07);
  --blue: #2f63ff;
  --blue-hi: #6b95ff;
  --ice: #e8efff;
  --mute: #8a9ccc;
  --display: "Bricolage Grotesque", system-ui, -apple-system, sans-serif;
  --mono: "DM Mono", ui-monospace, "SF Mono", Menlo, monospace;
  --ease: cubic-bezier(0.2, 0.8, 0.2, 1);
  --pad: clamp(20px, 4vw, 56px);
}

* { box-sizing: border-box; margin: 0; }
html { color-scheme: dark; }
body {
  min-height: 100vh;
  background-color: var(--bg);
  background-image:
    linear-gradient(var(--grid) 1px, transparent 1px),
    linear-gradient(90deg, var(--grid) 1px, transparent 1px);
  background-size: 44px 44px;
  background-attachment: fixed;
  color: var(--ice);
  font-family: var(--display);
  -webkit-font-smoothing: antialiased;
}
a { color: inherit; }
button { font: inherit; color: inherit; }
::selection { background: var(--blue); color: #fff; }
:focus-visible { outline: 2px solid var(--blue-hi); outline-offset: 3px; }

.mono { font-family: var(--mono); }

/* ───────────── Nav ───────────── */
.nav {
  position: relative; z-index: 2;
  display: flex; align-items: center; justify-content: space-between;
  padding: 20px var(--pad);
  border-bottom: 1px solid var(--line);
  background: rgba(5, 11, 30, 0.82);
}
.logo {
  display: flex; align-items: center; gap: 12px;
  font-weight: 800; font-size: 18px; letter-spacing: 0.06em; text-transform: uppercase;
  text-decoration: none;
}
.logo-mark { display: grid; grid-template: 1fr 1fr / 1fr 1fr; gap: 3px; width: 22px; height: 22px; }
.logo-mark i { background: var(--blue); transition: transform 0.45s var(--ease), background 0.3s; }
.logo-mark i:nth-child(2), .logo-mark i:nth-child(3) { background: var(--ice); }
.logo:hover .logo-mark i:nth-child(1) { transform: translateX(14px); }
.logo:hover .logo-mark i:nth-child(2) { transform: translateY(14px); }
.logo:hover .logo-mark i:nth-child(3) { transform: translateY(-14px); }
.logo:hover .logo-mark i:nth-child(4) { transform: translateX(-14px); }
.nav-meta {
  font-family: var(--mono); font-size: 12px; letter-spacing: 0.14em; text-transform: uppercase;
  color: var(--mute);
}
.nav-meta b { color: var(--ice); font-weight: 500; }

/* ───────────── Buttons ───────────── */
.btn {
  position: relative; isolation: isolate; overflow: hidden; cursor: pointer;
  display: inline-block;
  padding: 14px 24px;
  font-family: var(--mono); font-size: 13px; letter-spacing: 0.14em; text-transform: uppercase;
  color: #fff; background: var(--blue); border: 1px solid var(--blue);
  transition: color 0.35s var(--ease);
}
.btn::before {
  content: ""; position: absolute; inset: 0; z-index: -1;
  background: var(--ice);
  transform: scaleX(0); transform-origin: right;
  transition: transform 0.45s var(--ease);
}
.btn:hover, .btn:focus-visible { color: var(--bg); }
.btn:hover::before, .btn:focus-visible::before { transform: scaleX(1); transform-origin: left; }
.btn.ghost { background: transparent; color: var(--ice); border-color: var(--line2); }
.btn.ghost::before { background: var(--blue); }
.btn.ghost:hover, .btn.ghost:focus-visible { color: #fff; border-color: var(--blue); }

/* ───────────── Home · hero ───────────── */
#trail { position: fixed; inset: 0; z-index: 0; pointer-events: none; }

.hero {
  position: relative; z-index: 1;
  max-width: 1280px; margin: 0 auto;
  padding: clamp(56px, 11vw, 140px) var(--pad) 56px;
}
.hero h1 {
  font-size: clamp(52px, 10.5vw, 150px);
  line-height: 0.92; font-weight: 800; letter-spacing: -0.045em;
}
.line { display: block; overflow: hidden; padding-bottom: 0.1em; }
.line > span {
  display: block; transform: translateY(108%);
  animation: up 1s var(--ease) forwards;
  animation-delay: calc(var(--d, 0) * 1ms);
}
.line.outline > span { color: transparent; -webkit-text-stroke: 2px var(--blue-hi); }
@keyframes up { to { transform: none; } }

.hero-row {
  display: flex; flex-wrap: wrap; gap: 32px; align-items: flex-end; justify-content: space-between;
  margin-top: 44px;
  opacity: 0; animation: fade 0.9s var(--ease) 0.75s forwards;
}
@keyframes fade { to { opacity: 1; } }
.lede { max-width: 44ch; font-family: var(--mono); font-size: 14px; line-height: 1.7; color: var(--mute); }
.hero-row .btn::after { content: "  ↓"; }

.ticker {
  position: relative; z-index: 1;
  border-block: 1px solid var(--line); background: rgba(5, 11, 30, 0.82);
  overflow: hidden; white-space: nowrap;
  font-family: var(--mono); font-size: 12px; letter-spacing: 0.18em; text-transform: uppercase; color: var(--mute);
}
.ticker-track { display: inline-flex; gap: 36px; padding: 14px 0; animation: tick 45s linear infinite; }
.ticker-track span:nth-child(even) { color: var(--blue-hi); }
@keyframes tick { to { transform: translateX(-50%); } }

/* ───────────── Home · cards ───────────── */
.games { position: relative; z-index: 1; max-width: 1280px; margin: 0 auto; padding: 72px var(--pad) 120px; }
.sec-head {
  display: flex; justify-content: space-between; align-items: baseline;
  margin-bottom: 26px; padding-bottom: 16px; border-bottom: 1px solid var(--line);
  font-family: var(--mono); font-size: 12px; letter-spacing: 0.16em; text-transform: uppercase; color: var(--mute);
}
.sec-head h2 { font-family: var(--display); font-size: 28px; letter-spacing: -0.02em; text-transform: none; color: var(--ice); font-weight: 700; }

.grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(min(100%, 330px), 1fr)); gap: 18px; }

.card {
  position: relative; isolation: isolate; overflow: hidden;
  display: flex; flex-direction: column;
  background: var(--panel); border: 1px solid var(--line);
  text-decoration: none;
  transition: border-color 0.4s var(--ease), transform 0.5s var(--ease), opacity 0.7s var(--ease);
}
.js .card { opacity: 0; transform: translateY(28px); }
.js .card.in { opacity: 1; transform: none; transition-delay: calc(var(--i, 0) * 70ms), 0s, calc(var(--i, 0) * 70ms); }
.js .card.in:hover { transition-delay: 0s; }
.card::before {
  content: ""; position: absolute; inset: 0; z-index: -1; background: var(--blue);
  transform: translateY(101%); transition: transform 0.55s var(--ease);
}
.card:hover, .card:focus-visible { border-color: var(--blue-hi); }
.card:hover::before, .card:focus-visible::before { transform: none; }

.thumb-wrap {
  aspect-ratio: 5 / 3; display: grid; place-items: center;
  border-bottom: 1px solid var(--line); transition: border-color 0.4s;
  background-image: radial-gradient(rgba(120, 160, 255, 0.16) 1px, transparent 1px);
  background-size: 16px 16px;
}
.card:hover .thumb-wrap { border-color: rgba(255, 255, 255, 0.28); }
.thumb { width: 80%; height: auto; overflow: visible; color: var(--ice); }
.thumb text { font-family: var(--mono); font-size: 17px; fill: currentColor; stroke: none; text-anchor: middle; }

.card-body { display: flex; flex-direction: column; gap: 10px; flex: 1; padding: 20px 22px 22px; }
.card-top, .card-foot {
  display: flex; justify-content: space-between; align-items: center;
  font-family: var(--mono); font-size: 12px; letter-spacing: 0.12em; text-transform: uppercase; color: var(--mute);
  transition: color 0.35s;
}
.card h3 { font-size: 30px; font-weight: 700; letter-spacing: -0.025em; line-height: 1.05; }
.card p { font-size: 15px; line-height: 1.45; color: var(--mute); transition: color 0.35s; }
.card-foot { margin-top: auto; padding-top: 16px; }
.card-foot .go { display: inline-flex; gap: 10px; color: var(--ice); }
.arrow { display: inline-block; transition: transform 0.45s var(--ease); }
.card:hover .arrow, .card:focus-visible .arrow { transform: translateX(7px); }
.card:hover p, .card:hover .card-top, .card:hover .card-foot { color: rgba(255, 255, 255, 0.82); }

.footer {
  position: relative; z-index: 1;
  display: flex; flex-wrap: wrap; gap: 12px; justify-content: space-between;
  padding: 26px var(--pad); border-top: 1px solid var(--line); background: rgba(5, 11, 30, 0.82);
  font-family: var(--mono); font-size: 12px; letter-spacing: 0.1em; color: var(--mute);
}

/* ── thumbnails (each is a tiny hover-driven scene) ── */
/* snake */
.t-snake .snk { stroke-dasharray: 40 200; stroke-dashoffset: 0; transition: stroke-dashoffset 1.1s var(--ease); }
.t-snake .food { fill: currentColor; stroke: none; transition: opacity 0.2s 0.75s; }
.card:hover .t-snake .snk { stroke-dashoffset: -62; }
.card:hover .t-snake .food { opacity: 0; }
/* 2048 */
.t-2048 .tl { transition: transform 0.7s var(--ease); transition-delay: calc(var(--k) * 70ms); }
.card:hover .t-2048 .r1 { transform: translateX(60px); }
.card:hover .t-2048 .r2 { transform: translateX(-60px); }
.t-2048 rect { stroke-width: 2; }
/* tic tac toe */
.t-ttt .draw { stroke-dasharray: 1; stroke-dashoffset: 1; transition: stroke-dashoffset 0.4s var(--ease); }
.card:hover .t-ttt .d1 { stroke-dashoffset: 0; transition-delay: 0.05s; }
.card:hover .t-ttt .d2 { stroke-dashoffset: 0; transition-delay: 0.25s; }
.card:hover .t-ttt .win { stroke-dashoffset: 0; transition: stroke-dashoffset 0.6s var(--ease) 0.55s; }
/* reaction */
.t-react .ring { transform-box: fill-box; transform-origin: center; transition: transform 0.6s var(--ease), opacity 0.6s; transition-delay: calc(var(--k) * 60ms); }
.t-react .core { fill: transparent; transition: fill 0.25s 0.15s; }
.card:hover .t-react .core { fill: currentColor; }
.card:hover .t-react .ring { transform: scale(1.14); opacity: 0.4; }
/* breakout */
.t-brk .ball { animation: none; }
.t-brk .pad { transition: transform 0.4s var(--ease); }
.t-brk .gone { transition: opacity 0.2s 0.35s; }
.card:hover .t-brk .ball { animation: ball 1.3s linear infinite; }
.card:hover .t-brk .pad { animation: pad 1.3s ease-in-out infinite; }
.card:hover .t-brk .gone { opacity: 0; }
/* block buster */
.t-bb .pc { transition: transform 0.45s cubic-bezier(0.5, 0, 0.7, 1); }
.t-bb .row { transition: opacity 0.25s; }
.card:hover .t-bb .pc { transform: translateY(44px); }
.card:hover .t-bb .row { opacity: 0; transition-delay: 0.55s; }
/* box slicer */
.t-box .beam { stroke-dasharray: 1; stroke-dashoffset: 1; transition: stroke-dashoffset 0.55s cubic-bezier(0.3, 0, 0.6, 1); }
.t-box .gone { opacity: 0; transition: opacity 0.3s 0.55s; }
.card:hover .t-box .beam { stroke-dashoffset: 0; }
.card:hover .t-box .gone { opacity: 1; }
/* case simulator */
.t-case .reel { transition: transform 1.6s cubic-bezier(0.1, 0.7, 0.1, 1); }
.card:hover .t-case .reel { transform: translateX(156px); }
/* atlas rush */
.t-atlas .land { fill: currentColor; fill-opacity: 0; stroke-width: 1.5; transition: fill-opacity 0.35s var(--ease); transition-delay: calc(var(--k) * 180ms); }
.card:hover .t-atlas .land { fill-opacity: 0.85; }
/* meteor shower */
.t-met .beam { stroke-dasharray: 1; stroke-dashoffset: 1; }
.t-met .bits { opacity: 0; }
.t-met .rock, .t-met .rock2 { transition: transform 0.6s var(--ease); }
.card:hover .t-met .beam { animation: met-beam 1.2s steps(6) infinite; }
.card:hover .t-met .rock { animation: met-rock 1.2s steps(1) infinite; }
.card:hover .t-met .bits { animation: met-bits 1.2s steps(1) infinite; }
.card:hover .t-met .rock2 { transform: translate(10px, 8px); }
@keyframes met-beam { 0% { stroke-dashoffset: 1; } 25%, 45% { stroke-dashoffset: 0; } 46%, 100% { stroke-dashoffset: 1; } }
@keyframes met-rock { 0%, 40% { opacity: 1; } 41%, 100% { opacity: 0; } }
@keyframes met-bits { 0%, 40% { opacity: 0; } 41%, 75% { opacity: 1; } 76%, 100% { opacity: 0; } }
@keyframes ball { 0%,100% { transform: translate(0,0); } 25% { transform: translate(30px,-38px); } 50% { transform: translate(60px,0); } 75% { transform: translate(30px,-38px); } }
@keyframes pad { 0%,100% { transform: translateX(0); } 50% { transform: translateX(60px); } }

/* ───────────── Game pages ───────────── */
.gnav {
  display: grid; grid-template-columns: 1fr auto 1fr; align-items: center; gap: 16px;
  padding: 18px var(--pad); border-bottom: 1px solid var(--line); background: rgba(5, 11, 30, 0.82);
}
.back {
  justify-self: start; display: inline-flex; gap: 10px; align-items: center;
  font-family: var(--mono); font-size: 12px; letter-spacing: 0.14em; text-transform: uppercase;
  text-decoration: none; color: var(--mute); transition: color 0.3s;
}
.back span { display: inline-block; transition: transform 0.4s var(--ease); }
.back:hover { color: var(--ice); }
.back:hover span { transform: translateX(-6px); }
.gtitle { font-size: 22px; font-weight: 800; letter-spacing: -0.02em; }
.hud { justify-self: end; display: flex; gap: 28px; }
.hud div { display: flex; flex-direction: column; align-items: flex-end; }
.hud small { font-family: var(--mono); font-size: 10px; letter-spacing: 0.18em; text-transform: uppercase; color: var(--mute); }
.hud b { font-family: var(--mono); font-weight: 500; font-size: 20px; font-variant-numeric: tabular-nums; }
.hud b.bump { animation: bump 0.3s var(--ease); }
@keyframes bump { 40% { transform: translateY(-3px); color: var(--blue-hi); } }

.play {
  /* --w / --h = the room the game can use; every game sizes itself from these */
  --side: 280px;
  --w: calc(100vw - 2 * var(--pad) - var(--side) - 28px - 30px);
  --h: calc(100vh - 150px);
  --sz: max(300px, min(var(--w), var(--h)));
  margin: 0 auto; padding: 24px var(--pad) 40px;
  display: grid; grid-template-columns: auto var(--side); gap: 28px;
  justify-content: center; align-items: start;
}
.stage {
  position: relative; background: var(--panel); border: 1px solid var(--line2); padding: 14px;
  animation: stage-in 0.8s var(--ease) both;
}
@keyframes stage-in { from { opacity: 0; transform: translateY(18px); } }
.stage .c { position: absolute; width: 14px; height: 14px; border: 2px solid var(--blue-hi); animation: corner 0.8s var(--ease) 0.2s both; }
.stage .c.tl { top: -2px; left: -2px; border-right: 0; border-bottom: 0; --x: 8px; --y: 8px; }
.stage .c.tr { top: -2px; right: -2px; border-left: 0; border-bottom: 0; --x: -8px; --y: 8px; }
.stage .c.bl { bottom: -2px; left: -2px; border-right: 0; border-top: 0; --x: 8px; --y: -8px; }
.stage .c.br { bottom: -2px; right: -2px; border-left: 0; border-top: 0; --x: -8px; --y: -8px; }
@keyframes corner { from { transform: translate(var(--x), var(--y)); opacity: 0; } }

.screen { position: relative; }
.screen canvas { display: block; width: var(--sz); height: auto; background: var(--panel); }
.stage.shake { animation: shake 0.3s linear; }
@keyframes shake { 20% { transform: translateX(-4px); } 40% { transform: translateX(4px); } 60% { transform: translateX(-2px); } 80% { transform: translateX(2px); } }

.overlay {
  position: absolute; inset: 0; z-index: 5;
  display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 14px;
  padding: 24px; text-align: center;
  background: rgba(5, 11, 30, 0.84);
  transition: opacity 0.35s var(--ease), visibility 0.35s;
}
.overlay.hide { opacity: 0; visibility: hidden; pointer-events: none; }
.overlay .kicker { font-family: var(--mono); font-size: 12px; letter-spacing: 0.2em; text-transform: uppercase; color: var(--blue-hi); }
.overlay h2 { font-size: clamp(34px, 7vw, 52px); font-weight: 800; letter-spacing: -0.035em; line-height: 1; }
.overlay .sub { font-family: var(--mono); font-size: 13px; line-height: 1.6; color: var(--mute); max-width: 30ch; }
.overlay > * { animation: ov-in 0.5s var(--ease) both; }
.overlay > *:nth-child(2) { animation-delay: 0.05s; }
.overlay > *:nth-child(3) { animation-delay: 0.1s; }
.overlay > *:nth-child(4) { animation-delay: 0.15s; }
@keyframes ov-in { from { opacity: 0; transform: translateY(10px); } }

.howto { border: 1px solid var(--line); background: rgba(9, 21, 51, 0.6); padding: 22px; animation: stage-in 0.8s var(--ease) 0.1s both; }
.howto h3 { font-family: var(--mono); font-size: 12px; letter-spacing: 0.18em; text-transform: uppercase; color: var(--mute); font-weight: 500; margin-bottom: 16px; }
.howto ul { list-style: none; padding: 0; display: grid; gap: 12px; font-size: 15px; line-height: 1.4; }
.howto li { display: flex; gap: 10px; align-items: baseline; flex-wrap: wrap; }
.howto li span { color: var(--mute); }
.howto .btn { margin-top: 22px; width: 100%; text-align: center; }
kbd { font-family: var(--mono); font-size: 11px; padding: 3px 7px; border: 1px solid var(--line2); background: var(--bg); color: var(--ice); }
.howto .stats { margin-top: 20px; padding-top: 18px; border-top: 1px solid var(--line); display: grid; gap: 10px; font-family: var(--mono); font-size: 13px; }
.howto .stats div { display: flex; justify-content: space-between; color: var(--mute); }
.howto .stats b { color: var(--ice); font-weight: 500; font-variant-numeric: tabular-nums; }

@media (max-width: 860px) {
  .play { --w: calc(100vw - 2 * var(--pad) - 30px); --h: calc(100vh - 230px); grid-template-columns: minmax(0, 1fr); justify-items: center; }
  .howto { width: 100%; max-width: 520px; }
  .gnav { grid-template-columns: 1fr auto; }
  .gtitle { display: none; }
  .nav-meta { display: none; }
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation-duration: 0.001ms !important; animation-iteration-count: 1 !important; transition-duration: 0.001ms !important; transition-delay: 0s !important; }
  .ticker-track { animation: none; }
}
