* {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
}

html,
body {
  width: 100%;
  height: 100%;
  min-height: 100%;
  min-height: -webkit-fill-available;
  margin: 0;
  padding: 0;
  overflow: hidden;
  background: #0f1e2a;
  font-family: var(--font-family-ui-base, "Jost", "Arial", sans-serif);
  font-weight: var(--font-weight-ui-base, 600);
  color: #e6edf3;
}

.pregame-map-loading-filters {
  position: absolute;
  width: 0;
  height: 0;
  overflow: hidden;
  pointer-events: none;
}

:root {
  --ui-scale: clamp(0.75, calc(0.75 + (((100vw - 640px) / 800px) * 0.25)), 1);
  /*
   * Typography contract:
   * shared font tokens live here and are reused by HUD/buttons/top bars.
   * Do not change these values without explicit product approval.
   */
  --font-family-ui-base: "Jost", "Arial", sans-serif;
  --font-weight-ui-base: 400;
  --font-weight-ui-strong: 500;
  --font-weight-ui-heavy: 600;
  --font-size-ui-label: calc(12px * var(--ui-scale));
  --font-size-ui-body: calc(14px * var(--ui-scale));
  --font-size-ui-body-strong: calc(16px * var(--ui-scale));
  --font-size-ui-title-card: calc(20px * var(--ui-scale));
  --font-size-ui-title-section: calc(22px * var(--ui-scale));
  --font-size-ui-title-panel: calc(28px * var(--ui-scale));
  --font-size-ui-title-display: clamp(30px, 4.2vw, 48px);
  --font-size-ui-topbar-stat: calc(30px * var(--ui-scale));
  --font-size-ui-topbar-icon: calc(30px * var(--ui-scale));
  --font-size-ui-topbar-game-icon: calc(40px * var(--ui-scale));
  --font-size-ui-button-primary: calc(36px * var(--ui-scale));
  --font-size-ui-button-secondary: calc(22px * var(--ui-scale));
  --font-size-ui-button-cost: calc(30px * var(--ui-scale));
  --font-size-ui-button-icon: calc(42px * var(--ui-scale));
}

#appShell {
  position: relative;
  width: 100%;
  height: 100%;
}

@media (display-mode: standalone), (display-mode: fullscreen) {
  #appShell {
    gap: 0;
    padding: 0;
  }

  #gameRoot {
    border: none;
    border-radius: 0;
  }
}

#appShell.panel-collapsed {
  gap: 0;
}

#gameRoot {
  position: fixed;
  inset: 0;
  width: 100vw;
  width: 100dvw;
  height: 100vh;
  height: 100dvh;
  min-height: -webkit-fill-available;
  overflow: hidden;
  background: #0f1e2a;
  padding-top: env(safe-area-inset-top, 0px);
  padding-right: env(safe-area-inset-right, 0px);
  padding-bottom: env(safe-area-inset-bottom, 0px);
  padding-left: env(safe-area-inset-left, 0px);
  --edge-gap-desktop: 16px;
  --edge-gap-mobile: 24px;
  --edge-gap: var(--edge-gap-desktop);
  --hud-edge-top: calc(env(safe-area-inset-top, 0px) + var(--edge-gap));
  --hud-edge-right: calc(env(safe-area-inset-right, 0px) + var(--edge-gap));
  --hud-edge-bottom: calc(env(safe-area-inset-bottom, 0px) + var(--edge-gap));
  --hud-edge-left: calc(env(safe-area-inset-left, 0px) + var(--edge-gap));
  --hud-button-size: 48px;
  --hud-control-gap: 10px;
  --game-topbar-left-width: 226px;
  --game-topbar-right-width: 226px;
  z-index: 1;
  touch-action: none;
  -webkit-touch-callout: none;
  -webkit-user-select: none;
  user-select: none;
}

.pregame-ui-layer,
.game-ui-layer {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  pointer-events: none;
}

.pregame-ui-layer {
  z-index: 4;
}

.game-ui-layer {
  z-index: 2;
}

.pregame-ui-layer .pregame-topbar-burger,
.pregame-ui-layer .pregame-bottom-actions,
.pregame-ui-layer .pregame-upgrade-panel,
.game-ui-layer .pregame-topbar-burger,
.game-ui-layer #waveStart,
.game-ui-layer #speedControls,
.game-ui-layer #waveRestart,
.game-ui-layer .settings-popup.is-visible,
.game-ui-layer .settings-popup.is-visible button,
.game-ui-layer .madness-upgrade-overlay.is-visible,
.game-ui-layer .madness-upgrade-overlay.is-visible button,
.game-ui-layer .result-banner.is-visible,
.game-ui-layer .result-banner.is-visible button,
.game-ui-layer .reward-popup.is-visible,
.game-ui-layer .reward-popup.is-visible button,
.game-ui-layer .tutorial-popup.is-visible,
.game-ui-layer .tutorial-popup.is-visible button,
.game-ui-layer .locked-hybrid-recipe-popup.is-visible,
.game-ui-layer .locked-hybrid-recipe-popup.is-visible button,
.game-ui-layer .game-knowledge-popup.is-visible,
.game-ui-layer .game-knowledge-popup.is-visible button,
.game-ui-layer .new-enemy-popup.is-visible,
.game-ui-layer .new-enemy-popup.is-visible button,
.game-ui-layer .context-menu.is-visible,
.game-ui-layer .combine-popover.is-visible {
  pointer-events: auto;
}

#gameStage {
  position: absolute;
  inset: 0;
  overflow: hidden;
  border-radius: 0;
  background: #0f1e2a;
  clip-path: none;
}

body.is-mobile-fullbleed #gameStage,
#gameRoot.is-mobile-fullbleed #gameStage {
  inset: 0;
  border-radius: 0;
  clip-path: none;
}

#gameCanvas {
  display: block;
  width: 100%;
  height: 100%;
  position: absolute;
  inset: 0;
  touch-action: none;
  -webkit-touch-callout: none;
  -webkit-user-select: none;
  user-select: none;
}


#gameRoot .hud-top,
#gameRoot .wave-preview,
#gameRoot .hud-abilities,
#gameRoot .hud-start-button,
#gameRoot .hud-reset-button,
#gameRoot .hud-wave-cooldown,
#gameRoot .result-banner,
#gameRoot #contextOverlay,
#gameRoot #contextMenu,
#gameRoot .context-menu,
#gameRoot .combine-popover,
#gameRoot .toast-message {
  -webkit-touch-callout: none;
  -webkit-user-select: none;
  user-select: none;
}

#uiPanel {
  position: fixed;
  top: calc(var(--hud-edge-top, calc(env(safe-area-inset-top, 0px) + 16px)) + 56px);
  left: var(--hud-edge-left, calc(env(safe-area-inset-left, 0px) + 16px));
  z-index: 30;
  background: rgba(11, 15, 20, 0.85);
  border: none;
  border-radius: 8px;
  padding: 12px 14px;
  min-width: 260px;
  max-width: 340px;
  width: clamp(260px, 28vw, 340px);
  max-height: calc(100dvh - (var(--hud-edge-top, calc(env(safe-area-inset-top, 0px) + 16px)) + 72px));
  overflow-y: auto;
  -webkit-overflow-scrolling: touch;
  overscroll-behavior: contain;
  touch-action: pan-y;
  font-size: 14px;
  line-height: 1.4;
  transition: opacity 0.2s ease, width 0.2s ease, padding 0.2s ease;
}

.lighting-control-panel {
  display: flex;
  flex-direction: column;
  align-items: stretch;
  background: rgba(255, 255, 255, 0.03);
  border-radius: 8px;
  padding: 12px 14px;
  width: 100%;
  font-size: 13px;
  line-height: 1.35;
}

.lighting-control-title {
  font-weight: 700;
  margin-bottom: 10px;
}

.lighting-control-group {
  padding-top: 10px;
  margin-top: 10px;
  border-top: 1px solid rgba(255, 255, 255, 0.08);
}

.lighting-control-group:first-of-type {
  margin-top: 0;
  padding-top: 0;
  border-top: none;
}

.lighting-control-group-title {
  font-weight: 600;
  margin-bottom: 8px;
}

.lighting-control-field {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin: 8px 0 4px;
}

.lighting-control-value {
  color: #cbd5e1;
  font-variant-numeric: tabular-nums;
}

.lighting-control-panel input[type="range"] {
  width: 100%;
}

.lighting-control-panel input[type="color"] {
  width: 100%;
  height: 32px;
  border: none;
  background: transparent;
  padding: 0;
}

#appShell.panel-collapsed #uiPanel {
  width: 0;
  min-width: 0;
  max-width: 0;
  padding: 0;
  border: none;
  opacity: 0;
  overflow: hidden;
  pointer-events: none;
  overflow: visible;
}


.panel-toggle-button {
  position: fixed;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  white-space: nowrap;
  border: 0;
}

.devtools-toggle-button {
  position: fixed;
  top: var(--hud-edge-top);
  left: calc(var(--hud-edge-left) + 56px);
  z-index: 40;
  width: 48px;
  height: 48px;
  border-radius: 999px;
  border: 1px solid #2b3a4a;
  background: #111820;
  color: #e6edf3;
  font-size: 20px;
  cursor: pointer;
  box-shadow: 0 10px 24px rgba(0, 0, 0, 0.45);
}

.devtools-toggle-button:hover {
  background: #18212b;
}

.devtools-panel {
  position: fixed;
  top: calc(var(--hud-edge-top) + 56px);
  right: var(--hud-edge-right);
  z-index: 35;
  width: min(760px, calc(100vw - (var(--hud-edge-left) + var(--hud-edge-right))));
  max-height: calc(100dvh - (var(--hud-edge-top) + 72px));
  overflow: auto;
  background: rgba(11, 15, 20, 0.94);
  border: 1px solid #1e2a36;
  border-radius: 8px;
  padding: 12px;
  display: none;
}

.devtools-panel.is-open {
  display: block;
}

.devtools-header {
  position: sticky;
  top: -12px;
  z-index: 2;
  display: flex;
  gap: 10px;
  background: rgba(11, 15, 20, 0.98);
  padding: 8px 0 10px;
  border-bottom: 1px solid #1e2a36;
  margin-bottom: 10px;
}

.dev-tab-btn {
  border: 1px solid #2b3a4a;
  background: #111820;
  color: #e6edf3;
  border-radius: 6px;
  padding: 8px 12px;
  font-weight: 600;
  cursor: pointer;
}

.dev-tab-btn.is-active {
  border-color: #60a5fa;
  background: #1e3a8a;
}

.devtools-tab {
  display: none;
}

.devtools-tab.is-active {
  display: block;
}

.dev-form-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(130px, 1fr));
  gap: 10px;
  margin-bottom: 10px;
}

.dev-form-grid label {
  display: flex;
  flex-direction: column;
  gap: 4px;
  font-size: 12px;
}

.dev-form-grid input {
  border: 1px solid #2b3a4a;
  background: #111820;
  color: #e6edf3;
  padding: 6px;
  border-radius: 6px;
}

.dev-table-wrap {
  overflow: auto;
  border: 1px solid #1e2a36;
  border-radius: 6px;
  margin-bottom: 10px;
}

.dev-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 12px;
}

.dev-table th,
.dev-table td {
  border-bottom: 1px solid #1e2a36;
  padding: 6px;
  text-align: right;
  white-space: nowrap;
}

.dev-table th:first-child,
.dev-table td:first-child {
  text-align: left;
}

.dev-table tr.is-selected {
  background: rgba(30, 58, 138, 0.45);
}

.dev-card {
  border: 1px solid #1e2a36;
  border-radius: 8px;
  padding: 10px;
  margin-bottom: 10px;
  background: rgba(2, 6, 23, 0.85);
  white-space: pre-wrap;
}

.panel-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 8px;
}

.panel-level-block {
  margin-bottom: calc(8px * 0.8);
}

.panel-toggle {
  justify-content: flex-start;
}

.panel-toggle-label {
  display: inline-flex;
  align-items: center;
  gap: 10px;
  cursor: pointer;
}

.panel-header {
  align-items: flex-start;
}

.panel-title {
  font-weight: 600;
}

.panel-version-row {
  justify-content: flex-start;
  margin-bottom: 12px;
}

.panel-version {
  color: rgba(148, 163, 184, 0.84);
  font-size: 15px;
  font-weight: 600;
  line-height: 1;
  font-variant-numeric: tabular-nums;
}

.panel-info {
  flex-direction: column;
  align-items: flex-start;
  gap: 4px;
}

.panel-select {
  display: flex;
  flex-direction: column;
  gap: 4px;
  width: 100%;
}

.panel-select-input {
  border: 1px solid #2b3a4a;
  background: #111820;
  color: #e6edf3;
  padding: 6px 8px;
  border-radius: 6px;
  font-size: 13px;
}

.panel-color-input {
  width: 100%;
  height: 36px;
  border: 1px solid #2b3a4a;
  border-radius: 6px;
  background: #111820;
  padding: 4px;
}

.panel-button {
  border: 1px solid #2b3a4a;
  background: #111820;
  color: #e6edf3;
  padding: 6px 10px;
  border-radius: 6px;
  cursor: pointer;
  font-size: 13px;
}

.panel-button:hover {
  background: #18212b;
}

.panel-button:disabled {
  opacity: 0.5;
  cursor: not-allowed;
}

.panel-button.is-active {
  border-color: #f97316;
  box-shadow: 0 0 0 1px rgba(249, 115, 22, 0.4);
}

.panel-button-admin-mode {
  width: 100%;
  min-height: 44px;
  padding: 10px 14px;
  font-size: 15px;
  font-weight: 700;
}

.panel-section {
  border-top: 1px solid #1e2a36;
  margin-top: 8px;
  padding-top: 8px;
}

.panel-section-title {
  font-weight: 600;
  margin-bottom: 6px;
}

.panel-buttons {
  flex-wrap: wrap;
  justify-content: flex-start;
}

.panel-message {
  margin-top: 4px;
  font-size: 13px;
  color: #cbd5f5;
}

.balance-hint {
  font-size: 12px;
  color: #cbd5f5;
  margin-bottom: 8px;
}

.balance-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  margin-bottom: 8px;
}

.balance-group {
  border: 1px solid #1e2a36;
  border-radius: 8px;
  padding: 6px 8px;
  margin-bottom: 8px;
  background: rgba(10, 14, 20, 0.5);
}

.balance-group summary {
  cursor: pointer;
  font-weight: 600;
}

.balance-fields {
  margin-top: 8px;
  display: grid;
  gap: 10px;
}

.balance-tree {
  display: grid;
  gap: 10px;
  margin-top: 8px;
}

.balance-subgroup {
  border: 1px solid #1e2a36;
  border-radius: 8px;
  padding: 6px 8px;
  background: rgba(10, 14, 20, 0.45);
}

.balance-subgroup summary {
  cursor: pointer;
  font-weight: 600;
  font-size: 13px;
}

.tower-metrics {
  display: grid;
  gap: 10px;
  margin-top: 8px;
  font-size: 12px;
  color: #cbd5f5;
}

.tower-metric {
  border: 1px solid #1e2a36;
  border-radius: 8px;
  padding: 8px;
  background: rgba(8, 12, 18, 0.55);
}

.tower-metric-title {
  font-weight: 600;
  color: #e6edf3;
  margin-bottom: 6px;
}

.tower-metric-row {
  display: flex;
  justify-content: space-between;
  gap: 10px;
}

.field-label {
  display: inline-flex;
  align-items: center;
  gap: 6px;
}

.field-help {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 16px;
  height: 16px;
  border-radius: 999px;
  background: #1f2937;
  color: #cbd5f5;
  font-size: 11px;
  font-weight: 700;
  cursor: help;
  position: relative;
}

.field-help::after {
  content: attr(data-tooltip);
  position: absolute;
  bottom: 140%;
  left: 50%;
  transform: translateX(-50%);
  background: rgba(15, 23, 32, 0.96);
  border: none;
  border-radius: 10px;
  padding: 10px 12px;
  font-size: 13px;
  line-height: 1.35;
  color: #e6edf3;
  width: 260px;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.15s ease;
  z-index: 20;
}

.field-help:hover::after {
  opacity: 1;
}

.balance-field {
  display: grid;
  gap: 4px;
  font-size: 12px;
}

.balance-field input[type="number"] {
  background: #0f1720;
  color: #e6edf3;
  border: 1px solid #2b3a4a;
  padding: 4px 6px;
  border-radius: 6px;
  font-size: 12px;
}

.balance-field input.has-error {
  border-color: #f87171;
}

.balance-check {
  grid-template-columns: 1fr auto;
  align-items: center;
}

.field-error {
  font-size: 11px;
  color: #fca5a5;
  min-height: 12px;
}

.balance-readonly {
  margin-top: 6px;
  font-size: 12px;
  color: #cbd5f5;
}


.wave-preview {
  position: fixed;
  top: var(--hud-edge-top);
  left: var(--hud-edge-left);
  z-index: 11;
  display: flex;
  align-items: center;
  gap: 16px;
  padding: 0;
  font-size: 36px;
  font-weight: 800;
  color: #f8fafc;
  text-shadow: none;
  pointer-events: none;
}

.wave-preview-counter {
  display: inline-flex;
  align-items: center;
  gap: 10px;
  min-height: 38px;
  padding: 6px 10px;
  border-radius: 12px;
  border: 1px solid rgba(148, 163, 184, 0.32);
  background: rgba(8, 15, 28, 0.62);
  backdrop-filter: blur(3px);
  font-size: inherit;
  font-weight: 800;
  line-height: 1;
  letter-spacing: 0.3px;
  color: #f8fafc;
  text-shadow: none;
}

.hud-top {
  position: fixed;
  top: var(--hud-edge-top);
  right: var(--hud-edge-right);
  display: none;
  flex-direction: row;
  gap: 16px;
  font-size: 36px;
  font-weight: 800;
  color: #f8fafc;
  text-shadow: none;
  filter: none;
  opacity: 1;
  z-index: 11;
  pointer-events: none;
  align-items: center;
}

.hud-top:has(#madnessTopLevelItem.is-visible) {
  display: flex;
}

.hud-economy-item {
  display: inline-flex;
  align-items: center;
  gap: 13px;
  min-height: 38px;
  padding: 6px 10px;
  border-radius: 12px;
  border: 1px solid rgba(148, 163, 184, 0.32);
  background: rgba(8, 15, 28, 0.62);
  backdrop-filter: blur(3px);
}

.hud-economy-item.is-hidden {
  display: none;
}

.hud-abilities {
  --hud-ability-size: 58px;
  --hud-ability-gap: 10px;
  --hud-ability-collapsed-shift: calc(-5 * var(--hud-ability-gap));
  position: fixed;
  left: calc(var(--hud-edge-left) + var(--hud-button-size) + var(--hud-control-gap));
  right: auto;
  bottom: var(--hud-edge-bottom);
  z-index: 11;
  display: flex;
  flex-direction: row;
  gap: var(--hud-ability-gap);
  pointer-events: auto;
  opacity: 1;
  transform: translateY(0);
  transition: opacity 0.22s ease, transform 0.28s ease;
}

.hud-abilities.is-hidden {
  opacity: 0;
  pointer-events: none;
  transform: translateY(20px);
}

.hud-ability-skill {
  width: var(--hud-ability-size);
  opacity: 1;
  transform: translateX(0) scale(1);
  transform-origin: right center;
  transition:
    width 0.28s ease,
    opacity 0.22s ease,
    transform 0.28s ease,
    margin 0.28s ease,
    padding 0.28s ease,
    border-width 0.28s ease;
}

.hud-abilities.is-collapsed .hud-ability-skill {
  width: 0;
  opacity: 0;
  transform: translateX(-14px) scale(0.92);
  margin: 0;
  padding: 0;
  border-width: 0;
  pointer-events: none;
  overflow: hidden;
}

.hud-ability-collapse-toggle {
  overflow: hidden;
  transform: translateX(0);
  transition: transform 0.28s ease;
}

.hud-abilities.is-collapsed .hud-ability-collapse-toggle {
  transform: translateX(var(--hud-ability-collapsed-shift));
}

.hud-ability-collapse-toggle .hud-ability-icon {
  font-size: 24px;
}

.hud-ability-collapse-toggle .hud-ability-count {
  opacity: 0;
  transform: translateY(-3px) scale(0.92);
  transition: opacity 0.22s ease, transform 0.22s ease;
}

.hud-abilities.is-collapsed .hud-ability-collapse-toggle .hud-ability-count {
  opacity: 1;
  transform: translateY(0) scale(1);
}

.hud-ability-button {
  position: relative;
  width: var(--hud-ability-size);
  height: var(--hud-ability-size);
  border-radius: 14px;
  border: none;
  background: transparent;
  color: #f8fafc;
  font-size: 24px;
  cursor: pointer;
  box-shadow: none;
  transition: transform 0.15s ease, opacity 0.15s ease;
}

.hud-ability-button:hover {
  transform: translateY(-1px);
}

.hud-ability-button:disabled {
  opacity: 0.5;
  cursor: not-allowed;
  transform: none;
}

.hud-ability-button.is-targeting {
  border-color: #f59e0b;
  box-shadow:
    0 0 0 2px rgba(245, 158, 11, 0.35),
    0 12px 22px rgba(2, 6, 23, 0.6);
}

.hud-ability-bg {
  position: absolute;
  inset: 0;
  border-radius: inherit;
  pointer-events: none;
  display: none;
}

.hud-ability-bg.has-button-icon {
  background-repeat: no-repeat;
  background-position: center;
  background-size: contain;
}

.hud-ability-icon {
  position: absolute;
  left: 50%;
  top: 50%;
  transform: translate(-50%, -50%);
  font-size: 30px;
  line-height: 1;
  pointer-events: none;
}

.hud-ability-count {
  position: absolute;
  right: -5px;
  top: -5px;
  min-width: 24px;
  height: 24px;
  padding: 0 6px;
  border-radius: 999px;
  border: 1px solid rgba(255, 255, 255, 0.35);
  background: rgba(15, 23, 42, 0.96);
  color: #f8fafc;
  font-size: 13px;
  font-weight: 900;
  line-height: 22px;
  text-align: center;
  pointer-events: none;
}

.hud-icon {
  font-size: 47px;
  opacity: 1;
}


.hud-icon.has-icon {
  display: inline-block;
  width: 1em;
  height: 1em;
  background-repeat: no-repeat;
  background-size: contain;
  background-position: center;
  color: transparent;
  opacity: 1;
  filter: none;
  mix-blend-mode: normal;
}


.goal-damage-overlay {
  position: fixed;
  inset: 0;
  z-index: 12;
  pointer-events: none;
  opacity: 0;
  box-shadow: inset 0 0 0 0 rgba(239, 68, 68, 0.6);
}

.goal-damage-overlay.is-active {
  animation: goal-damage-flash 0.35s ease-out;
}

#gameRoot.is-hit-shake {
  animation: goal-hit-shake 0.35s ease-out;
}

.mobile-portrait-lock {
  position: fixed;
  inset: 0;
  z-index: 40;
  display: none;
  align-items: center;
  justify-content: center;
  background: rgba(5, 9, 15, 0.96);
  padding: 20px;
}

.mobile-portrait-lock-message {
  font-size: clamp(20px, 5vw, 34px);
  font-weight: 800;
  text-align: center;
  color: #f8fafc;
}

@keyframes goal-damage-flash {
  0% { opacity: 0; box-shadow: inset 0 0 0 0 rgba(239, 68, 68, 0.2); }
  30% { opacity: 1; box-shadow: inset 0 0 45px 18px rgba(239, 68, 68, 0.62); }
  100% { opacity: 0; box-shadow: inset 0 0 0 0 rgba(239, 68, 68, 0); }
}

@keyframes goal-hit-shake {
  0%, 100% { transform: translate3d(0, 0, 0); }
  20% { transform: translate3d(-8px, 4px, 0); }
  40% { transform: translate3d(8px, -5px, 0); }
  60% { transform: translate3d(-7px, -3px, 0); }
  80% { transform: translate3d(6px, 3px, 0); }
}

.hud-start-button {
  position: fixed;
  left: 50%;
  bottom: calc(var(--hud-edge-bottom) + (10px * var(--ui-scale)));
  transform: translateX(-50%);
  cursor: pointer;
  z-index: 9;
  transition: opacity 0.2s ease, transform 0.25s ease, filter 0.2s ease;
}

.hud-start-button:hover {
  transform: translateX(-50%) translateY(-2px);
  filter: brightness(1.04);
}

.hud-start-button.is-hidden {
  opacity: 0;
  pointer-events: none;
}

.madness-special-modes {
  position: fixed;
  left: 50%;
  bottom: calc(var(--hud-edge-bottom) + (110px * var(--ui-scale)));
  transform: translateX(-50%);
  z-index: 9;
  display: none;
  flex-wrap: wrap;
  align-items: center;
  justify-content: center;
  gap: calc(10px * var(--ui-scale));
  width: min(calc(720px * var(--ui-scale)), calc(100vw - 48px));
}

.madness-special-modes.is-visible {
  display: flex;
}

.madness-special-mode-option {
  display: inline-flex;
  align-items: center;
  gap: calc(10px * var(--ui-scale));
  padding: calc(10px * var(--ui-scale)) calc(16px * var(--ui-scale));
  border-radius: calc(18px * var(--ui-scale));
  background: rgba(2, 6, 23, 0.88);
  border: calc(2px * var(--ui-scale)) solid rgba(248, 113, 113, 0.28);
  color: #f8fafc;
  font-family: var(--font-family-ui-base);
  font-size: calc(16px * var(--ui-scale));
  font-weight: 900;
  letter-spacing: 0.02em;
  pointer-events: auto;
}

.madness-special-mode-checkbox {
  width: calc(18px * var(--ui-scale));
  height: calc(18px * var(--ui-scale));
  margin: 0;
  accent-color: #f97316;
}

.madness-special-mode-label {
  line-height: 1;
  white-space: nowrap;
}

.pregame-screen {
  position: fixed;
  inset: 0;
  z-index: 25;
  display: flex;
  flex-direction: column;
  align-items: stretch;
  justify-content: stretch;
  gap: 0;
  background: #000;
}

.pregame-screen.is-hidden {
  display: none;
}

.pregame-screen.is-map-mode {
  padding: 0;
  background: #000;
}

.pregame-screen.is-level-transition {
  background: transparent;
  pointer-events: none;
}

.pregame-screen.is-level-transition .pregame-map-panel,
.pregame-screen.is-level-transition .pregame-map-canvas {
  pointer-events: none;
}

.pregame-screen.is-level-transition .pregame-profile,
.pregame-screen.is-level-transition .pregame-screen-actions,
.pregame-screen.is-level-transition .pregame-map-canvas,
.pregame-screen.is-map-loading .pregame-profile,
.pregame-screen.is-map-loading .pregame-stat-chip-energy {
  opacity: 0;
  transition: opacity 180ms linear;
}

body.is-booting .pregame-map-panel {
  bottom: 0;
}

body.is-booting #appShell {
  visibility: hidden;
}

body.is-booting #uiPanel,
body.is-booting #gameRoot,
body.is-booting .pregame-profile,
body.is-booting .pregame-bottom-actions,
body.is-booting .pregame-upgrade-panel,
body.is-booting #levelCloudTransition,
body.is-booting #pregameMapTransitionOverlay,
body.is-booting .pregame-map-bottom-cut,
body.is-booting #pregameChestButton,
body.is-booting #pregameMapNotice,
body.is-booting .pregame-map-canvas {
  visibility: hidden;
  pointer-events: none;
}

body.is-booting #pregameMapLoading {
  display: flex;
}

.pregame-screen.is-map-loading .pregame-ui-layer,
.pregame-screen.is-map-loading #pregameChestButton,
.pregame-screen.is-map-loading .pregame-map-bottom-cut,
.pregame-screen.is-map-loading #pregameMapNotice,
.pregame-screen.is-map-loading #pregameMapTransitionOverlay,
.pregame-screen.is-map-loading .pregame-map-canvas {
  opacity: 0;
  visibility: hidden;
  pointer-events: none;
}

.pregame-map-loading-panel,
.pregame-topbar,
.pregame-bottom-actions,
.pregame-upgrade-card,
.pregame-chest-button,
.game-topbar-left,
.game-topbar-right,
#hudTop,
#madnessProgressHud,
#madnessLevelUpBanner,
.madness-upgrade-overlay,
#abilityHud,
#resultBanner,
.settings-popup-layout,
.context-menu,
.combine-popover,
.toast-message,
.mobile-portrait-lock-message,
.hud-start-button,
.hud-speed-controls,
.hud-reset-button,
.hud-wave-cooldown,
.wave-preview {
  zoom: var(--ui-scale);
}

.pregame-screen-title {
  font-size: clamp(42px, 8vw, 72px);
  font-weight: 900;
  letter-spacing: 2px;
  color: #f8fafc;
  text-shadow: 0 6px 24px rgba(0, 0, 0, 0.6);
}


.pregame-profile {
  position: absolute;
  inset: 0;
  z-index: 5;
  padding: 0;
  pointer-events: none;
  transition: opacity 260ms ease, transform 360ms cubic-bezier(0.22, 0.8, 0.26, 1);
}

.pregame-topbar {
  position: absolute;
  top: 16px;
  display: block;
  align-items: start;
  pointer-events: none;
  left: 0;
  right: 0;
  width: auto;
}

.game-topbar {
  position: absolute;
  z-index: 12;
  pointer-events: none;
  top: var(--hud-edge-top);
  display: block;
  left: 0;
  right: 0;
  width: auto;
}

.game-topbar-left {
  left: 0;
  right: 0;
  display: block;
  width: auto;
}

.game-topbar-right {
  left: 0;
  right: 0;
  display: block;
  width: auto;
}

.pregame-topbar-left {
  left: 0;
  right: 0;
  width: auto;
}

.pregame-topbar-right {
  left: 0;
  right: 0;
  width: auto;
  display: block;
}

.pregame-topbar-cut {
  display: none;
}

.pregame-topbar-left .pregame-topbar-cut-left {
  grid-column: 2;
  grid-row: 1;
  width: calc(31px * var(--ui-scale));
  height: calc(112px * var(--ui-scale));
  background-image: url("./assets/ui/cut_top_left.svg");
  background-size: calc(31px * var(--ui-scale)) calc(112px * var(--ui-scale));
}

.game-topbar-left .pregame-topbar-cut-left {
  grid-column: 1;
  grid-row: 1;
  width: calc(31px * var(--ui-scale));
  height: calc(112px * var(--ui-scale));
  background-image: url("./assets/ui/cut_top_left.svg");
  background-size: calc(31px * var(--ui-scale)) calc(112px * var(--ui-scale));
}

.pregame-topbar-left .pregame-topbar-cut-mid {
  grid-column: 3;
  grid-row: 1;
  height: calc(84px * var(--ui-scale));
  background: #000;
}

.game-topbar-left .pregame-topbar-cut-mid {
  grid-column: 2;
  grid-row: 1;
  height: calc(84px * var(--ui-scale));
  background: #000;
}

.pregame-topbar-left .pregame-topbar-cut-right {
  grid-column: 4;
  grid-row: 1;
  width: calc(97px * var(--ui-scale));
  height: calc(84px * var(--ui-scale));
  background-image: url("./assets/ui/cut_top_right.svg");
  background-size: calc(97px * var(--ui-scale)) calc(84px * var(--ui-scale));
  margin-left: calc(-1px * var(--ui-scale));
}

.game-topbar-left .pregame-topbar-cut-right {
  grid-column: 3;
  grid-row: 1;
  width: calc(97px * var(--ui-scale));
  height: calc(84px * var(--ui-scale));
  background-image: url("./assets/ui/cut_top_right.svg");
  background-size: calc(97px * var(--ui-scale)) calc(84px * var(--ui-scale));
  margin-left: calc(-1px * var(--ui-scale));
}

.pregame-topbar-right .pregame-topbar-cut-left {
  grid-column: 3;
  grid-row: 1;
  width: calc(31px * var(--ui-scale));
  height: calc(112px * var(--ui-scale));
  background-image: url("./assets/ui/cut_top_left.svg");
  background-size: calc(31px * var(--ui-scale)) calc(112px * var(--ui-scale));
  transform: scaleX(-1);
}

.game-topbar-right .pregame-topbar-cut-left {
  grid-column: 3;
  grid-row: 1;
  width: calc(31px * var(--ui-scale));
  height: calc(112px * var(--ui-scale));
  background-image: url("./assets/ui/cut_top_left.svg");
  background-size: calc(31px * var(--ui-scale)) calc(112px * var(--ui-scale));
  transform: scaleX(-1);
}

.pregame-topbar-right .pregame-topbar-cut-mid {
  grid-column: 2;
  grid-row: 1;
  height: calc(84px * var(--ui-scale));
  background: #000;
}

.game-topbar-right .pregame-topbar-cut-mid {
  grid-column: 2;
  grid-row: 1;
  height: calc(84px * var(--ui-scale));
  background: #000;
}

.pregame-topbar-right .pregame-topbar-cut-right {
  grid-column: 1;
  grid-row: 1;
  width: calc(97px * var(--ui-scale));
  height: calc(84px * var(--ui-scale));
  background-image: url("./assets/ui/cut_top_right.svg");
  background-size: calc(97px * var(--ui-scale)) calc(84px * var(--ui-scale));
  transform: scaleX(-1);
  margin-right: calc(-1px * var(--ui-scale));
}

.game-topbar-right .pregame-topbar-cut-right {
  grid-column: 1;
  grid-row: 1;
  width: calc(97px * var(--ui-scale));
  height: calc(84px * var(--ui-scale));
  background-image: url("./assets/ui/cut_top_right.svg");
  background-size: calc(97px * var(--ui-scale)) calc(84px * var(--ui-scale));
  transform: scaleX(-1);
  margin-right: calc(-1px * var(--ui-scale));
}

.pregame-topbar-content {
  position: relative;
  z-index: 1;
  min-height: auto;
  height: auto;
  padding: 0;
  display: flex;
  align-items: center;
  gap: calc(12px * var(--ui-scale));
  pointer-events: auto;
  white-space: nowrap;
  align-self: start;
}

.pregame-topbar-content-left {
  grid-column: auto;
  display: flex;
  justify-content: flex-start;
  width: 100%;
  padding: 0 0 0 16px;
}

.pregame-topbar-content-right {
  grid-column: auto;
  display: flex;
  justify-content: flex-end;
  pointer-events: none;
  width: 100%;
  padding: 0 16px 0 0;
  width: 100%;
  margin-left: 0;
}

.pregame-stat-chip {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: calc(8px * var(--ui-scale));
  min-height: calc(66px * var(--ui-scale));
  padding: 0;
  background: transparent;
  border: none;
  overflow: hidden;
  font-family: var(--font-family-ui-base);
  font-size: var(--font-size-ui-topbar-stat);
  font-weight: var(--font-weight-ui-heavy);
  line-height: 1;
}

.pregame-stat-chip-energy {
  gap: 8px;
}

.pregame-stat-chip-dust {
  gap: 6px;
}

.pregame-dust-icon,
.pregame-dust-value {
  color: #e9d5ff;
  text-shadow: 0 0 12px rgba(192, 132, 252, 0.45);
}

.pregame-stat-chip-icon {
  width: calc(30px * var(--ui-scale));
  height: calc(30px * var(--ui-scale));
  flex: 0 0 calc(30px * var(--ui-scale));
  display: inline-flex;
  align-items: center;
  justify-content: center;
  font-size: var(--font-size-ui-topbar-icon);
  line-height: 1;
  overflow: hidden;
}

.game-topbar .pregame-stat-chip-icon {
  width: calc(40px * var(--ui-scale));
  height: calc(40px * var(--ui-scale));
  flex-basis: calc(40px * var(--ui-scale));
  font-size: var(--font-size-ui-topbar-game-icon);
}

.pregame-energy-value,
.pregame-stars,
.pregame-dust-value,
.pregame-energy-timer {
  font-family: var(--font-family-ui-base);
  font-size: var(--font-size-ui-topbar-stat);
  font-weight: var(--font-weight-ui-heavy);
  line-height: 1;
  color: #fff;
}

.pregame-stars {
  color: #fff;
}

#pregameStarsHudItem {
  display: none;
}

#pregameStarsHudItem.is-visible {
  display: inline-flex;
}

.pregame-energy-timer:empty {
  display: none;
}

.pregame-topbar-logo {
  display: block;
  height: calc(46px * var(--ui-scale));
  width: auto;
}

.pregame-topbar-burger {
  width: calc(42px * var(--ui-scale));
  height: calc(42px * var(--ui-scale));
  padding: 0;
  border: none;
  background: transparent;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
}

.pregame-topbar-burger:hover {
  opacity: 0.82;
}

.pregame-topbar-burger img {
  width: calc(18px * var(--ui-scale));
  height: calc(14px * var(--ui-scale));
  display: block;
}

.game-topbar-content-left {
  grid-column: auto;
  display: flex;
  justify-content: flex-start;
  gap: calc(24px * var(--ui-scale));
  width: 100%;
  padding: 0 0 0 var(--hud-edge-left);
}

.game-topbar-content-right {
  grid-column: auto;
  display: flex;
  justify-content: flex-end;
  gap: calc(24px * var(--ui-scale));
  pointer-events: none;
  width: 100%;
  padding: 0 var(--hud-edge-right) 0 0;
  width: 100%;
  margin-left: 0;
}

.pregame-mode-tab {
  width: 100%;
}

.pregame-upgrade-open {
  position: relative;
  width: 100%;
  pointer-events: auto;
}

.pregame-upgrade-open.is-hidden {
  display: none;
}

.pregame-bottom-actions {
  position: absolute;
  left: calc(16px * var(--ui-scale));
  right: calc(16px * var(--ui-scale));
  bottom: calc(env(safe-area-inset-bottom, 0px) + (25px * var(--ui-scale)));
  z-index: 8;
  display: grid;
  grid-template-columns:
    minmax(0, 1fr)
    minmax(0, 1fr)
    calc(260px * var(--ui-scale))
    minmax(0, 1fr)
    minmax(0, 1fr);
  justify-content: center;
  align-items: end;
  gap: calc(12px * var(--ui-scale));
  transition: transform 360ms cubic-bezier(0.22, 0.8, 0.26, 1), opacity 260ms ease;
}

.pregame-screen.is-upgrade-mode .pregame-bottom-actions {
  opacity: 1;
  pointer-events: auto;
  transform: none;
}

.pregame-screen.is-knowledge-mode .pregame-bottom-actions {
  opacity: 1;
  pointer-events: auto;
  transform: none;
}

.pregame-screen.is-level-transition .pregame-bottom-actions,
.pregame-screen.is-map-loading .pregame-bottom-actions {
  opacity: 0;
  pointer-events: none;
  transform: translateY(24px);
}

.pregame-cloud-save-panel {
  position: absolute;
  left: 50%;
  bottom: calc(env(safe-area-inset-bottom, 0px) + (112px * var(--ui-scale)));
  z-index: 8;
  display: grid;
  grid-template-columns: calc(42px * var(--ui-scale)) minmax(0, 1fr);
  grid-template-areas:
    "emblem copy"
    "actions actions";
  align-items: center;
  justify-items: stretch;
  column-gap: calc(12px * var(--ui-scale));
  row-gap: calc(8px * var(--ui-scale));
  width: min(calc(520px * var(--ui-scale)), calc(100vw - env(safe-area-inset-left, 0px) - env(safe-area-inset-right, 0px) - (48px * var(--ui-scale))));
  min-height: calc(76px * var(--ui-scale));
  padding: calc(10px * var(--ui-scale)) calc(14px * var(--ui-scale)) calc(12px * var(--ui-scale));
  border: calc(2px * var(--ui-scale)) solid rgba(255, 211, 107, 0.64);
  border-radius: calc(22px * var(--ui-scale));
  background:
    radial-gradient(circle at 18% 18%, rgba(96, 165, 250, 0.22), transparent 38%),
    linear-gradient(145deg, rgba(7, 14, 28, 0.94), rgba(19, 31, 55, 0.9));
  box-shadow:
    0 calc(14px * var(--ui-scale)) calc(34px * var(--ui-scale)) rgba(0, 0, 0, 0.42),
    0 0 0 calc(1px * var(--ui-scale)) rgba(255, 255, 255, 0.12) inset,
    0 calc(4px * var(--ui-scale)) calc(12px * var(--ui-scale)) rgba(255, 214, 92, 0.16) inset;
  color: #eefbff;
  pointer-events: auto;
  transform: translateX(-50%);
  transition: opacity 220ms ease, transform 260ms ease, border-color 180ms ease, filter 180ms ease;
}

.pregame-cloud-save-panel::before {
  content: "";
  position: absolute;
  inset: calc(3px * var(--ui-scale));
  border-radius: calc(18px * var(--ui-scale));
  border: 1px solid rgba(116, 199, 255, 0.18);
  pointer-events: none;
}

.pregame-cloud-save-panel.is-busy {
  border-color: rgba(138, 214, 255, 0.72);
  filter: drop-shadow(0 0 calc(10px * var(--ui-scale)) rgba(90, 190, 255, 0.14));
}

.pregame-cloud-save-panel.is-error {
  border-color: rgba(255, 146, 126, 0.78);
  box-shadow:
    0 calc(14px * var(--ui-scale)) calc(34px * var(--ui-scale)) rgba(0, 0, 0, 0.44),
    0 0 0 calc(1px * var(--ui-scale)) rgba(255, 218, 168, 0.16) inset,
    0 0 calc(18px * var(--ui-scale)) rgba(255, 92, 92, 0.18);
}

.pregame-cloud-save-emblem {
  grid-area: emblem;
  width: calc(42px * var(--ui-scale));
  height: calc(42px * var(--ui-scale));
  display: inline-flex;
  align-items: center;
  justify-content: center;
  border-radius: calc(14px * var(--ui-scale));
  background: linear-gradient(145deg, rgba(21, 43, 76, 0.92), rgba(59, 130, 246, 0.42));
  box-shadow:
    0 calc(4px * var(--ui-scale)) calc(9px * var(--ui-scale)) rgba(0, 0, 0, 0.34),
    0 0 0 calc(2px * var(--ui-scale)) rgba(255, 213, 100, 0.32) inset;
  color: #e8fbff;
  font-size: calc(22px * var(--ui-scale));
  line-height: 1;
  text-shadow: 0 calc(2px * var(--ui-scale)) calc(5px * var(--ui-scale)) rgba(0, 0, 0, 0.42);
}

.pregame-cloud-save-copy {
  grid-area: copy;
  display: grid;
  gap: calc(2px * var(--ui-scale));
  min-width: 0;
  text-align: left;
}

.pregame-cloud-save-kicker {
  color: #ffd76b;
  font-size: calc(10px * var(--ui-scale));
  font-weight: 900;
  letter-spacing: 0.14em;
  text-transform: uppercase;
  text-shadow: 0 calc(2px * var(--ui-scale)) calc(4px * var(--ui-scale)) rgba(0, 0, 0, 0.42);
}

.pregame-cloud-save-status {
  overflow: hidden;
  color: #ffffff;
  font-family: var(--font-family-ui-base);
  font-size: calc(14px * var(--ui-scale));
  font-weight: var(--font-weight-ui-heavy);
  line-height: 1.08;
  text-overflow: ellipsis;
  white-space: nowrap;
  text-shadow: 0 calc(3px * var(--ui-scale)) calc(5px * var(--ui-scale)) rgba(0, 0, 0, 0.4);
}

.pregame-cloud-save-account {
  overflow: hidden;
  color: rgba(216, 239, 255, 0.78);
  font-size: calc(10px * var(--ui-scale));
  font-weight: 750;
  line-height: 1.1;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.pregame-cloud-save-actions {
  grid-area: actions;
  display: flex;
  justify-content: center;
  align-items: center;
  gap: calc(8px * var(--ui-scale));
  min-width: 0;
}

.pregame-cloud-save-button.secondary-action-button {
  min-width: calc(98px * var(--ui-scale));
  min-height: calc(34px * var(--ui-scale));
  height: calc(34px * var(--ui-scale));
  padding: 0 calc(12px * var(--ui-scale));
  border-radius: calc(12px * var(--ui-scale));
  background: rgba(6, 12, 24, 0.54);
  color: #fff;
  font-size: calc(12px * var(--ui-scale));
  text-shadow: 0 calc(2px * var(--ui-scale)) calc(4px * var(--ui-scale)) rgba(0, 0, 0, 0.35);
}

.pregame-cloud-save-button.secondary-action-button::before {
  opacity: 0.78;
  padding: calc(2px * var(--ui-scale));
}

.pregame-cloud-save-button.secondary-action-button:disabled::before {
  opacity: 0.28;
}

@media (max-width: 760px), (pointer: coarse) {
  .pregame-cloud-save-panel {
    bottom: calc(env(safe-area-inset-bottom, 0px) + (106px * var(--ui-scale)));
    width: min(calc(500px * var(--ui-scale)), calc(100vw - env(safe-area-inset-left, 0px) - env(safe-area-inset-right, 0px) - (28px * var(--ui-scale))));
    padding: calc(9px * var(--ui-scale)) calc(12px * var(--ui-scale)) calc(10px * var(--ui-scale));
  }

  .pregame-cloud-save-actions {
    gap: calc(6px * var(--ui-scale));
  }

  .pregame-cloud-save-button.secondary-action-button {
    min-width: calc(86px * var(--ui-scale));
    padding: 0 calc(9px * var(--ui-scale));
    font-size: calc(11px * var(--ui-scale));
  }
}

.pregame-screen.is-level-transition .pregame-cloud-save-panel,
.pregame-screen.is-map-loading .pregame-cloud-save-panel,
.pregame-screen.is-upgrade-mode .pregame-cloud-save-panel,
.pregame-screen.is-knowledge-mode .pregame-cloud-save-panel {
  opacity: 0;
  pointer-events: none;
  transform: translateX(-50%) translateY(calc(10px * var(--ui-scale)));
}

.pregame-screen-actions {
  position: absolute;
  left: 50%;
  bottom: calc(env(safe-area-inset-bottom, 0px) + 18px);
  transform: translateX(-50%);
  z-index: 5;
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  justify-content: center;
  gap: 16px;
}

.pregame-menu-button {
  min-width: 96px;
  min-height: 42px;
  padding: 6px 12px;
  border-radius: 16px;
  border: 2px solid #2b3a4a;
  background: rgba(17, 24, 32, 0.95);
  color: #f8fafc;
  font-size: 18px;
  font-weight: 800;
  cursor: pointer;
}

.pregame-menu-button:hover {
  background: rgba(30, 41, 59, 0.95);
}

.pregame-menu-button-primary {
  min-width: 180px;
  padding: 6px 20px;
  font-size: 20px;
  letter-spacing: 1px;
}

.primary-action-button {
  min-width: calc(260px * var(--ui-scale));
  height: calc(90px * var(--ui-scale));
  min-height: calc(90px * var(--ui-scale));
  padding: 0 calc(28px * var(--ui-scale));
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: calc(12px * var(--ui-scale));
  border-radius: calc(20px * var(--ui-scale));
  border: none;
  outline: none;
  appearance: none;
  -webkit-appearance: none;
  background: linear-gradient(262deg, #feca16 17.87%, #ff8800 85.15%);
  box-shadow:
      -2.95px -5.95px 2.3px 0 #ba4e1f inset,
      1.95px -8.875px 3.6px 0 #feca16 inset,
      .95px 4.125px 3.6px 0 #feca16 inset,
      2.95px 7.25px 2.3px 0 rgba(255, 213, 72, 0.58) inset;
  color: #fff;
  text-shadow: 0 4px 3px rgba(0, 0, 0, 0.2);
  font-family: var(--font-family-ui-base);
  font-size: var(--font-size-ui-button-primary);
  font-style: normal;
  font-weight: var(--font-weight-ui-heavy);
  line-height: 1;
  text-transform: none;
  letter-spacing: 0;
  cursor: pointer;
}

.secondary-action-button {
  --secondary-active-gradient: linear-gradient(135deg, #ff6531 0%, #f8d469 100%);
  width: auto;
  min-width: max-content;
  height: calc(60px * var(--ui-scale));
  padding: 0 calc(32px * var(--ui-scale));
  position: relative;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: calc(10px * var(--ui-scale));
  border-radius: calc(16px * var(--ui-scale));
  border: none;
  background: transparent;
  color: #fff;
  font-family: var(--font-family-ui-base);
  font-size: var(--font-size-ui-button-secondary);
  font-style: normal;
  font-weight: var(--font-weight-ui-heavy);
  line-height: 1;
  cursor: pointer;
  transition: transform 180ms ease, filter 180ms ease, background 180ms ease, border-color 180ms ease;
}

.secondary-action-button::before {
  content: "";
  position: absolute;
  inset: 0;
  padding: calc(3px * var(--ui-scale));
  border-radius: inherit;
  background: var(--secondary-active-gradient);
  pointer-events: none;
  opacity: 0;
  -webkit-mask:
    linear-gradient(#fff 0 0) content-box,
    linear-gradient(#fff 0 0);
  -webkit-mask-composite: xor;
  mask:
    linear-gradient(#fff 0 0) content-box,
    linear-gradient(#fff 0 0);
  mask-composite: exclude;
}

.secondary-action-button:hover {
  transform: translateY(-1px);
  filter: brightness(1.03);
}

.secondary-action-button:disabled {
  opacity: 0.45;
  cursor: not-allowed;
  transform: none;
  filter: none;
}

.secondary-action-button-ghost {
  border: none;
  background: transparent;
}

.popup-secondary-button {
  --secondary-active-gradient: linear-gradient(135deg, #151a21 0%, #151a21 100%);
  width: calc(234px * var(--ui-scale));
  min-width: calc(234px * var(--ui-scale));
  height: calc(72px * var(--ui-scale));
  min-height: calc(72px * var(--ui-scale));
  font-size: calc(20px * var(--ui-scale));
  font-weight: 700;
  letter-spacing: 0;
}

.popup-secondary-button::before {
  opacity: 1;
}

.secondary-action-button-ghost.is-active {
  background: transparent;
}

.secondary-action-button-ghost.is-active::before {
  opacity: 1;
}

#pregameModeMadness.secondary-action-button-ghost.is-active {
  --secondary-active-gradient: linear-gradient(135deg, #170006 0%, #7f0c28 52%, #e11d48 100%);
  background: linear-gradient(135deg, rgba(23, 0, 6, 0.86) 0%, rgba(127, 12, 40, 0.58) 100%);
  box-shadow: 0 14px 32px rgba(127, 12, 40, 0.35);
}

.secondary-action-button-icon {
  width: calc(72px * var(--ui-scale));
  min-width: calc(72px * var(--ui-scale));
  padding: 0;
}

.secondary-action-button-icon img {
  width: calc(28px * var(--ui-scale));
  height: calc(28px * var(--ui-scale));
  display: block;
}

.primary-action-button:hover {
  filter: brightness(1.04);
}

.primary-action-button:disabled {
  opacity: 0.6;
  cursor: not-allowed;
}

.primary-action-button:disabled:hover {
  filter: none;
}

.hud-start-button.is-madness-launch {
  background: linear-gradient(262deg, #e11d48 12%, #8a102d 52%, #24040c 92%);
  box-shadow:
    -2.95px -5.95px 2.3px 0 #170006 inset,
    1.95px -8.875px 3.6px 0 #b91435 inset,
    .95px 4.125px 3.6px 0 #f05263 inset,
    2.95px 7.25px 2.3px 0 rgba(255, 103, 122, 0.48) inset;
}

.primary-action-button-label {
  display: inline-flex;
  align-items: center;
  position: relative;
  top: -1px;
}

.wave-start-label-text {
  display: inline-flex;
  align-items: center;
}

.wave-start-cost {
  display: inline-flex;
  align-items: center;
  gap: calc(8px * var(--ui-scale));
  margin-left: calc(18px * var(--ui-scale));
  font-size: var(--font-size-ui-button-cost);
  line-height: 1;
}

.wave-start-cost-value {
  display: inline-flex;
  align-items: center;
  font-size: inherit;
  font-weight: var(--font-weight-ui-heavy);
  line-height: 1;
}

.wave-start-cost-icon {
  width: var(--font-size-ui-button-cost);
  height: var(--font-size-ui-button-cost);
  flex: 0 0 var(--font-size-ui-button-cost);
  display: inline-flex;
  align-items: center;
  justify-content: center;
  font-size: var(--font-size-ui-button-cost);
  line-height: 1;
  text-shadow: none;
}

#waveStart .primary-action-button-icon {
  display: none;
}

.primary-action-button-icon {
  width: var(--font-size-ui-button-icon);
  height: var(--font-size-ui-button-icon);
  flex: 0 0 var(--font-size-ui-button-icon);
  display: inline-flex;
  align-items: center;
  justify-content: center;
  font-size: var(--font-size-ui-button-icon);
  line-height: 1;
  text-shadow: none;
}

.pregame-play-button {
  pointer-events: auto;
    margin: auto;
}

.pregame-bottom-actions > * {
  align-self: end;
}

.pregame-bottom-actions .secondary-action-button {
  width: min(100%, calc(220px * var(--ui-scale)));
  min-width: 0;
  max-width: calc(220px * var(--ui-scale));
  justify-self: center;
}

@media (max-width: 900px), (pointer: coarse) {
  .pregame-bottom-actions {
    grid-template-columns:
      minmax(0, 1fr)
      minmax(0, 1fr)
      calc(260px * var(--ui-scale))
      minmax(0, 1fr)
      minmax(0, 1fr);
    gap: calc(8px * var(--ui-scale));
  }
}



.pregame-map-panel {
  position: fixed;
  top: 0;
  right: 0;
  bottom: calc(env(safe-area-inset-bottom, 0px) + (96px * var(--ui-scale)));
  left: 0;
  z-index: 1;
  display: flex;
  border-radius: 0;
  background: transparent;
  overflow: hidden;
  transform: translateY(0);
  transition: transform 430ms cubic-bezier(0.22, 0.8, 0.26, 1);
  will-change: transform;
}

body.is-mobile-fullbleed .pregame-map-panel,
#gameRoot.is-mobile-fullbleed .pregame-map-panel {
  top: 0;
  right: 0;
  bottom: 0;
  left: 0;
  border-radius: 0;
  background: transparent;
}

.pregame-map-panel.is-hidden {
  display: none;
}

.pregame-map-stage {
  position: relative;
  inset: 0;
  width: 100%;
  height: 100%;
  overflow: hidden;
  background: var(--pregame-map-background-color, #02040a);
  border-radius: 0;
  transform: translateY(0);
  will-change: transform;
}

body.is-mobile-fullbleed .pregame-map-stage,
#gameRoot.is-mobile-fullbleed .pregame-map-stage {
  border-radius: 0;
}

body.is-mobile-fullbleed .pregame-map-bottom-cut,
body.is-mobile-fullbleed .pregame-topbar-cut {
  display: none;
}

body.is-mobile-fullbleed .pregame-topbar,
body.is-mobile-fullbleed .game-topbar {
  top: calc(env(safe-area-inset-top, 0px) + 8px);
  display: block;
  width: auto;
}

body.is-mobile-fullbleed .pregame-topbar-left,
body.is-mobile-fullbleed .game-topbar-left {
  left: calc(env(safe-area-inset-left, 0px) + 8px);
}

body.is-mobile-fullbleed .pregame-topbar-right,
body.is-mobile-fullbleed .game-topbar-right {
  right: calc(env(safe-area-inset-right, 0px) + 8px);
}

body.is-mobile-fullbleed .pregame-topbar-content,
body.is-mobile-fullbleed .pregame-topbar-content-left,
body.is-mobile-fullbleed .pregame-topbar-content-right,
body.is-mobile-fullbleed .game-topbar-content-left,
body.is-mobile-fullbleed .game-topbar-content-right {
  grid-column: auto;
  min-height: auto;
  height: auto;
  padding: 0;
  gap: calc(12px * var(--ui-scale));
}

body.is-mobile-fullbleed .pregame-topbar-content-left,
body.is-mobile-fullbleed .game-topbar-content-left {
  justify-content: flex-start;
}

body.is-mobile-fullbleed .pregame-topbar-content-right,
body.is-mobile-fullbleed .game-topbar-content-right {
  justify-content: flex-end;
}

body.is-mobile-fullbleed .pregame-bottom-actions {
  left: calc(env(safe-area-inset-left, 0px) + 8px);
  right: calc(env(safe-area-inset-right, 0px) + 8px);
  bottom: calc(env(safe-area-inset-bottom, 0px) + 8px);
}

body.is-mobile-fullbleed .pregame-bottom-actions .primary-action-button,
body.is-mobile-fullbleed .pregame-bottom-actions .secondary-action-button,
body.is-mobile-fullbleed .pregame-stat-chip,
body.is-mobile-fullbleed .hud-economy-item,
body.is-mobile-fullbleed .wave-preview-counter {
  border: none;
  background: transparent center center / contain no-repeat;
  box-shadow: none;
  backdrop-filter: none;
  text-shadow: none;
}

body.is-mobile-fullbleed .pregame-bottom-actions .primary-action-button,
body.is-mobile-fullbleed .pregame-bottom-actions .secondary-action-button {
  padding-left: 0;
  padding-right: 0;
}

body.is-mobile-fullbleed .pregame-bottom-actions .secondary-action-button::before {
  display: none;
}

body.is-mobile-fullbleed .pregame-bottom-actions .primary-action-button {
  width: auto;
  min-width: max-content;
  height: auto;
  min-height: 0;
}

body.is-mobile-fullbleed .pregame-bottom-actions .pregame-play-button {
  width: calc(260px * var(--ui-scale));
  min-width: calc(260px * var(--ui-scale));
  height: calc(90px * var(--ui-scale));
  min-height: calc(90px * var(--ui-scale));
  padding: 0 calc(28px * var(--ui-scale));
  background: linear-gradient(262deg, #feca16 17.87%, #ff8800 85.15%);
  box-shadow:
    -2.95px -5.95px 2.3px 0 #ba4e1f inset,
    1.95px -8.875px 3.6px 0 #feca16 inset,
    .95px 4.125px 3.6px 0 #feca16 inset,
    2.95px 7.25px 2.3px 0 #ffffff inset;
}

.pregame-screen.is-madness-mode .pregame-play-button,
body.is-mobile-fullbleed .pregame-screen.is-madness-mode .pregame-bottom-actions .pregame-play-button {
  background: linear-gradient(262deg, #e11d48 12%, #8a102d 52%, #24040c 92%);
  box-shadow:
    -2.95px -5.95px 2.3px 0 #170006 inset,
    1.95px -8.875px 3.6px 0 #b91435 inset,
    .95px 4.125px 3.6px 0 #f05263 inset,
    2.95px 7.25px 2.3px 0 rgba(255, 255, 255, 0.82) inset;
}

body.is-mobile-fullbleed .pregame-bottom-actions .secondary-action-button {
  width: auto;
  max-width: none;
  min-width: max-content;
  height: 48px;
  min-height: 48px;
  align-items: center;
}

body.is-mobile-fullbleed .pregame-stat-chip,
body.is-mobile-fullbleed .hud-economy-item,
body.is-mobile-fullbleed .wave-preview-counter {
  min-height: 0;
  padding: 0;
}

.pregame-map-stage::before {
  content: "";
  position: absolute;
  inset: -12%;
  z-index: 0;
  pointer-events: none;
  background:
    linear-gradient(var(--pregame-map-background-overlay, rgba(2, 4, 10, 0.18)), var(--pregame-map-background-overlay, rgba(2, 4, 10, 0.18))),
    var(--pregame-map-background-image, url("./assets/background/back.png")) center center / cover no-repeat,
    var(--pregame-map-background-color, #02040a);
  transform-origin: center center;
  animation: pregameMapBackgroundDrift 9.333s ease-in-out infinite alternate;
  will-change: transform;
}

.pregame-screen.is-upgrade-mode .pregame-map-panel {
  pointer-events: none;
  transform: translateY(-104%);
}

.pregame-screen.is-knowledge-mode .pregame-map-panel {
  pointer-events: none;
  transform: translateY(-104%);
}

.pregame-screen.is-upgrade-mode .pregame-map-stage {
  transform: none;
}

.pregame-screen.is-knowledge-mode .pregame-map-stage {
  transform: none;
}

.pregame-screen.is-madness-mode .pregame-map-stage::before {
  filter: sepia(1) saturate(4) hue-rotate(315deg) brightness(0.68) contrast(1.08);
  animation-duration: 4.6665s;
}

.pregame-map-transition-overlay {
  position: absolute;
  inset: 0;
  z-index: 4;
  width: 100%;
  height: 100%;
  object-fit: cover;
  pointer-events: none;
  opacity: 0;
  transform: translateY(0);
  will-change: transform;
}

.pregame-map-transition-overlay.is-visible {
  opacity: 1;
}

.pregame-map-bottom-cut {
  display: none;
}

.pregame-screen.is-upgrade-mode .pregame-profile {
  opacity: 1;
  transform: none;
  pointer-events: none;
}

.pregame-screen.is-knowledge-mode .pregame-profile {
  opacity: 1;
  transform: none;
  pointer-events: none;
}

.pregame-map-canvas {
  width: 100%;
  height: 100%;
  display: block;
  touch-action: none;
  user-select: none;
  position: relative;
  z-index: 2;
}

@keyframes pregameMapBackgroundDrift {
  0% {
    transform: rotate(-10deg) scale(1.08);
  }

  50% {
    transform: rotate(0deg) scale(1.1);
  }

  100% {
    transform: rotate(10deg) scale(1.08);
  }
}

.pregame-map-loading {
  position: absolute;
  inset: 0;
  z-index: 4;
  display: none;
  align-items: stretch;
  justify-content: stretch;
  overflow: hidden;
  background: var(--pregame-map-background-color, #02040a);
}

.pregame-map-loading.is-visible {
  display: flex;
}

.pregame-map-loading > * {
  position: relative;
  z-index: 1;
}

.pregame-map-loading-panel {
  position: absolute;
  inset: 0;
  z-index: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: clamp(24px, 4.4vw, 38px);
  border-radius: 0;
  overflow: hidden;
}

.pregame-map-loading-backdrop {
  position: absolute;
  inset: 0;
  z-index: 0;
  border-radius: 0;
  overflow: hidden;
  background:
    linear-gradient(var(--pregame-map-background-overlay, rgba(0, 0, 0, 0.58)), var(--pregame-map-background-overlay, rgba(0, 0, 0, 0.58))),
    var(--pregame-map-background-image, url("./assets/background/back.png")) center center / cover no-repeat,
    var(--pregame-map-background-color, #02040a);
}

.pregame-map-loading-backdrop::before {
  content: "";
  position: absolute;
  inset: -14%;
  pointer-events: none;
  background: radial-gradient(ellipse at center, rgba(255, 255, 255, 0.06) 0%, rgba(255, 255, 255, 0) 56%);
}

.pregame-map-notice {
  position: absolute;
  left: 50%;
  top: calc(env(safe-area-inset-top, 0px) + 72px);
  transform: translate(-50%, -8px);
  z-index: 3;
  max-width: min(92vw, 520px);
  padding: 8px 12px;
  border: 1px solid rgba(251, 191, 36, 0.5);
  border-radius: 12px;
  background: rgba(15, 23, 42, 0.9);
  color: #fef3c7;
  font-size: 13px;
  font-weight: 700;
  line-height: 1.25;
  text-align: center;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.16s ease, transform 0.16s ease;
}

.pregame-map-notice.is-visible {
  opacity: 1;
  transform: translate(-50%, 0);
}

.pregame-upgrade-panel {
  position: absolute;
  inset: 0;
  z-index: 4;
  display: flex;
  align-items: flex-start;
  justify-content: center;
  padding:
    calc(env(safe-area-inset-top, 0px) + 112px)
    calc(env(safe-area-inset-right, 0px) + 28px)
    calc(env(safe-area-inset-bottom, 0px) + 118px)
    calc(env(safe-area-inset-left, 0px) + 28px);
  background: transparent;
  opacity: 0;
  visibility: hidden;
  transform: translateY(104%);
  transition:
    transform 430ms cubic-bezier(0.22, 0.8, 0.26, 1),
    opacity 180ms ease,
    visibility 0s linear 430ms;
  pointer-events: none;
  will-change: transform, opacity;
}

.pregame-screen.is-upgrade-mode #pregameUpgradePanel {
  opacity: 1;
  visibility: visible;
  transform: translateY(0);
  transition:
    transform 430ms cubic-bezier(0.22, 0.8, 0.26, 1),
    opacity 180ms ease;
  pointer-events: auto;
}

.pregame-screen.is-knowledge-mode .pregame-knowledge-panel {
  opacity: 1;
  visibility: visible;
  transform: translateY(0);
  transition:
    transform 430ms cubic-bezier(0.22, 0.8, 0.26, 1),
    opacity 180ms ease;
  pointer-events: auto;
}

.pregame-upgrade-card {
  width: min(1400px, calc(100vw - 28px));
  height: 100%;
  max-height: calc(100dvh - env(safe-area-inset-top, 0px) - env(safe-area-inset-bottom, 0px) - 24px);
  border-radius: 0;
  border: none;
  background: transparent;
  box-shadow: none;
  display: flex;
  flex-direction: column;
  align-items: stretch;
  justify-content: flex-start;
  gap: 18px;
  margin: 0 auto;
  overflow: hidden;
}

.pregame-knowledge-panel .pregame-upgrade-card {
  gap: 30px;
}

.pregame-upgrade-head {
  display: flex;
  flex-direction: row;
  align-items: flex-start;
  justify-content: flex-start;
  align-self: stretch;
  gap: 18px;
  padding: 0;
  margin-left: 0;
  width: 100%;
  border-bottom: none;
}

.pregame-upgrade-head-copy {
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  gap: 2px;
  min-width: 0;
}

.pregame-upgrade-head-icon {
  width: 64px;
  height: 64px;
  min-width: 64px;
  min-height: 64px;
  align-self: center;
  background-repeat: no-repeat;
  background-position: center;
  background-size: contain;
}

.secondary-action-button-inline-icon {
  width: 22px;
  height: 22px;
  min-width: 22px;
  min-height: 22px;
  display: inline-block;
  flex: 0 0 auto;
  background-repeat: no-repeat;
  background-position: center;
  background-size: contain;
}

.pregame-upgrade-title {
  color: #f1f5f9;
  font-size:var(--font-size-ui-title-panel);
  font-weight:var(--font-weight-ui-heavy);
}

.pregame-upgrade-stars {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  color: #fde68a;
  line-height: 1;
  font-size:var(--font-size-ui-title-section);
  font-weight:var(--font-weight-ui-heavy);
}

.pregame-knowledge-subtitle {
  color: rgba(226, 232, 240, 0.88);
}

.pregame-upgrade-stars-icon {
  width: 0.75em;
  height: 0.75em;
  min-width: 0.75em;
  min-height: 0.75em;
  aspect-ratio: 1 / 1;
  display: inline-block;
  flex: 0 0 auto;
}

.pregame-upgrade-browser {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 320px;
  gap: 36px;
  flex: 1 1 auto;
  align-items: stretch;
  min-height: 0;
}

.pregame-upgrade-grid {
  display: flex;
  flex-direction: column;
  gap: 20px;
  width: 100%;
  min-width: 0;
  height: 100%;
  max-height: none;
  overflow-y: auto;
  overflow-x: hidden;
  padding: 8px 0px 54px;
  scrollbar-width: none;
  -ms-overflow-style: none;
}

.pregame-upgrade-section {
  display: grid;
  grid-template-columns: 132px minmax(0, 1fr);
  align-items: start;
  align-self: stretch;
  gap: 10px;
  width: 100%;
  min-width: 0;
}

.pregame-upgrade-section-title {
  color: rgba(248, 250, 252, 0.92);
  padding-top: 10px;
  font-size:var(--font-size-ui-body-strong);
  font-weight:var(--font-weight-ui-strong);
}

.pregame-upgrade-section-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(72px, 72px));
  gap: 14px;
  align-content: start;
  justify-content: start;
  align-self: stretch;
  width: 100%;
  min-width: 0;
}

.pregame-upgrade-grid::-webkit-scrollbar {
  width: 0;
  height: 0;
  display: none;
}

.pregame-upgrade-tile {
  position: relative;
  width: 72px;
  height: 72px;
  padding: 0;
  margin: 0;
  appearance: none;
  -webkit-appearance: none;
  border: none;
  background: transparent;
  cursor: pointer;
  transition: transform 140ms ease, opacity 140ms ease;
}

.pregame-upgrade-tile:hover {
  transform: translateY(-1px);
}

.pregame-upgrade-tile.is-locked {
  opacity: 1;
}

.pregame-upgrade-tile.is-unaffordable {
  opacity: 0.55;
}

.pregame-upgrade-tile.is-selected {
  opacity: 1;
}

.pregame-knowledge-tile.is-locked {
  opacity: 0.42;
}

.pregame-knowledge-tile.is-locked .pregame-upgrade-tile-frame {
  border-color: rgba(148, 163, 184, 0.2);
  box-shadow: none;
}

.pregame-upgrade-tile-frame {
  position: absolute;
  inset: -6px;
  border: 2px solid rgba(203, 213, 225, 0);
  border-radius: 8px;
  transition: border-color 140ms ease, box-shadow 140ms ease;
}

.pregame-upgrade-tile.is-selected .pregame-upgrade-tile-frame {
  border-color: rgba(203, 213, 225, 0.8);
  box-shadow: 0 0 0 1px rgba(203, 213, 225, 0.18);
}

.pregame-upgrade-tile-media {
  position: absolute;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
}

.pregame-upgrade-tile-art {
  width: 100%;
  height: 100%;
  object-fit: contain;
  display: block;
  image-rendering: auto;
}

.pregame-upgrade-atlas-canvas {
  display: block;
  width: 100%;
  height: 100%;
}

.pregame-upgrade-tile-icon,
.pregame-upgrade-detail-icon {
  display: block;
  width: 100%;
  height: 100%;
  background-repeat: no-repeat;
  background-position: center;
  background-size: contain;
}

.pregame-upgrade-tile-icon {
  font-size: 48px;
}

.pregame-upgrade-detail-icon {
  font-size: 138px;
}

.pregame-knowledge-preview {
  flex: 0 0 auto;
}

.pregame-knowledge-preview-canvas {
  display: block;
  image-rendering: auto;
}

.pregame-knowledge-preview.is-status,
.pregame-knowledge-preview.is-unknown {
  width: 100%;
  height: 100%;
  display: block;
}

.pregame-knowledge-preview.is-status,
.pregame-knowledge-preview.is-unknown,
.pregame-knowledge-preview.is-tower {
  transform: scale(0.75);
  transform-origin: center center;
}

.pregame-knowledge-preview.is-unknown {
  opacity: 0.9;
  filter: grayscale(0.08);
}

.pregame-upgrade-tile-fallback {
  width: 100%;
  height: 100%;
  border: 2px solid rgba(203, 213, 225, 0.24);
  border-radius: 10px;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 8px;
  color: #f8fafc;
  font-size: 11px;
  font-weight: 900;
  line-height: 1.05;
  text-align: center;
  text-transform: uppercase;
}

.pregame-upgrade-tile-badge {
  position: absolute;
  top: -2px;
  left: -2px;
  min-height: 19px;
  padding: 0 7px;
  border-radius: 999px;
  background: #334155;
  color: #f8fafc;
  font-size: 10px;
  font-weight: 900;
  line-height: 19px;
  text-align: center;
  box-shadow: 0 6px 18px rgba(0, 0, 0, 0.28);
}

.pregame-upgrade-tile-new-badge {
  position: absolute;
  top: -2px;
  right: -2px;
  min-height: 19px;
  padding: 0 7px;
  border-radius: 999px;
  background: #dc2626;
  color: #fff;
  font-size: 10px;
  font-weight: 900;
  line-height: 19px;
  text-align: center;
  box-shadow: 0 8px 18px rgba(127, 29, 29, 0.35);
}

.pregame-upgrade-open-new-badge {
  position: absolute;
  top: -2px;
  right: -2px;
  display: none;
  min-height: 19px;
  padding: 0 7px;
  border-radius: 999px;
  background: #dc2626;
  color: #fff;
  font-size: 10px;
  font-weight: 900;
  line-height: 19px;
  text-align: center;
  box-shadow: 0 8px 18px rgba(127, 29, 29, 0.35);
}

.pregame-upgrade-open-new-badge.is-visible {
  display: block;
}

.pregame-upgrade-detail {
  display: none;
  flex-direction: column;
  align-items: flex-start;
  gap: 14px;
  height: 100%;
  min-height: 0;
  max-height: 100%;
  overflow-y: auto;
  overflow-x: hidden;
  padding: 6px 0 12px;
}

.pregame-upgrade-detail.is-visible {
  display: flex;
}

.pregame-upgrade-detail-title-row {
  display: flex;
  align-items: center;
  gap: 10px;
  flex-wrap: wrap;
}

.pregame-upgrade-detail-title {
  color: #f8fafc;
  font-size: var(--font-size-ui-title-section);
  font-weight: var(--font-weight-ui-heavy);
  line-height: 1.1;
}

.pregame-upgrade-detail-level {
  min-width: 58px;
  padding: 6px 10px;
  border-radius: 999px;
  border: 1px solid rgba(250, 204, 21, 0.55);
  background: linear-gradient(180deg, rgba(120, 53, 15, 0.52), rgba(69, 26, 3, 0.82));
  color: #fde68a;
  font-size: 12px;
  font-weight: 500;
  line-height: 1;
  text-align: center;
}

.pregame-upgrade-detail-level.is-upgraded {
  animation: pregame-upgrade-level-pop 720ms cubic-bezier(0.2, 1, 0.2, 1);
}

.pregame-upgrade-detail-status {
  color: #f8fafc;
  line-height: 1.1;
    font-size: var(--font-size-ui-body);
  font-weight: var(--font-weight-ui-strong);
}

.pregame-upgrade-detail-status.is-upgraded {
  color: #fde68a;
  text-shadow: 0 0 12px rgba(250, 204, 21, 0.4);
  animation: pregame-upgrade-status-flash 900ms ease-out;
}

.pregame-upgrade-detail-status.is-locked {
  color: rgba(248, 250, 252, 0.88);
}

.pregame-upgrade-detail-preview {
  position: relative;
  width: 176px;
  height: 176px;
  display: flex;
  align-items: center;
  justify-content: center;
}

.pregame-upgrade-detail-preview .pregame-knowledge-preview-canvas {
  width: 176px;
  height: 176px;
}

.pregame-upgrade-detail-preview.is-upgraded {
  filter: drop-shadow(0 0 22px rgba(250, 204, 21, 0.35));
}

.pregame-upgrade-detail-burst {
  position: absolute;
  inset: -18px;
  border-radius: 24px;
  background:
    radial-gradient(circle, rgba(253, 224, 71, 0.32) 0%, rgba(253, 224, 71, 0.18) 26%, rgba(253, 224, 71, 0) 64%),
    conic-gradient(from 0deg, rgba(251, 191, 36, 0.72), rgba(250, 204, 21, 0.08), rgba(251, 191, 36, 0.72));
  opacity: 0;
  pointer-events: none;
  animation: pregame-upgrade-burst 900ms ease-out;
}

.pregame-upgrade-detail-art {
  width: 100%;
  height: 100%;
  object-fit: contain;
  display: block;
}

.pregame-upgrade-detail-fallback {
  width: 100%;
  height: 100%;
  border: 2px solid rgba(203, 213, 225, 0.24);
  border-radius: 12px;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 18px;
  color: #f8fafc;
  font-size: 20px;
  font-weight: 900;
  text-align: center;
  text-transform: uppercase;
  line-height: 1.05;
}

.pregame-upgrade-detail-description {
  color: rgba(248, 250, 252, 0.86);
  line-height: 1.42;
  max-width: 280px;
  font-size: var(--font-size-ui-title-card);
  font-weight: var(--font-weight-ui-strong);
}

.pregame-upgrade-detail-description.is-locked {
  color: #ffffff;
  font-size: var(--font-size-ui-title-card);
  font-weight: var(--font-weight-ui-strong);
}

.pregame-upgrade-detail-hint-label {
  color: #fb923c;
}

.pregame-upgrade-detail-hint-text {
  color: #ffffff;
}

.pregame-knowledge-detail-stats {
  display: flex;
  flex-direction: column;
  gap: 10px;
  width: min(100%, 280px);
}

.pregame-knowledge-detail-stats .stat-row {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 12px;
  color: rgba(248, 250, 252, 0.92);
  font-size: var(--font-size-ui-body);
  font-weight: var(--font-weight-ui-strong);
}

.pregame-knowledge-detail-stats .stat-row .stat-bar-group {
  justify-content: flex-end;
}

.pregame-upgrade-detail-button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 12px;
  min-width: 176px;
  min-height: 58px;
  padding: 0 18px;
  border-radius: 18px;
  border: 2px solid rgba(30, 41, 59, 0.95);
  background: #020617;
  color: #f8fafc;
  font-size: 18px;
  font-weight: 900;
  line-height: 1;
  box-shadow: inset 0 0 0 1px rgba(255, 255, 255, 0.04);
}

.pregame-upgrade-detail-button.is-upgraded {
  animation: pregame-upgrade-button-flash 900ms ease-out;
}

.pregame-upgrade-detail-button-label,
.pregame-upgrade-detail-button-cost {
  display: inline-flex;
  align-items: center;
  justify-content: center;
}

.pregame-upgrade-detail-button-cost {
  gap: 6px;
}

.pregame-upgrade-detail-button-cost-icon {
  width: 18px;
  height: 18px;
  min-width: 18px;
  min-height: 18px;
  font-size: 15px;
}

.pregame-upgrade-detail-button.is-available {
  border: none;
  background: linear-gradient(262deg, #feca16 17.87%, #ff8800 85.15%);
  box-shadow:
    -2.95px -5.95px 2.3px 0 #ba4e1f inset,
    1.95px -8.875px 3.6px 0 #feca16 inset,
    .95px 4.125px 3.6px 0 #feca16 inset,
    2.95px 7.25px 2.3px 0 rgba(255, 213, 72, 0.58) inset;
  color: #fff;
  text-shadow: 0 4px 3px rgba(0, 0, 0, 0.2);
  cursor: pointer;
}

.pregame-upgrade-detail-button:disabled,
.pregame-upgrade-detail-button.is-disabled,
.pregame-upgrade-detail-button.is-maxed {
  color: rgba(248, 250, 252, 0.92);
  background: rgba(30, 41, 59, 0.58);
  border-color: rgba(30, 41, 59, 0.95);
  cursor: not-allowed;
}

@keyframes pregame-upgrade-level-pop {
  0% {
    transform: scale(0.72);
    opacity: 0;
  }
  45% {
    transform: scale(1.16);
    opacity: 1;
  }
  100% {
    transform: scale(1);
    opacity: 1;
  }
}

@keyframes pregame-upgrade-status-flash {
  0% {
    transform: translateY(8px);
    opacity: 0;
  }
  30% {
    transform: translateY(0);
    opacity: 1;
  }
  100% {
    transform: translateY(0);
    opacity: 1;
  }
}

@keyframes pregame-upgrade-burst {
  0% {
    transform: scale(0.72);
    opacity: 0;
  }
  30% {
    opacity: 1;
  }
  100% {
    transform: scale(1.18);
    opacity: 0;
  }
}

@keyframes pregame-upgrade-button-flash {
  0% {
    transform: scale(0.96);
    box-shadow: 0 0 0 rgba(250, 204, 21, 0), inset 0 0 0 1px rgba(255, 255, 255, 0.04);
  }
  35% {
    transform: scale(1.04);
    box-shadow: 0 0 26px rgba(250, 204, 21, 0.34), inset 0 0 0 1px rgba(255, 255, 255, 0.12);
  }
  100% {
    transform: scale(1);
    box-shadow: inset 0 0 0 1px rgba(255, 255, 255, 0.04);
  }
}

.pregame-upgrade-sections {
  display: flex;
  flex-direction: column;
  gap: 12px;
  padding: 4px 0 2px;
  flex: 1;
  min-width: 0;
  overflow-x: auto;
  overflow-y: auto;
  height: 100%;
  max-height: none;
  scrollbar-width: none;
  -ms-overflow-style: none;
  -webkit-overflow-scrolling: touch;
  touch-action: pan-x pan-y;
  cursor: grab;
}

.pregame-upgrade-sections:active {
  cursor: grabbing;
}

.pregame-upgrade-sections::-webkit-scrollbar {
  width: 0;
  height: 0;
  display: none;
}

.pregame-upgrade-section {
  border: none;
  border-radius: 0;
  background: transparent;
  padding: 0;
  display: grid;
  grid-template-columns: 132px minmax(0, 1fr);
  align-items: start;
  gap: 10px;
  width: 100%;
  min-width: 0;
}

.pregame-upgrade-section-title {
  color: rgba(248, 250, 252, 0.92);
  opacity: 1;
  width: auto;
  min-width: 0;
  padding-top: 10px;
}

.pregame-upgrade-tree {
  display: flex;
  flex-direction: row;
  align-items: flex-start;
  gap: 56px;
  flex: 1;
  min-width: max-content;
  overflow: visible;
  padding: 2px 2px 10px 2px;
}

.pregame-upgrade-node {
  position: relative;
  appearance: none;
  -webkit-appearance: none;
  width: 224px;
  min-width: 224px;
  min-height: 152px;
  border-radius: 0;
  border: none;
  background: transparent;
  padding: 2px 2px 4px;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: flex-start;
  gap: 4px;
  cursor: pointer;
  transition: transform 140ms ease, opacity 140ms ease;
}

.pregame-upgrade-node:hover:not(:disabled) {
  transform: translateY(-1px);
  opacity: 0.95;
}

.pregame-upgrade-node[data-has-parent="true"]::before {
  content: "";
  position: absolute;
  left: -56px;
  top: 50%;
  width: 56px;
  height: 2px;
  transform: translateY(-50%);
  background: rgba(203, 213, 225, 0.5);
}

.pregame-upgrade-node.is-locked {
  opacity: 0.34;
}

.pregame-upgrade-node.is-unaffordable {
  opacity: 1;
}

.pregame-upgrade-node.is-affordable {
  opacity: 1;
}

.pregame-upgrade-node.is-maxed {
  opacity: 1;
}

.pregame-upgrade-node:disabled {
  cursor: not-allowed;
}

.pregame-upgrade-node-icon-wrap {
  position: relative;
  width: 40px;
  height: 40px;
}

.pregame-upgrade-node-icon {
  width: 100%;
  height: 100%;
  border-radius: 0;
  border: none;
  background: transparent;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 24px;
  opacity: 1;
}

.pregame-upgrade-node-level {
  position: absolute;
  top: -4px;
  right: -8px;
  color: #f8fafc;
  font-size: 10px;
  font-weight: 800;
  line-height: 1;
  text-shadow: 0 2px 8px rgba(15, 23, 42, 0.95);
}

.pregame-upgrade-node-title {
  text-align: center;
  color: #e2e8f0;
  font-size: 14px;
  font-weight: 800;
  line-height: 1.12;
  min-height: 18px;
  width: 100%;
}

.pregame-upgrade-node-description {
  text-align: center;
  color: rgba(226, 232, 240, 0.78);
  font-size: 12px;
  line-height: 1.25;
  min-height: 32px;
  width: 100%;
}

.pregame-upgrade-node-meta {
  display: flex;
  flex-direction: row;
  align-items: center;
  justify-content: center;
  margin-top: auto;
}

.pregame-upgrade-node-cost {
  color: #fde68a;
  font-size: 13px;
  font-weight: 800;
}

.pregame-upgrade-node.is-unaffordable .pregame-upgrade-node-cost {
  opacity: 0.36;
}

.pregame-upgrade-node-hint {
  margin-top: 4px;
  color: rgba(248, 250, 252, 0.68);
  font-size: 11px;
  font-weight: 700;
  line-height: 1.22;
  text-align: center;
  width: 100%;
}

.pregame-upgrade-empty {
  color: #cbd5e1;
  font-size: 14px;
  font-weight: 700;
  line-height: 1.4;
  padding: 12px 0;
}

.pregame-upgrade-debug-section {
  align-items: stretch;
}

.pregame-upgrade-debug-list {
  display: flex;
  flex-direction: column;
  gap: 10px;
  min-width: min(920px, calc(100vw - 280px));
  width: min(920px, calc(100vw - 280px));
  padding: 6px 0 12px;
}

.pregame-upgrade-debug-entry {
  display: flex;
  flex-direction: column;
  gap: 4px;
  padding: 10px 12px;
  border: 1px solid rgba(148, 163, 184, 0.18);
  background: rgba(15, 23, 42, 0.22);
}

.pregame-upgrade-debug-entry.is-completed {
  border-color: rgba(74, 222, 128, 0.28);
}

.pregame-upgrade-debug-heading {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 12px;
}

.pregame-upgrade-debug-label {
  color: #e2e8f0;
  font-size: 14px;
  font-weight: 800;
}

.pregame-upgrade-debug-status {
  color: #94a3b8;
  font-size: 12px;
  font-weight: 800;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  flex-shrink: 0;
}

.pregame-upgrade-debug-entry.is-completed .pregame-upgrade-debug-status {
  color: #86efac;
}

.pregame-upgrade-debug-hint {
  color: #cbd5e1;
  font-size: 12px;
  line-height: 1.35;
}

.pregame-upgrade-debug-line {
  color: #fde68a;
  font-size: 12px;
  line-height: 1.35;
  word-break: break-word;
}

@media (max-width: 1050px) {
  .pregame-screen.is-upgrade-mode .pregame-map-panel {
    transform: translateY(-102%);
  }

  .pregame-screen.is-knowledge-mode .pregame-map-panel {
    transform: translateY(-102%);
  }

  .pregame-upgrade-panel {
    align-items: flex-start;
    padding:
      calc(env(safe-area-inset-top, 0px) + 88px)
      calc(env(safe-area-inset-right, 0px) + 12px)
      calc(env(safe-area-inset-bottom, 0px) + 104px)
      calc(env(safe-area-inset-left, 0px) + 12px);
    overflow: hidden;
  }

  .pregame-upgrade-card {
    width: min(
      100%,
      calc(100vw - env(safe-area-inset-left, 0px) - env(safe-area-inset-right, 0px) - 24px)
    );
    max-height: calc(
      100dvh - env(safe-area-inset-top, 0px) - env(safe-area-inset-bottom, 0px) - 16px
    );
    transform: none;
    gap: 14px;
  }

  .pregame-upgrade-browser {
    grid-template-columns: minmax(0, 1fr) minmax(220px, 280px);
    gap: 18px;
  }

  .pregame-upgrade-grid {
    gap: 14px;
    max-height: min(62vh, 520px);
    padding-bottom: 28px;
  }

  .pregame-upgrade-section-grid {
    grid-template-columns: repeat(auto-fill, minmax(64px, 64px));
    gap: 10px;
  }

  .pregame-upgrade-tile {
    width: 64px;
    height: 64px;
  }

  .pregame-upgrade-detail-preview {
    width: 148px;
    height: 148px;
  }

  .pregame-upgrade-detail-description,
  .pregame-knowledge-detail-stats {
    max-width: 100%;
    width: 100%;
  }
}

@media (max-width: 820px) {
  .pregame-upgrade-section {
    grid-template-columns: minmax(0, 1fr);
  }

  .pregame-upgrade-section-title {
    padding-top: 0;
  }

  .pregame-upgrade-browser {
    grid-template-columns: minmax(0, 1fr);
    gap: 22px;
  }

  .pregame-upgrade-detail {
    padding-top: 0;
  }
}

.level-cloud-transition {
  position: fixed;
  inset: 0;
  z-index: 26;
  display: none;
  pointer-events: none;
  overflow: hidden;
  --level-cloud-ms: 860ms;
}

.level-cloud-transition.is-visible {
  display: block;
}

.level-cloud-transition-layer {
  position: absolute;
  left: -56vw;
  width: 212vw;
  height: clamp(360px, 62vh, 760px);
  background-image:
    url("./assets/background/alotofclouds.webp"),
    url("./assets/background/alotofclouds.webp"),
    url("./assets/background/alotofclouds.webp"),
    url("./assets/background/alotofclouds.webp");
  background-repeat: repeat-x, repeat-x, repeat-x, repeat-x;
  background-size: auto 100%, auto 96%, auto 92%, auto 88%;
  background-position: 0 50%, -300px 56%, -160px 44%, -480px 52%;
  opacity: 1;
  transition: transform var(--level-cloud-ms) cubic-bezier(0.2, 0.8, 0.2, 1);
  will-change: transform;
}

.level-cloud-transition-layer.layer-1,
.level-cloud-transition-layer.layer-2 {
  top: -18vh;
  transform-origin: center top;
}

.level-cloud-transition-layer.layer-3,
.level-cloud-transition-layer.layer-4 {
  bottom: -18vh;
  transform-origin: center bottom;
}

.level-cloud-transition-layer.layer-1 {
  transform: translate3d(0, 2vh, 0) scale(0.96);
  z-index: 1;
}

.level-cloud-transition-layer.layer-2 {
  transform: translate3d(0, 18vh, 0) scale(1.08);
  z-index: 2;
}

.level-cloud-transition-layer.layer-3 {
  transform: translate3d(0, -18vh, 0) scale(1.18);
  z-index: 3;
}

.level-cloud-transition-layer.layer-4 {
  transform: translate3d(0, -2vh, 0) scale(1.3);
  z-index: 4;
}

.level-cloud-transition.is-open .level-cloud-transition-layer.layer-1 {
  transform: translate3d(0, -118vh, 0) scale(0.96);
}

.level-cloud-transition.is-open .level-cloud-transition-layer.layer-2 {
  transform: translate3d(0, -118vh, 0) scale(1.08);
}

.level-cloud-transition.is-open .level-cloud-transition-layer.layer-3 {
  transform: translate3d(0, 118vh, 0) scale(1.18);
}

.level-cloud-transition.is-open .level-cloud-transition-layer.layer-4 {
  transform: translate3d(0, 118vh, 0) scale(1.3);
}

.pregame-map-loading-logo-wrap {
  width: min(700px, calc(100vw - 88px), calc(34vh * 839 / 450));
  aspect-ratio: 839 / 450;
  flex: 0 0 auto;
  display: flex;
  align-items: center;
  justify-content: center;
  filter: drop-shadow(0 10px 26px rgba(0, 0, 0, 0.56));
}

.pregame-map-loading-logo {
  display: block;
  width: 100%;
  height: 100%;
  object-fit: contain;
}

.pregame-map-loading-progress {
  position: relative;
  width: min(500px, calc(100vw - 92px));
  height: clamp(9px, 1.15vw, 13px);
  border-radius: 999px;
  padding: 2px;
  border: 1px solid rgba(176, 111, 255, 0.26);
  background: linear-gradient(180deg, rgba(6, 4, 15, 0.96) 0%, rgba(15, 10, 30, 0.98) 100%);
  box-shadow:
    0 0 0 1px rgba(0, 0, 0, 0.72),
    0 0 24px rgba(126, 58, 242, 0.18),
    0 12px 28px rgba(0, 0, 0, 0.5),
    inset 0 1px 2px rgba(255, 255, 255, 0.08),
    inset 0 -1px 2px rgba(0, 0, 0, 0.75);
  overflow: hidden;
}

.pregame-map-loading-progress-fill {
  --pregame-loading-stage-color: #8d44ff;
  --pregame-loading-stage-color-bright: #f0abfc;
  --pregame-loading-stage-color-deep: #6d28d9;
  width: 0%;
  height: 100%;
  border-radius: inherit;
  position: relative;
  overflow: hidden;
  background: linear-gradient(
    90deg,
    var(--pregame-loading-stage-color-bright) 0%,
    var(--pregame-loading-stage-color) 45%,
    var(--pregame-loading-stage-color-deep) 100%
  );
  box-shadow:
    0 0 7px rgba(216, 180, 254, 0.78),
    0 0 18px rgba(168, 85, 247, 0.48),
    inset 0 1px 0 rgba(255, 255, 255, 0.58),
    inset 0 -1px 2px rgba(37, 0, 82, 0.64);
  isolation: isolate;
  transition: width 0.12s linear;
}

.pregame-map-loading-progress-fill::before,
.pregame-map-loading-progress-fill::after {
  content: "";
  position: absolute;
  inset: 0;
  pointer-events: none;
}

.pregame-map-loading-progress-fill::before {
  z-index: 3;
  background: linear-gradient(180deg, rgba(255, 255, 255, 0.42) 0%, rgba(255, 255, 255, 0.1) 42%, rgba(0, 0, 0, 0.18) 100%);
  opacity: 0.72;
}

.pregame-map-loading-progress-fill::after {
  z-index: 0;
  background:
    radial-gradient(circle at 100% 50%, rgba(255, 255, 255, 0.46) 0%, rgba(255, 255, 255, 0) 18%),
    linear-gradient(180deg, rgba(255, 255, 255, 0.2) 0%, rgba(255, 255, 255, 0.04) 66%, rgba(0, 0, 0, 0.18) 100%);
  opacity: 0.82;
  mix-blend-mode: screen;
}

.pregame-map-loading-progress-liquid {
  position: absolute;
  inset: 0;
  z-index: 1;
  pointer-events: none;
  background:
    radial-gradient(circle at 100% 50%, rgba(216, 180, 254, 0.32) 0%, rgba(168, 85, 247, 0.12) 22%, rgba(0, 0, 0, 0) 48%),
    linear-gradient(90deg, rgba(255, 255, 255, 0.08) 0%, rgba(255, 255, 255, 0.18) 100%);
  mix-blend-mode: screen;
  opacity: 0.5;
}

.pregame-map-loading-bubble-field {
  position: absolute;
  inset: -18% -4% -26%;
  z-index: 2;
  overflow: visible;
  pointer-events: none;
  filter: url("#pregameMapLoadingGoo") saturate(1.12);
  mix-blend-mode: screen;
  display: none;
  opacity: 0;
}

.pregame-map-loading-bubble {
  --bubble-duration: 3.8s;
  --bubble-delay: 0s;
  --bubble-drift-a: 8px;
  --bubble-drift-b: 18px;
  --bubble-rise: 22px;
  position: absolute;
  bottom: -52%;
  left: 10%;
  width: 16px;
  aspect-ratio: 1;
  border-radius: 999px;
  background:
    radial-gradient(circle at 30% 28%, rgba(255, 255, 255, 0.95) 0%, rgba(255, 255, 255, 0.62) 18%, rgba(255, 255, 255, 0) 36%),
    radial-gradient(circle at 54% 60%, rgba(255, 255, 255, 0.92) 0%, rgba(255, 255, 255, 0.32) 46%, rgba(255, 255, 255, 0) 100%);
  box-shadow: 0 0 12px rgba(255, 255, 255, 0.18);
  opacity: 0;
}

.pregame-map-loading-bubble::after {
  content: "";
  position: absolute;
  top: 12%;
  right: 18%;
  width: 34%;
  height: 24%;
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.66);
  filter: blur(0.6px);
  opacity: 0.76;
}

.pregame-map-loading-bubble:nth-child(1) {
  left: 7%;
  width: 14px;
  --bubble-duration: 3.2s;
  --bubble-delay: -0.8s;
  --bubble-drift-a: 10px;
  --bubble-drift-b: 20px;
  --bubble-rise: 18px;
}

.pregame-map-loading-bubble:nth-child(2) {
  left: 22%;
  width: 18px;
  --bubble-duration: 4.3s;
  --bubble-delay: -2.1s;
  --bubble-drift-a: -10px;
  --bubble-drift-b: 16px;
  --bubble-rise: 24px;
}

.pregame-map-loading-bubble:nth-child(3) {
  left: 37%;
  width: 12px;
  --bubble-duration: 2.9s;
  --bubble-delay: -0.4s;
  --bubble-drift-a: 7px;
  --bubble-drift-b: -12px;
  --bubble-rise: 19px;
}

.pregame-map-loading-bubble:nth-child(4) {
  left: 48%;
  width: 20px;
  --bubble-duration: 4.6s;
  --bubble-delay: -3.2s;
  --bubble-drift-a: -9px;
  --bubble-drift-b: 14px;
  --bubble-rise: 26px;
}

.pregame-map-loading-bubble:nth-child(5) {
  left: 62%;
  width: 15px;
  --bubble-duration: 3.4s;
  --bubble-delay: -1.6s;
  --bubble-drift-a: 12px;
  --bubble-drift-b: -10px;
  --bubble-rise: 21px;
}

.pregame-map-loading-bubble:nth-child(6) {
  left: 74%;
  width: 11px;
  --bubble-duration: 2.7s;
  --bubble-delay: -0.2s;
  --bubble-drift-a: -6px;
  --bubble-drift-b: 11px;
  --bubble-rise: 17px;
}

.pregame-map-loading-bubble:nth-child(7) {
  left: 84%;
  width: 19px;
  --bubble-duration: 4.1s;
  --bubble-delay: -2.8s;
  --bubble-drift-a: -12px;
  --bubble-drift-b: -6px;
  --bubble-rise: 25px;
}

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

.pregame-map-loading-version {
  position: relative;
  z-index: 1;
  color: rgba(148, 163, 184, 0.84);
  font-size: 15px;
  font-weight: 600;
  line-height: 1;
  font-variant-numeric: tabular-nums;
  text-shadow: 0 1px 2px rgba(0, 0, 0, 0.62);
}

@media (prefers-reduced-motion: reduce) {
  .pregame-map-loading-progress-fill,
  .pregame-map-loading-progress-fill::before,
  .pregame-map-loading-progress-fill::after,
  .pregame-map-loading-progress-liquid,
  .pregame-map-loading-bubble-field,
  .pregame-map-loading-bubble,
  .pregame-map-loading-backdrop::before {
    animation: none;
  }
}

@media (orientation: portrait), (max-aspect-ratio: 10 / 13) {
  .level-cloud-transition-layer {
    left: -70vw;
    width: 240vw;
    height: clamp(280px, 48vh, 560px);
  }

  .level-cloud-transition-layer.layer-1 {
    transform: translate3d(0, 3vh, 0) scale(0.96);
  }

  .level-cloud-transition-layer.layer-2 {
    transform: translate3d(0, 20vh, 0) scale(1.1);
  }

  .level-cloud-transition-layer.layer-3 {
    transform: translate3d(0, -20vh, 0) scale(1.22);
  }

  .level-cloud-transition-layer.layer-4 {
    transform: translate3d(0, -3vh, 0) scale(1.34);
  }

  .level-cloud-transition.is-open .level-cloud-transition-layer.layer-1 {
    transform: translate3d(0, -112vh, 0) scale(0.96);
  }

  .level-cloud-transition.is-open .level-cloud-transition-layer.layer-2 {
    transform: translate3d(0, -112vh, 0) scale(1.1);
  }

  .level-cloud-transition.is-open .level-cloud-transition-layer.layer-3 {
    transform: translate3d(0, 112vh, 0) scale(1.22);
  }

  .level-cloud-transition.is-open .level-cloud-transition-layer.layer-4 {
    transform: translate3d(0, 112vh, 0) scale(1.34);
  }
}

.hud-reset-button {
  position: fixed;
  right: var(--hud-edge-right);
  bottom: var(--hud-edge-bottom);
  width: calc(72px * var(--ui-scale));
  height: calc(72px * var(--ui-scale));
  z-index: 9;
  padding: 0;
}

.secondary-action-button-icon .hud-reset-button-icon {
  display: block;
  width: calc(28px * var(--ui-scale));
  height: calc(32px * var(--ui-scale));
  object-fit: contain;
  pointer-events: none;
}

.hud-reset-button:hover {
  background: transparent;
}

.hud-reset-button.has-button-icon,
.hud-wave-cooldown.has-button-icon {
  color: transparent;
  font-size: 0;
  border-color: transparent;
  background-color: transparent;
  background-repeat: no-repeat;
  background-position: center;
  background-size: contain;
}





.hud-speed-controls {
  --hud-button-size: calc(72px * var(--ui-scale));
  --hud-control-gap: calc(24px * var(--ui-scale));
  position: fixed;
  right: calc(var(--hud-edge-right) + var(--hud-button-size) + var(--hud-control-gap));
  bottom: var(--hud-edge-bottom);
  transform: translateY(0);
  display: flex;
  gap: calc(24px * var(--ui-scale));
  z-index: 9;
  opacity: 1;
  transition: opacity 0.22s ease, transform 0.28s ease;
}

.hud-speed-controls.is-hidden {
  opacity: 0;
  pointer-events: none;
  transform: translateY(20px);
}

.hud-speed-button {
  min-width: max-content;
  height: calc(72px * var(--ui-scale));
  flex: 0 0 auto;
}

.hud-speed-button:hover {
  background: transparent;
}

.hud-wave-cooldown {
  position: absolute;
  left: 50%;
  bottom: calc(94px * var(--ui-scale));
  transform: translateX(-50%);
  width: calc(108px * var(--ui-scale));
  height: calc(108px * var(--ui-scale));
  padding: 0;
  display: grid;
  place-items: center;
  border-radius: 50%;
  border: none;
  background: #171c24;
  color: #e2e8f0;
  z-index: 9;
  opacity: 0;
  pointer-events: none;
  box-shadow: 0 0 0 1px rgba(255, 255, 255, 0.02) inset;
  transition: opacity 0.15s ease, transform 0.15s ease;
}

.hud-wave-cooldown.is-visible {
  opacity: 1;
  pointer-events: auto;
}

.hud-wave-launch-button {
  display: grid;
  place-items: center;
  width: 50px;
  height: 50px;
  border: none;
  border-radius: 50%;
  background: transparent;
  color: #e6edf3;
}


.hud-wave-launch-button:disabled {
  opacity: 0.5;
  cursor: default;
}

.hud-wave-cooldown-ring {
  position: relative;
  width: 132px;
  height: 132px;
}

.hud-wave-cooldown-progress {
  width: 132px;
  height: 132px;
  transform: rotate(90deg) scaleX(-1);
}

.hud-wave-cooldown-track {
  fill: none;
  stroke: rgba(255, 255, 255, 0.06);
  stroke-width: 6;
  stroke-linecap: round;
}

.hud-wave-cooldown-bar {
  fill: none;
  stroke: #22c55e;
  stroke-width: 6;
  stroke-linecap: round;
}

.hud-wave-cooldown .hud-wave-launch-button {
  position: absolute;
  left: 50%;
  top: 50%;
  transform: translate(-50%, -50%);
}

.result-banner {
  position: fixed;
  inset: 0;
  z-index: 19;
  display: grid;
  place-items: center;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.2s ease;
}

.result-banner.is-visible {
  opacity: 1;
  pointer-events: auto;
}

.result-banner-confetti {
  position: absolute;
  left: 50%;
  top: 50%;
  width: 1px;
  height: 1px;
  z-index: -1;
  pointer-events: none;
  overflow: visible;
}

.result-banner-confetti span {
  position: absolute;
  left: -5px;
  top: -8px;
  width: 10px;
  height: 16px;
  border-radius: 2px;
  background: var(--c);
  opacity: 0;
  transform: translate(-50%, -50%) scale(0.35) rotate(0deg);
}

.result-banner.is-victory.is-visible .result-banner-confetti span {
  animation: result-banner-confetti-burst 1450ms cubic-bezier(0.16, 0.78, 0.28, 1) var(--d) both;
}

.result-banner:not(.is-victory) .result-banner-confetti span {
  animation: none;
}

.result-banner-card {
  position: relative;
  z-index: 1;
  overflow: visible;
  width: min(390px, calc(100vw - 48px));
  min-height: 420px;
  padding: 24px 24px 36px;
  display: flex;
  flex-direction: column;
  gap: 16px;
}

.result-banner-main-layout {
  position: relative;
  z-index: 1;
  width: 100%;
  display: grid;
  grid-template-columns: minmax(0, 1fr);
}

.result-banner-summary-panel {
  min-height: 360px;
  border-radius: 32px;
  background:
    linear-gradient(180deg, rgba(2, 4, 10, 0.96), rgba(0, 0, 0, 0.98)),
    #000;
  box-shadow: none;
  padding: 34px 28px 30px;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 16px;
}

.result-banner-title {
  font-size: var(--font-size-ui-title-display);
  font-weight: var(--font-weight-ui-strong);
  letter-spacing: 0;
  text-transform: uppercase;
  text-shadow: 0 6px 24px rgba(0, 0, 0, 0.6);
  text-align: center;
}

.result-banner-subhead {
  display: none;
  font-size: var(--font-size-ui-body-strong);
  font-weight: var(--font-weight-ui-strong);
  line-height: 1.2;
  text-align: center;
  color: rgba(255, 255, 255, 0.88);
}

.result-banner-subhead.is-visible {
  display: block;
}

.result-banner-upgrade-feed {
  display: none;
  width: 100%;
  max-width: none;
  flex-direction: column;
  gap: 18px;
}

.result-banner-upgrade-feed.is-visible {
  display: flex;
}

.result-banner-upgrade-feed-section {
  display: flex;
  flex-direction: column;
  gap: 14px;
  align-items: stretch;
}

.result-banner-upgrade-feed-title {
  color: #fff;
  font-size: var(--font-size-ui-title-panel);
  font-weight: var(--font-weight-ui-heavy);
  line-height: 1;
  text-align: left;
}

.result-banner-upgrade-feed-list {
  display: flex;
  flex-wrap: wrap;
  justify-content: flex-start;
  gap: 8px;
}

.result-banner-upgrade-feed-list.is-progress {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  align-items: stretch;
  width: 100%;
  gap: 16px;
}

.result-banner-upgrade-chip {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 28px;
  padding: 6px 12px;
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.08);
  color: rgba(255, 255, 255, 0.88);
  font-size: var(--font-size-ui-label);
  font-weight: var(--font-weight-ui-strong);
  line-height: 1.2;
  text-align: center;
}

.result-banner-upgrade-chip.is-new {
  box-shadow:
    inset 0 0 0 1px rgba(250, 204, 21, 0.3),
    0 10px 24px rgba(245, 158, 11, 0.15);
}

.result-banner-upgrade-chip.is-progress {
  width: 100%;
  max-width: 320px;
  background: rgba(96, 165, 250, 0.1);
  box-shadow: inset 0 0 0 1px rgba(96, 165, 250, 0.18);
}

.result-banner-upgrade-progress-row {
  width: 100%;
  display: flex;
  align-items: flex-start;
  gap: 18px;
  padding: 22px 20px 18px;
  border-radius: 10px;
  background: rgba(0, 0, 0, 0.94);
  box-shadow: inset 0 0 0 1px rgba(255, 255, 255, 0.08);
}

.result-banner-upgrade-progress-row.is-ready {
  box-shadow: inset 0 0 0 2px rgba(255, 196, 36, 0.95);
}

.result-banner.has-analytics-aside .result-banner-upgrade-feed,
.result-banner.is-madness-layout .result-banner-upgrade-feed {
  max-width: none;
}

.result-banner-upgrade-progress-icon {
  width: 56px;
  height: 56px;
  flex: 0 0 56px;
  background: rgba(15, 23, 42, 0.22);
  display: flex;
  align-items: center;
  justify-content: center;
  color: rgba(248, 250, 252, 0.92);
  font-size: 18px;
  font-weight: 800;
  overflow: hidden;
}

.result-banner-upgrade-progress-art {
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: block;
}

.result-banner-upgrade-progress-content {
  min-width: 0;
  flex: 1 1 auto;
  display: flex;
  flex-direction: column;
  gap: 5px;
}

.result-banner-upgrade-progress-header {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 10px;
}

.result-banner-upgrade-progress-label {
  color: #fff;
  font-size: var(--font-size-ui-title-card);
  font-weight: var(--font-weight-ui-heavy);
  line-height: 1.2;
}

.result-banner-upgrade-progress-hint {
  color: rgba(255, 255, 255, 0.58);
  font-size: calc(14px * var(--ui-scale));
  font-weight: var(--font-weight-ui-base);
  line-height: 1.45;
}

.result-banner-upgrade-progress-footer {
  display: flex;
  align-items: center;
  gap: 16px;
  margin-top: auto;
}

.result-banner-upgrade-progress-bar {
  flex: 1 1 auto;
  height: 13px;
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.16);
  overflow: hidden;
  position: relative;
}

.result-banner-upgrade-progress-previous-fill {
  width: 100%;
  height: 100%;
  min-width: 0;
  border-radius: inherit;
  position: absolute;
  inset: 0 auto 0 0;
  transform: scaleX(0);
  transform-origin: left center;
  will-change: transform;
  background: linear-gradient(180deg, rgba(42, 130, 23, 0.92), rgba(12, 84, 0, 0.94));
  box-shadow: inset 0 1px 0 rgba(177, 255, 128, 0.08);
}

.result-banner-upgrade-progress-fill {
  width: 100%;
  height: 100%;
  min-width: 0;
  border-radius: inherit;
  position: absolute;
  inset: 0 auto 0 0;
  background: linear-gradient(180deg, rgba(110, 255, 20, 0.98), rgba(32, 193, 0, 0.98));
  box-shadow: 0 0 16px rgba(71, 255, 0, 0.28);
  transform: scaleX(0);
  transform-origin: left center;
  will-change: transform;
}

.result-banner-upgrade-progress-row.is-run-scoped .result-banner-upgrade-progress-bar {
  background:
    repeating-linear-gradient(
      135deg,
      rgba(255, 255, 255, 0.12) 0 5px,
      rgba(255, 255, 255, 0.02) 5px 10px
    ),
    rgba(36, 53, 68, 0.84);
  box-shadow:
    inset 0 0 0 1px rgba(125, 221, 255, 0.18),
    inset 0 -1px 0 rgba(0, 0, 0, 0.42);
}

.result-banner-upgrade-progress-row.is-run-scoped .result-banner-upgrade-progress-previous-fill {
  background: linear-gradient(180deg, rgba(28, 94, 119, 0.92), rgba(9, 49, 68, 0.95));
  box-shadow: inset 0 1px 0 rgba(158, 236, 255, 0.1);
}

.result-banner-upgrade-progress-row.is-run-scoped .result-banner-upgrade-progress-fill {
  background: linear-gradient(180deg, rgba(103, 232, 249, 0.98), rgba(14, 165, 233, 0.98));
  box-shadow: 0 0 16px rgba(56, 189, 248, 0.34);
}

.result-banner-upgrade-progress-row.is-run-scoped .result-banner-upgrade-progress-value-delta {
  color: rgba(125, 221, 255, 0.9);
}

.result-banner-upgrade-progress-row.is-ready .result-banner-upgrade-progress-previous-fill {
  background: linear-gradient(180deg, rgba(126, 92, 12, 0.9), rgba(85, 47, 0, 0.94));
  box-shadow: inset 0 1px 0 rgba(255, 235, 156, 0.1);
}

.result-banner-upgrade-progress-row.is-ready .result-banner-upgrade-progress-fill {
  background: linear-gradient(180deg, rgba(255, 233, 90, 0.98), rgba(255, 168, 0, 0.98));
  box-shadow: 0 0 16px rgba(255, 196, 36, 0.32);
}

.result-banner-upgrade-progress-values {
  flex: 0 0 90px;
  width: 90px;
  display: inline-flex;
  align-items: baseline;
  justify-content: flex-end;
  gap: 8px;
  font-variant-numeric: tabular-nums;
  white-space: nowrap;
}

.result-banner-upgrade-progress-value-current {
  color: #fff;
  font-size: calc(16px * var(--ui-scale));
  font-weight: var(--font-weight-ui-heavy);
}

.result-banner-upgrade-progress-ready-button {
  width: 82px;
  min-width: 82px;
  max-width: 82px;
  min-height: 32px;
  padding: 0 10px;
  border: 1px solid rgba(255, 233, 90, 0.82);
  border-radius: 999px;
  background: linear-gradient(180deg, rgba(255, 233, 90, 0.98), rgba(255, 168, 0, 0.98));
  color: #2a1300;
  cursor: pointer;
  font-size: calc(13px * var(--ui-scale));
  font-weight: var(--font-weight-ui-heavy);
  line-height: 1;
  text-align: center;
  white-space: nowrap;
  box-shadow:
    inset 0 1px 0 rgba(255, 255, 255, 0.42),
    0 8px 18px rgba(255, 168, 0, 0.22);
}

.result-banner-upgrade-progress-ready-button:hover {
  transform: translateY(-1px);
}

.result-banner-upgrade-progress-value-delta {
  color: rgba(255, 255, 255, 0.4);
  font-size: calc(16px * var(--ui-scale));
  font-weight: var(--font-weight-ui-medium);
}

.result-banner-upgrade-progress-row.is-ready .result-banner-upgrade-progress-value-current {
  color: rgba(255, 196, 36, 0.98);
}

.result-banner-upgrade-progress-row.is-ready .result-banner-upgrade-progress-ready-button {
  color: #2a1300;
}

.result-banner-upgrade-progress-row.is-ready .result-banner-upgrade-progress-value-delta {
  display: none;
}

.result-banner-hint {
  display: none;
  width: 100%;
  max-width: 100%;
  color: rgba(255, 255, 255, 0.82);
  font-size: var(--font-size-ui-body-strong);
  font-weight: var(--font-weight-ui-base);
  line-height: 1.4;
  text-align: center;
  text-wrap: balance;
}

.result-banner-hint.is-visible {
  display: block;
}

.result-banner-star-balance {
  display: none;
  align-items: center;
  justify-content: center;
  gap: 10px;
  width: auto;
  color: #f8fafc;
}

.result-banner-star-balance.is-visible {
  display: flex;
}

.result-banner-star-balance-label {
  font-size: var(--font-size-ui-body-strong);
  font-weight: var(--font-weight-ui-base);
  line-height: 1.2;
  color: rgba(255, 255, 255, 0.82);
}

.result-banner-star-balance-icon {
  width: clamp(22px, 3.9vw, 30px);
  height: clamp(22px, 3.9vw, 30px);
  min-width: clamp(22px, 3.9vw, 30px);
  min-height: clamp(22px, 3.9vw, 30px);
}

.result-banner-star-balance-value {
  min-width: 1.8ch;
  text-align: left;
  font-size: var(--font-size-ui-title-section);
  font-weight: var(--font-weight-ui-base);
  font-variant-numeric: tabular-nums;
  line-height: 1;
  color: #f8fafc;
  text-shadow: 0 6px 20px rgba(0, 0, 0, 0.42);
}

.result-banner-star-balance-value.is-step {
  animation: result-banner-energy-value-step 190ms ease-out;
}

.result-banner.is-victory .result-banner-title,
.result-banner.is-defeat .result-banner-title {
  color: #fff;
}

@keyframes result-banner-confetti-burst {
  0% {
    opacity: 0;
    transform: translate(-50%, -50%) scale(0.2) rotate(0deg);
  }
  14% {
    opacity: 1;
  }
  72% {
    opacity: 1;
  }
  100% {
    opacity: 0;
    transform: translate(calc(-50% + var(--x)), calc(-50% + var(--y))) scale(1) rotate(var(--r));
  }
}

.result-banner-button {
  cursor: pointer;
}

.result-banner-button.primary-action-button {
  width: 312px;
  min-width: 312px;
  max-width: 312px;
  height: 100px;
  min-height: 100px;
  padding: 0 28px;
}

.result-banner .popup-secondary-button {
  background: rgba(1, 3, 7, 0.82);
}

.result-banner .popup-secondary-button::before {
  opacity: 0;
}

.result-banner-button:disabled {
  background: rgba(17, 24, 32, 0.65);
  border-color: #1f2937;
  color: rgba(248, 250, 252, 0.55);
  cursor: not-allowed;
}

.result-banner-button:disabled:hover {
  background: rgba(17, 24, 32, 0.65);
}

.result-banner-metrics {
  display: none;
  align-items: center;
  justify-content: center;
  flex-wrap: wrap;
  gap: 18px;
  width: 100%;
}

.result-banner-metrics.is-visible {
  display: flex;
}

.result-banner-metric-chip {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 10px;
  min-width: 0;
  min-height: 0;
  padding: 0;
  border-radius: 0;
  background: transparent;
  box-shadow: none;
}

.result-banner-metric-chip.is-energy {
  box-shadow: none;
}

.result-banner-metric-chip.is-stars {
  box-shadow: none;
}

.result-banner.is-defeat .result-banner-energy,
.result-banner.is-defeat .result-banner-star-balance {
  box-shadow: none;
  border: none;
  outline: none;
}

.result-banner.is-defeat .result-banner-metric-chip.is-energy,
.result-banner.is-defeat .result-banner-metric-chip.is-stars {
  box-shadow: none;
  border: none;
  outline: none;
}

.result-banner-metric-icon {
  width: 28px;
  height: 28px;
  min-width: 28px;
  min-height: 28px;
}

.result-banner-metric-value {
  font-size: var(--font-size-ui-topbar-stat);
  font-weight: var(--font-weight-ui-heavy);
  line-height: 1;
  color: #f8fafc;
  font-variant-numeric: tabular-nums;
}

.result-banner-action-label-text,
.result-banner-action-cost,
.result-banner-action-cost-value {
  display: inline-flex;
  align-items: center;
}

.result-banner-action-cost {
  gap: calc(6px * var(--ui-scale));
  margin-left: calc(10px * var(--ui-scale));
  padding: 0;
  border-radius: 0;
  background: transparent;
  color: #fff;
  font-size: var(--font-size-ui-button-cost);
  line-height: 1;
}

.result-banner-action-cost-icon {
  --result-banner-action-cost-icon-size: calc(30px * var(--ui-scale));
  width: var(--result-banner-action-cost-icon-size);
  height: var(--result-banner-action-cost-icon-size);
  min-width: var(--result-banner-action-cost-icon-size);
  min-height: var(--result-banner-action-cost-icon-size);
  flex: 0 0 var(--result-banner-action-cost-icon-size);
  font-size: var(--result-banner-action-cost-icon-size);
  line-height: 1;
  text-shadow: none;
  aspect-ratio: 1;
}

.result-banner-action-cost-icon.has-icon {
  background-size: contain !important;
}

.result-banner-analytics-list {
  display: none;
  width: 100%;
}

.result-banner-analytics-list.is-visible {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
  gap: 12px;
}

.result-banner-analytics-empty {
  color: rgba(248, 250, 252, 0.72);
  font-size: var(--font-size-ui-body-strong);
  font-weight: var(--font-weight-ui-base);
  line-height: 1.35;
  min-height: 108px;
  border-radius: 20px;
  background: rgba(10, 12, 20, 0.68);
  box-shadow: inset 0 0 0 1px rgba(255, 255, 255, 0.05);
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 18px;
}

.result-banner-analytics-row {
  display: flex;
  align-items: center;
  gap: 10px;
  min-height: 68px;
  padding: 12px 14px;
  border-radius: 10px;
  background: rgba(10, 12, 20, 0.78);
  box-shadow:
    inset 0 0 0 1px rgba(255, 255, 255, 0.05),
    0 18px 38px rgba(0, 0, 0, 0.28);
}

.result-banner-analytics-icon {
  width: 42px;
  height: 42px;
  min-width: 42px;
  min-height: 42px;
  border-radius: 12px;
  background: rgba(2, 6, 23, 0.65);
  box-shadow: inset 0 0 0 1px rgba(255, 255, 255, 0.08);
  background-repeat: no-repeat;
  background-position: center;
  background-size: 26px 26px;
  image-rendering: pixelated;
}

.result-banner-analytics-text {
  min-width: 0;
  display: flex;
  flex-direction: column;
}

.result-banner-analytics-value {
  font-size: var(--font-size-ui-title-card);
  font-weight: var(--font-weight-ui-heavy);
  line-height: 1;
  color: #f8fafc;
  font-variant-numeric: tabular-nums;
}

.result-banner-analytics-label {
  margin-top: 2px;
  font-size: var(--font-size-ui-body);
  font-weight: var(--font-weight-ui-base);
  line-height: 1.15;
  color: rgba(248, 250, 252, 0.76);
  text-transform: uppercase;
  letter-spacing: 0.04em;
}

.result-banner-rewards {
  display: none;
  align-items: center;
  justify-content: center;
  flex-direction: column;
  flex-wrap: nowrap;
  gap: 0;
  width: 100%;
  order: -2;
  min-height: 94px;
  margin-top: -18px;
}

.result-banner-rewards.has-stars,
.result-banner-rewards:has(.result-banner-stars.is-visible),
.result-banner-rewards.has-dust-reward {
  display: flex;
}

.result-banner-stars {
  display: none;
}

.result-banner-stars.is-visible {
  display: flex;
  align-items: center;
  justify-content: center;
}

.result-banner-stars.is-victory-stars {
  gap: 0;
  min-height: 0;
  margin-top: 0;
}

.result-banner-stars.is-defeat-info {
  order: 2;
  width: 100%;
  min-height: 48px;
  color: #f8fafc;
  font-size: var(--font-size-ui-title-panel);
  font-weight: var(--font-weight-ui-base);
  text-align: center;
}

.result-banner-dust-reward {
  position: relative;
  display: none;
  align-items: center;
  justify-content: center;
  gap: 12px;
  min-width: 220px;
  min-height: 48px;
  margin-top: -4px;
  padding: 0 12px 2px;
  color: #f8fafc;
}

.result-banner-dust-reward.is-visible {
  display: flex;
}

.result-banner-dust-gold-source,
.result-banner-dust-target {
  position: relative;
  z-index: 1;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
}

.result-banner-dust-gold-icon {
  width: clamp(34px, 4.7vw, 48px);
  height: clamp(34px, 4.7vw, 48px);
  min-width: clamp(34px, 4.7vw, 48px);
  min-height: clamp(34px, 4.7vw, 48px);
  filter: drop-shadow(0 0 12px rgba(250, 204, 21, 0.48));
}

.result-banner-dust-arrow {
  position: relative;
  z-index: 1;
  color: rgba(248, 250, 252, 0.84);
  font-size: clamp(22px, 3vw, 32px);
  font-weight: var(--font-weight-ui-heavy);
  line-height: 1;
  text-shadow: 0 5px 14px rgba(0, 0, 0, 0.48);
}

.result-banner-dust-reward-icon {
  width: clamp(36px, 5vw, 52px);
  height: clamp(36px, 5vw, 52px);
  min-width: clamp(36px, 5vw, 52px);
  min-height: clamp(36px, 5vw, 52px);
  filter: drop-shadow(0 0 14px rgba(192, 132, 252, 0.46));
}

.result-banner-dust-gold-value,
.result-banner-dust-reward-value {
  min-width: 2ch;
  text-align: left;
  font-size: var(--font-size-ui-title-section);
  font-weight: var(--font-weight-ui-heavy);
  font-variant-numeric: tabular-nums;
  line-height: 1;
  color: #fff;
  text-shadow: 0 6px 20px rgba(0, 0, 0, 0.42);
}

.result-banner-dust-gold-value.is-step,
.result-banner-dust-reward-value.is-step {
  animation: result-banner-energy-value-step 190ms ease-out;
}

.result-banner-dust-trail {
  position: absolute;
  inset: -28px 0 -26px;
  z-index: 0;
  pointer-events: none;
  overflow: visible;
}

.result-banner-dust-coin {
  position: absolute;
  left: 31%;
  top: 50%;
  display: inline-flex;
  align-items: center;
  gap: 5px;
  opacity: 0;
  transform: translate3d(-18px, calc(-50% + var(--coin-y, 0px)), 0) scale(0.42);
  animation: result-banner-dust-coin-fly 1700ms cubic-bezier(0.2, 0.68, 0.16, 1) var(--coin-delay, 0ms) forwards;
}

.result-banner-dust-coin-icon {
  width: 24px;
  height: 24px;
  min-width: 24px;
  min-height: 24px;
  filter: drop-shadow(0 6px 10px rgba(250, 204, 21, 0.45));
}

.result-banner-madness-kills {
  display: none;
  width: 100%;
}

.result-banner-madness-kills.is-visible {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
  gap: 12px;
}

.result-banner-madness-kill-row {
  display: flex;
  align-items: center;
  gap: 10px;
  min-height: 68px;
  padding: 12px 14px;
  border-radius: 20px;
  background: rgba(10, 12, 20, 0.78);
  box-shadow:
    inset 0 0 0 1px rgba(255, 255, 255, 0.05),
    0 18px 38px rgba(0, 0, 0, 0.28);
}

.result-banner-madness-kill-icon {
  width: 42px;
  height: 42px;
  min-width: 42px;
  min-height: 42px;
  border-radius: 12px;
  background: rgba(2, 6, 23, 0.65);
  box-shadow: inset 0 0 0 1px rgba(255, 255, 255, 0.08);
}

.result-banner-madness-kill-count {
  font-size: var(--font-size-ui-topbar-stat);
  font-weight: var(--font-weight-ui-heavy);
  line-height: 1;
  color: #f8fafc;
  font-variant-numeric: tabular-nums;
}

.result-banner-madness-kill-label {
  margin-top: 2px;
  font-size: var(--font-size-ui-body);
  font-weight: var(--font-weight-ui-base);
  line-height: 1.15;
  color: rgba(248, 250, 252, 0.76);
  text-transform: uppercase;
  letter-spacing: 0.04em;
}

.result-banner-energy {
  position: relative;
  display: none;
  min-height: 58px;
}

.result-banner-energy.is-visible {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 18px;
}

.result-banner-energy-icon {
  width: clamp(22px, 3.9vw, 30px);
  height: clamp(22px, 3.9vw, 30px);
  min-width: clamp(22px, 3.9vw, 30px);
  min-height: clamp(22px, 3.9vw, 30px);
}

.result-banner-energy-value {
  min-width: 1.8ch;
  text-align: right;
  font-size: var(--font-size-ui-title-section);
  font-weight: var(--font-weight-ui-base);
  font-variant-numeric: tabular-nums;
  line-height: 1;
  color: #f8fafc;
  text-shadow: 0 6px 20px rgba(0, 0, 0, 0.42);
}

.result-banner-energy-value.is-step {
  animation: result-banner-energy-value-step 190ms ease-out;
}

.result-banner-energy-trail {
  position: absolute;
  inset: -18px -64px;
  pointer-events: none;
}

.result-banner-energy-bolt {
  position: absolute;
  left: 18px;
  top: 50%;
  width: clamp(18px, 3vw, 24px);
  height: clamp(18px, 3vw, 24px);
  min-width: clamp(18px, 3vw, 24px);
  min-height: clamp(18px, 3vw, 24px);
  transform: translate3d(0, -50%, 0);
  opacity: 0;
  filter: drop-shadow(0 5px 10px rgba(250, 204, 21, 0.55));
  animation-name: result-banner-energy-bolt-fly;
  animation-duration: 470ms;
  animation-fill-mode: forwards;
  animation-delay: var(--bolt-delay, 0ms);
  animation-timing-function: cubic-bezier(0.2, 0.65, 0.12, 1);
}

.result-banner-energy-bolt.is-out {
  animation-name: result-banner-energy-bolt-out;
  animation-duration: 380ms;
  animation-timing-function: cubic-bezier(0.25, 0.54, 0.17, 1);
}

@keyframes result-banner-energy-bolt-fly {
  0% {
    opacity: 0;
    transform: translate3d(-132px, 20px, 0) scale(0.35) rotate(-26deg);
  }
  20% {
    opacity: 1;
  }
  100% {
    opacity: 0;
    transform: translate3d(0, -50%, 0) scale(1.16) rotate(0deg);
  }
}

@keyframes result-banner-energy-bolt-out {
  0% {
    opacity: 1;
    transform: translate3d(0, -50%, 0) scale(0.96) rotate(0deg);
  }
  100% {
    opacity: 0;
    transform: translate3d(78px, -64px, 0) scale(0.42) rotate(22deg);
  }
}

@keyframes result-banner-dust-coin-fly {
  0% {
    opacity: 0;
    transform: translate3d(-18px, calc(-50% + var(--coin-y, 0px)), 0) scale(0.42) rotate(-12deg);
  }
  16% {
    opacity: 1;
    transform: translate3d(8px, calc(-50% + var(--coin-y, 0px)), 0) scale(0.82) rotate(0deg);
  }
  72% {
    opacity: 1;
    transform: translate3d(92px, -50%, 0) scale(1.02) rotate(18deg);
  }
  100% {
    opacity: 0;
    transform: translate3d(128px, -50%, 0) scale(0.32) rotate(44deg);
  }
}

@keyframes result-banner-energy-value-step {
  0% {
    transform: translateY(8px) scale(0.88);
    opacity: 0.45;
  }
  100% {
    transform: translateY(0) scale(1);
    opacity: 1;
  }
}

.result-banner-star {
  --star-tilt: 0deg;
  width: 72px;
  height: 72px;
  min-width: 72px;
  min-height: 72px;
  opacity: 0;
  transform: translateY(10px) scale(0.2) rotate(var(--star-tilt));
  transform-origin: 50% 58%;
  background: url("./assets/ui/empty_star.png") center center / contain no-repeat;
  filter: drop-shadow(0 9px 16px rgba(0, 0, 0, 0.52));
  animation-name: result-banner-star-pop;
  animation-duration: 440ms;
  animation-fill-mode: forwards;
  animation-delay: var(--star-delay, 0ms);
  animation-timing-function: cubic-bezier(0.42, 0.02, 1, 0.85);
}

.result-banner-star.is-filled {
  background-image: url("./assets/ui/star.png");
}

.result-banner-star.is-center {
  width: 132px;
  height: 132px;
  min-width: 108px;
  min-height: 108px;
  margin: 0 -6px;
  z-index: 1;
}

.result-banner-star.is-left {
  --star-tilt: -15deg;
}

.result-banner-star.is-right {
  --star-tilt: 15deg;
}

@keyframes result-banner-star-pop {
  0% {
    opacity: 0;
    transform: translateY(10px) scale(0.2) rotate(var(--star-tilt));
  }
  72% {
    opacity: 1;
  }
  100% {
    opacity: 1;
    transform: translateY(0) scale(1) rotate(var(--star-tilt));
  }
}

@media (prefers-reduced-motion: reduce) {
  .result-banner-star {
    animation: none;
    opacity: 1;
    transform: none;
  }

  .result-banner-energy-bolt {
    animation: none;
    opacity: 0.45;
    transform: translate3d(0, -50%, 0) scale(1);
  }

  .result-banner-energy-value.is-step {
    animation: none;
  }
}

.result-banner-button.is-hidden {
  display: none;
}

.result-banner-madness-aside {
  display: none;
}

.result-banner-madness-section {
  display: none;
  flex-direction: column;
  gap: 16px;
}

.result-banner-madness-section.is-visible {
  display: flex;
}

.result-banner-stats-subsection {
  display: none;
  flex-direction: column;
  gap: 12px;
}

.result-banner-stats-subsection.is-visible {
  display: flex;
}

.result-banner-stats-subtitle {
  font-size: var(--font-size-ui-title-section);
  font-weight: var(--font-weight-ui-strong);
  line-height: 1.05;
  color: rgba(248, 250, 252, 0.94);
}

.result-banner-madness-section-title {
  font-size: var(--font-size-ui-title-panel);
  font-weight: var(--font-weight-ui-heavy);
  line-height: 1;
  color: #fff;
}

.result-banner-madness-perks {
  display: none;
  width: 100%;
}

.result-banner-madness-perks.is-visible {
  display: flex;
  flex-direction: column;
  gap: 26px;
}

.result-banner-madness-perk-group {
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.result-banner-madness-perk-group-title {
  font-size: var(--font-size-ui-title-section);
  font-size: calc(16px * var(--ui-scale));
  font-weight: var(--font-weight-ui-strong);
  line-height: 1.05;
}

.result-banner-madness-perk-cards {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 16px;
}

.result-banner-madness-perk-card {
  --perk-accent: rgba(255, 255, 255, 0.28);
  min-height: 0;
  padding: 16px 18px;
  border-radius: 24px;
  background:
    linear-gradient(180deg, rgba(4, 6, 14, 0.98), rgba(0, 0, 0, 0.98)),
    #000;
  box-shadow:
    inset 0 0 0 2px var(--perk-accent),
    0 18px 40px rgba(0, 0, 0, 0.32);
  display: flex;
  align-items: flex-start;
  gap: 14px;
}

.result-banner-madness-perk-icon {
  flex: 0 0 auto;
}

.result-banner-madness-perk-content {
  min-width: 0;
  flex: 1 1 auto;
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.result-banner-madness-perk-header {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 14px;
}

.result-banner-madness-perk-title {
  font-size: var(--font-size-ui-title-card);
  font-size: calc(16px * var(--ui-scale));
  font-weight: var(--font-weight-ui-heavy);
  line-height: 1.05;
  color: #fff;
}

.result-banner-madness-perk-description {
  font-size: var(--font-size-ui-body);
  font-weight: var(--font-weight-ui-strong);
  line-height: 1.5;
  color: rgba(241, 245, 249, 0.58);
}

.result-banner-madness-perk-level {
  font-size: var(--font-size-ui-title-card);
  font-size: calc(16px * var(--ui-scale));
  display: inline-flex;
  align-items: baseline;
  gap: 0;
  font-weight: var(--font-weight-ui-heavy);
  color: rgba(248, 250, 252, 0.92);
  font-variant-numeric: tabular-nums;
}

.result-banner-madness-perk-level-current {
  color: rgba(248, 250, 252, 0.92);
}

.result-banner-madness-perk-level-separator,
.result-banner-madness-perk-level-max {
  color: rgba(241, 245, 249, 0.48);
}

.result-banner-madness-empty {
  min-height: 108px;
  border-radius: 20px;
  background: rgba(10, 12, 20, 0.68);
  box-shadow: inset 0 0 0 1px rgba(255, 255, 255, 0.05);
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 18px;
  font-size: var(--font-size-ui-body-strong);
  font-weight: var(--font-weight-ui-base);
  color: rgba(248, 250, 252, 0.72);
}

.result-banner-madness-perk-group-title.is-group-global { color: #f8fafc; }
.result-banner-madness-perk-group-title.is-group-fire { color: #ff8d5c; }
.result-banner-madness-perk-group-title.is-group-ice { color: #60a5fa; }
.result-banner-madness-perk-group-title.is-group-lightning { color: #facc15; }
.result-banner-madness-perk-group-title.is-group-metal { color: #c4b5fd; }
.result-banner-madness-perk-group-title.is-group-ground { color: #d4a373; }
.result-banner-madness-perk-group-title.is-group-earth { color: #d4a373; }
.result-banner-madness-perk-group-title.is-group-multishot { color: #f472b6; }
.result-banner-madness-perk-group-title.is-group-burst { color: #fb7185; }
.result-banner-madness-perk-group-title.is-group-chain { color: #22d3ee; }
.result-banner-madness-perk-group-title.is-group-overload { color: #f97316; }

.result-banner-madness-perk-card.is-common { --perk-accent: rgba(161, 161, 170, 0.72); }
.result-banner-madness-perk-card.is-rare { --perk-accent: rgba(96, 165, 250, 0.92); }
.result-banner-madness-perk-card.is-epic { --perk-accent: rgba(168, 85, 247, 0.96); }
.result-banner-madness-perk-card.is-legendary { --perk-accent: rgba(245, 158, 11, 0.96); }

.result-banner.is-madness-layout .result-banner-card {
  width: min(1480px, calc(100vw - 40px));
  min-height: min(820px, calc(100vh - 40px));
  padding: 20px 20px 24px;
  background: transparent;
  box-shadow: none;
}

.result-banner.has-analytics-aside .result-banner-card {
  width: min(1480px, calc(100vw - 40px));
  min-height: min(760px, calc(100vh - 40px));
  padding: 20px 20px 24px;
  background: transparent;
  box-shadow: none;
}

.result-banner.is-madness-layout .result-banner-main-layout {
  grid-template-columns: minmax(320px, 390px) minmax(0, 1fr);
  align-items: start;
  gap: 32px;
}

.result-banner.is-madness-layout .result-banner-summary-panel {
  min-height: 0;
  min-width: 0;
  margin-top: 108px;
  padding: 42px 34px 30px;
}

.result-banner.is-madness-layout .result-banner-title {
  color: rgba(255, 255, 255, 0.94);
  font-size: var(--font-size-ui-title-panel);
  font-weight: var(--font-weight-ui-strong);
  line-height: 1.08;
  text-transform: none;
  text-shadow: 0 4px 14px rgba(0, 0, 0, 0.42);
}

.result-banner.is-madness-layout .result-banner-subhead {
  min-height: 28px;
}

.result-banner.is-madness-layout .result-banner-stars,
.result-banner.is-madness-layout .result-banner-energy {
  display: none !important;
}

.result-banner.is-madness-layout .result-banner-madness-aside {
  display: flex;
  flex-direction: column;
  gap: 34px;
  min-width: 0;
  padding: 108px 0 0;
  max-height: calc(100vh - 40px);
  overflow: auto;
  scrollbar-width: none;
  -ms-overflow-style: none;
}

.result-banner.has-analytics-aside .result-banner-main-layout {
  grid-template-columns: minmax(320px, 390px) minmax(0, 1fr);
  align-items: start;
  gap: 32px;
}

.result-banner.has-analytics-aside .result-banner-summary-panel {
  min-height: 0;
  min-width: 0;
  padding: 42px 34px 30px;
}

.result-banner.has-analytics-aside .result-banner-madness-aside {
  display: flex;
  flex-direction: column;
  gap: 34px;
  min-width: 0;
  padding: 108px 0 0;
  max-height: calc(100vh - 40px);
  overflow: auto;
  scrollbar-width: none;
  -ms-overflow-style: none;
}

.result-banner.is-madness-layout .result-banner-madness-aside::-webkit-scrollbar,
.result-banner.has-analytics-aside .result-banner-madness-aside::-webkit-scrollbar {
  display: none;
}

.game-popup-overlay {
  --game-popup-safe-top: calc(env(safe-area-inset-top, 0px) + 20px);
  --game-popup-safe-right: calc(env(safe-area-inset-right, 0px) + 20px);
  --game-popup-safe-bottom: calc(env(safe-area-inset-bottom, 0px) + 20px);
  --game-popup-safe-left: calc(env(safe-area-inset-left, 0px) + 20px);
  --game-popup-card-max-width: calc(100dvw - var(--game-popup-safe-left) - var(--game-popup-safe-right));
  --game-popup-card-max-height: calc(100dvh - var(--game-popup-safe-top) - var(--game-popup-safe-bottom));
  padding: var(--game-popup-safe-top) var(--game-popup-safe-right) var(--game-popup-safe-bottom) var(--game-popup-safe-left);
  background: rgba(29, 29, 32, 0.5);
  backdrop-filter: blur(14px);
  -webkit-backdrop-filter: blur(14px);
}

.game-popup-card {
  width: min(390px, calc(100vw - 48px));
  max-width: var(--game-popup-card-max-width);
  max-height: var(--game-popup-card-max-height);
  min-height: 420px;
  border-radius: 28px;
  background: #000;
  box-shadow: 0 18px 60px rgba(0, 0, 0, 0.45);
  overflow: auto;
  overscroll-behavior: contain;
  -webkit-overflow-scrolling: touch;
  scrollbar-width: none;
  -ms-overflow-style: none;
}

.game-popup-card::-webkit-scrollbar {
  width: 0;
  height: 0;
  display: none;
}

.game-popup-card-compact {
  min-height: auto;
  width: min(390px, calc(100vw - 48px));
  max-width: min(390px, var(--game-popup-card-max-width));
}

.game-popup-card-wide {
  width: min(980px, calc(100vw - 80px));
  max-width: min(980px, var(--game-popup-card-max-width));
  min-height: auto;
}


.settings-popup {
  position: fixed;
  inset: 0;
  z-index: 21;
  display: grid;
  place-items: center;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.2s ease;
}

.settings-popup.is-visible {
  opacity: 1;
  pointer-events: auto;
}

.game-knowledge-popup,
.new-enemy-popup {
  position: fixed;
  inset: 0;
  z-index: 21;
  display: grid;
  place-items: center;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.2s ease;
}

.game-knowledge-popup.is-visible,
.new-enemy-popup.is-visible {
  opacity: 1;
  pointer-events: auto;
}

.game-knowledge-popup-card,
.new-enemy-popup-card {
  position: relative;
}

.game-knowledge-popup-card {
  height: min(760px, var(--game-popup-card-max-height));
  min-height: 0;
  padding: 28px 32px 26px;
  display: flex;
  flex-direction: column;
  overflow: hidden;
}

.knowledge-popup-shell {
  width: 100%;
  height: 100%;
  min-height: 0;
  max-height: none;
}

.knowledge-popup-head {
  padding-right: 68px;
}

.knowledge-popup-browser {
  grid-template-columns: minmax(0, 1fr) 320px;
  height: 100%;
  max-height: 100%;
  min-height: 0;
  overflow: hidden;
}

.knowledge-popup-grid {
  height: 100%;
  max-height: 100%;
  min-height: 0;
  padding-bottom: 18px;
}

.knowledge-popup-detail {
  height: 100%;
  min-height: 0;
  max-height: 100%;
  overflow: auto;
  overscroll-behavior: contain;
  -webkit-overflow-scrolling: touch;
}

.knowledge-popup-close {
  position: absolute;
  top: 20px;
  right: 20px;
  z-index: 2;
  width: 64px;
  min-width: 64px;
  max-width: 64px;
  height: 64px;
  min-height: 64px;
  padding: 0;
}

.knowledge-popup-close::before {
  opacity: 0;
}

.knowledge-popup-close-icon {
  width: 26px;
  height: 26px;
  display: block;
  margin: 0 auto;
  background-repeat: no-repeat;
  background-position: center;
  background-size: contain;
}

.settings-popup-layout {
  position: relative;
  display: grid;
  grid-template-columns: minmax(0, 1fr);
  align-items: center;
  justify-content: center;
  gap: 0;
  width: min(420px, calc(100vw - 48px));
}

.settings-popup-layout:has(.madness-upgrade-pause-copy.is-visible),
.settings-popup-layout.has-madness-upgrades {
  grid-template-columns: 390px minmax(0, 1fr);
  align-items: start;
  column-gap: 36px;
  width: min(1480px, calc(100vw - 40px));
}

.settings-popup-actions {
  width: min(312px, 86vw);
  padding: 118px 0 36px;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 18px;
}

.settings-popup-panel {
  width: min(390px, 88vw);
  min-height: 420px;
  display: flex;
  align-items: stretch;
  justify-content: center;
}

.settings-popup-layout:has(.madness-upgrade-pause-copy.is-visible) .settings-popup-panel,
.settings-popup-layout.has-madness-upgrades .settings-popup-panel {
  grid-column: 1;
}

.settings-popup .primary-action-button {
  align-self: center;
  width: 312px;
  min-width: 312px;
}

.settings-popup-secondary {
  width: 234px;
  min-width: 234px;
  max-width: 234px;
}

.settings-volume-control {
  --settings-volume-ratio: 1;
  --settings-volume-percent: 100%;
  width: 234px;
  min-width: 234px;
  max-width: 234px;
  min-height: 58px;
  padding: 0 14px 0 7px;
  display: grid;
  grid-template-columns: 54px minmax(0, 1fr);
  align-items: center;
  gap: 12px;
  color: #f8fafc;
}

.settings-volume-toggle {
  --secondary-active-gradient: linear-gradient(135deg, #151a21 0%, #151a21 100%);
  width: 54px;
  min-width: 54px;
  max-width: 54px;
  height: 54px;
  min-height: 54px;
  padding: 0;
  border-radius: calc(16px * var(--ui-scale));
  font-size: 26px;
}

.settings-volume-toggle::before {
  opacity: 1;
  padding: calc(3px * var(--ui-scale));
}

.settings-volume-toggle.is-muted {
  filter: saturate(0.78);
}

.settings-volume-icon {
  display: block;
  line-height: 1;
  transform: translateY(-1px);
}

.settings-volume-slider {
  --settings-volume-track-height: 13px;
  --settings-volume-thumb-size: 28px;
  width: 100%;
  min-width: 0;
  height: var(--settings-volume-thumb-size);
  margin: 0;
  appearance: none;
  -webkit-appearance: none;
  border: 0;
  outline: none;
  background: transparent;
  cursor: pointer;
  touch-action: pan-y;
}

.settings-volume-slider::-webkit-slider-runnable-track {
  height: var(--settings-volume-track-height);
  border-radius: 999px;
  border: 1px solid rgba(176, 111, 255, 0.26);
  background:
    linear-gradient(90deg,
      #f0abfc 0%,
      #8d44ff var(--settings-volume-percent),
      rgba(15, 23, 42, 0.82) var(--settings-volume-percent),
      rgba(15, 23, 42, 0.82) 100%);
  box-shadow:
    inset 0 1px 5px rgba(0, 0, 0, 0.45),
    0 0 16px rgba(168, 85, 247, 0.28);
}

.settings-volume-slider::-moz-range-track {
  height: var(--settings-volume-track-height);
  border-radius: 999px;
  border: 1px solid rgba(176, 111, 255, 0.26);
  background: rgba(15, 23, 42, 0.82);
  box-shadow: inset 0 1px 5px rgba(0, 0, 0, 0.45);
}

.settings-volume-slider::-moz-range-progress {
  height: var(--settings-volume-track-height);
  border-radius: 999px;
  background: linear-gradient(90deg, #f0abfc 0%, #8d44ff 100%);
  box-shadow: 0 0 14px rgba(168, 85, 247, 0.34);
}

.settings-volume-slider::-webkit-slider-thumb {
  width: var(--settings-volume-thumb-size);
  height: var(--settings-volume-thumb-size);
  margin-top: calc((var(--settings-volume-track-height) - var(--settings-volume-thumb-size)) * 0.5);
  appearance: none;
  -webkit-appearance: none;
  border: 2px solid rgba(255, 255, 255, 0.72);
  border-radius: 50%;
  background:
    radial-gradient(circle at 35% 30%, rgba(255, 255, 255, 0.95) 0 18%, rgba(255, 255, 255, 0) 34%),
    linear-gradient(180deg, #fef3c7 0%, #f59e0b 100%);
  box-shadow:
    0 5px 12px rgba(0, 0, 0, 0.42),
    0 0 14px rgba(251, 191, 36, 0.35),
    inset 0 -2px 2px rgba(120, 53, 15, 0.38);
}

.settings-volume-slider::-moz-range-thumb {
  width: var(--settings-volume-thumb-size);
  height: var(--settings-volume-thumb-size);
  border: 2px solid rgba(255, 255, 255, 0.72);
  border-radius: 50%;
  background:
    radial-gradient(circle at 35% 30%, rgba(255, 255, 255, 0.95) 0 18%, rgba(255, 255, 255, 0) 34%),
    linear-gradient(180deg, #fef3c7 0%, #f59e0b 100%);
  box-shadow:
    0 5px 12px rgba(0, 0, 0, 0.42),
    0 0 14px rgba(251, 191, 36, 0.35),
    inset 0 -2px 2px rgba(120, 53, 15, 0.38);
}

.settings-popup-hero {
  position: absolute;
  top: -152px;
  left: 50%;
  transform: translateX(-50%);
  width: min(392px, 84vw);
  height: 234px;
  pointer-events: none;
  z-index: 1;
}

.settings-popup-layout:has(.madness-upgrade-pause-copy.is-visible) .settings-popup-hero,
.settings-popup-layout.has-madness-upgrades .settings-popup-hero {
  left: 195px;
}

.settings-popup-orbit {
  display: none;
}

.settings-popup-orb {
  --orb-color: #ff8a00;
  position: absolute;
  left: 50%;
  top: 88px;
  width: 54px;
  height: 54px;
  margin-left: -27px;
  border-radius: 18px;
  transform:
    rotate(45deg)
    translateY(calc(-1 * var(--orbit-radius, 88px)))
    rotate(calc(-1 * var(--orbit-angle, 0deg)));
  background:
    radial-gradient(circle at 32% 28%, rgba(255, 255, 255, 0.9) 0 20%, rgba(255, 255, 255, 0) 40%),
    linear-gradient(135deg, color-mix(in srgb, var(--orb-color) 88%, white 12%) 0%, var(--orb-color) 100%);
  box-shadow:
    0 8px 16px color-mix(in srgb, var(--orb-color) 32%, transparent 68%),
    0 0 22px color-mix(in srgb, var(--orb-color) 48%, transparent 52%);
  animation: settings-popup-orb-float 2.8s ease-in-out infinite;
  animation-delay: var(--orbit-delay, 0s);
}

.settings-popup-orb[data-type="fire"] { --orb-color: #ff6b2b; }
.settings-popup-orb[data-type="ice"] { --orb-color: #79bfff; }
.settings-popup-orb[data-type="lightning"] { --orb-color: #ffd84d; }
.settings-popup-orb[data-type="metal"] { --orb-color: #c9c6ff; }
.settings-popup-orb[data-type="earth"] { --orb-color: #d7904c; }

.settings-popup-orb-icon {
  position: absolute;
  inset: 10px;
  background-repeat: no-repeat;
  background-position: center;
  background-size: contain;
  image-rendering: pixelated;
  transform: rotate(-45deg);
}

.settings-popup-mascot-cloud {
  position: absolute;
  left: 50%;
  bottom: 6px;
  width: 252px;
  height: 78px;
  transform: translateX(-50%);
  border-radius: 999px;
  background:
    radial-gradient(circle at 20% 55%, rgba(255, 255, 255, 0.96) 0 18%, transparent 19%),
    radial-gradient(circle at 34% 42%, rgba(255, 255, 255, 0.98) 0 22%, transparent 23%),
    radial-gradient(circle at 50% 52%, rgba(255, 255, 255, 0.98) 0 24%, transparent 25%),
    radial-gradient(circle at 66% 40%, rgba(255, 255, 255, 0.98) 0 20%, transparent 21%),
    radial-gradient(circle at 80% 54%, rgba(255, 255, 255, 0.95) 0 18%, transparent 19%),
    linear-gradient(180deg, rgba(255, 255, 255, 0.96), rgba(213, 234, 255, 0.92));
  filter: drop-shadow(0 12px 24px rgba(0, 0, 0, 0.18));
}

.settings-popup-mascot {
  position: absolute;
  left: 50%;
  bottom: 20px;
  width: 260px;
  height: 218px;
  transform: translateX(-50%);
  filter: drop-shadow(0 14px 26px rgba(0, 0, 0, 0.28));
}

.settings-popup-mascot-sprite {
  position: absolute;
  left: 50%;
  bottom: 0;
  width: var(--settings-popup-mascot-frame-w, 333px);
  height: var(--settings-popup-mascot-frame-h, 279px);
  margin-left: calc(var(--settings-popup-mascot-frame-w, 333px) * -0.5);
  background-repeat: no-repeat;
  background-position:
    var(--settings-popup-mascot-frame-x, 0px)
    var(--settings-popup-mascot-frame-y, 0px);
  background-size:
    var(--settings-popup-mascot-atlas-w, auto)
    var(--settings-popup-mascot-atlas-h, auto);
  transform: translateZ(0) scale(0.78);
  transform-origin: 50% 100%;
  image-rendering: pixelated;
  opacity: 0;
}

.settings-popup-mascot-sprite.is-ready {
  opacity: 1;
}

#settingsPopup #madnessPauseUpgradeBlock {
  display: none;
}

#settingsPopup #madnessPauseUpgradeBlock.is-visible {
  display: grid;
  grid-column: 2;
  justify-self: stretch;
  align-self: stretch;
  width: 100%;
  max-height: calc(100vh - 40px);
  overflow: auto;
  padding: 118px 0 0;
  scrollbar-width: none;
  -ms-overflow-style: none;
}

#settingsPopup #madnessPauseUpgradeBlock.is-visible::-webkit-scrollbar {
  display: none;
}

@keyframes settings-popup-orb-float {
  0%,
  100% {
    top: 88px;
  }

  50% {
    top: 80px;
  }
}

@media (max-width: 1100px) {
  .settings-popup-layout {
    width: min(420px, calc(100vw - 32px));
  }

  .settings-popup-layout:has(.madness-upgrade-pause-copy.is-visible),
  .settings-popup-layout.has-madness-upgrades {
    grid-template-columns: minmax(248px, 280px) minmax(0, 1fr);
    width: min(1180px, calc(100vw - 32px));
    column-gap: 24px;
    row-gap: 0;
    align-items: center;
  }

  .settings-popup-layout:has(.madness-upgrade-pause-copy.is-visible) .settings-popup-hero,
  .settings-popup-layout.has-madness-upgrades .settings-popup-hero {
    left: 140px;
  }

  .settings-popup-layout:has(.madness-upgrade-pause-copy.is-visible) .settings-popup-panel,
  .settings-popup-layout.has-madness-upgrades .settings-popup-panel {
    width: min(280px, 32vw);
    min-height: 360px;
  }

  .settings-popup-layout:has(.madness-upgrade-pause-copy.is-visible) .settings-popup-actions,
  .settings-popup-layout.has-madness-upgrades .settings-popup-actions {
    width: min(248px, 100%);
    padding-top: 104px;
  }

  .settings-popup-layout:has(.madness-upgrade-pause-copy.is-visible) .primary-action-button,
  .settings-popup-layout.has-madness-upgrades .primary-action-button {
    width: min(248px, 100%);
    min-width: min(248px, 100%);
    max-width: min(248px, 100%);
  }

  .settings-popup-layout:has(.madness-upgrade-pause-copy.is-visible) .settings-popup-secondary,
  .settings-popup-layout:has(.madness-upgrade-pause-copy.is-visible) .settings-volume-control,
  .settings-popup-layout.has-madness-upgrades .settings-popup-secondary,
  .settings-popup-layout.has-madness-upgrades .settings-volume-control {
    width: min(186px, 78%);
    min-width: min(186px, 78%);
    max-width: min(186px, 78%);
  }

  #settingsPopup #madnessPauseUpgradeBlock.is-visible {
    grid-column: 2;
    width: 100%;
    max-height: calc(100vh - 32px);
    padding-top: 104px;
  }
}

@media (max-width: 760px) {
  .settings-popup-layout:has(.madness-upgrade-pause-copy.is-visible),
  .settings-popup-layout.has-madness-upgrades {
    grid-template-columns: minmax(0, 1fr);
    width: min(420px, calc(100vw - 32px));
    row-gap: 28px;
  }

  .settings-popup-layout:has(.madness-upgrade-pause-copy.is-visible) .settings-popup-hero,
  .settings-popup-layout.has-madness-upgrades .settings-popup-hero {
    left: 50%;
  }

  .settings-popup-layout:has(.madness-upgrade-pause-copy.is-visible) .settings-popup-panel,
  .settings-popup-layout.has-madness-upgrades .settings-popup-panel {
    width: min(390px, 88vw);
    min-height: 420px;
  }

  .settings-popup-layout:has(.madness-upgrade-pause-copy.is-visible) .settings-popup-actions,
  .settings-popup-layout.has-madness-upgrades .settings-popup-actions {
    width: min(312px, 86vw);
    padding-top: 118px;
  }

  .settings-popup-layout:has(.madness-upgrade-pause-copy.is-visible) .primary-action-button,
  .settings-popup-layout.has-madness-upgrades .primary-action-button {
    width: 312px;
    min-width: 312px;
    max-width: 312px;
  }

  .settings-popup-layout:has(.madness-upgrade-pause-copy.is-visible) .settings-popup-secondary,
  .settings-popup-layout:has(.madness-upgrade-pause-copy.is-visible) .settings-volume-control,
  .settings-popup-layout.has-madness-upgrades .settings-popup-secondary,
  .settings-popup-layout.has-madness-upgrades .settings-volume-control {
    width: 234px;
    min-width: 234px;
    max-width: 234px;
  }

  #settingsPopup #madnessPauseUpgradeBlock.is-visible {
    grid-column: 1;
    width: min(92vw, 760px);
    max-height: none;
    padding-top: 0;
  }
}

.result-banner-actions {
  order: 4;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 18px;
  margin-top: auto;
}

.result-banner-secondary-actions {
  display: flex;
  justify-content: center;
  flex-wrap: wrap;
  gap: 12px;
  width: 100%;
}

.result-banner-secondary-actions.is-hidden {
  display: none;
}

.result-banner .settings-popup-secondary {
  width: 234px;
  min-width: 234px;
  max-width: 234px;
}

@media (max-width: 900px), (pointer: coarse) {
  .game-popup-overlay {
    --game-popup-safe-top: calc(env(safe-area-inset-top, 0px) + 10px);
    --game-popup-safe-right: calc(env(safe-area-inset-right, 0px) + 10px);
    --game-popup-safe-bottom: calc(env(safe-area-inset-bottom, 0px) + 10px);
    --game-popup-safe-left: calc(env(safe-area-inset-left, 0px) + 10px);
    backdrop-filter: blur(10px);
    -webkit-backdrop-filter: blur(10px);
  }

  .game-popup-card {
    border-radius: 18px;
  }

  .game-popup-card-wide {
    width: var(--game-popup-card-max-width);
  }

  .game-knowledge-popup-card {
    width: min(620px, var(--game-popup-card-max-width));
    padding: 12px;
  }

  .new-enemy-popup-card {
    width: min(300px, var(--game-popup-card-max-width));
    padding: 14px;
  }

  .knowledge-popup-shell {
    max-height: none;
  }

  .knowledge-popup-head {
    padding-right: 42px;
  }

  .knowledge-popup-browser {
    grid-template-columns: minmax(0, 1fr) minmax(188px, 240px);
    gap: 10px;
  }

  .knowledge-popup-grid {
    max-height: min(50dvh, 360px);
  }

  .knowledge-popup-close {
    top: 8px;
    right: 8px;
    width: 34px;
    min-width: 34px;
    max-width: 34px;
    height: 34px;
    min-height: 34px;
  }

  .pregame-upgrade-panel {
    padding:
      calc(env(safe-area-inset-top, 0px) + 56px)
      calc(env(safe-area-inset-right, 0px) + 10px)
      calc(env(safe-area-inset-bottom, 0px) + 74px)
      calc(env(safe-area-inset-left, 0px) + 10px);
  }

  .pregame-upgrade-card {
    width: min(
      100%,
      calc(100vw - env(safe-area-inset-left, 0px) - env(safe-area-inset-right, 0px) - 20px)
    );
    max-height: calc(
      100dvh - env(safe-area-inset-top, 0px) - env(safe-area-inset-bottom, 0px) - 10px
    );
    gap: 8px;
  }

  .pregame-knowledge-panel .pregame-upgrade-card {
    gap: 14px;
  }

  .pregame-upgrade-head {
    gap: 8px;
  }

  .pregame-upgrade-head-icon {
    width: 38px;
    height: 38px;
    min-width: 38px;
    min-height: 38px;
  }

  .pregame-upgrade-title {
    font-size: clamp(22px, 3.6vw, 28px);
  }

  .pregame-upgrade-stars {
    font-size: clamp(14px, 2.4vw, 18px);
  }

  .pregame-upgrade-browser {
    grid-template-columns: minmax(0, 1fr) minmax(188px, 240px);
    gap: 10px;
  }

  .pregame-upgrade-grid {
    max-height: min(58vh, 400px);
    gap: 10px;
    padding-bottom: 14px;
  }

  .pregame-upgrade-section {
    grid-template-columns: 92px minmax(0, 1fr);
    gap: 8px;
  }

  .pregame-upgrade-section-title {
    padding-top: 7px;
    font-size: 14px;
  }

  .pregame-upgrade-section-grid {
    grid-template-columns: repeat(auto-fill, minmax(56px, 56px));
    gap: 8px;
  }

  .pregame-upgrade-tile {
    width: 56px;
    height: 56px;
  }

  .pregame-upgrade-tile-frame {
    inset: -4px;
  }

  .pregame-upgrade-detail {
    gap: 8px;
    padding: 0 0 8px;
  }

  .pregame-upgrade-detail-title {
    font-size: clamp(16px, 2.6vw, 20px);
  }

  .pregame-upgrade-detail-level {
    min-width: 48px;
    padding: 5px 8px;
    font-size: 11px;
  }

  .pregame-upgrade-detail-preview {
    width: 96px;
    height: 96px;
  }

  .pregame-upgrade-detail-preview .pregame-knowledge-preview-canvas {
    width: 96px;
    height: 96px;
  }

  .pregame-upgrade-detail-description,
  .pregame-upgrade-detail-description.is-locked {
    font-size: 13px;
    line-height: 1.32;
  }

  .pregame-knowledge-detail-stats .stat-row {
    gap: 8px;
    font-size: 12px;
  }

  .pregame-upgrade-detail-button {
    min-width: 132px;
    min-height: 38px;
    gap: 8px;
    padding: 0 12px;
    border-radius: 12px;
    font-size: 13px;
  }

  .pregame-upgrade-detail-button.is-available {
    box-shadow:
      -1px -2px 1px 0 rgba(120, 53, 15, 0.55) inset,
      1px -3px 2px 0 rgba(254, 202, 22, 0.62) inset,
      0 2px 2px 0 rgba(255, 255, 255, 0.58) inset,
      0 5px 12px rgba(0, 0, 0, 0.18);
    text-shadow: 0 1px 1px rgba(0, 0, 0, 0.22);
  }

  .pregame-upgrade-detail-button-cost-icon {
    width: 15px;
    height: 15px;
    min-width: 15px;
    min-height: 15px;
    font-size: 15px;
  }

  .result-banner-card {
    width: min(312px, calc(100vw - 24px));
    min-height: 0;
    padding: 8px;
  }

  .result-banner-summary-panel {
    min-height: 0;
    padding: 16px 14px 14px;
    border-radius: 18px;
    gap: 8px;
  }

  .result-banner-title {
    font-size: clamp(20px, 4.2vw, 28px);
  }

  .result-banner-subhead,
  .result-banner-hint {
    font-size: 13px;
    line-height: 1.25;
  }

  .result-banner-metrics {
    gap: 6px;
  }

  .result-banner-metric-chip {
    min-width: 76px;
    min-height: 32px;
    padding: 0 9px;
    gap: 6px;
  }

  .result-banner-metric-icon {
    width: 18px;
    height: 18px;
    min-width: 18px;
    min-height: 18px;
  }

  .result-banner-metric-value {
    font-size: clamp(17px, 3.2vw, 22px);
  }

  .result-banner-rewards {
    min-height: 46px;
    margin-top: -4px;
    gap: 0;
  }

  .result-banner-stars.is-victory-stars {
    min-height: 0;
  }

  .result-banner-dust-reward {
    min-width: 172px;
    min-height: 34px;
    margin-top: -3px;
    padding: 0 6px 2px;
    gap: 7px;
  }

  .result-banner-dust-gold-icon,
  .result-banner-dust-reward-icon {
    width: 30px;
    height: 30px;
    min-width: 30px;
    min-height: 30px;
  }

  .result-banner-dust-arrow {
    font-size: 20px;
  }

  .result-banner-dust-gold-value,
  .result-banner-dust-reward-value {
    font-size: clamp(18px, 3.4vw, 24px);
  }

  .result-banner-dust-trail {
    inset: -24px 0 -22px;
  }

  .result-banner-dust-coin-icon {
    width: 18px;
    height: 18px;
    min-width: 18px;
    min-height: 18px;
  }


  .result-banner-star {
    width: 38px;
    height: 38px;
    min-width: 38px;
    min-height: 38px;
  }

  .result-banner-star.is-center {
    width: 56px;
    height: 56px;
    min-width: 56px;
    min-height: 56px;
  }

  .result-banner-actions {
    gap: 8px;
  }

  .result-banner-button.primary-action-button {
    width: min(196px, 100%);
    min-width: min(196px, 100%);
    max-width: min(196px, 100%);
    height: 52px;
    min-height: 52px;
    padding: 0 14px;
    font-size: 22px;
  }

  .result-banner .settings-popup-secondary {
    width: min(150px, 100%);
    min-width: min(150px, 100%);
    max-width: min(150px, 100%);
    height: 40px;
    min-height: 40px;
    font-size: 14px;
  }

  .settings-popup-layout {
    width: min(300px, calc(100vw - 24px));
  }

  .settings-popup-panel {
    width: min(300px, calc(100vw - 24px));
    min-height: 0;
  }

  .settings-popup-actions {
    width: min(196px, 74vw);
    padding: 52px 0 14px;
    gap: 8px;
  }

  .settings-popup .primary-action-button {
    width: min(196px, 74vw);
    min-width: min(196px, 74vw);
    max-width: min(196px, 74vw);
    height: 52px;
    min-height: 52px;
    font-size: 22px;
  }

  .settings-popup-secondary {
    width: min(150px, 64vw);
    min-width: min(150px, 64vw);
    max-width: min(150px, 64vw);
    height: 40px;
    min-height: 40px;
    font-size: 14px;
  }

  .settings-volume-control {
    width: min(150px, 64vw);
    min-width: min(150px, 64vw);
    max-width: min(150px, 64vw);
    min-height: 40px;
    grid-template-columns: 34px minmax(0, 1fr);
    gap: 8px;
    padding: 0 9px 0 4px;
    border-radius: 14px;
  }

  .settings-volume-toggle {
    width: 34px;
    min-width: 34px;
    max-width: 34px;
    height: 34px;
    min-height: 34px;
    font-size: 19px;
  }

  .settings-volume-slider {
    --settings-volume-track-height: 9px;
    --settings-volume-thumb-size: 20px;
  }

  .settings-popup-hero {
    top: -58px;
    width: min(180px, 56vw);
    height: 104px;
  }

  .settings-popup-mascot {
    width: 120px;
    height: 100px;
    bottom: 6px;
  }

  .settings-popup-mascot-sprite {
    transform: translateZ(0) scale(0.36);
  }

  .settings-popup-mascot-cloud {
    width: 116px;
    height: 34px;
  }

  .reward-popup-card {
    width: min(260px, calc(100vw - 24px));
    min-width: 0;
    padding: 14px 16px 16px;
    border-radius: 18px;
  }

  .reward-popup-icon {
    width: 56px;
    height: 56px;
    font-size: 56px;
    margin-bottom: 6px;
  }

  .reward-popup-icon.is-chest-open {
    width: 76px;
    height: 64px;
  }

  .reward-popup-title {
    font-size: clamp(18px, 4vw, 22px);
  }

  .reward-popup-text {
    margin: 4px 0 10px;
    font-size: 12px;
    line-height: 1.3;
  }
}

@media (max-width: 760px), (max-height: 520px) and (pointer: coarse) {
  .pregame-upgrade-panel {
    padding:
      calc(env(safe-area-inset-top, 0px) + 50px)
      calc(env(safe-area-inset-right, 0px) + 10px)
      calc(env(safe-area-inset-bottom, 0px) + 68px)
      calc(env(safe-area-inset-left, 0px) + 10px);
  }

  .pregame-upgrade-card {
    gap: 8px;
    max-height: calc(
      100dvh - env(safe-area-inset-top, 0px) - env(safe-area-inset-bottom, 0px) - 8px
    );
  }

  .pregame-upgrade-head {
    gap: 8px;
  }

  .pregame-upgrade-head-icon {
    width: 34px;
    height: 34px;
    min-width: 34px;
    min-height: 34px;
  }

  .pregame-upgrade-title {
    font-size: clamp(20px, 3.2vw, 24px);
  }

  .pregame-upgrade-stars {
    font-size: clamp(13px, 2vw, 16px);
  }

  .pregame-upgrade-browser {
    grid-template-columns: minmax(0, 1fr);
  }

  .knowledge-popup-browser {
    grid-template-columns: minmax(0, 1fr);
  }

  .pregame-upgrade-browser,
  .knowledge-popup-browser {
    gap: 12px;
    overflow: auto;
    overscroll-behavior: contain;
    -webkit-overflow-scrolling: touch;
  }

  .pregame-upgrade-sections,
  .pregame-upgrade-grid {
    max-height: min(42dvh, 260px);
    padding-bottom: 14px;
  }

  .pregame-upgrade-section {
    grid-template-columns: minmax(0, 1fr);
    gap: 8px;
  }

  .pregame-upgrade-section-title {
    padding-top: 0;
    font-size: 13px;
  }

  .pregame-upgrade-section-grid {
    grid-template-columns: repeat(auto-fill, minmax(52px, 52px));
    gap: 8px;
  }

  .pregame-upgrade-tile {
    width: 52px;
    height: 52px;
  }

  .pregame-upgrade-detail {
    min-height: 0;
    max-height: min(26dvh, 104px);
    gap: 8px;
    overflow: auto;
    overscroll-behavior: contain;
    -webkit-overflow-scrolling: touch;
    scrollbar-width: none;
    -ms-overflow-style: none;
  }

  .pregame-upgrade-detail::-webkit-scrollbar {
    width: 0;
    height: 0;
    display: none;
  }

  .pregame-upgrade-detail-preview,
  .new-enemy-popup-detail .pregame-upgrade-detail-preview {
    width: 88px;
    height: 88px;
  }

  .pregame-upgrade-detail-preview .pregame-knowledge-preview-canvas,
  .new-enemy-popup-detail .pregame-upgrade-detail-preview .pregame-knowledge-preview-canvas {
    width: 88px;
    height: 88px;
  }

  .pregame-upgrade-detail-description,
  .pregame-upgrade-detail-description.is-locked,
  .pregame-knowledge-detail-stats {
    font-size: 14px;
    line-height: 1.32;
  }

  .game-knowledge-popup-card {
    width: min(620px, var(--game-popup-card-max-width));
    padding: 12px;
  }

  .new-enemy-popup-card {
    width: min(300px, var(--game-popup-card-max-width));
    padding: 12px;
  }

  .knowledge-popup-head {
    padding-right: 38px;
  }

  .knowledge-popup-grid {
    max-height: min(34dvh, 220px);
  }

  .knowledge-popup-close {
    top: 8px;
    right: 8px;
    width: 32px;
    min-width: 32px;
    max-width: 32px;
    height: 32px;
    min-height: 32px;
  }

  .settings-popup-layout {
    width: min(280px, var(--game-popup-card-max-width));
  }

  .settings-popup-panel {
    width: min(280px, var(--game-popup-card-max-width));
  }

  .settings-popup-actions {
    width: min(184px, 74vw);
    padding: 48px 0 12px;
    gap: 7px;
  }

  .settings-popup .primary-action-button {
    width: min(184px, 74vw);
    min-width: min(184px, 74vw);
    max-width: min(184px, 74vw);
    height: 48px;
    min-height: 48px;
    font-size: 20px;
  }

  .settings-popup-secondary {
    width: min(142px, 64vw);
    min-width: min(142px, 64vw);
    max-width: min(142px, 64vw);
    height: 38px;
    min-height: 38px;
    font-size: 13px;
  }

  .settings-popup-hero {
    top: -52px;
    width: min(166px, 54vw);
    height: 96px;
  }

  .settings-popup-mascot {
    width: 110px;
    height: 92px;
    bottom: 6px;
  }

  .settings-popup-mascot-sprite {
    transform: translateZ(0) scale(0.34);
  }

  .settings-popup-mascot-cloud {
    width: 108px;
    height: 32px;
  }

  .tutorial-popup-card {
    width: min(520px, var(--game-popup-card-max-width));
    padding: 20px 22px 22px;
  }

  .tutorial-popup-title {
    font-size: 24px;
  }

  .tutorial-popup-image {
    width: 58px;
    height: 58px;
    font-size: 44px;
  }

  .tutorial-popup.is-first-crystal-combine .tutorial-popup-image {
    width: 96px;
    height: 96px;
    font-size: 54px;
  }

  .tutorial-popup-image-value {
    min-width: 40px;
    font-size: 18px;
  }

  .tutorial-popup-text,
  .tutorial-popup.is-first-crystal-combine .tutorial-popup-text {
    margin-bottom: 8px;
    font-size: 12px;
    line-height: 1.3;
  }

  .tutorial-popup-visual {
    margin-bottom: 8px;
  }

  .tutorial-popup-limit-icon {
    width: 52px;
    height: 52px;
    font-size: 52px;
  }

  .reward-popup-icon {
    width: 56px;
    height: 56px;
    font-size: 56px;
  }

  .reward-popup-icon.is-chest-open {
    width: 76px;
    height: 64px;
  }
}

@media (min-width: 761px) and (max-height: 520px) and (pointer: coarse) {
  .pregame-upgrade-browser,
  .knowledge-popup-browser {
    grid-template-columns: minmax(0, 1fr) minmax(180px, 224px);
    align-items: start;
  }

  .pregame-upgrade-sections,
  .pregame-upgrade-grid {
    max-height: min(52dvh, 200px);
  }

  .pregame-upgrade-detail {
    max-height: min(58dvh, 226px);
  }

  .knowledge-popup-grid {
    max-height: min(48dvh, 188px);
  }
}

.result-banner-button-icon {
  min-width: 56px;
  width: 56px;
  height: 56px;
  padding: 0;
  font-size: 26px;
  line-height: 1;
}

.result-banner-action-icon.is-hidden,
.secondary-action-button-inline-icon.is-hidden {
  display: none;
}

@media (max-width: 1180px) {
  .result-banner.is-madness-layout .result-banner-card,
  .result-banner.has-analytics-aside .result-banner-card {
    width: min(1240px, calc(100vw - 32px));
  }

  .result-banner.is-madness-layout .result-banner-main-layout,
  .result-banner.has-analytics-aside .result-banner-main-layout {
    grid-template-columns: minmax(280px, 340px) minmax(0, 1fr);
    gap: 24px;
  }

  .result-banner.is-madness-layout .result-banner-summary-panel {
    margin-top: 72px;
    padding: 34px 26px 26px;
  }

  .result-banner-madness-perk-cards {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }
}

@media (max-width: 900px) {
  .result-banner.is-madness-layout .result-banner-card,
  .result-banner.has-analytics-aside .result-banner-card {
    width: min(760px, calc(100vw - 28px));
    min-height: 0;
    padding: 18px;
  }

  .result-banner.is-madness-layout .result-banner-main-layout,
  .result-banner.has-analytics-aside .result-banner-main-layout {
    grid-template-columns: minmax(0, 1fr);
    gap: 22px;
  }

  .result-banner.is-madness-layout .result-banner-summary-panel,
  .result-banner.has-analytics-aside .result-banner-summary-panel {
    margin-top: 0;
  }

  .result-banner.is-madness-layout .result-banner-madness-aside,
  .result-banner.has-analytics-aside .result-banner-madness-aside {
    max-height: none;
    overflow: visible;
    padding-right: 0;
    padding-top: 0;
  }

  .result-banner-madness-perk-cards {
    grid-template-columns: 1fr;
  }

  .result-banner-upgrade-feed-list.is-progress {
    grid-template-columns: 1fr;
  }
}

.status {
  font-weight: 600;
}

.status-ok {
  color: #34d399;
}

.status-error {
  color: #f87171;
}

.load-message {
  color: #fbbf24;
  margin-bottom: 8px;
}

.error-list {
  list-style: none;
  margin-top: 4px;
  max-height: 180px;
  overflow-y: auto;
}

.error-list li {
  margin-bottom: 4px;
  color: #fca5a5;
}

#contextOverlay {
  position: fixed;
  inset: 0;
  z-index: 20;
  pointer-events: none;
}

.context-menu {
  --context-anchor-x: 0px;
  --context-anchor-y: 0px;
  --context-enter-offset: 12px;
  position: absolute;
  min-width: 320px;
  max-width: 380px;
  background: rgba(8, 14, 23, 0.96);
  border: none;
  border-radius: 20px;
  padding: 20px;
  box-shadow: 0 14px 32px rgba(0, 0, 0, 0.45);
  opacity: 0;
  visibility: hidden;
  pointer-events: none;
  transform: translateY(var(--context-enter-offset));
  transition: opacity 0.18s ease, transform 0.18s ease, visibility 0s linear 0.18s;
  overflow: visible;
}


.context-menu.is-visible {
  opacity: 1;
  visibility: visible;
  pointer-events: auto;
  transform: translateY(0);
  transition: opacity 0.18s ease, transform 0.18s ease, visibility 0s linear 0s;
}

.context-menu-header {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 12px;
}

.context-menu-title {
  font-size: 19px;
  font-weight: 700;
}

.context-sell-icon-button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 32px;
  height: 32px;
  border: 1px solid rgba(148, 163, 184, 0.35);
  border-radius: 8px;
  background: rgba(15, 23, 42, 0.85);
  color: #fca5a5;
  cursor: pointer;
}

.context-sell-icon-button:hover {
  border-color: rgba(248, 113, 113, 0.8);
  background: rgba(127, 29, 29, 0.28);
}

.context-sell-icon-button:disabled {
  opacity: 0.45;
  cursor: not-allowed;
}

.context-sell-icon {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 18px;
  height: 18px;
  font-size: 14px;
  line-height: 1;
}

.context-menu-subtitle {
  margin-top: 4px;
  font-size: 15px;
  color: #cbd5f5;
}

.context-menu-subtitle.has-role-chips {
  display: flex;
  flex-wrap: wrap;
  justify-content: flex-start;
  gap: 6px;
  min-height: 18px;
  text-align: left;
  width: 100%;
}

.context-menu-subtitle.has-role-chips .context-role-chip {
  font-size: 13px;
}

.context-menu-info {
  margin-top: 12px;
  font-size: 15px;
  color: #cbd5f5;
}

.context-menu-stats {
  margin-top: 12px;
  display: flex;
  flex-direction: column;
  gap: 9px;
  font-size: 15px;
}

.context-menu-stats .stat-row {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 12px;
}

.stat-bar-group {
  display: inline-flex;
  gap: 4px;
}

.stat-row-subtitle {
  margin-left: 8px;
  font-size: 11px;
  color: #cbd5f5;
}

.stat-bar {
  width: 8px;
  height: 22px;
  border-radius: 3px;
}

.stat-bar-danger {
  background: #ef4444;
}

.stat-bar-warning {
  background: #facc15;
}

.stat-bar-lime {
  background: #84cc16;
}

.stat-bar-orange {
  background: #f97316;
}

.stat-bar-good {
  background: #22c55e;
}

.stat-chip-group {
  display: inline-flex;
  flex-wrap: wrap;
  justify-content: flex-end;
  gap: 6px;
}

.stat-chip {
  border-radius: 999px;
  padding: 4px 10px;
  font-size: 13px;
  font-weight: 700;
  letter-spacing: 0.02em;
}

.stat-chip-danger {
  background: rgba(239, 68, 68, 0.18);
  color: #fecaca;
}

.stat-chip-warning {
  background: rgba(250, 204, 21, 0.18);
  color: #fef08a;
}

.stat-chip-cold {
  background: rgba(56, 189, 248, 0.2);
  color: #bae6fd;
}

.stat-chip-energy {
  background: rgba(167, 139, 250, 0.2);
  color: #ddd6fe;
}

.stat-chip-neutral {
  background: rgba(148, 163, 184, 0.22);
  color: #e2e8f0;
}

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

.context-menu:not(.is-build-radial) .context-build-card {
  position: relative;
  width: 100%;
  --context-build-card-height: auto;
  --context-build-inline-gap: 8px;
}

.context-menu:not(.is-build-radial) .context-build-confirm-button {
  position: relative;
  width: 100%;
}

.context-menu:not(.is-build-radial) .context-build-card.is-build-confirmed {
  height: var(--context-build-card-height);
}

.context-menu:not(.is-build-radial) .context-build-card.is-build-confirmed .context-build-confirm-button {
  width: calc(75% - (var(--context-build-inline-gap) * 0.75));
  min-height: var(--context-build-card-height);
  height: var(--context-build-card-height);
  border-top-right-radius: 6px;
  border-bottom-right-radius: 6px;
}

.context-menu:not(.is-build-radial) .context-build-cancel-button {
  position: absolute;
  top: 0;
  right: 0;
  display: none;
  width: calc(25% - (var(--context-build-inline-gap) * 0.25));
  min-height: var(--context-build-card-height);
  height: var(--context-build-card-height);
  padding: 0;
  border: none;
  background: #111820;
  color: #e6edf3;
  border-radius: 8px;
  cursor: pointer;
}

.context-menu:not(.is-build-radial) .context-build-card.is-build-confirmed .context-build-cancel-button {
  display: flex;
  align-items: center;
  justify-content: center;
}

.context-menu:not(.is-build-radial) .context-build-card.is-build-confirmed .context-button-label,
.context-menu:not(.is-build-radial) .context-build-card.is-build-confirmed .context-button-role-chips,
.context-menu:not(.is-build-radial) .context-build-card.is-build-confirmed .context-button-sub {
  visibility: hidden;
}

.context-menu:not(.is-build-radial) .context-build-action-icon {
  position: absolute;
  left: 50%;
  top: 50%;
  transform: translate(-50%, -50%);
  display: block;
  opacity: 0;
  pointer-events: none;
}

.context-menu:not(.is-build-radial) .context-build-action-icon.has-icon {
  background-repeat: no-repeat;
  background-position: center;
  background-size: contain;
}

.context-menu:not(.is-build-radial) .context-build-confirm-icon {
  width: 24px;
  height: 24px;
  font-size: 24px;
}

.context-menu:not(.is-build-radial) .context-build-cancel-icon {
  width: 18px;
  height: 18px;
  font-size: 18px;
}

.context-menu:not(.is-build-radial) .context-build-card.is-build-confirmed .context-build-confirm-icon,
.context-menu:not(.is-build-radial) .context-build-card.is-build-confirmed .context-build-cancel-icon {
  opacity: 1;
}

.context-button {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  width: 100%;
  border: none;
  background: #111820;
  color: #e6edf3;
  padding: 13px 15px;
  border-radius: 10px;
  cursor: pointer;
  min-height: 44px;
  text-align: left;
  font-family: var(--font-family-ui-base);
  font-size: var(--font-size-ui-body-strong);
  font-weight: var(--font-weight-ui-strong);
}

#contextUpgrade {
  min-height: 48px;
  font-size: 18px;
  padding: 14px 16px;

}

.context-button-label {
  display: inline-flex;
  align-items: center;
    gap: 10px;}


.context-button-label span{
  font-family: var(--font-family-ui-base);
  font-size: var(--font-size-ui-body-strong);
  font-weight: var(--font-weight-ui-strong);
}

.context-button-icon {
  width: 28px;
  height: 28px;
  border-radius: 6px;
  background: #1f2937;
  color: #0b1120;
  font-weight: 700;
  font-size: 12px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  box-shadow: inset 0 0 0 1px rgba(15, 23, 42, 0.35);
  background-size: contain;
  background-repeat: no-repeat;
  background-position: center;
}

.context-button-icon.has-icon {
  color: transparent;
  background-color: transparent;
  box-shadow: none;
}

.context-button:disabled {
  opacity: 0.5;
  cursor: not-allowed;
}

.context-button-sub {
  font-size: 14px;
  color: #cbd5f5;
  white-space: nowrap;
}

.context-button-sub.has-gold-icon {
  display: inline-flex;
  align-items: center;
  gap: 4px;
}

.context-button-cost-icon {
  flex: 0 0 auto;
  font-size: 1.14em;
}

.context-button-role-chips {
  display: none;
}

.context-menu.is-build-menu:not(.is-build-radial) .context-button-role-chips {
  display: none !important;
}

.context-role-chip {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 0;
  padding: 0;
  border-radius: 0;
  background: transparent;
  border: 0;
  color: #dbeafe;
  font-size: 11px;
  font-weight: 700;
  letter-spacing: 0.02em;
  white-space: nowrap;
}

.context-role-chip-role-anti-tank {
  color: #fde68a;
}

.context-role-chip-role-anti-fast {
  color: #bfdbfe;
}

.context-role-chip-role-anti-swarm {
  color: #fcd34d;
}

.context-role-chip-role-control {
  color: #bae6fd;
}

.context-role-chip-role-priority {
  color: #fca5a5;
}

.context-role-chip-role-sustain {
  color: #bbf7d0;
}

.context-menu-message {
  margin-top: 12px;
  font-size: 15px;
  color: #fbbf24;
}

.context-menu.is-build-radial {
  min-width: 0;
  max-width: none;
  width: 0;
  height: 0;
  padding: 0;
  border: 0;
  border-radius: 0;
  background: transparent;
  box-shadow: none;
}

.context-menu.is-build-radial .context-menu-header,
.context-menu.is-build-radial .context-menu-subtitle,
.context-menu.is-build-radial .context-menu-info,
.context-menu.is-build-radial .context-menu-stats,
.context-menu.is-build-radial .context-menu-message,
.context-menu.is-build-radial #contextUpgrade,
.context-menu.is-build-radial #contextSellIcon {
  display: none !important;
}

.context-menu.is-build-radial .context-menu-actions {
  margin-top: 0;
  position: fixed;
  inset: 0;
  pointer-events: none;
  overflow: visible;
}

.context-menu.is-build-radial.is-build-layouting .context-menu-actions {
  visibility: hidden;
}

.context-menu.is-build-radial .context-build-card {
  position: absolute;
  width: 144px;
  display: flex;
  flex-direction: column;
  --context-build-card-height: auto;
  --context-build-card-split-gap: 50px;
  gap: 8px;
  pointer-events: none;
}

.context-menu.is-build-radial .context-button {
  width: 144px;
  width: 144px;
  min-height: 132px;
  border-radius: 20px;
  border: none;
  background: rgba(3, 10, 20, 0.92);
  padding: 28px 12px 14px;
  flex-direction: column;
  align-items: center;
  justify-content: flex-start;
  gap: 5px;
  pointer-events: auto;
  transform: translateY(0);
  transition: transform 0.2s ease, box-shadow 0.2s ease;
}

.context-menu.is-build-radial .context-build-confirm-button {
  position: relative;
}

.context-menu.is-build-radial .context-build-card.is-build-confirmed {
  height: var(--context-build-card-height);
}

.context-menu.is-build-radial .context-build-card.is-build-confirmed .context-build-confirm-button {
  height: calc(var(--context-build-card-height) - var(--context-build-card-split-gap));
  min-height: calc(var(--context-build-card-height) - var(--context-build-card-split-gap));
  border-radius: 20px 20px 14px 14px;
}

.context-menu.is-build-radial .context-button-label,
.context-menu.is-build-radial .context-button-icon,
.context-menu.is-build-radial .context-button-role-chips,
.context-menu.is-build-radial .context-role-chip,
.context-menu.is-build-radial .context-button-sub {
  pointer-events: none;
}

.context-menu.is-build-radial .context-button:hover {
  transform: translateY(-3px);
  box-shadow: 0 14px 28px rgba(2, 6, 23, 0.55);
}

.context-menu.is-build-radial .context-button-label {
  flex-direction: column;
  gap: 4px;
  justify-content: center;
  width: 100%;
  min-width: 0;
}


.context-menu.is-build-radial .context-button-icon {
  position: relative;
  width: 78px;
  height: 78px;
  flex: 0 0 78px;
  aspect-ratio: 1 / 1;
  margin: -57px 0 2px;
  border-radius: 12px;
  background: radial-gradient(circle at 35% 30%, rgba(255, 255, 255, 0.28), rgba(255, 255, 255, 0.02) 55%), #101828;
  border: none;
  color: #e2e8f0;
  font-size: 22px;
  box-shadow: 0 12px 18px rgba(2, 6, 23, 0.45);
  background-size: contain;
  background-repeat: no-repeat;
  background-position: center;
}

.context-menu.is-build-radial .context-button-icon.has-icon {
  background-size: contain !important;
  background-position: center center;
}

.context-menu.is-build-radial .context-button-sub {
  box-sizing: border-box;
  justify-content: center;
  width: 100%;
  padding-inline: 6px;
  font-size: 15px;
  color: #f8fafc;
  display: inline-flex;
  align-items: center;
  gap: 4px;
  margin: 2px 0 0;
}

.context-menu.is-build-radial .context-button-role-chips {
  display: none;
  flex-wrap: wrap;
  justify-content: center;
  gap: 5px;
  width: 100%;
  min-height: 14px;
  margin: 0;
  overflow: hidden;
}

.context-menu.is-build-menu.is-build-radial .context-button-role-chips.has-role-chips {
  display: flex !important;
}

.context-menu.is-build-radial .context-role-chip {
  min-height: 0;
  padding: 0;
  font-family: var(--font-family-ui-base);
  font-size: 11px;
  font-weight: var(--font-weight-ui-strong);
  line-height: 1;
}

.context-menu.is-build-radial .context-button-sub::after {
  content: "";
}

.context-menu.is-build-radial .context-button:disabled {
  opacity: 0.38;
}

.context-menu.is-build-radial .context-build-cancel-button {
  display: none;
  position: relative;
  width: 144px;
  min-height: 42px;
  padding: 0 12px;
  border: none;
  border-radius: 16px;
  background: rgba(3, 10, 20, 0.92);
  color: #f8fafc;
  font-size: 30px;
  font-weight: 800;
  line-height: 1;
  align-items: center;
  justify-content: center;
  pointer-events: auto;
  transition: transform 0.2s ease, box-shadow 0.2s ease;
}

.context-menu.is-build-radial .context-build-cancel-button:hover {
  transform: translateY(-2px);
  box-shadow: 0 14px 28px rgba(2, 6, 23, 0.55);
}

.context-menu.is-build-radial .context-build-card.is-build-confirmed .context-button-label,
.context-menu.is-build-radial .context-build-card.is-build-confirmed .context-button-role-chips,
.context-menu.is-build-radial .context-build-card.is-build-confirmed .context-button-sub {
  visibility: hidden;
}

.context-menu.is-build-radial .context-build-action-icon {
  position: absolute;
  left: 50%;
  top: 50%;
  transform: translate(-50%, -50%);
  display: block;
  opacity: 0;
  pointer-events: none;
}

.context-menu.is-build-radial .context-build-action-icon.has-icon {
  background-repeat: no-repeat;
  background-position: center;
  background-size: contain;
}

.context-menu.is-build-radial .context-build-confirm-icon {
  width: 62px;
  height: 62px;
  font-size: 62px;
}

.context-menu.is-build-radial .context-build-cancel-icon {
  width: 34px;
  height: 34px;
  font-size: 34px;
}

.context-menu.is-build-radial .context-build-card.is-build-confirmed .context-build-confirm-icon,
.context-menu.is-build-radial .context-build-card.is-build-confirmed .context-build-cancel-icon {
  opacity: 1;
}

.combine-popover {
  position: absolute;
  min-width: 0;
  max-width: min(280px, calc(100dvw - 32px));
  background: rgba(15, 23, 32, 0.96);
  border: none;
  border-radius: 11px;
  padding: 10px 12px;
  box-shadow: 0 8px 24px rgba(0, 0, 0, 0.35);
  opacity: 0;
  visibility: hidden;
  pointer-events: none;
  transform: translateY(var(--context-enter-offset, 12px));
  transition: opacity 0.18s ease, transform 0.18s ease, visibility 0s linear 0.18s;
  z-index: 30;
}

.combine-popover.is-resource-tooltip {
  min-width: 0;
  max-width: min(280px, calc(100dvw - 32px));
  padding: 10px 12px;
  border-radius: 11px;
  pointer-events: none;
}

.combine-popover.is-visible {
  opacity: 1;
  visibility: visible;
  pointer-events: none;
  transform: translateY(0);
  transition: opacity 0.18s ease, transform 0.18s ease, visibility 0s linear 0s;
}

.combine-popover.is-visible.is-resource-tooltip {
  pointer-events: none;
}

.combine-resource-tooltip {
  display: none;
  align-items: center;
  gap: 12px;
}

.combine-popover.is-resource-tooltip .combine-resource-tooltip {
  display: flex;
}

.combine-resource-tooltip-text {
  min-width: 0;
  color: #f8fafc;
  font-size: 15px;
  font-weight: 800;
  line-height: 1.15;
  white-space: nowrap;
}

.combine-resource-count {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 4px;
  min-width: 52px;
  height: 34px;
  padding: 2px 8px 2px 6px;
  border-radius: 999px;
  background: rgba(2, 6, 14, 0.54);
  color: #f8fafc;
  font-size: 18px;
  font-weight: 900;
  line-height: 1;
  flex: 0 0 auto;
}

.combine-resource-icon {
  width: 28px;
  height: 28px;
  flex: 0 0 28px;
  font-size: 28px;
  line-height: 1;
  background-size: contain !important;
  background-position: center center;
}

.combine-resource-value {
  min-width: 10px;
  text-align: center;
}

.toast-message {
  position: absolute;
  background: rgba(15, 23, 32, 0.96);
  border: none;
  border-radius: 12px;
  padding: 12px 16px;
  font-size: 15px;
  line-height: 1.3;
  font-weight: 700;
  color: #fbbf24;
  display: none;
  pointer-events: none;
  z-index: 32;
  box-shadow: 0 12px 26px rgba(0, 0, 0, 0.35);
}

.toast-message.is-visible {
  display: block;
}

.tutorial-popup {
  position: fixed;
  inset: 0;
  z-index: 130;
  display: none;
  pointer-events: auto;
  align-items: center;
  justify-content: center;
  padding: var(--game-popup-safe-top) var(--game-popup-safe-right) var(--game-popup-safe-bottom) var(--game-popup-safe-left);
}

.tutorial-popup.is-visible {
  display: flex;
}

.tutorial-popup-card {
  width: min(700px, 92vw);
  max-width: var(--game-popup-card-max-width);
  max-height: min(var(--game-popup-card-max-height), 760px);
  overflow: auto;
  overscroll-behavior: contain;
  -webkit-overflow-scrolling: touch;
  padding: 28px 24px 32px;
  text-align: center;
}

.tutorial-popup-hero {
  margin: 0 auto 10px;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 12px;
}

.tutorial-popup-image {
  width: 120px;
  height: 120px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 88px;
  line-height: 1;
  background-repeat: no-repeat;
  background-size: contain;
  background-position: center;
}

.tutorial-popup.is-first-crystal-combine .tutorial-popup-image {
  width: 168px;
  height: 168px;
  font-size: 112px;
}

.tutorial-popup-image-value {
  min-width: 70px;
  text-align: left;
  font-size: 30px;
  font-weight: 800;
  letter-spacing: 0.03em;
  color: #f8fafc;
}

.tutorial-popup-image-value:empty {
  display: none;
}

.tutorial-popup-title {
  margin: 0 0 8px;
  font-size: 46px;
  font-weight: 700;
  letter-spacing: 0;
  color: #fff;
}

.tutorial-popup-text {
  margin: 0 auto 16px;
  max-width: 620px;
  line-height: 1.5;
  font-size: 18px;
  font-weight: 600;
  color: rgba(255, 255, 255, 0.82);
  white-space: pre-line;
}

.tutorial-popup.is-first-crystal-combine .tutorial-popup-text {
  font-size: 15px;
  line-height: 1.45;
}

.tutorial-popup-visual {
  border: 1px solid rgba(255, 255, 255, 0.16);
  border-radius: 14px;
  background: rgba(10, 12, 20, 0.72);
  padding: 16px;
  margin: 0 auto 18px;
}

.tutorial-popup-visual-combine {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  min-height: 84px;
  border: none;
  background: transparent;
  padding: 0;
}

.tutorial-popup-visual-image {
  display: block;
  width: 100%;
  height: auto;
  user-select: none;
  -webkit-user-drag: none;
}

.tutorial-popup-visual-image-combine {
  max-width: min(460px, 82%);
}

.tutorial-popup-visual-image-limit {
  max-width: min(520px, 92%);
  margin-top: 12px;
}

.tutorial-popup-sign {
  font-size: 28px;
  font-weight: 700;
  opacity: 0.92;
}

.tutorial-tower-icon {
  width: 64px;
  height: 64px;
  border-radius: 12px;
  border: none;
  background: transparent;
  background-size: contain;
  background-repeat: no-repeat;
  background-position: center;
}

.tutorial-popup-visual-limit {
  display: none;
  align-items: center;
  justify-content: center;
  min-height: 84px;
  border: none;
  background: transparent;
  padding: 0;
}

.tutorial-popup-visual-upgrade {
  display: none;
  align-items: center;
  justify-content: center;
  min-height: 84px;
  border: none;
  background: transparent;
  padding: 0;
}

.tutorial-popup-limit-icon {
  width: 84px;
  height: 84px;
  font-size: 84px;
  background-repeat: no-repeat;
  background-size: contain;
  background-position: center;
}

.tutorial-popup-button {
  min-width: 220px;
}

.tutorial-popup.is-madness-map-intro .tutorial-popup-button {
  background: linear-gradient(262deg, #e11d48 12%, #8a102d 52%, #24040c 92%);
  box-shadow:
    -2.95px -5.95px 2.3px 0 #170006 inset,
    1.95px -8.875px 3.6px 0 #b91435 inset,
    .95px 4.125px 3.6px 0 #f05263 inset,
    2.95px 7.25px 2.3px 0 rgba(255, 255, 255, 0.82) inset;
}

.tutorial-popup-visual-image-upgrade {
  max-width: min(520px, 92%);
}

.new-enemy-popup-card {
  width: min(420px, calc(100vw - 48px));
  min-height: auto;
  padding: 28px 28px 30px;
}

.new-enemy-popup-kicker {
  margin-bottom: 16px;
  padding-right: 56px;
  color: #ff9a1a;
  text-shadow: 0 0 18px rgba(255, 122, 0, 0.28);
  font-size: var(--font-size-ui-title-section);
  font-weight: var(--font-weight-ui-heavy);
  line-height: 1.1;
}

.new-enemy-popup-detail {
  gap: 12px;
  align-items: flex-start;
}

.new-enemy-popup-detail .pregame-upgrade-detail-preview {
  width: 152px;
  height: 152px;
}

.new-enemy-popup-detail .pregame-upgrade-detail-preview .pregame-knowledge-preview-canvas {
  width: 152px;
  height: 152px;
}

.new-enemy-popup-detail .pregame-upgrade-detail-description,
.new-enemy-popup-detail .pregame-knowledge-detail-stats {
  max-width: 100%;
  width: 100%;
}

.new-enemy-popup-card .primary-action-button {
  width: 100%;
  min-width: 0;
}

.special-unlock-popup .tutorial-popup-card {
  max-width: 480px;
}

.special-unlock-popup-actions {
  margin-top: 18px;
  display: flex;
  gap: 16px;
  justify-content: center;
}

.locked-hybrid-recipe-popup .tutorial-popup-card {
  width: min(820px, 92vw);
  padding: 48px 40px 40px;
}

.locked-hybrid-recipe-popup .tutorial-popup-title {
  margin-bottom: 30px;
}

#lockedHybridRecipePopupText.tutorial-popup-text {
  margin-bottom: 34px;
}

.locked-hybrid-recipe-popup-requirement {
  width: min(100%, 520px);
  margin: 0 auto 38px;
  display: flex;
  align-items: center;
  gap: 16px;
  text-align: left;
}

.locked-hybrid-recipe-popup-recipe-icon {
  flex-shrink: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 22px;
  font-weight: 700;
  color: #f8fafc;
  background-repeat: no-repeat;
  background-position: center;
  background-size: contain;
}

.locked-hybrid-recipe-popup-recipe-icon.has-icon,
.locked-hybrid-recipe-popup-recipe-icon.is-pictogram {
  color: transparent;
}

.locked-hybrid-recipe-popup-requirement-text {
  margin: 0;
  color: #fff;
  font-size: 20px;
  font-weight: 600;
  line-height: 1.35;
}

.locked-hybrid-recipe-popup-upgrade-row {
  margin: 0 auto 40px;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 10px;
  flex-wrap: wrap;
}

.locked-hybrid-recipe-popup-upgrade-text {
  color: inherit;
}

.locked-hybrid-recipe-popup-stars-icon {
  width: 40px;
  height: 40px;
  font-size: 40px;
  flex-shrink: 0;
}

.hud-speed-controls.is-locked,
.hud-wave-cooldown.is-locked,
.hud-ability-button.is-locked {
  opacity: 1;
}

.hud-speed-controls.is-locked {
  filter: saturate(0.55) contrast(0.8);
}

.hud-speed-controls.is-locked::after,
.hud-wave-cooldown.is-locked::after {
  content: "🔒 Locked";
  position: absolute;
  left: 50%;
  top: -28px;
  transform: translateX(-50%);
  padding: 2px 8px;
  border-radius: 999px;
  border: 1px solid rgba(239, 68, 68, 0.75);
  background: rgba(15, 23, 42, 0.9);
  color: #fee2e2;
  font-size: 11px;
  font-weight: 700;
  white-space: nowrap;
  letter-spacing: 0.04em;
}

.hud-speed-controls.is-locked .hud-speed-button {
  border-style: dashed;
  border-color: rgba(248, 113, 113, 0.75);
  color: rgba(226, 232, 240, 0.7);
  background: rgba(17, 24, 32, 0.76);
}

.hud-wave-cooldown.is-locked {
  border-style: dashed;
  border-color: rgba(248, 113, 113, 0.75);
}

.hud-wave-cooldown.is-locked .hud-wave-launch-button {
  opacity: 0.68;
}


@media (max-width: 900px), (pointer: coarse) {
  #gameRoot {
    --edge-gap: var(--edge-gap-mobile);
  }

  body.is-mobile-fullbleed #gameRoot,
  #gameRoot.is-mobile-fullbleed {
    --edge-gap: 12px;
  }

  .context-menu:not(.is-build-radial) {
    min-width: 176px;
    max-width: min(220px, calc(100dvw - 24px));
    max-height: min(52dvh, 218px);
    border-radius: 12px;
    padding: 9px 10px;
    overflow: auto;
  }

  .context-menu:not(.is-build-radial) .context-sell-icon-button {
    width: 26px;
    height: 26px;
    border-radius: 7px;
  }

  .context-menu:not(.is-build-radial) .context-sell-icon {
    width: 14px;
    height: 14px;
    font-size: 12px;
  }

  .context-menu:not(.is-build-radial) .context-menu-header {
    gap: 7px;
  }

  .context-menu:not(.is-build-radial) .context-menu-title {
    font-size: 13px;
    line-height: 1.1;
  }

  .context-menu:not(.is-build-radial) .context-menu-subtitle,
  .context-menu:not(.is-build-radial) .context-menu-info,
  .context-menu:not(.is-build-radial) .context-menu-stats,
  .context-menu:not(.is-build-radial) .context-menu-message {
    font-size: 12px;
    line-height: 1.25;
  }

  .context-menu:not(.is-build-radial) .context-menu-actions {
    margin-top: 7px;
    gap: 6px;
  }

  .context-menu:not(.is-build-radial) .context-button {
    gap: 6px;
    padding: 7px 8px;
    border-radius: 7px;
    font-size: 12px;
    min-height: 30px;
  }

  .context-menu:not(.is-build-radial) #contextUpgrade {
    min-height: 32px;
    font-size: 12px;
  }

  .hud-top,
  .wave-preview {
    font-size: 18px;
    gap: 8px;
  }

  .hud-economy-item {
    gap: 7px;
    min-height: 30px;
    padding: 4px 8px;
  }

  .wave-preview-counter {
    min-height: 30px;
    padding: 4px 8px;
  }

  .hud-icon {
    font-size: 26px;
  }

  .hud-abilities {
    --hud-ability-size: 48px;
    --hud-ability-gap: 7px;
    bottom: var(--hud-edge-bottom);
  }

  .hud-ability-button {
    border-radius: 11px;
    font-size: 20px;
  }

  .hud-ability-icon {
    font-size: 24px;
  }

  .hud-ability-count {
    min-width: 20px;
    height: 20px;
    font-size: 11px;
    line-height: 18px;
    right: -4px;
    top: -4px;
    padding: 0 5px;
  }

  .context-menu:not(.is-build-radial) .context-button-label {
    gap: 4px;
  }

  .context-menu:not(.is-build-radial) .context-button-icon {
    width: 20px;
    height: 20px;
    border-radius: 5px;
    font-size: 10px;
  }

  .context-menu:not(.is-build-radial) .context-button-sub {
    font-size: 10px;
  }

  .context-menu:not(.is-build-radial) .context-build-card {
    --context-build-inline-gap: 5px;
  }

  .context-menu:not(.is-build-radial) .context-build-confirm-icon {
    width: 18px;
    height: 18px;
    font-size: 18px;
  }

  .context-menu:not(.is-build-radial) .context-build-cancel-icon {
    width: 14px;
    height: 14px;
    font-size: 14px;
  }

  .context-menu:not(.is-build-radial) .stat-bar-group {
    gap: 2px;
  }

  .context-menu:not(.is-build-radial) .stat-bar {
    width: 4px;
    height: 11px;
    border-radius: 2px;
  }

  .context-menu:not(.is-build-radial) .stat-row-subtitle {
    margin-left: 4px;
    font-size: 10px;
  }

  .context-menu:not(.is-build-radial) .stat-chip-group {
    gap: 3px;
  }

  .context-menu:not(.is-build-radial) .stat-chip {
    border-radius: 999px;
    padding: 2px 5px;
    font-size: 10px;
  }

  .combine-popover {
    min-width: 0;
    max-width: min(240px, calc(100dvw - 28px));
    border-radius: 10px;
    padding: 8px 10px;
  }

  .combine-popover.is-resource-tooltip {
    min-width: 0;
    max-width: min(240px, calc(100dvw - 28px));
    padding: 8px 10px;
  }

  .combine-resource-tooltip {
    gap: 8px;
  }

  .combine-resource-tooltip-text {
    font-size: 12px;
  }

  .combine-resource-count {
    min-width: 46px;
    height: 29px;
    padding: 2px 7px 2px 5px;
    font-size: 15px;
  }

  .combine-resource-icon {
    width: 24px;
    height: 24px;
    flex-basis: 24px;
    font-size: 24px;
  }

  .toast-message {
    max-width: min(240px, calc(100dvw - 28px));
    padding: 8px 10px;
    border-radius: 10px;
    font-size: 12px;
  }

  .locked-hybrid-recipe-popup-requirement {
    gap: 8px;
  }

  .locked-hybrid-recipe-popup-recipe-icon {
    font-size: 14px;
  }

  .locked-hybrid-recipe-popup-requirement-text {
    font-size: 13px;
  }

  .locked-hybrid-recipe-popup-stars-icon {
    width: 24px;
    height: 24px;
    font-size: 24px;
  }

  .context-menu.is-build-radial .context-button {
    width: 94px;
    min-height: 92px;
    border-radius: 10px;
    padding: 33px 8px 10px;
    gap: 4px;
  }

  .context-menu.is-build-radial .context-build-card {
    width: 94px;
    --context-build-card-split-gap: 26px;
    gap: 6px;
  }

  .context-menu.is-build-radial .context-button-label > span:last-child {
    font-size: 11.5px;
    white-space: nowrap;
  }

  .context-menu.is-build-radial .context-button-icon {
    width: 56px;
    height: 56px;
    flex: 0 0 56px;
    aspect-ratio: 1 / 1;
    margin: -45px 0 4px;
  }

  .context-menu.is-build-radial .context-build-cancel-button {
    width: 94px;
    min-height: 24px;
    border-radius: 7px;
  }

  .context-menu.is-build-radial .context-build-confirm-icon {
    width: 24px;
    height: 24px;
    font-size: 24px;
  }

  .context-menu.is-build-radial .context-build-cancel-icon {
    width: 14px;
    height: 14px;
    font-size: 14px;
  }

  .context-menu.is-build-radial .context-button-sub {
    justify-content: center;
    width: 100%;
    padding-inline: 4px;
    margin: 3px 0 0;
    gap: 3px;
    font-size: 11px;
    line-height: 1;
  }

  .context-menu.is-build-radial .context-button-role-chips.has-role-chips {
    display: flex !important;
    gap: 5px;
    min-height: 10px;
    margin: 0;
  }

  .context-menu.is-build-radial .context-role-chip {
    font-size: 9.5px;
    line-height: 1;
    letter-spacing: 0;
  }

  body.is-mobile-fullbleed #gameStage,
  #gameRoot.is-mobile-fullbleed #gameStage {
    inset: 0;
    border-radius: 0;
    clip-path: none;
  }

  body.is-mobile-fullbleed .pregame-map-panel,
  body.is-mobile-fullbleed .pregame-map-stage,
  #gameRoot.is-mobile-fullbleed .pregame-map-panel,
  #gameRoot.is-mobile-fullbleed .pregame-map-stage {
    border-radius: 0;
  }

  body.is-mobile-fullbleed .pregame-map-panel,
  #gameRoot.is-mobile-fullbleed .pregame-map-panel {
    top: 0;
    right: 0;
    bottom: 0;
    left: 0;
  }

  .locked-hybrid-recipe-popup .tutorial-popup-card {
    width: min(420px, calc(100vw - 24px));
    padding: 34px 22px 28px;
  }

  .locked-hybrid-recipe-popup .tutorial-popup-title {
    margin-bottom: 22px;
  }

  #lockedHybridRecipePopupText.tutorial-popup-text {
    margin-bottom: 24px;
  }

  .locked-hybrid-recipe-popup-requirement {
    margin-bottom: 28px;
  }

  .locked-hybrid-recipe-popup-upgrade-row {
    margin-bottom: 30px;
  }
}


@media (orientation: portrait) and (max-width: 900px), (orientation: portrait) and (pointer: coarse) {
  .mobile-portrait-lock {
    display: none;
  }

  html,
  body {
    overflow: hidden;
  }

  #appShell {
    position: fixed;
    top: 50%;
    left: 50%;
    width: 100vh;
    width: 100dvh;
    height: 100vw;
    height: 100dvw;
    transform: translate(-50%, -50%) rotate(-90deg);
    transform-origin: center center;
  }

  #gameRoot {
    position: absolute;
    inset: 0;
    width: 100%;
    height: 100%;
  }
}

.pregame-energy-value {
  color: #fde047;
}

.pregame-chest-button {
  position: absolute;
  left: calc(32px * var(--ui-scale));
  bottom: calc(32px * var(--ui-scale));
  z-index: 6;
  border: none;
  padding: 0;
  background: transparent;
  color: #fff;
  font-family: "Jost", "Arial", sans-serif;
  font-size: calc(24px * var(--ui-scale));
  font-weight: 600;
  line-height: 0.5;
  text-shadow: 0 4px 3px rgba(0, 0, 0, 0.7);
  cursor: pointer;
  display: inline-flex;
  flex-direction: column;
  align-items: center;
  gap: calc(10px * var(--ui-scale));
  pointer-events: auto;
}

.pregame-chest-icon {
  width: calc(112px * var(--ui-scale));
  height: calc(95px * var(--ui-scale));
  display: block;
  background: url("./assets/ui/treasure_close.png") center center / contain no-repeat;
}

.pregame-chest-button.is-opened .pregame-chest-icon {
  background-image: url("./assets/ui/treasure_open.png");
}

.pregame-chest-button.is-hidden {
  display: none;
}

.pregame-chest-button:disabled {
  cursor: default;
}

.pregame-chest-cooldown {
  min-height: calc(24px * var(--ui-scale));
  text-align: center;
}

.chest-popup {
  --chest-rarity-color: #f8fafc;
  --chest-charge-fill-duration: 2400ms;
  position: fixed;
  inset: 0;
  z-index: 40;
  display: grid;
  place-items: center;
  opacity: 0;
  visibility: hidden;
  pointer-events: none;
  transition: opacity 0.2s ease;
}

.chest-popup.is-visible {
  opacity: 1;
  visibility: visible;
  pointer-events: auto;
}

.chest-popup.is-rarity-common,
.reward-popup.is-rarity-common {
  --chest-rarity-color: #f8fafc;
}

.chest-popup.is-rarity-rare,
.reward-popup.is-rarity-rare {
  --chest-rarity-color: #60a5fa;
}

.chest-popup.is-rarity-epic,
.reward-popup.is-rarity-epic {
  --chest-rarity-color: #c084fc;
}

.chest-popup.is-rarity-legendary,
.reward-popup.is-rarity-legendary {
  --chest-rarity-color: #facc15;
}

.chest-popup-card {
  position: relative;
  width: min(92vw, 620px);
  max-width: min(620px, var(--game-popup-card-max-width));
  min-width: 0;
  padding: 42px 42px 38px;
  color: #f8fafc;
  text-align: center;
  border: 0;
  background: #000;
  box-shadow: 0 18px 60px rgba(0, 0, 0, 0.45);
  overflow: hidden;
  backface-visibility: hidden;
  z-index: 1;
}

.chest-popup-confetti {
  position: absolute;
  inset: 0;
  z-index: 0;
  pointer-events: none;
  overflow: visible;
}

.chest-popup-confetti span {
  position: absolute;
  left: var(--sx, 50%);
  top: var(--sy, 50%);
  width: 10px;
  height: 16px;
  border-radius: 2px;
  background: var(--c);
  opacity: 0;
  transform: translate(-50%, -50%) scale(0.26) rotate(0deg);
  filter: drop-shadow(0 0 8px var(--c));
}

.chest-popup.is-confetti .chest-popup-confetti span {
  animation: chest-popup-edge-confetti-burst 1650ms cubic-bezier(0.12, 0.76, 0.24, 1) var(--d) both;
}

@keyframes chest-popup-edge-confetti-burst {
  0% {
    opacity: 0;
    transform: translate(-50%, -50%) scale(0.18) rotate(0deg);
  }
  8% {
    opacity: 1;
  }
  70% {
    opacity: 1;
  }
  100% {
    opacity: 0;
    transform: translate(calc(-50% + var(--x)), calc(-50% + var(--y))) scale(1) rotate(var(--r));
  }
}

.chest-popup-close {
  top: 18px;
  right: 18px;
  width: 44px;
  min-width: 44px;
  max-width: 44px;
  height: 44px;
  min-height: 44px;
  opacity: 0.82;
}

.chest-popup-close:hover {
  opacity: 1;
}

.chest-popup-visual {
  position: relative;
  min-height: 176px;
  display: flex;
  align-items: flex-end;
  justify-content: center;
  margin: 0 auto 12px;
}

.chest-popup-icon {
  width: 164px;
  height: 138px;
  margin: 0 auto;
  background: url("./assets/ui/treasure_close.png") center center / contain no-repeat;
  filter: drop-shadow(0 0 16px color-mix(in srgb, var(--chest-rarity-color) 34%, transparent));
  transform-origin: 50% 78%;
}

.chest-popup-icon.is-open-state {
  background-image: url("./assets/ui/treasure_open.png");
}

.chest-popup.is-opening .chest-popup-icon {
  animation: chest-open-snap 0.34s cubic-bezier(0.2, 0.82, 0.2, 1) both;
}

.chest-popup.is-kicking .chest-popup-icon {
  animation: chest-kick-open 0.34s cubic-bezier(0.17, 0.84, 0.24, 1) both;
}

.chest-popup.is-charge-upgrading .chest-popup-icon {
  animation: chest-charge-upgrade 0.9s cubic-bezier(0.16, 0.84, 0.22, 1) both;
}

.chest-popup.is-charge-upgrading .chest-popup-progress-track {
  animation: chest-charge-progress-upgrade 0.9s ease both;
}

.chest-popup-reward-bubble {
  position: absolute;
  left: 50%;
  top: -10px;
  z-index: 2;
  width: 154px;
  height: 154px;
  min-width: 154px;
  max-width: 154px;
  min-height: 154px;
  padding: 22px;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 2px;
  border: 0;
  border-radius: 50%;
  background:
    radial-gradient(circle at 50% 45%, rgba(248, 250, 252, 0.94) 0%, rgba(226, 232, 240, 0.86) 44%, rgba(148, 163, 184, 0.16) 70%, transparent 72%);
  background-repeat: no-repeat;
  background-position: center;
  background-size: contain;
  box-shadow:
    0 18px 34px rgba(0, 0, 0, 0.32),
    0 0 24px color-mix(in srgb, var(--chest-rarity-color) 34%, transparent);
  opacity: 0;
  pointer-events: none;
  transform: translate(-50%, 38px) scale(0.72);
  transform-origin: 50% 80%;
}

.chest-popup-reward-bubble.has-special-bubble-art {
  background-color: transparent;
  box-shadow: none;
}

.chest-popup-reward-bubble.is-visible {
  opacity: 1;
  animation: chest-reward-bubble-rise 0.72s cubic-bezier(0.16, 0.88, 0.2, 1.08) both;
}

.chest-popup-reward-bubble-icon {
  width: 72px;
  height: 72px;
  min-width: 72px;
  min-height: 72px;
  flex: 0 0 72px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  font-size: 58px;
  line-height: 1;
  filter: drop-shadow(0 0 14px color-mix(in srgb, var(--chest-rarity-color) 48%, transparent));
}

.chest-popup-reward-copy {
  position: absolute;
  left: 50%;
  bottom: -8px;
  min-width: max-content;
  max-width: 220px;
  padding: 5px 10px 6px;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 2px;
  text-align: center;
  border-radius: 999px;
  background: rgba(2, 6, 23, 0.86);
  box-shadow: 0 10px 22px rgba(0, 0, 0, 0.28);
  transform: translateX(-50%);
}

.chest-popup-reward-main {
  color: #fff;
  font-family: var(--font-family-ui-base);
  font-size: clamp(14px, 2vw, 18px);
  font-weight: var(--font-weight-ui-heavy);
  line-height: 1;
  white-space: nowrap;
  text-shadow: 0 5px 14px rgba(0, 0, 0, 0.34);
}

.chest-popup-reward-rarity {
  color: var(--chest-rarity-color);
  font-family: var(--font-family-ui-base);
  font-size: var(--font-size-ui-caption);
  font-weight: var(--font-weight-ui-heavy);
  line-height: 1;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  opacity: 0.72;
}

.chest-popup-title {
  margin: 0 0 18px;
  font-family: var(--font-family-ui-base);
  font-size: var(--font-size-ui-title-panel);
  font-weight: var(--font-weight-ui-heavy);
  line-height: 1.08;
  color: #f8fafc;
  text-transform: none;
}

.chest-popup-progress {
  width: min(100%, 235px);
  margin: 0 auto 22px;
  padding-top: 28px;
}

.chest-popup-progress-track {
  position: relative;
  height: 14px;
  border-radius: 999px;
  overflow: visible;
  background: rgba(15, 23, 42, 0.82);
  border: 0;
  box-shadow: inset 0 1px 5px rgba(0, 0, 0, 0.45);
}

.chest-popup-progress-fill {
  width: 0%;
  height: 100%;
  border-radius: inherit;
  background: linear-gradient(90deg, color-mix(in srgb, var(--chest-rarity-color) 64%, #ffffff), var(--chest-rarity-color));
  box-shadow: 0 0 16px color-mix(in srgb, var(--chest-rarity-color) 52%, transparent);
  transition: width var(--chest-charge-fill-duration) linear;
}

.chest-popup-progress-milestones {
  position: absolute;
  inset: 0;
  z-index: 2;
  pointer-events: none;
}

.chest-popup-progress-milestone {
  --milestone-left: 0%;
  position: absolute;
  left: var(--milestone-left);
  top: 50%;
  width: 46px;
  height: 48px;
  transform: translate(-50%, -50%);
}

.chest-popup-progress-milestone::before {
  content: none;
}

.chest-popup-progress-milestone-icon {
  position: absolute;
  left: 50%;
  bottom: 22px;
  width: 34px;
  height: 28px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  background: url("./assets/ui/treasure_close.png") center center / contain no-repeat;
  color: #fef3c7;
  font-size: 18px;
  line-height: 1;
  filter:
    grayscale(0.28)
    drop-shadow(0 3px 4px rgba(0, 0, 0, 0.55));
  opacity: 0.72;
  transform: translateX(-50%) scale(0.88);
  transition:
    filter 220ms ease,
    opacity 220ms ease,
    transform 220ms ease;
}

.chest-popup-progress-milestone-icon.has-atlas-chest-art {
  color: transparent;
  font-size: 0;
}

.chest-popup-progress-milestone-label {
  position: absolute;
  left: 50%;
  top: 25px;
  padding: 1px 5px 2px;
  border-radius: 999px;
  background: rgba(2, 6, 23, 0.72);
  color: rgba(248, 250, 252, 0.76);
  font-family: var(--font-family-ui-base);
  font-size: 9px;
  font-weight: var(--font-weight-ui-heavy);
  line-height: 1;
  letter-spacing: 0.03em;
  text-transform: uppercase;
  white-space: nowrap;
  transform: translateX(-50%);
}

.chest-popup-progress-milestone.is-reached::before {
  background: transparent;
}

.chest-popup-progress-milestone.is-reached .chest-popup-progress-milestone-icon {
  opacity: 1;
  filter:
    grayscale(0)
    drop-shadow(0 0 8px color-mix(in srgb, var(--chest-rarity-color) 52%, transparent))
    drop-shadow(0 4px 5px rgba(0, 0, 0, 0.52));
  transform: translateX(-50%) scale(1);
}

.chest-popup-progress-milestone.is-reached .chest-popup-progress-milestone-label {
  color: #fff;
}

.chest-popup-progress-milestone.is-pop .chest-popup-progress-milestone-icon {
  animation: chest-charge-milestone-pop 760ms cubic-bezier(0.16, 0.86, 0.22, 1.06) both;
}

.chest-popup-progress-label {
  margin-top: 18px;
  color: #f8fafc;
  font-family: var(--font-family-ui-base);
  font-size: var(--font-size-ui-title-card);
  font-weight: var(--font-weight-ui-heavy);
  line-height: 1;
  text-align: center;
}

.chest-popup-possible {
  width: min(100%, 506px);
  margin: 0 auto 30px;
  text-align: left;
}

.chest-popup-possible-title {
  display: none;
  margin-bottom: 0;
  color: rgba(255, 255, 255, 0.86);
  font-size: var(--font-size-ui-body);
  font-weight: var(--font-weight-ui-heavy);
  text-transform: uppercase;
  letter-spacing: 0.04em;
}

.chest-popup-rewards-viewport {
  position: relative;
  width: 100%;
  height: 144px;
  overflow: visible;
  display: flex;
  align-items: center;
}

.chest-popup-rewards-strip {
  position: absolute;
  inset: 0;
  overflow: hidden;
  display: flex;
  align-items: center;
}

.chest-popup-rewards-strip::before,
.chest-popup-rewards-strip::after {
  content: "";
  position: absolute;
  top: 0;
  bottom: 0;
  z-index: 2;
  width: 86px;
  pointer-events: none;
}

.chest-popup-rewards-strip::before {
  left: 0;
  background: linear-gradient(90deg, #000 0%, #000 28%, rgba(0, 0, 0, 0.86) 58%, rgba(0, 0, 0, 0) 100%);
}

.chest-popup-rewards-strip::after {
  right: 0;
  background: linear-gradient(270deg, #000 0%, #000 28%, rgba(0, 0, 0, 0.86) 58%, rgba(0, 0, 0, 0) 100%);
}

.chest-popup-reward-selector {
  position: absolute;
  left: 50%;
  top: 50%;
  z-index: 3;
  width: 140px;
  height: 140px;
  border: 0;
  border-radius: 0;
  pointer-events: none;
  transform: translate(-50%, -50%);
  background: transparent center center / contain no-repeat;
  box-shadow: none;
  opacity: 0;
  visibility: hidden;
}

.chest-popup.is-reward-rolling .chest-popup-reward-selector,
.chest-popup.is-reward-centering .chest-popup-reward-selector,
.chest-popup.has-reward .chest-popup-reward-selector {
  opacity: 1;
  visibility: visible;
}

.chest-popup-reward-selector::before,
.chest-popup-reward-selector::after {
  content: none;
}

.chest-popup-rewards {
  margin: 0;
  padding: 0;
  list-style: none;
  display: flex;
  align-items: center;
  width: max-content;
  gap: 22px;
  position: relative;
  z-index: 1;
  color: rgba(255, 255, 255, 0.78);
  font-family: var(--font-family-ui-base);
  font-size: var(--font-size-ui-body);
  font-weight: var(--font-weight-ui-strong);
  line-height: 1.45;
  will-change: transform;
}

.chest-popup-rewards:not(.is-rolling):not(.is-centering):not(.has-selection) {
  animation: chest-rewards-idle-scroll 18s linear infinite;
}

.chest-popup-reward-item {
  position: relative;
  display: inline-flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 3px;
  min-width: 58px;
  min-height: 76px;
  padding: 6px 5px 5px;
  border-radius: 999px;
  background: transparent;
  border: 0;
  flex: 0 0 auto;
  transition:
    transform 280ms ease,
    min-width 280ms ease,
    min-height 280ms ease,
    background-color 280ms ease,
    box-shadow 280ms ease;
}

.chest-popup-reward-item.is-selected {
  min-width: 58px;
  min-height: 76px;
  padding: 6px 5px 5px;
  transform: none;
  background: transparent;
  box-shadow: none;
  animation: none;
}

.chest-popup-reward-icon {
  width: 44px;
  height: 44px;
  min-width: 44px;
  min-height: 44px;
  flex: 0 0 auto;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  font-size: 36px;
  line-height: 1;
}

.chest-popup-reward-item.is-selected .chest-popup-reward-icon {
  width: 44px;
  height: 44px;
  min-width: 44px;
  min-height: 44px;
  flex-basis: auto;
  font-size: 36px;
  filter: none;
}

.chest-popup-reward-caption {
  position: absolute;
  left: 50%;
  bottom: 8px;
  max-width: 150px;
  padding: 3px 8px;
  border-radius: 999px;
  color: rgba(248, 250, 252, 0.92);
  background: rgba(15, 23, 42, 0.78);
  font-family: var(--font-family-ui-base);
  font-size: var(--font-size-ui-caption);
  font-weight: var(--font-weight-ui-heavy);
  line-height: 1;
  text-align: center;
  white-space: nowrap;
  transform: translateX(-50%);
}

.chest-popup-reward-icon.is-ability {
  color: color-mix(in srgb, var(--chest-rarity-color) 82%, #ffffff);
  text-shadow: 0 0 12px color-mix(in srgb, var(--chest-rarity-color) 42%, transparent);
}

.chest-popup-reward-icon.is-dust {
  color: #e9d5ff;
  text-shadow: 0 0 12px rgba(192, 132, 252, 0.48);
}

.chest-popup-reward-value {
  color: #f8fafc;
  font-weight: var(--font-weight-ui-heavy);
  font-size: 12px;
  line-height: 1;
  text-align: center;
  white-space: nowrap;
  text-shadow: 0 2px 6px rgba(0, 0, 0, 0.7);
  transform: translateY(-1px);
}

.chest-popup-actions {
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  align-items: center;
  gap: 18px;
}

.chest-popup.has-reward .chest-popup-charge-button {
  display: none;
}

.chest-popup.has-reward .chest-popup-open-button {
  width: 260px;
  min-width: 260px;
}

.chest-popup-open-button {
  width: 254px;
  min-width: 254px;
  max-width: 254px;
  height: 76px;
  min-height: 76px;
  padding: 0 28px;
  border-radius: 18px;
  font-size: 24px;
  font-weight: var(--font-weight-ui-heavy);
}

.chest-popup-charge-button {
  width: 254px;
  min-width: 254px;
  max-width: 254px;
  height: 76px;
  min-height: 76px;
  padding: 0 22px;
  border-radius: 18px;
  font-size: 24px;
  font-weight: var(--font-weight-ui-heavy);
}

.chest-popup-charge-button.is-ready {
  background: rgba(2, 6, 23, 0.26);
}

.chest-popup-charge-button.is-ready::before {
  opacity: 1;
}

.chest-popup-charge-button.is-locked,
.chest-popup-charge-button:disabled {
  color: rgba(248, 250, 252, 0.92);
  background: #000;
  border: 2px solid rgba(30, 41, 59, 0.95);
  box-shadow: inset 0 0 0 1px rgba(255, 255, 255, 0.04);
  opacity: 1;
  cursor: not-allowed;
}

.chest-popup-charge-button.is-locked::before,
.chest-popup-charge-button:disabled::before {
  opacity: 0;
}

.chest-popup-dust-icon {
  color: #e9d5ff;
  text-shadow: 0 0 12px rgba(192, 132, 252, 0.45);
}

.chest-popup-dust-particle {
  position: fixed;
  left: var(--particle-x, 0px);
  top: var(--particle-y, 0px);
  z-index: 45;
  width: 9px;
  height: 9px;
  border-radius: 999px;
  pointer-events: none;
  background: #fde68a;
  box-shadow:
    0 0 8px rgba(250, 204, 21, 0.92),
    0 0 18px rgba(250, 204, 21, 0.48);
  animation: chest-dust-charge-flight 760ms cubic-bezier(0.28, 0.76, 0.16, 1) var(--particle-delay, 0ms) forwards;
}

.reward-popup-icon.is-chest-reward-reveal,
.chest-popup-reward-bubble-icon.is-chest-reward-reveal {
  color: var(--chest-rarity-color);
  animation: chest-reward-reveal 0.46s ease-out both;
  filter: drop-shadow(0 0 14px color-mix(in srgb, var(--chest-rarity-color) 48%, transparent));
}

@keyframes chest-open-snap {
  0% { transform: scale(1); filter: drop-shadow(0 0 10px color-mix(in srgb, var(--chest-rarity-color) 18%, transparent)); }
  58% { transform: scale(1.06); filter: drop-shadow(0 0 20px color-mix(in srgb, var(--chest-rarity-color) 42%, transparent)); }
  100% { transform: scale(1); filter: drop-shadow(0 0 16px color-mix(in srgb, var(--chest-rarity-color) 34%, transparent)); }
}

@keyframes chest-rewards-idle-scroll {
  0% { transform: translateX(0); }
  100% { transform: translateX(-33.333%); }
}

@keyframes chest-kick-open {
  0% { transform: translateX(0) rotate(0deg) scale(1); }
  22% { transform: translateX(-9px) rotate(-5deg) scale(1.03); }
  48% { transform: translateX(12px) rotate(6deg) scale(1.08); }
  72% { transform: translateX(-4px) rotate(-2deg) scale(1.03); }
  100% { transform: translateX(0) rotate(0deg) scale(1); }
}

@keyframes chest-reward-selected-pop {
  0% { transform: scale(1); }
  66% { transform: scale(1.28); }
  100% { transform: scale(1.18); }
}

@keyframes chest-reward-bubble-rise {
  0% {
    opacity: 0;
    transform: translate(-50%, 38px) scale(0.72);
  }
  70% {
    opacity: 1;
    transform: translate(-50%, -28px) scale(1.08);
  }
  100% {
    opacity: 1;
    transform: translate(-50%, -22px) scale(1);
  }
}

@keyframes chest-charge-upgrade {
  0% { transform: translateY(0) scale(1); filter: drop-shadow(0 0 16px color-mix(in srgb, var(--chest-rarity-color) 34%, transparent)); }
  32% { transform: translateY(-7px) scale(1.08); filter: drop-shadow(0 0 28px color-mix(in srgb, var(--chest-rarity-color) 64%, transparent)); }
  58% { transform: translateY(2px) scale(0.98); }
  78% { transform: translateY(-2px) scale(1.03); }
  100% { transform: translateY(0) scale(1); filter: drop-shadow(0 0 16px color-mix(in srgb, var(--chest-rarity-color) 34%, transparent)); }
}

@keyframes chest-charge-progress-upgrade {
  0% { box-shadow: inset 0 1px 5px rgba(0, 0, 0, 0.45), 0 0 0 rgba(250, 204, 21, 0); }
  48% { box-shadow: inset 0 1px 5px rgba(0, 0, 0, 0.45), 0 0 26px color-mix(in srgb, var(--chest-rarity-color) 48%, transparent); }
  100% { box-shadow: inset 0 1px 5px rgba(0, 0, 0, 0.45), 0 0 0 rgba(250, 204, 21, 0); }
}

@keyframes chest-charge-milestone-pop {
  0% { transform: translateX(-50%) scale(1); }
  36% { transform: translateX(-50%) translateY(-4px) scale(1.22); }
  62% { transform: translateX(-50%) translateY(1px) scale(0.96); }
  100% { transform: translateX(-50%) scale(1); }
}

@keyframes chest-reward-reveal {
  0% { opacity: 0; transform: translateY(8px) scale(0.72); }
  70% { opacity: 1; transform: translateY(-2px) scale(1.08); }
  100% { opacity: 1; transform: translateY(0) scale(1); }
}

@keyframes chest-reward-bubble-float {
  0%, 100% { transform: translate(-50%, -2px) scale(1); }
  50% { transform: translate(-50%, -9px) scale(1.015); }
}

@keyframes chest-dust-charge-flight {
  0% {
    opacity: 0;
    transform: translate3d(0, 0, 0) scale(0.55);
  }
  12% {
    opacity: 1;
  }
  78% {
    opacity: 1;
  }
  100% {
    opacity: 0;
    transform: translate3d(var(--particle-dx, 0px), var(--particle-dy, 0px), 0) scale(0.25);
  }
}

@media (max-width: 900px), (pointer: coarse) {
  .chest-popup-card {
    width: min(330px, calc(100vw - 24px));
    padding: 24px 16px 18px;
    border-radius: 18px;
  }

  .chest-popup-close {
    top: 8px;
    right: 8px;
    width: 32px;
    min-width: 32px;
    max-width: 32px;
    height: 32px;
    min-height: 32px;
  }

  .chest-popup-icon {
    width: 96px;
    height: 82px;
    margin-bottom: 6px;
  }

  .chest-popup-visual {
    min-height: 118px;
    margin-bottom: 6px;
  }

  .chest-popup-reward-bubble {
    top: -6px;
    width: 104px;
    height: 104px;
    min-width: 104px;
    max-width: 104px;
    min-height: 104px;
    padding: 15px;
    gap: 1px;
  }

  .chest-popup-reward-bubble-icon {
    width: 50px;
    height: 50px;
    min-width: 50px;
    min-height: 50px;
    flex-basis: auto;
    font-size: 40px;
  }

  .chest-popup-reward-copy {
    bottom: -7px;
    max-width: 160px;
    padding: 4px 8px 5px;
  }

  .chest-popup-reward-main {
    font-size: clamp(11px, 3vw, 13px);
  }

  .chest-popup-reward-rarity {
    font-size: 10px;
  }

  .chest-popup-title {
    margin-bottom: 8px;
    font-size: clamp(20px, 5vw, 24px);
  }

  .chest-popup-progress {
    padding-top: 23px;
    margin-bottom: 16px;
  }

  .chest-popup-progress-milestone {
    width: 36px;
    height: 42px;
  }

  .chest-popup-progress-milestone-icon {
    bottom: 21px;
    width: 27px;
    height: 23px;
  }

  .chest-popup-progress-milestone-label {
    top: 24px;
    padding: 1px 4px 2px;
    font-size: 7px;
  }

  .chest-popup-progress-label,
  .chest-popup-rewards {
    font-size: 12px;
  }

  .chest-popup-rewards-viewport {
    height: 94px;
  }

  .chest-popup-reward-selector {
    width: 96px;
    height: 96px;
    border-radius: 0;
  }

  .chest-popup-reward-selector::before,
  .chest-popup-reward-selector::after {
    content: none;
  }

  .chest-popup-reward-item {
    min-width: 38px;
    min-height: 48px;
    padding: 3px 2px 2px;
    gap: 2px;
  }

  .chest-popup-reward-icon {
    width: 28px;
    height: 28px;
    min-width: 28px;
    min-height: 28px;
    flex-basis: auto;
    font-size: 24px;
  }

  .chest-popup-reward-item.is-selected {
    min-width: 38px;
    min-height: 48px;
    padding: 3px 2px 2px;
    transform: none;
  }

  .chest-popup-reward-item.is-selected .chest-popup-reward-icon {
    width: 28px;
    height: 28px;
    min-width: 28px;
    min-height: 28px;
    flex-basis: auto;
    font-size: 24px;
  }

  .chest-popup-reward-value {
    font-size: 9px;
  }

  .chest-popup-reward-caption {
    bottom: 5px;
    max-width: 116px;
    padding: 2px 6px;
    font-size: 9px;
  }

  .chest-popup-progress {
    margin-bottom: 10px;
  }

  .chest-popup-actions {
    gap: 8px;
  }

  .chest-popup-open-button {
    width: 150px;
    min-width: 150px;
    max-width: 150px;
    height: 48px;
    min-height: 48px;
    font-size: 15px;
  }

  .chest-popup-charge-button {
    width: 150px;
    min-width: 150px;
    max-width: 150px;
    height: 48px;
    min-height: 48px;
    font-size: 15px;
  }

  .chest-popup.has-reward .chest-popup-open-button {
    width: 170px;
    min-width: 170px;
  }
}

@media (pointer: coarse) and (min-width: 761px) and (max-height: 700px) {
  .chest-popup-card {
    width: min(620px, calc(100vw - 36px));
    max-height: calc(100dvh - 32px);
    display: grid;
    grid-template-columns: minmax(176px, 0.82fr) minmax(292px, 1fr);
    grid-template-rows: 30px 80px 42px;
    grid-template-areas:
      "hero rewards-title"
      "hero rewards"
      "progress actions";
    column-gap: 20px;
    row-gap: 16px;
    align-items: center;
    align-content: center;
    padding: 30px 22px;
    overflow: visible;
  }

  .chest-popup-close {
    top: 10px;
    right: 10px;
    z-index: 6;
  }

  .chest-popup-visual {
    grid-area: hero;
    min-height: 102px;
    margin: 0 0 -6px;
    align-self: center;
  }

  .chest-popup-icon {
    width: 122px;
    height: 102px;
    margin: 0 auto;
    transform: translateY(-12px);
  }

  .chest-popup-reward-bubble {
    top: -12px;
    width: 94px;
    height: 94px;
    min-width: 94px;
    max-width: 94px;
    min-height: 94px;
    padding: 12px;
  }

  .chest-popup-reward-bubble-icon {
    width: 46px;
    height: 46px;
    min-width: 46px;
    min-height: 46px;
    font-size: 36px;
  }

  .chest-popup-reward-copy {
    bottom: -4px;
    max-width: 138px;
    padding: 3px 7px 4px;
  }

  .chest-popup-reward-main {
    font-size: 11px;
  }

  .chest-popup-title {
    grid-area: rewards-title;
    margin: 0;
    padding-right: 46px;
    font-size: 21px;
    line-height: 1.08;
    text-align: left;
    align-self: end;
  }

  .chest-popup-title::after {
    content: " rewards";
  }

  .chest-popup-progress {
    grid-area: progress;
    width: min(100%, 158px);
    padding-top: 0;
    margin: 0 auto;
    align-self: start;
  }

  .chest-popup-progress-label {
    margin-top: 18px;
    font-size: 10px;
  }

  .chest-popup-progress-track {
    height: 5px;
  }

  .chest-popup-progress-milestone {
    width: 26px;
    height: 28px;
  }

  .chest-popup-progress-milestone-icon {
    bottom: 15px;
    width: 20px;
    height: 17px;
  }

  .chest-popup-progress-milestone-label {
    top: 17px;
    font-size: 5px;
  }

  .chest-popup-possible {
    grid-area: rewards;
    min-width: 0;
    width: 100%;
    align-self: center;
    margin-bottom: 0;
  }

  .chest-popup-rewards-viewport {
    height: 80px;
  }

  .chest-popup-reward-selector {
    width: 76px;
    height: 76px;
  }

  .chest-popup-rewards-strip::before,
  .chest-popup-rewards-strip::after {
    width: 60px;
  }

  .chest-popup-reward-item {
    min-width: 38px;
    min-height: 48px;
  }

  .chest-popup-reward-icon,
  .chest-popup-reward-item.is-selected .chest-popup-reward-icon {
    width: 29px;
    height: 29px;
    min-width: 29px;
    min-height: 29px;
    font-size: 24px;
  }

  .chest-popup-reward-value {
    font-size: 9px;
  }

  .chest-popup-actions {
    grid-area: actions;
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 10px;
    align-self: center;
    width: min(100%, 292px);
    margin: 0 auto;
  }

  .chest-popup.game-popup-overlay .chest-popup-open-button,
  .chest-popup.game-popup-overlay .chest-popup-charge-button {
    width: 100%;
    min-width: 0;
    max-width: none;
    height: var(--mobile-popup-primary-height);
    min-height: var(--mobile-popup-primary-height);
    padding: 0 10px;
    gap: 5px;
    border-radius: var(--mobile-popup-radius);
    font-size: 14px;
    line-height: 1;
    white-space: nowrap;
  }

  .chest-popup.game-popup-overlay .chest-popup-charge-button .secondary-action-button-inline-icon {
    width: 16px;
    height: 16px;
    min-width: 16px;
    min-height: 16px;
    flex-basis: 16px;
    font-size: 16px;
  }

  .chest-popup.has-reward .chest-popup-actions {
    grid-template-columns: minmax(0, 210px);
    justify-content: start;
    margin: 0;
  }

  .chest-popup.has-reward .chest-popup-open-button {
    width: 210px;
    min-width: 0;
    max-width: 210px;
  }
}

.reward-popup {
  position: fixed;
  inset: 0;
  z-index: 40;
  display: grid;
  place-items: center;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.2s ease;
}

.reward-popup.is-visible {
  opacity: 1;
  pointer-events: auto;
}

.reward-popup-card {
  min-width: min(92vw, 390px);
  padding: 28px 24px 32px;
  color: #f8fafc;
  text-align: center;
}

.reward-popup-icon {
  display: inline-flex;
  justify-content: center;
  align-items: center;
  width: 122px;
  height: 122px;
  border-radius: 0;
  background: transparent;
  font-size: 122px;
  margin-bottom: 12px;
}

.reward-popup-icon.is-chest-open {
  width: 164px;
  height: 139px;
  background: url("./assets/ui/treasure_open.png") center center / contain no-repeat;
}

.reward-popup-title {
  margin: 0;
  font-family: var(--font-family-ui-base);
  font-size: var(--font-size-ui-title-panel);
  font-weight: var(--font-weight-ui-strong);
}

.reward-popup-text {
  margin: 8px 0 22px;
  color: rgba(255, 255, 255, 0.82);
  font-size: 18px;
  font-weight: 600;
  line-height: 1.5;
}

@media (max-width: 760px), (max-height: 520px) and (pointer: coarse) {
  .tutorial-popup-card {
    width: min(520px, var(--game-popup-card-max-width));
    padding: 20px 22px 22px;
  }

  .tutorial-popup-hero {
    margin-bottom: 6px;
  }

  .tutorial-popup-title {
    font-size: 24px;
  }

  .tutorial-popup-image {
    width: 58px;
    height: 58px;
    font-size: 44px;
  }

  .tutorial-popup.is-first-crystal-combine .tutorial-popup-image {
    width: 96px;
    height: 96px;
    font-size: 54px;
  }

  .tutorial-popup-image-value {
    min-width: 40px;
    font-size: 18px;
  }

  .tutorial-popup-text,
  .tutorial-popup.is-first-crystal-combine .tutorial-popup-text {
    margin-bottom: 8px;
    font-size: 12px;
    line-height: 1.3;
  }

  .tutorial-popup-visual {
    margin-bottom: 8px;
    max-height: 58px;
    overflow: hidden;
  }

  .tutorial-popup-limit-icon {
    width: 52px;
    height: 52px;
    font-size: 52px;
  }

  .tutorial-popup-visual-combine,
  .tutorial-popup-visual-limit,
  .tutorial-popup-visual-upgrade {
    min-height: 48px;
  }

  .tutorial-popup-visual-image-combine,
  .tutorial-popup-visual-image-limit,
  .tutorial-popup-visual-image-upgrade {
    width: auto;
    max-width: min(460px, 90%);
    max-height: 54px;
  }

  .tutorial-popup-button {
    min-width: 144px;
    min-height: 44px;
    height: 44px;
    font-size: 20px;
  }

  .reward-popup-card {
    width: min(260px, var(--game-popup-card-max-width));
    min-width: 0;
    padding: 14px 16px 16px;
    border-radius: 18px;
  }

  .reward-popup-icon {
    width: 56px;
    height: 56px;
    font-size: 56px;
  }

  .reward-popup-icon.is-chest-open {
    width: 76px;
    height: 64px;
  }

  .reward-popup-title {
    font-size: clamp(18px, 4vw, 22px);
  }

  .reward-popup-text {
    margin: 4px 0 10px;
    font-size: 12px;
    line-height: 1.3;
  }
}

@media (max-width: 900px), (pointer: coarse) {
  .reward-popup-card {
    width: min(260px, var(--game-popup-card-max-width));
    min-width: 0;
    padding: 14px 16px 16px;
    border-radius: 18px;
  }

  .reward-popup-icon {
    width: 56px;
    height: 56px;
    font-size: 56px;
  }

  .reward-popup-icon.is-chest-open {
    width: 76px;
    height: 64px;
  }

  .reward-popup-title {
    font-size: clamp(18px, 4vw, 22px);
  }

  .reward-popup-text {
    margin: 4px 0 10px;
    font-size: 12px;
    line-height: 1.3;
  }
}

@media (max-width: 900px), (pointer: coarse) {
  body.is-mobile-fullbleed .pregame-map-bottom-cut,
  #gameRoot.is-mobile-fullbleed .pregame-map-bottom-cut {
    position: absolute;
    left: 0;
    right: 0;
    bottom: 0;
    z-index: 4;
    display: block;
    height: calc(env(safe-area-inset-bottom, 0px) + 70px);
    background:
      linear-gradient(180deg, rgba(0, 0, 0, 0) 0%, rgba(0, 0, 0, 0.72) 32%, rgba(0, 0, 0, 0.92) 100%),
      #000;
    box-shadow: 0 -14px 30px rgba(0, 0, 0, 0.32);
    pointer-events: none;
  }

  body.is-mobile-fullbleed .pregame-bottom-actions {
    bottom: calc(env(safe-area-inset-bottom, 0px) + 6px);
    z-index: 9;
  }

  body.is-mobile-fullbleed .pregame-upgrade-open-new-badge {
    top: -9px;
    right: 50%;
    min-height: 14px;
    padding: 0 5px;
    border-radius: 999px;
    font-size: 8px;
    line-height: 14px;
    transform: translateX(36px);
    box-shadow: 0 4px 10px rgba(127, 29, 29, 0.42);
  }

  .game-popup-overlay,
  .tutorial-popup,
  .reward-popup,
  .chest-popup {
    --mobile-popup-primary-height: 42px;
    --mobile-popup-secondary-height: 34px;
    --mobile-popup-primary-font: 17px;
    --mobile-popup-secondary-font: 12px;
    --mobile-popup-icon-size: 18px;
    --mobile-popup-radius: 12px;
  }

  .game-popup-overlay .primary-action-button,
  .tutorial-popup .primary-action-button,
  .reward-popup .primary-action-button {
    min-width: 148px;
    width: auto;
    max-width: 100%;
    height: var(--mobile-popup-primary-height);
    min-height: var(--mobile-popup-primary-height);
    padding: 0 16px;
    gap: 7px;
    border-radius: var(--mobile-popup-radius);
    font-size: var(--mobile-popup-primary-font);
    box-shadow:
      -1px -2px 1px 0 rgba(120, 53, 15, 0.55) inset,
      1px -3px 2px 0 rgba(254, 202, 22, 0.62) inset,
      0 2px 2px 0 rgba(255, 255, 255, 0.58) inset,
      0 5px 12px rgba(0, 0, 0, 0.18);
  }

  .game-popup-overlay .primary-action-button-icon,
  .game-popup-overlay .result-banner-button-icon,
  .tutorial-popup .primary-action-button-icon,
  .reward-popup .primary-action-button-icon {
    width: var(--mobile-popup-icon-size);
    height: var(--mobile-popup-icon-size);
    min-width: var(--mobile-popup-icon-size);
    min-height: var(--mobile-popup-icon-size);
    flex: 0 0 var(--mobile-popup-icon-size);
    font-size: var(--mobile-popup-icon-size);
  }

  .game-popup-overlay .secondary-action-button,
  .tutorial-popup .secondary-action-button,
  .reward-popup .secondary-action-button {
    height: var(--mobile-popup-secondary-height);
    min-height: var(--mobile-popup-secondary-height);
    min-width: 0;
    padding: 0 11px;
    gap: 5px;
    border-radius: 10px;
    font-size: var(--mobile-popup-secondary-font);
  }

  .game-popup-overlay .secondary-action-button::before,
  .tutorial-popup .secondary-action-button::before,
  .reward-popup .secondary-action-button::before {
    padding: 1px;
  }

  .game-popup-overlay .secondary-action-button-inline-icon,
  .tutorial-popup .secondary-action-button-inline-icon,
  .reward-popup .secondary-action-button-inline-icon {
    width: 15px;
    height: 15px;
    min-width: 15px;
    min-height: 15px;
    flex: 0 0 15px;
    font-size: 15px;
  }

  .settings-popup .primary-action-button,
  .result-banner-button.primary-action-button {
    width: min(172px, 100%);
    min-width: min(172px, 100%);
    max-width: min(172px, 100%);
  }

  .settings-popup-secondary,
  .result-banner .settings-popup-secondary {
    width: min(132px, 100%);
    min-width: min(132px, 100%);
    max-width: min(132px, 100%);
  }

  .game-knowledge-popup-card {
    width: min(720px, var(--game-popup-card-max-width));
    padding: 10px 12px 12px;
  }

  .knowledge-popup-browser {
    grid-template-columns: minmax(0, 1fr) minmax(164px, 196px);
    gap: 14px;
    align-items: start;
    overflow: visible;
  }

  .knowledge-popup-grid {
    max-height: min(56dvh, 288px);
    padding: 6px 8px 12px;
  }

  .pregame-knowledge-panel .pregame-upgrade-grid,
  .game-knowledge-popup .pregame-upgrade-grid {
    padding-left: 8px;
    padding-right: 8px;
  }

  .pregame-knowledge-panel .pregame-upgrade-detail,
  .game-knowledge-popup .knowledge-popup-detail {
    display: grid;
    grid-template-columns: 62px minmax(0, 1fr);
    grid-template-areas:
      "title title"
      "status status"
      "preview description"
      "stats stats";
    align-items: start;
    align-content: start;
    gap: 4px 10px;
    max-height: none;
    overflow: visible;
  }

  .pregame-knowledge-panel .pregame-upgrade-detail-title-row,
  .game-knowledge-popup .pregame-upgrade-detail-title-row {
    grid-area: title;
  }

  .pregame-knowledge-panel .pregame-upgrade-detail-status,
  .game-knowledge-popup .pregame-upgrade-detail-status {
    grid-area: status;
    font-size: 11px;
    line-height: 1.15;
  }

  .pregame-knowledge-panel .pregame-upgrade-detail-preview,
  .game-knowledge-popup .pregame-upgrade-detail-preview {
    grid-area: preview;
    width: 62px;
    height: 62px;
  }

  .pregame-knowledge-panel .pregame-upgrade-detail-preview .pregame-knowledge-preview-canvas,
  .game-knowledge-popup .pregame-upgrade-detail-preview .pregame-knowledge-preview-canvas {
    width: 62px;
    height: 62px;
  }

  .pregame-knowledge-panel .pregame-upgrade-detail-description,
  .game-knowledge-popup .pregame-upgrade-detail-description {
    grid-area: description;
    max-width: none;
    font-size: 11px;
    line-height: 1.22;
  }

  .pregame-knowledge-panel .pregame-knowledge-detail-stats,
  .game-knowledge-popup .pregame-knowledge-detail-stats {
    grid-area: stats;
    width: 100%;
    gap: 4px;
  }

  .pregame-knowledge-panel .pregame-knowledge-detail-stats .stat-row,
  .game-knowledge-popup .pregame-knowledge-detail-stats .stat-row {
    gap: 6px;
    font-size: 10px;
  }

  .pregame-upgrade-tile-frame {
    inset: -3px;
  }

  .pregame-upgrade-tile.is-selected .pregame-upgrade-tile-frame {
    border-color: rgba(255, 255, 255, 0.86);
    box-shadow:
      0 0 0 1px rgba(15, 23, 42, 0.68),
      0 0 12px rgba(255, 255, 255, 0.16);
  }

  .context-menu:not(.is-build-radial) {
    min-width: 204px;
    max-width: min(238px, calc(100dvw - 24px));
    max-height: none;
    border-radius: 11px;
    padding: 10px 11px;
    overflow: visible;
  }

  .context-menu:not(.is-build-radial) .context-menu-header {
    gap: 8px;
    padding-bottom: 6px;
    margin-bottom: 6px;
    border-bottom: 1px solid rgba(148, 163, 184, 0.14);
  }

  .context-menu:not(.is-build-radial) .context-menu-title {
    font-size: 13px;
    line-height: 1.08;
  }

  .context-menu:not(.is-build-radial) .context-menu-subtitle {
    margin-top: 0;
  }

  .context-menu:not(.is-build-radial) .context-menu-info,
  .context-menu:not(.is-build-radial) .context-menu-stats,
  .context-menu:not(.is-build-radial) .context-menu-message {
    margin-top: 7px;
  }

  .context-menu:not(.is-build-radial) .context-menu-stats {
    gap: 5px;
  }

  .context-menu:not(.is-build-radial) .context-menu-stats .stat-row {
    gap: 8px;
  }

  .context-menu:not(.is-build-radial) .context-menu-actions {
    margin-top: 8px;
    padding-top: 7px;
    border-top: 1px solid rgba(148, 163, 184, 0.12);
  }

  .context-menu:not(.is-build-radial) .context-button {
    min-height: 28px;
    padding: 6px 8px;
    border-radius: 7px;
    font-size: 11px;
  }

  .context-menu:not(.is-build-radial) #contextUpgrade {
    min-height: 30px;
    font-size: 11px;
  }

  .context-menu:not(.is-build-radial) .context-button-sub {
    font-size: 9px;
  }

  .context-menu:not(.is-build-radial) .context-button-cost-icon {
    width: 10px;
    height: 10px;
    flex: 0 0 10px;
    font-size: 10px;
  }

  .context-menu.is-build-radial .context-button {
    width: 94px;
    min-height: 92px;
    overflow: visible;
    border-radius: 10px;
    padding: 33px 8px 10px;
    gap: 4px;
    background: rgba(3, 10, 20, 0.84);
    box-shadow: 0 8px 18px rgba(0, 0, 0, 0.34);
  }

  .context-menu.is-build-radial .context-build-card {
    width: 94px;
    gap: 6px;
    overflow: visible;
  }

  .context-menu.is-build-radial .context-button-label {
    gap: 4px;
  }

  .context-menu.is-build-radial .context-button-label > span:last-child {
    font-size: 11.5px;
    line-height: 1;
  }

  .context-menu.is-build-radial .context-button-icon {
    width: 56px;
    height: 56px;
    flex: 0 0 56px;
    aspect-ratio: 1 / 1;
    margin: -45px 0 4px;
    border-radius: 0;
    background-color: transparent;
    background-size: contain !important;
    background-repeat: no-repeat;
    background-position: center;
    box-shadow: none;
  }

  .context-menu.is-build-radial .context-button-role-chips {
    display: none;
  }

  .context-menu.is-build-radial .context-button-role-chips.has-role-chips {
    display: flex !important;
    gap: 5px;
    min-height: 10px;
    margin: 0;
  }

  .context-menu.is-build-radial .context-role-chip {
    font-size: 9.5px;
    line-height: 1;
    letter-spacing: 0;
  }

  .context-menu.is-build-radial .context-button-sub {
    justify-content: center;
    width: 100%;
    padding-inline: 4px;
    margin: 3px 0 0;
    gap: 3px;
    font-size: 11px;
    line-height: 1;
  }

  .context-menu.is-build-radial .context-button-cost-icon {
    width: 10px;
    height: 10px;
    flex: 0 0 10px;
    font-size: 10px;
  }

  .context-menu.is-build-radial .context-build-cancel-button {
    width: 94px;
    min-height: 24px;
    border-radius: 7px;
    font-size: 14px;
  }
}

@media (min-width: 761px) and (max-height: 520px) and (pointer: coarse) {
  .pregame-upgrade-panel {
    padding:
      calc(env(safe-area-inset-top, 0px) + 36px)
      calc(env(safe-area-inset-right, 0px) + 10px)
      calc(env(safe-area-inset-bottom, 0px) + 76px)
      calc(env(safe-area-inset-left, 0px) + 10px);
  }

  .pregame-upgrade-card {
    gap: 6px;
  }

  .pregame-knowledge-panel .pregame-upgrade-card {
    gap: 8px;
  }

  .pregame-upgrade-head {
    gap: 6px;
  }

  .pregame-upgrade-head-icon {
    width: 30px;
    height: 30px;
    min-width: 30px;
    min-height: 30px;
  }

  .pregame-upgrade-title {
    font-size: 18px;
    line-height: 1;
  }

  .pregame-upgrade-stars,
  .pregame-knowledge-subtitle {
    font-size: 11px;
    line-height: 1.1;
  }

  .pregame-upgrade-browser,
  .knowledge-popup-browser {
    grid-template-columns: minmax(0, 1fr) minmax(160px, 196px);
    gap: 14px;
    align-items: start;
  }

  .pregame-upgrade-grid,
  .pregame-upgrade-sections,
  .knowledge-popup-grid {
    max-height: calc(100dvh - env(safe-area-inset-top, 0px) - env(safe-area-inset-bottom, 0px) - 132px);
    padding: 6px 8px 12px;
  }

  .pregame-upgrade-section {
    grid-template-columns: 74px minmax(0, 1fr);
    gap: 8px;
  }

  .pregame-upgrade-section-title {
    font-size: 11px;
    line-height: 1.08;
  }

  .pregame-upgrade-section-grid {
    grid-template-columns: repeat(auto-fill, minmax(50px, 50px));
    gap: 8px;
  }

  .pregame-upgrade-tile {
    width: 50px;
    height: 50px;
  }

  .pregame-upgrade-detail {
    max-height: calc(100dvh - env(safe-area-inset-top, 0px) - env(safe-area-inset-bottom, 0px) - 132px);
    gap: 7px;
    padding-bottom: 8px;
    overflow: auto;
  }

  .pregame-knowledge-panel .pregame-upgrade-detail,
  .game-knowledge-popup .knowledge-popup-detail {
    overflow: visible;
  }

  .pregame-upgrade-detail-title {
    font-size: 14px;
    line-height: 1.08;
  }

  .pregame-upgrade-detail-preview {
    width: 78px;
    height: 78px;
  }

  .pregame-upgrade-detail-preview .pregame-knowledge-preview-canvas {
    width: 78px;
    height: 78px;
  }

  .pregame-upgrade-detail-description,
  .pregame-upgrade-detail-description.is-locked {
    font-size: 11px;
    line-height: 1.25;
  }

  .pregame-upgrade-detail-button {
    min-width: 112px;
    min-height: 34px;
    padding: 0 10px;
    border-radius: 10px;
    border-width: 1px;
    font-size: 11px;
  }

  .pregame-upgrade-detail-button.is-available {
    box-shadow:
      -1px -1px 0 0 rgba(120, 53, 15, 0.62) inset,
      1px -2px 1px 0 rgba(254, 202, 22, 0.48) inset,
      0 1px 1px 0 rgba(255, 255, 255, 0.42) inset;
    text-shadow: 0 1px 0 rgba(0, 0, 0, 0.26);
  }

  .pregame-upgrade-detail-button-cost-icon {
    width: 12px;
    height: 12px;
    min-width: 12px;
    min-height: 12px;
    font-size: 12px;
  }

  .result-banner.is-madness-layout .result-banner-card,
  .result-banner.has-analytics-aside .result-banner-card {
    width: min(824px, calc(100dvw - 16px));
    max-height: calc(100dvh - 16px);
    padding: 8px;
    overflow: visible;
  }

  .result-banner.is-madness-layout .result-banner-main-layout,
  .result-banner.has-analytics-aside .result-banner-main-layout {
    grid-template-columns: minmax(218px, 254px) minmax(0, 1fr);
    gap: 12px;
    align-items: start;
  }

  .result-banner.is-madness-layout .result-banner-summary-panel,
  .result-banner.has-analytics-aside .result-banner-summary-panel {
    padding: 12px 12px 11px;
    border-radius: 16px;
    gap: 6px;
  }

  .result-banner.is-madness-layout .result-banner-madness-aside,
  .result-banner.has-analytics-aside .result-banner-madness-aside {
    display: flex;
    gap: 10px;
    max-height: none;
    overflow: visible;
    padding: 0;
  }

  .result-banner-madness-section,
  .result-banner-stats-subsection,
  .result-banner-upgrade-feed-section {
    gap: 7px;
  }

  .result-banner-madness-section-title,
  .result-banner-upgrade-feed-title {
    font-size: 15px;
    line-height: 1;
  }

  .result-banner-stats-subtitle {
    font-size: 12px;
    line-height: 1;
  }

  .result-banner-upgrade-feed {
    gap: 10px;
  }

  .result-banner-upgrade-feed-list.is-progress,
  .result-banner-madness-perk-cards,
  .result-banner-analytics-list.is-visible,
  .result-banner-madness-kills.is-visible {
    grid-template-columns: repeat(auto-fit, minmax(132px, 1fr));
    gap: 6px;
  }

  .result-banner-upgrade-progress-row,
  .result-banner-madness-perk-card,
  .result-banner-analytics-row,
  .result-banner-madness-kill-row,
  .result-banner-analytics-empty,
  .result-banner-madness-empty {
    min-height: 42px;
    padding: 7px 8px;
    border-radius: 8px;
  }

  .result-banner-madness-perk-card {
    gap: 8px;
    background: rgba(0, 0, 0, 0.94);
    box-shadow: inset 0 0 0 1px rgba(255, 255, 255, 0.08);
  }

  .result-banner-upgrade-progress-icon,
  .result-banner-madness-perk-icon-stack.is-compact,
  .result-banner-analytics-icon,
  .result-banner-madness-kill-icon {
    width: 28px !important;
    height: 28px !important;
    min-width: 28px;
    min-height: 28px;
    aspect-ratio: 1 / 1;
    border-radius: 7px;
    background-size: 20px 20px;
  }

  .result-banner-upgrade-progress-label,
  .result-banner-madness-perk-title,
  .result-banner-madness-perk-level,
  .result-banner-analytics-value,
  .result-banner-madness-kill-count {
    font-size: 13px;
    line-height: 1.1;
  }

  .result-banner-upgrade-progress-hint,
  .result-banner-madness-perk-description,
  .result-banner-analytics-label,
  .result-banner-madness-kill-label {
    font-size: 9px;
    line-height: 1.12;
  }

  .result-banner-madness-perks.is-visible {
    gap: 10px;
  }

  .result-banner-madness-perk-group {
    gap: 6px;
  }

  .result-banner-madness-perk-group-title {
    font-size: 12px;
  }

  .result-banner-madness-perk-content {
    gap: 4px;
  }

  .result-banner-madness-perk-header {
    gap: 8px;
  }

  .result-banner-upgrade-progress-footer {
    gap: 6px;
  }

  .result-banner-upgrade-progress-bar {
    height: 7px;
  }

  .result-banner-upgrade-progress-values {
    flex-basis: 46px;
    width: 46px;
    gap: 3px;
  }

  .result-banner-upgrade-progress-value-current,
  .result-banner-upgrade-progress-value-delta {
    font-size: 10px;
  }

  .result-banner-upgrade-progress-ready-button {
    width: 58px;
    min-width: 58px;
    max-width: 58px;
    min-height: 24px;
    padding: 0 6px;
    font-size: 10px;
  }

  .result-banner-action-cost {
    gap: 4px;
    margin-left: 8px;
    font-size: 14px;
  }

  .result-banner-action-cost-icon {
    --result-banner-action-cost-icon-size: 20px;
    width: var(--result-banner-action-cost-icon-size);
    height: var(--result-banner-action-cost-icon-size);
    min-width: var(--result-banner-action-cost-icon-size);
    min-height: var(--result-banner-action-cost-icon-size);
    flex: 0 0 var(--result-banner-action-cost-icon-size);
    font-size: var(--result-banner-action-cost-icon-size);
  }
}

@media (min-width: 761px) {
  .game-knowledge-popup .knowledge-popup-browser {
    align-items: stretch;
    overflow: hidden;
  }

  .game-knowledge-popup .knowledge-popup-grid,
  .game-knowledge-popup .knowledge-popup-detail {
    height: 100%;
    max-height: 100%;
    overflow: auto;
    overscroll-behavior: contain;
    -webkit-overflow-scrolling: touch;
  }
}

@media (min-width: 761px) and (max-width: 900px),
  (min-width: 761px) and (max-height: 520px) and (pointer: coarse) {
  .game-knowledge-popup-card {
    width: min(660px, var(--game-popup-card-max-width));
    height: auto;
    min-height: 0;
    max-height: calc(100dvh - var(--game-popup-safe-top) - var(--game-popup-safe-bottom));
    padding: 10px 12px 12px;
  }

  .game-knowledge-popup .knowledge-popup-shell {
    height: auto;
    min-height: 0;
    max-height: none;
    gap: 8px;
    overflow: visible;
  }

  .game-knowledge-popup .knowledge-popup-browser {
    width: 100%;
    height: auto;
    max-height: none;
    grid-template-columns: minmax(0, 1fr) minmax(220px, 246px);
    gap: 14px;
    align-items: start;
    overflow: visible;
  }

  .game-knowledge-popup .knowledge-popup-grid {
    height: auto;
    max-height: min(52dvh, 246px);
    overflow: auto;
  }

  .game-knowledge-popup .knowledge-popup-detail {
    height: auto;
    max-height: none;
    grid-template-columns: 72px minmax(0, 1fr);
    gap: 4px 10px;
    overflow: visible;
  }

  .game-knowledge-popup .pregame-upgrade-detail-preview {
    width: 72px;
    height: 72px;
  }

  .game-knowledge-popup .pregame-upgrade-detail-preview .pregame-knowledge-preview-canvas,
  .game-knowledge-popup .pregame-upgrade-detail-icon {
    width: 72px;
    height: 72px;
  }
}

@media (max-width: 900px), (pointer: coarse) {
  body.is-mobile-fullbleed,
  #gameRoot.is-mobile-fullbleed {
    --pregame-mobile-bottom-cut-height: 46px;
  }

  body.is-mobile-fullbleed .pregame-map-bottom-cut,
  #gameRoot.is-mobile-fullbleed .pregame-map-bottom-cut {
    height: calc(env(safe-area-inset-bottom, 0px) + var(--pregame-mobile-bottom-cut-height));
    background:
      linear-gradient(180deg, rgba(0, 0, 0, 0) 0%, rgba(0, 0, 0, 0.72) 34%, rgba(0, 0, 0, 0.96) 100%),
      #000;
    box-shadow: 0 -10px 22px rgba(0, 0, 0, 0.32);
  }

  body.is-mobile-fullbleed .pregame-upgrade-panel,
  #gameRoot.is-mobile-fullbleed .pregame-upgrade-panel {
    padding-bottom: calc(env(safe-area-inset-bottom, 0px) + var(--pregame-mobile-bottom-cut-height));
  }

  body.is-mobile-fullbleed .pregame-screen:is(.is-upgrade-mode, .is-knowledge-mode) .pregame-upgrade-browser,
  #gameRoot.is-mobile-fullbleed .pregame-screen:is(.is-upgrade-mode, .is-knowledge-mode) .pregame-upgrade-browser {
    align-items: stretch;
  }

  body.is-mobile-fullbleed .pregame-screen:is(.is-upgrade-mode, .is-knowledge-mode) .pregame-upgrade-grid,
  #gameRoot.is-mobile-fullbleed .pregame-screen:is(.is-upgrade-mode, .is-knowledge-mode) .pregame-upgrade-grid {
    height: 100%;
    max-height: none;
  }

  body.is-mobile-fullbleed .pregame-screen:is(.is-upgrade-mode, .is-knowledge-mode) .pregame-upgrade-detail,
  #gameRoot.is-mobile-fullbleed .pregame-screen:is(.is-upgrade-mode, .is-knowledge-mode) .pregame-upgrade-detail {
    max-height: none;
  }

  body.is-mobile-fullbleed .pregame-bottom-actions {
    bottom: calc(env(safe-area-inset-bottom, 0px) + 4px);
  }

  body.is-mobile-fullbleed .pregame-chest-button,
  #gameRoot.is-mobile-fullbleed .pregame-chest-button {
    left: calc(env(safe-area-inset-left, 0px) + 12px);
    bottom: calc(env(safe-area-inset-bottom, 0px) + 54px);
    z-index: 8;
    gap: calc(5px * var(--ui-scale));
    font-size: calc(14px * var(--ui-scale));
    line-height: 1;
  }

  body.is-mobile-fullbleed .pregame-chest-icon,
  #gameRoot.is-mobile-fullbleed .pregame-chest-icon {
    width: calc(102px * var(--ui-scale));
    height: calc(86px * var(--ui-scale));
  }

  .hud-wave-cooldown {
    bottom: calc(var(--hud-edge-bottom) + 2px);
    width: calc(74px * var(--ui-scale));
    height: calc(74px * var(--ui-scale));
    background: rgba(17, 24, 34, 0.94);
    box-shadow:
      inset 0 0 0 1px rgba(255, 255, 255, 0.06),
      0 10px 20px rgba(0, 0, 0, 0.28);
  }

  .hud-wave-cooldown-ring,
  .hud-wave-cooldown-progress {
    width: calc(74px * var(--ui-scale));
    height: calc(74px * var(--ui-scale));
  }

  .hud-wave-cooldown-track,
  .hud-wave-cooldown-bar {
    stroke-width: 4;
  }

  .hud-wave-launch-button {
    width: calc(34px * var(--ui-scale));
    height: calc(34px * var(--ui-scale));
  }

  .context-menu:not(.is-build-radial) {
    font-family: var(--font-family-ui-base);
  }

  .context-menu:not(.is-build-radial):not(.is-build-menu) {
    min-width: 212px;
    max-width: min(246px, calc(100dvw - 24px));
    padding: 10px 11px 11px;
  }

  .context-menu:not(.is-build-radial):not(.is-build-menu) .context-menu-header {
    align-items: center;
    min-height: 25px;
    gap: 8px;
    padding-bottom: 6px;
    margin-bottom: 6px;
  }

  .context-menu:not(.is-build-radial):not(.is-build-menu) .context-menu-title {
    display: flex;
    align-items: center;
    min-height: 24px;
    font-family: var(--font-family-ui-base);
    font-size: 13px;
    font-weight: var(--font-weight-ui-heavy);
    line-height: 1.05;
  }

  .context-menu:not(.is-build-radial) .context-sell-icon-button {
    width: 24px;
    height: 24px;
    align-self: center;
    border-radius: 7px;
  }

  .context-menu:not(.is-build-radial) .context-sell-icon {
    width: 13px;
    height: 13px;
    font-size: 11px;
  }

  .context-menu:not(.is-build-radial) .context-button,
  .context-menu:not(.is-build-radial) #contextUpgrade,
  .context-menu:not(.is-build-radial) .context-button-sub,
  .context-menu:not(.is-build-radial) .context-role-chip,
  .context-menu:not(.is-build-radial) .stat-row {
    font-family: var(--font-family-ui-base);
    letter-spacing: 0;
  }

  .context-menu:not(.is-build-radial) .context-button,
  .context-menu:not(.is-build-radial) #contextUpgrade {
    font-size: 11px;
    font-weight: var(--font-weight-ui-heavy);
  }

  .context-menu:not(.is-build-radial) .context-button-sub {
    font-size: 10px;
    font-weight: var(--font-weight-ui-strong);
    line-height: 1;
  }

  .context-menu:not(.is-build-radial) .context-role-chip {
    font-size: 11px;
    font-weight: var(--font-weight-ui-heavy);
    line-height: 1;
  }

  .context-menu:not(.is-build-radial) .context-button-cost-icon {
    width: 11px;
    height: 11px;
    flex-basis: 11px;
    font-size: 11px;
  }

  .context-menu.is-build-menu:not(.is-build-radial) {
    min-width: 236px;
    max-width: min(278px, calc(100dvw - 24px));
    padding: 8px;
    border-radius: 12px;
    overflow: visible;
  }

  .context-menu.is-build-menu:not(.is-build-radial) .context-menu-header,
  .context-menu.is-build-menu:not(.is-build-radial) .context-menu-subtitle,
  .context-menu.is-build-menu:not(.is-build-radial) .context-menu-info,
  .context-menu.is-build-menu:not(.is-build-radial) .context-menu-stats,
  .context-menu.is-build-menu:not(.is-build-radial) .context-menu-message,
  .context-menu.is-build-menu:not(.is-build-radial) #contextUpgrade,
  .context-menu.is-build-menu:not(.is-build-radial) #contextSellIcon {
    display: none;
  }

  .context-menu.is-build-menu:not(.is-build-radial) .context-menu-actions {
    margin: 0;
    padding: 0;
    border: 0;
    gap: 6px;
  }

  .context-menu.is-build-menu:not(.is-build-radial) .context-button {
    min-height: 42px;
    padding: 6px 9px;
    gap: 8px;
    border-radius: 9px;
    font-size: 13px;
    line-height: 1;
  }

  .context-menu.is-build-menu:not(.is-build-radial) .context-button-icon {
    width: 30px;
    height: 30px;
    flex: 0 0 30px;
    border-radius: 7px;
  }

  .context-menu.is-build-menu:not(.is-build-radial) .context-button-label {
    gap: 8px;
    min-width: 0;
  }

  .context-menu.is-build-menu:not(.is-build-radial) .context-button-label > span:last-child {
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
  }

  .context-menu.is-build-menu:not(.is-build-radial) .context-button-role-chips.has-role-chips {
    display: none !important;
  }

  .context-menu.is-build-menu:not(.is-build-radial) .context-button-sub {
    font-size: 11px;
  }

  .context-menu.is-build-radial .context-button {
    width: 94px;
    min-height: 92px;
    overflow: visible;
    padding: 33px 8px 10px;
    gap: 4px;
    border-radius: 10px;
    background: rgba(3, 10, 20, 0.84);
    box-shadow: 0 8px 18px rgba(0, 0, 0, 0.34);
  }

  .context-menu.is-build-radial .context-build-card,
  .context-menu.is-build-radial .context-build-cancel-button {
    width: 94px;
    overflow: visible;
  }

  .context-menu.is-build-radial .context-button-label {
    flex-direction: column;
    gap: 4px;
    width: 100%;
    min-width: 0;
  }

  .context-menu.is-build-radial .context-button-label > span:last-child {
    max-width: 100%;
    overflow: hidden;
    text-align: center;
    text-overflow: ellipsis;
    white-space: nowrap;
    font-size: 11.5px;
    line-height: 1;
  }

  .context-menu.is-build-radial .context-button-icon {
    width: 56px;
    height: 56px;
    flex: 0 0 56px;
    aspect-ratio: 1 / 1;
    margin: -45px 0 4px;
    border-radius: 0;
    background-color: transparent;
    background-size: contain !important;
    background-repeat: no-repeat;
    background-position: center;
    box-shadow: none;
  }

  .context-menu.is-build-radial .context-button-role-chips.has-role-chips {
    display: flex !important;
    gap: 5px;
    min-height: 10px;
    margin: 0;
  }

  .context-menu.is-build-radial .context-role-chip {
    font-size: 9.5px;
    line-height: 1;
    letter-spacing: 0;
  }

  .context-menu.is-build-radial .context-button-sub {
    box-sizing: border-box;
    justify-content: center;
    width: 100%;
    padding-inline: 4px;
    margin: 3px 0 0;
    gap: 3px;
    font-family: var(--font-family-ui-base);
    font-size: 11px;
    font-weight: var(--font-weight-ui-heavy);
    line-height: 1;
  }

  .context-menu.is-build-radial .context-button-cost-icon {
    width: 11px;
    height: 11px;
    flex: 0 0 11px;
    font-size: 11px;
  }

  .pregame-knowledge-panel .pregame-upgrade-browser {
    grid-template-columns: minmax(0, 1fr) minmax(238px, 286px);
    gap: 16px;
  }

  .pregame-knowledge-panel .pregame-upgrade-grid {
    max-height: calc(100dvh - env(safe-area-inset-top, 0px) - env(safe-area-inset-bottom, 0px) - 124px);
  }

  .pregame-knowledge-panel .pregame-upgrade-section {
    grid-template-columns: 70px minmax(0, 1fr);
    gap: 8px;
  }

  .pregame-knowledge-panel .pregame-upgrade-section-grid {
    grid-template-columns: repeat(auto-fill, minmax(48px, 48px));
    gap: 8px;
  }

  .pregame-knowledge-panel .pregame-upgrade-tile {
    width: 48px;
    height: 48px;
  }

  .game-knowledge-popup-card {
    width: min(700px, var(--game-popup-card-max-width));
  }

  .game-knowledge-popup .knowledge-popup-browser {
    grid-template-columns: minmax(0, 1fr) minmax(238px, 286px);
    gap: 16px;
  }

  .game-knowledge-popup .knowledge-popup-grid {
    max-height: min(54dvh, 268px);
  }

  .pregame-knowledge-panel .pregame-upgrade-detail,
  .game-knowledge-popup .knowledge-popup-detail {
    grid-template-columns: 82px minmax(0, 1fr);
    gap: 5px 12px;
  }

  .pregame-knowledge-panel .pregame-upgrade-detail-title,
  .game-knowledge-popup .pregame-upgrade-detail-title {
    font-size: 15px;
    line-height: 1.04;
  }

  .pregame-knowledge-panel .pregame-upgrade-detail-status,
  .game-knowledge-popup .pregame-upgrade-detail-status {
    font-size: 9px;
    line-height: 1.1;
  }

  .pregame-knowledge-panel .pregame-upgrade-detail-preview,
  .game-knowledge-popup .pregame-upgrade-detail-preview {
    width: 82px;
    height: 82px;
  }

  .pregame-knowledge-panel .pregame-upgrade-detail-preview .pregame-knowledge-preview-canvas,
  .pregame-knowledge-panel .pregame-upgrade-detail-icon,
  .game-knowledge-popup .pregame-upgrade-detail-preview .pregame-knowledge-preview-canvas,
  .game-knowledge-popup .pregame-upgrade-detail-icon {
    width: 82px;
    height: 82px;
  }

  .pregame-knowledge-panel .pregame-upgrade-detail-description,
  .game-knowledge-popup .pregame-upgrade-detail-description {
    font-size: 10px;
    line-height: 1.2;
  }

  .pregame-knowledge-panel .pregame-knowledge-detail-stats,
  .game-knowledge-popup .pregame-knowledge-detail-stats {
    gap: 3px;
    width: 100%;
    max-width: 100%;
  }

  .pregame-knowledge-panel .pregame-knowledge-detail-stats .stat-row,
  .game-knowledge-popup .pregame-knowledge-detail-stats .stat-row {
    min-height: 15px;
    gap: 5px;
    font-family: var(--font-family-ui-base);
    font-size: 9.5px;
    font-weight: var(--font-weight-ui-strong);
    line-height: 1.05;
  }

  .pregame-knowledge-panel .pregame-knowledge-detail-stats .stat-bar-group,
  .game-knowledge-popup .pregame-knowledge-detail-stats .stat-bar-group {
    gap: 2px;
  }

  .pregame-knowledge-panel .pregame-knowledge-detail-stats .stat-bar,
  .game-knowledge-popup .pregame-knowledge-detail-stats .stat-bar {
    width: 4px;
    height: 12px;
    border-radius: 2px;
  }

  .pregame-knowledge-panel .pregame-knowledge-detail-stats .stat-row-subtitle,
  .game-knowledge-popup .pregame-knowledge-detail-stats .stat-row-subtitle {
    margin-left: 3px;
    font-size: 8px;
    line-height: 1;
  }

  .pregame-knowledge-panel .pregame-knowledge-detail-stats .stat-chip-group,
  .game-knowledge-popup .pregame-knowledge-detail-stats .stat-chip-group {
    gap: 3px;
  }

  .pregame-knowledge-panel .pregame-knowledge-detail-stats .stat-chip,
  .game-knowledge-popup .pregame-knowledge-detail-stats .stat-chip {
    padding: 1px 5px;
    font-size: 8px;
    font-weight: var(--font-weight-ui-heavy);
    line-height: 1.2;
  }

  .game-popup-overlay .primary-action-button,
  .tutorial-popup .primary-action-button,
  .reward-popup .primary-action-button,
  .result-banner-button.primary-action-button {
    text-shadow: 0 1px 1px rgba(0, 0, 0, 0.22);
  }

  .settings-popup-layout {
    width: min(340px, calc(100dvw - 24px));
  }

  .settings-popup-panel {
    width: min(340px, calc(100dvw - 24px));
  }

  .settings-popup-actions {
    width: min(248px, calc(100% - 44px));
    padding: 70px 0 24px;
    gap: 12px;
  }

  .settings-popup .primary-action-button {
    width: 100%;
    min-width: 100%;
    max-width: 100%;
    height: 46px;
    min-height: 46px;
    font-size: 18px;
  }

  .settings-popup-secondary {
    width: 100%;
    min-width: 100%;
    max-width: 100%;
    height: 38px;
    min-height: 38px;
    font-size: 13px;
  }
}

@media (min-width: 761px) and (max-height: 520px) and (pointer: coarse) {
  .tutorial-popup-card {
    width: min(650px, var(--game-popup-card-max-width));
    display: grid;
    grid-template-columns: minmax(190px, 0.78fr) minmax(260px, 1fr);
    grid-template-areas:
      "hero visual"
      "title visual"
      "text visual"
      "actions visual";
    align-items: center;
    column-gap: 28px;
    row-gap: 9px;
    padding: 24px 30px 26px;
    text-align: left;
    overflow: hidden;
  }

  .tutorial-popup-hero {
    grid-area: hero;
    justify-content: flex-start;
    margin: 0;
  }

  .tutorial-popup-title {
    grid-area: title;
    margin: 0;
    font-size: 26px;
    line-height: 1.04;
  }

  .tutorial-popup-text,
  .tutorial-popup.is-first-crystal-combine .tutorial-popup-text {
    grid-area: text;
    margin: 0;
    max-width: none;
    font-size: 13px;
    line-height: 1.28;
  }

  .tutorial-popup-visual {
    grid-area: visual;
    min-height: 150px;
    max-height: 176px;
    margin: 0;
    padding: 0;
    overflow: visible;
  }

  .tutorial-popup-visual-combine,
  .tutorial-popup-visual-limit,
  .tutorial-popup-visual-upgrade {
    align-items: center;
    justify-content: center;
    min-height: 150px;
  }

  .tutorial-popup-visual-image-combine,
  .tutorial-popup-visual-image-limit,
  .tutorial-popup-visual-image-upgrade {
    width: auto;
    max-width: 100%;
    max-height: 170px;
  }

  .tutorial-popup-button {
    grid-area: actions;
    justify-self: start;
    min-width: 152px;
    height: 40px;
    min-height: 40px;
    font-size: 17px;
  }

  .special-unlock-popup .tutorial-popup-card {
    width: min(430px, var(--game-popup-card-max-width));
    display: flex;
    flex-direction: column;
    align-items: flex-start;
    gap: 9px;
    padding: 22px 28px 24px;
    text-align: left;
    overflow: hidden;
  }

  .special-unlock-popup .tutorial-popup-hero {
    margin: 0 0 2px;
  }

  .special-unlock-popup .tutorial-popup-title,
  .special-unlock-popup .tutorial-popup-text {
    width: 100%;
  }

  .special-unlock-popup-actions {
    grid-area: actions;
    width: 100%;
    justify-content: flex-start;
    gap: 10px;
    margin-top: 2px;
  }

  .special-unlock-popup-actions .popup-secondary-button {
    flex: 0 0 auto;
    min-width: 70px;
  }

  .special-unlock-popup-actions .primary-action-button {
    flex: 1 1 auto;
    min-width: 148px;
  }

  .new-enemy-popup-card {
    width: min(660px, calc(100dvw - 24px));
    max-width: min(660px, calc(100dvw - 24px));
    display: grid;
    grid-template-columns: minmax(170px, 0.72fr) minmax(360px, 1.28fr);
    grid-template-areas:
      "kicker detail"
      "button detail";
    align-items: center;
    column-gap: 18px;
    row-gap: 12px;
    padding: 16px 18px;
    overflow: hidden;
  }

  .new-enemy-popup-kicker {
    grid-area: kicker;
    margin: 0;
    padding-right: 38px;
    font-size: 20px;
    line-height: 1.05;
  }

  .new-enemy-popup-detail {
    grid-area: detail;
    min-height: 0;
    max-height: 100%;
    display: grid;
    grid-template-columns: minmax(142px, 1fr) 188px;
    grid-template-areas:
      "title preview"
      "status preview"
      "description preview"
      "stats preview";
    align-items: center;
    column-gap: 14px;
    row-gap: 5px;
    overflow: hidden;
  }

  .new-enemy-popup-detail .pregame-upgrade-detail-title-row {
    grid-area: title;
    margin: 0;
  }

  .new-enemy-popup-detail .pregame-upgrade-detail-title {
    font-size: 22px;
    line-height: 1.05;
  }

  .new-enemy-popup-detail .pregame-upgrade-detail-status {
    grid-area: status;
    margin: 0;
    font-size: 11px;
    line-height: 1;
  }

  .new-enemy-popup-detail .pregame-upgrade-detail-preview {
    grid-area: preview;
    justify-self: center;
    align-self: center;
    width: 188px;
    height: 188px;
    margin: 0;
  }

  .new-enemy-popup-detail .pregame-upgrade-detail-preview .pregame-knowledge-preview-canvas {
    width: 188px;
    height: 188px;
  }

  .new-enemy-popup-detail .pregame-upgrade-detail-description {
    grid-area: description;
    margin: 0;
    font-size: 12px;
    line-height: 1.22;
  }

  .new-enemy-popup-detail .pregame-knowledge-detail-stats {
    grid-area: stats;
    gap: 3px;
    margin: 0;
  }

  .new-enemy-popup-detail .pregame-knowledge-detail-stats .stat-row {
    min-height: 15px;
    gap: 5px;
    font-size: 9.5px;
    line-height: 1.05;
  }

  .new-enemy-popup-detail .pregame-knowledge-detail-stats .stat-bar-group {
    gap: 2px;
  }

  .new-enemy-popup-detail .pregame-knowledge-detail-stats .stat-bar {
    width: 4px;
    height: 12px;
  }

  .new-enemy-popup-card .primary-action-button {
    grid-area: button;
    justify-self: start;
    width: 164px;
    min-width: 164px;
    max-width: 164px;
    height: 40px;
    min-height: 40px;
    font-size: 17px;
  }

  .result-banner.is-madness-layout .result-banner-card,
  .result-banner.has-analytics-aside .result-banner-card {
    width: min(900px, calc(100dvw - 16px));
    padding: 10px;
  }

  .result-banner.is-madness-layout .result-banner-main-layout,
  .result-banner.has-analytics-aside .result-banner-main-layout {
    grid-template-columns: minmax(228px, 270px) minmax(0, 1fr);
    gap: 14px;
  }

  .result-banner.is-madness-layout .result-banner-summary-panel,
  .result-banner.has-analytics-aside .result-banner-summary-panel {
    padding: 16px 15px 15px;
    gap: 8px;
  }

  .result-banner.is-madness-layout .result-banner-madness-aside,
  .result-banner.has-analytics-aside .result-banner-madness-aside {
    max-height: none;
    overflow: visible;
  }

  .result-banner-upgrade-feed-list.is-progress,
  .result-banner-madness-perk-cards {
    grid-template-columns: repeat(2, minmax(190px, 1fr));
    gap: 8px;
    max-height: none;
    overflow: visible;
  }

  .result-banner-upgrade-feed-list.is-progress::-webkit-scrollbar {
    display: none;
  }

  .result-banner-upgrade-progress-row,
  .result-banner-madness-perk-card {
    min-height: 72px;
    gap: 10px;
    padding: 10px;
    border-radius: 10px;
  }

  .result-banner-madness-perk-card {
    background: rgba(0, 0, 0, 0.94);
    box-shadow: inset 0 0 0 1px rgba(255, 255, 255, 0.08);
  }

  .result-banner-upgrade-progress-icon,
  .result-banner-madness-perk-icon-stack.is-compact {
    width: 38px !important;
    height: 38px !important;
    min-width: 38px;
    min-height: 38px;
    aspect-ratio: 1 / 1;
    flex-basis: 38px;
    border-radius: 8px;
    background-size: 28px 28px;
  }

  .result-banner-upgrade-progress-label,
  .result-banner-madness-perk-title,
  .result-banner-madness-perk-level {
    font-size: 15px;
    line-height: 1.08;
  }

  .result-banner-upgrade-progress-hint,
  .result-banner-madness-perk-description {
    font-size: 10px;
    line-height: 1.18;
  }

  .result-banner-madness-perks.is-visible {
    gap: 12px;
  }

  .result-banner-madness-perk-group {
    gap: 8px;
  }

  .result-banner-madness-perk-group-title {
    font-size: 13px;
  }

  .result-banner-madness-perk-content {
    gap: 5px;
  }

  .result-banner-madness-perk-header {
    gap: 10px;
  }

  .result-banner-upgrade-progress-footer {
    gap: 8px;
  }

  .result-banner-upgrade-progress-bar {
    height: 8px;
  }

  .result-banner-upgrade-progress-values {
    flex-basis: 58px;
    width: 58px;
  }

  .result-banner-upgrade-progress-value-current,
  .result-banner-upgrade-progress-value-delta {
    font-size: 11px;
  }

  .result-banner-upgrade-progress-ready-button {
    width: 72px;
    min-width: 72px;
    max-width: 72px;
    min-height: 28px;
    font-size: 11px;
  }
}

/* Late mobile layout repairs for popup variants that do not fit the generic tutorial pattern. */
.primary-action-button {
  border: none;
  outline: none;
  appearance: none;
  -webkit-appearance: none;
}

.new-enemy-popup-detail .pregame-upgrade-detail-preview,
.new-enemy-popup-detail .pregame-upgrade-detail-preview .pregame-knowledge-preview-canvas,
.new-enemy-popup-detail .pregame-upgrade-detail-icon {
  width: 128px !important;
  height: 128px !important;
  max-width: 128px;
  max-height: 128px;
  object-fit: contain;
}

.new-enemy-popup-detail .pregame-upgrade-detail-preview {
  justify-self: center;
}

.result-banner.is-madness-layout .result-banner-card,
.result-banner.has-analytics-aside .result-banner-card {
  height: min(820px, calc(100dvh - 40px));
  max-height: calc(100dvh - 40px);
  overflow: hidden;
}

.result-banner.is-madness-layout .result-banner-main-layout,
.result-banner.has-analytics-aside .result-banner-main-layout {
  height: 100%;
  min-height: 0;
}

.result-banner.is-madness-layout .result-banner-summary-panel,
.result-banner.has-analytics-aside .result-banner-summary-panel,
.result-banner.is-madness-layout .result-banner-madness-aside,
.result-banner.has-analytics-aside .result-banner-madness-aside {
  max-height: 100%;
  overflow-y: auto;
  overflow-x: hidden;
  overscroll-behavior: contain;
  -webkit-overflow-scrolling: touch;
  scrollbar-width: none;
  -ms-overflow-style: none;
}

.result-banner.is-madness-layout .result-banner-summary-panel::-webkit-scrollbar,
.result-banner.has-analytics-aside .result-banner-summary-panel::-webkit-scrollbar,
.result-banner.is-madness-layout .result-banner-madness-aside::-webkit-scrollbar,
.result-banner.has-analytics-aside .result-banner-madness-aside::-webkit-scrollbar {
  display: none;
}

.result-banner-upgrade-progress-footer {
  align-items: center;
}

.result-banner-upgrade-progress-bar {
  min-width: 72px;
}

.result-banner-upgrade-progress-ready-button {
  flex: 0 0 auto;
}

.pregame-screen:is(.is-upgrade-mode, .is-knowledge-mode) .pregame-upgrade-panel {
  padding-top: calc(env(safe-area-inset-top, 0px) + 132px);
}

@media (max-width: 900px), (pointer: coarse) {
  .pregame-screen:is(.is-upgrade-mode, .is-knowledge-mode) .pregame-upgrade-panel {
    padding-top: calc(env(safe-area-inset-top, 0px) + 68px);
  }
}

@media (pointer: coarse) and (min-width: 761px) and (max-height: 520px) {
  .locked-hybrid-recipe-popup .tutorial-popup-card {
    width: min(430px, var(--game-popup-card-max-width));
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 8px;
    padding: 16px 18px 18px;
    text-align: center;
    overflow: auto;
  }

  .locked-hybrid-recipe-popup .tutorial-popup-title {
    margin: 0;
    font-size: 26px;
    line-height: 1.04;
  }

  #lockedHybridRecipePopupText.tutorial-popup-text {
    margin: 0;
    max-width: 100%;
    font-size: 13px;
    line-height: 1.22;
  }

  .locked-hybrid-recipe-popup-requirement {
    width: 100%;
    margin: 4px 0 0;
    padding: 8px 10px;
    gap: 10px;
    flex: 0 0 auto;
    align-items: center;
    text-align: left;
    overflow: hidden;
  }

  .locked-hybrid-recipe-popup-recipe-icon {
    width: 50px;
    height: 50px;
    min-width: 50px;
    min-height: 50px;
  }

  .locked-hybrid-recipe-popup-requirement-text {
    min-width: 0;
    font-size: 12px;
    line-height: 1.18;
  }

  .locked-hybrid-recipe-popup-upgrade-row {
    margin: 2px 0 0;
    max-width: 100%;
    gap: 6px;
    font-size: 12px;
    line-height: 1.18;
  }

  .locked-hybrid-recipe-popup .tutorial-popup-button {
    margin-top: 4px;
    align-self: center;
    width: 170px;
    min-width: 170px;
    max-width: 170px;
    height: 40px;
    min-height: 40px;
    font-size: 17px;
  }

  .new-enemy-popup-card {
    width: min(610px, var(--game-popup-card-max-width));
    grid-template-columns: minmax(150px, 0.66fr) minmax(280px, 1fr);
    column-gap: 14px;
  }

  .new-enemy-popup-detail {
    grid-template-columns: minmax(132px, 1fr) minmax(104px, 128px);
    column-gap: 10px;
  }

  .new-enemy-popup-detail .pregame-upgrade-detail-preview,
  .new-enemy-popup-detail .pregame-upgrade-detail-preview .pregame-knowledge-preview-canvas,
  .new-enemy-popup-detail .pregame-upgrade-detail-icon {
    width: 112px !important;
    height: 112px !important;
    max-width: 112px;
    max-height: 112px;
  }

  .result-banner.is-madness-layout .result-banner-card,
  .result-banner.has-analytics-aside .result-banner-card {
    height: calc(100dvh - 16px);
    max-height: calc(100dvh - 16px);
    overflow: hidden;
  }

  .result-banner.is-madness-layout .result-banner-madness-aside,
  .result-banner.has-analytics-aside .result-banner-madness-aside {
    max-height: 100%;
    overflow-y: auto;
    overflow-x: hidden;
    padding-right: 2px;
  }

  .result-banner-upgrade-feed-list.is-progress,
  .result-banner-madness-perk-cards {
    overflow: visible;
  }

  .result-banner-upgrade-progress-footer {
    display: grid;
    grid-template-columns: minmax(72px, 1fr) auto;
    gap: 8px;
  }

  .result-banner-upgrade-progress-values {
    width: auto;
    min-width: 72px;
    flex-basis: auto;
  }
}
