:root {
  --bg: #0f1220;
  --card: #1a1f35;
  --card-border: #2a3152;
  --text: #eef0fa;
  --text-dim: #9aa3c7;
  --accent: #7c6cff;
  --accent2: #ff6ca8;
  --green: #4ade80;
  --gold: #fbbf24;
  --radius: 18px;
}

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

body {
  font-family: "Hiragino Sans", "Noto Sans JP", "Apple SD Gothic Neo", sans-serif;
  background: radial-gradient(1200px 600px at 80% -10%, #232a55 0%, var(--bg) 55%);
  color: var(--text);
  min-height: 100vh;
  line-height: 1.6;
}

.app {
  max-width: 560px;
  margin: 0 auto;
  padding: 20px 16px 48px;
  display: flex;
  flex-direction: column;
  gap: 16px;
}

/* ヘッダー */
.header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 4px 4px 0;
}
.logo { font-size: 1.3rem; font-weight: 800; }
.logo em { font-style: normal; color: var(--accent); }
.streak-pill {
  background: linear-gradient(135deg, #ff9f43, #ff6b6b);
  padding: 6px 14px;
  border-radius: 999px;
  font-weight: 700;
  font-size: 0.9rem;
  box-shadow: 0 4px 14px rgba(255, 107, 107, 0.35);
}
.streak-pill.pulse { animation: pulse 0.6s ease; }
@keyframes pulse {
  0% { transform: scale(1); }
  50% { transform: scale(1.15); }
  100% { transform: scale(1); }
}

/* カード共通 */
.card {
  background: var(--card);
  border: 1px solid var(--card-border);
  border-radius: var(--radius);
  padding: 20px;
  box-shadow: 0 8px 24px rgba(0, 0, 0, 0.25);
}
.card h2 {
  font-size: 1rem;
  margin-bottom: 14px;
  color: var(--text-dim);
  letter-spacing: 0.03em;
}

/* 応援メッセージ */
.cheer {
  background: linear-gradient(135deg, rgba(124,108,255,0.25), rgba(255,108,168,0.18));
  border-color: rgba(124,108,255,0.4);
  text-align: center;
  font-weight: 700;
  font-size: 1.05rem;
}

/* レベル */
.level-row { display: flex; align-items: center; gap: 16px; }
.level-badge {
  flex-shrink: 0;
  width: 72px;
  height: 72px;
  border-radius: 50%;
  background: conic-gradient(from 210deg, var(--accent), var(--accent2), var(--accent));
  display: flex;
  align-items: center;
  justify-content: center;
  font-weight: 800;
  font-size: 1.15rem;
  box-shadow: 0 4px 18px rgba(124, 108, 255, 0.45);
}
.level-info { flex: 1; }
.level-title { font-weight: 700; margin-bottom: 6px; }
.xp-bar {
  height: 12px;
  background: #10142a;
  border-radius: 999px;
  overflow: hidden;
}
.xp-fill {
  height: 100%;
  width: 0%;
  background: linear-gradient(90deg, var(--accent), var(--accent2));
  border-radius: 999px;
  transition: width 0.6s cubic-bezier(0.22, 1, 0.36, 1);
}
.xp-text { font-size: 0.8rem; color: var(--text-dim); margin-top: 4px; }

/* タイマー */
.timer-card { text-align: center; }
.lang-toggle {
  display: inline-flex;
  background: #10142a;
  border-radius: 999px;
  padding: 4px;
  margin-bottom: 12px;
}
.lang-btn {
  border: none;
  background: transparent;
  color: var(--text-dim);
  padding: 8px 20px;
  border-radius: 999px;
  font-size: 0.9rem;
  font-weight: 700;
  cursor: pointer;
  font-family: inherit;
  transition: all 0.2s;
}
.lang-btn.active { background: var(--accent); color: #fff; }
.timer-display {
  font-size: 3.4rem;
  font-weight: 800;
  font-variant-numeric: tabular-nums;
  letter-spacing: 0.04em;
  margin: 8px 0 16px;
}
.timer-display.running { color: var(--green); }
.timer-controls { display: flex; gap: 10px; justify-content: center; }
.timer-hint { margin-top: 12px; font-size: 0.82rem; color: var(--text-dim); }

/* ボタン */
.btn {
  border: none;
  border-radius: 12px;
  padding: 12px 28px;
  font-size: 1rem;
  font-weight: 700;
  cursor: pointer;
  font-family: inherit;
  transition: transform 0.1s, opacity 0.2s;
}
.btn:active { transform: scale(0.96); }
.btn-primary {
  background: linear-gradient(135deg, var(--accent), var(--accent2));
  color: #fff;
  box-shadow: 0 4px 16px rgba(124, 108, 255, 0.4);
}
.btn-ghost {
  background: #262c4a;
  color: var(--text-dim);
}
.btn-ghost:hover { color: var(--text); }

/* フレーズ */
.phrase-box {
  background: #10142a;
  border-radius: 14px;
  padding: 18px;
  text-align: center;
  margin-bottom: 12px;
  min-height: 130px;
  display: flex;
  flex-direction: column;
  justify-content: center;
  gap: 6px;
}
.phrase-en { font-size: 1.15rem; font-weight: 700; }
.phrase-ko { font-size: 1.1rem; font-weight: 700; color: var(--accent2); }
.phrase-ja { font-size: 0.88rem; color: var(--text-dim); }
.phrase-controls { display: flex; justify-content: space-between; }
.phrase-controls .btn { padding: 8px 18px; font-size: 0.88rem; }

/* ミッション */
.quest-list { list-style: none; display: flex; flex-direction: column; gap: 8px; }
.quest-item {
  display: flex;
  align-items: center;
  gap: 12px;
  background: #10142a;
  border-radius: 12px;
  padding: 12px 14px;
  cursor: pointer;
  transition: opacity 0.2s;
  user-select: none;
}
.quest-item .check {
  width: 24px;
  height: 24px;
  border-radius: 8px;
  border: 2px solid var(--card-border);
  flex-shrink: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 0.85rem;
  transition: all 0.2s;
}
.quest-item.done .check {
  background: var(--green);
  border-color: var(--green);
  color: #0f1220;
}
.quest-item.done .quest-label {
  text-decoration: line-through;
  color: var(--text-dim);
}
.quest-label { flex: 1; font-size: 0.95rem; }
.quest-xp { font-size: 0.8rem; color: var(--gold); font-weight: 700; }
.quest-hint { margin-top: 10px; font-size: 0.82rem; color: var(--text-dim); text-align: center; }

/* チャート */
.chart {
  display: flex;
  align-items: flex-end;
  justify-content: space-between;
  gap: 8px;
  height: 140px;
  padding: 0 4px;
}
.chart-col {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 6px;
  height: 100%;
  justify-content: flex-end;
}
.chart-bar-wrap {
  width: 100%;
  max-width: 36px;
  flex: 1;
  display: flex;
  align-items: flex-end;
}
.chart-bar {
  width: 100%;
  border-radius: 8px 8px 4px 4px;
  background: linear-gradient(180deg, var(--accent), #3d3580);
  min-height: 4px;
  transition: height 0.6s cubic-bezier(0.22, 1, 0.36, 1);
}
.chart-col.today .chart-bar { background: linear-gradient(180deg, var(--accent2), #8a3a63); }
.chart-min { font-size: 0.68rem; color: var(--text-dim); }
.chart-day { font-size: 0.78rem; color: var(--text-dim); }
.chart-col.today .chart-day { color: var(--accent2); font-weight: 700; }
.chart-total { margin-top: 12px; text-align: center; font-size: 0.9rem; color: var(--text-dim); }
.chart-total strong { color: var(--text); }

/* バッジ */
.badge-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(96px, 1fr));
  gap: 10px;
}
.badge {
  background: #10142a;
  border-radius: 14px;
  padding: 14px 8px;
  text-align: center;
  opacity: 0.35;
  filter: grayscale(1);
  transition: all 0.3s;
}
.badge.unlocked { opacity: 1; filter: none; box-shadow: 0 0 0 1px rgba(251, 191, 36, 0.4); }
.badge-icon { font-size: 1.7rem; }
.badge-name { font-size: 0.72rem; margin-top: 6px; color: var(--text-dim); }
.badge.unlocked .badge-name { color: var(--gold); font-weight: 700; }

/* 単語帳 */
.flashcard {
  perspective: 1200px;
  cursor: pointer;
  margin-bottom: 12px;
}
.flashcard-inner {
  position: relative;
  width: 100%;
  min-height: 160px;
  transform-style: preserve-3d;
  transition: transform 0.5s cubic-bezier(0.22, 1, 0.36, 1);
}
.flashcard.flipped .flashcard-inner { transform: rotateY(180deg); }
.flashcard-face {
  position: absolute;
  inset: 0;
  backface-visibility: hidden;
  -webkit-backface-visibility: hidden;
  border-radius: 14px;
  padding: 22px 18px;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 8px;
  text-align: center;
}
.flashcard-face-front {
  background: #10142a;
  border: 1px solid var(--card-border);
}
.flashcard-face-back {
  background: linear-gradient(135deg, rgba(124,108,255,0.22), rgba(255,108,168,0.16));
  border: 1px solid rgba(124,108,255,0.4);
  transform: rotateY(180deg);
}
.flashcard.card-known .flashcard-face-front {
  border-color: var(--green);
  box-shadow: inset 0 0 0 1px rgba(74, 222, 128, 0.4);
}
.card-word { font-size: 1.7rem; font-weight: 800; }
.card-reading { font-size: 0.95rem; color: var(--text-dim); }
.card-tap-hint { font-size: 0.75rem; color: var(--text-dim); margin-top: 6px; opacity: 0.8; }
.card-meaning { font-size: 1.4rem; font-weight: 800; color: var(--accent2); }
.card-example { font-size: 0.92rem; color: var(--text); opacity: 0.9; }
.card-meta {
  display: flex;
  justify-content: space-between;
  font-size: 0.8rem;
  color: var(--text-dim);
  margin-bottom: 12px;
}
.card-controls { display: flex; gap: 8px; justify-content: space-between; }
.card-controls .btn { padding: 10px 14px; font-size: 0.9rem; flex: 1; }
.btn-know {
  background: linear-gradient(135deg, var(--green), #22a559);
  color: #0f1220;
}
.btn-know.known {
  background: #10142a;
  color: var(--green);
  box-shadow: inset 0 0 0 1px var(--green);
}
.card-hint { margin-top: 12px; font-size: 0.8rem; color: var(--text-dim); text-align: center; }

/* 言語別内訳 */
.langbreak-bar {
  display: flex;
  height: 22px;
  border-radius: 999px;
  overflow: hidden;
  background: #10142a;
  margin-bottom: 16px;
}
.langbreak-seg { height: 100%; transition: width 0.6s cubic-bezier(0.22, 1, 0.36, 1); }
.langbreak-en { background: linear-gradient(90deg, var(--accent), #5b4fd6); }
.langbreak-ko { background: linear-gradient(90deg, #ff6ca8, var(--accent2)); }
.langbreak-legend { display: flex; flex-direction: column; gap: 10px; }
.langbreak-row { display: flex; align-items: center; gap: 10px; font-size: 0.95rem; }
.langbreak-dot { width: 12px; height: 12px; border-radius: 50%; flex-shrink: 0; }
.dot-en { background: var(--accent); }
.dot-ko { background: var(--accent2); }
.langbreak-name { flex: 1; }
.langbreak-min { color: var(--text-dim); font-variant-numeric: tabular-nums; }
.langbreak-pct { font-weight: 700; width: 48px; text-align: right; font-variant-numeric: tabular-nums; }

.footer {
  text-align: center;
  color: var(--text-dim);
  font-size: 0.85rem;
  margin-top: 8px;
}

/* トースト */
.toast {
  position: fixed;
  bottom: 28px;
  left: 50%;
  transform: translate(-50%, 80px);
  background: linear-gradient(135deg, var(--accent), var(--accent2));
  color: #fff;
  font-weight: 700;
  padding: 14px 26px;
  border-radius: 999px;
  box-shadow: 0 8px 28px rgba(124, 108, 255, 0.5);
  opacity: 0;
  transition: all 0.35s cubic-bezier(0.22, 1, 0.36, 1);
  pointer-events: none;
  z-index: 100;
  max-width: 90vw;
  text-align: center;
}
.toast.show { transform: translate(-50%, 0); opacity: 1; }
