:root {
  --ink: #23262b; --ink2: #4a4e55; --paper: #f3eee2; --paper2: #e7dfcd; --red: #a8322a; --sea: #2f5f74;
  --safe-b: env(safe-area-inset-bottom, 0px); --safe-t: env(safe-area-inset-top, 0px); --safe-l: env(safe-area-inset-left, 0px); --safe-r: env(safe-area-inset-right, 0px);
}
* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }
html, body { margin: 0; height: 100%; overflow: hidden; background: #0b0f16; overscroll-behavior: none; }
body { font-family: 'Klee One', 'Hiragino Maru Gothic ProN', sans-serif; color: var(--ink); -webkit-user-select: none; user-select: none; touch-action: none; }
#c { position: fixed; inset: 0; width: 100vw; height: 100vh; height: 100dvh; display: block; }
#ui { position: fixed; inset: 0; pointer-events: none; overflow: hidden; }
#ui svg path, #ui svg ellipse, #ui svg circle { fill: none; stroke: var(--ink); stroke-width: 2; stroke-linecap: round; stroke-linejoin: round; }

/* 周りの暗がりと霜 */
.vig { position: absolute; inset: 0; background: radial-gradient(ellipse at 50% 55%, transparent 55%, rgba(5, 8, 14, .38) 100%); }
.danger { position: absolute; inset: 0; opacity: 0; transition: opacity .4s; background: radial-gradient(ellipse at 50% 50%, transparent 50%, rgba(120, 20, 18, .42) 100%); }
.frost { position: absolute; inset: 0; opacity: 0; transition: opacity .6s;
  background: radial-gradient(ellipse at 50% 50%, transparent 45%, rgba(225, 236, 245, .55) 82%, rgba(240, 246, 252, .85) 100%); }

/* 映画の黒い帯 */
.bars i { position: absolute; left: 0; right: 0; height: 0; background: #05070a; transition: height .9s ease; }
.bars i:first-child { top: 0; } .bars i:last-child { bottom: 0; }
#ui.cine .bars i { height: 9vh; }

/* 紙の札（野帳・目当て） */
.note, .goal { position: absolute; padding: 10px 16px 11px; background: var(--paper); opacity: 0; transform: translateY(-8px) rotate(-1.2deg); transition: opacity .6s, transform .6s;
  box-shadow: 0 6px 18px rgba(0, 0, 0, .28); max-width: min(42vw, 300px); }
.note { left: calc(14px + var(--safe-l)); top: calc(14px + var(--safe-t)); }
.goal { right: calc(14px + var(--safe-r)); top: calc(64px + var(--safe-t)); transform: translateY(-8px) rotate(1.4deg); max-width: min(46vw, 320px); }
#ui.hud .note { opacity: 1; transform: rotate(-1.2deg); }
#ui.hud .goal.on { opacity: 1; transform: rotate(1.4deg); }
.frame { position: absolute; inset: 0; width: 100%; height: 100%; overflow: visible; }
.frame path { stroke-width: 1.6; }
.note .date { font-size: 19px; font-weight: 600; letter-spacing: .04em; }
.note .age { font-size: 14px; color: var(--ink2); margin-top: 1px; }
.note .place { font-size: 13px; color: var(--ink2); }
.goal .gk { font-size: 12px; color: var(--ink2); letter-spacing: .1em; }
.goal .gt { font-size: 16px; line-height: 1.45; font-weight: 600; word-break: keep-all; overflow-wrap: anywhere; }

/* 体の蓄えと体力の輪 */
.meter { position: absolute; left: calc(14px + var(--safe-l)); bottom: calc(16px + var(--safe-b)); width: 104px; height: 104px; opacity: 0; transition: opacity .6s; }
#ui.hud .meter { opacity: 1; }
.meter svg { width: 100%; height: 100%; overflow: visible; filter: drop-shadow(0 1px 2px rgba(0, 0, 0, .5)); }
.meter .ring0 { stroke: rgba(243, 238, 226, .35) !important; stroke-width: 7 !important; }
.meter .ring { stroke: var(--paper) !important; stroke-width: 5 !important; }
.meter .ring2 { stroke: #9fd0e0 !important; stroke-width: 3.5 !important; }
.meter .silline path, .meter .silline circle { stroke: var(--paper) !important; stroke-width: 2.6 !important; }
.meter .silfill .body { fill: rgba(243, 238, 226, .78) !important; stroke: none !important; }
.meter .silfill path:not(.body), .meter .silfill circle { stroke: none !important; }
.meter.low .silline path { stroke: #ffb3a8 !important; }
.meter.breath .ring2 { stroke: #ffb3a8 !important; }

/* 操作の合図 */
.prompt { position: absolute; left: 50%; bottom: calc(22vh + var(--safe-b)); transform: translate(-50%, 6px); display: flex; align-items: center; gap: 10px; opacity: 0; transition: opacity .3s, transform .3s;
  background: rgba(243, 238, 226, .94); padding: 7px 14px 7px 9px; border-radius: 3px; box-shadow: 0 4px 14px rgba(0, 0, 0, .3); }
.prompt.on { opacity: 1; transform: translate(-50%, 0); }
.prompt .key { position: relative; width: 44px; height: 30px; display: grid; place-items: center; }
.prompt .key svg { position: absolute; inset: 0; width: 100%; height: 100%; overflow: visible; }
.prompt .key b { font-size: 14px; font-weight: 600; }
.prompt.nokey .key { display: none; }
.prompt .pt { font-size: 17px; font-weight: 600; white-space: nowrap; }

/* 字幕（ナレーション） */
.narr { position: absolute; left: 0; right: 0; bottom: calc(5vh + var(--safe-b)); display: flex; justify-content: center; padding: 0 16px; }
.narr p { margin: 0; max-width: min(860px, 92vw); line-break: strict; font-size: clamp(16px, 2.2vw, 22px); line-height: 1.6; color: #fbf8f1; text-align: center; letter-spacing: .03em;
  text-shadow: 0 0 6px rgba(0, 0, 0, .95), 0 1px 3px rgba(0, 0, 0, .95), 0 0 18px rgba(0, 0, 0, .6); opacity: 0; transition: opacity .7s; word-break: keep-all; overflow-wrap: anywhere; }
.narr.on p { opacity: 1; }
#ui.cine .narr { bottom: calc(10.5vh + var(--safe-b)); }
#ui.mobile .narr { bottom: calc(150px + var(--safe-b)); }
#ui.mobile.cine .narr, #ui.mobile.notouch .narr { bottom: calc(10.5vh + var(--safe-b)); }

/* 声の向き */
.sound { position: absolute; width: 70px; height: 54px; opacity: 0; transition: opacity .3s; }
.sound.on { opacity: 1; }
.sound svg { width: 100%; height: 100%; overflow: visible; }
.sound path { stroke: var(--paper) !important; stroke-width: 3 !important; }
.sound.mine path { stroke: #ffe9a8 !important; stroke-width: 4 !important; }

/* 紙（扉・死・題・メニュー） */
.paper { position: absolute; inset: 0; background: var(--paper);
  background-image: radial-gradient(rgba(120, 100, 70, .06) 1px, transparent 1px), radial-gradient(rgba(120, 100, 70, .05) 1px, transparent 1px);
  background-size: 7px 7px, 11px 11px; background-position: 0 0, 3px 5px; }
.card, .death, .title, .menu { position: absolute; inset: 0; display: grid; place-items: center; align-content: center; gap: 6px; opacity: 0; transition: opacity 1s; pointer-events: none; text-align: center; padding: 24px; }
.card.on, .death.on, .title.on, .menu.on { opacity: 1; pointer-events: auto; }
.card .sk, .title .sk { position: relative; width: min(20vh, 130px); height: min(20vh, 130px); overflow: visible; }
.card .sk path, .card .sk circle, .card .sk ellipse, .title .sk path, .title .sk circle { stroke-width: 1.4 !important; stroke-dasharray: 400; stroke-dashoffset: 400; }
.card.on .sk path, .card.on .sk circle, .card.on .sk ellipse, .title.on .sk path, .title.on .sk circle { animation: draw 2.4s ease forwards; }
@keyframes draw { to { stroke-dashoffset: 0; } }
.card .cn { position: relative; font-size: clamp(15px, 2vw, 18px); color: var(--ink2); letter-spacing: .3em; }
.card .ct { position: relative; font-size: clamp(34px, 6vw, 56px); font-weight: 600; letter-spacing: .12em; }
.card .cs { position: relative; font-size: clamp(14px, 1.8vw, 17px); color: var(--ink2); max-width: 640px; line-height: 1.7; word-break: keep-all; overflow-wrap: anywhere; }
.death .dt { position: relative; font-size: clamp(26px, 4.5vw, 40px); font-weight: 600; letter-spacing: .1em; }
.death .dd { position: relative; font-size: clamp(15px, 2vw, 18px); color: var(--ink2); max-width: 620px; line-height: 1.75; margin: 6px 0 14px; word-break: keep-all; overflow-wrap: anywhere; }
.title h1 { position: relative; margin: 0; font-size: clamp(38px, 7vw, 68px); font-weight: 600; letter-spacing: .14em; }
.title .sub { position: relative; margin: 2px 0 14px; font-size: clamp(15px, 2vw, 18px); color: var(--ink2); max-width: 600px; line-height: 1.7; word-break: keep-all; overflow-wrap: anywhere; }
.title .hint { position: relative; margin: 14px 0 0; font-size: 13px; color: var(--ink2); max-width: 560px; line-height: 1.7; word-break: keep-all; overflow-wrap: anywhere; }
.menu .mt { position: relative; font-size: 28px; font-weight: 600; letter-spacing: .1em; margin-bottom: 8px; }
.btns { position: relative; display: flex; flex-wrap: wrap; gap: 12px; justify-content: center; }
.hb { position: relative; min-width: 200px; height: 54px; border: 0; background: transparent; font: 600 18px 'Klee One', sans-serif; color: var(--ink); cursor: pointer; padding: 0 20px; }
.hb svg { position: absolute; inset: 0; width: 100%; height: 100%; overflow: visible; }
.hb svg path { stroke-width: 2.2 !important; }
.hb span { position: relative; }
.hb:hover { background: rgba(35, 38, 43, .06); }
.hb:focus-visible { outline: 2px dashed var(--ink); outline-offset: 3px; }

.fade { position: absolute; inset: 0; opacity: 0; background: #000; }

.menuBtn { position: absolute; right: calc(14px + var(--safe-r)); top: calc(14px + var(--safe-t)); pointer-events: auto; height: 38px; padding: 0 14px; border: 0; border-radius: 3px;
  background: rgba(243, 238, 226, .9); font: 600 15px 'Klee One', sans-serif; color: var(--ink); cursor: pointer; opacity: 0; transition: opacity .6s; box-shadow: 0 3px 10px rgba(0, 0, 0, .25); }
#ui.hud .menuBtn { opacity: 1; }

/* スマホの操作 */
.touch { display: none; }
#ui.mobile.hud:not(.cine):not(.notouch) .touch { display: block; }
.touch .joy { position: absolute; left: calc(18px + var(--safe-l)); bottom: calc(22px + var(--safe-b)); width: 128px; height: 128px; pointer-events: auto; touch-action: none; }
.touch .joy svg { width: 100%; height: 100%; overflow: visible; }
.touch .joy path { stroke: var(--paper) !important; stroke-width: 3 !important; }
.touch .jk { fill: rgba(243, 238, 226, .35) !important; }
.touch .tb { position: absolute; right: calc(14px + var(--safe-r)); bottom: calc(18px + var(--safe-b)); width: 176px; height: 176px; }
.tbtn { position: absolute; width: 74px; height: 74px; display: grid; place-items: center; pointer-events: auto; touch-action: none; }
.tbtn svg { position: absolute; inset: 0; width: 100%; height: 100%; overflow: visible; }
.tbtn path { stroke: var(--paper) !important; stroke-width: 3 !important; fill: rgba(10, 14, 20, .28) !important; }
.tbtn span { position: relative; color: #fbf8f1; font-size: 15px; font-weight: 600; text-shadow: 0 1px 3px rgba(0, 0, 0, .9); white-space: nowrap; }
.tbtn.on path { fill: rgba(243, 238, 226, .4) !important; }
.tact { right: 0; bottom: 0; width: 84px; height: 84px; }
.tjump { right: 92px; bottom: 0; }
.tslide { right: 0; bottom: 92px; }
.trun { right: 92px; bottom: 92px; }
#ui.mobile .meter { left: auto; right: calc(14px + var(--safe-r)); top: calc(64px + var(--safe-t)); bottom: auto; width: 70px; height: 70px; }
#ui.mobile .note { max-width: 48vw; padding: 7px 11px 8px; }
#ui.mobile .note .date { font-size: 16px; }
#ui.mobile .note .age, #ui.mobile .note .place { font-size: 12px; }
#ui.mobile .goal { top: calc(112px + var(--safe-t)); right: auto; left: calc(14px + var(--safe-l)); bottom: auto; max-width: 62vw; padding: 7px 11px 8px; }
#ui.mobile .goal .gt { font-size: 14px; }
#ui.mobile .prompt { bottom: calc(214px + var(--safe-b)); }
#ui.mobile .narr { bottom: calc(272px + var(--safe-b)); }
#ui.mobile .narr p { font-size: 16px; max-width: 94vw; }
/* 横向きのスマホ：字幕は操作の間 */
@media (orientation: landscape) and (max-height: 520px) {
  #ui.mobile .narr { bottom: calc(14px + var(--safe-b)); padding: 0 200px; }
  #ui.mobile .narr p { font-size: 15px; }
  #ui.mobile .prompt { bottom: calc(150px + var(--safe-b)); }
  #ui.mobile .goal { top: calc(14px + var(--safe-t)); left: auto; right: calc(120px + var(--safe-r)); max-width: 34vw; }
  #ui.mobile .meter { top: auto; bottom: calc(196px + var(--safe-b)); }
  .touch .tb { transform: scale(.86); transform-origin: right bottom; }
  .touch .joy { width: 112px; height: 112px; }
}
@media (max-width: 420px) { .hb { min-width: 160px; font-size: 16px; } }

/* 卵の中 */
.hatch { position: absolute; inset: 0; opacity: 0; background: radial-gradient(ellipse at 50% 50%, #fffaf0 0%, #f2ead8 60%, #d9ccb0 100%); transition: opacity 1.2s; }
.hatch.on { opacity: 1; }
.hatch.open { opacity: 0; transform: scale(1.25); transition: opacity 1.3s, transform 1.3s; }
.hatch svg { position: absolute; inset: 0; width: 100%; height: 100%; }
.hatch path { stroke: #4a3f30 !important; stroke-width: .5 !important; vector-effect: non-scaling-stroke; stroke-width: 2.5px !important; }

/* 題の画面：景色の上に紙の札（札は中身の大きさ） */
.title { background: linear-gradient(to bottom, rgba(5, 8, 14, 0) 40%, rgba(5, 8, 14, .45) 100%); }
.title .tbox { position: relative; display: grid; justify-items: center; gap: 4px; padding: 26px clamp(18px, 4vw, 40px) 22px; width: min(560px, 92vw); transform: rotate(-.6deg); }
.title .tbox > .paper { position: absolute; inset: 0; box-shadow: 0 18px 50px rgba(0, 0, 0, .45); }
.title h1 { white-space: nowrap; font-size: clamp(30px, 9vw, 54px); letter-spacing: .08em; }
.title .sub { margin-bottom: 12px; }
