@import url('https://fonts.googleapis.com/css2?family=Orbitron:wght@400;700;900&family=Inter:wght@400;600&display=swap');

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

body {
  display: flex;
  flex-direction: column;
  background: radial-gradient(ellipse at center, #0e1a2a, #050a12);
  justify-content: flex-start;
  align-items: center;
  min-height: 100vh;
  margin: 0;
  font-family: 'Orbitron', 'Inter', sans-serif;
  color: #e0f0ff;
  padding: 16px;
  overflow-x: hidden;
}

body::before {
  content: '';
  position: fixed;
  inset: 0;
  background: radial-gradient(ellipse at 30% 30%, rgba(0,212,255,0.08) 0%, transparent 60%);
  pointer-events: none;
}

#game-container {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 16px;
  z-index: 1;
  width: 100%;
  max-width: 420px;
}

#game-title {
  font-family: 'Orbitron', monospace;
  font-size: clamp(1rem, 5vw, 1.5rem);
  font-weight: 900;
  color: #00d4ff;
  text-shadow: 0 0 16px rgba(0,212,255,0.5);
  letter-spacing: 2px;
  text-align: center;
}

#timer {
  font-size: clamp(1rem, 4vw, 1.4rem);
  font-weight: 700;
  color: #a855f7;
  text-shadow: 0 0 10px rgba(168,85,247,0.5);
  font-family: 'Orbitron', monospace;
  letter-spacing: 2px;
}

#moves-counter {
  font-size: clamp(0.7rem, 2.5vw, 1rem);
  color: rgba(0,212,255,0.6);
  font-family: 'Orbitron', monospace;
  letter-spacing: 1px;
}

#puzzle-container {
  display: grid;
  grid-template-columns: repeat(3, clamp(80px, 27vw, 115px));
  gap: 6px;
  background: rgba(0,212,255,0.06);
  border: 1px solid rgba(0,212,255,0.2);
  padding: 12px;
  box-shadow: 0 0 30px rgba(0,212,255,0.1), 0 8px 32px rgba(0,0,0,0.5);
  border-radius: 12px;
}

.tile {
  width: clamp(80px, 27vw, 115px);
  height: clamp(80px, 27vw, 115px);
  background: linear-gradient(135deg, #1a3a5c, #0e2840);
  border: 1px solid rgba(0,212,255,0.3);
  color: #00d4ff;
  display: flex;
  justify-content: center;
  align-items: center;
  font-size: clamp(1.4rem, 6vw, 2.2rem);
  font-weight: 900;
  cursor: pointer;
  user-select: none;
  border-radius: 8px;
  transition: all 0.15s;
  text-shadow: 0 0 10px rgba(0,212,255,0.5);
  box-shadow: 0 2px 8px rgba(0,0,0,0.4);
  -webkit-tap-highlight-color: transparent;
}

.tile:hover {
  background: linear-gradient(135deg, #1e4a70, #122e50);
  border-color: rgba(0,212,255,0.6);
  box-shadow: 0 0 14px rgba(0,212,255,0.3);
  transform: scale(1.04);
}

.tile:active { transform: scale(0.96); }

.tile.empty {
  background: rgba(0,0,0,0.3);
  cursor: default;
  border-color: rgba(0,0,0,0);
  box-shadow: none;
}

.tile.empty:hover { transform: none; border-color: transparent; box-shadow: none; }

.btn-group {
  display: flex;
  gap: 10px;
  flex-wrap: wrap;
  justify-content: center;
}

.btn-group button,
#shuffle-button,
#reset-button {
  padding: 10px 26px;
  font-size: clamp(0.7rem, 2.5vw, 1rem);
  font-family: 'Orbitron', monospace;
  font-weight: 700;
  cursor: pointer;
  color: #1a0a30;
  background: linear-gradient(135deg, #00d4ff, #a855f7);
  border: none;
  border-radius: 8px;
  letter-spacing: 1px;
  transition: all 0.2s;
  box-shadow: 0 4px 16px rgba(0,212,255,0.3);
}

#shuffle-button:hover, #reset-button:hover, .btn-group button:hover {
  transform: translateY(-2px);
  box-shadow: 0 6px 20px rgba(0,212,255,0.4);
}

/* ── Win message ── */
#win-message {
  font-family: 'Orbitron', monospace;
  font-size: clamp(1rem, 4vw, 1.4rem);
  font-weight: 900;
  color: #00ff88;
  text-shadow: 0 0 16px rgba(0,255,136,0.6);
  text-align: center;
  animation: winPop 0.4s cubic-bezier(0.34, 1.56, 0.64, 1);
}

@keyframes winPop {
  from { transform: scale(0.5); opacity: 0; }
  to   { transform: scale(1); opacity: 1; }
}

/* Mobile */
@media (max-width: 380px) {
  #puzzle-container {
    grid-template-columns: repeat(3, minmax(0, 1fr));
    width: min(100%, calc(100vw - 32px));
    gap: 4px;
    padding: 8px;
  }

  .tile {
    width: 100%;
    aspect-ratio: 1;
    height: auto;
  }
}
