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

body {
  background: linear-gradient(135deg, #0f0c29, #302b63, #24243e);
  height: 100dvh;
  height: 100vh;
  display: flex;
  flex-direction: column;
  align-items: center;
  font-family: 'Segoe UI', system-ui, sans-serif;
  color: #fff;
  overflow: hidden;
  touch-action: manipulation;
  -webkit-tap-highlight-color: transparent;
  user-select: none;
  -webkit-user-select: none;
}

.header {
  text-align: center;
  padding: 10px 15px 0;
  width: 100%;
  max-width: 800px;
  flex-shrink: 0;
}

.header h1 {
  font-size: 1.6em;
  background: linear-gradient(90deg, #ff6b6b, #ffd93d, #6bcb77, #4d96ff);
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  text-shadow: none;
  margin-bottom: 2px;
}

.header .subtitle {
  color: #8888aa;
  font-size: 0.8em;
}

.stats-bar {
  display: flex;
  justify-content: center;
  gap: 16px;
  padding: 8px 12px;
  background: rgba(255,255,255,0.05);
  border-radius: 10px;
  margin: 8px 0;
  backdrop-filter: blur(10px);
  border: 1px solid rgba(255,255,255,0.08);
  width: 100%;
  max-width: 800px;
  flex-shrink: 0;
}

.stat {
  text-align: center;
}

.stat .label {
  font-size: 0.65em;
  color: #8888aa;
  text-transform: uppercase;
  letter-spacing: 1px;
}

.stat .value {
  font-size: 1.2em;
  font-weight: bold;
  color: #ffd93d;
}

.controls {
  display: flex;
  gap: 8px;
  padding: 6px 10px;
  flex-wrap: nowrap;
  justify-content: center;
  width: 100%;
  max-width: 800px;
  flex-shrink: 0;
}

.btn {
  padding: 10px 14px;
  border: none;
  border-radius: 8px;
  font-size: 0.85em;
  cursor: pointer;
  transition: all 0.2s;
  font-weight: 600;
  color: #fff;
  white-space: nowrap;
  min-height: 44px;
  flex: 1;
  max-width: 140px;
}

.btn:hover { transform: translateY(-2px); box-shadow: 0 4px 15px rgba(0,0,0,0.3); }
.btn:active { transform: translateY(0); }
.btn:disabled { opacity: 0.4; cursor: not-allowed; transform: none; box-shadow: none; }

.btn-hint { background: linear-gradient(135deg, #4d96ff, #3b82f6); }
.btn-shuffle { background: linear-gradient(135deg, #ff6b6b, #ef4444); }
.btn-restart { background: linear-gradient(135deg, #6bcb77, #22c55e); }
.btn-undo { background: linear-gradient(135deg, #ffd93d, #f59e0b); }

.game-container {
  flex: 1;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 4px;
  min-height: 0;
  width: 100%;
}

canvas {
  border-radius: 12px;
  box-shadow: 0 8px 32px rgba(0,0,0,0.4);
  cursor: pointer;
  touch-action: manipulation;
}

.overlay {
  position: fixed;
  top: 0; left: 0; right: 0; bottom: 0;
  background: rgba(0,0,0,0.7);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 100;
  backdrop-filter: blur(5px);
}

.overlay-content {
  background: linear-gradient(135deg, #1a1a2e, #16213e);
  padding: 30px 35px;
  border-radius: 20px;
  text-align: center;
  border: 1px solid rgba(255,255,255,0.1);
  box-shadow: 0 20px 60px rgba(0,0,0,0.5);
  max-width: 340px;
  width: 90%;
}

.overlay-content h2 {
  font-size: 1.8em;
  margin-bottom: 8px;
  background: linear-gradient(90deg, #ff6b6b, #ffd93d);
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
}

.overlay-content p {
  color: #aaa;
  margin-bottom: 16px;
  line-height: 1.5;
  font-size: 0.9em;
}

.overlay-content .btn {
  font-size: 1.05em;
  padding: 12px 30px;
  flex: none;
  max-width: none;
}

.overlay-buttons {
  display: flex;
  gap: 10px;
  justify-content: center;
  flex-wrap: wrap;
}

.hidden { display: none !important; }

.combo-display {
  position: fixed;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  font-size: 2.5em;
  font-weight: bold;
  color: #ffd93d;
  text-shadow: 0 0 20px rgba(255,217,61,0.5);
  pointer-events: none;
  z-index: 50;
  opacity: 0;
  transition: opacity 0.3s;
}

.combo-display.show {
  opacity: 1;
  animation: comboPop 0.6s ease-out;
}

@keyframes comboPop {
  0% { transform: translate(-50%, -50%) scale(0.5); opacity: 0; }
  50% { transform: translate(-50%, -50%) scale(1.3); opacity: 1; }
  100% { transform: translate(-50%, -50%) scale(1); opacity: 0; }
}

.particles-container {
  position: fixed;
  top: 0; left: 0; right: 0; bottom: 0;
  pointer-events: none;
  z-index: 40;
}

.particle {
  position: absolute;
  width: 6px;
  height: 6px;
  border-radius: 50%;
  animation: particleFly 0.8s ease-out forwards;
}

@keyframes particleFly {
  0% { opacity: 1; transform: scale(1); }
  100% { opacity: 0; transform: scale(0) translateY(-60px); }
}

@media (min-width: 768px) {
  .header { padding: 20px; }
  .header h1 { font-size: 2.2em; }
  .stats-bar { gap: 30px; padding: 12px 20px; margin: 10px 0 12px; }
  .stat .label { font-size: 0.75em; }
  .stat .value { font-size: 1.5em; }
  .controls { gap: 10px; margin-bottom: 10px; }
  .btn { padding: 8px 20px; font-size: 0.9em; }
  .overlay-content { padding: 40px 50px; max-width: 400px; }
  .overlay-content h2 { font-size: 2em; }
  .combo-display { font-size: 3em; }
}

@media (max-height: 600px) and (orientation: landscape) {
  .header { padding: 4px 10px 0; }
  .header h1 { font-size: 1.2em; margin-bottom: 0; }
  .header .subtitle { display: none; }
  .stats-bar { padding: 4px 8px; margin: 4px 0; gap: 10px; }
  .stat .label { font-size: 0.55em; }
  .stat .value { font-size: 1em; }
  .controls { padding: 3px 6px; gap: 5px; }
  .btn { padding: 6px 10px; font-size: 0.75em; min-height: 36px; }
  .overlay-content { padding: 20px 25px; }
  .overlay-content h2 { font-size: 1.5em; }
}
