:root {
  --bg: #05060c;
  --ink: #eef0f7;
  --muted: #9aa3bd;
  --gold: #e8c27a;
  --marigold: #f29a1d;
  --accent: #8fb6ff;
  --panel: rgba(9, 14, 30, .84);
  --panel-2: rgba(16, 24, 48, .7);
  --line: rgba(143, 182, 255, .22);
  --line-strong: rgba(143, 182, 255, .5);
  --display: "Cormorant Garamond", "Noto Serif KR", Georgia, serif;
  --body: "Noto Serif KR", "Cormorant Garamond", Georgia, serif;
  --sans: "Noto Sans KR", system-ui, sans-serif;
  --radius: 12px;
}
* { box-sizing: border-box; }
html, body { margin: 0; height: 100%; overflow: hidden; background: var(--bg); color: var(--ink); }
body { font-family: var(--body); font-size: 16px; line-height: 1.6; -webkit-font-smoothing: antialiased; }
html[lang="en"] body { font-family: var(--display); font-size: 18px; }
button { font: inherit; color: inherit; cursor: pointer; }
.hidden { display: none !important; }
canvas#scene { position: fixed; inset: 0; width: 100%; height: 100%; display: block; touch-action: none; cursor: grab; }
canvas#scene.hover { cursor: pointer; }
canvas#scene.dragging { cursor: grabbing; }

/* ------------------------------------------------ main menu */
#menu { position: fixed; inset: 0; z-index: 30; overflow: hidden; }
#menu canvas { position: absolute; inset: 0; width: 100%; height: 100%; }
.menu-inner { position: absolute; left: clamp(16px, 7vw, 110px); top: 50%; transform: translateY(-50%); max-width: 560px; }
.title {
  font-family: var(--display); font-weight: 400; font-size: clamp(48px, 9vw, 104px); line-height: 1; margin: 0;
  background: linear-gradient(180deg, #fff6e0, #d9b46a 70%, #a77b33); -webkit-background-clip: text; background-clip: text; color: transparent;
  filter: drop-shadow(0 4px 24px rgba(0, 0, 0, .8));
}
.tagline { display: flex; align-items: center; gap: 12px; color: #cfd6ea; font-family: var(--display); font-style: italic; font-size: clamp(15px, 2vw, 20px); margin: 14px 0 40px; }
html[lang="ko"] .tagline { font-family: var(--body); font-style: normal; }
.tagline::before, .tagline::after { content: ""; flex: 0 0 34px; height: 1px; background: linear-gradient(90deg, transparent, var(--gold), transparent); }
.menu-list { display: flex; flex-direction: column; gap: 6px; align-items: flex-start; }
.menu-item {
  background: none; border: 1px solid transparent; border-radius: 999px; padding: 8px 26px; font-size: 18px; color: #d7dcec;
  transition: border-color .25s, background .25s, color .25s; position: relative;
}
.menu-item:hover, .menu-item:focus-visible { outline: none; border-color: var(--gold); color: #fff; background: linear-gradient(90deg, rgba(232, 194, 122, .18), rgba(232, 194, 122, .04)); box-shadow: 0 0 24px rgba(232, 194, 122, .2); }
.menu-item.primary { border-color: var(--gold); background: linear-gradient(90deg, rgba(232, 194, 122, .2), rgba(232, 194, 122, .03)); }
.lang-switch { position: absolute; top: 18px; right: 18px; display: flex; gap: 4px; background: rgba(0, 0, 0, .35); border: 1px solid var(--line); border-radius: 999px; padding: 3px; z-index: 2; }
.lang-switch button { background: none; border: none; border-radius: 999px; padding: 4px 14px; font-family: var(--sans); font-size: 13px; color: var(--muted); }
.lang-switch button.on { background: var(--gold); color: #1b1408; }
.menu-foot { position: absolute; left: clamp(16px, 7vw, 110px); right: 16px; bottom: 18px; font-family: var(--sans); font-size: 12px; color: rgba(207, 214, 234, .55); }

/* ------------------------------------------------ cards / overlays */
.overlay { position: fixed; inset: 0; z-index: 40; display: flex; align-items: center; justify-content: center; padding: 16px; background: rgba(3, 4, 10, .72); backdrop-filter: blur(4px); }
.card {
  background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius); width: min(560px, 100%); max-height: calc(100vh - 32px); overflow-y: auto;
  padding: 26px; box-shadow: 0 20px 60px rgba(0, 0, 0, .6), inset 0 1px 0 rgba(255, 255, 255, .04);
}
.card h2 { font-family: var(--display); font-weight: 600; font-size: 28px; margin: 0 0 6px; color: var(--gold); }
html[lang="ko"] .card h2 { font-family: var(--body); font-size: 23px; }
.card p { margin: 0 0 12px; }
.card .lead { color: #d7dcec; }
.row { display: flex; gap: 10px; justify-content: flex-end; flex-wrap: wrap; margin-top: 18px; }
.btn {
  background: var(--panel-2); border: 1px solid var(--line-strong); border-radius: 999px; padding: 8px 20px; font-size: 15px; color: var(--ink);
  transition: background .2s, border-color .2s;
}
.btn:hover { border-color: var(--accent); background: rgba(60, 90, 160, .35); }
.btn.gold { border-color: var(--gold); background: linear-gradient(90deg, rgba(232, 194, 122, .28), rgba(232, 194, 122, .08)); }
.btn.marigold { border-color: var(--marigold); background: linear-gradient(90deg, rgba(242, 154, 29, .45), rgba(242, 154, 29, .15)); }
.setting { display: flex; justify-content: space-between; align-items: center; gap: 12px; padding: 12px 0; border-bottom: 1px solid var(--line); }
.seg { display: flex; gap: 4px; }
.seg button { background: none; border: 1px solid var(--line); border-radius: 999px; padding: 4px 14px; font-size: 14px; color: var(--muted); }
.seg button.on { border-color: var(--gold); color: var(--ink); background: rgba(232, 194, 122, .15); }
input[type=range] { accent-color: var(--gold); width: 160px; }
.intro p { opacity: 0; transform: translateY(6px); transition: opacity 1.2s, transform 1.2s; color: #dfe3f0; }
.intro p.show { opacity: 1; transform: none; }
.about ul { padding-left: 18px; margin: 0 0 14px; color: #cfd6ea; }
.about li { margin-bottom: 6px; }
.about table { width: 100%; border-collapse: collapse; font-family: var(--sans); font-size: 13px; margin: 8px 0; }
.about th, .about td { text-align: left; padding: 8px 6px; border-bottom: 1px solid var(--line); vertical-align: top; }
.about th { color: var(--muted); font-weight: 500; }
.about td:not(:first-child) { white-space: nowrap; }
.about tr.ours td { color: var(--gold); }
.small { font-family: var(--sans); font-size: 12px; color: var(--muted); }

/* ------------------------------------------------ HUD */
.hud { position: fixed; inset: 0; pointer-events: none; z-index: 10; }
.hud > * { pointer-events: auto; }
.pill {
  position: absolute; top: 16px; left: 16px; display: flex; align-items: center; gap: 10px; background: var(--panel); border: 1px solid var(--line);
  border-radius: 999px; padding: 6px 16px 6px 10px; font-family: var(--sans); font-size: 13px; backdrop-filter: blur(6px);
}
.pill .icon { width: 22px; height: 22px; border-radius: 50%; background: radial-gradient(circle, var(--gold), #7a5a22); display: grid; place-items: center; color: #1b1408; font-size: 12px; }
.pill b { color: var(--gold); font-weight: 600; }
.room { position: absolute; top: 56px; left: 22px; font-family: var(--display); font-style: italic; color: var(--muted); font-size: 15px; text-shadow: 0 2px 8px #000; }
html[lang="ko"] .room { font-family: var(--body); font-style: normal; font-size: 13px; }
.minimap { position: absolute; top: 14px; right: 14px; width: 150px; height: 150px; border-radius: 50%; border: 1px solid var(--line-strong); background: rgba(5, 8, 18, .78); box-shadow: 0 0 0 4px rgba(5, 8, 18, .4), 0 8px 30px rgba(0, 0, 0, .5); }
.candles { position: absolute; top: 172px; right: 30px; display: flex; gap: 6px; align-items: flex-end; }
.candle { width: 7px; height: 20px; background: linear-gradient(#f4ecdc, #c8bba2); border-radius: 2px; position: relative; }
.candle::before { content: ""; position: absolute; left: 50%; top: -11px; width: 8px; height: 11px; transform: translateX(-50%); background: radial-gradient(ellipse at 50% 70%, #fff6c8 0%, var(--gold) 45%, transparent 72%); border-radius: 50% 50% 40% 40%; animation: flicker 1.6s infinite alternate; }
.candle.out::before { background: none; }
.candle.out { opacity: .45; }
@keyframes flicker { from { opacity: .8; } to { opacity: 1; transform: translateX(-50%) scale(1.15, .95); } }
.crosshair { position: absolute; left: 50%; top: 50%; width: 6px; height: 6px; margin: -3px; border-radius: 50%; background: rgba(255, 255, 255, .7); box-shadow: 0 0 6px rgba(0, 0, 0, .8); pointer-events: none; }
.prompt {
  position: absolute; left: 50%; bottom: 18%; transform: translateX(-50%); display: flex; align-items: center; gap: 10px; background: var(--panel);
  border: 1px solid var(--line-strong); border-radius: 999px; padding: 6px 18px 6px 6px; font-size: 15px; backdrop-filter: blur(6px); white-space: nowrap;
}
.key { display: inline-grid; place-items: center; min-width: 26px; height: 26px; padding: 0 6px; border-radius: 6px; background: #eef0f7; color: #10131d; font-family: var(--sans); font-weight: 700; font-size: 13px; }
.prompt .what { color: var(--muted); }
.controls { position: absolute; left: 50%; bottom: 14px; transform: translateX(-50%); font-family: var(--sans); font-size: 12px; color: rgba(207, 214, 234, .7); transition: opacity 1s; white-space: nowrap; }
.click-hint { position: absolute; left: 50%; top: 58%; transform: translateX(-50%); font-family: var(--sans); font-size: 13px; color: #dfe3f0; background: rgba(0, 0, 0, .5); padding: 4px 12px; border-radius: 999px; pointer-events: none; }
.dock { position: absolute; left: 16px; bottom: 16px; display: flex; gap: 8px; }
.toast {
  position: absolute; left: 50%; top: 18%; transform: translateX(-50%); max-width: min(620px, calc(100vw - 32px)); text-align: center; font-style: italic;
  font-size: 18px; color: #f4e6c8; text-shadow: 0 2px 14px #000, 0 0 2px #000; opacity: 0; transition: opacity 1s; pointer-events: none;
}
html[lang="ko"] .toast { font-style: normal; font-size: 16px; }
.toast.show { opacity: 1; }
.clue-card {
  position: absolute; right: 16px; bottom: 16px; width: min(330px, calc(100vw - 32px)); background: var(--panel); border: 1px solid var(--line);
  border-left: 3px solid var(--gold); border-radius: var(--radius); padding: 12px 16px; backdrop-filter: blur(6px); transform: translateY(20px); opacity: 0; transition: .5s;
}
.clue-card.show { transform: none; opacity: 1; }
.clue-card .k { font-family: var(--sans); font-size: 11px; letter-spacing: .1em; text-transform: uppercase; color: var(--gold); }
.clue-card h3 { margin: 2px 0 4px; font-size: 17px; }
.clue-card p { margin: 0; color: #cfd6ea; font-size: 14px; }
/* touch controls */
.joy { position: absolute; width: 110px; height: 110px; margin: -55px; border-radius: 50%; border: 1px solid var(--line-strong); background: rgba(10, 16, 32, .35); pointer-events: none; }
.joy i { position: absolute; left: 50%; top: 50%; width: 46px; height: 46px; margin: -23px; border-radius: 50%; background: rgba(143, 182, 255, .45); }
.touch-act { position: absolute; right: 22px; bottom: 90px; width: 74px; height: 74px; border-radius: 50%; border: 1px solid var(--gold); background: rgba(232, 194, 122, .25); font-size: 13px; color: #fff; }

/* ------------------------------------------------ dialogue */
.talk {
  position: fixed; inset: 0; z-index: 20; display: grid; grid-template-columns: minmax(0, 1fr) minmax(340px, 460px); gap: 24px; padding: 24px;
  background: linear-gradient(90deg, rgba(3, 5, 12, .35), rgba(3, 5, 12, .88) 55%);
}
.talk-art { position: relative; display: flex; flex-direction: column; align-items: center; justify-content: center; min-height: 0; }
.talk-art canvas { width: min(100%, 520px); aspect-ratio: 1; filter: drop-shadow(0 0 30px rgba(120, 160, 255, .25)); }
.wave { width: min(100%, 440px); background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius); padding: 12px 14px; }
.wave .k { font-family: var(--sans); font-size: 12px; color: var(--muted); margin-bottom: 4px; }
.wave canvas { width: 100%; height: 46px; aspect-ratio: auto; filter: none; }
.wave .bar { height: 3px; background: var(--line); border-radius: 2px; margin-top: 8px; overflow: hidden; }
.wave .bar i { display: block; height: 100%; width: 0; background: var(--accent); }
.talk-panel { background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius); display: flex; flex-direction: column; min-height: 0; backdrop-filter: blur(8px); box-shadow: 0 20px 60px rgba(0, 0, 0, .6); }
.talk-head { padding: 16px 18px 12px; border-bottom: 1px solid var(--line); display: flex; justify-content: space-between; gap: 10px; }
.talk-head h2 { margin: 0; font-family: var(--display); font-weight: 600; font-size: 26px; color: var(--accent); }
html[lang="ko"] .talk-head h2 { font-family: var(--body); font-size: 21px; }
.talk-head .sub { color: var(--muted); font-size: 13px; font-family: var(--sans); }
.talk-head .desc { margin: 6px 0 0; color: #cfd6ea; font-size: 14px; }
.x { background: none; border: 1px solid var(--line); border-radius: 999px; padding: 2px 12px; font-family: var(--sans); font-size: 13px; color: var(--muted); height: fit-content; white-space: nowrap; }
.log { flex: 1; overflow-y: auto; padding: 14px 18px; display: flex; flex-direction: column; gap: 10px; min-height: 120px; }
.msg { max-width: 90%; padding: 9px 13px; border-radius: 12px; font-size: 15px; }
html[lang="en"] .msg { font-size: 17px; }
.msg.them { align-self: flex-start; background: rgba(30, 44, 84, .55); border: 1px solid var(--line); border-top-left-radius: 4px; }
.msg.you { align-self: flex-end; background: rgba(70, 110, 200, .45); border: 1px solid rgba(143, 182, 255, .4); border-top-right-radius: 4px; font-family: var(--sans); font-size: 14px; }
.msg.letter { font-style: italic; }
.msg.record { color: #d6caff; }
.msg.narrator { align-self: center; background: none; border: none; color: var(--gold); font-style: italic; text-align: center; font-size: 14px; }
.msg.ink { animation: ink 2.4s ease-out; }
@keyframes ink { 0% { filter: blur(0); color: #000; } 40% { filter: blur(2px); } 100% { filter: blur(0); } }
.gemma { margin: 0 18px 10px; padding: 10px 12px; border: 1px dashed var(--line-strong); border-radius: 10px; font-family: var(--sans); font-size: 12px; color: #cfd6ea; }
.gemma p { margin: 0 0 8px; }
.gemma p.ok { margin: 0; color: var(--gold); }
.gemma .btn { font-size: 13px; padding: 5px 14px; }
.gemma .bar { height: 4px; background: var(--line); border-radius: 2px; overflow: hidden; }
.gemma .bar i { display: block; height: 100%; background: var(--gold); transition: width .3s; }
.ask-k { padding: 0 18px 6px; font-family: var(--sans); font-size: 12px; color: var(--muted); }
.chips { display: flex; flex-direction: column; gap: 6px; padding: 0 18px 10px; }
.chip { text-align: left; background: rgba(20, 30, 60, .6); border: 1px solid var(--line); border-radius: 8px; padding: 7px 12px; font-size: 14px; color: #dfe3f0; font-family: var(--sans); }
.chip:hover { border-color: var(--accent); background: rgba(60, 90, 160, .35); }
form.ask { display: flex; gap: 8px; padding: 12px 18px 16px; border-top: 1px solid var(--line); }
form.ask input { flex: 1; min-width: 0; background: rgba(0, 0, 0, .35); border: 1px solid var(--line-strong); border-radius: 999px; color: var(--ink); padding: 9px 16px; font-family: var(--sans); font-size: 14px; }
form.ask input:focus { outline: 1px solid var(--accent); }

/* ------------------------------------------------ journal */
.journal .objs { display: grid; grid-template-columns: 1fr auto; gap: 6px 12px; margin: 8px 0 14px; font-size: 15px; }
.journal .objs .ok { color: #7fd99a; }
.journal .objs .no { color: var(--muted); }
.goal { border-top: 1px solid var(--line); padding: 10px 0; }
.goal h3 { margin: 0; font-size: 16px; display: flex; justify-content: space-between; }
.goal.done h3 { color: var(--gold); }
.goal.done h3::after { content: "✦"; }
.goal ul { margin: 4px 0 0; padding-left: 18px; color: #cfd6ea; font-size: 14px; }
.check { display: inline-grid; place-items: center; width: 18px; height: 18px; border-radius: 50%; background: #3fb26a; color: #062010; font-size: 11px; margin-right: 8px; }
.check.no { background: transparent; border: 1px solid var(--line-strong); }

/* ------------------------------------------------ ofrenda */
.slot { margin-bottom: 12px; }
.slot label { display: block; margin-bottom: 4px; font-size: 15px; }
.slot select { width: 100%; background: rgba(0, 0, 0, .45); color: var(--ink); border: 1px solid var(--line-strong); border-radius: 8px; padding: 9px; font: inherit; font-size: 15px; }
.feedback { min-height: 24px; color: var(--marigold); font-style: italic; }

/* ------------------------------------------------ ending */
.ending { position: fixed; inset: 0; z-index: 45; display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 1fr); align-items: center; gap: 32px; padding: 32px clamp(16px, 6vw, 90px); background: radial-gradient(ellipse at 30% 50%, rgba(40, 20, 10, .3), rgba(3, 3, 8, .82) 70%); opacity: 0; transition: opacity 2.5s; }
.ending.show { opacity: 1; }
.ending canvas { width: min(100%, 440px); aspect-ratio: 4 / 5; justify-self: center; filter: drop-shadow(0 0 34px rgba(170, 182, 210, .22)); }
.ending .name { font-family: var(--display); font-size: clamp(36px, 5vw, 58px); color: var(--gold); margin: 0; line-height: 1.1; }
html[lang="ko"] .ending .name { font-family: var(--body); }
.ending .dates { font-family: var(--sans); color: var(--muted); letter-spacing: .2em; margin-bottom: 18px; }
.ending .line { opacity: 0; transition: opacity 1.6s; margin: 0 0 12px; color: #e6e1d6; }
.ending .line.show { opacity: 1; }
.ending .said { font-size: 21px; color: var(--marigold); font-style: italic; }
.forgotten { text-align: center; }
.forgotten .line { opacity: 0; transition: opacity 1.6s; }
.forgotten .line.show { opacity: 1; }

/* ------------------------------------------------ phones */
@media (max-width: 760px) {
  .minimap { width: 104px; height: 104px; }
  .candles { top: 124px; right: 20px; gap: 4px; }
  .room { top: 52px; }
  .controls { display: none; }
  .talk { grid-template-columns: 1fr; grid-template-rows: 30vh minmax(0, 1fr); padding: 10px; gap: 10px; background: rgba(3, 5, 12, .85); }
  .talk { grid-template-columns: minmax(0, 1fr); grid-template-rows: 22vh minmax(0, 1fr); }
  .talk > * { min-width: 0; }
  .talk-art canvas { width: auto; height: 100%; max-height: 20vh; }
  .talk-head .desc, .ask-k { display: none; }
  .gemma { margin: 0 10px 8px; padding: 8px 10px; }
  .chips { flex-direction: row; overflow-x: auto; padding-bottom: 8px; }
  .chip { white-space: nowrap; flex: none; }
  .wave { padding: 6px 10px; }
  .wave canvas { height: 28px; }
  .ending { grid-template-columns: 1fr; align-content: center; gap: 12px; padding: 16px; overflow-y: auto; }
  .ending canvas { width: 46vw; }
  .menu-inner { top: auto; bottom: 70px; transform: none; }
  .tagline { margin-bottom: 22px; }
}
@media (prefers-reduced-motion: reduce) { * { transition: none !important; animation: none !important; } }
/* tall screens of any width: the house fills the top, the title and menu sit below it */
@media (max-aspect-ratio: 9/10) {
  .menu-inner { top: auto; bottom: 64px; transform: none; }
}
