/* ===== 色彩變數 ===== */
:root {
  --bg: #f5f7fb;
  --card: #fff;
  --ink: #202638;
  --muted: #687188;
  --accent: #5267d8;
  --soft: #e9edff;
  --good: #16794b;
  --bad: #b42318;
}

/* ===== 基本設定 ===== */
* { box-sizing: border-box; }

body {
  margin: 0;
  background: var(--bg);
  color: var(--ink);
  font: 16px/1.55 system-ui, -apple-system, "Segoe UI", sans-serif;
}

.muted  { color: var(--muted); }
.hidden { display: none !important; }

/* ===== 頁首 ===== */
.site-header {
  background: linear-gradient(120deg, #313f91, #6e7de8);
  color: #fff;
  padding: 26px 18px;
}
.site-header .inner {
  max-width: 1050px;
  margin: auto;
  display: flex;
  align-items: center;
  gap: 16px;
}
.site-header .logo {
  width: 58px;
  height: 58px;
  flex: none;
  border-radius: 14px;
  box-shadow: 0 4px 14px #0003;
}
.site-header h1 { margin: 0 0 5px; font-size: clamp(24px, 4vw, 34px); }
.site-header p  { margin: 0; opacity: .92; }

/* ===== 主要區塊 ===== */
main {
  max-width: 1050px;
  margin: auto;
  padding: 18px;
}

.card {
  background: var(--card);
  border-radius: 18px;
  padding: 18px;
  box-shadow: 0 4px 18px #26345b0d;
  margin-bottom: 15px;
}

.panel        { display: none; }
.panel.active { display: block; }

/* ===== 按鈕與表單 ===== */
.tab, button, select {
  border: 0;
  border-radius: 12px;
  padding: 10px 14px;
  font: inherit;
  cursor: pointer;
}
button          { background: var(--soft); color: #303c80; }
button:disabled { opacity: .5; cursor: default; }
.tab            { background: #e4e8f5; color: #303953; }
.tab.active,
button.primary  { background: var(--accent); color: #fff; }

.tabs {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
  margin-bottom: 18px;
}

.toolbar {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
  align-items: center;
}
.toolbar.center { justify-content: center; }

/* ===== 單字卡 ===== */
.wordgrid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(165px, 1fr));
  gap: 12px;
}
.word {
  border: 1px solid #e8ebf3;
  border-radius: 15px;
  padding: 14px;
  text-align: center;
  background: var(--card);
}
.emoji   { font-size: 42px; line-height: 1.2; }
.jp      { font-size: 27px; font-weight: 750; }
.romaji  { color: var(--muted); font-size: 14px; }
.meaning { font-weight: 650; margin: 4px 0 10px; }

/* ===== 翻卡 ===== */
.progress {
  height: 8px;
  background: #e6e9f4;
  border-radius: 9px;
  overflow: hidden;
  margin: 12px 0;
}
.progress span {
  display: block;
  height: 100%;
  width: 0;
  background: var(--accent);
  transition: width .2s;
}
.flashface {
  min-height: 235px;
  display: flex;
  flex-direction: column;
  justify-content: center;
  align-items: center;
  gap: 6px;
  text-align: center;
}
.flashface .big { font-size: clamp(40px, 8vw, 66px); font-weight: 800; }
.flashface .pic { font-size: 66px; }

/* ===== 測驗 ===== */
.quizbox { text-align: center; padding: 24px; }
.quizjp  { font-size: clamp(42px, 8vw, 70px); font-weight: 800; margin: 12px; }
.choices {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 10px;
  max-width: 560px;
  margin: 18px auto;
}
.choices button         { min-height: 55px; background: #eef0fb; color: #28345f; }
.choices button.correct { background: #d9f5e6; color: var(--good); }
.choices button.wrong   { background: #ffe3e0; color: var(--bad); }
.status { min-height: 28px; font-weight: 650; }
.intro  { margin-top: 20px; }

/* ===== 五十音表 ===== */
.kana-table {
  width: 100%;
  border-collapse: separate;
  border-spacing: 5px;
  table-layout: fixed;
}
.kana-table th { color: var(--muted); font-size: 12px; }
.kana-table td {
  background: #f0f2fa;
  text-align: center;
  border-radius: 8px;
  padding: 8px 2px;
  font-size: 22px;
  font-weight: 700;
  cursor: pointer;
}
.kana-table td:hover { background: var(--soft); }
.kana-table td small {
  display: block;
  font-size: 11px;
  color: var(--muted);
  font-weight: 400;
}
.kana-table td.blank { background: transparent; cursor: default; }

/* ===== 頁尾 ===== */
footer {
  text-align: center;
  color: var(--muted);
  font-size: 13px;
  padding: 20px;
}

/* ===== 手機版 ===== */
@media (max-width: 540px) {
  .site-header .logo { width: 46px; height: 46px; }
  main  { padding: 12px; }
  .card { padding: 14px; }
  .wordgrid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .word { padding: 10px; }
  .kana-table { border-spacing: 2px; }
  .kana-table td { font-size: 18px; padding: 7px 0; }
}
