/* Modern, Child-Friendly, Fruit-Themed Styling for Fruit English Wonder */

:root {
  --primary: #ff5e62;
  --primary-hover: #ff4146;
  --secondary: #ff9966;
  --accent-green: #2ecc71;
  --accent-yellow: #f1c40f;
  --accent-purple: #9b59b6;
  --accent-blue: #3498db;
  --bg-main: #fffdf9;
  --card-bg: #ffffff;
  --text-dark: #2c3e50;
  --text-muted: #7f8c8d;
  --border-color: #f1ebd8;
  --radius-sm: 10px;
  --radius-md: 16px;
  --radius-lg: 24px;
  --shadow-card: 0 10px 25px rgba(0, 0, 0, 0.05);
  --shadow-hover: 0 16px 32px rgba(255, 94, 98, 0.18);
  --font-family: 'Fredoka', 'Noto Sans TC', sans-serif;
}

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

body {
  font-family: var(--font-family);
  background-color: var(--bg-main);
  color: var(--text-dark);
  line-height: 1.6;
  min-height: 100vh;
  display: flex;
  flex-direction: column;
}

/* Header */
.app-header {
  background: white;
  border-bottom: 2px solid var(--border-color);
  padding: 1rem 2rem;
  display: flex;
  justify-content: space-between;
  align-items: center;
  position: sticky;
  top: 0;
  z-index: 100;
  box-shadow: 0 4px 15px rgba(0,0,0,0.03);
}

.logo-area {
  display: flex;
  align-items: center;
  gap: 0.8rem;
}

.logo-emoji {
  font-size: 2.2rem;
  animation: bounce 2s infinite ease-in-out;
}

.logo-text h1 {
  font-size: 1.4rem;
  font-weight: 700;
  color: var(--primary);
  line-height: 1.1;
}

.logo-text .subtitle {
  font-size: 0.82rem;
  color: var(--text-muted);
}

.user-status-area {
  display: flex;
  align-items: center;
  gap: 1rem;
}

.student-badge {
  display: flex;
  align-items: center;
  gap: 0.8rem;
  background: #fff8f0;
  border: 2px solid #ffe3c9;
  padding: 0.4rem 1rem;
  border-radius: 50px;
}

.badge-info {
  display: flex;
  flex-direction: column;
}

.badge-title {
  font-weight: 700;
  font-size: 0.95rem;
  color: #d35400;
}

.badge-name {
  font-size: 0.8rem;
  color: var(--text-muted);
}

.points-pill {
  display: flex;
  align-items: center;
  gap: 0.3rem;
  background: #fff;
  border: 1.5px solid #f39c12;
  padding: 0.2rem 0.6rem;
  border-radius: 20px;
  font-weight: 700;
  color: #d35400;
  font-size: 0.9rem;
}

/* Buttons */
button {
  font-family: inherit;
  cursor: pointer;
  border: none;
  transition: all 0.2s ease;
}

.btn-primary {
  background: linear-gradient(135deg, var(--primary), var(--secondary));
  color: white;
  padding: 0.6rem 1.2rem;
  border-radius: 50px;
  font-weight: 600;
  font-size: 0.95rem;
  box-shadow: 0 4px 12px rgba(255, 94, 98, 0.3);
}

.btn-primary:hover {
  transform: translateY(-2px);
  box-shadow: 0 6px 16px rgba(255, 94, 98, 0.4);
}

.btn-action-primary {
  background: linear-gradient(135deg, #27ae60, #2ecc71);
  color: white;
  padding: 0.8rem 2rem;
  border-radius: 50px;
  font-size: 1.1rem;
  font-weight: 700;
  box-shadow: 0 6px 20px rgba(46, 204, 113, 0.35);
}

.btn-action-primary:hover {
  transform: translateY(-2px);
  box-shadow: 0 8px 24px rgba(46, 204, 113, 0.45);
}

.btn-secondary {
  background: #ecf0f1;
  color: var(--text-dark);
  padding: 0.5rem 1rem;
  border-radius: 50px;
  font-weight: 600;
  font-size: 0.88rem;
}

.btn-secondary:hover {
  background: #dfe6e9;
}

.btn-sm {
  padding: 0.3rem 0.7rem;
  border-radius: 20px;
  font-size: 0.8rem;
  background: #f1f2f6;
  color: #2f3542;
  font-weight: 600;
}

.btn-ghost {
  background: transparent;
  color: var(--text-muted);
}

.btn-ghost:hover {
  color: var(--primary);
}

/* Main Layout */
.main-content {
  flex: 1;
  max-width: 1140px;
  width: 100%;
  margin: 0 auto;
  padding: 1.5rem;
}

/* Hero Banner */
.hero-banner {
  background: linear-gradient(135deg, #fff3e6, #fffbf0);
  border: 2px dashed #fbd38d;
  border-radius: var(--radius-md);
  padding: 1.5rem 2rem;
  margin-bottom: 2rem;
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 1.5rem;
  flex-wrap: wrap;
}

.step-tags {
  display: flex;
  gap: 0.5rem;
  margin-bottom: 0.6rem;
  flex-wrap: wrap;
}

.badge-tag {
  background: white;
  border: 1px solid #ffd8a8;
  padding: 0.2rem 0.6rem;
  border-radius: 20px;
  font-size: 0.78rem;
  font-weight: 600;
  color: #d9480f;
}

.badge-tag.active {
  background: #ff922b;
  color: white;
  border-color: #ff922b;
}

.hero-banner h2 {
  font-size: 1.5rem;
  color: #c92a2a;
  margin-bottom: 0.4rem;
}

.hero-desc {
  font-size: 0.95rem;
  color: #495057;
  max-width: 700px;
}

.hero-d1-status {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  background: white;
  padding: 0.5rem 1rem;
  border-radius: 30px;
  font-size: 0.85rem;
  font-weight: 600;
  color: #2b8a3e;
  border: 1px solid #b2f2bb;
  box-shadow: 0 2px 8px rgba(0,0,0,0.04);
}

.status-dot {
  width: 10px;
  height: 10px;
  border-radius: 50%;
  background: #20c997;
}

.status-dot.online {
  box-shadow: 0 0 0 3px rgba(32, 201, 151, 0.3);
  animation: pulse 2s infinite;
}

/* Nav Tabs */
.nav-tabs {
  display: flex;
  gap: 0.8rem;
  margin-bottom: 2rem;
  overflow-x: auto;
  padding-bottom: 0.5rem;
}

.tab-btn {
  background: white;
  border: 2px solid var(--border-color);
  padding: 0.8rem 1.4rem;
  border-radius: var(--radius-md);
  font-weight: 700;
  font-size: 1rem;
  color: var(--text-dark);
  white-space: nowrap;
}

.tab-btn:hover {
  border-color: var(--primary);
  color: var(--primary);
}

.tab-btn.active {
  background: var(--primary);
  border-color: var(--primary);
  color: white;
  box-shadow: 0 6px 18px rgba(255, 94, 98, 0.3);
}

/* Content Sections */
.content-section {
  display: none;
}

.content-section.active {
  display: block;
  animation: fadeIn 0.3s ease-in;
}

.section-intro {
  margin-bottom: 1.5rem;
}

.section-title-wrap {
  display: flex;
  align-items: center;
  gap: 0.8rem;
  margin-bottom: 0.4rem;
}

.sec-badge {
  background: #e3fafc;
  color: #1098ad;
  border: 1px solid #99e9f2;
  font-size: 0.75rem;
  padding: 0.2rem 0.6rem;
  border-radius: 12px;
  font-weight: 700;
}

.section-intro h3 {
  font-size: 1.4rem;
  color: var(--text-dark);
}

.section-intro p {
  color: var(--text-muted);
  font-size: 0.95rem;
}

/* Unit 1: Flashcards Grid */
.voice-toolbar {
  display: flex;
  justify-content: space-between;
  align-items: center;
  background: white;
  padding: 0.8rem 1.4rem;
  border-radius: var(--radius-sm);
  border: 1px solid var(--border-color);
  margin-bottom: 1.5rem;
  flex-wrap: wrap;
  gap: 1rem;
}

.voice-speed-wrap {
  display: flex;
  align-items: center;
  gap: 0.8rem;
  font-size: 0.9rem;
  font-weight: 600;
}

.cards-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(200px, 1fr));
  gap: 1.2rem;
}

.fruit-card {
  background: white;
  border: 2px solid var(--border-color);
  border-radius: var(--radius-md);
  padding: 1.2rem;
  text-align: center;
  transition: all 0.3s cubic-bezier(0.25, 0.8, 0.25, 1);
  box-shadow: var(--shadow-card);
  position: relative;
  cursor: pointer;
}

.fruit-card:hover {
  transform: translateY(-5px);
  border-color: #ff9966;
  box-shadow: var(--shadow-hover);
}

.fruit-card .card-emoji {
  font-size: 3.5rem;
  display: block;
  margin-bottom: 0.5rem;
  transition: transform 0.2s;
}

.fruit-card:hover .card-emoji {
  transform: scale(1.15) rotate(5deg);
}

.fruit-card .card-en {
  font-size: 1.3rem;
  font-weight: 700;
  color: #d63031;
  margin-bottom: 0.2rem;
}

.fruit-card .card-phonics {
  font-size: 0.85rem;
  color: #7f8c8d;
  font-family: monospace;
  margin-bottom: 0.5rem;
}

.fruit-card .card-zh {
  font-size: 1rem;
  font-weight: 600;
  color: #2d3436;
  margin-bottom: 0.8rem;
}

.fruit-card .card-sentence {
  font-size: 0.8rem;
  color: #636e72;
  background: #f8f9fa;
  padding: 0.4rem;
  border-radius: 8px;
  margin-bottom: 0.8rem;
  font-style: italic;
}

.card-actions {
  display: flex;
  justify-content: center;
  gap: 0.5rem;
}

.btn-audio {
  background: #ffeaa7;
  color: #d35400;
  border: 1px solid #fdcb6e;
  padding: 0.35rem 0.8rem;
  border-radius: 20px;
  font-size: 0.85rem;
  font-weight: 700;
  display: inline-flex;
  align-items: center;
  gap: 0.3rem;
}

.btn-audio:hover {
  background: #fdcb6e;
  transform: scale(1.05);
}

/* Unit 2: Drag & Drop Sorting */
.game-dashboard {
  display: flex;
  align-items: center;
  justify-content: space-between;
  background: white;
  padding: 1rem 1.5rem;
  border-radius: var(--radius-md);
  border: 1px solid var(--border-color);
  margin-bottom: 1.5rem;
  flex-wrap: wrap;
  gap: 1rem;
}

.game-stat {
  font-size: 1rem;
  color: var(--text-dark);
}

.text-success {
  color: #27ae60;
  font-weight: 700;
}

.drag-pool-container {
  background: #fff9db;
  border: 2px dashed #fcc419;
  border-radius: var(--radius-md);
  padding: 1.2rem;
  margin-bottom: 2rem;
  text-align: center;
}

.drag-pool-container h4 {
  color: #e67700;
  margin-bottom: 1rem;
}

.drag-items-pool {
  display: flex;
  justify-content: center;
  align-items: center;
  gap: 1.5rem;
  flex-wrap: wrap;
  min-height: 80px;
}

.drag-fruit-item {
  font-size: 3rem;
  background: white;
  border: 2px solid #ffd43b;
  border-radius: 50%;
  width: 75px;
  height: 75px;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: grab;
  user-select: none;
  box-shadow: 0 4px 10px rgba(0,0,0,0.08);
  transition: transform 0.2s, box-shadow 0.2s;
}

.drag-fruit-item:hover {
  transform: scale(1.15);
  box-shadow: 0 8px 20px rgba(0,0,0,0.15);
}

.drag-fruit-item.dragging {
  opacity: 0.4;
  cursor: grabbing;
}

.baskets-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(180px, 1fr));
  gap: 1.2rem;
}

.fruit-basket {
  background: white;
  border: 3px dashed #ced4da;
  border-radius: var(--radius-md);
  padding: 1.5rem 1rem;
  text-align: center;
  min-height: 160px;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  transition: all 0.2s;
  position: relative;
}

.fruit-basket.drag-over {
  background: #e7f5ff;
  border-color: #339af0;
  transform: scale(1.03);
}

.fruit-basket.matched {
  background: #ebfbee;
  border-color: #51cf66;
  border-style: solid;
}

.basket-icon {
  font-size: 2.8rem;
  margin-bottom: 0.5rem;
}

.basket-label {
  font-size: 1.1rem;
  font-weight: 700;
  color: #495057;
}

.fruit-basket.matched .basket-label {
  color: #2b8a3e;
}

.congrats-banner {
  background: #d3f9d8;
  color: #2b8a3e;
  border: 2px solid #69db7c;
  padding: 1rem 2rem;
  border-radius: var(--radius-md);
  font-size: 1.1rem;
  font-weight: 700;
  text-align: center;
  margin-top: 1.5rem;
  animation: bounce 0.6s ease;
}

/* Unit 3: Sliders */
.slider-card {
  background: white;
  border: 2px solid var(--border-color);
  border-radius: var(--radius-md);
  padding: 1.5rem 2rem;
  margin-bottom: 1.8rem;
  box-shadow: var(--shadow-card);
}

.slider-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 1.2rem;
  flex-wrap: wrap;
  gap: 0.8rem;
}

.slider-info h4 {
  font-size: 1.2rem;
  color: #2d3436;
}

.slider-info p {
  font-size: 0.88rem;
  color: var(--text-muted);
}

.slider-val-pill {
  background: #fff3bf;
  border: 1.5px solid #ffd43b;
  color: #d9480f;
  padding: 0.4rem 1rem;
  border-radius: 30px;
  font-size: 1rem;
  font-weight: 700;
}

.slider-control-wrap {
  display: flex;
  align-items: center;
  gap: 1rem;
  margin-bottom: 1.5rem;
}

.slider-edge-label {
  font-size: 0.88rem;
  font-weight: 700;
  color: var(--text-muted);
  white-space: nowrap;
}

.fruit-slider {
  flex: 1;
  height: 12px;
  border-radius: 10px;
  background: #e9ecef;
  outline: none;
  accent-color: #ff5e62;
  cursor: pointer;
}

.slider-visual-box {
  background: #fdfbf7;
  border: 2px solid #f8f1e5;
  border-radius: var(--radius-sm);
  padding: 1.5rem;
  display: flex;
  align-items: center;
  gap: 2rem;
  flex-wrap: wrap;
}

.visual-avatar {
  font-size: 5rem;
  line-height: 1;
  transition: transform 0.3s;
}

.visual-details {
  flex: 1;
}

.visual-details h3 {
  font-size: 1.4rem;
  color: #c92a2a;
  margin-bottom: 0.3rem;
}

.en-sentence {
  font-size: 1.1rem;
  font-weight: 600;
  color: #2b8a3e;
  margin-bottom: 0.2rem;
}

.zh-sentence {
  font-size: 0.9rem;
  color: var(--text-muted);
  margin-bottom: 0.8rem;
}

.sweetness-meter {
  height: 10px;
  background: #dee2e6;
  border-radius: 10px;
  overflow: hidden;
}

.meter-bar {
  height: 100%;
  background: linear-gradient(90deg, #ffd43b, #ff6b6b);
  border-radius: 10px;
  transition: width 0.3s ease;
}

.fruit-display-grid {
  display: flex;
  gap: 0.5rem;
  font-size: 3rem;
  flex-wrap: wrap;
}

.quantity-grammar-info .grammar-title {
  font-size: 1.2rem;
  font-weight: 700;
  color: #1971c2;
}

.quantity-grammar-info .grammar-sub {
  font-size: 0.9rem;
  color: var(--text-muted);
}

/* Unit 4: Quiz */
.quiz-container {
  background: white;
  border: 2px solid var(--border-color);
  border-radius: var(--radius-lg);
  padding: 2.5rem;
  box-shadow: var(--shadow-card);
  max-width: 700px;
  margin: 0 auto;
}

.text-center {
  text-align: center;
}

.quiz-welcome-emoji {
  font-size: 4rem;
  margin-bottom: 1rem;
}

.quiz-progress-bar-wrap {
  margin-bottom: 1.5rem;
}

.progress-info {
  display: flex;
  justify-content: space-between;
  margin-bottom: 0.5rem;
  font-weight: 700;
  font-size: 0.95rem;
}

.progress-track {
  height: 12px;
  background: #f1f3f5;
  border-radius: 10px;
  overflow: hidden;
}

.progress-fill {
  height: 100%;
  background: linear-gradient(90deg, #40c057, #20c997);
  border-radius: 10px;
  transition: width 0.3s;
}

.quiz-card {
  text-align: center;
}

.quiz-q-type {
  display: inline-block;
  background: #e7f5ff;
  color: #1971c2;
  font-weight: 700;
  font-size: 0.85rem;
  padding: 0.3rem 0.8rem;
  border-radius: 20px;
  margin-bottom: 1rem;
}

.quiz-prompt {
  font-size: 1.4rem;
  font-weight: 700;
  margin-bottom: 1.8rem;
  min-height: 80px;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 0.5rem;
}

.quiz-prompt .prompt-emoji {
  font-size: 4rem;
}

.quiz-options-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 1rem;
}

.quiz-opt-btn {
  background: #f8f9fa;
  border: 2px solid #e9ecef;
  border-radius: var(--radius-md);
  padding: 1rem;
  font-size: 1.1rem;
  font-weight: 600;
  color: var(--text-dark);
  text-align: center;
  transition: all 0.2s;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 0.5rem;
}

.quiz-opt-btn:hover {
  background: #fff3e6;
  border-color: #ffa94d;
  transform: translateY(-2px);
}

.quiz-opt-btn.correct {
  background: #d3f9d8 !important;
  border-color: #40c057 !important;
  color: #2b8a3e !important;
}

.quiz-opt-btn.wrong {
  background: #ffe3e3 !important;
  border-color: #fa5252 !important;
  color: #c92a2a !important;
}

.big-score {
  font-size: 4.5rem;
  font-weight: 800;
  color: #ff5e62;
}

.score-total {
  font-size: 1.5rem;
  color: var(--text-muted);
}

.result-badge-emoji {
  font-size: 5rem;
  margin-bottom: 0.5rem;
}

.result-feedback {
  font-size: 1.2rem;
  margin: 1rem 0;
  font-weight: 600;
}

.d1-sync-notice {
  background: #e8f7ff;
  border: 1.5px solid #a5d8ff;
  color: #1971c2;
  padding: 0.6rem 1rem;
  border-radius: 30px;
  display: inline-flex;
  align-items: center;
  gap: 0.5rem;
  font-size: 0.88rem;
  font-weight: 600;
  margin-bottom: 1.5rem;
}

.result-actions {
  display: flex;
  justify-content: center;
  gap: 1rem;
}

/* Modals */
.modal-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.5);
  backdrop-filter: blur(4px);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 200;
  padding: 1.5rem;
}

.modal-overlay.hidden {
  display: none !important;
}

.modal-card {
  background: white;
  border-radius: var(--radius-lg);
  padding: 2rem;
  max-width: 460px;
  width: 100%;
  box-shadow: 0 20px 40px rgba(0, 0, 0, 0.2);
  animation: slideUp 0.3s ease;
  position: relative;
}

.modal-wide {
  max-width: 800px;
  max-height: 85vh;
  overflow-y: auto;
}

.modal-header {
  text-align: center;
  margin-bottom: 1.5rem;
}

.modal-icon {
  font-size: 3rem;
  display: block;
  margin-bottom: 0.3rem;
}

.modal-header h2 {
  font-size: 1.4rem;
  color: var(--text-dark);
}

.modal-header p {
  font-size: 0.88rem;
  color: var(--text-muted);
  margin-top: 0.3rem;
}

.btn-close {
  position: absolute;
  top: 1rem;
  right: 1.2rem;
  font-size: 1.8rem;
  background: transparent;
  color: #868e96;
}

.btn-close:hover {
  color: var(--text-dark);
}

.form-group {
  margin-bottom: 1.2rem;
}

.form-group label {
  display: block;
  font-weight: 700;
  font-size: 0.9rem;
  margin-bottom: 0.4rem;
  color: #34495e;
}

.req {
  color: #e74c3c;
}

.form-group input {
  width: 100%;
  padding: 0.75rem 1rem;
  border: 2px solid #dfe6e9;
  border-radius: var(--radius-sm);
  font-size: 1rem;
  font-family: inherit;
  outline: none;
  transition: border-color 0.2s;
}

.form-group input:focus {
  border-color: var(--primary);
  box-shadow: 0 0 0 3px rgba(255, 94, 98, 0.15);
}

.modal-actions {
  margin-top: 1.5rem;
  display: flex;
  justify-content: center;
}

.modal-actions button {
  width: 100%;
}

/* Profile Modal Cards */
.profile-overview-cards {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 1rem;
  margin-bottom: 1.5rem;
}

.stat-box {
  background: #f8f9fa;
  border: 1px solid #e9ecef;
  border-radius: var(--radius-md);
  padding: 1rem;
  text-align: center;
}

.stat-num {
  font-size: 2rem;
  font-weight: 800;
  color: var(--primary);
  display: block;
}

.stat-label {
  font-size: 0.8rem;
  color: var(--text-muted);
  font-weight: 600;
}

.data-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.88rem;
  margin-top: 0.5rem;
  margin-bottom: 1.5rem;
}

.data-table th, .data-table td {
  padding: 0.6rem 0.8rem;
  border-bottom: 1px solid #dee2e6;
  text-align: left;
}

.data-table th {
  background: #f8f9fa;
  font-weight: 700;
  color: #495057;
}

/* Footer */
.app-footer {
  text-align: center;
  padding: 2rem;
  background: white;
  border-top: 2px solid var(--border-color);
  font-size: 0.9rem;
  color: var(--text-muted);
  margin-top: 3rem;
}

.app-footer .small-text {
  font-size: 0.78rem;
  margin-top: 0.2rem;
}

/* Animations */
@keyframes fadeIn {
  from { opacity: 0; transform: translateY(6px); }
  to { opacity: 1; transform: translateY(0); }
}

@keyframes slideUp {
  from { opacity: 0; transform: scale(0.95); }
  to { opacity: 1; transform: scale(1); }
}

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

@keyframes pulse {
  0% { box-shadow: 0 0 0 0 rgba(32, 201, 151, 0.5); }
  70% { box-shadow: 0 0 0 7px rgba(32, 201, 151, 0); }
  100% { box-shadow: 0 0 0 0 rgba(32, 201, 151, 0); }
}

.hidden {
  display: none !important;
}

/* Responsive */
@media (max-width: 768px) {
  .app-header {
    padding: 0.8rem 1rem;
    flex-direction: column;
    gap: 0.8rem;
    align-items: flex-start;
  }
  .user-status-area {
    width: 100%;
    justify-content: space-between;
  }
  .quiz-options-grid {
    grid-template-columns: 1fr;
  }
  .profile-overview-cards {
    grid-template-columns: 1fr;
  }
}
