:root {
  --bg: #0b1033;
  --bg-glow: #2a1f6e;
  --text: #ffffff;
  --muted: #b9c0ff;
  --card: rgba(255, 255, 255, 0.08);
  --card-border: rgba(255, 255, 255, 0.16);
  --primary: #ffcc4d;
  --primary-dark: #e0a400;
  --primary-text: #3a2600;
  --good: #3ddc97;
  --bad: #ff6b81;
  --accent: #8a7bff;
  --radius: 20px;
}

* { box-sizing: border-box; }

html, body { margin: 0; }
html { -webkit-text-size-adjust: 100%; }

body {
  min-height: 100vh;
  /* 휴대폰·태블릿: 누를 때 회색 번쩍임 없이, 두 번 톡 눌러도 확대되지 않게, 끝까지 당겨도 새로 고침되지 않게 */
  -webkit-tap-highlight-color: transparent;
  touch-action: manipulation;
  overscroll-behavior-y: none;
  font-family: 'Jua', 'Malgun Gothic', 'Apple SD Gothic Neo', sans-serif;
  color: var(--text);
  background: radial-gradient(ellipse at top, var(--bg-glow) 0%, var(--bg) 65%) fixed, var(--bg);
  overflow-x: hidden;
}

/* 반짝이는 별 배경 */
.stars {
  position: fixed;
  inset: 0;
  pointer-events: none;
  background-image:
    radial-gradient(2px 2px at 20px 30px, #fff, transparent),
    radial-gradient(1.5px 1.5px at 90px 120px, #fff, transparent),
    radial-gradient(2px 2px at 150px 60px, #ffe9a8, transparent),
    radial-gradient(1px 1px at 60px 170px, #fff, transparent),
    radial-gradient(1.5px 1.5px at 180px 150px, #cfd8ff, transparent);
  background-size: 200px 200px;
  opacity: 0.7;
  animation: twinkle 4s ease-in-out infinite alternate;
}
.stars2 { background-size: 310px 310px; animation-delay: 2s; opacity: 0.4; }

@keyframes twinkle { from { opacity: 0.25; } to { opacity: 0.8; } }
@keyframes pop { from { opacity: 0; transform: translateY(12px); } to { opacity: 1; transform: none; } }
@keyframes float { 50% { transform: translateY(-12px); } }
@keyframes shake { 25% { transform: translateX(-6px); } 75% { transform: translateX(6px); } }

#app {
  position: relative;
  max-width: 960px;
  margin: 0 auto;
  /* 아이폰 노치·아래 막대, 화면 모서리에 가리지 않게 (홈 화면 앱으로 켜면 화면 끝까지 써요) */
  padding:
    max(24px, env(safe-area-inset-top)) max(16px, env(safe-area-inset-right))
    max(48px, env(safe-area-inset-bottom)) max(16px, env(safe-area-inset-left));
}

/* 그림을 길게 눌러도 저장 메뉴가 뜨거나 끌려가지 않게 */
img { -webkit-user-drag: none; -webkit-touch-callout: none; }
button { -webkit-touch-callout: none; -webkit-user-select: none; user-select: none; }

/* 새 버전 안내 띠 */
#update-bar {
  position: fixed; left: 50%; bottom: max(16px, env(safe-area-inset-bottom)); transform: translateX(-50%);
  z-index: 120; display: flex; align-items: center; gap: 8px; flex-wrap: wrap; justify-content: center;
  width: max-content; max-width: calc(100vw - 24px);
  padding: 10px 14px; border-radius: 999px;
  background: rgba(20, 16, 60, 0.96); border: 2px solid var(--primary); box-shadow: 0 6px 20px rgba(0, 0, 0, 0.4);
  animation: pop 0.35s ease;
}

.screen { animation: pop 0.35s ease; }

h1, h2, h3 { font-weight: normal; margin: 0; }
h3 { font-size: 1.25rem; margin-bottom: 12px; }

/* ---------- 버튼 ---------- */
.btn {
  font: inherit;
  font-size: 1.1rem;
  border: none;
  border-radius: 999px;
  padding: 12px 24px;
  cursor: pointer;
  color: var(--text);
  transition: transform 0.12s, box-shadow 0.12s, background 0.2s;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
}
.btn:active { transform: translateY(2px); }
.btn:disabled { opacity: 0.5; cursor: default; }
.btn-primary {
  background: var(--primary);
  color: var(--primary-text);
  box-shadow: 0 5px 0 var(--primary-dark);
}
.btn-primary:active { box-shadow: 0 2px 0 var(--primary-dark); }
.btn-ghost { background: var(--card); border: 2px solid var(--card-border); }
.btn-ghost:hover { background: rgba(255, 255, 255, 0.15); }
.btn-danger { background: rgba(255, 107, 129, 0.2); border: 2px solid var(--bad); }
.btn-big { font-size: 1.5rem; padding: 16px 40px; }
.btn-small { font-size: 0.95rem; padding: 8px 16px; }

/* ---------- 공통 ---------- */
.card {
  background: var(--card);
  border: 2px solid var(--card-border);
  border-radius: var(--radius);
  padding: 20px;
  margin-bottom: 16px;
  color: var(--text);
  font: inherit;
}
.card-title { font-size: 1.4rem; }
.card-sub { display: block; color: var(--muted); font-size: 0.95rem; margin-top: 4px; }
.guide { color: var(--muted); font-size: 1.15rem; margin: 0 0 16px; }

.topbar { display: flex; align-items: center; flex-wrap: wrap; gap: 12px; margin-bottom: 16px; }
.topbar h2 { flex: 1; font-size: 1.5rem; }

.status { display: flex; gap: 8px; }
.chip {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  background: rgba(0, 0, 0, 0.3);
  border: 2px solid var(--card-border);
  border-radius: 999px;
  padding: 4px 14px;
}
.exp { width: 60px; height: 8px; border-radius: 999px; background: rgba(255, 255, 255, 0.15); overflow: hidden; }
.exp span { display: block; height: 100%; background: var(--good); }

.menu { display: flex; flex-direction: column; align-items: center; gap: 14px; margin-top: 24px; }
.menu .row { justify-content: center; max-width: 900px; }
.row { display: flex; flex-wrap: wrap; gap: 12px; margin-top: 12px; }

/* ---------- 홈 ---------- */
.home { text-align: center; padding-top: 24px; }
.title {
  font-size: clamp(2.2rem, 8vw, 3.4rem);
  color: var(--primary);
  text-shadow: 0 4px 0 #b35c00, 0 0 24px rgba(255, 204, 77, 0.4);
}
.subtitle { color: var(--muted); font-size: 1.25rem; margin: 8px 0 12px; }

/* 레벨 심볼 */
.badge { display: inline-block; filter: drop-shadow(0 0 6px rgba(255, 210, 63, 0.6)); }
.badge.big { font-size: 1.8rem; }
.badge-title {
  display: flex;
  width: fit-content;
  margin: 0 auto;
  flex-wrap: wrap;
  align-items: center;
  justify-content: center;
  gap: 4px 10px;
  padding: 8px 18px;
  border-radius: 999px;
  background: rgba(0, 0, 0, 0.3);
  border: 2px solid var(--card-border);
}
.home-crew .hero { --w: min(250px, 62vw); margin: 18px 0 6px; }
.float { animation: float 3s ease-in-out infinite; }

/* ---------- 은하 / 행성 ---------- */
.grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(200px, 1fr)); gap: 16px; }
.galaxy-card {
  cursor: pointer;
  text-align: center;
  background: linear-gradient(160deg, rgba(138, 123, 255, 0.35), rgba(255, 255, 255, 0.05));
  transition: transform 0.15s;
}
.galaxy-card:hover { transform: translateY(-4px); }
.galaxy-icon { display: block; font-size: 3rem; margin-bottom: 8px; }

.planets { display: grid; grid-template-columns: repeat(auto-fill, minmax(160px, 1fr)); gap: 20px; }
.planet {
  font: inherit;
  color: var(--text);
  background: none;
  border: none;
  cursor: pointer;
  display: flex;
  flex-direction: column;
  align-items: center;
  padding: 8px;
  transition: transform 0.15s;
}
.planet:hover { transform: scale(1.06); }
.planet-ball {
  width: 110px;
  height: 110px;
  border-radius: 50%;
  background: radial-gradient(circle at 30% 30%, var(--c1), var(--c2));
  box-shadow: inset -12px -10px 0 rgba(0, 0, 0, 0.15), 0 0 30px color-mix(in srgb, var(--c2) 50%, transparent);
  position: relative;
  margin-bottom: 10px;
}
.planet-ball::after {
  content: '';
  position: absolute;
  left: -14px;
  right: -14px;
  top: 46%;
  height: 14px;
  border: 3px solid rgba(255, 255, 255, 0.55);
  border-radius: 50%;
  transform: rotate(-14deg);
}
/* 행성 그림이 있으면 색 공 대신 그림 (조금 크게, 고리 없이) */
.planet-ball.has-art { background: none; box-shadow: none; }
.planet-ball.has-art::after { display: none; }
.planet-art {
  position: absolute; left: -16%; top: -18%; width: 132%; pointer-events: none;
  filter: drop-shadow(0 0 16px color-mix(in srgb, var(--c1) 55%, transparent));
}
.planet-name { font-size: 1.25rem; }
.planet-monsters { font-size: 1.4rem; letter-spacing: 4px; margin-top: 2px; }
.planet-monsters img { width: 34px; margin: 0 2px; vertical-align: middle; }

/* ---------- 행성 필드 ---------- */
.field-screen { animation: none; } /* 필드는 매 프레임 움직여서 등장 애니메이션 없이 바로 보여줘요 */
.field {
  position: relative;
  height: clamp(380px, 70vh, 600px);
  border-radius: var(--radius);
  overflow: hidden;
  user-select: none;
  touch-action: manipulation;
  background:
    radial-gradient(circle at 15% 25%, rgba(255, 255, 255, 0.9) 0 2px, transparent 3px),
    radial-gradient(circle at 70% 15%, rgba(255, 255, 255, 0.8) 0 1.5px, transparent 2.5px),
    radial-gradient(circle at 85% 35%, var(--c1) 0 46px, transparent 47px),
    radial-gradient(circle at 35% 30%, rgba(255, 255, 255, 0.12) 0 22px, transparent 23px),
    linear-gradient(#0f1445, #2b2370 80%);
  border: 2px solid var(--card-border);
}
.world {
  position: absolute;
  inset: 0 auto 0 0;
  will-change: transform;
}
.ground {
  position: absolute;
  left: 0;
  right: 0;
  bottom: 0;
  height: 110px;
  background: linear-gradient(var(--c1), var(--c2));
  box-shadow: inset 0 10px 0 rgba(255, 255, 255, 0.25);
}
.crater {
  position: absolute;
  top: 34px;
  width: 90px;
  height: 22px;
  border-radius: 50%;
  background: rgba(0, 0, 0, 0.15);
  box-shadow: inset 0 4px 0 rgba(0, 0, 0, 0.12);
}
.rock { position: absolute; bottom: 100px; font-size: 1.8rem; opacity: 0.85; pointer-events: none; }
/* 행성 그림이 있을 때: 하늘(대원을 따라 천천히 움직여요), 땅·발판 무늬, 소품 */
.field.has-art { background: var(--sky) 0% 100% / cover no-repeat, #0f1445; }
.has-art .ground { background: var(--ground) 0 0 / auto 100% repeat-x; box-shadow: none; }
.has-art .platform { background: var(--ground) 0 0 / auto 64px repeat-x; }
.has-art .platform.step { background-size: auto 52px; }
.has-art .field-tip { padding: 3px 14px; border-radius: 999px; background: rgba(20, 16, 60, 0.6); color: #fff; }
.prop { position: absolute; bottom: 102px; transform: translateX(-50%); pointer-events: none; }
.prop.flip { transform: translateX(-50%) scaleX(-1); }
/* 2층부터의 층 바닥과 그 사이 발판. 윗면(bottom 값)이 대원 발 높이예요 */
.platform {
  position: absolute;
  height: 30px;
  transform: translateY(calc(100% - 6px));
  border-radius: 14px;
  background: linear-gradient(var(--c1), var(--c2));
  box-shadow: inset 0 7px 0 rgba(255, 255, 255, 0.3), 0 8px 0 rgba(0, 0, 0, 0.18);
  pointer-events: none;
}
.platform.step {
  height: 22px;
  border-radius: 999px;
  box-shadow: inset 0 6px 0 rgba(255, 255, 255, 0.35), 0 0 16px rgba(255, 255, 255, 0.35);
}
.floor-sign {
  position: absolute;
  padding: 1px 10px;
  border-radius: 8px;
  background: rgba(0, 0, 0, 0.4);
  color: #fff;
  font-size: 0.85rem;
  pointer-events: none;
}

.field-player, .field-monster {
  position: absolute;
  left: 0;
  bottom: 104px;
}
.field-player { z-index: 3; pointer-events: none; }
.field-player .hero { --w: 96px; display: block; }
.field-monster {
  font: inherit;
  color: var(--text);
  background: none;
  border: none;
  padding: 0;
  cursor: pointer;
  display: flex;
  flex-direction: column;
  align-items: center;
  z-index: 2;
}
.field-monster .monster-emoji { font-size: 64px; }
.field-monster .monster-img { width: 92px; }
.field-monster:hover .field-monster-body { filter: drop-shadow(0 0 10px #fff); }
.field-monster-body { display: block; transition: filter 0.2s; }

.field-hud {
  position: absolute;
  top: 12px;
  left: 12px;
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 6px 16px 6px 6px;
  border-radius: 999px;
  background: rgba(0, 0, 0, 0.45);
  z-index: 5;
}
.avatar { width: 48px; height: 48px; object-fit: contain; border-radius: 50%; background: #26357f; border: 2px solid #fff; }
.hud-level { display: flex; align-items: center; gap: 8px; }
.hud-gold { color: var(--primary); }
.field-title {
  position: absolute;
  top: 18px;
  left: 50%;
  transform: translateX(-50%);
  font-size: 1.3rem;
  background: rgba(0, 0, 0, 0.35);
  padding: 4px 18px;
  border-radius: 999px;
  z-index: 5;
  white-space: nowrap;
}
.field-menu {
  position: absolute;
  top: 12px;
  right: 12px;
  display: flex;
  flex-direction: column;
  gap: 8px;
  z-index: 5;
}
.field-menu button {
  position: relative;
  font: inherit;
  font-size: 1.15rem;
  width: 54px;
  padding: 3px 0 1px;
  border-radius: 16px;
  border: 2px solid var(--card-border);
  background: rgba(0, 0, 0, 0.45);
  color: #fff;
  cursor: pointer;
  display: flex;
  flex-direction: column;
  align-items: center;
}
.field-menu span { font-size: 0.72rem; }
.field-menu b { font-weight: normal; }
/* 화면이 낮으면 버튼이 점프 버튼을 덮지 않게 왼쪽으로 한 줄 더 놓아요 */
.field-menu { gap: 5px; bottom: 78px; flex-wrap: wrap-reverse; align-content: flex-start; }
.pad { position: absolute; bottom: 14px; display: flex; gap: 10px; z-index: 5; }
.pad-move { left: 14px; }
.pad-jump { right: 14px; }
.pad button {
  font: inherit;
  font-size: 1.5rem;
  width: 58px;
  height: 58px;
  border-radius: 50%;
  border: 2px solid rgba(255, 255, 255, 0.5);
  background: rgba(0, 0, 0, 0.35);
  color: #fff;
  cursor: pointer;
  touch-action: none;
}
.pad button:active { background: rgba(255, 255, 255, 0.3); }
.field-tip {
  position: absolute;
  bottom: 30px;
  left: 50%;
  transform: translateX(-50%);
  color: rgba(255, 255, 255, 0.8);
  font-size: 0.95rem;
  white-space: nowrap;
  z-index: 4;
  pointer-events: none;
}
.flash { position: absolute; inset: 0; background: #fff; opacity: 0; pointer-events: none; z-index: 9; }
.field.zooming .flash { animation: flash 0.65s ease-in forwards; }
.field.zooming .field-hud, .field.zooming .field-menu, .field.zooming .pad, .field.zooming .field-tip, .field.zooming .field-title { opacity: 0; transition: opacity 0.2s; }
@keyframes flash { 60% { opacity: 0; } 100% { opacity: 0.9; } }

/* ---------- 몬스터 북 ---------- */
.book-layout { display: grid; grid-template-columns: minmax(240px, 300px) 1fr; gap: 16px; align-items: start; }
.book-detail { text-align: center; }
.book-detail h3 { margin: 8px 0 0; font-size: 1.5rem; }
.book-portrait .monster-emoji { font-size: 110px; }
.book-portrait .monster-img { width: 140px; }
.unknown .monster-emoji, .unknown .monster-img { filter: brightness(0) opacity(0.45); }
.book-detail .swords { margin-top: 10px; }
.book-info { text-align: left; margin: 14px 0; display: grid; grid-template-columns: auto 1fr; gap: 6px 12px; }
.book-info dt { color: var(--primary); }
.book-info dd { margin: 0; color: var(--muted); }
.sell { display: flex; align-items: center; justify-content: center; gap: 14px; font-size: 1.2rem; margin-top: 10px; white-space: nowrap; }
.btn-sell { background: linear-gradient(#ff6b6b, #d63031); box-shadow: 0 5px 0 #8f1d1d; font-size: 1.15rem; padding: 10px 22px; white-space: nowrap; }
.tabs { display: flex; align-items: center; gap: 8px; margin-bottom: 14px; flex-wrap: wrap; }
.tab {
  font: inherit;
  color: var(--text);
  background: rgba(255, 255, 255, 0.1);
  border: none;
  border-radius: 999px;
  padding: 6px 18px;
  cursor: pointer;
}
.tab.on { background: var(--accent); }
.book-count { margin-left: auto; color: var(--muted); font-size: 1.1rem; }
.book-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(92px, 1fr)); gap: 10px; }
.book-cell {
  position: relative;
  aspect-ratio: 1;
  border-radius: 16px;
  border: 3px solid transparent;
  background: linear-gradient(160deg, #3f5bd6, #26357f);
  cursor: pointer;
  display: grid;
  place-items: center;
}
.book-cell.unknown { background: rgba(255, 255, 255, 0.08); }
.book-cell.selected { border-color: var(--primary); }
.book-cell .monster-emoji { font-size: 48px; }
.book-cell .monster-img { width: 64px; }
.book-cell .count {
  position: absolute;
  right: 6px;
  bottom: 2px;
  font-size: 1.3rem;
  color: #fff;
  text-shadow: 0 2px 0 #000;
}

/* ---------- 배틀: 위쪽 무대 ---------- */
.arena {
  position: relative;
  height: clamp(240px, 42vw, 340px);
  border-radius: var(--radius) var(--radius) 0 0;
  overflow: hidden;
  background:
    radial-gradient(circle at 58% 42%, rgba(255, 220, 140, 0.3) 0 28px, transparent 29px),
    linear-gradient(#1b1f5e, #3b2a7a 70%);
}
.arena::after { /* 행성 땅 */
  content: '';
  position: absolute;
  left: -10%;
  right: -10%;
  bottom: -60%;
  height: 90%;
  border-radius: 50%;
  background: radial-gradient(ellipse at top, var(--c1, #8a6bd8), var(--c2, #4a3590));
  box-shadow: inset 0 8px 0 rgba(255, 255, 255, 0.25);
}
/* 행성 그림이 있으면 그 행성의 하늘과 땅 무늬 (보스·반짝이·오답이 배틀은 하늘을 그대로 둬요) */
.arena.arena-normal.has-art { background: var(--sky) center 80% / cover no-repeat; }
.arena.has-art::after { background: var(--ground) center 0 / auto 130px repeat-x; box-shadow: none; }

.hud {
  position: absolute;
  top: 12px;
  left: 12px;
  right: 12px;
  display: flex;
  align-items: center;
  gap: 8px;
  z-index: 3;
}
.hp-bar { flex: 1; height: 18px; border-radius: 999px; background: rgba(0, 0, 0, 0.4); overflow: hidden; display: flex; }
.hp-fill { height: 100%; border-radius: 999px; transition: width 0.4s ease; }
.player-hp .hp-fill { background: linear-gradient(#5cf0a8, #22b06e); }
.monster-hp .hp-fill { background: linear-gradient(#ff8a8a, #e0344f); margin-left: auto; }
.q-count {
  width: 52px;
  height: 52px;
  border-radius: 50%;
  background: #1a1440;
  border: 3px solid rgba(255, 255, 255, 0.3);
  display: grid;
  place-items: center;
  font-size: 1.6rem;
  flex-shrink: 0;
}
.pause {
  font: inherit;
  font-size: 1.1rem;
  width: 40px;
  height: 40px;
  border-radius: 50%;
  border: 2px solid rgba(255, 255, 255, 0.4);
  background: rgba(0, 0, 0, 0.35);
  color: #fff;
  cursor: pointer;
  flex-shrink: 0;
}

.fighter {
  position: absolute;
  bottom: 14%;
  z-index: 2;
  display: flex;
  flex-direction: column;
  align-items: center;
}
.player-side { left: 16%; }
.player-side .hero { --w: clamp(100px, 17vw, 150px); }
.monster-side { right: 16%; }
.monster-side .monster-img { transform: scaleX(-1); } /* 오른쪽을 보는 그림을 뒤집어 대원 쪽을 보게 */
.monster-emoji { font-size: clamp(70px, 13vw, 110px); line-height: 1; filter: drop-shadow(0 6px 0 rgba(0, 0, 0, 0.25)); }
.monster-img { width: clamp(90px, 16vw, 140px); }
.fighter-name { background: rgba(0, 0, 0, 0.45); border-radius: 999px; padding: 2px 12px; margin-bottom: 4px; font-size: 0.95rem; }

.player-side.attack { animation: lunge-right 0.45s ease; }
.monster-side.attack { animation: lunge-left 0.45s ease; }
.fighter.hurt { animation: hurt 0.4s ease; }
.fighter.victory { animation: victory 0.8s ease-in-out infinite; }
.fighter.dizzy { animation: dizzy 1.2s ease-in-out infinite; }
.dizzy-stars { position: absolute; top: -10px; font-size: 1.8rem; animation: spin 1.2s linear infinite; }
@keyframes dizzy { 25% { transform: rotate(-10deg); } 75% { transform: rotate(10deg); } }
@keyframes spin { to { transform: rotate(360deg); } }

@keyframes lunge-right { 40% { transform: translateX(clamp(60px, 14vw, 140px)); } }
@keyframes lunge-left { 40% { transform: translateX(calc(-1 * clamp(60px, 14vw, 140px))); } }
@keyframes hurt {
  20%, 60% { transform: translateX(-8px); filter: brightness(2.2); }
  40%, 80% { transform: translateX(8px); }
}
@keyframes victory { 50% { transform: translateY(-16px); } }

.hit-fx {
  position: absolute;
  top: 20%;
  font-size: 3.5rem;
  pointer-events: none;
  animation: burst 0.7s ease forwards;
}
@keyframes burst {
  from { transform: scale(0.3); opacity: 1; }
  to { transform: scale(1.6); opacity: 0; }
}
.bubble {
  position: absolute;
  top: -36px;
  background: #fff;
  color: #333;
  border-radius: 12px;
  padding: 2px 10px;
  font-size: 1rem;
  animation: pop 0.2s ease;
}

.mark {
  position: absolute;
  left: 50%;
  top: 50%;
  transform: translate(-50%, -50%);
  font-size: clamp(70px, 14vw, 120px);
  z-index: 4;
  opacity: 0;
  pointer-events: none;
}
.mark.show { animation: mark 1s ease forwards; }
@keyframes mark {
  0% { opacity: 0; transform: translate(-50%, -50%) scale(0.3); }
  20%, 70% { opacity: 1; transform: translate(-50%, -50%) scale(1); }
  100% { opacity: 0; transform: translate(-50%, -50%) scale(1); }
}

.drops {
  position: absolute;
  right: 12px;
  top: 72px;
  display: flex;
  flex-direction: column;
  gap: 6px;
  z-index: 2;
}
.drop {
  display: flex;
  align-items: center;
  gap: 4px;
  font-size: 0.85rem;
  background: rgba(0, 0, 0, 0.35);
  border-radius: 999px;
  padding: 2px 10px 2px 6px;
}
/* 퍼펙트 도전 표시: 처음 틀리면 "퍼펙트 실패"로 바뀌고 사라져요 */
.perfect {
  position: absolute;
  left: 12px;
  top: 72px;
  z-index: 2;
  font-size: 0.85rem;
  color: var(--primary);
  background: rgba(0, 0, 0, 0.35);
  border: 1px solid rgba(255, 204, 77, 0.6);
  border-radius: 999px;
  padding: 2px 10px;
}
.perfect.lost { color: #ffb4c4; border-color: transparent; animation: perfect-lost 2s ease forwards; }
@keyframes perfect-lost { 0%, 60% { opacity: 1; } 100% { opacity: 0; } }

.intro {
  position: absolute;
  inset: 0;
  display: grid;
  place-items: center;
  font-size: clamp(2.2rem, 8vw, 4rem);
  color: #ff5a5a;
  text-shadow: 0 4px 0 #7a1020, 0 0 20px rgba(255, 90, 90, 0.6);
  z-index: 5;
  pointer-events: none;
  animation: intro 1.3s ease forwards;
}
@keyframes intro {
  0% { opacity: 0; transform: scale(2); }
  25%, 70% { opacity: 1; transform: scale(1); }
  100% { opacity: 0; transform: scale(1); }
}

/* ---------- 배틀: 아래쪽 문제 판 ---------- */
.quiz-panel {
  display: grid;
  grid-template-columns: 1fr minmax(220px, 320px);
  gap: 16px;
  padding: 20px;
  background: rgba(255, 255, 255, 0.07);
  border: 2px solid var(--card-border);
  border-top: none;
  border-radius: 0 0 var(--radius) var(--radius);
  min-height: 240px;
}
.q-area { text-align: center; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 10px; }
.q-type {
  display: inline-block;
  background: var(--accent);
  border-radius: 999px;
  padding: 4px 14px;
  font-size: 0.95rem;
}
.q-text { font-size: clamp(1.3rem, 4vw, 1.8rem); margin: 0; line-height: 1.4; word-break: keep-all; }
.q-hint { font-size: 1.3rem; margin: 0; }
.speaker { font-size: 1.2rem; }
.q-images {
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  gap: 6px 10px;
  font-size: clamp(2rem, 6vw, 2.8rem);
  max-width: 420px;
}
.q-images img { width: clamp(48px, 9vw, 72px); height: auto; }
.q-clock { width: clamp(110px, 22vw, 140px); height: auto; }

.a-area { display: flex; flex-direction: column; gap: 10px; justify-content: center; }
.choice {
  font: inherit;
  font-size: 1.3rem;
  text-align: left;
  color: #222;
  background: linear-gradient(#ffffff, #dfe3f0);
  border: 3px solid transparent;
  border-radius: 16px;
  padding: 12px 18px;
  cursor: pointer;
  box-shadow: 0 4px 0 #a9afc4;
  transition: transform 0.1s;
  word-break: keep-all;
}
.choice:hover:not(:disabled) { transform: translateY(-2px); }
.choice:disabled { cursor: default; }
.choice.correct { background: linear-gradient(#5cf0a8, #1fae6a); color: #fff; box-shadow: 0 4px 0 #13774a; }
.choice.wrong { background: linear-gradient(#ff8a8a, #e0344f); color: #fff; box-shadow: 0 4px 0 #8f1d30; animation: shake 0.3s; }

.short { display: flex; flex-direction: column; gap: 10px; }
.short input {
  font: inherit;
  font-size: 1.4rem;
  padding: 12px 18px;
  border-radius: 16px;
  border: 3px solid var(--card-border);
  background: rgba(255, 255, 255, 0.95);
  color: #222;
}
.short input:focus { outline: none; border-color: var(--primary); }
.short input.correct { border-color: var(--good); background: #e2fff1; }
.short input.wrong { border-color: var(--bad); background: #ffe6ea; animation: shake 0.3s; }

.feedback-box {
  padding: 12px 16px;
  border-radius: 14px;
  background: rgba(255, 107, 129, 0.15);
  border: 2px solid var(--bad);
  animation: pop 0.25s ease;
}
.feedback-box p { margin: 0 0 6px; }
.explain { color: var(--muted); }

/* ---------- 배틀 결과 ---------- */
.result-panel { grid-column: 1 / -1; text-align: center; animation: pop 0.35s ease; }
.result-badge { font-size: clamp(3rem, 10vw, 4.5rem); line-height: 1; margin-bottom: 12px; }
.win .result-badge { color: var(--primary); text-shadow: 0 5px 0 #b35c00, 0 0 24px rgba(255, 204, 77, 0.6); }
.lose .result-badge { color: #9aa3d9; text-shadow: 0 5px 0 #3a3f6e; }
.result-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
  gap: 16px;
  align-items: center;
}
.result-monster { display: flex; flex-direction: column; align-items: center; gap: 4px; font-size: 1.2rem; }
.result-monster .monster-emoji { font-size: 64px; }
.result-monster .monster-img { width: 90px; }
.result-stats p { margin: 0 0 8px; font-size: 1.15rem; }
.big { font-size: 1.8rem; color: var(--primary); }
.level-up { color: var(--good); }
.capture p { margin: 8px 0 0; }
.swords { display: flex; justify-content: center; flex-wrap: wrap; gap: 4px; font-size: 1.6rem; }
.sword { opacity: 0.2; filter: grayscale(1); }
.sword.on { opacity: 1; filter: none; }
.review { text-align: left; margin-top: 16px; padding: 14px 18px; border-radius: 14px; background: rgba(0, 0, 0, 0.2); }
.review ul { margin: 0; padding-left: 20px; line-height: 1.8; }
.review-answer { color: var(--good); }
.result-actions { display: flex; justify-content: center; flex-wrap: wrap; gap: 12px; margin-top: 18px; }

/* ---------- 설정 (문제 만들기·불러오기, 기록) ---------- */
.steps { margin: 0; padding-left: 22px; line-height: 1.9; font-size: 1.1rem; }
.types { width: 100%; border-collapse: collapse; }
.types th { text-align: left; white-space: nowrap; padding: 8px 12px 8px 0; color: var(--primary); vertical-align: top; font-weight: normal; }
.types td { padding: 8px 0; color: var(--muted); line-height: 1.5; }
.types tr + tr { border-top: 1px solid var(--card-border); }
.sets { list-style: none; margin: 0; padding: 0; }
.set-item { display: flex; align-items: center; justify-content: space-between; gap: 12px; padding: 10px 0; }
.set-item + .set-item { border-top: 1px solid var(--card-border); }
.places { list-style: none; margin: 6px 0 0; padding: 0; font-size: 14px; line-height: 1.8; color: var(--muted); }
.places b { color: var(--text, #fff); }
.new-planet { margin-left: 4px; padding: 1px 8px; border-radius: 999px; background: #4ade80; color: #10301c; font-size: 12px; font-weight: 700; }
.empty { color: var(--muted); }
.divider { margin: 18px 0 12px; border: 0; border-top: 1px solid rgba(255, 255, 255, 0.12); }
.notice { margin-top: 16px; padding: 14px 16px; border-radius: 14px; line-height: 1.6; }
.notice p { margin: 0 0 4px; }
.notice ul { margin: 4px 0 0; padding-left: 20px; color: var(--muted); }
.notice.good { background: rgba(61, 220, 151, 0.15); border: 2px solid var(--good); }
.notice.bad { background: rgba(255, 107, 129, 0.15); border: 2px solid var(--bad); }

@media (max-width: 640px) {
  .quiz-panel { grid-template-columns: 1fr; padding: 16px; }
  .topbar h2 { font-size: 1.2rem; }
  .btn-big { font-size: 1.3rem; padding: 14px 32px; }
  .drops { display: none; }
  .book-layout { grid-template-columns: 1fr; }
  .field-title { display: none; }
  .field-tip { display: none; }
}

/* ---------- 재미 요소 ---------- */
.row.center { justify-content: center; margin: 4px 0 12px; }
.dot, .field-menu .dot {
  display: inline-grid;
  place-items: center;
  min-width: 20px;
  height: 20px;
  padding: 0 5px;
  border-radius: 999px;
  background: var(--bad);
  color: #fff;
  font-size: 0.8rem;
  font-style: normal;
  margin-left: 4px;
}
.field-menu .dot { position: absolute; top: -6px; right: -6px; margin: 0; }

/* 몬스터 종류별 모습 */
.foe { position: relative; display: inline-block; }
.foe-shiny .monster-emoji, .foe-shiny .monster-img {
  filter: sepia(1) saturate(5) hue-rotate(-12deg) brightness(1.15) drop-shadow(0 0 10px gold);
}
.sparkles { position: absolute; top: -8px; right: -12px; font-size: 1.4rem; animation: twinkle 0.6s ease-in-out infinite alternate; }
.crown { position: absolute; top: -0.55em; left: 50%; transform: translateX(-50%); font-size: 0.45em; }
.foe-boss { font-size: 1.5em; }
.foe-boss .monster-emoji, .foe-boss .monster-img { filter: drop-shadow(0 0 14px rgba(255, 80, 80, 0.8)); }
.foe-wrong { opacity: 0.9; }
.kind-boss .monster-emoji { font-size: 96px; }
.kind-boss .monster-img { width: 124px; }
.kind-boss .crown { font-size: 40px; top: -30px; }
.field-monster.locked { filter: grayscale(0.9) brightness(0.7); }
.field-monster.locked .fighter-name { background: rgba(0, 0, 0, 0.7); }
.monster-side .foe-boss .monster-emoji { font-size: clamp(100px, 18vw, 150px); }
.monster-side .foe-boss .monster-img { width: clamp(130px, 24vw, 200px); }
.monster-side .foe-boss .crown { font-size: 2.6rem; top: -34px; }
.arena-boss { background: radial-gradient(circle at 70% 40%, rgba(255, 60, 60, 0.35), transparent 60%), linear-gradient(#2a1235, #4a1f4f 70%); }
.arena-wrong { background: linear-gradient(#141a3a, #2d2f5c 70%); }
.arena-shiny { background: radial-gradient(circle at 70% 40%, rgba(255, 215, 0, 0.35), transparent 60%), linear-gradient(#1b1f5e, #3b2a7a 70%); }
.shiny-text { color: var(--primary); font-size: 1.2rem; }

/* 동료 몬스터 */
.companion { position: absolute; left: 0; bottom: 104px; z-index: 2; pointer-events: none; }
.companion .monster-emoji { font-size: 42px; }
.companion .monster-img { width: 54px; }
.buddy-side { left: 4%; bottom: 12%; }
.buddy-side .monster-emoji { font-size: clamp(36px, 6vw, 52px); }
.buddy-side .monster-img { width: clamp(48px, 8vw, 70px); }
.buddy-side.attack { animation: lunge-right 0.5s ease; }
.home-crew { position: relative; display: inline-block; }
.home-buddy { position: absolute; right: -50px; bottom: 0; font-size: 1.2rem; animation-delay: 0.5s; }
.home-buddy .monster-emoji { font-size: 64px; }
.home-buddy .monster-img { width: 84px; }

/* 손맛: 흔들림, 필살기, 콤보, 데미지, 파티클 */
.arena.shake { animation: arena-shake 0.3s ease; }
@keyframes arena-shake {
  20% { transform: translate(-6px, 3px); }
  40% { transform: translate(6px, -3px); }
  60% { transform: translate(-4px, 2px); }
  80% { transform: translate(4px, -1px); }
}
.arena.special::before {
  content: '';
  position: absolute;
  inset: 0;
  z-index: 6;
  pointer-events: none;
  background: radial-gradient(circle, rgba(255, 240, 150, 0.9), rgba(255, 200, 0, 0.2) 60%, transparent);
  animation: special-flash 0.7s ease forwards;
}
@keyframes special-flash { from { opacity: 1; } to { opacity: 0; } }
.special-text {
  position: absolute;
  left: 50%;
  top: 38%;
  transform: translate(-50%, -50%);
  z-index: 7;
  white-space: nowrap;
  font-size: clamp(2rem, 7vw, 3.4rem);
  color: var(--primary);
  text-shadow: 0 4px 0 #b35c00, 0 0 20px rgba(255, 204, 77, 0.8);
  animation: special-pop 1.3s ease forwards;
  pointer-events: none;
}
@keyframes special-pop {
  0% { transform: translate(-50%, -50%) scale(0.3); opacity: 0; }
  20%, 75% { transform: translate(-50%, -50%) scale(1); opacity: 1; }
  100% { transform: translate(-50%, -80%) scale(1); opacity: 0; }
}
.combo {
  position: absolute;
  left: 50%;
  top: 72px;
  transform: translateX(-50%);
  z-index: 5;
  font-size: clamp(1.4rem, 4vw, 2rem);
  color: #7cf5ff;
  text-shadow: 0 3px 0 #1b5e8a, 0 0 14px rgba(124, 245, 255, 0.7);
  opacity: 0;
  pointer-events: none;
  white-space: nowrap;
}
.combo.show { animation: combo 1s ease forwards; }
@keyframes combo {
  0% { opacity: 0; transform: translateX(-50%) scale(1.8); }
  20%, 70% { opacity: 1; transform: translateX(-50%) scale(1); }
  100% { opacity: 0; transform: translateX(-50%) translateY(-14px); }
}
.dmg {
  position: absolute;
  top: -10px;
  font-size: 1.8rem;
  color: #ff5a6e;
  text-shadow: 0 3px 0 #fff;
  white-space: nowrap;
  animation: dmg 0.9s ease forwards;
  pointer-events: none;
  z-index: 5;
}
@keyframes dmg { from { transform: translateY(0); opacity: 1; } to { transform: translateY(-60px); opacity: 0; } }
.particle {
  position: absolute;
  top: 40%;
  left: 40%;
  font-size: 1.3rem;
  pointer-events: none;
  animation: particle 0.8s ease-out forwards;
  z-index: 5;
}
@keyframes particle {
  from { transform: translate(0, 0) scale(1); opacity: 1; }
  to { transform: translate(var(--dx), var(--dy)) scale(0.4); opacity: 0; }
}
.coin-rain {
  position: absolute;
  top: -40px;
  font-size: 1.8rem;
  z-index: 6;
  pointer-events: none;
  animation: coin-fall 1.2s ease-in forwards;
}
@keyframes coin-fall {
  0% { transform: translateY(0) rotate(0); opacity: 1; }
  100% { transform: translateY(380px) rotate(540deg); opacity: 0.2; }
}
.count-up { color: var(--primary); }

/* 보물상자 */
.chest-box { position: relative; margin-top: 16px; padding: 14px; border-radius: 16px; background: rgba(255, 204, 77, 0.12); border: 2px dashed var(--primary); }
.chest-box p { margin: 6px 0 0; }
.chest-hint { margin-top: 14px; }
.chest { font-size: 4rem; background: none; border: none; cursor: pointer; line-height: 1; animation: float 1.6s ease-in-out infinite; }
.chest.wiggle { animation: wiggle 0.3s ease; }
.chest.opened { animation: pop 0.4s ease; }
@keyframes wiggle { 25% { transform: rotate(-15deg) scale(1.1); } 75% { transform: rotate(15deg) scale(1.1); } }

/* 몬스터 북 반짝이 */
.shiny-badge { position: absolute; left: 6px; top: 4px; font-size: 0.85rem; color: var(--primary); text-shadow: 0 1px 0 #000; }

/* 오늘의 목표 */
.stamps { display: grid; grid-template-columns: repeat(7, 1fr); gap: 8px; margin-top: 12px; }
.stamp {
  aspect-ratio: 1;
  border-radius: 14px;
  border: 2px dashed var(--card-border);
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  font-size: 1.4rem;
  color: var(--muted);
}
.stamp small { font-size: 0.7rem; }
.stamp.on { border-style: solid; border-color: var(--primary); background: rgba(255, 204, 77, 0.15); color: var(--text); }
.goal-list { list-style: none; margin: 12px 0 0; padding: 0; }
.goal { display: flex; align-items: center; gap: 14px; padding: 12px 0; }
.goal + .goal { border-top: 1px solid var(--card-border); }
.goal.claimed { opacity: 0.6; }
.goal-text { flex: 1; }
.goal-bar { height: 10px; border-radius: 999px; background: rgba(255, 255, 255, 0.12); overflow: hidden; margin: 6px 0 2px; }
.goal-bar span { display: block; height: 100%; background: linear-gradient(90deg, var(--accent), var(--good)); }

/* 학습 리포트 */
.report-tiles { display: grid; grid-template-columns: repeat(4, 1fr); gap: 12px; margin-bottom: 16px; }
.report-tile { display: flex; flex-direction: column; align-items: center; gap: 2px; padding: 16px 8px; border-radius: var(--radius); background: var(--card); border: 2px solid var(--card-border); }
.report-tile b { font-size: 1.9rem; line-height: 1.2; }
.report-tile span { color: var(--muted); font-size: 0.95rem; }
.report-summary p { margin: 4px 0; }
.day-chart { display: flex; align-items: stretch; gap: 8px; height: 170px; margin-top: 14px; }
.day { flex: 1; display: flex; flex-direction: column; align-items: center; justify-content: flex-end; min-width: 0; }
.day-value { font-size: 0.9rem; min-height: 1.3em; }
.day-bar { width: min(100%, 36px); flex: 0 1 auto; max-height: calc(100% - 44px); background: var(--accent); border-radius: 4px 4px 0 0; }
.day-bar.none { height: 2px !important; background: var(--card-border); border-radius: 0; }
.day-label { margin-top: 6px; color: var(--muted); font-size: 0.9rem; }
.report-subject { margin-top: 16px; }
.report-subject h4 { margin: 0 0 4px; font-size: 1.15rem; }
.subject-rate { margin-left: 6px; color: var(--muted); font-size: 0.95rem; font-weight: normal; }
.unit-list { list-style: none; margin: 0; padding: 0; }
.unit-row { display: grid; grid-template-columns: 1fr auto; gap: 0 12px; align-items: center; padding: 10px 0; }
.unit-row + .unit-row { border-top: 1px solid var(--card-border); }
.unit-row .goal-bar, .unit-row > .card-sub { grid-column: 1 / -1; }
.unit-row.untried > .card-sub { grid-column: auto; margin-top: 0; }
.unit-row.untried .unit-name { color: var(--muted); }
.unit-row .goal-bar span { background: var(--accent); }
.unit-rate { font-weight: bold; }
.weak-tag { margin-left: 4px; padding: 1px 8px; border-radius: 999px; background: rgba(255, 204, 77, 0.18); border: 1px solid var(--primary); font-size: 0.8rem; white-space: nowrap; }
.hard-list { list-style: none; margin: 8px 0 0; padding: 0; }
.hard-q { padding: 12px 0; }
.hard-q + .hard-q { border-top: 1px solid var(--card-border); }
.hard-q p { margin: 4px 0; }
.hard-q .q-images { justify-content: flex-start; font-size: 1.4rem; gap: 2px 4px; margin: 6px 0; }
.hard-q .q-images img { width: 36px; }
.hard-q .q-clock { width: 90px; }
.hard-answer b { color: var(--good); }
.report-note { text-align: center; margin-bottom: 16px; }
@media (max-width: 640px) {
  .report-tiles { grid-template-columns: repeat(2, 1fr); }
}
.planet-crown { position: absolute; top: -18px; left: 50%; transform: translateX(-50%); font-size: 1.6rem; z-index: 1; }

/* 행성 잠금 · 단계 진행 */
.planet.locked { cursor: not-allowed; }
.planet.locked .planet-ball { filter: grayscale(0.9) brightness(0.55); }
.planet.locked .planet-name { color: var(--muted); }
.planet-lock { position: absolute; inset: 0; display: grid; place-items: center; font-size: 2.4rem; z-index: 1; }
.step-bar { width: 120px; height: 8px; border-radius: 999px; background: rgba(255, 255, 255, 0.15); overflow: hidden; margin-top: 6px; }
.step-bar span { display: block; height: 100%; background: linear-gradient(90deg, var(--primary), var(--good)); }
.field-monster.kind-normal .fighter-name { white-space: nowrap; }

/* 미션 */
.missions .tabs { justify-content: center; }
.missions .tab .dot { margin-left: 6px; }
.mission-now { text-align: center; padding: 18px; margin-top: 12px; border-radius: 18px; background: rgba(0, 0, 0, 0.25); border: 2px solid var(--card-border); }
.mission-now.ready { border-color: var(--primary); box-shadow: 0 0 18px rgba(255, 204, 77, 0.35); }
.mission-now h3 { margin: 6px 0 10px; font-size: 1.35rem; }
.mission-now .goal-bar { max-width: 360px; margin: 6px auto 2px; height: 14px; }
.rewards { display: flex; justify-content: center; align-items: center; flex-wrap: wrap; gap: 12px; margin: 14px 0; }
.reward { display: inline-flex; align-items: center; gap: 8px; padding: 6px 14px; border-radius: 14px; background: rgba(255, 255, 255, 0.08); font-size: 1.1rem; }
.reward.rare { background: linear-gradient(135deg, rgba(180, 140, 255, 0.3), rgba(255, 210, 63, 0.25)); border: 2px solid #b48cff; text-align: left; }
.reward.rare small { display: block; color: var(--muted); font-size: 0.85rem; }
.mission-next { opacity: 0.7; }
.rare-tag { color: #d6b8ff; }

/* 조합실 */
.craft .tab .dot, .craft-room .dot { margin-left: 6px; }
.craft-flow { display: flex; flex-wrap: wrap; justify-content: center; align-items: center; gap: 6px; margin: 0 0 8px; font-size: 1.1rem; }
.craft-flow span { padding: 4px 12px; border-radius: 999px; background: rgba(255, 255, 255, 0.1); }
.recipes { display: grid; grid-template-columns: repeat(auto-fill, minmax(210px, 1fr)); gap: 14px; }
.recipe {
  position: relative;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 6px;
  padding: 16px;
  border-radius: 18px;
  background: var(--card);
  border: 2px solid var(--card-border);
  text-align: center;
}
.recipe.ready { border-color: var(--primary); box-shadow: 0 0 16px rgba(255, 204, 77, 0.3); }
.recipe.hidden { opacity: 0.75; }
.recipe-result { min-height: 90px; display: grid; place-items: center; }
.recipe .mystery {
  display: grid;
  place-items: center;
  width: 76px;
  height: 76px;
  border-radius: 50%;
  border: 3px dashed var(--card-border);
  font-size: 2.4rem;
  color: var(--muted);
}
.needs { list-style: none; margin: 4px 0 6px; padding: 0; width: 100%; font-size: 0.95rem; }
.needs li { display: flex; align-items: center; gap: 6px; padding: 3px 8px; border-radius: 8px; color: var(--muted); }
.needs li b { margin-left: auto; }
.needs li.ok { color: var(--text); }
.needs li.ok b { color: var(--good); }
.tag.new { left: 8px; right: auto; background: #ff6b9a; }
.have-note { font-size: 0.95rem; color: var(--good); }
.craft-done { display: flex; align-items: center; gap: 14px; position: relative; }

/* 알림 */
/* 첫 플레이 팁: 고양이 대장 말풍선 + 눌러 볼 버튼 반짝임 */
.tip-layer {
  position: fixed; inset: 0; z-index: 200; display: flex; align-items: flex-end; justify-content: center;
  padding: 16px 16px max(24px, env(safe-area-inset-bottom)); background: rgba(8, 6, 32, 0.35);
  animation: tip-fade 0.25s ease-out;
}
.tip-bubble {
  display: flex; align-items: flex-end; gap: 12px; width: min(560px, 100%);
  animation: tip-pop 0.35s cubic-bezier(0.3, 1.4, 0.5, 1);
}
.tip-layer.tip-top { align-items: flex-start; padding-top: max(24px, env(safe-area-inset-top)); }
.tip-guide { flex: none; width: 96px; filter: drop-shadow(0 4px 8px rgba(0, 0, 0, 0.4)); animation: float 2.4s ease-in-out infinite; }
.tip-body {
  position: relative; flex: 1; margin-bottom: 26px; padding: 16px 18px 14px;
  background: #fffaf0; color: #3a2f4a; border: 3px solid #2c2433; border-radius: 22px;
  box-shadow: 0 8px 24px rgba(0, 0, 0, 0.35); font-size: 17px; line-height: 1.55;
}
.tip-body::before { /* 말풍선 꼬리 (고양이 쪽) */
  content: ''; position: absolute; left: -14px; bottom: 18px; width: 22px; height: 22px;
  background: #fffaf0; border-left: 3px solid #2c2433; border-bottom: 3px solid #2c2433; transform: rotate(45deg);
}
.tip-body p { margin: 0 0 10px; }
.tip-body b { color: #d9467a; }
.tip-ok { display: block; margin-left: auto; padding: 8px 22px; font-size: 16px; }
.tip-target { animation: tip-glow 1.1s ease-in-out infinite; }
@keyframes tip-glow {
  0%, 100% { filter: drop-shadow(0 0 0 rgba(255, 226, 92, 0)); }
  50% { filter: drop-shadow(0 0 10px rgba(255, 226, 92, 0.95)) drop-shadow(0 0 3px #fff3b0); }
}
@keyframes tip-fade { from { opacity: 0; } }
@keyframes tip-pop { from { opacity: 0; transform: translateY(24px) scale(0.92); } }
@media (max-width: 480px) {
  .tip-guide { width: 68px; }
  .tip-body { font-size: 15px; padding: 12px 14px 12px; }
}
#toasts { position: fixed; bottom: max(24px, env(safe-area-inset-bottom)); left: 50%; transform: translateX(-50%); z-index: 100; display: flex; flex-direction: column; gap: 8px; align-items: center; pointer-events: none; width: max-content; max-width: calc(100vw - 32px); }
.toast {
  background: rgba(20, 16, 60, 0.95);
  border: 2px solid var(--primary);
  border-radius: 999px;
  padding: 10px 20px;
  font-family: 'Jua', 'Malgun Gothic', sans-serif;
  color: #fff;
  animation: toast 2.8s ease forwards;
  text-align: center;
}
@keyframes toast {
  0% { opacity: 0; transform: translateY(-20px); }
  10%, 85% { opacity: 1; transform: none; }
  100% { opacity: 0; transform: translateY(-10px); }
}

/* ---------- 탐험대원 · 꾸미기 ---------- */
.hero { --w: 120px; position: relative; display: inline-block; width: var(--w); vertical-align: bottom; }
.hero-body { position: relative; z-index: 2; display: block; width: 100%; }
.hero-wing {
  position: absolute; z-index: 1; left: -21%; top: -16%; width: 66%;
  transform-origin: 87% 65%; animation: flap 1.4s ease-in-out infinite;
}
/* 날개마다 움직임이 달라요 */
/* 로켓은 앞쪽 위를 향하고, 불꽃이 몸 뒤쪽 아래로 나와요 */
.hero-wing.wing-jet { left: -15%; top: -6%; width: 44%; transform-origin: 50% 50%; animation: jet-rumble 0.18s linear infinite; }
.hero-wing.wing-fairy { animation: flutter 0.26s ease-in-out infinite; }
.hero-wing.wing-butterfly { animation: fold 1.9s ease-in-out infinite; }
.hero-wing.wing-sky { animation: drift 2.8s ease-in-out infinite; }
.hero-wing.wing-cotton { animation: squish 2.2s ease-in-out infinite; }
.hero-wing.wing-bat { animation: flap-sharp 0.9s cubic-bezier(0.5, 0, 0.2, 1) infinite; }
.hero-wing.wing-dragon { animation: flap-deep 1.2s ease-in-out infinite; }
.hero-wing.wing-gold { animation: flap-regal 2.8s ease-in-out infinite; }
.hero-wing.wing-starlight { animation: glimmer 3s ease-in-out infinite; }
.hero-wing.wing-phoenix { animation: blaze 0.7s ease-in-out infinite; }
.hero-wing.wing-wave { animation: surge 2s ease-in-out infinite; }
@keyframes flap { 50% { transform: rotate(-14deg); } }
@keyframes flutter { 50% { transform: rotate(-9deg) scaleX(0.92); } }
@keyframes fold { 50% { transform: scaleX(0.68); } }
@keyframes drift { 50% { transform: translate(-3%, -5%) rotate(-3deg); } }
@keyframes squish { 50% { transform: scale(1.08, 0.94); } }
@keyframes flap-sharp { 45% { transform: rotate(-24deg); } 60% { transform: rotate(4deg); } }
@keyframes flap-deep { 50% { transform: rotate(-22deg); } }
@keyframes flap-regal { 50% { transform: rotate(-6deg) scale(1.03); } }
@keyframes glimmer { 50% { transform: rotate(-8deg); filter: brightness(1.35); } }
@keyframes blaze { 50% { transform: scale(1.06, 0.96) skewX(-4deg); filter: brightness(1.15); } }
@keyframes surge { 50% { transform: skewX(-8deg) translateX(-3%); } }
@keyframes jet-rumble { 0%, 100% { transform: rotate(32deg); } 50% { transform: rotate(32deg) translate(-1%, 1.5%); } }
/* 불꽃 그림이 따로 있는 날개: 몸통 아래에 불꽃을 겹치고, 노즐 쪽 끝을 고정한 채 불꽃만 늘었다 줄었다 해요 */
.hero-wing.has-flame { display: block; }
.has-flame .wing-body { position: relative; display: block; width: 100%; }
.has-flame .wing-flame {
  position: absolute; left: 0; top: 0; width: 100%;
  transform-origin: var(--flame-origin, 60.6% 78.1%); /* 노즐 바로 아래 (660x780에서 x 400, y 609) */ animation: flame-flick 0.25s ease-in-out infinite;
}
@keyframes flame-flick { 0%, 100% { transform: scale(1.05, 1.4); } 50% { transform: scale(0.86, 0.6); } }
.hero-mark {
  position: absolute; z-index: 3; top: 52%; left: 24%;
  width: calc(var(--w) * 0.24); aspect-ratio: 1; transform: scaleX(var(--dir, 1));
  filter: drop-shadow(0 2px 0 rgba(0, 0, 0, 0.3));
}
.decor-icon { width: 1.4em; height: 1.4em; object-fit: contain; vertical-align: middle; }
.hero-aura {
  position: absolute; z-index: 0; inset: -20% -16% -6%; border-radius: 50%; pointer-events: none;
  background: radial-gradient(closest-side, var(--ac), transparent); opacity: 0.75;
  animation: aura-pulse 1.8s ease-in-out infinite;
}
/* 빛 모양 */
.hero-aura.glow-spin { background: none; opacity: 1; }
.hero-aura.glow-spin::before {
  content: ''; position: absolute; inset: 12%; border-radius: 50%; opacity: 0.6;
  background: conic-gradient(#ff6b6b, #ffd23f, #9cff8f, #7be0ff, #b48cff, #ff6b6b);
  filter: blur(calc(var(--w) * 0.1)); animation: aura-spin 4s linear infinite;
}
.hero-aura.glow-rays { background: radial-gradient(closest-side, var(--ac), transparent 70%); opacity: 0.8; animation: none; }
.hero-aura.glow-rays::before {
  content: ''; position: absolute; inset: -4%; border-radius: 50%;
  background: repeating-conic-gradient(var(--ac) 0 12deg, transparent 12deg 30deg);
  -webkit-mask: radial-gradient(closest-side, #000 40%, transparent); mask: radial-gradient(closest-side, #000 40%, transparent);
  animation: aura-spin 9s linear infinite;
}
.hero-aura.glow-ground {
  background: none; opacity: 0.9; transform-origin: 50% 100%;
  animation: aura-surge 1.5s ease-in-out infinite;
}
.hero-aura.glow-ground::before {
  content: ''; position: absolute; inset: 0;
  background: radial-gradient(ellipse 48% 68% at 50% 82%, var(--ac) 20%, transparent);
  -webkit-mask: linear-gradient(to top, transparent, #000 16%); mask: linear-gradient(to top, transparent, #000 16%);
}
.hero-aura.glow-ring { background: radial-gradient(closest-side, transparent 58%, var(--ac) 76%, transparent 100%); opacity: 0.85; }
.hero-aura.glow-flicker { animation: aura-flicker 1.3s steps(1) infinite; }
@keyframes aura-surge { 50% { transform: scaleY(1.14); } }
@keyframes aura-flicker { 0%, 100% { opacity: 0.35; } 12% { opacity: 1; } 20% { opacity: 0.3; } 28% { opacity: 0.9; } 40% { opacity: 0.4; } 72% { opacity: 0.95; } 80% { opacity: 0.35; } }
/* 입자는 빛과 따로, 몸 앞에 그려요 (빛의 투명도에 흐려지거나 몸·날개에 가려지지 않게) */
.hero-bits { position: absolute; z-index: 4; inset: -20% -16% -6%; pointer-events: none; }
.hero-bits i {
  position: absolute; bottom: 12%; left: var(--x, 50%); font-style: normal;
  width: calc(var(--w) * 0.15); opacity: 0;
  animation: aura-rise 2.2s ease-in infinite; animation-delay: calc(var(--i) * 0.45s);
}
.hero-bits i img { display: block; width: 100%; filter: drop-shadow(0 1px 2px rgba(0, 0, 0, 0.35)); }
/* 입자 움직임 */
.move-sway i { animation: aura-sway 2.8s ease-in-out infinite; animation-delay: calc(var(--i) * 0.56s); }
.move-fall i { bottom: auto; top: 4%; animation: aura-fall 2.6s linear infinite; animation-delay: calc(var(--i) * 0.52s); }
.move-orbit i {
  left: 50%; bottom: auto; top: 54%; margin: calc(var(--w) * -0.075) 0 0 calc(var(--w) * -0.075); opacity: 1;
  animation: aura-orbit 4.2s linear infinite; animation-delay: calc(var(--i) * -0.84s);
}
.move-burst i { width: calc(var(--w) * 0.18); bottom: 4%; animation: aura-burst 0.95s ease-out infinite; animation-delay: calc(var(--i) * 0.19s); }
.move-wobble i { animation: aura-wobble 3.2s ease-in-out infinite; animation-delay: calc(var(--i) * 0.64s); }
.move-flash i, .move-pop i { bottom: auto; }
.move-flash i { animation: aura-flash 1.5s steps(1) infinite; animation-delay: calc(var(--i) * 0.31s); }
.move-pop i { animation: aura-pop 1.9s ease-in-out infinite; animation-delay: calc(var(--i) * 0.38s); }
.move-flash i:nth-child(1), .move-pop i:nth-child(1) { left: 10%; top: 26%; }
.move-flash i:nth-child(2), .move-pop i:nth-child(2) { left: 72%; top: 8%; }
.move-flash i:nth-child(3), .move-pop i:nth-child(3) { left: 40%; top: 0%; }
.move-flash i:nth-child(4), .move-pop i:nth-child(4) { left: 86%; top: 46%; }
.move-flash i:nth-child(5), .move-pop i:nth-child(5) { left: 2%; top: 58%; }
@keyframes aura-sway {
  20% { opacity: 1; } 25% { transform: translate(calc(var(--w) * 0.08), calc(var(--w) * -0.2)) rotate(14deg); }
  50% { transform: translate(calc(var(--w) * -0.08), calc(var(--w) * -0.42)) rotate(-14deg); }
  75% { transform: translate(calc(var(--w) * 0.07), calc(var(--w) * -0.62)) rotate(12deg); opacity: 0.9; }
  100% { transform: translate(0, calc(var(--w) * -0.8)); opacity: 0; }
}
@keyframes aura-fall { 15% { opacity: 1; } 80% { opacity: 1; } 100% { transform: translateY(calc(var(--w) * 0.75)) rotate(200deg); opacity: 0; } }
@keyframes aura-orbit {
  from { transform: rotate(0deg) translateX(calc(var(--w) * 0.66)) rotate(0deg); }
  to { transform: rotate(360deg) translateX(calc(var(--w) * 0.66)) rotate(-360deg); }
}
@keyframes aura-burst { 10% { opacity: 1; } 100% { transform: translateY(calc(var(--w) * -0.6)) scale(0.35); opacity: 0; } }
@keyframes aura-wobble {
  15% { opacity: 0.95; } 33% { transform: translate(calc(var(--w) * 0.1), calc(var(--w) * -0.28)) scale(1.1); }
  66% { transform: translate(calc(var(--w) * -0.1), calc(var(--w) * -0.56)) scale(1.25); opacity: 0.95; }
  100% { transform: translate(0, calc(var(--w) * -0.85)) scale(1.4); opacity: 0; }
}
@keyframes aura-flash { 0%, 100% { opacity: 0; } 10% { opacity: 1; } 18% { opacity: 0; } 26% { opacity: 1; } 34% { opacity: 0; } }
@keyframes aura-pop { 0%, 100% { opacity: 0; transform: scale(0.2) rotate(-20deg); } 50% { opacity: 1; transform: scale(1.15) rotate(10deg); } }
@keyframes aura-pulse { 50% { transform: scale(1.08); opacity: 0.95; } }
@keyframes aura-spin { to { transform: rotate(360deg); } }
@keyframes aura-rise { 20% { opacity: 1; } 100% { transform: translateY(calc(var(--w) * -0.8)); opacity: 0; } }
.hero.mini { --w: 70px; }

.starters { display: flex; gap: 16px; justify-content: center; flex-wrap: wrap; margin: 26px 0 16px; }
.starter {
  display: flex; flex-direction: column; align-items: center; gap: 12px; cursor: pointer;
  padding: 34px 20px 16px; font: inherit; color: var(--text); transition: transform 0.15s;
}
.starter:hover { transform: translateY(-4px); border-color: var(--primary); }
.starter .hero { --w: 160px; }

/* ---------- 상점 · 보관함 ---------- */
.closet-preview { padding: 34px 0 8px; }
.closet-preview .hero { --w: 190px; }
.closet-action { margin-top: 12px; display: flex; flex-direction: column; align-items: center; gap: 6px; }
.closet-grid { grid-template-columns: repeat(auto-fill, minmax(112px, 1fr)); }
.closet-cell {
  aspect-ratio: auto; display: flex; flex-direction: column; align-items: center; justify-content: flex-end;
  gap: 4px; padding: 22px 6px 8px; overflow: hidden; font: inherit; color: var(--text);
}
.closet-cell .hero { margin-bottom: 4px; }
.closet-cell.equipped { border-color: #2fbf8a; }
.cell-name { font-size: 0.85rem; line-height: 1.2; text-align: center; }
.price { font-size: 0.85rem; color: #ffd23f; }
.tag { position: absolute; z-index: 4; top: 5px; right: 5px; font-size: 0.7rem; padding: 1px 7px; border-radius: 6px; background: #2fbf8a; color: #fff; }
.tag.on { background: var(--primary); color: #222; }
.item-cell { cursor: default; justify-content: center; padding-top: 14px; }
.item-icon { font-size: 2.4rem; line-height: 1; }
.tab-link { margin-left: auto; background: rgba(255, 210, 63, 0.2); }
.btn-buy { background: linear-gradient(#ff6b6b, #d63031); box-shadow: 0 5px 0 #8f1d1d; color: #fff; font-size: 1.2rem; padding: 10px 26px; }
.btn-buy:disabled { filter: grayscale(0.7); opacity: 0.7; }