[hidden] { display: none !important; }
:root {
  --ink: #f2ead9; --dim: #a9b4d6; --glass: rgba(14, 22, 48, 0.58); --line: rgba(190, 205, 255, 0.14);
  --moon: #f3d9a4; --green: #2e6b4f; --green2: #3f8d68;
  --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: #050915; color: var(--ink);
  font-family: 'Pretendard Variable', Pretendard, -apple-system, 'Apple SD Gothic Neo', 'Noto Sans KR', sans-serif; letter-spacing: -0.01em; }
#app, #app canvas { position: fixed; inset: 0; width: 100%; height: 100%; display: block; touch-action: none; }
button { font: inherit; color: inherit; cursor: pointer; border: 0; background: none; }
input { font: inherit; color: inherit; }
kbd { margin-left: 8px; font: 600 11px/1 ui-monospace, monospace; padding: 3px 5px; border-radius: 5px; background: rgba(255,255,255,.14); opacity: .75; }
@media (pointer: coarse) { kbd { display: none; } }

/* ---------- 입장 ---------- */
#intro { position: fixed; inset: 0; display: grid; place-items: center; z-index: 50; padding: 20px;
  background: radial-gradient(120% 90% at 50% 10%, rgba(10,18,46,.15), rgba(4,7,20,.78)); transition: opacity 1.4s ease, visibility 1.4s; }
#intro.gone { opacity: 0; visibility: hidden; }
#intro .card { width: min(420px, 100%); text-align: center; padding: 34px 28px 24px; border-radius: 28px;
  background: linear-gradient(180deg, rgba(20,30,64,.62), rgba(10,16,38,.72)); border: 1px solid var(--line);
  backdrop-filter: blur(18px) saturate(1.2); -webkit-backdrop-filter: blur(18px) saturate(1.2); box-shadow: 0 30px 80px rgba(0,0,0,.45), inset 0 1px 0 rgba(255,255,255,.06);
  animation: rise 1.4s cubic-bezier(.2,.8,.2,1) both; }
@keyframes rise { from { opacity: 0; transform: translateY(18px) scale(.98); } }
.moon { width: 58px; height: 58px; margin: 0 auto 16px; border-radius: 50%; background: radial-gradient(circle at 38% 38%, #fff8e6, #f3d9a4 60%, #d8b878);
  box-shadow: 0 0 40px 8px rgba(243,217,164,.35), 0 0 120px 30px rgba(140,160,255,.18); position: relative; animation: glow 6s ease-in-out infinite; }
.moon::after { content: ''; position: absolute; inset: -4px -14px 10px 18px; border-radius: 50%; background: #0f1838; opacity: .0; }
@keyframes glow { 50% { box-shadow: 0 0 56px 12px rgba(243,217,164,.45), 0 0 160px 40px rgba(140,160,255,.22); } }
.kicker { margin: 0; font-size: 12px; letter-spacing: .18em; color: var(--moon); opacity: .85; }
h1 { margin: 8px 0 6px; font-size: 40px; font-weight: 800; letter-spacing: -0.04em;
  background: linear-gradient(180deg, #fffaf0, #d8cdb5); -webkit-background-clip: text; background-clip: text; color: transparent; }
.sub { margin: 0 0 22px; color: var(--dim); line-height: 1.6; font-size: 15px; }
.field { display: block; text-align: left; margin: 0 0 14px; }
.field > span { display: block; font-size: 12.5px; color: var(--dim); margin: 0 0 7px 2px; }
.field em { font-style: normal; color: var(--ink); }
#nameIn { width: 100%; padding: 14px 16px; border-radius: 14px; border: 1px solid var(--line); background: rgba(255,255,255,.06); outline: none; font-size: 16px; transition: border-color .2s, background .2s; }
#nameIn:focus { border-color: rgba(243,217,164,.55); background: rgba(255,255,255,.09); }
#nameIn::placeholder { color: rgba(220,226,255,.4); }
#swatches { display: flex; gap: 9px; flex-wrap: wrap; }
.sw { width: 34px; height: 34px; border-radius: 50%; background: var(--c); box-shadow: inset 0 -4px 8px rgba(0,0,0,.18), 0 0 0 2px rgba(255,255,255,.06); transition: transform .2s, box-shadow .2s; }
.sw.on { transform: scale(1.12); box-shadow: inset 0 -4px 8px rgba(0,0,0,.18), 0 0 0 3px #0b1330, 0 0 0 5px var(--moon); }
.primary { display: inline-flex; align-items: center; justify-content: center; gap: 6px; padding: 14px 22px; border-radius: 16px; font-weight: 700; font-size: 16px;
  background: linear-gradient(180deg, var(--green2), var(--green)); box-shadow: 0 10px 28px rgba(46,107,79,.45), inset 0 1px 0 rgba(255,255,255,.18); transition: transform .15s, filter .2s; }
.primary:active { transform: scale(.97); }
.primary:hover { filter: brightness(1.08); }
#enterForm .primary { width: 100%; margin-top: 8px; padding: 16px; font-size: 17px; }
.hint { margin: 16px 0 0; font-size: 12.5px; color: var(--dim); opacity: .8; }

/* ---------- HUD ---------- */
#hud, #dock, #joy, #zone { opacity: 0; pointer-events: none; transition: opacity 1.2s ease .6s; }
body.in #hud, body.in #dock, body.in #zone { opacity: 1; }
body.in #hud *, body.in #dock * { pointer-events: auto; }
body.sleeping #hud, body.sleeping #dock, body.sleeping #joy, body.sleeping #zone, body.sleeping #toast { opacity: 0 !important; pointer-events: none !important; transition-delay: 0s; }
#hud { position: fixed; top: calc(12px + var(--safe-t)); left: 12px; right: 12px; display: flex; justify-content: space-between; align-items: flex-start; gap: 10px; z-index: 10; }
.brand { padding: 10px 14px; border-radius: 16px; background: var(--glass); border: 1px solid var(--line); backdrop-filter: blur(14px); -webkit-backdrop-filter: blur(14px); }
.brand b { display: block; font-size: 15px; font-weight: 800; letter-spacing: -0.03em; }
.brand span { display: block; margin-top: 3px; font-size: 12px; color: var(--dim); white-space: nowrap; }
.brand em { font-style: normal; color: var(--ink); }
#net { font-style: normal; }
#net::before { content: ''; display: inline-block; width: 6px; height: 6px; border-radius: 50%; margin-right: 5px; vertical-align: 1px; background: #f6c96a; }
#net[data-s=online]::before { background: #6ee7a8; box-shadow: 0 0 8px #6ee7a8; }
#net[data-s=offline]::before { background: #8b93ad; }
.tools { display: flex; gap: 6px; }
.tbtn { position: relative; display: flex; flex-direction: column; align-items: center; gap: 2px; min-width: 52px; padding: 8px 8px 7px; border-radius: 14px; font-size: 18px;
  background: var(--glass); border: 1px solid var(--line); backdrop-filter: blur(14px); -webkit-backdrop-filter: blur(14px); transition: background .2s, border-color .2s; }
.tbtn span { font-size: 10.5px; color: var(--dim); }
.tbtn.on { background: rgba(46,107,79,.55); border-color: rgba(110,231,168,.35); }
.tbtn i { position: absolute; top: -7px; right: -4px; font: 700 10px/1 ui-monospace, monospace; padding: 3px 5px; border-radius: 8px; background: var(--moon); color: #1a1a2e; font-style: normal; }
#zone { position: fixed; top: calc(80px + var(--safe-t)); left: 50%; transform: translate(-50%, -6px); text-align: center; z-index: 5; opacity: 0 !important; transition: opacity .8s, transform .8s; }
#zone.on { opacity: 1 !important; transform: translate(-50%, 0); }
#zone b { display: block; font-size: 17px; font-weight: 700; text-shadow: 0 2px 16px rgba(0,0,0,.7); }
#zone span { font-size: 12.5px; color: var(--dim); text-shadow: 0 2px 10px rgba(0,0,0,.8); }
#toast { position: fixed; left: 50%; bottom: calc(150px + var(--safe-b)); transform: translate(-50%, 10px); max-width: calc(100% - 40px); padding: 11px 16px; border-radius: 14px; font-size: 13.5px;
  background: rgba(10,16,38,.78); border: 1px solid var(--line); backdrop-filter: blur(12px); -webkit-backdrop-filter: blur(12px); opacity: 0; transition: opacity .4s, transform .4s; z-index: 20; pointer-events: none; text-align: center; }
#toast.on { opacity: 1; transform: translate(-50%, 0); }

/* ---------- 패널 ---------- */
.panel { position: fixed; z-index: 30; top: calc(78px + var(--safe-t)); right: 12px; width: min(340px, calc(100% - 24px)); max-height: calc(100% - 200px); overflow: auto;
  padding: 16px; border-radius: 20px; background: rgba(12,19,44,.82); border: 1px solid var(--line); backdrop-filter: blur(20px) saturate(1.2); -webkit-backdrop-filter: blur(20px) saturate(1.2);
  box-shadow: 0 24px 60px rgba(0,0,0,.45); opacity: 0; visibility: hidden; transform: translateY(-8px) scale(.98); transform-origin: top right; transition: opacity .25s, transform .25s, visibility .25s; }
.panel.on { opacity: 1; visibility: visible; transform: none; }
.panel header { display: flex; justify-content: space-between; align-items: center; margin-bottom: 12px; }
.panel h3 { margin: 0; font-size: 16px; font-weight: 800; }
.panel .x { width: 30px; height: 30px; border-radius: 10px; background: rgba(255,255,255,.06); color: var(--dim); }
.note { font-size: 12.5px; color: var(--dim); line-height: 1.6; margin: 12px 0 0; }
.chips { display: flex; flex-wrap: wrap; gap: 6px; }
.chip { padding: 8px 12px; border-radius: 999px; font-size: 13px; background: rgba(255,255,255,.07); border: 1px solid var(--line); transition: background .2s; }
.chip.on { background: rgba(46,107,79,.7); border-color: rgba(110,231,168,.4); }
#presets { margin-bottom: 12px; }
.mix { display: grid; grid-template-columns: 24px 1fr 1.3fr 28px; align-items: center; gap: 8px; padding: 7px 0; font-size: 13.5px; }
.mix .v { font: 600 11px ui-monospace, monospace; color: var(--dim); text-align: right; }
.mix.master { border-top: 1px solid var(--line); margin-top: 6px; padding-top: 12px; }
input[type=range] { -webkit-appearance: none; appearance: none; width: 100%; height: 22px; background: transparent; }
input[type=range]::-webkit-slider-runnable-track { height: 4px; border-radius: 4px; background: rgba(255,255,255,.14); }
input[type=range]::-webkit-slider-thumb { -webkit-appearance: none; width: 18px; height: 18px; margin-top: -7px; border-radius: 50%; background: var(--moon); box-shadow: 0 0 12px rgba(243,217,164,.6); }
input[type=range]::-moz-range-track { height: 4px; border-radius: 4px; background: rgba(255,255,255,.14); }
input[type=range]::-moz-range-thumb { width: 16px; height: 16px; border: 0; border-radius: 50%; background: var(--moon); }
.breath { position: relative; height: 180px; display: grid; place-items: center; }
.ring { width: 150px; height: 150px; border-radius: 50%; transform: scale(.55); transition: transform 4s ease-in-out;
  background: radial-gradient(circle, rgba(160,200,255,.35), rgba(110,231,168,.12) 60%, transparent 70%); box-shadow: 0 0 0 1px rgba(200,220,255,.25), 0 0 60px rgba(140,180,255,.25); }
.breath p { position: absolute; margin: 0; font-size: 15px; font-weight: 600; }
.guide { list-style: none; padding: 0; margin: 0; display: grid; gap: 8px; font-size: 13px; color: var(--dim); }
.guide b { display: block; color: var(--ink); font-size: 14px; }
.ghost { margin-top: 14px; width: 100%; padding: 10px; border-radius: 12px; border: 1px solid var(--line); background: rgba(255,255,255,.05); font-size: 13px; color: var(--dim); }

/* ---------- 하단 ---------- */
#dock { position: fixed; left: 0; right: 0; bottom: calc(14px + var(--safe-b)); display: flex; flex-direction: column; align-items: center; gap: 10px; z-index: 10; pointer-events: none; }
.acts { display: flex; gap: 8px; }
.acts .primary { padding: 12px 18px; font-size: 15px; }
.moonish { background: linear-gradient(180deg, #4b5ea8, #2d3a78); box-shadow: 0 10px 28px rgba(60,80,180,.45), inset 0 1px 0 rgba(255,255,255,.18); }
.bar { display: flex; align-items: center; gap: 6px; padding: 6px; border-radius: 18px; background: var(--glass); border: 1px solid var(--line); backdrop-filter: blur(14px); -webkit-backdrop-filter: blur(14px); max-width: calc(100% - 24px); }
.bar > button { display: flex; align-items: center; gap: 5px; padding: 9px 11px; border-radius: 12px; font-size: 16px; transition: background .2s; }
.bar > button span { font-size: 12.5px; color: var(--dim); }
.bar > button:active { background: rgba(255,255,255,.1); }
#chatForm { margin: 0; }
#chatInput { width: 190px; padding: 10px 12px; border-radius: 12px; border: 1px solid transparent; background: rgba(255,255,255,.06); outline: none; font-size: 14px; }
#chatInput:focus { border-color: rgba(243,217,164,.4); }
#joy { display: none; position: fixed; left: calc(22px + env(safe-area-inset-left, 0px)); bottom: calc(110px + var(--safe-b)); width: 120px; height: 120px; border-radius: 50%; z-index: 11;
  background: radial-gradient(circle, rgba(255,255,255,.08), rgba(255,255,255,.03)); border: 1px solid var(--line); touch-action: none; }
#joyKnob { position: absolute; left: 50%; top: 50%; width: 52px; height: 52px; margin: -26px 0 0 -26px; border-radius: 50%; background: rgba(243,217,164,.3); border: 1px solid rgba(243,217,164,.5); box-shadow: 0 0 20px rgba(243,217,164,.25); pointer-events: none; }
@media (pointer: coarse) {
  body.in #joy { display: block; opacity: 1; pointer-events: auto; }
  .bar > button span { display: none; }
  #chatInput { width: 150px; }
  .tbtn span { display: none; }
  .tbtn { min-width: 42px; padding: 9px; }
  #dock { align-items: flex-end; padding-right: 12px; }
}
@media (max-width: 520px) {
  .brand span { white-space: normal; max-width: 150px; }
  h1 { font-size: 34px; }
  #chatInput { width: 120px; }
}

/* ---------- 잠들기 ---------- */
#sleepLayer { --dim: 0; position: fixed; inset: 0; z-index: 40; display: grid; place-items: center; opacity: 0; visibility: hidden; transition: opacity 2s, visibility 2s;
  background: rgba(2,4,12, var(--dim)); cursor: pointer; }
#sleepLayer.on { opacity: 1; visibility: visible; }
.sleepInner { text-align: center; opacity: calc(1 - var(--dim) * 0.7); }
.breath.big .ring { width: 200px; height: 200px; }
.breath.big { height: 240px; }
.sleepMsg { margin: 6px 0 4px; font-size: 15px; color: var(--ink); opacity: .85; }
.sleepHint { margin: 0; font-size: 12px; color: var(--dim); opacity: .6; }

/* ---------- 1.1.0 설정 · 이웃 · 플러스 ---------- */
a { color: inherit; }
.legal { margin: 10px 0 0; font-size: 11.5px; color: var(--dim); opacity: .7; }
.legal a { text-decoration: none; border-bottom: 1px solid rgba(169,180,214,.35); }
#notice { position: fixed; top: calc(74px + var(--safe-t)); left: 50%; transform: translateX(-50%); z-index: 9; max-width: calc(100% - 24px); padding: 8px 14px; border-radius: 12px; font-size: 13px;
  background: rgba(243,217,164,.16); border: 1px solid rgba(243,217,164,.35); backdrop-filter: blur(12px); -webkit-backdrop-filter: blur(12px); text-align: center; }
body:not(.in) #notice, body.sleeping #notice { display: none; }
#setPanel, #whoPanel, #crisisPanel { max-height: calc(100% - 110px - var(--safe-t) - var(--safe-b)); }
.sec { padding: 12px 0; border-top: 1px solid var(--line); }
.sec:first-child { border-top: 0; padding-top: 0; }
.sec > b { display: block; font-size: 14px; }
.row { display: flex; gap: 6px; align-items: center; flex-wrap: wrap; margin-top: 8px; }
.in { flex: 1; min-width: 0; padding: 9px 12px; border-radius: 12px; border: 1px solid var(--line); background: rgba(255,255,255,.06); outline: none; font-size: 14px; }
.sws { display: flex; flex-wrap: wrap; gap: 7px; margin-top: 10px; }
.sws .sw { width: 28px; height: 28px; }
.plusOnly.locked { position: relative; opacity: .55; }
.sw.plusOnly.locked::after { content: '🔒'; position: absolute; right: -4px; bottom: -4px; font-size: 11px; }
.chip.plusOnly.locked::after { content: ' 🔒'; font-size: 11px; }
.badge { margin-left: 6px; padding: 2px 8px; border-radius: 999px; font-size: 11px; font-weight: 600; background: rgba(110,231,168,.2); color: #b9f5d4; }
.perks { margin: 8px 0 0; padding-left: 18px; font-size: 12.5px; color: var(--dim); line-height: 1.7; }
.plans { display: grid; grid-template-columns: 1fr 1fr; gap: 6px; margin-top: 10px; }
.plan { display: grid; gap: 2px; padding: 10px; border-radius: 14px; text-align: left; background: rgba(243,217,164,.1); border: 1px solid rgba(243,217,164,.3); }
.plan b { font-size: 13px; } .plan span { font-size: 12px; color: var(--moon); }
.bars { display: flex; align-items: flex-end; gap: 2px; height: 58px; margin-top: 10px; }
.bars i { flex: 1; border-radius: 3px 3px 0 0; background: linear-gradient(180deg, #a9b8ff, #4b5ea8); min-width: 2px; }
.links { margin-top: 4px; }
.links .chip { text-decoration: none; font-size: 12px; }
.help .chip { text-decoration: none; }
.about { display: flex; justify-content: space-between; margin-top: 14px; font-size: 12px; color: var(--dim); }
#sVer { user-select: none; -webkit-user-select: none; }
.whoName { margin: 0; font-size: 17px; font-weight: 800; }
#crisisPanel a.chip { text-decoration: none; }
.brand em { white-space: nowrap; }
