:root {
  --ink: #16261c;
  --panel: rgba(16, 32, 23, .78);
  --panel-solid: #15281d;
  --line: rgba(255, 255, 255, .14);
  --paper: #fbf7ec;
  --paper-ink: #24332a;
  --paper-sub: #5e6b60;
  --bamboo: #6fb04a;
  --bamboo-deep: #3f7f2f;
  --bamboo-pale: #d7ecbd;
  --sun: #ffd76a;
  --heart: #ff7a93;
  --text: #fff;
  --sub: rgba(255, 255, 255, .72);
  --safe-b: env(safe-area-inset-bottom, 0px);
  --safe-t: env(safe-area-inset-top, 0px);
  --font: Jua, 'Noto Sans KR', 'Apple SD Gothic Neo', sans-serif;
  --font-body: 'Noto Sans KR', 'Apple SD Gothic Neo', sans-serif;
}

* { box-sizing: border-box; margin: 0; padding: 0; }
[hidden] { display: none !important; }

html, body {
  width: 100%; height: 100%; overflow: hidden;
  background: #bcdcef; color: var(--text);
  font-family: var(--font);
  -webkit-user-select: none; user-select: none;
  touch-action: none; overscroll-behavior: none;
  -webkit-tap-highlight-color: transparent;
}
#world { position: fixed; inset: 0; width: 100%; height: 100%; display: block; }
button, input { font: inherit; color: inherit; }
button { border: 0; background: none; cursor: pointer; }
input { -webkit-user-select: text; user-select: text; }
button:focus-visible, a:focus-visible, input:focus-visible, label:focus-within {
  outline: 3px solid var(--sun); outline-offset: 2px;
}

/* ---------- 입장권 ---------- */
.ticket {
  position: fixed; z-index: 30; left: 50%; bottom: calc(16px + var(--safe-b));
  transform: translateX(-50%);
  width: min(calc(100% - 32px), 400px); max-height: calc(100dvh - 32px); overflow: hidden auto;
  padding: 22px 22px 16px;
  background: var(--paper); color: var(--paper-ink);
  border-radius: 20px;
  box-shadow: 0 18px 48px rgba(10, 30, 15, .35);
}
.ticket::before, .ticket::after {
  content: ''; position: absolute; top: 64px; width: 18px; height: 18px; border-radius: 50%;
  background: rgba(30, 60, 40, .18);
}
.ticket::before { left: -9px; }
.ticket::after { right: -9px; }
.ticket-stamp {
  display: inline-block; padding: 2px 10px; margin-bottom: 8px;
  border: 2px solid var(--bamboo-deep); border-radius: 6px;
  color: var(--bamboo-deep); font-size: 13px; letter-spacing: .12em;
  transform: rotate(-3deg);
}
.ticket h1 { font-size: 27px; font-weight: 400; line-height: 1.2; }
.ticket-lead { margin-top: 6px; font-family: var(--font-body); font-size: 14px; line-height: 1.55; color: var(--paper-sub); }
.ticket-live { margin-top: 8px; font-size: 14px; color: var(--bamboo-deep); }
.field { display: block; margin: 14px 0 6px; font-size: 14px; color: var(--paper-ink); }
.name-row { display: flex; gap: 8px; }
.ticket input, .sheet input:not([type]) {
  flex: 1; min-width: 0; width: 100%; height: 44px; padding: 0 12px;
  background: #fff; color: var(--paper-ink);
  border: 2px solid #dcd6c3; border-radius: 12px; font-size: 16px;
}
.ghost {
  display: inline-flex; align-items: center; justify-content: center; gap: 6px;
  min-height: 44px; min-width: 44px; padding: 0 14px;
  border: 2px solid #dcd6c3; border-radius: 12px; background: #fff; color: var(--paper-ink);
  font-size: 15px; text-decoration: none;
}
.kinds, .feed-foods { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; }
.kind, .food {
  display: flex; align-items: center; justify-content: center; gap: 8px; min-height: 58px; padding: 6px;
  background: #fff; color: var(--paper-ink); border: 2px solid #dcd6c3; border-radius: 12px; font-size: 16px;
}
.kind svg, .food svg { width: 38px; height: 38px; flex: none; }
.kind[aria-checked="true"], .food[aria-checked="true"] { border-color: var(--bamboo-deep); background: var(--bamboo-pale); }
.feed-pandas { display: grid; grid-template-columns: repeat(auto-fit, minmax(92px, 1fr)); gap: 6px; }
.feed-panda {
  display: flex; align-items: center; justify-content: center; gap: 6px; min-height: 44px; padding: 4px 6px;
  background: #fff; color: var(--paper-ink); border: 2px solid #dcd6c3; border-radius: 12px; font-size: 15px;
}
.feed-panda i { width: 11px; height: 11px; border-radius: 50%; flex: none; }
.feed-panda[aria-checked="true"] { border-color: var(--bamboo-deep); background: var(--bamboo-pale); }
.cta.small.feed-go { margin-top: 16px; }
.feed-note { margin-top: 8px; font-family: var(--font-body); font-size: 13px; color: var(--paper-sub); text-align: center; }
.panda-actions { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; }
.swatches { display: flex; gap: 10px; flex-wrap: wrap; }
.swatch {
  width: 40px; height: 40px; border-radius: 50%; border: 3px solid transparent;
  box-shadow: inset 0 0 0 2px rgba(255, 255, 255, .55);
  transition: transform .12s;
}
.swatch[aria-checked="true"] { border-color: var(--paper-ink); transform: scale(1.1); }
.cta {
  display: flex; align-items: center; justify-content: center; gap: 8px;
  width: 100%; min-height: 54px; margin-top: 16px;
  background: var(--bamboo-deep); color: #fff; border-radius: 14px; font-size: 19px;
  box-shadow: 0 4px 0 #2c5c22; transition: transform .08s, box-shadow .08s, opacity .2s;
}
.cta:active:not(:disabled) { transform: translateY(3px); box-shadow: 0 1px 0 #2c5c22; }
.cta:disabled { opacity: .55; cursor: default; }
.cta.small { min-height: 44px; font-size: 16px; margin-top: 0; }
.fine a { color: inherit; }
.text-link { padding: 0; text-decoration: underline; }
.fine { margin-top: 10px; font-family: var(--font-body); font-size: 12px; color: var(--paper-sub); text-align: center; }

/* ---------- HUD ---------- */
.hud {
  display: inline-flex; align-items: center; gap: 8px; min-height: 40px; padding: 0 14px;
  background: var(--panel); color: var(--text); border-radius: 14px;
  box-shadow: 0 4px 14px rgba(0, 0, 0, .22); font-size: 15px;
  -webkit-backdrop-filter: blur(6px); backdrop-filter: blur(6px);
}
.hud.round { width: 40px; padding: 0; justify-content: center; }
.hud-zone { position: fixed; z-index: 10; top: calc(12px + var(--safe-t)); left: 12px; }
#zoneStep { padding: 1px 7px; border-radius: 8px; background: var(--sun); color: var(--ink); font-size: 13px; }
.hud-visit { position: fixed; z-index: 10; top: calc(60px + var(--safe-t)); left: 12px; min-height: 32px; padding: 0 12px; font-size: 14px; }
.hud-visit strong { font-weight: 400; color: var(--sun); font-variant-numeric: tabular-nums; }
.hud-right { position: fixed; z-index: 10; top: calc(12px + var(--safe-t)); right: 12px; display: flex; gap: 8px; }
#channelName { color: var(--sub); }

/* 줄 정보 */
.queue {
  position: fixed; z-index: 10; top: calc(62px + var(--safe-t)); left: 50%; transform: translateX(-50%);
  width: min(calc(100% - 24px), 340px); padding: 12px 16px 12px;
  background: var(--panel); border-radius: 18px; text-align: center;
  box-shadow: 0 6px 20px rgba(0, 0, 0, .25);
  -webkit-backdrop-filter: blur(6px); backdrop-filter: blur(6px);
}
.queue-label { font-size: 14px; color: var(--sub); }
.queue-time { font-size: 18px; line-height: 1.1; }
.queue-time strong { font-size: 46px; font-weight: 400; color: var(--sun); font-variant-numeric: tabular-nums; }
.queue-stats { display: grid; grid-template-columns: repeat(3, 1fr); gap: 6px; margin-top: 6px; }
.queue-stats div { padding: 6px 2px; background: rgba(255, 255, 255, .08); border-radius: 10px; }
.queue-stats dt { font-size: 12px; color: var(--sub); }
.queue-stats dd { font-size: 18px; font-variant-numeric: tabular-nums; }
.queue-note { margin-top: 8px; font-size: 13px; color: var(--bamboo-pale); }

/* 사랑 누적 */
.love {
  position: fixed; z-index: 10; top: calc(62px + var(--safe-t)); right: 12px; width: 168px;
  background: var(--panel); border-radius: 14px; overflow: hidden;
  -webkit-backdrop-filter: blur(6px); backdrop-filter: blur(6px);
}
.love-head { display: flex; justify-content: space-between; width: 100%; min-height: 36px; padding: 0 12px; font-size: 14px; align-items: center; }
.love ol { list-style: none; padding: 0 12px 10px; }
.love li { display: flex; justify-content: space-between; gap: 8px; padding: 2px 0; font-size: 14px; }
.love li b { font-weight: 400; color: var(--sun); font-variant-numeric: tabular-nums; }
.love.closed ol { display: none; }

.visit-warn {
  position: fixed; z-index: 60; left: 50%; top: calc(116px + var(--safe-t)); transform: translateX(-50%);
  width: max-content; max-width: calc(100% - 32px); padding: 8px 18px;
  background: var(--sun); color: var(--ink); border-radius: 14px; font-size: 17px; text-align: center;
  box-shadow: 0 8px 24px rgba(0, 0, 0, .3); pointer-events: none;
}
.visit-warn strong { font-weight: 400; font-size: 24px; font-variant-numeric: tabular-nums; }
.hint {
  position: fixed; z-index: 9; left: 50%; bottom: calc(96px + var(--safe-b)); transform: translateX(-50%);
  max-width: min(calc(100% - 32px), 460px); padding: 8px 14px;
  background: var(--panel); border-radius: 12px; font-size: 14px; text-align: center; pointer-events: none;
}
.toast {
  position: fixed; z-index: 60; left: 50%; top: calc(66px + var(--safe-t)); transform: translateX(-50%);
  max-width: min(calc(100% - 32px), 420px); padding: 10px 16px;
  background: var(--paper); color: var(--paper-ink); border-radius: 12px; font-size: 15px; text-align: center;
  box-shadow: 0 8px 24px rgba(0, 0, 0, .25); pointer-events: none;
}

/* 조작 */
.joy {
  position: fixed; z-index: 10; left: 18px; bottom: calc(82px + var(--safe-b));
  width: 112px; height: 112px; border-radius: 50%;
  background: rgba(16, 32, 23, .35); border: 2px solid rgba(255, 255, 255, .28);
  touch-action: none;
}
.joy-knob {
  position: absolute; left: 50%; top: 50%; width: 52px; height: 52px; margin: -26px 0 0 -26px;
  border-radius: 50%; background: rgba(255, 255, 255, .88); box-shadow: 0 3px 10px rgba(0, 0, 0, .3);
}
.bar {
  position: fixed; z-index: 10; left: 50%; bottom: calc(12px + var(--safe-b)); transform: translateX(-50%);
  display: flex; gap: 4px; padding: 6px;
  background: var(--panel); border-radius: 18px; box-shadow: 0 6px 20px rgba(0, 0, 0, .28);
  -webkit-backdrop-filter: blur(6px); backdrop-filter: blur(6px);
}
.bar button {
  display: flex; align-items: center; gap: 6px; min-height: 44px; padding: 0 12px;
  border-radius: 12px; font-size: 15px; white-space: nowrap;
}
.bar button:hover { background: rgba(255, 255, 255, .1); }
.bar button:active { background: rgba(255, 255, 255, .2); }

/* 채팅 */
.chat-btn {
  position: fixed; z-index: 11; left: 12px; bottom: calc(14px + var(--safe-b));
  width: 48px; height: 48px; border-radius: 50%; background: var(--panel); font-size: 20px;
  box-shadow: 0 4px 14px rgba(0, 0, 0, .25);
}
.chat {
  position: fixed; z-index: 12; left: 12px; bottom: calc(70px + var(--safe-b));
  width: min(calc(100% - 24px), 340px); background: var(--panel); border-radius: 14px; overflow: hidden;
  -webkit-backdrop-filter: blur(6px); backdrop-filter: blur(6px);
}
.chat ul {
  list-style: none; max-height: min(30dvh, 210px); overflow-y: auto; padding: 10px 12px;
  font-family: var(--font-body); font-size: 14px; line-height: 1.45;
  -webkit-user-select: text; user-select: text; touch-action: pan-y;
}
.chat li + li { margin-top: 3px; }
.chat li b { color: var(--sun); font-weight: 500; margin-right: 6px; }
.chat form { display: flex; gap: 6px; padding: 8px; border-top: 1px solid var(--line); }
.chat input { flex: 1; min-width: 0; height: 40px; padding: 0 10px; border: 0; border-radius: 10px; background: rgba(255, 255, 255, .92); color: var(--paper-ink); font-size: 16px; font-family: var(--font-body); }
.chat form button { padding: 0 12px; border-radius: 10px; background: var(--bamboo-deep); font-size: 14px; }

/* 판다 소개 */
.panda-card {
  position: fixed; z-index: 20; right: 12px; bottom: calc(76px + var(--safe-b));
  width: min(calc(100% - 24px), 320px); padding: 16px;
  background: var(--paper); color: var(--paper-ink); border-radius: 18px;
  box-shadow: 0 14px 36px rgba(0, 0, 0, .3);
}
.panda-role { display: inline-block; padding: 1px 8px; border-radius: 7px; color: #fff; font-size: 13px; }
.panda-card h2 { margin-top: 4px; font-size: 26px; font-weight: 400; }
.panda-meaning { font-size: 15px; color: var(--bamboo-deep); }
.panda-intro { margin-top: 8px; font-family: var(--font-body); font-size: 14px; line-height: 1.55; color: var(--paper-sub); }
.panda-facts { display: grid; grid-template-columns: 1fr 1fr; gap: 6px; margin: 10px 0; }
.panda-facts div { padding: 6px 8px; background: #f0ead8; border-radius: 10px; }
.panda-facts dt { font-size: 12px; color: var(--paper-sub); }
.panda-facts dd { font-size: 15px; }
.close {
  position: absolute; top: 10px; right: 10px; width: 36px; height: 36px; border-radius: 50%;
  background: rgba(0, 0, 0, .07); color: inherit; font-size: 15px;
}

/* 시트 */
.sheet {
  position: fixed; z-index: 40; left: 50%; top: 50%; transform: translate(-50%, -50%);
  width: min(calc(100% - 24px), 440px); max-height: calc(100dvh - 24px); overflow-y: auto;
  padding: 18px; background: var(--paper); color: var(--paper-ink); border-radius: 20px;
  box-shadow: 0 20px 60px rgba(0, 0, 0, .4); touch-action: pan-y;
}
.sheet.small { width: min(calc(100% - 24px), 360px); }
.sheet.wide { width: min(calc(100% - 24px), 720px); }
.sheet header { position: relative; display: flex; align-items: center; min-height: 36px; margin-bottom: 12px; padding-right: 44px; }
.sheet header h2 { font-size: 22px; font-weight: 400; }
.sheet header .close { top: 0; right: 0; }
.sheet img { display: block; width: 100%; border-radius: 12px; background: #eee; }
.sheet-actions { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; margin-top: 14px; }
.notice-list { display: grid; gap: 8px; font-family: var(--font-body); }
.notice-list div { padding: 8px 10px; background: #f0ead8; border-radius: 10px; }
.notice-list dt { font-size: 12px; color: var(--paper-sub); }
.notice-list dd { font-size: 15px; overflow-wrap: anywhere; }
.notice-list a { color: var(--bamboo-deep); }
.notice-note { margin-top: 14px; font-size: 17px; text-align: center; }
.channel-list { list-style: none; display: grid; gap: 6px; }
.channel-list button {
  display: flex; justify-content: space-between; width: 100%; min-height: 44px; padding: 0 14px;
  align-items: center; background: #f0ead8; border-radius: 12px; font-size: 16px;
}
.channel-list button[aria-current="true"] { background: var(--bamboo-pale); }
.channel-list button:disabled { opacity: .5; cursor: default; }
.album-actions { display: flex; align-items: center; gap: 10px; margin-bottom: 12px; flex-wrap: wrap; }
.album-actions p { flex: 1; min-width: 160px; font-family: var(--font-body); font-size: 13px; color: var(--paper-sub); }
.file-btn { width: auto; padding: 0 16px; cursor: pointer; }
.file-btn input { position: absolute; width: 1px; height: 1px; opacity: 0; }
.album-empty { padding: 30px 0; text-align: center; color: var(--paper-sub); }
.album-grid { list-style: none; display: grid; grid-template-columns: repeat(auto-fill, minmax(120px, 1fr)); gap: 8px; }
.album-grid button { position: relative; display: block; width: 100%; aspect-ratio: 1; overflow: hidden; border-radius: 12px; background: #e8e2d0; }
.album-grid img { width: 100%; height: 100%; object-fit: cover; border-radius: 0; }
.badge { position: absolute; left: 6px; bottom: 6px; padding: 2px 7px; border-radius: 7px; background: rgba(16, 32, 23, .85); color: #fff; font-size: 12px; }
.consent-list { padding-left: 18px; font-family: var(--font-body); font-size: 14px; line-height: 1.6; }
.check { display: flex; align-items: center; gap: 8px; min-height: 44px; margin: 10px 0; font-size: 16px; cursor: pointer; }
.check input { width: 22px; height: 22px; }

/* 사진 크게 보기 */
.lightbox {
  position: fixed; z-index: 50; inset: 0; display: flex; flex-direction: column;
  align-items: center; justify-content: center; gap: 12px;
  padding: calc(16px + var(--safe-t)) 16px calc(16px + var(--safe-b));
  background: rgba(8, 16, 11, .92);
}
.lightbox img { max-width: 100%; max-height: 72dvh; border-radius: 10px; }
.lightbox .close { top: calc(12px + var(--safe-t)); right: 12px; background: rgba(255, 255, 255, .16); color: #fff; }
.lightbox-info { display: flex; flex-wrap: wrap; justify-content: center; align-items: center; gap: 4px 12px; text-align: center; font-size: 17px; }
.lightbox-info p { width: 100%; }
.lightbox-by { color: var(--sub); font-size: 14px; }
.lightbox .ghost { background: transparent; color: #fff; border-color: var(--line); }

/* 화면 효과 */
.flash { position: fixed; z-index: 70; inset: 0; background: #fff; opacity: 0; pointer-events: none; }
.flash.on { animation: flash .35s ease-out; }
@keyframes flash { 0% { opacity: .95; } 100% { opacity: 0; } }
.fade {
  position: fixed; z-index: 80; inset: 0; display: flex; align-items: center; justify-content: center;
  background: #fbf7ec; color: var(--bamboo-deep); font-size: clamp(28px, 7vw, 46px); text-align: center; padding: 20px;
  opacity: 0; pointer-events: none; transition: opacity .5s;
}
.fade.on { opacity: 1; pointer-events: auto; }
.loading {
  position: fixed; z-index: 90; inset: 0; display: flex; align-items: center; justify-content: center;
  background: #16261c; color: #fff; font-size: 18px; transition: opacity .4s;
}
.loading.done { opacity: 0; pointer-events: none; }

@media (min-width: 900px) {
  .ticket { left: auto; right: 6vw; bottom: 50%; transform: translateY(50%); }
  .joy { display: none; }
  .chat-btn { bottom: 18px; }
  .chat { bottom: 76px; }
}
/* 터치 화면은 넓어도 조이스틱이 필요하다 */
@media (min-width: 900px) and (pointer: coarse) {
  .joy { display: block; }
}
@media (max-width: 899px) {
  /* 왼쪽은 조이스틱 자리라 채팅 버튼을 오른쪽으로 옮긴다 */
  .chat-btn { left: auto; right: 12px; bottom: calc(76px + var(--safe-b)); }
  .chat { bottom: calc(132px + var(--safe-b)); left: 12px; right: 12px; width: auto; max-width: 420px; }
}
@media (max-width: 480px) {
  .bar { gap: 0; padding: 4px; }
  .bar button { flex-direction: column; justify-content: center; gap: 1px; min-height: 50px; padding: 2px 9px; font-size: 12px; line-height: 1.1; }
  .love { width: 138px; }
  #channelName { display: none; }
  .love li { font-size: 13px; }
  .queue-time strong { font-size: 38px; }
}
@media (max-height: 560px) {
  .queue { top: 8px; padding: 6px 12px 8px; width: 300px; }
  .queue-time strong { font-size: 28px; }
  .queue-note { display: none; }
  .ticket { max-height: calc(100dvh - 16px); bottom: 8px; padding: 14px 18px 10px; }
  .ticket h1 { font-size: 22px; }
}
@media (prefers-reduced-motion: reduce) {
  .flash.on { animation: none; }
  .fade { transition: none; }
}
