/* Retro Swap website: one arcade cabinet's worth of CSS, shared by every page.
   Colors are the game's own PICO-8 palette (engine/PixelArt.kt, object Pal). */

:root {
  --ink: #140C1C;
  --navy: #1D2B53;
  --deep: #10172e;
  --plum: #7E2553;
  --maroon: #5A1A2E;
  --white: #FFF1E8;
  --lgrey: #C2C3C7;
  --dgrey: #5F574F;
  --lavender: #83769C;
  --red: #FF004D;
  --orange: #FFA300;
  --yellow: #FFEC27;
  --gold: #FFD541;
  --lime: #00E436;
  --green: #008751;
  --blue: #29ADFF;
  --pink: #FF77A8;
  --purple: #A65DFF;
  --peach: #FFCCAA;

  --bg: var(--ink);
  --panel: var(--navy);
  --text: var(--white);
  --muted: var(--lavender);
  --mono: ui-monospace, "SF Mono", SFMono-Regular, Menlo, Consolas, "Liberation Mono", monospace;
  color-scheme: dark;
}

* { box-sizing: border-box; }
html { scroll-behavior: smooth; }
@media (prefers-reduced-motion: reduce) { html { scroll-behavior: auto; } }

body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font: 600 16px/1.7 var(--mono);
  -webkit-font-smoothing: antialiased;
  overflow-x: hidden;
  cursor: var(--cur, auto);
}
a, button, [role="button"], #title { cursor: var(--cur-hot, pointer); }
::selection { background: var(--pink); color: var(--ink); }

a { color: var(--blue); text-decoration-thickness: 2px; text-underline-offset: 4px; }
a:hover { color: var(--yellow); }
:focus-visible { outline: 3px dashed var(--yellow); outline-offset: 3px; }

.sr {
  position: absolute; width: 1px; height: 1px; overflow: hidden;
  clip: rect(0 0 0 0); clip-path: inset(50%); white-space: nowrap;
}

/* ---------- CRT: scanlines, vignette, flicker, power-on ---------- */

body::before, body::after {
  content: ""; position: fixed; inset: 0; pointer-events: none; z-index: 900;
}
body::before {
  background: repeating-linear-gradient(to bottom, rgba(0,0,0,0.22) 0 1px, transparent 1px 3px);
  mix-blend-mode: multiply;
}
body::after {
  background: radial-gradient(ellipse at center, transparent 58%, rgba(0,0,0,0.55) 100%);
  animation: flicker 6s steps(1) infinite;
}
@keyframes flicker {
  0%, 100% { opacity: 1; }
  41% { opacity: 0.86; }
  42% { opacity: 1; }
  77% { opacity: 0.92; }
  78% { opacity: 1; }
}

.boot {
  position: fixed; inset: 0; z-index: 1000; background: #000; pointer-events: none;
  animation: boot-open 0.9s cubic-bezier(.7,0,.3,1) forwards;
}
.boot::after {
  content: ""; position: absolute; left: 50%; top: 50%; height: 4px; width: 0;
  transform: translate(-50%, -50%);
  background: var(--white); box-shadow: 0 0 24px 6px rgba(255,241,232,0.7);
  animation: boot-line 0.9s ease-out forwards;
}
@keyframes boot-open {
  0%, 35% { clip-path: inset(0 0 0 0); }
  100% { clip-path: inset(50% 0 50% 0); }
}
@keyframes boot-line {
  0% { width: 0; opacity: 1; }
  35% { width: 100%; opacity: 1; }
  100% { width: 100%; opacity: 0; }
}

/* particle layer for the pointer trail and coin bursts */
.fx { position: fixed; inset: 0; width: 100%; height: 100%; pointer-events: none; z-index: 800; }

/* ---------- pixel-font text (drawn into a canvas by retro.js) ---------- */

.px { display: block; margin: 0; --cell: 3; line-height: 0; }
.px canvas { display: inline-block; image-rendering: pixelated; max-width: none; }

/* ---------- pixel boxes and arcade buttons ---------- */

.pixbox {
  background: var(--panel);
  box-shadow:
    0 -4px 0 0 var(--ink), 0 4px 0 0 var(--ink), -4px 0 0 0 var(--ink), 4px 0 0 0 var(--ink),
    inset 0 4px 0 0 rgba(255,255,255,0.08), inset 0 -4px 0 0 rgba(0,0,0,0.3),
    8px 8px 0 0 rgba(0,0,0,0.45);
}

.btn {
  --c: var(--blue);
  display: inline-block; position: relative;
  padding: 12px 18px 14px; border: 0; margin: 4px;
  background: var(--c); color: var(--ink);
  font: 800 14px/1.1 var(--mono); letter-spacing: 0.06em; text-transform: uppercase; text-decoration: none;
  box-shadow:
    0 -3px 0 0 var(--ink), 0 3px 0 0 var(--ink), -3px 0 0 0 var(--ink), 3px 0 0 0 var(--ink),
    inset 0 3px 0 0 rgba(255,255,255,0.35), inset 0 -5px 0 0 rgba(0,0,0,0.3);
  transition: transform 60ms steps(2);
}
.btn:hover { color: var(--ink); filter: brightness(1.12); }
.btn:active, .btn.pressed { transform: translateY(3px); box-shadow:
    0 -3px 0 0 var(--ink), 0 3px 0 0 var(--ink), -3px 0 0 0 var(--ink), 3px 0 0 0 var(--ink),
    inset 0 5px 0 0 rgba(0,0,0,0.3); }
.btn[disabled] { filter: grayscale(1) brightness(0.6); cursor: not-allowed; }
.btn.ghost { --c: var(--dgrey); color: var(--white); }
.btn.red { --c: var(--red); color: var(--white); }
.btn.pink { --c: var(--pink); }
.btn.purple { --c: var(--purple); color: var(--white); }
.btn.lime { --c: var(--lime); }
.btn.green { --c: var(--green); color: var(--white); }
.btn.gold { --c: var(--gold); }

/* ---------- top bar: marquee + sound toggle ---------- */

.topbar {
  position: sticky; top: 0; z-index: 700;
  display: flex; align-items: stretch;
  background: var(--red); color: var(--yellow);
  border-bottom: 4px solid var(--ink);
  font: 800 13px/1 var(--mono); letter-spacing: 0.08em; text-transform: uppercase;
}
.marquee { flex: 1; overflow: hidden; white-space: nowrap; padding: 10px 0; }
.marquee span { display: inline-block; padding-left: 100%; animation: marquee 32s linear infinite; }
.marquee:hover span { animation-play-state: paused; }
@keyframes marquee { to { transform: translateX(-100%); } }
.sound {
  flex: none; border: 0; border-left: 4px solid var(--ink);
  background: var(--ink); color: var(--lavender);
  font: inherit; letter-spacing: inherit; padding: 0 14px;
}
.sound[aria-pressed="true"] { color: var(--lime); }
.sound:hover { color: var(--yellow); }

/* ---------- footer ---------- */

footer {
  text-align: center; color: var(--muted); font-size: 13px; letter-spacing: 0.04em;
  padding: 24px 16px 64px; position: relative;
}
footer a { color: var(--lgrey); }
.blink { animation: blink 1.1s steps(1) infinite; }
@keyframes blink { 50% { opacity: 0; } }
.insert-coin { color: var(--yellow); margin-bottom: 18px; --cell: 3; }
.insert-coin canvas { margin: 0 auto; }
.hint { margin-top: 10px; font-size: 12px; color: var(--dgrey); }

/* ---------- grail easter egg banner ---------- */

.grail-banner {
  position: fixed; left: 50%; top: 40%; z-index: 850; pointer-events: none;
  transform: translate(-50%, -50%);
  padding: 22px 26px; text-align: center; width: min(520px, calc(100vw - 32px));
  background: var(--ink);
  box-shadow: 0 -4px 0 0 var(--gold), 0 4px 0 0 var(--gold), -4px 0 0 0 var(--gold), 4px 0 0 0 var(--gold),
    0 0 0 12px rgba(20,12,28,0.6);
  animation: grail-in 4s steps(12) forwards;
}
.grail-banner .px { color: var(--gold); --cell: 4; --shadow: var(--plum); }
.grail-banner .px + .px { color: var(--lime); --cell: 3; margin-top: 14px; --shadow: var(--green); }
.grail-banner .px canvas { margin: 0 auto; }
@keyframes grail-in {
  0% { opacity: 0; transform: translate(-50%, -50%) scale(0.3); }
  8%, 85% { opacity: 1; transform: translate(-50%, -50%) scale(1); }
  100% { opacity: 0; transform: translate(-50%, -50%) scale(1); }
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation-duration: 0.001s !important; animation-iteration-count: 1 !important; }
  .boot { display: none; }
  .blink { animation: none; }
  .marquee span { padding-left: 0; }
}

/* ======================================================================
   Home page
   ====================================================================== */

.hero {
  --mx: 0; --my: 0;
  position: relative; overflow: hidden; isolation: isolate;
  text-align: center;
  padding: 56px 16px 120px;
  background: linear-gradient(to bottom, var(--ink) 0%, var(--deep) 45%, var(--maroon) 78%, var(--plum) 100%);
}
.stars { position: absolute; inset: 0; z-index: -2; pointer-events: none;
  transform: translate(calc(var(--mx) * var(--depth) * -60px), calc(var(--my) * var(--depth) * -30px)); }
.stars i { position: absolute; display: block; background: var(--white);
  animation: twinkle 2.4s steps(2) infinite; }
@keyframes twinkle { 50% { opacity: 0.25; } }

.horizon {
  position: absolute; left: 0; right: 0; bottom: 34%; height: 4px; z-index: -1;
  background: var(--pink); box-shadow: 0 0 24px 6px rgba(255,119,168,0.55);
}
.floor {
  position: absolute; left: -60%; right: -60%; bottom: -10%; height: 46%; z-index: -1;
  background-image:
    linear-gradient(to bottom, rgba(166,93,255,0.85) 3px, transparent 3px),
    linear-gradient(to right, rgba(166,93,255,0.85) 3px, transparent 3px);
  background-size: 56px 56px;
  transform-origin: 50% 0;
  transform: perspective(220px) rotateX(58deg) translateX(calc(var(--mx) * -90px));
  animation: floor 0.9s linear infinite;
  -webkit-mask-image: linear-gradient(to bottom, transparent, #000 35%);
  mask-image: linear-gradient(to bottom, transparent, #000 35%);
}
@keyframes floor { to { background-position: 0 56px; } }

.hero .icon {
  width: 104px; height: 104px; image-rendering: pixelated; display: block; margin: 0 auto;
  box-shadow: 0 -4px 0 0 var(--ink), 0 4px 0 0 var(--ink), -4px 0 0 0 var(--ink), 4px 0 0 0 var(--ink), 8px 8px 0 0 rgba(0,0,0,0.5);
  animation: bob 1.6s steps(2) infinite;
  transform: translate(calc(var(--mx) * 14px), calc(var(--my) * 10px));
}
.icon-btn { background: none; border: 0; padding: 0; display: block; margin: 0 auto; }
@keyframes bob { 50% { translate: 0 -4px; } }

.title-wrap { margin: 30px auto 0; max-width: 1040px; }
#title { display: block; margin: 0 auto; touch-action: pan-y; }
.hero .sub { color: var(--blue); --cell: 3; --shadow: var(--ink); margin-top: 10px; text-align: center; }
.hero .sub canvas { margin: 0 auto; }

.tagline {
  position: relative; max-width: 600px; margin: 22px auto 0;
  color: var(--white); font-size: 17px; text-shadow: 3px 3px 0 var(--ink);
}
.tagline .ghost { visibility: hidden; }
.tagline .typed { position: absolute; inset: 0; }
.caret { display: inline-block; width: 0.6em; height: 1.05em; vertical-align: -0.15em; background: var(--yellow); margin-left: 2px; animation: blink 0.8s steps(1) infinite; }

.badges { display: flex; gap: 8px; justify-content: center; flex-wrap: wrap; margin-top: 26px; }
.badges .btn small { display: block; font-size: 10px; margin-top: 5px; opacity: 0.75; letter-spacing: 0.1em; }

.press-start {
  display: inline-block; margin-top: 34px; color: var(--yellow); text-decoration: none;
  font: 800 14px/1 var(--mono); letter-spacing: 0.2em; text-transform: uppercase; text-shadow: 3px 3px 0 var(--ink);
}

main { max-width: 1000px; margin: 0 auto; padding: 0 16px 40px; }

.section { margin-top: 84px; scroll-margin-top: 64px; }
.section > .px { --cell: 4; color: var(--yellow); --shadow: var(--plum); margin-bottom: 8px; }
.section > .lede { color: var(--lgrey); margin: 10px 0 28px; max-width: 640px; }

/* ----- haggle mini-game ----- */

.stand { display: grid; grid-template-columns: minmax(0, 300px) minmax(0, 1fr); gap: 28px; align-items: start; }
.vendor-wrap { position: relative; padding: 14px; }
#vendor { display: block; width: 100%; aspect-ratio: 1; image-rendering: pixelated; }
.mood {
  position: absolute; left: 14px; right: 14px; bottom: 14px;
  background: var(--orange); color: var(--ink); text-align: center;
  font: 800 12px/1 var(--mono); letter-spacing: 0.1em; padding: 6px 0;
}
.mood[data-mood="happy"] { background: var(--lime); }
.mood[data-mood="hmm"] { background: var(--gold); }
.mood[data-mood="annoyed"] { background: var(--orange); }
.mood[data-mood="furious"] { background: var(--red); color: var(--white); }
.closed-sign {
  position: absolute; left: 50%; top: 42%; transform: translate(-50%, -50%) rotate(-6deg);
  background: var(--white); color: var(--red); padding: 10px 12px; white-space: nowrap;
  font: 800 15px/1 var(--mono); letter-spacing: 0.08em;
  box-shadow: 0 0 0 4px var(--ink), 6px 6px 0 4px rgba(0,0,0,0.4);
}

.deal { padding: 20px 22px; position: relative; min-width: 0; }
.who { display: flex; flex-wrap: wrap; gap: 4px 12px; align-items: baseline; }
.who b { font-size: 20px; color: var(--white); }
.who span { color: var(--pink); font-size: 13px; letter-spacing: 0.1em; }
.patience { display: flex; align-items: center; gap: 10px; margin-top: 6px; font-size: 12px; letter-spacing: 0.1em; color: var(--lgrey); }
.bar { flex: 1; height: 10px; background: var(--ink); box-shadow: 0 0 0 2px var(--dgrey); }
.bar i { display: block; height: 100%; width: 100%; background: var(--lime); transition: width 0.3s steps(6), background 0.3s; }
.item { margin-top: 14px; display: flex; flex-wrap: wrap; gap: 6px 10px; align-items: center; }
.item b { color: var(--white); }
.rarity { font-size: 11px; letter-spacing: 0.1em; padding: 3px 7px; background: var(--lime); color: var(--ink); }
.rarity[data-r="RARE"] { background: var(--purple); color: var(--white); }
.rarity[data-r="COMMON"] { background: var(--lgrey); }
.price { display: flex; justify-content: space-between; align-items: end; margin-top: 14px; padding: 12px 14px; background: var(--deep); }
.price small { display: block; font-size: 12px; color: var(--lgrey); letter-spacing: 0.1em; }
.price strong { display: block; font-size: 38px; line-height: 1.1; color: var(--yellow); }
.price .start { text-align: right; color: var(--lavender); font-size: 13px; }
.price .start b { display: block; font-size: 20px; color: var(--lgrey); }

.log { margin-top: 14px; height: 210px; overflow: hidden; display: flex; flex-direction: column; gap: 8px; justify-content: flex-end; }
.log p { margin: 0; padding: 7px 11px; max-width: 92%; font-size: 14px; line-height: 1.45; animation: pop 0.2s steps(3); }
.log .them { background: var(--white); color: var(--ink); align-self: flex-start; }
.log .you { background: var(--blue); color: var(--white); align-self: flex-end; }
.log .note { background: none; color: var(--peach); font-style: italic; align-self: center; text-align: center; padding: 0; }
@keyframes pop { from { transform: scale(0.85); opacity: 0; } }

.moves { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 6px; margin-top: 16px; }
.moves .btn { margin: 3px; padding-left: 6px; padding-right: 6px; font-size: 13px; }
.moves .wide { grid-column: span 3; }

.stamp {
  position: absolute; right: 18px; top: 18px; z-index: 2;
  font: 900 34px/1 var(--mono); letter-spacing: 0.06em; padding: 8px 14px;
  border: 5px solid currentColor; transform: rotate(-12deg);
  background: rgba(20,12,28,0.85);
  animation: stamp 0.35s steps(4);
}
.stamp.steal { color: var(--lime); }
.stamp.oof { color: var(--red); }
@keyframes stamp { from { transform: rotate(-12deg) scale(2.6); opacity: 0; } }

/* ----- screenshots in handheld frames ----- */

.shots { display: flex; gap: 26px; justify-content: center; flex-wrap: wrap; perspective: 900px; }
.tilt {
  --rx: 0deg; --ry: 0deg; --gx: 50%; --gy: 50%;
  position: relative; width: min(260px, 100%); padding: 12px 12px 38px; margin: 0;
  background: var(--lgrey);
  box-shadow: 0 -4px 0 0 var(--ink), 0 4px 0 0 var(--ink), -4px 0 0 0 var(--ink), 4px 0 0 0 var(--ink),
    inset 0 -6px 0 0 rgba(0,0,0,0.2), 10px 10px 0 0 rgba(0,0,0,0.45);
  transform: rotateX(var(--rx)) rotateY(var(--ry));
  transform-style: preserve-3d;
  transition: transform 0.12s ease-out;
}
.tilt img { display: block; width: 100%; height: auto; border: 4px solid var(--ink); }
.tilt::after {
  content: ""; position: absolute; inset: 12px 12px 38px; pointer-events: none;
  background: radial-gradient(circle at var(--gx) var(--gy), rgba(255,255,255,0.28), transparent 45%);
  mix-blend-mode: screen;
}
.tilt figcaption {
  position: absolute; left: 12px; right: 12px; bottom: 9px;
  display: flex; justify-content: space-between; align-items: center;
  font: 800 11px/1 var(--mono); letter-spacing: 0.1em; color: var(--dgrey); text-transform: uppercase;
}
.tilt figcaption i { width: 9px; height: 9px; background: var(--red); box-shadow: 0 0 6px var(--red); }

/* ----- feature cards ----- */

.grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(220px, 1fr)); gap: 26px; }
.card { padding: 20px 20px 22px; transition: transform 80ms steps(2); }
.card:hover { transform: translate(-3px, -3px); }
.card .px { --cell: 3; margin-bottom: 12px; }
.card p { margin: 0; color: var(--lgrey); font-size: 15px; line-height: 1.6; }
.card canvas.glyph { width: 40px; height: 40px; image-rendering: pixelated; display: block; margin-bottom: 14px; }
.card:nth-child(1) .px { color: var(--pink); }
.card:nth-child(2) .px { color: var(--blue); }
.card:nth-child(3) .px { color: var(--gold); }
.card:nth-child(4) .px { color: var(--lime); }

/* ----- high score table ----- */

.scores { max-width: 640px; margin: 0 auto; padding: 22px 16px; text-align: center; }
.scores .px { --cell: 4; color: var(--red); --shadow: var(--ink); margin-bottom: 18px; }
.scores .px canvas { margin: 0 auto; }
.scores table { width: 100%; border-collapse: collapse; font-size: 15px; letter-spacing: 0.06em; text-transform: uppercase; }
.scores th { color: var(--lavender); font-size: 12px; font-weight: 800; padding: 0 6px 10px; text-align: left; }
.scores td { padding: 7px 6px; text-align: left; vertical-align: top; }
.scores td.num { font-variant-numeric: tabular-nums; white-space: nowrap; }
.scores tr:nth-child(6n+1) td { color: var(--yellow); }
.scores tr:nth-child(6n+2) td { color: var(--orange); }
.scores tr:nth-child(6n+3) td { color: var(--pink); }
.scores tr:nth-child(6n+4) td { color: var(--blue); }
.scores tr:nth-child(6n+5) td { color: var(--lime); }
.scores tr:nth-child(6n+6) td { color: var(--purple); }

@media (max-width: 720px) {
  .stand { grid-template-columns: minmax(0, 1fr); }
  .vendor-wrap { max-width: 260px; margin: 0 auto; width: 100%; }
  .price strong { font-size: 32px; }
  .section { margin-top: 64px; }
  .scores table { font-size: 13px; }
  .scores th:first-child, .scores td:first-child { display: none; }
}

/* ======================================================================
   Privacy page
   ====================================================================== */

.page-hero {
  text-align: center; padding: 56px 16px 72px;
  background: linear-gradient(to bottom, var(--ink), var(--deep) 60%, var(--maroon));
}
.page-hero .px { --cell: 5; color: var(--yellow); --shadow: var(--plum); text-align: center; }
.page-hero .px canvas { margin: 0 auto; }
.page-hero p { margin: 14px 0 0; color: var(--lgrey); font-size: 13px; letter-spacing: 0.08em; text-transform: uppercase; }

.policy { max-width: 760px; }
.policy section { padding: 22px 24px; margin-top: 30px; }
.policy section:first-of-type { margin-top: -34px; position: relative; }
.policy h2.px { --cell: 3; color: var(--pink); margin-bottom: 14px; }
.policy p { margin: 0 0 14px; color: var(--lgrey); }
.policy p:last-child, .policy ul:last-child { margin-bottom: 0; }
.policy ul { margin: 0 0 14px; padding-left: 0; list-style: none; color: var(--lgrey); }
.policy li { margin-bottom: 8px; padding-left: 22px; position: relative; }
.policy li::before { content: ""; position: absolute; left: 2px; top: 0.6em; width: 8px; height: 8px; background: var(--yellow); }
.policy .lead { font-size: 18px; line-height: 1.6; color: var(--white); }
.policy .muted { color: var(--lavender); font-size: 14px; }
