/* 꽃나음 다원 — HUD. 3D 위에 얹는 얇은 유리 패널. 핑크는 강조어에만, 모서리는 직각.
   낮(크림)과 밤(남색) 장면 위에서 모두 읽히도록: 유리는 조금 더 진하게, 테두리는 1px 먹선. */
:root {
  --pink: #F2AEBC; --pink-deep: #E08FA3; --cream: #FDFDFB; --paper: #F2EDE4; --ink: #26282E; --ink-soft: #5C5F66; --muted: #8E9097;
  --glass: rgba(253, 253, 251, .86); --glass-line: rgba(38, 40, 46, .18); --hair: rgba(38, 40, 46, .1);
  --ease: cubic-bezier(.22, 1, .36, 1);
  --sans: -apple-system, BlinkMacSystemFont, "Apple SD Gothic Neo", "Pretendard", "Noto Sans KR", sans-serif;
  --serif: "Noto Serif KR", "Apple Myungjo", "Nanum Myeongjo", serif;
  --safe-top: env(safe-area-inset-top, 0px); --safe-bottom: env(safe-area-inset-bottom, 0px);
  --bar-h: 70px;                                   /* 하단 행동 바 높이 (패널·토스트가 이 위로 올라선다) */
  --bar-gap: max(14px, var(--safe-bottom));
}
* { box-sizing: border-box; }
html, body { margin: 0; height: 100%; overflow: hidden; background: var(--paper); }
body { font-family: var(--sans); color: var(--ink); font-size: 15px; line-height: 1.6; -webkit-font-smoothing: antialiased; letter-spacing: -0.01em; overscroll-behavior: none; }
#scene { position: fixed; inset: 0; width: 100%; height: 100%; display: block; touch-action: none; cursor: grab; }
#scene.dragging { cursor: grabbing; }
button { font: inherit; color: inherit; background: none; border: 0; padding: 0; cursor: pointer; -webkit-tap-highlight-color: transparent; touch-action: manipulation; }
button:focus-visible { outline: 2px solid var(--pink-deep); outline-offset: 2px; }
em { font-style: normal; color: var(--pink-deep); font-weight: 800; }
kbd { font: 10px/1 var(--sans); color: var(--muted); border: 1px solid var(--glass-line); padding: 2px 4px; margin-left: 2px; }
[hidden] { display: none !important; }
.glass { background: var(--glass); backdrop-filter: blur(18px) saturate(1.25); -webkit-backdrop-filter: blur(18px) saturate(1.25); border: 1px solid var(--glass-line); box-shadow: 0 1px 0 rgba(255, 255, 255, .6) inset, 0 8px 28px rgba(20, 24, 40, .12); }
.link { font-size: 13px; color: var(--ink-soft); text-decoration: underline; text-underline-offset: 3px; min-height: 44px; padding: 0 8px; }
.serif { font-family: var(--serif); }
.sprite { position: absolute; width: 0; height: 0; overflow: hidden; }
.logo { display: inline-block; height: auto; vertical-align: middle; }
.sep { color: var(--muted); }

/* HUD 배치 */
.hud { position: fixed; left: 0; right: 0; display: flex; align-items: center; justify-content: space-between; gap: 10px; padding: 0 14px; pointer-events: none; z-index: 5; }
.hud > * { pointer-events: auto; }
.hud-top { top: max(12px, var(--safe-top)); }
.hud-left { display: flex; align-items: center; gap: 10px; min-height: 44px; padding: 6px 12px; font-size: 13px; }
.hud-brand { display: inline-flex; align-items: center; gap: 6px; font-weight: 600; letter-spacing: .02em; white-space: nowrap; }
.hud-brand .logo { width: 150px; }
.hud-brand .brand-word { font-weight: 600; color: var(--pink-deep); letter-spacing: .04em; }
.hud-term { color: var(--ink-soft); white-space: nowrap; }
.hud-people { color: var(--pink-deep); font-weight: 600; white-space: nowrap; }
.hud-points { color: var(--ink); font-weight: 600; white-space: nowrap; font-variant-numeric: tabular-nums; }
.hud-points::before { content: ""; display: inline-block; width: 5px; height: 5px; margin-right: 5px; background: var(--pink); vertical-align: 2px; }
.hud-cup { position: absolute; left: 50%; top: 0; transform: translateX(-50%); width: 58px; height: 58px; display: grid; place-items: center; }
.hud-cup svg { position: absolute; inset: 6px; transform: rotate(-90deg); }
.cup-ring { fill: none; stroke: var(--glass-line); stroke-width: 1.5; }
.cup-fill { fill: #F3EBD6; stroke: var(--pink); stroke-width: 1.5; stroke-dasharray: 113.1; stroke-dashoffset: 113.1; transition: stroke-dashoffset 1s linear, fill 1s linear; }
.hud-cup span { position: relative; font-size: 11px; color: var(--ink-soft); font-variant-numeric: tabular-nums; }
.hud-right { display: flex; align-items: center; }
.tool { padding: 0 14px; font-size: 12px; color: var(--ink-soft); min-height: 44px; min-width: 44px; }
.tool[aria-pressed="true"] { color: var(--pink-deep); }

.hint { position: fixed; top: calc(max(12px, var(--safe-top)) + 56px); left: 50%; transform: translateX(-50%); margin: 0; font-size: 12px; color: var(--ink-soft); background: var(--glass); border: 1px solid var(--glass-line); padding: 6px 12px; z-index: 4; transition: opacity .8s; white-space: nowrap; max-width: calc(100% - 28px); overflow: hidden; text-overflow: ellipsis; }
.hint.gone { opacity: 0; pointer-events: none; }
.toast { position: fixed; left: 50%; bottom: calc(var(--bar-gap) + var(--bar-h) + 56px); transform: translateX(-50%) translateY(8px); margin: 0; padding: 9px 14px; background: var(--ink); color: var(--cream); font-size: 13px; opacity: 0; pointer-events: none; transition: opacity .3s, transform .3s var(--ease); z-index: 9; max-width: calc(100% - 40px); text-align: center; }
.toast.show { opacity: 1; transform: translateX(-50%); }

/* 하단 행동 바 — 엄지로 누르기 좋게 (버튼 60px, 간격은 1px 먹선) */
.hud-bottom { bottom: var(--bar-gap); flex-direction: column; align-items: center; }
.prompt { margin: 0 0 8px; padding: 7px 14px; font-size: 13px; color: var(--ink); max-width: calc(100% - 8px); text-align: center; }
.prompt strong { color: var(--pink-deep); font-weight: 600; }
.actions { display: flex; gap: 0; padding: 4px; min-height: var(--bar-h); }
.actions button { display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 2px; min-width: 84px; min-height: 60px; padding: 6px 12px; font-size: 12px; color: var(--ink-soft); transition: background .2s, color .2s; }
.actions button + button { border-left: 1px solid var(--hair); }
.actions button:hover { background: rgba(242, 174, 188, .18); color: var(--ink); }
.actions button:active { background: rgba(242, 174, 188, .3); }
.actions button[aria-pressed="true"] { color: var(--pink-deep); }
.act-ic { font-size: 20px; line-height: 1.2; }
#act-main { color: var(--ink); font-weight: 600; }

/* 리추얼 패널 — 항상 행동 바 위에 선다 (겹치지 않음) */
.panel { position: fixed; left: 50%; transform: translateX(-50%); bottom: calc(var(--bar-gap) + var(--bar-h) + 10px); width: min(440px, calc(100% - 24px)); max-height: min(46dvh, calc(100dvh - var(--bar-gap) - var(--bar-h) - var(--safe-top) - 96px)); overflow: auto; overscroll-behavior: contain; z-index: 6; padding: 14px 16px 16px; animation: rise .45s var(--ease); }
@keyframes rise { from { opacity: 0; transform: translateX(-50%) translateY(14px); } to { opacity: 1; transform: translateX(-50%); } }
.panel-head { display: grid; grid-template-columns: auto 1fr auto; gap: 12px; align-items: center; }
.panel-hanja { min-width: 44px; padding: 4px 8px; font-size: 20px; font-weight: 600; letter-spacing: .06em; color: var(--pink-deep); line-height: 1.2; text-align: center; border: 1px solid var(--pink); white-space: nowrap; }
.panel-title { margin: 0; font-size: 16px; font-weight: 600; }
.panel-sub { margin: 0; font-size: 12px; color: var(--ink-soft); }
.panel-body { margin-top: 12px; display: flex; flex-direction: column; gap: 10px; align-items: center; text-align: center; }
.panel-body p { margin: 0; }
.big { font-size: 22px; font-weight: 400; letter-spacing: .04em; min-height: 1.4em; }
.cap { font-size: 14px; color: var(--ink-soft); }
.small { font-size: 12px; color: var(--muted); }
.sentence { font-family: var(--serif); font-size: 19px; line-height: 1.7; font-weight: 300; text-wrap: balance; }
.bar { width: 100%; height: 2px; background: var(--hair); position: relative; overflow: hidden; }
.bar i { position: absolute; left: 0; top: 0; bottom: 0; width: 0; background: var(--pink); transition: width 1s linear; }
.step { width: 100%; text-align: left; }
.step .k { font-size: 11px; color: var(--pink-deep); letter-spacing: .1em; }
.step .n { font-size: 20px; margin-top: 2px; }
.step .n small { font-family: var(--serif); color: var(--muted); font-size: 13px; margin-left: 6px; }
.step .w { font-size: 14px; color: var(--ink-soft); margin-top: 6px; }
.step .h { font-size: 13px; margin-top: 8px; }
.chips { display: flex; flex-wrap: wrap; gap: 6px; justify-content: center; }
.chip { min-height: 36px; padding: 6px 12px; background: rgba(38, 40, 46, .05); font-size: 13px; border: 1px solid transparent; }
.chip[aria-pressed="true"] { border-color: var(--pink-deep); color: var(--pink-deep); }
.line-input { width: 100%; padding: 10px 0; border: 0; border-bottom: 1px solid var(--ink); background: transparent; font: inherit; font-family: var(--serif); font-size: 16px; text-align: center; color: var(--ink); }
.line-input:focus { outline: none; border-bottom-color: var(--pink-deep); }
.btn { min-height: 48px; padding: 0 22px; background: var(--ink); color: var(--cream); font-size: 15px; letter-spacing: .02em; transition: opacity .2s, transform .25s var(--ease); }
.btn:disabled { opacity: .45; cursor: default; }
.btn:active:not(:disabled) { transform: scale(.985); }
.btn-small { min-height: 44px; padding: 0 16px; font-size: 14px; }

/* 다이얼로그 */
.dlg { border: 1px solid var(--glass-line); padding: 16px 18px; width: min(360px, calc(100% - 32px)); max-height: 70dvh; color: var(--ink); }
.dlg::backdrop { background: rgba(38, 40, 46, .18); }
.dlg header { display: flex; justify-content: space-between; align-items: center; }
.dlg h2 { margin: 0; display: inline-flex; align-items: center; gap: 8px; font-size: 15px; font-weight: 600; }
.dlg .pick { margin-top: 12px; }
.dlg .swatches { margin-top: 10px; }
.dlg ul { list-style: none; margin: 12px 0 0; padding: 0; display: grid; gap: 6px; font-size: 14px; }
.dlg li { display: flex; justify-content: space-between; padding: 6px 0; border-bottom: 1px solid var(--hair); }
.dlg li span:last-child { color: var(--muted); font-size: 12px; }
.dlg-note { margin: 14px 0 0; font-size: 12px; color: var(--muted); }

/* 오버레이 — 조용한 브랜드 카드: 14px 핑크 상단 바, 직각, '다원'만 핑크 강조 */
.overlay { position: fixed; inset: 0; z-index: 20; display: grid; place-items: center; padding: max(20px, var(--safe-top)) 20px max(20px, var(--safe-bottom)); background: var(--paper); overflow: auto; }
.overlay-soft { background: rgba(242, 237, 228, .82); backdrop-filter: blur(10px); -webkit-backdrop-filter: blur(10px); }
.overlay-card { width: min(420px, 100%); background: var(--cream); padding: 0 24px 24px; border: 1px solid var(--hair); box-shadow: 0 14px 50px rgba(38, 40, 46, .1); animation: rise2 .6s var(--ease); }
@keyframes rise2 { from { opacity: 0; transform: translateY(10px); } to { opacity: 1; transform: none; } }
.brand-bar { display: block; height: 14px; background: var(--pink); margin: 0 -24px; }
.eyebrow { margin: 18px 0 0; display: flex; align-items: center; flex-wrap: wrap; gap: 8px; font-size: 11px; letter-spacing: .22em; color: var(--pink-deep); font-weight: 600; }
.eyebrow .logo { width: 220px; }
#done .eyebrow .logo { width: 180px; }
.overlay h1 { margin: 10px 0 0; font-size: 30px; line-height: 1.3; font-weight: 400; letter-spacing: -0.02em; }
.overlay h1 em { font-weight: 600; color: var(--pink-deep); }
.lead { margin: 16px 0 0; color: var(--ink-soft); font-size: 14px; }
/* 모습 고르기 — 직각 사각 버튼 둘, 고른 쪽만 핑크 테두리 */
.pick { display: flex; align-items: center; gap: 8px; margin: 18px 0 0; }
.pick-label { font-size: 10px; letter-spacing: .18em; color: var(--pink-deep); font-weight: 600; margin-right: 4px; }
.pick-opt { display: flex; flex-direction: column; align-items: center; gap: 2px; min-width: 72px; min-height: 76px; padding: 8px 10px 6px; border: 1px solid var(--glass-line); background: var(--cream); font-size: 12px; color: var(--ink-soft); transition: border-color .2s, background .2s, color .2s; }
.pick-opt svg { width: 36px; height: 42px; display: block; }
.pick-opt:hover { background: rgba(242, 174, 188, .12); }
.pick-opt[aria-pressed="true"] { border-color: var(--pink-deep); box-shadow: inset 0 0 0 1px var(--pink-deep); color: var(--ink); background: rgba(242, 174, 188, .14); }
/* 한복 색 — 작은 정사각 견본 (치마/두루마기 색), 고른 쪽만 핑크 테두리 */
.swatches { display: flex; flex-wrap: wrap; gap: 4px; margin: 8px 0 0; }
.swatch { display: flex; flex-direction: column; align-items: center; gap: 3px; min-width: 46px; min-height: 48px; padding: 5px 4px 3px; border: 1px solid transparent; font-size: 10px; color: var(--ink-soft); transition: border-color .2s; }
.swatch i { display: block; width: 24px; height: 24px; background: var(--c, var(--cream)); border: 1px solid var(--hair); }
.swatch:hover { border-color: var(--glass-line); }
.swatch[aria-pressed="true"] { border-color: var(--pink-deep); color: var(--ink); }
.swatch[aria-pressed="true"] i { box-shadow: inset 0 0 0 1px var(--cream), inset 0 0 0 2px var(--pink-deep); }
/* 잠긴 색: 복채를 모으면 열린다 (main.js가 .is-locked 와 data-need 를 붙인다) */
.swatch.is-locked { cursor: default; color: var(--muted); }
.swatch.is-locked:hover { border-color: transparent; }
.swatch.is-locked i { position: relative; filter: saturate(.25); opacity: .45; }
.swatch.is-locked i::after { content: ""; position: absolute; left: 50%; top: 50%; width: 10px; height: 11px; transform: translate(-50%, -50%); opacity: 1;
  background: url("data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 10 11'><path d='M2.5 4.5V3.2a2.5 2.5 0 0 1 5 0v1.3' fill='none' stroke='%2326282E' stroke-width='1.2'/><rect x='1' y='4.5' width='8' height='6' fill='%2326282E'/></svg>") center / contain no-repeat; }
.swatch.is-locked::after { content: "복채 " attr(data-need); display: block; font-size: 9px; line-height: 1.2; color: var(--pink-deep); font-weight: 600; letter-spacing: .02em; }
.swatch.is-locked[aria-pressed="true"] { border-color: transparent; }
.status-online { margin: 6px 0 0; font-size: 12px; color: var(--pink-deep); }
.status-online::before { content: ""; display: inline-block; width: 6px; height: 6px; margin-right: 7px; background: var(--pink); vertical-align: middle; }
.controls { display: flex; flex-wrap: wrap; align-items: center; gap: 6px 14px; margin: 18px 0 0; padding: 10px 0; border-top: 1px solid var(--hair); border-bottom: 1px solid var(--hair); font-size: 12px; color: var(--ink-soft); }
.controls dt { font-size: 10px; letter-spacing: .18em; color: var(--pink-deep); font-weight: 600; margin-right: 2px; }
.controls dd { margin: 0; display: inline-flex; align-items: center; gap: 5px; white-space: nowrap; }
.controls b { font-weight: 600; color: var(--ink); }
.controls kbd { margin: 0; color: var(--ink); border-color: var(--glass-line); }
.status { margin: 20px 0 0; font-size: 12px; color: var(--muted); }
.status::after { content: ""; display: inline-block; width: 4px; height: 4px; margin-left: 8px; background: var(--pink); vertical-align: middle; animation: breathe 1.8s ease-in-out infinite; }
.status.ready::after { display: none; }
@keyframes breathe { 50% { opacity: .2; } }
.overlay .btn { width: 100%; margin-top: 10px; }
.note { margin: 12px 0 0; font-size: 12px; color: var(--muted); text-align: center; }

@media (max-width: 480px) {
  .hud-cup { top: 52px; }                          /* 좁은 화면: 왼쪽 패널과 겹치지 않게 한 줄 아래, 가운데는 그대로 */
  .hud-brand .logo { width: 116px; }
}
@media (max-width: 420px) {
  .hud { padding: 0 10px; }
  .hud-brand .brand-word { display: none; }
  .hud-left { gap: 8px; padding: 6px 10px; font-size: 12px; }
  .hud-term { display: none; }
  .actions button { min-width: 72px; padding: 6px 8px; }
  .overlay h1 { font-size: 26px; }
  .overlay-card { padding: 0 20px 20px; }
  .brand-bar { margin: 0 -20px; }
}
@media (max-height: 560px) {
  .panel { max-height: calc(100dvh - var(--bar-gap) - var(--bar-h) - var(--safe-top) - 80px); }
}
@media (prefers-reduced-motion: reduce) { .panel, .overlay-card, .status::after { animation: none; } }

/* 왕실 옷 (임금 · 왕비) */
.royal { margin-top: 12px; padding-top: 10px; border-top: 1px solid var(--glass-line, rgba(38,40,46,.1)); }
.royal-title { margin: 0 0 6px; font-size: 13px; font-weight: 600; color: #8A6A1E; }
.royal-title span { font-weight: 400; font-size: 11px; color: var(--muted, #8E9097); margin-left: 6px; }
.royal-title span.is-admin { color: #B3232B; font-weight: 600; }
.royal-opt { background: linear-gradient(180deg, rgba(226,181,78,.12), transparent); }
.royal-opt.is-locked { opacity: .55; }
.royal-opt.is-locked::after { content: "결제"; position: absolute; top: 4px; right: 4px; font-size: 9px; color: #B3232B; font-weight: 600; }
.royal-opt { position: relative; }
