*,
*::before,
*::after {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
}
:root {
  --bg: #0a0a0a;
  --surface: rgba(255, 255, 255, 0.04);
  --surface2: rgba(255, 255, 255, 0.07);
  --border: rgba(255, 255, 255, 0.07);
  --text: #f0f0f0;
  --muted: rgba(240, 240, 240, 0.38);
  --accent: #ff6640;
  --accent2: #ffb340;
  --glow: rgba(255, 102, 64, 0.22);
}
html,
body {
  height: 100%;
  font-family: "Rubik", sans-serif;
  background: var(--bg);
  color: var(--text);
  overflow-x: hidden;
}
body::before {
  content: "";
  position: fixed;
  inset: 0;
  background:
    radial-gradient(
      ellipse 70% 60% at 50% -10%,
      rgba(255, 102, 64, 0.07) 0%,
      transparent 70%
    ),
    radial-gradient(
      ellipse 50% 40% at 80% 110%,
      rgba(255, 179, 64, 0.05) 0%,
      transparent 60%
    );
  pointer-events: none;
  z-index: 0;
}
body::after {
  content: "";
  position: fixed;
  inset: 0;
  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.9' numOctaves='4' stitchTiles='stitch'/%3E%3C/filter%3E%3Crect width='100%25' height='100%25' filter='url(%23n)' opacity='0.04'/%3E%3C/svg%3E");
  background-size: 200px;
  pointer-events: none;
  z-index: 0;
  opacity: 0.6;
}

main {
  position: relative;
  z-index: 1;
  min-height: 100vh;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: 60px 20px;
  gap: 32px;
}

/* Header */
.header {
  text-align: center;
  animation: fadeDown 0.7s cubic-bezier(0.22, 1, 0.36, 1) both;
}
.label-chip {
  display: inline-block;
  font-size: 0.72rem;
  font-weight: 500;
  letter-spacing: 0.14em;
  text-transform: uppercase;
  color: var(--accent);
  border: 1px solid rgba(255, 102, 64, 0.3);
  border-radius: 100px;
  padding: 4px 14px;
  margin-bottom: 18px;
}
.header h1 {
  font-size: clamp(2.2rem, 7vw, 4.5rem);
  font-weight: 900;
  letter-spacing: -0.04em;
  line-height: 1.05;
}
.header h1 span {
  background: linear-gradient(90deg, var(--accent), var(--accent2));
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  background-clip: text;
}
.header p {
  margin-top: 14px;
  color: var(--muted);
  font-size: 0.95rem;
  font-weight: 300;
}
.world-pop {
  margin-top: 10px;
  font-size: 0.78rem;
  color: rgba(255, 102, 64, 0.6);
  font-weight: 400;
  letter-spacing: 0.03em;
}

/* Button */
.btn-spin {
  position: relative;
  padding: 16px 52px;
  font-size: 1rem;
  font-weight: 600;
  font-family: "Rubik", sans-serif;
  border: none;
  border-radius: 100px;
  cursor: pointer;
  color: #0a0a0a;
  letter-spacing: 0.02em;
  background: linear-gradient(135deg, var(--accent), var(--accent2));
  transition:
    transform 0.18s,
    box-shadow 0.18s,
    opacity 0.18s;
  overflow: hidden;
}
.btn-spin::after {
  content: "";
  position: absolute;
  inset: 0;
  background: linear-gradient(
    135deg,
    rgba(255, 255, 255, 0.15),
    transparent
  );
  opacity: 0;
  transition: opacity 0.2s;
}
.btn-spin:hover {
  transform: translateY(-2px);
  box-shadow: 0 8px 40px var(--glow);
}
.btn-spin:hover::after {
  opacity: 1;
}
.btn-spin:active {
  transform: translateY(0) scale(0.97);
}
.btn-spin:disabled {
  opacity: 0.4;
  cursor: not-allowed;
  transform: none;
  box-shadow: none;
}
.ripple {
  position: absolute;
  border-radius: 50%;
  background: rgba(255, 255, 255, 0.3);
  transform: scale(0);
  animation: rippleAnim 0.6s linear;
  pointer-events: none;
}
@keyframes rippleAnim {
  to {
    transform: scale(4);
    opacity: 0;
  }
}

/* Slot container */
.slot-container {
  width: min(580px, 95vw);
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 24px;
  padding: 28px;
  backdrop-filter: blur(12px);
  animation: fadeUp 0.7s cubic-bezier(0.22, 1, 0.36, 1) 0.1s both;
  transition:
    border-color 0.5s,
    box-shadow 0.5s;
}
.slot-container.result-shown {
  border-color: rgba(255, 102, 64, 0.2);
  box-shadow: 0 0 60px rgba(255, 102, 64, 0.07);
}

/* Slot window */
.slot-window {
  height: 330px;
  overflow: hidden;
  position: relative;
  border-radius: 14px;
  background: rgba(0, 0, 0, 0.35);
  border: 1px solid var(--border);
}
.slot-window::before,
.slot-window::after {
  content: "";
  position: absolute;
  left: 0;
  right: 0;
  height: 44px;
  z-index: 2;
  pointer-events: none;
}
.slot-window::before {
  top: 0;
  background: linear-gradient(to bottom, #0a0a0a, transparent);
}
.slot-window::after {
  bottom: 0;
  background: linear-gradient(to top, #0a0a0a, transparent);
}
.slot-selection {
  position: absolute;
  top: 50%;
  transform: translateY(-50%);
  left: 0;
  right: 0;
  height: 110px;
  border-top: 1px solid rgba(255, 102, 64, 0.4);
  border-bottom: 1px solid rgba(255, 102, 64, 0.4);
  pointer-events: none;
  z-index: 3;
}
.slot-reel {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  will-change: transform;
}
.slot-item {
  height: 110px;
  width: 100%;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 5px;
  flex-shrink: 0;
}
.slot-flag {
  font-size: 2.6rem;
  line-height: 1;
}
.slot-name {
  font-size: 0.9rem;
  font-weight: 500;
  color: var(--text);
  text-align: center;
  padding: 0 16px;
}

/* Result card */
.result-card {
  display: none;
  flex-direction: column;
  align-items: center;
  gap: 14px;
  padding-top: 24px;
  border-top: 1px solid var(--border);
  margin-top: 22px;
}
.result-card.show {
  display: flex;
  animation: popIn 0.5s cubic-bezier(0.34, 1.56, 0.64, 1) both;
}
.result-flag {
  font-size: 4rem;
  line-height: 1;
  animation: flagDrop 0.5s cubic-bezier(0.34, 1.56, 0.64, 1) both;
}
@keyframes flagDrop {
  from {
    opacity: 0;
    transform: scale(0.5) translateY(-10px);
  }
  to {
    opacity: 1;
    transform: scale(1) translateY(0);
  }
}
.result-nationality {
  font-size: 1.5rem;
  font-weight: 700;
  letter-spacing: -0.02em;
  text-align: center;
}

/* Prob block */
.probability-block {
  width: 100%;
  background: rgba(255, 102, 64, 0.05);
  border: 1px solid rgba(255, 102, 64, 0.15);
  border-radius: 16px;
  padding: 20px;
  text-align: center;
}
.prob-label {
  font-size: 0.7rem;
  text-transform: uppercase;
  letter-spacing: 0.12em;
  color: var(--muted);
  margin-bottom: 8px;
  font-weight: 500;
}
.prob-value {
  font-size: 2.6rem;
  font-weight: 900;
  letter-spacing: -0.04em;
  color: var(--accent);
  font-variant-numeric: tabular-nums;
  text-shadow: 0 0 40px rgba(255, 102, 64, 0.4);
}
.prob-fraction {
  font-size: 0.82rem;
  color: var(--muted);
  margin-top: 4px;
  font-weight: 400;
}

/* Bar */
.bar-wrap {
  width: 100%;
}
.bar-label-row {
  display: flex;
  justify-content: space-between;
  font-size: 0.72rem;
  color: var(--muted);
  margin-bottom: 7px;
  font-weight: 400;
}
.bar-track {
  width: 100%;
  height: 4px;
  background: rgba(255, 255, 255, 0.06);
  border-radius: 100px;
  overflow: hidden;
}
.bar-fill {
  height: 100%;
  border-radius: 100px;
  background: linear-gradient(90deg, var(--accent), var(--accent2));
  width: 0;
  transition: width 1.4s cubic-bezier(0.22, 1, 0.36, 1);
}

/* ── STORY SECTION ── */
.story-section {
  width: 100%;
  margin-top: 4px;
}
.story-title {
  font-size: 0.7rem;
  text-transform: uppercase;
  letter-spacing: 0.14em;
  color: var(--muted);
  font-weight: 500;
  margin-bottom: 12px;
  padding-left: 2px;
}
.stats-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 8px;
}
.stat-card {
  background: var(--surface2);
  border: 1px solid var(--border);
  border-radius: 14px;
  padding: 14px 16px;
  transition:
    border-color 0.25s,
    transform 0.25s;
  opacity: 0;
  transform: translateY(12px);
}
.stat-card.revealed {
  animation: statReveal 0.45s cubic-bezier(0.22, 1, 0.36, 1) forwards;
}
@keyframes statReveal {
  to {
    opacity: 1;
    transform: translateY(0);
  }
}
.stat-card:hover {
  border-color: rgba(255, 102, 64, 0.2);
  transform: translateY(-1px);
}
.stat-icon {
  font-size: 1.1rem;
  margin-bottom: 6px;
  display: block;
}
.stat-label {
  font-size: 0.65rem;
  text-transform: uppercase;
  letter-spacing: 0.1em;
  color: var(--muted);
  font-weight: 500;
  margin-bottom: 4px;
}
.stat-value {
  font-size: 1.05rem;
  font-weight: 700;
  letter-spacing: -0.01em;
  color: var(--text);
  line-height: 1.2;
}
.stat-sub {
  font-size: 0.68rem;
  color: var(--muted);
  font-weight: 400;
  margin-top: 3px;
  line-height: 1.4;
}

/* Wealth colors */
.wealth-poor .stat-value {
  color: #f87171;
}
.wealth-middle .stat-value {
  color: #fbbf24;
}
.wealth-rich .stat-value {
  color: #4ade80;
}

/* IQ bar */
.iq-bar-wrap {
  margin-top: 6px;
  width: 100%;
}
.iq-track {
  width: 100%;
  height: 3px;
  background: rgba(255, 255, 255, 0.06);
  border-radius: 100px;
  overflow: hidden;
}
.iq-fill {
  height: 100%;
  border-radius: 100px;
  background: linear-gradient(90deg, #818cf8, #c084fc);
  width: 0;
  transition: width 1s cubic-bezier(0.22, 1, 0.36, 1);
}

/* Comparisons */
.comparisons {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 8px;
  width: 100%;
}
.cmp-item {
  background: var(--surface2);
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 12px 14px;
  font-size: 0.74rem;
  color: var(--muted);
  line-height: 1.4;
  transition: border-color 0.2s;
}
.cmp-item:hover {
  border-color: rgba(255, 102, 64, 0.2);
}
.cmp-item strong {
  color: var(--text);
  display: block;
  font-size: 1rem;
  font-weight: 700;
  letter-spacing: -0.02em;
  margin-bottom: 1px;
}

/* Particles */
#particles {
  position: fixed;
  inset: 0;
  pointer-events: none;
  z-index: 100;
}
.particle {
  position: absolute;
  pointer-events: none;
  animation: particleFly var(--dur) cubic-bezier(0.22, 1, 0.36, 1)
    forwards;
}
@keyframes particleFly {
  0% {
    transform: translate(0, 0) scale(1) rotate(0deg);
    opacity: 1;
  }
  100% {
    transform: translate(var(--tx), var(--ty)) scale(0) rotate(var(--rot));
    opacity: 0;
  }
}

/* Animations */
@keyframes fadeDown {
  from {
    opacity: 0;
    transform: translateY(-16px);
  }
  to {
    opacity: 1;
    transform: none;
  }
}
@keyframes fadeUp {
  from {
    opacity: 0;
    transform: translateY(16px);
  }
  to {
    opacity: 1;
    transform: none;
  }
}
@keyframes popIn {
  from {
    opacity: 0;
    transform: scale(0.9);
  }
  to {
    opacity: 1;
    transform: scale(1);
  }
}

/* Footer */
.stats-footer {
  text-align: center;
  font-size: 0.74rem;
  color: rgba(240, 240, 240, 0.2);
  animation: fadeUp 0.7s cubic-bezier(0.22, 1, 0.36, 1) 0.2s both;
  max-width: 460px;
  font-weight: 300;
  line-height: 1.6;
}
.stats-footer strong {
  color: rgba(240, 240, 240, 0.35);
  font-weight: 500;
}
.spin-count {
  font-size: 0.78rem;
  color: var(--muted);
  margin-top: -20px;
  font-weight: 300;
  min-height: 18px;
}
.divider {
  width: 100%;
  height: 1px;
  background: var(--border);
}
@keyframes countUp {
  from {
    transform: translateY(8px);
    opacity: 0;
  }
  to {
    transform: translateY(0);
    opacity: 1;
  }
}
.prob-value.animate {
  animation: countUp 0.4s cubic-bezier(0.22, 1, 0.36, 1) both;
}
