:root {
  --bg: #f6f3ec;
  --card: #ffffff;
  --text: #22252b;
  --muted: #6b6f78;
  --line: #e2ddd2;
  --primary: #2f5d8a;
  --primary-text: #ffffff;
  --known: #2e7d4f;
  --vague: #a87412;
  --unknown: #b2443a;
  --notice-bg: #fff1d6;
  --notice-text: #6a4a00;
  font-family: -apple-system, BlinkMacSystemFont, "Hiragino Sans", "Noto Sans JP", sans-serif;
}

@media (prefers-color-scheme: dark) {
  :root {
    --bg: #16181c;
    --card: #22252b;
    --text: #eceae5;
    --muted: #9ea2ab;
    --line: #34383f;
    --primary: #6b9fd1;
    --primary-text: #0f1114;
    --known: #5cbf85;
    --vague: #e0aa45;
    --unknown: #e27a70;
    --notice-bg: #3b3020;
    --notice-text: #f3d9a4;
  }
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  height: 100%;
  background: var(--bg);
  color: var(--text);
  -webkit-text-size-adjust: 100%;
}

body {
  padding: env(safe-area-inset-top) env(safe-area-inset-right) env(safe-area-inset-bottom) env(safe-area-inset-left);
}

main { height: 100%; }

.screen {
  position: relative;
  display: flex;
  flex-direction: column;
  min-height: 100%;
  max-width: 560px;
  margin: 0 auto;
  padding: 16px;
}
.screen[hidden] { display: none; }

.title {
  margin: 8px 0 0;
  font-size: 17px;
  font-weight: 600;
  color: var(--muted);
  text-align: center;
}

.home-center {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 20px;
  text-align: center;
}

.stats { margin: 0; color: var(--muted); line-height: 1.9; }
.stats strong { color: var(--text); font-size: 18px; }
.hint { margin: 0; color: var(--vague); font-size: 14px; }

.btn {
  min-height: 56px;
  padding: 0 20px;
  border: 1px solid var(--line);
  border-radius: 14px;
  background: var(--card);
  color: var(--text);
  font: inherit;
  font-size: 17px;
  font-weight: 600;
  cursor: pointer;
  -webkit-tap-highlight-color: transparent;
  touch-action: manipulation;
}
.btn:disabled { opacity: 0.5; }
.btn:active { transform: scale(0.98); }
.btn-primary { background: var(--primary); border-color: var(--primary); color: var(--primary-text); }
.btn-big { width: min(100%, 320px); min-height: 72px; font-size: 22px; border-radius: 18px; }
.btn-quiet { background: transparent; border-color: transparent; color: var(--muted); font-weight: 500; }

.corner { position: absolute; right: 8px; top: 4px; }

.bar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin: -8px -8px 8px;
}
.progress { color: var(--muted); font-size: 15px; padding-right: 12px; }

.card {
  flex: 1;
  display: flex;
  flex-direction: column;
  justify-content: center;
  gap: 10px;
  padding: 24px 20px;
  border: 1px solid var(--line);
  border-radius: 20px;
  background: var(--card);
  text-align: center;
}

.term {
  margin: 0;
  font-family: ui-monospace, "SF Mono", Menlo, monospace;
  font-size: clamp(32px, 11vw, 48px);
  font-weight: 600;
  overflow-wrap: anywhere;
}
.term-small { font-size: clamp(24px, 8vw, 32px); }
.reading { margin: 0; color: var(--muted); font-size: 17px; }
.meaning { margin: 8px 0; font-size: 22px; font-weight: 700; line-height: 1.5; }
.detail { margin: 0; color: var(--muted); font-size: 15px; line-height: 1.7; }

.term-area {
  flex: 1;
  display: flex;
  align-items: center;
  justify-content: center;
  min-height: 120px;
  text-align: center;
}

.choices { display: flex; flex-direction: column; gap: 10px; }
.choice {
  display: flex;
  align-items: center;
  gap: 10px;
  width: 100%;
  min-height: 60px;
  padding: 10px 16px;
  border: 1px solid var(--line);
  border-radius: 14px;
  background: var(--card);
  color: var(--text);
  font: inherit;
  font-size: 17px;
  line-height: 1.45;
  text-align: left;
  cursor: pointer;
  -webkit-tap-highlight-color: transparent;
  touch-action: manipulation;
}
button.choice:active { transform: scale(0.98); }
.choice .mark { flex: none; width: 1.4em; font-weight: 700; text-align: center; }
.choice.is-correct { border-color: var(--known); box-shadow: inset 0 0 0 2px var(--known); }
.choice.is-correct .mark { color: var(--known); }
.choice.is-wrong { border-color: var(--unknown); box-shadow: inset 0 0 0 2px var(--unknown); }
.choice.is-wrong .mark { color: var(--unknown); }
.choice.is-other { opacity: 0.55; }

.answer-head { padding: 8px 0 16px; text-align: center; }
.answer-head p { margin: 0; }
.result { font-size: 26px; font-weight: 700; margin-bottom: 6px !important; }
.result.ok { color: var(--known); }
.result.ng { color: var(--unknown); }
.explain { flex: 1; display: flex; flex-direction: column; gap: 8px; padding-top: 16px; }

.actions { display: flex; flex-direction: column; gap: 10px; padding-top: 16px; }
.actions .btn { width: 100%; }
.btn-known { background: var(--known); border-color: var(--known); color: var(--primary-text); }
.btn-vague { color: var(--vague); border-color: var(--vague); }
.btn-unknown { color: var(--unknown); border-color: var(--unknown); }

.done-text { margin: 0; font-size: 22px; font-weight: 600; }

.records { display: flex; flex-direction: column; gap: 14px; line-height: 1.7; }
.records p { margin: 0; }

.notice {
  position: sticky;
  top: 0;
  z-index: 1;
  padding: 10px 16px;
  background: var(--notice-bg);
  color: var(--notice-text);
  font-size: 14px;
  line-height: 1.6;
  text-align: center;
}
