:root {
  --ink: #f8f1e3;
  --muted: #d6c7b0;
  --navy: #1a120c;
  --gold: #e0b35a;
  --teal: #2f6f66;
  --rose: #9a3b4a;
  --danger: #b42318;
  --panel: rgba(18, 12, 8, 0.78);
  --line: rgba(224, 179, 90, 0.28);
  --stage: clamp(300px, 40vw, 42vmin);
}
* { box-sizing: border-box; }
html, body { margin: 0; height: 100%; }
body {
  font-family: "Pretendard", "Noto Sans KR", "Apple SD Gothic Neo", sans-serif;
  color: var(--ink);
  overflow: hidden;
}
button, input { font: inherit; }
.hidden { display: none !important; }

.world {
  min-height: 100dvh;
  background-color: #0b0705;
  background-image: url("assets/bg/shop_door.jpg");
  background-size: cover;
  background-position: center;
  transition: background-image .8s ease, filter .8s ease, transform 1.1s ease;
}
body.world-shop .world,
body.world-care .world {
  background-image: url("assets/bg/shop_inside.jpg");
}
body.entering .world {
  transform: scale(1.18);
  filter: brightness(1.15);
}

.home-btn {
  position: fixed;
  top: max(14px, env(safe-area-inset-top));
  left: max(14px, env(safe-area-inset-left));
  z-index: 8;
  border: 1px solid var(--line);
  background: var(--panel);
  color: var(--ink);
  border-radius: 999px;
  padding: 8px 14px;
  cursor: pointer;
  backdrop-filter: blur(8px);
}
.hud {
  position: fixed;
  top: max(14px, env(safe-area-inset-top));
  right: max(14px, env(safe-area-inset-right));
  z-index: 8;
  display: flex; gap: 8px; align-items: center;
  font-size: 12px; color: var(--muted);
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 999px;
  padding: 6px 10px;
  backdrop-filter: blur(8px);
}
.save-dot { color: #b7e4c7; }
.ghost {
  background: transparent; border: 1px solid var(--line); color: var(--ink);
  border-radius: 999px; padding: 4px 10px; cursor: pointer;
}

.panel {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 20px;
  backdrop-filter: blur(10px);
  box-shadow: 0 24px 50px rgba(0,0,0,.35);
  color: var(--ink);
}
.auth-panel {
  position: absolute;
  left: 50%;
  top: 54%;
  transform: translate(-50%, -50%);
  width: min(400px, calc(100vw - 32px));
  padding: 22px;
}
.shop-kicker {
  margin: 0 0 4px;
  letter-spacing: .18em;
  font-size: 11px;
  color: var(--gold);
}
.auth-panel h1, .main-panel h2 { margin: 0 0 6px; letter-spacing: -0.03em; }
.lead, .meta { color: var(--muted); font-size: 13px; line-height: 1.45; margin: 0 0 12px; }
.tabs { display: flex; gap: 6px; margin-bottom: 10px; }
.tab {
  flex: 1; border: 0; border-radius: 11px; padding: 9px;
  background: rgba(255,255,255,.08); color: var(--ink); cursor: pointer; font-weight: 700;
}
.tab.on { background: var(--gold); color: #1a120c; }
label { display: block; font-size: 12px; color: var(--muted); margin: 8px 0 5px; }
input[type="text"], input[type="password"] {
  width: 100%; border-radius: 12px; border: 1px solid var(--line);
  background: rgba(8,5,3,.55); color: var(--ink); padding: 11px 12px; outline: none;
}
.btn {
  border: 0; border-radius: 12px; padding: 11px 12px; cursor: pointer;
  background: #3a2a1c; color: var(--ink); font-weight: 700;
}
.btn.teal { background: var(--teal); }
.btn.gold { background: var(--gold); color: #1a120c; }
.btn.rose { background: var(--rose); }
.btn.danger { background: var(--danger); }
.auth-panel .btn { width: 100%; margin-top: 14px; }
.err { min-height: 18px; color: #ffb4a8; font-size: 13px; margin-top: 6px; }

.main-panel {
  position: absolute;
  inset: 64px 16px 16px;
  padding: 18px;
  overflow: auto;
}
.slots-head { display: flex; justify-content: space-between; gap: 12px; align-items: end; }
.grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(180px, 1fr));
  gap: 12px;
}
.slot {
  background: rgba(8,5,3,.45);
  border: 1px solid var(--line);
  border-radius: 16px;
  padding: 10px;
  display: flex; flex-direction: column; gap: 6px;
}
.slot img, .egg {
  width: 100%; height: 120px; object-fit: contain; border-radius: 12px;
  background: rgba(255,255,255,.06);
}
.egg { display: grid; place-items: center; font-size: 42px; }
.slot h3 { margin: 0; font-size: 15px; }
.row { display: flex; gap: 6px; }
.row .btn { flex: 1; padding: 8px; font-size: 12px; }

.care-layer {
  position: absolute;
  inset: 0;
  display: grid;
  place-items: center;
  padding: 72px 16px 16px;
}
.game-window {
  position: relative;
  width: var(--stage);
  height: var(--stage);
  aspect-ratio: 1 / 1;
  border-radius: 18px;
  overflow: hidden;
  border: 2px solid rgba(224,179,90,.5);
  box-shadow: 0 20px 60px rgba(0,0,0,.45), 0 0 0 8px rgba(18,12,8,.35);
}
.window-bg {
  position: absolute; inset: 0;
  background-size: cover;
  background-position: center;
  transform: scale(1.04);
}
.window-ui {
  position: relative;
  height: 100%;
  display: grid;
  grid-template-rows: auto 1fr auto auto auto;
  padding: 8px;
  background: linear-gradient(180deg, rgba(8,5,3,.35), rgba(8,5,3,.12) 30%, rgba(8,5,3,.55));
}
.win-top { display: flex; justify-content: space-between; gap: 8px; font-size: 11px; }
.win-top strong { font-size: 13px; }
.stage-art { display: grid; place-items: center; min-height: 0; }
.stage-art img { max-width: 72%; max-height: 100%; object-fit: contain; }
.stage-art .egg { width: 46%; height: 46%; background: rgba(255,255,255,.16); }
.xp { font-size: 10px; text-align: center; color: var(--muted); }
.stats { display: grid; gap: 3px; }
.stat { display: grid; grid-template-columns: 14px 1fr; gap: 4px; align-items: center; font-size: 10px; }
.bar { height: 6px; background: rgba(255,255,255,.16); border-radius: 99px; overflow: hidden; }
.bar > i { display: block; height: 100%; width: 0; background: #3d9b8f; transition: width .2s; }
.bar.happy > i { background: var(--gold); }
.bar.clean > i { background: #4d8ecb; }
.bar.energy > i { background: #8b6ad4; }
.actions { display: grid; grid-template-columns: repeat(5, 1fr); gap: 4px; }
.actions .btn { padding: 6px 0; font-size: 10px; }

.enter-fx {
  position: fixed; inset: 0; z-index: 20; pointer-events: none;
}
.enter-fx.go { animation: enterFlash 1.15s ease forwards; }
@keyframes enterFlash {
  0% { background: rgba(0,0,0,0); }
  35% { background: rgba(224,179,90,.28); }
  100% { background: rgba(0,0,0,0); }
}

.gacha {
  position: fixed; inset: 0; z-index: 25;
  display: grid; place-items: center;
  background: rgba(6,3,2,.55);
  backdrop-filter: blur(4px);
}
.gacha-card {
  width: min(420px, calc(100vw - 28px));
  text-align: center;
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 20px;
  padding: 18px;
}
.orb {
  width: 220px; height: 220px; margin: 10px auto;
  border-radius: 50%;
  background: radial-gradient(circle at 35% 30%, rgba(255,255,255,.45), rgba(224,179,90,.18) 45%, rgba(20,12,8,.8));
  border: 3px solid rgba(224,179,90,.55);
  display: grid; place-items: center;
  overflow: hidden;
  box-shadow: inset 0 0 30px rgba(224,179,90,.25), 0 10px 30px rgba(0,0,0,.4);
}
.orb-spin { font-size: 64px; animation: spinEgg .16s linear infinite; }
@keyframes spinEgg { to { transform: rotate(360deg) scale(1.05); } }
.gacha-hero { width: 78%; height: 78%; object-fit: contain; }
.gacha-name { min-height: 24px; color: var(--gold); font-weight: 700; }
.gacha-card .btn { width: 100%; }

.page-fade {
  position: fixed; inset: 0; z-index: 30; pointer-events: none;
  background: #070403;
  opacity: 0;
  transition: opacity .45s ease;
}
.page-fade.on { opacity: 1; }

.modal-bg {
  position: fixed; inset: 0; z-index: 40;
  background: rgba(0,0,0,.5);
  display: grid; place-items: center; padding: 16px;
}
.modal { max-width: 400px; width: 100%; padding: 18px; }
.modal h3 { margin: 0 0 8px; }
.modal p { color: var(--muted); }
.toast {
  position: fixed; left: 50%; bottom: 18px; transform: translateX(-50%);
  background: var(--navy); color: var(--ink); padding: 10px 14px;
  border-radius: 12px; border: 1px solid var(--line); z-index: 50;
}

.site-intro {
  position: fixed; top: 16px; left: 50%; z-index: 12;
  width: min(940px, calc(100vw - 32px)); transform: translateX(-50%);
  display: flex; align-items: center; gap: 16px; padding: 10px 14px;
  color: var(--ink); background: rgba(10, 6, 4, .66); border: 1px solid var(--line);
  border-radius: 14px; backdrop-filter: blur(10px);
}
.site-intro .brand { color: var(--gold); font-weight: 900; letter-spacing: .14em; text-decoration: none; }
.site-intro p { flex: 1; margin: 0; font-size: .82rem; color: var(--muted); }
.play-link { color: var(--ink); font-weight: 700; white-space: nowrap; }

@media (max-width: 720px) {
  :root { --stage: min(86vw, 62vh); }
  .hud span:not(#who):not(#saveDot) { display: none; }
  .main-panel { inset: 70px 10px 10px; padding: 12px; }
  .grid { grid-template-columns: 1fr 1fr; }
  .site-intro { top: 8px; gap: 10px; padding: 8px 10px; }
  .site-intro p { display: none; }
}
@media (max-height: 700px) {
  :root { --stage: min(38vw, 52vh); }
}
