:root {
  --ink: #f3e6c9;
  --ink-dim: rgba(243, 230, 201, 0.66);
  --amber: #f0b35a;
  --red: #b8262a;
  --blue: #2a4fae;
  --night: #070914;
  --paper: #efe2c2;
  --paper-ink: #2a1d14;
  --serif: 'Gowun Batang', 'Noto Serif KR', 'Apple SD Gothic Neo', serif;
  --safe-b: env(safe-area-inset-bottom, 0px);
  --safe-t: env(safe-area-inset-top, 0px);
}
* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }
html, body { margin: 0; height: 100%; overflow: hidden; background: var(--night); color: var(--ink); font-family: var(--serif); touch-action: none; user-select: none; -webkit-user-select: none; }
canvas#c { position: fixed; inset: 0; width: 100%; height: 100%; display: block; outline: none; }
button { font-family: var(--serif); cursor: pointer; border: 0; color: inherit; }
.hidden { display: none !important; }

#vignette { position: fixed; inset: 0; pointer-events: none; background: radial-gradient(ellipse at 50% 45%, transparent 55%, rgba(2, 3, 10, 0.65) 100%); }
#fade { position: fixed; inset: 0; background: #000; opacity: 0; pointer-events: none; transition: opacity 0.9s ease; z-index: 40; }
#fade.on { opacity: 1; }

/* intro */
#intro { position: fixed; inset: 0; z-index: 30; display: grid; place-items: center; background: radial-gradient(ellipse at 50% 30%, rgba(40, 30, 60, 0.35), rgba(4, 5, 12, 0.88) 70%); backdrop-filter: blur(2px); transition: opacity 1.2s ease; }
#intro.out { opacity: 0; pointer-events: none; }
.intro-inner { width: min(92vw, 440px); text-align: center; padding: 24px 0 calc(24px + var(--safe-b)); }
.kicker { letter-spacing: 0.6em; color: var(--amber); font-size: 13px; margin: 0 0 14px; text-shadow: 0 0 14px rgba(240, 179, 90, 0.8); }
h1 { font-family: 'Noto Serif KR', serif; font-weight: 700; font-size: clamp(34px, 9vw, 48px); line-height: 1.18; margin: 0 0 16px; text-shadow: 0 0 30px rgba(255, 190, 110, 0.45), 0 2px 0 #000; }
.lead { color: var(--ink-dim); line-height: 1.75; font-size: 15px; margin: 0 0 26px; }
.paper { background: linear-gradient(180deg, #f3e8cc, #e6d6b0); color: var(--paper-ink); border-radius: 6px; box-shadow: 0 20px 60px rgba(0, 0, 0, 0.55), inset 0 0 40px rgba(150, 110, 50, 0.25); position: relative; }
.paper::before { content: ''; position: absolute; inset: 6px; border: 1px solid rgba(90, 50, 20, 0.25); border-radius: 3px; pointer-events: none; }
.paper-dark { background: rgba(10, 12, 26, 0.62); border: 1px solid rgba(240, 179, 90, 0.22); backdrop-filter: blur(10px); -webkit-backdrop-filter: blur(10px); border-radius: 14px; }
.card { padding: 18px 20px 30px; text-align: left; margin-bottom: 18px; }
.card label { display: block; font-size: 12px; letter-spacing: 0.15em; color: #7a5a3a; margin: 4px 0 8px; }
.name-row { display: flex; align-items: center; justify-content: space-between; font-size: 22px; font-weight: 700; margin-bottom: 12px; }
.ghost { background: transparent; border: 1px solid currentColor; border-radius: 999px; padding: 4px 12px; font-size: 16px; opacity: 0.75; }
.hues { display: flex; gap: 10px; }
.hues button { width: 40px; height: 40px; border-radius: 50%; position: relative; box-shadow: 0 0 0 2px rgba(0, 0, 0, 0.15); }
.hues button.on { box-shadow: 0 0 0 3px #2a1d14, 0 0 18px currentColor; }
.hues button small { position: absolute; top: 44px; left: 50%; transform: translateX(-50%); font-size: 10px; color: #6a4a2a; white-space: nowrap; }
.primary { width: 100%; padding: 16px; font-size: 17px; font-weight: 700; border-radius: 999px; background: linear-gradient(180deg, #f6c46e, #d48a32); color: #2a1406; box-shadow: 0 0 0 1px rgba(255, 220, 160, 0.5) inset, 0 10px 40px rgba(240, 150, 60, 0.45); margin-top: 12px; }
.primary:active { transform: translateY(1px); }
.hint { font-size: 12px; color: var(--ink-dim); margin: 16px 0 4px; }
.status { font-size: 12px; color: rgba(243, 230, 201, 0.45); margin: 0; }

/* HUD */
#hud { position: fixed; inset: 0; pointer-events: none; z-index: 10; }
#hud > * { pointer-events: auto; }
#topbar { position: absolute; top: calc(12px + var(--safe-t)); left: 14px; right: 14px; display: flex; justify-content: space-between; align-items: flex-start; pointer-events: none; }
#place { font-size: 18px; font-weight: 700; text-shadow: 0 0 12px rgba(255, 180, 90, 0.6), 0 1px 2px #000; letter-spacing: 0.08em; }
#online { font-size: 12px; color: var(--ink-dim); background: rgba(8, 10, 22, 0.55); padding: 6px 12px; border-radius: 999px; display: flex; align-items: center; gap: 6px; backdrop-filter: blur(6px); }
#online i { width: 7px; height: 7px; border-radius: 50%; background: #7cf0a8; box-shadow: 0 0 8px #7cf0a8; }
#online b { color: var(--ink); }
#queueBox { position: absolute; top: calc(50px + var(--safe-t)); left: 14px; padding: 12px 14px; min-width: 210px; max-width: 70vw; }
#queueText { font-size: 13px; line-height: 1.5; }
#queueDots { display: flex; gap: 6px; margin: 8px 0; }
#queueDots i { width: 12px; height: 16px; border-radius: 5px 5px 7px 7px; background: linear-gradient(180deg, #2a3a6a 45%, #4a1a1a 45%); opacity: 0.5; transition: all 0.6s; }
#queueDots i.on { background: linear-gradient(180deg, #4f7cff 45%, #ff5a3a 45%); box-shadow: 0 0 10px rgba(255, 160, 80, 0.9); opacity: 1; }
.qbtns { display: flex; gap: 6px; }
.small { font-size: 13px; padding: 7px 14px; border-radius: 999px; background: rgba(240, 179, 90, 0.16); border: 1px solid rgba(240, 179, 90, 0.45); color: var(--ink); }
.small.glow { background: linear-gradient(180deg, #f6c46e, #d48a32); color: #2a1406; font-weight: 700; animation: pulse 1.6s infinite; }
@keyframes pulse { 0%, 100% { box-shadow: 0 0 0 0 rgba(246, 196, 110, 0.7); } 50% { box-shadow: 0 0 0 8px rgba(246, 196, 110, 0); } }
#lore { position: absolute; top: calc(48px + var(--safe-t)); right: 14px; font-size: 12px; color: var(--ink-dim); background: rgba(8, 10, 22, 0.5); padding: 5px 12px; border-radius: 999px; }
#online em { font-style: normal; }
#online .short { display: none; }
#place { max-width: 60vw; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
@media (max-width: 560px) {
  #place { font-size: 15px; }
  #online .long { display: none; }
  #online .short { display: inline; }
  #queueBox { min-width: 0; max-width: 62vw; padding: 10px 12px; }
  #queueText { font-size: 12px; }
  #queueDots i { width: 10px; height: 14px; }
  #actions { grid-template-columns: repeat(3, 54px); }
  #actions button { height: 54px; }
}
#prompt { position: absolute; left: 50%; bottom: calc(120px + var(--safe-b)); transform: translateX(-50%); padding: 11px 20px; border-radius: 999px; background: rgba(12, 10, 20, 0.72); border: 1px solid rgba(240, 179, 90, 0.55); font-size: 15px; box-shadow: 0 0 24px rgba(240, 179, 90, 0.25); white-space: nowrap; }
#prompt kbd { font-family: inherit; background: var(--amber); color: #2a1406; border-radius: 5px; padding: 1px 7px; margin-right: 8px; font-weight: 700; }
#toast { position: absolute; left: 50%; top: 30%; transform: translate(-50%, -50%); text-align: center; font-size: 17px; line-height: 1.6; text-shadow: 0 0 18px rgba(255, 190, 110, 0.7), 0 1px 3px #000; opacity: 0; transition: opacity 0.8s; pointer-events: none; width: 86vw; }
#toast.on { opacity: 1; }
#skyBanner { position: absolute; top: 22%; left: 50%; transform: translateX(-50%); text-align: center; font-size: 20px; letter-spacing: 0.2em; color: #ffe6b8; text-shadow: 0 0 20px rgba(200, 170, 255, 0.9); animation: fadeio 6s forwards; pointer-events: none; }
#skyBanner small { display: block; font-size: 12px; letter-spacing: 0.05em; color: var(--ink-dim); margin-top: 6px; }
@keyframes fadeio { 0% { opacity: 0; } 15%, 75% { opacity: 1; } 100% { opacity: 0; } }

#actions { position: absolute; right: 12px; bottom: calc(16px + var(--safe-b)); display: grid; grid-template-columns: repeat(3, 58px); gap: 8px; }
#actions button { height: 58px; border-radius: 16px; background: rgba(10, 12, 26, 0.62); border: 1px solid rgba(240, 179, 90, 0.28); backdrop-filter: blur(8px); font-size: 11px; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 2px; color: var(--ink); }
#actions button span { font-size: 19px; line-height: 1; }
#actions button.on { border-color: var(--amber); box-shadow: 0 0 14px rgba(240, 179, 90, 0.5); }
#joy { position: absolute; left: 22px; bottom: calc(26px + var(--safe-b)); width: 128px; height: 128px; border-radius: 50%; background: radial-gradient(circle, rgba(240, 179, 90, 0.08), rgba(240, 179, 90, 0.02)); border: 1px solid rgba(240, 179, 90, 0.25); display: none; touch-action: none; }
#joyKnob { position: absolute; left: 50%; top: 50%; width: 54px; height: 54px; margin: -27px; border-radius: 50%; background: radial-gradient(circle at 40% 35%, #ffd89a, #d4842e); box-shadow: 0 0 20px rgba(240, 150, 60, 0.6); }
body.touch #joy { display: block; }
body.touch #introHint { display: none; }

/* modal */
#modal { position: fixed; inset: 0; z-index: 25; display: grid; place-items: center; background: rgba(2, 3, 10, 0.55); backdrop-filter: blur(3px); }
.sheet { width: min(92vw, 460px); max-height: 78vh; overflow: auto; padding: 26px 22px 22px; }
.close { position: absolute; right: 10px; top: 6px; font-size: 28px; background: none; color: #6a4a2a; }
.sheet h2 { font-family: 'Noto Serif KR', serif; margin: 0 0 12px; font-size: 21px; }
.sheet p { line-height: 1.85; font-size: 15px; margin: 0 0 10px; }
.sheet .q { font-weight: 700; }
.sheet .a { color: #6a4a2a; padding-left: 12px; border-left: 2px solid #c09860; font-size: 14px; }
.sheet hr { border: 0; border-top: 1px dashed rgba(90, 50, 20, 0.3); margin: 14px 0; }
.chips { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 6px; }
.chips button { padding: 9px 14px; border-radius: 999px; background: #2a1d14; color: #f3e6c9; font-size: 14px; }
.chips button:active { background: #6a3a1a; }
.sheet input, .sheet textarea { width: 100%; padding: 12px; border-radius: 8px; border: 1px solid #c09860; background: #fbf4e2; font-family: var(--serif); font-size: 16px; color: #2a1d14; }
.sheet .row { display: flex; gap: 8px; margin-top: 10px; }
.sheet .btn { flex: 1; padding: 11px; border-radius: 8px; background: #2a1d14; color: #f3e6c9; font-size: 15px; }
.notes { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; margin: 10px 0; }
.notes div { background: #fbf4e2; padding: 10px; font-size: 13px; line-height: 1.5; border-radius: 4px; box-shadow: 0 2px 6px rgba(0, 0, 0, 0.15); transform: rotate(var(--r, 0deg)); }
.notes small { display: block; color: #8a6a4a; font-size: 10px; margin-top: 4px; }
.charm { background: linear-gradient(180deg, #f4dc8a, #e8c262); border: 2px solid #a3261c; padding: 14px; margin: 8px 0; border-radius: 3px; text-align: center; color: #5a1410; }
.charm b { display: block; font-size: 17px; margin-bottom: 4px; }
.charm small { color: #7a4a2a; }

/* consult */
#consult { position: fixed; inset: 0; z-index: 15; pointer-events: none; display: flex; flex-direction: column; justify-content: flex-end; padding: calc(16px + var(--safe-t)) 16px calc(20px + var(--safe-b)); }
#consult > * { pointer-events: auto; }
#cTop { position: absolute; top: calc(14px + var(--safe-t)); left: 16px; right: 16px; display: flex; justify-content: space-between; align-items: center; font-size: 14px; letter-spacing: 0.2em; color: var(--ink-dim); }
#cSpeech { text-align: center; font-size: 17px; line-height: 1.8; text-shadow: 0 0 16px rgba(160, 130, 255, 0.6), 0 1px 3px #000; margin: 0 auto 14px; max-width: 560px; min-height: 2em; }
#cCards { display: flex; gap: 10px; justify-content: center; margin-bottom: 6px; }
#cCards button { width: min(30vw, 150px); aspect-ratio: 0.66; border-radius: 10px; background: linear-gradient(180deg, rgba(40, 26, 50, 0.85), rgba(16, 10, 24, 0.92)); border: 1px solid rgba(240, 179, 90, 0.45); display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 8px; padding: 10px; box-shadow: 0 10px 30px rgba(0, 0, 0, 0.5); transition: transform 0.35s, opacity 0.5s; animation: rise 0.8s backwards; }
#cCards button:nth-child(2) { animation-delay: 0.15s; }
#cCards button:nth-child(3) { animation-delay: 0.3s; }
#cCards button:active { transform: translateY(-6px) scale(1.03); }
#cCards button .ic { font-size: 34px; filter: drop-shadow(0 0 10px rgba(255, 190, 110, 0.8)); }
#cCards button b { font-size: 16px; }
#cCards button small { font-size: 11px; color: var(--ink-dim); line-height: 1.4; }
@keyframes rise { from { opacity: 0; transform: translateY(30px); } }
#cReading { background: rgba(8, 6, 16, 0.72); border: 1px solid rgba(240, 179, 90, 0.3); border-radius: 14px; padding: 16px 18px; max-width: 560px; margin: 0 auto; width: 100%; max-height: 52vh; overflow: auto; backdrop-filter: blur(6px); }
#cReading h3 { font-size: 12px; letter-spacing: 0.3em; color: var(--amber); margin: 12px 0 4px; font-weight: 400; }
#cReading h3:first-child { margin-top: 0; }
#cReading p { margin: 0; line-height: 1.85; font-size: 15px; }
#cReading .core { margin-top: 14px; text-align: center; font-size: 18px; color: #ffe2a8; text-shadow: 0 0 16px rgba(255, 190, 110, 0.7); }
#cNext { max-width: 560px; margin: 12px auto 0; }

@media (min-width: 900px) {
  #actions { grid-template-columns: repeat(6, 64px); }
  #actions button { height: 64px; }
}

/* 1.1.0 — 설정 · 검색용 안내 · 입장 대기 */
.sr-only { position: absolute; width: 1px; height: 1px; padding: 0; margin: -1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; border: 0; }
.primary:disabled { opacity: 0.55; filter: grayscale(0.4); cursor: progress; }
#topbar .tr { display: flex; gap: 8px; align-items: center; pointer-events: auto; }
#aSet { width: 34px; height: 34px; border-radius: 50%; background: rgba(8, 10, 22, 0.55); border: 1px solid rgba(240, 179, 90, 0.28); font-size: 17px; line-height: 1; backdrop-filter: blur(6px); color: var(--ink); }
#lore { top: calc(54px + var(--safe-t)); }
.set-row { display: flex; justify-content: space-between; align-items: center; gap: 12px; padding: 8px 0; font-size: 15px; }
.set-row > span:first-child { color: #7a5a3a; }
#verRow { cursor: default; }
.chips.seg { margin: 0; gap: 6px; }
.chips.seg button { padding: 7px 13px; background: rgba(42, 29, 20, 0.12); color: #2a1d14; border: 1px solid rgba(90, 50, 20, 0.3); }
.chips.seg button.on { background: #2a1d14; color: #f3e6c9; }
.set-help { font-size: 13px !important; line-height: 1.7 !important; color: #5a4030; }
@media (prefers-reduced-motion: reduce) { #cCards button, #skyBanner { animation: none; } }
