/* ================= 메인 화면 ================= */
[hidden] { display: none !important; }

.home {
  --title-font: "Black Han Sans", "Apple SD Gothic Neo", sans-serif;
  position: relative; overflow: hidden;
  max-width: 480px; margin: 0 auto; min-height: 100vh; min-height: 100dvh;
  display: flex; flex-direction: column; align-items: center;
  padding: 10px 12px calc(14px + env(safe-area-inset-bottom));
  isolation: isolate;
}

/* ---- 배경 ---- */
.home-bg { position: absolute; inset: 0; z-index: -1; }
.castle { width: 100%; height: 100%; display: block; }
.vignette { position: absolute; inset: 0; background: radial-gradient(ellipse at 50% 42%, transparent 35%, rgba(8,6,20,.75) 100%); }
.torch { position: absolute; top: 47%; width: 54px; height: 70px; transform: translateY(-100%); }
.torch.left { left: 3%; } .torch.right { right: 3%; }
.torch span, .torch::before {
  content: ""; position: absolute; left: 50%; bottom: 0; width: 36px; height: 56px; translate: -50% 0;
  border-radius: 50% 50% 45% 45% / 70% 70% 30% 30%;
  background: radial-gradient(ellipse at 50% 80%, #fff6c0 0%, #ffb52e 40%, #ff5b1a 75%, transparent 76%);
  filter: blur(.5px) drop-shadow(0 0 14px #ff8a1f);
  animation: flame 0.9s ease-in-out infinite alternate;
  transform-origin: 50% 100%;
}
.torch::before { width: 22px; height: 40px; opacity: .8; animation-duration: .6s; animation-delay: -.3s; }
@keyframes flame { from { transform: scale(1, 1) skewX(-3deg); } to { transform: scale(.88, 1.12) skewX(4deg); } }

/* ---- 상단 HUD ---- */
.hud { width: 100%; display: flex; align-items: center; gap: 6px; }
.profile {
  flex: 1 1 auto; min-width: 0; display: flex; align-items: center; gap: 8px;
  background: linear-gradient(#2c3150, #1c1f36); border: 2px solid #4b5180; border-radius: 12px; padding: 4px 10px 4px 4px;
}
.avatar {
  width: 44px; height: 44px; flex: none; border-radius: 10px; display: grid; place-items: center; font-size: 28px;
  background: linear-gradient(#ffb36b, #e0763a); border: 3px solid #f5c04a; box-shadow: 0 2px 0 #8a5a12;
}
.profile-info { min-width: 0; flex: 1; }
.nick { font-weight: 800; font-size: 14px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.plv { display: flex; align-items: center; gap: 6px; font-size: 12px; font-weight: 700; color: #d6d2ea; }
.pbar { flex: 1; height: 7px; background: #0e1022; border-radius: 99px; overflow: hidden; min-width: 30px; }
.pbar i { display: block; height: 100%; width: 0; background: linear-gradient(#ffe46a, #f2b01e); border-radius: 99px; transition: width .4s; }

.currency {
  flex: none; display: flex; align-items: center; gap: 4px;
  background: #15172b; border: 2px solid #3b4066; border-radius: 99px; padding: 2px 3px 2px 2px; font-size: 13px;
}
.currency b { min-width: 22px; text-align: right; }
.coin-ico, .gem-ico { width: 24px; height: 24px; border-radius: 50%; display: grid; place-items: center; font-size: 13px; color: #8a5a0a; }
.coin-ico { background: radial-gradient(circle at 35% 35%, #fff2a0, #f5b81f 60%, #c47f0b); border: 2px solid #ffd85c; }
.gem-ico { background: none; color: #e15cff; font-size: 22px; text-shadow: 0 0 8px #d14bff; }
.plus {
  width: 22px; height: 22px; border-radius: 6px; border: 0; padding: 0; font-weight: 900; font-size: 16px; line-height: 1;
  background: linear-gradient(#6ee35a, #2e9d2a); color: #fff; box-shadow: 0 2px 0 #1c5f19;
}
.gear {
  flex: none; width: 40px; height: 40px; border-radius: 10px; border: 2px solid #4b5180; font-size: 22px;
  background: linear-gradient(#2c3150, #1c1f36); color: #e7e4f5;
}

/* ---- 로고 ---- */
.logo { margin-top: 14px; text-align: center; position: relative; }
.crown { font-size: 34px; line-height: 1; color: #ffd24a; text-shadow: 0 2px 0 #8a5a0a, 0 0 14px rgba(255,210,74,.6); }
.logo-title {
  margin: -2px 0 0; font-family: var(--title-font); font-weight: 400;
  font-size: clamp(38px, 11.5vw, 54px); letter-spacing: -1px; line-height: 1.05;
  background: linear-gradient(180deg, #fffbe0 0%, #ffe270 38%, #f2a51c 62%, #ffcf4a 100%);
  -webkit-background-clip: text; background-clip: text; color: transparent;
  -webkit-text-stroke: 2px #4a1d08;
  filter: drop-shadow(0 4px 0 #4a1d08) drop-shadow(0 6px 10px rgba(0,0,0,.6));
  transform: rotate(-3deg);
}
.ribbon {
  display: inline-block; margin-top: 6px; padding: 5px 18px; font-weight: 800; font-size: clamp(12px, 3.6vw, 15px);
  background: linear-gradient(#c52a3a, #8a1424); border: 2px solid #f0b94a; border-radius: 4px; color: #fff;
  box-shadow: 0 3px 0 #4f0b15; position: relative; transform: rotate(-1.5deg);
}
.ribbon span { color: #f5c04a; }

/* ---- 무기 쇼케이스 ---- */
.showcase { position: relative; width: 100%; height: clamp(230px, 66vw, 310px); margin-top: 4px; }
.rays {
  position: absolute; left: 50%; top: 58%; width: 520px; height: 520px; translate: -50% -50%;
  background: repeating-conic-gradient(from 0deg, rgba(255,226,140,.22) 0deg 6deg, transparent 6deg 18deg);
  mask: radial-gradient(circle, #000 0%, transparent 62%);
  -webkit-mask: radial-gradient(circle, #000 0%, transparent 62%);
  animation: spin 40s linear infinite;
}
.rays::after {
  content: ""; position: absolute; inset: 35%; border-radius: 50%;
  background: radial-gradient(circle, rgba(255,240,190,.75), rgba(255,190,80,.25) 45%, transparent 70%);
}
@keyframes spin { to { transform: rotate(360deg); } }

.bolts { position: absolute; inset: 0; width: 100%; height: 100%; pointer-events: none; z-index: 2; }
.bolts polyline { fill: none; stroke-width: 2.5; stroke-linejoin: round; }
.bolt-blue polyline { stroke: #bdf0ff; filter: drop-shadow(0 0 4px #39b6ff) drop-shadow(0 0 8px #39b6ff); }
.bolt-purple polyline { stroke: #f2d6ff; filter: drop-shadow(0 0 4px #b44bff) drop-shadow(0 0 8px #b44bff); }
.bolt-blue { animation: zap 2.2s steps(1) infinite; }
.bolt-purple { animation: zap 2.6s steps(1) infinite .7s; }
@keyframes zap { 0%, 18%, 40%, 100% { opacity: 1; } 10%, 30%, 60%, 80% { opacity: 0; } }

.weapon-pick {
  position: absolute; bottom: 0; border: 0; background: none; padding: 0; z-index: 1;
  transition: transform .25s, filter .25s; transform-origin: 50% 95%;
}
.weapon-pick svg { height: clamp(220px, 64vw, 300px); width: auto; display: block; }
.weapon-pick.sword { left: calc(50% - 52px); transform: rotate(-32deg); z-index: 2; filter: drop-shadow(0 0 10px #3cb4ff) drop-shadow(0 0 22px rgba(60,180,255,.6)); }
.weapon-pick.club { left: calc(50% - 30px); transform: rotate(28deg); filter: drop-shadow(0 0 10px #b44bff) drop-shadow(0 0 22px rgba(180,75,255,.6)); }
.weapon-pick:not(.selected) { opacity: .72; }
.weapon-pick.selected.sword { transform: rotate(-32deg) scale(1.06); }
.weapon-pick.selected.club { transform: rotate(28deg) scale(1.06); }
.weapon-pick:hover { opacity: 1; }
.wtag {
  position: absolute; left: 50%; top: 42%; translate: -50% 0; rotate: var(--unrotate);
  font-family: var(--title-font); font-size: 22px; color: #fff; -webkit-text-stroke: 1px #1a1030;
  text-shadow: 0 2px 0 #1a1030, 0 0 10px rgba(0,0,0,.6); white-space: nowrap; pointer-events: none;
}
.sword .wtag { --unrotate: 32deg; }
.club .wtag { --unrotate: -28deg; }

/* ---- 레벨 패널 (돌 받침대) ---- */
.level-panel {
  position: relative; width: min(92%, 380px); margin-top: -14px; z-index: 3; text-align: center;
  padding: 10px 18px 12px;
  background: linear-gradient(#2a2840, #16152a);
  border: 3px solid #b88a3a; border-radius: 16px;
  box-shadow: 0 0 0 4px #3e3a5a, 0 0 0 7px #24223a, 0 10px 24px rgba(0,0,0,.6), inset 0 2px 0 rgba(255,255,255,.08);
}
.lp-title { font-weight: 800; font-size: 16px; color: #f4ecd6; display: flex; align-items: center; justify-content: center; gap: 8px; }
.laurel { color: #e5b34a; font-size: 20px; }
.laurel.flip { transform: scaleX(-1); display: inline-block; }
.lp-level { font-family: var(--title-font); display: flex; align-items: baseline; justify-content: center; gap: 8px; line-height: 1; margin-top: 4px; }
.lp-level .lv, .lp-level .max { font-size: 32px; color: #f2f0fa; text-shadow: 0 3px 0 #000; }
.lp-level b {
  font-weight: 400; font-size: 60px;
  background: linear-gradient(#fff6a8, #ffd21f 50%, #f29a10); -webkit-background-clip: text; background-clip: text; color: transparent;
  filter: drop-shadow(0 3px 0 #5a2c00);
}
.segs { display: grid; grid-template-columns: repeat(10, 1fr); gap: 4px; margin-top: 8px; padding: 4px; background: #0d0c1a; border-radius: 8px; }
.segs i { height: 12px; border-radius: 3px; background: #4a4862; }
.segs i.on { background: linear-gradient(#fff07a, #f5b81f); box-shadow: 0 0 6px rgba(255,210,60,.6); }
.segs i.part { background: linear-gradient(90deg, #f5b81f var(--p), #4a4862 var(--p)); }
.lp-weapon { margin-top: 6px; font-size: 13px; color: #b9b3d4; font-weight: 700; }

/* ---- 큰 버튼 3개 ---- */
.main-btns { width: 100%; display: grid; grid-template-columns: 1fr 1.7fr 1fr; gap: 8px; margin-top: 16px; align-items: stretch; }
.mbtn {
  position: relative; border: 3px solid rgba(255,255,255,.55); border-radius: 18px; padding: 10px 4px 12px;
  display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 2px;
  transition: transform .1s; min-height: 118px;
}
.mbtn:active { transform: translateY(3px); }
.mbtn .mico { font-size: 38px; line-height: 1; filter: drop-shadow(0 3px 0 rgba(0,0,0,.35)); }
.mbtn .mlabel { font-family: var(--title-font); font-size: clamp(24px, 7vw, 30px); color: #fff; -webkit-text-stroke: 1.5px #1a1030; text-shadow: 0 3px 0 #1a1030; white-space: nowrap; }
.mbtn.blue { background: linear-gradient(#5fb8ff, #1f6fe0 60%, #1450b8); box-shadow: 0 5px 0 #0c2f73, 0 0 0 3px #0c2f73; }
.mbtn.purple { background: linear-gradient(#d89aff, #9a3fe0 60%, #6c22b0); box-shadow: 0 5px 0 #3f0f6e, 0 0 0 3px #3f0f6e; }
.mbtn.gold {
  background: linear-gradient(#fff3a0, #ffcf2e 45%, #f29a10); box-shadow: 0 6px 0 #8a4a05, 0 0 0 3px #8a4a05, 0 0 26px rgba(255,200,60,.55);
  border-color: #fff8d0; animation: pulse 1.8s ease-in-out infinite;
}
.mbtn.gold .mico { font-size: 52px; }
.mbtn.gold .mlabel { font-size: clamp(30px, 9vw, 42px); }
@keyframes pulse { 50% { box-shadow: 0 6px 0 #8a4a05, 0 0 0 3px #8a4a05, 0 0 40px rgba(255,210,80,.85); } }

/* ---- 하단 메뉴 ---- */
.dock { width: 100%; display: grid; grid-template-columns: repeat(5, 1fr); gap: 6px; margin-top: auto; padding-top: 18px; }
.dock button {
  display: flex; flex-direction: column; align-items: center; gap: 2px; padding: 8px 0 6px;
  background: linear-gradient(#2f3354, #1b1d33); border: 2px solid #4b5180; border-radius: 12px;
  font-weight: 800; font-size: clamp(11px, 3.2vw, 14px); box-shadow: 0 3px 0 #0e1022;
}
.dock button span { font-size: 26px; line-height: 1.1; }

/* ---- 준비 중 알림 ---- */
.toast {
  position: fixed; left: 50%; bottom: 110px; translate: -50% 20px; opacity: 0; pointer-events: none;
  background: rgba(15,13,30,.92); border: 1px solid #4b5180; padding: 10px 16px; border-radius: 99px; font-weight: 700; font-size: 14px;
  transition: opacity .2s, translate .2s; z-index: 20; white-space: nowrap;
}
.toast.show { opacity: 1; translate: -50% 0; }

/* 강화 화면 뒤로 버튼 */
.back { border: 1px solid #45405a; background: var(--panel); color: var(--text); padding: 8px 12px; border-radius: 10px; font-weight: 700; }

@media (prefers-reduced-motion: reduce) {
  .rays, .bolt-blue, .bolt-purple, .mbtn.gold, .torch span, .torch::before { animation: none; }
}
