/* 五十音はやよみ。色は謎解きRTAにそろえる */
:root {
  --bg: #f7f4ee;
  --panel: #ffffff;
  --text: #2b2824;
  --muted: #8a847b;
  --accent: #e5483d;
  --border: #e3ddd2;
  --grid: #cfc7b9;
  --radius: 6px;
}

* { box-sizing: border-box; }
[hidden] { display: none !important; }
html, body { margin: 0; }
body {
  background: var(--bg);
  color: var(--text);
  font-family: "Hiragino Sans", "Noto Sans JP", system-ui, sans-serif;
  line-height: 1.8;
  min-height: 100vh;
}
button { font: inherit; color: inherit; }

/* 画面の切り替え */
.screen { display: none; }
body[data-screen="top"] .top-screen,
body[data-screen="play"] .play-screen,
body[data-screen="result"] .result-screen { display: block; }

/* ---------- ボタン ---------- */
.btn {
  background: var(--accent);
  color: #fff;
  border: 0;
  border-radius: var(--radius);
  padding: 0.5em 1.4em;
  font-weight: 700;
  cursor: pointer;
  text-decoration: none;
  display: inline-block;
  text-align: center;
}
@media (hover: hover) { .btn:hover { filter: brightness(1.06); } }
.btn.big { font-size: 1.15rem; padding: 0.7em 2.4em; }
.btn.small { font-size: 0.9rem; padding: 0.35em 1.6em; }
.btn.ghost { background: transparent; border: 1px solid var(--muted); color: var(--muted); }
.btn.dark { background: var(--text); }
.link { background: none; border: 0; color: var(--muted); text-decoration: underline; cursor: pointer; font-size: 0.85rem; }

/* ---------- 説明 ---------- */
.back-top {
  position: absolute;
  top: 12px;
  left: 12px;
  font-size: 0.8rem;
  color: var(--muted);
  border: 1px solid var(--border);
  border-radius: 999px;
  padding: 0.1em 0.8em;
  text-decoration: none;
}
.hero { text-align: center; padding: 72px 16px 24px; }
.sub { color: var(--muted); letter-spacing: 0.3em; font-size: 0.8rem; margin: 0; }
.logo { font-size: clamp(2.2rem, 10vw, 4.2rem); margin: 0.1em 0 0.3em; line-height: 1.2; letter-spacing: 0.04em; }
.accent { color: var(--accent); }
.catch { margin: 0; font-size: 1.05rem; font-weight: 700; letter-spacing: 0.12em; }
.doc { max-width: 640px; margin: 0 auto; padding: 0 16px 80px; }
.doc section { margin: 48px 0; }
.doc h2 { font-size: 1.2rem; letter-spacing: 0.15em; text-align: center; margin: 0 0 0.8em; }
.doc h2 small { display: block; font-size: 0.7rem; color: var(--muted); letter-spacing: 0.2em; font-weight: 400; }
.doc ul { padding-left: 1.2em; }
.doc strong { background: linear-gradient(transparent 60%, rgba(229, 72, 61, 0.18) 60%); }
.example { margin: 16px auto 4px; max-width: 420px; }
.example-a { text-align: center; margin: 0 0 16px; font-size: 0.95rem; }
.start { text-align: center; display: flex; flex-direction: column; align-items: center; gap: 12px; margin: 40px 0; }
.start .btn { width: 240px; }
.best-line { margin: 0; color: var(--muted); font-size: 0.9rem; }
.best-line b { color: var(--text); font-size: 1.2rem; }
.credit { text-align: center; color: var(--muted); font-size: 0.85rem; margin: 0.3em 0; }

/* ---------- 50音表 ----------
   11列（右端が あ行）＋右に段の見出し、上に行の見出し */
.gojuon {
  --c: min(calc((100vw - 32px) / 12), 46px);
  display: grid;
  grid-template-columns: repeat(11, var(--c)) calc(var(--c) * 0.7);
  grid-auto-rows: var(--c);
  grid-template-rows: calc(var(--c) * 0.7);
  justify-content: center;
  gap: 2px;
  user-select: none;
}
.gojuon .head {
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: calc(var(--c) * 0.42);
  color: var(--muted);
  font-weight: 700;
}
.gojuon .cell {
  position: relative;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 1px;
  background: var(--panel);
  border: 1px solid var(--grid);
  line-height: 1;
}
.gojuon .cell.none { background: transparent; border-color: transparent; }
.gojuon .kana {
  position: absolute;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: calc(var(--c) * 0.5);
  color: var(--text);
}
/* 数字の入ったマスでは字を左上に小さく寄せる */
.gojuon .cell.hit .kana {
  inset: 2px auto auto 3px;
  display: block;
  font-size: calc(var(--c) * 0.26);
  color: var(--muted);
}
.gojuon .n {
  position: relative;
  font-weight: 800;
  color: var(--accent);
  font-size: calc(var(--c) * 0.52);
  font-variant-numeric: tabular-nums;
}
.order {
  display: flex;
  justify-content: center;
  flex-wrap: wrap;
  gap: 0.15em 0.35em;
  margin-top: 14px;
  min-height: 1.4em;
  font-size: clamp(1.8rem, 8vw, 2.4rem);
  font-weight: 700;
  color: var(--accent);
  line-height: 1.2;
}
.order .o { display: inline-flex; align-items: flex-start; }
.order small { font-size: 0.6em; line-height: 1; margin-left: -0.05em; }
.example .order { font-size: 1.6rem; }
/* Lv.1 は見出しなし。Lv.2 は字を消して見出しだけ。Lv.3 は見出しも消す */
.gojuon.lv1 .head, .gojuon.lv3 .head { visibility: hidden; }
.gojuon.lv2 .kana, .gojuon.lv3 .kana { display: none !important; }

/* ---------- プレイ ---------- */
.bar {
  position: sticky;
  top: 0;
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 8px;
  padding: 10px 16px;
  background: rgba(247, 244, 238, 0.92);
  z-index: 5;
}
.back {
  font-size: 0.8rem;
  color: var(--muted);
  background: none;
  border: 1px solid var(--border);
  border-radius: 999px;
  padding: 0.1em 0.8em;
  cursor: pointer;
}
.meters { display: flex; gap: 14px; }
.meter { display: flex; flex-direction: column; align-items: center; line-height: 1; }
.meter small { font-size: 0.65rem; color: var(--muted); margin-bottom: 4px; }
.num { font-size: clamp(1.4rem, 6vw, 1.9rem); font-weight: 800; font-variant-numeric: tabular-nums; min-width: 1.3em; text-align: center; }
body.hurry #time { color: var(--accent); }

.stage { max-width: 640px; margin: 0 auto; padding: 16px 16px 40px; }
.board-wrap { position: relative; padding: 8px 0 16px; }
.board-wrap #board.ok .gojuon { animation: ok 0.25s; }
@keyframes ok { from { opacity: 0.3; transform: scale(0.98); } to { opacity: 1; transform: none; } }
.countdown {
  position: absolute;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 4rem;
  font-weight: 800;
  color: var(--accent);
  background: rgba(247, 244, 238, 0.85);
}

.answer-area { display: flex; flex-direction: column; align-items: center; gap: 12px; }
.answer-input {
  width: min(100%, 300px);
  background: var(--panel);
  border: 1px solid var(--border);
  color: var(--text);
  padding: 0.5em 0.8em;
  border-radius: var(--radius);
  font-size: 1.1rem;  /* 16px 未満だと iPhone で入力時に拡大されてしまう */
  text-align: center;
}
.answer-input:focus { outline: 1px solid var(--muted); }
.shake { animation: shake 0.3s; }
@keyframes shake { 25% { translate: -4px 0; } 75% { translate: 4px 0; } }

/* ---------- 結果 ---------- */
.result { text-align: center; padding-top: 56px; }
.r-score { margin: 8px 0 0; font-size: 1.2rem; font-weight: 700; }
.r-score b { font-size: 4rem; color: var(--accent); margin-right: 0.1em; }
.r-detail { margin: 0; color: var(--muted); }
.r-best { margin: 4px 0 0; font-weight: 700; }
