* {
  margin: 0;
  padding: 0;
  box-sizing: border-box;
  touch-action: manipulation;
  -webkit-tap-highlight-color: transparent;
  user-select: none;
}

html, body {
  width: 100%;
  height: 100%;
  overflow: hidden;
  background: #0f0f1a;
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
}

#game {
  width: 100%;
  height: 100%;
  max-width: 480px;
  margin: 0 auto;
  display: flex;
  flex-direction: column;
  padding: 16px;
  position: relative;
}

/* HUD */
#hud {
  display: flex;
  align-items: center;
  gap: 12px;
  margin-bottom: 20px;
}

#score-box, #best-box {
  display: flex;
  flex-direction: column;
  align-items: center;
  min-width: 60px;
}

#score, #best {
  font-size: 28px;
  font-weight: 800;
  color: #fff;
}

#score-box .label, #best-box .label {
  font-size: 10px;
  font-weight: 700;
  color: #666;
  letter-spacing: 1px;
}

#timer-bar {
  flex: 1;
  height: 12px;
  background: #1a1a2e;
  border-radius: 6px;
  overflow: hidden;
  border: 2px solid #333;
}

#timer-fill {
  height: 100%;
  width: 100%;
  background: linear-gradient(90deg, #22c55e 0%, #eab308 50%, #ef4444 100%);
  border-radius: 4px;
  transition: width 0.1s linear;
}

/* Target Section */
#target-section {
  text-align: center;
  margin-bottom: 30px;
}

.instruction {
  color: #888;
  font-size: 14px;
  margin-bottom: 12px;
  text-transform: uppercase;
  letter-spacing: 2px;
}

#target-word {
  font-size: 72px;
  font-weight: 900;
  text-transform: uppercase;
  letter-spacing: 4px;
  text-shadow: 0 4px 20px rgba(0,0,0,0.5);
  transition: transform 0.1s;
}

#target-word.pop {
  animation: pop 0.2s ease-out;
}

@keyframes pop {
  0% { transform: scale(1); }
  50% { transform: scale(1.15); }
  100% { transform: scale(1); }
}

/* Color Grid */
#color-grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 12px;
  flex: 1;
}

.color-btn {
  aspect-ratio: 1;
  border: none;
  border-radius: 20px;
  background: var(--btn-color);
  cursor: pointer;
  position: relative;
  box-shadow: 
    0 4px 0 rgba(0,0,0,0.3),
    0 8px 20px rgba(0,0,0,0.4),
    inset 0 2px 10px rgba(255,255,255,0.2);
  transition: all 0.1s;
}

.color-btn:active {
  transform: translateY(4px);
  box-shadow: 
    0 0 0 rgba(0,0,0,0.3),
    0 4px 10px rgba(0,0,0,0.4),
    inset 0 2px 10px rgba(0,0,0,0.2);
}

.color-btn.correct {
  animation: correct 0.3s ease-out;
}

.color-btn.wrong {
  animation: shake 0.4s ease-out;
}

@keyframes correct {
  0% { transform: scale(1); }
  50% { transform: scale(0.9); filter: brightness(1.5); }
  100% { transform: scale(1); }
}

@keyframes shake {
  0%, 100% { transform: translateX(0); }
  20% { transform: translateX(-10px); }
  40% { transform: translateX(10px); }
  60% { transform: translateX(-10px); }
  80% { transform: translateX(10px); }
}

/* Combo Indicator */
#combo {
  position: absolute;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  font-size: 48px;
  font-weight: 900;
  color: #eab308;
  text-shadow: 0 4px 20px rgba(234, 179, 8, 0.5);
  pointer-events: none;
  opacity: 0;
}

#combo.show {
  animation: comboAnim 0.8s ease-out forwards;
}

@keyframes comboAnim {
  0% { opacity: 0; transform: translate(-50%, -50%) scale(0.5); }
  20% { opacity: 1; transform: translate(-50%, -50%) scale(1.2); }
  80% { opacity: 1; transform: translate(-50%, -50%) scale(1); }
  100% { opacity: 0; transform: translate(-50%, -50%) scale(1) translateY(-50px); }
}

/* Overlays */
.overlay {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  background: rgba(15, 15, 26, 0.98);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 100;
}

.overlay.hidden {
  display: none;
}

.overlay-content {
  text-align: center;
  padding: 40px 20px;
  max-width: 360px;
}

.overlay h1 {
  font-size: 42px;
  font-weight: 900;
  color: #fff;
  margin-bottom: 24px;
  background: linear-gradient(135deg, #a855f7 0%, #3b82f6 100%);
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
}

.overlay h2 {
  font-size: 32px;
  font-weight: 800;
  color: #fff;
  margin-bottom: 24px;
}

.rules {
  color: #aaa;
  font-size: 16px;
  line-height: 1.6;
  margin-bottom: 20px;
}

.example {
  color: #666;
  font-size: 14px;
  margin-bottom: 40px;
  padding: 16px;
  background: #1a1a2e;
  border-radius: 12px;
}

.blue-dot {
  display: inline-block;
}

#final-score-display {
  margin: 30px 0;
}

#final-score {
  display: block;
  font-size: 72px;
  font-weight: 900;
  color: #22c55e;
  line-height: 1;
}

#new-record {
  font-size: 20px;
  font-weight: 700;
  color: #eab308;
  margin-bottom: 30px;
  animation: pulse 1s ease-in-out infinite;
}

@keyframes pulse {
  0%, 100% { transform: scale(1); }
  50% { transform: scale(1.05); }
}

.btn-primary {
  background: linear-gradient(135deg, #a855f7 0%, #3b82f6 100%);
  color: white;
  border: none;
  padding: 18px 60px;
  font-size: 20px;
  font-weight: 800;
  border-radius: 50px;
  cursor: pointer;
  box-shadow: 0 4px 20px rgba(168, 85, 247, 0.4);
  transition: all 0.2s;
  text-transform: uppercase;
  letter-spacing: 2px;
}

.btn-primary:hover {
  transform: translateY(-2px);
  box-shadow: 0 6px 25px rgba(168, 85, 247, 0.5);
}

.btn-primary:active {
  transform: translateY(0);
}

/* Responsive */
@media (max-height: 700px) {
  #target-word {
    font-size: 56px;
  }
  
  #color-grid {
    gap: 10px;
  }
  
  .color-btn {
    border-radius: 16px;
  }
}

@media (max-height: 600px) {
  #target-word {
    font-size: 48px;
  }
  
  .instruction {
    font-size: 12px;
    margin-bottom: 8px;
  }
  
  #target-section {
    margin-bottom: 20px;
  }
}
