:root {
  --bg: #07081a;
  --glass: rgba(255, 255, 255, 0.06);
  --glass-border: rgba(255, 255, 255, 0.12);
  --text: #eef0ff;
  --muted: #9aa1c7;
  --violet: #8b5cf6;
  --blue: #3b82f6;
  --cyan: #22d3ee;
  --gold: #fbbf24;
  --green: #34d399;
  --font-ui: "Vazirmatn", Tahoma, system-ui, sans-serif;
  --font-display: "Space Grotesk", "Vazirmatn", system-ui, sans-serif;
}

* { box-sizing: border-box; }

body {
  margin: 0;
  min-height: 100vh;
  background: var(--bg);
  color: var(--text);
  font-family: var(--font-ui);
  display: flex;
  justify-content: center;
  overflow-x: hidden;
}

/* Animated aurora background */
.aurora {
  position: fixed;
  inset: 0;
  z-index: -1;
  overflow: hidden;
}
.aurora i {
  position: absolute;
  width: 55vmax;
  height: 55vmax;
  border-radius: 50%;
  filter: blur(90px);
  opacity: 0.35;
  animation: drift 22s ease-in-out infinite alternate;
}
.aurora i:nth-child(1) { background: var(--violet); top: -20vmax; left: -15vmax; }
.aurora i:nth-child(2) { background: var(--blue); bottom: -25vmax; right: -15vmax; animation-delay: -8s; }
.aurora i:nth-child(3) { background: var(--cyan); top: 30%; left: 40%; width: 30vmax; height: 30vmax; opacity: 0.18; animation-delay: -14s; }
@keyframes drift {
  to { transform: translate(8vmax, 6vmax) scale(1.15); }
}

.app {
  width: 100%;
  max-width: 480px;
  padding: 28px 16px 48px;
}

header { text-align: center; margin-bottom: 22px; }
header h1 {
  margin: 0;
  font-family: var(--font-display);
  font-size: clamp(2.6rem, 11vw, 3.4rem);
  font-weight: 700;
  letter-spacing: -1px;
  line-height: 1;
  background: linear-gradient(90deg, #fff 0%, var(--cyan) 45%, var(--violet) 100%);
  -webkit-background-clip: text;
  background-clip: text;
  color: transparent;
}
header h1 span { filter: drop-shadow(0 0 14px rgba(34, 211, 238, 0.55)); }
header p { margin: 10px 0 0; color: var(--muted); font-size: 0.95rem; }
header b {
  color: var(--gold);
  font-family: var(--font-display);
  background: rgba(251, 191, 36, 0.12);
  padding: 1px 8px;
  border-radius: 8px;
}

/* Board */
.board {
  position: relative;
  width: min(100%, 380px);
  aspect-ratio: 1;
  margin: 0 auto;
  padding: 10px;
  border-radius: 28px;
  background: var(--glass);
  border: 1px solid var(--glass-border);
  backdrop-filter: blur(18px);
  -webkit-backdrop-filter: blur(18px);
  box-shadow: 0 30px 80px -20px rgba(139, 92, 246, 0.45), inset 0 1px 0 rgba(255, 255, 255, 0.12);
}

.tile {
  position: absolute;
  width: calc((100% - 20px) / 3);
  height: calc((100% - 20px) / 3);
  padding: 5px;
  transition: left 0.2s cubic-bezier(0.34, 1.3, 0.64, 1), top 0.2s cubic-bezier(0.34, 1.3, 0.64, 1);
}
.tile button {
  width: 100%;
  height: 100%;
  border: 0;
  border-radius: 20px;
  background: linear-gradient(145deg, var(--violet), var(--blue));
  color: #fff;
  font-family: var(--font-display);
  font-size: clamp(2rem, 9vw, 2.8rem);
  font-weight: 700;
  cursor: pointer;
  text-shadow: 0 2px 8px rgba(0, 0, 0, 0.35);
  box-shadow: 0 10px 22px -8px rgba(59, 130, 246, 0.7), inset 0 2px 0 rgba(255, 255, 255, 0.35), inset 0 -4px 0 rgba(0, 0, 0, 0.18);
  transition: transform 0.12s, box-shadow 0.2s, background 0.3s;
}
.tile button:hover { transform: translateY(-2px) scale(1.03); }
.tile button:active { transform: translateY(2px) scale(0.97); }
.tile.placed button {
  background: linear-gradient(145deg, var(--green), var(--cyan));
  color: #04261b;
  text-shadow: none;
  box-shadow: 0 10px 22px -8px rgba(52, 211, 153, 0.7), inset 0 2px 0 rgba(255, 255, 255, 0.45), inset 0 -4px 0 rgba(0, 0, 0, 0.12);
}

.banner {
  text-align: center;
  font-weight: 800;
  font-size: 1.15rem;
  margin: 16px 0 0;
  color: var(--green);
  text-shadow: 0 0 18px rgba(52, 211, 153, 0.6);
  animation: pop 0.5s cubic-bezier(0.34, 1.56, 0.64, 1);
}
@keyframes pop { from { transform: scale(0.6); opacity: 0; } }

/* Controls */
.controls {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  justify-content: center;
  margin: 24px 0;
}
.controls button,
.controls select {
  font: inherit;
  font-weight: 600;
  font-size: 0.9rem;
  padding: 10px 16px;
  border-radius: 14px;
  border: 1px solid var(--glass-border);
  background: var(--glass);
  color: var(--text);
  cursor: pointer;
  backdrop-filter: blur(10px);
  transition: transform 0.12s, background 0.2s, box-shadow 0.2s;
}
.controls button:hover:not(:disabled) { background: rgba(255, 255, 255, 0.12); transform: translateY(-1px); }
.controls button:active:not(:disabled) { transform: translateY(1px); }
.controls button.primary {
  border: 0;
  color: #1c1300;
  background: linear-gradient(135deg, var(--gold), #fb923c);
  box-shadow: 0 10px 28px -8px rgba(251, 146, 60, 0.7);
}
.controls button.primary:hover:not(:disabled) { background: linear-gradient(135deg, #fcd34d, #fdba74); }
.controls button:disabled { opacity: 0.35; cursor: not-allowed; }
.controls select option { color: #111; }
.speed { display: flex; align-items: center; gap: 8px; color: var(--muted); font-size: 0.85rem; }

/* Progress */
.progress {
  height: 6px;
  border-radius: 99px;
  background: var(--glass);
  overflow: hidden;
  margin-bottom: 18px;
}
.progress div {
  height: 100%;
  width: 0;
  border-radius: inherit;
  background: linear-gradient(90deg, var(--cyan), var(--violet));
  box-shadow: 0 0 14px var(--cyan);
  transition: width 0.25s ease;
}

/* Stats */
.stats {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 10px;
}
.stats div {
  background: var(--glass);
  border: 1px solid var(--glass-border);
  border-radius: 16px;
  padding: 12px 6px;
  text-align: center;
}
.stats span {
  display: block;
  font-size: 1.45rem;
  font-weight: 800;
  background: linear-gradient(180deg, #fff, var(--cyan));
  -webkit-background-clip: text;
  background-clip: text;
  color: transparent;
}
.stats small { color: var(--muted); font-size: 0.72rem; }

/* Solution chips */
.solution {
  margin-top: 16px;
  background: var(--glass);
  border: 1px solid var(--glass-border);
  border-radius: 18px;
  padding: 14px 16px;
}
.solution h2 { margin: 0 0 10px; font-size: 0.85rem; color: var(--muted); font-weight: 500; }
.solution ol {
  list-style: none;
  margin: 0;
  padding: 0;
  display: flex;
  flex-wrap: wrap;
  gap: 5px;
}
.solution li {
  min-width: 30px;
  text-align: center;
  padding: 3px 7px;
  border-radius: 9px;
  background: rgba(255, 255, 255, 0.08);
  font-size: 1.05rem;
  transition: background 0.2s, color 0.2s;
}
.solution li.done { background: linear-gradient(135deg, var(--green), var(--cyan)); color: #04261b; }

footer { margin-top: 24px; text-align: center; color: var(--muted); font-size: 0.8rem; line-height: 1.8; }

.repo-link {
  display: flex;
  width: fit-content;
  align-items: center;
  gap: 8px;
  margin: 14px auto 0;
  padding: 8px 16px;
  border-radius: 99px;
  border: 1px solid var(--glass-border);
  background: var(--glass);
  color: var(--text);
  text-decoration: none;
  font-weight: 600;
  transition: background 0.2s, transform 0.12s;
}
.repo-link:hover { background: rgba(255, 255, 255, 0.12); transform: translateY(-1px); }

#confetti { position: fixed; inset: 0; width: 100%; height: 100%; pointer-events: none; z-index: 10; }

@media (prefers-reduced-motion: reduce) {
  .aurora i, .banner { animation: none; }
  .tile { transition: none; }
}
