/* 画面の部品。空の絵（canvas の層）は render/sky.js。部品は中央の幅 440px に寄せる（PC では左右に空が広がる）。 */
:root {
  --band: calc(max(104px, 16vh) + env(safe-area-inset-bottom));
  --ink: #e8ecff;
  --lit: #fff6d6;
  --hand: #ff9a4a;
  --gold: #ffd98a;
  --shame: #ff6b6b;
  --lamp: #ff6b6b;
  --sky-top: #050813;
  --sky-mid: #0b1226;
  --sky-low: #1b2540;
  --mincho: "Hiragino Mincho ProN", "Yu Mincho", "Noto Serif JP", serif;
}
* { box-sizing: border-box; }
html, body, #stage, #sky-hit, #cards { touch-action: none; overscroll-behavior: none; user-select: none; -webkit-user-select: none; -webkit-touch-callout: none; -webkit-tap-highlight-color: transparent; }
/* 読み込み中も黒でなく空の色 */
html, body { margin: 0; height: 100%; background: linear-gradient(var(--sky-top), var(--sky-mid) 60%, var(--sky-low)); color: var(--ink); font-family: "Hiragino Kaku Gothic ProN", system-ui, -apple-system, "Segoe UI", sans-serif; }
body { position: fixed; inset: 0; overflow: hidden; }
#stage { position: absolute; inset: 0; overflow: hidden; background: linear-gradient(var(--sky-top), var(--sky-mid) 60%, var(--sky-low)); }
.layer { position: absolute; inset: 0; width: 100%; height: 100%; pointer-events: none; z-index: 1; }
.sky-dusk { background: linear-gradient(#1a3a78, #3a2a5a 70%, #b0603a); opacity: 0.8; }
.sky-dawn { background: linear-gradient(rgba(20,40,90,0), #5a78b8 55%, #f0b080); opacity: 0; }
#sky-hit { position: absolute; left: 0; right: 0; top: 0; bottom: var(--band); z-index: 2; }
/* 枠そのものは押しを通す（stacking context を作らない。#tools を結果の上に出すため） */
#col { position: absolute; inset: 0; max-width: 440px; margin: 0 auto; pointer-events: none; }
button { font-family: inherit; }

/* ---- 上の帯 ---- */
#hud-top { position: absolute; z-index: 3; left: 0; right: 0; top: env(safe-area-inset-top); height: 38px; padding: 0 14px; display: grid; grid-template-columns: 1fr auto 1fr; align-items: center; font-size: 12px; pointer-events: none; text-shadow: 0 0 6px rgba(5,8,19,.9); transition: opacity .8s; }
#hud-time { display: flex; align-items: center; gap: 8px; opacity: .8; font-variant-numeric: tabular-nums; }
#hud-night { position: relative; display: block; width: 60px; height: 2px; background: rgba(232,236,255,.2); border-radius: 1px; }
#hud-night b { position: absolute; left: 0; top: 0; height: 2px; width: calc(var(--p, 0) * 100%); background: linear-gradient(90deg, #5a74d0, #cfdcff); border-radius: 1px; }
#hud-night b::after { content: ""; position: absolute; right: -2px; top: -2px; width: 6px; height: 6px; border-radius: 50%; background: #e8f0ff; box-shadow: 0 0 6px #cfdcff; }
#hud-night u { position: absolute; top: -1px; width: 1px; height: 4px; background: rgba(232,236,255,.45); }
#hud-night u:nth-of-type(1) { left: 25%; } #hud-night u:nth-of-type(2) { left: 50%; } #hud-night u:nth-of-type(3) { left: 75%; }
#hud-score { text-align: center; font-size: 14px; font-variant-numeric: tabular-nums; opacity: .92; letter-spacing: .04em; }
#hud-score b { font-weight: 600; font-size: 16px; }
#hud-score .sep { opacity: .55; }
#hud-score.hit b, #hud-score.hit #hud-goal { color: var(--gold); text-shadow: 0 0 8px rgba(255,217,138,.6); }
#hud-right { display: flex; align-items: center; justify-content: flex-end; gap: 10px; }
#hud-eye { opacity: .75; transform-origin: center; }
#hud-eye[hidden] { display: none; }
#hud-shame { display: flex; gap: 6px; }
#hud-shame i { display: block; width: 11px; height: 11px; border: 1.5px solid rgba(232,236,255,.8); border-radius: 50%; }
#hud-shame i.on { background: var(--shame); border-color: var(--shame); box-shadow: 0 0 6px rgba(255,107,107,.7); }
#hud-shame[data-full="1"] i.on { animation: beat 1.6s ease-in-out infinite; }
@keyframes beat { 0%, 100% { transform: scale(1); } 50% { transform: scale(1.3); } }

/* ---- 小さい操作（押す範囲は 44px。見た目は小さい） ---- */
#tools { position: absolute; z-index: 12; right: 4px; top: calc(env(safe-area-inset-top) + 36px); display: flex; gap: 2px; pointer-events: none; }
#tools button { position: relative; pointer-events: auto; white-space: nowrap; min-width: 44px; height: 44px; padding: 0 12px; border: 0; background: transparent; color: var(--ink); opacity: .8; font-size: 12px; letter-spacing: .04em; display: flex; align-items: center; justify-content: center; }
#btn-lang::before { content: ""; position: absolute; inset: 11px 2px; border: 1px solid rgba(232,236,255,.4); border-radius: 12px; }
#btn-sound svg { display: block; }
#btn-sound .cut { opacity: 0; }
#btn-sound[data-on="0"] { opacity: .5; }
#btn-sound[data-on="0"] .wave { opacity: 0; }
#btn-sound[data-on="0"] .cut { opacity: 1; }
#btn-sound[data-pending="1"] { opacity: .55; }

/* ---- 願いの字（押さえている間。約26%の高さ） ---- */
#wish-band { position: absolute; z-index: 3; left: 0; right: 0; top: 26%; padding: 0 18px; text-align: center; pointer-events: none; }
#wish-band[hidden] { display: none; }
#wish-text { margin: 0 auto; max-width: 360px; font-family: var(--mincho); font-weight: 300; font-size: 22px; line-height: 1.6; letter-spacing: .04em; text-shadow: 0 0 14px rgba(5,8,19,.95), 0 2px 18px rgba(5,8,19,.9); text-wrap: balance; overflow-wrap: anywhere; }
#wish-text[data-tier="long"] { font-size: 17.5px; line-height: 1.75; }
#wish-text .u { color: rgba(232,236,255,.36); }
#wish-text .u.lit { color: var(--lit); text-shadow: 0 0 10px rgba(255,246,214,.75), 0 0 2px rgba(5,8,19,.9); }
#wish-text .u.gone { display: none; }
#wish-text .u.pulse.lit { animation: tailglow .55s ease-in-out infinite alternate; }
@keyframes tailglow { from { color: var(--lit); text-shadow: 0 0 8px rgba(255,246,214,.7); } to { color: #fff; text-shadow: 0 0 18px rgba(255,255,255,1), 0 0 6px rgba(255,236,170,.9); } }
#wish-text .ell { color: #c9cde4; }
/* 言い切った: 金色 */
#wish-band[data-state="done"] #wish-text .u { color: var(--gold); text-shadow: 0 0 12px rgba(255,217,138,.8); }
/* 離した、消えた: 灯った字が灰色で止まる（休みの間） */
#wish-band[data-state="broken"] #wish-text .u { color: rgba(200,205,225,.28); }
#wish-band[data-state="broken"] #wish-text .u.lit { color: #a7acc2; text-shadow: none; }
/* 惜しい: 震えて「…」 */
#wish-band[data-close="1"] #wish-text { animation: tremble .45s linear 2; }
@keyframes tremble { 0%, 100% { transform: translateX(0); } 20% { transform: translateX(-2.5px); } 40% { transform: translateX(2.5px); } 60% { transform: translateX(-1.5px); } 80% { transform: translateX(1.5px); } }
/* 見間違い: 灯った字が飛行機の灯と同じ色で点滅 */
#wish-band[data-kind="misread"][data-state="wishing"] #wish-text .u.lit { color: var(--lamp); text-shadow: 0 0 10px var(--lamp); animation: blink 1s steps(1, end) infinite; }
@keyframes blink { 0% { opacity: 1; } 12% { opacity: .15; } 100% { opacity: .15; } }
/* ひとりごと: 最初の数字だけ、手元から浮かんで消える */
#wish-band[data-kind="alone"] #wish-text { animation: floatup .8s ease-out forwards; }
#wish-band[data-kind="alone"] #wish-text .u { color: rgba(232,236,255,.75); }
@keyframes floatup { from { opacity: 0; transform: translateY(8px); } 25% { opacity: 1; } to { opacity: 0; transform: translateY(-8px); } }

/* ---- 案内の1行（地平線の上）---- */
#hint { position: absolute; z-index: 3; left: 0; right: 0; bottom: calc(var(--band) + 16px); margin: 0 auto; max-width: 380px; padding: 0 14px; text-align: center; font-size: 15px; line-height: 1.5; color: #f1f4ff; text-shadow: 0 0 10px rgba(5,8,19,.95), 0 0 3px rgba(5,8,19,.9); pointer-events: none; }
#hint[hidden] { display: none; }
#hint[data-kind="note"] { color: #ffd0c8; }
#hint { text-wrap: balance; white-space: pre-line; }
#hint[data-key="hint.intro"] { max-width: 320px; }
#hint[data-kind="murmur"] { font-size: 14px; opacity: .85; color: #cfd6f2; }
@keyframes fadein { from { opacity: 0; transform: translateY(4px); } to { opacity: 1; transform: none; } }

/* ---- 願いのカード（地平線の影の中。短冊のような札） ---- */
#cards { position: absolute; z-index: 3; left: 0; right: 0; bottom: 0; height: var(--band); margin: 0 auto; padding: 16px 12px calc(10px + env(safe-area-inset-bottom)); display: flex; align-items: flex-end; gap: 10px; background: linear-gradient(rgba(3,5,12,0), rgba(3,5,12,.88) 42%, #03050c); pointer-events: auto; transition: opacity .8s; }
#cards button { position: relative; flex: 1 1 0; min-width: 0; min-height: 66px; padding: 7px 4px 6px; border: 1px solid rgba(255,154,74,.2); border-radius: 3px 3px 9px 9px; background: linear-gradient(rgba(16,20,38,.86), rgba(7,9,20,.9)); color: var(--ink); font-size: 12px; display: flex; flex-direction: column; justify-content: center; align-items: center; gap: 3px; transition: transform .18s, box-shadow .18s, border-color .18s, background .18s, opacity .2s; }
#cards button::before { content: ""; position: absolute; left: 50%; top: -5px; width: 7px; height: 7px; margin-left: -3.5px; border-radius: 50%; border: 1px solid rgba(255,154,74,.28); background: #03050c; }
#cards .head { display: flex; align-items: center; justify-content: center; gap: 6px; }
#cards .size { display: flex; align-items: center; gap: 2px; color: var(--hand); }
#cards .size i { display: block; border-radius: 50%; background: currentColor; }
#cards [data-tier="short"] .size i { width: 5px; height: 5px; }
#cards [data-tier="normal"] .size i { width: 7px; height: 7px; }
#cards [data-tier="long"] .size i { width: 9px; height: 9px; }
#cards .name { font-size: 12px; letter-spacing: .04em; opacity: .9; white-space: nowrap; }
#cards .gauge { width: 72%; height: 4px; display: flex; align-items: center; }
#cards .gauge i { display: block; background: rgba(255,154,74,.8); border-radius: 2px; }
#cards [data-tier="short"] .gauge i { width: 28%; height: 2px; }
#cards [data-tier="normal"] .gauge i { width: 62%; height: 3px; }
#cards [data-tier="long"] .gauge i { width: 100%; height: 4px; }
#cards .snippet { min-width: 0; max-width: 100%; height: 15px; line-height: 15px; font-family: var(--mincho); font-size: 11.5px; color: var(--lit); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; text-align: center; opacity: .5; }
#cards .left { font-size: 9px; letter-spacing: 2px; color: var(--hand); min-height: 12px; line-height: 12px; text-align: center; }
#cards button[data-selected="1"] { border-color: var(--hand); background: linear-gradient(rgba(255,154,74,.2), rgba(40,22,10,.9)); box-shadow: 0 0 14px rgba(255,154,74,.5), inset 0 0 8px rgba(255,154,74,.18); transform: translateY(-5px); }
#cards button[data-selected="1"]::before { border-color: var(--hand); background: var(--hand); box-shadow: 0 0 8px var(--hand); }
#cards button[data-selected="1"] .snippet { opacity: 1; }
#cards button[data-pressing="1"] { background: rgba(255,154,74,.22); }
#cards button[data-empty="1"] { opacity: .5; }
#cards button[data-empty="1"] .left { font-size: 12px; letter-spacing: 0; color: rgba(255,154,74,.75); }
#cards[data-holding="1"] button { opacity: .45; filter: brightness(.7); }
#cards button[data-flash="1"] { animation: usedflash .75s ease-out; }
@keyframes usedflash { 0% { box-shadow: 0 0 0 0 rgba(255,190,120,.9), 0 0 16px rgba(255,154,74,.9); } 100% { box-shadow: 0 0 0 16px rgba(255,190,120,0), 0 0 0 rgba(255,154,74,0); } }
#stage[data-screen="result"] #hud-top, #stage[data-screen="result"] #cards { visibility: hidden; }
#stage[data-screen="result"] #wish-band, #stage[data-screen="result"] #hint { display: none; }

/* ---- 結果（夜明けの写真） ---- */
#result { position: absolute; z-index: 10; inset: 0; background: linear-gradient(rgba(2,3,10,.97), rgba(5,8,19,.97)); touch-action: manipulation; }
#result[hidden] { display: none; }
#result * { touch-action: manipulation; }
#result .panel { position: absolute; inset: 0; max-width: 440px; margin: 0 auto; display: grid; grid-template-rows: minmax(0, 1fr) auto auto; gap: 10px; padding: calc(env(safe-area-inset-top) + 82px) 14px calc(12px + env(safe-area-inset-bottom)); text-align: center; animation: fadein .6s ease-out; }
#result-photo { position: relative; min-height: 0; display: grid; place-items: center; }
#result-photo canvas, #result-photo img { position: absolute; inset: 0; width: 100%; height: 100%; object-fit: contain; display: block; filter: drop-shadow(0 6px 18px rgba(0,0,0,.6)); }
#result-photo .skip { position: absolute; z-index: 3; left: 0; right: 0; bottom: 6px; text-align: center; font-size: 12px; color: rgba(232,236,255,.7); text-shadow: 0 0 6px #000; pointer-events: none; animation: fadein .6s ease-out; }
#result-photo.done canvas { animation: settle .9s ease-out forwards; }
@keyframes settle { from { transform: rotate(0); } 60% { transform: rotate(-1.3deg); } to { transform: rotate(-.7deg); } }
#result-photo img { position: absolute; inset: 0; z-index: 2; -webkit-touch-callout: default; -webkit-user-select: auto; user-select: auto; }
#result-info { display: grid; grid-template-columns: 1fr 1fr; gap: 3px 8px; align-items: baseline; }
#result-info p { margin: 0; grid-column: 1 / -1; font-size: 13px; line-height: 1.5; color: rgba(232,236,255,.78); text-wrap: balance; }
#result-headline { font-size: 21px !important; font-family: var(--mincho); color: var(--gold) !important; letter-spacing: .05em; }
#result-lead { font-size: 13px; font-style: normal; }
#result-granted { grid-column: 1 !important; text-align: right; font-size: 15px !important; color: var(--ink) !important; }
#result-score { grid-column: 2 !important; text-align: left; font-size: 15px !important; color: var(--ink) !important; font-variant-numeric: tabular-nums; }
#result-title { color: #ffe9b8 !important; }
#result-best { font-size: 12px !important; opacity: .8; }
#result-note { min-height: 0; font-size: 12px !important; color: #ffd0c8 !important; }
#result-note:empty { display: none; }
#result .row { display: flex; gap: 8px; justify-content: center; }
#result .row button { flex: 1 1 0; min-width: 0; min-height: 46px; padding: 0 8px; border: 1px solid rgba(232,236,255,.45); border-radius: 23px; background: rgba(8,12,28,.72); color: var(--ink); font-size: 14px; white-space: nowrap; }
#result .row button[hidden] { display: none; }
#result .row #btn-again { border-color: rgba(255,217,138,.8); color: var(--gold); }

/* ---- エラー ---- */
#fatal { position: absolute; z-index: 20; inset: 0; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 18px; padding: 28px; text-align: center; background: linear-gradient(var(--sky-top), var(--sky-mid) 60%, var(--sky-low)); }
#fatal[hidden] { display: none; }
#fatal p { margin: 0; max-width: 320px; font-size: 16px; line-height: 1.7; }
#fatal button { min-height: 46px; padding: 0 28px; border: 1px solid rgba(232,236,255,.5); border-radius: 23px; background: rgba(8,12,28,.7); color: var(--ink); font-size: 15px; }

@media (prefers-reduced-motion: reduce) {
  #hud-shame[data-full="1"] i.on, #wish-text .u.pulse.lit, #wish-band[data-close="1"] #wish-text { animation: none; }
}

/* ---- 最初の1手: 押さえる手本と、上の数の意味（まだ1回も押さえたことのない端末だけ）---- */
/* 親指の届く、空の下のほうの中央。星の上には出さない。押しは #sky-hit に通す */
#demo { position: absolute; z-index: 3; left: 50%; bottom: calc(var(--band) + 104px); width: 72px; height: 96px; margin-left: -36px; pointer-events: none; }
#demo[hidden] { display: none; }
#demo .ring { position: absolute; left: 4px; top: 0; width: 64px; height: 64px; border-radius: 50%; border: 2px solid rgba(255,246,214,.9); box-shadow: 0 0 14px rgba(255,246,214,.55), inset 0 0 10px rgba(255,246,214,.25); animation: demoring 1.6s ease-out infinite; }
#demo .ring.r2 { animation-delay: .8s; }
#demo .finger { position: absolute; left: 16px; top: 30px; width: 40px; height: 56px; filter: drop-shadow(0 2px 8px rgba(5,8,19,.8)); animation: demotap 1.6s ease-in-out infinite; transform-origin: 50% 8%; }
@keyframes demoring { 0% { transform: scale(.55); opacity: 0; } 25% { opacity: 1; } 100% { transform: scale(1.25); opacity: 0; } }
@keyframes demotap { 0%, 100% { transform: translateY(8px) scale(1); } 35%, 65% { transform: translateY(0) scale(.93); } }
#hud-score { position: relative; }
#hud-goal-label { position: absolute; left: 50%; top: 100%; transform: translateX(-50%); margin-top: -2px; white-space: nowrap; font-size: 10.500px; letter-spacing: .06em; opacity: .75; pointer-events: none; color: var(--gold); }
#hud-goal-label[hidden] { display: none; }
/* 霞む理由の印: 見て分かる大きさに */
#hud-eye { width: 28px; height: 28px; opacity: .95; color: #ffe9b8; filter: drop-shadow(0 0 6px rgba(255,233,184,.5)); }
@media (prefers-reduced-motion: reduce) { #demo .ring, #demo .finger { animation: none; } #demo .ring.r2 { display: none; } }

/* ---- 空の札: 灰色の輪、残りのある札の脈打ち（ux 周回1）---- */
#deny-ring { position: absolute; z-index: 3; width: 58px; height: 58px; margin: -29px 0 0 -29px; border-radius: 50%; border: 2px solid rgba(150,155,170,.85); background: rgba(52,56,72,.62); box-shadow: 0 0 0 7px rgba(150,155,170,.18); pointer-events: none; }
#deny-ring[hidden] { display: none; }
#deny-ring::before, #deny-ring::after { content: ""; position: absolute; left: 50%; top: 50%; width: 22px; height: 2px; margin: -1px 0 0 -11px; background: rgba(205,210,225,.85); border-radius: 1px; transform: rotate(45deg); }
#deny-ring::after { transform: rotate(-45deg); }
#deny-ring[data-go="1"] { animation: denyin .22s ease-out; }
@keyframes denyin { from { transform: scale(.6); opacity: 0; } to { transform: none; opacity: 1; } }
#cards[data-pick="1"] button:not([data-empty="1"]) { animation: pickpulse 1.5s ease-in-out infinite; }
@keyframes pickpulse { 0%, 100% { box-shadow: 0 0 0 0 rgba(255,154,74,0); border-color: rgba(255,154,74,.25); } 50% { box-shadow: 0 0 14px rgba(255,154,74,.55); border-color: rgba(255,154,74,.85); } }
@media (prefers-reduced-motion: reduce) { #cards[data-pick="1"] button:not([data-empty="1"]) { animation: none; border-color: rgba(255,154,74,.8); } }

/* ---- 右上の丸3つの一言（最初の夜だけ）、結果の見間違い、折り返し ---- */
#hud-shame { position: relative; }
#hud-shame-label { position: absolute; right: 0; top: 100%; margin-top: 1px; white-space: nowrap; font-size: 10.5px; letter-spacing: .06em; opacity: .75; pointer-events: none; color: var(--gold); }
#hud-shame-label[hidden] { display: none; }
#result-shame { font-size: 13px; }
#result-shame[hidden] { display: none; }
#result-reason { white-space: pre-line; }
#hint[data-key="hint.intro"] { max-width: 380px; }
#hint { word-break: auto-phrase; line-break: strict; }
@media (max-width: 380px) { #hint[data-key="hint.intro"] { font-size: 14px; } #hint[data-kind="note"], #hint[data-kind="murmur"] { font-size: 14px; } }

/* ---- おまけの札（12枚を使い切って、恥ずかしい夜に決まっていない時だけ。空は暗くしない）---- */
#card-bonus[hidden] { display: none; }
#card-bonus { position: relative; flex: 1.3 1 0; min-width: 0; min-height: 66px; padding: 7px 4px 6px; border: 1px solid var(--hand); border-radius: 3px 3px 9px 9px; background: linear-gradient(rgba(255,154,74,.2), rgba(40,22,10,.9)); box-shadow: 0 0 14px rgba(255,154,74,.5), inset 0 0 8px rgba(255,154,74,.18); transform: translateY(-5px); color: var(--ink); font-size: 12px; display: flex; flex-direction: column; justify-content: center; align-items: center; gap: 3px; pointer-events: none; animation: fadein .5s ease-out; }
#card-bonus::before { content: ""; position: absolute; left: 50%; top: -5px; width: 7px; height: 7px; margin-left: -3.5px; border-radius: 50%; border: 1px solid var(--hand); background: var(--hand); box-shadow: 0 0 8px var(--hand); }
#card-bonus .head { display: flex; align-items: center; justify-content: center; gap: 6px; }
#card-bonus .size { display: flex; color: var(--hand); }
#card-bonus .size i { display: block; width: 5px; height: 5px; border-radius: 50%; background: currentColor; }
#card-bonus .bname { font-size: 12px; letter-spacing: .04em; white-space: nowrap; }
#card-bonus .gauge { width: 72%; height: 4px; display: flex; align-items: center; }
#card-bonus .gauge i { display: block; width: 28%; height: 2px; background: rgba(255,154,74,.8); border-radius: 2px; }
#card-bonus .snippet { height: 15px; line-height: 15px; font-size: 11.5px; color: var(--lit); white-space: nowrap; }
#card-bonus .left { font-size: 12px; min-height: 12px; line-height: 12px; color: var(--gold); font-variant-numeric: tabular-nums; }
/* 0枚の3枚は細くする（360 幅でも4枚が収まる） */
#cards[data-bonus="1"] button { flex: .6 1 0; padding-left: 2px; padding-right: 2px; }
#cards[data-bonus="1"] button .size, #cards[data-bonus="1"] button .gauge { display: none; }
#cards[data-bonus="1"] button .name { font-size: 11px; letter-spacing: 0; }
#cards[data-bonus="1"] button[data-selected="1"] { transform: none; box-shadow: none; border-color: rgba(255,154,74,.2); background: linear-gradient(rgba(16,20,38,.86), rgba(7,9,20,.9)); }
#cards[data-bonus="1"] button[data-selected="1"]::before { border-color: rgba(255,154,74,.28); background: #03050c; box-shadow: none; }

/* ---- 周回2: 札の点と残り、おまけの数、結果の称号の一覧と星見のひとこと ---- */
#cards .size { display: none; }
#cards .pt { font-size: 10.5px; color: var(--gold); white-space: nowrap; opacity: .9; }
#cards .left { font-size: 9.5px; letter-spacing: 1px; white-space: nowrap; }
#cards .left:empty, #cards button[data-empty="1"] .pt { display: none; }
#cards[data-bonus="1"] button .pt { display: none; }
#cards[data-bonus="1"] button { flex: .6 1 0; }
#hud-bonus { color: var(--gold); font-size: 13px; margin-left: 3px; }
#hud-bonus[hidden] { display: none; }
#result-sky { font-size: 12px !important; color: #cfd6f2 !important; line-height: 1.55; font-family: var(--mincho); }
#result-sky[hidden], #result-tonight[hidden], #result-titles[hidden] { display: none; }
#result-tonight { font-size: 12px !important; color: var(--gold) !important; }
#result-titles { grid-column: 1 / -1; font-size: 12px; color: rgba(232,236,255,.78); }
#result-titles summary { list-style: none; cursor: pointer; min-height: 32px; line-height: 32px; display: inline-block; padding: 0 12px; border-radius: 16px; border: 1px solid rgba(232,236,255,.25); }
#result-titles summary::-webkit-details-marker { display: none; }
#result-titles summary::after { content: " ▾"; opacity: .7; }
#result-titles[open] summary::after { content: " ▴"; }
#result-titles ul { margin: 6px 0 0; padding: 0; list-style: none; display: grid; grid-template-columns: 1fr 1fr; gap: 2px 10px; text-align: left; font-size: 11px; line-height: 1.4; }
#result-titles li { opacity: .5; padding-left: 1em; text-indent: -1em; }
#result-titles li::before { content: "· "; }
#result-titles li[data-seen="1"] { opacity: .95; color: #ffe9b8; }
#result-titles li[data-current="1"]::before { content: "✦ "; }

/* ---- 休みの終わりを見せる（--rest は hud が view.rest.untilT から毎コマ 1→0 に決める。transition なし）---- */
#wish-band[data-state="broken"][data-rest="1"] #wish-text { opacity: calc(.3 + .7 * var(--rest, 0)); }
#wish-band[data-state="broken"][data-rest="1"]::after { content: ""; display: block; width: calc(var(--rest, 0) * 140px); height: 2px; margin: 10px auto 0; border-radius: 1px; background: rgba(200,205,225,.65); }
/* おまけのある夜は「叶った数」が長くなるので、叶った数と点を1行ずつにする */
#result-info[data-wide="1"] #result-granted, #result-info[data-wide="1"] #result-score { grid-column: 1 / -1 !important; text-align: center; }
/* 英語の語の間の空白は、どの状態でも落とさない（折り返しの行末では消える） */
#wish-text .sp { white-space: pre; }
/* 言い切った直後、中央の字は 0.35 秒おいて消える（筋の字と重ならないように。--done は hud が毎コマ 1→0 に決める。transition なし） */
#wish-band[data-state="done"] #wish-text { opacity: var(--done, 1); }

/* ---- 周回3: おまけの札の連続と長さ、結果のおまけの連続、押しても起きない理由の置き場所、右上の○の一言 ---- */
#card-bonus .bstreak { color: var(--gold); font-size: 12px; font-weight: 600; font-variant-numeric: tabular-nums; white-space: nowrap; }
#card-bonus .bstreak[hidden] { display: none; }
#card-bonus .snippet { font-size: 11px; font-variant-numeric: tabular-nums; }
#result-bonus { grid-column: 1 / -1; font-size: 12.5px !important; color: var(--gold) !important; font-variant-numeric: tabular-nums; }
#result-bonus[hidden] { display: none; }
#hud-shame-label { font-size: 11px; opacity: .9; }
#hud-goal-label { font-size: 11px; opacity: .9; }
/* 押しても何も起きなかった理由は、置き場所で見分ける: 休み=字の下（灰色の線のそば）、空の札=札の上（橙）、霞=上のほう（目の印のそば、青）、ほかは地平線の上 */
#hint[data-why="rest"] { bottom: auto; top: calc(26% + 84px); color: #b4bad2; }
#hint[data-why="empty"] { color: #ffcfa0; }
#hint[data-why="dark"] { bottom: auto; top: 96px; color: #bcd0ff; }
#hint[data-why="late"] { color: #d8dcf0; }
#hud-eye[data-ping="1"] { animation: eyeping .9s ease-in-out infinite alternate; }
@keyframes eyeping { from { filter: drop-shadow(0 0 4px rgba(255,233,184,.4)); } to { filter: drop-shadow(0 0 12px rgba(190,210,255,1)); } }
@media (prefers-reduced-motion: reduce) { #hud-eye[data-ping="1"] { animation: none; } }

/* 英語の語の間: 空白だけの span が幅 0 に潰れないよう、幅そのものを持たせる（WebKit で "Somedaya" と詰まって見えた対策） */
#wish-text .sp { display: inline-block; min-width: .3em; white-space: pre; }

/* ---- 周回4: 結果の画面は縦に流す。写真を幅いっぱいに大きく先に出し、字の行をその下へ。ボタンは下に貼り付く ---- */
#result .panel { display: block; overflow-y: auto; overflow-x: hidden; -webkit-overflow-scrolling: touch; padding-bottom: 0; overscroll-behavior: contain; touch-action: pan-y; }
#result * { touch-action: pan-y manipulation; }
#result-photo { display: block; width: 100%; aspect-ratio: 4 / 5; min-height: 0; margin: 0 auto 10px; }
@media (min-width: 600px) { #result-photo { width: min(100%, calc((100dvh - 330px) * .8)); min-width: 240px; } }
#result-photo canvas, #result-photo img { width: 100%; height: 100%; }
#result-info { margin-bottom: 10px; }
#result .row { position: sticky; bottom: 0; z-index: 4; padding: 10px 0 calc(12px + env(safe-area-inset-bottom)); background: linear-gradient(rgba(5,8,19,0), rgba(5,8,19,.97) 14px, rgba(5,8,19,.97)); }
#result-closest { grid-column: 1 / -1; font-size: 12.5px !important; color: var(--gold) !important; font-variant-numeric: tabular-nums; }
#result-closest[hidden] { display: none; }
#result-closest .nb { display: inline-block; white-space: nowrap; }
#result-closest .nb.note { font-size: 11px; opacity: 0.78; }
