/* ============================================================
   UNSAFE CREDITS — brand system
   Palette, type and button behaviour follow the Unsafe.design
   style guide. Corner radius everywhere: 0px.
   ============================================================ */

/* Brand typeface, self-hosted — visitors don't have it installed. */
@font-face {
  font-family: "Alte Haas Grotesk";
  src: url("../fonts/Alte Haas Grotesk/AlteHaasGroteskRegular.ttf") format("truetype");
  font-weight: 400;
  font-style: normal;
  font-display: swap;
}

@font-face {
  font-family: "Alte Haas Grotesk";
  src: url("../fonts/Alte Haas Grotesk/AlteHaasGroteskBold.ttf") format("truetype");
  font-weight: 700;
  font-style: normal;
  font-display: swap;
}

:root {
  /* Primary */
  --red: #ff6622;
  --sand: #f5f2e9;
  --dark-brown: #382723;

  /* Accents */
  --yellow: #ffc857;
  --blue: #00a2b0;
  --dark-blue: #264653;
  --light-brown: #6d4e42;

  /* Neutrals */
  --n-950: #24221f;
  --n-800: #45443b;
  --n-700: #58584d;
  --n-600: #79766b;
  --n-400: #a9a79d;
  --n-300: #d6d5d1;
  --n-200: #e7e6e4;
  --n-100: #f5f5f4;
  --n-50: #fafaf9;

  /* Type */
  --font-body: "Alte Haas Grotesk", "Helvetica Neue", Helvetica, Arial, sans-serif;
  --font-mono: "Geist Mono", "SF Mono", "Courier New", monospace;
}

* {
  margin: 0;
  padding: 0;
  box-sizing: border-box;
  border-radius: 0;
}

html,
body {
  height: 100%;
}

body {
  background: var(--red);
  color: var(--sand);
  font-family: var(--font-body);
  font-size: 15px;
  letter-spacing: -0.04em;
  display: flex;
  flex-direction: column;
  align-items: center;
  /* dvh tracks the real visible height on mobile (the URL bar
     eats part of 100vh and pushes the footer below the fold). */
  min-height: 100vh;
  min-height: 100dvh;
  /* Logo pinned 40px from the top, credit 40px from the bottom;
     the stage floats in the middle of whatever's left. */
  padding: 40px clamp(12px, 2vw, 32px);
  /* Whole page is a tap target on touch screens — kill the
     double-tap-zoom delay. */
  touch-action: manipulation;
}

/* ---- unsafe.design logo, top centre ---- */
.site-logo {
  display: block;
  margin-bottom: 28px;
  line-height: 0;
}

.site-logo img {
  height: clamp(28px, 4vw, 40px);
  width: auto;
  image-rendering: pixelated;
}

.site-logo:focus-visible {
  outline: 2px solid var(--dark-brown);
  outline-offset: 4px;
}

/* ---- Labels (Geist Mono, caps, 12px, +2% LS) ---- */
.label {
  font-family: var(--font-mono);
  font-size: 12px;
  letter-spacing: 0.02em;
  text-transform: uppercase;
  color: var(--n-400);
}

/* ---- Layout around the stage ---- */
.stage-wrap {
  width: 100%;
  /* Centers the game window in the space between the logo and
     the crafted-by credit. */
  margin-block: auto;
}

.under-stage {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 10px 2px;
}

/* Page chrome sits on the orange field — primary sand. */
.under-stage .label {
  color: var(--sand);
}

/* ---- Stage / canvas ---- */
.stage {
  position: relative;
  width: 100%;
  aspect-ratio: 960 / 440;
  background: var(--n-950);
  border: 2px solid var(--dark-brown);
  overflow: hidden;
  user-select: none;
  -webkit-user-select: none;
  touch-action: manipulation;
}

#game {
  display: block;
  width: 100%;
  height: 100%;
  image-rendering: pixelated;
  image-rendering: crisp-edges;
}

/* ---- HUD ---- */
.hud {
  position: absolute;
  inset: 0 0 auto 0;
  display: flex;
  justify-content: space-between;
  padding: 14px 18px;
  pointer-events: none;
}

.hud-left,
.hud-right {
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.hud-right {
  text-align: right;
}

.hud-title {
  color: var(--sand);
}

.hud-credits {
  color: var(--yellow);
  font-size: 15px;
}

.hud-credits.is-hit {
  color: var(--red);
}

/* ---- Session-limit toast (death beat) ---- */
.limit-toast {
  position: absolute;
  left: 50%;
  top: 6%;
  transform: translateX(-50%);
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 4px;
  width: max-content;
  text-align: center;
  pointer-events: none;
  opacity: 0;
  /* Sits above the game-over overlay and stays there. */
  z-index: 5;
  /* Boxless — a soft shadow keeps it readable over the city. */
  text-shadow: 0 1px 10px rgba(0, 0, 0, 0.55);
}

.limit-toast.is-hidden {
  display: none;
}

.limit-toast.is-in {
  animation: toast-in 0.45s ease-out forwards;
}

@keyframes toast-in {
  from {
    opacity: 0;
    transform: translateX(-50%) translateY(10px);
  }
  to {
    opacity: 1;
    transform: translateX(-50%) translateY(0);
  }
}

/* Both lines in Alte Haas Grotesk — no mono here. */
.limit-toast-kicker {
  font-family: var(--font-body);
  font-size: 20px;
  letter-spacing: -0.04em;
  color: var(--red);
}

.limit-toast-sub {
  font-family: var(--font-body);
  font-size: 15px;
  letter-spacing: -0.04em;
  color: var(--n-300);
}

/* ---- Overlays ---- */
.overlay {
  position: absolute;
  inset: 0;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 18px;
  text-align: center;
  padding: 24px;
  background: color-mix(in srgb, var(--n-950) 82%, transparent);
  backdrop-filter: blur(1px);
}

.overlay.is-hidden {
  display: none;
}

/* The game-over screen leaves headroom for the session-limit
   toast that stays pinned above the heading. */
#screenOver {
  padding-top: 13%;
}

.overlay-kicker {
  color: var(--yellow);
}

.overlay-kicker--alert {
  color: var(--red);
}

.overlay-title {
  font-family: var(--font-body);
  font-weight: 400;
  font-size: clamp(40px, 8vw, 75px);
  letter-spacing: -0.04em;
  line-height: 1;
  color: var(--sand);
}

.overlay-title--over {
  color: var(--red);
}

.overlay-title--pause {
  font-size: 40px;
}

.overlay-copy {
  max-width: 420px;
  color: var(--n-300);
  line-height: 1.45;
}

.overlay-hint {
  color: var(--n-600);
}

/* ---- Game-over stats ---- */
.stats {
  display: flex;
  gap: 36px;
}

.stat {
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.stat b {
  font-family: var(--font-body);
  font-weight: 400;
  font-size: 24px;
  letter-spacing: -0.04em;
  color: var(--sand);
}

.stat b.is-highlight {
  color: var(--yellow);
}

/* ============================================================
   Buttons — [ WORK ] style.
   Bracket gap: 4px default → 8px hover → 2px pressed.
   ============================================================ */
.btn {
  --gap: 4px;
  appearance: none;
  background: none;
  border: none;
  cursor: pointer;
  font-family: var(--font-mono);
  font-size: 15px;
  letter-spacing: 0.02em;
  text-transform: uppercase;
  color: var(--sand);
  padding: 10px 6px;
}

.btn::before {
  content: "[";
  margin-right: var(--gap);
  transition: margin 0.14s ease;
  color: var(--n-400);
}

.btn::after {
  content: "]";
  margin-left: var(--gap);
  transition: margin 0.14s ease;
  color: var(--n-400);
}

/* Hover/press animate the bracket gap only — text colour never
   changes. */
.btn:hover {
  --gap: 8px;
}

.btn:active {
  --gap: 2px;
}

.btn:focus-visible {
  outline: 2px solid var(--blue);
  outline-offset: 2px;
}

/* ---- Small screens: the stage gets short, so the overlays
       tighten up to stay inside it. ---- */
@media (max-width: 640px) {
  body {
    padding-top: 24px;
  }

  .site-logo {
    margin-bottom: 16px;
  }

  .overlay {
    gap: 8px;
    padding: 10px;
  }

  .overlay-title {
    font-size: clamp(22px, 8vw, 34px);
  }

  .overlay-copy {
    font-size: 12px;
    line-height: 1.3;
    max-width: 300px;
  }

  .overlay-hint {
    display: none;
  }

  .btn {
    padding: 4px 6px;
  }

  .stats {
    gap: 18px;
  }

  .stat b {
    font-size: 16px;
  }

  .stat .label {
    font-size: 10px;
  }

  .hud {
    padding: 8px 10px;
  }

  .limit-toast {
    top: 4%;
    gap: 2px;
  }

  .limit-toast-kicker {
    font-size: 13px;
  }

  .limit-toast-sub {
    font-size: 11px;
  }
}

.btn--small {
  font-size: 12px;
  color: var(--sand);
}

.btn--small::before,
.btn--small::after {
  color: var(--sand);
}

/* ---- Crafted-by credit, 40px off the viewport bottom ---- */
.crafted {
  margin-top: 18px;
  font-family: var(--font-body);
  font-size: 15px;
  letter-spacing: -0.04em;
  color: var(--sand);
  text-align: center;
}

.crafted a {
  color: inherit;
  text-decoration: underline;
  text-underline-offset: 3px;
}

