/* 我愛區段 — 視覺：炭黑、黃銅細框、暖黃桌燈（依參考圖 S__47570946.jpg） */
:root {
  color-scheme: dark;
  --bg: #090b0e; --panel: rgba(13, 16, 21, .93); --panel-solid: #10141a; --panel-2: #171c24;
  --line: rgba(196, 164, 108, .34); --line-strong: rgba(214, 180, 118, .62);
  --text: #efe6d2; --dim: #b9ad95; --muted: #7d7567;
  --accent: #e8b65a; --accent-press: #c9983f; --on-accent: #17120a;
  --prep: #d9c39a; --energy: #6dbb68; --mood: #5a94e0; --money: #e0a93b;
  --up: #7fb4f0; --down: #e2705f; --good: #7ccf8a;
  --r-panel: .7rem; --r-ctl: .45rem;
  --focus: 0 0 0 2px rgba(232, 182, 90, .55);
  --serif: 'Noto Serif TC', 'Songti TC', 'PMingLiU', serif;
  --sans: 'Noto Sans TC', 'PingFang TC', 'Microsoft JhengHei', sans-serif;
  --mono: 'JetBrains Mono', 'SF Mono', Menlo, monospace;
}
* { box-sizing: border-box; margin: 0; }
html { font-size: clamp(14px, .62vw + 1.02vh, 24px); height: 100%; }
body { height: 100%; background: var(--bg); color: var(--text); font-family: var(--sans); line-height: 1.6; overflow: hidden; -webkit-font-smoothing: antialiased; }
button { font: inherit; color: inherit; background: none; border: 0; cursor: pointer; text-align: inherit; }
button:focus-visible, [tabindex]:focus-visible { outline: none; box-shadow: var(--focus); }
button:disabled { cursor: not-allowed; }
.num { font-family: var(--mono); font-variant-numeric: tabular-nums; }
.icon { width: 1em; height: 1em; fill: none; stroke: currentColor; stroke-width: 1.7; stroke-linecap: round; stroke-linejoin: round; flex: none; }
[hidden] { display: none !important; }

#app { position: fixed; inset: 0; overflow: hidden; }

/* ---------- 場景 ---------- */
#scene { position: absolute; inset: 0; background: #07090b; }
#scene .bg { position: absolute; inset: -2%; width: 104%; height: 104%; object-fit: cover; object-position: 62% 32%; opacity: 0; transition: opacity 1.1s ease; will-change: opacity, transform; }
#scene .bg.on { opacity: 1; animation: drift 26s ease-in-out infinite alternate; }
@keyframes drift { from { transform: scale(1.0) translate(0, 0); } to { transform: scale(1.045) translate(-.8%, -.6%); } }
#fx { position: absolute; inset: 0; width: 100%; height: 100%; pointer-events: none; transition: opacity .6s; }
#world { position: absolute; inset: 0; width: 100%; height: 100%; opacity: 0; pointer-events: none; transition: opacity .6s; touch-action: none; cursor: pointer; }
#app.world-on #world { opacity: 1; pointer-events: auto; }
#app.world-on #scene .bg, #app.world-on #scene .lamp, #app.world-on #fx { opacity: 0; }
#app.world-on #scene .grade { pointer-events: none; background: radial-gradient(130% 100% at 55% 45%, transparent 55%, rgba(5, 6, 8, .7) 100%), linear-gradient(to right, rgba(7, 9, 12, .6) 0%, transparent 30%), linear-gradient(to top, rgba(7, 9, 12, .8) 0%, transparent 22%); }
#wlabels { position: absolute; inset: 0; z-index: 2; pointer-events: none; overflow: hidden; }
.wl { position: absolute; left: 0; top: 0; pointer-events: auto; display: flex; align-items: center; gap: .4rem; padding: .16rem .6rem; border-radius: 1rem; border: 1px solid var(--line); background: rgba(13, 16, 21, .78); font-size: .74rem; color: var(--dim); white-space: nowrap; transition: border-color .15s, background .15s, color .15s; }
.wl b { font-weight: 500; } .wl kbd, .wl span { display: none; }
.wl:hover { border-color: var(--line-strong); color: var(--text); }
.wl.near { border-color: var(--accent); color: var(--text); background: rgba(18, 20, 25, .96); font-size: .9rem; padding: .3rem .8rem .3rem .4rem; z-index: 2; }
.wl.near kbd { display: inline-grid; place-items: center; width: 1.4rem; height: 1.4rem; border-radius: var(--r-ctl); background: var(--accent); color: var(--on-accent); font-family: var(--mono); font-size: .74rem; font-weight: 700; }
.wl.near span { display: inline; color: var(--dim); font-size: .78rem; }
.wl.off b { color: var(--muted); } .wl.off.near span { color: var(--down); }
.wbar { display: flex; align-items: center; gap: 1.2rem; padding: .7rem 1.1rem; width: fit-content; max-width: 100%; margin: 0 auto; }
.wbar h2 { font-family: var(--serif); font-size: 1.15rem; font-weight: 700; letter-spacing: .06em; white-space: nowrap; }
.wbar p { font-size: .8rem; color: var(--dim); }
.wbar p kbd, .linkish kbd { font-family: var(--mono); font-size: .7rem; padding: .05rem .35rem; border: 1px solid var(--line); border-radius: var(--r-ctl); color: var(--text); }
.linkish { padding: .35rem .8rem; border: 1px solid var(--line); border-radius: var(--r-ctl); font-size: .8rem; color: var(--dim); white-space: nowrap; transition: border-color .15s, color .15s; }
.linkish:hover { border-color: var(--line-strong); color: var(--accent); }
.talk .walkhint { margin-top: .7rem; display: flex; flex-wrap: wrap; align-items: center; gap: .8rem; font-size: .86rem; color: var(--accent); }
#scene .grade { position: absolute; inset: 0; pointer-events: none;
  background:
    radial-gradient(120% 90% at 62% 30%, transparent 35%, rgba(5, 6, 8, .62) 100%),
    linear-gradient(to right, rgba(7, 9, 12, .82) 0%, rgba(7, 9, 12, .35) 26%, transparent 46%),
    linear-gradient(to top, rgba(7, 9, 12, .97) 0%, rgba(7, 9, 12, .86) 24%, rgba(7, 9, 12, .3) 52%, transparent 70%); }
#scene .lamp { position: absolute; inset: 0; pointer-events: none; background: radial-gradient(38% 34% at 72% 26%, rgba(255, 196, 110, .16), transparent 70%); mix-blend-mode: screen; animation: flicker 7s infinite; }
@keyframes flicker { 0%, 100% { opacity: .9; } 42% { opacity: 1; } 44% { opacity: .72; } 46% { opacity: 1; } 78% { opacity: .84; } }
#app.urgent #scene { animation: shake .5s; }
#app.urgent #scene .grade { box-shadow: inset 0 0 12rem rgba(226, 112, 95, .32); }
@keyframes shake { 10%, 90% { transform: translate(-2px, 0); } 30%, 70% { transform: translate(4px, 1px); } 50% { transform: translate(-5px, -1px); } }

/* ---------- 面板共用 ---------- */
.panel { background: var(--panel); border: 1px solid var(--line); border-radius: var(--r-panel); }
.micro { font-family: var(--mono); font-size: .62rem; letter-spacing: .18em; text-transform: uppercase; color: var(--muted); }

/* ---------- HUD ---------- */
#hud { position: absolute; top: 1rem; left: 1rem; width: 17.5rem; display: grid; gap: .5rem; z-index: 3; }
.who { display: flex; gap: .8rem; align-items: center; padding: .1rem .1rem .3rem; }
.avatar { width: 4.6rem; height: 4.6rem; border-radius: 50%; border: 2px solid var(--line-strong); overflow: hidden; background: #111; flex: none; box-shadow: 0 0 0 4px rgba(0, 0, 0, .35); }
.avatar img { width: 100%; height: 100%; object-fit: cover; object-position: 50% 22%; transition: opacity .5s; }
.who small { display: block; color: var(--dim); font-size: .74rem; }
.who b { display: block; font-family: var(--serif); font-size: 1.45rem; font-weight: 700; letter-spacing: .06em; line-height: 1.25; }
.stat { padding: .5rem .7rem .55rem; display: grid; grid-template-columns: 1.7rem 1fr auto; column-gap: .6rem; align-items: center; position: relative; }
.stat .icon { font-size: 1.45rem; }
.stat .label { font-size: .86rem; font-weight: 500; }
.stat .val { font-size: .8rem; color: var(--dim); }
.stat .bar { grid-column: 2 / 4; height: .42rem; border-radius: 1rem; background: rgba(255, 255, 255, .09); overflow: hidden; margin-top: .2rem; }
.stat .bar i { display: block; height: 100%; border-radius: 1rem; width: 0; transition: width .7s cubic-bezier(.2, .7, .2, 1); }
.stat.prep .icon, .stat.prep .bar i { color: var(--prep); background-color: var(--prep); }
.stat.energy .icon { color: var(--energy); } .stat.energy .bar i { background: var(--energy); }
.stat.mood .icon { color: var(--mood); } .stat.mood .bar i { background: var(--mood); }
.stat.money .icon { color: var(--money); } .stat.money .bar i { background: var(--money); }
.stat.prep .icon { background: none; }
.stat.low .bar i { background: var(--down); }
.stat.low { border-color: rgba(226, 112, 95, .6); animation: lowpulse 1.6s infinite; }
@keyframes lowpulse { 50% { border-color: rgba(226, 112, 95, .2); } }
.topics { grid-column: 1 / 4; display: grid; grid-template-columns: repeat(4, 1fr); gap: .35rem; margin-top: .45rem; }
.topics div { font-size: .68rem; color: var(--dim); position: relative; }
.topics div span { display: flex; justify-content: space-between; }
.topics div em { font-style: normal; color: var(--accent); }
.topics div u { display: block; height: .22rem; border-radius: 1rem; background: rgba(255, 255, 255, .09); margin-top: .12rem; overflow: hidden; text-decoration: none; }
.topics div u b { display: block; height: 100%; background: var(--prep); transition: width .7s; }
.float { position: absolute; right: .6rem; top: -.2rem; font-family: var(--mono); font-size: .92rem; font-weight: 700; pointer-events: none; animation: floatup 1.5s ease-out forwards; text-shadow: 0 1px 4px #000; }
.float.up { color: var(--good); } .float.down { color: var(--down); }
@keyframes floatup { from { opacity: 0; transform: translateY(.4rem); } 15% { opacity: 1; } to { opacity: 0; transform: translateY(-1.5rem); } }
.buffs { display: flex; flex-wrap: wrap; gap: .3rem; }
.buffs span { font-size: .68rem; padding: .12rem .5rem; border-radius: 1rem; border: 1px solid var(--line); background: var(--panel); color: var(--dim); }
.buffs span.bad { color: var(--down); border-color: rgba(226, 112, 95, .45); }
.buffs span.good { color: var(--good); border-color: rgba(124, 207, 138, .4); }

/* ---------- 日期／工具 ---------- */
#right { position: absolute; top: 1rem; right: 1rem; z-index: 3; display: grid; gap: .5rem; justify-items: end; }
#clock { width: 13.5rem; padding: .7rem .9rem .75rem; text-align: center; }
#clock .date { font-size: 1rem; font-weight: 500; }
#clock .slot { display: flex; justify-content: center; align-items: center; gap: .45rem; font-family: var(--serif); font-size: 1.45rem; font-weight: 700; margin: .1rem 0 .35rem; }
#clock .slot .icon { color: var(--accent); font-size: 1.3rem; }
#clock .pips { display: flex; justify-content: center; gap: .3rem; margin-bottom: .5rem; }
#clock .pips i { width: 1.5rem; height: .22rem; border-radius: 1rem; background: rgba(255, 255, 255, .13); }
#clock .pips i.done { background: var(--muted); } #clock .pips i.now { background: var(--accent); }
#clock .count { border-top: 1px solid var(--line); padding-top: .45rem; font-size: .84rem; color: var(--dim); }
#clock .count b { font-family: var(--serif); font-size: 1.9rem; color: var(--accent); margin: 0 .25rem; line-height: 1; vertical-align: -.12em; }
#clock .todo { margin-top: .4rem; font-size: .72rem; color: var(--accent); }
#tools { display: flex; gap: .4rem; }
#tools button { width: 2.5rem; height: 2.5rem; display: grid; place-items: center; font-size: 1.15rem; color: var(--dim); position: relative; transition: color .15s, border-color .15s, transform .15s; }
#tools button:hover { color: var(--accent); border-color: var(--line-strong); transform: translateY(-1px); }
#tools button .dot { position: absolute; top: .3rem; right: .3rem; width: .45rem; height: .45rem; border-radius: 50%; background: var(--down); }

/* ---------- 下方操作區 ---------- */
#dock { position: absolute; left: 0; right: 0; bottom: 0; padding: 0 1.2rem 1.2rem; z-index: 4; display: flex; justify-content: center; pointer-events: none; }
#dock > section { width: min(100%, 72rem); pointer-events: none; }
#dock > section > * { pointer-events: auto; }
.prompt { display: flex; align-items: baseline; gap: 1rem; margin: 0 .2rem .6rem; }
.prompt h2 { font-family: var(--serif); font-size: 1.35rem; font-weight: 700; letter-spacing: .04em; text-shadow: 0 2px 10px #000; }
.prompt p { color: var(--dim); font-size: .86rem; text-shadow: 0 1px 6px #000; }
.prompt .shop { margin-left: auto; padding: .4rem .9rem; display: flex; align-items: center; gap: .5rem; font-size: .88rem; transition: border-color .15s, color .15s; }
.prompt .shop:hover { border-color: var(--line-strong); color: var(--accent); }
.prompt .shop .icon { font-size: 1.1rem; color: var(--accent); }
.acts { display: grid; grid-template-columns: repeat(6, 1fr); gap: .7rem; }
.act { padding: .85rem .7rem .8rem; text-align: center; display: grid; justify-items: center; gap: .1rem; position: relative; transition: transform .16s, border-color .16s, background .16s; }
.act .icon { font-size: 2.3rem; color: var(--prep); margin-bottom: .25rem; stroke-width: 1.4; }
.act h3 { font-family: var(--serif); font-size: 1.2rem; font-weight: 700; letter-spacing: .08em; }
.act p { font-size: .76rem; color: var(--dim); }
.act kbd { position: absolute; top: .4rem; left: .55rem; font-family: var(--mono); font-size: .62rem; color: var(--muted); }
.act:not(:disabled):hover { transform: translateY(-3px); border-color: var(--line-strong); background: rgba(24, 28, 36, .94); }
.act:not(:disabled):hover .icon { color: var(--accent); }
.act:disabled { opacity: .46; }
.act:disabled p { color: var(--down); }

/* 對話／結果 */
.talk { display: grid; grid-template-columns: auto 1fr; gap: 1.1rem; padding: 1.1rem 1.3rem 1.2rem; animation: rise .35s ease-out; }
@keyframes rise { from { opacity: 0; transform: translateY(.8rem); } }
@keyframes risein { from { opacity: 0; transform: translateY(.6rem); } to { opacity: 1; transform: none; } }
.talk .face { width: 6.2rem; }
.talk .face .ph { width: 6.2rem; height: 6.2rem; border-radius: 50%; border: 2px solid var(--line-strong); overflow: hidden; background: var(--panel-2); display: grid; place-items: center; font-family: var(--serif); font-size: 2rem; color: var(--accent); }
.talk .face img { width: 100%; height: 100%; object-fit: cover; object-position: 50% 20%; }
.talk .face span { display: block; text-align: center; margin-top: .35rem; font-size: .82rem; color: var(--dim); }
.talk .tag { display: flex; align-items: center; gap: .6rem; margin-bottom: .3rem; }
.talk .tag h2 { font-family: var(--serif); font-size: 1.25rem; font-weight: 700; letter-spacing: .04em; }
.talk.urgent { border-color: rgba(226, 112, 95, .7); }
.talk.urgent .tag h2 { color: var(--down); }
.talk .body { font-size: 1.02rem; line-height: 1.85; white-space: pre-line; min-height: 3.6rem; max-width: 52rem; cursor: default; }
.talk .choices { display: grid; grid-template-columns: repeat(auto-fit, minmax(15rem, 1fr)); gap: .55rem; margin-top: .9rem; }
.choice { padding: .6rem .9rem; border: 1px solid var(--line); border-radius: var(--r-ctl); background: rgba(255, 255, 255, .03); display: grid; gap: .05rem; transition: border-color .15s, background .15s, transform .15s; opacity: 0; animation: risein .3s ease-out forwards; }
.choice b { font-weight: 500; font-size: .98rem; }
.choice small { font-size: .74rem; color: var(--dim); }
.choice:not(:disabled):hover { border-color: var(--accent); background: rgba(232, 182, 90, .1); transform: translateX(3px); }
.choice:disabled { filter: saturate(.4) brightness(.6); }
.choice:disabled small { color: var(--down); }
.chips { display: flex; flex-wrap: wrap; gap: .4rem; margin-top: .8rem; }
.chip { font-family: var(--mono); font-size: .8rem; padding: .16rem .6rem; border-radius: 1rem; border: 1px solid var(--line); background: rgba(0, 0, 0, .3); opacity: 0; animation: risein .3s ease-out forwards; }
.chip.up { color: var(--up); border-color: rgba(127, 180, 240, .4); } .chip.down { color: var(--down); border-color: rgba(226, 112, 95, .4); }
.go { margin-top: .9rem; display: inline-flex; align-items: center; gap: .5rem; padding: .5rem 1.4rem; border-radius: var(--r-ctl); background: var(--accent); color: var(--on-accent); font-weight: 700; transition: background .15s, transform .15s; }
.go:hover { background: #f3c672; transform: translateY(-1px); }
.go:active { background: var(--accent-press); }
.go kbd { font-family: var(--mono); font-size: .68rem; opacity: .6; font-weight: 400; }

/* 新的一天 */
#daycard { position: absolute; inset: 0; z-index: 8; display: grid; place-items: center; background: rgba(6, 7, 9, .9); animation: fade .5s; text-align: center; padding: 2rem; }
@keyframes fade { from { opacity: 0; } }
#daycard .in { max-width: 34rem; }
#daycard h2 { font-family: var(--serif); font-size: 2.6rem; font-weight: 700; letter-spacing: .1em; margin: .5rem 0 .2rem; }
#daycard .big { font-family: var(--serif); font-size: 1.1rem; color: var(--dim); }
#daycard .big b { font-size: 3.6rem; color: var(--accent); margin: 0 .5rem; vertical-align: -.1em; }
#daycard p { color: var(--dim); margin-top: 1rem; line-height: 1.9; }
#daycard .chips { justify-content: center; }

/* LINE 通知 */
#banner { position: absolute; top: 1rem; left: 50%; width: min(26rem, 92vw); transform: translate(-50%, -160%); z-index: 9; padding: .7rem .9rem; display: flex; gap: .7rem; align-items: center; transition: transform .45s cubic-bezier(.2, .9, .3, 1.2); }
#banner.on { transform: translate(-50%, 0); animation: buzz .5s .35s 2; }
@keyframes buzz { 20% { margin-left: -4px; } 40% { margin-left: 4px; } 60% { margin-left: -3px; } 80% { margin-left: 3px; } }
#banner .ph { width: 2.6rem; height: 2.6rem; border-radius: 50%; overflow: hidden; background: var(--panel-2); display: grid; place-items: center; font-family: var(--serif); color: var(--accent); flex: none; border: 1px solid var(--line); }
#banner .ph img { width: 100%; height: 100%; object-fit: cover; object-position: 50% 20%; }
#banner b { display: block; font-size: .84rem; } #banner span { display: block; font-size: .8rem; color: var(--dim); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; max-width: 19rem; }
#banner .micro { margin-left: auto; align-self: flex-start; }

/* ---------- 對話框（選單／商店／日誌） ---------- */
dialog { border: 1px solid var(--line-strong); border-radius: var(--r-panel); background: var(--panel-solid); color: var(--text); padding: 0; width: min(46rem, 94vw); max-height: 88vh; margin: auto; }
dialog::backdrop { background: rgba(4, 5, 7, .78); }
dialog[open] { animation: rise .25s ease-out; }
dialog header { display: flex; align-items: center; gap: .8rem; padding: 1rem 1.2rem .8rem; border-bottom: 1px solid var(--line); position: sticky; top: 0; background: var(--panel-solid); z-index: 1; }
dialog header h2 { font-family: var(--serif); font-size: 1.4rem; font-weight: 700; letter-spacing: .06em; }
dialog header p { color: var(--dim); font-size: .82rem; }
dialog header .x { margin-left: auto; width: 2.2rem; height: 2.2rem; display: grid; place-items: center; border-radius: var(--r-ctl); border: 1px solid var(--line); color: var(--dim); font-size: 1rem; }
dialog header .x:hover { color: var(--accent); border-color: var(--line-strong); }
dialog .in { padding: 1rem 1.2rem 1.3rem; overflow: auto; }
.tsel { display: grid; grid-template-columns: repeat(4, 1fr); gap: .5rem; margin-bottom: 1rem; }
.tsel button { padding: .5rem .6rem; border: 1px solid var(--line); border-radius: var(--r-ctl); background: rgba(255, 255, 255, .03); transition: border-color .15s, background .15s; }
.tsel button:hover { border-color: var(--line-strong); }
.tsel button[aria-pressed="true"] { border-color: var(--accent); background: rgba(232, 182, 90, .12); }
.tsel b { display: flex; justify-content: space-between; font-size: .95rem; font-weight: 500; }
.tsel b em { font-style: normal; color: var(--accent); font-size: .74rem; }
.tsel u { display: block; height: .3rem; border-radius: 1rem; background: rgba(255, 255, 255, .1); margin: .3rem 0 .15rem; overflow: hidden; text-decoration: none; }
.tsel u i { display: block; height: 100%; background: var(--prep); }
.tsel small { font-size: .7rem; color: var(--dim); }
.hintline { font-size: .8rem; color: var(--dim); margin-bottom: .8rem; }
.hintline b { color: var(--accent); font-weight: 500; }
.opt { width: 100%; display: grid; grid-template-columns: 1fr auto; gap: .2rem 1rem; align-items: center; padding: .75rem .95rem; border: 1px solid var(--line); border-radius: var(--r-ctl); background: rgba(255, 255, 255, .03); margin-bottom: .55rem; transition: border-color .15s, background .15s, transform .15s; }
.opt h3 { font-size: 1.05rem; font-weight: 500; }
.opt p { font-size: .8rem; color: var(--dim); grid-column: 1; }
.opt .fx { grid-row: 1 / 3; grid-column: 2; display: flex; flex-wrap: wrap; gap: .3rem; justify-content: flex-end; max-width: 17rem; }
.opt .fx span { font-family: var(--mono); font-size: .74rem; padding: .1rem .5rem; border-radius: 1rem; border: 1px solid var(--line); white-space: nowrap; }
.opt .fx .up { color: var(--up); } .opt .fx .down { color: var(--down); } .opt .fx .gold { color: var(--accent); }
.opt:not(:disabled):hover { border-color: var(--accent); background: rgba(232, 182, 90, .09); transform: translateX(3px); }
.opt:disabled { opacity: .45; } .opt:disabled p { color: var(--down); }
.logrow { padding: .7rem 0; border-bottom: 1px solid rgba(255, 255, 255, .06); }
.logrow time { font-family: var(--mono); font-size: .68rem; color: var(--muted); letter-spacing: .08em; }
.logrow h3 { font-size: .98rem; font-weight: 500; margin: .1rem 0; }
.logrow p { font-size: .84rem; color: var(--dim); white-space: pre-line; }
.empty { color: var(--muted); text-align: center; padding: 2rem 0; }
.notes h3 { font-family: var(--serif); font-size: 1.05rem; margin: 1rem 0 .4rem; color: var(--accent); }
.notes h3:first-child { margin-top: 0; }
.notes li { margin-left: 1.2rem; font-size: .9rem; color: var(--dim); padding: .12rem 0; }
.notes p { font-size: .9rem; color: var(--dim); }

/* ---------- 全螢幕畫面：標題／考試／結局 ---------- */
.screen { position: absolute; inset: 0; z-index: 6; display: grid; overflow: auto; }
#title { align-content: center; justify-items: start; padding: 0 clamp(1.5rem, 8vw, 9rem); background: linear-gradient(to right, rgba(6, 7, 9, .94) 0%, rgba(6, 7, 9, .72) 38%, rgba(6, 7, 9, .1) 70%); }
#title .micro { margin-bottom: .8rem; }
#title h1 { font-family: var(--serif); font-size: clamp(3.4rem, 7.2vw, 6.4rem); font-weight: 900; letter-spacing: .14em; line-height: 1.15; text-shadow: 0 4px 30px rgba(0, 0, 0, .8); }
#title h1 em { font-style: normal; color: var(--accent); }
#title .sub { font-family: var(--serif); font-size: 1.2rem; color: var(--dim); margin: .9rem 0 2rem; line-height: 1.9; }
#title .menu { display: grid; gap: .6rem; width: 17rem; }
#title .menu button { padding: .75rem 1.2rem; border: 1px solid var(--line); border-radius: var(--r-ctl); background: rgba(13, 16, 21, .8); font-size: 1.02rem; display: flex; justify-content: space-between; align-items: center; transition: border-color .15s, background .15s, transform .15s; }
#title .menu button:hover { border-color: var(--accent); transform: translateX(4px); }
#title .menu button.main { background: var(--accent); color: var(--on-accent); font-weight: 700; border-color: var(--accent); }
#title .menu button.main:hover { background: #f3c672; }
#title .menu small { font-family: var(--mono); font-size: .7rem; opacity: .7; }
#title .foot { margin-top: 2rem; font-size: .76rem; color: var(--muted); max-width: 30rem; line-height: 1.8; }
#loading { position: absolute; inset: 0; z-index: 20; background: var(--bg); display: grid; place-items: center; text-align: center; transition: opacity .6s; }
#loading.off { opacity: 0; pointer-events: none; }
#loading .barwrap { width: 14rem; height: .25rem; border-radius: 1rem; background: rgba(255, 255, 255, .1); margin: 1rem auto 0; overflow: hidden; }
#loading .barwrap i { display: block; height: 100%; width: 0; background: var(--accent); transition: width .3s; }

#exam { place-items: start center; padding: 2rem 1.2rem; background: rgba(6, 7, 9, .55); }
#exam .sheet { width: min(44rem, 100%); padding: 1.6rem 1.8rem 1.8rem; margin: auto 0; }
#exam h2 { font-family: var(--serif); font-size: 1.9rem; letter-spacing: .1em; }
#exam .lead { color: var(--dim); margin: .3rem 0 1.2rem; }
.round { display: grid; grid-template-columns: 5.5rem 1fr 4.2rem; gap: .9rem; align-items: center; padding: .65rem 0; border-top: 1px solid rgba(255, 255, 255, .07); animation: rise .4s ease-out; }
.round h3 { font-family: var(--serif); font-size: 1.2rem; }
.round h3 small { display: block; font-family: var(--mono); font-size: .68rem; color: var(--muted); font-weight: 400; letter-spacing: .05em; }
.round.boss h3 small { color: var(--down); }
.round p { font-size: .88rem; color: var(--dim); }
.round .pct { font-family: var(--mono); font-size: 1.5rem; text-align: right; }
.round .pct.hi { color: var(--good); } .round .pct.mid { color: var(--text); } .round .pct.low { color: var(--money); } .round .pct.bad { color: var(--down); }
.modrow { display: flex; justify-content: space-between; font-size: .88rem; color: var(--dim); padding: .22rem 0; animation: rise .3s ease-out; }
.modrow b { font-family: var(--mono); font-weight: 500; }
.modrow b.up { color: var(--good); } .modrow b.down { color: var(--down); }
#exam .ask { margin-top: 1rem; padding-top: 1rem; border-top: 1px solid var(--line); animation: rise .4s ease-out; }
#exam .ask p { margin-bottom: .7rem; line-height: 1.8; }
#exam .ask .choices { display: grid; grid-template-columns: 1fr 1fr; gap: .55rem; }
.final { text-align: center; margin-top: 1.2rem; padding-top: 1.2rem; border-top: 1px solid var(--line); }
.final .score { font-family: var(--serif); font-size: 5rem; font-weight: 900; line-height: 1; color: var(--accent); }
.final .score small { font-size: 1.2rem; color: var(--dim); font-weight: 400; }
.final .stamp { display: inline-block; margin: .8rem 0 1rem; padding: .2rem 1.4rem; border: 3px solid currentColor; border-radius: var(--r-ctl); font-family: var(--serif); font-size: 1.6rem; font-weight: 900; letter-spacing: .3em; transform: rotate(-6deg); animation: stamp .45s cubic-bezier(.3, 1.6, .5, 1); }
.final .stamp.pass { color: var(--good); } .final .stamp.fail { color: var(--down); }
@keyframes stamp { from { transform: rotate(-6deg) scale(2.6); opacity: 0; } }

#ending { padding: 2.2rem 1.2rem 3rem; justify-items: center; align-content: start; background: linear-gradient(to bottom, rgba(6, 7, 9, .35), rgba(6, 7, 9, .9) 55%); }
#ending .wrap { width: min(52rem, 100%); }
#ending .head { text-align: center; margin: 9vh 0 1.6rem; }
#ending .head h2 { font-family: var(--serif); font-size: clamp(2.2rem, 5vw, 3.6rem); font-weight: 900; letter-spacing: .1em; margin: .5rem 0; text-shadow: 0 3px 20px #000; }
#ending .head .rank { font-family: var(--mono); color: var(--accent); font-size: 1rem; letter-spacing: .2em; }
#ending .story { padding: 1.3rem 1.6rem; font-family: var(--serif); font-size: 1.08rem; line-height: 2.1; white-space: pre-line; }
#ending .grid { display: grid; grid-template-columns: 1fr 1fr; gap: .8rem; margin-top: .8rem; }
#ending .box { padding: 1rem 1.2rem; }
#ending .box h3 { font-family: var(--serif); font-size: 1.05rem; color: var(--accent); margin-bottom: .5rem; letter-spacing: .06em; }
#ending .box li { list-style: none; font-size: .86rem; color: var(--dim); padding: .25rem 0 .25rem 1rem; position: relative; line-height: 1.6; }
#ending .box li::before { content: ''; position: absolute; left: 0; top: .78rem; width: .35rem; height: .35rem; border-radius: 50%; background: var(--line-strong); }
#ending .box li time { font-family: var(--mono); font-size: .68rem; color: var(--muted); margin-right: .4rem; }
.alloc { display: grid; grid-template-columns: 4rem 1fr 2rem; gap: .5rem; align-items: center; font-size: .82rem; color: var(--dim); padding: .14rem 0; }
.alloc u { height: .4rem; border-radius: 1rem; background: rgba(255, 255, 255, .08); overflow: hidden; }
.alloc u i { display: block; height: 100%; background: var(--prep); }
#ending .ask { text-align: center; font-family: var(--serif); font-size: 1.15rem; margin: 1.6rem 0 1rem; color: var(--text); }
#ending .btns { display: flex; flex-wrap: wrap; gap: .6rem; justify-content: center; }
.btn { padding: .65rem 1.4rem; border: 1px solid var(--line); border-radius: var(--r-ctl); background: rgba(13, 16, 21, .85); transition: border-color .15s, transform .15s, background .15s; }
.btn:hover { border-color: var(--accent); transform: translateY(-1px); }
.btn.main { background: var(--accent); color: var(--on-accent); font-weight: 700; border-color: var(--accent); }
.gal { display: grid; grid-template-columns: repeat(3, 1fr); gap: .6rem; }
.gal div { padding: .8rem; border: 1px solid var(--line); border-radius: var(--r-ctl); min-height: 5.4rem; }
.gal div.lock { opacity: .4; }
.gal h3 { font-family: var(--serif); font-size: .98rem; margin-bottom: .2rem; }
.gal p { font-size: .74rem; color: var(--dim); }

/* ---------- 衝刺小遊戲 ---------- */
#mini { position: absolute; inset: 0; z-index: 10; display: grid; place-items: end center; padding: 0 1.2rem 9vh; background: linear-gradient(to top, rgba(6, 7, 9, .88), rgba(6, 7, 9, .1) 60%); }
#mini .box { width: min(40rem, 100%); padding: 1.2rem 1.4rem 1.4rem; text-align: center; border-color: rgba(226, 112, 95, .6); }
#mini h2 { font-family: var(--serif); font-size: 1.7rem; letter-spacing: .08em; }
#mini p { color: var(--dim); font-size: .9rem; margin: .2rem 0 .9rem; }
#mini .track { height: 1.1rem; border-radius: 1rem; background: rgba(255, 255, 255, .1); overflow: hidden; position: relative; border: 1px solid var(--line); }
#mini .track i { display: block; height: 100%; width: 0; background: linear-gradient(to right, var(--accent-press), var(--accent)); transition: width .08s; }
#mini .meta { display: flex; justify-content: space-between; font-family: var(--mono); font-size: .86rem; margin: .5rem 0 1rem; color: var(--dim); }
#mini .meta b { color: var(--down); font-size: 1.3rem; }
#mini .tap { width: 100%; padding: 1.1rem; border-radius: var(--r-ctl); background: var(--accent); color: var(--on-accent); font-size: 1.3rem; font-weight: 900; letter-spacing: .2em; user-select: none; touch-action: manipulation; }
#mini .tap:active { background: var(--accent-press); transform: scale(.985); }

#toast { position: absolute; left: 50%; bottom: 1.2rem; transform: translateX(-50%); z-index: 30; padding: .5rem 1.1rem; font-size: .88rem; animation: rise .25s; max-width: 92vw; }

/* ---------- 直式（手機） ---------- */
@media (max-aspect-ratio: 1/1) {
  html { font-size: clamp(13px, 3.55vw, 20px); }
  #scene .bg { height: 56%; inset: -1% -2% auto; object-position: 66% 30%; }
  #scene .grade { background: linear-gradient(to bottom, rgba(7, 9, 12, .55) 0%, transparent 18%, transparent 36%, rgba(7, 9, 12, .96) 54%, var(--bg) 60%), linear-gradient(to right, rgba(7, 9, 12, .7), transparent 55%); }
  #hud { top: .6rem; left: .6rem; width: 12.4rem; gap: .3rem; }
  .avatar { width: 3.3rem; height: 3.3rem; } .who b { font-size: 1.15rem; } .who small { font-size: .66rem; }
  .stat { padding: .32rem .5rem .38rem; grid-template-columns: 1.2rem 1fr auto; column-gap: .4rem; }
  .stat .icon { font-size: 1.05rem; } .stat .label { font-size: .76rem; } .stat .val { font-size: .7rem; }
  .topics { gap: .25rem; } .topics div { font-size: .6rem; }
  #right { top: .6rem; right: .6rem; gap: .35rem; }
  #clock { width: 9.6rem; padding: .5rem .6rem; }
  #clock .date { font-size: .82rem; } #clock .slot { font-size: 1.15rem; } #clock .count b { font-size: 1.5rem; } #clock .count { font-size: .74rem; }
  #clock .pips i { width: 1rem; }
  #tools button { width: 2.2rem; height: 2.2rem; font-size: 1rem; }
  #dock { padding: 0 .7rem .8rem; }
  .acts { grid-template-columns: repeat(3, 1fr); gap: .5rem; }
  .act { padding: .7rem .4rem; } .act .icon { font-size: 2rem; } .act kbd { display: none; }
  .prompt { flex-wrap: wrap; gap: .1rem .8rem; } .prompt p { order: 3; width: 100%; }
  .talk { grid-template-columns: 1fr; gap: .5rem; padding: .9rem 1rem 1rem; }
  .talk .face { width: auto; display: flex; align-items: center; gap: .6rem; } .talk .face .ph { width: 3rem; height: 3rem; font-size: 1.2rem; } .talk .face span { margin: 0; }
  .talk .choices { grid-template-columns: 1fr; }
  .tsel { grid-template-columns: repeat(2, 1fr); }
  .opt { grid-template-columns: 1fr; } .opt .fx { grid-row: auto; grid-column: 1; justify-content: flex-start; max-width: none; margin-top: .3rem; }
  #title { padding: 0 1.4rem; align-content: end; padding-bottom: 12vh; background: linear-gradient(to top, rgba(6, 7, 9, .97) 30%, rgba(6, 7, 9, .3) 70%); }
  #ending .grid { grid-template-columns: 1fr; } .gal { grid-template-columns: 1fr 1fr; }
  #exam .ask .choices { grid-template-columns: 1fr; }
  .round { grid-template-columns: 4.4rem 1fr 3.4rem; }
}
/* 手機橫向（高度很矮） */
@media (max-height: 480px) and (min-aspect-ratio: 1/1) {
  html { font-size: 11.5px; }
  #hud { width: 15rem; gap: .25rem; top: .5rem; left: .5rem; } .avatar { width: 3rem; height: 3rem; } .who { padding: 0; }
  .stat { padding: .25rem .5rem .3rem; } .topics { display: none; } .buffs { display: none; }
  #right { top: .5rem; right: .5rem; grid-auto-flow: column; align-items: start; }
  #clock { padding: .4rem .6rem; order: 2; } #clock .pips { margin-bottom: .25rem; }
  #dock { padding: 0 .6rem .5rem; } .act { padding: .45rem .4rem; } .act .icon { font-size: 1.6rem; margin: 0; } .prompt { margin-bottom: .3rem; }
  .talk { padding: .7rem .9rem; } .talk .face, .talk .face .ph { width: 4rem; height: 4rem; } .talk .face span { display: none; }
  .talk .body { line-height: 1.6; min-height: 0; }
}
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation-duration: .01ms !important; animation-iteration-count: 1 !important; transition-duration: .01ms !important; }
}

@media print { #app { position: static; } #scene, #world, #fx { display: none; } body { background: #fff; color: #000; overflow: visible; } }
