:root {
  --bg: #05060f; --bg2: #0b0e1f; --panel: #10142a; --border: #23284a;
  --text: #e8ecff; --muted: #8a91c0; --neon: #00f5d4; --neon2: #ff2e97; --neon3: #7b5cff;
  --warn: #ffd23f;
}
* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }
html, body { margin: 0; padding: 0; }
body {
  font-family: "Segoe UI", -apple-system, BlinkMacSystemFont, Roboto, Helvetica, Arial, sans-serif;
  background: radial-gradient(1000px 600px at 50% -5%, #141a3a 0%, var(--bg) 55%);
  color: var(--text); min-height: 100vh; line-height: 1.5;
}
.mono { font-family: ui-monospace, "JetBrains Mono", Menlo, Consolas, monospace; }
a { color: var(--neon); }

.wrap { max-width: 960px; margin: 0 auto; padding: 0 16px 60px; }

/* Header */
header.site { text-align: center; padding: 30px 0 6px; }
.brand { font-size: 30px; font-weight: 900; letter-spacing: 1px; }
.brand .px { color: var(--neon); text-shadow: 0 0 12px var(--neon); }
.brand .br { color: var(--neon2); text-shadow: 0 0 12px var(--neon2); }
.tagline { color: var(--muted); margin: 6px 0 0; font-size: 15px; }

/* Hub grid */
.grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(180px, 1fr)); gap: 16px; margin-top: 22px; }
.game-card { display: block; text-decoration: none; color: var(--text); background: var(--panel);
  border: 1px solid var(--border); border-radius: 14px; overflow: hidden; transition: transform .12s, border-color .12s; }
.game-card:hover { transform: translateY(-3px); border-color: var(--neon); }
.game-card .thumb { width: 100%; aspect-ratio: 4/3; display: block; background: #04060e; }
.game-card .meta { padding: 12px 14px; }
.game-card .title { font-weight: 700; font-size: 16px; }
.game-card .sub { color: var(--muted); font-size: 13px; margin-top: 3px; }
.badge { display: inline-block; font-size: 11px; color: var(--neon); border: 1px solid var(--neon); border-radius: 20px; padding: 1px 8px; margin-top: 8px; }

.ad-slot { min-height: 90px; display: flex; align-items: center; justify-content: center; color: #3a4a5a;
  border: 1px dashed var(--border); border-radius: 12px; margin: 20px 0; font-size: 13px; }

footer.site { text-align: center; color: var(--muted); font-size: 13px; margin-top: 30px; padding-top: 18px; border-top: 1px solid var(--border); }
footer.site a { color: var(--muted); }

/* ============ GAME PAGE ============ */
.game-shell { display: flex; flex-direction: column; align-items: center; }
.game-top { display: flex; justify-content: space-between; align-items: center; width: 100%; max-width: 480px; padding: 8px 4px; }
.game-top a { text-decoration: none; color: var(--muted); font-size: 14px; }
.game-title { font-weight: 800; font-size: 18px; }

.stage-wrap { position: relative; max-width: 100%; display: inline-block; line-height: 0; }
/* Canvas keeps its 360:640 (9:16) ratio but is capped by viewport height so the
   controls always stay on screen. Scales by whichever limit hits first. */
canvas.stage { display: block; width: auto; height: auto;
  max-width: 100%; max-height: 60vh; aspect-ratio: 360 / 640; background: #04060e;
  border: 1px solid var(--border); border-radius: 12px; touch-action: none; }

/* HUD overlay messages */
.overlay { position: absolute; inset: 0; display: flex; flex-direction: column; align-items: center; justify-content: center;
  text-align: center; background: rgba(4,6,14,.82); border-radius: 12px; padding: 20px; }
.overlay.hidden { display: none; }
.overlay h2 { margin: 0 0 6px; font-size: 26px; }
.overlay .neon { color: var(--neon); text-shadow: 0 0 14px var(--neon); }
.overlay p { color: var(--muted); margin: 4px 0 14px; font-size: 14px; }
.play-btn { background: linear-gradient(135deg, var(--neon), #2fbf6f); color: #04120a; border: none;
  padding: 13px 30px; border-radius: 10px; font-size: 17px; font-weight: 800; cursor: pointer; }
.play-btn:active { transform: translateY(1px); }

/* Controls panel */
.controls { width: 100%; max-width: 480px; margin-top: 12px; display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.dpad { display: grid; grid-template-columns: repeat(3, 56px); grid-template-rows: repeat(3, 56px);
  gap: 6px; justify-content: start; }
.dbtn { background: var(--panel); border: 1px solid var(--border); border-radius: 12px; color: var(--text);
  font-size: 22px; display: flex; align-items: center; justify-content: center; user-select: none; cursor: pointer; }
.dbtn:active, .dbtn.on { background: var(--neon3); border-color: var(--neon3); color: #fff; }
.dbtn.up { grid-column: 2; grid-row: 1; } .dbtn.left { grid-column: 1; grid-row: 2; }
.dbtn.right { grid-column: 3; grid-row: 2; } .dbtn.down { grid-column: 2; grid-row: 3; }
.actions { display: flex; align-items: center; justify-content: flex-end; gap: 14px; }
.abtn { width: 76px; height: 76px; border-radius: 50%; border: 2px solid var(--border); background: var(--panel);
  color: var(--text); font-weight: 800; font-size: 15px; user-select: none; cursor: pointer; display: flex; align-items: center; justify-content: center; }
.abtn.a { border-color: var(--neon); color: var(--neon); }
.abtn.b { border-color: var(--neon2); color: var(--neon2); }
.abtn:active, .abtn.on { filter: brightness(1.6); transform: translateY(1px); }
.ctrl-hint { text-align: center; color: var(--muted); font-size: 12px; margin-top: 8px; max-width: 480px; }

/* Short/mobile screens: shrink canvas + controls so the whole game fits without scrolling. */
@media (max-height: 760px) {
  header.site { padding: 12px 0 4px; }
  canvas.stage { max-height: 56vh; }
  .dpad { grid-template-columns: repeat(3, 48px); grid-template-rows: repeat(3, 48px); }
  .abtn { width: 64px; height: 64px; font-size: 13px; }
  .about, .ad-slot { display: none; }
}
@media (max-height: 620px) {
  canvas.stage { max-height: 52vh; }
  .dpad { grid-template-columns: repeat(3, 42px); grid-template-rows: repeat(3, 42px); }
  .abtn { width: 56px; height: 56px; }
  .ctrl-hint { display: none; }
}

@media (min-width: 620px) { .ctrl-hint::after { content: " — or use arrow keys, Space to fire, B for bomb."; } }

.about { max-width: 480px; margin: 20px auto 0; color: var(--muted); font-size: 14px; }
h1,h2,h3 { line-height: 1.2; }
