@font-face { font-family: "Klee One"; src: url("fonts/KleeOne-Regular.subset.woff2") format("woff2"); font-weight: 400; font-display: swap; }
:root {
  --bg: #fbf4e2; --card: #fffdf6; --ink: #2b2a33; --soft: #8c8576; --line: #e6dcc0;
  --accent: #1f6f8b; --accent-ink: #fff; --star: #f2b01e; --ok: #3d8b5f; --off: #d9d2bd;
  --font: "Klee One", "Hiragino Maru Gothic ProN", "Hiragino Sans", system-ui, sans-serif;
}
* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }
html, body { margin: 0; height: 100%; background: var(--bg); color: var(--ink); font-family: var(--font); overflow: hidden; overscroll-behavior: none; -webkit-user-select: none; user-select: none; -webkit-touch-callout: none; }
button { font: inherit; color: inherit; border: 0; background: none; cursor: pointer; touch-action: manipulation; }
button:disabled { cursor: default; }
#app { height: 100%; padding: env(safe-area-inset-top) env(safe-area-inset-right) env(safe-area-inset-bottom) env(safe-area-inset-left); }
#rotate { display: none; position: fixed; inset: 0; background: var(--bg); align-items: center; justify-content: center; font-size: 28px; z-index: 9; }
@media (orientation: portrait) and (max-width: 900px) { #rotate { display: flex; } }

.screen { height: 100%; display: flex; flex-direction: column; }
.top { display: flex; align-items: center; gap: 14px; padding: 14px 24px 8px; }
.top h1 { font-size: 30px; margin: 0; font-weight: 400; flex: 1; letter-spacing: .04em; }
.stars-total { font-size: 26px; display: flex; align-items: center; gap: 6px; min-width: 90px; justify-content: flex-end; }
.star { width: 1em; height: 1em; fill: var(--star); flex: none; }
.star.off { fill: var(--off); }
.chips { display: flex; gap: 8px; }
.chip { height: 44px; padding: 0 16px; border-radius: 22px; background: var(--card); border: 2px solid var(--line); font-size: 18px; display: flex; align-items: center; gap: 6px; }
.chip[aria-pressed="true"] { background: var(--accent); color: var(--accent-ink); border-color: var(--accent); }
.chip.nov { opacity: .45; text-decoration: line-through; }
.tabs { display: flex; gap: 10px; padding: 6px 24px 10px; }
.tab { height: 52px; padding: 0 22px; border-radius: 26px; font-size: 22px; background: transparent; border: 2px solid var(--line); }
.tab[aria-selected="true"] { background: var(--ink); color: var(--bg); border-color: var(--ink); }
.tab small { font-size: 15px; opacity: .6; margin-left: 6px; }
.grid { flex: 1; overflow-y: auto; -webkit-overflow-scrolling: touch; padding: 6px 24px 28px; display: grid; grid-template-columns: repeat(4, 1fr); gap: 18px; align-content: start; }
.car { background: var(--card); border: 2px solid var(--line); border-radius: 22px; overflow: hidden; display: flex; flex-direction: column; }
.car .pic { display: block; width: 100%; aspect-ratio: 3 / 2; object-fit: cover; background: #f6efd9; }
.car .meta { display: flex; align-items: center; gap: 8px; padding: 8px 10px 10px 14px; }
.car .name { flex: 1; font-size: 20px; line-height: 1.25; min-width: 0; }
.rbtn { width: 48px; height: 48px; border-radius: 24px; background: var(--bg); border: 2px solid var(--line); display: grid; place-items: center; flex: none; }
.rbtn svg { width: 24px; height: 24px; fill: none; stroke: var(--ink); stroke-width: 2; stroke-linecap: round; stroke-linejoin: round; }
.rbtn.go { background: var(--accent); border-color: var(--accent); }
.rbtn.go svg { stroke: #fff; }
.rbtn:disabled { background: #efe9d6; border-color: #e7e0c8; }
.rbtn:disabled svg { stroke: #c4bda6; }
.rbtn.speaking { background: #dcebf0; border-color: var(--accent); }
.car .done { display: flex; gap: 2px; font-size: 14px; padding: 0 14px 8px; color: var(--soft); min-height: 22px; }

.trace { flex-direction: row; }
.side { width: 360px; padding: 18px 8px 18px 24px; display: flex; flex-direction: column; gap: 14px; }
.side .pic { width: 100%; aspect-ratio: 3/2; object-fit: cover; border-radius: 20px; border: 2px solid var(--line); }
.side .cname { font-size: 26px; display: flex; align-items: center; gap: 10px; }
.side .cname span { flex: 1; }
.letters { display: flex; flex-wrap: wrap; gap: 8px; }
.letter { min-width: 44px; height: 52px; padding: 0 6px; border-radius: 12px; border: 2px solid var(--line); background: var(--card); font-size: 28px; display: grid; place-items: center; }
.letter.cur { border-color: var(--accent); background: #dcebf0; }
.letter.done { background: var(--ok); border-color: var(--ok); color: #fff; }
.stage { flex: 1; display: flex; flex-direction: column; align-items: center; padding: 14px 24px 18px 8px; gap: 10px; min-width: 0; }
.stage .bar { width: 100%; display: flex; align-items: center; gap: 12px; }
.stage .mode { flex: 1; font-size: 28px; }
.pad { flex: 1; aspect-ratio: 1; max-height: 100%; background: var(--card); border: 3px solid var(--line); border-radius: 26px; position: relative; touch-action: none; }
.pad svg { position: absolute; inset: 0; width: 100%; height: 100%; touch-action: none; }
.pad .glyph { font-family: var(--font); fill: #d8d2c0; }
.pad .cross { stroke: #eee6cf; stroke-width: .5; stroke-dasharray: 2 2; }
.pad .ink { fill: none; stroke: var(--ink); stroke-width: 4.2; stroke-linecap: round; stroke-linejoin: round; }
.pad .ink.live { stroke: var(--accent); }
.pad .ink.fail { animation: fade .5s forwards; stroke: #c9573d; }
@keyframes fade { to { opacity: 0; } }
.pad .good { fill: none; stroke: var(--ink); stroke-width: 4.4; stroke-linecap: round; stroke-linejoin: round; }
.pad .hintline { fill: none; stroke: var(--accent); stroke-width: 1.2; stroke-dasharray: 3 3; opacity: .7; }
.pad .hintdot { fill: var(--accent); }
.pad .hintarrow { fill: none; stroke: var(--accent); stroke-width: 2.4; stroke-linecap: round; stroke-linejoin: round; }
.btn { height: 56px; padding: 0 28px; border-radius: 28px; font-size: 24px; background: var(--card); border: 2px solid var(--line); }
.btn.primary { background: var(--accent); color: #fff; border-color: var(--accent); }
.btn.small { height: 46px; font-size: 19px; padding: 0 18px; }

.complete { align-items: center; justify-content: center; gap: 22px; text-align: center; }
.complete .big { font-size: 96px; letter-spacing: .06em; }
.complete .row { display: flex; gap: 14px; font-size: 96px; }
.complete .row .star { animation: pop .5s both; }
.complete .row .star:nth-child(2) { animation-delay: .15s; }
.complete .row .star:nth-child(3) { animation-delay: .3s; }
@keyframes pop { from { transform: scale(.2); opacity: 0; } to { transform: none; opacity: 1; } }
.complete .ch { font-size: 120px; line-height: 1; color: var(--accent); }
.complete .acts { display: flex; gap: 20px; margin-top: 8px; }
.complete .btn { height: 72px; font-size: 30px; padding: 0 40px; border-radius: 36px; }
.note { font-size: 14px; color: var(--soft); text-align: center; padding: 6px 24px 10px; }
.note a { color: inherit; }
@media (prefers-reduced-motion: reduce) { .complete .row .star { animation: none; } }
.car .pic { flex: none; }
.car .meta { flex: none; }
.chip { white-space: nowrap; }
.side .chip { height: 40px; padding: 0 11px; font-size: 15px; }
.pad .hintline { stroke-width: .8; opacity: .55; }
.grid { grid-auto-rows: max-content; }
.pad .ink { stroke-width: 2.8; }
.pad .good { stroke-width: 3; }

/* ---------- v2：塗り絵・さくひん ---------- */
.gal { display: flex; align-items: center; gap: 6px; }
.gal svg { width: 22px; height: 22px; fill: none; stroke: currentColor; stroke-width: 2; stroke-linecap: round; stroke-linejoin: round; }
.gal small { opacity: .6; }
.car { cursor: pointer; }
.nurie, .gallery { gap: 0; }
.ntop { display: flex; align-items: center; gap: 10px; padding: 12px 24px 8px; }
.ntop .nname { flex: 1; font-size: 28px; min-width: 0; }
.ntop .btn { display: flex; align-items: center; gap: 6px; }
.ntop .btn svg { width: 22px; height: 22px; fill: none; stroke: currentColor; stroke-width: 2; stroke-linecap: round; stroke-linejoin: round; }
.btn[aria-pressed="true"] { background: var(--ink); color: var(--bg); border-color: var(--ink); }
.btn:disabled { opacity: .4; }
.btn.speaking { background: #dcebf0; border-color: var(--accent); }
.nbody { flex: 1; display: flex; gap: 16px; padding: 4px 24px 18px; min-height: 0; }
.side-tools { width: 190px; display: flex; flex-direction: column; gap: 12px; flex: none; }
.palette { display: grid; grid-template-columns: repeat(3, 1fr); gap: 10px; }
.sw { aspect-ratio: 1; border-radius: 50%; background: var(--c); border: 3px solid var(--line); box-shadow: inset 0 0 0 2px rgba(255,255,255,.55); }
.sw[aria-checked="true"] { border-color: var(--ink); transform: scale(1.12); box-shadow: 0 0 0 3px var(--bg), 0 0 0 6px var(--ink); }
.tool { width: 100%; }
.done-btn { height: 64px; border-radius: 32px; font-size: 26px; margin-top: auto; background: var(--accent); color: #fff; border: 2px solid var(--accent); }
.canvas-wrap { flex: 1; position: relative; min-width: 0; display: grid; place-items: center; background: #fff; border: 3px solid var(--line); border-radius: 22px; overflow: hidden; }
.canvas-wrap canvas { max-width: 100%; max-height: 100%; width: auto; height: auto; aspect-ratio: 3 / 2; touch-action: none; display: block; }
.canvas-wrap .real { position: absolute; right: 12px; top: 12px; width: 30%; border-radius: 14px; border: 3px solid var(--line); box-shadow: 0 4px 14px rgba(0,0,0,.18); pointer-events: none; background: #fff; }
.canvas-wrap .story { position: absolute; left: 12px; bottom: 12px; right: 12px; background: rgba(255,253,246,.94); border: 2px solid var(--line); border-radius: 18px; padding: 10px 18px; font-size: 26px; line-height: 1.4; pointer-events: none; }
.story .sub { font-size: 18px; color: var(--soft); }
.canvas-wrap .loading { position: absolute; font-size: 40px; color: var(--soft); }
.gallery .works .car.new { border-color: var(--accent); }
.gallery .empty { grid-column: 1 / -1; text-align: center; padding: 60px 0; font-size: 24px; color: var(--soft); }
.lightbox { position: fixed; inset: 0; background: rgba(251,244,226,.97); display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 22px; z-index: 5; }
.lightbox img { max-width: 80%; max-height: 66%; border-radius: 20px; border: 3px solid var(--line); background: #fff; }
.lightbox .acts { display: flex; gap: 18px; }
.complete .say { font-size: 30px; max-width: 80%; line-height: 1.4; }

/* ---------- 京王線 型番えらび浮層 ---------- */
.overlay { position: fixed; inset: 0; background: rgba(40, 30, 10, .5); display: flex; align-items: center; justify-content: center; z-index: 50; }
.overlay .sheet { position: relative; width: min(1000px, 94vw); max-height: 90vh; overflow-y: auto; background: var(--bg, #fffaf0); border-radius: 28px; padding: 28px 28px 32px; }
.overlay h2 { margin: 0 64px 16px 4px; font-size: 32px; }
.overlay .close { position: absolute; top: 14px; right: 14px; width: 64px; height: 64px; border-radius: 32px; border: 0; background: var(--card); font-size: 34px; line-height: 1; cursor: pointer; }
.overlay .grid.pick { padding: 0; overflow: visible; grid-template-columns: repeat(3, 1fr); }

/* ---------- v3：進度・かぞえる・おうちのひと ---------- */
.garage { position: relative; }
.corner { position: absolute; left: 0; top: 0; width: 110px; height: 72px; z-index: 4; -webkit-touch-callout: none; }
.car .done { display: none; }
.prog { display: flex; gap: 8px; padding: 0 12px 12px; align-items: center; }
.pb { height: 44px; min-width: 52px; padding: 0 12px; border-radius: 22px; border: 2px solid var(--line); background: #efe9d6; display: flex; align-items: center; justify-content: center; gap: 4px; font-size: 16px; }
.pb svg { width: 22px; height: 22px; fill: none; stroke: #b9b19a; stroke-width: 2; stroke-linecap: round; stroke-linejoin: round; }
.pb small { font-size: 13px; color: var(--soft); }
.pb.on { background: var(--star); border-color: #d99a0f; }
.pb.on svg { stroke: #fff; } .pb.on small { color: #fff; }
.pb.nur { margin-left: auto; background: var(--accent); border-color: var(--accent); color: #fff; }
.pb.nur svg { stroke: #fff; }
.pb:disabled { opacity: .4; }
.overlay .grid.pick .prog { padding-top: 0; }

.count .ntop .lv { font-size: 24px; padding: 4px 16px; border-radius: 20px; background: var(--ink); color: var(--bg); }
.count .dots { display: flex; gap: 6px; font-size: 34px; min-width: 130px; }
.count .qtext { text-align: center; font-size: 34px; padding: 2px 0 6px; }
.count .swrap { flex: 1; min-height: 0; display: flex; align-items: center; justify-content: center; padding: 0 24px; }
.count .scene { position: relative; overflow: hidden; border: 3px solid var(--line); border-radius: 26px; background: #9fd4f5; box-sizing: content-box; flex: none; user-select: none; -webkit-user-select: none; touch-action: manipulation; }
.count .scene .bg { position: absolute; inset: 0; width: 100%; height: 100%; object-fit: cover; pointer-events: none; }
.sp { position: absolute; transform: translate(-50%, -100%); }
.sp .bob { transform-origin: 50% 100%; }
.sp img { display: block; width: 100%; height: auto; pointer-events: none; -webkit-user-drag: none; }
.sp.item { cursor: pointer; -webkit-tap-highlight-color: transparent; }
.sp.parked { pointer-events: none; }
.sp.person { transition: left 1.2s linear, opacity .5s; }
.sp.veh.drive { transition: left 1.5s cubic-bezier(.5, 0, 1, 1); }
.sp.person.fade { opacity: 0; transition: left 1s ease-in-out, opacity .4s .75s; }
.sp.walking .bob { animation: step .32s ease-in-out infinite alternate; }
@keyframes step { from { transform: translateY(0) rotate(-2deg); } to { transform: translateY(-4%) rotate(2deg); } }
.sp .bob.jump { animation: jump .45s ease-out; }
@keyframes jump { 0% { transform: none; } 35% { transform: translateY(-16%) scale(1.06, 1.1); } 70% { transform: translateY(0) scale(1.05, .92); } 100% { transform: none; } }
.sp .badge { position: absolute; left: 50%; top: -2%; transform: translate(-50%, -100%); min-width: calc(var(--u) * 5); height: calc(var(--u) * 5); line-height: calc(var(--u) * 5); border-radius: 50%; background: var(--star); color: #fff; border: 3px solid #fff; box-shadow: 0 3px 8px rgba(0,0,0,.28); font-size: calc(var(--u) * 3.4); text-align: center; font-weight: 700; animation: pop .35s both; pointer-events: none; z-index: 5; }
.sp.veh .badge { top: 8%; }
.count .nums { display: flex; gap: 22px; justify-content: center; padding: 16px 24px 22px; }
.num { position: relative; width: 240px; height: 150px; border-radius: 34px; font-size: 100px; line-height: 1; background: var(--card); border: 4px solid var(--line); box-shadow: 0 6px 0 var(--line); font-family: var(--font); }
.num:active { transform: translateY(3px); box-shadow: 0 3px 0 var(--line); }
.num.ok { background: #e3f3e8; border-color: var(--ok); box-shadow: 0 6px 0 var(--ok); }
.num.shake { animation: shake .45s; }
@keyframes shake { 0%,100% { transform: none; } 20% { transform: translateX(-12px) rotate(-2deg); } 45% { transform: translateX(10px) rotate(2deg); } 70% { transform: translateX(-6px); } }
.burst { position: absolute; inset: 0; pointer-events: none; }
.burst .star { position: absolute; left: 50%; top: 40%; width: 44px; height: 44px; margin: -22px; animation: fly .9s ease-out both; }
.burst .star:nth-child(1) { --dx: -110px; --dy: -70px; } .burst .star:nth-child(2) { --dx: -55px; --dy: -120px; }
.burst .star:nth-child(3) { --dx: 0px; --dy: -140px; } .burst .star:nth-child(4) { --dx: 55px; --dy: -120px; } .burst .star:nth-child(5) { --dx: 110px; --dy: -70px; }
@keyframes fly { from { transform: scale(.2); opacity: 0; } 30% { opacity: 1; } to { transform: translate(var(--dx), var(--dy)) scale(1.1); opacity: 0; } }
.count .toast { position: fixed; inset: 0; background: rgba(251,244,226,.9); display: flex; align-items: center; justify-content: center; z-index: 20; }
.count .toast[hidden] { display: none; }
.tbox { text-align: center; display: flex; flex-direction: column; gap: 14px; align-items: center; }
.tbox .big { font-size: 64px; } .tbox .sub { font-size: 30px; color: var(--soft); }
.tbox .acts { display: flex; gap: 18px; margin-top: 10px; }
.tbox .btn { height: 68px; font-size: 28px; padding: 0 34px; border-radius: 34px; }

.celebrate .sheet { text-align: center; display: flex; flex-direction: column; align-items: center; gap: 18px; width: min(640px, 90vw); overflow: hidden; }
.celebrate .pic { width: 70%; aspect-ratio: 3/2; object-fit: cover; border-radius: 22px; border: 3px solid var(--line); animation: pop .6s both; }
.celebrate .big { font-size: 52px; }
.celebrate .acts { display: flex; gap: 16px; }
.celebrate .btn { height: 68px; font-size: 28px; display: flex; align-items: center; gap: 8px; border-radius: 34px; }
.celebrate .btn svg { width: 26px; height: 26px; fill: none; stroke: currentColor; stroke-width: 2; stroke-linecap: round; stroke-linejoin: round; }
.confetti { position: absolute; inset: 0; pointer-events: none; }
.confetti i { position: absolute; left: calc(var(--i) * 7.2%); top: -40px; width: 36px; height: 36px; animation: fall 2.4s calc(var(--i) * .11s) ease-in both; }
.confetti .star { width: 100%; height: 100%; }
@keyframes fall { to { transform: translateY(560px) rotate(300deg); opacity: .2; } }
@media (prefers-reduced-motion: reduce) { .confetti i, .burst .star { animation: none; } }
.complete .acts .btn svg { width: 30px; height: 30px; fill: none; stroke: currentColor; stroke-width: 2; stroke-linecap: round; stroke-linejoin: round; vertical-align: -5px; margin-right: 6px; }
.complete .acts { flex-wrap: wrap; justify-content: center; }
.complete .acts .btn { padding: 0 30px; }

.settings .sheet { width: min(720px, 92vw); }
.srow { display: flex; align-items: center; justify-content: space-between; gap: 20px; padding: 18px 4px; border-top: 2px solid var(--line); font-size: 26px; }
.srow small { display: block; font-size: 15px; color: var(--soft); margin-top: 4px; }
.switch { width: 92px; height: 52px; border-radius: 26px; background: var(--off); position: relative; flex: none; }
.switch i { position: absolute; left: 4px; top: 4px; width: 44px; height: 44px; border-radius: 50%; background: #fff; transition: left .15s; }
.switch[aria-checked="true"] { background: var(--ok); }
.switch[aria-checked="true"] i { left: 44px; }
.btn.danger { background: #c9573d; color: #fff; border-color: #c9573d; }
.count .swrap { position: relative; }
.eqhint { position: absolute; top: 14px; left: 0; right: 0; margin: 0 auto; width: fit-content; padding: 6px 40px; border-radius: 30px; background: rgba(255,255,255,.94); border: 4px solid var(--star); font-size: 96px; line-height: 1.15; font-weight: 700; letter-spacing: .06em; z-index: 20; pointer-events: none; animation: pop .35s both; }
