/* ============================================
   Buddy English - Kids Interaction App
   ============================================ */

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

:root {
  --primary: #FF6B35;
  --primary-light: #FF8C5A;
  --secondary: #4ECDC4;
  --secondary-dark: #3DB8B0;
  --accent-yellow: #FFE66D;
  --accent-purple: #A06CD5;
  --accent-green: #2ECC71;
  --accent-red: #E74C3C;
  --bg-gradient-start: #FFF8E7;
  --bg-gradient-end: #E8F8F5;
  --text-dark: #2C3E50;
  --text-light: #7F8C8D;
  --white: #FFFFFF;
  --shadow: 0 4px 15px rgba(0, 0, 0, 0.1);
  --shadow-lg: 0 8px 30px rgba(0, 0, 0, 0.15);
  --radius: 20px;
  --radius-sm: 12px;
}

html, body {
  height: 100%;
  overflow: hidden;
  font-family: 'Segoe UI', 'PingFang SC', 'Microsoft YaHei', sans-serif;
  background: linear-gradient(135deg, var(--bg-gradient-start) 0%, var(--bg-gradient-end) 100%);
  color: var(--text-dark);
  -webkit-tap-highlight-color: transparent;
  user-select: none;
  -webkit-user-select: none;
}

.app-container {
  display: flex;
  flex-direction: column;
  height: 100vh;
  height: 100dvh;
  max-width: 480px;
  margin: 0 auto;
  position: relative;
  overflow: hidden;
}

/* --- Header --- */
.header {
  display: flex;
  justify-content: center;
  align-items: center;
  padding: 12px 16px;
  background: var(--white);
  box-shadow: var(--shadow);
  z-index: 100;
  flex-shrink: 0;
}

.header-title {
  display: flex;
  align-items: center;
  gap: 8px;
}

.title-emoji { font-size: 24px; }

.header-title h1 {
  font-size: 20px;
  font-weight: 700;
  color: var(--primary);
}

/* --- Character Area --- */
.character-area {
  flex: 0 0 auto;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  position: relative;
  padding: 10px 16px;
}

.character-container {
  position: relative;
  width: 120px;
  height: 120px;
  border-radius: 50%;
  overflow: hidden;
  box-shadow: var(--shadow-lg);
  border: 4px solid var(--accent-yellow);
  flex-shrink: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  background: #FFF8E7;
}

.character-image {
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: block;
  border-radius: 50%;
}

.fallback-avatar {
  width: 100%;
  height: 100%;
  display: flex;
  align-items: center;
  justify-content: center;
}

.fallback-avatar svg { width: 100%; height: 100%; }

/* --- Story Content --- */
.story-content {
  flex: 1;
  min-height: 0;
  overflow-y: auto;
  padding: 0 16px 8px;
}

.story-para {
  background: var(--white);
  padding: 14px 16px;
  border-radius: var(--radius-sm);
  margin-bottom: 8px;
  box-shadow: var(--shadow);
  font-size: 15px;
  line-height: 1.6;
  color: var(--text-dark);
  animation: slideUp 0.3s ease;
}

@keyframes slideUp {
  from { opacity: 0; transform: translateY(10px); }
  to { opacity: 1; transform: translateY(0); }
}

/* --- Learn Content --- */
.learn-content {
  flex: 1;
  min-height: 0;
  overflow-y: auto;
  padding: 0 16px 8px;
}

.learn-card {
  display: flex;
  align-items: center;
  gap: 14px;
  background: var(--white);
  padding: 12px 16px;
  border-radius: var(--radius-sm);
  margin-bottom: 8px;
  box-shadow: var(--shadow);
  animation: slideUp 0.3s ease;
}

.learn-card .card-emoji {
  font-size: 36px;
  flex-shrink: 0;
}

.learn-card .card-info {
  flex: 1;
  min-width: 0;
}

.learn-card .card-word {
  font-size: 18px;
  font-weight: 700;
  color: var(--primary);
}

.learn-card .card-meaning {
  font-size: 13px;
  color: var(--text-light);
  margin-top: 2px;
}

/* --- Game Area --- */
.game-area {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  padding: 12px 16px;
  min-height: 0;
  overflow-y: auto;
}

.game-header {
  display: flex;
  justify-content: space-between;
  width: 100%;
  padding: 8px 16px;
  background: var(--white);
  border-radius: var(--radius-sm);
  margin-bottom: 12px;
  box-shadow: var(--shadow);
  font-size: 14px;
  font-weight: 600;
}

.game-question {
  font-size: 22px;
  font-weight: 700;
  text-align: center;
  padding: 20px;
  background: var(--white);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  margin-bottom: 16px;
  width: 100%;
  color: var(--text-dark);
  line-height: 1.4;
}

.game-options {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 10px;
  width: 100%;
  margin-bottom: 12px;
}

.game-option {
  padding: 14px 10px;
  border: 2px solid #E8E8E8;
  border-radius: var(--radius-sm);
  background: var(--white);
  font-size: 16px;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.2s ease;
  text-align: center;
  color: var(--text-dark);
}

.game-option:hover {
  border-color: var(--primary);
  background: rgba(255, 107, 53, 0.05);
  transform: translateY(-2px);
}

.game-option:active { transform: scale(0.95); }

.game-option.correct {
  border-color: var(--accent-green);
  background: rgba(46, 204, 113, 0.15);
  color: var(--accent-green);
}

.game-option.wrong {
  border-color: var(--accent-red);
  background: rgba(231, 76, 60, 0.15);
  color: var(--accent-red);
}

.game-feedback {
  text-align: center;
  font-size: 18px;
  font-weight: 700;
  padding: 12px;
  border-radius: var(--radius-sm);
  width: 100%;
  min-height: 50px;
}

.game-feedback.correct {
  color: var(--accent-green);
  background: rgba(46, 204, 113, 0.1);
}

.game-feedback.wrong {
  color: var(--accent-red);
  background: rgba(231, 76, 60, 0.1);
}

.game-feedback.next-btn {
  background: var(--primary);
  color: var(--white);
  margin-top: 8px;
  cursor: pointer;
}

/* --- Controls Area --- */
.controls-area {
  background: var(--white);
  border-top: 1px solid rgba(0,0,0,0.05);
  padding: 8px 12px 12px;
  flex-shrink: 0;
}

/* Mode Tabs */
.mode-tabs {
  display: flex;
  gap: 6px;
  margin-bottom: 8px;
}

.mode-btn {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 2px;
  padding: 8px 6px;
  border: 2px solid transparent;
  border-radius: var(--radius-sm);
  background: #F8F9FA;
  color: var(--text-dark);
  font-size: 11px;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.2s ease;
}

.mode-btn:hover, .mode-btn.active {
  border-color: var(--primary);
  background: rgba(255, 107, 53, 0.08);
  transform: translateY(-1px);
}

.mode-btn.active {
  box-shadow: 0 2px 8px rgba(255, 107, 53, 0.2);
}

.mode-icon { font-size: 18px; }

/* Story Navigation */
.story-nav {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 6px;
  margin-bottom: 6px;
}

.nav-btn {
  padding: 6px 10px;
  border: 1px solid #E8E8E8;
  border-radius: 8px;
  background: #F8F9FA;
  font-size: 12px;
  cursor: pointer;
  transition: all 0.2s;
  flex-shrink: 0;
}

.nav-btn:hover { background: #E8E8E8; }

.story-title {
  font-size: 13px;
  font-weight: 600;
  color: var(--primary);
  text-align: center;
  flex: 1;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

/* Learn Categories */
.learn-categories {
  display: flex;
  gap: 6px;
  margin-bottom: 6px;
  flex-wrap: wrap;
}

.cat-btn {
  flex: 1;
  min-width: 70px;
  padding: 6px 8px;
  border: 1px solid #E8E8E8;
  border-radius: 8px;
  background: #F8F9FA;
  font-size: 12px;
  cursor: pointer;
  transition: all 0.2s;
  text-align: center;
}

.cat-btn:hover { background: var(--accent-yellow); }

/* --- Responsive --- */
@media (max-height: 600px) {
  .character-container { width: 100px; height: 100px; }
}

@media (min-width: 481px) {
  .app-container {
    border-left: 1px solid rgba(0,0,0,0.05);
    border-right: 1px solid rgba(0,0,0,0.05);
  }
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after {
    animation-duration: 0.01ms !important;
    transition-duration: 0.01ms !important;
  }
}
