:root {
  --bg: #faf5ed; --card: #fffdf8; --ink: #493f36; --sub: #746758; --line: #d8cfc2;
  --brand: #e675a0; --brand-soft: #fbe7ef; --brand-ink: #84334f;
  --accent: var(--brand-ink); --accent-soft: var(--brand-soft); --sel: #b65378; --sel-soft: var(--brand-soft);
  --green: #dce9d5; --purple: #e7ddef; --gold: #e6c979;
  --hl: #fff0c2; --back: #6b5b95; --back2: #85769f; --ok: #2f8a4c; --ng: #c0392b;
}
* { box-sizing: border-box; }
[hidden] { display: none !important; }
/* 共通書体（screens.md 1節）。共通サブセットはひらがな・カタカナ・英数のみ（漢字なし）。
   漢字の多いおとなモードは、1文の中で書体が混ざらないよう端末の丸ゴシックを使う【想定】。 */
@font-face { font-family: "M PLUS Rounded 1c"; font-weight: 400; font-display: swap;
  src: url("../assets/fonts/MPLUSRounded1c-Regular.subset.woff2") format("woff2"); }
@font-face { font-family: "M PLUS Rounded 1c"; font-weight: 700; font-display: swap;
  src: url("../assets/fonts/MPLUSRounded1c-Bold.subset.woff2") format("woff2"); }
:root { --font-family: "M PLUS Rounded 1c", "Hiragino Maru Gothic ProN", "Yu Gothic UI", "Meiryo", sans-serif;
  --font-family-kanji: "Hiragino Maru Gothic ProN", "Yu Gothic UI", "Meiryo", sans-serif; }
body { margin: 0; background: var(--bg); color: var(--ink); font-family: var(--font-family); line-height: 1.7; }
body.adult { font-family: var(--font-family-kanji); }
button, select, input { font-family: inherit; }
main { position: relative; max-width: 620px; margin: 0 auto; padding: 8px 16px max(16px, env(safe-area-inset-bottom)); min-height: 100svh; }
h1 { font-size: 1.5rem; margin: 8px 0 0; } h1 small { font-size: .7rem; color: var(--sub); font-weight: normal; }
h2 { font-size: 1.2rem; margin: 8px 0 12px; text-align: center; }
.lead { color: var(--sub); margin: 25px 0 29px; font-size: 15px; line-height: 24px; text-align: center; }
.panel { background: var(--card); border: 1px solid var(--line); border-radius: 14px; padding: 12px 14px; margin-bottom: 12px; }
.panel.small { font-size: .85rem; }
.panel.small summary { cursor: pointer; font-weight: bold; }
.row { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; margin: 8px 0; }
.row > .lbl { width: 100%; font-size: .8rem; color: var(--sub); margin-bottom: -4px; }
.seg { display: flex; width: 100%; gap: 4px; padding: 4px; border: 0; border-radius: 16px; background: #eae2d6; }
.seg button { flex: 1; min-width: 0; min-height: 44px; border: 0; border-radius: 12px; background: transparent; padding: 8px 4px; font: inherit; font-weight: 700; color: var(--ink); cursor: pointer; }
.seg button[aria-pressed="true"] { background: #fff; color: var(--brand-ink); box-shadow: 0 1px 3px #493f3620; }
.btn { font: inherit; font-weight: 700; border: 0; background: var(--purple); border-radius: 18px; padding: 12px; cursor: pointer; color: #4e3869; min-height: 54px; }
.btn.ok { background: var(--gold); color: #503e17; }
.btn.dark { background: var(--purple); color: #4e3869; }
.btn.green { background: var(--green); color: #30462e; }
.btn.subtle, #back, #stop { background: #eae2d6; color: #6b5a49; }
.btn.ghost { min-height: 36px; padding: 4px 12px; font-size: .85rem; }
.btn.big { font-size: 1.2rem; }
.btn:disabled { opacity: .4; cursor: default; }
button.main { display: block; width: 100%; min-height: 60px; background: var(--green); color: #30462e; border: 0; font: inherit; font-size: 18px; font-weight: bold; padding: 12px; border-radius: 18px; margin: 10px 0 0; cursor: pointer; }
.btns { display: flex; gap: 8px; flex-wrap: wrap; margin-top: 12px; }
.btns .btn { flex: 1; min-width: 6em; }
.top { display: flex; justify-content: space-between; align-items: center; }
.who { font-size: .9rem; color: var(--sub); }
footer.title-footer { text-align: center; color: var(--sub); font-size: .75rem; margin-top: 20px; }
select { font: inherit; padding: 6px; border-radius: 8px; border: 1px solid var(--line); max-width: 100%; }
input[type=range] { flex: 1; }
table { width: 100%; border-collapse: collapse; font-size: .78rem; margin-top: 6px; }
td, th { border-bottom: 1px solid var(--line); padding: 3px; text-align: left; }
.yes { color: var(--ok); font-weight: bold; } .no { color: var(--ng); }
pre.log { background: var(--ink); color: var(--bg); font-size: .7rem; padding: 8px; border-radius: 8px; max-height: 200px; overflow: auto; white-space: pre-wrap; }

/* なまえ */
.names { display: grid; grid-template-columns: repeat(auto-fill, minmax(96px, 1fr)); gap: 8px; }
.names button { font: inherit; font-size: 1.15rem; font-weight: 700; min-height: 58px; padding: 12px 4px; border-radius: 16px; border: 2px solid transparent; background: var(--purple); cursor: pointer; color: #4e3869; }
.names button.cand { border-color: var(--sel); background: var(--brand-soft); color: var(--brand-ink); animation: pulse 1s infinite; }

/* ばん */
.board { display: grid; gap: 8px; margin-top: 8px; }
.brow { display: grid; grid-template-columns: 48px repeat(var(--cols), minmax(0, 1fr)); gap: 6px; align-items: stretch; padding: 4px; border-radius: 12px; }
.brow.active { background: var(--hl); }
.brow.done { opacity: .85; }
.rlabel { display: flex; flex-direction: column; align-items: center; justify-content: center; font-size: .72rem; color: var(--sub); line-height: 1.2; text-align: center; }
.rlabel .ico { font-size: 1.3rem; }
.cell { position: relative; width: 100%; min-width: 0; aspect-ratio: 1; border-radius: 10px; border: 2px solid transparent; background: linear-gradient(145deg, var(--back), var(--back2));
  color: #fff; font: inherit; font-size: 1.4rem; font-weight: bold; cursor: pointer; display: flex; align-items: center; justify-content: center; padding: 0; }
.cell:disabled { cursor: default; }
.brow:not(.active) .cell:not(.open) { filter: saturate(.6); }
.cell.cand { border-color: var(--accent); box-shadow: 0 0 0 3px var(--accent-soft); animation: pulse 1s infinite; }
.cell.cand.unsel { border-style: dashed; }
.cell.sel { border-color: var(--sel); box-shadow: 0 0 0 3px var(--sel-soft); }
.cell .badge { position: absolute; top: -6px; right: -6px; background: var(--sel); color: #fff; border-radius: 999px; font-size: .7rem; min-width: 20px; height: 20px; line-height: 20px; }
.cell .badge.omakase { background: var(--accent); padding: 0 5px; font-size: .6rem; right: auto; left: 50%; transform: translateX(-50%); white-space: nowrap; }
.cell.open { background: #fff; color: var(--ink); border-color: var(--line); flex-direction: column; animation: flip .5s both; animation-delay: var(--d, 0s); }
.cell.open.sel, .cell.open.omk { border-color: var(--sel); }
.cell.open.omk { border-color: var(--accent); }
.cell.open.dim { opacity: .35; animation: none; background: linear-gradient(145deg, var(--back), var(--back2)); }
.cell .emo { font-size: 1.9rem; line-height: 1; }
.cell .word { font-size: .62rem; font-weight: normal; line-height: 1.2; margin-top: 2px; padding: 0 2px; word-break: break-all; }
body.adult .cell .emo { font-size: 1.5rem; }
body.adult .cell .word { font-size: .52rem; }
.guide { text-align: center; margin: 12px auto 0; }
.guide .words { display: block; font-size: .78rem; color: var(--sub); }
@keyframes pulse { 50% { box-shadow: 0 0 0 6px var(--accent-soft); } }
@keyframes flip { 0% { transform: rotateY(90deg); } 100% { transform: rotateY(0); } }

/* おはなし */
.picks { list-style: none; padding: 0; margin: 14px 0 6px; font-size: .85rem; color: var(--sub); }
.picks li.reading { background: var(--hl); border-radius: 6px; }
ol.story { list-style: none; padding: 0; margin: 0; background: var(--card); border: 1px solid var(--line); border-radius: 14px; padding: 8px; }
ol.story li { padding: 8px; border-radius: 8px; }
ol.story li.shift { color: var(--sub); }
ol.story li.reading { background: var(--hl); }
body.kids ol.story li { font-size: 1.2rem; line-height: 1.9; }
.toast { position: fixed; left: 50%; bottom: 20px; transform: translateX(-50%); background: var(--ink); color: #fff; padding: 8px 14px; border-radius: 999px; font-size: .85rem; opacity: 0; transition: opacity .2s; pointer-events: none; }
.toast.show { opacity: 1; }

/* マイク（共通部品 mic-toggle と組み合わせる） */
#mic-notice { background: var(--card); border: 1px solid var(--line); border-radius: 12px; padding: 6px 8px; font-size: .75rem; display: flex; gap: 6px; align-items: center; flex-wrap: wrap; margin: 8px 0; }
.mic-state .mic { width: 26px; height: 26px; }
.mic-state .mic .body { fill: currentColor; }
.mic-state .mic .slash { display: none; stroke-width: 2.5; }
.mic-state.listening { background: #f2e2a8; color: #806121; }
.mic-state.restarting { opacity: .6; }
.mic-state.denied { background: #f3d7d3; color: var(--ng); }
.top { justify-content: center; margin: 8px 0; }
.heard { text-align: center; font-size: .8rem; color: var(--sel); min-height: 1.3em; margin: 2px 0 0; }
.names + .guide .words, #name-guide .words { display: block; font-size: .78rem; color: var(--sub); }
.intro { margin: 10px 0 6px; font-weight: bold; color: var(--accent); }
.story-version-label { margin: 14px 0 0; font-size: 14px; font-weight: 700; color: var(--sub); }
.switch-caption { margin: 16px 0 8px; text-align: center; color: var(--sub); font-size: 14px; line-height: 1.6; }
.story-versions { display: flex; gap: 4px; padding: 4px; border-radius: 16px; background: #eae2d6; }
.story-versions button { flex: 1; min-width: 0; min-height: 60px; padding: 8px 4px; border: 0; border-radius: 12px; background: transparent; color: var(--ink); font: inherit; font-size: 14px; font-weight: 700; line-height: 1.5; cursor: pointer; }
.story-versions button span { display: block; white-space: nowrap; }
.story-versions button[aria-pressed="true"] { background: #fff; color: var(--brand-ink); box-shadow: 0 1px 3px #493f3620; }
#voice { width: 100%; padding: 10px 8px; border-radius: 10px; background: #fff; }
#voice:disabled { opacity: .5; }

/* トランプ風のカード（2026-09-27 発案者指示）：行ごとに ♠♥♦♣、数字の札のように数だけ印を並べる */
.brow { --suit: #2f2a24; }
.brow.red { --suit: #c8283c; }
.rlabel .suit { color: var(--suit); font-size: 1.6rem; line-height: 1.1; }
.cell { aspect-ratio: 5 / 7; background: #fffdf8; color: var(--suit); border: 2px solid var(--line);
  box-shadow: 0 1px 3px rgba(47,42,36,.18), inset 0 0 0 3px #fffdf8, inset 0 0 0 4px var(--line); }
.brow:not(.active) .cell:not(.open) { filter: none; opacity: .75; }
.brow.active .cell:not(:disabled) { box-shadow: 0 2px 6px rgba(47,42,36,.25), inset 0 0 0 3px #fffdf8, inset 0 0 0 4px var(--line); }
.cell .idx { position: absolute; top: 3px; left: 5px; font-size: .72rem; line-height: 1.05; font-weight: bold; text-align: center; }
.cell .pips { position: absolute; inset: 18% 16% 10% 22%; display: grid; grid-template: repeat(3, 1fr) / repeat(2, 1fr); place-items: center; font-size: 1rem; line-height: 1; }
.cell .pips.p1 i { grid-area: 1 / 1 / 4 / 3; font-size: 2rem; }
.cell .pips.p2 i:nth-child(1) { grid-area: 1 / 1 / 2 / 3; } .cell .pips.p2 i:nth-child(2) { grid-area: 3 / 1 / 4 / 3; transform: rotate(180deg); }
.cell .pips.p3 i:nth-child(1) { grid-area: 1 / 1 / 2 / 3; } .cell .pips.p3 i:nth-child(2) { grid-area: 2 / 1 / 3 / 3; } .cell .pips.p3 i:nth-child(3) { grid-area: 3 / 1 / 4 / 3; transform: rotate(180deg); }
.cell .pips.p4 i:nth-child(1) { grid-area: 1 / 1; } .cell .pips.p4 i:nth-child(2) { grid-area: 1 / 2; }
.cell .pips.p4 i:nth-child(3) { grid-area: 3 / 1; transform: rotate(180deg); } .cell .pips.p4 i:nth-child(4) { grid-area: 3 / 2; transform: rotate(180deg); }
.cell .pips.p5 i:nth-child(1) { grid-area: 1 / 1; } .cell .pips.p5 i:nth-child(2) { grid-area: 1 / 2; } .cell .pips.p5 i:nth-child(3) { grid-area: 2 / 1 / 3 / 3; }
.cell .pips.p5 i:nth-child(4) { grid-area: 3 / 1; transform: rotate(180deg); } .cell .pips.p5 i:nth-child(5) { grid-area: 3 / 2; transform: rotate(180deg); }
.cell .pips i { font-style: normal; }
body.adult .cell .pips { font-size: .8rem; } body.adult .cell .pips.p1 i { font-size: 1.6rem; }
.cell.sel { border-color: var(--sel); box-shadow: 0 0 0 3px var(--sel-soft); background: #fcf2f6; }
.cell.open { background: #fffdf8; color: var(--ink); border-color: var(--line); }
.cell.open .idx { color: var(--suit); font-size: .6rem; }
.cell.open.dim { opacity: .35; background: #fffdf8; color: var(--suit); }
/* めくった札：左上の数字と重ならないよう上をあけ、長い言葉のときは札が縦にのびる */
.cell.open:not(.dim) { aspect-ratio: auto; justify-content: flex-start; padding: 19px 2px 4px; gap: 1px; }
body.adult .cell.open:not(.dim) .emo { font-size: 1.3rem; }

/* ジントリズムのタイトル配置、イロドリズムの戻る導線を継承。共通ファイルは変更しない。 */
button, a { touch-action: manipulation; -webkit-tap-highlight-color: transparent; }
button:focus-visible, a:focus-visible, select:focus-visible, input:focus-visible, summary:focus-visible { outline: 3px solid #7459a8; outline-offset: 3px; }
button:active:not(:disabled) { transform: translateY(1px); }
button:disabled { opacity: .42; cursor: default; }
/* めくった札は操作不可でも鮮明に。選ばなかった札の .dim だけは薄く残す。 */
.cell.open:not(.dim):disabled { opacity: 1; }
.toolbar { display: flex; align-items: center; gap: 8px; min-height: 50px; }
.icon { width: 44px; height: 44px; flex-shrink: 0; padding: 0; display: grid; place-items: center; border: 0; border-radius: 12px; background: #fff; color: #8a5a3c; cursor: pointer; }
.icon svg { width: 25px; height: 25px; fill: none; stroke: currentColor; stroke-width: 2; stroke-linecap: round; stroke-linejoin: round; }
#help-open { margin-left: auto; }
main:has(#s-start:not([hidden])) { padding-inline: 16px; padding-bottom: max(8px, env(safe-area-inset-bottom)); }
#s-start { display: flex; flex-direction: column; min-height: calc(100svh - 58px - max(8px, env(safe-area-inset-bottom))); }
/* 基準SVGは799×196、本作は937×196。文字を同じ高さで見せるため横幅を937/799倍にする。
   画面幅を超える場合だけ object-fit:contain で全体を縮小し、字形を変形させない。 */
#s-start h1 { width: min(446px, 100%); height: 93px; margin: 0 auto; flex-shrink: 0; }
.wordmark { display: block; width: 100%; height: 100%; object-fit: contain; object-position: top; }
.menu-options, .menu-actions, #s-start > .panel { width: min(420px, 100%); margin-inline: auto; }
.menu-options { display: grid; gap: 10px; }
.menu-options .row { margin: 0; gap: 4px; }
.menu-options .lbl { margin: 0; font-size: 12px; }
.menu-actions { margin-top: 16px; }
#s-start > .panel { margin-top: 14px; background: transparent; }
#s-start .title-footer { margin: auto 0 0; padding-top: 20px; font-size: 10px; line-height: 14px; }
#s-name, #s-board { max-width: 520px; margin-inline: auto; }
.voice-options { text-align: center; font-size: 12px; color: var(--sub); line-height: 1.6; margin: 4px 0 0; overflow-wrap: anywhere; }
.voice-options:empty, .guide:empty { display: none; }
/* 読み終わりのマイク再開で案内が現れても、最下部の位置を変えない。 */
#after-guide-words { display: block; min-height: 1.6em; }
.result-actions { display: grid; gap: 10px; margin-top: 14px; }
.help-steps { padding-left: 1.4em; }
.help-steps li { margin-bottom: 12px; }
.menu-help-dialog button { width: 100%; }
.menu-help-dialog .result-actions button { margin: 0; }
.diagnostics { margin: 20px 0 0; font-family: var(--font-family-kanji); overflow-wrap: anywhere; }
.diagnostics table { table-layout: fixed; }
#voice { min-width: 0; min-height: 44px; color: var(--ink); }
.toast { max-width: calc(100% - 24px); text-align: center; z-index: 10; }
.heard:empty { display: none; }
/* 案内・発話候補・聞き取り結果の有無で、下の操作ボタンを動かさない。 */
#guide.voice-guide { min-height: 68px; margin: 6px auto; }
#guide.voice-guide strong { font-size: 18px; }
#guide.voice-guide span { font-size: 16px; }
.voice-guide.is-reading strong { white-space: pre; font-size: 18px; }
/* 意味のまとまりで2行に固定し、括弧だけの折り返しを防ぐ。 */
#board-btns #start { padding-block: 6px; }
#start .action-label, #start .action-detail { display: block; white-space: nowrap; }
#start .action-label { font-size: 18px; line-height: 22px; }
#start .action-detail { font-size: 14px; line-height: 20px; }
#guide-words { display: block; min-height: 48px; font-size: 15px; line-height: 24px; white-space: pre-line; margin: 4px 0 0; }
#s-board:has(#board-btns:not([hidden])) .heard { display: block; min-height: 22px; line-height: 22px; }
#s-board:has(#board-btns[hidden]) #guide-words { display: none; }
@media (max-height: 819px) {
  #s-start h1 { height: 74px; width: min(352px, 100%); }
  .lead { margin: 10px 0 16px; }
  .menu-options { gap: 7px; }
  .menu-actions { margin-top: 8px; }
  button.main { min-height: 48px; }
  #s-start > .panel { margin-top: 10px; }
  #s-start .title-footer { padding-top: 12px; }
}
@media (max-width: 359px) {
  main { padding-inline: 12px; }
  .brow { grid-template-columns: 36px repeat(var(--cols), minmax(0, 1fr)); gap: 5px; }
  .board { gap: 6px; }
  .btns { gap: 6px; }
  .btns .btn { min-width: 0; padding-inline: 8px; font-size: 14px; }
  .cell .pips { font-size: .85rem; }
  .rlabel { font-size: .65rem; }
  .voice-guide strong { font-size: 20px; }
  .voice-guide span { font-size: 14px; }
}
@media (max-height: 700px) {
  .menu-options { grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 8px; }
  .menu-options .row:nth-child(n + 3) { grid-column: 1 / -1; }
  .seg button { min-height: 36px; padding: 6px 3px; font-size: 14px; }
  .brow .cell:not(.open) { aspect-ratio: auto; height: clamp(44px, calc((100svh - 382px) / 4), 76px); }
  .brow .cell:not(.open) .pips { grid-template-rows: repeat(3, minmax(0, 1fr)); font-size: clamp(10px, 1.8svh, 13px); }
  .cell .pips.p1 i { font-size: 1.6rem; }
  .cell .idx { font-size: .65rem; }
  .voice-options { font-size: 11px; }
}
@media (max-height: 620px) {
  #s-start h1 { height: 50px; width: min(239px, 100%); }
  .lead { margin: 4px 0 8px; font-size: 13px; line-height: 21px; }
}
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation: none !important; transition: none !important; scroll-behavior: auto !important; }
}
