:root {
  --bg: #0b1030;
  --panel: #141b45;
  --edge: #26318a;
  --red: #e63946;
  --gold: #f6d04d;
  --ink: #f1f1f1;
  --muted: #9aa3c7;
  --display: Impact, 'Arial Black', 'Helvetica Neue', sans-serif;
  font-family: system-ui, -apple-system, 'Segoe UI', Roboto, sans-serif;
  color: var(--ink);
  background: var(--bg);
  color-scheme: dark;
}
* { box-sizing: border-box; }
body {
  margin: 0;
  min-height: 100vh;
  background: radial-gradient(circle at 50% -20%, #26318a, var(--bg) 60%) fixed;
}
a { color: var(--gold); }
kbd {
  background: #222b66;
  border: 1px solid #3a46a0;
  border-bottom-width: 3px;
  border-radius: 5px;
  padding: 0 0.35em;
  font: 600 0.85em ui-monospace, monospace;
  white-space: nowrap;
}

/* ---------- arcade index ---------- */
.hero { text-align: center; padding: 2.5rem 1rem 0.5rem; }
.hero h1 {
  margin: 0;
  font: 400 clamp(3rem, 11vw, 6.5rem) / 0.9 var(--display);
  color: #fff;
  text-shadow: 4px 4px 0 var(--red), 8px 8px 0 #1d3a8a;
  letter-spacing: 0.02em;
}
.hero h1 span { color: var(--gold); font-size: 0.55em; letter-spacing: 0.3em; }
.hero p { color: var(--muted); margin: 1.2rem 0 0; }
.cards {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(240px, 1fr));
  gap: 1.2rem;
  max-width: 1100px;
  margin: 2rem auto;
  padding: 0 1rem;
}
.card {
  display: flex;
  flex-direction: column;
  background: var(--panel);
  border: 3px solid var(--edge);
  border-radius: 16px;
  overflow: hidden;
  text-decoration: none;
  color: var(--ink);
  transition: transform 0.12s, border-color 0.12s;
}
.card:hover, .card:focus-visible { transform: translateY(-4px) rotate(-1deg); border-color: var(--gold); outline: none; }
.card .thumb {
  aspect-ratio: 4 / 3;
  display: grid;
  place-items: center;
  background: repeating-linear-gradient(45deg, #1d2668 0 14px, #18205a 14px 28px);
}
.card .thumb svg { width: 58%; height: auto; filter: drop-shadow(0 6px 8px #0007); }
.card h2 { margin: 0.7rem 0.9rem 0.2rem; font: 400 1.6rem var(--display); color: var(--gold); letter-spacing: 0.02em; }
.card p { margin: 0 0.9rem 0.6rem; color: var(--muted); font-size: 0.92rem; line-height: 1.4; }
.card .controls { margin: auto 0.9rem 0.9rem; font-size: 0.75rem; color: #c7cdf0; opacity: 0.75; }
.disclaimer { max-width: 760px; margin: 3rem auto 2rem; padding: 0 1rem; text-align: center; color: var(--muted); font-size: 0.8rem; line-height: 1.5; }

/* ---------- game pages ---------- */
.bar {
  display: flex;
  align-items: center;
  gap: 0.6rem 1.2rem;
  flex-wrap: wrap;
  padding: 0.5rem 1rem;
  background: #060a22;
  border-bottom: 3px solid var(--red);
}
.bar .back { text-decoration: none; font-weight: 700; }
.bar h1 { margin: 0; flex: 1; font: 400 1.5rem var(--display); color: var(--gold); letter-spacing: 0.02em; white-space: nowrap; }
.stats { display: flex; gap: 1rem; flex-wrap: wrap; font-size: 0.9rem; color: var(--muted); }
.stats b { color: #fff; font-size: 1.1rem; }
[data-extra] { display: contents; }
.btns { display: flex; gap: 0.4rem; }
.btns button {
  background: var(--panel);
  color: #fff;
  border: 2px solid var(--edge);
  border-radius: 8px;
  padding: 0.25rem 0.6rem;
  font-size: 1rem;
  cursor: pointer;
}
.stage {
  position: relative;
  margin: 1rem auto 0.5rem;
  width: min(96vw, calc((100vh - 9.5rem) * var(--ar, 1.6)));
  /* iOS Safari: 100vh is taller than the visible area; dvh is the real one */
  width: min(96vw, calc((100dvh - 9.5rem) * var(--ar, 1.6)));
}
.stage canvas {
  display: block;
  width: 100%;
  height: auto;
  border-radius: 12px;
  box-shadow: 0 10px 40px #0008;
  touch-action: none;
  user-select: none;
  -webkit-user-select: none;
}
.overlay {
  position: absolute;
  inset: 0;
  z-index: 5;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  text-align: center;
  padding: 1rem;
  background: #060a22e8;
  border-radius: 12px;
  overflow: auto;
}
.overlay[hidden] { display: none; }
.overlay h2 { margin: 0 0 0.5rem; font: 400 clamp(2rem, 6vw, 3.6rem) var(--display); color: #fff; text-shadow: 3px 3px 0 var(--red); }
.howto { max-width: 34rem; color: #d7dcf5; line-height: 1.6; font-size: 0.95rem; }
.final { font-size: 1.3rem; margin: 0.3rem 0; }
.final b { font: 400 2.2rem var(--display); color: var(--gold); }
.taunt { color: #d7dcf5; max-width: 30rem; }
.go {
  margin-top: 1rem;
  padding: 0.5rem 2.2rem;
  border: 0;
  border-radius: 999px;
  background: var(--red);
  color: #fff;
  font: 400 1.6rem var(--display);
  letter-spacing: 0.04em;
  cursor: pointer;
  box-shadow: 0 5px 0 #8d1c25;
}
.go:active { transform: translateY(3px); box-shadow: 0 2px 0 #8d1c25; }
.hint { color: var(--muted); font-size: 0.8rem; }
.newbest { color: var(--gold); font: 400 1.5rem var(--display); margin: 0.2rem; animation: pulse 0.5s infinite alternate; }
@keyframes pulse { to { transform: scale(1.12); } }

/* d-pad: touch devices only */
.dpad { display: none; }
@media (pointer: coarse), (hover: none) {
  .dpad {
    display: grid;
    grid-template: 'a u b' 1fr 'l c r' 1fr 'd2 d d3' 1fr / 1fr 1fr 1fr;
    width: 11rem;
    height: 11rem;
    margin: 0.5rem auto 1rem;
    gap: 0.3rem;
    touch-action: none;
  }
  .dpad button {
    border: 2px solid var(--edge);
    border-radius: 12px;
    background: var(--panel);
    color: #fff;
    font-size: 1.4rem;
  }
  .dpad button:active { background: var(--edge); }
  .dpad [data-dir='up'] { grid-area: u; }
  .dpad [data-dir='left'] { grid-area: l; }
  .dpad [data-dir='right'] { grid-area: r; }
  .dpad [data-dir='down'] { grid-area: d; }
  /* leave room for the d-pad under the stage */
  body:has(.dpad) .stage { width: min(96vw, calc((100dvh - 22rem) * var(--ar, 1))); }
}

/* small screens: let start/game-over text grow past a short canvas instead of clipping */
@media (max-width: 700px) {
  .overlay { bottom: auto; min-height: 100%; overflow: visible; }
  .overlay h2 { font-size: 2.2rem; }
  .howto { font-size: 0.85rem; line-height: 1.45; }
  .bar h1 { font-size: 1.2rem; }
}
.toolbar {
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  gap: 0.5rem;
  margin: 0.4rem auto 1rem;
  padding: 0 0.5rem;
}
.toolbar button {
  display: flex;
  align-items: center;
  gap: 0.4rem;
  padding: 0.3rem 0.7rem;
  border: 2px solid var(--edge);
  border-radius: 10px;
  background: var(--panel);
  color: #fff;
  font-size: 0.85rem;
  cursor: pointer;
}
.toolbar button.on { border-color: var(--gold); background: #2a2a10; }
.toolbar button:disabled { opacity: 0.4; cursor: default; }
.toolbar img { width: 26px; height: 26px; }

/* ---------- sharing ---------- */
.share-btn {
  margin-top: 0.6rem;
  padding: 0.35rem 1.2rem;
  border: 2px solid var(--gold);
  border-radius: 999px;
  background: transparent;
  color: var(--gold);
  font: 700 0.95rem system-ui, sans-serif;
  cursor: pointer;
}
.share-links { display: flex; flex-wrap: wrap; justify-content: center; gap: 0.4rem; margin: 0.6rem 0 0; }
.share-links a, .share-links button {
  padding: 0.2rem 0.6rem;
  border: 1px solid var(--edge);
  border-radius: 6px;
  background: var(--panel);
  color: #d7dcf5;
  font: 600 0.8rem system-ui, sans-serif;
  text-decoration: none;
  cursor: pointer;
}
.share-links a:hover, .share-links button:hover { border-color: var(--gold); color: #fff; }

/* ---------- static page content (SEO / how to play) ---------- */
.intro { max-width: 46rem; margin: 1rem auto 0; padding: 0 1rem; text-align: center; color: #c7cdf0; line-height: 1.55; }
.home-share { text-align: center; margin: 1.5rem auto 0; color: var(--muted); font-size: 0.85rem; }
.about {
  max-width: 46rem;
  margin: 1.5rem auto 3rem;
  padding: 1.2rem 1.4rem;
  border: 2px solid var(--edge);
  border-radius: 14px;
  background: #0d1338;
  color: #c7cdf0;
  line-height: 1.55;
}
.about h2 { margin: 0 0 0.4rem; font: 400 1.5rem var(--display); color: var(--gold); letter-spacing: 0.02em; }
.about h2 + p { margin-top: 0; }
.about .more { display: flex; flex-wrap: wrap; gap: 0.4rem 1rem; padding: 0; list-style: none; }
.about .more a { font-weight: 700; text-decoration: none; }
.about .more a:hover { text-decoration: underline; }
.noscript { text-align: center; padding: 2rem; color: var(--gold); }
.about .share-links { justify-content: flex-start; margin-bottom: 1rem; }

/* ---------- accounts ---------- */
.bar .acct { color: #d7dcf5; text-decoration: none; font-weight: 700; font-size: 0.9rem; white-space: nowrap; }
.bar .acct:hover { color: var(--gold); }
.board-slot { margin-top: 0.4rem; color: #d7dcf5; font-size: 0.95rem; min-height: 1.4em; }
.board-slot a { font-weight: 700; }
.site-nav { display: flex; justify-content: center; gap: 1.2rem; margin-top: 1rem; font-weight: 700; }
.site-nav a { text-decoration: none; }
.site-nav a:hover { text-decoration: underline; }
.panel { max-width: 34rem; margin: 2rem auto; padding: 1.4rem; border: 2px solid var(--edge); border-radius: 14px; background: #0d1338; line-height: 1.55; }
.panel h1, .panel h2 { margin: 0 0 0.6rem; font: 400 1.9rem var(--display); color: var(--gold); letter-spacing: 0.02em; }
.panel h2 { font-size: 1.4rem; margin-top: 1.4rem; }
.panel label { display: block; margin: 0.8rem 0 0.3rem; font-weight: 700; }
.panel input[type='email'], .panel input[type='text'] {
  width: 100%;
  padding: 0.6rem 0.8rem;
  border: 2px solid var(--edge);
  border-radius: 10px;
  background: #060a22;
  color: #fff;
  font: inherit;
}
.panel input:focus { outline: none; border-color: var(--gold); }
.panel .check { display: flex; gap: 0.6rem; align-items: flex-start; font-weight: 400; color: #c7cdf0; }
.panel .check input { margin-top: 0.35rem; }
.panel .go { font-size: 1.3rem; }
.panel .msg { min-height: 1.4em; color: var(--gold); }
.panel .msg.err { color: #ff8a8a; }
.panel .fine { font-size: 0.8rem; color: var(--muted); }
.panel .row { display: flex; gap: 0.6rem; flex-wrap: wrap; align-items: center; margin-top: 1rem; }
.btn-ghost { padding: 0.4rem 1rem; border: 2px solid var(--edge); border-radius: 999px; background: transparent; color: #d7dcf5; font: 700 0.9rem system-ui, sans-serif; cursor: pointer; }
.btn-ghost:hover { border-color: var(--gold); color: #fff; }
.btn-danger { border-color: #8d1c25; color: #ff8a8a; }
.tabs { display: flex; gap: 0.4rem; flex-wrap: wrap; margin: 0.8rem 0; }
.tabs button { padding: 0.3rem 0.9rem; border: 2px solid var(--edge); border-radius: 999px; background: var(--panel); color: #fff; font-weight: 700; cursor: pointer; }
.tabs button.on { border-color: var(--gold); color: var(--gold); }
.lb { width: 100%; border-collapse: collapse; }
.lb td, .lb th { padding: 0.4rem 0.5rem; border-bottom: 1px solid #1d2668; text-align: left; }
.lb td:last-child, .lb th:last-child { text-align: right; font-variant-numeric: tabular-nums; }
.lb tr:nth-child(-n + 3) td:first-child { color: var(--gold); font-weight: 900; }
select.game-pick { width: 100%; padding: 0.5rem; border: 2px solid var(--edge); border-radius: 10px; background: #060a22; color: #fff; font: inherit; }

/* ---------- share icons (overrides the earlier text-link style) ---------- */
.share-links { gap: 0.45rem; }
.share-links .sh {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 0.35rem;
  min-width: 2.4rem;
  height: 2.4rem;
  padding: 0 0.6rem;
  border: 2px solid var(--edge);
  border-radius: 999px;
  background: var(--panel);
  color: #e3e7ff;
  transition: transform 0.1s, background 0.15s, border-color 0.15s;
}
.share-links .sh:hover, .share-links .sh:focus-visible { transform: translateY(-2px); color: #fff; outline: none; }
.share-links .sh svg { display: block; }
.share-links .sh span { font: 700 0.8rem system-ui, sans-serif; }
.sh-x:hover, .sh-x:focus-visible { background: #000; border-color: #444; }
.sh-bluesky:hover, .sh-bluesky:focus-visible { background: #1185fe; border-color: #1185fe; }
.sh-facebook:hover, .sh-facebook:focus-visible { background: #1877f2; border-color: #1877f2; }
.sh-reddit:hover, .sh-reddit:focus-visible { background: #ff4500; border-color: #ff4500; }
.sh-whatsapp:hover, .sh-whatsapp:focus-visible { background: #1faa53; border-color: #1faa53; }
.sh-telegram:hover, .sh-telegram:focus-visible { background: #229ed9; border-color: #229ed9; }
.sh-email:hover, .sh-email:focus-visible, .sh-copy:hover, .sh-copy:focus-visible { background: var(--edge); border-color: var(--gold); }
.sh-copy.copied { background: #1faa53; border-color: #1faa53; }
.sh-copy.copied::after { content: 'Copied!'; font: 700 0.8rem system-ui, sans-serif; }
.sh-copy.copied svg { display: none; }
.sh-copy.failed { border-color: #8d1c25; }
.btns [data-share-game] { display: inline-flex; align-items: center; }
.share-panel {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: center;
  gap: 0.6rem;
  padding: 0.6rem 1rem;
  background: #0d1338;
  border-bottom: 2px solid var(--edge);
  color: #c7cdf0;
  font-weight: 700;
}
.share-panel[hidden] { display: none; }
.share-panel .share-links { margin: 0; }
.overlay .share-links { margin-top: 0.5rem; }

/* ---------- support ---------- */
.coin { margin: 1rem 0; padding: 0.8rem 1rem; border: 1px solid var(--edge); border-radius: 12px; background: #060a22; }
.coin h2 { margin: 0 0 0.4rem; font-size: 1.2rem; }
.coin .addr { display: block; margin-bottom: 0.6rem; word-break: break-all; font: 0.9rem ui-monospace, monospace; color: #fff; user-select: all; }
.coin [data-copy].copied { border-color: #1faa53; color: #8ff0b0; }
.bmc { display: inline-block; text-decoration: none; }

/* ---------- passkeys & supporter badge ---------- */
.badge {
  display: inline-block;
  padding: 0 0.45em;
  border-radius: 999px;
  background: linear-gradient(135deg, #fff3a0, #f2c230 55%, #b8860b);
  color: #3a2a08;
  font: 800 0.75em system-ui, sans-serif;
  vertical-align: middle;
  white-space: nowrap;
}
.linkish { padding: 0; border: 0; background: none; color: var(--gold); font: inherit; text-decoration: underline; cursor: pointer; }
.keys { list-style: none; padding: 0; margin: 0.4rem 0; }
.keys li { display: flex; justify-content: space-between; align-items: center; gap: 0.6rem; padding: 0.4rem 0; border-bottom: 1px solid #1d2668; }
.keys small { color: var(--muted); margin-left: 0.4rem; }
a.btn-ghost { text-decoration: none; display: inline-block; }

/* Games with a toolbar under the stage: leave room for it. */
body:has(.toolbar) .stage { width: min(96vw, calc((100dvh - 13rem) * var(--ar, 1.6))); }
@media (pointer: coarse) {
  body:has(.toolbar) .stage { width: min(96vw, calc((100dvh - 15rem) * var(--ar, 1.6))); }
}

.next-game { margin: 0.6rem 0 0; font-weight: 700; }
.next-game a { text-decoration: none; }
.overlay:focus { outline: none; }
.notfound-thumb { max-width: 220px; margin: 2rem auto; }

/* Respect reduced-motion preferences. */
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation-duration: 0.01ms !important; animation-iteration-count: 1 !important; transition-duration: 0.01ms !important; }
  .card:hover, .card:focus-visible { transform: none; }
}

/* ---------- cosmetics picker ---------- */
.cos { width: min(34rem, 100%); text-align: left; }
.cos-slot { border: 2px solid var(--edge); border-radius: 12px; margin: 0 0 0.8rem; padding: 0.4rem 0.6rem 0.6rem; }
.cos-slot legend { padding: 0 0.4rem; font: 400 1.2rem var(--display); color: var(--gold); }
.cos-item {
  display: inline-flex; align-items: center; gap: 0.4rem; flex-wrap: wrap;
  margin: 0.25rem; padding: 0.35rem 0.7rem;
  border: 2px solid var(--edge); border-radius: 999px; background: var(--panel); color: #fff;
  font: 700 0.85rem system-ui, sans-serif; cursor: pointer;
}
.cos-item.on { border-color: var(--gold); background: #2a2a10; }
.cos-item:disabled { opacity: 0.55; cursor: not-allowed; }
.cos-item small { width: 100%; font-weight: 600; color: var(--muted); }
.cos-swatch { width: 1rem; height: 1rem; border-radius: 50%; border: 2px solid #0008; }
.cos-new { color: var(--gold); font-weight: 700; }
