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

:root {
  --bg: #0b1220;
  --bg-2: #0f172a;
  --surface: #1e293b;
  --surface-2: #334155;
  --border: #475569;
  --text: #f8fafc;
  --text-muted: #94a3b8;
  --primary: #6366f1;
  --primary-light: #818cf8;
  --gold: #f59e0b;
  --gold-light: #fbbf24;
  --red: #ef4444;
  --green: #10b981;
}

body {
  font-family: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
  background: radial-gradient(ellipse at top, #0f172a 0%, #0b1220 60%, #050912 100%);
  color: var(--text);
  min-height: 100vh;
  overflow-x: hidden;
}

/* ── Top bar ── */
.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0.6rem 1.5rem;
  background: rgba(15, 23, 42, 0.7);
  border-bottom: 1px solid var(--border);
  backdrop-filter: blur(10px);
}

.back-link {
  font-size: 0.78rem;
  color: var(--text-muted);
  text-decoration: none;
  transition: color 0.2s;
}
.back-link:hover { color: var(--text); }

.reset-btn {
  background: var(--surface-2);
  border: 1px solid var(--border);
  color: var(--text-muted);
  padding: 0.45rem 1rem;
  border-radius: 0.5rem;
  cursor: pointer;
  font-size: 0.8rem;
  transition: all 0.2s;
}
.reset-btn:hover {
  background: var(--surface);
  color: var(--text);
  border-color: var(--primary-light);
}

/* ── Header ── */
.game-header {
  background: linear-gradient(135deg, #1e293b 0%, #0f172a 100%);
  border-bottom: 1px solid var(--border);
  padding: 1.25rem 1.5rem;
}

.header-inner {
  max-width: 1100px;
  margin: 0 auto;
  display: grid;
  grid-template-columns: 1fr 1.4fr 1.6fr;
  gap: 1rem;
  align-items: center;
}

.stat-block {
  text-align: center;
  padding: 0.5rem 0.75rem;
  background: rgba(15, 23, 42, 0.5);
  border: 1px solid var(--border);
  border-radius: 0.75rem;
}

.stat-block--primary {
  background: linear-gradient(135deg, rgba(99, 102, 241, 0.18), rgba(245, 158, 11, 0.12));
  border-color: rgba(129, 140, 248, 0.45);
}

.stat-label {
  font-size: 0.68rem;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--text-muted);
  margin-bottom: 0.25rem;
}

.stat-value {
  font-size: 1.4rem;
  font-weight: 800;
  font-variant-numeric: tabular-nums;
  color: var(--text);
  line-height: 1.1;
  word-break: break-word;
}

.stat-value--lg {
  font-size: 1.85rem;
  color: var(--gold-light);
}

.stat-value--sm {
  font-size: 1rem;
  color: var(--primary-light);
}

/* ── Main layout ── */
.game-main {
  max-width: 1100px;
  margin: 0 auto;
  padding: 1.5rem 1.5rem 1.5rem;
  display: grid;
  grid-template-columns: 1fr 340px;
  gap: 1.5rem;
  align-items: start;
}

@media (max-width: 880px) {
  .game-main { grid-template-columns: 1fr; }
  .header-inner { grid-template-columns: 1fr; gap: 0.5rem; }
  .stat-value--lg { font-size: 1.5rem; }
}

/* ── Visual panel ── */
.visual-panel {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 1rem;
  padding: 1.5rem;
  position: relative;
  overflow: hidden;
}

.scene {
  position: relative;
  min-height: 380px;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: flex-end;
  padding-bottom: 1rem;
}

.paper-stage {
  position: relative;
  width: 100%;
  flex: 1;
  display: flex;
  align-items: flex-end;
  justify-content: center;
  cursor: pointer;
  padding-bottom: 2rem;
}

.paper-stage:hover .paper-stack {
  filter: brightness(1.06);
}

.paper-stack {
  position: relative;
  width: 220px;
  height: 12px;
  background: linear-gradient(180deg, #fef3c7 0%, #fde68a 30%, #fcd34d 100%);
  border-radius: 3px;
  box-shadow:
    inset 0 1px 0 rgba(255, 255, 255, 0.6),
    0 4px 18px rgba(0, 0, 0, 0.4);
  transition: transform 0.45s cubic-bezier(0.34, 1.56, 0.64, 1), height 0.45s cubic-bezier(0.4, 0, 0.2, 1), width 0.45s ease;
  transform-origin: bottom center;
}

.paper-stack.folding {
  animation: fold-pop 0.45s cubic-bezier(0.34, 1.56, 0.64, 1);
}

@keyframes fold-pop {
  0%   { transform: scaleY(1) scaleX(1); }
  45%  { transform: scaleY(1.18) scaleX(0.92); }
  100% { transform: scaleY(1) scaleX(1); }
}

.paper-layer {
  position: absolute;
  left: 0;
  right: 0;
  height: 1px;
  background: rgba(255, 255, 255, 0.18);
}

.paper-shadow {
  position: absolute;
  bottom: 0;
  left: 50%;
  transform: translateX(-50%);
  width: 240px;
  height: 18px;
  background: radial-gradient(ellipse at center, rgba(0,0,0,0.5) 0%, transparent 70%);
  filter: blur(4px);
  opacity: 0.6;
  transition: width 0.45s ease, opacity 0.45s ease;
}

/* Comparison stage */
.comparison-stage {
  position: absolute;
  top: 1rem;
  right: 1rem;
  text-align: center;
  max-width: 120px;
  transition: all 0.4s ease;
}

.comparison-emoji {
  font-size: 3rem;
  line-height: 1;
  filter: drop-shadow(0 4px 12px rgba(99, 102, 241, 0.4));
  animation: float 3s ease-in-out infinite;
}

@keyframes float {
  0%, 100% { transform: translateY(0); }
  50% { transform: translateY(-6px); }
}

.comparison-name {
  margin-top: 0.35rem;
  font-size: 0.75rem;
  font-weight: 600;
  color: var(--primary-light);
}

/* Fold button */
.fold-button {
  margin-top: 0.5rem;
  background: linear-gradient(135deg, var(--primary), var(--primary-light));
  border: none;
  color: white;
  padding: 0.85rem 2.2rem;
  border-radius: 999px;
  cursor: pointer;
  font-size: 1rem;
  font-weight: 700;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 0.15rem;
  transition: all 0.2s ease;
  box-shadow: 0 8px 22px rgba(99, 102, 241, 0.35);
}

.fold-button:hover {
  transform: translateY(-2px);
  box-shadow: 0 12px 28px rgba(99, 102, 241, 0.5);
}

.fold-button:active {
  transform: translateY(0);
}

.fold-button__hint {
  font-size: 0.65rem;
  font-weight: 500;
  opacity: 0.85;
  text-transform: uppercase;
  letter-spacing: 0.05em;
}

/* Milestone blurb */
.milestone-blurb {
  margin-top: 1rem;
  padding: 1rem 1.25rem;
  background: linear-gradient(135deg, rgba(99, 102, 241, 0.12), rgba(245, 158, 11, 0.06));
  border: 1px solid rgba(129, 140, 248, 0.3);
  border-radius: 0.75rem;
  font-size: 0.92rem;
  line-height: 1.6;
  color: var(--text);
  text-align: center;
}

/* ── Info panel ── */
.info-panel {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 1rem;
  padding: 1.25rem;
  position: sticky;
  top: 1rem;
}

.info-title {
  font-size: 0.75rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--text-muted);
  margin-bottom: 0.75rem;
}
.info-title--mt { margin-top: 1.25rem; }

.info-scale {
  display: flex;
  flex-direction: column;
  gap: 0.4rem;
}

.scale-row {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 0.45rem 0.6rem;
  background: rgba(15, 23, 42, 0.5);
  border: 1px solid var(--border);
  border-radius: 0.5rem;
  font-size: 0.8rem;
}

.scale-label {
  color: var(--text-muted);
}

.scale-value {
  color: var(--gold-light);
  font-weight: 700;
  font-variant-numeric: tabular-nums;
  text-align: right;
  word-break: break-word;
  max-width: 60%;
}

.facts-list {
  list-style: none;
  display: flex;
  flex-direction: column;
  gap: 0.4rem;
  font-size: 0.82rem;
  color: var(--text-muted);
  line-height: 1.5;
}

.facts-list li {
  padding-left: 0.9rem;
  position: relative;
}

.facts-list li::before {
  content: '◆';
  position: absolute;
  left: 0;
  color: var(--gold);
  font-size: 0.6rem;
  top: 0.3rem;
}

.facts-list strong {
  color: var(--text);
}

/* ── Achievements ── */
.achievements-section {
  max-width: 1100px;
  margin: 0 auto;
  padding: 1rem 1.5rem 3rem;
}

.achievements-title {
  font-size: 0.85rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--text-muted);
  margin-bottom: 1rem;
}

.achievements-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(220px, 1fr));
  gap: 0.75rem;
}

.achievement-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 0.875rem;
  padding: 0.9rem 1rem;
  display: flex;
  align-items: center;
  gap: 0.75rem;
  opacity: 0.45;
  filter: grayscale(0.7);
  transition: all 0.3s ease;
}

.achievement-card.unlocked {
  opacity: 1;
  filter: none;
  border-color: rgba(129, 140, 248, 0.5);
  background: linear-gradient(135deg, rgba(99, 102, 241, 0.1), var(--surface));
}

.achievement-card.current {
  border-color: var(--gold);
  box-shadow: 0 0 0 1px rgba(245, 158, 11, 0.3), 0 8px 20px rgba(245, 158, 11, 0.15);
  background: linear-gradient(135deg, rgba(245, 158, 11, 0.12), var(--surface));
}

.achievement-emoji {
  font-size: 1.8rem;
  flex-shrink: 0;
}

.achievement-info {
  min-width: 0;
  flex: 1;
}

.achievement-name {
  font-size: 0.85rem;
  font-weight: 700;
  color: var(--text);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.achievement-card:not(.unlocked) .achievement-name {
  color: var(--text-muted);
}

.achievement-folds {
  font-size: 0.7rem;
  color: var(--text-muted);
  margin-top: 0.1rem;
}

.achievement-card.unlocked .achievement-folds {
  color: var(--primary-light);
}

.achievement-card.current .achievement-folds {
  color: var(--gold-light);
}

/* ── Moon overlay ── */
.moon-overlay {
  display: none;
  position: fixed;
  inset: 0;
  background: radial-gradient(ellipse at center, rgba(30, 41, 59, 0.95) 0%, rgba(0, 0, 0, 0.97) 100%);
  z-index: 200;
  align-items: center;
  justify-content: center;
  backdrop-filter: blur(8px);
}

.moon-overlay.active {
  display: flex;
  animation: fadeIn 0.4s ease;
}

@keyframes fadeIn {
  from { opacity: 0; }
  to { opacity: 1; }
}

.moon-overlay__inner {
  text-align: center;
  max-width: 460px;
  padding: 2rem 1.5rem;
  animation: popIn 0.5s cubic-bezier(0.34, 1.56, 0.64, 1);
}

@keyframes popIn {
  from { opacity: 0; transform: scale(0.85) translateY(20px); }
  to { opacity: 1; transform: scale(1) translateY(0); }
}

.moon-overlay__emoji {
  font-size: 5rem;
  line-height: 1;
  margin-bottom: 1rem;
  filter: drop-shadow(0 0 30px rgba(251, 191, 36, 0.6));
  animation: float 3s ease-in-out infinite;
}

.moon-overlay__title {
  font-size: 2rem;
  font-weight: 800;
  color: var(--gold-light);
  margin-bottom: 0.75rem;
}

.moon-overlay__desc {
  font-size: 0.95rem;
  color: var(--text-muted);
  line-height: 1.7;
  margin-bottom: 1.5rem;
}

.moon-overlay__btn {
  background: linear-gradient(135deg, var(--gold-dark, #d97706), var(--gold-light));
  border: none;
  color: white;
  padding: 0.75rem 2rem;
  border-radius: 999px;
  cursor: pointer;
  font-size: 1rem;
  font-weight: 700;
  transition: all 0.2s;
}

.moon-overlay__btn:hover {
  transform: translateY(-2px);
  box-shadow: 0 8px 24px rgba(245, 158, 11, 0.4);
}

/* ── Star burst on fold ── */
.spark {
  position: absolute;
  pointer-events: none;
  width: 4px;
  height: 4px;
  background: var(--gold-light);
  border-radius: 50%;
  z-index: 5;
  animation: spark-fly 0.6s ease-out forwards;
}

@keyframes spark-fly {
  0% { opacity: 1; transform: translate(0, 0) scale(1); }
  100% { opacity: 0; transform: translate(var(--dx, 40px), var(--dy, -40px)) scale(0.3); }
}

/* ── Background stars (visible at high folds) ── */
.stars-bg {
  position: fixed;
  inset: 0;
  pointer-events: none;
  z-index: -1;
  opacity: 0;
  transition: opacity 1.5s ease;
}

.stars-bg.visible { opacity: 1; }
