:root {
  --background: 230 30% 9%;
  --foreground: 210 28% 95%;
  --primary: 281 91% 63%;
  --secondary: 167 83% 60%;
  --muted: 229 20% 16%;
  --destructive: 0 84% 63%;
  --border: 229 18% 24%;
  --card: 228 26% 12%;
  --shadow-sm: 0 10px 24px rgba(5, 8, 20, 0.16);
  --shadow-md: 0 16px 40px rgba(5, 8, 20, 0.26);
  --shadow-lg: 0 24px 70px rgba(5, 8, 20, 0.42);
  --transition-fast: 160ms ease;
  --transition-smooth: 320ms cubic-bezier(0.2, 0.8, 0.2, 1);
  --radius-sm: 0.75rem;
  --radius-md: 1rem;
  --radius-lg: 1.5rem;
}

.dark {
  --background: 230 30% 9%;
  --foreground: 210 28% 95%;
  --primary: 281 91% 63%;
  --secondary: 167 83% 60%;
  --muted: 229 20% 16%;
  --destructive: 0 84% 63%;
  --border: 229 18% 24%;
  --card: 228 26% 12%;
}

html:not(.dark) {
  --background: 220 35% 96%;
  --foreground: 228 26% 12%;
  --primary: 275 84% 52%;
  --secondary: 167 74% 38%;
  --muted: 220 24% 90%;
  --destructive: 0 78% 52%;
  --border: 220 18% 82%;
  --card: 0 0% 100%;
  --shadow-sm: 0 10px 24px rgba(66, 76, 119, 0.10);
  --shadow-md: 0 16px 40px rgba(66, 76, 119, 0.16);
  --shadow-lg: 0 24px 70px rgba(66, 76, 119, 0.22);
}

* {
  box-sizing: border-box;
}

html, body, #root {
  min-height: 100%;
}

body {
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  line-height: 1.5;
  text-rendering: optimizeLegibility;
}

body * {
  min-width: 0;
}

p, div, span, h1, h2, h3, button, a {
  overflow-wrap: anywhere;
}

button, a {
  transition: transform var(--transition-fast), box-shadow var(--transition-fast), background-color var(--transition-fast), border-color var(--transition-fast), color var(--transition-fast), opacity var(--transition-fast);
}

button {
  line-height: 1.2;
  text-align: center;
  white-space: normal;
}

.hud-scroll {
  scrollbar-width: none;
}

.hud-scroll::-webkit-scrollbar {
  display: none;
}

.hud-stat {
  min-height: 24px;
  border: 1px solid hsl(var(--border) / 0.48);
  background: linear-gradient(180deg, hsl(var(--card) / 0.68), hsl(var(--background) / 0.44));
  backdrop-filter: blur(14px);
  box-shadow: inset 0 1px 0 hsl(var(--foreground) / 0.06);
  white-space: nowrap;
}

.hud-ready {
  border-color: hsl(var(--secondary) / 0.5);
  background: hsl(var(--secondary) / 0.09);
}

.hud-rate {
  border-color: hsl(var(--secondary) / 0.45);
  background: hsl(var(--secondary) / 0.10);
}

.hud-number {
  animation: statPop 180ms ease-out;
}

.temporal-glow {
  border-color: hsl(var(--primary) / 0.55);
  background: hsl(var(--primary) / 0.10);
  box-shadow: 0 0 18px hsl(var(--primary) / 0.28), inset 0 1px 0 hsl(var(--foreground) / 0.06);
}

.instability-warn {
  border-color: hsl(var(--destructive) / 0.62);
  background: hsl(var(--destructive) / 0.11);
  animation: warnPulse 1.4s ease-in-out infinite;
}

.chrono-click::after {
  content: "";
  position: absolute;
  inset: -20%;
  background: radial-gradient(circle, hsla(281, 91%, 63%, 0.28), transparent 38%);
  opacity: 0;
  transform: scale(0.7);
  transition: opacity var(--transition-smooth), transform var(--transition-smooth);
}

.chrono-click:hover::after,
.chrono-click:focus-visible::after {
  opacity: 1;
  transform: scale(1);
}

.click-pulse {
  animation: clickPulse 260ms ease-out;
}

.floating-number {
  position: absolute;
  right: 1rem;
  top: 1rem;
  font-weight: 900;
  pointer-events: none;
  animation: floatUp 1s ease forwards;
  text-shadow: 0 8px 20px rgba(0, 0, 0, 0.25);
}

.stat-glow {
  box-shadow: 0 0 24px hsl(var(--primary) / 0.14), var(--shadow-sm);
}

.tab-view {
  animation: fadeScaleIn 220ms ease both;
  scroll-margin-top: 88px;
}

.resource-value {
  font-size: clamp(1.65rem, 8vw, 2.25rem);
  line-height: 1.05;
  letter-spacing: -0.04em;
  font-variant-numeric: tabular-nums;
}

.resource-rate {
  line-height: 1.1;
  font-variant-numeric: tabular-nums;
}

@media (max-width: 640px) {
  :root {
    --radius-lg: 1.15rem;
  }

  .tab-view {
    scroll-margin-top: 76px;
  }

  .floating-number {
    right: 0.75rem;
    top: 0.75rem;
    font-size: 0.875rem;
  }
}

@keyframes statPop {
  0% {
    transform: scale(0.92);
  }
  70% {
    transform: scale(1.13);
  }
  100% {
    transform: scale(1);
  }
}

@keyframes warnPulse {
  0%, 100% {
    box-shadow: 0 0 0 hsl(var(--destructive) / 0), inset 0 1px 0 hsl(var(--foreground) / 0.06);
  }
  50% {
    box-shadow: 0 0 18px hsl(var(--destructive) / 0.28), inset 0 1px 0 hsl(var(--foreground) / 0.06);
  }
}

@keyframes clickPulse {
  0% {
    transform: scale(0.98);
    box-shadow: 0 0 0 0 hsl(var(--primary) / 0.38), var(--shadow-lg);
  }
  70% {
    transform: scale(1.025);
    box-shadow: 0 0 0 12px hsl(var(--primary) / 0), var(--shadow-lg);
  }
  100% {
    transform: scale(1);
    box-shadow: var(--shadow-lg);
  }
}

@keyframes fadeScaleIn {
  0% {
    opacity: 0;
    transform: translateY(8px) scale(0.99);
  }
  100% {
    opacity: 1;
    transform: translateY(0) scale(1);
  }
}

@keyframes floatUp {
  0% {
    opacity: 0;
    transform: translateY(8px) scale(0.95);
  }
  20% {
    opacity: 1;
  }
  100% {
    opacity: 0;
    transform: translateY(-34px) scale(1.08);
  }
}

::-webkit-scrollbar {
  height: 10px;
  width: 10px;
}

::-webkit-scrollbar-thumb {
  background: hsl(var(--border));
  border-radius: 999px;
}

::-webkit-scrollbar-track {
  background: transparent;
}