/* おはなしタイマー：明るい空の色で統一した、子ども向けのシール風デザイン */
:root {
  --ink: #23325a; --sky1: #bfe6ff; --sky2: #fff4d1; --yellow: #ffd23f; --pink: #ff8fab; --mint: #7fe0c3;
  --blue: #4a8cff; --white: #ffffff; --dim: #c9d6ee;
  --maru: "Hiragino Maru Gothic ProN", "Hiragino Maru Gothic Pro", "Zen Maru Gothic", "M PLUS Rounded 1c", "BIZ UDPGothic", "Hiragino Sans", "Noto Sans JP", sans-serif;
  color-scheme: light;
}
* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body { margin: 0; min-height: 100vh; color: var(--ink); font-family: var(--maru); line-height: 1.7; background: linear-gradient(180deg, var(--sky1) 0%, #e3f4ff 45%, var(--sky2) 100%) fixed; overflow-x: hidden; }
button { font: inherit; color: inherit; }
:focus-visible { outline: 4px solid var(--blue); outline-offset: 3px; }

.sky { position: fixed; inset: 0; pointer-events: none; z-index: 0; overflow: hidden; }
.cloud { position: absolute; width: 120px; height: 40px; background: #fff; border-radius: 40px; opacity: .8; }
.cloud::before, .cloud::after { content: ""; position: absolute; background: #fff; border-radius: 50%; }
.cloud::before { width: 54px; height: 54px; left: 16px; top: -26px; }
.cloud::after { width: 40px; height: 40px; left: 60px; top: -18px; }
.c1 { top: 60px; left: -20px; } .c2 { top: 150px; right: -30px; transform: scale(.8); }
.bubble { position: absolute; border: 3px solid rgba(255,255,255,.9); border-radius: 50%; }
.b1 { width: 26px; height: 26px; left: 12%; bottom: 18%; } .b2 { width: 16px; height: 16px; right: 14%; bottom: 30%; } .b3 { width: 34px; height: 34px; right: 8%; top: 42%; }

.app { position: relative; z-index: 1; max-width: 560px; margin: 0 auto; padding: calc(18px + env(safe-area-inset-top)) calc(16px + env(safe-area-inset-right)) calc(28px + env(safe-area-inset-bottom)) calc(16px + env(safe-area-inset-left)); }
.head { text-align: center; }
h1 { margin: 0; font-size: 34px; line-height: 1.15; letter-spacing: .06em; color: var(--ink); text-shadow: 3px 3px 0 var(--yellow); }
.br { display: none; }
.lead { margin: 6px 0 0; font-size: 16px; font-weight: 700; }

.stage { margin-top: 14px; background: var(--white); border: 4px solid var(--ink); border-radius: 36px; box-shadow: 6px 6px 0 var(--ink); padding: 18px 16px 20px; text-align: center; }
.hero { position: relative; width: 220px; height: 220px; margin: 0 auto; }
.ring { position: absolute; inset: 0; transform: rotate(-90deg); }
.ring-bg { fill: #eaf6ff; stroke: var(--dim); stroke-width: 14; }
.ring-fg { fill: none; stroke: var(--mint); stroke-width: 14; stroke-linecap: round; stroke-dasharray: 628.3; stroke-dashoffset: 0; transition: stroke-dashoffset .3s linear; }
.pal { position: absolute; left: 30px; top: 26px; width: 160px; height: 160px; overflow: visible; }
.tooth { fill: #fff; stroke: var(--ink); stroke-width: 3.5; stroke-linejoin: round; }
.cheek { fill: var(--pink); opacity: .7; }
.eyes circle { fill: var(--ink); } .eyes .shine { fill: #fff; }
.mouth { fill: none; stroke: var(--ink); stroke-width: 3; stroke-linecap: round; }
.spark { fill: var(--yellow); stroke: var(--ink); stroke-width: 1.5; }
.brush rect { fill: var(--blue); stroke: var(--ink); stroke-width: 2.5; }
.brush .bristle { fill: var(--mint); }
.brush { transform-origin: 90px 70px; }

.time { margin: 6px 0 2px; font-size: 52px; font-weight: 800; line-height: 1; letter-spacing: .04em; font-variant-numeric: tabular-nums; }
.stars { list-style: none; padding: 0; margin: 10px 0 14px; display: flex; justify-content: center; gap: 8px; }
.stars li { width: 34px; height: 34px; }
.stars svg { width: 100%; height: 100%; }
.stars path { fill: #fff; stroke: var(--dim); stroke-width: 2.5; stroke-linejoin: round; transition: fill .3s; }
.stars .done path { fill: var(--yellow); stroke: var(--ink); }
.stars .now path { fill: #fff3b8; stroke: var(--ink); }

.where { display: flex; align-items: center; gap: 12px; background: #eaf6ff; border-radius: 24px; padding: 8px 14px; margin: 0 auto 16px; max-width: 420px; }
.mouth-map { width: 110px; height: 96px; flex: none; }
.where-text { margin: 0; text-align: left; line-height: 1.35; display: flex; flex-direction: column; }
.where-text b { font-size: 26px; font-weight: 800; }
.where-text span { font-size: 17px; font-weight: 700; }
.mouth-map .gum { fill: #ffd0dc; }
.mouth-map .t { fill: #fff; stroke: var(--ink); stroke-width: 1.8; }
.mouth-map .t.hot { fill: var(--yellow); }
.mouth-map .arc { fill: none; stroke: var(--blue); stroke-width: 6; stroke-linecap: round; }
.mouth-map .off { opacity: .3; }
.mouth-map .lbl { font-size: 13px; font-weight: 800; fill: var(--ink); font-family: var(--maru); }

.controls { display: flex; flex-direction: column; align-items: center; gap: 8px; }
.big { min-width: 230px; min-height: 68px; border: 4px solid var(--ink); border-radius: 999px; font-size: 24px; font-weight: 800; cursor: pointer; box-shadow: 0 6px 0 var(--ink); letter-spacing: .08em; }
.big:active { transform: translateY(4px); box-shadow: 0 2px 0 var(--ink); }
.go { background: var(--pink); color: #fff; text-shadow: 0 2px 0 rgba(35,50,90,.35); }
.pause { background: var(--yellow); }
.small { border: 0; background: none; text-decoration: underline; text-underline-offset: 4px; padding: 10px 14px; cursor: pointer; font-weight: 700; font-size: 15px; }

.story { margin-top: 18px; background: #fffdf3; border: 4px solid var(--ink); border-radius: 28px 28px 28px 8px; padding: 16px 20px 18px; box-shadow: 6px 6px 0 var(--yellow); }
.story-label { margin: 0; font-size: 13px; font-weight: 800; color: #6a7aa6; }
.story h2 { margin: 2px 0 6px; font-size: 21px; line-height: 1.45; }
.story-text { margin: 0; font-size: 20px; line-height: 1.9; min-height: 3.8em; }

.pick { margin-top: 22px; }
.pick h2 { font-size: 18px; margin: 0 0 10px; text-align: center; }
.books { display: grid; grid-template-columns: repeat(2, 1fr); gap: 10px; }
.book { position: relative; display: flex; align-items: center; gap: 10px; min-height: 72px; text-align: left; padding: 10px 12px; border: 3px solid var(--ink); border-radius: 18px; background: #fff; cursor: pointer; font-size: 14px; font-weight: 700; line-height: 1.35; box-shadow: 0 4px 0 var(--ink); }
.book[aria-checked="true"] { background: #fff3b8; }
.book[aria-checked="true"]::after { content: "これにする！"; position: absolute; top: -10px; right: 8px; background: var(--pink); color: #fff; border: 2px solid var(--ink); border-radius: 999px; font-size: 11px; padding: 0 8px; }
.book:disabled { cursor: default; opacity: .6; }
.book .cover { flex: none; width: 40px; height: 40px; border-radius: 12px; border: 2.5px solid var(--ink); display: grid; place-items: center; }
.book .cover svg { width: 26px; height: 26px; }
.switch { display: flex; align-items: center; justify-content: center; gap: 10px; margin: 16px auto 0; font-weight: 800; cursor: pointer; min-height: 48px; width: fit-content; position: relative; }
.switch input { position: absolute; opacity: 0; width: 1px; height: 1px; }
.knob { width: 56px; height: 32px; border: 3px solid var(--ink); border-radius: 999px; background: #fff; position: relative; transition: background .2s; }
.knob::after { content: ""; position: absolute; top: 3px; left: 3px; width: 20px; height: 20px; border-radius: 50%; background: var(--ink); transition: transform .2s; }
.switch input:checked + .knob { background: var(--mint); }
.switch input:checked + .knob::after { transform: translateX(24px); }
.switch input:focus-visible + .knob { outline: 4px solid var(--blue); outline-offset: 3px; }
.count { text-align: center; font-weight: 800; margin: 10px 0 0; min-height: 1.5em; }

.foot { margin-top: 30px; font-size: 12px; text-align: center; color: #3e4c74; }
.foot p { margin: 4px 0; }
.foot a { color: var(--ink); font-weight: 700; }

/* 歯みがき中だけ、キャラクターが動く */
.running .brush { animation: scrub .5s ease-in-out infinite alternate; }
.running .pal-body { animation: bob 1.2s ease-in-out infinite; }
.done-state .pal-body { animation: hop .6s ease-in-out 3; }
.done-state .spark { animation: twinkle .8s ease-in-out infinite alternate; }
@keyframes scrub { from { transform: translate(-4px, 3px) rotate(-6deg); } to { transform: translate(4px, -3px) rotate(6deg); } }
@keyframes bob { 50% { transform: translateY(-4px); } }
@keyframes hop { 50% { transform: translateY(-14px); } }
@keyframes twinkle { to { transform: scale(1.3); opacity: .6; } }
.spark { transform-box: fill-box; transform-origin: center; opacity: 0; }
.done-state .spark, .idle .spark { opacity: 1; }

@media (max-width: 360px) { .br { display: inline; } .where-text b { font-size: 22px; } .mouth-map { width: 90px; } .books { grid-template-columns: 1fr; } }
@media (min-width: 720px) { h1 { font-size: 44px; } }
@media (prefers-reduced-motion: reduce) { *, *::before, *::after { animation: none !important; transition: none !important; } }

/* 仕上げ：本だなのように横にならべる */
h1, h2 { text-wrap: balance; }
p { text-wrap: pretty; }
.ln { display: inline-block; }
.books { display: flex; gap: 12px; overflow-x: auto; scroll-snap-type: x mandatory; scroll-padding-inline: 16px; padding: 14px 4px 14px; margin: 0 -16px; padding-left: 16px; padding-right: 16px; scrollbar-width: none; }
.books::-webkit-scrollbar { display: none; }
.book { flex: 0 0 158px; flex-direction: column; align-items: stretch; text-align: center; min-height: 0; padding: 10px 10px 12px; scroll-snap-align: start; gap: 8px; }
.book .cover { width: 100%; height: 88px; border-radius: 12px; }
.book .cover svg { width: 46px; height: 46px; }
.book .name { display: flex; flex-direction: column; font-size: 13px; white-space: nowrap; line-height: 1.4; }
.book .name .ln { display: block; }
.book[aria-checked="true"]::after { top: -12px; right: auto; left: 50%; transform: translateX(-50%); white-space: nowrap; font-size: 12px; padding: 1px 10px; }
.pick h2 { margin-bottom: 0; }
.parent { text-align: left; background: rgba(255,255,255,.6); border-radius: 14px; padding: 10px 14px; margin: 0 0 10px !important; line-height: 1.7; }
.foot a { display: inline-block; padding: 8px; }
.where-text { word-break: keep-all; overflow-wrap: anywhere; }

/* できたときの、ぱちぱち */
.burst { position: absolute; left: 50%; top: 50%; width: 0; height: 0; z-index: 2; pointer-events: none; }
.burst i { position: absolute; left: -7px; top: -7px; width: 14px; height: 14px; border-radius: 50%; background: var(--yellow); border: 2px solid var(--ink); opacity: 0; }
.burst i:nth-child(2n) { background: var(--pink); }
.burst i:nth-child(3n) { background: var(--mint); border-radius: 3px; }
@media (prefers-reduced-motion: no-preference) {
  .done-state .burst i { animation: pop 1s ease-out both; }
  .done-state .burst i:nth-child(1) { --dx: 0px; --dy: -120px; }
  .done-state .burst i:nth-child(2) { --dx: 86px; --dy: -86px; animation-delay: .05s; }
  .done-state .burst i:nth-child(3) { --dx: 120px; --dy: 0px; animation-delay: .1s; }
  .done-state .burst i:nth-child(4) { --dx: 86px; --dy: 86px; animation-delay: .05s; }
  .done-state .burst i:nth-child(5) { --dx: 0px; --dy: 120px; }
  .done-state .burst i:nth-child(6) { --dx: -86px; --dy: 86px; animation-delay: .1s; }
  .done-state .burst i:nth-child(7) { --dx: -120px; --dy: 0px; animation-delay: .05s; }
  .done-state .burst i:nth-child(8) { --dx: -86px; --dy: -86px; animation-delay: .1s; }
}
@keyframes pop { 0% { opacity: 1; transform: translate(0, 0) scale(.4); } 70% { opacity: 1; } 100% { opacity: 0; transform: translate(var(--dx), var(--dy)) scale(1.1); } }
.done-state .ring-fg { stroke: var(--yellow); }
/* じぶんで つくる おはなし */
.books .fc-item { position: relative; display: grid; }
.books .fc-x { position: absolute; right: -6px; bottom: -6px; width: 34px; height: 34px; border-radius: 50%; border: 2.5px solid var(--ink); background: #fff; color: var(--ink); font-size: 16px; font-weight: 800; line-height: 1; cursor: pointer; font-family: var(--maru); padding: 0; }
.book.add { justify-content: center; border-style: dashed; box-shadow: none; background: rgba(255,255,255,.6); color: var(--ink); font-size: 15px; font-family: var(--maru); }
.fc-form { display: grid; grid-template-columns: minmax(0, 1fr); gap: 6px; margin-top: 12px; }
.fc-form[hidden] { display: none; }
.fc-row { display: flex; gap: 8px; align-items: center; }
.fc-in { flex: 1; min-width: 0; min-height: 52px; border: 3px solid var(--ink); border-radius: 16px; background: #fff; color: var(--ink); padding: 8px 14px; font-family: var(--maru); font-size: 17px; font-weight: 700; }
.fc-in[aria-invalid=true] { border-color: #d6336c; }
.fc-ok { min-height: 52px; padding: 0 18px; border: 3px solid var(--ink); border-radius: 999px; background: var(--pink); color: #fff; font-family: var(--maru); font-size: 17px; font-weight: 800; cursor: pointer; flex: none; box-shadow: 0 4px 0 var(--ink); text-shadow: 0 1px 0 rgba(35,50,90,.35); }
.fc-no { min-height: 52px; border: 0; background: none; color: var(--ink); font-family: var(--maru); font-weight: 700; text-decoration: underline; text-underline-offset: 3px; cursor: pointer; flex: none; }
.fc-err { margin: 0; color: #c2255c; font-weight: 800; font-size: 14px; text-align: center; }
.fc-err:empty { display: none; }
.books .fc-item { flex: 0 0 158px; scroll-snap-align: start; }
.book.add { justify-content: center; align-items: center; min-height: 150px; }

/* iPhone (WebKit) keeps a fieldset at least as wide as its content; let it shrink so nothing overflows narrow screens */
fieldset{min-width:0;min-inline-size:0}
input,select,textarea{max-width:100%}
