:root {
  color-scheme: light;
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  background: #15222b;
  color: #10202a;
  --app-height: 100vh;
  --safe-top: env(safe-area-inset-top, 0px);
  --safe-right: env(safe-area-inset-right, 0px);
  --safe-bottom: env(safe-area-inset-bottom, 0px);
  --safe-left: env(safe-area-inset-left, 0px);
  --stage-max-height: calc(var(--app-height) - var(--safe-top) - var(--safe-bottom));
  --stage-max-width: calc(100vw - var(--safe-left) - var(--safe-right));
}

* {
  box-sizing: border-box;
}

html,
body {
  width: 100%;
  height: 100%;
  margin: 0;
  -webkit-text-size-adjust: 100%;
}

body {
  min-height: var(--app-height);
  display: grid;
  place-items: center;
  overflow: hidden;
  overscroll-behavior: none;
  -webkit-user-select: none;
  user-select: none;
  background:
    radial-gradient(circle at 24% 12%, rgba(255, 215, 120, 0.22), transparent 26%),
    linear-gradient(150deg, #263d45 0%, #16242e 52%, #10171f 100%);
}

body[data-theme="night"] {
  background:
    radial-gradient(circle at 74% 14%, rgba(184, 220, 255, 0.18), transparent 22%),
    linear-gradient(150deg, #172532 0%, #101827 54%, #070b12 100%);
}

button {
  font: inherit;
}

.shell {
  width: 100vw;
  min-height: var(--app-height);
  display: grid;
  place-items: center;
  padding:
    max(10px, var(--safe-top))
    max(10px, var(--safe-right))
    max(10px, var(--safe-bottom))
    max(10px, var(--safe-left));
}

.game-wrap {
  position: relative;
  width: min(var(--stage-max-width), 432px, calc(var(--stage-max-height) * 0.675));
  aspect-ratio: 432 / 640;
  max-height: var(--stage-max-height);
  border-radius: 8px;
  overflow: hidden;
  box-shadow: 0 28px 70px rgba(0, 0, 0, 0.42);
  background: #8bd3ff;
  touch-action: manipulation;
}

body.low-power .game-wrap {
  box-shadow: 0 12px 30px rgba(0, 0, 0, 0.28);
}

.game-wrap:fullscreen {
  width: 100vw;
  height: 100vh;
  max-width: none;
  max-height: none;
  aspect-ratio: auto;
  border-radius: 0;
  box-shadow: none;
}

canvas {
  width: 100%;
  height: 100%;
  display: block;
  touch-action: none;
}

.hud {
  position: absolute;
  inset: 0;
  z-index: 3;
  pointer-events: none;
  padding:
    max(clamp(14px, 4vw, 22px), var(--safe-top))
    max(clamp(14px, 4vw, 22px), var(--safe-right))
    max(clamp(14px, 4vw, 22px), var(--safe-bottom))
    max(clamp(14px, 4vw, 22px), var(--safe-left));
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
}

.brand-logo,
.score-card,
.health-card,
.ember-card,
.hud-objectives {
  color: #fff9df;
  text-shadow: 0 2px 0 rgba(39, 61, 67, 0.28);
}

.brand-logo {
  width: clamp(72px, 18vw, 102px);
  height: auto;
  display: block;
  object-fit: contain;
  filter: drop-shadow(0 3px 0 rgba(39, 61, 67, 0.3));
}

body.low-power .brand-logo {
  filter: none;
}

.hud-left-actions {
  position: absolute;
  left: clamp(14px, 4vw, 22px);
  bottom: clamp(14px, 4vw, 22px);
  display: flex;
  align-items: center;
  gap: 6px;
  pointer-events: auto;
}

.health-card {
  position: absolute;
  top: clamp(14px, 4vw, 22px);
  left: 50%;
  transform: translateX(-50%);
  width: min(34%, 150px);
  padding: 6px 8px 8px;
  border: 2px solid rgba(255, 255, 255, 0.58);
  border-radius: 8px;
  background: rgba(21, 34, 43, 0.28);
  backdrop-filter: blur(6px);
}

body.low-power .health-card,
body.low-power .score-card,
body.low-power .ember-card,
body.low-power .hud-objectives,
body.low-power .icon-btn,
body.low-power .story-btn,
body.low-power .fire-btn {
  backdrop-filter: none;
}

body.android-app .health-card,
body.android-app .score-card,
body.android-app .ember-card,
body.android-app .hud-objectives,
body.android-app .icon-btn,
body.android-app .story-btn,
body.android-app .fullscreen-btn,
body.android-app .fire-btn,
body.android-app .story-overlay,
body.android-app .speed-overlay,
body.android-app .menu-overlay {
  backdrop-filter: none;
}

.health-card span {
  display: block;
  margin-bottom: 4px;
  font-size: 10px;
  font-weight: 900;
  text-transform: uppercase;
}

.health-track {
  width: 100%;
  height: 10px;
  overflow: hidden;
  border-radius: 8px;
  background: rgba(255, 255, 255, 0.36);
  box-shadow: inset 0 1px 3px rgba(13, 28, 36, 0.3);
}

.health-fill {
  width: 100%;
  height: 100%;
  border-radius: inherit;
  background: #45d66e;
  transition: width 180ms ease, background 180ms ease;
}

.health-fill.low {
  background: #e0443f;
}

.streak-line {
  display: flex;
  justify-content: space-between;
  gap: 8px;
  margin-top: 5px;
  font-size: 9px;
  font-weight: 950;
  text-transform: uppercase;
}

.streak-line strong {
  color: #ffe066;
}

.surge-track {
  width: 100%;
  height: 6px;
  margin-top: 4px;
  overflow: hidden;
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.26);
  box-shadow: inset 0 1px 2px rgba(13, 28, 36, 0.26);
}

.surge-fill {
  width: 0%;
  height: 100%;
  border-radius: inherit;
  background: linear-gradient(90deg, #ff7a32, #ffe066);
  transition: width 180ms ease;
}

.surge-fill.active {
  background: linear-gradient(90deg, #fff2aa, #ff7a32, #e83b28);
  box-shadow: 0 0 10px rgba(255, 122, 50, 0.72);
}

.surge-fill.ending {
  background: linear-gradient(90deg, #ffead0, #ff6f32, #d52f2f);
  animation: surgeWarn 220ms ease-in-out infinite alternate;
}

.surge-fill.grace {
  background: linear-gradient(90deg, #ffe066, #c96535);
  opacity: 0.62;
}

.surge-warning {
  margin-top: 3px;
  color: #fff2aa;
  font-size: 9px;
  font-weight: 950;
  text-align: center;
  text-transform: uppercase;
  animation: surgeWarn 220ms ease-in-out infinite alternate;
}

.surge-warning.hidden {
  visibility: hidden;
}

.distance-line {
  display: none;
  justify-content: space-between;
  gap: 8px;
  margin-top: 5px;
  font-size: 9px;
  font-weight: 950;
  text-transform: uppercase;
}

body.journey-mode .distance-line {
  display: flex;
}

.distance-line strong {
  color: #fff2a1;
}

.distance-track {
  display: none;
  width: 100%;
  height: 6px;
  margin-top: 4px;
  overflow: hidden;
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.25);
  box-shadow: inset 0 1px 3px rgba(13, 28, 36, 0.24);
}

body.journey-mode .distance-track {
  display: block;
}

.distance-fill {
  width: 0%;
  height: 100%;
  border-radius: inherit;
  background: linear-gradient(90deg, #45d66e, #ffe066, #ff8a38);
  transition: width 140ms linear;
}

.hud-objectives {
  position: absolute;
  left: calc(clamp(14px, 4vw, 22px) + 82px);
  right: auto;
  bottom: clamp(14px, 4vw, 22px);
  display: none;
  width: auto;
  max-width: min(58vw, 620px);
  min-height: 34px;
  padding: 5px 8px;
  border: 1px solid rgba(255, 255, 255, 0.5);
  border-radius: 8px;
  background: rgba(21, 34, 43, 0.42);
  backdrop-filter: blur(4px);
  contain: layout paint;
  align-items: center;
  gap: 10px;
  min-width: 0;
}

body.journey-mode.show-play-hud .hud-objectives {
  display: flex;
}

.hud-objectives > span {
  display: block;
  flex: 0 0 auto;
  max-width: 120px;
  overflow: hidden;
  font-size: 9px;
  font-weight: 950;
  line-height: 1;
  text-transform: uppercase;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.hud-objectives > strong {
  display: none;
  flex: 0 1 110px;
  color: #fff2a1;
  font-size: 7px;
  font-weight: 950;
  line-height: 1.1;
}

.hud-objective-checklist {
  flex: 1 1 auto;
  min-width: 0;
  margin: 0;
  display: flex;
  flex-wrap: wrap;
  justify-content: flex-start;
  align-items: center;
  gap: 5px 7px;
}

.hud-objective-checklist li {
  display: inline-flex;
  align-items: center;
  gap: 3px;
  color: #fff9df;
  font-size: clamp(5.4px, 1.65vw, 7px);
  font-weight: 900;
  line-height: 1.12;
  text-shadow: 0 1px 0 rgba(39, 61, 67, 0.34);
  white-space: nowrap;
}

.hud-objective-checklist li span {
  width: 9px;
  height: 9px;
  flex: 0 0 auto;
  border-width: 1px;
  background: rgba(255, 255, 255, 0.18);
}

.hud-objective-checklist li.done {
  color: #dfffd7;
}

.hud-objective-checklist li.done span {
  background: #45d66e;
  border-color: #dfffd7;
}

@media (min-width: 900px) and (min-height: 520px) {
  .hud-objectives {
    left: 126px;
    bottom: 18px;
    width: min(52vw, 660px);
    max-width: none;
    min-height: 38px;
    padding: 6px 10px;
    gap: 10px;
    border-width: 2px;
    background: rgba(25, 42, 50, 0.52);
  }

  .hud-objectives > span {
    flex: 0 1 210px;
    max-width: 210px;
    font-size: 12px;
    line-height: 1;
  }

  .hud-objective-checklist {
    flex: 1 1 auto;
    justify-content: flex-end;
    gap: 7px 10px;
  }

  .hud-objective-checklist li {
    gap: 5px;
    font-size: 11px;
    line-height: 1;
  }

  .hud-objective-checklist li span {
    width: 11px;
    height: 11px;
    border-width: 1px;
  }
}

.icon-btn {
  min-width: 42px;
  min-height: 34px;
  border: 2px solid rgba(255, 255, 255, 0.58);
  border-radius: 8px;
  color: #fff9df;
  background: rgba(21, 34, 43, 0.3);
  box-shadow: 0 2px 0 rgba(39, 61, 67, 0.2);
  backdrop-filter: blur(6px);
  font-size: 10px;
  font-weight: 950;
  cursor: pointer;
  text-shadow: 0 2px 0 rgba(39, 61, 67, 0.28);
}

.pause-btn,
.objective-btn,
.fullscreen-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 5px;
}

.menu-mark {
  width: 19px;
  height: 19px;
  display: grid;
  align-content: center;
  gap: 3px;
  padding: 3px;
  border-radius: 50%;
  background: radial-gradient(circle at 35% 28%, #fff2aa, #ff7a32 46%, #cf3929 72%);
  box-shadow: 0 0 0 2px rgba(255, 249, 223, 0.72), 0 2px 0 rgba(39, 61, 67, 0.24);
}

.menu-mark span {
  height: 2px;
  border-radius: 999px;
  background: #20323c;
}

.icon-btn:disabled {
  opacity: 0.48;
  cursor: default;
}

.icon-btn:hover {
  background: rgba(21, 34, 43, 0.44);
}

.icon-btn:active {
  transform: translateY(1px);
}

.story-btn {
  min-width: 92px;
  min-height: 34px;
  border: 2px solid rgba(255, 255, 255, 0.58);
  border-radius: 8px;
  color: #fff9df;
  background: rgba(21, 34, 43, 0.3);
  box-shadow: 0 2px 0 rgba(39, 61, 67, 0.2);
  backdrop-filter: blur(6px);
  font-size: 11px;
  font-weight: 950;
  cursor: pointer;
  text-shadow: 0 2px 0 rgba(39, 61, 67, 0.28);
}

.fullscreen-btn {
  position: absolute;
  z-index: 8;
  right: clamp(14px, 4vw, 22px);
  bottom: clamp(14px, 4vw, 22px);
  min-width: 62px;
  min-height: 34px;
  border: 2px solid rgba(255, 255, 255, 0.58);
  border-radius: 8px;
  color: #fff9df;
  background: rgba(21, 34, 43, 0.3);
  box-shadow: 0 2px 0 rgba(39, 61, 67, 0.2);
  backdrop-filter: blur(6px);
  font-size: 10px;
  font-weight: 950;
  cursor: pointer;
  pointer-events: auto;
  text-shadow: 0 2px 0 rgba(39, 61, 67, 0.28);
}

.fullscreen-btn[hidden] {
  display: none;
}

.fire-btn {
  position: absolute;
  z-index: 8;
  right: clamp(82px, 14vw, 96px);
  bottom: clamp(14px, 4vw, 22px);
  width: 62px;
  height: 62px;
  min-width: 62px;
  min-height: 62px;
  border: 2px solid rgba(255, 255, 255, 0.68);
  border-radius: 50%;
  color: #fff9df;
  background: linear-gradient(180deg, rgba(255, 122, 47, 0.86), rgba(207, 57, 41, 0.88));
  box-shadow: 0 3px 0 rgba(109, 40, 23, 0.42), 0 0 18px rgba(255, 159, 48, 0.22);
  backdrop-filter: blur(6px);
  font-size: 9px;
  font-weight: 950;
  cursor: pointer;
  pointer-events: auto;
  text-shadow: 0 2px 0 rgba(82, 37, 28, 0.34);
  display: inline-flex;
  align-items: center;
  justify-content: center;
  flex-direction: column;
  gap: 5px;
}

.fire-btn.hidden {
  display: none;
}

.fire-btn.movable {
  touch-action: none;
  user-select: none;
}

.fire-btn.is-dragging {
  opacity: 0.88;
  transform: scale(1.04);
}

.fire-btn:disabled {
  opacity: 0.48;
  cursor: default;
  filter: saturate(0.65);
}

.fire-btn:not(:disabled):active {
  transform: translateY(1px);
}

.fire-mark {
  width: 18px;
  height: 18px;
  display: inline-block;
  border-radius: 50%;
  background:
    radial-gradient(circle at 50% 56%, #fff7a8 0 20%, #ffb531 21% 45%, #ff6734 46% 72%, rgba(195, 31, 28, 0) 73%),
    radial-gradient(circle at 50% 50%, rgba(255, 224, 90, 0.86), rgba(255, 109, 49, 0.34) 58%, rgba(255, 109, 49, 0) 70%);
  box-shadow: 0 0 0 2px rgba(255, 249, 223, 0.52), 0 0 14px rgba(255, 186, 48, 0.48);
}

.fullscreen-mark {
  width: 16px;
  height: 16px;
  flex: 0 0 16px;
  display: inline-block;
  border: 3px solid #fff9df;
  border-radius: 3px;
  box-shadow: inset 0 0 0 3px rgba(21, 34, 43, 0.3), 0 2px 0 rgba(39, 61, 67, 0.18);
}

body.fullscreen-active .fullscreen-mark {
  border-color: #ffe066;
}

.objective-mark {
  width: 19px;
  height: 19px;
  flex: 0 0 19px;
  display: inline-block;
  border-radius: 50%;
  background:
    radial-gradient(circle at 50% 48%, #ffe066 0 20%, transparent 22%),
    radial-gradient(circle at 50% 50%, #ff7a32 0 43%, #cf3929 45% 62%, #20323c 64% 74%, #43a9db 76%);
  box-shadow: 0 0 0 2px rgba(255, 249, 223, 0.75), 0 2px 0 rgba(39, 61, 67, 0.22);
}

body[data-world="frost"] .objective-mark {
  background:
    linear-gradient(135deg, transparent 28%, #ffffff 29% 35%, transparent 36%),
    radial-gradient(circle at 50% 48%, #ffffff 0 18%, transparent 20%),
    radial-gradient(circle at 50% 50%, #9ce5ff 0 43%, #4da8d3 45% 62%, #20323c 64% 74%, #e8fbff 76%);
}

body[data-world="volcano"] .objective-mark {
  background:
    radial-gradient(circle at 50% 36%, #fff2aa 0 16%, transparent 18%),
    radial-gradient(circle at 50% 50%, #ff7a32 0 38%, #e83b28 40% 60%, #54251e 62% 74%, #ffe066 76%);
}

body[data-world="storm"] .objective-mark {
  background:
    linear-gradient(135deg, transparent 30%, #fff2aa 31% 41%, transparent 42%),
    radial-gradient(circle at 50% 50%, #82d3ff 0 40%, #315176 42% 60%, #20323c 62% 74%, #e8fbff 76%);
}

.objective-mark.large {
  width: 46px;
  height: 46px;
  flex-basis: 46px;
}

.story-btn:hover {
  background: rgba(21, 34, 43, 0.44);
}

.story-btn:active {
  transform: translateY(1px);
}

.score-card {
  position: absolute;
  top: clamp(14px, 4vw, 22px);
  right: clamp(14px, 4vw, 22px);
  min-width: 62px;
  padding: 6px 8px;
  border: 2px solid rgba(255, 255, 255, 0.55);
  border-radius: 8px;
  background: rgba(21, 34, 43, 0.28);
  backdrop-filter: blur(6px);
  text-align: center;
}

.ember-card {
  position: absolute;
  top: clamp(76px, 18vw, 92px);
  right: clamp(14px, 4vw, 22px);
  min-width: 70px;
  padding: 6px 8px 7px;
  border: 2px solid rgba(255, 255, 255, 0.48);
  border-radius: 8px;
  background: rgba(21, 34, 43, 0.25);
  backdrop-filter: blur(6px);
  text-align: center;
}

.ember-card > span {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 3px;
  white-space: nowrap;
  font-size: 8px;
  font-weight: 900;
  text-transform: uppercase;
}

.ember-card strong {
  display: block;
  line-height: 1;
  margin-top: 2px;
  font-size: 20px;
  color: #ffe066;
}

.ember-gem {
  width: 11px;
  height: 11px;
  flex: 0 0 11px;
  display: inline-block;
  border-radius: 50% 50% 45% 45%;
  background:
    radial-gradient(circle at 50% 38%, #fff59d 0 18%, #ffbd42 20% 43%, #ff7132 45% 67%, #9f2c24 70% 100%);
  box-shadow:
    0 0 5px rgba(255, 142, 48, 0.78),
    inset 0 -2px 0 rgba(125, 39, 28, 0.32);
}

.score-card span {
  display: block;
  font-size: 10px;
  font-weight: 800;
  text-transform: uppercase;
  letter-spacing: 0;
  opacity: 0.9;
}

.score-card strong {
  display: block;
  line-height: 1;
  margin-top: 3px;
  font-size: 24px;
}

.journey-toast {
  position: absolute;
  left: 50%;
  top: 102px;
  z-index: 4;
  width: min(82%, 330px);
  transform: translateX(-50%);
  border: 2px solid rgba(255, 255, 255, 0.66);
  border-radius: 8px;
  padding: 9px 12px;
  color: #fff9df;
  background: rgba(32, 50, 60, 0.78);
  box-shadow: 0 12px 28px rgba(14, 25, 32, 0.24);
  font-size: 12px;
  font-weight: 900;
  text-align: center;
  text-shadow: 0 2px 0 rgba(39, 61, 67, 0.28);
  pointer-events: none;
}

.journey-toast.hidden {
  display: none;
}

.training-callout {
  position: absolute;
  left: 50%;
  bottom: calc(var(--safe-bottom) + clamp(118px, 17vh, 168px));
  z-index: 3;
  max-width: min(74vw, 460px);
  transform: translateX(-50%);
  padding: 9px 18px;
  border: 3px solid rgba(255, 255, 255, 0.9);
  border-radius: 14px;
  background: rgba(255, 245, 190, 0.94);
  color: #1c3440;
  font-size: clamp(17px, 3vw, 30px);
  font-weight: 950;
  line-height: 1.05;
  text-align: center;
  text-shadow: 0 2px 0 rgba(255, 255, 255, 0.75);
  box-shadow: 0 14px 34px rgba(31, 42, 48, 0.22);
  pointer-events: none;
  animation: tutorialPop 420ms ease-out;
}

.training-callout.hidden {
  display: none;
}

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

.overlay {
  position: absolute;
  inset: 0;
  z-index: 5;
  display: grid;
  place-items: center;
  padding: max(12px, var(--safe-top)) max(12px, var(--safe-right)) max(12px, var(--safe-bottom)) max(12px, var(--safe-left));
  background: linear-gradient(180deg, rgba(10, 24, 36, 0.12), rgba(10, 24, 36, 0.42));
}

.overlay.hidden {
  display: none;
}

.story-overlay {
  position: absolute;
  inset: 0;
  z-index: 4;
  display: grid;
  place-items: center;
  padding: 24px;
  background: rgba(8, 18, 26, 0.5);
  backdrop-filter: blur(3px);
  animation: storyFadeIn 260ms ease both;
}

body.low-power .story-overlay,
body.low-power .speed-overlay,
body.low-power .menu-overlay,
body.low-power .help-overlay,
body.low-power .store-overlay {
  backdrop-filter: none;
}

.speed-overlay,
.menu-overlay,
.help-overlay,
.store-overlay {
  position: absolute;
  inset: 0;
  z-index: 7;
  display: grid;
  place-items: center;
  padding: 24px;
  background: rgba(8, 18, 26, 0.42);
  backdrop-filter: blur(2px);
}

.store-overlay {
  z-index: 8;
}

.speed-overlay.hidden,
.menu-overlay.hidden,
.help-overlay.hidden,
.store-overlay.hidden {
  display: none;
}

.speed-panel,
.menu-panel,
.help-panel,
.store-panel {
  width: min(100%, 314px);
  border-radius: 8px;
  border: 2px solid rgba(255, 255, 255, 0.72);
  background: rgba(255, 249, 223, 0.95);
  box-shadow: 0 20px 50px rgba(14, 25, 32, 0.28);
  padding: 18px;
  text-align: center;
  color: #263841;
}

.menu-panel h2,
.help-panel h2,
.store-panel h2 {
  margin: 0 0 12px;
  color: #20323c;
  font-size: 26px;
  line-height: 1;
}

.help-grid {
  display: grid;
  gap: 10px;
  margin: 4px 0 14px;
}

.help-card {
  display: grid;
  gap: 7px;
  padding: 12px;
  border: 2px solid rgba(32, 50, 60, 0.12);
  border-radius: 8px;
  background: rgba(255, 255, 255, 0.42);
  text-align: left;
}

.help-card h3 {
  margin: 0 0 2px;
  color: #c55d3c;
  font-size: 14px;
  line-height: 1;
  text-transform: uppercase;
}

.help-card p {
  display: grid;
  grid-template-columns: minmax(96px, 1fr) auto;
  align-items: center;
  gap: 10px;
  margin: 0;
  color: #20323c;
  font-size: 14px;
  font-weight: 850;
}

.help-card strong {
  color: #20323c;
  font-size: 15px;
  font-weight: 950;
}

.help-card span {
  justify-self: end;
  padding: 4px 8px;
  border-radius: 999px;
  color: #fff9df;
  background: #45a564;
  font-size: 12px;
  font-weight: 950;
}

.store-panel {
  max-height: calc(100% - 34px);
  overflow-y: auto;
}

.store-balance {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  margin: -4px 0 12px;
  padding: 5px 9px;
  border-radius: 999px;
  color: #20323c;
  background: rgba(255, 224, 102, 0.42);
  font-size: 13px;
  font-weight: 950;
}

.skin-list {
  display: grid;
  gap: 8px;
  margin-bottom: 12px;
}

.skin-card {
  display: grid;
  grid-template-columns: 92px 1fr auto;
  align-items: center;
  gap: 10px;
  padding: 9px;
  border: 2px solid rgba(32, 50, 60, 0.14);
  border-radius: 8px;
  background: rgba(255, 255, 255, 0.44);
  text-align: left;
}

.skin-card.active {
  border-color: #45a564;
  background: rgba(223, 255, 215, 0.72);
}

.skin-preview {
  position: relative;
  width: 88px;
  height: 58px;
  overflow: hidden;
  border: 2px solid rgba(67, 158, 220, 0.44);
  border-radius: 8px;
  background: radial-gradient(circle at 72% 20%, rgba(255, 255, 255, 0.2), rgba(0, 27, 48, 0.92) 72%);
  box-shadow: inset 0 0 18px rgba(33, 161, 230, 0.22), 0 3px 0 rgba(32, 50, 60, 0.18);
}

.skin-preview span {
  position: absolute;
  display: block;
}

.skin-trail {
  left: 4px;
  bottom: 6px;
  width: 58px;
  height: 28px;
  border-radius: 999px;
  opacity: 0.78;
  background: linear-gradient(110deg, transparent, var(--skin-mid), var(--skin-light));
  filter: blur(2px);
  transform: rotate(-33deg);
}

.skin-tail {
  left: 19px;
  top: 34px;
  width: 38px;
  height: 12px;
  border-radius: 100% 8px 100% 8px;
  background: linear-gradient(90deg, var(--skin-dark), var(--skin-mid), var(--skin-light));
  transform: rotate(-33deg);
}

.skin-wing {
  left: 25px;
  top: 15px;
  width: 42px;
  height: 19px;
  border-radius: 100% 10px 100% 10px;
  background: linear-gradient(135deg, var(--skin-wing-light), var(--skin-wing) 48%, var(--skin-dark));
  transform: rotate(-29deg);
  transform-origin: 75% 80%;
}

.skin-body {
  left: 42px;
  top: 20px;
  width: 32px;
  height: 24px;
  border-radius: 58% 48% 54% 46%;
  background: radial-gradient(circle at 70% 30%, var(--skin-light) 0 18%, var(--skin-mid) 44%, var(--skin-dark) 100%);
  box-shadow: inset -5px -4px 0 rgba(0, 0, 0, 0.12);
}

.skin-eye {
  left: 64px;
  top: 19px;
  width: 10px;
  height: 10px;
  border-radius: 50%;
  background: radial-gradient(circle at 68% 38%, #18242d 0 28%, #fff 30% 100%);
  box-shadow: 0 0 0 1px rgba(32, 50, 60, 0.22);
}

.skin-beak {
  left: 72px;
  top: 29px;
  width: 16px;
  height: 11px;
  clip-path: polygon(0 20%, 100% 50%, 0 86%);
  background: linear-gradient(90deg, var(--skin-beak), #ff9d26);
}

.skin-name {
  display: block;
  color: #20323c;
  font-size: 13px;
  font-weight: 950;
}

.skin-meta {
  display: block;
  color: rgba(32, 50, 60, 0.72);
  font-size: 10px;
  font-weight: 850;
}

.skin-card button,
#store-close {
  min-height: 34px;
  border: 0;
  border-radius: 8px;
  color: #fff9df;
  background: #df6d42;
  box-shadow: inset 0 -3px 0 rgba(111, 45, 31, 0.34);
  font-size: 12px;
  font-weight: 950;
  cursor: pointer;
}

.skin-card button.selected {
  background: #45a564;
  box-shadow: inset 0 -3px 0 rgba(24, 78, 58, 0.38);
}

.skin-card button:disabled {
  opacity: 0.55;
  cursor: not-allowed;
}

#store-close {
  width: 100%;
  min-height: 42px;
  font-size: 16px;
}

.menu-actions {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 8px;
}

.speedometer {
  position: relative;
  width: min(100%, 260px);
  height: 118px;
  margin: 4px auto 12px;
  display: grid;
  place-items: end center;
}

.speedometer-arc {
  position: absolute;
  left: 50%;
  bottom: 0;
  width: 220px;
  height: 110px;
  transform: translateX(-50%);
  border-radius: 120px 120px 0 0;
  background:
    conic-gradient(
      from 251deg at 50% 100%,
      #206b45 0deg 28deg,
      #45a564 28deg 56deg,
      #ffe066 56deg 84deg,
      #df6d42 84deg 112deg,
      #d9362f 112deg 150deg,
      rgba(32, 50, 60, 0.16) 150deg 180deg,
      transparent 180deg
    ),
    rgba(32, 50, 60, 0.13);
  box-shadow: inset 0 -8px 0 rgba(32, 50, 60, 0.12);
}

.speedometer-arc::after {
  content: "";
  position: absolute;
  left: 50%;
  bottom: 0;
  width: 150px;
  height: 75px;
  transform: translateX(-50%);
  border-radius: 90px 90px 0 0;
  background: rgba(255, 249, 223, 0.96);
}

.speedometer-needle {
  --speed-angle: -42deg;
  position: absolute;
  left: 50%;
  bottom: 18px;
  width: 8px;
  height: 74px;
  transform-origin: 50% 100%;
  transform: translateX(-50%) rotate(var(--speed-angle));
  border-radius: 999px;
  background: linear-gradient(180deg, #e83b28, #20323c);
  box-shadow: 0 2px 0 rgba(39, 61, 67, 0.18);
  transition: transform 220ms ease;
  z-index: 2;
}

.speedometer-hub {
  position: absolute;
  left: 50%;
  bottom: 10px;
  width: 34px;
  height: 34px;
  transform: translateX(-50%);
  border: 4px solid #fff9df;
  border-radius: 50%;
  background: radial-gradient(circle at 35% 30%, #ffe066, #ff7a32 55%, #20323c 58%);
  box-shadow: 0 4px 0 rgba(39, 61, 67, 0.24);
  z-index: 3;
}

#speed-readout {
  position: absolute;
  bottom: 42px;
  z-index: 4;
  color: #20323c;
  font-size: 16px;
  font-weight: 950;
}

.speed-options {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 8px;
  margin: 12px 0 14px;
}

.speed-stepper {
  display: grid;
  grid-template-columns: 56px 1fr 56px;
  gap: 10px;
  align-items: stretch;
  margin: 12px 0 14px;
}

.speed-step-btn,
.speed-current {
  min-height: 62px;
  border-radius: 8px;
  color: #fff9df;
  box-shadow: inset 0 -4px 0 rgba(111, 45, 31, 0.34);
  font-weight: 950;
}

.speed-step-btn {
  border: 0;
  background: #df6d42;
  font-size: 30px;
  cursor: pointer;
}

.speed-step-btn:disabled {
  opacity: 0.42;
  cursor: not-allowed;
}

.speed-current {
  display: grid;
  place-items: center;
  gap: 2px;
  padding: 8px 10px;
  color: #20323c;
  background: #8ee09b;
  box-shadow:
    inset 0 -4px 0 rgba(26, 101, 61, 0.3),
    0 0 0 3px rgba(255, 249, 223, 0.84);
}

.speed-current strong {
  font-size: 30px;
  line-height: 1;
}

.speed-current span {
  font-size: 12px;
  line-height: 1;
  text-transform: uppercase;
}

.games-actions {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 8px;
  margin: 12px 0 14px;
}

.speed-option,
#speed-close,
#games-close,
#help-close,
.menu-actions button {
  min-height: 42px;
  border: 0;
  border-radius: 8px;
  color: #fff9df;
  background: #df6d42;
  box-shadow: inset 0 -3px 0 rgba(111, 45, 31, 0.34);
  font-size: 16px;
  font-weight: 950;
  cursor: pointer;
}

.speed-option {
  display: grid;
  place-items: center;
  gap: 2px;
  min-height: 58px;
  padding: 6px 4px;
}

.speed-option strong {
  font-size: 18px;
  line-height: 1;
}

.speed-option span {
  font-size: 8px;
  line-height: 1;
}

#menu-story {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 7px;
}

#menu-fullscreen[hidden] {
  display: none;
}

#menu-resume {
  grid-column: span 2;
  background: #45a564;
}

#menu-restart {
  background: #20323c;
}

.speed-option.active {
  color: #fff9df;
  background: #45a564;
  box-shadow:
    inset 0 -4px 0 rgba(26, 101, 61, 0.42),
    0 0 0 3px rgba(255, 249, 223, 0.82),
    0 0 0 5px rgba(69, 165, 100, 0.38);
}

#speed-close {
  width: 100%;
}

#games-close {
  width: 100%;
}

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

.story-panel {
  width: min(100%, 334px);
  max-height: calc(100% - 24px);
  overflow: auto;
  border-radius: 8px;
  border: 2px solid rgba(255, 255, 255, 0.76);
  background: rgba(255, 249, 223, 0.95);
  box-shadow: 0 22px 54px rgba(14, 25, 32, 0.34);
  padding: 20px;
  color: #263841;
  animation: storyRise 360ms cubic-bezier(0.19, 1, 0.22, 1) both;
}

.story-scene {
  position: relative;
  height: 142px;
  margin: -4px -2px 16px;
  overflow: hidden;
  border-radius: 8px;
  background:
    radial-gradient(circle at 34% 70%, rgba(255, 178, 58, 0.58), transparent 24%),
    linear-gradient(180deg, #263841 0%, #20323c 58%, #14232b 100%);
}

.story-scene::before,
.story-scene::after {
  content: "";
  position: absolute;
  inset: auto 0 0;
  height: 28px;
  background: linear-gradient(90deg, rgba(255, 178, 58, 0.18), rgba(86, 184, 219, 0.25));
}

.story-saint {
  position: absolute;
  left: 35px;
  bottom: 28px;
  width: 34px;
  height: 58px;
  border-radius: 18px 18px 8px 8px;
  background: linear-gradient(180deg, #fff2aa, #c87449);
  box-shadow: 0 0 26px rgba(255, 178, 58, 0.48);
  animation: saintGlow 2.4s ease-in-out infinite;
}

.story-saint::before {
  content: "";
  position: absolute;
  left: 8px;
  top: -17px;
  width: 18px;
  height: 18px;
  border-radius: 50%;
  background: #f4c58a;
}

.story-saint::after {
  content: "";
  position: absolute;
  left: -10px;
  top: 18px;
  width: 54px;
  height: 10px;
  border-radius: 999px;
  background: rgba(255, 242, 170, 0.58);
}

.story-fire {
  position: absolute;
  left: 88px;
  bottom: 18px;
  width: 74px;
  height: 82px;
  filter: drop-shadow(0 0 18px rgba(255, 111, 54, 0.76));
}

body.low-power .story-fire,
body.low-power .story-saint,
body.low-power .story-phoenix .body,
body.low-power .story-ice {
  filter: none;
  box-shadow: none;
}

.story-fire span {
  position: absolute;
  bottom: 0;
  border-radius: 48% 52% 46% 54%;
  transform-origin: 50% 100%;
  animation: storyFlame 680ms ease-in-out infinite alternate;
}

.story-fire span:nth-child(1) {
  left: 16px;
  width: 44px;
  height: 76px;
  background: #ef4f2f;
}

.story-fire span:nth-child(2) {
  left: 27px;
  width: 30px;
  height: 58px;
  background: #ffb23a;
  animation-delay: 120ms;
}

.story-fire span:nth-child(3) {
  left: 34px;
  width: 19px;
  height: 38px;
  background: #fff2aa;
  animation-delay: 240ms;
}

.story-phoenix {
  position: absolute;
  left: 130px;
  bottom: 46px;
  width: 92px;
  height: 70px;
  opacity: 0;
  animation: phoenixBirth 3.2s ease-in-out infinite;
}

.story-phoenix .body {
  position: absolute;
  left: 35px;
  top: 16px;
  width: 26px;
  height: 36px;
  border-radius: 50% 50% 42% 42%;
  background: linear-gradient(180deg, #fff2aa, #f04f2f 72%);
  box-shadow: 0 0 22px rgba(255, 178, 58, 0.72);
}

.story-phoenix .body::before {
  content: "";
  position: absolute;
  right: -13px;
  top: 4px;
  width: 22px;
  height: 16px;
  border-radius: 50% 50% 48% 45%;
  background: #ffb23a;
}

.story-phoenix .wing {
  position: absolute;
  top: 10px;
  width: 48px;
  height: 35px;
  border-radius: 100% 8px 100% 24px;
  background: linear-gradient(135deg, #fff2aa, #df6d42 55%, #b63232);
  transform-origin: 84% 78%;
  --wing-side: 1;
  animation: storyWing 520ms ease-in-out infinite alternate;
}

.story-phoenix .wing.left {
  left: 0;
}

.story-phoenix .wing.right {
  right: 0;
  --wing-side: -1;
  animation-delay: 80ms;
}

.story-phoenix .tail {
  position: absolute;
  left: 24px;
  top: 48px;
  width: 48px;
  height: 24px;
  border-radius: 0 0 50% 50%;
  background: linear-gradient(90deg, #f04f2f, #ffb23a, #fff2aa);
  transform: rotate(10deg);
}

.story-ice {
  position: absolute;
  right: 46px;
  bottom: 16px;
  width: 42px;
  height: 70px;
  clip-path: polygon(50% 0, 88% 100%, 12% 100%);
  background: linear-gradient(135deg, #f5fdff, #8edaf2 48%, #3f6f9f);
  box-shadow: inset -8px -8px 0 rgba(63, 111, 159, 0.2);
  animation: iceShimmer 1.6s ease-in-out infinite alternate;
}

.story-ice.ice-two {
  right: 14px;
  bottom: 8px;
  width: 34px;
  height: 54px;
  animation-delay: 320ms;
}

.story-demon {
  position: absolute;
  right: 76px;
  top: 27px;
  width: 32px;
  height: 31px;
  border-radius: 50% 50% 44% 44%;
  background: rgba(36, 26, 44, 0.78);
  animation: demonDrift 2.2s ease-in-out infinite alternate;
}

.story-demon::before,
.story-demon::after {
  content: "";
  position: absolute;
  top: -9px;
  width: 12px;
  height: 16px;
  background: rgba(36, 26, 44, 0.78);
  clip-path: polygon(50% 0, 100% 100%, 0 100%);
}

.story-demon::before {
  left: 0;
}

.story-demon::after {
  right: 0;
}

.story-demon.demon-two {
  right: 28px;
  top: 42px;
  transform: scale(0.72);
  animation-delay: 420ms;
}

.story-panel h2 {
  margin: 0 0 12px;
  color: #20323c;
  font-size: 30px;
  line-height: 1;
}

.objective-card {
  display: flex;
  align-items: center;
  gap: 12px;
  margin: 0 0 14px;
  padding: 12px;
  border: 2px solid rgba(32, 50, 60, 0.12);
  border-radius: 8px;
  background: rgba(255, 255, 255, 0.36);
  text-align: left;
}

.objective-card p {
  margin: 0;
}

.objective-checklist {
  margin: 10px 0 0;
  padding: 0;
  list-style: none;
  display: grid;
  gap: 7px;
}

.objective-checklist li {
  display: grid;
  grid-template-columns: 20px 1fr;
  align-items: center;
  gap: 8px;
  color: #42535b;
  font-size: 13px;
  font-weight: 850;
}

.objective-checklist li span {
  width: 20px;
  height: 20px;
  display: inline-grid;
  place-items: center;
  border: 2px solid rgba(32, 50, 60, 0.28);
  border-radius: 5px;
  background: rgba(255, 255, 255, 0.42);
}

.objective-checklist li.done {
  color: #24724a;
}

.objective-checklist li.done span {
  border-color: #45a564;
  background: #45a564;
}

.objective-checklist li.done span::after {
  content: "";
  width: 9px;
  height: 5px;
  border-left: 3px solid #fff9df;
  border-bottom: 3px solid #fff9df;
  transform: rotate(-45deg) translateY(-1px);
}

.hud-objective-checklist {
  flex: 1 1 auto;
  margin: 0;
  display: flex;
  justify-content: flex-end;
  align-items: center;
  gap: 6px;
}

.hud-objective-checklist li {
  display: inline-flex;
  grid-template-columns: none;
  align-items: center;
  gap: 3px;
  color: #fff9df;
  font-size: 7px;
  font-weight: 900;
  line-height: 1.12;
  text-shadow: 0 1px 0 rgba(39, 61, 67, 0.34);
  white-space: nowrap;
}

.hud-objective-checklist li span {
  width: 10px;
  height: 10px;
  border-width: 1px;
  border-radius: 3px;
  background: rgba(255, 255, 255, 0.18);
}

.hud-objective-checklist li.done {
  color: #dfffd7;
}

.hud-objective-checklist li.done span {
  background: #45d66e;
  border-color: #dfffd7;
}

.hud-objective-checklist li.done span::after {
  width: 5px;
  height: 3px;
  border-left-width: 2px;
  border-bottom-width: 2px;
}

.start-objective-checklist {
  margin: 8px 0 0;
  padding: 8px;
  border-radius: 8px;
  background: rgba(255, 255, 255, 0.26);
  text-align: left;
}

.story-panel p:not(.kicker) {
  margin: 0 0 12px;
  color: #42535b;
  font-size: 15px;
  line-height: 1.38;
  font-weight: 650;
}

.app-version {
  padding-top: 2px;
  color: #c05a3b;
  font-size: 12px;
  font-weight: 900;
  text-transform: uppercase;
}

#story-close {
  width: 100%;
  min-height: 44px;
  margin-top: 4px;
  border: 0;
  border-radius: 8px;
  color: #fff9df;
  background: #df6d42;
  box-shadow: inset 0 -4px 0 rgba(111, 45, 31, 0.34);
  font-size: 16px;
  font-weight: 900;
  cursor: pointer;
}

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

@keyframes surgeWarn {
  from {
    filter: brightness(1);
  }

  to {
    filter: brightness(1.55);
  }
}

@keyframes storyRise {
  from {
    opacity: 0;
    transform: translateY(18px) scale(0.96);
  }
  to {
    opacity: 1;
    transform: translateY(0) scale(1);
  }
}

@keyframes saintGlow {
  0%,
  100% {
    filter: brightness(0.94);
  }
  50% {
    filter: brightness(1.16);
  }
}

@keyframes storyFlame {
  from {
    transform: scaleY(0.88) rotate(-4deg);
  }
  to {
    transform: scaleY(1.08) rotate(5deg);
  }
}

@keyframes phoenixBirth {
  0% {
    opacity: 0;
    transform: translate(-42px, 30px) scale(0.34) rotate(-12deg);
  }
  32% {
    opacity: 1;
    transform: translate(-6px, -8px) scale(0.9) rotate(4deg);
  }
  58%,
  100% {
    opacity: 1;
    transform: translate(30px, -18px) scale(1) rotate(-2deg);
  }
}

@keyframes storyWing {
  from {
    transform: scaleX(var(--wing-side)) rotate(-28deg) scaleY(0.86);
  }
  to {
    transform: scaleX(var(--wing-side)) rotate(-5deg) scaleY(1.08);
  }
}

@keyframes iceShimmer {
  from {
    filter: brightness(0.94);
  }
  to {
    filter: brightness(1.18);
  }
}

@keyframes demonDrift {
  from {
    opacity: 0.52;
    transform: translateY(0);
  }
  to {
    opacity: 0.86;
    transform: translateY(8px);
  }
}

.panel {
  width: min(100%, 314px);
  max-height: min(92%, 610px);
  border-radius: 8px;
  border: 2px solid rgba(255, 255, 255, 0.72);
  background: rgba(255, 249, 223, 0.9);
  box-shadow: 0 20px 50px rgba(14, 25, 32, 0.28);
  padding: 0;
  overflow: hidden;
  text-align: center;
  display: flex;
  flex-direction: column;
}

.panel-scroll {
  min-height: 0;
  overflow-y: auto;
  overscroll-behavior: contain;
  padding: 14px 18px 10px;
  scrollbar-width: thin;
}

.panel-actions {
  flex: 0 0 auto;
  padding: 10px 20px 18px;
  background: linear-gradient(180deg, rgba(255, 249, 223, 0.68), rgba(255, 249, 223, 0.96));
  box-shadow: 0 -10px 18px rgba(255, 249, 223, 0.66);
}

.kicker {
  margin: 0 0 7px;
  color: #c05a3b;
  font-size: 12px;
  font-weight: 900;
  text-transform: uppercase;
  letter-spacing: 0;
}

h1 {
  margin: 0;
  color: #20323c;
  font-size: 46px;
  line-height: 0.95;
}

.home-hero {
  position: relative;
  min-height: 122px;
  display: grid;
  justify-items: center;
  align-content: start;
  margin: -2px 0 10px;
  padding: 8px 10px 44px;
  overflow: hidden;
  border: 2px solid rgba(32, 50, 60, 0.12);
  border-radius: 8px;
  background:
    radial-gradient(circle at 76% 28%, rgba(255, 224, 102, 0.3), transparent 15%),
    radial-gradient(circle at 22% 62%, rgba(255, 255, 255, 0.5), transparent 18%),
    linear-gradient(180deg, #80d8ff 0%, #bdefff 56%, #dff8d4 100%);
  box-shadow: inset 0 -12px 0 rgba(69, 165, 100, 0.18);
}

.home-logo {
  width: 184px;
  max-width: 78%;
  filter: drop-shadow(0 3px 0 rgba(32, 50, 60, 0.22));
}

.home-status {
  position: absolute;
  left: 10px;
  right: 10px;
  bottom: 9px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
}

.home-status > span {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  padding: 5px 9px;
  border-radius: 999px;
  color: #20323c;
  background: rgba(255, 249, 223, 0.72);
  font-size: 12px;
  font-weight: 950;
}

.home-actions {
  display: flex;
  align-items: center;
  gap: 6px;
}

.home-menu-btn,
#home-store {
  min-height: 30px;
  padding: 0 12px;
  border: 0;
  border-radius: 8px;
  color: #fff9df;
  background: #20323c;
  box-shadow: inset 0 -3px 0 rgba(0, 0, 0, 0.22);
  font-size: 11px;
  font-weight: 950;
}

.home-menu-btn {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  padding: 0 10px;
  background: #e76e43;
}

.home-menu-btn .menu-mark {
  width: 18px;
  height: 18px;
  border-width: 2px;
}

.home-menu-btn .menu-mark span {
  height: 2px;
}

.mode-select,
.world-select,
.level-select {
  display: grid;
  gap: 6px;
  margin: 8px 0;
}

.mode-select {
  grid-template-columns: repeat(2, 1fr);
}

.world-select {
  grid-template-columns: repeat(2, 1fr);
}

.level-select {
  display: none;
  grid-template-columns: 42px 1fr 42px;
  align-items: center;
}

body.journey-mode .level-select {
  display: grid;
}

body.journey-mode .level-map {
  display: block;
}

.mode-option,
.world-option,
.level-step {
  min-height: 34px;
  border: 2px solid rgba(32, 50, 60, 0.16);
  border-radius: 8px;
  color: #263841;
  background: rgba(255, 255, 255, 0.55);
  font-size: 11px;
  font-weight: 950;
  cursor: pointer;
}

.level-step:disabled {
  opacity: 0.42;
  cursor: not-allowed;
}

#level-label {
  min-height: 34px;
  display: grid;
  place-items: center;
  border: 2px solid rgba(32, 50, 60, 0.16);
  border-radius: 8px;
  color: #20323c;
  background: rgba(255, 224, 102, 0.58);
  font-size: 11px;
  font-weight: 950;
}

.level-map {
  position: relative;
  display: none;
  height: min(46vh, 390px);
  margin: 8px 0 10px;
  overflow-y: auto;
  overscroll-behavior: contain;
  border: 2px solid rgba(32, 50, 60, 0.14);
  border-radius: 8px;
  background:
    radial-gradient(circle at 20% 20%, rgba(255, 255, 255, 0.34), transparent 16%),
    radial-gradient(circle at 76% 70%, rgba(255, 255, 255, 0.24), transparent 18%),
    linear-gradient(180deg, #7bd5ff 0%, #8fe66e 54%, #58c85a 100%);
  box-shadow: inset 0 -18px 0 rgba(98, 160, 58, 0.16);
  scrollbar-width: thin;
}

body[data-world="frost"] .level-map {
  background:
    radial-gradient(circle at 18% 20%, rgba(255, 255, 255, 0.42), transparent 16%),
    radial-gradient(circle at 78% 72%, rgba(255, 255, 255, 0.28), transparent 18%),
    linear-gradient(180deg, #a7dfff 0%, #dffaff 48%, #9ce5ff 100%);
  box-shadow: inset 0 -18px 0 rgba(76, 150, 186, 0.16);
}

body[data-world="volcano"] .level-map {
  background:
    radial-gradient(circle at 18% 20%, rgba(255, 224, 102, 0.28), transparent 16%),
    radial-gradient(circle at 78% 72%, rgba(255, 122, 50, 0.26), transparent 18%),
    linear-gradient(180deg, #f2a64e 0%, #d85c38 50%, #7f3828 100%);
  box-shadow: inset 0 -18px 0 rgba(57, 32, 28, 0.18);
}

body[data-world="storm"] .level-map {
  background:
    radial-gradient(circle at 18% 20%, rgba(255, 242, 170, 0.24), transparent 16%),
    radial-gradient(circle at 78% 72%, rgba(130, 211, 255, 0.24), transparent 18%),
    linear-gradient(180deg, #315176 0%, #537196 48%, #263f69 100%);
  box-shadow: inset 0 -18px 0 rgba(12, 24, 42, 0.2);
}

.level-map-head {
  position: sticky;
  top: 0;
  z-index: 2;
  display: flex;
  justify-content: space-between;
  gap: 8px;
  padding: 7px 9px;
  color: #fff9df;
  background: rgba(32, 50, 60, 0.68);
  font-size: 10px;
  font-weight: 950;
  text-transform: uppercase;
  text-shadow: 0 2px 0 rgba(39, 61, 67, 0.28);
}

.level-map-track {
  position: relative;
  min-height: 920px;
  margin-top: -1px;
}

.level-map-path {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 920px;
  pointer-events: none;
}

.level-map-path polyline {
  fill: none;
  stroke: rgba(255, 230, 150, 0.88);
  stroke-width: 6;
  stroke-linecap: round;
  stroke-linejoin: round;
  filter: drop-shadow(0 3px 0 rgba(111, 77, 38, 0.28));
}

.level-node {
  position: absolute;
  z-index: 1;
  width: 38px;
  height: 38px;
  transform: translate(-50%, -50%);
  border: 3px solid #1e6c9c;
  border-radius: 50%;
  color: #fff9df;
  background: linear-gradient(180deg, #a9b7c2, #51626f);
  box-shadow: 0 4px 0 #174866, 0 8px 14px rgba(14, 25, 32, 0.28);
  font-size: 10px;
  font-weight: 950;
  cursor: pointer;
}

.level-node-stars {
  position: absolute;
  z-index: 1;
  width: 74px;
  transform: translateX(-50%);
  font-size: 16px;
  font-weight: 950;
  letter-spacing: 1px;
  text-align: center;
  pointer-events: none;
}

.level-node-stars .earned {
  color: #ffd447;
  -webkit-text-stroke: 1px #a95f17;
  text-shadow: 0 2px 0 #8d4c13, 0 0 9px rgba(255, 224, 102, 0.72);
}

.level-node-stars .empty {
  color: rgba(49, 63, 70, 0.34);
  -webkit-text-stroke: 1px rgba(255, 249, 223, 0.52);
  text-shadow: none;
}

.level-node.complete {
  border-color: #1f8a5a;
  background: linear-gradient(180deg, #ffe066, #ff7a32);
  box-shadow: 0 4px 0 #b94825, 0 8px 14px rgba(14, 25, 32, 0.28);
}

.level-node.current {
  width: 46px;
  height: 46px;
  border-color: #20323c;
  background: radial-gradient(circle at 50% 36%, #fff2aa 0 18%, #ff7a32 20% 58%, #e83b28 60%);
  box-shadow: 0 5px 0 #20323c, 0 0 0 5px rgba(255, 249, 223, 0.78), 0 12px 18px rgba(14, 25, 32, 0.28);
  font-size: 15px;
}

.level-node.locked {
  border-color: #2e5e88;
  color: #d6e2ec;
  background: linear-gradient(180deg, #9caaba, #586674);
  box-shadow: 0 4px 0 #244864, 0 8px 14px rgba(14, 25, 32, 0.24);
  cursor: not-allowed;
}

.here-marker {
  position: absolute;
  z-index: 2;
  width: 72px;
  transform: translate(-50%, -50%);
  border: 3px solid #ff7a9b;
  border-radius: 8px;
  padding: 5px;
  color: #fff9df;
  background: #20323c;
  box-shadow: 0 4px 0 #ff7a9b, 0 7px 12px rgba(14, 25, 32, 0.22);
  font-size: 9px;
  font-weight: 950;
  line-height: 1.05;
  text-align: center;
  text-transform: uppercase;
  pointer-events: none;
}

.mode-option.active,
.world-option.active {
  color: #fff9df;
  background: #20323c;
  box-shadow: inset 0 -2px 0 rgba(0, 0, 0, 0.22);
}

.world-option.locked {
  opacity: 0.45;
  cursor: not-allowed;
}

.world-option.complete:not(.active) {
  color: #20323c;
  background: rgba(255, 224, 102, 0.58);
}

.panel p {
  color: #42535b;
  font-weight: 650;
}

#message {
  min-height: 48px;
  margin: 14px 0 4px;
}

#start,
.continue-btn,
.next-level-btn {
  width: 100%;
  min-height: 48px;
  border: 0;
  border-radius: 8px;
  color: #fff9df;
  background: #df6d42;
  box-shadow: inset 0 -4px 0 rgba(111, 45, 31, 0.34);
  font-size: 18px;
  font-weight: 900;
  cursor: pointer;
}

#start:hover,
.continue-btn:hover,
.next-level-btn:hover {
  background: #ed7e4d;
}

#start:active,
.continue-btn:active,
.next-level-btn:active {
  transform: translateY(2px);
  box-shadow: inset 0 -2px 0 rgba(111, 45, 31, 0.34);
}

.continue-btn,
.next-level-btn {
  margin-bottom: 10px;
  background: #20323c;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 10px;
}

.continue-btn:hover,
.next-level-btn:hover {
  background: #2b4654;
}

.continue-btn.hidden,
.next-level-btn.hidden {
  display: none;
}

.next-level-btn {
  background: #2f8f6a;
  box-shadow: inset 0 -4px 0 rgba(24, 78, 58, 0.38);
}

.continue-cost {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  color: #ffe066;
}

.continue-cost .ember-gem {
  width: 14px;
  height: 14px;
  flex-basis: 14px;
}

.level-result {
  display: grid;
  gap: 9px;
  justify-items: center;
  margin: 10px 0 12px;
  padding: 12px 14px;
  border: 2px solid rgba(255, 212, 71, 0.54);
  border-radius: 12px;
  background: radial-gradient(circle at 50% 12%, rgba(255, 240, 166, 0.68), rgba(255, 224, 102, 0.18) 56%, rgba(255, 255, 255, 0.08));
  box-shadow: inset 0 0 22px rgba(255, 224, 102, 0.2);
  animation: resultReveal 260ms ease-out both;
}

.result-title {
  color: #bd5b3e;
  font-size: 12px;
  font-weight: 950;
  line-height: 1;
  text-transform: uppercase;
}

.result-stars {
  display: flex;
  gap: clamp(8px, 2vw, 16px);
  font-size: clamp(44px, 12vw, 68px);
  line-height: 1;
}

.result-star {
  position: relative;
  display: inline-block;
  color: rgba(49, 63, 70, 0.32);
  -webkit-text-stroke: 2px rgba(32, 50, 60, 0.42);
  text-shadow: none;
}

.result-star.earned {
  color: #ffd447;
  -webkit-text-stroke: 2px #a95f17;
  text-shadow: 0 3px 0 #a95f17, 0 0 12px rgba(255, 224, 102, 0.72);
  animation: starBang 620ms cubic-bezier(0.18, 0.9, 0.28, 1.35) both;
  animation-delay: calc(120ms + var(--star-index) * 280ms);
}

.result-star.earned::after {
  content: "";
  position: absolute;
  inset: -9px;
  z-index: -1;
  border-radius: 50%;
  background: radial-gradient(circle, rgba(255, 255, 210, 0.95) 0 16%, rgba(255, 210, 55, 0.58) 17% 38%, rgba(255, 122, 44, 0) 62%);
  animation: starFlash 500ms ease-out both;
  animation-delay: calc(120ms + var(--star-index) * 280ms);
}

.result-transfer {
  display: inline-flex;
  align-items: center;
  gap: 7px;
  padding: 7px 10px;
  border-radius: 8px;
  color: #20323c;
  background: rgba(255, 224, 102, 0.46);
  font-size: 13px;
  font-weight: 950;
  animation: transferIn 420ms ease-out both;
  animation-delay: 640ms;
}

.result-transfer.rewarded {
  animation-name: transferIn, rewardPulse;
  animation-duration: 420ms, 760ms;
  animation-delay: 640ms, 960ms;
  animation-timing-function: ease-out, ease-in-out;
  animation-fill-mode: both, both;
}

@keyframes resultReveal {
  from {
    opacity: 0;
    transform: translateY(8px) scale(0.98);
  }
  to {
    opacity: 1;
    transform: translateY(0) scale(1);
  }
}

@keyframes starBang {
  0% {
    opacity: 0;
    transform: translateY(18px) scale(0.28) rotate(-18deg);
    filter: brightness(1);
  }
  38% {
    opacity: 1;
    transform: translateY(-10px) scale(1.42) rotate(8deg);
    filter: brightness(1.25);
  }
  68% {
    opacity: 1;
    transform: translateY(2px) scale(0.92) rotate(-3deg);
    filter: brightness(1.1);
  }
  100% {
    opacity: 1;
    transform: translateY(0) scale(1);
    filter: brightness(1);
  }
}

@keyframes starFlash {
  0% {
    opacity: 0;
    transform: scale(0.3);
  }
  38% {
    opacity: 1;
    transform: scale(1.25);
  }
  100% {
    opacity: 0;
    transform: scale(1.75);
  }
}

@keyframes transferIn {
  from {
    opacity: 0;
    transform: translateY(8px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

@keyframes rewardPulse {
  0%,
  100% {
    box-shadow: 0 0 0 rgba(255, 193, 61, 0);
    transform: scale(1);
  }
  48% {
    box-shadow: 0 0 20px rgba(255, 193, 61, 0.55);
    transform: scale(1.05);
  }
}

@media (max-height: 560px) {
  .game-wrap {
    width: min(var(--stage-max-width), calc(var(--stage-max-height) * 0.675));
    height: auto;
  }

  .panel {
    width: min(100%, 296px);
    max-height: calc(100% - 18px);
  }

  .panel-scroll {
    padding: 12px 14px 6px;
  }

  .panel-actions {
    padding: 8px 14px 12px;
  }

  .mode-option,
  .world-option,
  .level-step,
  #level-label {
    min-height: 30px;
    font-size: 10px;
  }

  .level-map {
    height: 122px;
  }

  .speedometer {
    height: 92px;
    margin-bottom: 8px;
  }

  .speedometer-arc {
    width: 178px;
    height: 89px;
  }

  .speedometer-arc::after {
    width: 120px;
    height: 60px;
  }

  .speedometer-needle {
    height: 58px;
    bottom: 14px;
  }

  .speedometer-hub {
    width: 28px;
    height: 28px;
    bottom: 7px;
  }

  #speed-readout {
    bottom: 34px;
    font-size: 13px;
  }

  .speed-option {
    min-height: 45px;
  }

  .speed-stepper {
    grid-template-columns: 48px 1fr 48px;
    gap: 8px;
    margin: 8px 0 10px;
  }

  .speed-step-btn,
  .speed-current {
    min-height: 52px;
  }

  .speed-current strong {
    font-size: 24px;
  }

  .speed-current span {
    font-size: 9px;
  }

  .level-node {
    width: 34px;
    height: 34px;
    font-size: 9px;
  }

  .level-node.current {
    width: 40px;
    height: 40px;
    font-size: 13px;
  }

  .here-marker {
    width: 62px;
    font-size: 8px;
  }

  h1 {
    font-size: 36px;
  }
}

@media (max-width: 390px) {
  .hud {
    padding: 12px;
  }

  .brand-logo {
    width: 78px;
  }

  .health-card {
    top: 12px;
    width: 112px;
    padding: 5px 7px 7px;
  }

  .hud-objectives {
    left: 82px;
    right: 12px;
    bottom: 12px;
    width: auto;
    max-width: none;
    padding: 4px 6px;
    gap: 4px 5px;
  }

  .hud-objectives > span {
    max-width: 78px;
    font-size: 7px;
  }

  .hud-objectives > strong {
    display: none;
  }

  .hud-objective-checklist {
    gap: 3px 5px;
  }

  .hud-objective-checklist li {
    font-size: clamp(5.2px, 1.45vw, 6.5px);
  }

  .hud-left-actions {
    left: 12px;
    bottom: 12px;
    gap: 5px;
  }

  .icon-btn {
    min-width: 36px;
    min-height: 32px;
    font-size: 8px;
  }

  .story-btn {
    min-width: 58px;
    min-height: 32px;
    font-size: 10px;
  }

  .score-card {
    top: 12px;
    right: 12px;
    min-width: 54px;
    padding: 6px;
  }

  .ember-card {
    top: 70px;
    right: 12px;
    min-width: 54px;
    padding: 5px 6px;
  }

  .score-card strong {
    font-size: 21px;
  }

  .ember-card strong {
    font-size: 16px;
  }

  .training-callout {
    bottom: calc(var(--safe-bottom) + 150px);
    max-width: min(72vw, 300px);
    padding: 8px 14px;
    font-size: clamp(16px, 5vw, 22px);
  }
}

@media (max-width: 600px) {
  .shell {
    padding: 0;
  }

  .game-wrap {
    width: 100vw;
    height: var(--app-height);
    max-height: none;
    aspect-ratio: auto;
    border-radius: 0;
    box-shadow: none;
  }

  .hud {
    padding:
      max(12px, var(--safe-top))
      max(12px, var(--safe-right))
      max(12px, var(--safe-bottom))
      max(12px, var(--safe-left));
  }
}

@media (orientation: landscape) {
  .shell {
    padding: 0;
  }

  .game-wrap {
    width: 100vw;
    height: var(--app-height);
    max-width: none;
    max-height: none;
    aspect-ratio: auto;
    border-radius: 0;
    box-shadow: none;
  }

  canvas {
    object-fit: fill;
  }

  .hud-objectives {
    left: 102px;
    right: 18px;
    bottom: 18px;
    width: auto;
    max-width: min(62vw, 760px);
  }

  .training-callout {
    bottom: calc(var(--safe-bottom) + 86px);
    max-width: min(58vw, 520px);
    font-size: clamp(16px, 2.4vw, 28px);
  }
}

@media (max-width: 340px), (max-height: 620px) {
  .hud {
    padding:
      max(9px, var(--safe-top))
      max(9px, var(--safe-right))
      max(9px, var(--safe-bottom))
      max(9px, var(--safe-left));
  }

  .brand {
    font-size: 16px;
  }

  .brand-logo {
    width: 66px;
  }

  .health-card {
    top: 9px;
    width: 100px;
    padding: 5px 6px 6px;
  }

  .hud-objectives {
    left: 72px;
    right: 9px;
    bottom: 9px;
    width: auto;
    max-width: none;
    padding: 4px 5px;
    gap: 4px;
  }

  .hud-objectives > span {
    margin-bottom: 2px;
    font-size: 8px;
  }

  .hud-objectives > strong {
    margin-bottom: 3px;
    font-size: 6.5px;
  }

  .hud-objective-checklist {
    gap: 4px;
  }

  .hud-objective-checklist li {
    gap: 3px;
    font-size: 6.2px;
  }

  .hud-objective-checklist li span {
    width: 9px;
    height: 9px;
  }

  .health-card span,
  .score-card span,
  .ember-card span {
    font-size: 9px;
  }

  .health-track {
    height: 9px;
  }

  .surge-track {
    height: 5px;
  }

  .score-card {
    top: 9px;
    right: 9px;
    min-width: 48px;
    padding: 5px;
  }

  .ember-card {
    top: 62px;
    right: 9px;
    min-width: 60px;
    padding: 4px 6px 5px;
  }

  .score-card strong {
    font-size: 19px;
  }

  .ember-card strong {
    font-size: 17px;
  }

  .journey-toast {
    top: 86px;
    width: min(78%, 270px);
    padding: 7px 9px;
    font-size: 10px;
  }

  .training-callout {
    bottom: calc(var(--safe-bottom) + 124px);
    max-width: min(70vw, 260px);
    padding: 7px 12px;
    border-width: 2px;
    font-size: clamp(14px, 4.8vw, 19px);
  }

  .hud-left-actions {
    left: 9px;
    bottom: 9px;
    gap: 5px;
  }

  .icon-btn {
    min-width: 32px;
    min-height: 29px;
    font-size: 7px;
  }

  .story-btn {
    min-width: 82px;
    min-height: 29px;
    font-size: 8px;
  }

  .fullscreen-btn {
    right: 9px;
    bottom: 9px;
    min-width: 50px;
    min-height: 29px;
    font-size: 8px;
  }

  .fire-btn {
    right: 66px;
    bottom: 9px;
    width: 58px;
    height: 58px;
    min-width: 58px;
    min-height: 58px;
    font-size: 8px;
  }

  .fire-mark {
    width: 15px;
    height: 15px;
  }

  .objective-mark,
  .menu-mark {
    width: 16px;
    height: 16px;
    flex-basis: 16px;
  }

  .panel {
    width: min(100%, 286px);
  }

  .panel-scroll {
    padding: 16px 16px 8px;
  }

  .panel-actions {
    padding: 9px 16px 15px;
  }

  h1 {
    font-size: 34px;
  }

  #message {
    min-height: 38px;
    margin: 10px 0 14px;
  }

  .story-overlay {
    padding: 14px;
  }

  .story-panel {
    width: min(100%, 306px);
    padding: 15px;
  }

  .story-scene {
    height: 116px;
    margin-bottom: 12px;
  }

  .story-panel h2 {
    font-size: 24px;
  }

  .story-panel p:not(.kicker) {
    font-size: 13px;
  }
}

@media (min-width: 900px) and (min-height: 520px) {
  body.journey-mode.show-play-hud .hud-objectives {
    left: 126px;
    right: auto;
    bottom: 18px;
    width: auto;
    max-width: min(46vw, 520px);
    min-height: 34px;
    padding: 5px 9px;
    gap: 9px;
    border-width: 2px;
    border-radius: 8px;
    background: rgba(25, 42, 50, 0.56);
  }

  .hud-objectives > span {
    flex: 0 0 auto;
    max-width: 92px;
    font-size: 10px;
  }

  .hud-objective-checklist {
    flex: 0 1 auto;
    justify-content: flex-start;
    gap: 6px 9px;
  }

  .hud-objective-checklist li {
    gap: 4px;
    font-size: 10px;
  }

  .hud-objective-checklist li span {
    width: 10px;
    height: 10px;
    border-width: 1px;
  }
}
