:root {
  --ink: #111;
  --paper: #fff;
  --muted: #666;
  --line: #d8d8d8;
  --bg: #f2f2f0;
  --font: 'Yu Gothic', 'Hiragino Sans', 'Noto Sans JP', Meiryo, sans-serif;
}
* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body { margin: 0; background: var(--bg); color: var(--ink); font-family: var(--font); line-height: 1.55; min-height: 100vh; }
button, select, textarea { font: inherit; color: inherit; }
button { cursor: pointer; }
button:focus-visible, select:focus-visible, textarea:focus-visible { outline: 3px solid #1a73e8; outline-offset: 2px; }
[hidden] { display: none !important; }

.top { display: flex; align-items: center; justify-content: space-between; gap: 8px; padding: 8px 12px; background: var(--ink); color: #fff; }
.top h1 { margin: 0; font-size: 16px; letter-spacing: .03em; white-space: nowrap; }
.demo { font-size: 11px; border: 1px solid #fff; padding: 1px 6px; border-radius: 3px; margin-left: 6px; vertical-align: middle; }
.tabs { display: flex; gap: 6px; }
.tabs button { background: transparent; border: 1px solid #fff; color: #fff; border-radius: 999px; padding: 4px 10px; font-weight: 700; font-size: 13px; white-space: nowrap; }
.tabs button[aria-selected="true"] { background: #fff; color: var(--ink); }

main { max-width: 1040px; margin: 0 auto; padding: 10px 10px 8px; }
h2 { font-size: 18px; margin: 0 0 8px; }
h3 { font-size: 14px; margin: 18px 0 8px; }

.panel { background: var(--paper); border: 2px solid var(--ink); border-radius: 12px; padding: 18px 16px; }
.setup-field { display: flex; flex-direction: column; gap: 6px; margin: 14px 0; font-size: 14px; }
.setup-field select { border: 2px solid var(--ink); border-radius: 8px; padding: 9px 10px; background: var(--paper); }

.btn { border: 2px solid var(--ink); border-radius: 10px; padding: 10px 20px; font-weight: 800; font-size: 15px; min-width: 160px; background: var(--paper); }
.btn.primary { background: var(--ink); color: #fff; }
.btn:disabled { opacity: .35; cursor: not-allowed; }
.btn:active:not(:disabled) { transform: translateY(1px); }
.link { display: block; margin: 14px auto 0; background: none; border: 0; color: var(--muted); text-decoration: underline; font-size: 13px; }
.actions { display: flex; justify-content: center; margin-top: 8px; position: sticky; bottom: 0; padding: 8px 0 10px;
  background: linear-gradient(to bottom, rgba(242,242,240,0), var(--bg) 35%); z-index: 5; }

.status { text-align: center; font-size: 12px; color: var(--muted); font-weight: 700; }
.step { margin: 4px 0 8px; padding: 7px 10px; background: var(--ink); color: #fff; border-radius: 8px; font-size: 13px; font-weight: 700; }

/* ---- 悩み札(印刷物と同じ構成。悩み面は細枠。画面に場の10枚を収めるためコンパクトに) ---- */
.problem { background: var(--paper); border: 2px solid var(--ink); border-radius: 12px; padding: 8px 10px 6px; box-shadow: 0 3px 10px rgba(0, 0, 0, .14); }
.bar { display: flex; justify-content: space-between; align-items: center; gap: 8px; background: var(--ink); color: #fff; font-weight: 800; font-size: 13px; padding: 4px 9px; border-radius: 3px; }
.pchip { flex: 1; font-size: 12px; font-weight: 700; color: #ddd; }
.body { margin: 0; padding: 7px 2px 4px; font-weight: 800; font-size: clamp(17px, 4.8vw, 22px); line-height: 1.4;
  word-break: auto-phrase; line-break: strict; overflow-wrap: anywhere; text-wrap: balance; }

/* ---- 場の解決策札(10枚を一覧できる大きさ。裏面=二重の太枠) ---- */
.field-area h3 { margin: 10px 0 6px; font-size: 13px; }
.field { list-style: none; padding: 0; margin: 0; display: grid; gap: 6px; grid-template-columns: repeat(2, 1fr); }
.fcard { width: 100%; height: 100%; text-align: left; background: var(--paper); border: 4px double var(--ink); border-radius: 8px; padding: 3px 6px 5px; display: flex; flex-direction: column; gap: 2px; }
.fcard .head { display: flex; justify-content: space-between; align-items: center; gap: 4px; min-height: 17px; }
.fcard .meta { font-size: 11px; font-weight: 800; color: var(--muted); display: inline-flex; gap: 4px; align-items: baseline; }
.fcard .cat { display: none; }
.fcard .txt { font-size: clamp(12px, 3.35vw, 14px); font-weight: 700; line-height: 1.35; word-break: auto-phrase; line-break: strict; text-wrap: balance; }
.fcard:not(:disabled):hover { background: #f7f7f7; }
.fcard.selected { background: var(--ink); color: #fff; }
.fcard.selected .meta { color: #ccc; }
.fcard.taken { background: #f0f0f0; }
.fcard.win { background: var(--paper); border-color: #1a73e8; box-shadow: 0 0 0 3px #1a73e8 inset; }
.fcard:disabled { cursor: default; }
.tags { display: inline-flex; gap: 3px; }
.tag { font-size: 10px; font-weight: 800; line-height: 1.5; padding: 0 6px; border-radius: 999px; border: 1.5px solid var(--ink); background: var(--paper); color: var(--ink); white-space: nowrap; }
.tag.me { background: var(--ink); color: #fff; }
.fcard.selected .tag.me { background: #fff; color: var(--ink); }
.tag.win { background: #1a73e8; color: #fff; border-color: #1a73e8; }
.tag.new { background: #fff3b0; }
.tag.back { border-style: dashed; color: var(--muted); border-color: var(--muted); }

.explain { margin-top: 8px; }
.explain label { display: block; font-size: 13px; font-weight: 700; margin-bottom: 6px; }
.explain textarea { width: 100%; font-size: 14px; border: 2px solid var(--ink); border-radius: 8px; padding: 9px 10px; resize: vertical; }

.result { margin-top: 8px; padding: 10px 12px; background: var(--paper); border: 2px solid #1a73e8; border-radius: 10px; }
.res-head { margin: 0 0 4px; font-weight: 800; font-size: 16px; }
.res-line { margin: 0 0 8px; font-weight: 700; font-size: 15px; }
.res-reason { margin: 0 0 8px; font-size: 13px; color: #333; }
.res-note { margin: 0; font-size: 12px; color: var(--muted); }

.scores { margin-top: 22px; }
.score-list { list-style: none; padding: 0; margin: 0; display: flex; flex-direction: column; gap: 6px; }
.score-list li { display: flex; justify-content: space-between; border: 1.5px solid var(--ink); border-radius: 8px; padding: 7px 12px; background: var(--paper); font-weight: 700; font-size: 14px; }
.score-list li.me { background: var(--ink); color: #fff; }
.won { margin: 0 0 12px; padding-left: 18px; font-size: 14px; }
.note { font-size: 12px; color: var(--muted); }

/* ---- ルール ---- */
.rules ol { padding-left: 20px; margin: 0; }
.rules li { margin: 4px 0; font-size: 14px; }

/* ---- カード一覧(表裏) ---- */
.hint { text-align: center; color: var(--muted); font-size: 13px; margin: 4px 0 10px; }
.chips { display: flex; flex-wrap: wrap; gap: 6px; justify-content: center; }
.chip-btn { background: var(--paper); border: 1.5px solid var(--ink); border-radius: 999px; padding: 5px 12px; font-size: 13px; font-weight: 700; }
.chip-btn[aria-pressed="true"] { background: var(--ink); color: #fff; }
.grid { list-style: none; padding: 0; margin: 12px 0 0; display: grid; gap: 10px; grid-template-columns: repeat(auto-fill, minmax(260px, 1fr)); }
.pair { display: flex; flex-direction: column; background: var(--paper); border: 1.5px solid var(--ink); border-radius: 10px; overflow: hidden; }
.side { padding: 8px 10px; display: flex; flex-direction: column; gap: 3px; }
.side.back { border-top: 4px double var(--ink); background: #fafafa; }
.side .meta { font-size: 11px; font-weight: 800; color: var(--muted); }
.side .txt { font-size: 13px; font-weight: 700; line-height: 1.45; word-break: auto-phrase; line-break: strict; }

.page-foot { max-width: 720px; margin: 20px auto 28px; padding: 0 16px; font-size: 11px; color: var(--muted); text-align: center; }

@media (min-width: 520px) { .field { grid-template-columns: repeat(5, 1fr); gap: 8px; } .fcard .cat { display: inline; font-weight: 700; } .fcard .txt { font-size: 14px; } }
@media (min-width: 900px) { .fcard .txt { font-size: 15px; } .body { font-size: 24px; } }

/* ---- 2人用デモ: 役の表示・悩みの山・親の判断 ---- */
.statusrow { display: flex; align-items: center; justify-content: space-between; gap: 8px; }
.statusrow .status { flex: 1; text-align: left; }
.link-btn { background: none; border: 1.5px solid var(--ink); border-radius: 999px; padding: 2px 10px; font-size: 12px; font-weight: 700; }
.step { display: flex; align-items: center; gap: 8px; }
.step .role { flex: none; font-size: 12px; font-weight: 800; padding: 1px 9px; border-radius: 999px; background: #fff; color: var(--ink); }
.step .role.parent { background: #fff3b0; }
.step .steptext { flex: 1; }
.roles { padding-left: 20px; margin: 8px 0; font-size: 14px; }
.roles li { margin: 3px 0; }
.check { display: flex; align-items: center; gap: 8px; margin: 10px 0 14px; font-size: 14px; }
.check input { width: 18px; height: 18px; }
.pile { display: flex; align-items: center; gap: 12px; margin: 4px 0 8px; }
.pile-card { flex: none; width: 76px; aspect-ratio: 59 / 86; border: 2px solid var(--ink); border-radius: 8px; background: repeating-linear-gradient(45deg, #fff, #fff 6px, #eee 6px, #eee 12px);
  display: flex; align-items: center; justify-content: center; font-size: 12px; font-weight: 800; box-shadow: 3px 3px 0 var(--ink); }
.pile p { margin: 0; font-size: 13px; color: var(--muted); }
.judge { margin-top: 8px; padding: 10px 12px; background: var(--paper); border: 2px solid var(--ink); border-radius: 10px; }
.judge-head { margin: 0 0 4px; font-size: 12px; font-weight: 800; color: var(--muted); }
.judge-text { margin: 0; font-size: 14px; font-weight: 700; line-height: 1.5; }
.actions { gap: 10px; flex-direction: row-reverse; }   /* 2つのボタン(A/B)は、Aが左・Bが右に並ぶ */
.btn.secondary { background: var(--paper); }

/* ---- チュートリアル(tutorial.js) ---- */
.tut { position: fixed; inset: 0; z-index: 1000; pointer-events: none; }
.tut-dim { position: absolute; inset: 0; background: rgba(0, 0, 0, .6); }
.tut-block { position: absolute; inset: 0; background: transparent; pointer-events: auto; }
.tut-hole { position: absolute; border-radius: 10px; outline: 3px solid #fff3b0; box-shadow: 0 0 0 100vmax rgba(0, 0, 0, .6); pointer-events: none; transition: all .2s ease; }
.tut-tip { position: fixed; left: 50%; transform: translateX(-50%); width: min(440px, calc(100vw - 20px)); background: #fff; color: var(--ink);
  border: 3px solid var(--ink); border-radius: 12px; padding: 10px 12px 10px; box-shadow: 0 8px 24px rgba(0, 0, 0, .35); pointer-events: auto; }
.tut-tip.center { top: 50%; transform: translate(-50%, -50%); }
.tut-count { font-size: 11px; font-weight: 800; color: var(--muted); }
.tut-title { margin: 2px 0 4px; font-size: 16px; }
.tut-text { margin: 0 0 8px; font-size: 14px; line-height: 1.55; }
.tut-foot { display: flex; align-items: center; justify-content: space-between; gap: 8px; }
.tut-hint { flex: 1; text-align: center; font-size: 12px; color: #1a73e8; font-weight: 800; }
.tut-skip { background: none; border: 0; color: var(--muted); text-decoration: underline; font-size: 13px; padding: 6px 4px; }
.tut-next { background: var(--ink); color: #fff; border: 0; border-radius: 8px; padding: 8px 18px; font-weight: 800; font-size: 14px; }
.tut-next[hidden] { display: none; }

/* ---- 3人用: 子の説明(複数) ---- */
.judge-item { display: flex; flex-direction: column; gap: 1px; padding: 5px 0; border-top: 1px dashed #bbb; }
.judge-item:first-child { border-top: 0; padding-top: 0; }
.judge-name { font-size: 12px; font-weight: 800; }
.judge-item .judge-text { font-size: 13px; }

/* ---- 概要ページ ---- */
.about h3 { margin: 20px 0 6px; font-size: 15px; border-left: 4px solid var(--ink); padding-left: 8px; }
.about p { margin: 6px 0; font-size: 14px; line-height: 1.8; }
.about ul, .about ol { margin: 6px 0; padding-left: 20px; font-size: 14px; line-height: 1.8; }
.about li { margin: 8px 0; }
.about-cta { text-align: center; margin-top: 18px !important; }
.about-link { text-align: center; margin: 14px 0 0; }

/* 狭い画面ではタブ4つが収まるよう、DEMOの印を隠して詰める */
@media (max-width: 440px) {
  .top { padding: 8px 10px; gap: 6px; }
  .top h1 { font-size: 15px; }
  .demo { display: none; }
  .tabs { gap: 4px; }
  .tabs button { padding: 4px 9px; font-size: 13px; }
}
@media (max-width: 350px) {
  .top h1 { font-size: 13px; }
  .tabs button { padding: 4px 6px; font-size: 12px; }
}

/* ---- 親の番: 悩み札を2枚から選ぶ ---- */
.choices { display: grid; gap: 8px; grid-template-columns: 1fr; margin: 6px 0; }
@media (min-width: 520px) { .choices { grid-template-columns: 1fr 1fr; } }
.pcard { text-align: left; background: var(--paper); border: 2px solid var(--ink); border-radius: 12px; padding: 8px 10px 4px; box-shadow: 0 3px 10px rgba(0, 0, 0, .14); }
.pcard .bar { font-size: 13px; }
.pcard.selected { background: var(--ink); color: #fff; }
.pcard.selected .bar { background: #fff; color: var(--ink); }
.pcard.selected .pchip { color: var(--muted); }
.pcard .body { font-size: clamp(15px, 4.2vw, 19px); padding: 6px 2px 4px; }
.pnote { margin: 2px 0 0; font-size: 11px; color: var(--muted); }
