* { box-sizing: border-box; margin: 0; padding: 0; }

:root {
  --t0: #8a97a8;
  --t1: #3b82f6;
  --t2: #a855f7;
  --t3: #f59e0b;
  --ink: #23304a;
  --card: #ffffff;
}

html, body { height: 100%; }
body {
  font-family: "Jua", "Segoe UI", "Malgun Gothic", system-ui, sans-serif;
  /* 폰트 미로딩(오프라인) 시에도 위 시스템 폰트로 자연스럽게 대체된다 */
  background: linear-gradient(180deg, #bfe3ff 0%, #dff3ff 45%, #e8f7dd 100%);
  color: var(--ink);
  padding: 10px;
}

/* ===== 화면 한 판에 담기 =====
 * 전에는 오른쪽 패널이 세로로 계속 자라 페이지가 화면 두 배 길이가 됐다.
 * 이제 화면 높이에 맞춰 두 열을 잡고, 넘치는 목록만 그 안에서 스크롤한다.
 * (좁은 화면에서는 아래 미디어 쿼리가 다시 한 줄 세로 배치로 되돌린다) */
.wrap {
  display: flex;
  gap: 12px;
  max-width: 1320px;
  height: calc(100dvh - 20px);
  margin: 0 auto;
  align-items: stretch;
}
.left {
  flex: 1;
  min-width: 0;
  display: flex;
  flex-direction: column;
}
.right {
  width: 340px;
  flex-shrink: 0;
  display: flex;
  flex-direction: column;
  gap: 8px;
  min-height: 0;
}
/* 위쪽 고정 카드는 줄어들지 않고, 탭 내용만 남는 높이를 먹고 스크롤한다 */
.right .fixed { flex: 0 0 auto; }
.tabbody {
  flex: 1;
  min-height: 0;
  overflow-y: auto;
  overscroll-behavior: contain;
}

/* ===== 상단 ===== */
.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 8px;
}
.topbar h1 { font-size: 25px; letter-spacing: -0.5px; }
.top-right { display: flex; gap: 8px; align-items: center; }
.record {
  background: #fff7d6;
  border: 2px solid #f2cf5b;
  border-radius: 999px;
  padding: 4px 12px;
  font-size: 13px;
  white-space: nowrap;
}
.record.shard { background: #efe6ff; border-color: #c4a8f0; }
#metaBtn {
  border: none;
  border-radius: 999px;
  padding: 6px 14px;
  font-weight: 800;
  font-size: 13px;
  color: #fff;
  cursor: pointer;
  background: linear-gradient(180deg, #9d7bff, #6d43e8);
  box-shadow: 0 2px 0 #4d2bb0;
  font-family: inherit;
}
#metaBtn:active { transform: translateY(2px); box-shadow: none; }

/* ===== 성 체력바 (잔상 포함) ===== */
.castlebar-wrap { margin-bottom: 8px; }
.castlebar-label {
  font-weight: 700;
  font-size: 14px;
  margin-bottom: 3px;
  display: flex;
  justify-content: space-between;
}
.castlebar {
  position: relative;
  height: 20px;
  background: #d9e2ec;
  border-radius: 999px;
  overflow: hidden;
  border: 2px solid #b8c4d0;
}
#castleFill, #castleGhost {
  position: absolute;
  inset: 0 auto 0 0;
  height: 100%;
  border-radius: 999px;
}
#castleFill {
  background: linear-gradient(90deg, #ff5d5d, #ff9d5d);
  transition: width 0.15s;
  z-index: 2;
}
#castleGhost {
  background: #ffd76e;
  transition: width 0.6s ease 0.3s;   /* 잃은 체력이 잔상으로 보인다 */
  z-index: 1;
}

/* ===== 전장 (3D) =====
 * 남는 세로 공간을 전부 전장이 먹는다 — 화면이 크면 전장이 커지고,
 * 작으면 최소 높이(320px)까지만 줄어든 뒤 페이지가 스크롤된다. */
.stage {
  position: relative;
  border-radius: 16px;
  overflow: hidden;
  box-shadow: 0 8px 24px rgba(30, 60, 90, 0.25);
  flex: 1;
  min-height: 320px;
  /* 세로가 남는 화면에서 전장이 정사각형에 가까워지면 카메라가 좌우를 잘라 먹는다.
   * 왼쪽 열 폭(= wrap 폭 − 오른쪽 패널 340 − gap 12)의 1/1.6 을 높이 상한으로 둔다. */
  max-height: calc((min(100vw - 20px, 1320px) - 352px) / 1.6);
}
#scene3d {
  width: 100%;
  height: 100%;
  background: #bfe3ff;
}
/* 캔버스 위 손가락 제스처는 페이지 스크롤이 아니라 "용사 끌기"로 쓴다 */
#scene3d canvas { display: block; touch-action: none; }
/* 끌어서 옮기는 중 — 손 모양으로 "잡고 있다"를 알린다 */
#scene3d.dragging, #scene3d.dragging canvas { cursor: grabbing; }

#hitFlash {
  position: absolute;
  inset: 0;
  pointer-events: none;
  background: radial-gradient(ellipse at center, transparent 40%, rgba(255, 40, 40, 0.55) 100%);
  opacity: 0;
  z-index: 5;
}
#hitFlash.on { animation: hitflash 0.5s ease-out; }
@keyframes hitflash { 0% { opacity: 1; } 100% { opacity: 0; } }

#lowHpVignette {
  position: absolute;
  inset: 0;
  pointer-events: none;
  background: radial-gradient(ellipse at center, transparent 45%, rgba(255, 30, 30, 0.4) 100%);
  opacity: 0;
  transition: opacity 0.4s;
  z-index: 4;
}
#lowHpVignette.on { animation: lowhp 1s ease-in-out infinite; }
@keyframes lowhp { 0%, 100% { opacity: 0.25; } 50% { opacity: 0.75; } }

#bossBanner {
  position: absolute;
  top: 16%;
  left: 50%;
  transform: translateX(-50%);
  background: rgba(120, 10, 10, 0.88);
  color: #ffd93d;
  font-size: 26px;
  font-weight: 900;
  padding: 12px 34px;
  border-radius: 14px;
  border: 3px solid #ffd93d;
  z-index: 8;
  animation: bossin 0.4s cubic-bezier(0.2, 1.6, 0.4, 1);
  white-space: nowrap;
}
#bossBanner.mid {
  background: rgba(120, 60, 10, 0.88);
  border-color: #ffa040;
  color: #ffd9a0;
  font-size: 21px;
  padding: 9px 26px;
}
@keyframes bossin { from { transform: translateX(-50%) scale(0.3); opacity: 0; } }

/* 등장 예고 경고 배너 */
#bossWarnBanner {
  position: absolute;
  top: 28%;
  left: 50%;
  transform: translateX(-50%);
  background: rgba(30, 12, 12, 0.82);
  color: #ff9a3d;
  border: 2px dashed #ff9a3d;
  border-radius: 12px;
  font-size: 18px;
  font-weight: 900;
  padding: 8px 22px;
  z-index: 8;
  white-space: nowrap;
  animation: warnblink 0.65s ease-in-out infinite;
}
#bossWarnBanner.great {
  color: #ff5252;
  border-color: #ff5252;
  border-style: solid;
  font-size: 21px;
}
@keyframes warnblink { 0%, 100% { opacity: 1; } 50% { opacity: 0.35; } }

/* 보스 전투 분위기: 화면 가장자리 붉은 기운 */
#bossVignette {
  position: absolute;
  inset: 0;
  pointer-events: none;
  opacity: 0;
  transition: opacity 0.6s;
  z-index: 3;
  background: radial-gradient(ellipse at center, transparent 42%, rgba(120, 20, 40, 0.5) 100%);
}
.stage.boss-mid #bossVignette { opacity: 0.55; }
.stage.boss-great #bossVignette {
  opacity: 1;
  background: radial-gradient(ellipse at center, transparent 36%, rgba(150, 10, 10, 0.62) 100%);
  animation: bosspulse 1.7s ease-in-out infinite;
}
.stage.warning #bossVignette {
  opacity: 1;
  background: radial-gradient(ellipse at center, transparent 45%, rgba(255, 120, 0, 0.5) 100%);
  animation: warnblink 0.65s ease-in-out infinite;
}
@keyframes bosspulse { 0%, 100% { opacity: 0.7; } 50% { opacity: 1; } }

#comboChip {
  position: absolute;
  top: 10px;
  right: 12px;
  background: rgba(30, 34, 48, 0.82);
  color: #ffd0a0;
  font-weight: 800;
  font-size: 14px;
  padding: 6px 14px;
  border-radius: 999px;
  z-index: 6;
  white-space: nowrap;
  border: 1.5px solid rgba(255, 157, 61, 0.6);
}
/* 골드 배율이 붙으면 강조 */
#comboChip.boost {
  background: linear-gradient(180deg, #ff9d3d, #ff6a00);
  color: #fff;
  font-size: 15px;
  border-color: #ffd93d;
  box-shadow: 0 3px 12px rgba(255, 106, 0, 0.55);
}
#comboChip.pop { animation: combopop 0.35s cubic-bezier(0.2, 1.6, 0.4, 1); }
@keyframes combopop { 0% { transform: scale(1.5); } 100% { transform: scale(1); } }

#waveInfo {
  position: absolute;
  top: 10px;
  left: 50%;
  transform: translateX(-50%);
  background: rgba(20, 32, 50, 0.75);
  color: #fff;
  font-weight: 700;
  font-size: 14px;
  padding: 6px 16px;
  border-radius: 999px;
  z-index: 6;
}

#wavePreview {
  position: absolute;
  top: 10px;
  left: 50%;
  transform: translateX(-50%);
  display: flex;
  gap: 6px;
  align-items: center;
  background: rgba(255, 255, 255, 0.92);
  border: 2px solid #cdd6e2;
  padding: 5px 12px;
  border-radius: 999px;
  z-index: 6;
  font-size: 13px;
}
#wavePreview .wlabel { font-weight: 800; color: #4a5a74; font-size: 12px; margin-right: 2px; }
#wavePreview .wchip {
  background: #f2f6fa;
  border-radius: 999px;
  padding: 2px 8px;
  font-weight: 700;
}
#wavePreview .wchip.boss {
  background: #ffe3e3;
  border: 1.5px solid #ff8a8a;
  animation: lowhp 1.2s ease-in-out infinite;
}
#wavePreview .wchip.midboss {
  background: #fff0e0;
  border: 1.5px solid #ffb073;
}

#bossBar {
  position: absolute;
  top: 44px;
  left: 50%;
  transform: translateX(-50%);
  display: flex;
  align-items: center;
  gap: 8px;
  width: min(62%, 440px);
  background: rgba(40, 10, 10, 0.8);
  border: 2px solid #ff6a6a;
  border-radius: 999px;
  padding: 5px 14px;
  z-index: 6;
  font-size: 13px;
  font-weight: 800;
  color: #ffd9d9;
}
#bossBar.mid {
  border-color: #ffa040;
  background: rgba(45, 26, 8, 0.8);
  color: #ffdcb0;
  width: min(52%, 360px);
}
#bossBar.enraged { animation: warnblink 0.5s ease-in-out infinite; }
#bossBarName { white-space: nowrap; }
#bossBar .bossbar-track {
  flex: 1;
  height: 12px;
  background: rgba(255, 255, 255, 0.18);
  border-radius: 999px;
  overflow: hidden;
}
#bossBarFill {
  height: 100%;
  width: 100%;
  border-radius: 999px;
  background: linear-gradient(90deg, #ff5d5d, #c084fc);
  transition: width 0.2s;
}
#bossBar.mid #bossBarFill { background: linear-gradient(90deg, #ff8a3d, #ffc93d); }

.wave-btn {
  position: absolute;
  left: 50%;
  bottom: 18px;
  transform: translateX(-50%);
  font-size: 20px;
  font-weight: 800;
  padding: 12px 28px;
  border: none;
  border-radius: 999px;
  background: linear-gradient(180deg, #ffd93d, #ffb302);
  color: #5b3d00;
  cursor: pointer;
  box-shadow: 0 4px 0 #c98a00, 0 8px 18px rgba(0, 0, 0, 0.25);
  font-family: inherit;
  z-index: 6;
}
.wave-btn:hover { filter: brightness(1.06); }
.wave-btn:active { transform: translateX(-50%) translateY(3px); box-shadow: 0 1px 0 #c98a00; }

#coachChip {
  position: absolute;
  bottom: 76px;
  left: 50%;
  transform: translateX(-50%);
  background: rgba(255, 255, 255, 0.96);
  border: 2px solid #4da3ff;
  border-radius: 12px;
  padding: 10px 16px;
  font-size: 13px;
  line-height: 1.6;
  z-index: 7;
  width: min(92%, 520px);
  box-shadow: 0 6px 18px rgba(30, 60, 90, 0.3);
  animation: coachin 0.5s ease-out;
}
@keyframes coachin { from { opacity: 0; transform: translateX(-50%) translateY(10px); } }

#toasts {
  position: absolute;
  top: 46px;
  left: 50%;
  transform: translateX(-50%);
  display: flex;
  flex-direction: column;
  gap: 6px;
  align-items: center;
  pointer-events: none;
  width: 90%;
  /* 모달(z-index 50)보다 위. 문제창이 떠 있을 때 뜨는 안내가 제일 중요한데
     그동안 스크림 뒤에 깔려 아무에게도 안 보였다. */
  z-index: 60;
}
.toast {
  background: rgba(20, 32, 50, 0.85);
  color: #fff;
  padding: 7px 16px;
  border-radius: 999px;
  font-size: 14px;
  font-weight: 600;
  animation: toast-in 0.25s ease-out, toast-out 0.4s ease-in forwards;
  animation-delay: 0s, 2.2s;
  max-width: 100%;
}
.toast.good { background: rgba(22, 130, 60, 0.92); }
.toast.bad  { background: rgba(190, 40, 40, 0.92); }
@keyframes toast-in  { from { opacity: 0; transform: translateY(-8px); } }
@keyframes toast-out { to   { opacity: 0; transform: translateY(-8px); } }

/* ===== 전장 아래 줄 =====
 * 조작법 설명 두 문단이 늘 자리를 차지하던 걸 "❓ 조작법" 토글 안으로 넣었다. */
.under-row {
  margin-top: 8px;
  display: flex;
  align-items: center;
  gap: 10px;
  flex-wrap: wrap;
}
.helpbtn {
  margin-left: auto;
  border: 2px solid #cdd6e2;
  background: #f2f6fa;
  border-radius: 999px;
  padding: 4px 14px;
  cursor: pointer;
  font-weight: 700;
  font-size: 12px;
  color: #5a6a84;
}
.helpbtn.on { border-color: #2478e0; background: #e3f0ff; color: #1a5cb0; }
.helpbox {
  margin-top: 6px;
  background: #eef4fb;
  border: 1px solid #d5e2f2;
  border-radius: 10px;
  padding: 8px 12px;
  font-size: 12px;
  line-height: 1.7;
  color: #35507a;
}
.helpbox.hidden { display: none; }
.helpbox p + p { margin-top: 3px; }
.helpbox b {
  background: #fff;
  border: 1px solid #b8c9e0;
  border-bottom-width: 2px;
  border-radius: 4px;
  padding: 0 4px;
}
.difficulty {
  display: flex;
  gap: 6px;
  align-items: center;
}
.difficulty .dlabel { font-size: 13px; font-weight: 700; color: #4a5a74; }
.difficulty button {
  border: 2px solid #cdd6e2;
  background: #f2f6fa;
  border-radius: 999px;
  padding: 4px 12px;
  cursor: pointer;
  font-weight: 700;
  font-size: 12px;
  color: #5a6a84;
  font-family: inherit;
}
.difficulty button.on { border-color: #2478e0; background: #e3f0ff; color: #1a5cb0; }
.difficulty button:disabled { opacity: 0.55; cursor: not-allowed; }
.kbd {
  display: inline-block;
  background: #f2f6fa;
  border: 1px solid #cdd6e2;
  border-bottom-width: 2px;
  border-radius: 4px;
  padding: 0 4px;
  font-size: 10px;
  font-weight: 800;
  color: #5a6a84;
  margin-left: 3px;
}

/* ===== 카드 ===== */
.card {
  background: var(--card);
  border-radius: 14px;
  padding: 12px;
  box-shadow: 0 3px 10px rgba(30, 60, 90, 0.12);
}
.card h2 { font-size: 15px; margin-bottom: 8px; }
.card h2 .sub { font-size: 11px; font-weight: 500; color: #7a879c; margin-left: 4px; }

.card.fixed { padding: 9px 10px; }
.statrow {
  display: flex;
  align-items: center;
  gap: 10px;
  font-size: 15px;
}
.stat b { font-size: 17px; }
/* 학년 선택은 카드 하나를 통째로 쓸 만큼 중요하진 않다 — 통계 줄 밑에 붙인다 */
.gradebar {
  display: flex;
  align-items: center;
  gap: 7px;
  margin-top: 7px;
  padding-top: 7px;
  border-top: 1px dashed #e3e9f2;
}
.gradebar .glabel {
  font-size: 12px;
  font-weight: 800;
  color: #4a5a74;
  white-space: nowrap;
  cursor: help;
}

/* ===== 오른쪽 패널 탭 ===== */
.tabs { display: flex; gap: 6px; flex: 0 0 auto; }
.tabs button {
  flex: 1;
  position: relative;
  border: 2px solid #cdd6e2;
  border-bottom: none;
  background: #e9eff7;
  border-radius: 10px 10px 0 0;
  padding: 7px 0 8px;
  cursor: pointer;
  font-weight: 800;
  font-size: 13px;
  color: #5a6a84;
}
.tabs button.on {
  background: #fff;
  border-color: #2478e0;
  color: #1a5cb0;
  margin-bottom: -2px;
  padding-bottom: 10px;
}
.tabdot {
  position: absolute;
  top: 4px;
  right: 8px;
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: #ff5d5d;
}
.tabdot.hidden { display: none; }
.pane.hidden { display: none; }
/* 탭 바로 아래에 붙으므로 위쪽 모서리는 각지게 */
.tabbody .pane { border-radius: 0 0 14px 14px; }
.minibtns { margin-left: auto; display: flex; gap: 6px; }
.minibtns button {
  border: 1px solid #cdd6e2;
  background: #f2f6fa;
  border-radius: 8px;
  padding: 4px 8px;
  cursor: pointer;
  font-size: 12px;
  font-weight: 700;
  font-family: inherit;
  white-space: nowrap;
}
/* 꺼진 소리 버튼은 회색으로 눌린 듯이 */
.minibtns button.off {
  background: #e3e7ee;
  color: #98a3b4;
  border-color: #c3cbd8;
  text-decoration: line-through;
}

/* ===== 버튼 ===== */
button { font-family: inherit; }
.big {
  width: 100%;
  padding: 11px;
  font-size: 16px;
  font-weight: 800;
  border: none;
  border-radius: 10px;
  cursor: pointer;
  color: #fff;
}
.big.blue  { background: linear-gradient(180deg, #4da3ff, #2478e0); box-shadow: 0 3px 0 #1a5cb0; }
.big.amber { background: linear-gradient(180deg, #ffc24d, #ff9800); box-shadow: 0 3px 0 #c76a00; }
.big.green { background: linear-gradient(180deg, #7bc96f, #43a047); box-shadow: 0 3px 0 #2d7a31; margin-bottom: 8px; }
.big:active { transform: translateY(2px); box-shadow: none; }
.big:disabled { background: #c5cedb; box-shadow: none; cursor: not-allowed; }

/* ===== 학년 ===== */
.grades { display: flex; gap: 5px; flex: 1; }
.grades button {
  flex: 1;
  padding: 7px 0;
  border-radius: 8px;
  border: 2px solid #cdd6e2;
  background: #f2f6fa;
  cursor: pointer;
  font-weight: 700;
  font-size: 13px;
  color: #5a6a84;
}
.grades button.on { border-color: #2478e0; background: #e3f0ff; color: #1a5cb0; }

/* ===== 소환 공개 카드 / 등급 플래시 ===== */
#rarityFlash {
  position: absolute;
  inset: 0;
  pointer-events: none;
  opacity: 0;
  z-index: 7;
}
#rarityFlash.on { animation: rarityflash 0.9s ease-out; }
#rarityFlash.hero { background: radial-gradient(ellipse at center, rgba(168, 85, 247, 0.5) 0%, transparent 70%); }
#rarityFlash.legend { background: radial-gradient(ellipse at center, rgba(255, 217, 61, 0.62) 0%, transparent 72%); }
@keyframes rarityflash { 0% { opacity: 1; } 100% { opacity: 0; } }

.reveal {
  position: absolute;
  top: 34%;
  left: 50%;
  transform: translate(-50%, -50%);
  background: rgba(255, 255, 255, 0.97);
  border: 4px solid var(--t0);
  border-radius: 18px;
  padding: 14px 26px;
  text-align: center;
  z-index: 9;
  box-shadow: 0 10px 34px rgba(0, 0, 0, 0.4);
}
.reveal .rv-em { font-size: 52px; line-height: 1.1; }
.reveal .rv-tier { font-size: 14px; font-weight: 900; }
.reveal .rv-name { font-size: 18px; font-weight: 800; }
.reveal.t0 { border-color: var(--t0); }
.reveal.t1 { border-color: var(--t1); }
.reveal.t2 { border-color: var(--t2); box-shadow: 0 0 30px rgba(168, 85, 247, 0.75); }
.reveal.t3 {
  border-color: var(--t3);
  box-shadow: 0 0 44px rgba(255, 217, 61, 0.9);
  animation: legendglow 0.8s ease-in-out infinite alternate;
}
@keyframes legendglow {
  from { box-shadow: 0 0 30px rgba(255, 217, 61, 0.7); }
  to   { box-shadow: 0 0 60px rgba(255, 217, 61, 1); }
}
.reveal.pop { animation: revealpop 0.45s cubic-bezier(0.2, 1.7, 0.4, 1); }
.reveal.t3.pop { animation: revealpop 0.45s cubic-bezier(0.2, 1.7, 0.4, 1), legendglow 0.8s ease-in-out 0.45s infinite alternate; }
@keyframes revealpop {
  0%   { transform: translate(-50%, -50%) scale(0.2) rotate(-12deg); opacity: 0; }
  60%  { transform: translate(-50%, -50%) scale(1.14) rotate(3deg); opacity: 1; }
  100% { transform: translate(-50%, -50%) scale(1) rotate(0); }
}

/* ===== 벤치 ===== */
.benchhint {
  background: #e8ffe3;
  border: 2px dashed #45b02e;
  color: #2a7a1a;
  border-radius: 8px;
  text-align: center;
  font-size: 13px;
  font-weight: 700;
  padding: 6px;
  margin-top: 8px;
}
.bench {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 6px;
  margin-top: 8px;
  min-height: 40px;
}
.bench .empty-msg {
  grid-column: 1 / -1;
  color: #9aa7ba;
  font-size: 12px;
  text-align: center;
  padding: 8px 0;
}
.hcard {
  border: 2.5px solid var(--t0);
  border-radius: 10px;
  background: #fafcff;
  padding: 5px 2px 3px;
  text-align: center;
  cursor: pointer;
  user-select: none;
  transition: transform 0.08s;
}
.hcard:hover { transform: translateY(-2px); }
.hcard .em { font-size: 22px; line-height: 1.1; position: relative; }
.hcard .nm { font-size: 10px; font-weight: 700; }
.hcard .tr { font-size: 9px; font-weight: 800; }
/* 카드에 표시되는 사거리 */
.hcard .rg {
  font-size: 9.5px;
  font-weight: 800;
  border-radius: 4px;
  margin: 1px 3px;
  padding: 0 2px;
  color: #fff;
}
.hcard .rg.r1 { background: #e07a5f; }   /* 근접 */
.hcard .rg.r2 { background: #d9a13b; }   /* 중거리 */
.hcard .rg.r3 { background: #4f9e57; }   /* 장거리 */
.hcard .rg.r4 { background: #3b82f6; }   /* 초장거리 */
.hcard .bdgs {
  position: absolute;
  top: -2px;
  right: -6px;
  font-size: 9px;
  line-height: 1;
}
.hcard .bdg { display: block; }

/* ===== 상세 정보 툴팁 ===== */
#tooltip {
  position: fixed;
  z-index: 100;
  width: 268px;
  background: rgba(20, 28, 44, 0.96);
  color: #e8eefb;
  border: 1.5px solid #4a5a7a;
  border-radius: 12px;
  padding: 10px 12px;
  font-size: 11.5px;
  line-height: 1.6;
  pointer-events: none;
  box-shadow: 0 8px 24px rgba(0, 0, 0, 0.45);
}
#tooltip b { color: #ffd93d; }
.tt-head {
  display: flex;
  align-items: center;
  gap: 5px;
  font-size: 13px;
  font-weight: 800;
  margin-bottom: 6px;
}
.tt-head .tt-emoji { font-size: 18px; }
.tt-head .tt-name { flex: 1; }
.tt-head .tt-tier {
  font-size: 9.5px;
  font-weight: 800;
  color: #fff;
  border-radius: 999px;
  padding: 1px 7px;
}
.tt-head .tt-lv { font-size: 10px; color: #ffd93d; }
.tt-range { margin-bottom: 6px; }
.tt-rlabel {
  display: inline-block;
  font-size: 10px;
  font-weight: 800;
  color: #fff;
  border-radius: 4px;
  padding: 0 6px;
  margin-right: 5px;
}
.tt-rlabel.r1 { background: #e07a5f; }
.tt-rlabel.r2 { background: #d9a13b; }
.tt-rlabel.r3 { background: #4f9e57; }
.tt-rlabel.r4 { background: #3b82f6; }
.tt-rnum { font-size: 11px; color: #b8c6de; }
.tt-rbar {
  height: 5px;
  background: rgba(255, 255, 255, 0.14);
  border-radius: 999px;
  margin-top: 3px;
  overflow: hidden;
}
.tt-rfill { height: 100%; border-radius: 999px; }
.tt-rfill.r1 { background: #e07a5f; }
.tt-rfill.r2 { background: #d9a13b; }
.tt-rfill.r3 { background: #4f9e57; }
.tt-rfill.r4 { background: #3b82f6; }
.tt-rows { border-top: 1px solid rgba(255,255,255,0.12); padding-top: 5px; }
.tt-legend {
  margin-top: 5px;
  background: rgba(245, 158, 11, 0.18);
  border: 1px solid rgba(245, 158, 11, 0.5);
  border-radius: 7px;
  padding: 4px 7px;
  color: #ffd98a;
}
.tt-recipe {
  margin-top: 5px;
  background: rgba(168, 85, 247, 0.18);
  border: 1px solid rgba(168, 85, 247, 0.5);
  border-radius: 7px;
  padding: 4px 7px;
  color: #d8b4ff;
}
.tt-desc { margin-top: 5px; color: #9fb0cc; font-style: italic; }
.tt-foot {
  margin-top: 5px;
  padding-top: 4px;
  border-top: 1px solid rgba(255,255,255,0.12);
  font-size: 10px;
  color: #8496b4;
}
/* 용사 패널에서도 같은 마크업 재사용 */
#hpInfo #tooltip, #hpInfo .tt-head { color: var(--ink); }
#hpInfo .tt-head .tt-lv { color: #c98a00; }
#hpInfo b { color: #23304a; }
#hpInfo .tt-rnum { color: #6a7a94; }
#hpInfo .tt-rows { border-color: #e3e9f2; }
#hpInfo .tt-rbar { background: #e3e9f2; }
#hpInfo .tt-legend { background: #fff7e0; border-color: #f2cf5b; color: #8a6400; }
#hpInfo .tt-recipe { background: #f3ebff; border-color: #c4a8f0; color: #5b2fb8; }
#hpInfo .tt-desc { color: #7a879c; }
#hpInfo .tt-foot { color: #93a0b4; border-color: #e3e9f2; }
.hcard .lv { color: #c98a00; }
.hcard.t0 { border-color: var(--t0); } .hcard.t0 .tr { color: var(--t0); }
.hcard.t1 { border-color: var(--t1); } .hcard.t1 .tr { color: var(--t1); }
.hcard.t2 { border-color: var(--t2); } .hcard.t2 .tr { color: var(--t2); }
.hcard.t3 { border-color: var(--t3); box-shadow: 0 0 8px rgba(245, 158, 11, 0.55); animation: legendshine 2s ease-in-out infinite; }
.hcard.t3 .tr { color: var(--t3); }
@keyframes legendshine { 0%, 100% { box-shadow: 0 0 6px rgba(245, 158, 11, 0.4); } 50% { box-shadow: 0 0 14px rgba(245, 158, 11, 0.85); } }
.hcard.sel {
  outline: 3px solid #22c55e;
  outline-offset: 1px;
  background: #eaffea;
}

/* ===== 조합/성 관리 행 ===== */
.combine-row {
  display: flex;
  align-items: center;
  gap: 7px;
  padding: 5px 0;
  font-size: 13px;
  font-weight: 700;
}
.combine-row .cnt { color: #7a879c; font-weight: 600; font-size: 12px; }
.combine-row .cdesc { color: #93a0b4; font-weight: 500; font-size: 11px; flex: 1; }
.combine-row button {
  margin-left: auto;
  border: none;
  border-radius: 8px;
  padding: 6px 10px;
  font-size: 12px;
  font-weight: 800;
  color: #fff;
  cursor: pointer;
  background: linear-gradient(180deg, #7bc96f, #43a047);
  white-space: nowrap;
}
.combine-row button:disabled { background: #c5cedb; cursor: not-allowed; }
.tier-dot { width: 10px; height: 10px; border-radius: 50%; display: inline-block; flex-shrink: 0; }

.combine-sub {
  font-size: 12px;
  font-weight: 800;
  color: #4a5a74;
  margin: 8px 0 2px;
  padding-top: 6px;
  border-top: 1px dashed #e3e9f2;
}
.combine-sub:first-child { border-top: none; padding-top: 0; margin-top: 0; }
.combine-sub .cnt { font-weight: 500; font-size: 11px; }
.combine-empty { font-size: 11px; color: #9aa7ba; padding: 4px 0; }
.combine-row.recipe { font-size: 12px; gap: 4px; }
.combine-row .rarrow { color: #9aa7ba; font-weight: 400; }
.combine-row /* 재료 표시 — 예전엔 "없는 재료"를 가장 안 보이게 흐려 놨다.
   정작 알아야 하는 건 "무엇이 비었나"라서 강조를 뒤집었다. */
.ing {
  display: inline-flex;
  align-items: center;
  padding: 1px 4px;
  border-radius: 8px;
  border: 2px solid transparent;
}
.ing.have { border-color: #cfe0f5; background: #f2f8ff; }
.ing.lack {
  border: 2px dashed #f0a04a;
  background: #fff6ea;
  animation: ingpulse 1.6s ease-in-out infinite;
}
.ing .ingx { font-weight: 900; color: #e0761f; margin-left: 2px; }
@keyframes ingpulse {
  0%, 100% { border-color: #f0a04a; }
  50%      { border-color: #ffd9ae; }
}

/* 지금 바로 되는 조합 — 스크롤 없이 맨 위에서 착착 */
.combine-now {
  background: linear-gradient(180deg, #fffdf0, #fff8dc);
  border: 2px solid #ffd76a;
  border-radius: 12px;
  padding: 8px;
  margin-bottom: 10px;
}
.now-title { font-size: 13px; font-weight: 900; color: #8a6a12; margin-bottom: 6px; }
.now-btn {
  display: flex;
  align-items: center;
  gap: 6px;
  width: 100%;
  margin-bottom: 5px;
  padding: 7px 8px;
  border: 2px solid #ddd;
  border-radius: 10px;
  background: #fff;
  cursor: pointer;
  font-family: inherit;
  font-size: 13px;
  text-align: left;
}
.now-btn:last-child { margin-bottom: 0; }
.now-btn:hover { transform: translateY(-1px); box-shadow: 0 3px 8px rgba(0,0,0,0.12); }
.now-btn:active { transform: translateY(1px); box-shadow: none; }
.now-what { white-space: nowrap; }
.now-arrow { color: #9aa4b5; }
.now-res { font-weight: 900; flex: 1; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.now-cost { font-weight: 800; color: #7a6a3a; }

/* 재료가 모자란 줄에서 눌러 바로 행동 */
.combine-row button.need { background: #fff2e0; border-color: #f0b071; color: #8a5a12; }
.combine-row button.lack { opacity: 0.85; }
.combine-row.flash { animation: rowflash 1.4s ease-out; }
@keyframes rowflash {
  0%   { background: #fff3c4; box-shadow: 0 0 0 3px #ffd76a inset; }
  100% { background: transparent; box-shadow: none; }
}
.combine-row .ing.have { opacity: 1; filter: none; }
.combine-row .need { font-size: 10px; margin-left: auto; }
.combine-row .peek {
  cursor: help;
  border-bottom: 1.5px dotted #9aa7ba;
}
.combine-row .peek:hover { background: #fff7e0; border-radius: 4px; }
.tt-preview {
  background: #6d43e8;
  color: #fff;
  font-size: 9px;
  font-weight: 800;
  border-radius: 4px;
  padding: 1px 5px;
}
#tooltip.preview { border-color: #9d7bff; }
.combine-row.ready {
  background: #f4fff2;
  border-radius: 8px;
  padding: 5px 6px;
  animation: readyglow 1.6s ease-in-out infinite;
}
@keyframes readyglow {
  0%, 100% { box-shadow: 0 0 0 rgba(69, 176, 46, 0); }
  50% { box-shadow: 0 0 8px rgba(69, 176, 46, 0.45); }
}
.hcard.sp { background: #faf5ff; }
.hcard.sp .nm { color: #6d43e8; }
.ability.sp { background: #f3ebff; border-color: #c4a8f0; color: #5b2fb8; }

.movehint {
  background: #eaffea;
  border: 1.5px dashed #45b02e;
  border-radius: 8px;
  padding: 6px 9px;
  font-size: 11.5px;
  font-weight: 600;
  color: #2a7a1a;
  line-height: 1.5;
  margin-bottom: 8px;
}

/* ===== 용사 패널 ===== */
#hpInfo { font-size: 13px; line-height: 1.65; margin-bottom: 8px; }
#hpInfo .lv { color: #c98a00; font-weight: 800; }
#hpInfo .cdesc { color: #7a879c; }
.ability {
  margin-top: 4px;
  background: #fff7e0;
  border: 1.5px solid #f2cf5b;
  border-radius: 8px;
  padding: 5px 8px;
  font-size: 12px;
  color: #8a6400;
  font-weight: 700;
}
.rowbtns { display: flex; gap: 6px; }
.rowbtns button {
  flex: 1;
  padding: 8px;
  border: none;
  border-radius: 8px;
  font-weight: 700;
  cursor: pointer;
  font-size: 13px;
}
#recallBtn { background: #e3f0ff; color: #1a5cb0; }
#sellBtn { background: #ffe9e3; color: #c0392b; }
#overMetaBtn { background: #efe6ff; color: #5b2fb8; }
#shareBtn { background: #e3f0ff; color: #1a5cb0; }

/* ===== 모달 ===== */
.modal {
  position: fixed;
  inset: 0;
  background: rgba(15, 25, 45, 0.55);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 50;
  padding: 16px;
}
.modal.hidden { display: none; }
.modal-card {
  background: #fff;
  border-radius: 18px;
  padding: 22px;
  width: 430px;
  max-width: 100%;
  box-shadow: 0 20px 60px rgba(0, 0, 0, 0.35);
  text-align: center;
  animation: modalin 0.25s cubic-bezier(0.2, 1.4, 0.4, 1);
}
@keyframes modalin { from { transform: scale(0.85); opacity: 0; } }
.modal-card h2 { font-size: 20px; margin-bottom: 6px; }
.mgrade {
  display: inline-block;
  background: #e3f0ff;
  color: #1a5cb0;
  font-size: 12px;
  font-weight: 800;
  border-radius: 999px;
  padding: 3px 12px;
  margin-bottom: 12px;
}
.mproblem {
  /* 손글씨풍 Gaegu — 숫자·수식이 또렷하고 아이들 눈에 친근하다 */
  font-family: "Gaegu", "Jua", system-ui, sans-serif;
  font-size: 27px;
  font-weight: 800;
  line-height: 1.5;
  background: #f5f8fc;
  border-radius: 12px;
  padding: 18px 14px;
  margin-bottom: 14px;
  word-break: keep-all;
  white-space: pre-line;
}
/* 세로 분수 — 분자 위, 분모 아래, 가운데 가로줄.
   한 줄짜리 "3/6"은 15÷3÷6 으로 읽히기 쉬워서 아이가 헷갈린다. */
.frac {
  display: inline-flex;
  flex-direction: column;
  align-items: center;
  vertical-align: middle;
  margin: 0 0.14em;
  line-height: 1.05;
  font-size: 0.82em;
}
.frac b, .frac i {
  font-style: normal;
  font-weight: inherit;
  padding: 0 0.18em;
}
.frac i { border-top: 2px solid currentColor; }

.mrow { display: flex; gap: 8px; margin-bottom: 10px; justify-content: center; }
.mrow input {
  flex: 1;
  font-family: "Gaegu", "Jua", system-ui, sans-serif;
  font-size: 25px;
  font-weight: 700;
  padding: 10px 12px;
  border: 2px solid #cdd6e2;
  border-radius: 10px;
  text-align: center;
}
.mrow input:focus { outline: none; border-color: #2478e0; }
.mrow .big { width: auto; padding: 10px 20px; }
.mfeedback { min-height: 26px; font-size: 15px; font-weight: 800; margin-bottom: 6px; }
.mfeedback.ok { color: #16a34a; }
.mfeedback.no { color: #dc2626; }

.mhint {
  background: #fff7e0;
  border: 1.5px solid #f2cf5b;
  border-radius: 10px;
  padding: 8px 12px;
  font-size: 13px;
  font-weight: 700;
  color: #8a6400;
  margin-bottom: 8px;
  line-height: 1.5;
  animation: coachin 0.3s ease-out;
}
.hintbtn {
  border: 1.5px solid #f2cf5b;
  background: #fff7e0;
  color: #8a6400;
  border-radius: 8px;
  padding: 8px 14px;
  cursor: pointer;
  font-size: 13px;
  font-weight: 800;
}
.hintbtn:disabled { opacity: 0.5; cursor: not-allowed; }
#mNext, #mClose {
  border: 1px solid #cdd6e2;
  background: #f2f6fa;
  border-radius: 8px;
  padding: 8px 16px;
  cursor: pointer;
  font-size: 14px;
  font-weight: 700;
  color: #4a5a74;
}
#mNext { background: #e3f0ff; border-color: #9cc4ee; color: #1a5cb0; }

.modal-card.over h2 { font-size: 24px; }
#overStats {
  background: #f5f8fc;
  border-radius: 12px;
  padding: 14px;
  margin: 12px 0;
  font-size: 14px;
  line-height: 1.9;
  text-align: left;
}
.over-shards {
  font-size: 17px;
  font-weight: 900;
  color: #6d43e8;
  margin-bottom: 8px;
  animation: combopop 0.5s cubic-bezier(0.2, 1.6, 0.4, 1);
}
.over-msg { font-size: 13px; color: #6a7a94; margin-bottom: 10px; }
.modal-card.over .rowbtns { margin-bottom: 10px; }

/* ===== 별의 축복 ===== */
.meta-desc { font-size: 13px; color: #5a6a84; margin-bottom: 12px; line-height: 1.6; }
.meta-row {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 8px 6px;
  border-bottom: 1px solid #eef2f7;
  text-align: left;
}
.meta-row .memoji { font-size: 24px; }
.meta-row .minfo { flex: 1; font-size: 13px; line-height: 1.5; }
.meta-row .minfo .cnt { color: #7a879c; font-size: 12px; }
.meta-row .minfo .cdesc { color: #93a0b4; font-size: 11px; }
.meta-row button {
  border: none;
  border-radius: 8px;
  padding: 7px 12px;
  font-weight: 800;
  font-size: 13px;
  color: #fff;
  cursor: pointer;
  background: linear-gradient(180deg, #9d7bff, #6d43e8);
  white-space: nowrap;
}
.meta-row button:disabled { background: #c5cedb; cursor: not-allowed; }
#metaClose { margin-top: 12px; }

.hidden { display: none !important; }

/* ===== 좁은 화면 ===== */
@media (max-width: 920px) {
  .wrap { flex-direction: column; }
  .right { width: 100%; }
}

/* ===== 신화(4) 등급 ===== */
:root { --t4: #ff4d9d; }
.hcard.t4 {
  border-color: var(--t4);
  background: #fff0f8;
  box-shadow: 0 0 10px rgba(255, 77, 157, 0.6);
  animation: mythicshine 1.6s ease-in-out infinite;
}
.hcard.t4 .tr { color: var(--t4); }
@keyframes mythicshine {
  0%, 100% { box-shadow: 0 0 8px rgba(255, 77, 157, 0.5); }
  50% { box-shadow: 0 0 20px rgba(255, 77, 157, 1); }
}
.reveal.t4 {
  border-color: var(--t4);
  box-shadow: 0 0 50px rgba(255, 77, 157, 0.95);
  animation: mythicglow 0.7s ease-in-out infinite alternate;
}
@keyframes mythicglow {
  from { box-shadow: 0 0 32px rgba(255, 77, 157, 0.7); }
  to   { box-shadow: 0 0 68px rgba(255, 77, 157, 1); }
}
#rarityFlash.mythic { background: radial-gradient(ellipse at center, rgba(255, 77, 157, 0.68) 0%, transparent 74%); }
.prob.t4 { background: var(--t4); }

/* 신화 조합 섹션 */
.combine-sub.mythic { color: #c2185b; border-top-color: #ffc2dd; }
.combine-row.mythic { background: linear-gradient(90deg, #fff0f8, transparent); border-radius: 8px; }
.combine-row .found { color: #16a34a; font-weight: 900; }
.tt-mythic {
  margin-top: 5px;
  background: rgba(255, 77, 157, 0.18);
  border: 1px solid rgba(255, 77, 157, 0.6);
  border-radius: 7px;
  padding: 4px 7px;
  color: #ff9ecb;
}
#hpInfo .tt-mythic { background: #fff0f8; border-color: #ff9ecb; color: #c2185b; }

/* 조합 규칙 안내 */
.combine-rule {
  background: #eef4fb;
  border: 1px solid #d5e2f2;
  border-radius: 8px;
  padding: 6px 9px;
  font-size: 11px;
  line-height: 1.65;
  color: #35507a;
  margin-bottom: 6px;
}
.combine-rule b { color: #1a5cb0; }
/* 재료 등급 배지 */
.combine-row .ingt {
  display: inline-block;
  font-size: 8.5px;
  font-weight: 900;
  color: #fff;
  border-radius: 3px;
  padding: 0 3px;
  margin-left: 1px;
  vertical-align: super;
}

/* ===== 수학 난이도 / 제한 시간 =====
 * 조합이 셀수록 문제가 세진다 — 그 사실을 "누르기 전"과 "푸는 중" 모두에서 보이게 한다. */

/* 조합 목록의 난이도 미리보기 배지 */
.combine-row .mlv {
  font-size: 8.5px;
  font-weight: 900;
  color: #fff;
  border-radius: 5px;
  padding: 2px 5px;
  letter-spacing: -1px;
  white-space: nowrap;
  flex-shrink: 0;
  margin-left: auto;
}
.combine-row .mlv + button { margin-left: 6px; }

/* 문제창 상단 메타 줄 */
.mmeta {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  flex-wrap: wrap;
  margin-bottom: 8px;
}
.mdiff, .msteps, .mstreak {
  display: inline-block;
  font-size: 12px;
  font-weight: 800;
  color: #fff;
  border-radius: 999px;
  padding: 3px 11px;
  letter-spacing: -0.5px;
}
.mgrade { margin-bottom: 0; }
.msteps { background: #6d43e8; }
.mstreak {
  background: linear-gradient(90deg, #ff8a3d, #ff4d6d);
  animation: streakpulse 1.1s ease-in-out infinite;
}
@keyframes streakpulse {
  0%, 100% { transform: scale(1); }
  50% { transform: scale(1.08); }
}

/* 남은 시간 바 */
.mtimer {
  position: relative;
  height: 22px;
  border-radius: 999px;
  background: #e7edf5;
  overflow: hidden;
  margin-bottom: 12px;
}
#mTimerFill {
  position: absolute;
  inset: 0 auto 0 0;
  width: 100%;
  border-radius: 999px;
  background: linear-gradient(90deg, #5ac47a, #2fa8d8);
  transition: background 0.3s;
}
#mTimerText {
  position: relative;
  display: block;
  line-height: 22px;
  font-size: 12px;
  font-weight: 900;
  color: #23405f;
  text-shadow: 0 1px 0 rgba(255, 255, 255, 0.6);
}
.mtimer.warn #mTimerFill { background: linear-gradient(90deg, #ff7043, #e53935); }
.mtimer.warn {
  animation: timepanic 0.6s ease-in-out infinite;
}
.mtimer.warn #mTimerText { color: #fff; text-shadow: 0 1px 2px rgba(0, 0, 0, 0.45); }
@keyframes timepanic {
  0%, 100% { box-shadow: 0 0 0 rgba(229, 57, 53, 0); }
  50% { box-shadow: 0 0 12px rgba(229, 57, 53, 0.75); }
}

/* 새 문제가 뜰 때 한 번 튕겨 준다 */
.mproblem.pop { animation: probpop 0.32s cubic-bezier(0.2, 1.5, 0.4, 1); }
@keyframes probpop { from { transform: scale(0.9); opacity: 0.2; } }

/* 난이도별 문제창 분위기 — 고난도일수록 카드가 뜨거워진다 */
.modal-card.lv4 { box-shadow: 0 20px 60px rgba(0, 0, 0, 0.35), 0 0 0 3px #f59e0b; }
.modal-card.lv5 {
  box-shadow: 0 20px 60px rgba(0, 0, 0, 0.45), 0 0 0 3px #ff4d9d;
  animation: modalin 0.25s cubic-bezier(0.2, 1.4, 0.4, 1), mythicaura 1.8s ease-in-out infinite 0.25s;
}
@keyframes mythicaura {
  0%, 100% { box-shadow: 0 20px 60px rgba(0, 0, 0, 0.45), 0 0 0 3px #ff4d9d; }
  50% { box-shadow: 0 20px 70px rgba(255, 77, 157, 0.5), 0 0 0 5px #ff4d9d; }
}
.modal-card.lv5 .mproblem { background: #fff2f8; }

/* ===== 좁거나 낮은 화면 =====
 * 두 열이 들어갈 폭이 안 되거나 세로가 너무 짧으면, 한 줄로 쌓고 페이지 스크롤을 되살린다.
 * (전장은 다시 16:10 비율로 고정 — 낮은 화면에서 납작해지지 않게) */
@media (max-width: 1080px) {
  body { padding: 8px; }
  .wrap { flex-direction: column; height: auto; }
  .left { display: block; }
  .right { width: 100%; min-height: 0; }
  .stage { flex: none; min-height: 0; max-height: none; }
  #scene3d { height: auto; aspect-ratio: 16 / 10; }
  .tabbody { overflow: visible; }
}
/* 세로가 짧은 노트북: 두 열은 유지하고 전장만 더 납작하게 (넓은 건 안 잘린다) */
@media (min-width: 1081px) and (max-height: 660px) {
  .topbar { margin-bottom: 5px; }
  .topbar h1 { font-size: 20px; }
  .castlebar-wrap { margin-bottom: 5px; }
  .stage { min-height: 240px; }
  .under-row { margin-top: 5px; }
}
/* 아주 좁은 화면: 벤치를 3열로, 글자를 조금 줄인다 */
@media (max-width: 560px) {
  .topbar h1 { font-size: 20px; }
  .bench { grid-template-columns: repeat(3, 1fr); }
  .gradebar { flex-wrap: wrap; }
}


/* ===== 막간 이야기 ===== */
.modal-card.story {
  max-width: 460px;
  text-align: center;
  background: linear-gradient(180deg, #fffdf7, #fff6e6);
  border: 3px solid #e8d5a8;
}
.story-icon { font-size: 46px; line-height: 1; margin-bottom: 4px; }
.modal-card.story h2 { color: #6b5220; margin-bottom: 12px; }
.story-lines {
  text-align: left;
  background: #fffaf0;
  border-radius: 12px;
  padding: 16px 18px;
  margin-bottom: 14px;
  font-size: 16px;
  line-height: 1.75;
  color: #3a2e18;
  word-break: keep-all;
}
.story-gap { height: 10px; }
.story-off {
  display: block;
  margin: 8px auto 0;
  background: none;
  border: none;
  color: #a89878;
  font-family: inherit;
  font-size: 12px;
  text-decoration: underline;
  cursor: pointer;
}

/* ===== 전설·신화 탄생 연출 =====
   z-index 70 — 수학 모달(50)과 토스트(60) 위를 덮는다 */
#revealModal { z-index: 70; }
.reveal-card {
  position: relative;
  width: min(92vw, 380px);
  padding: 26px 20px 22px;
  border-radius: 22px;
  text-align: center;
  background: radial-gradient(circle at 50% 34%, #ffffff 0%, #f6f2ff 55%, #e9e2fb 100%);
  border: 4px solid var(--tier, #f59e0b);
  box-shadow: 0 0 44px var(--tier, #f59e0b), 0 16px 40px rgba(0, 0, 0, 0.35);
  overflow: hidden;
}
.reveal-card.pop { animation: revealpop 0.6s cubic-bezier(0.16, 1.4, 0.4, 1); }
@keyframes revealpop {
  0%   { transform: scale(0.55) rotate(-6deg); opacity: 0; }
  60%  { transform: scale(1.06) rotate(2deg); opacity: 1; }
  100% { transform: scale(1) rotate(0); }
}
/* 뒤에서 도는 빛줄기 — 이미지 없이 원뿔 그라디언트로 */
.reveal-rays {
  position: absolute;
  inset: -40%;
  background: conic-gradient(from 0deg,
    rgba(255,255,255,0) 0deg, rgba(255,255,255,0.55) 12deg, rgba(255,255,255,0) 26deg,
    rgba(255,255,255,0) 90deg, rgba(255,255,255,0.45) 102deg, rgba(255,255,255,0) 116deg,
    rgba(255,255,255,0) 180deg, rgba(255,255,255,0.5) 192deg, rgba(255,255,255,0) 206deg,
    rgba(255,255,255,0) 270deg, rgba(255,255,255,0.45) 282deg, rgba(255,255,255,0) 296deg);
  animation: rayspin 9s linear infinite;
  pointer-events: none;
}
@keyframes rayspin { to { transform: rotate(360deg); } }
.reveal-tier {
  position: relative;
  font-size: 15px;
  font-weight: 900;
  letter-spacing: 3px;
  margin-bottom: 4px;
}
.reveal-art {
  position: relative;
  height: 190px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 104px;
  line-height: 1;
}
.reveal-art img {
  height: 100%;
  filter: drop-shadow(0 6px 14px rgba(0, 0, 0, 0.3));
  animation: revealfloat 3s ease-in-out infinite;
}
@keyframes revealfloat {
  0%, 100% { transform: translateY(0); }
  50%      { transform: translateY(-7px); }
}
.reveal-name {
  position: relative;
  font-size: 27px;
  font-weight: 900;
  color: #26304a;
  margin-top: 2px;
}
.reveal-desc {
  position: relative;
  font-size: 14px;
  color: #4b5670;
  margin-top: 6px;
  line-height: 1.5;
  word-break: keep-all;
  min-height: 20px;
}
.reveal-hint { position: relative; margin-top: 12px; font-size: 12px; color: #8d94a8; }
.reveal-card.short .reveal-art { height: 130px; font-size: 76px; }
.reveal-card.short .reveal-hint { display: none; }


/* ===== 데모 모드 ===== */
#demoBtn.on { background: #ffe0e0; border-color: #ff8a8a; color: #a33; }
#demoBar {
  position: absolute;
  left: 50%;
  bottom: 12px;
  transform: translateX(-50%);
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 8px 12px;
  border-radius: 999px;
  background: rgba(20, 32, 50, 0.88);
  color: #fff;
  font-size: 14px;
  font-weight: 800;
  z-index: 9;
  box-shadow: 0 6px 18px rgba(0, 0, 0, 0.3);
  max-width: 92%;
}
#demoBar.hidden { display: none; }
#demoCaption { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
#demoCaption.pop { animation: demopop 0.35s cubic-bezier(0.2, 1.5, 0.4, 1); }
@keyframes demopop {
  0%   { transform: translateY(5px); opacity: 0.3; }
  100% { transform: translateY(0); opacity: 1; }
}
#demoExit {
  flex: none;
  padding: 4px 10px;
  border-radius: 999px;
  border: none;
  background: #ff7b7b;
  color: #fff;
  font-family: inherit;
  font-size: 12px;
  font-weight: 800;
  cursor: pointer;
}
/* 데모 중에는 화면 테두리가 살짝 빛나 "지금 내가 조작하는 게 아니다"를 알린다 */
body.demo-on #scene3d { box-shadow: inset 0 0 0 3px rgba(255, 123, 123, 0.55); }
