/* 꼬리별 — 보랏빛 오로라 밤하늘 + 말랑한 유리 HUD */
:root {
  /* --ext-* 는 JS 가 앱(웹뷰)이 넣어 준 --safe-area-top/right/bottom/left 를 읽어 px 로 넣어 줘요 */
  --sa-top: max(env(safe-area-inset-top, 0px), var(--ext-top, 0px));
  --sa-right: max(env(safe-area-inset-right, 0px), var(--ext-right, 0px));
  --sa-bottom: max(env(safe-area-inset-bottom, 0px), var(--ext-bottom, 0px));
  --sa-left: max(env(safe-area-inset-left, 0px), var(--ext-left, 0px));
  color-scheme: dark;
  --bg: #0d0824;
  --ink: #fbeedd;
  --dim: rgba(251, 238, 221, .66);
  --gold: #ffd98a;
  --pink: #ff9ccf;
  --mint: #8ff0d0;
  --glass: rgba(34, 22, 70, .55);
  --line: rgba(255, 226, 190, .22);
  --font: "Jua", "Apple SD Gothic Neo", "Noto Sans KR", system-ui, sans-serif;
}
html, body {
  margin: 0; height: 100%; overflow: hidden; background: var(--bg); color: var(--ink);
  font-family: var(--font); touch-action: none;
  -webkit-user-select: none; user-select: none; -webkit-tap-highlight-color: transparent;
}
canvas { display: block; }
[hidden] { display: none !important; }
a { color: inherit; }

.glass {
  background: var(--glass); border: 1px solid var(--line); border-radius: 18px;
  -webkit-backdrop-filter: blur(10px) saturate(1.3); backdrop-filter: blur(10px) saturate(1.3);
  box-shadow: 0 6px 24px rgba(8, 4, 24, .35);
}
.hud { position: fixed; z-index: 3; }

/* 좌상단 행성 카드 */
#card { left: calc(12px + var(--sa-left)); top: calc(12px + var(--sa-top)); display: flex; align-items: center; gap: 10px; padding: 8px 18px; border-radius: 999px; }
.card__name { font-size: 16px; letter-spacing: .04em; line-height: 1.1; }
.card__goal { font-size: 13px; color: var(--gold); letter-spacing: .1em; margin-top: 2px; }

/* 우상단 지도 + 별가루/소리 */
#side { right: calc(12px + var(--sa-right)); top: calc(12px + var(--sa-top)); display: flex; flex-direction: column; align-items: flex-end; gap: 8px; }
#map { width: 132px; height: 99px; border-radius: 16px; cursor: pointer; touch-action: manipulation; }
.side__row { display: flex; gap: 8px; }
.pill { font: inherit; color: var(--ink); font-size: 14px; padding: 6px 12px; border-radius: 999px; min-width: 20px; text-align: center; }
.pill b { font-weight: 400; color: var(--pink); }
button.pill { cursor: pointer; }

/* 하단 안내 */
#hint {
  left: 50%; bottom: calc(22px + var(--sa-bottom)); transform: translateX(-50%);
  box-sizing: border-box; width: max-content; max-width: min(92vw, 520px); text-align: center;
  font-size: 15px; line-height: 1.5; padding: 9px 20px; border-radius: 999px; pointer-events: none; transition: opacity .7s;
}
#hint b { color: var(--gold); font-weight: 400; }
#hint.off { opacity: 0; }

#bubble {
  position: fixed; z-index: 2; pointer-events: none; font-size: 15px; padding: 3px 12px; border-radius: 14px;
  background: rgba(255, 247, 235, .94); color: #2b1d4a; transform: translate(-50%, -100%); transition: opacity .5s; opacity: 0; white-space: nowrap;
}
#fade { position: fixed; inset: 0; background: #fff2dc; opacity: 0; pointer-events: none; transition: opacity .8s; z-index: 5; }
#title { position: fixed; inset: var(--sa-top) var(--sa-right) var(--sa-bottom) var(--sa-left); display: flex; flex-direction: column; align-items: center; justify-content: center; text-align: center; z-index: 4; pointer-events: none; opacity: 0; transition: opacity 1.2s; }
#title.show { opacity: 1; }
#title .n { font-size: 34px; letter-spacing: .24em; text-shadow: 0 0 26px rgba(255, 156, 207, .55), 0 2px 18px rgba(0,0,0,.6); }
#title .s { font-size: 15px; letter-spacing: .2em; color: var(--dim); margin-top: 10px; text-shadow: 0 2px 12px rgba(0,0,0,.6); }
#arrow { position: fixed; z-index: 3; width: 0; height: 0; border-left: 10px solid transparent; border-right: 10px solid transparent; border-bottom: 18px solid rgba(255, 217, 138, .9); pointer-events: none; filter: drop-shadow(0 0 6px rgba(255,217,138,.8)); }

/* 공통 오버레이 / 버튼 */
.overlay {
  position: fixed; inset: 0; z-index: 8; display: flex; align-items: center; justify-content: center; padding: calc(16px + var(--sa-top)) calc(16px + var(--sa-right)) calc(16px + var(--sa-bottom)) calc(16px + var(--sa-left));
  background: radial-gradient(ellipse at 50% 30%, rgba(60, 30, 110, .72), rgba(8, 4, 24, .92));
  -webkit-backdrop-filter: blur(6px); backdrop-filter: blur(6px); overflow-y: auto;
}
.btn {
  display: block; width: min(260px, 70vw); margin: 10px auto 0; font: inherit; font-size: 17px; letter-spacing: .08em; color: var(--ink);
  background: rgba(255,255,255,.08); border: 1px solid var(--line); border-radius: 999px; padding: 12px 20px; cursor: pointer; text-decoration: none; text-align: center;
  transition: transform .15s, background .2s;
}
.btn:active { transform: scale(.96); }
.btn--main { background: linear-gradient(135deg, #ffb870, #ff8fc0); color: #3a1740; border-color: transparent; box-shadow: 0 6px 24px rgba(255, 143, 192, .4); }
.btn--ghost { font-size: 14px; width: auto; padding: 8px 22px; margin-top: 10px; }

.intro__box { margin: auto; text-align: center; max-width: 360px; animation: rise .9s both; }
.intro__star { font-size: 30px; color: var(--gold); text-shadow: 0 0 20px rgba(255, 217, 138, .9); animation: tw 2.4s ease-in-out infinite; }
.intro__title { font-weight: 400; font-size: 58px; letter-spacing: .14em; margin: 4px 0 4px 0.14em; background: linear-gradient(180deg, #fff6e6, #ffb6dc); -webkit-background-clip: text; background-clip: text; color: transparent; filter: drop-shadow(0 4px 18px rgba(255, 143, 192, .45)); }
.intro__title--s { font-size: 32px; letter-spacing: .06em; }
.intro__sub { margin: 0 0 18px; color: var(--dim); font-size: 15px; letter-spacing: .06em; line-height: 1.6; }
.intro__how { list-style: none; margin: 0 0 20px; padding: 14px 18px; text-align: left; font-size: 14px; line-height: 1.8; color: var(--dim); background: var(--glass); border: 1px solid var(--line); border-radius: 16px; }
.intro__how li::before { content: "✦ "; color: var(--gold); }
.intro__how b { color: var(--ink); font-weight: 400; }

/* 퍼즐 카드 */
#pz .card { width: min(92vw, 380px); box-sizing: border-box; background: rgba(28, 18, 60, .96); border: 1px solid rgba(255, 217, 138, .45); border-radius: 22px; padding: 16px 18px 14px; text-align: center; box-shadow: 0 10px 50px rgba(0,0,0,.5); }
#pzTag { display: inline-block; font-size: 13px; letter-spacing: .08em; color: #3a1740; background: var(--gold); border-radius: 999px; padding: 3px 12px; }
#pzTitle { font-size: 19px; letter-spacing: .1em; margin: 10px 0 4px; }
#pzHint { font-size: 14px; line-height: 1.6; color: var(--dim); min-height: 2.6em; margin-bottom: 8px; }
#pzHint b { color: var(--gold); font-weight: 400; }
#pzc { width: 100%; aspect-ratio: 1; display: block; border-radius: 16px; background: #0b0720; touch-action: none; }
#pzNote { font-size: 12px; color: var(--dim); margin-top: 10px; line-height: 1.5; }
#pz.room .card { width: min(96vw, 440px); height: min(90vh, 800px); height: min(calc(100dvh - 24px - var(--sa-top) - var(--sa-bottom)), 800px); display: flex; flex-direction: column; padding: 10px 10px 8px; }
#pz.room #pzTitle, #pz.room #pzHint, #pz.room #pzc { display: none; }
#pzFrame { flex: 1; width: 100%; border: 0; border-radius: 14px; background: #070616; min-height: 0; }
#pz.room #pzTag { align-self: center; margin-bottom: 8px; }

#err { flex-direction: column; text-align: center; line-height: 1.7; z-index: 20; }

/* 별가루 상점 (아래에서 올라오는 창) */
.sheet { position: fixed; left: 0; right: 0; bottom: 0; z-index: 7; max-width: 520px; margin: 0 auto; box-sizing: border-box; border-radius: 22px 22px 0 0; border-bottom: 0;
  height: min(46vh, 380px); height: min(46dvh, 380px); padding: 12px 14px calc(12px + var(--sa-bottom)); display: flex; flex-direction: column; background: rgba(28, 18, 60, .92); animation: up .3s ease-out; }
.sheet[hidden] { display: none; }
.sheet__head { display: flex; align-items: center; gap: 8px; }
.sheet__title { flex: 1; font-size: 18px; letter-spacing: .06em; }
.shop__view { display: flex; align-items: center; justify-content: space-between; flex: none; gap: 8px; margin-top: 8px; }
.shop__view-label { font-size: 12px; color: var(--dim); }
.shop__view-options { display: flex; gap: 2px; padding: 3px; border: 1px solid rgba(220,200,255,.16); border-radius: 999px; background: rgba(255,255,255,.04); }
.shop__view-button { font: inherit; font-size: 12px; color: var(--dim); background: transparent; border: 0; border-radius: 999px; padding: 6px 12px; min-height: 30px; cursor: pointer; }
.shop__view-button[aria-pressed="true"] { color: #3a1740; background: var(--gold); }
.shop__view-button:focus-visible { outline: 2px solid var(--pink); outline-offset: 2px; }

.tabs { display: flex; gap: 6px; margin: 10px 0 8px; overflow-x: auto; scrollbar-width: none; }
.tabs::-webkit-scrollbar { display: none; }
.tab { flex: none; font: inherit; font-size: 13px; color: var(--dim); background: rgba(255,255,255,.07); border: 1px solid transparent; border-radius: 999px; padding: 6px 13px; cursor: pointer; }
.tab.on { color: #3a1740; background: var(--gold); }
.shop__list { flex: 1; min-height: 0; overflow-y: auto; display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px; align-content: start; -webkit-overflow-scrolling: touch; overscroll-behavior: contain; touch-action: pan-y; }
.item { position: relative; text-align: center; padding: 10px 4px 8px; border-radius: 14px; background: rgba(255,255,255,.07); border: 1px solid transparent; cursor: pointer; }
.item.eq { border-color: var(--gold); background: rgba(255,217,138,.12); }
.item.try { border-color: var(--pink); border-style: dashed; }
.item__e { font-size: 28px; line-height: 1.2; }
.item__n { font-size: 12.5px; margin: 2px 0 6px; }
.item__b { font: inherit; font-size: 12px; color: #3a1740; background: linear-gradient(135deg, #ffb870, #ff8fc0); border: 0; border-radius: 999px; padding: 4px 10px; cursor: pointer; }
.item__b.no { background: rgba(255,255,255,.14); color: var(--dim); }
.item__s { font-size: 12px; color: var(--gold); }
.shop__msg { min-height: 1.4em; margin-top: 6px; font-size: 13px; text-align: center; color: var(--pink); }
@keyframes up { from { transform: translateY(40px); opacity: 0; } to { transform: none; opacity: 1; } }
@keyframes pop { 0% { transform: scale(1); } 40% { transform: scale(1.14); box-shadow: 0 0 22px rgba(255, 217, 138, .55); } 100% { transform: scale(1); } }
.pop { animation: pop .38s ease-out; }
@keyframes rise { from { opacity: 0; transform: translateY(16px); } to { opacity: 1; transform: none; } }
@keyframes tw { 0%, 100% { opacity: .6; transform: scale(.9); } 50% { opacity: 1; transform: scale(1.1); } }
@media (max-width: 520px) {
  .intro__title { font-size: 48px; }
  #map { width: 108px; height: 81px; }
  #title .n { font-size: 26px; }
}
@media (prefers-reduced-motion: reduce) { .intro__star, .intro__box { animation: none; } }
