/* ============================================================
   CLOUDBORNE — SKY ENGINE
   Design system + styles for every screen.

   TOKEN SYSTEM
   ------------
   Color   Dawn Peach #FFB88C · Sky Blue #7EC8E3 · Deep Dusk #2B3A67
           Cloud White #F7F9FC · Sunset Gold #FFD97D · Ember #FF6F59
   Type    Display: "Fraunces" (warm editorial serif, used sparingly)
           Body/UI: "Quicksand" (rounded, soft, premium-casual)
           Utility: "Poppins" (HUD numerals, labels, data)
   Signature element: the hand-built layered hot-air balloon
   (canopy panels + rigging + basket + flame) reused everywhere —
   loading screen, menu hero, and customization preview all share
   one construction so the balloon reads as the game's mascot.
   ============================================================ */

/* ------------------------------------------------------------
   1. RESET & BASE
   ------------------------------------------------------------ */
*, *::before, *::after { box-sizing: border-box; }

html, body {
  margin: 0;
  padding: 0;
  width: 100%;
  height: 100%;
  overflow: hidden; /* the game is a full-viewport app, not a scrolling page */
}

body {
  font-family: 'Quicksand', -apple-system, sans-serif;
  background: #0F1B33;
  color: #F7F9FC;
  -webkit-font-smoothing: antialiased;
  -webkit-tap-highlight-color: transparent;
  user-select: none;
  position: relative;
}

button {
  font-family: inherit;
  border: none;
  background: none;
  color: inherit;
  cursor: pointer;
  -webkit-tap-highlight-color: transparent;
}

h1, h2, h3, p { margin: 0; }

img { max-width: 100%; display: block; }

.sr-only {
  position: absolute;
  width: 1px; height: 1px;
  padding: 0; margin: -1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  white-space: nowrap;
  border: 0;
}

:focus-visible {
  outline: 2px solid #FFD97D;
  outline-offset: 3px;
  border-radius: 6px;
}

/* ------------------------------------------------------------
   2. DESIGN TOKENS
   ------------------------------------------------------------ */
:root {
  /* -- palette -- */
  --peach: #FFB88C;
  --sky: #7EC8E3;
  --dusk: #2B3A67;
  --dusk-deep: #1A2647;
  --cloud: #F7F9FC;
  --gold: #FFD97D;
  --ember: #FF6F59;
  --purple: #6C5B7B;
  --ink: #16213E;

  /* -- glass surfaces -- */
  --glass-fill: rgba(247, 249, 252, 0.10);
  --glass-fill-strong: rgba(247, 249, 252, 0.16);
  --glass-border: rgba(247, 249, 252, 0.28);
  --glass-shadow: 0 20px 60px rgba(10, 16, 33, 0.45);

  /* -- clay surfaces (raised, soft) -- */
  --clay-light: #34456F;
  --clay-shadow-dark: rgba(6, 10, 24, 0.55);
  --clay-shadow-light: rgba(139, 158, 210, 0.18);

  /* -- type scale -- */
  --font-display: 'Fraunces', Georgia, serif;
  --font-body: 'Quicksand', sans-serif;
  --font-utility: 'Poppins', sans-serif;

  /* -- motion -- */
  --ease-soft: cubic-bezier(0.22, 1, 0.36, 1);
  --ease-out-back: cubic-bezier(0.34, 1.56, 0.64, 1);
  --dur-fast: 180ms;
  --dur-med: 420ms;
  --dur-slow: 900ms;

  /* -- layout -- */
  --radius-lg: 28px;
  --radius-md: 18px;
  --radius-sm: 12px;
  --safe-top: env(safe-area-inset-top, 0px);
  --safe-bottom: env(safe-area-inset-bottom, 0px);
  --safe-left: env(safe-area-inset-left, 0px);
  --safe-right: env(safe-area-inset-right, 0px);
}

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

/* body-level class toggled by the Reduced Motion setting */
body.reduced-motion * {
  animation-play-state: paused !important;
  transition-duration: 60ms !important;
}

/* ------------------------------------------------------------
   3. SCREEN FRAMEWORK
   ------------------------------------------------------------ */
.screen {
  position: fixed;
  inset: 0;
  width: 100%;
  height: 100%;
  overflow: hidden;
  opacity: 1;
  transition: opacity var(--dur-med) var(--ease-soft);
}

.screen--hidden {
  opacity: 0;
  pointer-events: none;
  visibility: hidden;
}

/* ------------------------------------------------------------
   4. LOADING SCREEN
   ------------------------------------------------------------ */
#screen-loading {
  background: linear-gradient(180deg, #1A2647 0%, #2B3A67 45%, #4A5A8C 75%, #FFB88C 100%);
}

.loading-sky {
  position: absolute;
  inset: 0;
  overflow: hidden;
}

.loading-stars {
  position: absolute;
  inset: 0;
  background-image:
    radial-gradient(1.5px 1.5px at 15% 20%, #fff, transparent),
    radial-gradient(1.5px 1.5px at 35% 10%, #fff, transparent),
    radial-gradient(1px 1px at 55% 25%, #fff, transparent),
    radial-gradient(2px 2px at 75% 15%, #fff, transparent),
    radial-gradient(1px 1px at 85% 35%, #fff, transparent),
    radial-gradient(1.5px 1.5px at 25% 40%, #fff, transparent),
    radial-gradient(1px 1px at 65% 45%, #fff, transparent);
  opacity: 0.7;
  animation: twinkle 4s ease-in-out infinite alternate;
}

@keyframes twinkle {
  from { opacity: 0.35; }
  to   { opacity: 0.85; }
}

.loading-glow {
  position: absolute;
  bottom: -20%;
  left: 50%;
  transform: translateX(-50%);
  width: 140vw;
  height: 60vh;
  background: radial-gradient(ellipse at center, rgba(255, 217, 125, 0.35) 0%, transparent 65%);
  filter: blur(20px);
}

.loading-clouds { position: absolute; inset: 0; }

.cloud-drift {
  position: absolute;
  border-radius: 50%;
  background: rgba(247, 249, 252, 0.5);
  filter: blur(2px);
}

.cloud-drift::before, .cloud-drift::after {
  content: '';
  position: absolute;
  background: inherit;
  border-radius: 50%;
}

.cloud-drift--back {
  width: 180px; height: 60px;
  top: 22%; left: -20%;
  opacity: 0.35;
  animation: driftAcross 42s linear infinite;
}
.cloud-drift--back::before { width: 100px; height: 100px; top: -50px; left: 20px; }
.cloud-drift--back::after  { width: 80px;  height: 80px;  top: -35px; left: 90px; }

.cloud-drift--mid {
  width: 220px; height: 70px;
  top: 45%; left: -25%;
  opacity: 0.5;
  animation: driftAcross 30s linear infinite;
  animation-delay: -8s;
}
.cloud-drift--mid::before { width: 120px; height: 120px; top: -60px; left: 30px; }
.cloud-drift--mid::after  { width: 90px;  height: 90px;  top: -40px; left: 110px; }

.cloud-drift--front {
  width: 260px; height: 80px;
  top: 68%; left: -30%;
  opacity: 0.7;
  animation: driftAcross 22s linear infinite;
  animation-delay: -4s;
}
.cloud-drift--front::before { width: 140px; height: 140px; top: -70px; left: 30px; }
.cloud-drift--front::after  { width: 110px; height: 110px; top: -50px; left: 130px; }

@keyframes driftAcross {
  from { transform: translateX(0); }
  to   { transform: translateX(160vw); }
}

/* -- the signature balloon construction, reused across screens -- */
.loading-balloon {
  position: absolute;
  left: 50%;
  top: 38%;
  transform: translate(-50%, -50%);
  animation: balloonBob 5s ease-in-out infinite, balloonRiseIn 1.6s var(--ease-soft) both;
}

@keyframes balloonRiseIn {
  from { transform: translate(-50%, 20vh); opacity: 0; }
  to   { transform: translate(-50%, -50%); opacity: 1; }
}

@keyframes balloonBob {
  0%, 100% { transform: translate(-50%, -50%) rotate(-1.5deg); }
  50%      { transform: translate(-50%, -54%) rotate(1.5deg); }
}

.balloon-canopy {
  position: relative;
  width: 96px;
  height: 118px;
  border-radius: 50% 50% 46% 46% / 58% 58% 42% 42%;
  overflow: hidden;
  box-shadow: 0 12px 30px rgba(10, 16, 33, 0.4), inset -10px -14px 24px rgba(0,0,0,0.15), inset 8px 10px 20px rgba(255,255,255,0.25);
  display: flex;
}

.balloon-panel { flex: 1; height: 100%; }
.balloon-panel--a { background: var(--ember); }
.balloon-panel--b { background: var(--gold); }
.balloon-panel--c { background: var(--peach); }
.balloon-panel--d { background: #FFE1B8; }

.balloon-rigging {
  position: relative;
  width: 60px;
  height: 26px;
  margin: -4px auto 0;
}
.balloon-rigging span {
  position: absolute;
  top: 0;
  width: 1.5px;
  height: 26px;
  background: rgba(43, 58, 103, 0.55);
  transform-origin: top center;
}
.balloon-rigging span:nth-child(1) { left: 6px;  transform: rotate(6deg); }
.balloon-rigging span:nth-child(2) { left: 24px; transform: rotate(1deg); }
.balloon-rigging span:nth-child(3) { left: 36px; transform: rotate(-1deg); }
.balloon-rigging span:nth-child(4) { left: 54px; transform: rotate(-6deg); }

.balloon-basket {
  position: relative;
  width: 40px;
  height: 30px;
  margin: 0 auto;
  background: linear-gradient(180deg, #A9764F, #7A5236);
  border-radius: 5px 5px 8px 8px;
  box-shadow: inset 0 -4px 8px rgba(0,0,0,0.3), 0 6px 14px rgba(10,16,33,0.35);
  display: flex;
  align-items: flex-start;
  justify-content: center;
}

.balloon-flame {
  position: relative;
  top: -14px;
  width: 10px;
  height: 18px;
  background: linear-gradient(180deg, #FFE1A8 0%, var(--gold) 40%, var(--ember) 100%);
  border-radius: 50% 50% 50% 50% / 60% 60% 40% 40%;
  filter: drop-shadow(0 0 8px rgba(255, 111, 89, 0.7));
  animation: flameFlicker 0.4s ease-in-out infinite alternate;
}

@keyframes flameFlicker {
  from { transform: scaleY(1) scaleX(1); opacity: 0.9; }
  to   { transform: scaleY(1.15) scaleX(0.9); opacity: 1; }
}

.loading-foreground {
  position: absolute;
  bottom: 14%;
  left: 50%;
  transform: translateX(-50%);
  width: min(88vw, 420px);
  text-align: center;
}

.loading-wordmark {
  font-family: var(--font-display);
  font-weight: 500;
  font-size: clamp(2.6rem, 10vw, 3.6rem);
  letter-spacing: 0.01em;
  color: var(--cloud);
  margin-bottom: 4px;
}
.wordmark-line--accent { color: var(--gold); font-style: italic; font-weight: 400; }

.loading-tagline {
  font-family: var(--font-utility);
  font-size: 0.8rem;
  letter-spacing: 0.28em;
  text-transform: uppercase;
  color: rgba(247, 249, 252, 0.65);
  margin-bottom: 32px;
}

.loading-progress-track {
  position: relative;
  width: 100%;
  height: 6px;
  border-radius: 6px;
  background: rgba(247, 249, 252, 0.15);
  overflow: hidden;
}

.loading-progress-fill {
  height: 100%;
  width: 0%;
  border-radius: 6px;
  background: linear-gradient(90deg, var(--peach), var(--gold));
  transition: width 260ms var(--ease-soft);
}

.loading-progress-spark {
  position: absolute;
  top: 50%;
  left: 0%;
  width: 10px; height: 10px;
  border-radius: 50%;
  background: var(--cloud);
  box-shadow: 0 0 10px 3px rgba(255, 217, 125, 0.9);
  transform: translate(-50%, -50%);
  transition: left 260ms var(--ease-soft);
}

.loading-progress-label {
  margin-top: 12px;
  font-family: var(--font-utility);
  font-size: 0.82rem;
  color: rgba(247, 249, 252, 0.75);
}

.loading-credit {
  position: absolute;
  bottom: calc(18px + var(--safe-bottom));
  left: 50%;
  transform: translateX(-50%);
  font-family: var(--font-utility);
  font-size: 0.68rem;
  letter-spacing: 0.08em;
  color: rgba(247, 249, 252, 0.4);
  white-space: nowrap;
}

/* ------------------------------------------------------------
   5. MAIN MENU + PARALLAX SKY
   ------------------------------------------------------------ */
#screen-menu { background: var(--dusk-deep); }

.parallax-sky {
  position: absolute;
  inset: -4% -8%;
  overflow: hidden;
}

.parallax-layer {
  position: absolute;
  inset: 0;
  will-change: transform;
}

.parallax-layer--gradient {
  background: linear-gradient(180deg, #1A2647 0%, #2B3A67 38%, #5A6FA0 68%, #FFB88C 100%);
}

.parallax-layer--stars {
  background-image:
    radial-gradient(1.5px 1.5px at 10% 12%, #fff, transparent),
    radial-gradient(1px 1px at 30% 8%, #fff, transparent),
    radial-gradient(2px 2px at 50% 18%, #fff, transparent),
    radial-gradient(1px 1px at 70% 6%, #fff, transparent),
    radial-gradient(1.5px 1.5px at 90% 14%, #fff, transparent),
    radial-gradient(1px 1px at 20% 25%, #fff, transparent),
    radial-gradient(1.5px 1.5px at 80% 28%, #fff, transparent);
  opacity: 0.55;
  animation: twinkle 5s ease-in-out infinite alternate;
}

.parallax-layer--sun {
  background: radial-gradient(circle 90px at 78% 20%, rgba(255, 217, 125, 0.9), rgba(255, 217, 125, 0) 70%);
  filter: blur(4px);
}

.parallax-layer--mountains-far {
  background:
    linear-gradient(180deg, transparent 60%, rgba(43, 58, 103, 0.55) 60%),
    linear-gradient(180deg, transparent 66%, rgba(108, 91, 123, 0.4) 66%);
  clip-path: polygon(0 100%, 0 74%, 12% 66%, 24% 72%, 38% 60%, 52% 70%, 68% 58%, 82% 68%, 100% 62%, 100% 100%);
  background-color: rgba(43, 58, 103, 0.55);
  bottom: 0;
}

.parallax-layer--islands {
  background:
    radial-gradient(60px 22px at 15% 55%, rgba(108, 91, 123, 0.6), transparent 70%),
    radial-gradient(80px 26px at 85% 62%, rgba(108, 91, 123, 0.5), transparent 70%),
    radial-gradient(46px 18px at 55% 50%, rgba(108, 91, 123, 0.55), transparent 70%);
  animation: floatSlow 8s ease-in-out infinite;
}

.parallax-layer--birds {
  background-image:
    radial-gradient(1px 6px at 30% 30%, rgba(22,33,62,0.5), transparent),
    radial-gradient(1px 6px at 60% 22%, rgba(22,33,62,0.5), transparent);
  animation: driftAcross 60s linear infinite;
  opacity: 0.6;
}

.parallax-layer--clouds-back {
  background:
    radial-gradient(90px 34px at 20% 78%, rgba(247,249,252,0.5), transparent 70%),
    radial-gradient(120px 40px at 70% 85%, rgba(247,249,252,0.4), transparent 70%);
  animation: driftAcross 50s linear infinite;
}

.parallax-layer--clouds-front {
  background:
    radial-gradient(140px 46px at 10% 95%, rgba(247,249,252,0.65), transparent 70%),
    radial-gradient(100px 36px at 90% 100%, rgba(247,249,252,0.55), transparent 70%);
  animation: driftAcross 34s linear infinite reverse;
}

@keyframes floatSlow {
  0%, 100% { transform: translateY(0); }
  50%      { transform: translateY(-6px); }
}

.menu-topbar {
  position: absolute;
  top: calc(18px + var(--safe-top));
  left: calc(18px + var(--safe-left));
  right: calc(18px + var(--safe-right));
  display: flex;
  align-items: center;
  justify-content: space-between;
  z-index: 2;
}

.player-badge, .currency-badge {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 8px 14px;
  border-radius: 999px;
  background: var(--glass-fill);
  border: 1px solid var(--glass-border);
  backdrop-filter: blur(14px);
  -webkit-backdrop-filter: blur(14px);
  box-shadow: var(--glass-shadow);
}

.player-badge-icon { font-size: 1rem; }
.player-badge-info { display: flex; flex-direction: column; line-height: 1.15; }
.player-badge-label {
  font-family: var(--font-utility);
  font-size: 0.6rem;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  color: rgba(247, 249, 252, 0.6);
}
.player-badge-name { font-family: var(--font-body); font-weight: 700; font-size: 0.85rem; }

.currency-icon { color: var(--gold); font-size: 0.95rem; }
.currency-value { font-family: var(--font-utility); font-weight: 600; font-size: 0.9rem; }

.menu-hero {
  position: absolute;
  top: 16%;
  left: 50%;
  transform: translateX(-50%);
  width: 100%;
  text-align: center;
  z-index: 2;
}

.menu-balloon-hero {
  position: relative;
  margin: 0 auto 8px;
  width: fit-content;
  animation: balloonBob 6s ease-in-out infinite;
  filter: drop-shadow(0 18px 30px rgba(10,16,33,0.5));
}

.menu-title {
  font-family: var(--font-display);
  font-weight: 500;
  font-size: clamp(2.4rem, 11vw, 3.2rem);
  color: var(--cloud);
}
.menu-title-line--accent { color: var(--gold); font-style: italic; font-weight: 400; }

.menu-subtitle {
  margin-top: 6px;
  font-family: var(--font-body);
  font-weight: 600;
  font-size: 0.95rem;
  color: rgba(247, 249, 252, 0.75);
  letter-spacing: 0.02em;
}

.menu-actions {
  position: absolute;
  bottom: calc(48px + var(--safe-bottom));
  left: 50%;
  transform: translateX(-50%);
  width: min(86vw, 360px);
  display: flex;
  flex-direction: column;
  gap: 12px;
  z-index: 2;
}

.menu-footer {
  position: absolute;
  bottom: calc(14px + var(--safe-bottom));
  left: 50%;
  transform: translateX(-50%);
  font-family: var(--font-utility);
  font-size: 0.62rem;
  letter-spacing: 0.06em;
  color: rgba(247, 249, 252, 0.35);
  z-index: 2;
}

/* ------------------------------------------------------------
   6. BUTTONS
   ------------------------------------------------------------ */
.btn {
  position: relative;
  font-family: var(--font-body);
  font-weight: 700;
  font-size: 0.98rem;
  padding: 16px 28px;
  border-radius: var(--radius-md);
  overflow: hidden;
  transition: transform var(--dur-fast) var(--ease-soft), box-shadow var(--dur-fast) var(--ease-soft);
  text-align: center;
  letter-spacing: 0.01em;
}

.btn:active { transform: scale(0.96); }

.btn--primary {
  color: var(--ink);
  background: linear-gradient(180deg, #FFE1A8, var(--gold));
  box-shadow: 0 10px 24px rgba(255, 217, 125, 0.35), inset 0 1px 0 rgba(255,255,255,0.6), inset 0 -3px 6px rgba(180, 130, 40, 0.25);
}
.btn--primary:hover { box-shadow: 0 14px 30px rgba(255, 217, 125, 0.5), inset 0 1px 0 rgba(255,255,255,0.6); transform: translateY(-2px); }

.btn-shine {
  position: absolute;
  top: 0; left: -60%;
  width: 40%; height: 100%;
  background: linear-gradient(120deg, transparent, rgba(255,255,255,0.55), transparent);
  transform: skewX(-20deg);
  animation: shineSweep 3.4s ease-in-out infinite;
}
@keyframes shineSweep {
  0%   { left: -60%; }
  40%  { left: 130%; }
  100% { left: 130%; }
}

.btn--secondary {
  color: var(--cloud);
  background: var(--glass-fill);
  border: 1px solid var(--glass-border);
  backdrop-filter: blur(14px);
  -webkit-backdrop-filter: blur(14px);
}
.btn--secondary:hover { background: var(--glass-fill-strong); transform: translateY(-2px); }

.btn--ghost {
  color: rgba(247, 249, 252, 0.7);
  font-weight: 600;
  padding: 10px 20px;
  font-size: 0.85rem;
}
.btn--ghost:hover { color: var(--cloud); }

.btn--danger { color: var(--ember); }

.btn--small { padding: 10px 18px; font-size: 0.82rem; border-radius: var(--radius-sm); }

.btn-back {
  display: flex;
  align-items: center;
  gap: 6px;
  font-family: var(--font-body);
  font-weight: 700;
  font-size: 0.88rem;
  color: var(--cloud);
  padding: 10px 16px;
  border-radius: 999px;
  background: var(--glass-fill);
  border: 1px solid var(--glass-border);
}

/* ------------------------------------------------------------
   7. SUBSCREENS (levels, customize, achievements, settings)
   ------------------------------------------------------------ */
#screen-levels, #screen-customize, #screen-achievements, #screen-settings {
  background: linear-gradient(180deg, #1A2647, #2B3A67 60%, #3D4E82);
}

.panel-backdrop {
  position: absolute;
  inset: 0;
  background:
    radial-gradient(circle at 15% 0%, rgba(255, 184, 140, 0.12), transparent 45%),
    radial-gradient(circle at 90% 100%, rgba(126, 200, 227, 0.14), transparent 50%);
}

.subscreen-header {
  position: relative;
  z-index: 2;
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: calc(18px + var(--safe-top)) 20px 12px;
}

.subscreen-title {
  font-family: var(--font-display);
  font-weight: 500;
  font-size: 1.3rem;
  color: var(--cloud);
}

.subscreen-header-spacer { width: 74px; }

/* -- level select -- */
.region-grid {
  position: relative;
  z-index: 1;
  height: calc(100% - 80px - var(--safe-top));
  overflow-y: auto;
  -webkit-overflow-scrolling: touch;
  padding: 8px 18px calc(24px + var(--safe-bottom));
  display: flex;
  flex-direction: column;
  gap: 14px;
}

.region-card {
  position: relative;
  display: flex;
  align-items: stretch;
  gap: 14px;
  padding: 14px;
  border-radius: var(--radius-lg);
  background: var(--glass-fill);
  border: 1px solid var(--glass-border);
  backdrop-filter: blur(16px);
  -webkit-backdrop-filter: blur(16px);
  box-shadow: var(--glass-shadow);
  transition: transform var(--dur-fast) var(--ease-soft);
}

.region-card:active { transform: scale(0.98); }

.region-card[data-locked="true"] { opacity: 0.55; filter: grayscale(0.4); }

.region-card-art {
  flex-shrink: 0;
  width: 84px;
  border-radius: var(--radius-md);
  background-size: cover;
}
.region-card-art--sunrise    { background: linear-gradient(160deg, #FFD97D, #FFB88C, #FF6F59); }
.region-card-art--rainforest { background: linear-gradient(160deg, #7EC8E3, #3E8E7E, #2B3A67); }
.region-card-art--frozen     { background: linear-gradient(160deg, #E8F4F8, #A9CBE0, #6C5B7B); }
.region-card-art--islands    { background: linear-gradient(160deg, #B7E4C7, #7EC8E3, #6C5B7B); }
.region-card-art--volcanic   { background: linear-gradient(160deg, #FFB88C, #FF6F59, #2B1B2E); }
.region-card-art--star       { background: linear-gradient(160deg, #6C5B7B, #2B3A67, #16213E); }

.region-card-body { flex: 1; display: flex; flex-direction: column; gap: 3px; justify-content: center; min-width: 0; }
.region-card-eyebrow {
  font-family: var(--font-utility);
  font-size: 0.62rem;
  letter-spacing: 0.14em;
  text-transform: uppercase;
  color: var(--gold);
}
.region-card-title { font-family: var(--font-body); font-weight: 700; font-size: 1.05rem; color: var(--cloud); }
.region-card-desc { font-family: var(--font-body); font-size: 0.78rem; color: rgba(247, 249, 252, 0.65); line-height: 1.35; }

.region-card-stars { display: flex; gap: 3px; margin-top: 3px; }
.star {
  width: 12px; height: 12px;
  background: rgba(247, 249, 252, 0.25);
  clip-path: polygon(50% 0%, 61% 35%, 98% 35%, 68% 57%, 79% 91%, 50% 70%, 21% 91%, 32% 57%, 2% 35%, 39% 35%);
}
.star.is-earned { background: var(--gold); }
.star--big { width: 26px; height: 26px; }

.region-card-play { align-self: center; }
.region-card-lock { align-self: center; font-size: 1.3rem; opacity: 0.7; padding-right: 6px; }

/* -- customize -- */
.customize-preview {
  position: relative;
  z-index: 1;
  height: 40%;
  display: flex;
  align-items: center;
  justify-content: center;
}
.customize-balloon { animation: balloonBob 5s ease-in-out infinite; transform: scale(1.6); filter: drop-shadow(0 20px 26px rgba(10,16,33,0.5)); }

.customize-tabs {
  position: relative;
  z-index: 1;
  display: flex;
  justify-content: center;
  gap: 8px;
  padding: 0 20px 16px;
}
.customize-tab {
  font-family: var(--font-body);
  font-weight: 700;
  font-size: 0.82rem;
  padding: 9px 18px;
  border-radius: 999px;
  color: rgba(247, 249, 252, 0.6);
  background: var(--glass-fill);
  border: 1px solid transparent;
}
.customize-tab.is-active {
  color: var(--ink);
  background: var(--gold);
  border-color: var(--gold);
}

.customize-swatches {
  position: relative;
  z-index: 1;
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 12px;
  padding: 0 20px calc(24px + var(--safe-bottom));
  overflow-y: auto;
}
.swatch {
  aspect-ratio: 1;
  border-radius: var(--radius-md);
  border: 2px solid transparent;
  box-shadow: inset 0 -6px 10px rgba(0,0,0,0.2), inset 0 4px 8px rgba(255,255,255,0.25);
  position: relative;
}
.swatch.is-selected { border-color: var(--gold); box-shadow: 0 0 0 3px rgba(255, 217, 125, 0.3), inset 0 -6px 10px rgba(0,0,0,0.2); }
.swatch.is-locked { opacity: 0.4; }
.swatch-lock-icon { position: absolute; inset: 0; display: flex; align-items: center; justify-content: center; font-size: 1rem; }

/* -- achievements -- */
.achievements-summary {
  position: relative; z-index: 1;
  text-align: center;
  font-family: var(--font-utility);
  font-size: 0.8rem;
  color: rgba(247, 249, 252, 0.7);
  padding-bottom: 12px;
}
.achievements-list {
  position: relative; z-index: 1;
  height: calc(100% - 140px - var(--safe-top));
  overflow-y: auto;
  padding: 0 18px calc(24px + var(--safe-bottom));
  display: flex;
  flex-direction: column;
  gap: 10px;
}
.achievement-row {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 12px 14px;
  border-radius: var(--radius-md);
  background: var(--glass-fill);
  border: 1px solid var(--glass-border);
}
.achievement-row.is-locked { opacity: 0.45; }
.achievement-icon {
  width: 40px; height: 40px;
  border-radius: 50%;
  display: flex; align-items: center; justify-content: center;
  background: linear-gradient(160deg, var(--gold), var(--peach));
  font-size: 1.1rem;
  flex-shrink: 0;
}
.achievement-row.is-locked .achievement-icon { background: rgba(247,249,252,0.15); }
.achievement-text { display: flex; flex-direction: column; gap: 1px; min-width: 0; }
.achievement-title { font-family: var(--font-body); font-weight: 700; font-size: 0.88rem; }
.achievement-desc { font-family: var(--font-body); font-size: 0.74rem; color: rgba(247,249,252,0.6); }

/* -- settings -- */
.settings-list {
  position: relative; z-index: 1;
  height: calc(100% - 80px - var(--safe-top));
  overflow-y: auto;
  padding: 8px 20px calc(24px + var(--safe-bottom));
  display: flex;
  flex-direction: column;
  gap: 4px;
}
.settings-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 14px;
  padding: 16px 4px;
  border-bottom: 1px solid rgba(247, 249, 252, 0.1);
}
.settings-row--slider { flex-direction: column; align-items: stretch; gap: 10px; }
.settings-row-title { font-family: var(--font-body); font-weight: 700; font-size: 0.92rem; display: block; }
.settings-row-desc { font-family: var(--font-body); font-size: 0.74rem; color: rgba(247,249,252,0.55); display: block; margin-top: 2px; }

.switch { position: relative; width: 48px; height: 28px; flex-shrink: 0; }
.switch input { position: absolute; opacity: 0; width: 100%; height: 100%; margin: 0; cursor: pointer; }
.switch-track {
  position: absolute; inset: 0;
  background: rgba(247, 249, 252, 0.2);
  border-radius: 999px;
  transition: background var(--dur-fast) var(--ease-soft);
}
.switch-thumb {
  position: absolute;
  top: 3px; left: 3px;
  width: 22px; height: 22px;
  border-radius: 50%;
  background: var(--cloud);
  box-shadow: 0 2px 6px rgba(0,0,0,0.3);
  transition: transform var(--dur-fast) var(--ease-out-back);
}
.switch input:checked ~ .switch-track { background: var(--gold); }
.switch input:checked ~ .switch-track .switch-thumb { transform: translateX(20px); }

.slider {
  -webkit-appearance: none;
  width: 100%;
  height: 6px;
  border-radius: 6px;
  background: rgba(247, 249, 252, 0.2);
  outline: none;
}
.slider::-webkit-slider-thumb {
  -webkit-appearance: none;
  width: 20px; height: 20px;
  border-radius: 50%;
  background: var(--gold);
  box-shadow: 0 2px 8px rgba(255, 217, 125, 0.5);
  cursor: pointer;
}
.slider::-moz-range-thumb {
  width: 20px; height: 20px;
  border-radius: 50%;
  background: var(--gold);
  border: none;
  box-shadow: 0 2px 8px rgba(255, 217, 125, 0.5);
  cursor: pointer;
}

/* ------------------------------------------------------------
   8. GAME SCREEN + HUD
   ------------------------------------------------------------ */
#screen-game { background: #7EC8E3; }

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

.hud {
  position: absolute;
  inset: 0;
  pointer-events: none;
  z-index: 5;
}
.hud > * { pointer-events: auto; }

.hud-top {
  position: absolute;
  top: calc(14px + var(--safe-top));
  left: calc(14px + var(--safe-left));
  right: calc(14px + var(--safe-right));
  display: flex;
  align-items: center;
  gap: 10px;
}

.hud-pause-btn {
  width: 44px; height: 44px;
  border-radius: 50%;
  background: var(--glass-fill);
  border: 1px solid var(--glass-border);
  backdrop-filter: blur(10px);
  -webkit-backdrop-filter: blur(10px);
  display: flex; align-items: center; justify-content: center;
  flex-shrink: 0;
}
.hud-pause-icon, .hud-pause-icon::before, .hud-pause-icon::after {
  content: '';
  display: block;
  width: 4px; height: 16px;
  background: var(--cloud);
  border-radius: 2px;
}
.hud-pause-icon { position: relative; }
.hud-pause-icon::before, .hud-pause-icon::after { position: absolute; top: 0; }
.hud-pause-icon::before { left: -5px; }
.hud-pause-icon::after { left: 5px; }

.hud-region-label {
  font-family: var(--font-utility);
  font-size: 0.7rem;
  letter-spacing: 0.08em;
  color: rgba(255,255,255,0.85);
  background: rgba(22, 33, 62, 0.35);
  padding: 6px 12px;
  border-radius: 999px;
  backdrop-filter: blur(8px);
}

.hud-mission {
  margin-left: auto;
  display: flex;
  align-items: center;
  gap: 6px;
  max-width: 52%;
  padding: 8px 14px;
  border-radius: 999px;
  background: var(--glass-fill);
  border: 1px solid var(--glass-border);
  backdrop-filter: blur(10px);
}
.hud-mission-icon { color: var(--gold); font-size: 0.85rem; flex-shrink: 0; }
.hud-mission-text {
  font-family: var(--font-body);
  font-weight: 600;
  font-size: 0.72rem;
  color: var(--cloud);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.hud-side--right {
  position: absolute;
  right: calc(14px + var(--safe-right));
  top: 50%;
  transform: translateY(-50%);
}
.hud-meter { display: flex; flex-direction: column; align-items: center; gap: 6px; }
.hud-meter-icon { color: var(--cloud); font-size: 0.7rem; }
.hud-meter-track {
  width: 8px; height: 140px;
  border-radius: 999px;
  background: rgba(22, 33, 62, 0.3);
  overflow: hidden;
  display: flex;
  align-items: flex-end;
}
.hud-meter-fill {
  width: 100%;
  height: 30%;
  background: linear-gradient(180deg, var(--gold), var(--peach));
  border-radius: 999px;
  transition: height 200ms var(--ease-soft);
}

.hud-bottom {
  position: absolute;
  bottom: calc(18px + var(--safe-bottom));
  left: calc(14px + var(--safe-left));
  right: calc(14px + var(--safe-right));
  display: flex;
  align-items: center;
  gap: 12px;
}

.hud-stat {
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 8px 12px;
  border-radius: 999px;
  background: var(--glass-fill);
  border: 1px solid var(--glass-border);
  backdrop-filter: blur(10px);
  font-family: var(--font-utility);
  font-weight: 600;
  font-size: 0.82rem;
  flex-shrink: 0;
}
.hud-stat-icon { color: var(--gold); }
.hud-stat--distance .hud-stat-icon { color: var(--cloud); }

.hud-fuel {
  flex: 1;
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 8px 14px;
  border-radius: 999px;
  background: var(--glass-fill);
  border: 1px solid var(--glass-border);
  backdrop-filter: blur(10px);
}
.hud-fuel-track {
  flex: 1;
  height: 8px;
  border-radius: 999px;
  background: rgba(22, 33, 62, 0.3);
  overflow: hidden;
}
.hud-fuel-fill {
  height: 100%;
  width: 100%;
  background: linear-gradient(90deg, var(--ember), var(--gold));
  border-radius: 999px;
  transition: width 150ms linear;
}

.hud-weather {
  position: absolute;
  top: calc(70px + var(--safe-top));
  left: 50%;
  transform: translateX(-50%);
  width: 34px; height: 34px;
  border-radius: 50%;
  background: var(--glass-fill);
  border: 1px solid var(--glass-border);
  display: flex; align-items: center; justify-content: center;
  font-size: 1rem;
  backdrop-filter: blur(10px);
}

/* -- burner hold control -- */
.burner-control {
  position: absolute;
  right: calc(24px + var(--safe-right));
  bottom: calc(90px + var(--safe-bottom));
  width: 84px; height: 84px;
  border-radius: 50%;
  display: flex; align-items: center; justify-content: center;
}
.burner-control-ring {
  position: absolute;
  inset: 0;
  border-radius: 50%;
  background: var(--glass-fill);
  border: 2px solid var(--glass-border);
  backdrop-filter: blur(10px);
  transition: transform var(--dur-fast) var(--ease-out-back), background var(--dur-fast);
}
.burner-control-flame {
  position: relative;
  width: 22px; height: 34px;
  background: linear-gradient(180deg, #FFE1A8, var(--gold) 45%, var(--ember));
  border-radius: 50% 50% 50% 50% / 60% 60% 40% 40%;
  filter: drop-shadow(0 0 10px rgba(255, 111, 89, 0.6));
  animation: flameFlicker 0.35s ease-in-out infinite alternate;
}
.burner-control.is-active .burner-control-ring {
  transform: scale(1.08);
  background: rgba(255, 217, 125, 0.28);
  border-color: var(--gold);
  box-shadow: 0 0 30px rgba(255, 217, 125, 0.5);
}
.burner-control.is-active .burner-control-flame { animation-duration: 0.15s; }

/* ------------------------------------------------------------
   9. NOTIFICATIONS + FEEDBACK TEXT
   ------------------------------------------------------------ */
.notification-stack {
  position: absolute;
  top: calc(64px + var(--safe-top));
  left: 50%;
  transform: translateX(-50%);
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 8px;
  z-index: 6;
  pointer-events: none;
}

.notification-toast {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px 18px;
  border-radius: 999px;
  background: rgba(22, 33, 62, 0.55);
  border: 1px solid var(--glass-border);
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
  box-shadow: var(--glass-shadow);
  font-family: var(--font-body);
  font-weight: 700;
  font-size: 0.8rem;
  color: var(--cloud);
  animation: toastIn var(--dur-med) var(--ease-out-back) both, toastOut var(--dur-med) var(--ease-soft) 2.6s both;
}
.notification-toast-icon { color: var(--gold); }

@keyframes toastIn {
  from { transform: translateY(-16px) scale(0.9); opacity: 0; }
  to   { transform: translateY(0) scale(1); opacity: 1; }
}
@keyframes toastOut {
  from { transform: translateY(0) scale(1); opacity: 1; }
  to   { transform: translateY(-10px) scale(0.95); opacity: 0; }
}

.feedback-layer {
  position: absolute;
  inset: 0;
  z-index: 4;
  overflow: hidden;
}

.feedback-pop {
  position: absolute;
  font-family: var(--font-utility);
  font-weight: 600;
  font-size: 0.95rem;
  color: var(--gold);
  text-shadow: 0 2px 6px rgba(10,16,33,0.5);
  animation: popFloat 900ms var(--ease-soft) both;
  white-space: nowrap;
}
@keyframes popFloat {
  0%   { transform: translateY(0) scale(0.7); opacity: 0; }
  20%  { transform: translateY(-6px) scale(1.1); opacity: 1; }
  100% { transform: translateY(-46px) scale(1); opacity: 0; }
}

/* ------------------------------------------------------------
   10. OVERLAYS (pause / game over / victory)
   ------------------------------------------------------------ */
.overlay {
  position: fixed;
  inset: 0;
  z-index: 20;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 24px;
  background: rgba(10, 16, 33, 0.55);
  backdrop-filter: blur(10px);
  -webkit-backdrop-filter: blur(10px);
  transition: opacity var(--dur-med) var(--ease-soft);
}
.overlay--hidden { opacity: 0; pointer-events: none; }

.overlay-panel {
  width: min(100%, 380px);
  padding: 32px 26px;
  border-radius: var(--radius-lg);
  background: linear-gradient(165deg, rgba(52, 69, 111, 0.92), rgba(26, 38, 71, 0.94));
  border: 1px solid var(--glass-border);
  box-shadow: var(--glass-shadow);
  text-align: center;
  animation: panelPop var(--dur-med) var(--ease-out-back) both;
  position: relative;
  overflow: hidden;
}
@keyframes panelPop {
  from { transform: scale(0.85) translateY(20px); opacity: 0; }
  to   { transform: scale(1) translateY(0); opacity: 1; }
}

.overlay-icon { font-size: 2.4rem; margin-bottom: 8px; }
.overlay-icon--victory { color: var(--gold); animation: floatSlow 2.4s ease-in-out infinite; }
.overlay-icon--gameover { color: rgba(247,249,252,0.6); }

.overlay-title { font-family: var(--font-display); font-weight: 500; font-size: 1.6rem; color: var(--cloud); }
.overlay-subtitle { margin-top: 6px; font-family: var(--font-body); font-size: 0.88rem; color: rgba(247,249,252,0.65); }

.overlay-star-rating { display: flex; justify-content: center; gap: 6px; margin: 18px 0 4px; }

.overlay-stats {
  display: flex;
  justify-content: center;
  gap: 22px;
  margin: 20px 0 8px;
  padding: 14px 0;
  border-top: 1px solid rgba(247,249,252,0.12);
  border-bottom: 1px solid rgba(247,249,252,0.12);
}
.overlay-stat { display: flex; flex-direction: column; gap: 2px; }
.overlay-stat-label { font-family: var(--font-utility); font-size: 0.62rem; letter-spacing: 0.08em; text-transform: uppercase; color: rgba(247,249,252,0.5); }
.overlay-stat-value { font-family: var(--font-utility); font-weight: 600; font-size: 1.05rem; color: var(--gold); }

.overlay-actions { display: flex; flex-direction: column; gap: 10px; margin-top: 18px; }

.overlay-confetti { position: absolute; inset: 0; pointer-events: none; overflow: hidden; }
.confetti-piece {
  position: absolute;
  top: -10%;
  width: 7px; height: 12px;
  border-radius: 2px;
  animation: confettiFall 2.6s ease-in forwards;
}
@keyframes confettiFall {
  to { transform: translateY(120vh) rotate(540deg); opacity: 0; }
}

/* ------------------------------------------------------------
   11. WEATHER OVERLAY EFFECTS (rendered as DOM layers above canvas)
   ------------------------------------------------------------ */
.weather-layer {
  position: absolute;
  inset: 0;
  pointer-events: none;
  z-index: 3;
}
.weather-layer--fog {
  background: linear-gradient(180deg, rgba(247,249,252,0.5), rgba(247,249,252,0.15) 40%, transparent 70%);
  opacity: 0;
  transition: opacity 1.2s var(--ease-soft);
}
.weather-layer--fog.is-active { opacity: 1; }

.weather-layer--storm-flash {
  background: rgba(247, 249, 252, 0.5);
  opacity: 0;
}
.weather-layer--storm-flash.flash { animation: lightningFlash 400ms ease-out; }
@keyframes lightningFlash {
  0%   { opacity: 0; }
  10%  { opacity: 0.8; }
  20%  { opacity: 0.1; }
  30%  { opacity: 0.6; }
  100% { opacity: 0; }
}

.weather-layer--vignette-night {
  background: radial-gradient(circle at 50% 40%, transparent 40%, rgba(10,16,33,0.55) 100%);
  opacity: 0;
  transition: opacity 1.5s var(--ease-soft);
}
.weather-layer--vignette-night.is-active { opacity: 1; }

/* ------------------------------------------------------------
   12. RESPONSIVE
   ------------------------------------------------------------ */

/* small phones */
@media (max-width: 360px) {
  .menu-actions { gap: 9px; }
  .btn { padding: 13px 22px; font-size: 0.9rem; }
  .burner-control { width: 72px; height: 72px; right: 16px; }
}

/* landscape phones — HUD needs to hug edges instead of stacking tall */
@media (orientation: landscape) and (max-height: 480px) {
  .menu-hero { top: 8%; }
  .menu-balloon-hero { transform: scale(0.7); }
  .menu-actions {
    flex-direction: row;
    flex-wrap: wrap;
    bottom: 14px;
    width: min(92vw, 620px);
  }
  .menu-actions .btn { flex: 1 1 46%; padding: 12px 18px; }
  .hud-bottom { bottom: 10px; }
  .burner-control { bottom: 14px; width: 68px; height: 68px; }
  .region-grid { flex-direction: row; flex-wrap: wrap; }
  .region-card { flex: 1 1 46%; }
}

/* tablets / larger screens — cap width, keep the game feeling handheld */
@media (min-width: 720px) {
  #screen-game canvas { max-width: 100%; }
  .region-grid { display: grid; grid-template-columns: 1fr 1fr; align-content: start; }
  .customize-swatches { grid-template-columns: repeat(6, 1fr); max-width: 520px; margin: 0 auto; }
  .menu-actions, .loading-foreground { width: min(70vw, 380px); }
}

/* very short viewports (small phones, browser chrome expanded) */
@media (max-height: 620px) {
  .menu-hero { top: 10%; }
  .loading-balloon { top: 32%; transform: translate(-50%, -50%) scale(0.85); }
}
