/* お風呂に入らない弟：見た目と動き。
   匂いの段階＝body[data-stage]／絵の描き方＝body[data-style]（soft＝面と光、line＝線）／場面＝body[data-view][data-art] */
:root {
  --ink: #26221d;
  --ink-2: #6f665b;
  --paper: #f4efe6;
  --card: #fffdf8;
  --line: #dcd4c6;
  --haze: #b9b39c;
  --haze-a: 0;
  --wall: #f5ecdc;
  --floor: #d6b081;
  --wood: #b98a5b;
  --wood-d: #9a6f44;
  --curtain: #e58f72;
  --curtain-d: #c96f55;
  --skin: #f6cfab;
  --hair: #2e2823;
  --blush: #f2907f;
  --blanket: #e9ae3f;
  --blanket-d: #c2831d;
  --mat: #fdfbf6;
  --pillow: #e3ecf2;
  --olc: transparent;
  --olw: 0px;
  --ease: cubic-bezier(.2, .8, .2, 1);
  --t: 190ms;
  --safe-b: env(safe-area-inset-bottom, 0px);
  --safe-t: env(safe-area-inset-top, 0px);
}
body[data-style="line"] { --olc: var(--ink); --olw: 3px; }
body[data-stage="faint"] { --paper: #efecdb; --haze: #9c9b47; --haze-a: .5; }
body[data-stage="meat"] { --paper: #eddac7; --haze: #a5512f; --haze-a: .9; }
body[data-stage="shift"] { --paper: #e7e0d6; --haze: #7d6f8a; --haze-a: .6; }
body[data-stage="clear"] { --paper: #eef4f1; --haze: #74b39c; --haze-a: 0; }
body[data-stage="wood"] { --paper: #e5efdb; --haze: #4f8a43; --haze-a: .35; }
body[data-stage="solemn"] { --paper: #e7e0f4; --haze: #6a4fa8; --haze-a: .5; }
body[data-stage="amber"] { --paper: #f8e7b2; --haze: #c98f0e; --haze-a: .7; }
/* 神木の香りの後の段階（作った段階。中の名前は forest〜star のまま）：古社＝古い木の茶・伽羅＝金・蘭奢待＝えんじと金・高天原＝白に近い金。どんどん明るく、神々しく */
body[data-stage="forest"] { --paper: #ece3d2; --haze: #7a5634; --haze-a: .45; }
body[data-stage="flower"] { --paper: #f6ebcc; --haze: #b8862b; --haze-a: .55; }
body[data-stage="sky"] { --paper: #f4e2d6; --haze: #8e2b2b; --haze-a: .5; }
body[data-stage="star"] { --paper: #fbf6e3; --haze: #d9a92c; --haze-a: .6; }

* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }
html, body { height: 100%; margin: 0; }
body {
  font-family: "Hiragino Sans", "Hiragino Kaku Gothic ProN", "Yu Gothic UI", "Yu Gothic", "Noto Sans JP", system-ui, sans-serif;
  color: var(--ink);
  background: var(--paper);
  transition: background-color 600ms linear;
  overflow: hidden;
  overscroll-behavior: none;
  -webkit-user-select: none;
  user-select: none;
  touch-action: manipulation;
}
button { font: inherit; color: inherit; border: 0; background: none; padding: 0; cursor: pointer; }
svg { display: block; }
[hidden] { display: none !important; }

#app {
  height: 100dvh;
  max-width: 480px;
  margin: 0 auto;
  display: flex;
  flex-direction: column;
  padding: calc(var(--safe-t) + 14px) 18px calc(var(--safe-b) + 14px);
}

/* ---------- 上：日数と匂い ---------- */
/* 「スキップ」は数字の上に置く（横に並べると、3けたの日数・弟の話の数が出たときに、右のアイコンが画面からはみ出す） */
.top { display: flex; align-items: flex-end; justify-content: space-between; gap: 8px; }
.count { display: grid; grid-template-columns: auto auto; justify-content: start; align-items: baseline; column-gap: 6px; row-gap: 6px; line-height: 1; }
.count-label { grid-column: 1 / -1; }
.count-label, .count-unit { font-size: 14px; font-weight: 700; color: var(--ink-2); letter-spacing: .04em; }
.count-num { font-size: 60px; font-weight: 800; font-variant-numeric: tabular-nums; letter-spacing: -.03em; display: inline-block; overflow: hidden; height: 1.02em; }
.roll { display: inline-block; }
.roll.in { animation: rollIn var(--t) var(--ease); }
@keyframes rollIn { from { transform: translateY(58%); opacity: .2; } to { transform: none; opacity: 1; } }
.top-side { display: flex; flex-direction: column; align-items: flex-end; gap: 8px; }
.stage {
  position: relative; font-size: 13px; font-weight: 800; padding: 5px 12px; border-radius: 999px;
  background: color-mix(in srgb, var(--haze) 24%, var(--card)); border: 1.5px solid color-mix(in srgb, var(--haze) 55%, var(--line));
  white-space: nowrap; transition: background-color 500ms linear, border-color 500ms linear;
}
body[data-stage="none"] .stage, body[data-stage="clear"] .stage { background: var(--card); border-color: var(--line); }
.stage.up { animation: chip 520ms var(--ease); }
.stage.up::after { content: ""; position: absolute; inset: -2px; border-radius: 999px; border: 2px solid var(--haze); animation: ring 620ms var(--ease) both; }
@keyframes chip { 0% { transform: scale(1); } 35% { transform: scale(1.22); } 100% { transform: scale(1); } }
@keyframes ring { from { transform: scale(1); opacity: .9; } to { transform: scale(1.9, 2.6); opacity: 0; } }
.tools { display: flex; gap: 4px; }
.tool {
  min-width: 40px; height: 40px; border-radius: 12px; display: inline-flex; align-items: center; justify-content: center;
  gap: 3px; font-size: 13px; font-weight: 800; color: var(--ink-2); padding: 0 8px;
}
.tool svg, .act svg, .result svg, .next svg, .reopen svg { width: 22px; height: 22px; fill: none; stroke: currentColor; stroke-width: 1.9; stroke-linecap: round; stroke-linejoin: round; }
.tool.is-down { background: color-mix(in srgb, var(--ink) 10%, transparent); }
.tool.got { animation: chip 420ms var(--ease); color: var(--ink); }
.tool .snd-off, .tool.is-off .snd-on { display: none; }
.tool.is-off .snd-off { display: block; }

/* ---------- まん中：絵 ---------- */
.scene {
  flex: 1 1 auto; min-height: 0; position: relative; margin: 12px 0 0; border-radius: 28px; overflow: hidden;
  background: var(--wall); box-shadow: 0 1px 0 rgba(255, 255, 255, .7) inset, 0 10px 26px -14px rgba(60, 40, 10, .45);
}
body[data-style="line"] .scene { border: 2.5px solid var(--ink); box-shadow: none; }
.defs { position: absolute; }
.view { position: absolute; inset: 0; width: 100%; height: 100%; display: none; overflow: visible; }
body[data-view="room"] .view-room, body[data-view="bath"] .view-bath, body[data-view="opera"] .view-opera, body[data-view="drive"] .view-drive, body[data-view="grave"] .view-grave { display: block; }
.view-enter { animation: viewIn 220ms var(--ease); }
@keyframes viewIn { from { opacity: .35; transform: scale(1.03); } to { opacity: 1; transform: none; } }

/* 匂いの段階が上がったとき */
.stage-pop {
  position: absolute; left: 50%; top: 30%; white-space: nowrap; font-size: 30px; font-weight: 800; letter-spacing: .04em;
  color: var(--ink); background: var(--card); border: 4px solid var(--haze); border-radius: 999px; padding: 8px 26px; pointer-events: none;
  box-shadow: 0 12px 26px -14px rgba(0, 0, 0, .6); animation: stagePop 1300ms var(--ease) both;
}
@keyframes stagePop { 0% { opacity: 0; transform: translateX(-50%) scale(.6); } 14% { opacity: 1; transform: translateX(-50%) scale(1.08); } 22% { transform: translateX(-50%) scale(1); } 78% { opacity: 1; transform: translateX(-50%) scale(1); } 100% { opacity: 0; transform: translateX(-50%) scale(1.04); } }
.flash { position: absolute; inset: 0; background: var(--haze); opacity: 0; pointer-events: none; }
.flash.go { animation: flash 700ms linear; }
.flash.white { background: #fff; animation: flash 420ms linear; }
@keyframes flash { 0% { opacity: 0; } 18% { opacity: .55; } 100% { opacity: 0; } }

/* 弟の話が出たとき */
.banner {
  position: absolute; left: 12px; right: 12px; top: 12px; display: flex; align-items: center; gap: 10px;
  background: var(--ink); color: var(--card); border-radius: 16px; padding: 9px 13px; animation: bannerIn 240ms var(--ease) both;
  box-shadow: 0 8px 18px -10px rgba(0, 0, 0, .6);
}
.banner.out { animation: bannerOut 200ms linear both; }
@keyframes bannerIn { from { opacity: 0; transform: translateY(-16px) scale(.96); } to { opacity: 1; transform: none; } }
@keyframes bannerOut { to { opacity: 0; transform: translateY(-8px); } }
.banner-label { flex: 0 0 auto; font-size: 11px; font-weight: 800; letter-spacing: .08em; padding: 3px 7px; border-radius: 7px; background: var(--blanket); color: var(--ink); }
.banner-text { font-size: 14px; font-weight: 800; line-height: 1.35; }
.banner-text::before { content: "「"; } .banner-text::after { content: "」"; }

/* ---------- ドット絵（data-style="pix"。今の既定） ----------
   描ける場面（部屋・オペラの客席・お風呂に入った所）では body[data-demo="pix"] が付き、SVG の絵を隠してドット絵を出す。
   まだ打っていない場面（ヘリ・帰り道・夜の運転・墓）は、線の描き方の絵がそのまま出る。 */
body[data-style="pix"] { --olc: #1a1a20; --olw: 3px; --dot: #1a1a20; }
.pview { display: none; position: absolute; inset: 0; width: 100%; height: 100%; image-rendering: pixelated; image-rendering: crisp-edges; object-fit: cover; object-position: 50% 100%; background: #f2d47c; }
/* 絵の枠が低いとき（小さい画面・言葉が3行の日）：下にそろえたままだと、弟の頭が上で切れる。
   上を切るのは、絵の 76 段目まで（弟の髪の上）で止めて、足りない分は下（畳・座布団の下）を切る。
   枠の大きさの単位（cqw・cqh）が使えないブラウザでは、上の行のまま（下にそろえる） */
.scene { container-type: size; }
.pview { --cap: 76; object-position: 50% min(0px, max(calc(100cqh - 150cqw), calc(var(--cap) / -96 * 100cqw))); }
/* 見せたい物が上のほうにある絵は、上を切る段数を小さくする（風呂＝弟の頭が 57 段目・ヘリに立つ＝30 段目・ホワイトボード＝5 段目） */
body[data-view="bath"] .pview { --cap: 52; }
body[data-view="bath"][data-art="rim"] .pview { --cap: 26; }
body[data-view="opera"] .pview { --cap: 70; }
body[data-view="grave"] .pview { --cap: 54; }
body[data-view="room"][data-art="board"] .pview { --cap: 3; }
/* 背の低い画面では、絵の枠の幅をせばめる（幅いっぱいのままだと、枠が横長になって、窓・日めくりが絵の外へ出る） */
.scene { align-self: center; width: min(calc(100% - 8px), 48vh); width: min(calc(100% - 8px), 48dvh); }
body[data-demo="pix"] .scene .view { display: none; }
body[data-demo="pix"] .pview { display: block; }
.day-pix, .pix-icon { display: none; image-rendering: pixelated; image-rendering: crisp-edges; }

/* 文字もドットの字にする（16px の字なので、大きさは 16px か 32px にそろえる。ボールドは使わない） */
body[data-style="pix"]:not(.sysfont) { font-family: "DotGothic16", "Hiragino Sans", "Hiragino Kaku Gothic ProN", "Yu Gothic UI", "Yu Gothic", sans-serif; }
body[data-style="pix"]:not(.sysfont) .line, body[data-style="pix"]:not(.sysfont) .act, body[data-style="pix"]:not(.sysfont) .reopen, body[data-style="pix"]:not(.sysfont) .stage, body[data-style="pix"]:not(.sysfont) .count-label,
body[data-style="pix"]:not(.sysfont) .count-unit, body[data-style="pix"]:not(.sysfont) .banner-text, body[data-style="pix"]:not(.sysfont) .result-label, body[data-style="pix"]:not(.sysfont) .result-verdict,
body[data-style="pix"]:not(.sysfont) .result-stat, body[data-style="pix"]:not(.sysfont) .result-book, body[data-style="pix"]:not(.sysfont) .result-actions button, body[data-style="pix"]:not(.sysfont) .result-day small,
body[data-style="pix"]:not(.sysfont) .tool, body[data-style="pix"]:not(.sysfont) .sheet p, body[data-style="pix"]:not(.sysfont) .sheet h2, body[data-style="pix"]:not(.sysfont) .book-item, body[data-style="pix"]:not(.sysfont) .author,
body[data-style="pix"]:not(.sysfont) .line .who, body[data-style="pix"]:not(.sysfont) .banner-label, body[data-style="pix"]:not(.sysfont) .line.h { font-size: 16px; font-weight: 400; letter-spacing: 0; }
body[data-style="pix"]:not(.sysfont) .stage-pop { font-size: 32px; font-weight: 400; }
body[data-style="pix"]:not(.sysfont) .line { line-height: 1.5; }
/* 画面の部品も、角をドットの段にする（丸い角・ぼかした影をやめる） */
body[data-style="pix"] .scene { border-radius: 0; border: 0; margin: 16px 4px 0; box-shadow: 0 -4px 0 0 var(--dot), 0 4px 0 0 var(--dot), -4px 0 0 0 var(--dot), 4px 0 0 0 var(--dot); }
body[data-style="pix"] .count-num { height: auto; overflow: visible; display: inline-flex; align-items: flex-end; }
body[data-style="pix"] .count-num .roll { display: none; }
body[data-style="pix"] .day-pix { display: block; height: 45px; width: auto; }
body[data-style="pix"] .day-pix.wide { height: 35px; } /* 3けたからは、少し小さく */
body[data-style="pix"] .count-label, body[data-style="pix"] .count-unit { white-space: nowrap; flex: none; }
body[data-style="pix"] .count { flex: none; }
body[data-style="pix"] .day-pix.in { animation: dotIn 180ms steps(3) both; }
@keyframes dotIn { from { transform: translateY(12px); opacity: .4; } to { transform: none; opacity: 1; } }
body[data-style="pix"] .stage { border-radius: 0; border: 0; background: var(--card); padding: 5px 10px; margin: 3px; box-shadow: 0 -3px 0 0 var(--dot), 0 3px 0 0 var(--dot), -3px 0 0 0 var(--dot), 3px 0 0 0 var(--dot); }
body[data-style="pix"] .stage.up { animation: blink 480ms steps(1) 1; }
body[data-style="pix"] .stage.up::after { display: none; }
@keyframes blink { 0%, 50% { background: var(--dot); color: var(--card); } 25%, 75%, 100% { background: var(--card); color: var(--ink); } }
body[data-style="pix"] .actions { gap: 16px; padding: 4px 4px 6px; }
body[data-style="pix"] .act, body[data-style="pix"] .next, body[data-style="pix"] .reopen {
  border-radius: 0; border: 0; height: 72px; transition: none;
  box-shadow: 0 -4px 0 0 var(--dot), 0 4px 0 0 var(--dot), -4px 0 0 0 var(--dot), 4px 0 0 0 var(--dot), 0 8px 0 0 #8b8475;
}
body[data-style="pix"] .act.is-down, body[data-style="pix"] .next.is-down, body[data-style="pix"] .reopen.is-down { transform: translateY(4px); box-shadow: 0 -4px 0 0 var(--dot), 0 4px 0 0 var(--dot), -4px 0 0 0 var(--dot), 4px 0 0 0 var(--dot); background: var(--card); }
body[data-style="pix"] .act svg { display: none; }
body[data-style="pix"] .pix-icon { display: block; width: 32px; height: 32px; }
body[data-style="pix"] .next svg { animation: nextDot 600ms steps(2) infinite; }
@keyframes nextDot { to { transform: translateX(8px); } }
body[data-style="pix"] .dots i { border-radius: 0; }
body[data-style="pix"] .line { animation: lineIn 100ms steps(2) both; }
@keyframes lineIn { from { transform: translateY(4px); } to { transform: none; } }
/* 押したとき：絵が、こつんと沈む。匂いの段階が上がったとき：横にゆれる（臭い）／ふわっと上がる（良い匂い） */
.pview.nudge { animation: nudge 110ms steps(2) both; }
@keyframes nudge { from { transform: translateY(3px); } to { transform: none; } }
.scene.shake { animation: shake 280ms steps(1) both; }
@keyframes shake { 0% { transform: translateX(-4px); } 25% { transform: translateX(4px); } 50% { transform: translateX(-2px); } 75% { transform: translateX(2px); } 100% { transform: none; } }
.scene.lift { animation: lift 320ms steps(4) both; }
@keyframes lift { 0% { transform: translateY(0); } 40% { transform: translateY(-5px); } 100% { transform: none; } }
body[data-style="pix"] .result-verdict { animation: stamp 200ms 430ms steps(3) both; }
@keyframes stamp { from { opacity: 0; transform: scale(1.5); } to { opacity: 1; transform: none; } }
body[data-style="pix"] .line.b, body[data-style="pix"] .line.m, body[data-style="pix"] .line.f, body[data-style="pix"] .line.o {
  border-radius: 0; border: 0; margin: 3px; box-shadow: 0 -3px 0 0 var(--dot), 0 3px 0 0 var(--dot), -3px 0 0 0 var(--dot), 3px 0 0 0 var(--dot);
}
body[data-style="pix"] .banner { border-radius: 0; left: 8px; right: 8px; top: 8px; box-shadow: 0 -4px 0 0 var(--dot), 0 4px 0 0 var(--dot), -4px 0 0 0 var(--dot), 4px 0 0 0 var(--dot); animation: dotIn 180ms steps(3) both; }
body[data-style="pix"] .banner-label { border-radius: 0; }
body[data-style="pix"] .stage-pop { border-radius: 0; border: 0; box-shadow: 0 -4px 0 0 var(--dot), 0 4px 0 0 var(--dot), -4px 0 0 0 var(--dot), 4px 0 0 0 var(--dot); animation: stagePopDot 1300ms steps(1) both; transform: translateX(-50%); }
.stage-pop.warm, body[data-style="pix"] .stage-pop.warm { animation: none; opacity: .01; }
@keyframes stagePopDot { 0% { opacity: 0; transform: translateX(-50%) translateY(12px); } 6% { opacity: 1; transform: translateX(-50%) translateY(4px); } 12%, 92% { opacity: 1; transform: translateX(-50%); } 100% { opacity: 0; transform: translateX(-50%); } }
body[data-style="pix"] .flash { display: none; }
body[data-style="pix"] .result-card { border-radius: 0; border: 0; box-shadow: 0 -4px 0 0 var(--dot), -4px 0 0 0 var(--dot), 4px 0 0 0 var(--dot); animation: dotUp 240ms steps(4) both; }
@keyframes dotUp { from { transform: translateY(64px); } to { transform: none; } }
body[data-style="pix"] .result-close { border-radius: 0; box-shadow: 0 -3px 0 0 var(--dot), 0 3px 0 0 var(--dot), -3px 0 0 0 var(--dot), 3px 0 0 0 var(--dot); }
body[data-style="pix"] .result.closing .result-card { animation: dotDown 180ms steps(4) both; }
@keyframes dotDown { from { transform: none; } to { transform: translateY(105%); } }
body[data-style="pix"] .result-actions button { border-radius: 0; box-shadow: 0 -3px 0 0 var(--dot), 0 3px 0 0 var(--dot), -3px 0 0 0 var(--dot), 3px 0 0 0 var(--dot); }
body[data-style="pix"] .tool { border-radius: 0; }
body[data-style="pix"] .sheet { border-radius: 0; box-shadow: 0 -4px 0 0 var(--dot); }
body[data-style="pix"] .book-item { border-radius: 0; }

.res-pix { display: none; image-rendering: pixelated; image-rendering: crisp-edges; }
body[data-style="pix"] #resDay { display: none; }
body[data-style="pix"] .res-pix { display: inline-block; height: 80px; width: auto; vertical-align: baseline; }
/* リンクの見出しの画像を撮るための並べ方（?og=1） */
body.og #app { max-width: none; height: 100vh; padding: 0; display: block; }
body.og .top, body.og .talk, body.og .actions { display: none; }
body.og .scene, body.og[data-style="pix"] .scene { position: absolute; right: 60px; top: 45px; width: 360px; height: 540px; margin: 0; }
body.og::before { content: "お風呂に\A入らない弟"; white-space: pre; position: absolute; left: 80px; top: 130px; font-size: 92px; line-height: 1.2; font-weight: 800; }
body.og::after { content: "押すと1日たつ。入るまで、待つ。"; position: absolute; left: 84px; top: 400px; font-size: 34px; font-weight: 800; color: var(--ink-2); }

/* ---------- 言葉 ---------- */
.talk {
  flex: 0 0 auto; min-height: 112px; display: flex; flex-direction: column; justify-content: flex-end; align-items: flex-start;
  gap: 7px; padding: 10px 2px 14px;
}
.line { margin: 0; font-size: 18px; font-weight: 700; line-height: 1.45; animation: say var(--t) var(--ease) both; max-width: 100%; }
.line:nth-child(2) { animation-delay: 70ms; }
.line:nth-child(3) { animation-delay: 140ms; }
@keyframes say { from { opacity: .3; transform: translateY(6px); } to { opacity: 1; transform: none; } }
.line.h { font-size: 13px; color: var(--ink-2); letter-spacing: .06em; margin-top: 4px; }
.line.b, .line.m, .line.f, .line.o {
  background: var(--card); border-radius: 18px 18px 18px 5px; padding: 8px 14px; box-shadow: 0 6px 14px -10px rgba(60, 40, 10, .6);
  animation-name: sayPop;
}
body[data-style="line"] .line.b, body[data-style="line"] .line.m, body[data-style="line"] .line.f, body[data-style="line"] .line.o { border: 2px solid var(--ink); box-shadow: none; }
@keyframes sayPop { from { opacity: .3; transform: translateY(6px) scale(.94); } to { opacity: 1; transform: none; } }
.line .who { font-size: 11px; font-weight: 800; color: var(--ink-2); margin-right: 8px; letter-spacing: .06em; }
.line.b { background: color-mix(in srgb, var(--blanket) 32%, var(--card)); }

/* ---------- 下：ボタン ---------- */
.actions { flex: 0 0 auto; display: grid; grid-template-columns: 1fr 1fr 1fr; gap: 10px; }
.act {
  height: 78px; border-radius: 24px; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 5px;
  font-size: 13px; font-weight: 800; background: var(--card); box-shadow: 0 8px 18px -12px rgba(60, 40, 10, .7);
  transition: transform 90ms var(--ease), background-color 90ms linear;
}
body[data-style="line"] .act, body[data-style="line"] .next, body[data-style="line"] .reopen { border: 2px solid var(--ink); box-shadow: none; }
.act svg { width: 26px; height: 26px; }
.act.is-down, .next.is-down, .reopen.is-down { transform: scale(.95); background: color-mix(in srgb, var(--ink) 16%, var(--card)); }
body.locked .act, body.locked .next { opacity: .55; }
body.in-event .act { display: none; }
/* 入った後に、結果の板を閉じている間：3つのボタンの所に「結果を開く」だけを出す */
body.res-closed .act, body.res-closed .next { display: none; }
.reopen {
  grid-column: 1 / -1; height: 78px; border-radius: 24px; background: var(--card); color: var(--ink); display: flex; align-items: center; justify-content: center; gap: 10px;
  font-size: 16px; font-weight: 800; transition: transform 90ms var(--ease);
}
.reopen svg { width: 24px; height: 24px; stroke-width: 2.6; }
.next {
  grid-column: 1 / -1; height: 78px; border-radius: 24px; background: var(--card); color: var(--ink); display: flex; align-items: center; justify-content: center; gap: 14px;
  transition: transform 90ms var(--ease);
}
.next svg { width: 28px; height: 28px; stroke-width: 2.6; animation: nextHint 1.1s ease-in-out infinite; }
@keyframes nextHint { 0%, 100% { transform: translateX(0); } 50% { transform: translateX(5px); } }
.dots { display: inline-flex; gap: 7px; }
.dots i { width: 8px; height: 8px; border-radius: 50%; background: currentColor; opacity: .3; }
.dots i.on { opacity: 1; }

/* ---------- 結果 ---------- */
.result { position: fixed; inset: 0; z-index: 20; display: flex; align-items: flex-end; justify-content: center; pointer-events: none; }
.result-card {
  position: relative; pointer-events: auto; width: 100%; max-width: 480px; background: var(--card); border-radius: 30px 30px 0 0;
  padding: 24px 22px calc(var(--safe-b) + 22px); text-align: center; animation: up 260ms var(--ease) both;
  box-shadow: 0 -14px 34px -18px rgba(40, 25, 5, .55);
}
body[data-style="line"] .result-card { border: 2.5px solid var(--ink); border-bottom: 0; box-shadow: none; }
@keyframes up { from { transform: translateY(60px); opacity: .4; } to { transform: none; opacity: 1; } }
/* 板を閉じる（右上。押す所は 48×44）・閉じる動き 180ms・開き直す動き 200ms（数え上げと一言の動きは、初めの1回だけ） */
.result-close {
  position: absolute; top: 10px; right: 12px; width: 48px; height: 44px; border-radius: 14px; display: flex; align-items: center; justify-content: center;
  background: color-mix(in srgb, var(--ink) 7%, var(--card)); color: var(--ink); transition: transform 90ms var(--ease);
}
.result-close svg { width: 24px; height: 24px; stroke-width: 2.6; }
.result-close.is-down { transform: scale(.94); }
.result.closing { pointer-events: none; }
.result.closing .result-card { pointer-events: none; animation: down 180ms ease-in both; }
@keyframes down { from { transform: none; } to { transform: translateY(105%); } }
body .result.quick:not(.closing) .result-card { animation-duration: 200ms; }
body .result.quick .result-verdict { animation: none; }
@keyframes fade { from { opacity: 0; } to { opacity: 1; } }
/* 200日・365日を越えて入った印（しるしの絵と名前） */
.result-mark { display: flex; width: fit-content; align-items: center; gap: 8px; margin: 0 auto 10px; padding: 4px 16px 4px 8px; font-size: 16px; font-weight: 800; color: var(--card); background: var(--ink); border-radius: 999px; }
.result-mark[hidden] { display: none; }
.mark-icon { width: 32px; height: 32px; image-rendering: pixelated; background: var(--card); border-radius: 999px; }
body[data-style="pix"] .result-mark { border-radius: 0; }
body[data-style="pix"] .mark-icon { border-radius: 0; }
body[data-style="pix"]:not(.sysfont) .result-mark { font-size: 18px; font-weight: 400; letter-spacing: 0; }
/* 特別な日（200日・365日）の言葉：長めに出す。絵のいちばん上に置く（日めくり・ふすまの家族・カメラにかぶせない） */
.stage-pop.long, body[data-style="pix"] .stage-pop.long { animation-duration: 2400ms; }
.stage-pop.top { top: 12px; }
.result-label { margin: 0; font-size: 15px; font-weight: 800; color: var(--ink-2); letter-spacing: .08em; }
.result-day { margin: 2px 0 8px; font-size: 96px; line-height: 1; font-weight: 800; letter-spacing: -.04em; font-variant-numeric: tabular-nums; }
.result-day small { font-size: 20px; margin-left: 6px; letter-spacing: 0; }
.result-verdict { margin: 0 0 12px; font-size: 19px; font-weight: 800; line-height: 1.4; animation: sayPop 260ms 420ms var(--ease) both; }
.result-verdict::before { content: "「"; } .result-verdict::after { content: "」"; }
.result-stat, .result-book { margin: 0 0 4px; font-size: 14px; font-weight: 700; color: var(--ink-2); }
.result-actions { display: grid; grid-template-columns: 1fr 64px 64px; gap: 10px; margin-top: 18px; }
.result-actions button { height: 60px; border-radius: 20px; display: flex; align-items: center; justify-content: center; gap: 8px; font-size: 17px; font-weight: 800; background: color-mix(in srgb, var(--ink) 7%, var(--card)); transition: transform 90ms var(--ease); }
body[data-style="line"] .result-actions button { border: 2px solid var(--ink); background: var(--card); }
.result-actions .primary, body[data-style="line"] .result-actions .primary { background: var(--ink); color: var(--card); }
.result-actions .is-down { transform: scale(.96); }
.author { display: inline-block; margin-top: 14px; font-size: 13px; font-weight: 700; color: var(--ink-2); text-decoration: none; }

/* ---------- 下から出る板 ---------- */
.sheet-back { position: fixed; inset: 0; z-index: 30; background: rgba(0, 0, 0, .3); animation: fade 160ms linear both; }
.sheet {
  position: fixed; left: 0; right: 0; bottom: 0; z-index: 31; margin: 0 auto; max-width: 480px; max-height: 78dvh; overflow: auto;
  background: var(--card); border-radius: 26px 26px 0 0; padding: 10px 22px calc(var(--safe-b) + 24px); animation: up 220ms var(--ease) both; overscroll-behavior: contain;
}
.sheet-grip { width: 40px; height: 5px; border-radius: 3px; background: var(--line); margin: 0 auto 14px; }
.sheet h2 { margin: 0 0 12px; font-size: 17px; }
.sheet h2 small { font-size: 14px; color: var(--ink-2); margin-left: 8px; }
.sheet p { margin: 0 0 10px; font-size: 15px; font-weight: 600; line-height: 1.6; }
.book-list { display: grid; gap: 8px; }
.book-item { border-radius: 14px; padding: 12px 14px; font-size: 15px; font-weight: 800; color: var(--ink-2); background: color-mix(in srgb, var(--ink) 5%, var(--card)); letter-spacing: .3em; }
.book-item.found { color: var(--ink); background: color-mix(in srgb, var(--blanket) 26%, var(--card)); letter-spacing: 0; }
.book-item.found::before { content: "「"; } .book-item.found::after { content: "」"; }

/* 小さな知らせ */
.toast {
  position: fixed; left: 50%; bottom: calc(var(--safe-b) + 120px); transform: translateX(-50%); z-index: 40;
  background: var(--ink); color: var(--card); font-size: 14px; font-weight: 800; padding: 9px 16px; border-radius: 999px;
  animation: fade 160ms linear both; white-space: nowrap;
}

@media (max-height: 620px) {
  .count-num { font-size: 46px; }
  .talk { min-height: 92px; }
  .line { font-size: 16px; }
  .act, .next, .reopen { height: 66px; }
  /* 結果の板も低くする（板の上に、風呂の弟の顔が見えるように） */
  .result-card { padding-top: 14px; }
  body[data-style="pix"] .res-pix { height: 60px; }
  .result-verdict { margin-bottom: 6px; }
  .result-actions { margin-top: 10px; }
  .result-actions button { height: 52px; }
  .author { margin-top: 8px; }
}
/* せまい画面：右上のアイコンを詰める（はみ出さないように） */
@media (max-width: 380px) {
  .tools { gap: 0; }
  .tool { min-width: 34px; padding: 0 4px; }
}
@media (max-width: 339px) {
  #app { padding-left: 12px; padding-right: 12px; }
  .tool { min-width: 32px; padding: 0 3px; }
  .result-card { padding-left: 14px; padding-right: 14px; }
}
/* 横向き（背の低い画面）：絵を左、日数・言葉・ボタンを右に並べる（たてに積むと、絵が細い帯になる） */
@media (orientation: landscape) and (max-height: 520px) and (min-width: 560px) {
  :root { --lw: min(42vw, calc((100dvh - var(--safe-t) - var(--safe-b) - 28px) * .6667)); --safe-l: env(safe-area-inset-left, 0px); --safe-r: env(safe-area-inset-right, 0px); }
  #app {
    max-width: none; display: grid; grid-template-columns: var(--lw) minmax(0, 1fr); grid-template-rows: auto minmax(0, 1fr) auto; column-gap: 24px;
    padding: calc(var(--safe-t) + 10px) calc(var(--safe-r) + 18px) calc(var(--safe-b) + 10px) calc(var(--safe-l) + 18px);
  }
  .scene, body[data-style="pix"] .scene { grid-column: 1; grid-row: 1 / -1; margin: 4px; width: auto; align-self: stretch; }
  .top, .talk, .actions, body[data-style="pix"] .actions { grid-column: 2; }
  .talk { min-height: 0; overflow: hidden; padding-top: 6px; }
  .result { justify-content: flex-end; }
  /* 結果の板が、右の列の「◯日目」に重なる。板が出ている間は隠す（同じ数字が、板に大きく出ている） */
  body:has(.result:not([hidden])) .count { visibility: hidden; }
  .result-card { width: calc(100vw - var(--lw) - var(--safe-l) - var(--safe-r) - 60px); max-width: none; margin-right: calc(var(--safe-r) + 18px); padding-top: 14px; padding-bottom: calc(var(--safe-b) + 12px); }
  body[data-style="pix"] .result-card { box-shadow: 0 -4px 0 0 var(--dot), -4px 0 0 0 var(--dot), 4px 0 0 0 var(--dot); }
  body[data-style="pix"] .res-pix { height: 56px; }
  .result-verdict { margin-bottom: 6px; }
  .result-actions { margin-top: 10px; }
  .result-actions button { height: 48px; }
  .author { margin-top: 8px; }
  .sheet { max-height: 88dvh; }
}
/* 「1日たつ」の動きの間：前の日の言葉を、うすくする（次の日の言葉が出るまで） */
.talk { transition: opacity 140ms linear; }
body.passing .talk { opacity: .28; }
/* 動きの間は、ボタンを押しても進まない（飛ばせない）。押した瞬間の沈みが見えてから（0.1 秒後）、3つともうすくなる。動きが終わると、すぐ元に戻る */
body.passing .act, body[data-style="pix"].passing .act { opacity: .45; transition: opacity 60ms linear 100ms; }
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation: none !important; transition: none !important; }
}
