* { box-sizing: border-box; margin: 0; padding: 0; }
html, body { width: 100%; height: 100%; background: #0c0a09; overflow: hidden; touch-action: none; -webkit-user-select: none; user-select: none;
  font-family: "Hiragino Sans", "Hiragino Kaku Gothic ProN", "Noto Sans JP", sans-serif; color: #f2ede4; -webkit-tap-highlight-color: transparent; }
#wrap { position: fixed; inset: 0; overflow: hidden; }
#view { position: absolute; left: 0; top: 0; transform-origin: 0 0; overflow: hidden; }
#gl { position: absolute; inset: 0; width: 100%; height: 100%; display: block; }
button { font: inherit; border: 0; cursor: pointer; color: inherit; }
.off { display: none !important; }

/* 映画の黒い帯 */
#bars .bar { position: absolute; left: 0; right: 0; height: 0; background: #000; transition: height .8s ease; pointer-events: none; }
#bars .top { top: 0; } #bars .bot { bottom: 0; }
#bars.on .bar { height: 6.5%; }

#hud { position: absolute; inset: 0; pointer-events: none; }
#hud > * { pointer-events: auto; }
#clock { position: absolute; left: max(16px, env(safe-area-inset-left)); top: 14px; font-variant-numeric: tabular-nums; text-shadow: 0 2px 8px rgba(0,0,0,.8);
  display: flex; align-items: baseline; gap: 10px; pointer-events: none; }
#clock small { font-size: clamp(14px, 3.4vmin, 22px); color: #d9cdb8; letter-spacing: .1em; }
#clock b { font-size: clamp(22px, 6vmin, 44px); font-weight: 300; letter-spacing: .04em; }
#btnMenu { position: absolute; right: max(14px, env(safe-area-inset-right)); top: 12px; width: clamp(44px, 10vmin, 60px); height: clamp(44px, 10vmin, 60px); border-radius: 50%;
  background: rgba(0,0,0,.45); font-size: clamp(22px, 5.4vmin, 32px); border: 1px solid rgba(255,255,255,.25); }
#btnThink { position: absolute; right: max(14px, env(safe-area-inset-right)); top: calc(22px + clamp(44px, 10vmin, 60px)); padding: 8px 16px; border-radius: 22px;
  background: rgba(0,0,0,.45); font-size: clamp(14px, 3.6vmin, 20px); border: 1px solid rgba(255,255,255,.3); }

/* 調べられる場所の印 */
#marks { position: absolute; inset: 0; pointer-events: none; }
.mark { position: absolute; transform: translate(-50%, -50%); pointer-events: auto; display: flex; flex-direction: column; align-items: center; gap: 4px; cursor: pointer; }
.mark .dot { width: clamp(30px, 7vmin, 44px); height: clamp(30px, 7vmin, 44px); border-radius: 50%; border: 2px solid rgba(255,255,255,.95); background: rgba(255,255,255,.18);
  box-shadow: 0 0 18px rgba(255,240,200,.55); animation: pulse 1.6s ease-in-out infinite; display: grid; place-items: center; font-size: clamp(14px, 3.4vmin, 20px); }
.mark .lab { font-size: clamp(14px, 3.6vmin, 20px); font-weight: 700; background: rgba(0,0,0,.6); padding: 2px 10px; border-radius: 10px; white-space: nowrap; }
.mark.far .dot { opacity: .75; }
@keyframes pulse { 0%,100% { transform: scale(1); } 50% { transform: scale(1.12); } }

/* 指の動きの合図 */
#prompt { position: absolute; transform: translate(-50%, -50%); display: flex; flex-direction: column; align-items: center; gap: 6px; pointer-events: none; }
#prompt .ring { position: relative; width: clamp(70px, 17vmin, 110px); height: clamp(70px, 17vmin, 110px); }
#prompt svg { position: absolute; inset: 0; transform: rotate(-90deg); }
#prompt circle { fill: rgba(0,0,0,.35); stroke-width: 6; }
#prompt circle.bg { stroke: rgba(255,255,255,.35); }
#prompt circle.fg { fill: none; stroke: #fff; stroke-dasharray: 276.5; stroke-dashoffset: 0; stroke-linecap: round; }
#prompt.urgent circle.fg { stroke: #ff6a4a; }
#prompt .icon { position: absolute; inset: 0; display: grid; place-items: center; font-size: clamp(28px, 7vmin, 46px); font-weight: 800; }
#prompt .label { font-size: clamp(16px, 4vmin, 24px); font-weight: 700; background: rgba(0,0,0,.6); padding: 3px 12px; border-radius: 10px; white-space: nowrap; }
#prompt.ok .ring { animation: okpop .35s ease-out; }
#prompt.ok circle.fg { stroke: #7be08f; }
#prompt.bad circle.fg { stroke: #ff6a4a; }
@keyframes okpop { 0% { transform: scale(1); } 50% { transform: scale(1.25); } 100% { transform: scale(1); } }
.icon .arrow { display: inline-block; animation: nudge 0.9s ease-in-out infinite; }
@keyframes nudge { 0%,100% { transform: translate(0,0); } 50% { transform: translate(var(--dx,0), var(--dy,0)); } }

/* 長押しの目盛り */
#gauge { position: absolute; left: 50%; bottom: 24%; transform: translateX(-50%); width: min(60%, 520px); height: clamp(20px, 5vmin, 30px); background: rgba(0,0,0,.55);
  border: 2px solid rgba(255,255,255,.7); border-radius: 16px; overflow: visible; }
#gauge .band { position: absolute; top: -4px; bottom: -4px; background: rgba(123,224,143,.45); border-left: 3px solid #7be08f; border-right: 3px solid #7be08f; }
#gauge .fill { position: absolute; left: 0; top: 0; bottom: 0; width: 0; background: linear-gradient(90deg, #6b3e1f, #c88b52); border-radius: 14px; }
#gauge .cap { position: absolute; left: 50%; top: calc(100% + 8px); transform: translateX(-50%); white-space: nowrap; font-size: clamp(14px, 3.6vmin, 20px); text-shadow: 0 2px 6px #000; }

/* 選択肢 */
#choices { position: absolute; left: 50%; bottom: 7%; transform: translateX(-50%); width: min(94%, 900px); }
#choices .timer { height: 5px; background: rgba(255,255,255,.2); border-radius: 3px; margin: 0 auto 10px; width: 60%; overflow: hidden; }
#choices .timer i { display: block; height: 100%; width: 100%; background: #fff; transform-origin: left; }
#choices.notime .timer { visibility: hidden; }
#choices .list { display: grid; grid-template-columns: repeat(auto-fit, minmax(min(46%, 200px), 1fr)); gap: 10px; }
#choices button { background: rgba(10,10,10,.72); border: 1.5px solid rgba(255,255,255,.55); border-radius: 14px; padding: 12px 14px; font-size: clamp(16px, 4.2vmin, 24px); font-weight: 700;
  text-align: center; line-height: 1.35; transition: background .15s; }
#choices button:hover { background: rgba(60,50,40,.85); }
#choices button.picked { background: #f2ede4; color: #111; }

/* 字幕 */
#sub { position: absolute; left: 50%; bottom: 8%; transform: translateX(-50%); width: min(92%, 980px); text-align: center; pointer-events: none; }
#sub .name { font-size: clamp(14px, 3.6vmin, 20px); color: #f0c98a; font-weight: 700; margin-bottom: 2px; text-shadow: 0 2px 6px #000; }
#sub .text { display: inline-block; font-size: clamp(17px, 4.6vmin, 30px); line-height: 1.5; background: rgba(0,0,0,.6); padding: 6px 18px; border-radius: 10px; font-weight: 600; }
#sub.thought .text { font-style: italic; background: rgba(20,24,34,.6); color: #dfe6f2; }
#sub .next { font-size: clamp(12px, 3vmin, 16px); opacity: .7; margin-top: 4px; animation: blink 1.2s infinite; }
@keyframes blink { 50% { opacity: .2; } }
#sub.raise { bottom: calc(10% + clamp(130px, 30vmin, 210px)); }

#toast { position: absolute; left: 50%; top: 14%; transform: translateX(-50%); font-size: clamp(15px, 3.8vmin, 22px); background: rgba(0,0,0,.6); padding: 6px 16px; border-radius: 12px;
  opacity: 0; transition: opacity .4s; pointer-events: none; white-space: nowrap; }
#toast.on { opacity: 1; }

/* 文字の札（場所と時刻、手紙） */
#card { position: absolute; inset: 0; display: grid; place-items: center; background: rgba(0,0,0,.55); z-index: 5; }
#card .in { max-width: min(86%, 820px); max-height: 88%; overflow-y: auto; text-align: center; font-family: "Hiragino Mincho ProN", "Yu Mincho", serif; }
#card .place { font-size: clamp(15px, 3.8vmin, 24px); letter-spacing: .2em; color: #d9cdb8; }
#card .big { font-size: clamp(26px, 8vmin, 60px); margin-top: 8px; letter-spacing: .06em; }
#card .letter { background: #f4ecdc; color: #2a2118; padding: clamp(18px, 4vmin, 36px); border-radius: 4px; text-align: left; font-size: clamp(17px, 4.4vmin, 27px); line-height: 1.8;
  box-shadow: 0 20px 60px rgba(0,0,0,.6); transform: rotate(-1deg); }
#card .letter small { display: block; margin-top: 12px; color: #6a5a48; font-size: .8em; }
#card .tap { margin-top: 16px; font-size: clamp(13px, 3.2vmin, 18px); opacity: .7; font-family: inherit; animation: blink 1.2s infinite; }

#fade { position: absolute; inset: 0; background: #000; opacity: 1; pointer-events: none; transition: opacity .8s ease; z-index: 8; }

/* 画面（タイトル・メニュー・結末） */
.screen { position: absolute; inset: 0; display: none; z-index: 10; overflow-y: auto; }
.screen.on { display: flex; align-items: center; justify-content: center; }
#title { background: linear-gradient(90deg, rgba(8,7,6,.88) 0%, rgba(8,7,6,.55) 55%, rgba(8,7,6,.1) 100%); justify-content: flex-start; }
#title .tin { margin-left: max(5%, env(safe-area-inset-left)); max-width: 640px; padding: 18px 0; }
.kicker { font-size: clamp(13px, 3.2vmin, 18px); letter-spacing: .32em; color: #c9b48f; }
#title h1 { font-family: "Hiragino Mincho ProN", "Yu Mincho", serif; font-size: clamp(36px, 11vmin, 84px); font-weight: 600; letter-spacing: .08em; line-height: 1.2; }
.en { font-size: clamp(13px, 3.2vmin, 18px); letter-spacing: .4em; color: #a99c88; margin-bottom: 2.5vmin; }
.lead { font-size: clamp(16px, 4.2vmin, 24px); line-height: 1.7; margin-bottom: 1.5vmin; }
.how { font-size: clamp(14px, 3.6vmin, 19px); line-height: 1.7; color: #d6ccbc; margin-bottom: 2vmin; }
.how b { color: #fff; }
.opt { display: flex; align-items: center; gap: 12px; margin: 1.2vmin 0; flex-wrap: wrap; }
.opt > span { font-size: clamp(14px, 3.6vmin, 19px); color: #d6ccbc; min-width: 7em; }
.seg { display: inline-flex; border: 1.5px solid rgba(255,255,255,.5); border-radius: 12px; overflow: hidden; }
.seg button { padding: 7px 16px; font-size: clamp(14px, 3.6vmin, 19px); background: transparent; }
.seg button.on { background: #f2ede4; color: #111; font-weight: 700; }
.load { font-size: clamp(14px, 3.4vmin, 18px); color: #a99c88; margin: 1.5vmin 0; }
.btn { background: #f2ede4; color: #14110f; font-size: clamp(18px, 5vmin, 28px); font-weight: 800; padding: 12px 34px; border-radius: 40px; letter-spacing: .05em; }
.btn:disabled { opacity: .35; }
.btn.sub { background: transparent; color: #f2ede4; border: 2px solid #f2ede4; }
.note { font-size: clamp(13px, 3vmin, 15px); color: #8f8474; margin-top: 2vmin; }
.btns { display: flex; gap: 14px; justify-content: center; flex-wrap: wrap; margin-top: 2vmin; }
#menu, #ending { background: rgba(8,7,6,.86); }
#menu .tin, #ending .tin { width: min(92%, 760px); text-align: center; padding: 24px 0; max-height: 100%; }
#menu .opt { justify-content: center; }
#menu h2 { font-size: clamp(22px, 6vmin, 36px); margin-bottom: 2vmin; }
#ending h2 { font-family: "Hiragino Mincho ProN", "Yu Mincho", serif; font-size: clamp(28px, 8vmin, 54px); margin: 4px 0 2vmin; letter-spacing: .08em; }
#endBody { font-family: "Hiragino Mincho ProN", "Yu Mincho", serif; font-size: clamp(16px, 4.2vmin, 24px); line-height: 1.9; text-align: left; display: inline-block; max-width: 100%; }
#endBody p { margin-bottom: 1em; }
#endPath { margin: 2vmin auto 0; text-align: left; display: inline-block; font-size: clamp(14px, 3.5vmin, 18px); color: #d6ccbc; line-height: 1.7; border-top: 1px solid rgba(255,255,255,.2); padding-top: 1.5vmin; }
#endPath b { color: #f0c98a; font-weight: 700; }

#rotate { display: none; position: absolute; left: 50%; bottom: 60px; transform: translateX(-50%); background: #f2ede4; color: #111; padding: 8px 18px; border-radius: 12px; font-size: 18px; z-index: 20; }
body.portrait #rotate { display: block; }
body.portrait #rotate.hide { display: none; }

/* 文字の大きさ（大・特大） */
#view.fz1 #sub, #view.fz1 #choices, #view.fz1 #prompt .label, #view.fz1 .mark .lab, #view.fz1 #card .in, #view.fz1 .screen .tin { zoom: 1.15; }
#view.fz2 #sub, #view.fz2 #choices, #view.fz2 #prompt .label, #view.fz2 .mark .lab, #view.fz2 #card .in, #view.fz2 .screen .tin { zoom: 1.3; }
/* 低い画面（スマホの横持ち） */
#view.short #title .tin { padding: 6px 0; }
#view.short #title .kicker, #view.short #title .en { display: none; }
#view.short #title h1 { font-size: 32px; }
#view.short .lead { margin-bottom: 4px; line-height: 1.5; }
#view.short .how { margin-bottom: 4px; line-height: 1.5; }
#view.short .opt { margin: 4px 0; }
#view.short .btn { padding: 8px 28px; }
#view.short .note { margin-top: 4px; }
#view.short #title { overflow-y: auto; align-items: flex-start; }
#view.short #title .tin { margin-top: auto; margin-bottom: auto; }
.mark.goal { pointer-events: none; }
.mark.goal .dot { animation: none; border-style: dashed; background: transparent; box-shadow: none; }
.mark.goal .lab { background: rgba(20,24,34,.7); }
.mark.edge .dot { width: clamp(24px, 5vmin, 32px); height: clamp(24px, 5vmin, 32px); }

#chapters { background: rgba(8,7,6,.9); }
#chapters .tin { width: min(94%, 820px); padding: 18px 0; text-align: center; max-height: 100%; }
#chapters h2 { font-family: "Hiragino Mincho ProN", "Yu Mincho", serif; font-size: clamp(24px, 7vmin, 40px); margin: 4px 0 2vmin; letter-spacing: .1em; }
#chList { display: grid; gap: 8px; text-align: left; }
.ch { display: flex; align-items: center; gap: 14px; padding: 10px 16px; border-radius: 12px; background: rgba(255,255,255,.06); border: 1px solid rgba(255,255,255,.18); width: 100%; }
.ch:hover { background: rgba(255,255,255,.12); }
.ch .no { font-family: "Hiragino Mincho ProN", serif; font-size: clamp(16px, 4vmin, 22px); color: #c9b48f; min-width: 3.2em; }
.ch .tt { font-family: "Hiragino Mincho ProN", serif; font-size: clamp(18px, 4.8vmin, 28px); }
.ch .sb { font-size: clamp(13px, 3.4vmin, 17px); color: #a99c88; margin-left: auto; text-align: right; }
.ch .dn { font-size: clamp(13px, 3.2vmin, 15px); color: #7be08f; }
.ch[disabled] { opacity: .35; }
#view.fz1 #chapters .tin { zoom: 1.1; } #view.fz2 #chapters .tin { zoom: 1.2; }
#view.short #chapters .tin { padding: 4px 0; } #view.short .ch { padding: 6px 12px; }

#openHint { display: none; position: absolute; left: 50%; top: max(10px, env(safe-area-inset-top)); transform: translateX(-50%); width: min(92%, 640px); z-index: 12;
  background: #f2ede4; color: #14110f; border-radius: 12px; padding: 10px 44px 10px 14px; font-size: clamp(14px, 3.6vmin, 17px); line-height: 1.5; box-shadow: 0 6px 20px rgba(0,0,0,.5); }
#openHint.on { display: block; }
#openHint button { position: absolute; right: 6px; top: 50%; transform: translateY(-50%); width: 34px; height: 34px; border-radius: 50%; background: #14110f; color: #f2ede4; font-size: 18px; }
#view.fz1 #openHint { zoom: 1.1; } #view.fz2 #openHint { zoom: 1.2; }
