/* ---------------------------------------------------------------------------
   Site chrome. Colours, type scale, button shapes and spacing are taken from
   the live tesla.com: white ground, #393C41 body copy, #171A20 ink, the
   #3E6AE1 primary action, 4px corners, 14px/500 UI text, generous whitespace.
   The pixel art stays inside the game frame — the page itself is not pixelated.
--------------------------------------------------------------------------- */
:root {
  --white: #fff;
  --ink: #171a20;
  --text: #393c41;
  --muted: #5c5e62;
  --line: #e3e4e6;
  --grey-bg: #f4f4f4;
  --blue: #3e6ae1;
  --blue-hi: #3457b1;
  --red: #e82127;
  --nav-h: 56px;
  --pad: clamp(20px, 5vw, 64px);
  --font: "Inter", -apple-system, BlinkMacSystemFont, "Segoe UI", Helvetica, Arial, sans-serif;
}

* { box-sizing: border-box; }

html { scroll-behavior: smooth; }

body {
  margin: 0;
  font-family: var(--font);
  font-size: 14px;
  font-weight: 400;
  color: var(--text);
  background: var(--white);
  -webkit-font-smoothing: antialiased;
}

img { max-width: 100%; }

h1, h2, h3 { font-weight: 500; letter-spacing: -0.01em; color: var(--ink); margin: 0; }

/* ------------------------------------------------------------------- nav */
.nav {
  position: fixed;
  inset: 0 0 auto 0;
  height: var(--nav-h);
  /* Three tracks, not space-between: the wordmark and the profile button are
     different widths, so flex pushed the link row off centre. */
  display: grid;
  grid-template-columns: 1fr auto 1fr;
  align-items: center;
  padding: 0 var(--pad);
  z-index: 60;
  transition: background .28s ease, box-shadow .28s ease;
}
.nav.solid {
  background: rgba(255, 255, 255, .92);
  backdrop-filter: saturate(160%) blur(14px);
  box-shadow: 0 1px 0 rgba(0, 0, 0, .06);
}
.wordmark {
  font-size: 15px;
  font-weight: 600;
  letter-spacing: .34em;
  color: var(--ink);
  text-decoration: none;
  white-space: nowrap;
  justify-self: start;
  /* Tracking adds a trailing gap after the last letter; pull it back so the
     mark sits flush with the page margin. */
  margin-right: -.34em;
}
.wordmark span { font-weight: 400; opacity: .55; margin-left: .22em; }
.nav-links { display: flex; gap: 4px; justify-self: center; }
.nav-right { justify-self: end; }
.nav-links a, .nav-cta {
  font-size: 14px;
  font-weight: 500;
  color: var(--ink);
  text-decoration: none;
  padding: 6px 16px;
  border-radius: 4px;
  transition: background .18s ease;
  white-space: nowrap;
}
.nav-links a:hover, .nav-cta:hover { background: rgba(0, 0, 0, .05); }
.nav-cta { background: rgba(0, 0, 0, .05); }
@media (max-width: 780px) { .nav-links { display: none; } }

/* --------------------------------------------------------------- buttons */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 254px;
  height: 40px;
  padding: 0 24px;
  border: 0;
  border-radius: 4px;
  font-family: var(--font);
  font-size: 14px;
  font-weight: 500;
  text-decoration: none;
  cursor: pointer;
  transition: background .18s ease, color .18s ease, transform .12s ease;
}
.btn:active { transform: translateY(1px); }
.btn-primary { background: var(--blue); color: #fff; }
.btn-primary:hover { background: var(--blue-hi); }
.btn-ghost { background: rgba(255, 255, 255, .88); color: var(--ink); }
.btn-ghost:hover { background: #fff; }
@media (max-width: 640px) { .btn { min-width: min(84vw, 300px); } }

@media (max-width: 640px) {
  .hero { padding-bottom: 52px; }
  .hero-actions { flex-direction: column; }
}

/* ------------------------------------------------------------------ hero */
.hero {
  position: relative;
  min-height: 100svh;
  display: flex;
  flex-direction: column;
  /* Copy and buttons ride together in the middle of the block; the padding
     accounts for the fixed header so the group is optically centred. */
  justify-content: center;
  gap: clamp(24px, 5vh, 56px);
  align-items: center;
  padding: calc(var(--nav-h) + 24px) var(--pad) 24px;
  text-align: center;
  /* Hero only. The rest of the page keeps its flat surfaces. */
  background-color: #e6e8eb;
  background-image: url('assets/site/background.png');
  /* Framed 135% tall from the top so the cat in the photograph sits clear
     below the copy instead of under the wordmark. The max() keeps it covering
     on any window shape: the first term guards wide windows, the second tall
     ones. */
  background-size: max(135%, 240vh) auto;
  background-position: center top;
  background-repeat: no-repeat;
  overflow: hidden;
}
/* One wash along the top only, so the fixed header stays readable against the
   dark storefront. The rest of the art is left alone. */
.hero::before {
  content: '';
  position: absolute;
  inset: 0 0 auto 0;
  height: 34%;
  background: linear-gradient(to bottom,
    rgba(255, 255, 255, .9) 0%,
    rgba(255, 255, 255, .5) 20%,
    rgba(255, 255, 255, 0) 100%);
  pointer-events: none;
}
.hero > * { position: relative; z-index: 1; }

.eyebrow {
  margin: 0 0 12px;
  font-size: 12px;
  font-weight: 500;
  letter-spacing: .18em;
  text-transform: uppercase;
  color: var(--ink);
}

/* The game identity: a pixel display face used for the wordmark only, never for
   interface text. Tight leading stacks it into a logo block. */
.wordmark-title {
  margin: 0;
  font-family: "Pixelify Sans", "Inter", sans-serif;
  font-weight: 700;
  font-size: clamp(26px, 4.4vw, 64px);
  line-height: 1;
  color: var(--ink);
  display: flex;
  flex-direction: row;
  justify-content: center;
  gap: .3em;
  white-space: nowrap;
}
.wt-line { display: block; }
.wt-accent { color: var(--red); }

.lede {
  margin: 14px 0 0;
  font-size: clamp(15px, 1.5vw, 19px);
  color: var(--muted);
}

.hero-actions { display: flex; gap: 16px; flex-wrap: wrap; justify-content: center; }
.scroll-cue {
  position: absolute;
  bottom: 14px; left: 50%;
  width: 14px; height: 14px;
  margin-left: -7px;
  border-right: 1.5px solid var(--muted);
  border-bottom: 1.5px solid var(--muted);
  transform: rotate(45deg);
  animation: cue 2.2s ease-in-out infinite;
  z-index: 1;
}
@keyframes cue {
  0%, 100% { opacity: .35; transform: rotate(45deg) translate(0, 0); }
  50% { opacity: .9; transform: rotate(45deg) translate(3px, 3px); }
}

/* --------------------------------------------------------------- section */
.section-head { text-align: center; max-width: 620px; margin: 0 auto 34px; }
.section-head h2 { font-size: clamp(26px, 3.4vw, 40px); }
.section-head p { margin: 12px 0 0; color: var(--muted); font-size: 15px; }

.stage-section { padding: clamp(56px, 9vh, 104px) var(--pad) clamp(40px, 7vh, 72px); background: var(--white); }
.light-section { padding: clamp(56px, 9vh, 104px) var(--pad); background: var(--grey-bg); }
.dark-section { padding: clamp(56px, 9vh, 104px) var(--pad); background: var(--ink); }
.dark-section .section-head h2 { color: #fff; }
.dark-section .section-head p { color: #9ea1a6; }

/* ----------------------------------------------------------- game frame */
.frame {
  max-width: 1180px;
  margin: 0 auto;
  border-radius: 10px;
  background: #0d0f12;
  box-shadow: 0 24px 70px -28px rgba(15, 18, 24, .55), 0 1px 0 rgba(255, 255, 255, .06) inset;
  overflow: hidden;
}
.frame-inner {
  position: relative;
  aspect-ratio: 16 / 9;
  width: 100%;
}
/* Fullscreen is requested on the frame, not the canvas, so the DOM HUD, the
   banner and the overlays all come with it. */
.frame:fullscreen,
.frame:-webkit-full-screen {
  max-width: none;
  width: 100vw;
  height: 100vh;
  border-radius: 0;
  display: grid;
  place-items: center;
  background: #05070a;
}
.frame:fullscreen .frame-inner,
.frame:-webkit-full-screen .frame-inner {
  width: min(100vw, calc(100vh * 16 / 9));
  height: min(100vh, calc(100vw * 9 / 16));
}
/* Fallback for browsers that refuse the Fullscreen API: the frame is pinned
   over the viewport instead. Same look, same animation. */
.frame.is-maximised {
  position: fixed;
  inset: 0;
  z-index: 200;
  max-width: none;
  width: 100vw;
  height: 100vh;
  border-radius: 0;
  display: grid;
  place-items: center;
  background: #05070a;
}
.frame.is-maximised .frame-inner {
  width: min(100vw, calc(100vh * 16 / 9));
  height: min(100vh, calc(100vw * 9 / 16));
}
body.fs-lock { overflow: hidden; }

/* The swap between the two sizes is animated rather than snapping. */
.frame-inner { transition: width .34s cubic-bezier(.4, 0, .2, 1), height .34s cubic-bezier(.4, 0, .2, 1); }
.frame.fs-anim .frame-inner { animation: fs-in .42s cubic-bezier(.2, .8, .3, 1); }
@keyframes fs-in {
  0% { opacity: .35; transform: scale(.965); }
  60% { opacity: 1; }
  100% { opacity: 1; transform: scale(1); }
}

#game-canvas { position: absolute; inset: 0; }
#game-canvas canvas {
  display: block;
  width: 100% !important;
  height: 100% !important;
  image-rendering: pixelated;
  image-rendering: crisp-edges;
}

/* ------------------------------------------------------------------- hud */
.hud {
  position: absolute;
  inset: 0 0 auto 0;
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 16px;
  padding: clamp(10px, 1.6vw, 18px) clamp(12px, 2vw, 22px);
  pointer-events: none;
  opacity: 0;
  transition: opacity .4s ease;
}
body.game-ready .hud { opacity: 1; }
.hud.shake { animation: hudshake .3s ease; }
@keyframes hudshake { 25% { transform: translateX(-3px); } 75% { transform: translateX(3px); } }

.hud-left, .hud-right { flex: 0 0 auto; }
.hud-left { display: flex; align-items: center; gap: 10px; }
.hud-face {
  image-rendering: pixelated;
  filter: drop-shadow(0 2px 6px rgba(0, 0, 0, .45));
}
.hud-stack { display: flex; flex-direction: column; gap: calc(2px * var(--z, 2)); }

/* The supplied HUD bars, sliced into icon / track / fill. Everything renders at
   a whole-number zoom so the pixels line up with the game canvas. */
.pxbar { display: flex; align-items: center; gap: calc(3px * var(--z, 2)); }
.pxbar img { display: block; image-rendering: pixelated; }
.pxbar-rail { position: relative; display: block; line-height: 0; }
.pxbar-fill {
  position: absolute;
  left: 0;
  top: 0;
  transition: clip-path .14s linear;
}
.pxbar-boss { justify-content: center; }

.hud-mid {
  text-align: center;
  display: flex;
  flex-direction: column;
  gap: 5px;
  min-width: 0;
  flex: 1 1 auto;
  max-width: 42%;
  padding-top: 2px;
}
.hud-mid > span { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.hud-room {
  font-size: 11px;
  font-weight: 600;
  letter-spacing: .2em;
  text-transform: uppercase;
  color: #fff;
  text-shadow: 0 1px 6px rgba(0, 0, 0, .7);
}
.hud-objective {
  font-size: 12px;
  color: rgba(255, 255, 255, .74);
  text-shadow: 0 1px 6px rgba(0, 0, 0, .7);
}
@media (max-width: 720px) { .hud-objective { display: none; } }

/* Currency readout, plated to match the counter drawn on the source sheet. */
.hud-right { display: flex; flex-direction: column; align-items: flex-end; gap: 5px; }
.coin-plate {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: calc(2px * var(--z, 2)) calc(6px * var(--z, 2)) calc(2px * var(--z, 2)) calc(4px * var(--z, 2));
  border-radius: calc(4px * var(--z, 2));
  background: #262f3f;
  border: 2px solid #596577;
  box-shadow: 0 0 0 2px #080f17, 0 4px 12px rgba(0, 0, 0, .45);
}
.hud-coin { image-rendering: pixelated; }
.hud-coins {
  font-size: calc(11px * var(--z, 2));
  font-weight: 500;
  color: #fff;
  font-variant-numeric: tabular-nums;
  line-height: 1;
}
.hud-coins.bump { animation: bump .28s cubic-bezier(.3, 1.6, .5, 1); }
@keyframes bump { 0% { transform: scale(1); } 40% { transform: scale(1.22); color: #ff5a5a; } 100% { transform: scale(1); } }
.hud-coins-label {
  font-size: 10px;
  font-weight: 500;
  letter-spacing: .16em;
  text-transform: uppercase;
  color: rgba(255, 255, 255, .55);
}
.hud-dash {
  image-rendering: pixelated;
  opacity: .3;
  transition: opacity .18s ease, filter .18s ease;
}
.hud-dash.ready { opacity: 1; filter: drop-shadow(0 0 5px rgba(110, 175, 255, .8)); }

/* --------------------------------------------------------------- boss bar */
.boss-bar {
  position: absolute;
  left: 50%;
  bottom: 54px;
  transform: translateX(-50%);
  text-align: center;
  pointer-events: none;
}
.boss-name {
  display: block;
  font-size: 10px;
  font-weight: 600;
  letter-spacing: .24em;
  text-transform: uppercase;
  color: #fff;
  margin-bottom: 6px;
  text-shadow: 0 1px 6px rgba(0, 0, 0, .8);
}

/* ------------------------------------------------------------ fullscreen */
.fs-btn {
  position: absolute;
  right: clamp(10px, 1.4vw, 16px);
  bottom: clamp(10px, 1.4vw, 16px);
  width: 34px;
  height: 34px;
  display: grid;
  place-items: center;
  padding: 0;
  border: 1px solid rgba(255, 255, 255, .18);
  border-radius: 4px;
  background: rgba(13, 15, 18, .55);
  backdrop-filter: blur(6px);
  cursor: pointer;
  opacity: 0;
  transition: opacity .25s ease, background .18s ease, border-color .18s ease;
  z-index: 20;
}
body.game-ready .fs-btn { opacity: .55; }
.frame:hover .fs-btn, .fs-btn:focus-visible { opacity: 1; }
.fs-btn:hover { background: rgba(13, 15, 18, .8); border-color: rgba(255, 255, 255, .34); }

/* Four corner brackets drawn in one element; they pull inward when exiting. */
.fs-icon {
  position: relative;
  width: 15px;
  height: 15px;
  transition: transform .28s cubic-bezier(.4, 0, .2, 1);
}
.fs-icon::before, .fs-icon::after {
  content: '';
  position: absolute;
  width: 5px;
  height: 5px;
  border: 2px solid #fff;
}
.fs-icon::before { top: 0; left: 0; border-right: 0; border-bottom: 0; }
.fs-icon::after { right: 0; bottom: 0; border-left: 0; border-top: 0; }
.frame.is-fs .fs-icon { transform: rotate(180deg); }

/* --------------------------------------------------------------- caption */
.caption {
  position: absolute;
  left: 50%;
  bottom: 18px;
  transform: translate(-50%, 8px);
  padding: 7px 16px;
  border-radius: 4px;
  background: rgba(13, 15, 18, .72);
  backdrop-filter: blur(6px);
  color: #fff;
  font-size: 12px;
  font-weight: 500;
  letter-spacing: .06em;
  white-space: nowrap;
  opacity: 0;
  pointer-events: none;
  transition: opacity .2s ease, transform .2s ease;
}
.caption.show { opacity: 1; transform: translate(-50%, 0); }

/* ---------------------------------------------------------------- banner */
.banner {
  position: absolute;
  left: 50%;
  top: 34%;
  transform: translate(-50%, -50%) scale(.96);
  text-align: center;
  pointer-events: none;
  opacity: 0;
  transition: opacity .35s ease, transform .35s ease;
}
.banner.show { opacity: 1; transform: translate(-50%, -50%) scale(1); }
.banner-title {
  font-size: clamp(20px, 3vw, 34px);
  font-weight: 500;
  letter-spacing: .16em;
  color: #fff;
  text-shadow: 0 2px 18px rgba(0, 0, 0, .8);
}
.banner-sub {
  margin-top: 6px;
  font-size: 12px;
  letter-spacing: .1em;
  color: rgba(255, 255, 255, .72);
  text-shadow: 0 1px 10px rgba(0, 0, 0, .8);
}

/* --------------------------------------------------------------- overlay */
/* End-of-run panels are part of the game, not the website, so they are built
   from the same plate the supplied HUD art uses: dark fill, light bevel, hard
   outline — and the run's title set in the pixel display face. */
.overlay {
  position: absolute;
  inset: 0;
  display: grid;
  place-items: center;
  background: rgba(8, 10, 14, .7);
  opacity: 0;
  pointer-events: none;
  transition: opacity .28s ease;
}
.overlay.show { opacity: 1; pointer-events: auto; }
.overlay-card {
  width: min(400px, 86%);
  padding: 26px 26px 22px;
  background: #262f3f;
  border: 2px solid #596577;
  box-shadow: 0 0 0 2px #080f17, 0 24px 60px -18px rgba(0, 0, 0, .8);
  text-align: center;
  transform: translateY(10px) scale(.97);
  opacity: 0;
  transition: transform .34s cubic-bezier(.2, .9, .3, 1), opacity .28s ease;
}
.overlay.show .overlay-card { transform: none; opacity: 1; }

.overlay-face {
  image-rendering: pixelated;
  display: block;
  margin: 0 auto 14px;
  filter: drop-shadow(0 3px 0 rgba(0, 0, 0, .35));
}
.overlay-card h3 {
  font-family: "Pixelify Sans", "Inter", sans-serif;
  font-weight: 700;
  font-size: clamp(22px, 2.4vw, 30px);
  line-height: 1;
  letter-spacing: .02em;
  text-transform: uppercase;
  color: #fff;
}
.overlay.lose .overlay-card h3 { color: #ff5a5a; }
.overlay.win .overlay-card h3 { color: #6ec1ff; }
.overlay-card p {
  margin: 12px 0 20px;
  color: #aeb6c2;
  font-size: 13px;
  line-height: 1.55;
}

/* A pixel-panel button to match: square corners, hard bevel, no gradient. */
.btn-pixel {
  min-width: 100%;
  height: 40px;
  border: 2px solid #7d8ea8;
  border-radius: 0;
  background: #3e6ae1;
  color: #fff;
  font-family: "Pixelify Sans", "Inter", sans-serif;
  font-size: 17px;
  font-weight: 600;
  letter-spacing: .06em;
  text-transform: uppercase;
  box-shadow: 0 0 0 2px #080f17, 0 3px 0 #22357a;
  transition: background .16s ease, transform .1s ease, box-shadow .1s ease;
}
.btn-pixel:hover { background: #4d78ee; }
.btn-pixel:active {
  transform: translateY(2px);
  box-shadow: 0 0 0 2px #080f17, 0 1px 0 #22357a;
}

/* --------------------------------------------------------------- loading */
.loading {
  position: absolute;
  inset: 0;
  display: grid;
  place-items: center;
  align-content: center;
  gap: 14px;
  background: #0d0f12;
  color: #8d9096;
  font-size: 11px;
  letter-spacing: .22em;
  text-transform: uppercase;
  transition: opacity .5s ease;
}
body.game-ready .loading { opacity: 0; pointer-events: none; }
.load-track { width: 180px; height: 2px; background: rgba(255, 255, 255, .14); border-radius: 2px; overflow: hidden; }
.load-track span { display: block; height: 100%; width: 0; background: var(--blue); transition: width .2s ease; }

/* -------------------------------------------------------------- controls */
.controls {
  max-width: 1180px;
  margin: 26px auto 0;
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  gap: 10px 26px;
}
.ctl { display: flex; align-items: center; gap: 9px; font-size: 13px; color: var(--muted); }
.keycap {
  display: inline-flex;
  align-items: center;
  height: 24px;
  padding: 0 9px;
  border-radius: 4px;
  border: 1px solid var(--line);
  background: #fafafa;
  font-size: 11px;
  font-weight: 600;
  letter-spacing: .08em;
  color: var(--ink);
}

/* ------------------------------------------------------------------ grid */
.grid {
  max-width: 1180px;
  margin: 0 auto;
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(232px, 1fr));
  gap: 14px;
}
.grid-tight { grid-template-columns: repeat(auto-fill, minmax(140px, 1fr)); }
.card {
  border-radius: 8px;
  background: #fff;
  border: 1px solid var(--line);
  padding: 18px 14px 14px;
  text-align: center;
  transition: transform .22s ease, box-shadow .22s ease;
}
.card:hover { transform: translateY(-3px); box-shadow: 0 14px 30px -18px rgba(0, 0, 0, .45); }
.dark-section .card { background: #1f2228; border-color: #2c3038; }
.card-art { height: 132px; display: grid; place-items: center; margin-bottom: 12px; }
.grid-tight .card-art { height: 96px; }
.card-art img { image-rendering: pixelated; max-width: 100%; }
.card-name { font-size: 13px; font-weight: 500; color: var(--ink); }
.dark-section .card-name { color: #fff; }
.card-meta { margin-top: 3px; font-size: 11px; letter-spacing: .1em; text-transform: uppercase; color: var(--muted); }
.dark-section .card-meta { color: #83878e; }

@media (prefers-reduced-motion: reduce) {
  * { animation: none !important; transition-duration: .01ms !important; }
  html { scroll-behavior: auto; }
}
