:root {
  --ink: #14121f;
  --paper: #fff6e0;
  --card: #ffffff;
  --green: #3ce07a;
  --green-d: #1fa85a;
  --yellow: #ffd23f;
  --pink: #ff5da2;
  --blue: #3da5ff;
  --muted: #5d5872;
  --line: 3px solid var(--ink);
  --shadow: 4px 4px 0 var(--ink);
  --pixel: "Press Start 2P", monospace;
  --body: "Space Grotesk", system-ui, -apple-system, Segoe UI, sans-serif;
}
* { box-sizing: border-box; }
[hidden] { display: none !important; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0; color: var(--ink); background: var(--paper); font: 500 17px/1.5 var(--body);
  overflow-x: hidden;
}
.sky {
  position: fixed; inset: 0; z-index: -1; pointer-events: none;
  background:
    radial-gradient(circle at 12% 8%, rgba(255, 210, 63, .55) 0 90px, transparent 91px),
    linear-gradient(180deg, #8fd6ff 0, #c9eeff 300px, var(--paper) 520px);
}
a { color: inherit; }
button { font: inherit; color: inherit; }

/* ---------- top bar */
.top {
  display: flex; align-items: center; justify-content: space-between; gap: 12px;
  max-width: 1080px; margin: 0 auto; padding: 14px 16px;
}
.logo { display: flex; align-items: center; gap: 10px; text-decoration: none; font: 14px var(--pixel); letter-spacing: 1px; }
.logo canvas { width: 51px; height: 39px; image-rendering: pixelated; }
.top-r { display: flex; gap: 8px; align-items: center; }
.chip {
  display: inline-flex; align-items: center; gap: 8px; height: 38px; padding: 0 12px; border: var(--line); border-radius: 999px;
  background: var(--card); box-shadow: 2px 2px 0 var(--ink); cursor: pointer; text-decoration: none; font-size: 14px; white-space: nowrap;
}
.chip b { font: 10px var(--pixel); }
.chip span { color: var(--muted); font-size: 13px; }
.chip.icon { width: 38px; justify-content: center; padding: 0; font-size: 16px; }
.chip:active { transform: translate(2px, 2px); box-shadow: none; }
.coin-chip.live span { color: var(--green-d); font-weight: 700; }

/* ---------- coin banner */
.coinbar { max-width: 1080px; margin: 0 auto; padding: 4px 16px 0; }
.cb-in {
  display: flex; align-items: center; gap: 14px; padding: 12px 14px; background: var(--yellow); border: var(--line); border-radius: 16px; box-shadow: var(--shadow);
}
.coinbar.live .cb-in { background: var(--green); }
.cb-in canvas { width: 51px; height: 39px; image-rendering: pixelated; flex: none; }
.cb-text { display: flex; flex-direction: column; min-width: 0; }
.cb-text b { font: 11px/1.6 var(--pixel); display: flex; align-items: center; gap: 8px; }
.cb-text b::before { content: ""; width: 10px; height: 10px; border-radius: 50%; border: 2px solid var(--ink); background: var(--pink); flex: none; animation: blink 1s steps(2) infinite; }
.coinbar.live .cb-text b::before { background: #fff; animation: none; }
.cb-text span { font-size: 14px; color: #2c2840; }
@keyframes blink { 50% { opacity: .25; } }
.cb-ca {
  display: flex; align-items: center; gap: 10px; min-width: 0; margin-left: auto; padding: 0 6px 0 12px; height: 42px; border: 2px solid var(--ink); border-radius: 10px;
  background: var(--card); cursor: pointer;
}
.cb-ca code { font: 600 14px ui-monospace, SFMono-Regular, Menlo, Consolas, monospace; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.cb-ca span { flex: none; padding: 4px 10px; border-radius: 6px; background: var(--ink); color: #fff; font-size: 13px; font-weight: 700; }
.cb-ca:active { transform: translate(1px, 1px); }
.cb-links { display: flex; gap: 8px; flex: none; }
.cb-links .btn.sm { height: 42px; }

/* ---------- hero */
main { max-width: 1080px; margin: 0 auto; padding: 0 16px; }
.hero { text-align: center; padding: 26px 0 12px; }
.kicker { display: inline-block; margin: 0 0 14px; padding: 6px 10px; background: var(--ink); color: var(--yellow); font: 10px/1.4 var(--pixel); border-radius: 6px; transform: rotate(-1.5deg); }
h1 { margin: 0; font: clamp(30px, 6.4vw, 60px)/1.25 var(--pixel); letter-spacing: -1px; }
h1 .hl { color: var(--green); -webkit-text-stroke: 2px var(--ink); paint-order: stroke fill; text-shadow: 4px 4px 0 var(--ink); }
.sub { max-width: 620px; margin: 18px auto 22px; font-size: 18px; color: #2c2840; }

.prompt { max-width: 760px; margin: 0 auto; }
.prompt-box {
  display: flex; gap: 10px; align-items: stretch; background: var(--card); border: var(--line); border-radius: 18px; box-shadow: 6px 6px 0 var(--ink); padding: 10px;
}
.prompt textarea {
  flex: 1; min-width: 0; resize: none; border: 0; outline: 0; background: transparent; font: 700 19px/1.4 var(--body); color: var(--ink); padding: 8px 6px;
}
.prompt textarea::placeholder { color: #9a95ad; }
.prompt-actions { display: flex; gap: 8px; align-items: center; }
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 6px; height: 48px; padding: 0 18px; border: var(--line); border-radius: 12px;
  background: var(--yellow); box-shadow: var(--shadow); cursor: pointer; font: 700 16px var(--body); text-decoration: none; white-space: nowrap;
  transition: transform .06s, box-shadow .06s;
}
.btn:hover { transform: translate(-1px, -1px); box-shadow: 5px 5px 0 var(--ink); }
.btn:active { transform: translate(4px, 4px); box-shadow: 0 0 0 var(--ink); }
.btn:disabled { opacity: .45; cursor: default; transform: none; box-shadow: var(--shadow); }
.btn.go { background: var(--green); font: 13px var(--pixel); }
.btn.ghost { background: var(--card); }
.btn.sm { height: 40px; padding: 0 14px; font-size: 15px; box-shadow: 3px 3px 0 var(--ink); }
.btn.sm.go { font-size: 11px; }
.genres { display: flex; flex-wrap: wrap; justify-content: center; gap: 8px; margin-top: 16px; }
.g {
  height: 36px; padding: 0 14px; border: 2px solid var(--ink); border-radius: 999px; background: rgba(255, 255, 255, .7); cursor: pointer; font-weight: 700; font-size: 15px;
}
.g.on { background: var(--ink); color: var(--yellow); }

/* ---------- stage */
.stage-wrap { margin: 30px auto 0; max-width: 900px; }
.console { background: var(--pink); border: var(--line); border-radius: 22px; box-shadow: 8px 8px 0 var(--ink); padding: 12px; }
.console-top { display: flex; align-items: center; gap: 10px; padding: 2px 6px 10px; min-height: 30px; }
.led { width: 12px; height: 12px; border-radius: 50%; background: #5a1530; border: 2px solid var(--ink); flex: none; }
.led.on { background: #7dffb0; box-shadow: 0 0 10px #7dffb0; }
.console-title { font: 11px/1.4 var(--pixel); color: var(--ink); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.console-tags { margin-left: auto; font: 9px var(--pixel); color: #fff; text-shadow: 1px 1px 0 var(--ink); white-space: nowrap; }
.screen { position: relative; border: var(--line); border-radius: 10px; overflow: hidden; background: #0d0b18; aspect-ratio: 16 / 9; }
.screen canvas#game { display: block; width: 100%; height: 100%; image-rendering: pixelated; touch-action: none; outline: none; cursor: pointer; }
.screen:fullscreen { border: 0; border-radius: 0; display: flex; align-items: center; justify-content: center; background: #000; }
.screen:fullscreen canvas#game { width: min(100vw, calc(100vh * 16 / 9)); height: auto; aspect-ratio: 16 / 9; }
.empty { position: absolute; inset: 0; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 14px; color: #c9c3e6; text-align: center; font: 11px/1.9 var(--pixel); background: repeating-linear-gradient(0deg, #0d0b18 0 3px, #12101f 3px 6px); }
.empty canvas { width: 102px; height: 78px; image-rendering: pixelated; animation: bob 1.2s ease-in-out infinite; }
.empty p { margin: 0; padding: 0 16px; }
@keyframes bob { 50% { transform: translateY(-8px); } }
.build-log {
  position: absolute; inset: 0; padding: 18px 20px; background: rgba(10, 8, 20, .92); color: #7dffb0; font: 11px/2 var(--pixel); overflow: hidden;
}
.build-log div { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.build-log .dim { color: #8d86ad; }
.build-log .y { color: var(--yellow); }
.console-bar { display: flex; flex-wrap: wrap; gap: 10px; padding: 12px 2px 2px; }
.console-bar #fsBtn { margin-left: auto; width: 44px; padding: 0; }
.cast { text-align: center; color: var(--muted); min-height: 26px; margin: 14px 0 0; font-size: 15px; }
.cast b { color: var(--ink); }

/* ---------- blocks */
.block { margin: 64px auto 0; }
h2 { font: 20px/1.4 var(--pixel); margin: 0 0 6px; }
.muted { color: var(--muted); margin: 0 0 18px; }
.gallery { display: grid; grid-template-columns: repeat(4, 1fr); gap: 16px; }
.card {
  display: flex; flex-direction: column; text-align: left; padding: 0; overflow: hidden; border: var(--line); border-radius: 14px; background: var(--card);
  box-shadow: var(--shadow); cursor: pointer; transition: transform .08s, box-shadow .08s;
}
.card:hover { transform: translate(-2px, -2px) rotate(-.5deg); box-shadow: 6px 6px 0 var(--ink); }
.card canvas { display: block; width: 100%; aspect-ratio: 16 / 9; image-rendering: pixelated; border-bottom: var(--line); }
.card .meta { padding: 10px 12px 12px; }
.card .t { font: 10px/1.6 var(--pixel); }
.card .p { font-size: 14px; color: var(--muted); margin-top: 4px; line-height: 1.35; }
.card .tag { display: inline-block; margin-top: 8px; font-size: 12px; font-weight: 700; padding: 2px 8px; border: 2px solid var(--ink); border-radius: 999px; background: var(--yellow); }

.steps { list-style: none; padding: 0; margin: 18px 0 0; display: grid; grid-template-columns: repeat(4, 1fr); gap: 16px; }
.steps li { background: var(--card); border: var(--line); border-radius: 14px; box-shadow: var(--shadow); padding: 16px; font-size: 16px; }
.steps .n { display: inline-grid; place-items: center; width: 32px; height: 32px; border: var(--line); border-radius: 50%; background: var(--green); font: 12px var(--pixel); margin-bottom: 10px; }
.steps b { display: block; font-size: 18px; margin-bottom: 4px; }

.coin { display: flex; gap: 24px; align-items: center; background: var(--yellow); border: var(--line); border-radius: 20px; box-shadow: 8px 8px 0 var(--ink); padding: 24px; }
.coin canvas { width: 136px; height: 104px; image-rendering: pixelated; flex: none; animation: bob 1.4s ease-in-out infinite; }
.coin p { margin: 6px 0 0; font-size: 17px; }
.ca { display: flex; gap: 10px; align-items: center; flex-wrap: wrap; margin-top: 14px; }
.ca code { font: 600 14px ui-monospace, SFMono-Regular, Menlo, monospace; background: var(--card); border: 2px solid var(--ink); border-radius: 8px; padding: 8px 10px; word-break: break-all; }
.coin-links { display: flex; gap: 10px; margin-top: 12px; flex-wrap: wrap; }

footer { max-width: 1080px; margin: 70px auto 0; padding: 22px 16px 40px; border-top: var(--line); color: var(--muted); font-size: 14px; }
footer p { margin: 0 0 8px; }

.toast {
  position: fixed; left: 50%; bottom: 24px; transform: translate(-50%, 140%); background: var(--ink); color: #fff; padding: 12px 18px; border-radius: 12px;
  font-weight: 700; transition: transform .25s cubic-bezier(.2, 1.4, .4, 1); z-index: 50; max-width: calc(100vw - 32px);
}
.toast.show { transform: translate(-50%, 0); }

body.frog { --green: #7bd36b; }
body.frog h1 .hl::after { content: " 🐸"; -webkit-text-stroke: 0; text-shadow: none; }

/* ---------- small screens */
@media (max-width: 860px) {
  .gallery { grid-template-columns: repeat(2, 1fr); }
  .steps { grid-template-columns: repeat(2, 1fr); }
}
@media (max-width: 860px) {
  .cb-in { flex-wrap: wrap; }
  .cb-ca { order: 3; flex: 1 1 100%; margin-left: 0; justify-content: space-between; }
  .cb-links { order: 4; flex: 1 1 100%; }
  .cb-links .btn { flex: 1; }
}
@media (max-width: 600px) {
  body { font-size: 16px; }
  .cb-in { gap: 10px; padding: 10px; }
  .cb-in canvas { display: none; }
  .coin-chip { display: none; }
  .cb-ca code { font-size: 12px; white-space: normal; word-break: break-all; text-align: left; }
  .cb-ca { height: auto; padding: 8px 6px 8px 10px; }
  .logo span { font-size: 11px; }
  .chip span { display: none; }
  .hero { padding-top: 14px; }
  .sub { font-size: 16px; }
  .prompt-box { flex-direction: column; padding: 8px; }
  .prompt textarea { font-size: 17px; }
  .prompt-actions .btn { flex: 1; }
  .btn.ghost span { display: none; }
  .console { padding: 8px; border-radius: 16px; box-shadow: 5px 5px 0 var(--ink); }
  .console-tags { display: none; }
  .console-bar .btn.sm { flex: 1; padding: 0 8px; font-size: 14px; }
  .console-bar #fsBtn { display: none; }
  .gallery { gap: 12px; }
  .card .p { display: none; }
  .steps { grid-template-columns: 1fr; }
  .coin { flex-direction: column; text-align: center; padding: 20px 16px; }
  .ca, .coin-links { justify-content: center; }
  h2 { font-size: 16px; }
}
