/* とんち寺子屋（/tonchi/）: 入口はサイトの明るい地のまま、遊ぶ画面（.tc-game）は画面全体（和紙の地・墨の字・朱・藍・山吹）
   遊ぶ画面は縦に「上の帯・先生と問題・ヒント・舞台（正方形）・答えのボタン・ヒントのボタン」。舞台の大きさは pages/tonchi.js の fitStage */
:root { --tbg: #f6efdf; --tpaper: #fffaf0; --tline: #e2d6bb; --tink: #3a2f25; --tmut: #7d7262; --tshu: #d9482b; --tshuD: #a8331d; --tai: #34548a; --tyama: #efb12f; }

/* ── 入口 ── */
.tc-top { display: grid; gap: 16px; padding-top: 8px; }
.tc-hero { position: relative; margin: 0; border-radius: 20px; overflow: hidden; background: var(--tbg); aspect-ratio: 6 / 5; box-shadow: 0 18px 40px -26px rgba(60, 40, 20, .7); }
.tc-hero > svg { display: block; width: 100%; height: 100%; }
.tc-hero-cap { position: absolute; left: 50%; top: 12px; transform: translateX(-50%); z-index: 1; display: grid; justify-items: center; gap: 0; width: max-content; max-width: calc(100% - 24px); padding: 6px 20px 8px; border-radius: 12px; background: #fffaf0; border: 3px solid var(--tink); box-shadow: 0 5px 0 rgba(58, 47, 37, .25); color: var(--tink); }
.tc-hero-cap::before, .tc-hero-cap::after { content: ""; position: absolute; top: -14px; width: 3px; height: 12px; background: var(--tink); }
.tc-hero-cap::before { left: 22%; } .tc-hero-cap::after { right: 22%; }
.tc-eb { font-size: 11.5px; font-weight: 800; letter-spacing: .12em; color: var(--tshuD); }
.tc-hero-cap b { font-family: "Hiragino Mincho ProN", "Yu Mincho", "YuMincho", "Noto Serif JP", serif; font-size: clamp(28px, 8.4vw, 40px); line-height: 1.15; letter-spacing: .08em; }
.tc-hero .tc-bob { animation: tc-bob 2.6s ease-in-out infinite; }
.tc-hero .tc-bob2 { animation: tc-bob 2.2s ease-in-out .4s infinite; }
.tc-hero .tc-bob3 { animation: tc-bob 2.4s ease-in-out .9s infinite; }
.tc-top .lead b { color: var(--tshuD); }
.tc-start { display: grid; gap: 10px; }
.tc-start .btn.go { --go: #d9482b; --go-step: #a8331d; --go-soft: rgba(168, 51, 29, .5); }
.tc-note { font-size: 13px; color: var(--muted); }
.tc-note b { color: var(--ink); }
.tc-h2 { font-size: 20px; margin-top: 12px; }
.tc-how { margin: 0; padding: 0; list-style: none; counter-reset: tc; display: grid; gap: 10px; }
.tc-how li { counter-increment: tc; position: relative; display: grid; gap: 2px; padding: 12px 14px 12px 50px; border-radius: 14px; background: var(--card); border: 1px solid var(--line); }
.tc-how li::before { content: counter(tc); position: absolute; left: 14px; top: 12px; width: 26px; height: 26px; border-radius: 50%; display: grid; place-items: center; background: var(--tai); color: #fff; font: 800 14px/1 var(--f-round); }
.tc-how b { font-size: 15.5px; }
.tc-how span { font-size: 13.5px; color: var(--ink2); line-height: 1.6; }
.tc-faq details { border-bottom: 1px solid var(--line); padding: 10px 2px; }
.tc-faq summary { cursor: pointer; font-weight: 700; }
.tc-faq p { margin-top: 6px; font-size: 14px; color: var(--ink2); }

/* ── 遊ぶ画面 ── */
html.tc-lock, html.tc-lock body { overflow: hidden; overscroll-behavior: none; }
.tc-game { position: fixed; inset: 0; z-index: 2147483000; background: var(--tbg); color: var(--tink); font-family: var(--f-body); line-height: 1.5; -webkit-tap-highlight-color: transparent; user-select: none; -webkit-user-select: none; -webkit-touch-callout: none; }
.tc-game button { font: inherit; color: inherit; cursor: pointer; touch-action: manipulation; }
.tc-play, .tc-select { position: absolute; inset: 0; margin: 0 auto; max-width: 480px; display: flex; flex-direction: column; }
.tc-play > *, .tc-select > * { flex: none; }
.tc-play > .tc-stagebox, .tc-select > .tc-sel-body { flex: 1 1 0; min-height: 0; }
.tc-head { display: flex; align-items: center; gap: 8px; padding: max(8px, env(safe-area-inset-top, 0px)) max(10px, env(safe-area-inset-right, 0px)) 6px max(10px, env(safe-area-inset-left, 0px)); }
.tc-ibtn { flex: none; display: grid; place-items: center; width: 40px; height: 40px; padding: 0; border-radius: 12px; border: 1.5px solid var(--tline); background: var(--tpaper); }
.tc-ibtn svg { width: 20px; height: 20px; }
.tc-where { flex: 1 1 auto; min-width: 0; display: grid; line-height: 1.2; }
.tc-where b { font: 800 14px/1.25 var(--f-round); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.tc-where span { font-size: 12px; color: var(--tmut); white-space: nowrap; }
.tc-stars { display: flex; gap: 1px; flex: none; }
.tc-star { display: grid; width: 26px; height: 26px; touch-action: none; }
.tc-star svg { width: 100%; height: 100%; }
.tc-star.can-drag { cursor: grab; }
.tc-star.away { opacity: .25; }
.tc-total { display: flex; align-items: baseline; gap: 4px; padding: 5px 10px; border-radius: 999px; background: var(--tpaper); border: 1px solid var(--tline); white-space: nowrap; }
.tc-total svg { width: 18px; height: 18px; align-self: center; }
.tc-total b { font: 800 17px/1 var(--f-round); }
.tc-total span { font-size: 12px; color: var(--tmut); }

.tc-ask { display: grid; grid-template-columns: 62px minmax(0, 1fr); gap: 6px; align-items: center; padding: 2px 12px 0; }
.tc-sensei { width: 62px; height: 54px; padding: 0; border: 0; background: none; display: grid; touch-action: manipulation; }
.tc-sensei svg { width: 100%; height: 100%; overflow: visible; }
.tc-sensei.hop svg { animation: tc-hop .45s ease-out; }
.tc-bubble { position: relative; padding: 9px 12px; border-radius: 16px; background: var(--tpaper); border: 2px solid var(--tink); box-shadow: 0 3px 0 rgba(58, 47, 37, .14); }
.tc-bubble::before { content: ""; position: absolute; left: -9px; top: calc(50% - 7px); width: 12px; height: 12px; background: var(--tpaper); border-left: 2px solid var(--tink); border-bottom: 2px solid var(--tink); transform: rotate(45deg); }
.tc-q { margin: 0; font-size: 16px; font-weight: 700; line-height: 1.6; word-break: auto-phrase; }
.tc-tok { display: inline-block; touch-action: none; border-radius: 4px; transition: opacity .2s; } /* touch-action は inline の要素には効かない（指でドラッグすると途中で取り消される）ので inline-block */
.tc-ask { touch-action: none; }
.tc-tok.can-drag { cursor: grab; }
.tc-tok.away { opacity: .2; }
.tc-tok.used { opacity: .12; }
.tc-ghost { position: fixed; z-index: 2147483200; transform: translate(-50%, -60%); font: 800 34px/1 var(--f-body); color: var(--tink); pointer-events: none; text-shadow: 0 4px 10px rgba(58, 47, 37, .3); }
.tc-ghost.star { width: 40px; height: 40px; }
.tc-ghost.star svg { width: 100%; height: 100%; }
.tc-ghost.home { transition: left .25s ease-out, top .25s ease-out, opacity .25s; opacity: .4; }

.tc-hintbox { margin: 6px 12px 0; padding: 8px 12px; border-radius: 12px; background: #fff4d0; border: 1.5px dashed #c88a12; display: grid; gap: 4px; font-size: 13.5px; line-height: 1.55; }
.tc-hintbox[hidden] { display: none; }
.tc-hintbox p { margin: 0; }
.tc-hintbox b { display: inline-block; margin-right: 6px; padding: 0 8px; border-radius: 999px; background: #c88a12; color: #fff; font-size: 12px; }
.tc-hintbox .ans b { background: var(--tshu); }

.tc-stagebox { position: relative; min-height: 0; display: grid; place-items: center; padding: 8px 12px; }
.tc-stage { position: relative; width: 300px; height: 300px; border-radius: 18px; overflow: hidden; background: #fff; box-shadow: 0 0 0 3px var(--tink), 0 14px 30px -18px rgba(58, 47, 37, .6); }
.tc-svg { display: block; width: 100%; height: 100%; touch-action: none; user-select: none; -webkit-user-select: none; }
.tc-svg text { pointer-events: none; }
.tc-hit { cursor: pointer; }
.tc-svg .lift { filter: drop-shadow(0 8px 6px rgba(58, 47, 37, .35)); }
.tc-stage.shake { animation: tc-shake .38s ease-out; }
.tc-count { position: absolute; left: 8px; top: 8px; padding: 3px 10px; border-radius: 999px; background: rgba(255, 250, 240, .94); border: 1.5px solid var(--tink); font-size: 12.5px; font-weight: 700; pointer-events: none; }
.tc-count b { font: 800 15px/1 var(--f-round); color: var(--tshu); }
.tc-count[hidden] { display: none; }
.tc-maru { position: absolute; left: 10%; top: 10%; width: 80%; height: 80%; pointer-events: none; animation: tc-stamp .5s ease-out .5s both; }
.tc-maru path { stroke-dasharray: 1; stroke-dashoffset: 1; }
.tc-maru .p2 { animation: tc-draw .55s ease-out .05s forwards; }
.tc-maru .p1 { animation: tc-draw .6s ease-out .45s forwards; }
.tc-ringdraw { animation: tc-ring .45s ease-out forwards; }
.tc-svg .tc-flame { transform-box: fill-box; transform-origin: 50% 100%; animation: tc-flick .7s ease-in-out infinite alternate; }
.tc-svg .tc-smoke { animation: tc-smoke 1.6s ease-out forwards; }

.tc-toast { position: absolute; left: 50%; top: var(--toast-top, 40%); transform: translateX(-50%); z-index: 4; width: max-content; max-width: min(440px, calc(100% - 28px)); padding: 9px 14px; border-radius: 14px; background: rgba(58, 47, 37, .94); color: #fff; font-size: 14px; font-weight: 700; text-align: center; line-height: 1.5; box-shadow: 0 10px 26px -14px rgba(0, 0, 0, .7); pointer-events: none; }
.tc-toast[hidden] { display: none; }
.tc-toast.in { animation: tc-in .22s ease-out; }

.tc-panel { padding: 0 12px 2px; }
.tc-panel[hidden] { display: none; }
.tc-choices { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 8px; }
.tc-choices.two { grid-template-columns: repeat(2, minmax(0, 1fr)); }
.tc-choice { min-height: 46px; padding: 6px 4px; border-radius: 12px; border: 2px solid var(--tink); background: var(--tpaper); font-weight: 800 !important; font-size: 16.5px !important; box-shadow: 0 3px 0 var(--tink); transition: transform .06s; }
.tc-choice:active { transform: translateY(2px); box-shadow: 0 1px 0 var(--tink); }
.tc-choice.ng { animation: tc-shake .35s ease-out; background: #fde3dc; }
.tc-choice.ok { background: #fff1c7; border-color: var(--tshu); }
.tc-pad { display: grid; gap: 6px; }
.tc-disp { height: 40px; display: grid; place-items: center; border-radius: 10px; background: #fff; border: 2px solid var(--tink); }
.tc-disp b { font: 800 24px/1 var(--f-round); letter-spacing: .12em; }
.tc-disp span { font-size: 13px; color: var(--tmut); }
.tc-disp.ng { animation: tc-shake .35s ease-out; background: #fde3dc; }
.tc-keys { display: grid; grid-template-columns: repeat(6, minmax(0, 1fr)); gap: 6px; }
.tc-key { height: 40px; padding: 0; border-radius: 10px; border: 1.5px solid var(--tline); background: var(--tpaper); font: 800 18px/1 var(--f-round) !important; box-shadow: 0 2px 0 var(--tline); }
.tc-key.fn { font: 700 13px/1 var(--f-body) !important; }
.tc-key.go { grid-column: span 1; background: var(--tshu); border-color: var(--tshuD); color: #fff !important; font: 800 12.5px/1 var(--f-body) !important; box-shadow: 0 2px 0 var(--tshuD); }
.tc-key:active { transform: translateY(1px); }

.tc-foot { padding: 6px 12px max(10px, env(safe-area-inset-bottom, 0px)); }
.tc-hintbtn { min-height: 46px !important; display: flex !important; gap: 6px; font-size: 15.5px !important; }
.tc-hintbtn svg { width: 20px; height: 20px; color: #c88a12; flex: none; }
.tc-hintbtn small { font-size: 11.5px; color: var(--tmut); font-weight: 700; }
.tc-hintbtn[disabled] { opacity: .55; }

/* 問題えらび */
.tc-sel-body { overflow: auto; padding: 4px 12px max(16px, env(safe-area-inset-bottom, 0px)); display: grid; gap: 16px; align-content: start; }
.tc-vol { display: grid; gap: 8px; }
.tc-vol h2 { display: flex; align-items: baseline; gap: 4px; font-size: 17px; }
.tc-vol h2 .v { font-family: "Hiragino Mincho ProN", "Yu Mincho", "YuMincho", serif; font-weight: 800; }
.tc-vol h2 .s { font-size: 14px; color: var(--tshuD); }
.tc-vol h2 small { margin-left: auto; font-size: 12.5px; color: var(--tmut); font-weight: 700; }
.tc-grid { display: grid; grid-template-columns: repeat(5, minmax(0, 1fr)); gap: 6px; }
.tc-tile { position: relative; display: grid; justify-items: center; align-content: center; gap: 1px; min-height: 74px; padding: 6px 2px 5px; border-radius: 12px; border: 1.5px solid var(--tline); background: var(--tpaper); }
.tc-tile b { font: 800 19px/1.1 var(--f-round); }
.tc-tile .nm { max-width: 100%; font-size: 10px; color: var(--tmut); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; padding: 0 2px; }
.tc-tile .st { display: flex; gap: 0; }
.tc-tile .st svg { width: 12px; height: 12px; }
.tc-tile.done { border-color: var(--tshu); background: #fff6e8; }
.tc-tile.done::after { content: ""; position: absolute; right: 3px; top: 3px; width: 12px; height: 12px; border-radius: 50%; border: 2.5px solid var(--tshu); opacity: .8; }
.tc-grad { margin-top: 4px; }

/* 札（ヒントの確かめ・正解・巻のおわり・卒業） */
.tc-sheet { position: absolute; inset: 0; z-index: 5; display: grid; place-items: center; padding: 14px; background: rgba(58, 47, 37, .45); overflow: auto; animation: tc-fade .2s ease-out; }
.tc-sheet[hidden] { display: none; }
.tc-card { width: min(420px, 100%); max-height: calc(100dvh - 28px); overflow: auto; padding: 18px 18px 16px; border-radius: 20px; background: var(--tpaper); box-shadow: 0 24px 60px -24px rgba(0, 0, 0, .6); display: grid; gap: 12px; animation: tc-up .25s ease-out; }
.tc-card h2 { font: 800 21px/1.3 var(--f-round); text-align: center; }
.tc-card .sub { font-size: 14px; color: var(--tmut); text-align: center; margin: 0; }
.tc-res-top { display: grid; justify-items: center; gap: 4px; }
.tc-result h2 { font-family: "Hiragino Mincho ProN", "Yu Mincho", "YuMincho", serif; font-size: 34px; color: var(--tshu); letter-spacing: .1em; }
.tc-got { display: flex; gap: 4px; }
.tc-got svg { width: 34px; height: 34px; }
.tc-ex { display: grid; grid-template-columns: 64px minmax(0, 1fr); gap: 8px; align-items: center; }
.tc-ex-face svg, .tc-end-face svg { width: 100%; height: auto; overflow: visible; }
.tc-ex-b { padding: 10px 12px; border-radius: 14px; background: #fff; border: 1.5px solid var(--tline); }
.tc-ex-b small { display: block; font-size: 11.5px; color: var(--tmut); font-weight: 700; }
.tc-ex-b p { margin: 2px 0 0; font-size: 15px; font-weight: 700; line-height: 1.6; }
.tc-acts { display: grid; gap: 8px; }
.tc-acts .btn { min-height: 48px; font-size: 16px; }
.tc-acts .btn.go { --go: #d9482b; --go-step: #a8331d; --go-soft: rgba(168, 51, 29, .5); color: #fff; }
.tc-acts .btn.tc-main { background: var(--tshu); color: #fff; }
.tc-acts .btn.sub { color: var(--tink); }
.tc-end { text-align: center; }
.tc-end-eb { margin: 0; font-size: 13px; font-weight: 800; letter-spacing: .12em; color: var(--tshuD); }
.tc-end h2 { font-family: "Hiragino Mincho ProN", "Yu Mincho", "YuMincho", serif; font-size: 24px; }
.tc-end-face { width: 110px; margin: 0 auto; }
.tc-big { display: flex; align-items: baseline; justify-content: center; gap: 6px; }
.tc-big svg { width: 40px; height: 40px; align-self: center; }
.tc-big b { font: 900 52px/1 var(--f-round); font-variant-numeric: tabular-nums; }
.tc-big span { font-size: 18px; font-weight: 700; color: var(--tmut); }
.tc-rank { margin: 0; display: grid; gap: 0; }
.tc-rank small { font-size: 12px; color: var(--tmut); font-weight: 700; }
.tc-rank b { font-family: "Hiragino Mincho ProN", "Yu Mincho", "YuMincho", serif; font-size: 26px; color: var(--tshu); }
.tc-end-sub { margin: -4px 0 0; font-size: 13.5px; color: var(--tmut); }
/* 共有のかたまり（../js/share.js の shareBlock）。札の中なので見出しを小さく左に・ゲームの button の字の指定を戻す */
.tc-sharebox { text-align: left; }
.tc-sharebox .section { margin-top: 2px; gap: 10px; }
.tc-sharebox .share > h2 { font: 800 15px/1.3 var(--f-round); text-align: left; }
.tc-sharebox .btn { min-height: 50px; color: #fff; font: 700 16px/1.3 var(--f-round); }
.tc-sharebox .seg button { font: 700 13px/1.5 var(--f-body); }
.tc-sharebox .share-apps { grid-template-columns: repeat(auto-fit, minmax(124px, 1fr)); }
.tc-sharebox .seg button:not([aria-pressed="true"]) { color: var(--tmut); }
.tc-lock .toast, .tc-lock .share-sheet { z-index: 2147483100; }
.tc-lock .pc-cols .toast { left: 50%; }

@keyframes tc-bob { 0%, 100% { transform: translateY(0); } 50% { transform: translateY(-4px); } }
@keyframes tc-hop { 0% { transform: translateY(0); } 40% { transform: translateY(-6px) rotate(-4deg); } 100% { transform: none; } }
@keyframes tc-shake { 0%, 100% { transform: translateX(0); } 20% { transform: translateX(-6px); } 40% { transform: translateX(5px); } 60% { transform: translateX(-3px); } 80% { transform: translateX(2px); } }
@keyframes tc-draw { to { stroke-dashoffset: 0; } }
@keyframes tc-ring { to { stroke-dashoffset: 0; } }
@keyframes tc-stamp { 0% { transform: scale(1); } 40% { transform: scale(1.08); } 100% { transform: scale(1); } }
@keyframes tc-flick { from { transform: scale(1, 1) rotate(-2deg); } to { transform: scale(.92, 1.08) rotate(2deg); } }
@keyframes tc-smoke { from { opacity: .9; transform: translateY(0); } to { opacity: 0; transform: translateY(-16px); } }
@keyframes tc-in { from { opacity: 0; transform: translate(-50%, -6px); } to { opacity: 1; transform: translate(-50%, 0); } }
@keyframes tc-fade { from { opacity: 0; } to { opacity: 1; } }
@keyframes tc-up { from { opacity: 0; transform: translateY(14px); } to { opacity: 1; transform: none; } }
@media (prefers-reduced-motion: reduce) {
  .tc-hero .tc-bob, .tc-hero .tc-bob2, .tc-hero .tc-bob3, .tc-stage.shake, .tc-card, .tc-sheet, .tc-toast.in, .tc-svg .tc-flame, .tc-choice.ng, .tc-disp.ng, .tc-sensei.hop svg { animation: none; }
}
/* せまい画面（幅340未満）: 字と★を少し小さく */
@media (max-width: 340px) {
  .tc-q { font-size: 15px; }
  .tc-star { width: 22px; height: 22px; }
  .tc-ask { grid-template-columns: 52px minmax(0, 1fr); }
  .tc-sensei { width: 52px; height: 46px; }
  .tc-choice { font-size: 15px !important; }
}
/* 背の低い画面: 先生を小さく・すきまをつめる */
@media (max-height: 640px) {
  .tc-head { padding-top: max(4px, env(safe-area-inset-top, 0px)); padding-bottom: 2px; }
  .tc-q { font-size: 14.5px; line-height: 1.5; }
  .tc-bubble { padding: 6px 10px; }
  .tc-key { height: 36px; }
  .tc-choice { min-height: 40px; }
  .tc-hintbtn { min-height: 40px !important; }
}
