:root {
  --ink: #fff6e8;
  --dim: #c9b9a6;
  --ember: #ff9a3c;
  --ember2: #ffcf6b;
  --glass: rgba(24, 18, 30, 0.62);
  --line: rgba(255, 210, 160, 0.18);
}
* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }
html, body { margin: 0; height: 100%; overflow: hidden; background: #0b0d1a; color: var(--ink);
  font-family: "Gowun Dodum", system-ui, sans-serif; user-select: none; -webkit-user-select: none; }
canvas#c { position: fixed; inset: 0; width: 100%; height: 100%; display: block; touch-action: none; }
button { font: inherit; color: inherit; cursor: pointer; }
[hidden] { display: none !important; }

/* 입장 */
#intro { position: fixed; inset: 0; display: grid; place-items: center; padding: 16px;
  background: linear-gradient(180deg, rgba(8,10,24,.25), rgba(8,10,24,.75)), url(art/keyart.jpg) center/cover; z-index: 20; }
#intro .card { width: min(420px, 100%); padding: 28px 26px 22px; border-radius: 22px; background: var(--glass);
  border: 1px solid var(--line); backdrop-filter: blur(10px); -webkit-backdrop-filter: blur(10px); box-shadow: 0 20px 60px rgba(0,0,0,.45); }
#intro h1 { font-family: Jua, sans-serif; font-weight: 400; font-size: 44px; margin: 0; letter-spacing: 1px;
  color: var(--ember2); text-shadow: 0 0 24px rgba(255,140,40,.55); }
#intro .sub { margin: 6px 0 18px; color: var(--dim); line-height: 1.55; }
.fld { display: grid; gap: 7px; margin-bottom: 14px; font-size: 13px; color: var(--dim); }
.fld input { font: inherit; font-size: 17px; color: var(--ink); background: rgba(255,255,255,.07); border: 1px solid var(--line);
  border-radius: 12px; padding: 11px 13px; outline: none; }
.fld input:focus { border-color: var(--ember); }
#swatches { display: flex; gap: 9px; flex-wrap: wrap; }
#swatches button { width: 34px; height: 34px; border-radius: 50%; border: 2px solid transparent; outline: 2px solid transparent; }
#swatches button.on { border-color: #fff; outline-color: var(--ember); }
.big { width: 100%; margin-top: 6px; padding: 14px; border: 0; border-radius: 14px; font-family: Jua, sans-serif; font-size: 20px;
  color: #3a1a05; background: linear-gradient(180deg, #ffd27a, #ff9a3c); box-shadow: 0 6px 24px rgba(255,140,40,.4); }
.hint { margin: 14px 0 0; font-size: 12px; color: var(--dim); text-align: center; line-height: 1.6; }

/* HUD */
#hud { position: fixed; inset: 0; pointer-events: none; z-index: 5; }
#hud button, #hud input, #hud form, #joy { pointer-events: auto; }
#topL { position: absolute; left: 16px; top: calc(14px + env(safe-area-inset-top, 0px)); display: flex; align-items: center; gap: 10px;
  padding: 8px 14px; border-radius: 999px; background: var(--glass); border: 1px solid var(--line); font-size: 14px; }
#topL b { font-family: Jua, sans-serif; font-weight: 400; font-size: 18px; color: var(--ember2); }
#people { color: var(--dim); }
.dot { width: 8px; height: 8px; border-radius: 50%; background: #777; }
.dot.on { background: #6be38a; box-shadow: 0 0 8px #6be38a; }
#topR { position: absolute; right: 16px; top: calc(14px + env(safe-area-inset-top, 0px)); display: flex; gap: 8px; }
#topR button, #sitBtn, .acts button { border: 1px solid var(--line); background: var(--glass); border-radius: 999px; padding: 9px 14px;
  font-size: 15px; backdrop-filter: blur(8px); -webkit-backdrop-filter: blur(8px); }
#topR button:active, .acts button:active, #sitBtn:active { transform: scale(.96); }
small { font-size: 10px; opacity: .55; margin-left: 4px; }

#feed { position: absolute; left: 16px; top: calc(66px + env(safe-area-inset-top, 0px)); display: grid; gap: 6px; max-width: min(360px, 70vw); }
#feed div { font-size: 13px; padding: 6px 11px; border-radius: 10px; background: rgba(20,14,24,.5); color: var(--dim);
  animation: fin .4s ease; transition: opacity 1s; }
#feed div b { color: var(--ink); font-weight: 400; }
@keyframes fin { from { opacity: 0; transform: translateY(-6px); } }

#bottom { position: absolute; left: 50%; bottom: calc(18px + env(safe-area-inset-bottom, 0px)); transform: translateX(-50%);
  display: flex; gap: 10px; align-items: center; }
#foods { display: flex; gap: 8px; padding: 7px; border-radius: 20px; background: var(--glass); border: 1px solid var(--line); }
#foods button { width: 58px; height: 58px; border-radius: 14px; border: 2px solid transparent; background-color: rgba(255,255,255,.06);
  background-image: url(art/foods.png); background-size: 200% 200%; position: relative; }
#foods button.on { border-color: var(--ember); background-color: rgba(255,154,60,.18); }
#foods button.locked { opacity: .45; }
#foods button span { position: absolute; left: 0; right: 0; bottom: -2px; font-size: 10px; text-shadow: 0 1px 3px #000; }
#sitBtn { padding: 14px 18px; font-family: Jua, sans-serif; font-size: 17px; }
#sitBtn.go { background: linear-gradient(180deg, #ffd27a, #ff9a3c); color: #3a1a05; border-color: transparent; }

#cook { position: absolute; left: 50%; bottom: calc(104px + env(safe-area-inset-bottom, 0px)); transform: translateX(-50%);
  width: min(420px, calc(100vw - 32px)); padding: 12px 14px; border-radius: 18px; background: var(--glass); border: 1px solid var(--line);
  backdrop-filter: blur(8px); -webkit-backdrop-filter: blur(8px); }
#cook .ttl { display: flex; justify-content: space-between; font-size: 15px; margin-bottom: 8px; }
#foodName { font-family: Jua, sans-serif; color: var(--ember2); }
#state { color: var(--dim); }
#state.hot { color: #ff7a5a; }
#state.good { color: #ffd76b; }
.bars { display: grid; gap: 6px; }
.bar { display: flex; align-items: center; gap: 8px; font-size: 11px; color: var(--dim); }
.bar i { font-style: normal; width: 14px; }
.track { flex: 1; height: 10px; border-radius: 6px; background: rgba(255,255,255,.08); position: relative; overflow: hidden; }
.zone { position: absolute; top: 0; bottom: 0; left: 37%; width: 16.3%; background: rgba(255,215,110,.28); border-left: 1px dashed #ffd76b; border-right: 1px dashed #ffd76b; }
.fill { position: absolute; left: 0; top: 0; bottom: 0; width: 0; border-radius: 6px; background: #f4ead7; }
.acts { display: flex; gap: 8px; margin-top: 10px; flex-wrap: wrap; }
.acts button { flex: 1; min-width: 74px; padding: 10px 8px; }
.acts button.held { background: rgba(255,154,60,.35); border-color: var(--ember); }
#eatBtn { background: linear-gradient(180deg, #ffd27a, #ff9a3c); color: #3a1a05; border-color: transparent; font-family: Jua, sans-serif; }
#blowBtn { background: #5b8cff55; border-color: #8fb0ff; }

#chat { position: absolute; left: 16px; bottom: calc(18px + env(safe-area-inset-bottom, 0px)); }
#chatIn { width: 200px; font: inherit; font-size: 14px; color: var(--ink); padding: 10px 13px; border-radius: 999px; outline: none;
  border: 1px solid var(--line); background: var(--glass); }
#chatIn:focus { border-color: var(--ember); width: 260px; }

#joy { position: absolute; left: 22px; bottom: calc(80px + env(safe-area-inset-bottom, 0px)); width: 110px; height: 110px; border-radius: 50%;
  background: rgba(255,255,255,.07); border: 1px solid var(--line); display: none; touch-action: none; }
#knob { position: absolute; left: 50%; top: 50%; width: 46px; height: 46px; margin: -23px; border-radius: 50%; background: rgba(255,210,160,.35); }
.touch #joy { display: block; }

#toast { position: absolute; left: 50%; top: 22%; transform: translate(-50%, 0); text-align: center; font-family: Jua, sans-serif;
  font-size: 26px; color: var(--ember2); text-shadow: 0 2px 16px rgba(0,0,0,.7), 0 0 30px rgba(255,140,40,.5); opacity: 0; transition: opacity .4s, transform .4s; pointer-events: none; }
#toast.show { opacity: 1; transform: translate(-50%, -8px); }
#toast small { display: block; font-family: "Gowun Dodum", sans-serif; font-size: 15px; color: var(--ink); opacity: .85; margin-top: 4px; }

/* 이름표·말풍선 */
#labels { position: fixed; inset: 0; pointer-events: none; z-index: 4; overflow: hidden; }
.tag { position: absolute; left: 0; top: 0; transform: translate(-50%, -100%); display: grid; justify-items: center; gap: 4px; will-change: transform; }
.tag .nm { font-size: 12px; padding: 2px 8px; border-radius: 999px; background: rgba(10,8,16,.55); color: var(--ink); white-space: nowrap; }
.tag .bb { max-width: 180px; font-size: 13px; padding: 6px 10px; border-radius: 12px; background: #fff6e8; color: #2a1a10; line-height: 1.35;
  text-align: center; word-break: keep-all; box-shadow: 0 4px 14px rgba(0,0,0,.35); }
.tag .bb:empty { display: none; }

#bulmeong { position: fixed; left: 0; right: 0; bottom: calc(40px + env(safe-area-inset-bottom, 0px)); text-align: center; z-index: 6; pointer-events: none;
  color: var(--dim); animation: fin 2s ease; }
#bmTime { font-family: Jua, sans-serif; font-size: 34px; color: rgba(255,220,170,.75); }
#bulmeong p { margin: 4px 0 0; }

@media (max-width: 640px) {
  #topL b, #topR .lb { display: none; } #foods button span { display: none; }
  #topL { font-size: 12px; padding: 7px 11px; }
  #topR { top: calc(58px + env(safe-area-inset-top, 0px)); }
  #toast { top: 42%; font-size: 22px; width: 90vw; }
  #topR button { padding: 8px 10px; font-size: 13px; }
  #foods button { width: 48px; height: 48px; }
  #bottom { left: auto; right: 12px; transform: none; flex-direction: column-reverse; align-items: flex-end; }
  #foods { flex-direction: column; }
  #cook { bottom: auto; top: calc(142px + env(safe-area-inset-top, 0px)); }
  #chat { bottom: calc(14px + env(safe-area-inset-bottom, 0px)); }
  #chatIn { width: 150px; } #chatIn:focus { width: 200px; }
  #feed { top: auto; bottom: calc(210px + env(safe-area-inset-bottom, 0px)); }
}
.bar.heat .track { height: 6px; background: linear-gradient(90deg, rgba(255,255,255,.06), rgba(255,180,80,.18) 55%, rgba(255,70,40,.3)); }
.bar.heat .fill { background: linear-gradient(90deg, #ffcf6b, #ff6a3a); }

/* 할로윈 */
.eyebrow { margin: 0 0 4px; font-size: 13px; color: #ffb36b; letter-spacing: .5px; }
#costumes { display: grid; grid-template-columns: repeat(6, 1fr); gap: 6px; }
#costumes button { aspect-ratio: 1; border-radius: 12px; border: 2px solid transparent; background-color: rgba(255,255,255,.07);
  background-image: url(art/costumes.png); background-size: 300% 200%; position: relative; padding: 0; }
#costumes button.on { border-color: var(--ember); background-color: rgba(255,154,60,.2); }
#costumes button span { position: absolute; left: 0; right: 0; bottom: -17px; font-size: 10px; color: var(--dim); }
#costumes { margin-bottom: 14px; }
#fest { position: absolute; left: 16px; top: calc(62px + env(safe-area-inset-top, 0px)); display: flex; gap: 12px; padding: 6px 12px;
  border-radius: 999px; background: rgba(60, 24, 70, .6); border: 1px solid rgba(190, 120, 255, .3); font-size: 13px; }
#fest b { font-weight: 400; color: var(--ember2); }
#feed { top: calc(104px + env(safe-area-inset-top, 0px)); }
#actBtn { position: absolute; left: 50%; bottom: calc(100px + env(safe-area-inset-bottom, 0px)); transform: translateX(-50%); padding: 13px 22px;
  border-radius: 999px; border: 0; font-family: Jua, sans-serif; font-size: 18px; color: #2a0f3a; white-space: nowrap;
  background: linear-gradient(180deg, #ffd27a, #ff8a2a); box-shadow: 0 0 0 3px rgba(160, 90, 255, .5), 0 8px 28px rgba(255, 120, 30, .45);
  animation: bob 1.4s ease-in-out infinite; }
@keyframes bob { 50% { transform: translate(-50%, -4px); } }
body.tricked::after { content: ''; position: fixed; inset: 0; z-index: 30; pointer-events: none;
  background: radial-gradient(circle, transparent 30%, rgba(90, 20, 130, .75)); animation: trick .9s ease-out forwards; }
@keyframes trick { from { opacity: 1; } to { opacity: 0; } }

#guide { position: fixed; inset: 0; z-index: 25; display: grid; place-items: center; padding: 16px; background: rgba(10, 6, 20, .55); }
#guide .card { width: min(520px, 100%); max-height: calc(100vh - 32px); overflow: auto; padding: 22px 22px 18px; border-radius: 22px;
  background: rgba(30, 18, 40, .9); border: 1px solid rgba(190, 120, 255, .3); box-shadow: 0 20px 60px rgba(0,0,0,.5); animation: fin .4s ease; }
#guide h2 { margin: 0 0 12px; font-family: Jua, sans-serif; font-weight: 400; font-size: 28px; color: var(--ember2); }
#guide ol { list-style: none; margin: 0 0 14px; padding: 0; display: grid; gap: 10px; }
#guide li { display: grid; gap: 2px; font-size: 13px; line-height: 1.5; color: var(--dim); }
#guide li b { font-weight: 400; font-size: 15px; color: var(--ink); }
kbd { font-family: inherit; font-size: 11px; padding: 1px 6px; border-radius: 5px; background: rgba(255,255,255,.12); border: 1px solid rgba(255,255,255,.2); color: var(--ink); }
.skip { display: flex; gap: 6px; align-items: center; font-size: 12px; color: var(--dim); margin-bottom: 4px; }
@media (max-width: 640px) {
  #fest { top: calc(102px + env(safe-area-inset-top, 0px)); font-size: 12px; }
  #actBtn { bottom: calc(70px + env(safe-area-inset-bottom, 0px)); left: 16px; transform: none; font-size: 15px; animation: none; }
}
@media (max-width: 640px) {
  #feed { top: auto; bottom: calc(210px + env(safe-area-inset-bottom, 0px)); }
}
