:root {
  --primary: #4a6cf7;
  --primary-light: #6a88ff;
  --primary-dark: #3454d1;
  --secondary: #f75a5a;
  --accent: #ffb800;
  --bg-color: #f0f4ff;
  --text-main: #2d3748;
  --text-light: #718096;
  --white: #ffffff;
  --radius: 24px;
  --shadow: 0 10px 30px rgba(74, 108, 247, 0.1);
  --shadow-hover: 0 15px 40px rgba(74, 108, 247, 0.2);
}

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

body {
  font-family: 'Comic Sans MS', 'Nunito', 'Microsoft YaHei', 'PingFang SC', sans-serif;
  background-color: var(--bg-color);
  color: var(--text-main);
  min-height: 100vh;
  overflow-x: hidden;
  user-select: none;
  transition: background-color 0.5s ease;
}

/* Base UI */
button {
  font-family: 'Comic Sans MS', 'Nunito', 'Microsoft YaHei', 'PingFang SC', sans-serif;
  cursor: pointer;
  border: none;
  outline: none;
  border-radius: var(--radius);
  transition: all 0.2s cubic-bezier(0.175, 0.885, 0.32, 1.275);
}

button:active {
  transform: scale(0.95);
}

.page {
  display: none;
  min-height: 100vh;
  padding: 20px;
  align-items: center;
  justify-content: center;
}

.page.active {
  display: flex;
}

/* Sound Toggle */
.sound-toggle {
  position: fixed;
  top: 20px;
  right: 20px;
  width: 50px;
  height: 50px;
  border-radius: 50%;
  background: white;
  box-shadow: var(--shadow);
  font-size: 24px;
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 100;
}

/* Menu Page */
.menu-container {
  max-width: 800px;
  width: 100%;
  text-align: center;
}

.title-area {
  margin-bottom: 30px;
}

.title-clock-icon {
  font-size: 60px;
  animation: bounce 2s infinite;
}

.game-title {
  font-size: 48px;
  color: var(--primary);
  font-weight: 900;
  text-shadow: 2px 2px 0px white, 4px 4px 0px rgba(0,0,0,0.1);
  margin-bottom: 10px;
}

.game-subtitle {
  font-size: 20px;
  color: var(--text-light);
  font-weight: 600;
}

/* Mascot */
.mascot-area {
  margin-bottom: 40px;
  position: relative;
  height: 150px;
}

.mascot {
  position: absolute;
  left: 50%;
  transform: translateX(-50%);
  display: flex;
  align-items: flex-end;
}

.mascot-body {
  width: 100px;
  height: 100px;
  background: var(--accent);
  border-radius: 50px;
  position: relative;
  box-shadow: inset -10px -10px 0 rgba(0,0,0,0.1), 0 10px 20px rgba(255, 184, 0, 0.4);
  animation: float 3s ease-in-out infinite;
}

.mascot-face {
  position: absolute;
  top: 30px;
  left: 20px;
  right: 20px;
}

.mascot-eyes {
  display: flex;
  justify-content: space-around;
  margin-bottom: 10px;
}

.mascot-eye {
  width: 12px;
  height: 12px;
  background: #333;
  border-radius: 50%;
  position: relative;
  animation: blink 4s infinite;
}

.mascot-eye::after {
  content: '';
  position: absolute;
  top: 2px;
  right: 2px;
  width: 4px;
  height: 4px;
  background: white;
  border-radius: 50%;
}

.mascot-mouth {
  width: 20px;
  height: 10px;
  border: 3px solid #333;
  border-top: none;
  border-radius: 0 0 20px 20px;
  margin: 0 auto;
}

.mascot-mouth.happy {
  height: 15px;
  background: #ff7676;
}

.mascot-hands {
  position: absolute;
  width: 140px;
  left: -20px;
  top: 40px;
  display: flex;
  justify-content: space-between;
  font-size: 24px;
}

.mascot-speech {
  background: white;
  padding: 15px 25px;
  border-radius: 20px;
  margin-left: 20px;
  box-shadow: var(--shadow);
  position: relative;
  font-weight: 700;
  color: var(--text-main);
  animation: float 3s ease-in-out infinite 0.5s;
}

.mascot-speech::before {
  content: '';
  position: absolute;
  left: -10px;
  top: 20px;
  border-width: 10px 10px 10px 0;
  border-style: solid;
  border-color: transparent white transparent transparent;
}

/* Mode Grid */
.mode-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
  gap: 20px;
  padding: 0 20px;
}

.mode-card {
  background: white;
  padding: 30px 20px;
  display: flex;
  flex-direction: column;
  align-items: center;
  box-shadow: var(--shadow);
  color: var(--text-main);
}

.mode-card:hover {
  transform: translateY(-10px) scale(1.02);
  box-shadow: var(--shadow-hover);
}

.mode-card.challenge {
  background: linear-gradient(135deg, #ff9a9e 0%, #fecfef 99%, #fecfef 100%);
}

.mode-icon {
  font-size: 48px;
  margin-bottom: 15px;
}

.mode-name {
  font-size: 24px;
  font-weight: 800;
  margin-bottom: 5px;
}

.mode-desc {
  font-size: 14px;
  color: var(--text-light);
  margin-bottom: 15px;
}

.mode-stars {
  color: var(--accent);
  font-size: 20px;
  letter-spacing: 2px;
}

/* Game Page */
.game-container {
  max-width: 800px;
  width: 100%;
  background: white;
  border-radius: 40px;
  padding: 40px;
  box-shadow: var(--shadow);
  position: relative;
}

.game-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 30px;
}

.btn-back {
  background: #edf2f7;
  color: var(--text-main);
  padding: 10px 20px;
  font-weight: 700;
  font-size: 16px;
}

.btn-back:hover {
  background: #e2e8f0;
}

.game-mode-title {
  font-size: 24px;
  font-weight: 800;
  color: var(--primary);
  background: #edf2f7;
  padding: 5px 20px;
  border-radius: 20px;
}

.game-progress {
  text-align: right;
  font-weight: 800;
  color: var(--text-light);
}

.progress-bar {
  width: 100px;
  height: 10px;
  background: #edf2f7;
  border-radius: 5px;
  margin-top: 5px;
  overflow: hidden;
}

.progress-fill {
  height: 100%;
  background: var(--primary);
  width: 20%;
  transition: width 0.3s ease;
  border-radius: 5px;
}

/* Challenge Timer */
.challenge-timer {
  position: absolute;
  top: -25px;
  left: 50%;
  transform: translateX(-50%);
  background: var(--secondary);
  color: white;
  padding: 10px 30px;
  border-radius: 30px;
  font-size: 24px;
  font-weight: 900;
  display: flex;
  align-items: center;
  gap: 10px;
  box-shadow: 0 10px 20px rgba(247, 90, 90, 0.3);
  animation: pulse 1s infinite;
}

.combo-display {
  position: absolute;
  top: 20px;
  right: -20px;
  background: linear-gradient(45deg, #ff9a9e, #fecfef);
  padding: 10px 20px;
  border-radius: 20px;
  font-weight: 800;
  color: #333;
  box-shadow: var(--shadow);
  transform: rotate(5deg);
  animation: popIn 0.5s cubic-bezier(0.175, 0.885, 0.32, 1.275);
}

/* Question Area */
.question-area {
  text-align: center;
  margin-bottom: 30px;
  min-height: 80px;
  display: flex;
  flex-direction: column;
  justify-content: center;
}

.question-text {
  font-size: 32px;
  font-weight: 800;
  color: var(--text-main);
  line-height: 1.4;
}

.story-content {
  background: #f8fafc;
  padding: 20px;
  border-radius: 20px;
  border: 2px dashed #cbd5e1;
}

.story-scene {
  font-size: 48px;
  margin-bottom: 10px;
}

.story-text {
  font-size: 20px;
  color: var(--text-main);
  margin-bottom: 15px;
}

.story-step {
  font-size: 24px;
  font-weight: 800;
  color: var(--primary);
}

/* Clock Area */
.clock-area {
  display: flex;
  flex-direction: column;
  align-items: center;
  margin-bottom: 30px;
  position: relative;
}

.clock-svg {
  width: 300px;
  height: 300px;
  touch-action: none; /* Prevent scrolling when dragging */
}

.current-time-display {
  margin-top: 20px;
  background: #edf2f7;
  padding: 10px 30px;
  border-radius: 20px;
  font-size: 28px;
  font-weight: 900;
  font-family: monospace;
  color: var(--primary);
  display: flex;
  align-items: center;
  gap: 10px;
}

/* Choices Area */
.choices-area {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 20px;
}

.choice-btn {
  background: white;
  border: 3px solid #e2e8f0;
  padding: 20px;
  font-size: 28px;
  font-weight: 800;
  color: var(--text-main);
  font-family: monospace;
}

.choice-btn:hover {
  border-color: var(--primary-light);
  background: #f0f4ff;
  transform: translateY(-5px);
}

.choice-btn.correct {
  background: #48bb78;
  color: white;
  border-color: #48bb78;
}

.choice-btn.wrong {
  background: #f56565;
  color: white;
  border-color: #f56565;
  animation: shake 0.5s;
}

/* Submit Area */
.submit-area {
  text-align: center;
}

.btn-submit {
  background: var(--primary);
  color: white;
  font-size: 24px;
  font-weight: 800;
  padding: 15px 50px;
  box-shadow: 0 10px 20px rgba(74, 108, 247, 0.3);
}

.btn-submit:hover {
  background: var(--primary-dark);
  transform: translateY(-5px);
  box-shadow: 0 15px 25px rgba(74, 108, 247, 0.4);
}

.btn-submit.correct {
  background: #48bb78;
  box-shadow: 0 10px 20px rgba(72, 187, 120, 0.3);
}

.btn-submit.wrong {
  background: #f56565;
  box-shadow: 0 10px 20px rgba(245, 101, 101, 0.3);
  animation: shake 0.5s;
}

/* Feedback Overlay */
.feedback-overlay {
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  background: rgba(255, 255, 255, 0.9);
  border-radius: 40px;
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 10;
  backdrop-filter: blur(5px);
}

.feedback-card {
  text-align: center;
  background: white;
  padding: 40px;
  border-radius: 30px;
  box-shadow: var(--shadow-hover);
  animation: popIn 0.5s cubic-bezier(0.175, 0.885, 0.32, 1.275);
}

.feedback-emoji {
  font-size: 80px;
  margin-bottom: 20px;
  animation: bounce 1s infinite;
}

.feedback-text {
  font-size: 32px;
  font-weight: 900;
  margin-bottom: 10px;
  color: var(--text-main);
}

.feedback-detail {
  font-size: 20px;
  color: var(--text-light);
  margin-bottom: 30px;
}

.btn-next {
  background: var(--primary);
  color: white;
  font-size: 20px;
  font-weight: 800;
  padding: 15px 40px;
  box-shadow: 0 10px 20px rgba(74, 108, 247, 0.3);
}

.btn-next:hover {
  transform: scale(1.05);
}

/* Result Page */
.result-container {
  max-width: 600px;
  width: 100%;
  background: white;
  border-radius: 40px;
  padding: 50px 40px;
  box-shadow: var(--shadow);
  text-align: center;
}

.result-stars {
  font-size: 60px;
  color: #e2e8f0;
  margin-bottom: 20px;
  letter-spacing: 10px;
}

.result-stars.star-1 { background: linear-gradient(to right, var(--accent) 33%, #e2e8f0 33%); -webkit-background-clip: text; -webkit-text-fill-color: transparent; }
.result-stars.star-2 { background: linear-gradient(to right, var(--accent) 66%, #e2e8f0 66%); -webkit-background-clip: text; -webkit-text-fill-color: transparent; }
.result-stars.star-3 { color: var(--accent); text-shadow: 0 0 20px rgba(255, 184, 0, 0.5); }

.result-title {
  font-size: 40px;
  color: var(--primary);
  font-weight: 900;
  margin-bottom: 30px;
}

.result-mascot {
  height: 150px;
  margin-bottom: 30px;
  position: relative;
}

.result-stats {
  display: flex;
  justify-content: space-around;
  margin-bottom: 30px;
  background: #f8fafc;
  padding: 20px;
  border-radius: 20px;
}

.stat-value {
  font-size: 32px;
  font-weight: 900;
  color: var(--text-main);
}

.stat-label {
  font-size: 16px;
  color: var(--text-light);
  font-weight: 700;
}

.result-message {
  font-size: 24px;
  font-weight: 800;
  color: var(--text-main);
  margin-bottom: 30px;
}

.result-badge {
  background: linear-gradient(135deg, #f6d365 0%, #fda085 100%);
  padding: 20px;
  border-radius: 20px;
  margin-bottom: 30px;
  color: white;
  animation: pulse 2s infinite;
}

.badge-icon {
  font-size: 48px;
  margin-bottom: 10px;
}

.badge-name {
  font-size: 20px;
  font-weight: 800;
}

.result-buttons {
  display: flex;
  gap: 20px;
  justify-content: center;
}

.btn-replay {
  background: var(--primary);
  color: white;
  font-size: 20px;
  font-weight: 800;
  padding: 15px 30px;
}

.btn-home {
  background: #edf2f7;
  color: var(--text-main);
  font-size: 20px;
  font-weight: 800;
  padding: 15px 30px;
}

/* Animations */
@keyframes bounce {
  0%, 100% { transform: translateY(0); }
  50% { transform: translateY(-15px); }
}

@keyframes float {
  0%, 100% { transform: translateY(0); }
  50% { transform: translateY(-10px); }
}

@keyframes blink {
  0%, 48%, 52%, 100% { transform: scaleY(1); }
  50% { transform: scaleY(0.1); }
}

@keyframes popIn {
  0% { transform: scale(0.5); opacity: 0; }
  100% { transform: scale(1); opacity: 1; }
}

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

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

#particleCanvas {
  position: fixed;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  pointer-events: none;
  z-index: 9999;
}

/* Responsive */
@media (max-width: 600px) {
  .game-container {
    padding: 20px;
    border-radius: 20px;
  }
  
  .clock-svg {
    width: 250px;
    height: 250px;
  }
  
  .question-text {
    font-size: 24px;
  }
  
  .choice-btn {
    font-size: 20px;
    padding: 15px;
  }
}
