/* Flux Runner - layout & UI chrome.
   The game itself renders to <canvas>; everything here is menu/HUD skin. */

:root {
  --bg: #05060e;
  --ink: #e8f1ff;
  --muted: #7d8bad;
  --accent: #35e6ff;
  --accent-2: #ff2f87;
  --coin: #ffd24a;
  --panel: rgba(10, 14, 30, 0.86);
  --line: rgba(53, 230, 255, 0.28);
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  padding: 0;
  height: 100%;
  overflow: hidden;
  background: var(--bg);
  color: var(--ink);
  font-family: "Trebuchet MS", "Segoe UI", system-ui, sans-serif;

  /* CrazyGames mobile requirement: block text selection / gesture callouts. */
  -webkit-user-select: none;
  user-select: none;
  -webkit-touch-callout: none;
  -webkit-tap-highlight-color: transparent;
  touch-action: none;
  overscroll-behavior: none;
}

#app {
  position: fixed;
  inset: 0;
  display: grid;
  place-items: center;
}

#game {
  display: block;
  width: 100%;
  height: 100%;
  touch-action: none;
  image-rendering: auto;
}

/* Overlay layers sit inside the mobile safe area so nothing hides behind
   notches or the CrazyGames app chrome. */
.layer {
  position: absolute;
  inset: 0;
  padding: calc(env(safe-area-inset-top, 0px) + 12px)
           calc(env(safe-area-inset-right, 0px) + 12px)
           calc(env(safe-area-inset-bottom, 0px) + 12px)
           calc(env(safe-area-inset-left, 0px) + 12px);
  pointer-events: none;
}

.hidden { display: none !important; }

/* ------------------------------------------------------------------ screens */

.screen {
  display: grid;
  place-items: center;
  background: radial-gradient(120% 90% at 50% 40%, rgba(5, 6, 14, 0.72), rgba(5, 6, 14, 0.96));
  pointer-events: auto;
  animation: fade 0.18s ease-out;
}

@keyframes fade { from { opacity: 0; } to { opacity: 1; } }

.panel {
  width: min(420px, 100%);
  max-height: 100%;
  overflow-y: auto;
  padding: 26px 24px;
  text-align: center;
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 18px;
  box-shadow: 0 0 60px rgba(53, 230, 255, 0.09), inset 0 1px 0 rgba(255, 255, 255, 0.05);
}

.panel--bare {
  background: none;
  border: none;
  box-shadow: none;
}

.logo {
  margin: 0 0 6px;
  font-size: clamp(30px, 8vw, 46px);
  letter-spacing: 5px;
  font-weight: 800;
  color: var(--accent);
  text-shadow: 0 0 22px rgba(53, 230, 255, 0.55);
}
.logo span {
  display: block;
  font-size: 0.52em;
  letter-spacing: 11px;
  color: var(--accent-2);
  text-shadow: 0 0 18px rgba(255, 47, 135, 0.5);
}

.title {
  margin: 0 0 14px;
  font-size: 26px;
  letter-spacing: 2px;
  text-transform: uppercase;
}

.muted { color: var(--muted); }
.tiny { font-size: 12px; line-height: 1.5; }
.warn { color: var(--accent-2); min-height: 18px; margin: 6px 0 0; }
.greeting { margin: 0 0 14px; font-size: 13px; min-height: 18px; }
.collected { font-size: 13px; margin: 4px 0 16px; }
.coin-text { color: var(--coin); font-weight: 700; }

.stats {
  display: flex;
  gap: 10px;
  margin: 18px 0;
}
.stat {
  flex: 1;
  padding: 10px 6px;
  border-radius: 12px;
  background: rgba(255, 255, 255, 0.04);
  border: 1px solid rgba(255, 255, 255, 0.06);
}
.stat-label {
  display: block;
  font-size: 11px;
  letter-spacing: 2px;
  text-transform: uppercase;
  color: var(--muted);
}
.stat-value {
  display: block;
  margin-top: 3px;
  font-size: 24px;
  font-weight: 800;
}
.stat-value--coin { color: var(--coin); }

/* ------------------------------------------------------------------ buttons */

.btn {
  display: block;
  width: 100%;
  margin: 8px 0 0;
  padding: 13px 16px;
  font: inherit;
  font-weight: 700;
  font-size: 15px;
  letter-spacing: 2px;
  text-transform: uppercase;
  color: var(--ink);
  background: rgba(255, 255, 255, 0.06);
  border: 1px solid rgba(255, 255, 255, 0.12);
  border-radius: 12px;
  cursor: pointer;
  transition: transform 0.08s ease, background 0.15s ease, border-color 0.15s ease;
}
.btn:hover { background: rgba(255, 255, 255, 0.11); }
.btn:active { transform: scale(0.975); }
.btn:disabled { opacity: 0.45; cursor: default; }

.btn--primary {
  color: #04121a;
  background: linear-gradient(180deg, #6ff2ff, var(--accent));
  border-color: transparent;
  box-shadow: 0 0 26px rgba(53, 230, 255, 0.35);
}
.btn--primary:hover { background: linear-gradient(180deg, #8df6ff, #4aeaff); }

/* Rewarded ads must read as optional and be visually distinct from the
   normal flow (CrazyGames ad requirements). */
.btn--reward {
  color: #1a1000;
  background: linear-gradient(180deg, #ffe07a, var(--coin));
  border-color: transparent;
}
.btn--reward:hover { background: linear-gradient(180deg, #ffe797, #ffcf2e); }
.ad-icon {
  display: inline-grid;
  place-items: center;
  width: 18px;
  height: 18px;
  margin-right: 6px;
  font-size: 9px;
  vertical-align: -3px;
  border-radius: 4px;
  background: rgba(0, 0, 0, 0.35);
  color: #fff;
}

.icon-btn {
  position: absolute;
  top: calc(env(safe-area-inset-top, 0px) + 12px);
  right: calc(env(safe-area-inset-right, 0px) + 12px);
  width: 42px;
  height: 42px;
  font: 700 13px/1 inherit;
  letter-spacing: 1px;
  color: var(--ink);
  background: rgba(10, 14, 30, 0.6);
  border: 1px solid var(--line);
  border-radius: 11px;
  cursor: pointer;
  z-index: 5;
}

/* -------------------------------------------------------------------- skins */

.skin-grid {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 10px;
  margin: 14px 0 4px;
}
.skin {
  padding: 12px 8px;
  border-radius: 12px;
  background: rgba(255, 255, 255, 0.04);
  border: 1px solid rgba(255, 255, 255, 0.08);
  cursor: pointer;
  transition: border-color 0.15s ease, background 0.15s ease;
}
.skin:hover { background: rgba(255, 255, 255, 0.08); }
.skin.is-selected { border-color: var(--accent); box-shadow: 0 0 18px rgba(53, 230, 255, 0.25); }
.skin.is-locked { opacity: 0.72; }
.skin-swatch {
  width: 34px;
  height: 34px;
  margin: 0 auto 8px;
  border-radius: 8px;
}
.skin-name { display: block; font-size: 12px; font-weight: 700; letter-spacing: 1px; }
.skin-cost { display: block; margin-top: 3px; font-size: 11px; color: var(--muted); }
.skin-cost--afford { color: var(--coin); }

/* ---------------------------------------------------------------------- HUD */

#hud { pointer-events: none; }

.hud-row {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  padding-right: 58px; /* clear of the pause button */
}
.hud-block { text-align: left; }
.hud-block--right { text-align: right; }
.hud-label {
  display: block;
  font-size: 10px;
  letter-spacing: 3px;
  text-transform: uppercase;
  color: var(--muted);
}
.hud-value {
  display: block;
  font-size: clamp(22px, 5vw, 32px);
  font-weight: 800;
  line-height: 1.05;
  text-shadow: 0 0 16px rgba(53, 230, 255, 0.35);
}
.hud-value--coin { color: var(--coin); text-shadow: 0 0 16px rgba(255, 210, 74, 0.35); }

.combo {
  position: absolute;
  left: 50%;
  top: calc(env(safe-area-inset-top, 0px) + 14px);
  transform: translateX(-50%);
  width: min(180px, 40vw);
  text-align: center;
  opacity: 0;
  transition: opacity 0.2s ease;
}
.combo.is-active { opacity: 1; }
.combo span {
  display: block;
  font-size: 18px;
  font-weight: 800;
  color: var(--accent-2);
  text-shadow: 0 0 14px rgba(255, 47, 135, 0.5);
}
.combo-bar {
  height: 4px;
  margin-top: 4px;
  border-radius: 2px;
  background: rgba(255, 255, 255, 0.12);
  overflow: hidden;
}
.combo-bar i {
  display: block;
  height: 100%;
  width: 0%;
  background: var(--accent-2);
  transition: width 0.1s linear;
}

/* -------------------------------------------------------------- showdown */

.showdown {
  position: absolute;
  inset: 0;
  pointer-events: none;
  overflow: hidden;
  z-index: 6;
}

/* Angled slabs the fighters ride in on. */
.sd-portrait {
  position: absolute;
  top: 50%;
  width: 46%;
  height: 240px;
  margin-top: -120px;
  display: grid;
  place-items: center;
}
.sd-hero {
  left: 0;
  background: linear-gradient(90deg, rgba(53, 230, 255, 0.3), rgba(53, 230, 255, 0));
  transform: translateX(-110%) skewX(-12deg);
  animation: sd-in-left 0.5s cubic-bezier(.16,1.2,.3,1) forwards;
}
.sd-foe {
  right: 0;
  background: linear-gradient(270deg, rgba(255, 47, 135, 0.34), rgba(255, 47, 135, 0));
  transform: translateX(110%) skewX(-12deg);
  animation: sd-in-right 0.5s cubic-bezier(.16,1.2,.3,1) 0.1s forwards;
}
.sd-portrait canvas {
  width: 200px;
  height: 200px;
  transform: skewX(12deg);   /* cancel the slab skew on the artwork */
}

@keyframes sd-in-left {
  0%   { transform: translateX(-110%) skewX(-12deg); }
  70%  { transform: translateX(6%) skewX(-12deg); }
  100% { transform: translateX(0) skewX(-12deg); }
}
@keyframes sd-in-right {
  0%   { transform: translateX(110%) skewX(-12deg); }
  70%  { transform: translateX(-6%) skewX(-12deg); }
  100% { transform: translateX(0) skewX(-12deg); }
}

.sd-word {
  position: absolute;
  inset: 0;
  display: grid;
  place-items: center;
}
.sd-word span {
  font-size: clamp(34px, 9vw, 84px);
  font-weight: 800;
  letter-spacing: 10px;
  color: #fff;
  text-shadow: 0 0 26px rgba(255, 47, 135, 0.9), 0 0 60px rgba(53, 230, 255, 0.6);
  transform: scale(3);
  opacity: 0;
  animation: sd-slam 0.45s cubic-bezier(.2,1.4,.3,1) 0.42s forwards;
}
@keyframes sd-slam {
  0%   { transform: scale(3); opacity: 0; }
  60%  { transform: scale(0.92); opacity: 1; }
  100% { transform: scale(1); opacity: 1; }
}

.sd-sub {
  position: absolute;
  left: 0;
  right: 0;
  top: calc(50% + 62px);
  text-align: center;
  font-size: 13px;
  font-weight: 800;
  letter-spacing: 8px;
  color: var(--accent-2);
  opacity: 0;
  animation: sd-fade 0.4s ease-out 0.75s forwards;
}
@keyframes sd-fade { to { opacity: 1; } }

/* The whole banner clears itself out. */
.showdown.is-leaving { animation: sd-out 0.45s ease-in forwards; }
@keyframes sd-out { to { opacity: 0; transform: scale(1.06); } }

@media (prefers-reduced-motion: reduce) {
  .sd-hero, .sd-foe, .sd-word span, .sd-sub { animation-duration: 0.01s; }
}

/* ----------------------------------------------------------- boss & boost */

/* Sits in the dead space above the ceiling rail. Keep it shallow - on short
   landscape phones that band is only ~55px tall. */
.boss-bar {
  position: absolute;
  left: 50%;
  top: calc(env(safe-area-inset-top, 0px) + 10px);
  transform: translateX(-50%);
  width: min(420px, 62vw);
  text-align: center;
}
.boss-label {
  display: block;
  font-size: 11px;
  font-weight: 800;
  letter-spacing: 5px;
  color: var(--accent-2);
  text-shadow: 0 0 14px rgba(255, 47, 135, 0.6);
}
.boss-label i { font-style: normal; }
.boss-track {
  height: 9px;
  margin: 5px 0 4px;
  border-radius: 5px;
  background: rgba(255, 255, 255, 0.1);
  border: 1px solid rgba(255, 47, 135, 0.35);
  overflow: hidden;
}
.boss-track i {
  display: block;
  height: 100%;
  width: 100%;
  background: linear-gradient(90deg, #ff2f87, #ff8ac0);
  transition: width 0.12s linear;
}
/* Onboarding for the fight - shown only on the first Sentinel, and never when
   the band above the rail is too shallow to hold it. */
.boss-tip {
  display: none;
  font-size: 10px;
  letter-spacing: 1.5px;
  color: var(--muted);
}
.boss-bar.show-tip .boss-tip { display: block; }

@media (max-height: 620px) {
  .boss-bar.show-tip .boss-tip { display: none; }
}

/* The combo readout lives at top-centre too; the shield bar owns that space
   during a fight. Graze feedback still comes through on the canvas. */
.boss-active .combo { display: none; }

/* Lives, directly under the score - the first thing you look for after a hit. */
.health {
  position: absolute;
  left: calc(env(safe-area-inset-left, 0px) + 12px);
  top: calc(env(safe-area-inset-top, 0px) + 62px);
}
.hearts { display: flex; gap: 5px; }
.hearts i {
  width: 15px;
  height: 15px;
  background: var(--accent-2);
  box-shadow: 0 0 10px rgba(255, 47, 135, 0.75);
  /* Heart via two lobes and a point, so no image asset is needed. */
  clip-path: polygon(50% 100%, 0 38%, 0 16%, 16% 0, 50% 16%, 84% 0, 100% 16%, 100% 38%);
  transition: transform 0.15s ease, opacity 0.15s ease;
}
.hearts i.gone {
  background: rgba(255, 255, 255, 0.16);
  box-shadow: none;
  transform: scale(0.82);
}

/* Weapon pips sit below the hearts. */
.weapon-pips {
  position: absolute;
  left: calc(env(safe-area-inset-left, 0px) + 12px);
  top: calc(env(safe-area-inset-top, 0px) + 86px);
  display: flex;
  align-items: center;
  gap: 6px;
}
.weapon-label {
  font-size: 10px;
  font-weight: 800;
  letter-spacing: 3px;
  color: var(--muted);
}
.weapon-dots {
  display: flex;
  gap: 3px;
}
.weapon-dots i {
  width: 9px;
  height: 9px;
  border-radius: 2px;
  background: rgba(255, 255, 255, 0.14);
}
.weapon-dots i.on {
  background: var(--accent);
  box-shadow: 0 0 8px rgba(53, 230, 255, 0.8);
}

.boost-meter {
  position: absolute;
  left: 50%;
  bottom: calc(env(safe-area-inset-bottom, 0px) + 58px);
  transform: translateX(-50%);
  width: min(230px, 52vw);
  text-align: center;
}
.boost-label {
  font-size: 10px;
  font-weight: 800;
  letter-spacing: 4px;
  color: var(--coin);
  text-shadow: 0 0 12px rgba(255, 210, 74, 0.6);
}
.boost-track {
  height: 5px;
  margin-top: 4px;
  border-radius: 3px;
  background: rgba(255, 255, 255, 0.12);
  overflow: hidden;
}
.boost-track i {
  display: block;
  height: 100%;
  width: 100%;
  background: linear-gradient(90deg, #ff8a2b, var(--coin));
}

.hint {
  position: absolute;
  left: 0;
  right: 0;
  bottom: calc(env(safe-area-inset-bottom, 0px) + 26px);
  text-align: center;
  font-size: 13px;
  letter-spacing: 2px;
  color: var(--muted);
  transition: opacity 0.4s ease;
}
.hint.is-gone { opacity: 0; }

/* -------------------------------------------------------------- rotate hint */

.rotate {
  position: absolute;
  left: 50%;
  bottom: calc(env(safe-area-inset-bottom, 0px) + 74px);
  transform: translateX(-50%);
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px 16px;
  border-radius: 999px;
  background: rgba(10, 14, 30, 0.9);
  border: 1px solid var(--line);
  pointer-events: none;
  z-index: 4;
}
.rotate p {
  margin: 0;
  font-size: 12px;
  letter-spacing: 1px;
  color: var(--muted);
}
.rotate-icon {
  font-size: 20px;
  color: var(--accent);
  animation: tilt 1.8s ease-in-out infinite;
}
@keyframes tilt {
  0%, 45% { transform: rotate(90deg); }
  55%, 100% { transform: rotate(0deg); }
}
@media (prefers-reduced-motion: reduce) {
  .rotate-icon { animation: none; }
}

#btn-ad-skip {
  width: auto;
  margin: 18px auto 0;
  padding: 10px 20px;
  font-size: 13px;
  animation: fade 0.3s ease-out;
}

/* ----------------------------------------------------------------- loaders */

.loader {
  width: min(280px, 70vw);
  height: 5px;
  margin: 22px auto 10px;
  border-radius: 3px;
  background: rgba(255, 255, 255, 0.1);
  overflow: hidden;
}
.loader i {
  display: block;
  height: 100%;
  width: 0%;
  background: linear-gradient(90deg, var(--accent-2), var(--accent));
  transition: width 0.25s ease;
}

.spinner {
  width: 34px;
  height: 34px;
  margin: 0 auto 14px;
  border: 3px solid rgba(255, 255, 255, 0.14);
  border-top-color: var(--accent);
  border-radius: 50%;
  animation: spin 0.8s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }

@media (prefers-reduced-motion: reduce) {
  .screen { animation: none; }
  .spinner { animation-duration: 2s; }
}

/* ============ ZONE BANNER ============
   Announces a new stretch of the run. Presentational only — the run never
   pauses for it. Placed high and centred so it clears both lanes; an obstacle
   hidden behind a banner would be a death the player could not have read. */
.zone {
  position: absolute;
  top: 11%;
  left: 50%;
  transform: translateX(-50%);
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 0.15rem;
  pointer-events: none;
  text-align: center;
  z-index: 6;
}
.zone__eyebrow {
  font-size: 0.62rem;
  letter-spacing: 0.42em;
  text-indent: 0.42em;
  color: rgba(239, 236, 246, 0.55);
}
.zone__name {
  font-family: var(--display, inherit);
  font-size: clamp(1.35rem, 3.4vw, 2.1rem);
  font-weight: 800;
  letter-spacing: 0.06em;
  color: #fff;
  text-shadow: 0 0 18px rgba(53, 230, 255, 0.55), 0 2px 10px rgba(0, 0, 0, 0.7);
}
.zone.is-in { animation: zone-in 2.6s ease-out forwards; }

@keyframes zone-in {
  0%   { opacity: 0; transform: translateX(-50%) translateY(-10px); }
  12%  { opacity: 1; transform: translateX(-50%) translateY(0); }
  78%  { opacity: 1; }
  100% { opacity: 0; }
}

@media (prefers-reduced-motion: reduce) {
  .zone.is-in { animation: none; opacity: 1; }
}

/* ------------------------------------------------------------------- store */
/* Shown only in the self-hosted build, where a checkout actually exists.
   src/purchase.js decides; this is just the dressing. */

.store {
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
  margin: 0.75rem 0 0.25rem;
  padding: 0.85rem;
  border: 1px solid rgba(53, 230, 255, 0.28);
  border-radius: 10px;
  background: rgba(10, 18, 30, 0.55);
  text-align: left;
}

.store-row {
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem;
}

/* Both stores on the skins screen - the Chrome Pack written into index.html and
   the arcade-wide pack built by src/store.js - use `.store-btn` below, so the
   two blocks are the same control in the same size. */

.field {
  width: 100%;
  padding: 0.55rem 0.7rem;
  border: 1px solid rgba(160, 200, 230, 0.3);
  border-radius: 8px;
  background: rgba(4, 8, 16, 0.7);
  color: #eaf6ff;
  font: inherit;
  font-size: 0.9rem;
}

.field:focus-visible {
  outline: 2px solid #35e6ff;
  outline-offset: 1px;
}

.btn--ghost {
  background: transparent;
  border: 1px solid rgba(160, 200, 230, 0.35);
  color: #cfe6f5;
}

/* The licence key is the one thing a player must be able to copy accurately. */
#buy-key {
  user-select: all;
  -webkit-user-select: all;
  font-family: ui-monospace, SFMono-Regular, Menlo, monospace;
  color: #9be7ff;
  word-break: break-word;
}

/* The embedded Stripe checkout, mounted over the game by src/purchase.js.
   Stripe renders inside its own iframe, so this only has to give it a legible,
   scrollable box and a way out. */

.checkout-overlay {
  position: fixed;
  inset: 0;
  z-index: 10000;
  display: grid;
  place-items: center;
  padding: max(16px, env(safe-area-inset-top)) 16px;
  background: rgba(3, 6, 12, 0.86);
  backdrop-filter: blur(4px);
  overflow: auto;
}

.checkout-mount {
  width: min(460px, 100%);
  max-height: 86vh;
  overflow: auto;
  padding: 14px;
  border-radius: 12px;
  /* Stripe's form is light-themed; a white card reads as intentional rather
     than as something failing to load. */
  background: #fff;
}

.checkout-close {
  position: absolute;
  top: calc(10px + env(safe-area-inset-top));
  right: 12px;
  width: 40px;
  height: 40px;
  border: 1px solid rgba(220, 235, 250, 0.35);
  border-radius: 50%;
  background: rgba(8, 12, 22, 0.85);
  color: #eaf6ff;
  font-size: 1.4rem;
  line-height: 1;
  cursor: pointer;
}

.checkout-close:focus-visible {
  outline: 2px solid #35e6ff;
  outline-offset: 2px;
}

/* The runtime-built store block (src/store.js), used for the arcade-wide pack
   sold beside the Chrome Pack. It reuses `.store` and `.store-row` above; only
   the pieces the static markup has no equivalent for are defined here. */

.store-copy { font-size: 0.78rem; line-height: 1.45; color: #eaf6ff; }
.store-label { font-size: 0.72rem; color: #9fb4c6; }

.store-field {
  width: 100%;
  padding: 0.55rem 0.7rem;
  border: 1px solid rgba(160, 200, 230, 0.3);
  border-radius: 8px;
  background: rgba(4, 8, 16, 0.7);
  color: #eaf6ff;
  font: inherit;
  font-size: 0.85rem;
  user-select: text;
  -webkit-user-select: text;
}

.store-field:focus-visible { outline: 2px solid #35e6ff; outline-offset: 1px; }

.store-btn {
  flex: 1 1 8rem;
  padding: 0.6rem 0.5rem;
  border: 1px solid transparent;
  border-radius: 10px;
  background: #35e6ff;
  color: #06111a;
  font: inherit;
  font-weight: 700;
  font-size: 0.82rem;
  white-space: nowrap;
  cursor: pointer;
}

.store-btn--ghost {
  background: transparent;
  border-color: rgba(160, 200, 230, 0.35);
  color: #cfe6f5;
  font-weight: 600;
}

.store-btn:disabled { opacity: 0.5; cursor: default; }
.store-btn:focus-visible { outline: 2px solid #35e6ff; outline-offset: 2px; }

.store-msg { font-size: 0.75rem; color: #eaf6ff; min-height: 1em; }

.store-key {
  font-family: ui-monospace, SFMono-Regular, Menlo, monospace;
  font-size: 0.78rem;
  color: #9be7ff;
  word-break: break-all;
  user-select: all;
  -webkit-user-select: all;
}

.store-fine { font-size: 0.68rem; color: #9fb4c6; line-height: 1.5; }
.store-fine a { color: #9fb4c6; }
