* { box-sizing: border-box; margin: 0; padding: 0; -webkit-tap-highlight-color: transparent; }
:root {
  --bg: #1a0f2e;
  --bg2: #251544;
  --panel: #2c1a52;
  --panel2: #34205f;
  --ink: #f3ecff;
  --sub: #b6a3e0;
  --accent: #b388ff;
  --accent2: #7c4dff;
  --gold: #ffd76a;
  --line: #4a3470;
  --good: #6affc0;
}
html, body { height: 100%; }
body {
  font-family: "SF Pro Display", -apple-system, BlinkMacSystemFont, "Segoe UI", system-ui, "Apple SD Gothic Neo", sans-serif;
  color: var(--ink);
  background:
    radial-gradient(900px 500px at 80% -10%, rgba(124,77,255,.35), transparent 60%),
    radial-gradient(700px 500px at 10% 110%, rgba(255,140,200,.18), transparent 55%),
    var(--bg);
  min-height: 100dvh;
  display: flex; flex-direction: column;
  user-select: none;
  overflow-x: hidden;
}

/* ── Topbar ── */
.topbar {
  position: sticky; top: 0; z-index: 30;
  height: 50px; display: flex; align-items: center; gap: 12px;
  padding: 0 14px;
  background: rgba(26,15,46,.72);
  backdrop-filter: blur(14px); -webkit-backdrop-filter: blur(14px);
  border-bottom: 1px solid var(--line);
  font-size: 14px;
}
.topbar .back { color: var(--sub); }
.topbar .brand { font-weight: 700; letter-spacing: -.02em; }
.topbar .dex { margin-left: auto; color: var(--sub); font-size: 13px; }
.topbar .dex b { color: var(--gold); }

/* ── Stage ── */
#stage {
  flex: 1;
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 14px;
  padding: 16px;
  max-width: 920px; width: 100%; margin: 0 auto;
  align-items: stretch;
}
.panel {
  background: linear-gradient(180deg, var(--panel), var(--bg2));
  border: 1px solid var(--line);
  border-radius: 22px;
  padding: 16px;
  display: flex; flex-direction: column; align-items: center;
  box-shadow: 0 18px 40px rgba(0,0,0,.35), inset 0 1px 0 rgba(255,255,255,.05);
}

/* 마법사 */
.wizard-panel { justify-content: flex-start; }
#wizard {
  width: 100%; max-width: 300px; aspect-ratio: 1; height: auto;
  image-rendering: auto;
  filter: drop-shadow(0 14px 22px rgba(0,0,0,.45));
}
.potion-name {
  margin-top: 6px; font-size: 20px; font-weight: 800; letter-spacing: -.02em;
  text-align: center; min-height: 26px;
  background: linear-gradient(90deg, var(--accent), var(--gold));
  -webkit-background-clip: text; background-clip: text; color: transparent;
}
.potion-desc {
  margin-top: 6px; font-size: 13px; color: var(--sub); text-align: center;
  line-height: 1.5; max-width: 280px; min-height: 38px;
}

/* 가마솥 */
.cauldron-panel { justify-content: space-between; gap: 12px; }
.cauldron {
  position: relative; width: 100%; display: flex; flex-direction: column; align-items: center;
}
.slots {
  display: flex; gap: 10px; justify-content: center; margin-bottom: 6px; min-height: 58px;
}
.slot {
  width: 54px; height: 54px; border-radius: 16px;
  border: 2px dashed var(--line);
  display: grid; place-items: center; font-size: 30px;
  background: rgba(0,0,0,.18);
  transition: transform .15s, border-color .2s;
}
.slot.filled { border-style: solid; border-color: var(--accent); background: rgba(124,77,255,.18); }
.slot.pop { transform: scale(1.18); }
#brew { width: 100%; max-width: 220px; height: auto; }
.cauldron-actions { display: flex; gap: 10px; width: 100%; }
.btn {
  flex: 1; cursor: pointer; border: 1px solid var(--line);
  background: var(--panel2); color: var(--ink);
  padding: 12px 14px; border-radius: 14px; font-size: 15px; font-weight: 700;
  transition: transform .1s, filter .15s, background .15s;
}
.btn:active { transform: translateY(1px) scale(.98); }
.btn.primary { background: linear-gradient(180deg, var(--accent2), #5e2fd6); border-color: #6a3ce0; }
.btn.primary:hover { filter: brightness(1.08); }
.btn.small { flex: none; padding: 8px 14px; font-size: 13px; }
.btn.drink {
  width: 100%; margin-top: 4px;
  background: linear-gradient(180deg, #2fd6a6, #14a37a); border-color: #1fbd8c;
  animation: pulse 1.1s ease-in-out infinite;
}
@keyframes pulse { 0%,100%{ box-shadow:0 0 0 0 rgba(47,214,166,.5);} 50%{ box-shadow:0 0 0 10px rgba(47,214,166,0);} }
.hidden { display: none !important; }

/* ── Shelf ── */
.shelf {
  display: grid; grid-template-columns: repeat(auto-fill, minmax(74px, 1fr));
  gap: 10px; padding: 4px 16px 18px; max-width: 920px; width: 100%; margin: 0 auto;
}
.ing {
  cursor: pointer; border: 1px solid var(--line); border-radius: 16px;
  background: linear-gradient(180deg, var(--panel), var(--bg2));
  padding: 10px 4px 8px; text-align: center;
  transition: transform .1s, border-color .15s, background .15s;
}
.ing:active { transform: scale(.94); }
.ing:hover { border-color: var(--accent); }
.ing .e { font-size: 30px; display: block; line-height: 1; }
.ing .n { font-size: 12px; color: var(--sub); margin-top: 5px; display: block; }

.hint {
  text-align: center; color: var(--sub); font-size: 12px; padding-bottom: 18px;
}

/* ── FAB + Modal ── */
.fab {
  position: fixed; right: 16px; bottom: 16px; z-index: 25;
  width: 54px; height: 54px; border-radius: 50%; font-size: 24px; cursor: pointer;
  border: 1px solid var(--line); background: linear-gradient(180deg, var(--accent2), #5e2fd6);
  box-shadow: 0 10px 26px rgba(0,0,0,.4);
}
.modal {
  position: fixed; inset: 0; z-index: 40;
  background: rgba(10,5,20,.72); backdrop-filter: blur(6px);
  display: grid; place-items: center; padding: 16px;
}
.modal-card {
  width: 100%; max-width: 560px; max-height: 82dvh; overflow: hidden;
  background: linear-gradient(180deg, var(--panel), var(--bg2));
  border: 1px solid var(--line); border-radius: 22px; display: flex; flex-direction: column;
}
.modal-head { display: flex; align-items: center; padding: 16px 18px; border-bottom: 1px solid var(--line); }
.modal-head h2 { font-size: 19px; font-weight: 800; }
.modal-head .btn { margin-left: auto; }
.dex-grid {
  overflow-y: auto; padding: 14px; display: grid;
  grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); gap: 10px;
}
.dex-card {
  border: 1px solid var(--line); border-radius: 14px; padding: 12px;
  background: rgba(0,0,0,.18);
}
.dex-card.locked { opacity: .55; }
.dex-card .dn { font-size: 14px; font-weight: 700; }
.dex-card.locked .dn { color: var(--sub); }
.dex-card .dr { font-size: 11px; color: var(--sub); margin-top: 4px; line-height: 1.4; }
.dex-card .dd { font-size: 12px; color: var(--ink); margin-top: 6px; line-height: 1.45; }

/* ── Toast ── */
.toast {
  position: fixed; left: 50%; bottom: 86px; transform: translateX(-50%) translateY(10px);
  z-index: 50; padding: 12px 20px; border-radius: 999px;
  background: rgba(0,0,0,.82); border: 1px solid var(--line);
  font-size: 14px; font-weight: 700; color: var(--ink);
  opacity: 0; transition: opacity .25s, transform .25s; pointer-events: none;
  max-width: 90vw; text-align: center;
}
.toast.show { opacity: 1; transform: translateX(-50%) translateY(0); }
.toast.new { color: var(--gold); }

@media (max-width: 640px) {
  #stage { grid-template-columns: 1fr; }
  .wizard-panel { order: 1; }
  .cauldron-panel { order: 2; }
}
