/* ==========================================================================
   Kellian Jump — chunky, high-contrast UI to match the voxel art style.
   Everything is sized in vmin-ish units so it reads the same on phone + desktop.
   ========================================================================== */

:root {
  --ink: #0d1b2a;
  --ink-soft: #29405a;
  --paper: #fdf7e4;
  --paper-2: #f2e6c8;
  --green: #6dbe45;
  --green-dark: #4a8f2e;
  --blue: #4fb3ff;
  --blue-dark: #2b7fc4;
  --gold: #ffcf3f;
  --gold-dark: #d19b12;
  --red: #ec5b4b;
  --red-dark: #b53b2d;
  --purple: #9b6bff;
  --edge: 4px;
  --ui: 'Segoe UI', system-ui, -apple-system, 'Helvetica Neue', Arial, sans-serif;
}

* {
  box-sizing: border-box;
  -webkit-tap-highlight-color: transparent;
}

html,
body {
  margin: 0;
  padding: 0;
  height: 100%;
  overflow: hidden;
  background: #7ec8ff;
  font-family: var(--ui);
  color: var(--ink);
  overscroll-behavior: none;
  touch-action: none;
  user-select: none;
  -webkit-user-select: none;
}

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

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

.hidden {
  display: none !important;
}

.muted {
  color: var(--ink-soft);
  font-size: 14px;
  font-weight: 600;
}

/* ------------------------------- Overlays -------------------------------- */

.overlay {
  position: absolute;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: max(16px, env(safe-area-inset-top)) 16px max(16px, env(safe-area-inset-bottom));
  background: rgba(10, 24, 40, 0.34);
  backdrop-filter: blur(2px);
  -webkit-backdrop-filter: blur(2px);
  z-index: 20;
  animation: fadeIn 0.18s ease-out;
}

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

.card {
  width: min(420px, 100%);
  max-height: 100%;
  overflow-y: auto;
  background: var(--paper);
  border: var(--edge) solid var(--ink);
  border-radius: 10px;
  box-shadow: 0 10px 0 rgba(13, 27, 42, 0.35), 0 18px 40px rgba(0, 0, 0, 0.35);
  padding: 22px 20px;
  text-align: center;
  animation: pop 0.22s cubic-bezier(0.2, 1.4, 0.5, 1);
}

.card.wide {
  width: min(500px, 100%);
}

@keyframes pop {
  from {
    transform: scale(0.9) translateY(10px);
    opacity: 0;
  }
  to {
    transform: none;
    opacity: 1;
  }
}

.card h2 {
  margin: 0 0 14px;
  font-size: 26px;
  letter-spacing: 3px;
  font-weight: 900;
}

/* --------------------------------- Logo ---------------------------------- */

.logo {
  line-height: 0.9;
  margin-bottom: 10px;
}

.logo-k,
.logo-j {
  display: block;
  font-weight: 900;
  letter-spacing: 6px;
}

.logo-k {
  font-size: clamp(26px, 8vw, 40px);
  color: var(--green-dark);
  text-shadow: 0 3px 0 rgba(13, 27, 42, 0.18);
}

.logo-j {
  font-size: clamp(38px, 12vw, 58px);
  color: var(--blue-dark);
  text-shadow: 0 4px 0 rgba(13, 27, 42, 0.2);
}

.tagline {
  margin: 6px 0 16px;
  font-size: 14px;
  font-weight: 600;
  color: var(--ink-soft);
}

/* -------------------------------- Buttons -------------------------------- */

.btn {
  appearance: none;
  border: var(--edge) solid var(--ink);
  background: var(--paper-2);
  color: var(--ink);
  font-family: inherit;
  font-weight: 900;
  letter-spacing: 2px;
  font-size: 14px;
  padding: 11px 14px;
  border-radius: 8px;
  cursor: pointer;
  box-shadow: 0 5px 0 rgba(13, 27, 42, 0.4);
  transition: transform 0.06s, box-shadow 0.06s, filter 0.12s;
  flex: 1;
  min-width: 0;
}

.btn:hover {
  filter: brightness(1.06);
}

.btn:active {
  transform: translateY(4px);
  box-shadow: 0 1px 0 rgba(13, 27, 42, 0.4);
}

.btn.big {
  display: block;
  width: 100%;
  font-size: 20px;
  padding: 15px;
  margin: 6px 0;
}

.btn.small {
  font-size: 11px;
  padding: 8px;
  margin-top: 14px;
  width: 100%;
}

.btn.primary {
  background: var(--green);
  color: #fff;
  text-shadow: 0 2px 0 rgba(0, 0, 0, 0.25);
}

.btn.danger {
  background: var(--red);
  color: #fff;
  text-shadow: 0 2px 0 rgba(0, 0, 0, 0.25);
}

.btn:disabled {
  opacity: 0.45;
  cursor: default;
  box-shadow: 0 5px 0 rgba(13, 27, 42, 0.25);
}

.btn-row {
  display: flex;
  gap: 8px;
  margin-top: 8px;
}

/* --------------------------------- Stats --------------------------------- */

.stat-row {
  display: flex;
  gap: 8px;
  margin: 14px 0;
}

.stat {
  flex: 1;
  background: var(--paper-2);
  border: 3px solid var(--ink);
  border-radius: 8px;
  padding: 8px 4px;
  min-width: 0;
}

.stat span {
  display: block;
  font-size: 20px;
  font-weight: 900;
  color: var(--ink);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.stat small {
  display: block;
  font-size: 9px;
  letter-spacing: 1.5px;
  font-weight: 800;
  color: var(--ink-soft);
  margin-top: 2px;
}

.big-score {
  font-size: 62px;
  font-weight: 900;
  line-height: 1;
  color: var(--blue-dark);
  text-shadow: 0 4px 0 rgba(13, 27, 42, 0.18);
}

.big-score small {
  font-size: 22px;
  color: var(--ink-soft);
}

.new-best {
  margin: 10px 0 0;
  font-weight: 900;
  letter-spacing: 2px;
  color: var(--gold-dark);
  animation: pulse 0.7s ease-in-out infinite alternate;
}

@keyframes pulse {
  from {
    transform: scale(1);
  }
  to {
    transform: scale(1.08);
  }
}

/* ------------------------------- Controls -------------------------------- */

.controls-grid {
  display: grid;
  grid-template-columns: auto 1fr;
  gap: 6px 10px;
  margin-top: 16px;
  font-size: 12px;
  font-weight: 700;
  color: var(--ink-soft);
  text-align: left;
  align-items: center;
}

.key {
  display: inline-block;
  background: var(--ink);
  color: var(--paper);
  border-radius: 5px;
  padding: 3px 7px;
  font-size: 11px;
  font-weight: 900;
  letter-spacing: 1px;
  white-space: nowrap;
}

.row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 9px 2px;
  font-weight: 800;
  font-size: 14px;
  border-bottom: 2px solid rgba(13, 27, 42, 0.1);
  cursor: pointer;
}

.row input[type='checkbox'] {
  width: 24px;
  height: 24px;
  accent-color: var(--green-dark);
  cursor: pointer;
}

.row input[type='range'] {
  width: 150px;
  accent-color: var(--blue-dark);
}

.row select {
  font-family: inherit;
  font-weight: 800;
  border: 3px solid var(--ink);
  border-radius: 6px;
  padding: 4px 6px;
  background: var(--paper-2);
}

/* --------------------------------- Loader -------------------------------- */

.loader-track {
  height: 16px;
  background: var(--paper-2);
  border: 3px solid var(--ink);
  border-radius: 10px;
  overflow: hidden;
  margin: 16px 0 10px;
}

#loader-fill {
  height: 100%;
  width: 0%;
  background: linear-gradient(90deg, var(--green), var(--blue));
  transition: width 0.2s ease-out;
}

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

#hud {
  position: absolute;
  inset: 0;
  pointer-events: none;
  z-index: 10;
  padding: max(10px, env(safe-area-inset-top)) max(10px, env(safe-area-inset-right))
    max(10px, env(safe-area-inset-bottom)) max(10px, env(safe-area-inset-left));
}

.hud-top {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 10px;
}

.alt-block {
  text-align: left;
  text-shadow: 0 3px 0 rgba(13, 27, 42, 0.55);
}

#alt-value {
  font-size: clamp(34px, 9vw, 52px);
  font-weight: 900;
  line-height: 0.95;
  color: #fff;
  font-variant-numeric: tabular-nums;
}

.alt-unit {
  font-size: 10px;
  font-weight: 900;
  letter-spacing: 4px;
  color: rgba(255, 255, 255, 0.85);
}

.hud-right {
  display: flex;
  align-items: center;
  gap: 8px;
  pointer-events: auto;
}

.pill {
  background: rgba(13, 27, 42, 0.5);
  border: 3px solid rgba(255, 255, 255, 0.85);
  border-radius: 999px;
  color: #fff;
  font-weight: 900;
  font-size: 16px;
  padding: 5px 12px;
  display: flex;
  align-items: center;
  gap: 6px;
  font-variant-numeric: tabular-nums;
}

.coin-ico {
  color: var(--gold);
}

.pill.bump {
  animation: bump 0.25s ease-out;
}

@keyframes bump {
  50% {
    transform: scale(1.22);
  }
}

.icon-btn {
  width: 42px;
  height: 42px;
  border-radius: 10px;
  border: 3px solid rgba(255, 255, 255, 0.85);
  background: rgba(13, 27, 42, 0.5);
  color: #fff;
  font-size: 15px;
  font-weight: 900;
  cursor: pointer;
  pointer-events: auto;
}

.zone-badge {
  position: absolute;
  top: max(10px, env(safe-area-inset-top));
  left: 50%;
  transform: translateX(-50%);
  background: rgba(13, 27, 42, 0.45);
  border: 3px solid rgba(255, 255, 255, 0.75);
  border-radius: 999px;
  color: #fff;
  font-size: 11px;
  font-weight: 900;
  letter-spacing: 3px;
  padding: 5px 14px;
  white-space: nowrap;
}

/* --------------------------------- Combo --------------------------------- */

.combo {
  position: absolute;
  left: max(12px, env(safe-area-inset-left));
  top: 96px;
  width: 118px;
}

#combo-text {
  font-size: 26px;
  font-weight: 900;
  color: var(--gold);
  text-shadow: 0 3px 0 rgba(13, 27, 42, 0.6);
  line-height: 1;
}

.combo-track {
  height: 7px;
  background: rgba(13, 27, 42, 0.45);
  border-radius: 4px;
  overflow: hidden;
  margin-top: 3px;
  border: 2px solid rgba(255, 255, 255, 0.6);
}

#combo-fill {
  height: 100%;
  width: 100%;
  background: var(--gold);
}

/* ------------------------------- Power bar ------------------------------- */

.power-bar {
  position: absolute;
  bottom: max(18px, env(safe-area-inset-bottom));
  left: 50%;
  transform: translateX(-50%);
  width: min(260px, 62vw);
  text-align: center;
}

#power-label {
  font-size: 12px;
  font-weight: 900;
  letter-spacing: 3px;
  color: #fff;
  text-shadow: 0 2px 0 rgba(13, 27, 42, 0.6);
  margin-bottom: 3px;
}

.power-track {
  height: 12px;
  background: rgba(13, 27, 42, 0.5);
  border: 3px solid rgba(255, 255, 255, 0.8);
  border-radius: 999px;
  overflow: hidden;
}

#power-fill {
  height: 100%;
  width: 100%;
  background: var(--gold);
  transition: background 0.2s;
}

/* ------------------------------ Altitude ladder -------------------------- */

.ladder {
  position: absolute;
  right: max(14px, env(safe-area-inset-right));
  top: 50%;
  transform: translateY(-50%);
  height: min(52vh, 380px);
  display: flex;
  /* Track hugs the screen edge, labels run inward — otherwise the long band
     names ("STRATOSPHERE") walk straight off a phone screen. */
  flex-direction: row-reverse;
  align-items: stretch;
  gap: 6px;
}

.ladder-track {
  position: relative;
  width: 10px;
  background: rgba(13, 27, 42, 0.4);
  border: 3px solid rgba(255, 255, 255, 0.7);
  border-radius: 999px;
}

.ladder-dot {
  position: absolute;
  left: 50%;
  bottom: 0%;
  width: 16px;
  height: 16px;
  margin-left: -8px;
  margin-bottom: -8px;
  border-radius: 50%;
  background: var(--gold);
  border: 3px solid #fff;
  box-shadow: 0 0 10px rgba(255, 207, 63, 0.9);
  transition: bottom 0.12s linear;
}

.ladder-best {
  position: absolute;
  left: -5px;
  right: -5px;
  height: 4px;
  bottom: 0%;
  background: #fff;
  border-radius: 2px;
  box-shadow: 0 0 6px rgba(255, 255, 255, 0.9);
  opacity: 0.9;
}

#ladder-marks {
  position: relative;
  width: 74px;
  font-size: 8px;
  font-weight: 900;
  letter-spacing: 1px;
  color: rgba(255, 255, 255, 0.95);
  text-shadow: 0 2px 0 rgba(13, 27, 42, 0.7);
}

#ladder-marks div {
  position: absolute;
  right: 0;
  text-align: right;
  transform: translateY(50%);
  white-space: nowrap;
  transition: opacity 0.3s;
}

/* -------------------------------- Banner --------------------------------- */

.banner {
  position: absolute;
  top: 34%;
  left: 0;
  right: 0;
  text-align: center;
  pointer-events: none;
}

#banner-text {
  display: inline-block;
  font-size: clamp(20px, 6vw, 34px);
  font-weight: 900;
  letter-spacing: 5px;
  color: #fff;
  text-shadow: 0 0 22px rgba(120, 220, 255, 0.95), 0 5px 0 rgba(13, 27, 42, 0.6);
  animation: bannerIn 2.6s ease-out forwards;
}

@keyframes bannerIn {
  0% {
    opacity: 0;
    transform: scale(0.6);
    filter: blur(6px);
  }
  16% {
    opacity: 1;
    transform: scale(1.05);
    filter: blur(0);
  }
  24% {
    transform: scale(1);
  }
  78% {
    opacity: 1;
    transform: scale(1);
  }
  100% {
    opacity: 0;
    transform: scale(1.15) translateY(-24px);
  }
}

/* -------------------------------- Toasts --------------------------------- */

.toasts {
  position: absolute;
  left: 50%;
  top: 46%;
  transform: translateX(-50%);
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 2px;
  pointer-events: none;
}

.toast {
  font-size: 18px;
  font-weight: 900;
  letter-spacing: 1px;
  color: #fff;
  text-shadow: 0 3px 0 rgba(13, 27, 42, 0.6);
  animation: toastUp 1s ease-out forwards;
  white-space: nowrap;
}

.toast.gold {
  color: var(--gold);
}
.toast.green {
  color: #9dff6b;
}
.toast.purple {
  color: #c9a8ff;
}

@keyframes toastUp {
  0% {
    opacity: 0;
    transform: translateY(14px) scale(0.7);
  }
  20% {
    opacity: 1;
    transform: translateY(0) scale(1.1);
  }
  30% {
    transform: scale(1);
  }
  100% {
    opacity: 0;
    transform: translateY(-40px);
  }
}

/* -------------------------------- Joystick ------------------------------- */

.stick {
  position: absolute;
  left: 0;
  bottom: 0;
  width: 46%;
  height: 46%;
  pointer-events: auto;
  touch-action: none;
}

/* The stick is parked at a resting position and always drawn, so it's obvious
   there IS one. Touching anywhere in the zone relocates it under your thumb
   (JS writes inline left/top, which over-constrains and so wins over `bottom`);
   releasing clears those and it springs back here. */
.stick-base {
  position: absolute;
  left: clamp(76px, 22vw, 104px);
  bottom: clamp(64px, 15vh, 104px);
  top: auto;
  width: 116px;
  height: 116px;
  margin: -58px 0 0 -58px;
  border-radius: 50%;
  border: 4px solid rgba(255, 255, 255, 0.5);
  background: rgba(13, 27, 42, 0.25);
  opacity: 0.42;
  transition: opacity 0.15s;
  pointer-events: none;
}

.stick-base.on {
  opacity: 1;
  transition: opacity 0.08s;
}

/* Breathes until the player first grabs it, then never again this run. */
.stick-base.hint {
  animation: stickHint 1.9s ease-in-out infinite;
}

@keyframes stickHint {
  0%,
  100% {
    opacity: 0.34;
    transform: scale(1);
  }
  50% {
    opacity: 0.7;
    transform: scale(1.07);
  }
}

.stick-knob {
  position: absolute;
  left: 50%;
  top: 50%;
  width: 52px;
  height: 52px;
  margin: -26px 0 0 -26px;
  border-radius: 50%;
  background: rgba(255, 255, 255, 0.9);
  border: 4px solid rgba(13, 27, 42, 0.6);
}

/* --------------------------------- Skins --------------------------------- */

.skins-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(96px, 1fr));
  gap: 8px;
  margin: 14px 0;
}

.skin {
  border: 3px solid var(--ink);
  border-radius: 8px;
  background: var(--paper-2);
  padding: 8px 4px;
  cursor: pointer;
  transition: transform 0.1s;
}

.skin:active {
  transform: scale(0.95);
}

.skin.locked {
  opacity: 0.55;
}

.skin.equipped {
  background: var(--green);
  color: #fff;
  box-shadow: 0 0 0 3px var(--gold) inset;
}

.skin .swatch {
  width: 100%;
  height: 26px;
  border-radius: 5px;
  border: 3px solid var(--ink);
  margin-bottom: 5px;
}

.skin .nm {
  font-size: 10px;
  font-weight: 900;
  letter-spacing: 1px;
}

.skin .pr {
  font-size: 10px;
  font-weight: 800;
  color: var(--ink-soft);
}

/* -------------------------------- Missions ------------------------------- */

.missions {
  display: flex;
  flex-direction: column;
  gap: 7px;
  margin: 12px 0;
  text-align: left;
}

.mission {
  background: var(--paper-2);
  border: 3px solid var(--ink);
  border-radius: 8px;
  padding: 8px 10px;
}

.mission.done {
  background: var(--green);
  color: #fff;
}

.mission .mt {
  font-size: 12px;
  font-weight: 900;
  display: flex;
  justify-content: space-between;
  gap: 8px;
}

.mission .mr {
  color: var(--gold-dark);
}

.mission.done .mr {
  color: #fff;
}

.mission .mbar {
  height: 7px;
  background: rgba(13, 27, 42, 0.18);
  border-radius: 4px;
  margin-top: 5px;
  overflow: hidden;
}

.mission .mbar i {
  display: block;
  height: 100%;
  background: var(--blue-dark);
}

.mission.done .mbar i {
  background: #fff;
}

.missions.compact .mission {
  padding: 6px 8px;
}

/* ------------------------------ FX overlays ------------------------------ */

.flash {
  position: absolute;
  inset: 0;
  pointer-events: none;
  z-index: 15;
  background: #fff;
  opacity: 0;
}

.vignette {
  position: absolute;
  inset: 0;
  pointer-events: none;
  z-index: 14;
  opacity: 0;
  transition: opacity 0.3s;
  background: radial-gradient(ellipse at center, transparent 42%, rgba(255, 60, 40, 0.75) 100%);
}

/* ------------------------------ Responsive ------------------------------- */

.mobile-only {
  display: none;
}

body.is-touch .mobile-only {
  display: grid;
}

body.is-touch label.mobile-only {
  display: flex;
}

body.is-touch .desktop-only {
  display: none;
}

@media (max-width: 480px) {
  .card {
    padding: 18px 14px;
  }
  /* Three buttons across a 375px phone: shed the letter-spacing before the
     labels start clipping. */
  .btn-row .btn {
    font-size: 11px;
    letter-spacing: 0.5px;
    padding: 11px 6px;
  }
  .stat span {
    font-size: 17px;
  }
  .ladder {
    height: 40vh;
  }
  #ladder-marks {
    width: 66px;
    font-size: 7px;
    letter-spacing: 0.5px;
  }
}

@media (max-height: 620px) {
  .controls-grid {
    display: none !important;
  }
  .big-score {
    font-size: 46px;
  }
}

/* ---------------------------- Cinematic Intro ---------------------------- */

.intro-overlay {
  position: absolute;
  inset: 0;
  pointer-events: none;
  z-index: 25;
  display: flex;
  flex-direction: column;
  justify-content: space-between;
}

.intro-overlay .intro-bar {
  height: 6.5vmin;
  background: #000;
  width: 100%;
}

.intro-skip {
  position: absolute;
  bottom: 8vmin;
  right: 4vw;
  pointer-events: auto;
  background: rgba(13, 27, 42, 0.85);
  color: var(--paper);
  border: 3px solid var(--gold);
  border-radius: 24px;
  padding: 8px 18px;
  font-weight: 800;
  font-size: 14px;
  letter-spacing: 1px;
  cursor: pointer;
  box-shadow: 0 4px 14px rgba(0, 0, 0, 0.4);
  transition: transform 0.15s, background 0.15s;
  font-family: inherit;
}

.intro-skip:hover {
  background: rgba(13, 27, 42, 1);
  transform: scale(1.06);
}

.intro-skip span {
  opacity: 0.75;
  font-size: 11px;
  margin-left: 4px;
}
