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

:root {
  --bg: #071014;
  --surface: #101820;
  --surface-2: #18232d;
  --surface-3: #20303b;
  --border: #33424d;
  --text: #f8fafc;
  --text-muted: #98a7b3;
  --acid: #b6ff3b;
  --cyan: #38e8ff;
  --pink: #ff4db8;
  --yellow: #ffd23f;
  --orange: #ff7a38;
  --danger: #ff335f;
  --shadow: rgba(0, 0, 0, 0.35);
}

html {
  min-height: 100%;
}

body {
  min-height: 100vh;
  overflow-x: hidden;
  background:
    radial-gradient(circle at 18% 12%, rgba(56, 232, 255, 0.16), transparent 22rem),
    radial-gradient(circle at 84% 86%, rgba(255, 77, 184, 0.16), transparent 26rem),
    linear-gradient(135deg, #071014 0%, #131019 52%, #061017 100%);
  color: var(--text);
  font-family: Inter, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}

button,
input {
  font: inherit;
}

button {
  color: inherit;
}

.back-bar {
  position: relative;
  z-index: 20;
  padding: 0.75rem 1.5rem;
  background: rgba(7, 16, 20, 0.78);
  border-bottom: 1px solid rgba(255, 255, 255, 0.08);
  backdrop-filter: blur(14px);
}

.back-link {
  color: var(--text-muted);
  text-decoration: none;
  font-size: 0.8rem;
  transition: color 0.16s ease;
}

.back-link:hover {
  color: var(--text);
}

.particle-canvas,
.chaos-layer,
.visual-noise {
  position: fixed;
  inset: 0;
  pointer-events: none;
}

.particle-canvas {
  z-index: 5;
}

.chaos-layer {
  z-index: 6;
  overflow: hidden;
}

.visual-noise {
  z-index: 4;
  opacity: 0;
  background-image:
    linear-gradient(rgba(255, 255, 255, 0.08) 1px, transparent 1px),
    linear-gradient(90deg, rgba(255, 255, 255, 0.08) 1px, transparent 1px);
  background-size: 28px 28px;
  mix-blend-mode: screen;
  transition: opacity 0.25s ease;
}

body.noise-on .visual-noise {
  opacity: 0.14;
  animation: noise-shift 0.45s steps(2, end) infinite;
}

@keyframes noise-shift {
  0% {
    transform: translate3d(0, 0, 0);
  }

  50% {
    transform: translate3d(7px, -4px, 0);
  }

  100% {
    transform: translate3d(-3px, 6px, 0);
  }
}

.clicker-shell {
  position: relative;
  z-index: 10;
  width: min(1180px, calc(100% - 2rem));
  min-height: calc(100vh - 48px);
  margin: 0 auto;
  padding: 2rem 0;
  display: grid;
  grid-template-columns: minmax(0, 1fr) 360px;
  gap: 1rem;
  align-items: stretch;
}

.stage,
.side-panel {
  border: 1px solid rgba(255, 255, 255, 0.1);
  background: rgba(16, 24, 32, 0.78);
  box-shadow: 0 20px 60px var(--shadow);
  backdrop-filter: blur(18px);
}

.stage {
  min-height: 680px;
  padding: clamp(1rem, 3vw, 2rem);
  border-radius: 8px;
  display: grid;
  grid-template-rows: auto auto 1fr auto;
  gap: 1.25rem;
  overflow: hidden;
}

.title-block {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 1rem;
}

.eyebrow {
  color: var(--acid);
  font-size: 0.72rem;
  font-weight: 800;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  margin-bottom: 0.35rem;
}

h1 {
  font-size: clamp(2rem, 7vw, 5rem);
  line-height: 0.95;
  letter-spacing: 0;
  max-width: 8ch;
}

.score-board {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 0.75rem;
}

.score-card {
  min-height: 86px;
  padding: 0.85rem;
  border: 1px solid rgba(255, 255, 255, 0.1);
  border-radius: 8px;
  background: rgba(255, 255, 255, 0.055);
}

.score-label {
  display: block;
  color: var(--text-muted);
  font-size: 0.72rem;
  font-weight: 700;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  margin-bottom: 0.35rem;
}

.score-card strong {
  display: block;
  min-width: 0;
  overflow-wrap: anywhere;
  color: var(--cyan);
  font-size: clamp(1.25rem, 4vw, 2rem);
  line-height: 1.05;
  font-variant-numeric: tabular-nums;
}

.button-zone {
  display: grid;
  place-items: center;
  min-height: 320px;
}

.main-button {
  width: min(330px, 78vw);
  aspect-ratio: 1;
  border: 0;
  border-radius: 50%;
  cursor: pointer;
  user-select: none;
  color: #071014;
  background:
    radial-gradient(circle at 34% 28%, #fff 0%, #eaffb7 18%, transparent 19%),
    conic-gradient(from 0deg, var(--acid), var(--cyan), var(--pink), var(--yellow), var(--acid));
  box-shadow:
    0 0 0 10px rgba(182, 255, 59, 0.08),
    0 0 42px rgba(56, 232, 255, 0.35),
    0 22px 60px rgba(0, 0, 0, 0.45);
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 0.45rem;
  transition: transform 0.08s ease, filter 0.16s ease;
  animation: button-pulse 2.4s ease-in-out infinite;
}

.main-button:hover {
  filter: saturate(1.18) brightness(1.05);
}

.main-button:active {
  transform: scale(0.96);
}

.button-main {
  font-size: clamp(1.5rem, 8vw, 3.3rem);
  font-weight: 950;
  line-height: 0.95;
}

.button-sub {
  max-width: 78%;
  color: rgba(7, 16, 20, 0.76);
  font-size: 0.92rem;
  font-weight: 800;
  overflow-wrap: anywhere;
}

@keyframes button-pulse {
  0%,
  100% {
    box-shadow:
      0 0 0 10px rgba(182, 255, 59, 0.08),
      0 0 42px rgba(56, 232, 255, 0.35),
      0 22px 60px rgba(0, 0, 0, 0.45);
  }

  50% {
    box-shadow:
      0 0 0 18px rgba(255, 77, 184, 0.08),
      0 0 58px rgba(255, 77, 184, 0.38),
      0 22px 60px rgba(0, 0, 0, 0.45);
  }
}

.status-strip {
  display: grid;
  grid-template-columns: auto minmax(120px, 1fr) auto;
  gap: 0.8rem;
  align-items: center;
}

.status-pill {
  display: inline-flex;
  align-items: center;
  gap: 0.5rem;
  min-height: 36px;
  padding: 0 0.8rem;
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.07);
  border: 1px solid rgba(255, 255, 255, 0.1);
  color: var(--text);
  font-size: 0.78rem;
  font-weight: 800;
  white-space: nowrap;
}

.status-dot {
  width: 0.55rem;
  height: 0.55rem;
  border-radius: 50%;
  background: var(--acid);
  box-shadow: 0 0 16px var(--acid);
}

.progress-track {
  height: 10px;
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.11);
  overflow: hidden;
}

.progress-fill {
  width: 0%;
  height: 100%;
  border-radius: inherit;
  background: linear-gradient(90deg, var(--cyan), var(--pink), var(--yellow));
  transition: width 0.18s ease;
}

.next-unlock {
  color: var(--text-muted);
  font-size: 0.76rem;
  text-align: right;
  min-width: 150px;
}

.side-panel {
  max-height: calc(100vh - 88px);
  border-radius: 8px;
  overflow: hidden;
  position: sticky;
  top: 1rem;
  display: grid;
  grid-template-rows: auto 1fr;
}

.panel-tabs {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  background: rgba(255, 255, 255, 0.05);
  border-bottom: 1px solid rgba(255, 255, 255, 0.1);
}

.tab-button {
  min-height: 44px;
  border: 0;
  background: transparent;
  color: var(--text-muted);
  cursor: pointer;
  font-size: 0.78rem;
  font-weight: 800;
}

.tab-button.is-active {
  color: var(--text);
  background: rgba(255, 255, 255, 0.08);
}

.panel-section {
  min-height: 0;
  display: none;
  padding: 1rem;
  overflow-y: auto;
  scrollbar-width: thin;
  scrollbar-color: var(--border) transparent;
}

.panel-section.is-active {
  display: block;
}

.section-heading {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.75rem;
  margin-bottom: 0.85rem;
}

.section-heading h2 {
  font-size: 0.88rem;
  letter-spacing: 0.08em;
  text-transform: uppercase;
}

.section-heading span {
  color: var(--text-muted);
  font-size: 0.75rem;
  font-weight: 700;
  white-space: nowrap;
}

.upgrades-list,
.achievements-list,
.settings-list {
  display: grid;
  gap: 0.65rem;
}

.upgrade-card,
.achievement-card,
.setting-row {
  border: 1px solid rgba(255, 255, 255, 0.1);
  border-radius: 8px;
  background: rgba(255, 255, 255, 0.055);
}

.upgrade-card {
  width: 100%;
  min-height: 94px;
  padding: 0.75rem;
  display: grid;
  grid-template-columns: 42px 1fr;
  gap: 0.7rem;
  text-align: left;
  cursor: pointer;
  transition: border-color 0.16s ease, background 0.16s ease, transform 0.16s ease;
}

.upgrade-card:hover:not(:disabled) {
  border-color: rgba(56, 232, 255, 0.65);
  background: rgba(56, 232, 255, 0.08);
  transform: translateY(-1px);
}

.upgrade-card:disabled {
  cursor: not-allowed;
  opacity: 0.46;
}

.upgrade-icon {
  width: 42px;
  height: 42px;
  border-radius: 8px;
  display: grid;
  place-items: center;
  background: rgba(255, 255, 255, 0.09);
  font-size: 1.45rem;
}

.upgrade-title-row {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 0.5rem;
}

.upgrade-title {
  font-size: 0.9rem;
  font-weight: 850;
}

.upgrade-level {
  color: var(--acid);
  font-size: 0.72rem;
  font-weight: 850;
  white-space: nowrap;
}

.upgrade-desc {
  color: var(--text-muted);
  font-size: 0.76rem;
  line-height: 1.35;
  margin: 0.28rem 0 0.45rem;
}

.upgrade-meta {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.55rem;
  color: var(--cyan);
  font-size: 0.75rem;
  font-weight: 800;
}

.achievement-card {
  padding: 0.75rem;
  display: grid;
  grid-template-columns: 36px 1fr;
  gap: 0.7rem;
  opacity: 0.58;
}

.achievement-card.is-earned {
  opacity: 1;
  border-color: rgba(182, 255, 59, 0.38);
  background: rgba(182, 255, 59, 0.08);
}

.achievement-icon {
  width: 36px;
  height: 36px;
  border-radius: 8px;
  display: grid;
  place-items: center;
  background: rgba(255, 255, 255, 0.09);
}

.achievement-title {
  font-size: 0.86rem;
  font-weight: 850;
}

.achievement-desc {
  color: var(--text-muted);
  font-size: 0.74rem;
  line-height: 1.35;
  margin-top: 0.18rem;
}

.setting-row {
  min-height: 72px;
  padding: 0.75rem;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
}

.setting-row strong,
.setting-row small {
  display: block;
}

.setting-row strong {
  font-size: 0.86rem;
}

.setting-row small {
  color: var(--text-muted);
  font-size: 0.74rem;
  line-height: 1.35;
  margin-top: 0.12rem;
}

.setting-row input {
  width: 1.15rem;
  height: 1.15rem;
  accent-color: var(--acid);
  flex: 0 0 auto;
}

.reset-button {
  min-height: 44px;
  border: 1px solid rgba(255, 51, 95, 0.4);
  border-radius: 8px;
  background: rgba(255, 51, 95, 0.12);
  color: #ffd5de;
  cursor: pointer;
  font-weight: 850;
}

.reset-button:hover {
  background: rgba(255, 51, 95, 0.2);
}

.floating-score {
  position: fixed;
  z-index: 30;
  color: var(--acid);
  font-size: 1.15rem;
  font-weight: 950;
  text-shadow: 0 2px 14px rgba(0, 0, 0, 0.45);
  pointer-events: none;
  animation: float-score 0.78s ease forwards;
}

@keyframes float-score {
  from {
    opacity: 1;
    transform: translate(-50%, 0) scale(1);
  }

  to {
    opacity: 0;
    transform: translate(-50%, -72px) scale(1.28) rotate(-7deg);
  }
}

.toast-stack {
  position: fixed;
  z-index: 40;
  top: 4rem;
  right: 1rem;
  width: min(320px, calc(100vw - 2rem));
  display: grid;
  gap: 0.6rem;
  pointer-events: none;
}

.toast {
  border: 1px solid rgba(255, 255, 255, 0.14);
  border-radius: 8px;
  padding: 0.8rem 0.9rem;
  background: rgba(16, 24, 32, 0.92);
  box-shadow: 0 18px 40px rgba(0, 0, 0, 0.32);
  animation: toast-in 0.22s ease;
}

.toast-title {
  color: var(--acid);
  font-size: 0.78rem;
  font-weight: 900;
  letter-spacing: 0.08em;
  text-transform: uppercase;
}

.toast-body {
  margin-top: 0.25rem;
  color: var(--text);
  font-size: 0.86rem;
  line-height: 1.35;
}

@keyframes toast-in {
  from {
    opacity: 0;
    transform: translateX(20px);
  }

  to {
    opacity: 1;
    transform: translateX(0);
  }
}

.chaos-item {
  position: absolute;
  pointer-events: none;
  user-select: none;
}

.notification-pop {
  min-width: 180px;
  max-width: 240px;
  padding: 0.65rem 0.75rem;
  border-radius: 8px;
  color: #071014;
  background: #f8fafc;
  box-shadow: 0 16px 34px rgba(0, 0, 0, 0.28);
  font-size: 0.78rem;
  font-weight: 850;
  animation: pop-drift 4.2s linear forwards;
}

.notification-pop small {
  display: block;
  color: #40515f;
  font-size: 0.68rem;
  font-weight: 750;
  margin-top: 0.18rem;
}

.feed-ticker {
  white-space: nowrap;
  padding: 0.35rem 0.7rem;
  border-radius: 999px;
  background: var(--yellow);
  color: #171108;
  font-size: 0.78rem;
  font-weight: 950;
  animation: ticker-slide 7s linear forwards;
}

.emoji-burst {
  font-size: 2rem;
  filter: drop-shadow(0 10px 18px rgba(0, 0, 0, 0.25));
  animation: emoji-fall 4s ease-in forwards;
}

.ad-card {
  width: 180px;
  padding: 0.7rem;
  border: 2px solid var(--yellow);
  border-radius: 8px;
  background: #111827;
  color: var(--text);
  font-size: 0.76rem;
  font-weight: 900;
  text-align: center;
  box-shadow: 0 0 28px rgba(255, 210, 63, 0.34);
  animation: ad-wobble 5s ease forwards;
}

.ad-card strong {
  display: block;
  color: var(--yellow);
  font-size: 0.95rem;
  margin-bottom: 0.25rem;
}

@keyframes pop-drift {
  0% {
    opacity: 0;
    transform: translateY(12px) scale(0.92);
  }

  10%,
  72% {
    opacity: 1;
  }

  100% {
    opacity: 0;
    transform: translateY(-70px) scale(1.03);
  }
}

@keyframes ticker-slide {
  from {
    transform: translateX(105vw);
  }

  to {
    transform: translateX(-125vw);
  }
}

@keyframes emoji-fall {
  0% {
    opacity: 0;
    transform: translateY(-20px) rotate(0deg);
  }

  12%,
  78% {
    opacity: 1;
  }

  100% {
    opacity: 0;
    transform: translateY(55vh) rotate(220deg);
  }
}

@keyframes ad-wobble {
  0% {
    opacity: 0;
    transform: scale(0.75) rotate(-8deg);
  }

  12%,
  80% {
    opacity: 1;
  }

  35% {
    transform: scale(1.02) rotate(7deg);
  }

  62% {
    transform: scale(0.96) rotate(-5deg);
  }

  100% {
    opacity: 0;
    transform: scale(0.9) rotate(10deg);
  }
}

body.shake-on .stage {
  animation: stage-shake 0.16s linear infinite;
}

@keyframes stage-shake {
  0%,
  100% {
    transform: translate(0, 0);
  }

  33% {
    transform: translate(1px, -1px);
  }

  66% {
    transform: translate(-1px, 1px);
  }
}

body.reduced-motion *,
body.reduced-motion *::before,
body.reduced-motion *::after {
  animation-duration: 0.01ms !important;
  animation-iteration-count: 1 !important;
  scroll-behavior: auto !important;
}

body.reduced-motion .particle-canvas,
body.reduced-motion .chaos-layer,
body.reduced-motion .visual-noise {
  display: none;
}

@media (max-width: 900px) {
  .clicker-shell {
    grid-template-columns: 1fr;
  }

  .stage {
    min-height: 600px;
  }

  .side-panel {
    position: static;
    max-height: none;
  }
}

@media (max-width: 620px) {
  .back-bar {
    padding: 0.65rem 1rem;
  }

  .clicker-shell {
    width: min(100% - 1rem, 1180px);
    padding: 0.5rem 0 1rem;
  }

  .stage {
    min-height: calc(100vh - 72px);
    gap: 0.85rem;
  }

  .score-board {
    grid-template-columns: 1fr;
    gap: 0.5rem;
  }

  .score-card {
    min-height: 64px;
  }

  .button-zone {
    min-height: 260px;
  }

  .status-strip {
    grid-template-columns: 1fr;
  }

  .next-unlock {
    min-width: 0;
    text-align: left;
  }

  .toast-stack {
    top: auto;
    right: 0.5rem;
    bottom: 0.5rem;
    width: calc(100vw - 1rem);
  }
}
