/* じかんコントローラー（レガシーデザイン：白・緑／BIZ UDPゴシック・Zen丸ゴシック）
   ・画面は動かない（スクロール・拡大・ゆれ なし）。縦も横も、端末の大きさに合わせて中身が縮む */
:root {
  --font: 'BIZ UDPGothic', 'Hiragino Sans', 'Meiryo', sans-serif;
  --round: 'Zen Maru Gothic', 'BIZ UDPGothic', 'Hiragino Maru Gothic ProN', sans-serif;
  --bg: #f5f8f7; --line: #e2e9e7; --line2: #d5dcdb; --text: #2f3b3a; --muted: #6f7d7b;
  --primary: #3a9e8f; --primary-d: #2c8073; --primary-l: #e6f4f1; --primary-m: #8cc5ba;
  --accent: #f0a95c; --accent-d: #c7833b; --danger: #d65c5c; --surface: #fff;
  --shadow: 0 2px 12px rgba(40, 80, 75, .07);
  --sa-t: env(safe-area-inset-top, 0px); --sa-r: env(safe-area-inset-right, 0px);
  --sa-b: env(safe-area-inset-bottom, 0px); --sa-l: env(safe-area-inset-left, 0px);
}
* { box-sizing: border-box; margin: 0; padding: 0; }
html, body {
  position: fixed; inset: 0; width: 100%; height: 100%; overflow: hidden; overscroll-behavior: none;
  background: var(--bg); color: var(--text); font-family: var(--font);
  -webkit-text-size-adjust: 100%; text-size-adjust: 100%; touch-action: manipulation;
  -webkit-user-select: none; user-select: none; -webkit-touch-callout: none; -webkit-tap-highlight-color: transparent;
}
button { font: inherit; color: inherit; border: 0; background: none; cursor: pointer; touch-action: manipulation; }
button:disabled { cursor: default; }
button:focus-visible, label:focus-within { outline: 3px solid var(--primary-m); outline-offset: 2px; }
svg { display: block; }
[hidden] { display: none !important; }

/* ---------- 全体のわく ---------- */
.app {
  position: fixed; inset: 0; display: grid;
  grid-template-rows: auto minmax(0, 1fr) auto; grid-template-columns: minmax(0, 1fr);
  grid-template-areas: "top" "stage" "bar";
  padding: var(--sa-t) var(--sa-r) var(--sa-b) var(--sa-l);
}
.topbar { grid-area: top; display: flex; align-items: center; gap: 8px; padding: 10px 14px 4px; min-height: 58px; }
.timer-label { flex: 1; min-width: 0; font-family: var(--round); font-weight: 900; font-size: clamp(20px, 4.6vmin, 34px); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; color: var(--primary-d); }
.teacher-btn { flex: none; display: inline-flex; align-items: center; gap: 6px; height: 40px; padding: 0 14px; border-radius: 999px; background: var(--surface); border: 1.5px solid var(--line2); color: var(--muted); font-size: 14px; font-weight: 700; box-shadow: var(--shadow); }
.teacher-btn svg { width: 17px; height: 17px; }

.stage { grid-area: stage; position: relative; container-type: size; margin: 4px 14px; border-radius: 26px; background: var(--surface); border: 1px solid var(--line); box-shadow: var(--shadow); overflow: hidden; }
.view { position: absolute; inset: 0; display: none; align-items: center; justify-content: center; }
.app[data-view="rings"] .view-rings, .app[data-view="digital"] .view-digital, .app[data-view="charas"] .view-charas { display: flex; }

/* ---------- 1. いろのわ ---------- */
.view-rings { flex-direction: column; gap: 2cqmin; }
.rings-svg { width: min(92cqw, 92cqh); height: min(92cqw, 92cqh); }
.app.show-num .rings-svg { width: min(90cqw, 76cqh); height: min(90cqw, 76cqh); }
.ring-arc, .ring-core { transition: stroke .8s, fill .8s; }
.cap { display: none; font-family: var(--round); font-weight: 900; color: var(--text); white-space: nowrap; line-height: 1.25; height: 1.25em; font-size: clamp(18px, 7.5cqmin, 64px); }
.app.show-num .cap { display: block; }
.cap.done { color: var(--danger); }

/* ---------- 2. すうじ ---------- */
.view-digital { flex-direction: column; gap: 4cqmin; }
.dg-panel { display: flex; align-items: center; justify-content: center; padding: 3cqmin 5cqmin; border-radius: 5cqmin; background: #eef6f3; border: max(3px, .8cqmin) solid var(--line2); box-shadow: inset 0 3px 0 rgba(255, 255, 255, .8), inset 0 -3px 0 rgba(40, 80, 75, .05); }
.dg { display: flex; align-items: center; font-family: var(--round); font-weight: 900; line-height: 1; color: var(--text); font-size: min(26cqw, 50cqh); font-variant-numeric: tabular-nums; transition: color .8s; }
.dg.long { font-size: min(16.5cqw, 40cqh); }
.dg i { font-style: normal; display: inline-block; width: .62em; text-align: center; }
.dg .col { width: .32em; position: relative; top: -.06em; }
.app[data-run="paused"] .dg .col { animation: blink 1.1s steps(1) infinite; }
@keyframes blink { 50% { opacity: .15; } }
.dg-bar { width: min(84cqw, 1000px); height: max(16px, 4.5cqmin); border-radius: 999px; background: var(--line); overflow: hidden; }
.dg-bar b { display: block; height: 100%; width: 100%; border-radius: inherit; background: var(--primary); transition: background-color .8s; }
.dg-sub { display: none; font-family: var(--round); font-weight: 700; color: var(--muted); font-size: clamp(14px, 4cqmin, 30px); }
.app.show-num .dg-sub { display: block; }

/* ---------- 3. どうぶつ ---------- */
.view-charas { flex-direction: column; }
.cg { display: grid; grid-template-columns: repeat(var(--c, 5), var(--s, 80px)); grid-auto-rows: var(--s, 80px); justify-content: center; align-content: center; }
.cc { position: relative; display: flex; align-items: center; justify-content: center; }
.cc .ch { width: 88%; height: 88%; transform-origin: 50% 85%; }
.cc .ch svg { width: 100%; height: 100%; }
.cc::before { content: ''; position: absolute; inset: 16%; border: max(2px, calc(var(--s) * .035)) dashed var(--line2); border-radius: 50%; opacity: 0; transition: opacity .5s .3s; }
.cc.gone::before { opacity: 1; }
.cc.gone .ch { animation: bye .9s cubic-bezier(.3, .1, .4, 1) forwards; }
.cc.gone.still .ch { animation: none; opacity: 0; transform: scale(.2); }
.app[data-run="running"] .cc:not(.gone) .ch { animation: bob 2.6s ease-in-out infinite; animation-delay: var(--d, 0s); }
.app[data-run="running"] .cc.next:not(.gone) .ch { animation: wig .45s ease-in-out infinite; }
@keyframes bob { 0%, 100% { transform: translateY(0); } 50% { transform: translateY(-4%); } }
@keyframes wig { 0%, 100% { transform: rotate(0); } 25% { transform: rotate(-9deg); } 75% { transform: rotate(9deg); } }
@keyframes bye { 0% { transform: translateY(0) scale(1); opacity: 1; } 35% { transform: translateY(-22%) scale(1.1); opacity: 1; } 100% { transform: translateY(-55%) scale(.25); opacity: 0; } }
.cap-chip { position: absolute; left: 50%; bottom: 2.4cqmin; transform: translateX(-50%); display: none; padding: .25em .9em; border-radius: 999px; background: var(--primary-l); color: var(--primary-d); font-family: var(--round); font-weight: 900; font-size: clamp(14px, 4.2cqmin, 30px); white-space: nowrap; }
.app.show-num .cap-chip { display: block; }
.cap-chip.done { background: #fbe3e3; color: var(--danger); }

/* ---------- こどものそうさ ---------- */
.kidbar { grid-area: bar; display: flex; flex-direction: column; gap: 10px; padding: 10px 14px 14px; }
.view-pick { display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px; }
.view-pick button { display: flex; align-items: center; justify-content: center; gap: 6px; height: 52px; border-radius: 16px; background: var(--surface); border: 2px solid var(--line); font-family: var(--round); font-weight: 700; font-size: 16px; color: var(--muted); }
.view-pick svg, .vp-chara svg { width: 28px; height: 28px; flex: none; }
.vp-chara { display: block; width: 28px; height: 28px; }
.view-pick button[aria-checked="true"] { border-color: var(--primary); background: var(--primary-l); color: var(--primary-d); }
.app.no-pick .view-pick { display: none; }
.quick { display: none; grid-template-columns: repeat(4, 1fr); gap: 8px; }
.app.kid-time .quick { display: grid; }
.app.kid-time[data-run="running"] .quick { visibility: hidden; }
.quick button { height: 44px; border-radius: 999px; background: var(--surface); border: 2px solid var(--line2); font-family: var(--round); font-weight: 900; font-size: 16px; color: var(--text); }
.quick button.on { background: var(--accent); border-color: var(--accent); color: #fff; }
.kid-main { display: grid; grid-template-columns: 1fr 2.2fr; gap: 10px; }
.app.no-ctrl .kid-main { grid-template-columns: 1fr; }
.app.no-ctrl .kid-reset { display: none; }
.kid-btn { display: flex; align-items: center; justify-content: center; gap: 10px; height: 76px; border-radius: 22px; font-family: var(--round); font-weight: 900; font-size: 24px; white-space: nowrap; transition: transform .08s, box-shadow .08s, background-color .2s; }
.kid-btn svg { width: 32px; height: 32px; flex: none; }
.kid-reset { background: var(--surface); border: 2px solid var(--line2); color: var(--muted); box-shadow: 0 4px 0 var(--line2); }
.kid-play { background: var(--primary); color: #fff; box-shadow: 0 5px 0 var(--primary-d); }
.kid-btn:active:not(:disabled) { transform: translateY(4px); box-shadow: 0 1px 0 var(--line2); }
.kid-play:active:not(:disabled) { box-shadow: 0 1px 0 var(--primary-d); }
.kid-play .ic-pause { display: none; }
.app[data-run="running"] .kid-play { background: var(--accent); box-shadow: 0 5px 0 var(--accent-d); }
.app[data-run="running"] .kid-play .ic-play { display: none; }
.app[data-run="running"] .kid-play .ic-pause { display: block; }
.app.no-ctrl[data-run="running"] .kid-play { background: var(--line); color: var(--muted); box-shadow: none; }
.app.no-ctrl[data-run="running"] .kid-play svg { display: none !important; }

/* 横向き（タブレット横・スマホ横）：そうさは右の列 */
@media (min-aspect-ratio: 5/4) {
  .app { grid-template-columns: minmax(0, 1fr) clamp(180px, 25vw, 280px); grid-template-rows: auto minmax(0, 1fr); grid-template-areas: "top bar" "stage bar"; }
  .stage { margin: 4px 0 14px 14px; }
  .kidbar { justify-content: flex-end; padding: 14px 14px 14px 12px; }
  .view-pick, .app.kid-time .quick { grid-template-columns: 1fr 1fr; }
  .view-pick button { flex-direction: column; gap: 2px; height: auto; padding: 8px 4px; font-size: 14px; }
  .view-pick button:last-child { grid-column: span 2; flex-direction: row; gap: 6px; }
  .kid-main { grid-template-columns: 1fr; }
  .kid-reset { height: 60px; font-size: 20px; }
  .kid-play { height: 96px; }
}
@media (min-aspect-ratio: 5/4) and (max-height: 520px) {
  .topbar { min-height: 48px; padding-top: 6px; }
  .kidbar { gap: 7px; padding: 8px 12px 10px 10px; }
  .view-pick button { padding: 5px 4px; font-size: 13px; }
  .view-pick svg, .vp-chara, .vp-chara svg { width: 22px; height: 22px; }
  .quick button { height: 36px; font-size: 14px; }
  .kid-reset { height: 46px; font-size: 17px; }
  .kid-play { height: 70px; font-size: 21px; }
  .kid-btn svg { width: 26px; height: 26px; }
}
@media (max-aspect-ratio: 5/4) and (max-height: 640px) {
  .topbar { min-height: 50px; }
  .kidbar { gap: 8px; padding-bottom: 10px; }
  .view-pick button { height: 44px; font-size: 14px; }
  .quick button { height: 38px; }
  .kid-btn { height: 62px; font-size: 21px; }
}
@media (min-width: 768px) and (min-height: 768px) {
  .view-pick button { height: 62px; font-size: 19px; }
  .view-pick svg, .vp-chara, .vp-chara svg { width: 34px; height: 34px; }
  .kid-btn { height: 92px; font-size: 30px; }
  .kid-btn svg { width: 40px; height: 40px; }
  .quick button { height: 52px; font-size: 19px; }
  .teacher-btn { height: 46px; font-size: 16px; }
}

/* ---------- 扉 ---------- */
.doors { position: fixed; inset: 0; z-index: 50; display: none; perspective: 1800px; }
.doors.show { display: block; }
.door { position: absolute; top: 0; bottom: 0; width: 50.4%; background: linear-gradient(180deg, #52b5a5, #3a9e8f 60%, #348f81); transition: transform 1.15s cubic-bezier(.65, .05, .3, 1); backface-visibility: hidden; -webkit-backface-visibility: hidden; box-shadow: inset 0 0 0 6px rgba(255, 255, 255, .12); }
.door-l { left: 0; transform-origin: left center; border-right: 3px solid #2c8073; }
.door-r { right: 0; transform-origin: right center; border-left: 3px solid #2c8073; }
.doors.open .door-l { transform: rotateY(-108deg); }
.doors.open .door-r { transform: rotateY(108deg); }
.doors.still .door, .doors.still .door-msg { transition: none !important; }
.door .panel { position: absolute; left: 15%; right: 15%; border: 4px solid rgba(255, 255, 255, .32); border-radius: 18px; background: rgba(255, 255, 255, .07); }
.door .p1 { top: 7%; height: 37%; }
.door .p2 { top: 50%; height: 42%; }
.door .knob { position: absolute; top: calc(50% - 2.4vmin); width: max(18px, 4.8vmin); height: max(18px, 4.8vmin); border-radius: 50%; background: radial-gradient(circle at 35% 35%, #fff1c7, #e7b04a 60%, #b98222); box-shadow: 0 3px 6px rgba(0, 0, 0, .25); }
.door-l .knob { right: 7%; }
.door-r .knob { left: 7%; }
.door-msg { position: absolute; left: 50%; top: 50%; transform: translate(-50%, -50%) scale(.85); display: flex; flex-direction: column; align-items: center; gap: 2vmin; padding: 3vmin 6vmin; border-radius: 6vmin; background: #fff; box-shadow: 0 10px 34px rgba(0, 0, 0, .2); opacity: 0; pointer-events: none; transition: opacity .35s, transform .35s; text-align: center; white-space: nowrap; }
.door-msg.on { opacity: 1; transform: translate(-50%, -50%) scale(1); pointer-events: auto; }
.door-msg b { font-family: var(--round); font-weight: 900; font-size: clamp(30px, 9vmin, 80px); color: var(--primary-d); line-height: 1.2; }
.door-msg .dm-ch { width: clamp(70px, 20vmin, 170px); height: clamp(70px, 20vmin, 170px); }
.door-msg .dm-ch svg { width: 100%; height: 100%; }

/* おしまい（扉なしのとき） */
.finish { position: fixed; inset: 0; z-index: 45; display: flex; align-items: center; justify-content: center; background: rgba(36, 65, 60, .4); animation: fadein .3s; }
.finish-card { display: flex; flex-direction: column; align-items: center; gap: 2vmin; padding: 4vmin 8vmin; border-radius: 6vmin; background: #fff; box-shadow: 0 10px 34px rgba(0, 0, 0, .2); animation: pop .45s cubic-bezier(.3, 1.6, .5, 1); }
.finish-chara { width: clamp(80px, 24vmin, 200px); height: clamp(80px, 24vmin, 200px); }
.finish-chara svg { width: 100%; height: 100%; }
.finish-t { font-family: var(--round); font-weight: 900; font-size: clamp(30px, 9vmin, 80px); color: var(--primary-d); }
@keyframes fadein { from { opacity: 0; } }
@keyframes pop { from { transform: scale(.6); opacity: 0; } }

/* ---------- ボタン ---------- */
.btn { display: inline-flex; align-items: center; justify-content: center; gap: 6px; height: 44px; padding: 0 18px; border-radius: 999px; font-family: var(--round); font-weight: 700; font-size: 16px; white-space: nowrap; }
.btn-primary { background: var(--primary); color: #fff; }
.btn-primary:disabled { background: var(--primary-m); }
.btn-sub { background: var(--surface); border: 1.5px solid var(--line2); color: var(--text); }
.btn-warn { background: var(--surface); border: 1.5px solid #f0caca; color: #b23f3f; }
.btn-lg { height: 56px; padding: 0 34px; font-size: 22px; font-weight: 900; }
.btn-block { width: 100%; }

/* ---------- シート（呪文・先生のパネル） ---------- */
.sheet { position: fixed; inset: 0; z-index: 60; display: flex; align-items: center; justify-content: center; background: rgba(36, 65, 60, .45); padding: calc(var(--sa-t) + 10px) calc(var(--sa-r) + 10px) calc(var(--sa-b) + 10px) calc(var(--sa-l) + 10px); animation: fadein .2s; }
.sheet-box { width: min(600px, 100%); max-height: 100%; display: flex; flex-direction: column; background: var(--surface); border-radius: 22px; box-shadow: 0 20px 50px rgba(0, 0, 0, .25); overflow: hidden; }
.sheet-box.shake { animation: shake .4s; }
@keyframes shake { 20%, 60% { translate: -10px 0; } 40%, 80% { translate: 10px 0; } }
.sh-head { flex: none; display: flex; align-items: center; gap: 8px; padding: 12px 12px 12px 18px; border-bottom: 1px solid var(--line); }
.sh-head h2 { flex: 1; font-family: var(--round); font-weight: 900; font-size: 19px; color: var(--text); }
.sh-x { width: 40px; height: 40px; border-radius: 50%; display: flex; align-items: center; justify-content: center; color: var(--muted); font-size: 22px; }
.sh-x:active { background: var(--bg); }
.sh-body { flex: 1; min-height: 0; overflow-y: auto; overscroll-behavior: contain; touch-action: pan-y; -webkit-overflow-scrolling: touch; padding: 14px 18px 16px; }
.sh-foot { flex: none; display: flex; gap: 8px; justify-content: flex-end; padding: 10px 18px 14px; border-top: 1px solid var(--line); }
.sh-note { font-size: 13px; color: var(--muted); line-height: 1.6; }
.sh-msg { min-height: 1.5em; text-align: center; font-size: 14px; font-weight: 700; color: var(--danger); margin: 6px 0; }
.sh-msg.ok { color: var(--primary-d); }

/* 呪文の入力 */
.spell-ttl { text-align: center; font-family: var(--round); font-weight: 900; font-size: 18px; color: var(--primary-d); margin-bottom: 2px; }
.spell-wrap { display: flex; flex-direction: column; gap: 4px; }
.spell-disp { display: grid; grid-template-columns: repeat(8, minmax(0, 40px)) 40px; justify-content: center; align-items: center; gap: 5px; margin: 8px 0 0; }
.spell-disp span { height: 48px; border-radius: 11px; border: 2px dashed var(--line2); display: flex; align-items: center; justify-content: center; font-family: var(--round); font-weight: 900; font-size: 24px; color: var(--text); }
.spell-disp span.f { border-style: solid; border-color: var(--primary); background: var(--primary-l); }
.spell-disp span.opt { opacity: .5; }
.spell-eye { width: 40px; height: 40px; border-radius: 50%; color: var(--muted); display: flex; align-items: center; justify-content: center; }
.spell-eye svg { width: 22px; height: 22px; }
.kp { display: grid; grid-template-columns: repeat(5, 1fr); gap: 6px; margin-top: 6px; }
.kp button { height: clamp(30px, calc((100vh - 190px) / 6.8), 52px); border-radius: 11px; background: var(--bg); border: 1.5px solid var(--line); font-family: var(--round); font-weight: 700; font-size: 21px; color: var(--text); }
.kp button:active { background: var(--primary-l); border-color: var(--primary-m); }
.kp .blank { visibility: hidden; }
.kp-tabs { display: grid; grid-template-columns: repeat(5, 1fr); gap: 6px; margin-top: 4px; }
.kp-tabs button { height: clamp(30px, calc((100vh - 190px) / 6.8), 46px); border-radius: 11px; border: 1.5px solid var(--line2); background: var(--surface); font-family: var(--round); font-weight: 700; font-size: 15px; color: var(--muted); }
.kp-tabs button.on { background: var(--primary-l); border-color: var(--primary); color: var(--primary-d); }
.kp-tabs .bs { color: var(--danger); }

@media (max-height: 520px) and (min-aspect-ratio: 5/4) {
  .sheet-box.wide { width: min(820px, 100%); }
  .spell-wrap { display: grid; grid-template-columns: 1fr 1.25fr; gap: 14px; align-items: center; }
  .sh-head { padding-top: 6px; padding-bottom: 6px; }
  .sh-body { padding-top: 8px; padding-bottom: 10px; }
}
.spell-ok { margin-top: 6px; }

/* 先生のパネル */
.tabs { flex: none; display: grid; grid-template-columns: repeat(4, 1fr); gap: 4px; padding: 8px 12px 0; border-bottom: 1px solid var(--line); }
.tabs button { height: 42px; border-radius: 12px 12px 0 0; font-family: var(--round); font-weight: 700; font-size: 15px; color: var(--muted); border-bottom: 3px solid transparent; }
.tabs button.on { color: var(--primary-d); border-bottom-color: var(--primary); background: var(--primary-l); }
.sec { margin-bottom: 16px; }
.sec:last-child { margin-bottom: 0; }
.sec-t { font-size: 13px; font-weight: 700; color: var(--muted); margin-bottom: 8px; }
.chips { display: flex; flex-wrap: wrap; gap: 6px; }
.chip { height: 40px; padding: 0 14px; border-radius: 999px; border: 1.5px solid var(--line2); background: var(--surface); font-family: var(--round); font-weight: 700; font-size: 15px; color: var(--text); }
.chip.on { background: var(--primary); border-color: var(--primary); color: #fff; }
.stp-row { display: flex; flex-wrap: wrap; gap: 14px; align-items: center; }
.stp { display: inline-flex; align-items: center; gap: 6px; }
.stp button { width: 44px; height: 44px; border-radius: 50%; border: 1.5px solid var(--line2); background: var(--surface); font-size: 22px; font-weight: 700; color: var(--primary-d); }
.stp b { min-width: 2.4em; text-align: center; font-family: var(--round); font-weight: 900; font-size: 26px; }
.stp span { font-size: 14px; color: var(--muted); font-weight: 700; }
.now { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; padding: 10px 12px; border-radius: 14px; background: var(--bg); margin-bottom: 14px; }
.now b { font-family: var(--round); font-weight: 900; font-size: 18px; }
.now span { flex: 1; font-size: 13px; color: var(--muted); }
.views3 { display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px; }
.views3 button { display: flex; flex-direction: column; align-items: center; gap: 4px; padding: 10px 4px; border-radius: 14px; border: 2px solid var(--line); font-family: var(--round); font-weight: 700; font-size: 14px; }
.views3 button svg, .views3 .vp-chara { width: 34px; height: 34px; }
.views3 button.on { border-color: var(--primary); background: var(--primary-l); color: var(--primary-d); }
.charas8 { display: grid; grid-template-columns: repeat(auto-fill, minmax(64px, 1fr)); gap: 8px; }
.charas8 button { display: flex; flex-direction: column; align-items: center; gap: 2px; padding: 6px 2px; border-radius: 14px; border: 2px solid var(--line); font-size: 12px; font-weight: 700; color: var(--muted); }
.charas8 button .c { width: 46px; height: 46px; }
.charas8 button .c svg { width: 100%; height: 100%; }
.charas8 button.on { border-color: var(--primary); background: var(--primary-l); color: var(--primary-d); }
.mix { display: grid; grid-template-columns: 1fr 1fr; width: 46px; height: 46px; }
.mix svg { width: 23px; height: 23px; }
.tg { display: flex; align-items: center; gap: 10px; padding: 12px 0; border-bottom: 1px solid var(--line); cursor: pointer; }
.tg:last-child { border-bottom: 0; }
.tg span { flex: 1; font-size: 15px; font-weight: 700; color: var(--text); }
.tg small { display: block; font-size: 12px; font-weight: 400; color: var(--muted); margin-top: 2px; line-height: 1.5; }
.tg input { position: absolute; opacity: 0; width: 1px; height: 1px; }
.tg i { flex: none; position: relative; width: 52px; height: 30px; border-radius: 999px; background: var(--line2); transition: background .2s; }
.tg i::after { content: ''; position: absolute; top: 3px; left: 3px; width: 24px; height: 24px; border-radius: 50%; background: #fff; box-shadow: 0 1px 3px rgba(0, 0, 0, .2); transition: transform .2s; }
.tg input:checked + i { background: var(--primary); }
.tg input:checked + i::after { transform: translateX(22px); }
.tg input:focus-visible + i { outline: 3px solid var(--primary-m); outline-offset: 2px; }
.sp-list { display: flex; flex-direction: column; gap: 6px; }
.sp-item { display: flex; align-items: center; gap: 10px; padding: 10px 12px; border-radius: 14px; border: 1.5px solid var(--line); }
.sp-item b { font-family: var(--round); font-weight: 900; font-size: 16px; }
.sp-item span { flex: 1; font-size: 13px; color: var(--muted); }

.toast { position: fixed; left: 50%; bottom: calc(var(--sa-b) + 24px); z-index: 80; transform: translate(-50%, 20px); padding: 12px 20px; border-radius: 999px; background: #24413c; color: #fff; font-size: 15px; font-weight: 700; opacity: 0; pointer-events: none; transition: opacity .25s, transform .25s; white-space: nowrap; max-width: calc(100vw - 24px); overflow: hidden; text-overflow: ellipsis; }
.toast.on { opacity: 1; transform: translate(-50%, 0); }

@media (prefers-reduced-motion: reduce) {
  .app[data-run="running"] .cc .ch { animation: none !important; }
}

/* せまいスマホ（幅360px以下）：みためボタンの文字を1行に */
@media (max-width: 360px) and (max-aspect-ratio: 5/4) {
  .view-pick { gap: 6px; }
  .view-pick button { gap: 3px; font-size: 13px; white-space: nowrap; padding: 0 2px; }
  .view-pick svg, .vp-chara, .vp-chara svg { width: 22px; height: 22px; }
  .kid-btn { font-size: 19px; gap: 6px; }
  .kid-btn svg { width: 26px; height: 26px; }
}

/* ---------- 1・2・3（ロックのボタン）・ロックの印 ---------- */
.seq-btns { flex: none; display: flex; gap: 6px; }
.seq-btns button { width: 40px; height: 40px; border-radius: 12px; background: var(--surface); border: 1.5px solid var(--line2); color: var(--muted); font: 900 18px/1 var(--round); box-shadow: 0 2px 0 var(--line2); transition: transform .08s; }
.seq-btns { position: relative; }
.seq-btns button:active { transform: translateY(2px); box-shadow: none; }
.seq-btns button.hit { animation: seqHit .45s ease-out; }
@keyframes seqHit { 0% { background: var(--primary); color: #fff; border-color: var(--primary); transform: translateY(2px) scale(.94); box-shadow: 0 0 0 5px rgba(58, 158, 143, .35); } 100% { background: var(--surface); color: var(--muted); border-color: var(--line2); transform: none; box-shadow: 0 2px 0 var(--line2); } }
.seq-dots { position: absolute; left: 50%; top: calc(100% + 3px); transform: translateX(-50%); display: flex; gap: 4px; opacity: 0; transition: opacity .2s; pointer-events: none; }
.seq-dots.show { opacity: 1; }
.seq-dots i { width: 8px; height: 8px; border-radius: 50%; border: 1.5px solid var(--primary-m); background: #fff; display: block; }
.seq-dots i.on { background: var(--primary); border-color: var(--primary); }
.seq-dots.ok i { background: #2fb36b; border-color: #2fb36b; }
.seq-dots.ng i { background: #e05252; border-color: #e05252; }
.seq-dots.ng { animation: shake .4s; }
.lock-badge { cursor: pointer; }
.lock-badge { flex: none; display: inline-flex; align-items: center; gap: 4px; height: 34px; padding: 0 10px; border-radius: 999px; background: #fdecea; color: #c0392b; font: 700 14px/1 var(--round); border: 1.5px solid #f5c2bb; }
.lock-badge svg { width: 15px; height: 15px; }
.lock-badge.bump { animation: shake .4s; }
.app.locked .kid-reset, .app.locked .view-pick button:not([aria-checked="true"]), .app.locked .quick button { opacity: .4; }
.app.locked[data-run="running"] .kid-play { background: #f3d9d5; color: #a94434; box-shadow: none; }
.app.locked[data-run="running"] .kid-play svg { display: none !important; }
.app.locked .dial-hint { visibility: hidden; }
@media (max-width: 420px) {
  .topbar { gap: 6px; padding-left: 10px; padding-right: 10px; }
  .seq-btns { gap: 4px; }
  .seq-btns button { width: 34px; height: 34px; font-size: 16px; border-radius: 10px; }
  .teacher-btn { padding: 0 10px; height: 36px; font-size: 13px; }
  .teacher-btn span { display: none; }
  .lock-badge { padding: 0 7px; height: 30px; font-size: 12px; }
  .lock-badge span { display: none; }
}
@media (min-width: 768px) and (min-height: 768px) {
  .seq-btns button { width: 48px; height: 48px; font-size: 21px; }
}

/* ---------- とけい（タイムタイマーの形） ---------- */
.view-rings { gap: 1.2cqmin; }
.rings-svg { width: min(94cqw, 86cqh); height: min(94cqw, 86cqh); touch-action: none; cursor: grab; }
.app.show-num .rings-svg { width: min(92cqw, 74cqh); height: min(92cqw, 74cqh); }
.app.locked .rings-svg { cursor: not-allowed; }
.rings-svg:active { cursor: grabbing; }
.rings-svg:focus { outline: none; }
.rings-svg:focus-visible { outline: 3px solid var(--primary-m); outline-offset: 4px; border-radius: 50%; }
.dial-num { font-family: var(--round); font-weight: 900; fill: var(--text); }
#dialWedge { transition: fill .4s; }
#dialGrip { filter: drop-shadow(0 1px 2px rgba(0, 0, 0, .25)); }
.app[data-run="running"] #dialGrip, .app.locked #dialGrip { display: none; }
.dial-hint { font: 700 clamp(12px, 3.4cqmin, 18px)/1.2 var(--round); color: var(--muted); background: var(--primary-l); padding: .3em .9em; border-radius: 999px; }
.app[data-run="running"] .dial-hint { visibility: hidden; }
.cap.drag { color: var(--primary-d); }
.chip.sw { display: inline-flex; align-items: center; gap: 6px; }
.chip.sw i { width: 16px; height: 16px; border-radius: 50%; display: block; }

/* 先生のパネル：ロックの順番 */
.seq-disp { display: grid; grid-template-columns: repeat(8, minmax(0, 38px)); justify-content: center; gap: 5px; margin: 6px 0 10px; }
.seq-disp span { height: 44px; border-radius: 10px; border: 2px dashed var(--line2); display: flex; align-items: center; justify-content: center; font: 900 22px/1 var(--round); }
.seq-disp span.f { border-style: solid; border-color: var(--primary); background: var(--primary-l); color: var(--primary-d); }
.seq-disp span.opt { opacity: .5; }
.seq-pad { display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px; }
.seq-pad button { height: 56px; border-radius: 14px; background: var(--bg); border: 1.5px solid var(--line2); font: 900 26px/1 var(--round); color: var(--text); }
.seq-pad button:active { background: var(--primary-l); }
.tabs { grid-template-columns: repeat(5, 1fr); }
.tabs button { font-size: 14px; }
