/* ==========================================================================
   SUBWAY RUNNER — base design system + shell
   Component styles live in src/ui/ui.css (owned by the UI module).
   ========================================================================== */

@font-face {
  font-family: 'Bungee';
  src: url('./assets/fonts/bungee.woff2') format('woff2');
  font-weight: 400;
  font-style: normal;
  font-display: swap;
}
@font-face {
  font-family: 'Outfit';
  src: url('./assets/fonts/outfit-var.woff2') format('woff2-variations');
  font-weight: 100 900;
  font-style: normal;
  font-display: swap;
}

:root {
  /* palette — mirrors PAL in constants.js so UI and 3D read as one piece */
  --ink:        #0b0e1c;
  --ink-2:      #141a30;
  --ink-3:      #1e2643;
  --cream:      #fff4e2;
  --cream-dim:  #e8dcc6;
  --yellow:     #f7bc22;
  --yellow-hi:  #ffd964;
  --yellow-deep:#c98f0c;
  --red:        #e0392f;
  --red-deep:   #a82420;
  --cyan:       #35d8ff;
  --navy:       #2c3852;
  --green:      #7ec242;
  --violet:     #8b5cf6;

  /* semantic */
  --bg:         var(--ink);
  --fg:         var(--cream);
  --fg-dim:     rgba(255, 244, 226, 0.62);
  --accent:     var(--yellow);
  --accent-2:   var(--red);

  /* type */
  --font-display: 'Bungee', 'Arial Black', system-ui, sans-serif;
  --font-ui: 'Outfit', system-ui, -apple-system, 'Segoe UI', sans-serif;
  --font-num: 'Outfit', ui-monospace, 'SF Mono', Menlo, monospace;

  /* geometry */
  --r-sm: 8px;
  --r-md: 14px;
  --r-lg: 22px;
  --r-pill: 999px;

  /* elevation — chunky offset shadows, sticker-like */
  --sh-1: 0 2px 0 rgba(0, 0, 0, 0.45);
  --sh-2: 0 4px 0 rgba(0, 0, 0, 0.5), 0 10px 24px rgba(0, 0, 0, 0.35);
  --sh-3: 0 6px 0 rgba(0, 0, 0, 0.55), 0 18px 44px rgba(0, 0, 0, 0.45);
  --stroke: 0 0 0 3px rgba(11, 14, 28, 0.9);

  --ease-out: cubic-bezier(0.22, 1, 0.36, 1);
  --ease-spring: cubic-bezier(0.34, 1.56, 0.64, 1);

  --safe-t: env(safe-area-inset-top, 0px);
  --safe-b: env(safe-area-inset-bottom, 0px);
  --safe-l: env(safe-area-inset-left, 0px);
  --safe-r: env(safe-area-inset-right, 0px);
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  padding: 0;
  height: 100%;
  overflow: hidden;
  background: var(--ink);
  color: var(--fg);
  font-family: var(--font-ui);
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
  overscroll-behavior: none;
  touch-action: none;
}

#app {
  position: fixed;
  inset: 0;
  overflow: hidden;
}

#game {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  display: block;
  touch-action: none;
}

/* UI layer sits above the canvas and never eats pointer events unless a
   child explicitly opts in. */
#ui-layer {
  position: absolute;
  inset: 0;
  pointer-events: none;
  z-index: 10;
}
#ui-layer > * { pointer-events: none; }

/* --------------------------------------------------------------------------
   Boot screen
   -------------------------------------------------------------------------- */
#boot {
  position: absolute;
  inset: 0;
  z-index: 40;
  display: grid;
  place-items: center;
  background:
    radial-gradient(120% 90% at 50% 0%, #1b2547 0%, #0b0e1c 62%, #06080f 100%);
  transition: opacity 0.55s var(--ease-out), visibility 0.55s;
}
#boot.is-gone {
  opacity: 0;
  visibility: hidden;
  pointer-events: none;
}
.boot-inner { text-align: center; }
.boot-logo {
  font-family: var(--font-display);
  font-size: clamp(38px, 9vw, 76px);
  line-height: 0.86;
  letter-spacing: 0.01em;
  color: var(--yellow);
  text-shadow:
    0 4px 0 var(--red-deep),
    0 8px 0 rgba(0, 0, 0, 0.5),
    0 22px 50px rgba(247, 188, 34, 0.22);
  transform: rotate(-2.5deg);
}
.boot-logo span { color: var(--cream); text-shadow: 0 4px 0 rgba(0,0,0,.55), 0 8px 0 rgba(0,0,0,.4); }
.boot-bar {
  margin: 30px auto 12px;
  width: min(260px, 60vw);
  height: 7px;
  border-radius: var(--r-pill);
  background: rgba(255, 244, 226, 0.13);
  overflow: hidden;
}
.boot-bar i {
  display: block;
  height: 100%;
  width: 30%;
  border-radius: inherit;
  background: linear-gradient(90deg, var(--yellow), var(--yellow-hi));
  animation: boot-slide 1.15s var(--ease-out) infinite;
}
@keyframes boot-slide {
  0%   { transform: translateX(-110%); }
  100% { transform: translateX(360%); }
}
.boot-status {
  font-size: 12.5px;
  letter-spacing: 0.22em;
  text-transform: uppercase;
  color: var(--fg-dim);
}

/* --------------------------------------------------------------------------
   Landscape hint (phones only)
   -------------------------------------------------------------------------- */
#rotate-hint {
  position: absolute;
  inset: 0;
  z-index: 60;
  display: none;
  place-items: center;
  gap: 18px;
  background: var(--ink);
  text-align: center;
}
#rotate-hint p {
  font-family: var(--font-display);
  font-size: 17px;
  color: var(--cream);
  letter-spacing: 0.03em;
}
.rotate-icon {
  width: 54px;
  height: 88px;
  margin: 0 auto;
  border: 4px solid var(--yellow);
  border-radius: 12px;
  animation: rotate-tilt 1.8s var(--ease-spring) infinite;
}
@keyframes rotate-tilt {
  0%, 40%   { transform: rotate(0deg); }
  70%, 100% { transform: rotate(-90deg); }
}
@media (orientation: portrait) and (max-width: 820px) {
  #rotate-hint { display: grid; }
}

/* --------------------------------------------------------------------------
   Shared primitives (UI module reuses these)
   -------------------------------------------------------------------------- */

.btn {
  pointer-events: auto;
  position: relative;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 10px;
  padding: 15px 30px;
  border: 0;
  border-radius: var(--r-pill);
  font-family: var(--font-display);
  font-size: 15px;
  letter-spacing: 0.045em;
  color: var(--ink);
  background: linear-gradient(180deg, var(--yellow-hi), var(--yellow));
  box-shadow: 0 5px 0 var(--yellow-deep), 0 14px 30px rgba(0, 0, 0, 0.45);
  cursor: pointer;
  transition: transform 0.12s var(--ease-out), box-shadow 0.12s var(--ease-out),
    filter 0.18s var(--ease-out);
  -webkit-tap-highlight-color: transparent;
  user-select: none;
}
.btn:hover { filter: brightness(1.07); transform: translateY(-1px); }
.btn:active {
  transform: translateY(4px);
  box-shadow: 0 1px 0 var(--yellow-deep), 0 6px 16px rgba(0, 0, 0, 0.4);
}
.btn--ghost {
  background: rgba(255, 244, 226, 0.09);
  color: var(--cream);
  box-shadow: 0 4px 0 rgba(0, 0, 0, 0.45), inset 0 0 0 2px rgba(255, 244, 226, 0.18);
}
.btn--ghost:active { box-shadow: 0 1px 0 rgba(0, 0, 0, 0.45), inset 0 0 0 2px rgba(255,244,226,.18); }
.btn--danger {
  background: linear-gradient(180deg, #ff6a52, var(--red));
  color: var(--cream);
  box-shadow: 0 5px 0 var(--red-deep), 0 14px 30px rgba(0, 0, 0, 0.45);
}
.btn--danger:active { box-shadow: 0 1px 0 var(--red-deep); }
.btn--lg { padding: 19px 44px; font-size: 18px; }
.btn--icon { padding: 12px; width: 48px; height: 48px; border-radius: 50%; }

.card {
  pointer-events: auto;
  background: linear-gradient(180deg, rgba(30, 38, 67, 0.97), rgba(14, 18, 36, 0.98));
  border-radius: var(--r-lg);
  box-shadow: var(--sh-3), inset 0 0 0 2px rgba(255, 244, 226, 0.09);
  backdrop-filter: blur(14px);
}

.kbd {
  display: inline-grid;
  place-items: center;
  min-width: 26px;
  height: 26px;
  padding: 0 7px;
  border-radius: 6px;
  background: rgba(255, 244, 226, 0.12);
  box-shadow: inset 0 -2px 0 rgba(0, 0, 0, 0.4), inset 0 0 0 1.5px rgba(255, 244, 226, 0.2);
  font-family: var(--font-ui);
  font-weight: 800;
  font-size: 11.5px;
  color: var(--cream);
}

.label {
  font-size: 11px;
  font-weight: 800;
  letter-spacing: 0.2em;
  text-transform: uppercase;
  color: var(--fg-dim);
}

/* Focus ring — visible for keyboard users only. */
:focus-visible {
  outline: 3px solid var(--cyan);
  outline-offset: 3px;
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after {
    animation-duration: 0.001ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.001ms !important;
  }
}
