/* ===== VocabQuest - Soft Social-Game Style ===== */
:root {
  --bg: #fdf4ff;
  --bg-card: #ffffff;
  --primary: #a78bfa;
  --primary-dark: #8b5cf6;
  --accent: #f472b6;
  --success: #34d399;
  --danger: #f87171;
  --text: #4c1d95;
  --text-soft: #7c3aed;
  --border: #e9d5ff;
  --shadow: 0 8px 24px rgba(167, 139, 250, 0.18);
  --radius: 20px;
  --radius-sm: 12px;
  --font: "Hiragino Sans", "Hiragino Kaku Gothic ProN", "Noto Sans JP", sans-serif;
}

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

body {
  font-family: var(--font);
  background: linear-gradient(160deg, #fdf4ff 0%, #fce7f3 40%, #ede9fe 100%);
  color: var(--text);
  min-height: 100vh;
  line-height: 1.5;
}

#app {
  max-width: 480px;
  margin: 0 auto;
  padding: 16px;
  min-height: 100vh;
}

/* ===== Header / Logo ===== */
.app-header {
  text-align: center;
  margin-bottom: 12px;
}
.logo {
  font-size: 1.8rem;
  font-weight: 800;
  background: linear-gradient(90deg, #a78bfa, #f472b6);
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  background-clip: text;
}
.tagline {
  font-size: 0.85rem;
  color: var(--text-soft);
  opacity: 0.8;
}

/* ===== Character ===== */
.character-area {
  display: flex;
  justify-content: center;
  margin: 16px 0;
}
.character-placeholder {
  background: var(--bg-card);
  border: 3px dashed var(--border);
  border-radius: 50%;
  width: 120px;
  height: 120px;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  position: relative;
  box-shadow: var(--shadow);
}
.char-emoji {
  font-size: 3rem;
}
.char-bubble {
  position: absolute;
  bottom: -28px;
  background: var(--bg-card);
  padding: 4px 12px;
  border-radius: 12px;
  font-size: 0.75rem;
  box-shadow: 0 2px 8px rgba(0,0,0,0.08);
  white-space: nowrap;
  color: var(--text-soft);
}

/* ===== Streak ===== */
.streak-box {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  background: linear-gradient(90deg, #fef3c7, #fde68a);
  border-radius: 999px;
  padding: 8px 20px;
  margin: 24px auto 16px;
  width: fit-content;
  box-shadow: 0 4px 12px rgba(251, 191, 36, 0.25);
}
.streak-box.large {
  padding: 12px 28px;
  margin-bottom: 24px;
}
.streak-icon { font-size: 1.3rem; }
.streak-num {
  font-size: 1.5rem;
  font-weight: 800;
  color: #b45309;
}
.streak-label {
  font-size: 0.85rem;
  color: #92400e;
}

/* ===== Level buttons ===== */
.level-section h2,
.today-stats h2 {
  font-size: 1rem;
  margin-bottom: 10px;
  color: var(--text-soft);
}
.level-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 10px;
  margin-bottom: 20px;
}
.level-btn {
  background: var(--bg-card);
  border: 2px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 14px 10px;
  cursor: pointer;
  transition: all 0.2s;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 4px;
  color: var(--text);
  font-family: inherit;
}
.level-btn:hover {
  transform: translateY(-2px);
  box-shadow: var(--shadow);
}
.level-btn.active {
  border-color: var(--level-color, var(--primary));
  background: linear-gradient(135deg, #fff, color-mix(in srgb, var(--level-color, var(--primary)) 15%, white));
  box-shadow: 0 0 0 3px color-mix(in srgb, var(--level-color, var(--primary)) 30%, transparent);
}
.level-name { font-weight: 700; font-size: 0.95rem; }
.level-pct { font-size: 0.8rem; opacity: 0.7; }

/* ===== Stats ===== */
.stat-cards {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 8px;
  margin-bottom: 24px;
}
.stat-card {
  background: var(--bg-card);
  border-radius: var(--radius-sm);
  padding: 12px 8px;
  text-align: center;
  box-shadow: var(--shadow);
}
.stat-num {
  display: block;
  font-size: 1.4rem;
  font-weight: 800;
}
.stat-label {
  font-size: 0.7rem;
  color: var(--text-soft);
}
.stat-card.due .stat-num { color: #f59e0b; }
.stat-card.new .stat-num { color: #8b5cf6; }
.stat-card.learned .stat-num { color: #10b981; }

/* ===== Buttons ===== */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  padding: 12px 20px;
  border: none;
  border-radius: 999px;
  font-family: inherit;
  font-size: 0.95rem;
  font-weight: 700;
  cursor: pointer;
  transition: all 0.2s;
}
.btn-primary {
  background: linear-gradient(135deg, #a78bfa, #f472b6);
  color: white;
  box-shadow: 0 6px 16px rgba(167, 139, 250, 0.4);
}
.btn-primary:hover {
  transform: translateY(-2px);
  box-shadow: 0 8px 20px rgba(167, 139, 250, 0.5);
}
.btn-lg {
  width: 100%;
  padding: 16px;
  font-size: 1.1rem;
  margin-bottom: 12px;
}
.btn-secondary {
  background: var(--bg-card);
  color: var(--text-soft);
  border: 2px solid var(--border);
  padding: 10px 14px;
  font-size: 0.85rem;
}
.btn-secondary:hover {
  background: #f5f3ff;
}
.btn-danger {
  background: #fee2e2;
  color: #dc2626;
  margin-top: 16px;
  width: 100%;
}
.btn-back {
  background: none;
  border: none;
  font-size: 1.4rem;
  cursor: pointer;
  color: var(--text-soft);
  padding: 4px 8px;
}
.main-actions {
  margin-top: 8px;
}
.sub-actions {
  display: flex;
  gap: 8px;
  justify-content: center;
  flex-wrap: wrap;
}

/* ===== Quiz Screen ===== */
.quiz-header {
  display: flex;
  align-items: center;
  gap: 12px;
  margin-bottom: 20px;
}
.quiz-type-badge {
  background: linear-gradient(90deg, #a78bfa, #c4b5fd);
  color: white;
  padding: 4px 12px;
  border-radius: 999px;
  font-size: 0.8rem;
  font-weight: 700;
}
.session-count {
  margin-left: auto;
  font-size: 0.9rem;
  color: var(--text-soft);
  background: var(--bg-card);
  padding: 4px 10px;
  border-radius: 999px;
}

.question-area {
  background: var(--bg-card);
  border-radius: var(--radius);
  padding: 28px 20px;
  text-align: center;
  box-shadow: var(--shadow);
  margin-bottom: 20px;
  min-height: 120px;
  display: flex;
  align-items: center;
  justify-content: center;
}
.word-main {
  font-size: 2rem;
  font-weight: 800;
  color: var(--text);
}
.ipa {
  font-size: 0.95rem;
  color: var(--text-soft);
  opacity: 0.8;
}
.meaning-main {
  font-size: 1.6rem;
  font-weight: 700;
}
.example-cloze {
  font-size: 1.15rem;
  line-height: 1.6;
}
.hint {
  font-size: 0.85rem;
  color: var(--text-soft);
  margin-top: 8px;
  display: block;
}

.choices-area {
  display: flex;
  flex-direction: column;
  gap: 10px;
  margin-bottom: 16px;
}
.choice-btn {
  display: flex;
  align-items: center;
  gap: 12px;
  background: var(--bg-card);
  border: 2px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 14px 16px;
  cursor: pointer;
  font-family: inherit;
  font-size: 1rem;
  color: var(--text);
  text-align: left;
  transition: all 0.15s;
}
.choice-btn:hover:not(:disabled) {
  border-color: var(--primary);
  background: #f5f3ff;
}
.choice-btn:disabled {
  cursor: default;
}
.choice-btn.correct {
  border-color: var(--success);
  background: #ecfdf5;
}
.choice-btn.wrong {
  border-color: var(--danger);
  background: #fef2f2;
}
.choice-letter {
  width: 28px;
  height: 28px;
  border-radius: 50%;
  background: #ede9fe;
  display: flex;
  align-items: center;
  justify-content: center;
  font-weight: 700;
  font-size: 0.85rem;
  color: var(--primary-dark);
  flex-shrink: 0;
}
.choice-btn.correct .choice-letter {
  background: var(--success);
  color: white;
}
.choice-btn.wrong .choice-letter {
  background: var(--danger);
  color: white;
}

.word-image-placeholder {
  border: 2px dashed var(--border);
  border-radius: var(--radius-sm);
  padding: 20px;
  text-align: center;
  color: var(--text-soft);
  opacity: 0.6;
  font-size: 0.85rem;
  margin-top: 8px;
}

/* ===== Result panel ===== */
.result-panel {
  margin-top: 20px;
  animation: fadeIn 0.3s ease;
}
@keyframes fadeIn {
  from { opacity: 0; transform: translateY(8px); }
  to { opacity: 1; transform: translateY(0); }
}
.feedback {
  text-align: center;
  font-size: 1.2rem;
  font-weight: 700;
  margin-bottom: 12px;
}
.correct-feedback { color: #059669; }
.wrong-feedback { color: #dc2626; }

.answer-detail {
  background: var(--bg-card);
  border-radius: var(--radius);
  padding: 16px;
  margin-bottom: 16px;
  box-shadow: var(--shadow);
}
.detail-word {
  font-size: 1.4rem;
  font-weight: 800;
  margin-bottom: 4px;
}
.detail-meaning {
  font-size: 1.05rem;
  color: var(--text-soft);
  margin-bottom: 10px;
}
.detail-example {
  background: #f5f3ff;
  border-radius: 10px;
  padding: 10px 12px;
  margin-bottom: 10px;
  font-size: 0.9rem;
}
.example-ja {
  color: var(--text-soft);
  font-size: 0.85rem;
  margin-top: 4px;
}
.detail-etymology {
  font-size: 0.8rem;
  color: #6b7280;
  border-top: 1px solid var(--border);
  padding-top: 8px;
}
.ety-label {
  display: inline-block;
  background: #ede9fe;
  color: var(--primary-dark);
  padding: 2px 8px;
  border-radius: 6px;
  font-size: 0.7rem;
  font-weight: 700;
  margin-right: 6px;
}

/* ===== Rating ===== */
.rating-area {
  text-align: center;
}
.rating-prompt {
  font-size: 0.9rem;
  margin-bottom: 10px;
  color: var(--text-soft);
}
.rating-buttons {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 8px;
}
.rate-btn {
  border: none;
  border-radius: var(--radius-sm);
  padding: 12px 4px;
  font-family: inherit;
  font-size: 0.8rem;
  font-weight: 700;
  cursor: pointer;
  color: white;
  transition: transform 0.15s;
}
.rate-btn:hover { transform: scale(1.05); }
.rate-btn.again { background: #f87171; }
.rate-btn.hard { background: #fb923c; }
.rate-btn.good { background: #34d399; }
.rate-btn.easy { background: #60a5fa; }

/* ===== Word List ===== */
.word-list {
  display: flex;
  flex-direction: column;
  gap: 8px;
}
.word-item {
  background: var(--bg-card);
  border-radius: var(--radius-sm);
  padding: 12px 14px;
  box-shadow: 0 2px 8px rgba(167, 139, 250, 0.1);
}
.word-main-row {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-bottom: 2px;
}
.word-en {
  font-weight: 700;
  font-size: 1.05rem;
}
.word-ipa {
  font-size: 0.8rem;
  color: var(--text-soft);
  opacity: 0.8;
}
.word-ja {
  font-size: 0.9rem;
  color: var(--text-soft);
}
.badge {
  margin-left: auto;
  font-size: 0.65rem;
  font-weight: 700;
  padding: 2px 8px;
  border-radius: 999px;
}
.badge.new { background: #ede9fe; color: #7c3aed; }
.badge.due { background: #fef3c7; color: #b45309; }
.badge.learned { background: #d1fae5; color: #047857; }

/* ===== Progress ===== */
.progress-levels {
  display: flex;
  flex-direction: column;
  gap: 16px;
  margin-bottom: 24px;
}
.progress-level {
  background: var(--bg-card);
  border-radius: var(--radius-sm);
  padding: 14px;
  box-shadow: var(--shadow);
}
.progress-header {
  display: flex;
  justify-content: space-between;
  font-weight: 700;
  margin-bottom: 8px;
}
.progress-bar {
  height: 10px;
  background: #ede9fe;
  border-radius: 999px;
  overflow: hidden;
  margin-bottom: 6px;
}
.progress-fill {
  height: 100%;
  border-radius: 999px;
  transition: width 0.4s ease;
}
.progress-detail {
  font-size: 0.8rem;
  color: var(--text-soft);
}

/* ===== Settings ===== */
.settings-section {
  background: var(--bg-card);
  border-radius: var(--radius);
  padding: 16px;
  margin-bottom: 16px;
  box-shadow: var(--shadow);
}
.settings-section h3 {
  font-size: 0.95rem;
  margin-bottom: 12px;
  color: var(--text-soft);
}
.check-group {
  display: flex;
  flex-direction: column;
  gap: 10px;
}
.check-label {
  display: flex;
  align-items: center;
  gap: 10px;
  cursor: pointer;
  font-size: 0.9rem;
}
.check-label input {
  width: 18px;
  height: 18px;
  accent-color: var(--primary);
}
#dailyNewLimit {
  width: 100%;
  padding: 10px 14px;
  border: 2px solid var(--border);
  border-radius: var(--radius-sm);
  font-size: 1rem;
  font-family: inherit;
  color: var(--text);
}

/* ===== Result / Empty ===== */
.result-screen {
  text-align: center;
  padding-top: 40px;
}
.session-result {
  font-size: 1.3rem;
  font-weight: 700;
  margin: 16px 0 24px;
  color: var(--primary-dark);
}

.error {
  text-align: center;
  padding: 40px;
  color: var(--danger);
}

/* ===== Responsive ===== */
@media (max-width: 360px) {
  .rating-buttons {
    grid-template-columns: 1fr 1fr;
  }
  .stat-cards {
    grid-template-columns: 1fr;
  }
}
