/* トキタビ: 和紙の紙色 × 墨 × 朱(日本史)/ 青緑(世界史)。文字は大きめ */
:root {
  --paper: #f7f1e5; --card: #fffdf8; --ink: #2a2421; --sub: #5d544d; --line: #e2d6c2;
  --jp: #b8402a; --w: #1f6f78; --gold: #c3922e; --ok: #2f7d4f; --ng: #b23a3a;
  --night: #1c2033; --r: 16px;
  font-size: 18px;
}
* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0; background: var(--paper); color: var(--ink);
  font-family: "Hiragino Sans", "Hiragino Kaku Gothic ProN", "Noto Sans JP", "Noto Sans CJK JP", "Yu Gothic", Meiryo, sans-serif;
  line-height: 1.75; word-break: auto-phrase; overflow-wrap: anywhere;
}
h1, h2, h3, .btn, .chip, nav a, .lead, .tag { text-wrap: balance; }
p, li { text-wrap: pretty; }
a { color: var(--w); }
img, svg { max-width: 100%; }
.nb { white-space: nowrap; }
.wrap { max-width: 880px; margin: 0 auto; padding: 0 16px; }

/* ヘッダー */
header.top { background: var(--night); color: #f7f1e5; }
header.top .wrap { display: flex; align-items: center; gap: 12px; min-height: 60px; flex-wrap: wrap; padding-top: 6px; padding-bottom: 6px; }
.brand { display: flex; align-items: center; gap: 10px; color: inherit; text-decoration: none; font-weight: 800; font-size: 1.2rem; white-space: nowrap; }
.brand svg { width: 38px; height: 38px; flex: none; }
.brand small { display: block; font-size: .62rem; letter-spacing: .18em; opacity: .75; font-weight: 600; line-height: 1.1; }
.brand span { line-height: 1.15; }
nav.main { display: flex; gap: 4px; margin-left: auto; overflow-x: auto; scrollbar-width: none; }
nav.main a { color: #f7f1e5; text-decoration: none; padding: 8px 10px; border-radius: 10px; white-space: nowrap; font-size: .92rem; }
nav.main a:hover, nav.main a[aria-current] { background: rgba(255,255,255,.12); }
@media (max-width: 560px) {
  header.top .wrap { justify-content: center; }
  nav.main { margin: 0 -16px; padding: 0 12px 4px; width: calc(100% + 32px); justify-content: center; }
}

main { padding: 20px 0 48px; }
section { margin: 0 0 32px; }
h1 { font-size: 1.7rem; line-height: 1.35; margin: 8px 0 14px; }
h2 { font-size: 1.35rem; line-height: 1.4; margin: 28px 0 12px; }
h3 { font-size: 1.12rem; margin: 0 0 8px; line-height: 1.45; }
.hint, .small { color: var(--sub); font-size: .9rem; }

/* カード */
.card { background: var(--card); border: 1px solid var(--line); border-radius: var(--r); padding: 18px; margin: 0 0 16px; box-shadow: 0 2px 0 rgba(60,40,20,.05); }
.cards { display: grid; gap: 16px; grid-template-columns: repeat(auto-fit, minmax(240px, 1fr)); margin: 0 0 16px; }
.cards .card { margin: 0; }

/* ボタン */
.btn { display: inline-flex; align-items: center; justify-content: center; gap: 8px; min-height: 52px; padding: 10px 22px; border-radius: 999px; border: 2px solid var(--ink);
  background: var(--ink); color: #fff; font: inherit; font-weight: 700; text-decoration: none; cursor: pointer; text-align: center; line-height: 1.4; }
.btn.jp { background: var(--jp); border-color: var(--jp); }
.btn.w { background: var(--w); border-color: var(--w); }
.btn.gold { background: var(--gold); border-color: var(--gold); color: #1d1608; }
.btn.ghost { background: transparent; color: var(--ink); }
.btn[disabled] { opacity: .45; cursor: default; }
.btn .sub { display: block; font-size: .78rem; font-weight: 500; opacity: .9; }
.btnrow { display: flex; flex-wrap: wrap; gap: 12px; margin: 16px 0; }
@media (max-width: 560px) {
  .btnrow { flex-direction: column; align-items: center; }
  .btnrow .btn { width: min(100%, 360px); }
}

/* トップ */
.hero { background: radial-gradient(120% 120% at 50% 0%, #2c3355 0%, var(--night) 70%); color: #f7f1e5; padding: 36px 0 40px; text-align: center; }
.hero h1 { font-size: 2rem; margin: 10px 0 12px; }
.hero p { max-width: 36em; margin: 0 auto 8px; }
.hero .btnrow { justify-content: center; }
.hero .clock { width: 120px; height: 120px; margin: 0 auto; display: block; }
.hero .clock .hand { transform-origin: 60px 60px; animation: spin 6s linear infinite; }
.hero .clock .hand2 { transform-origin: 60px 60px; animation: spin 60s linear infinite reverse; }
@keyframes spin { to { transform: rotate(360deg); } }
@media (prefers-reduced-motion: reduce) { .hero .clock .hand, .hero .clock .hand2, .warp::before { animation: none !important; } }
.steps { counter-reset: s; list-style: none; padding: 0; margin: 0; display: grid; gap: 12px; }
.steps li { counter-increment: s; background: var(--card); border: 1px solid var(--line); border-radius: var(--r); padding: 14px 16px 14px 58px; position: relative; }
.steps li::before { content: counter(s); position: absolute; left: 16px; top: 14px; width: 30px; height: 30px; border-radius: 50%; background: var(--gold); color: #1d1608; font-weight: 800; display: grid; place-items: center; }

/* 時代の地図 */
.course-tabs { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; margin: 0 0 18px; }
.course-tabs button { min-height: 56px; border-radius: 14px; border: 2px solid var(--line); background: var(--card); font: inherit; font-weight: 800; cursor: pointer; color: var(--ink); }
.course-tabs button[aria-pressed="true"].jp { background: var(--jp); border-color: var(--jp); color: #fff; }
.course-tabs button[aria-pressed="true"].w { background: var(--w); border-color: var(--w); color: #fff; }
.eras { list-style: none; padding: 0; margin: 0; position: relative; display: grid; gap: 12px; }
.eras::before { content: ""; position: absolute; left: 27px; top: 10px; bottom: 10px; width: 4px; background: var(--line); border-radius: 2px; }
.eras a { display: grid; grid-template-columns: 58px 1fr auto; align-items: center; gap: 10px; text-decoration: none; color: var(--ink); background: var(--card);
  border: 1px solid var(--line); border-radius: var(--r); padding: 12px 14px 12px 0; position: relative; }
.eras .dot { width: 22px; height: 22px; border-radius: 50%; background: var(--card); border: 4px solid var(--line); justify-self: center; z-index: 1; }
.eras .done .dot { background: var(--gold); border-color: var(--gold); }
.eras .name { font-weight: 800; font-size: 1.08rem; display: block; line-height: 1.4; }
.eras .span { color: var(--sub); font-size: .85rem; display: block; }
.eras .who { color: var(--sub); font-size: .85rem; display: block; }
.stars { color: var(--gold); font-size: 1rem; white-space: nowrap; letter-spacing: 1px; }

/* 時代の画面 */
.warp { position: relative; overflow: hidden; border-radius: var(--r); background: var(--night); color: #f7f1e5; padding: 22px 20px; margin: 0 0 18px; }
.warp::before { content: ""; position: absolute; inset: -50%; background: conic-gradient(from 0deg, transparent, rgba(195,146,46,.18), transparent 30%); animation: spin 8s linear infinite; }
.warp > * { position: relative; }
.warp .era-name { font-size: 1.6rem; font-weight: 800; margin: 0; line-height: 1.35; }
.warp .span { opacity: .8; margin: 0 0 10px; }
.warp .story { margin: 0; font-size: 1.02rem; }
.warp.arrive { animation: arrive .9s ease-out; }
@keyframes arrive { from { filter: blur(8px) brightness(2); transform: scale(1.04); } to { filter: none; transform: none; } }
.person { display: grid; grid-template-columns: 64px 1fr; gap: 14px; align-items: center; }
.avatar { width: 64px; height: 64px; border-radius: 50%; display: grid; place-items: center; font-size: 1.6rem; font-weight: 800; color: #fff; flex: none; }
.person .role { color: var(--sub); font-size: .88rem; display: block; }

/* クイズ */
.qbox { background: var(--card); border: 1px solid var(--line); border-radius: var(--r); padding: 18px; }
.qhead { display: flex; justify-content: space-between; align-items: center; gap: 10px; color: var(--sub); font-size: .9rem; margin: 0 0 8px; }
.bar { height: 8px; background: var(--line); border-radius: 4px; overflow: hidden; margin: 0 0 14px; }
.bar i { display: block; height: 100%; background: var(--gold); transition: width .3s; }
.qlead { font-weight: 800; color: var(--jp); margin: 0 0 4px; font-size: 1.05rem; }
.w-course .qlead { color: var(--w); }
.qtext { font-size: 1.22rem; font-weight: 700; margin: 0 0 16px; line-height: 1.6; }
.blank { display: inline-block; min-width: 3.2em; border-bottom: 3px solid var(--gold); text-align: center; color: var(--gold); }
.choices { display: grid; gap: 10px; }
.choice { min-height: 58px; border-radius: 14px; border: 2px solid var(--line); background: #fff; font: inherit; font-weight: 700; font-size: 1.08rem; cursor: pointer; padding: 10px 14px; color: var(--ink); touch-action: manipulation; }
.choice.ok { background: var(--ok); border-color: var(--ok); color: #fff; }
.choice.ng { background: var(--ng); border-color: var(--ng); color: #fff; }
.choice[disabled] { cursor: default; }
.fb { min-height: 1.8em; margin: 12px 0 0; font-weight: 700; text-align: center; }
.fb.ok { color: var(--ok); } .fb.ng { color: var(--ng); }
.result { text-align: center; }
.result .big { font-size: 2.6rem; font-weight: 800; margin: 4px 0; }
.result .stamp { width: 110px; height: 110px; margin: 6px auto; border-radius: 50%; border: 5px solid var(--jp); color: var(--jp); display: grid; place-items: center; font-weight: 800; font-size: 1.05rem; transform: rotate(-8deg); animation: stamp .5s ease-out; line-height: 1.3; white-space: pre-line; text-align: center; }
@keyframes stamp { from { transform: scale(2) rotate(-8deg); opacity: 0; } to { transform: rotate(-8deg); opacity: 1; } }
.miss { text-align: left; padding-left: 1.2em; }

/* 年表ならべ */
.sort { display: grid; gap: 10px; }
.sort button { text-align: left; min-height: 58px; }
.sort .n { display: inline-grid; place-items: center; width: 30px; height: 30px; border-radius: 50%; background: var(--line); margin-right: 10px; font-weight: 800; flex: none; }
.sort button.picked .n { background: var(--gold); color: #1d1608; }
.sort button { display: flex; align-items: center; }
.sort .y { margin-left: auto; padding-left: 10px; color: var(--sub); white-space: nowrap; font-weight: 700; }

/* どっちが先 */
.pair { display: grid; gap: 12px; }
.pair .choice { min-height: 96px; font-size: 1.05rem; }
.timer { font-variant-numeric: tabular-nums; font-weight: 800; color: var(--jp); white-space: nowrap; }

/* 会話 */
.chat { display: flex; flex-direction: column; gap: 12px; margin: 0 0 14px; }
.msg { max-width: 88%; padding: 12px 15px; border-radius: 18px; line-height: 1.7; white-space: pre-wrap; }
.msg.a { background: var(--card); border: 1px solid var(--line); align-self: flex-start; border-bottom-left-radius: 6px; }
.msg.u { background: var(--night); color: #f7f1e5; align-self: flex-end; border-bottom-right-radius: 6px; }
.msg.sys { align-self: center; background: transparent; color: var(--sub); font-size: .88rem; text-align: center; max-width: 100%; }
.msg .who { display: block; font-size: .78rem; font-weight: 800; color: var(--sub); margin-bottom: 2px; }
.typing::after { content: "…"; animation: blink 1s steps(2) infinite; }
@keyframes blink { 50% { opacity: 0; } }
.chips { display: flex; flex-wrap: wrap; gap: 8px; margin: 0 0 12px; justify-content: center; }
.chip { border: 2px solid var(--line); background: #fff; border-radius: 999px; padding: 8px 14px; font: inherit; font-size: .92rem; cursor: pointer; color: var(--ink); min-height: 44px; }
.composer { display: grid; grid-template-columns: 1fr auto; gap: 8px; position: sticky; bottom: 0; background: var(--paper); padding: 10px 0 12px; }
.composer textarea { font: inherit; border: 2px solid var(--line); border-radius: 14px; padding: 10px 12px; resize: none; min-height: 52px; background: #fff; color: var(--ink); }
.composer .btn { min-height: 52px; padding: 0 18px; }
.left { text-align: center; color: var(--sub); font-size: .88rem; margin: 0; }

.notice { background: #fff6dc; border: 1px solid #ecd9a2; border-radius: 12px; padding: 12px 14px; }
.error { color: var(--ng); font-weight: 700; }
.center { text-align: center; }
table.tl { width: 100%; border-collapse: collapse; }
.tl-list { list-style: none; padding: 0; margin: 0; display: grid; gap: 8px; }
.tl-list li { background: var(--card); border: 1px solid var(--line); border-radius: 12px; padding: 10px 14px; display: grid; grid-template-columns: 6.5em 1fr; gap: 10px; }
.tl-list .y { font-weight: 800; color: var(--jp); white-space: nowrap; }
.w-course .tl-list .y { color: var(--w); }
@media (max-width: 400px) { .tl-list li { grid-template-columns: 1fr; gap: 0; } }

footer { background: #ece3d2; color: var(--sub); font-size: .88rem; padding: 22px 0 30px; }
footer .links { display: flex; flex-wrap: wrap; gap: 6px 16px; justify-content: center; }
footer p { margin: 8px 0; text-align: center; }
.sr { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); }

/* 答え合わせのときの年号は白で読めるように */
.choice.ok .y, .choice.ng .y { color: #fff; }
.composer .btn { border-radius: 14px; }
/* トップの人物一覧(スマホは2列のコンパクト表示) */
.people { display: grid; gap: 10px; grid-template-columns: repeat(auto-fill, minmax(200px, 1fr)); margin: 0 0 16px; }
.people a { display: grid; grid-template-columns: 44px 1fr; gap: 10px; align-items: center; background: var(--card); border: 1px solid var(--line); border-radius: 14px; padding: 10px 12px; text-decoration: none; color: var(--ink); }
.people .avatar { width: 44px; height: 44px; font-size: 1.15rem; }
.people b { display: block; line-height: 1.35; font-size: .98rem; }
.people small { display: block; color: var(--sub); font-size: .8rem; line-height: 1.35; }
@media (max-width: 560px) { .people { grid-template-columns: 1fr 1fr; } .people a { grid-template-columns: 1fr; justify-items: center; text-align: center; gap: 6px; } }
main.wrap { padding-top: 20px; padding-bottom: 48px; }
.people b, .people small { text-wrap: balance; }
.people b { white-space: nowrap; font-size: min(.9rem, 3.9vw); }
.people { grid-template-columns: repeat(auto-fill, minmax(190px, 1fr)); }
.people a { grid-template-columns: 1fr; justify-items: center; text-align: center; gap: 6px; padding: 10px 6px; }
.choice, .choice span { text-wrap: pretty; }
