/* Pixel Ant Inu — tokens from Reef's spec (Owner's Inbox/reef-135-pixel-spec.md) */
:root {
  --K: #2f130b; --B: #703723; --D: #ab522a; --O: #d97f52; --o: #f3b179;
  --W: #fcf6ee; --w: #f4ded1; --s: #dfb7b1; --P: #ec846d; --p: #e87469; --M: #b3504b;
  --G: #2b1518; --g: #3f2d2c; --h: #64595a; --e: #a48f88; --L: #9f4a24; --H: #ffca9d;
  --Y: #fadabe; --y: #fbcda6; --S: #e0916b; --r: #c48a66;
  --u: 4px;
  --display: "Press Start 2P", ui-monospace, monospace;
  --body: "Silkscreen", ui-monospace, monospace;
  --gutter: 32px;
}
@media (max-width: 640px) { :root { --gutter: 16px; } }

* { box-sizing: border-box; }
html { scroll-behavior: smooth; background: var(--Y); }
body { margin: 0; background: var(--Y); color: var(--K); font: 16px/1.6 var(--body); overflow-x: hidden; }
@media (max-width: 640px) { body { font-size: 14px; } }
@media (prefers-reduced-motion: reduce) { html { scroll-behavior: auto; } }
img, .spr, .layer, .ground { image-rendering: pixelated; image-rendering: crisp-edges; }
h1, h2, h3, .btn, .chip, .num, nav, .brand { font-family: var(--display); -webkit-font-smoothing: none; font-weight: 400; }
h1 { font-size: 32px; line-height: 1.5; margin: 0 0 16px; }
h2 { font-size: 24px; line-height: 1.5; margin: 0 0 24px; }
h3 { font-size: 12px; line-height: 1.5; margin: 0 0 8px; }
@media (max-width: 640px) { h1 { font-size: 24px; } h2 { font-size: 16px; } }
p { margin: 0 0 16px; }
a { color: var(--K); }
code { font-family: var(--body); background: var(--w); padding: 0 4px; word-break: break-all; }
:focus-visible { outline: 4px solid var(--K); outline-offset: 4px; }
.skip { position: absolute; left: -9999px; }
.skip:focus { left: 16px; top: 16px; z-index: 100; background: var(--W); padding: 8px; }
.wrap { max-width: 1040px; margin: 0 auto; padding: 0 var(--gutter); position: relative; z-index: 2; }

/* ---- sprites ---- */
.spr { display: inline-block; background-repeat: no-repeat; vertical-align: middle; flex: none; }
.spr.flip { transform: scaleX(-1); }

/* ---- pixel panels + buttons (stepped corners, 4px ink, 4px drop) ---- */
.panel {
  background: var(--W); margin: 4px;
  box-shadow: 0 -4px 0 var(--K), 0 4px 0 var(--K), -4px 0 0 var(--K), 4px 0 0 var(--K), 0 8px 0 var(--D), 4px 4px 0 var(--D), -4px 4px 0 var(--D);
}
.btn {
  display: inline-flex; align-items: center; gap: 8px; min-height: 48px; padding: 12px 20px; margin: 4px 4px 12px;
  background: var(--O); color: var(--W); border: 0; cursor: pointer; text-decoration: none; font-size: 16px; line-height: 1;
  box-shadow: 0 -4px 0 var(--K), 0 4px 0 var(--K), -4px 0 0 var(--K), 4px 0 0 var(--K), 0 8px 0 var(--D), 4px 4px 0 var(--D), -4px 4px 0 var(--D);
  transition: transform 80ms steps(2), background-color 80ms steps(2);
}
.btn:hover { background: var(--p); }
.btn:active { transform: translateY(4px); box-shadow: 0 -4px 0 var(--K), 0 4px 0 var(--K), -4px 0 0 var(--K), 4px 0 0 var(--K); }
.btn-light { background: var(--W); color: var(--K); }
.btn-light:hover { background: var(--o); }
.btn-dark { white-space: nowrap; background: var(--G); color: var(--W); font-size: 10px; min-height: 36px; padding: 8px 12px; }
.btn-dark:hover { background: var(--g); }
.btn[aria-disabled="true"] { background: var(--s); color: var(--K); }
@media (max-width: 640px) { .btn { font-size: 12px; padding: 12px 14px; } }
.linkbtn { font: inherit; background: none; border: 0; color: var(--W); text-decoration: underline; cursor: pointer; padding: 0; }

/* ---- top bar ---- */
.topbar { position: relative; z-index: 20; display: flex; align-items: center; gap: 16px; padding: 8px var(--gutter); background: var(--W); box-shadow: 0 4px 0 var(--K); }
.brand { display: flex; align-items: center; gap: 8px; font-size: 12px; text-decoration: none; white-space: nowrap; }
.topbar nav { display: flex; gap: 20px; margin-left: auto; font-size: 10px; }
.topbar nav a { text-decoration: none; }
.topbar nav a:hover { color: var(--D); }
@media (max-width: 760px) { .topbar nav { display: none; } .crt-btn { margin-left: auto; } .brand { font-size: 10px; } }

/* ---- hero scene ---- */
.hero { position: relative; min-height: max(560px, min(calc(100svh - 84px), 820px)); overflow: hidden; display: flex; flex-direction: column; background: var(--Y); }
.sky { position: absolute; inset: 0; pointer-events: none; }
.layer { position: absolute; left: 0; right: 0; background-repeat: repeat-x; will-change: transform; }
.clouds { top: 24px; height: 240px; background-image: url(assets/clouds-tile.png), url(assets/clouds-tile.png); background-size: 600px 120px, 400px 80px; background-position: 0 0, 220px 150px; background-repeat: repeat-x; opacity: 1; }
.mesas { bottom: 104px; height: 192px; background-image: url(assets/mesas.png); background-size: 512px 192px; background-position: 0 bottom; }
.town { bottom: 48px; height: 168px; background-image: url(assets/town.png); background-size: 384px 168px; background-position: 120px bottom; }
.hero-copy { padding-top: 64px; text-align: center; width: 100%; }
.chip { display: inline-block; font-size: 12px; background: var(--G); color: var(--H); padding: 8px 12px; margin-bottom: 16px; box-shadow: 0 -4px 0 var(--K), 0 4px 0 var(--K), -4px 0 0 var(--K), 4px 0 0 var(--K); }
.hook { font-size: 16px; max-width: 34ch; margin: 0 auto 24px; }
.actions { display: flex; flex-wrap: wrap; justify-content: center; gap: 12px; }
.hero-stage { position: relative; margin-top: auto; height: 256px; z-index: 3; }
.hero-dog-track { position: absolute; left: 50%; bottom: -8px; transform: translateX(-50%); }
.hero-dog { will-change: transform; }
.crowd.crowd-hero { position: absolute; inset: auto 0 -4px 0; justify-content: space-between; padding: 0 var(--gutter); margin: 0; }
@media (max-width: 760px) { .crowd.crowd-hero { display: none; } }
@media (max-width: 640px) { .hero-stage { height: 192px; } .hero-copy { padding-top: 40px; } }
.ground { height: 48px; background: url(assets/ground.png) 0 0 / 96px 48px repeat-x; position: relative; z-index: 2; }

/* ---- sparkles ---- */
.sparkles { position: absolute; inset: 0; pointer-events: none; z-index: 1; }
.sparkles .spr { position: absolute; }

/* ---- bands ---- */
.band { position: relative; padding-top: 96px; background: var(--Y); overflow: hidden; }
.band.alt { background: var(--y); }
@media (max-width: 640px) { .band { padding-top: 64px; } }
.crowd { position: relative; z-index: 2; display: flex; justify-content: space-around; align-items: flex-end; margin-top: 48px; padding: 0 8px; min-height: 128px; }
.crowd .spr { cursor: pointer; }
.crowd .slot { position: relative; display: flex; }
.zed { position: absolute; left: 40%; top: 24px; width: 16px; height: 16px; background: url(assets/zed.png) 0 0 / 16px 16px; image-rendering: pixelated; animation: zed 1.5s steps(3) infinite; }
@keyframes zed { from { transform: translateY(0); opacity: 1; } to { transform: translateY(-16px); opacity: 0; } }
@media (prefers-reduced-motion: reduce) { .zed { animation: none; } }

.story { display: grid; grid-template-columns: auto 1fr; gap: 48px; align-items: center; }
.portrait { padding: 16px; line-height: 0; }
@media (max-width: 760px) { .story { grid-template-columns: 1fr; gap: 32px; justify-items: start; } }

.steps { list-style: none; padding: 0; margin: 0; display: grid; grid-template-columns: repeat(4, 1fr); gap: 32px; }
.steps li { padding: 20px 16px 8px; position: relative; }
.num { display: inline-grid; place-items: center; width: 32px; height: 32px; background: var(--G); color: var(--H); font-size: 12px; margin-bottom: 12px; }
@media (max-width: 960px) { .steps { grid-template-columns: repeat(2, 1fr); } }
@media (max-width: 560px) { .steps { grid-template-columns: 1fr; gap: 28px; } }

.items { display: grid; grid-template-columns: repeat(4, 1fr); gap: 32px; margin: 0; }
.item { padding: 16px; text-align: center; }
.item dt { font-family: var(--display); font-size: 10px; margin: 8px 0; }
.item dd { margin: 0; font-size: 20px; word-break: break-all; }
@media (max-width: 760px) { .items { grid-template-columns: repeat(2, 1fr); gap: 24px; } }

/* ---- footer ---- */
.footer { background: var(--g); color: var(--W); padding: 24px 0 144px; box-shadow: 0 -4px 0 var(--K); }
.footer .crowd { margin: 0 0 24px; min-height: 128px; }
.disclaimer { max-width: 72ch; font-size: 14px; color: var(--W); }
.small { font-size: 12px; color: var(--e); }

/* ---- runner, fx, toast ---- */
.runner-wrap { position: fixed; left: 0; bottom: 8px; z-index: 15; pointer-events: none; visibility: hidden; }
.runner-wrap.on { visibility: visible; }
.runner { will-change: transform; }
.fx-layer { position: fixed; inset: 0; pointer-events: none; z-index: 30; overflow: hidden; }
.fx-layer .spr { position: absolute; left: 0; top: 0; will-change: transform; }
.toast { position: fixed; left: 50%; bottom: 152px; transform: translateX(-50%); z-index: 40; background: var(--G); color: var(--H); font: 12px/1.5 var(--display); padding: 12px 16px; box-shadow: 0 0 0 4px var(--K); visibility: hidden; max-width: calc(100vw - 32px); text-align: center; }
.toast.show { visibility: visible; }

/* ---- CRT ---- */
.crt-overlay { position: fixed; inset: 0; z-index: 50; pointer-events: none; display: none;
  background:
    repeating-linear-gradient(to bottom, rgba(43, 21, 24, .18) 0 2px, transparent 2px 4px),
    radial-gradient(ellipse at center, transparent 55%, rgba(43, 21, 24, .45) 100%); }
html.crt .crt-overlay { display: block; }
html.crt.crt-flick .crt-overlay { background-color: rgba(252, 246, 238, .25); }

@media (prefers-reduced-motion: reduce) {
  .runner-wrap { display: none; }
  .btn { transition: none; }
}
