:root {
  --bg-deep: #09090b;
  --bg-elevated: rgba(24, 24, 27, 0.82);
  --stroke: rgba(250, 250, 250, 0.06);
  --stroke-strong: rgba(250, 250, 250, 0.11);
  --text: #fafafa;
  --muted: #a1a1aa;
  --accent: #f59e0b;
  --accent-rgb: 245, 158, 11;
  --accent-2: #38bdf8;
  --accent-2-rgb: 56, 189, 248;
  --accent-hot: #fb923c;
  --danger: #f87171;
  --glow: 0 0 40px rgba(var(--accent-rgb), 0.14);
  /* Slightly smaller radii + density — less vertical scroll on typical viewports */
  --radius: 12px;
  --radius-sm: 8px;
  --tap-min: 44px;
  --font: "Plus Jakarta Sans", system-ui, sans-serif;
  --font-display: "Plus Jakarta Sans", var(--font);
  --font-mono: "JetBrains Mono", ui-monospace, monospace;
  --ease-spring: cubic-bezier(0.34, 1.35, 0.64, 1);
  --ease-out-soft: cubic-bezier(0.16, 1, 0.3, 1);
  --ease-in-out-smooth: cubic-bezier(0.45, 0, 0.55, 1);
  --ease-flow: cubic-bezier(0.4, 0, 0.18, 1);
  --dur-fast: 0.18s;
  --dur-med: 0.42s;
  /* One column width for hero + core playfield — keeps the forge row aligned with stat deck */
  --playfield-max: 42rem;
}

*,
*::before,
*::after {
  box-sizing: border-box;
}

html {
  height: 100%;
  overflow-x: clip;
}

body {
  margin: 0;
  width: 100%;
  /* svh = small viewport height — does not grow/shrink when mobile browser chrome hides (unlike dvh / 100vh). */
  min-height: 100%;
  min-height: 100svh;
  font-family: var(--font);
  color: var(--text);
  line-height: 1.45;
  background-color: var(--bg-deep);
  background-image:
    radial-gradient(ellipse 120% 80% at 50% -25%, rgba(39, 39, 42, 0.55) 0%, transparent 55%),
    radial-gradient(ellipse 90% 50% at 100% 0%, rgba(var(--accent-2-rgb), 0.06) 0%, transparent 45%),
    radial-gradient(ellipse 80% 45% at 0% 100%, rgba(var(--accent-rgb), 0.05) 0%, transparent 50%);
  overflow-x: clip;
  overscroll-behavior-y: contain;
  -webkit-text-size-adjust: 100%;
  text-size-adjust: 100%;
  -webkit-tap-highlight-color: transparent;
}

.svg-sprite {
  position: absolute;
  width: 0;
  height: 0;
  overflow: hidden;
}

.icon {
  display: block;
  flex-shrink: 0;
  color: inherit;
}

.icon--stat {
  width: 15px;
  height: 15px;
  opacity: 0.85;
}

.stat-card--primary .icon--stat {
  color: rgba(var(--accent-rgb), 0.95);
}

.icon--panel {
  width: 17px;
  height: 17px;
  color: var(--accent);
  opacity: 0.95;
}

.icon--forge {
  width: 20px;
  height: 20px;
  color: rgba(254, 243, 199, 0.98);
  filter: drop-shadow(0 0 8px rgba(var(--accent-rgb), 0.45));
}

.icon--res {
  width: 12px;
  height: 12px;
  opacity: 0.7;
}

.icon--combo {
  width: 16px;
  height: 16px;
  color: var(--accent);
  opacity: 0.85;
}

.icon--row {
  width: 15px;
  height: 15px;
  opacity: 0.65;
}

.icon--row-item {
  width: 22px;
  height: 22px;
  color: var(--accent-2);
  opacity: 0.9;
}

.icon--footer {
  width: 15px;
  height: 15px;
  opacity: 0.75;
}

.icon--milestone {
  width: 26px;
  height: 26px;
  color: var(--accent-2);
  filter: drop-shadow(0 0 10px rgba(var(--accent-2-rgb), 0.35));
}

.mono {
  font-family: var(--font-mono);
  font-variant-numeric: tabular-nums;
}

.ambient {
  position: fixed;
  inset: 0;
  pointer-events: none;
  z-index: 0;
  overflow: hidden;
}

.ambient__grid {
  position: absolute;
  inset: 0;
  background-image:
    linear-gradient(rgba(250, 250, 250, 0.04) 1px, transparent 1px),
    linear-gradient(90deg, rgba(250, 250, 250, 0.04) 1px, transparent 1px);
  background-size: 56px 56px;
  mask-image: radial-gradient(ellipse 85% 65% at 50% 20%, #000 0%, transparent 72%);
  opacity: 0.55;
}

.ambient__wash {
  position: absolute;
  inset: 0;
  background: radial-gradient(ellipse 120% 80% at 50% -10%, rgba(39, 39, 42, 0.5) 0%, transparent 55%);
}

.ambient__glow {
  position: absolute;
  border-radius: 50%;
  filter: blur(72px);
  opacity: 0.5;
  animation: ambient-drift 22s ease-in-out infinite;
}

.ambient__glow--a {
  width: min(480px, 95svw);
  height: min(420px, 85svh);
  left: -8%;
  top: -12%;
  background: radial-gradient(circle at 40% 35%, rgba(var(--accent-rgb), 0.22) 0%, transparent 68%);
  animation-delay: 0s;
}

.ambient__glow--b {
  width: min(440px, 90svw);
  height: min(380px, 80svh);
  right: -14%;
  bottom: -8%;
  background: radial-gradient(circle at 60% 50%, rgba(var(--accent-2-rgb), 0.16) 0%, transparent 70%);
  animation-delay: -8s;
}

@keyframes ambient-drift {
  0%,
  100% {
    transform: translate(0, 0) scale(1);
  }
  40% {
    transform: translate(1.5%, 2%) scale(1.03);
  }
  70% {
    transform: translate(-1%, 1%) scale(0.99);
  }
}

.grain {
  position: absolute;
  inset: 0;
  opacity: 0.028;
  background-image: url("data:image/svg+xml,%3Csvg viewBox='0 0 256 256' xmlns='http://www.w3.org/2000/svg'%3E%3Cfilter id='n'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='0.85' numOctaves='4' stitchTiles='stitch'/%3E%3C/filter%3E%3Crect width='100%25' height='100%25' filter='url(%23n)'/%3E%3C/svg%3E");
  mix-blend-mode: overlay;
}

.app {
  position: relative;
  z-index: 1;
  max-width: 1080px;
  margin: 0 auto;
  padding-top: max(clamp(0.65rem, 2svw, 1.35rem), env(safe-area-inset-top, 0px));
  padding-left: max(clamp(0.65rem, 2.5svw, 1.35rem), env(safe-area-inset-left, 0px));
  padding-right: max(clamp(0.65rem, 2.5svw, 1.35rem), env(safe-area-inset-right, 0px));
  padding-bottom: clamp(1.1rem, 3svw, 2rem);
  display: flex;
  flex-direction: column;
  gap: 0.85rem;
}

.hero {
  display: flex;
  flex-direction: column;
  gap: 0.85rem;
}

.hero-top {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 0.55rem 1rem;
}

.brand-block {
  display: flex;
  align-items: center;
  gap: 0.75rem;
}

.logo-glyph {
  width: 44px;
  height: 44px;
  border-radius: 12px;
  background: linear-gradient(145deg, #2e2e32 0%, #18181b 100%);
  border: 1px solid rgba(var(--accent-rgb), 0.4);
  box-shadow: var(--glow), inset 0 1px 0 rgba(255, 255, 255, 0.09), 0 12px 32px rgba(0, 0, 0, 0.35);
  position: relative;
  display: grid;
  place-items: center;
}

.logo-glyph__shard {
  position: relative;
  z-index: 2;
  color: rgba(230, 252, 255, 0.95);
  filter: drop-shadow(0 2px 8px rgba(0, 0, 0, 0.45));
  animation: logo-shard 6s var(--ease-in-out-smooth) infinite;
}

@keyframes logo-shard {
  0%,
  100% {
    transform: rotate(0deg) scale(1);
    opacity: 1;
  }
  50% {
    transform: rotate(8deg) scale(1.04);
    opacity: 0.92;
  }
}

.logo-glyph::after {
  content: "";
  position: absolute;
  inset: 3px;
  border-radius: 9px;
  background: linear-gradient(165deg, rgba(24, 24, 27, 0.98), rgba(9, 9, 11, 0.96));
  border: 1px solid rgba(255, 255, 255, 0.05);
  z-index: 1;
}

.brand-text .eyebrow {
  margin: 0 0 0.15rem;
  font-size: 0.72rem;
  font-weight: 600;
  letter-spacing: 0.2em;
  text-transform: uppercase;
  color: var(--muted);
}

.title {
  margin: 0;
  font-family: var(--font-display);
  font-size: clamp(1.45rem, 3.4svw, 2rem);
  font-weight: 700;
  letter-spacing: -0.03em;
  background: linear-gradient(115deg, #fafafa 0%, #fde68a 42%, #f59e0b 100%);
  -webkit-background-clip: text;
  background-clip: text;
  color: transparent;
}

.toast {
  flex: 1;
  min-width: min(100%, 380px);
  padding: 0.45rem 0.75rem;
  font-size: 0.76rem;
  color: var(--accent);
  background: rgba(24, 24, 27, 0.92);
  border: 1px solid rgba(var(--accent-rgb), 0.35);
  border-radius: var(--radius-sm);
  backdrop-filter: blur(12px);
  box-shadow: 0 16px 40px rgba(0, 0, 0, 0.35);
  opacity: 0;
  transition: opacity 0.4s ease;
  text-align: left;
}

.toast:not([hidden]) {
  opacity: 1;
}

.milestone-toast {
  flex: 1;
  min-width: min(100%, 340px);
  max-width: 420px;
  padding: 0.45rem 0.75rem;
  font-size: 0.76rem;
  color: var(--text);
  background: linear-gradient(135deg, rgba(var(--accent-2-rgb), 0.14), rgba(var(--accent-rgb), 0.08));
  border: 1px solid rgba(var(--accent-2-rgb), 0.45);
  border-radius: var(--radius-sm);
  backdrop-filter: blur(12px);
  box-shadow: 0 16px 40px rgba(0, 0, 0, 0.35);
  display: flex;
  flex-direction: row;
  align-items: flex-start;
  gap: 0.65rem;
  line-height: 1.35;
  animation: milestone-pop var(--dur-med) var(--ease-out-soft);
}

.milestone-toast__icon {
  flex-shrink: 0;
  padding-top: 0.1rem;
}

.milestone-toast__body {
  display: flex;
  flex-direction: column;
  gap: 0.2rem;
  min-width: 0;
}

.milestone-toast[hidden] {
  display: none !important;
}

.milestone-toast__title {
  font-weight: 700;
  font-size: 0.8rem;
  color: var(--accent-2);
  letter-spacing: -0.02em;
}

.milestone-toast__text {
  font-size: 0.72rem;
  color: var(--muted);
}

@keyframes milestone-pop {
  from {
    opacity: 0;
    transform: translateY(-8px) scale(0.96);
  }
  to {
    opacity: 1;
    transform: translateY(0) scale(1);
  }
}

.net-offline-banner {
  position: sticky;
  top: 0;
  z-index: 200;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 0.65rem;
  flex-wrap: wrap;
  padding: 0.45rem 0.85rem;
  font-size: 0.78rem;
  color: rgba(254, 240, 200, 0.95);
  background: rgba(127, 29, 29, 0.88);
  border-bottom: 1px solid rgba(248, 113, 113, 0.45);
  backdrop-filter: blur(8px);
}

.net-offline-banner[hidden] {
  display: none !important;
}

.net-offline-banner__dot {
  width: 0.45rem;
  height: 0.45rem;
  border-radius: 999px;
  background: #fca5a5;
  box-shadow: 0 0 8px rgba(252, 165, 165, 0.9);
  animation: net-pulse 1.4s ease-in-out infinite;
}

@keyframes net-pulse {
  0%,
  100% {
    opacity: 0.65;
  }
  50% {
    opacity: 1;
  }
}

@media (prefers-reduced-motion: reduce) {
  .net-offline-banner__dot {
    animation: none;
    opacity: 1;
  }
}

.net-offline-banner__text {
  flex: 1;
  min-width: 0;
  text-align: center;
}

.server-notice-banner {
  position: sticky;
  top: 0;
  z-index: 199;
  display: flex;
  align-items: flex-start;
  justify-content: center;
  gap: 0.55rem;
  flex-wrap: wrap;
  padding: 0.45rem 0.85rem;
  font-size: 0.78rem;
  line-height: 1.35;
  color: rgba(240, 253, 255, 0.96);
  border-bottom: 1px solid rgba(56, 189, 248, 0.35);
  backdrop-filter: blur(8px);
}

.server-notice-banner--info {
  background: rgba(30, 58, 95, 0.92);
}

.server-notice-banner--warning {
  background: rgba(113, 63, 18, 0.92);
  border-bottom-color: rgba(251, 191, 36, 0.45);
  color: rgba(255, 251, 235, 0.98);
}

.server-notice-banner[hidden] {
  display: none !important;
}

.server-notice-banner__label {
  flex-shrink: 0;
  font-size: 0.62rem;
  font-weight: 800;
  letter-spacing: 0.14em;
  text-transform: uppercase;
  opacity: 0.85;
  padding-top: 0.12rem;
}

.server-notice-banner__text {
  flex: 1;
  min-width: 0;
  text-align: center;
}

.server-notice-banner__dismiss {
  flex-shrink: 0;
}

.event-chip {
  width: 100%;
  max-width: 42rem;
  margin: 0 auto 0.35rem;
  padding: 0.3rem 0.65rem;
  font-size: 0.7rem;
  font-weight: 600;
  letter-spacing: 0.04em;
  text-align: center;
  color: rgba(253, 230, 138, 0.95);
  background: linear-gradient(95deg, rgba(245, 158, 11, 0.22), rgba(56, 189, 248, 0.14));
  border: 1px solid rgba(245, 158, 11, 0.38);
  border-radius: 999px;
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.06);
}

.event-chip[hidden] {
  display: none !important;
}

.achievement-strip {
  width: 100%;
  max-width: 42rem;
  margin: 0.35rem auto 0;
  padding: 0.3rem 0.45rem;
  display: flex;
  flex-wrap: wrap;
  gap: 0.28rem;
  align-items: center;
  justify-content: center;
  font-size: 0.64rem;
  color: var(--muted);
}

.achievement-strip[hidden] {
  display: none !important;
}

.ach-badge {
  display: inline-flex;
  align-items: center;
  padding: 0.2rem 0.45rem;
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.04);
  border: 1px solid var(--stroke);
  color: var(--text);
  font-weight: 600;
  max-width: 100%;
}

.stat-deck {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(118px, 1fr));
  gap: 0.65rem;
}

/* Stats + forge rank: one row on wide screens — less vertical scrolling */
.hero-hud {
  display: flex;
  flex-direction: column;
  gap: 0.65rem;
  width: 100%;
  max-width: var(--playfield-max);
  margin: 0 auto;
}

@media (min-width: 880px) {
  .hero-hud {
    flex-direction: row;
    align-items: stretch;
    max-width: none;
    gap: 0.75rem;
  }

  .hero-hud .stat-deck {
    flex: 1.2;
    min-width: 0;
  }

  .hero-hud .forge-rank {
    flex: 1;
    max-width: 19rem;
    margin: 0;
  }
}

.forge-rank {
  width: 100%;
  max-width: 42rem;
  margin: 0 auto;
  padding: 0.55rem 0.75rem 0.6rem;
  display: flex;
  flex-direction: column;
  gap: 0.4rem;
}

.forge-rank__top {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 0.5rem 1rem;
}

.forge-rank__title {
  display: inline-flex;
  align-items: center;
  gap: 0.45rem;
  font-size: 0.72rem;
  font-weight: 700;
  letter-spacing: 0.14em;
  text-transform: uppercase;
  color: var(--muted);
}

.icon--forge-rank {
  width: 16px;
  height: 16px;
  color: rgba(253, 224, 138, 0.95);
  opacity: 0.95;
}

.forge-rank__level-wrap {
  font-size: 0.88rem;
  font-weight: 700;
  color: rgba(254, 243, 199, 0.98);
  letter-spacing: -0.02em;
}

.forge-rank__bar {
  position: relative;
  height: 6px;
  border-radius: 999px;
  background: rgba(0, 0, 0, 0.45);
  border: 1px solid var(--stroke);
  overflow: hidden;
  box-shadow: inset 0 1px 2px rgba(0, 0, 0, 0.45);
}

.forge-rank__fill {
  height: 100%;
  width: 0%;
  border-radius: inherit;
  background: linear-gradient(90deg, rgba(var(--accent-rgb), 0.35), rgba(var(--accent-2-rgb), 0.95));
  box-shadow: 0 0 14px rgba(var(--accent-2-rgb), 0.35);
  transition: width 0.35s var(--ease-out-soft);
}

.forge-rank__meta {
  margin: 0;
  font-size: 0.68rem;
  color: var(--muted);
  line-height: 1.35;
  text-align: center;
}

@media (prefers-reduced-motion: reduce) {
  .forge-rank__fill {
    transition: none;
  }
}

.stat-card {
  position: relative;
  padding: 0.72rem 0.8rem;
  border-radius: var(--radius);
  background: var(--bg-elevated);
  border: 1px solid var(--stroke);
  backdrop-filter: blur(16px);
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.045), 0 20px 50px rgba(0, 0, 0, 0.38);
  overflow: hidden;
}

.stat-card::before {
  content: "";
  position: absolute;
  inset: 0;
  background: linear-gradient(135deg, rgba(var(--accent-rgb), 0.06), transparent 55%);
  pointer-events: none;
}

.stat-card--primary {
  border-color: rgba(var(--accent-rgb), 0.25);
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.055), var(--glow), 0 20px 50px rgba(0, 0, 0, 0.35);
}

.stat-card--pulse {
  animation: balance-pulse var(--dur-med) var(--ease-spring);
}

@keyframes balance-pulse {
  0% {
    transform: scale(1);
    box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.055), var(--glow), 0 20px 50px rgba(0, 0, 0, 0.35);
  }
  50% {
    transform: scale(1.028);
    box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.07), 0 0 48px rgba(var(--accent-rgb), 0.32), 0 24px 55px rgba(0, 0, 0, 0.4);
  }
  100% {
    transform: scale(1);
    box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.055), var(--glow), 0 20px 50px rgba(0, 0, 0, 0.35);
  }
}

.stat-card__label {
  display: flex;
  align-items: center;
  gap: 0.35rem;
  font-size: 0.65rem;
  font-weight: 600;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  color: var(--muted);
  margin-bottom: 0.25rem;
}

.stat-card__value {
  display: block;
  font-size: clamp(1.1rem, 2.5svw, 1.45rem);
  font-weight: 600;
  color: var(--accent);
  line-height: 1.1;
}

.stat-card__hint {
  display: block;
  margin-top: 0.15rem;
  font-size: 0.68rem;
  color: var(--muted);
}

.glass {
  background: linear-gradient(165deg, rgba(32, 32, 36, 0.92) 0%, rgba(24, 24, 27, 0.88) 100%);
  border: 1px solid var(--stroke);
  backdrop-filter: blur(14px);
  border-radius: var(--radius);
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.06), 0 20px 52px rgba(0, 0, 0, 0.48);
  transition: transform var(--dur-fast) var(--ease-out-soft), box-shadow var(--dur-fast) var(--ease-out-soft),
    border-color var(--dur-fast) ease;
}

@media (hover: hover) {
  .glass:hover {
    border-color: rgba(255, 255, 255, 0.11);
    box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.08), 0 28px 64px rgba(0, 0, 0, 0.52);
  }
}

.layout {
  display: grid;
  gap: 0.85rem;
}

/* Desktop: Core is full-width (hero); shop row is Upgrades | Generators | Rebirth */
@media (min-width: 1024px) {
  .layout {
    grid-template-columns: minmax(0, 1fr) minmax(0, 1fr) minmax(0, 1fr);
    grid-template-rows: auto 1fr;
    align-items: start;
  }

  .layout > .panel--core {
    grid-column: 1 / -1;
    width: 100%;
    max-width: none;
  }

  .layout > .upgrades-panel {
    grid-column: 1;
    grid-row: 2;
  }

  .layout > .buildings-panel {
    grid-column: 2;
    grid-row: 2;
  }

  .layout > .prestige-panel {
    grid-column: 3;
    grid-row: 2;
    min-width: 0;
  }

  /* Keep long shop lists in view — scroll inside the panel, not the whole page */
  .upgrades-panel:not(.panel--collapsed) .panel__body-inner,
  .buildings-panel:not(.panel--collapsed) .panel__body-inner,
  .prestige-panel:not(.panel--collapsed) .panel__body-inner {
    max-height: min(52vh, 28rem);
    overflow-y: auto;
    overscroll-behavior: contain;
    scrollbar-gutter: stable;
  }

  /* Third column is narrow — stack dense Rebirth UI */
  @media (min-width: 1024px) and (max-width: 1240px) {
    .layout > .prestige-panel .prestige-stat-row {
      grid-template-columns: 1fr;
    }

    .layout > .prestige-panel .prestige-cta {
      grid-template-columns: 1fr;
      gap: 0.5rem;
    }

    .layout > .prestige-panel .prestige-hint {
      text-align: left;
    }
  }
}

.panel {
  padding: 0.85rem 1rem;
}

.panel--core {
  padding: 1rem 1rem 1.05rem;
}

.panel__head {
  margin-bottom: 0.65rem;
}

.panel__head--inline {
  display: flex;
  flex-wrap: wrap;
  align-items: baseline;
  justify-content: space-between;
  gap: 0.5rem 1rem;
}

.panel__title {
  margin: 0;
  font-family: var(--font-display);
  font-size: 0.95rem;
  font-weight: 700;
  letter-spacing: -0.025em;
}

.panel__title--with-icon {
  display: flex;
  align-items: center;
  gap: 0.45rem;
}

.panel__sub {
  margin: 0.2rem 0 0;
  font-size: 0.76rem;
  line-height: 1.4;
  color: var(--muted);
}

.core-header {
  display: grid;
  grid-template-columns: 4px minmax(0, 1fr);
  gap: 0.75rem;
  align-items: start;
  margin-bottom: 0.75rem;
  text-align: left;
}

.core-header__intro {
  flex: 1;
  min-width: 0;
}

.core-header__rail {
  width: 4px;
  min-height: 2.75rem;
  margin-top: 0.15rem;
  border-radius: 999px;
  background: linear-gradient(180deg, rgba(var(--accent-rgb), 0.95), rgba(var(--accent-2-rgb), 0.45));
  box-shadow: 0 0 16px rgba(var(--accent-rgb), 0.25);
  align-self: stretch;
}

.core-header__body {
  min-width: 0;
}

.core-header__title {
  font-size: 0.95rem;
}

.core-header__sub {
  margin-top: 0.25rem;
  max-width: 36rem;
  line-height: 1.38;
  font-size: 0.78rem;
}

.core-header__touch {
  display: none;
}

.core-flow {
  display: none;
  flex-wrap: wrap;
  align-items: center;
  justify-content: flex-end;
  gap: 0.35rem 0.45rem;
  margin-top: 0.5rem;
}

@media (min-width: 1024px) {
  .core-header__body {
    display: grid;
    grid-template-columns: minmax(0, 1fr) auto;
    align-items: center;
    gap: 0.5rem 1rem;
    width: 100%;
  }

  .core-header__intro {
    margin: 0;
  }

  .core-flow {
    display: flex;
    margin-top: 0;
    flex-shrink: 0;
  }
}

.core-flow__chip {
  display: inline-flex;
  align-items: center;
  padding: 0.2rem 0.55rem;
  border-radius: 999px;
  font-size: 0.62rem;
  font-weight: 700;
  letter-spacing: 0.14em;
  text-transform: uppercase;
  color: var(--muted);
  border: 1px solid var(--stroke-strong);
  background: rgba(0, 0, 0, 0.22);
}

.core-flow__wire {
  flex: 1 1 1.25rem;
  min-width: 0.75rem;
  max-width: 2.5rem;
  height: 2px;
  border-radius: 999px;
  background: linear-gradient(90deg, rgba(var(--accent-rgb), 0.15), rgba(var(--accent-rgb), 0.55), rgba(var(--accent-2-rgb), 0.45));
  opacity: 0.85;
}

@media (min-width: 1024px) {
  .panel--core {
    padding-top: 0.85rem;
  }
}

@media (max-width: 640px) {
  .core-header {
    grid-template-columns: 1fr;
    justify-items: center;
    text-align: center;
  }

  .core-header__rail {
    width: 3rem;
    height: 4px;
    min-height: 0;
    margin-top: 0;
    align-self: center;
    background: linear-gradient(90deg, rgba(var(--accent-rgb), 0.95), rgba(var(--accent-2-rgb), 0.45));
    grid-row: 1;
  }

  .core-header__body {
    width: 100%;
    display: block;
    grid-row: 2;
  }

  .core-header__intro {
    width: 100%;
  }

  .core-header__sub {
    margin-left: auto;
    margin-right: auto;
  }

  .core-flow {
    justify-content: center;
    margin-top: 0.65rem;
  }

  .core-flow__wire {
    max-width: 1.75rem;
  }
}

.click-panel {
  position: relative;
  overflow: clip;
  --core-mx: 0;
  --core-my: 0;
}

.core-ripples {
  position: absolute;
  inset: 0;
  pointer-events: none;
  z-index: 6;
}

.core-ripple {
  position: absolute;
  width: 14px;
  height: 14px;
  margin-left: -7px;
  margin-top: -7px;
  border-radius: 50%;
  border: 2px solid rgba(var(--accent-rgb), 0.48);
  opacity: 0;
  transform: scale(0.25);
  pointer-events: none;
}

.core-ripple.is-on {
  animation: core-ripple-out 0.62s var(--ease-out-soft) forwards;
}

@keyframes core-ripple-out {
  0% {
    opacity: 0.55;
    transform: scale(0.25);
  }
  100% {
    opacity: 0;
    transform: scale(12);
  }
}

.core-wrap {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 0.55rem;
  padding: 0.2rem 0 0;
  width: 100%;
  max-width: var(--playfield-max);
  margin-inline: auto;
  transition: transform 0.52s var(--ease-out-soft);
  transform: translate3d(calc(var(--core-mx, 0) * 12px), calc(var(--core-my, 0) * 8px), 0);
}

.core-footer {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 0.55rem;
  width: 100%;
  max-width: var(--playfield-max);
  margin: 0 auto;
  padding-top: 0.65rem;
  margin-top: 0.15rem;
  border-top: 1px solid rgba(255, 255, 255, 0.055);
}

.core-stage {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: center;
  gap: 0.45rem 0.85rem;
  width: 100%;
  transform-origin: 50% 42%;
}

@media (min-width: 541px) {
  .core-stage {
    flex-wrap: nowrap;
    align-items: flex-end;
    justify-content: center;
  }
}

.core-stage--kick {
  animation: core-stage-kick 0.5s var(--ease-out-soft);
}

@keyframes core-stage-kick {
  0% {
    transform: translate3d(0, 0, 0) rotate(0deg);
  }
  18% {
    transform: translate3d(-4px, 0, 0) rotate(-0.55deg);
  }
  38% {
    transform: translate3d(3px, 0, 0) rotate(0.42deg);
  }
  58% {
    transform: translate3d(-2px, 0, 0) rotate(-0.22deg);
  }
  100% {
    transform: translate3d(0, 0, 0) rotate(0deg);
  }
}

.conduit {
  position: relative;
  width: clamp(56px, 14svw, 120px);
  height: 56px;
  flex: 0 0 auto;
  opacity: 0.85;
  cursor: pointer;
}

.conduit--poke .conduit__svg {
  animation: conduit-twang 0.38s var(--ease-spring);
}

@keyframes conduit-twang {
  0%,
  100% {
    transform: translateY(0) scale(1);
  }
  38% {
    transform: translateY(2px) scale(1.07);
  }
  70% {
    transform: translateY(-1px) scale(1.02);
  }
}

@media (hover: hover) and (pointer: fine) {
  .conduit:hover .conduit__path {
    filter: drop-shadow(0 0 10px rgba(var(--accent-rgb), 0.55));
    opacity: 0.95;
  }
}

.conduit__svg {
  width: 100%;
  height: 100%;
  display: block;
}

.conduit__path {
  stroke-dasharray: 140;
  stroke-dashoffset: 0;
  filter: drop-shadow(0 0 6px rgba(var(--accent-rgb), 0.45));
}

.conduit:not(.conduit--pulse) .conduit__path {
  animation: conduit-idle 5.5s var(--ease-in-out-smooth) infinite;
}

.conduit--pulse .conduit__path {
  animation: conduit-flow 0.92s var(--ease-flow) forwards;
}

@keyframes conduit-idle {
  0%,
  100% {
    stroke-dashoffset: 0;
    opacity: 0.42;
  }
  50% {
    stroke-dashoffset: 18;
    opacity: 0.68;
  }
}

@keyframes conduit-flow {
  0% {
    stroke-dashoffset: 140;
    opacity: 0.18;
  }
  32% {
    opacity: 1;
  }
  100% {
    stroke-dashoffset: 0;
    opacity: 0.9;
  }
}

.conduit__spark {
  position: absolute;
  right: 4px;
  top: 50%;
  width: 8px;
  height: 8px;
  margin-top: -4px;
  border-radius: 50%;
  background: var(--accent);
  box-shadow: 0 0 14px var(--accent);
  opacity: 0;
  pointer-events: none;
}

.conduit--pulse .conduit__spark {
  animation: spark-pop 0.72s var(--ease-spring);
}

@keyframes spark-pop {
  0% {
    opacity: 0;
    transform: scale(0.15);
  }
  45% {
    opacity: 1;
    transform: scale(1.25);
  }
  100% {
    opacity: 0.55;
    transform: scale(1);
  }
}

.gen-feed {
  position: relative;
  flex: 0 0 auto;
  width: 0;
  max-width: 0;
  height: 72px;
  margin: 0;
  opacity: 0;
  overflow: hidden;
  transition: max-width 0.55s var(--ease-flow), opacity 0.45s ease, margin 0.45s ease;
  pointer-events: none;
}

.gen-feed--active {
  width: 44px;
  max-width: 52px;
  opacity: 1;
  margin: 0 0.08rem;
  pointer-events: auto;
  cursor: pointer;
}

.gen-feed.gen-feed--active.gen-feed--poke {
  animation: gen-feed-poke-pop 0.4s var(--ease-spring);
}

@keyframes gen-feed-poke-pop {
  0%,
  100% {
    transform: scale(1);
  }
  45% {
    transform: scale(1.1) translateY(-2px);
  }
}

.gen-feed__svg {
  width: 44px;
  height: 72px;
  display: block;
}

.gen-feed__path {
  stroke-dasharray: 118;
  stroke-dashoffset: 0;
  filter: drop-shadow(0 0 5px rgba(var(--accent-2-rgb), 0.38));
}

.gen-feed__path--glow {
  filter: blur(1.5px);
}

.gen-feed--active .gen-feed__path {
  animation: gen-feed-stream 2.65s linear infinite;
}

@keyframes gen-feed-stream {
  from {
    stroke-dashoffset: 118;
  }
  to {
    stroke-dashoffset: 0;
  }
}

.gen-feed__spark {
  position: absolute;
  width: 7px;
  height: 7px;
  border-radius: 50%;
  pointer-events: none;
  opacity: 0;
}

.gen-feed__spark--src {
  right: 0;
  top: 48%;
  transform: translateY(-50%);
  background: var(--accent-2);
  box-shadow: 0 0 12px rgba(var(--accent-2-rgb), 0.85);
}

.gen-feed__spark--sink {
  left: 0;
  top: 56%;
  transform: translateY(-50%);
  background: var(--accent);
  box-shadow: 0 0 12px rgba(var(--accent-rgb), 0.75);
}

.gen-feed--active .gen-feed__spark--src {
  animation: gen-feed-spark 2.4s var(--ease-in-out-smooth) infinite;
}

.gen-feed--active .gen-feed__spark--sink {
  animation: gen-feed-spark 2.4s var(--ease-in-out-smooth) infinite 0.35s;
}

@keyframes gen-feed-spark {
  0%,
  100% {
    opacity: 0.25;
    transform: translateY(-50%) scale(0.75);
  }
  50% {
    opacity: 1;
    transform: translateY(-50%) scale(1.08);
  }
}

.reservoir {
  --level: 0.12;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 0.32rem;
  flex: 0 0 auto;
  cursor: pointer;
}

.reservoir--poke {
  animation: reservoir-poke-squish 0.48s var(--ease-spring);
}

@keyframes reservoir-poke-squish {
  0%,
  100% {
    transform: translateY(0) scale(1);
  }
  22% {
    transform: translateY(-5px) scale(1.03);
  }
  48% {
    transform: translateY(3px) scale(0.98);
  }
  72% {
    transform: translateY(-2px) scale(1.01);
  }
}

.reservoir__glass {
  width: 82px;
  height: 152px;
  border-radius: 16px;
  padding: 5px;
  background: linear-gradient(145deg, rgba(255, 255, 255, 0.08), rgba(255, 255, 255, 0.02));
  border: 1px solid var(--stroke-strong);
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.1), 0 16px 40px rgba(0, 0, 0, 0.45);
  position: relative;
}

.reservoir--ping .reservoir__glass {
  animation: reservoir-ping 0.36s ease-out;
}

@keyframes reservoir-ping {
  0% {
    filter: brightness(1);
    box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.1), 0 16px 40px rgba(0, 0, 0, 0.45);
  }
  40% {
    filter: brightness(1.12);
    box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.14), 0 0 0 2px rgba(var(--accent-rgb), 0.45),
      0 18px 44px rgba(var(--accent-rgb), 0.12);
  }
  100% {
    filter: brightness(1);
    box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.1), 0 16px 40px rgba(0, 0, 0, 0.45);
  }
}

.reservoir__inner {
  position: absolute;
  left: 7px;
  right: 7px;
  bottom: 9px;
  top: 10px;
  border-radius: 11px;
  overflow: hidden;
  background: rgba(0, 0, 0, 0.35);
  z-index: 1;
}

.reservoir__fill {
  position: absolute;
  left: 0;
  right: 0;
  bottom: 0;
  height: 100%;
  transform-origin: bottom center;
  transform: scaleY(var(--level));
  transition: transform 0.88s var(--ease-flow);
  background: linear-gradient(
    180deg,
    rgba(254, 243, 199, 0.95) 0%,
    rgba(var(--accent-rgb), 0.88) 38%,
    rgba(var(--accent-2-rgb), 0.42) 100%
  );
  box-shadow: inset 0 8px 24px rgba(255, 255, 255, 0.12);
}

.reservoir__fill::before {
  content: "";
  position: absolute;
  inset: 0;
  background: linear-gradient(
    105deg,
    transparent 0%,
    rgba(255, 255, 255, 0.06) 42%,
    rgba(var(--accent-rgb), 0.12) 50%,
    rgba(255, 255, 255, 0.05) 58%,
    transparent 100%
  );
  background-size: 200% 100%;
  animation: fill-fluid 4.2s var(--ease-in-out-smooth) infinite;
  pointer-events: none;
  mix-blend-mode: soft-light;
}

.reservoir__surface {
  position: absolute;
  left: -5%;
  right: -5%;
  bottom: calc(100% * var(--level) - 5px);
  z-index: 2;
  height: 9px;
  border-radius: 50%;
  background: linear-gradient(
    90deg,
    transparent,
    rgba(255, 255, 255, 0.45),
    transparent
  );
  opacity: 0.55;
  animation: surface-shimmer 2.8s ease-in-out infinite;
  pointer-events: none;
}

.reservoir--passive .reservoir__surface {
  animation-duration: 1.4s;
  opacity: 0.75;
}

@keyframes surface-shimmer {
  0%,
  100% {
    transform: translateX(-6%) scaleX(0.92);
    opacity: 0.42;
  }
  33% {
    transform: translateX(4%) scaleX(1.02);
    opacity: 0.62;
  }
  66% {
    transform: translateX(-3%) scaleX(0.98);
    opacity: 0.55;
  }
}

@keyframes fill-fluid {
  0%,
  100% {
    background-position: 0% 50%;
  }
  50% {
    background-position: 100% 50%;
  }
}

.reservoir__ticks {
  position: absolute;
  inset: 0;
  border-radius: 16px;
  z-index: 2;
  pointer-events: none;
  background: repeating-linear-gradient(
    to top,
    transparent,
    transparent 18px,
    rgba(255, 255, 255, 0.04) 18px,
    rgba(255, 255, 255, 0.04) 19px
  );
  opacity: 0.5;
  mix-blend-mode: overlay;
}

.reservoir__label {
  display: inline-flex;
  align-items: center;
  gap: 0.35rem;
  font-size: 0.68rem;
  font-weight: 600;
  letter-spacing: 0.14em;
  text-transform: uppercase;
  color: var(--muted);
}

.reservoir--gulp .reservoir__glass {
  animation: reservoir-gulp 0.62s var(--ease-spring);
}

@keyframes reservoir-gulp {
  0% {
    transform: scale(1);
    filter: brightness(1);
  }
  40% {
    transform: scale(1.05);
    filter: brightness(1.2);
  }
  100% {
    transform: scale(1);
    filter: brightness(1);
  }
}

.reservoir--passive .reservoir__fill::after {
  content: "";
  position: absolute;
  left: 0;
  right: 0;
  bottom: 0;
  height: 40%;
  background: radial-gradient(ellipse at 50% 100%, rgba(255, 255, 255, 0.12), transparent 70%);
  animation: passive-glow 2s ease-in-out infinite;
}

@keyframes passive-glow {
  0%,
  100% {
    opacity: 0.4;
  }
  50% {
    opacity: 0.85;
  }
}

.energy-bolt {
  position: fixed;
  left: 0;
  top: 0;
  width: 12px;
  height: 12px;
  margin-left: -6px;
  margin-top: -6px;
  border-radius: 50%;
  pointer-events: none;
  z-index: 45;
  background: radial-gradient(circle at 35% 35%, #fff 0%, var(--accent) 45%, rgba(var(--accent-2-rgb), 0.4) 100%);
  box-shadow: 0 0 14px rgba(var(--accent-rgb), 0.85), 0 0 28px rgba(var(--accent-2-rgb), 0.32);
}

.energy-bolt--trail {
  width: 22px;
  height: 22px;
  margin-left: -11px;
  margin-top: -11px;
  z-index: 44;
  opacity: 0.45;
  filter: blur(4px);
  background: radial-gradient(circle at 40% 40%, rgba(255, 255, 255, 0.55) 0%, var(--accent) 38%, transparent 72%);
  box-shadow: 0 0 22px rgba(var(--accent-rgb), 0.5);
}

@media (max-width: 540px) {
  .core-stage {
    flex-direction: column;
  }

  .conduit {
    width: 48px;
    height: 40px;
    transform: rotate(90deg);
  }

  .gen-feed {
    height: 48px;
  }

  .gen-feed--active {
    width: 52px;
    max-width: 60px;
  }

  .gen-feed__svg {
    width: 52px;
    height: 48px;
  }

  .gen-feed__spark--src {
    top: 46%;
    right: 2px;
  }

  .gen-feed__spark--sink {
    top: 52%;
    left: 2px;
  }
}

.click-btn {
  position: relative;
  width: clamp(148px, 36svw, 176px);
  height: clamp(148px, 36svw, 176px);
  border: none;
  border-radius: 50%;
  cursor: pointer;
  color: var(--text);
  font: inherit;
  font-weight: 700;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  font-size: 0.76rem;
  background: radial-gradient(circle at 32% 22%, #3f3f46 0%, #27272a 48%, #09090b 100%);
  box-shadow: 0 0 0 1px rgba(255, 255, 255, 0.1), 0 24px 60px rgba(0, 0, 0, 0.55),
    inset 0 1px 0 rgba(255, 255, 255, 0.08);
  transition: transform var(--dur-fast) var(--ease-spring), box-shadow 0.28s var(--ease-out-soft);
  touch-action: manipulation;
  user-select: none;
  -webkit-user-select: none;
}

.click-btn:hover {
  transform: translateY(-3px) scale(1.02);
  box-shadow: 0 0 0 1px rgba(var(--accent-rgb), 0.42), 0 30px 72px rgba(var(--accent-rgb), 0.18);
}

.click-btn:active {
  transform: scale(0.96);
  transition-duration: 0.08s;
}

.click-btn.is-pressing,
.click-btn.is-pressing:hover {
  transform: translateY(1px) scale(0.93);
  box-shadow: 0 0 0 1px rgba(var(--accent-rgb), 0.55), 0 14px 36px rgba(0, 0, 0, 0.5),
    inset 0 4px 14px rgba(0, 0, 0, 0.55);
  transition-duration: 0.06s;
}

.click-btn:focus-visible {
  outline: 2px solid rgba(var(--accent-rgb), 0.85);
  outline-offset: 5px;
}

.click-btn:focus:not(:focus-visible) {
  outline: none;
}

.click-btn::after {
  content: "";
  position: absolute;
  inset: -8%;
  border-radius: 50%;
  border: 2px solid rgba(var(--accent-rgb), 0.55);
  opacity: 0;
  pointer-events: none;
  z-index: 3;
}

.click-btn.is-ripple::after {
  animation: forge-shockwave 0.58s var(--ease-out-soft) forwards;
}

@keyframes forge-shockwave {
  0% {
    transform: scale(0.88);
    opacity: 0.55;
  }
  100% {
    transform: scale(1.38);
    opacity: 0;
  }
}

.click-btn--double .click-halo {
  animation: spin-halo 2.2s linear infinite, halo-burst 0.55s ease-out;
}

.click-btn--double {
  box-shadow: 0 0 0 2px rgba(var(--accent-2-rgb), 0.42), 0 26px 64px rgba(var(--accent-2-rgb), 0.14),
    inset 0 1px 0 rgba(255, 255, 255, 0.1);
}

.click-halo {
  position: absolute;
  inset: -20%;
  z-index: 0;
  border-radius: 50%;
  background: conic-gradient(
    from 180deg,
    rgba(var(--accent-rgb), 0),
    rgba(var(--accent-rgb), 0.5),
    rgba(var(--accent-2-rgb), 0.45),
    rgba(var(--accent-rgb), 0)
  );
  opacity: 0.45;
  animation: spin-halo 10s linear infinite;
  pointer-events: none;
}

@keyframes spin-halo {
  to {
    transform: rotate(360deg);
  }
}

.click-btn.is-ripple .click-halo {
  animation: spin-halo 2.5s linear infinite, halo-burst 0.55s ease-out;
}

@keyframes halo-burst {
  0% {
    opacity: 0.65;
    filter: brightness(1.4);
  }
  100% {
    opacity: 0.45;
    filter: brightness(1);
  }
}

.click-btn.is-ripple .click-ring {
  animation: ring-pulse 0.5s ease-out;
}

@keyframes ring-pulse {
  0% {
    transform: scale(1);
    opacity: 1;
  }
  100% {
    transform: scale(1.12);
    opacity: 0.25;
  }
}

.click-ring {
  position: absolute;
  inset: 14px;
  z-index: 2;
  border-radius: 50%;
  border: 2px solid rgba(var(--accent-rgb), 0.45);
  pointer-events: none;
}

.click-label {
  position: relative;
  z-index: 4;
  display: inline-flex;
  align-items: center;
  gap: 0.4rem;
  text-shadow: 0 4px 20px rgba(0, 0, 0, 0.6);
  transition: transform 0.08s var(--ease-out-soft);
}

.click-btn.is-pressing .click-label {
  transform: scale(0.94);
}

.hint {
  margin: 0;
  font-size: 0.72rem;
  line-height: 1.45;
  color: var(--muted);
  text-align: center;
  max-width: 22rem;
  opacity: 0.92;
}

.hint__touch {
  display: none;
}

.save-hint__touch {
  display: none;
}

.combo-hud {
  display: flex;
  align-items: center;
  justify-content: center;
  flex-wrap: wrap;
  gap: 0.35rem 0.55rem;
  padding: 0.38rem 0.9rem;
  border-radius: 999px;
  background: linear-gradient(165deg, rgba(var(--accent-rgb), 0.12) 0%, rgba(0, 0, 0, 0.22) 100%);
  border: 1px solid rgba(var(--accent-rgb), 0.28);
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.06), 0 6px 24px rgba(0, 0, 0, 0.35);
  font-size: 0.72rem;
  animation: combo-appear 0.35s var(--ease-out-soft);
}

.combo-hud__stats {
  display: inline-flex;
  align-items: baseline;
  gap: 0.3rem;
  flex-wrap: wrap;
  justify-content: center;
}

.combo-hud__bonus:empty {
  display: none;
}

@keyframes combo-appear {
  from {
    opacity: 0;
    transform: translateY(6px) scale(0.96);
  }
  to {
    opacity: 1;
    transform: translateY(0) scale(1);
  }
}

.combo-hud__label {
  font-weight: 600;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  color: var(--muted);
  font-size: 0.65rem;
}

.combo-hud__value {
  font-size: 1rem;
  font-weight: 700;
  color: var(--accent);
  letter-spacing: -0.02em;
}

.combo-hud__bonus {
  font-size: 0.72rem;
  color: var(--accent-2);
  opacity: 0.95;
}

.combo-hud.combo-hud--pulse {
  animation: combo-burst 0.4s var(--ease-spring);
}

@keyframes combo-burst {
  0% {
    transform: scale(1);
    border-color: rgba(var(--accent-rgb), 0.25);
    box-shadow: none;
  }
  42% {
    transform: scale(1.07);
    border-color: rgba(var(--accent-rgb), 0.55);
    box-shadow: 0 0 22px rgba(var(--accent-rgb), 0.22);
  }
  100% {
    transform: scale(1);
    border-color: rgba(var(--accent-rgb), 0.25);
    box-shadow: none;
  }
}

.upgrade-list,
.building-list {
  list-style: none;
  margin: 0;
  padding: 0;
  display: flex;
  flex-direction: column;
  gap: 0.45rem;
}

.row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.5rem;
  padding: 0.5rem 0.6rem;
  background: linear-gradient(180deg, rgba(255, 255, 255, 0.055) 0%, rgba(255, 255, 255, 0.02) 100%);
  border: 1px solid var(--stroke);
  border-radius: var(--radius-sm);
  transition: border-color var(--dur-fast) ease, transform var(--dur-fast) var(--ease-out-soft),
    background var(--dur-fast) ease, box-shadow var(--dur-fast) ease;
}

.row__glyph {
  flex-shrink: 0;
  display: flex;
  align-items: center;
  justify-content: center;
}

.row:hover {
  border-color: var(--stroke-strong);
  background: rgba(255, 255, 255, 0.05);
  transform: translateY(-2px);
  box-shadow: 0 8px 24px rgba(0, 0, 0, 0.2);
}

.row--locked {
  opacity: 0.88;
  border-style: dashed;
  border-color: rgba(250, 250, 250, 0.08);
  background: linear-gradient(180deg, rgba(255, 255, 255, 0.025) 0%, rgba(0, 0, 0, 0.12) 100%);
}

.row--locked:hover {
  transform: none;
  box-shadow: none;
  border-color: rgba(250, 250, 250, 0.1);
}

.row--peek-empty {
  justify-content: center;
  font-size: 0.78rem;
  line-height: 1.4;
  color: var(--muted);
  border-style: dashed;
  cursor: default;
}

.row--peek-empty:hover {
  transform: none;
  box-shadow: none;
}

.row-info {
  flex: 1;
  min-width: 0;
}

.row-title {
  font-weight: 600;
  font-size: 0.86rem;
  letter-spacing: -0.01em;
}

.row-desc {
  font-size: 0.72rem;
  color: var(--muted);
  margin-top: 0.08rem;
}

.row-meta {
  font-size: 0.65rem;
  color: var(--muted);
  margin-top: 0.22rem;
  opacity: 0.9;
}

.buy-btn-wrap {
  display: flex;
  flex-direction: column;
  align-items: flex-end;
  justify-content: center;
  gap: 0.2rem;
  flex-shrink: 0;
}

.buy-btn {
  border: 1px solid rgba(var(--accent-rgb), 0.35);
  background: linear-gradient(145deg, rgba(var(--accent-rgb), 0.14), rgba(var(--accent-2-rgb), 0.09));
  color: var(--text);
  padding: 0.35rem 0.65rem;
  border-radius: 8px;
  font: inherit;
  font-size: 0.76rem;
  font-weight: 600;
  cursor: pointer;
  touch-action: manipulation;
  transition: transform 0.15s ease, box-shadow 0.2s ease, opacity 0.2s ease, border-color 0.2s ease;
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.06), 0 8px 24px rgba(0, 0, 0, 0.28);
}

.buy-btn:focus-visible {
  outline: 2px solid rgba(var(--accent-rgb), 0.85);
  outline-offset: 2px;
}

.buy-btn:hover:not(:disabled) {
  border-color: rgba(var(--accent-rgb), 0.55);
  box-shadow: 0 10px 28px rgba(var(--accent-rgb), 0.14);
  transform: translateY(-1px);
}

.buy-btn:disabled {
  opacity: 0.4;
  cursor: not-allowed;
  transform: none;
  box-shadow: none;
}

.stats-panel .stat-grid {
  margin: 0;
  display: grid;
  gap: 0.4rem;
}

.stat-row {
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  gap: 1rem;
  padding: 0.4rem 0.55rem;
  background: rgba(255, 255, 255, 0.03);
  border: 1px solid var(--stroke);
  border-radius: var(--radius-sm);
}

.stat-row__dt {
  display: flex;
  align-items: center;
  gap: 0.4rem;
}

.stat-row dt {
  margin: 0;
  font-size: 0.76rem;
  color: var(--muted);
}

.stat-row dd {
  margin: 0;
  font-size: 0.82rem;
  font-weight: 500;
  color: var(--accent-2);
}

.lb-panel {
  border-top: 3px solid transparent;
  border-image: linear-gradient(90deg, rgba(var(--accent-rgb), 0.65), rgba(var(--accent-2-rgb), 0.5)) 1;
}

.lb-panel__intro {
  margin-bottom: 0.5rem;
}

.lb-eyebrow {
  display: inline-block;
  font-size: 0.68rem;
  font-weight: 700;
  letter-spacing: 0.14em;
  text-transform: uppercase;
  color: rgba(var(--accent-rgb), 0.85);
  margin-bottom: 0.35rem;
}

.lb-panel .panel__head,
.lb-panel .lb-panel__head {
  margin-bottom: 0.35rem;
}

.lb-panel__head {
  align-items: center;
}

.lb-panel__sub {
  margin: 0;
  font-size: 0.72rem;
  color: var(--muted);
  line-height: 1.4;
  max-width: 40rem;
}

.lb-refresh-btn {
  display: inline-flex;
  align-items: center;
  gap: 0.35rem;
  border: 1px solid var(--stroke-strong);
  background: rgba(0, 0, 0, 0.2);
  color: var(--muted);
  font: inherit;
  font-size: 0.78rem;
  font-weight: 600;
  padding: 0.35rem 0.65rem;
  border-radius: 10px;
  cursor: pointer;
  transition: color 0.15s ease, border-color 0.15s ease, background 0.15s ease;
}

.lb-refresh-btn:hover {
  color: var(--text);
  border-color: rgba(var(--accent-rgb), 0.35);
  background: rgba(var(--accent-rgb), 0.06);
}

.icon--lb-refresh {
  flex-shrink: 0;
  opacity: 0.9;
}

.lb-memberbar {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 0.5rem;
  margin-bottom: 0.5rem;
  padding: 0.45rem 0.65rem;
  border-radius: var(--radius-sm);
  background: linear-gradient(135deg, rgba(var(--accent-rgb), 0.08), rgba(var(--accent-2-rgb), 0.06));
  border: 1px solid rgba(var(--accent-rgb), 0.22);
}

.lb-memberbar__who {
  display: flex;
  align-items: center;
  gap: 0.65rem;
  min-width: 0;
}

.lb-avatar {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 2.25rem;
  height: 2.25rem;
  border-radius: 999px;
  font-size: 1rem;
  font-weight: 700;
  color: #18181b;
  background: linear-gradient(145deg, rgba(var(--accent-rgb), 0.95), rgba(var(--accent-2-rgb), 0.85));
  box-shadow: 0 4px 14px rgba(0, 0, 0, 0.25);
}

.lb-memberbar__text {
  display: flex;
  flex-direction: column;
  gap: 0.1rem;
  min-width: 0;
}

.lb-memberbar__eyebrow {
  font-size: 0.68rem;
  font-weight: 700;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  color: var(--muted);
}

.lb-memberbar__name {
  font-size: 1rem;
  font-weight: 600;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.lb-chips {
  display: flex;
  flex-wrap: wrap;
  gap: 0.35rem;
  margin-bottom: 0.5rem;
  min-height: 1.25rem;
}

.lb-chip {
  display: inline-flex;
  align-items: center;
  padding: 0.28rem 0.55rem;
  border-radius: 999px;
  font-size: 0.68rem;
  font-weight: 600;
  letter-spacing: 0.02em;
  color: var(--muted);
  background: rgba(0, 0, 0, 0.28);
  border: 1px solid var(--stroke);
}

.lb-yours {
  display: flex;
  flex-direction: column;
  gap: 0.4rem;
}

.lb-yours__grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 0.45rem;
}

@media (max-width: 520px) {
  .lb-yours__grid {
    grid-template-columns: 1fr;
  }
}

.lb-stat {
  padding: 0.4rem 0.5rem;
  border-radius: var(--radius-sm);
  background: rgba(255, 255, 255, 0.03);
  border: 1px solid var(--stroke);
}

.lb-stat__label {
  display: block;
  font-size: 0.68rem;
  font-weight: 700;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--muted);
  margin-bottom: 0.2rem;
}

.lb-stat__value {
  display: block;
  font-size: 1.02rem;
  font-weight: 700;
  color: var(--text);
  line-height: 1.2;
}

.lb-stat__hint {
  display: block;
  font-size: 0.72rem;
  color: var(--muted);
  margin-top: 0.15rem;
}

.lb-your-line {
  margin: 0;
  font-size: 0.74rem;
  line-height: 1.38;
  color: var(--accent);
}

.lb-name-row--block {
  flex-direction: column;
  align-items: stretch;
}

.lb-name-row--block .lb-name-input {
  max-width: none;
}

.lb-board {
  --lb-col-rank: 4.85rem;
  display: flex;
  flex-direction: column;
  gap: 0.35rem;
}

.lb-board:has(#lb-empty:not([hidden])) .lb-table-head {
  display: none;
}

.lb-table-head {
  display: grid;
  grid-template-columns: var(--lb-col-rank) 1fr minmax(4.25rem, auto);
  gap: 0.5rem;
  align-items: center;
  padding: 0 0.65rem;
  font-size: 0.68rem;
  font-weight: 700;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--muted);
}

.lb-table-head__rank {
  display: inline-flex;
  align-items: center;
  gap: 0.25rem;
  min-width: 0;
}

.lb-table-head__medal-spacer {
  flex-shrink: 0;
  width: 1.35rem;
  height: 1em;
}

.lb-table-head__hash {
  font-variant-numeric: tabular-nums;
}

.lb-table-head__score {
  text-align: right;
}

.lb-empty {
  padding: 1rem 0.85rem;
  border-radius: var(--radius-sm);
  text-align: center;
  background: rgba(0, 0, 0, 0.2);
  border: 1px dashed var(--stroke-strong);
}

.lb-empty__title {
  margin: 0 0 0.35rem;
  font-size: 0.92rem;
  font-weight: 600;
  color: var(--text);
}

.lb-empty__text {
  margin: 0;
  font-size: 0.8rem;
  line-height: 1.45;
  color: var(--muted);
}

.login-body {
  min-height: 100%;
  min-height: 100svh;
  margin: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: max(1.25rem, env(safe-area-inset-top, 0px)) max(1.25rem, env(safe-area-inset-right, 0px))
    max(1.25rem, env(safe-area-inset-bottom, 0px)) max(1.25rem, env(safe-area-inset-left, 0px));
}

.login-shell {
  width: 100%;
  max-width: 22rem;
  position: relative;
  z-index: 1;
}

.login-card {
  padding: 1.35rem 1.25rem 1.5rem;
}

.login-title {
  margin: 0.15rem 0 0.35rem;
  font-family: var(--font-display);
  font-size: 1.35rem;
  font-weight: 700;
  letter-spacing: -0.02em;
}

.login-sub {
  margin: 0 0 1rem;
  font-size: 0.84rem;
  color: var(--muted);
  line-height: 1.45;
}

.login-fields {
  margin-bottom: 0.5rem;
}

.login-actions {
  margin-top: 0.25rem;
}

.lb-auth {
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
  margin-bottom: 0.65rem;
  padding: 0.65rem 0.75rem;
  border-radius: var(--radius-sm);
  background: rgba(255, 255, 255, 0.04);
  border: 1px solid var(--stroke);
}

.lb-auth--compact {
  flex-direction: row;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 0.5rem 0.85rem;
}

.lb-auth-form-wrap {
  display: flex;
  flex-direction: column;
  gap: 0.55rem;
}

.lb-auth-fields {
  display: flex;
  flex-wrap: wrap;
  gap: 0.45rem;
}

.lb-auth-fields .lb-name-input {
  flex: 1;
  min-width: 7rem;
}

.lb-auth-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 0.45rem;
  align-items: center;
}

.lb-btn {
  border: 1px solid rgba(var(--accent-rgb), 0.45);
  background: linear-gradient(145deg, rgba(var(--accent-rgb), 0.2), rgba(var(--accent-2-rgb), 0.12));
  color: var(--text);
  font: inherit;
  font-size: 0.8rem;
  font-weight: 600;
  padding: 0.4rem 0.85rem;
  border-radius: 10px;
  cursor: pointer;
  transition: transform 0.12s ease, border-color 0.15s ease;
}

.lb-btn:hover {
  transform: translateY(-1px);
  border-color: rgba(var(--accent-rgb), 0.65);
}

.lb-btn--ghost {
  background: transparent;
  border-color: var(--stroke-strong);
  color: var(--muted);
}

.lb-btn--ghost:hover {
  color: var(--text);
  border-color: var(--stroke-strong);
}

.lb-auth-signed {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 0.5rem 0.85rem;
  justify-content: space-between;
}

.lb-auth__user {
  font-size: 0.84rem;
  color: var(--muted);
}

.lb-auth__user strong {
  color: var(--text);
  font-weight: 600;
}

.lb-auth-msg {
  margin: 0;
  min-height: 1.1em;
  font-size: 0.75rem;
  color: var(--danger);
}

.lb-toolbar {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 0.5rem;
  margin-bottom: 0.55rem;
}

.lb-live-chip {
  font-size: 0.65rem;
  font-weight: 700;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  padding: 0.3rem 0.6rem;
  border-radius: 999px;
  border: 1px solid var(--stroke);
  background: rgba(0, 0, 0, 0.28);
  color: var(--muted);
  max-width: 100%;
  line-height: 1.2;
}

.lb-live-chip[hidden] {
  display: none !important;
}

.lb-live-chip--live {
  color: rgba(134, 239, 172, 0.95);
  border-color: rgba(74, 222, 128, 0.4);
  background: rgba(22, 101, 52, 0.2);
}

.lb-live-chip--busy {
  color: rgba(253, 224, 71, 0.95);
  border-color: rgba(250, 204, 21, 0.4);
  background: rgba(113, 63, 18, 0.2);
}

.lb-scope {
  display: inline-flex;
  border-radius: 999px;
  padding: 3px;
  background: rgba(0, 0, 0, 0.35);
  border: 1px solid var(--stroke);
  gap: 2px;
}

.lb-scope-btn {
  border: none;
  background: transparent;
  color: var(--muted);
  font: inherit;
  font-size: 0.78rem;
  font-weight: 600;
  padding: 0.35rem 0.85rem;
  border-radius: 999px;
  cursor: pointer;
  transition: color 0.15s ease, background 0.15s ease;
}

.lb-scope-btn:hover {
  color: var(--text);
}

.lb-scope-btn--on {
  color: #18181b;
  background: linear-gradient(120deg, rgba(var(--accent-rgb), 0.95), rgba(var(--accent-2-rgb), 0.9));
  box-shadow: 0 4px 14px rgba(var(--accent-rgb), 0.15);
}

.lb-offline {
  padding: 0.65rem 0.75rem;
  border-radius: var(--radius-sm);
  background: rgba(251, 113, 113, 0.06);
  border: 1px solid rgba(251, 113, 113, 0.2);
}

.lb-offline__text {
  margin: 0;
  font-size: 0.82rem;
  color: var(--muted);
  line-height: 1.45;
}

.lb-main {
  display: flex;
  flex-direction: column;
  gap: 0.65rem;
}

.lb-name-row {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 0.5rem 0.75rem;
}

.lb-name-row__label {
  font-size: 0.78rem;
  font-weight: 600;
  color: var(--muted);
  letter-spacing: 0.06em;
  text-transform: uppercase;
}

.lb-name-input {
  flex: 1;
  min-width: 8rem;
  max-width: 16rem;
  padding: 0.45rem 0.65rem;
  border-radius: 10px;
  border: 1px solid var(--stroke-strong);
  background: rgba(0, 0, 0, 0.25);
  color: var(--text);
  font: inherit;
  font-size: 0.88rem;
}

.lb-name-input:focus {
  outline: none;
  border-color: rgba(var(--accent-rgb), 0.45);
  box-shadow: 0 0 0 2px rgba(var(--accent-rgb), 0.12);
}

@media (max-width: 960px) {
  .lb-name-input {
    font-size: 16px;
    min-height: var(--tap-min);
  }
}

.lb-list {
  margin: 0;
  padding: 0;
  list-style: none;
  display: flex;
  flex-direction: column;
  gap: 0.35rem;
  max-height: 17rem;
  overflow: auto;
}

.lb-list__item {
  display: grid;
  grid-template-columns: var(--lb-col-rank, 4.85rem) 1fr minmax(4.25rem, auto);
  gap: 0.5rem;
  align-items: center;
  padding: 0.45rem 0.65rem;
  border-radius: var(--radius-sm);
  background: rgba(255, 255, 255, 0.03);
  border: 1px solid var(--stroke);
  font-size: 0.84rem;
}

.lb-list__left {
  display: inline-flex;
  align-items: center;
  gap: 0.25rem;
  min-width: 0;
  overflow: hidden;
}

.lb-list__item--self {
  border-color: rgba(var(--accent-rgb), 0.35);
  background: rgba(var(--accent-rgb), 0.06);
}

.lb-list__item--online:not(.lb-list__item--self) {
  border-color: rgba(134, 239, 172, 0.25);
}

.lb-online-dot {
  display: inline-block;
  width: 0.5rem;
  height: 0.5rem;
  border-radius: 50%;
  background: #86efac;
  box-shadow: 0 0 5px rgba(134, 239, 172, 0.7);
  margin-left: 0.4rem;
  vertical-align: middle;
  flex-shrink: 0;
  animation: lb-dot-pulse 2.4s ease-in-out infinite;
}

@keyframes lb-dot-pulse {
  0%, 100% { opacity: 1; transform: scale(1); }
  50% { opacity: 0.55; transform: scale(0.75); }
}

@media (prefers-reduced-motion: reduce) {
  .lb-online-dot {
    animation: none;
  }
}

.lb-list__medal {
  flex-shrink: 0;
  font-size: 0.95rem;
  line-height: 1;
  width: 1.35rem;
  text-align: center;
}

.lb-list__medal--empty {
  visibility: hidden;
  pointer-events: none;
}

.lb-list__rank {
  flex-shrink: 0;
  min-width: 2rem;
  font-weight: 700;
  color: var(--muted);
  font-variant-numeric: tabular-nums;
}

.lb-list__item:nth-child(1) .lb-list__rank {
  color: #fde68a;
}

.lb-list__item:nth-child(2) .lb-list__rank {
  color: #e5e7eb;
}

.lb-list__item:nth-child(3) .lb-list__rank {
  color: #fdba74;
}

.lb-list__name {
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  color: var(--text);
}

.lb-list__score {
  font-weight: 600;
  color: var(--accent-2);
  font-variant-numeric: tabular-nums;
  text-align: right;
  justify-self: end;
}

.lb-status {
  margin: 0;
  min-height: 1.2em;
  font-size: 0.72rem;
  color: var(--muted);
}

.text-btn--small {
  font-size: 0.78rem;
}

.footer {
  display: flex;
  flex-wrap: wrap;
  flex-direction: row;
  align-items: center;
  justify-content: space-between;
  gap: 0.55rem 0.85rem;
  margin-top: 0.15rem;
  padding: 0.55rem 0.75rem;
  font-size: 0.72rem;
  color: var(--muted);
  background: linear-gradient(180deg, rgba(255, 255, 255, 0.04) 0%, rgba(9, 9, 11, 0.65) 100%);
  border: 1px solid var(--stroke);
  border-radius: var(--radius);
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.05);
}

.footer-actions {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 0.65rem 1.1rem;
}

.footer-save-row {
  display: flex;
  flex-wrap: wrap;
  align-items: baseline;
  justify-content: space-between;
  gap: 0.35rem 1rem;
  flex: 1;
  min-width: 0;
}

.save-hint {
  line-height: 1.45;
  max-width: min(100%, 36rem);
}

.save-hint__lead {
  font-weight: 600;
  color: rgba(228, 228, 231, 0.92);
}

.cloud-sync-status {
  flex-shrink: 0;
  font-size: 0.68rem;
  font-weight: 500;
  letter-spacing: 0.02em;
  color: var(--muted);
  white-space: nowrap;
}

.cloud-sync-status.cloud-sync-status--synced {
  color: rgba(52, 211, 153, 0.88);
}

.cloud-sync-status.cloud-sync-status--busy {
  color: rgba(251, 191, 36, 0.92);
}

.cloud-sync-status.cloud-sync-status--offline,
.cloud-sync-status.cloud-sync-status--pending {
  color: rgba(161, 161, 170, 0.95);
}

@media (max-width: 640px) {
  .footer {
    flex-direction: column;
    align-items: stretch;
  }

  .footer-save-row {
    flex-direction: column;
    align-items: stretch;
  }

  .cloud-sync-status {
    white-space: normal;
  }
}

.text-btn {
  background: none;
  border: none;
  color: var(--muted);
  font: inherit;
  font-size: 0.85rem;
  cursor: pointer;
  text-decoration: underline;
  text-underline-offset: 3px;
  padding: 0;
  border-radius: 4px;
  transition: color 0.2s ease;
}

.text-btn:hover {
  color: var(--text);
}

.text-btn:focus-visible {
  outline: 2px solid rgba(var(--accent-rgb), 0.75);
  outline-offset: 3px;
  text-decoration: none;
}

.text-btn.danger:hover {
  color: var(--danger);
}

.text-btn--icon {
  display: inline-flex;
  align-items: center;
  gap: 0.35rem;
  text-decoration: none;
  padding: 0.2rem 0;
  border-radius: 6px;
  transition: color var(--dur-fast) ease, background var(--dur-fast) ease;
}

.text-btn--icon:hover {
  background: rgba(255, 255, 255, 0.04);
}

.text-btn--icon.danger:hover {
  background: rgba(251, 113, 113, 0.08);
}

.floating {
  position: fixed;
  pointer-events: none;
  font-family: var(--font-mono);
  font-weight: 600;
  font-size: 0.95rem;
  color: var(--accent);
  text-shadow: 0 0 20px rgba(var(--accent-rgb), 0.6);
  animation: float-up 0.82s var(--ease-out-soft) forwards;
  z-index: 50;
}

@keyframes float-up {
  from {
    opacity: 1;
    transform: translateY(0) scale(1);
  }
  to {
    opacity: 0;
    transform: translateY(-52px) scale(1.06);
  }
}

@media (prefers-reduced-motion: reduce) {
  .ambient__glow,
  .click-halo,
  .click-btn.is-ripple::after,
  .floating,
  .conduit__path,
  .conduit__spark,
  .gen-feed__path,
  .gen-feed__spark,
  .reservoir__surface,
  .reservoir__fill::before,
  .reservoir--passive .reservoir__fill::after,
  .reservoir--ping .reservoir__glass,
  .milestone-toast,
  .stat-card--pulse,
  .logo-glyph__shard,
  .combo-hud,
  .combo-hud.combo-hud--pulse,
  .core-stage--kick,
  .core-ripple,
  .core-ripple.is-on,
  .conduit--poke .conduit__svg,
  .reservoir--poke,
  .gen-feed.gen-feed--active.gen-feed--poke {
    animation: none !important;
  }

  .core-wrap {
    transition: none;
    transform: none;
  }

  .reservoir__fill {
    transition: none;
  }

  .gen-feed {
    transition: none;
  }

  .glass:hover,
  .row:hover {
    transform: none;
  }
}

/* ── Collapsible panels ──────────────────────────────────────────────────────── */

.panel__head {
  display: flex;
  align-items: flex-start;
  gap: 8px;
}

.panel__head-main {
  flex: 1;
  min-width: 0;
}

.panel__toggle {
  flex-shrink: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  width: 28px;
  height: 28px;
  border: none;
  border-radius: 8px;
  background: transparent;
  color: var(--muted);
  cursor: pointer;
  transition: background var(--dur-fast), color var(--dur-fast);
  margin-top: 2px;
}

.panel__toggle:hover {
  background: rgba(255, 255, 255, 0.06);
  color: var(--text);
}

.panel__toggle:focus-visible {
  outline: 2px solid rgba(var(--accent-2-rgb), 0.75);
  outline-offset: 2px;
}

.panel__chevron {
  display: block;
  transition: transform 0.26s var(--ease-in-out-smooth);
}

.panel--collapsed .panel__chevron {
  transform: rotate(-90deg);
}

/* Grid-rows trick — smooth height animate with no JS height measuring */
.panel__body {
  display: grid;
  grid-template-rows: 1fr;
  transition: grid-template-rows 0.28s var(--ease-in-out-smooth);
}

.panel--collapsed .panel__body {
  grid-template-rows: 0fr;
}

.panel__body-inner {
  overflow: hidden;
  min-height: 0;
}

/* Tighten bottom padding when collapsed so header sits flush */
.panel--collapsed {
  padding-bottom: 14px;
}

/* Leaderboard head button group */
.lb-panel__head-btns {
  display: flex;
  align-items: center;
  gap: 4px;
  flex-shrink: 0;
}

/* ── Prestige / Rebirth panel ───────────────────────────────────────────────── */

.prestige-panel {
  max-width: none;
  margin: 0;
  min-width: 0;
}

.prestige-body {
  display: flex;
  flex-direction: column;
  gap: 1.1rem;
}

.prestige-info {
  display: flex;
  flex-direction: column;
  gap: 0.75rem;
}

.prestige-stat-row {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 0.55rem;
}

.prestige-stat {
  display: flex;
  flex-direction: column;
  gap: 3px;
  background: rgba(255, 255, 255, 0.03);
  border: 1px solid var(--stroke);
  border-radius: var(--radius-sm);
  padding: 0.45rem 0.65rem;
  min-width: 0;
}

.prestige-stat--highlight {
  border-color: rgba(var(--accent-2-rgb), 0.35);
  background: rgba(var(--accent-2-rgb), 0.06);
}

.prestige-stat__label {
  font-size: 0.72rem;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--muted);
}

.prestige-stat__value {
  font-size: 1.05rem;
  font-weight: 600;
  color: var(--accent-2);
}

.prestige-meter {
  display: flex;
  flex-direction: column;
  gap: 0.4rem;
  padding: 0.55rem 0.65rem;
  border-radius: var(--radius-sm);
  border: 1px solid var(--stroke);
  background: rgba(0, 0, 0, 0.12);
}

.prestige-meter__head {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 0.75rem;
}

.prestige-meter__title {
  font-size: 0.72rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.07em;
  color: var(--muted);
}

.prestige-meter__label {
  font-size: 0.72rem;
  color: var(--text);
  opacity: 0.9;
}

.prestige-progress {
  position: relative;
  height: 8px;
  border-radius: 999px;
  overflow: hidden;
  background: rgba(255, 255, 255, 0.06);
  border: 1px solid rgba(255, 255, 255, 0.06);
}

.prestige-progress__fill {
  height: 100%;
  width: 0%;
  border-radius: inherit;
  background: linear-gradient(
    90deg,
    rgba(var(--accent-2-rgb), 0.35),
    rgba(var(--accent-2-rgb), 0.95)
  );
  transition: width 0.35s var(--ease-in-out-smooth);
}

.prestige-ready {
  display: flex;
  align-items: flex-start;
  gap: 0.45rem;
  margin: 0;
  padding: 0.55rem 0.65rem;
  border-radius: var(--radius-sm);
  border: 1px solid rgba(var(--accent-2-rgb), 0.35);
  background: rgba(var(--accent-2-rgb), 0.08);
  font-size: 0.78rem;
  line-height: 1.45;
  color: rgba(var(--accent-2-rgb), 0.95);
}

.prestige-ready__icon {
  flex-shrink: 0;
  margin-top: 2px;
  opacity: 0.9;
}

.prestige-rules {
  display: grid;
  grid-template-columns: 1fr auto 1fr;
  align-items: stretch;
  gap: 0.65rem;
  padding: 0.5rem 0.6rem;
  border-radius: var(--radius-sm);
  border: 1px dashed rgba(255, 255, 255, 0.08);
  background: rgba(255, 255, 255, 0.02);
}

.prestige-rules__item {
  display: flex;
  flex-direction: column;
  gap: 0.2rem;
  min-width: 0;
}

.prestige-rules__tag {
  font-size: 0.65rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.09em;
  color: var(--muted);
}

.prestige-rules__text {
  font-size: 0.76rem;
  line-height: 1.4;
  color: var(--text);
  opacity: 0.88;
}

.prestige-rules__sep {
  width: 1px;
  align-self: stretch;
  background: rgba(255, 255, 255, 0.1);
  min-height: 2.25rem;
}

@media (max-width: 780px) {
  .prestige-rules {
    grid-template-columns: 1fr;
    gap: 0.55rem;
  }

  .prestige-rules__sep {
    display: none;
  }
}

.prestige-cta {
  display: grid;
  grid-template-columns: minmax(0, auto) minmax(0, 1fr);
  align-items: center;
  gap: 0.85rem 1rem;
}

.prestige-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  padding: 0.45rem 1rem;
  border-radius: 999px;
  border: 1.5px solid var(--accent-2);
  background: rgba(var(--accent-2-rgb), 0.08);
  color: var(--accent-2);
  font-family: var(--font);
  font-size: 0.84rem;
  font-weight: 600;
  cursor: pointer;
  transition: background var(--dur-fast), box-shadow var(--dur-fast), opacity var(--dur-fast);
  align-self: center;
}

.prestige-btn:hover:not(:disabled) {
  background: rgba(var(--accent-2-rgb), 0.18);
  box-shadow: 0 0 20px rgba(var(--accent-2-rgb), 0.25);
}

.prestige-btn:disabled {
  opacity: 0.4;
  cursor: not-allowed;
}

.prestige-hint {
  font-size: 0.74rem;
  color: var(--muted);
  margin: 0;
  line-height: 1.45;
}

.prestige-hint--ready {
  color: rgba(var(--accent-2-rgb), 0.85);
}

/* ── Skill Tree ──────────────────────────────────────────────────────────────── */

.skill-tree-section {
  display: flex;
  flex-direction: column;
  gap: 0.55rem;
  margin-top: 0.15rem;
  padding-top: 0.85rem;
  border-top: 1px solid rgba(255, 255, 255, 0.06);
}

.skill-tree__title {
  display: flex;
  align-items: center;
  gap: 7px;
  margin: 0;
  font-family: var(--font);
  font-size: 0.85rem;
  font-weight: 600;
  color: var(--muted);
  text-transform: uppercase;
  letter-spacing: 0.07em;
}

.skill-tree__subtitle {
  font-weight: 400;
  text-transform: none;
  letter-spacing: 0;
  color: var(--muted);
  opacity: 0.7;
}

.skill-list {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(168px, 1fr));
  gap: 8px;
  list-style: none;
  padding: 0;
  margin: 0;
}

.skill-card {
  display: flex;
  flex-direction: column;
  gap: 6px;
  background: rgba(255, 255, 255, 0.03);
  border: 1px solid var(--stroke);
  border-radius: var(--radius-sm);
  padding: 0.55rem 0.65rem;
  transition: border-color var(--dur-fast), background var(--dur-fast);
}

.skill-card:not(.skill-card--locked):hover {
  border-color: var(--stroke-strong);
  background: rgba(255, 255, 255, 0.05);
}

.skill-card--locked {
  opacity: 0.45;
}

.skill-card--maxed {
  border-color: rgba(var(--accent-rgb), 0.22);
  background: rgba(var(--accent-rgb), 0.04);
}

.skill-card__header {
  display: flex;
  align-items: center;
  gap: 7px;
}

.skill-card__icon {
  color: var(--accent-2);
  opacity: 0.9;
  flex-shrink: 0;
}

.skill-card--maxed .skill-card__icon {
  color: var(--accent);
}

.skill-card__name {
  font-size: 0.88rem;
  font-weight: 600;
  flex: 1;
  min-width: 0;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.skill-card__level {
  font-size: 0.72rem;
  color: var(--muted);
  flex-shrink: 0;
}

.skill-card--maxed .skill-card__level {
  color: var(--accent);
}

.skill-card__desc {
  margin: 0;
  font-size: 0.78rem;
  color: var(--muted);
  line-height: 1.45;
}

.skill-card__req {
  margin: 0;
  font-size: 0.72rem;
  color: rgba(var(--accent-2-rgb), 0.55);
  line-height: 1.4;
}

.skill-buy-btn {
  margin-top: auto;
  padding: 6px 12px;
  border-radius: 8px;
  border: 1px solid var(--stroke-strong);
  background: rgba(255, 255, 255, 0.04);
  color: var(--text);
  font-family: var(--font-mono);
  font-size: 0.8rem;
  cursor: pointer;
  transition: background var(--dur-fast), border-color var(--dur-fast), color var(--dur-fast);
  text-align: center;
}

.skill-buy-btn:hover:not(:disabled) {
  background: rgba(var(--accent-2-rgb), 0.15);
  border-color: var(--accent-2);
  color: var(--accent-2);
}

.skill-buy-btn:disabled {
  opacity: 0.4;
  cursor: not-allowed;
}

.skill-card--maxed .skill-buy-btn {
  border-color: rgba(var(--accent-rgb), 0.3);
  color: var(--accent);
  cursor: default;
  opacity: 0.7;
}

.skill-card--peek-empty {
  grid-column: 1 / -1;
  justify-content: center;
  text-align: center;
  font-size: 0.78rem;
  line-height: 1.45;
  color: var(--muted);
  border-style: dashed;
  cursor: default;
}

.skill-card--peek-empty:hover {
  border-color: var(--stroke);
  background: rgba(255, 255, 255, 0.02);
  transform: none;
}

/* ═══ Phone & small tablet — touch-first layout ═══════════════════════════════ */

@media (max-width: 960px) {
  :root {
    --tap-min: 40px;
    /* Keep mobile compact — large radii add perceived height */
    --radius: 12px;
    --radius-sm: 8px;
  }

  .hint__desk {
    display: none;
  }

  .hint__touch {
    display: inline;
  }

  .save-hint__desk {
    display: none;
  }

  .save-hint__touch {
    display: inline;
  }

  .app {
    gap: 0.55rem;
    padding-top: max(clamp(0.5rem, 2svw, 1.1rem), env(safe-area-inset-top, 0px));
    padding-left: max(clamp(0.55rem, 2.2svw, 1.1rem), env(safe-area-inset-left, 0px));
    padding-right: max(clamp(0.55rem, 2.2svw, 1.1rem), env(safe-area-inset-right, 0px));
    padding-bottom: max(clamp(1.1rem, 3svw, 2rem), env(safe-area-inset-bottom, 0px));
    overscroll-behavior-y: contain;
  }

  .core-header__desk {
    display: none;
  }

  .core-header__touch {
    display: block;
  }

  .hero {
    gap: 0.65rem;
  }

  .brand-block {
    gap: 0.55rem;
  }

  .logo-glyph {
    width: 40px;
    height: 40px;
    border-radius: 13px;
  }

  .logo-glyph::after {
    border-radius: 10px;
  }

  .title {
    font-size: clamp(1.2rem, 5.25svw, 1.52rem);
  }

  .brand-text .eyebrow {
    font-size: 0.62rem;
    letter-spacing: 0.14em;
  }

  .stat-deck {
    display: flex;
    flex-direction: row;
    flex-wrap: nowrap;
    gap: 0.55rem;
    overflow-x: auto;
    overflow-y: hidden;
    scroll-snap-type: x mandatory;
    -webkit-overflow-scrolling: touch;
    padding: 0.15rem 0 0.35rem;
    padding-left: max(0.15rem, env(safe-area-inset-left, 0px));
    padding-right: max(0.15rem, env(safe-area-inset-right, 0px));
    margin: 0 -0.15rem;
    scroll-padding-inline: 0.35rem;
    scrollbar-width: thin;
  }

  .stat-deck::-webkit-scrollbar {
    height: 4px;
  }

  .stat-deck::-webkit-scrollbar-thumb {
    background: rgba(var(--accent-rgb), 0.25);
    border-radius: 4px;
  }

  .stat-card {
    /* vmin tracks the shorter edge — stable when only the dynamic URL bar changes vh */
    flex: 0 0 min(40vmin, 168px);
    scroll-snap-align: start;
    padding: 0.55rem 0.65rem;
  }

  .stat-card__label {
    font-size: 0.68rem;
  }

  .stat-card__value {
    font-size: clamp(0.98rem, 3.35svw, 1.28rem);
  }

  .stat-card__hint {
    font-size: 0.65rem;
  }

  .layout {
    gap: 0.65rem;
  }

  /* Long lists scroll inside panels on small screens */
  .upgrades-panel:not(.panel--collapsed) .panel__body-inner,
  .buildings-panel:not(.panel--collapsed) .panel__body-inner,
  .prestige-panel:not(.panel--collapsed) .panel__body-inner {
    max-height: min(50svh, 22rem);
    overflow-y: auto;
    overscroll-behavior: contain;
    -webkit-overflow-scrolling: touch;
    scrollbar-gutter: stable;
  }

  .panel__head--inline {
    align-items: flex-start;
  }

  .panel__head--inline .panel__head-main {
    flex: 1;
    min-width: 0;
  }

  .panel__toggle {
    min-width: var(--tap-min);
    min-height: var(--tap-min);
    width: var(--tap-min);
    height: var(--tap-min);
    border-radius: 10px;
    margin-top: 0;
    touch-action: manipulation;
  }

  .panel {
    padding: 0.8rem 0.85rem;
  }

  .panel__head {
    margin-bottom: 0.65rem;
  }

  .panel__title {
    font-size: 0.92rem;
  }

  .panel__title--with-icon .icon--panel {
    width: 17px;
    height: 17px;
  }

  .panel__sub {
    font-size: 0.74rem;
  }

  .click-btn {
    width: min(62vmin, 210px);
    height: min(62vmin, 210px);
    min-width: 158px;
    min-height: 158px;
    font-size: 0.78rem;
    touch-action: manipulation;
  }

  .core-wrap {
    padding-top: 0.25rem;
    gap: 0.65rem;
  }

  .core-footer {
    padding-top: 0.4rem;
    gap: 0.5rem;
  }

  .hint {
    font-size: 0.72rem;
    max-width: 22rem;
  }

  .combo-hud {
    min-height: 40px;
    padding: 0.35rem 0.8rem;
    font-size: 0.72rem;
  }

  .upgrade-list,
  .building-list {
    gap: 0.45rem;
  }

  .row {
    flex-wrap: wrap;
    align-items: flex-start;
    padding: 0.5rem 0.6rem;
    gap: 0.5rem;
  }

  .row-title {
    font-size: 0.86rem;
  }

  .row-desc {
    font-size: 0.74rem;
    margin-top: 0.1rem;
  }

  .row-meta {
    font-size: 0.66rem;
    margin-top: 0.25rem;
  }

  .buy-btn {
    min-height: var(--tap-min);
    padding: 0.4rem 0.75rem;
    font-size: 0.78rem;
    touch-action: manipulation;
  }

  .row .buy-btn-wrap {
    flex-direction: column;
    align-items: flex-end;
    margin-left: auto;
  }

  .footer {
    padding-bottom: env(safe-area-inset-bottom, 0px);
  }

  .footer-actions {
    gap: 0.5rem 1rem;
  }

  .text-btn--icon {
    min-height: var(--tap-min);
    padding: 0.35rem 0.25rem;
    align-items: center;
  }

  .lb-refresh-btn {
    min-height: var(--tap-min);
    padding: 0.4rem 0.75rem;
  }

  .lb-scope-btn {
    min-height: calc(var(--tap-min) - 6px);
    padding: 0.4rem 0.75rem;
  }

  .lb-list {
    max-height: min(48svh, 20rem);
  }

  .lb-eyebrow {
    font-size: 0.62rem;
    margin-bottom: 0.25rem;
  }

  .lb-panel__sub {
    font-size: 0.72rem;
    line-height: 1.42;
  }

  .lb-memberbar {
    padding: 0.5rem 0.65rem;
    margin-bottom: 0.55rem;
    gap: 0.45rem;
  }

  .lb-avatar {
    width: 2rem;
    height: 2rem;
    font-size: 0.88rem;
  }

  .lb-memberbar__name {
    font-size: 0.88rem;
  }

  .lb-memberbar__eyebrow {
    font-size: 0.6rem;
  }

  .lb-table-head,
  .lb-list__item {
    font-size: 0.78rem;
  }

  .lb-stat__label,
  .lb-stat__hint {
    font-size: 0.62rem;
  }

  .lb-stat__value {
    font-size: 0.95rem;
  }

  .lb-your-line {
    font-size: 0.72rem;
  }

  .lb-chips {
    font-size: 0.65rem;
  }

  .conduit {
    width: clamp(48px, 12svw, 100px);
    height: 48px;
  }

  .stats-panel .stat-row {
    padding: 0.45rem 0.55rem;
  }

  .stat-row__dt {
    font-size: 0.74rem;
  }

  .stat-row dd {
    font-size: 0.84rem;
  }

  .lb-panel__intro .panel__head--inline {
    flex-wrap: wrap;
  }

  .prestige-stat-row {
    grid-template-columns: 1fr;
    gap: 0.5rem;
  }

  .prestige-stat {
    width: 100%;
    padding: 10px 14px;
    min-width: 0;
  }

  .prestige-stat__label {
    font-size: 0.65rem;
  }

  .prestige-stat__value {
    font-size: 1.05rem;
  }

  .prestige-meter {
    padding: 10px 12px;
    gap: 0.45rem;
  }

  .prestige-meter__head {
    flex-wrap: wrap;
  }

  .prestige-rules {
    grid-template-columns: 1fr;
    gap: 0.5rem;
  }

  .prestige-rules__sep {
    display: none;
  }

  .prestige-cta {
    grid-template-columns: 1fr;
    gap: 0.55rem;
  }

  .prestige-btn {
    width: 100%;
    justify-content: center;
    min-height: var(--tap-min);
    padding: 9px 18px;
    font-size: 0.86rem;
  }

  .prestige-hint {
    font-size: 0.74rem;
    text-align: center;
  }

  .prestige-ready {
    font-size: 0.74rem;
    padding: 10px 12px;
  }

  .skill-tree-section {
    gap: 12px;
  }

  .skill-tree__title {
    font-size: 0.78rem;
  }

  .skill-list {
    grid-template-columns: 1fr;
    gap: 8px;
  }

  .skill-card {
    padding: 10px 12px;
    gap: 6px;
  }

  .skill-card__name {
    font-size: 0.82rem;
  }

  .skill-card__desc {
    font-size: 0.72rem;
  }

  .skill-card__level,
  .skill-card__req {
    font-size: 0.66rem;
  }

  .skill-buy-btn {
    min-height: var(--tap-min);
    padding: 0.35rem 0.85rem;
    font-size: 0.78rem;
    touch-action: manipulation;
  }

  .footer-actions {
    gap: 0.35rem 0.75rem;
  }

  .text-btn--icon {
    font-size: 0.78rem;
  }

  .save-hint {
    font-size: 0.68rem;
  }

  .milestone-toast,
  .toast {
    max-width: 100%;
    min-width: 0;
  }
}

@media (max-width: 540px) {
  .row {
    flex-direction: column;
    align-items: stretch;
  }

  .row .buy-btn-wrap {
    width: 100%;
    flex-direction: row;
    justify-content: space-between;
    align-items: center;
    margin-left: 0;
  }

}

/* Narrow phones: stack stats vertically instead of a horizontal carousel */
@media (max-width: 420px) {
  .stat-deck {
    display: flex;
    flex-direction: column;
    flex-wrap: nowrap;
    overflow-x: visible;
    scroll-snap-type: none;
    gap: 0.55rem;
  }

  .stat-card {
    flex: 1 1 auto !important;
    width: 100%;
    max-width: 100%;
  }
}

@media (prefers-reduced-motion: reduce) {
  .ambient__glow {
    animation: none !important;
  }

  .click-halo {
    animation: none !important;
  }
}
