:root {
  --bg: #f4f1ea;
  --card: #fffdf8;
  --text: #2b2b2b;
  --muted: #7a746a;
  --accent: #c0392b;
  --line: #e4ded2;
}
@media (prefers-color-scheme: dark) {
  :root {
    --bg: #1c1b19;
    --card: #2a2825;
    --text: #ece8e1;
    --muted: #a39d92;
    --accent: #e8735f;
    --line: #3d3a35;
  }
}
* { box-sizing: border-box; }
body {
  margin: 0;
  min-height: 100vh;
  background: var(--bg);
  color: var(--text);
  font-family: system-ui, -apple-system, "Segoe UI", "Noto Sans JP", sans-serif;
  display: flex;
  flex-direction: column;
  align-items: center;
  padding: 20px 16px 32px;
}
.tabs { width: 100%; max-width: 560px; display: flex; gap: 4px; margin-bottom: 14px; border-bottom: 1px solid var(--line); }
.tabs a { padding: 8px 14px; color: var(--muted); text-decoration: none; font-weight: 600; border-bottom: 2px solid transparent; margin-bottom: -1px; }
.tabs a.active { color: var(--accent); border-bottom-color: var(--accent); }
header { width: 100%; max-width: 560px; display: flex; flex-wrap: wrap; gap: 8px; justify-content: flex-end; margin-bottom: 16px; }
select, button {
  font: inherit; font-size: 14px;
  background: var(--card); color: var(--text);
  border: 1px solid var(--line); border-radius: 8px;
  padding: 6px 10px; cursor: pointer;
}
select { max-width: 100%; }
button:hover, select:hover { border-color: var(--accent); }
button.on { background: var(--accent); color: #fff; border-color: var(--accent); }

.scene { width: 100%; max-width: 560px; height: 520px; perspective: 1200px; cursor: pointer; }
.card {
  position: relative; width: 100%; height: 100%;
  transition: transform .45s;
  transform-style: preserve-3d;
}
.card.flipped { transform: rotateY(180deg); }
.face {
  position: absolute; inset: 0;
  backface-visibility: hidden;
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: 16px;
  box-shadow: 0 6px 24px rgba(0,0,0,.08);
  padding: 24px;
  overflow-y: auto;
}
.front { display: flex; flex-direction: column; align-items: center; justify-content: center; }
.back { transform: rotateY(180deg); }
.num { position: absolute; top: 14px; left: 18px; color: var(--muted); font-size: 13px; }
.big-kanji { font-family: "Noto Serif JP", "Yu Mincho", serif; font-size: 180px; line-height: 1; }
.front-text { font-size: 30px; font-weight: 600; text-align: center; }
.front-sub { font-size: 20px; color: var(--muted); margin-top: 10px; text-align: center; }
.hint { position: absolute; bottom: 14px; color: var(--muted); font-size: 13px; }

.back-head { display: flex; align-items: center; gap: 16px; margin-bottom: 14px; padding-bottom: 14px; border-bottom: 1px solid var(--line); }
.back-head .k { font-family: "Noto Serif JP", "Yu Mincho", serif; font-size: 72px; line-height: 1; }
.hv { font-size: 24px; font-weight: 700; color: var(--accent); }
.mean { font-size: 17px; margin-top: 4px; }
.row { margin: 10px 0; font-size: 15px; line-height: 1.6; }
.row b { display: inline-block; min-width: 64px; color: var(--muted); font-weight: 600; }
.imgs { display: flex; flex-wrap: wrap; gap: 8px; justify-content: center; margin-top: 12px; }
.imgs img { max-width: 100%; max-height: 150px; border-radius: 8px; background: #fff; }

/* Trang từ vựng */
.word { font-family: "Noto Serif JP", "Yu Mincho", serif; font-size: 56px; line-height: 1.3; text-align: center; word-break: break-all; }
.back.center { display: flex; flex-direction: column; align-items: center; justify-content: center; text-align: center; }
.back .kana { font-size: 34px; color: var(--accent); font-weight: 600; }
.back .word-kanji { font-family: "Noto Serif JP", "Yu Mincho", serif; font-size: 26px; color: var(--muted); margin-top: 6px; }
.back .romaji { font-size: 15px; color: var(--muted); font-style: italic; margin-top: 6px; }
.back .word-mean { font-size: 22px; margin-top: 22px; line-height: 1.5; }

nav { display: flex; align-items: center; gap: 12px; margin-top: 18px; }
nav button { font-size: 16px; padding: 8px 18px; }
.progress { min-width: 80px; text-align: center; color: var(--muted); }
.keys { margin-top: 12px; color: var(--muted); font-size: 12px; text-align: center; }

@media (max-width: 480px) {
  .scene { height: 460px; }
  .big-kanji { font-size: 140px; }
  .back-head .k { font-size: 56px; }
  .word { font-size: 44px; }
}
