/* Siam Pop coming-soon v2: arcade night screen.
   Colours: brand tokens (CLAUDE.md) + the exact purples/pinks measured in the designer's pixel logo.
   Fonts: VT323 (big titles only), Lato Bold (capitals only: HUD, loading, button), Plus Jakarta Sans (one body line). */

@font-face { font-family: "VT323"; src: url("/fonts/vt323-regular.woff2") format("woff2"); font-weight: 400; font-style: normal; font-display: swap; }
@font-face { font-family: "Lato"; src: url("/fonts/lato-bold.woff2") format("woff2"); font-weight: 700; font-style: normal; font-display: swap; }
@font-face { font-family: "Plus Jakarta Sans"; src: url("/fonts/plusjakartasans-variable.woff2") format("woff2"); font-weight: 200 800; font-style: normal; font-display: swap; }
/* metric-matched fallbacks so a late font swap does not move anything */
@font-face { font-family: "VT323 Fallback"; src: local("Courier New"), local("Courier"); size-adjust: 66%; ascent-override: 90%; descent-override: 20%; line-gap-override: 0%; }
@font-face { font-family: "Lato Fallback"; src: local("Arial"), local("Helvetica"); size-adjust: 98%; ascent-override: 98%; descent-override: 21%; line-gap-override: 0%; }
@font-face { font-family: "Jakarta Fallback"; src: local("Arial"), local("Helvetica"); size-adjust: 104%; ascent-override: 93%; descent-override: 24%; line-gap-override: 0%; }

:root {
  /* brand tokens */
  --arcade-purple: #321B47;
  --bubblegum-pink: #F18BA8;
  --neon-citrus: #CCFF00;
  --arcade-yellow: #FFD000;
  --mango-orange: #FF8800;
  --pandan-green: #00E676;
  --cream-canvas: #F8F3E6;
  --pixel-white: #FFFFFF;
  /* measured in the pixel logo */
  --logo-ink: #23143C;
  --logo-purple: #613092;
  --logo-lilac: #925CA1;
  --logo-magenta: #CD6790;
  --logo-pink: #D785A6;
  --logo-blush: #E1A4BA;
  --logo-cream: #FDF7EA;

  --f-title: "VT323", "VT323 Fallback", monospace;
  --f-ui: "Lato", "Lato Fallback", Arial, sans-serif;
  --f-body: "Plus Jakarta Sans", "Jakarta Fallback", Arial, sans-serif;
}

*, *::before, *::after { box-sizing: border-box; }
html { background: var(--logo-ink); -webkit-text-size-adjust: 100%; color-scheme: dark; }
body {
  margin: 0;
  min-height: 100svh;
  background: var(--logo-ink);
  color: var(--logo-cream);
  font-family: var(--f-body);
  font-size: 1rem;
  line-height: 1.4;
  overflow-x: hidden;
}
img { display: block; max-width: 100%; height: auto; }
.sr-only { position: absolute; width: 1px; height: 1px; margin: -1px; padding: 0; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; border: 0; }

/* ---------- the CRT ---------- */
.crt {
  position: relative;
  min-height: 100svh;
  background: radial-gradient(ellipse 80% 55% at 50% 30%, rgba(97, 48, 146, 0.55) 0%, rgba(97, 48, 146, 0) 70%), radial-gradient(ellipse 80% 55% at 50% 30%, var(--arcade-purple) 0%, var(--arcade-purple) 45%, var(--logo-ink) 100%);
}
/* scanlines + vignette, above everything, never intercept input */
.crt::after {
  content: "";
  position: fixed;
  inset: 0;
  z-index: 10;
  pointer-events: none;
  background:
    repeating-linear-gradient(to bottom, rgba(35,20,60,0) 0 2px, rgba(35,20,60,0.13) 2px 3px),
    radial-gradient(ellipse at center, rgba(35,20,60,0) 62%, rgba(35,20,60,0.5) 100%);
  animation: flick 11s steps(1, end) 1.4s infinite;
}
/* CRT power-on: an overlay (not an animation on the page itself, so the real content paints immediately) */
.boot { position: fixed; inset: 0; z-index: 20; pointer-events: none; animation: boot-gone 0.9s steps(1, end) both; }
.boot::before, .boot::after { content: ""; position: absolute; left: 0; right: 0; height: 50%; background: var(--logo-ink); }
.boot::before { top: 0; animation: open-up 0.9s steps(7, end) both; }
.boot::after { bottom: 0; animation: open-down 0.9s steps(7, end) both; }
.boot i { position: absolute; left: 0; right: 0; top: calc(50% - 2px); height: 4px; background: var(--pixel-white); box-shadow: 0 0 18px 4px var(--bubblegum-pink); animation: line 0.9s steps(6, end) both; }
@keyframes open-up   { 0%, 35% { transform: none; } 100% { transform: translateY(-101%); } }
@keyframes open-down { 0%, 35% { transform: none; } 100% { transform: translateY(101%); } }
@keyframes line { 0% { transform: scaleX(0); opacity: 1; } 30% { transform: scaleX(1); opacity: 1; } 60% { opacity: 1; } 100% { transform: scaleX(1); opacity: 0; } }
@keyframes boot-gone { 0%, 99% { visibility: visible; } 100% { visibility: hidden; } }
@keyframes flick {
  0%, 100% { opacity: 1; }
  41%, 43% { opacity: 0.8; }
  42% { opacity: 1; }
  77% { opacity: 0.7; }
  78% { opacity: 1; }
}

.cab {
  width: min(100%, 780px);
  min-height: 100svh;
  margin: 0 auto;
  padding: 12px 16px 20px;
  display: grid;
  grid-template-columns: minmax(0, 1fr);
  grid-template-rows: auto auto minmax(200px, 1fr) auto;
  align-content: center;
  gap: 10px;
  justify-items: center;
}

/* ---------- HUD ---------- */
.hud {
  width: 100%;
  display: grid;
  grid-template-columns: 1fr auto 1fr;
  align-items: center;
  gap: 8px;
  min-height: 32px;
  font-family: var(--f-ui);
  font-weight: 700;
  font-size: 0.8125rem;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  white-space: nowrap;
}
.hud, .line, .load-t { position: relative; z-index: 11; }
.hud-l { color: var(--arcade-yellow); justify-self: start; }
.hud-c { color: var(--logo-blush); justify-self: center; animation: blink 1s steps(1, end) infinite; }
.hud-c.go { animation: none; color: var(--arcade-yellow); }
@keyframes blink { 0%, 55% { opacity: 1; } 56%, 100% { opacity: 0; } }

.motion {
  justify-self: end;
  padding: 6px 8px;
  background: transparent;
  color: var(--logo-cream);
  font: inherit;
  letter-spacing: inherit;
  text-transform: inherit;
  border: 2px solid var(--logo-lilac);
  cursor: pointer;
}
.motion:hover { background: var(--logo-purple); color: var(--pixel-white); }
.motion:focus-visible, .btn:focus-visible, .field:has(#game:focus-visible) { outline: 3px solid var(--arcade-yellow); outline-offset: 3px; }
#game:focus-visible { outline: none; }
.motion[hidden] { display: none; }

/* ---------- logo ---------- */
.logo {
  position: relative;
  margin: 14px 0 12px;
  width: min(58vw, 220px);
  aspect-ratio: 540 / 494;
  animation: float 3.6s ease-in-out infinite;
}
.logo img { width: 100%; filter: drop-shadow(0 0 14px rgba(241, 139, 168, 0.45)); }
@keyframes float { 0%, 100% { transform: translateY(5px); } 50% { transform: translateY(-5px); } }

.sparks i {
  position: absolute;
  width: var(--s, 14px);
  height: var(--s, 14px);
  left: var(--x);
  top: var(--y);
  background: var(--c, var(--pixel-white));
  clip-path: polygon(40% 0, 60% 0, 60% 40%, 100% 40%, 100% 60%, 60% 60%, 60% 100%, 40% 100%, 40% 60%, 0 60%, 0 40%, 40% 40%);
  animation: twinkle 2.4s steps(1, end) var(--d, 0s) infinite;
}
@keyframes twinkle { 0%, 100% { opacity: 1; transform: scale(1); } 30% { opacity: 0.25; transform: scale(0.6); } 55% { opacity: 1; transform: scale(1.25); } 80% { opacity: 0.5; transform: scale(0.8); } }
.sparks i:nth-child(1) { --x: -14%; --y: 8%;   --s: 16px; --c: var(--pixel-white);    --d: 0s; }
.sparks i:nth-child(2) { --x: 100%; --y: 2%;   --s: 12px; --c: var(--bubblegum-pink); --d: -0.6s; }
.sparks i:nth-child(3) { --x: -22%; --y: 58%;  --s: 10px; --c: var(--arcade-yellow);  --d: -1.2s; }
.sparks i:nth-child(4) { --x: 104%; --y: 52%;  --s: 18px; --c: var(--logo-blush);     --d: -0.3s; }
.sparks i:nth-child(5) { --x: 8%;   --y: -6%; --s: 10px; --c: var(--neon-citrus);    --d: -1.8s; }
.sparks i:nth-child(6) { --x: 84%;  --y: 90%;  --s: 12px; --c: var(--pixel-white);    --d: -0.9s; }
.sparks i:nth-child(7) { --x: 34%;  --y: 98%; --s: 10px; --c: var(--pandan-green);   --d: -1.5s; }
.sparks i:nth-child(8) { --x: 64%;  --y: -8%; --s: 14px; --c: var(--logo-lilac);     --d: -2.1s; }

/* ---------- playfield ---------- */
.field {
  position: relative;
  width: 100%;
  min-height: 200px;
  max-height: 360px;
  border: 4px solid var(--logo-lilac);
  background: rgba(35, 20, 60, 0.78);
  box-shadow: inset 0 0 0 4px var(--logo-ink);
  overflow: hidden;
}
#game { position: absolute; inset: 0; width: 100%; height: 100%; image-rendering: pixelated; cursor: crosshair; touch-action: manipulation; -webkit-tap-highlight-color: transparent; }

.levelup {
  position: absolute;
  left: 50%;
  top: 50%;
  translate: -50% -50%;
  display: grid;
  justify-items: center;
  gap: 2px;
  padding: 10px 16px;
  background: var(--logo-ink);
  border: 3px solid var(--arcade-yellow);
  text-align: center;
  pointer-events: none;
  white-space: nowrap;
  animation: lvl 0.5s steps(5, end) both;
}
.levelup strong { font-family: var(--f-title); font-weight: 400; font-size: clamp(2.5rem, 11vw, 3.75rem); line-height: 0.9; color: var(--arcade-yellow); text-shadow: 3px 3px 0 var(--logo-magenta); letter-spacing: 0.02em; }
.levelup span { font-family: var(--f-ui); font-weight: 700; font-size: 0.8125rem; letter-spacing: 0.1em; color: var(--logo-cream); }
.levelup[hidden] { display: none; }
.levelup.bye { opacity: 0; transition: opacity 0.4s steps(4, end); }
@keyframes lvl { 0% { transform: scale(0.2); opacity: 0; } 60% { transform: scale(1.18); opacity: 1; } 100% { transform: scale(1); } }

/* ---------- copy ---------- */
.copy { display: grid; justify-items: center; gap: 8px; width: 100%; text-align: center; }

.title {
  margin: 0;
  height: 1em;
  font-family: var(--f-title);
  font-weight: 400;
  font-size: clamp(3.25rem, 15.5vw, 4.5rem);
  line-height: 1;
  letter-spacing: 0.02em;
  white-space: nowrap;
  color: var(--logo-cream);
  text-shadow: 4px 4px 0 var(--logo-magenta), 0 0 22px rgba(241, 139, 168, 0.5);
  animation: swap 7s steps(1, end) infinite;
}
.cur { animation: blink 1.1s steps(1, end) infinite; }
@keyframes swap {
  0%   { text-shadow: 4px 4px 0 var(--logo-magenta), 0 0 22px rgba(241,139,168,.5); }
  25%  { text-shadow: 4px 4px 0 var(--logo-lilac), 0 0 22px rgba(146,92,161,.7); }
  50%  { text-shadow: 4px 4px 0 var(--bubblegum-pink), 0 0 22px rgba(241,139,168,.6); }
  75%  { text-shadow: 4px 4px 0 var(--logo-purple), 0 0 22px rgba(97,48,146,.8); }
}
.line { margin: 0; min-height: 1.4em; font-size: 0.9375rem; font-weight: 500; color: var(--logo-blush); white-space: nowrap; }

/* loading bar */
.load { width: min(100%, 360px); display: grid; gap: 6px; }
.load-t { display: block; height: 1.2em; font-family: var(--f-ui); font-weight: 700; font-size: 0.8125rem; letter-spacing: 0.08em; color: var(--logo-blush); white-space: nowrap; text-align: left; }
.bar { display: block; position: relative; height: 18px; border: 3px solid var(--logo-lilac); background: var(--logo-ink); padding: 2px; }
.fill {
  display: block;
  height: 100%;
  width: calc(var(--p, 87) * 1%);
  background: repeating-linear-gradient(to right, var(--bubblegum-pink) 0 8px, transparent 8px 10px);
}
.load.glitch .bar { animation: glitch 0.5s steps(1, end); }
.load.glitch .load-t { animation: glitch-t 0.5s steps(1, end); color: var(--neon-citrus); }
.load.glitch .fill { background: repeating-linear-gradient(to right, var(--neon-citrus) 0 8px, transparent 8px 10px); }
@keyframes glitch {
  0% { transform: translate(-4px, 0); } 20% { transform: translate(5px, 1px); } 40% { transform: translate(-3px, -1px); }
  60% { transform: translate(6px, 0); } 80% { transform: translate(-5px, 1px); } 100% { transform: none; }
}
@keyframes glitch-t { 0%, 40%, 80% { transform: translateX(3px); } 20%, 60%, 100% { transform: translateX(-3px); } }

/* the button */
.btn {
  display: inline-block;
  margin-top: 6px;
  padding: 14px 24px;
  background: var(--bubblegum-pink);
  color: var(--logo-ink);
  font-family: var(--f-ui);
  font-weight: 700;
  font-size: 1rem;
  line-height: 1.2;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  text-decoration: none;
  white-space: nowrap;
  border: 3px solid var(--logo-cream);
  box-shadow: 4px 4px 0 var(--logo-magenta);
  transition: transform 0.1s steps(2, end), box-shadow 0.1s steps(2, end), background-color 0.1s steps(2, end);
}
.btn:hover { background: var(--arcade-yellow); transform: translate(-2px, -2px); box-shadow: 6px 6px 0 var(--logo-magenta); }
.btn:active { transform: translate(4px, 4px); box-shadow: 0 0 0 var(--logo-magenta); }
.btn.hot { animation: pulse 0.9s steps(1, end) infinite; background: var(--neon-citrus); }
@keyframes pulse {
  0%   { box-shadow: 4px 4px 0 var(--logo-magenta), 0 0 0 0 rgba(204,255,0,0.9); }
  50%  { box-shadow: 4px 4px 0 var(--logo-magenta), 0 0 0 8px rgba(204,255,0,0.35); }
}

/* ---------- narrow phones ---------- */
@media (max-width: 359px) {
  .line { white-space: normal; min-height: 2.8em; }
  .hud { font-size: 0.6875rem; letter-spacing: 0.04em; }
  .btn { padding: 12px 16px; font-size: 0.9375rem; }
  .title { font-size: 3rem; }
}

/* short portrait phones (e.g. 320x568): keep the button on the first screen */
@media (max-height: 660px) and (max-width: 899px) and (orientation: portrait) {
  .cab { gap: 6px; padding-top: 8px; padding-bottom: 12px; grid-template-rows: auto auto minmax(120px, 1fr) auto; }
  .logo { width: min(34vw, 130px); margin: 8px 0 6px; }
  .field { min-height: 120px; }
  .title { font-size: 2.75rem; }
  .copy { gap: 4px; }
  .btn { padding: 10px 18px; margin-top: 2px; }
}

/* ---------- desktop: logo + headline band on top, a big play area below ---------- */
@media (min-width: 900px) {
  .cab {
    width: min(100%, 1500px);
    padding: 14px 24px 22px;
    grid-template-columns: 1fr auto auto 1fr;
    grid-template-rows: auto auto minmax(260px, 1fr);
    column-gap: 48px;
    row-gap: 12px;
    justify-items: stretch;
    align-content: stretch;
  }
  .hud { grid-column: 1 / -1; grid-row: 1; font-size: 0.9375rem; }
  .logo { grid-column: 2; grid-row: 2; width: clamp(240px, 37svh, 400px); margin: 4px 0; justify-self: center; align-self: center; }
  .copy { grid-column: 3; grid-row: 2; grid-template-columns: auto auto; justify-items: start; align-items: center; text-align: left; column-gap: 24px; row-gap: 8px; width: auto; align-self: center; }
  .title, .line { grid-column: 1 / -1; }
  .title { font-size: clamp(4.75rem, 14.5svh, 8rem); height: 1em; }
  .line { font-size: clamp(1.125rem, 2.4svh, 1.5rem); }
  .load { width: 340px; }
  .load-t { font-size: 0.875rem; }
  .btn { margin-top: 0; }
  .field { grid-column: 1 / -1; grid-row: 3; max-height: none; min-height: 260px; }
  .levelup strong { font-size: 5rem; }
  .levelup span { font-size: 1rem; }
}
@media (min-width: 900px) and (max-width: 1199px) {
  .cab { column-gap: 28px; }
  .logo { width: clamp(180px, 26svh, 240px); }
  .copy { grid-template-columns: auto; justify-items: start; }
  .title { font-size: clamp(3.75rem, 9vw, 5.5rem); }
  .line { font-size: 1.0625rem; }
  .load { width: min(340px, 100%); }
  .btn { margin-top: 4px; }
}
@media (min-width: 900px) and (max-height: 760px) {
  .logo { width: clamp(150px, 28svh, 220px); }
  .title { font-size: 4.5rem; }
}

/* ---------- calm: OS reduced-motion OR the visitor's own pause. Static look, the game still works by tapping. ---------- */
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation: none !important; transition: none !important; }
  .boot { display: none; }
}
:root.still *, :root.still *::before, :root.still *::after { animation: none !important; transition: none !important; }
:root.still .boot { display: none; }
