:root {
  --bg-deep: #101828;
  --bg-mid: #1b2a40;
  --bg-light: #24344f;
  --surface: #fdf6ea;
  --surface-alt: #fff1d6;
  --ink: #101828;
  --ink-soft: #334155;
  --neon: #3bd1ff;
  --sun: #ff8a5c;
  --lime: #9ef01a;
  --purple: #6c5ce7;
  --shadow: 0 18px 45px rgba(16, 24, 40, 0.28);
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  font-family: "Outfit", "Segoe UI", sans-serif;
  color: var(--ink);
  background: radial-gradient(circle at 20% 20%, rgba(255, 138, 92, 0.35), transparent 45%),
    radial-gradient(circle at 80% 10%, rgba(59, 209, 255, 0.35), transparent 40%),
    linear-gradient(145deg, #f7efe4 0%, #f6fbff 50%, #f0f5e7 100%);
  min-height: 100vh;
}

.page {
  max-width: 1200px;
  margin: 0 auto;
  padding: 32px 24px 40px;
  position: relative;
}

.game-header {
  display: grid;
  grid-template-columns: auto 1fr auto;
  gap: 24px;
  align-items: center;
  background: linear-gradient(120deg, #ffefcf, #fce7f3 45%, #dbeafe 100%);
  border-radius: 24px;
  padding: 24px;
  box-shadow: var(--shadow);
  position: relative;
  overflow: hidden;
}

.game-header::after {
  content: "";
  position: absolute;
  right: -60px;
  top: -60px;
  width: 180px;
  height: 180px;
  background: radial-gradient(circle, rgba(59, 209, 255, 0.6), transparent 70%);
  opacity: 0.7;
}

.back-link {
  width: 44px;
  height: 44px;
  border-radius: 12px;
  background: #fff;
  display: grid;
  place-items: center;
  text-decoration: none;
  color: var(--ink);
  font-size: 22px;
  box-shadow: 0 12px 24px rgba(15, 23, 42, 0.12);
}

.title-block h1 {
  margin: 8px 0 6px;
  font-family: "Bungee", "Segoe UI", sans-serif;
  font-size: clamp(2rem, 3.2vw, 3rem);
  letter-spacing: 1px;
  text-transform: uppercase;
}

.eyebrow {
  font-size: 0.9rem;
  letter-spacing: 2px;
  text-transform: uppercase;
  color: #c026d3;
  margin: 0;
  font-weight: 600;
}

.subtitle {
  margin: 0;
  color: var(--ink-soft);
  max-width: 520px;
}

.header-actions {
  display: grid;
  gap: 12px;
}

.btn {
  border: none;
  border-radius: 14px;
  padding: 12px 20px;
  font-family: "Outfit", "Segoe UI", sans-serif;
  font-weight: 600;
  cursor: pointer;
  transition: transform 0.2s ease, box-shadow 0.2s ease, background 0.2s ease;
}

.btn.primary {
  background: linear-gradient(120deg, var(--sun), var(--neon));
  color: #0f172a;
  box-shadow: 0 14px 30px rgba(255, 138, 92, 0.35);
}

.btn.ghost {
  background: #fff;
  color: var(--ink);
  border: 1px solid rgba(15, 23, 42, 0.1);
}

.btn:hover {
  transform: translateY(-2px) scale(1.01);
  box-shadow: 0 16px 34px rgba(15, 23, 42, 0.18);
}

.game-grid {
  display: grid;
  grid-template-columns: minmax(280px, 330px) 1fr;
  gap: 24px;
  margin-top: 28px;
}

.scoreboard {
  display: grid;
  gap: 18px;
}

.panel {
  background: #ffffff;
  border-radius: 20px;
  padding: 18px;
  box-shadow: var(--shadow);
  border: 1px solid rgba(15, 23, 42, 0.08);
}

.panel h2 {
  margin: 0 0 12px;
  font-size: 1.1rem;
}

.mode-options {
  display: grid;
  gap: 10px;
}

.mode-option {
  display: flex;
  align-items: center;
  gap: 10px;
  background: var(--surface-alt);
  border-radius: 12px;
  padding: 10px 12px;
  cursor: pointer;
  font-weight: 600;
}

.mode-option input {
  accent-color: var(--purple);
}

.stats-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 12px;
}

.stat {
  background: #f8fafc;
  border-radius: 14px;
  padding: 10px 12px;
  display: grid;
  gap: 4px;
}

.stat-label {
  font-size: 0.75rem;
  text-transform: uppercase;
  letter-spacing: 1px;
  color: #64748b;
}

.stat-value {
  font-size: 1.4rem;
  font-weight: 700;
}

.combo-panel {
  background: linear-gradient(140deg, #fff1d6, #e0f2fe);
}

.combo-copy {
  margin: 0 0 12px;
  color: #475569;
}

.combo-meter {
  height: 12px;
  background: rgba(15, 23, 42, 0.08);
  border-radius: 999px;
  overflow: hidden;
}

.combo-fill {
  height: 100%;
  width: 0;
  background: linear-gradient(120deg, #34d399, #3b82f6);
  transition: width 0.3s ease;
}

.instructions-panel ol {
  margin: 0;
  padding-left: 18px;
  display: grid;
  gap: 6px;
  color: #334155;
}

.tip-panel {
  background: linear-gradient(120deg, #dbeafe, #fef3c7);
}

.arena {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 24px;
}

.column {
  background: rgba(255, 255, 255, 0.9);
  border-radius: 22px;
  padding: 20px;
  box-shadow: var(--shadow);
  min-height: 480px;
  display: grid;
  grid-template-rows: auto 1fr;
  gap: 16px;
}

.column-header h2 {
  margin: 0;
  font-size: 1.3rem;
  display: flex;
  align-items: center;
  gap: 8px;
}

.column-tip {
  margin: 4px 0 0;
  color: #64748b;
}

.tile-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(140px, 1fr));
  gap: 14px;
}

.tile {
  border: none;
  border-radius: 16px;
  padding: 14px;
  text-align: left;
  display: grid;
  gap: 6px;
  background: #fff;
  box-shadow: 0 10px 18px rgba(15, 23, 42, 0.12);
  cursor: pointer;
  position: relative;
  transition: transform 0.2s ease, box-shadow 0.2s ease, border 0.2s ease;
  min-height: 86px;
}

.tile.extension {
  background: #fff7ed;
}

.tile.program {
  background: #eff6ff;
}

.tile .tile-icon {
  font-size: 1.5rem;
}

.step-badge {
  width: 28px;
  height: 28px;
  border-radius: 999px;
  display: inline-grid;
  place-items: center;
  font-size: 0.85rem;
  font-weight: 700;
  color: #fff;
  background: #f97316;
  box-shadow: 0 8px 14px rgba(249, 115, 22, 0.35);
}

.step-badge.step-two {
  background: #2563eb;
  box-shadow: 0 8px 14px rgba(37, 99, 235, 0.35);
}

.tile-badge {
  width: 36px;
  height: 36px;
  border-radius: 10px;
  background: var(--badge-color, #334155);
  color: #fff;
  display: grid;
  place-items: center;
  font-weight: 700;
  letter-spacing: 1px;
}

.tile .tile-label {
  font-weight: 700;
}

.tile .tile-sub {
  font-size: 0.85rem;
  color: #64748b;
}

.tile.selected {
  border: 2px solid var(--neon);
  box-shadow: 0 12px 24px rgba(59, 209, 255, 0.3);
  transform: translateY(-2px);
}

.tile.matched {
  background: #dcfce7;
  border: 2px solid #22c55e;
  color: #14532d;
  cursor: default;
}

.tile.hint {
  border: 2px dashed var(--purple);
  box-shadow: 0 0 0 4px rgba(108, 92, 231, 0.2);
}

.tile.wrong {
  animation: shake 0.3s linear;
  border: 2px solid #ef4444;
}

@keyframes shake {
  0% { transform: translateX(0); }
  25% { transform: translateX(-4px); }
  50% { transform: translateX(4px); }
  75% { transform: translateX(-3px); }
  100% { transform: translateX(0); }
}

.mission-banner {
  margin-top: 24px;
  display: flex;
  flex-wrap: wrap;
  gap: 12px;
  align-items: center;
  justify-content: space-between;
  background: #fff;
  border-radius: 18px;
  padding: 12px 18px;
  box-shadow: var(--shadow);
}

.mission-chip {
  background: var(--surface);
  padding: 10px 14px;
  border-radius: 999px;
  font-weight: 600;
}

#status {
  font-weight: 700;
}

#status.status-live {
  color: #16a34a;
}

#status.status-idle {
  color: #c2410c;
}

.overlay {
  position: fixed;
  inset: 0;
  background: rgba(15, 23, 42, 0.65);
  display: grid;
  place-items: center;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.2s ease;
  z-index: 20;
}

.overlay.active {
  opacity: 1;
  pointer-events: auto;
}

.overlay-card {
  background: #fff;
  border-radius: 24px;
  padding: 28px;
  max-width: 420px;
  width: 90%;
  box-shadow: var(--shadow);
  text-align: center;
}

.overlay-card h2 {
  margin-top: 0;
}

.overlay-stats {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 12px;
  margin: 18px 0 24px;
}

.overlay-label {
  display: block;
  font-size: 0.75rem;
  letter-spacing: 1px;
  text-transform: uppercase;
  color: #64748b;
}

.overlay-value {
  font-size: 1.2rem;
  font-weight: 700;
}

.overlay-actions {
  display: grid;
  gap: 10px;
}

.site-footer {
  margin-top: 36px;
  display: flex;
  flex-wrap: wrap;
  justify-content: space-between;
  gap: 12px;
  font-weight: 600;
  color: #475569;
}

.footer-links {
  display: flex;
  gap: 16px;
}

.footer-links a {
  color: inherit;
  text-decoration: none;
}

@media (max-width: 1024px) {
  .game-grid {
    grid-template-columns: 1fr;
  }

  .arena {
    grid-template-columns: 1fr;
  }

  .game-header {
    grid-template-columns: 1fr;
    align-items: start;
  }

  .header-actions {
    grid-template-columns: repeat(auto-fit, minmax(140px, 1fr));
    width: 100%;
  }
}

@media (max-width: 640px) {
  .page {
    padding: 20px 16px 32px;
  }

  .tile-grid {
    grid-template-columns: repeat(auto-fit, minmax(120px, 1fr));
  }

  .mission-banner {
    flex-direction: column;
    align-items: stretch;
  }
}

@media (prefers-reduced-motion: reduce) {
  * {
    animation-duration: 0.01ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.01ms !important;
  }
}
