:root {
  --ink: #2f2a22;
  --ink-soft: #6d6455;
  --bg: #f4ecdc;
  --paper: #fffdf6;
  --line: #e2d4b8;
  --primary: #9a5b26;
  --primary-dark: #6e3d14;
  --gold: #f5b82e;
  --wood: #e9c27a;
  --wood-dark: #c99a4b;
  --grid: #6e4a20;
  --hl: rgba(255, 230, 120, 0.85);
  --font: "Zen Maru Gothic", system-ui, sans-serif;
  --koma: "Shippori Mincho B1", "Hiragino Mincho ProN", "Yu Mincho", serif;
}
* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }
html { -webkit-text-size-adjust: 100%; }
body { margin: 0; background: var(--bg); color: var(--ink); font-family: var(--font); font-weight: 500; line-height: 1.7; line-break: strict; }
.hidden { display: none !important; }
.nw { white-space: nowrap; }

.g-head { display: flex; align-items: center; gap: 10px; padding: 10px 16px; max-width: 520px; margin: 0 auto; font-size: 13px; font-weight: 900; }
.g-brand { color: var(--ink-soft); text-decoration: none; }
.g-title { flex: 1; text-align: center; }
.g-head [data-mg-account] a { color: var(--primary-dark); text-decoration: none; }

main { max-width: 520px; margin: 0 auto; padding: 0 12px 24px; }
.play { position: relative; user-select: none; -webkit-user-select: none; -webkit-touch-callout: none; }

.bar { display: grid; grid-template-columns: 1fr 1fr 1fr; gap: 8px; margin-bottom: 6px; }
.box { background: var(--paper); border: 1px solid var(--line); border-radius: 12px; padding: 5px 6px; text-align: center; min-width: 0; }
.lbl { font-size: 11px; font-weight: 900; color: var(--ink-soft); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.val { font: 900 20px/1.25 var(--font); font-variant-numeric: tabular-nums; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
#qno { font-size: 16px; line-height: 1.55; }
#qno small { display: block; font-size: 11px; line-height: 1.1; margin-top: -2px; }
.bar .box { display: flex; flex-direction: column; justify-content: center; min-height: 56px; }
.sq.hk, .hp.hk { background: #bfe2ff; box-shadow: inset 0 0 0 3px #2b8be0; }
.pc.g.k::before { background: #f4c9a8; box-shadow: inset 0 0 0 2px #b0502a, inset 0 -2px 0 rgba(0, 0, 0, 0.15); }
.steps-bar { list-style: none; display: flex; justify-content: center; gap: 6px; margin: 0 0 4px; padding: 0; }
.steps-bar li { padding: 1px 10px; border-radius: 999px; background: var(--paper); border: 1px solid var(--line); font-size: 12px; font-weight: 900; color: var(--ink-soft); }
.steps-bar li.now { background: var(--primary); border-color: var(--primary); color: #fff; }
.steps-bar li.ok { background: #e6f2dc; border-color: #9cc77d; color: #2d6a1e; }
.note { margin: 0 0 4px; min-height: 1.6em; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; font-size: 13px; font-weight: 900; color: var(--primary-dark); text-align: center; }
.note.warn { color: #b3402e; }

/* 盤（9×9。上が玉方）。マスを押す操作は touch-action: manipulation の下（portal の nozoom.js がすばやい連打を止めない） */
.board-wrap { background: var(--wood-dark); border-radius: 10px; padding: 5px; box-shadow: 0 8px 22px rgba(80, 55, 25, 0.25); width: fit-content; max-width: 100%; margin: 0 auto; touch-action: manipulation; }
.board-wrap.shake { animation: shake 0.35s; }
@keyframes shake { 20% { transform: translateX(-5px); } 45% { transform: translateX(5px); } 70% { transform: translateX(-3px); } }
.board { display: grid; grid-template-columns: repeat(9, var(--cs, 36px)); grid-template-rows: repeat(9, var(--cs, 36px)); background: var(--wood); border: 2px solid var(--grid); touch-action: manipulation; }
.sq { position: relative; border-right: 1px solid var(--grid); border-bottom: 1px solid var(--grid); display: flex; align-items: center; justify-content: center; cursor: pointer; }
.sq:nth-child(9n) { border-right: 0; }
.sq:nth-child(n+73) { border-bottom: 0; }
.sq.mv::after { content: ""; position: absolute; width: 32%; height: 32%; border-radius: 50%; background: rgba(60, 140, 60, 0.55); pointer-events: none; }
.sq.cap::after { content: ""; position: absolute; inset: 3px; border-radius: 6px; box-shadow: inset 0 0 0 3px rgba(60, 140, 60, 0.75); pointer-events: none; }
.sq.sel { background: var(--hl); }
.sq.last { background: rgba(255, 170, 90, 0.45); }
.sq.hint { animation: hint 0.9s ease-in-out 3; background: #bfe2ff; }
.sq.ng { background: rgba(255, 110, 90, 0.5); }
@keyframes hint { 50% { filter: brightness(1.15); transform: scale(1.06); } }

/* 駒（五角形）。玉方の駒は逆さま */
.pc { position: relative; width: 86%; height: 92%; display: flex; align-items: center; justify-content: center; pointer-events: none; }
.pc::before { content: ""; position: absolute; inset: 0; background: #f7dfa6; clip-path: polygon(50% 0, 88% 18%, 100% 100%, 0 100%, 12% 18%); box-shadow: inset 0 -2px 0 rgba(0, 0, 0, 0.15); }
.pc span { position: relative; font: 800 calc(var(--cs, 36px) * 0.56)/1 var(--koma); color: #1e140a; margin-top: 12%; }
.pc.pro span { color: #c0281b; }
.pc.g { transform: rotate(180deg); }
.pc.k span { font-size: calc(var(--cs, 36px) * 0.6); }

/* 持ち駒 */
.hand { display: flex; align-items: center; justify-content: center; flex-wrap: wrap; gap: 4px; min-height: 40px; margin: 4px auto; padding: 2px 6px; font-size: 12px; font-weight: 900; color: var(--ink-soft); }
.hand .hl { margin-right: 4px; }
.hand-g { min-height: 0; margin: 0 auto 3px; font-size: 11px; font-weight: 700; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; display: block; text-align: center; }
.hp { position: relative; width: 40px; height: 40px; border: 0; background: transparent; padding: 0; display: flex; align-items: center; justify-content: center; cursor: pointer; border-radius: 8px; touch-action: manipulation; }
.hp .pc { width: 34px; height: 38px; --cs: 40px; }
.hp b { position: absolute; right: -2px; bottom: -2px; min-width: 16px; padding: 0 3px; border-radius: 8px; background: var(--primary-dark); color: #fff; font-size: 11px; line-height: 16px; }
.hp.sel { background: var(--hl); }
.hp.hint { animation: hint 0.9s ease-in-out 3; background: #bfe2ff; }
.hand-g .hp { cursor: default; width: 30px; height: 32px; }
.hand-g .hp .pc { width: 26px; height: 30px; --cs: 30px; }
.hand-s.empty::after { content: "持ち駒なし"; font-size: 12px; color: var(--ink-soft); }

.promo { position: absolute; left: 50%; top: 42%; transform: translate(-50%, -50%); z-index: 30; display: flex; gap: 10px; padding: 12px; border-radius: 16px; background: var(--paper); box-shadow: 0 10px 30px rgba(0, 0, 0, 0.25); }
.promo .btn { margin: 0; width: 110px; }

.tools { display: grid; grid-template-columns: 2fr 1fr; gap: 6px; margin-top: 8px; touch-action: manipulation; }
.tool { display: inline-flex; flex-direction: row; align-items: center; justify-content: center; gap: 6px; padding: 10px 4px; border: 1px solid var(--line); border-radius: 12px; background: var(--paper); color: var(--ink); font: 900 13px/1 var(--font); cursor: pointer; white-space: nowrap; }
.tool:disabled { opacity: 0.35; cursor: default; }
.kbd { margin: 8px 0 0; font-size: 12px; color: var(--ink-soft); text-align: center; }
@media (prefers-reduced-motion: reduce) { .sq.hint, .hp.hint, .board-wrap.shake { animation: none; } }

/* タイトル・結果（盤を隠して全体を見せる） */
.play.menu .bar, .play.menu .steps-bar, .play.menu .note, .play.menu .board-wrap, .play.menu .hand, .play.menu .tools, .play.menu .kbd, .play.menu .promo { display: none; }
.card-ui { width: 100%; max-width: 420px; margin: 0 auto; background: var(--paper); border: 1px solid var(--line); border-radius: 18px; padding: 18px 16px 16px; text-align: center; box-shadow: 0 10px 30px rgba(80, 60, 30, 0.1); }
.logo-art { display: flex; justify-content: center; align-items: flex-end; gap: 8px; }
.logo-art .pz { position: relative; width: 38px; height: 42px; display: flex; align-items: center; justify-content: center; font: 800 22px/1 var(--koma); }
.logo-art .pz::before { content: ""; position: absolute; inset: 0; background: #f7dfa6; clip-path: polygon(50% 0, 88% 18%, 100% 100%, 0 100%, 12% 18%); z-index: -1; box-shadow: inset 0 -2px 0 rgba(0, 0, 0, 0.15); }
.logo-art .pz { z-index: 0; padding-top: 6px; }
.logo-art .pz.k { width: 46px; height: 52px; font-size: 27px; padding-top: 8px; }
.logo { margin: 4px 0 0; font: 800 30px/1.3 var(--koma); letter-spacing: 0.06em; white-space: nowrap; color: var(--primary-dark); }
.day { margin: 2px 0 10px; font-size: 13px; color: var(--ink-soft); font-weight: 900; }
.daily-box { border: 2px solid var(--primary); border-radius: 16px; padding: 12px; margin-bottom: 10px; }
.daily-lbl { font-size: 11px; font-weight: 900; color: var(--ink-soft); letter-spacing: 0.1em; }
.daily-name { font: 900 19px/1.4 var(--font); color: var(--primary-dark); }
.daily-note { margin: 6px 0 8px; font-size: 12px; color: var(--ink-soft); }
.done { font-size: 14px; font-weight: 900; margin-top: 6px; }
.free-lbl { font-size: 12px; font-weight: 900; color: var(--ink-soft); margin: 6px 0 4px; }
.free-row { display: grid; grid-template-columns: repeat(3, 1fr); gap: 6px; }
.howto { list-style: none; margin: 12px 0 0; padding: 10px 12px; background: var(--bg); border-radius: 12px; text-align: left; font-size: 13px; font-weight: 700; }
.howto li { display: flex; align-items: baseline; gap: 6px; padding: 3px 0; }
.howto .num { flex: none; font-weight: 900; color: var(--primary); }
.stats { font-size: 12px; color: var(--ink-soft); font-weight: 700; margin: 10px 0 0; }

.list-h { margin: 0; font: 800 24px/1.4 var(--koma); color: var(--primary-dark); }
.list-sub { margin: 2px 0 10px; font-size: 12px; color: var(--ink-soft); font-weight: 700; }
.qlist { list-style: none; margin: 0; padding: 0; display: grid; grid-template-columns: repeat(5, 1fr); gap: 6px; touch-action: manipulation; }
.qlist button { width: 100%; padding: 8px 0 6px; border: 1px solid var(--line); border-radius: 10px; background: var(--bg); font: 900 15px/1.1 var(--font); color: var(--ink); cursor: pointer; }
.qlist button small { display: block; margin-top: 3px; font-size: 10px; letter-spacing: -1px; color: #c48a00; min-height: 1em; }

.btn { display: block; width: 100%; margin: 8px 0; padding: 13px 10px; border: 0; border-radius: 14px; font: 900 16px/1.2 var(--font); cursor: pointer; background: var(--bg); color: var(--ink); }
.btn small { display: block; font-size: 11px; font-weight: 700; color: var(--ink-soft); margin-top: 3px; }
.btn.primary { background: var(--primary); color: #fff; box-shadow: 0 4px 0 var(--primary-dark); }
.btn.primary:active { transform: translateY(2px); box-shadow: 0 2px 0 var(--primary-dark); }
.btn.lv { margin: 0; font-size: 15px; padding: 10px 2px; background: #f6e6c6; }
.btn.sub { font-size: 14px; }
.btn.ghost { background: transparent; border: 2px solid var(--line); color: var(--ink-soft); font-size: 14px; }
.btn.x { background: #000; color: #fff; display: flex; align-items: center; justify-content: center; gap: 8px; }
.btn:disabled { opacity: 0.5; cursor: default; }

.clear-lbl { font-size: 13px; font-weight: 900; color: var(--primary-dark); }
.clear-time { font: 900 54px/1.1 var(--font); font-variant-numeric: tabular-nums; margin: 6px 0; }
.clear-sub { margin: 0; font-size: 14px; font-weight: 700; }
.marks { margin: 8px auto 0; display: grid; gap: 2px; justify-content: center; font-size: 15px; font-weight: 900; letter-spacing: 0.08em; }
.marks div { display: flex; gap: 8px; justify-content: flex-start; }
.marks span.n { width: 3.4em; text-align: right; color: var(--ink-soft); font-size: 12px; letter-spacing: 0; padding-top: 2px; }
.c-detail { list-style: none; margin: 8px auto 0; padding: 8px 12px; max-width: 300px; background: var(--bg); border-radius: 12px; text-align: left; font-size: 13px; font-weight: 700; }
.c-detail li { display: flex; justify-content: space-between; gap: 8px; padding: 1px 0; }
.c-detail li b { font-weight: 900; }
.c-detail li.tot { border-top: 1px solid var(--line); margin-top: 3px; padding-top: 4px; }
.best { display: inline-block; margin: 8px 4px 0; padding: 2px 12px; border-radius: 999px; background: var(--gold); font-weight: 900; font-size: 13px; }
.rank { margin: 12px 0; padding: 8px; background: var(--bg); border-radius: 14px; }
.rank-lbl { font-size: 11px; font-weight: 900; color: var(--ink-soft); }
.rank-name { font: 800 26px/1.4 var(--koma); color: var(--primary-dark); }
.c-note { margin: 8px 0; padding: 8px 10px; border-radius: 12px; background: #fff6dd; font-size: 13px; font-weight: 700; text-align: left; }
.share { margin: 8px 0; }
.pstreak { display: inline-block; margin: 8px 4px 0; padding: 2px 12px; border-radius: 999px; background: #e6f6ee; color: #1f6b47; font-weight: 900; font-size: 13px; }

.toast { position: absolute; left: 50%; top: 40%; transform: translate(-50%, -50%); z-index: 40; width: max-content; max-width: calc(100% - 24px); padding: 10px 18px; border-radius: 16px; background: rgba(47, 42, 34, 0.92); color: #fff; font-weight: 900; font-size: 15px; text-align: center; pointer-events: none; }
.toast.big { font: 800 30px/1.3 var(--koma); padding: 14px 30px; background: rgba(150, 30, 20, 0.92); }

/* 下の解説（ポータルと同じ決まり） */
.guide { margin-top: 28px; background: var(--paper); border: 1px solid var(--line); border-radius: 18px; padding: 22px 20px 12px; font-size: 15px; line-height: 1.85; }
.guide p { margin: 0 0 1em; }
.guide h2 { font: 900 19px/1.4 var(--font); margin: 32px 0 12px; padding-left: 10px; border-left: 5px solid var(--primary); }
.guide h2:first-child { margin-top: 0; }
.guide h3 { font-size: 16px; margin: 22px 0 6px; line-height: 1.5; }
.guide ul { padding-left: 1.3em; margin: 0 0 1em; }
.guide li { margin: 6px 0; }
.guide .steps { list-style: none; padding: 0; }
.guide .steps li { display: flex; align-items: baseline; gap: 6px; }
.guide .steps .num { flex: none; font-weight: 900; color: var(--primary); }
.guide details { border-top: 1px solid var(--line); padding: 12px 0; }
.guide details p { margin: 8px 0 4px; }
.guide summary { font-weight: 900; cursor: pointer; }
.guide a { color: var(--primary-dark); }
.g-foot { max-width: 520px; margin: 0 auto; padding: 14px 16px 28px; font-size: 12px; text-align: center; }
.g-foot a { color: var(--ink-soft); }
.card-ui .mg-box { background: var(--bg); border-color: transparent; }
@media (max-width: 360px) { main { padding: 0 6px 24px; } }

/* 遊んでいるあいだ（html.tsume-play）: ページが指でずれない・サイトの見出しを隠して盤を大きく */
html.tsume-play, html.tsume-play body { overscroll-behavior: none; }
html.tsume-play .g-head { display: none; }
html.tsume-play main { padding: 6px 6px 24px; }
