/* 発音判定くん - シンプルUI */
* { margin: 0; padding: 0; box-sizing: border-box; }
[hidden] { display: none !important; }

:root {
  --accent: #ff6b35;
  --accent-dark: #e5541f;
  --accent-soft: #fff1ea;
  --ink: #333;
  --ink-light: #777;
  --bg: #faf7f2;
  --card: #ffffff;
  --line: #eee4da;
  --good: #2eaf5d;
  --ok: #8ec63f;
  --meh: #f5a623;
  --bad: #e74c3c;
  --radius: 16px;
}

html { -webkit-text-size-adjust: 100%; }
body {
  font-family: "Hiragino Kaku Gothic ProN", "Hiragino Sans", "BIZ UDPGothic", Meiryo, system-ui, sans-serif;
  background: var(--bg);
  color: var(--ink);
  line-height: 1.7;
}

main { max-width: 720px; margin: 0 auto; padding: 0 14px 40px; }

/* header */
.site-header {
  text-align: center;
  padding: 34px 16px 22px;
  background: linear-gradient(160deg, #fff6ef, #ffe8d9);
  border-bottom: 3px solid var(--accent);
  margin-bottom: 22px;
}
.site-header h1 { font-size: 1.15rem; color: var(--ink-light); font-weight: 600; line-height: 1.4; }
.title-main { font-size: 2.2rem; color: var(--accent-dark); font-weight: 800; letter-spacing: .04em; }
.mic-emoji { font-size: 1.8rem; }
.subtitle { margin-top: 12px; font-size: .92rem; color: var(--ink); }
.subtitle strong { color: var(--accent-dark); }

/* cards & steps */
.card {
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 20px 18px;
  margin-bottom: 18px;
  box-shadow: 0 2px 8px rgba(160, 120, 90, .06);
}
.step h2 { font-size: 1.1rem; margin-bottom: 14px; display: flex; align-items: center; gap: 10px; }
.step-num {
  background: var(--accent);
  color: #fff;
  border-radius: 999px;
  padding: 3px 14px;
  font-size: .85rem;
  white-space: nowrap;
}
.optional { font-size: .78rem; color: var(--ink-light); font-weight: normal; }
.hint { font-size: .8rem; color: var(--ink-light); margin-top: 10px; }

/* buttons */
.btn {
  border: none; cursor: pointer; border-radius: 999px;
  font-family: inherit; font-weight: 700; transition: transform .1s, opacity .2s;
}
.btn:active { transform: scale(.97); }
.btn:disabled { opacity: .4; cursor: not-allowed; }
.btn-primary { background: var(--accent); color: #fff; }
.btn-primary:not(:disabled):hover { background: var(--accent-dark); }
.btn-secondary { background: #fff; color: var(--accent-dark); border: 2px solid var(--accent); padding: 9px 20px; font-size: .95rem; }
.btn-big { width: 100%; padding: 16px; font-size: 1.25rem; }
.btn-small { background: var(--accent-soft); color: var(--accent-dark); padding: 7px 14px; font-size: .85rem; }
.btn-ghost { background: #f4f4f4; color: var(--ink-light); }

/* mode tabs */
.mode-tabs { display: flex; gap: 8px; margin-bottom: 14px; flex-wrap: wrap; }
.mode-tab {
  flex: 1; min-width: 110px; padding: 10px 6px; border-radius: 10px;
  border: 2px solid var(--line); background: #fff; cursor: pointer;
  font-family: inherit; font-size: .9rem; font-weight: 700; color: var(--ink-light);
}
.mode-tab.active { border-color: var(--accent); background: var(--accent-soft); color: var(--accent-dark); }

.cat-tabs { display: flex; gap: 6px; flex-wrap: wrap; margin-bottom: 10px; }
.cat-tab {
  border: 1px solid var(--line); background: #fff; border-radius: 999px;
  padding: 5px 12px; font-size: .82rem; cursor: pointer; font-family: inherit; color: var(--ink);
}
.cat-tab.active { background: var(--accent); border-color: var(--accent); color: #fff; }

.sentence-list { display: flex; flex-direction: column; gap: 8px; }
.sentence-item {
  text-align: left; border: 2px solid var(--line); border-radius: 12px;
  background: #fff; padding: 10px 14px; cursor: pointer; font-family: inherit;
}
.sentence-item.selected { border-color: var(--accent); background: var(--accent-soft); }
.sentence-en { font-size: 1rem; font-weight: 700; color: var(--ink); }
.sentence-ja { font-size: .78rem; color: var(--ink-light); }

#customText {
  width: 100%; border: 2px solid var(--line); border-radius: 12px; padding: 12px;
  font-family: inherit; font-size: 1rem; resize: vertical;
}
#customText:focus { outline: none; border-color: var(--accent); }
.free-note { font-size: .92rem; background: var(--accent-soft); border-radius: 12px; padding: 14px; }

/* model row */
.model-row { display: flex; gap: 10px; align-items: center; flex-wrap: wrap; }
#voiceSelect {
  flex: 1; min-width: 190px; padding: 10px; border-radius: 10px;
  border: 2px solid var(--line); font-family: inherit; font-size: .92rem; background: #fff;
}
.slow-label { font-size: .85rem; color: var(--ink); white-space: nowrap; }

/* recording */
.rec-area { text-align: center; }
.rec-btn {
  width: 130px; height: 130px; border-radius: 50%;
  border: 5px solid var(--accent); background: var(--accent-soft);
  cursor: pointer; font-family: inherit;
  display: inline-flex; flex-direction: column; align-items: center; justify-content: center; gap: 4px;
  transition: transform .1s;
}
.rec-btn:active { transform: scale(.95); }
.rec-btn.recording { background: var(--bad); border-color: #c0392b; animation: pulse 1.2s infinite; }
.rec-btn.recording .rec-label { color: #fff; }
.rec-icon { font-size: 2.4rem; }
.rec-label { font-size: .72rem; font-weight: 700; color: var(--accent-dark); }
@keyframes pulse {
  0%, 100% { box-shadow: 0 0 0 0 rgba(231, 76, 60, .4); }
  50% { box-shadow: 0 0 0 18px rgba(231, 76, 60, 0); }
}
.rec-timer { font-size: 1.6rem; font-weight: 800; color: var(--bad); margin-top: 10px; font-variant-numeric: tabular-nums; }
.rec-done { margin-top: 12px; display: flex; gap: 8px; justify-content: center; align-items: center; flex-wrap: wrap; font-size: .9rem; }

/* loading overlay */
.loading-overlay {
  position: fixed; inset: 0; background: rgba(50, 30, 20, .55);
  display: flex; align-items: center; justify-content: center; z-index: 100; padding: 20px;
}
.loading-box { background: #fff; border-radius: 20px; padding: 28px 22px; max-width: 430px; text-align: center; }
.spinner {
  width: 46px; height: 46px; margin: 0 auto 14px;
  border: 5px solid var(--accent-soft); border-top-color: var(--accent);
  border-radius: 50%; animation: spin 1s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }
.loading-title { font-weight: 800; color: var(--accent-dark); margin-bottom: 14px; }
.loading-fact { background: var(--bg); border-radius: 12px; padding: 12px 14px; font-size: .85rem; text-align: left; }
.fact-label { font-weight: 700; color: var(--accent-dark); font-size: .78rem; margin-bottom: 4px; }

/* results */
.result-card { border: 2px solid var(--accent); }
.result-title { text-align: center; color: var(--accent-dark); margin-bottom: 14px; }
.result-card h3 { font-size: 1rem; margin: 22px 0 10px; border-left: 4px solid var(--accent); padding-left: 8px; }
.h3-note { font-size: .75rem; color: var(--ink-light); font-weight: normal; }

.verdict-banner {
  background: linear-gradient(135deg, #ff8c5a, var(--accent-dark));
  color: #fff; font-weight: 800; font-size: 1.1rem; text-align: center;
  border-radius: 14px; padding: 14px 16px; margin-bottom: 16px;
}

.score-hero { display: flex; gap: 20px; align-items: center; flex-wrap: wrap; justify-content: center; }
.score-circle { position: relative; width: 150px; height: 150px; }
.score-circle svg { width: 100%; height: 100%; transform: rotate(-90deg); }
.ring-bg { fill: none; stroke: #f0e8e0; stroke-width: 10; }
.ring-fg {
  fill: none; stroke: var(--accent); stroke-width: 10; stroke-linecap: round;
  stroke-dasharray: 326.7; stroke-dashoffset: 326.7;
  transition: stroke-dashoffset 1.2s ease-out, stroke .4s;
}
.score-circle-inner {
  position: absolute; inset: 0; display: flex; flex-direction: column;
  align-items: center; justify-content: center;
}
.total-score { font-size: 2.6rem; font-weight: 800; color: var(--accent-dark); line-height: 1; }
.total-label { font-size: .72rem; color: var(--ink-light); }

.meters { flex: 1; min-width: 230px; display: flex; flex-direction: column; gap: 14px; }
.meter-head { display: flex; justify-content: space-between; font-size: .9rem; font-weight: 700; margin-bottom: 4px; }
.meter { background: #f0e8e0; border-radius: 999px; height: 16px; overflow: hidden; }
.meter-fill { height: 100%; width: 0; border-radius: 999px; transition: width 1.2s ease-out; }
.meter-fill.native { background: linear-gradient(90deg, #4aa3ff, #2e7dd6); }
.meter-fill.junjapa { background: linear-gradient(90deg, #ffb84a, #ff6b35); }

/* accent bars */
.accent-bars { display: flex; flex-direction: column; gap: 8px; }
.accent-row { display: grid; grid-template-columns: 11em 1fr 3.2em; gap: 8px; align-items: center; font-size: .88rem; }
.accent-name { font-weight: 700; text-align: right; }
.accent-track { background: #f0e8e0; border-radius: 999px; height: 14px; overflow: hidden; }
.accent-fill { height: 100%; width: 0; background: linear-gradient(90deg, #ffa270, var(--accent)); border-radius: 999px; transition: width 1s ease-out; }
.accent-pct { font-weight: 800; color: var(--accent-dark); font-variant-numeric: tabular-nums; }

/* detail scores */
.detail-scores { display: grid; grid-template-columns: repeat(auto-fit, minmax(130px, 1fr)); gap: 10px; }
.dscore { background: var(--bg); border-radius: 12px; padding: 10px; text-align: center; }
.dscore-val { font-size: 1.5rem; font-weight: 800; }
.dscore-name { font-size: .75rem; color: var(--ink-light); }

.recognized { background: var(--bg); border-radius: 12px; padding: 12px 14px; font-size: .95rem; font-style: italic; }

/* word chips */
.word-legend { display: flex; gap: 8px; flex-wrap: wrap; font-size: .7rem; margin-bottom: 8px; color: var(--ink-light); }
.lg::before { content: "●"; margin-right: 3px; }
.lg.good::before { color: var(--good); }
.lg.ok::before { color: var(--ok); }
.lg.meh::before { color: var(--meh); }
.lg.bad::before { color: var(--bad); }
.lg.miss::before { color: #999; }
.word-chips { display: flex; flex-wrap: wrap; gap: 6px; }
.word-chip {
  border: none; border-radius: 8px; padding: 5px 10px; font-size: 1rem; font-weight: 700;
  cursor: pointer; font-family: inherit; color: #fff;
}
.word-chip.good { background: var(--good); }
.word-chip.ok { background: var(--ok); }
.word-chip.meh { background: var(--meh); }
.word-chip.bad { background: var(--bad); }
.word-chip.miss { background: #aaa; text-decoration: line-through; }
.word-chip.active { outline: 3px solid #333; }

.phoneme-detail { margin-top: 10px; background: var(--bg); border-radius: 12px; padding: 12px 14px; font-size: .88rem; }
.phoneme-detail h4 { margin-bottom: 8px; }
.ph-table { width: 100%; border-collapse: collapse; }
.ph-table th, .ph-table td { padding: 4px 8px; border-bottom: 1px solid var(--line); text-align: left; font-size: .85rem; }
.ph-ipa { font-family: "Segoe UI", sans-serif; font-weight: 700; }
.ph-score.good { color: var(--good); font-weight: 700; }
.ph-score.ok { color: var(--ok); font-weight: 700; }
.ph-score.meh { color: var(--meh); font-weight: 700; }
.ph-score.bad { color: var(--bad); font-weight: 700; }

/* jp errors */
.jp-errors { list-style: none; display: flex; flex-direction: column; gap: 8px; }
.jp-errors li { background: #fff8ec; border-left: 4px solid var(--meh); border-radius: 8px; padding: 10px 12px; font-size: .88rem; }
.jp-errors b { color: var(--accent-dark); }

/* AI block */
.ai-praise {
  background: #eefaf1; border: 1px solid #bfe8cc; border-radius: 12px;
  padding: 10px 14px; font-weight: 700; color: #1e7c43; margin-bottom: 10px; font-size: .92rem;
}
.ai-comment { font-size: .92rem; margin-bottom: 12px; }
#aiBlock h4 { font-size: .92rem; margin: 14px 0 6px; color: var(--accent-dark); }
.ai-tips, .ai-roadmap { padding-left: 1.4em; font-size: .88rem; display: flex; flex-direction: column; gap: 6px; }
.ai-roadmap li::marker { font-weight: 800; color: var(--accent-dark); }

.retry-row { text-align: center; margin-top: 22px; }

/* trivia */
.trivia-card h2 { text-align: center; font-size: 1.15rem; margin-bottom: 14px; color: var(--accent-dark); }
.trivia-tabs { display: flex; gap: 6px; flex-wrap: wrap; margin-bottom: 14px; }
.trivia-tab {
  flex: 1; min-width: 140px; padding: 9px 6px; border-radius: 10px;
  border: 2px solid var(--line); background: #fff; cursor: pointer;
  font-family: inherit; font-size: .82rem; font-weight: 700; color: var(--ink-light);
}
.trivia-tab.active { border-color: var(--accent); background: var(--accent-soft); color: var(--accent-dark); }
.accordion { border: 1px solid var(--line); border-radius: 12px; margin-bottom: 8px; overflow: hidden; }
.accordion summary {
  cursor: pointer; padding: 11px 14px; font-weight: 700; font-size: .95rem;
  background: #fff; list-style: none; position: relative;
}
.accordion summary::after { content: "▾"; position: absolute; right: 14px; color: var(--ink-light); transition: transform .2s; }
.accordion[open] summary::after { transform: rotate(180deg); }
.accordion[open] summary { background: var(--accent-soft); }
.accordion-body { padding: 10px 16px 14px; font-size: .87rem; background: #fffdfb; }
.accordion-body ul { padding-left: 1.3em; display: flex; flex-direction: column; gap: 5px; }
.trivia-tip { margin-top: 8px; background: var(--accent-soft); border-radius: 8px; padding: 8px 10px; font-size: .84rem; }
.trivia-tip::before { content: "💡 "; }
.fact-item { background: #fffdfb; border: 1px solid var(--line); border-radius: 12px; padding: 11px 14px; font-size: .87rem; margin-bottom: 8px; }
.fact-item::before { content: "🤓 "; }

/* 原田英語クレジット */
.credit-block {
  max-width: 720px;
  margin: 10px auto 0;
  text-align: center;
  background: linear-gradient(160deg, #fff6ef, #ffe8d9);
  border: 2px solid var(--accent);
  border-radius: var(--radius);
  padding: 26px 18px 24px;
}
.credit-lead { font-size: .85rem; color: var(--ink-light); font-weight: 700; letter-spacing: .08em; }
.credit-brand {
  display: block;
  font-size: 2.4rem;
  font-weight: 800;
  color: var(--accent-dark);
  text-decoration: none;
  letter-spacing: .1em;
  line-height: 1.3;
  margin: 4px 0 2px;
}
.credit-brand:hover { text-decoration: underline; }
.credit-url {
  display: inline-block;
  font-size: 1.05rem;
  font-weight: 700;
  color: var(--accent);
  text-decoration: none;
  border-bottom: 2px solid var(--accent);
  padding-bottom: 2px;
}
.credit-url:hover { color: var(--accent-dark); border-color: var(--accent-dark); }
.credit-sub { margin-top: 12px; font-size: .85rem; color: var(--ink); }

/* footer */
.site-footer { text-align: center; font-size: .78rem; color: var(--ink-light); padding: 24px 16px 40px; }
.site-footer a { color: var(--accent-dark); }
.credit { margin-top: 6px; }

@media (max-width: 480px) {
  .title-main { font-size: 1.7rem; }
  .accent-row { grid-template-columns: 8.5em 1fr 3em; font-size: .8rem; }
  .credit-block { margin: 10px 14px 0; }
  .credit-brand { font-size: 2rem; }
  .credit-url { font-size: .92rem; }
}
