/* ============================================================================
   TWIST TOWER — UI 스타일 (자가호스팅 폰트, 글래스모피즘, 네온 타이포)
   @font-face url 은 이 CSS 파일 기준 상대경로 (../vendor/fonts/)  — 감사 P2
============================================================================ */

@font-face {
  font-family: 'Giants-Inline';
  src: url('../vendor/fonts/Giants-Inline.ttf') format('truetype');
  font-style: normal;
  font-weight: 400;
  font-display: swap;
}

:root {
  --cyan: #35e6ff;
  --magenta: #ff45c8;
  --violet: #8a7bff;
  --gold: #ffcf5c;
  --danger: #ff2b57;
  --ink: #eaf2ff;
  --dim: #9aa8d6;
  --panel: rgba(20, 14, 46, 0.55);
  --panel-brd: rgba(140, 130, 255, 0.28);
  --hud-font: 'Giants-Inline', 'Segoe UI', system-ui, sans-serif;
  --display-font: 'Giants-Inline', system-ui, sans-serif;
}

* { margin: 0; padding: 0; box-sizing: border-box; }
html, body { width: 100%; height: 100%; overflow: hidden; background: #090418; }
body {
  font-synthesis: none;
  font-family: var(--hud-font);
  color: var(--ink);
  -webkit-user-select: none; user-select: none;
  -webkit-tap-highlight-color: transparent;
  touch-action: none;
}
#gl { position: fixed; inset: 0; width: 100%; height: 100%; display: block; }

.layer { position: fixed; inset: 0; pointer-events: none; }
.overlay {
  display: flex; align-items: center; justify-content: center;
  opacity: 0; visibility: hidden; transition: opacity .22s ease, visibility 0s linear .22s;
  background: radial-gradient(ellipse at 50% 40%, rgba(30, 18, 70, 0.35), rgba(6, 3, 16, 0.82) 75%);
  backdrop-filter: blur(2px);
}
.overlay.active { opacity: 1; visibility: visible; pointer-events: auto; transition-delay: 0s; }
.overlay.fade-out { opacity: 0 !important; visibility: hidden !important; }

/* ------------------------------------------------ 타이포 공통 */
.chip-label, .depth-label, .score-sub, .best-row, .controls-hint, .panel-badge {
  font-family: var(--hud-font);
  text-transform: uppercase;
  letter-spacing: 0.14em;
}
.tabnum { font-variant-numeric: tabular-nums; }

/* ================================================ HUD */
#hud { opacity: 0; visibility: hidden; transition: opacity .2s ease, visibility 0s linear .2s; }
#hud.active { opacity: 1; visibility: visible; transition-delay: 0s; }
#hud::before {
  content: ''; position: absolute; inset: 3px; border: 1px solid rgba(255, 182, 64, .5);
  box-shadow: inset 0 0 20px rgba(255, 138, 30, .12), 0 0 12px rgba(255, 138, 30, .18);
  border-radius: 16px; opacity: 0; transition: opacity .28s ease; pointer-events: none;
}
#hud.fever-active::before { opacity: 1; }
.hud-top {
  position: absolute; top: 0; left: 0; right: 0;
  display: flex; align-items: flex-start; justify-content: space-between;
  padding: calc(12px + env(safe-area-inset-top)) clamp(12px, 3vw, 26px) 12px;
  gap: 12px;
  transform: translateY(-10px); transition: transform .22s ease;
}
#hud.active .hud-top { transform: translateY(0); }
.hud-left-stack { display: flex; flex-direction: column; gap: 8px; }
.hud-chip {
  pointer-events: none;
  display: flex; flex-direction: column; gap: 2px;
  padding: 10px 16px;
  background: var(--panel); border: 1px solid var(--panel-brd);
  border-radius: 14px; backdrop-filter: blur(12px);
  box-shadow: 0 6px 24px rgba(0,0,0,.35), inset 0 1px 0 rgba(255,255,255,.08);
}
.chip-label { font-size: 11px; color: var(--dim); font-weight: 600; }
.chip-value {
  font-family: var(--display-font); font-weight: 700; font-size: 22px;
  font-variant-numeric: tabular-nums; color: var(--cyan);
  text-shadow: 0 0 10px rgba(53,230,255,.55);
}

/* ================================================ 하트·코인 경제 HUD */
.economy-row { display: flex; align-items: center; gap: 8px; }
.economy-chip {
  display: inline-flex; align-items: center; justify-content: center; gap: 5px;
  min-height: 36px; padding: 7px 10px; border-radius: 12px;
  font-family: var(--display-font); font-size: 14px; line-height: 1;
  letter-spacing: .05em; font-variant-numeric: tabular-nums;
  background: rgba(12, 8, 34, .66); border: 1px solid var(--panel-brd);
  box-shadow: inset 0 1px 0 rgba(255,255,255,.08), 0 7px 20px rgba(0,0,0,.2);
}
button.economy-chip { pointer-events: auto; cursor: pointer; border-style: solid; }
button.economy-chip:focus-visible { outline: 3px solid #fff; outline-offset: 3px; }
.economy-chip strong { font-size: 17px; }
.economy-chip strong, #hud-level { display: inline-block; }
.result-economy { justify-content: center; margin: 12px 0 18px; }
.shop-economy { flex-wrap: wrap; margin-top: 8px; }
.reward-flight {
  position: fixed; z-index: 5; pointer-events: none; white-space: nowrap;
  font-family: var(--display-font); font-size: 18px; font-weight: 700;
  color: var(--gold); text-shadow: 0 0 14px currentColor;
}
.reward-hearts { color: #ff7c9d; }
.sr-only { position: absolute; width: 1px; height: 1px; padding: 0; margin: -1px; overflow: hidden; clip-path: inset(50%); white-space: nowrap; }
.motion-highlight { animation: motionHighlight .6s ease-out; }
@keyframes motionHighlight { from { color: #fff; text-shadow: 0 0 14px currentColor; } }
.economy-chip em { font-family: var(--hud-font); font-style: normal; font-size: 9px; color: var(--dim); letter-spacing: .12em; }
.heart-chip { color: #ff7c9d; border-color: rgba(255, 69, 200, .42); text-shadow: 0 0 12px rgba(255, 69, 200, .45); }
.coin-chip { color: var(--gold); border-color: rgba(255, 207, 92, .42); text-shadow: 0 0 12px rgba(255, 207, 92, .4); }
.hud-economy .economy-chip { min-height: 31px; padding: 6px 8px; font-size: 12px; backdrop-filter: blur(10px); }
.hud-economy .economy-chip strong { font-size: 14px; }

.hud-progress-wrap {
  flex: 1; max-width: 340px; display: flex; flex-direction: column; align-items: center;
  gap: 6px; margin-top: 2px;
}
.progress-num {
  font-family: var(--display-font); font-weight: 900;
  font-size: clamp(30px, 7vw, 48px); line-height: 1;
  font-variant-numeric: tabular-nums;
  color: #fff; letter-spacing: 0.02em;
  text-shadow: 0 0 18px rgba(138,123,255,.6), 0 0 40px rgba(53,230,255,.3);
}
.progress-num i { font-size: 0.5em; font-style: normal; color: var(--violet); margin-left: 2px; }
.progress-bar {
  width: 100%; height: 6px; border-radius: 6px;
  background: rgba(255,255,255,.08);
  overflow: hidden; box-shadow: inset 0 1px 2px rgba(0,0,0,.5);
}
.progress-bar-fill {
  height: 100%; width: 0%;
  background: linear-gradient(90deg, var(--violet), var(--cyan));
  box-shadow: 0 0 12px rgba(53,230,255,.7);
  transition: width .25s ease;
}
.depth-label { font-size: 11px; color: var(--dim); font-weight: 600; }
.depth-label span { color: var(--ink); font-variant-numeric: tabular-nums; }

/* 무한 피버 게이지 */
.fever-gauge {
  display: none; position: relative;
  width: 100%; height: 15px; margin-top: 9px; border-radius: 8px;
  background: rgba(255,255,255,.07); border: 1px solid rgba(255,138,30,.25);
  overflow: hidden; box-shadow: inset 0 1px 3px rgba(0,0,0,.5);
}
.fever-gauge-fill {
  height: 100%; width: 0%;
  background: linear-gradient(90deg, var(--gold), #ff8a1e);
  box-shadow: 0 0 14px rgba(255,138,30,.7); transition: width .12s linear;
}
.fever-gauge-label {
  position: absolute; inset: 0; display: flex; align-items: center; justify-content: center;
  font-family: var(--display-font); font-weight: 700; font-size: 9px;
  letter-spacing: .22em; color: rgba(255,255,255,.78); text-shadow: 0 1px 2px rgba(0,0,0,.6);
}
.fever-gauge.full .fever-gauge-fill { background: linear-gradient(90deg, #ffd23e, #ff5a1e); }
.fever-gauge.full { animation: gaugeFull .5s ease-in-out infinite alternate; }
@keyframes gaugeFull { from { box-shadow: inset 0 1px 3px rgba(0,0,0,.5), 0 0 8px rgba(255,138,30,.4); } to { box-shadow: inset 0 1px 3px rgba(0,0,0,.5), 0 0 22px rgba(255,138,30,.95); } }

/* 무한모드 HUD 전환 */
#hud.endless .hud-chip { display: none; }
#hud.endless .progress-bar { display: none; }
#hud.endless #hud-unit { display: none; }
#hud.endless #hud-depth-label { display: none; }
#hud.endless .fever-gauge { display: block; }
/* 중앙의 밝은 코어와 겹치지 않게 좌상단 정렬(가독성) */
#hud.endless .hud-progress-wrap { align-items: flex-start; max-width: 300px; }
#hud.endless .progress-num { text-shadow: 0 2px 10px rgba(0,0,0,.7), 0 0 18px rgba(53,230,255,.5); }

.hud-actions { display: flex; gap: 8px; }
.icon-btn {
  pointer-events: auto;
  width: 44px; height: 44px; border-radius: 12px;
  background: var(--panel); border: 1px solid var(--panel-brd);
  color: var(--ink); font-size: 18px; cursor: pointer;
  backdrop-filter: blur(12px);
  display: flex; align-items: center; justify-content: center;
  transition: transform .15s ease, background .2s;
}
.icon-btn.muted { opacity: .55; }

/* combo */
.combo {
  position: absolute; top: 50%; left: 50%;
  transform: translate(-50%, -50%) scale(.6);
  opacity: 0; transition: opacity .25s ease;
  font-family: var(--display-font); font-weight: 900;
  font-size: clamp(28px, 8vw, 64px);
  color: var(--cyan);
  text-shadow: 0 0 20px rgba(53,230,255,.8);
  pointer-events: none;
}
.combo.visible { opacity: .95; transform: translate(-50%, -50%) scale(1); }
.combo-num { display: inline-block; }
.combo.fever {
  color: var(--gold);
  text-shadow: 0 0 24px rgba(255,138,30,.9), 0 0 48px rgba(255,80,0,.6);
}
.combo.pulse { animation: comboPulse .4s ease-out; }
@keyframes comboPulse {
  0% { transform: translate(-50%,-50%) scale(1.4); opacity: 1; }
  100% { transform: translate(-50%,-50%) scale(1); opacity: .95; }
}

.tutorial-card, .milestone-toast {
  pointer-events: none; position: absolute; left: 50%; top: 27%; transform: translateX(-50%);
  width: min(calc(100vw - 32px), 330px); padding: 16px 18px; border-radius: 16px;
  text-align: center; background: rgba(9, 5, 28, .84); border: 1px solid rgba(53,230,255,.48);
  box-shadow: 0 14px 42px rgba(0,0,0,.48), 0 0 24px rgba(53,230,255,.15);
  backdrop-filter: blur(12px);
}
.tutorial-card { display: grid; gap: 5px; animation: tutorialIn .35s ease-out; }
.tutorial-card .lesson-move, .tutorial-card .lesson-danger { display: grid; gap: 7px; }
.tutorial-card[data-lesson="move"] .lesson-danger,
.tutorial-card[data-lesson="danger"] .lesson-move { display: none; }
.tutorial-card .drag-demo { font-size: 26px; animation: dragDemo 1.8s ease-in-out infinite; }
@keyframes dragDemo { 0%, 100% { transform: translateX(-18px); } 50% { transform: translateX(18px); } }
.shield-status {
  position: absolute; bottom: max(24px, env(safe-area-inset-bottom)); left: 50%; transform: translateX(-50%);
  padding: 9px 16px; border-radius: 20px; background: rgba(9,5,28,.88); color: var(--cyan);
  font-size: 16px; white-space: nowrap; pointer-events: none;
}
#pause-overlay .panel { max-height: calc(100svh - 32px); overflow-y: auto; }
@media (prefers-reduced-motion: reduce) { .tutorial-card .drag-demo { animation: none; } }
.tutorial-card strong { color: var(--cyan); font-family: var(--display-font); font-size: 12px; letter-spacing: .16em; margin-bottom: 3px; }
.tutorial-card span { font-size: 15px; font-weight: 600; line-height: 1.25; }
.milestone-toast { top: 38%; width: auto; color: var(--gold); font-family: var(--display-font); font-weight: 700; letter-spacing: .1em; opacity: 0; }
.milestone-toast.visible { opacity: 1; animation: tutorialIn .25s ease-out; }
@keyframes tutorialIn { from { opacity: 0; transform: translate(-50%, 10px); } to { opacity: 1; transform: translate(-50%, 0); } }

/* ================================================ 패널 공통 */
.panel {
  pointer-events: auto;
  width: min(90vw, 380px);
  padding: 36px 32px;
  text-align: center;
  background: var(--panel);
  border: 1px solid var(--panel-brd);
  border-radius: 24px;
  backdrop-filter: blur(22px);
  box-shadow: 0 24px 80px rgba(0,0,0,.6), inset 0 1px 0 rgba(255,255,255,.1);
}
.overlay.active > .panel { animation: panelIn .22s ease-out; }
#screen-win > .panel, #screen-gameover > .panel {
  max-height: calc(100svh - env(safe-area-inset-top) - env(safe-area-inset-bottom) - 28px);
  overflow-y: auto; overscroll-behavior: contain; touch-action: pan-y;
}
/* The content enters in stages; keep the reward's destination stationary. */
#screen-win.active > .panel, #screen-gameover.active > .panel { animation: none; }
@keyframes panelIn {
  from { opacity: 0; transform: translateY(20px) scale(.96); }
  to { opacity: 1; transform: translateY(0) scale(1); }
}
.panel-title, .panel-badge { font-family: var(--display-font); }
.panel-badge {
  display: inline-block; font-weight: 700; font-size: 15px;
  padding: 8px 18px; border-radius: 999px; margin-bottom: 18px;
  letter-spacing: 0.16em;
}
.panel-badge.danger { color: var(--danger); border: 1px solid rgba(255,43,87,.5); background: rgba(255,43,87,.12); text-shadow: 0 0 14px rgba(255,43,87,.6); }
.panel-badge.success { color: var(--gold); border: 1px solid rgba(255,207,92,.5); background: rgba(255,207,92,.12); text-shadow: 0 0 14px rgba(255,207,92,.6); }

.score-big {
  font-family: var(--display-font); font-weight: 900;
  font-size: clamp(48px, 14vw, 76px); line-height: 1;
  font-variant-numeric: tabular-nums;
  color: #fff; margin: 4px 0;
  text-shadow: 0 0 26px rgba(138,123,255,.7), 0 0 60px rgba(53,230,255,.35);
}
.score-big.gold { color: var(--gold); text-shadow: 0 0 26px rgba(255,207,92,.8), 0 0 60px rgba(255,138,30,.4); }
.score-sub { font-size: 12px; color: var(--dim); font-weight: 600; margin-bottom: 22px; }
.score-sub span { color: var(--cyan); font-variant-numeric: tabular-nums; }
.first-clear { color: var(--gold); font-family: var(--display-font); font-size: 12px; letter-spacing: .1em; margin: -10px 0 18px; }
.newbest {
  font-family: var(--display-font); font-weight: 700; font-size: 13px;
  color: var(--gold); letter-spacing: .14em; margin-bottom: 16px;
  opacity: 0; height: 0; transition: opacity .3s;
}
.newbest.visible { opacity: 1; height: auto; }
@keyframes blink { from { opacity: .55; } to { opacity: 1; } }

/* ================================================ 버튼 */
.btn {
  pointer-events: auto;
  display: block; width: 100%;
  font-family: var(--display-font); font-weight: 700;
  font-size: 16px; letter-spacing: 0.14em; text-transform: uppercase;
  padding: 15px 24px; margin: 10px 0 0; border: none; border-radius: 14px;
  cursor: pointer; color: #0a0620; position: relative; overflow: hidden;
  transition: transform .15s ease, box-shadow .25s ease, filter .2s;
}
.btn-primary {
  background: linear-gradient(135deg, var(--cyan), var(--violet));
  box-shadow: 0 8px 28px rgba(53,230,255,.35), inset 0 1px 0 rgba(255,255,255,.4);
}
.btn-ghost {
  background: transparent; color: var(--dim);
  border: 1px solid var(--panel-brd); box-shadow: none;
}
.btn-lg { font-size: 20px; padding: 18px 24px; }
.btn-coin, .btn-shop {
  color: #281800;
  background: linear-gradient(135deg, var(--gold), #ff9e38);
  box-shadow: 0 8px 26px rgba(255, 158, 56, .28), inset 0 1px 0 rgba(255,255,255,.45);
}
.btn:disabled, .shop-card:disabled { cursor: not-allowed; filter: saturate(.45); opacity: .58; transform: none; }
.btn:focus-visible, .icon-btn:focus-visible, .shop-card:focus-visible { outline: 3px solid #fff; outline-offset: 3px; }

/* 보상형 광고 버튼(부활·하트) — 골드 강조 + 시머 */
.btn-reward {
  background: linear-gradient(135deg, var(--gold), #ff8a1e);
  color: #2a1400;
  box-shadow: 0 8px 26px rgba(255,138,30,.4), inset 0 1px 0 rgba(255,255,255,.5);
}
.btn-reward::after {
  content: ''; position: absolute; inset: 0;
  background: linear-gradient(110deg, transparent 25%, rgba(255,255,255,.5) 50%, transparent 75%);
  background-size: 220% 100%;
  animation: rewardShine 2.6s linear infinite;
  pointer-events: none;
}
@keyframes rewardShine { from { background-position: 130% 0; } to { background-position: -130% 0; } }

.hidden { display: none !important; }

/* ================================================ 메뉴 */
.menu-inner {
  text-align: center; pointer-events: auto; width: min(90vw, 440px);
  opacity: 0; transform: translateY(-14px);
  transition: opacity .2s ease, transform .22s ease;
}
#screen-menu.active .menu-inner { opacity: 1; transform: translateY(0); }
#screen-menu { flex-direction: column; gap: 16px; }
.menu-topbar {
  flex: 0 0 auto; width: 100%; display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(100px, 1.4fr) minmax(0, 1fr);
  align-items: start; gap: clamp(6px, 2vw, 16px);
}
#screen-menu .menu-topbar button.economy-chip {
  width: 100%; max-width: 116px; min-width: 0; min-height: 44px;
  padding: 9px 10px; gap: 5px; justify-self: start;
}
#screen-menu .menu-topbar button.coin-chip { justify-self: end; }
.menu-topbar button.economy-chip strong { min-width: 0; overflow-wrap: anywhere; }
.menu-records { display: grid; gap: 4px; min-width: 0; text-align: center; }
.menu-records > div { display: flex; flex-wrap: wrap; align-items: baseline; justify-content: center; gap: 3px 7px; min-width: 0; }
.menu-records span { color: var(--dim); font-size: 11px; white-space: nowrap; }
.menu-records strong { font-family: var(--display-font); color: var(--gold); font-size: 17px; font-variant-numeric: tabular-nums; overflow-wrap: anywhere; min-width: 0; }
.menu-content { flex: 1; min-height: 0; width: 100%; display: flex; align-items: center; justify-content: center; }
#screen-menu .menu-inner { max-height: 100%; }
.mode-button { display: grid; gap: 3px; justify-items: center; padding-top: 13px; padding-bottom: 13px; }
.mode-button small, .mode-button em { font-family: var(--hud-font); font-style: normal; text-transform: none; letter-spacing: .04em; }
.mode-button small { font-size: 13px; font-weight: 600; }
.mode-button em { font-size: 11px; font-weight: 600; opacity: .78; }
.btn-primary.mode-button small, .btn-primary.mode-button em { color: rgba(10,6,32,.75); }
.btn-ghost.mode-button small, .btn-ghost.mode-button em { color: var(--dim); }
.title-wrap { position: relative; }
.game-title {
  font-family: var(--display-font); font-weight: 900;
  font-size: clamp(40px, 13vw, 92px); line-height: .95;
  letter-spacing: 0.04em;
  background: linear-gradient(120deg, #fff 10%, var(--cyan) 40%, var(--violet) 70%, var(--magenta) 100%);
  background-size: 200% auto;
  -webkit-background-clip: text; background-clip: text;
  -webkit-text-fill-color: transparent; color: transparent;
  filter: drop-shadow(0 4px 30px rgba(53,230,255,.4));
  animation: titleShine 6s linear infinite;
}
.game-title span { display: block; -webkit-text-stroke: 1px rgba(255,255,255,.12); }
@keyframes titleShine { to { background-position: 200% center; } }
.title-underline {
  height: 3px; width: 60%; margin: 14px auto 0;
  background: linear-gradient(90deg, transparent, var(--cyan), var(--magenta), transparent);
  box-shadow: 0 0 16px rgba(53,230,255,.6);
}
.tagline { color: var(--dim); font-size: 16px; font-weight: 500; letter-spacing: .08em; margin: 18px 0 30px; }
.menu-economy { justify-content: center; margin: -12px 0 18px; }
.menu-economy .economy-chip { min-width: 116px; }
.best-row { display: flex; justify-content: center; align-items: baseline; gap: 8px 24px; flex-wrap: wrap; margin-top: 20px; font-size: 13px; color: var(--dim); font-weight: 600; }
.best-row > div { white-space: nowrap; }
.best-row span { font-family: var(--display-font); color: var(--gold); font-size: 20px; font-variant-numeric: tabular-nums; margin-left: 6px; text-shadow: 0 0 12px rgba(255,207,92,.5); }
.controls-hint { margin-top: 26px; display: flex; gap: 10px; justify-content: center; flex-wrap: wrap; font-size: 12px; color: var(--dim); font-weight: 500; }

/* ================================================ 로딩 */
.loader { text-align: center; }
.loader-ring {
  width: 54px; height: 54px; margin: 0 auto 18px;
  border: 3px solid rgba(140,130,255,.2);
  border-top-color: var(--cyan);
  border-radius: 50%;
  animation: spin .9s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }
.loader-text { font-family: var(--display-font); font-weight: 700; letter-spacing: .3em; font-size: 13px; color: var(--dim); }

/* ================================================ 광고 오버레이(mock) */
.ad-overlay {
  position: fixed; inset: 0; z-index: 100;   /* 게임오버 패널(overlay) 위 */
  display: flex; align-items: center; justify-content: center;
  opacity: 0; visibility: hidden; transition: opacity .3s ease, visibility 0s linear .3s;
  background: radial-gradient(ellipse at 50% 40%, rgba(20,12,46,.7), rgba(4,2,12,.94) 80%);
  backdrop-filter: blur(6px);
  pointer-events: none;
}
.ad-overlay.active { opacity: 1; visibility: visible; pointer-events: auto; transition-delay: 0s; }  /* 배경 버튼 클릭 차단 */
.ad-modal {
  width: min(90vw, 400px); padding: 28px 26px 24px; text-align: center;
  background: var(--panel); border: 1px solid var(--panel-brd); border-radius: 22px;
  backdrop-filter: blur(22px);
  box-shadow: 0 24px 80px rgba(0,0,0,.6), inset 0 1px 0 rgba(255,255,255,.1);
  animation: panelIn .4s cubic-bezier(.2,.9,.3,1.2);
}
.ad-tag {
  display: inline-block; font-family: var(--hud-font); font-weight: 700;
  font-size: 11px; letter-spacing: .18em; text-transform: uppercase;
  color: var(--dim); padding: 4px 12px; border: 1px solid var(--panel-brd);
  border-radius: 999px; margin-bottom: 16px;
}
.ad-visual {
  position: relative; width: 92px; height: 92px; margin: 4px auto 14px;
  display: flex; align-items: center; justify-content: center;
  border-radius: 20px; background: rgba(255,255,255,.04); border: 1px solid var(--panel-brd);
  overflow: hidden;
}
.ad-visual-glow {
  position: absolute; inset: -30%;
  background: conic-gradient(from 0deg, var(--cyan), var(--violet), var(--magenta), var(--gold), var(--cyan));
  filter: blur(14px); opacity: .5; animation: adSpin 6s linear infinite;
}
.ad-visual-mark { position: relative; font-size: 42px; filter: drop-shadow(0 2px 8px rgba(0,0,0,.5)); }
@keyframes adSpin { to { transform: rotate(360deg); } }
.ad-headline { font-family: var(--display-font); font-weight: 700; font-size: 20px; color: var(--ink); }
.ad-sub { font-size: 13px; color: var(--dim); font-weight: 500; margin: 6px 0 18px; }
.ad-progress {
  width: 100%; height: 6px; border-radius: 6px; background: rgba(255,255,255,.08);
  overflow: hidden; box-shadow: inset 0 1px 2px rgba(0,0,0,.5);
}
.ad-progress-fill {
  height: 100%; width: 0%;
  background: linear-gradient(90deg, var(--gold), #ff8a1e);
  box-shadow: 0 0 12px rgba(255,138,30,.7); transition: width .1s linear;
}
.ad-countdown { font-family: var(--display-font); font-weight: 700; font-size: 13px; color: var(--dim); margin: 8px 0 16px; font-variant-numeric: tabular-nums; }
.ad-countdown i { font-style: normal; font-size: .8em; margin-left: 1px; }
.ad-actions { display: flex; flex-direction: column; gap: 8px; }
.ad-btn {
  pointer-events: auto; width: 100%; cursor: pointer;
  font-family: var(--display-font); font-weight: 700; font-size: 14px;
  letter-spacing: .1em; text-transform: uppercase;
  padding: 13px 18px; border: none; border-radius: 12px;
  transition: transform .15s ease, box-shadow .25s ease, filter .2s;
}
.ad-btn-reward {
  color: #2a1400; background: linear-gradient(135deg, var(--gold), #ff8a1e);
  box-shadow: 0 8px 24px rgba(255,138,30,.45), inset 0 1px 0 rgba(255,255,255,.5);
  animation: rewardReady .7s ease-in-out infinite alternate;
}
@keyframes rewardReady { from { box-shadow: 0 8px 24px rgba(255,138,30,.35); } to { box-shadow: 0 8px 30px rgba(255,138,30,.75); } }
.ad-btn-skip {
  color: var(--dim); background: transparent; border: 1px solid var(--panel-brd);
  font-size: 12px; padding: 10px 18px;
}
.ad-btn-skip.is-wait, .ad-btn-skip:disabled { opacity: .5; cursor: default; }

/* 메뉴 하단 앵커 배너 슬롯(provider 연결 전엔 비노출) */
.ad-banner {
  position: fixed; left: 50%; bottom: 0; transform: translateX(-50%);
  width: min(100vw, 728px); min-height: 0;
  display: none;   /* 실제 배너 채워질 때만 표시 */
  pointer-events: auto;
}
.ad-banner.filled { display: block; }

/* ================================================ 하트 복구 및 상점 */
.overlay { padding: calc(14px + env(safe-area-inset-top)) 14px calc(14px + env(safe-area-inset-bottom)); }
.heart-panel {
  text-align: left; max-height: calc(100svh - env(safe-area-inset-top) - env(safe-area-inset-bottom) - 28px);
  overflow-y: auto; overscroll-behavior: contain; touch-action: pan-y;
}
.heart-panel .panel-badge { margin-bottom: 14px; }
.dialog-copy { color: var(--dim); font-size: 15px; line-height: 1.45; margin: 12px 0 18px; }
.heart-quota { color: var(--cyan); font-size: 14px; margin-top: -10px; }
.dialog-economy { justify-content: flex-start; margin-bottom: 18px; }
.dialog-actions { display: grid; gap: 8px; }
.dialog-actions .btn { margin: 0; }

.shop-panel {
  width: min(92vw, 520px); max-height: calc(100svh - env(safe-area-inset-top) - env(safe-area-inset-bottom) - 28px);
  padding: 24px; display: flex; flex-direction: column; text-align: left; overflow: hidden;
  background:
    linear-gradient(140deg, rgba(34, 20, 73, .84), rgba(8, 5, 24, .88)),
    radial-gradient(circle at 85% 0%, rgba(53,230,255,.19), transparent 35%);
}
.shop-heading { display: flex; align-items: flex-start; justify-content: space-between; gap: 14px; }
.shop-heading .panel-badge { margin-bottom: 10px; }
.shop-heading .panel-title { font-size: clamp(19px, 5vw, 25px); letter-spacing: .04em; }
.shop-orbit { color: var(--cyan); font-family: var(--display-font); font-size: 48px; line-height: .8; text-shadow: 0 0 24px rgba(53,230,255,.75); }
.shop-list {
  display: grid; gap: 9px; min-height: 0; margin: 14px -5px 10px; padding: 0 5px 5px;
  overflow-y: auto; overscroll-behavior: contain; touch-action: pan-y; scrollbar-color: var(--violet) transparent;
}
.shop-card {
  display: flex; align-items: center; justify-content: space-between; gap: 12px; width: 100%; min-height: 76px;
  padding: 12px 13px; border: 1px solid rgba(140,130,255,.3); border-radius: 15px; cursor: pointer;
  color: var(--ink); text-align: left; background: linear-gradient(105deg, rgba(59,42,117,.42), rgba(13,8,35,.5));
  box-shadow: inset 0 1px 0 rgba(255,255,255,.06), 0 8px 20px rgba(0,0,0,.18);
  transition: transform .16s ease, border-color .16s ease, background .16s ease;
}
.shop-card-copy { display: grid; min-width: 0; gap: 4px; }
.shop-name { font-family: var(--display-font); font-size: 13px; letter-spacing: .04em; }
.shop-grant { color: var(--dim); font-size: 14px; }
.shop-badge { width: fit-content; color: var(--gold); font-family: var(--hud-font); font-size: 10px; font-weight: 700; letter-spacing: .08em; }
.shop-price { flex: 0 0 auto; color: var(--cyan); font-family: var(--display-font); font-size: 14px; text-align: right; text-shadow: 0 0 12px rgba(53,230,255,.38); }
.shop-card.is-unavailable .shop-price { color: var(--dim); font-family: var(--hud-font); font-size: 12px; text-shadow: none; }
.shop-card.is-busy { border-color: var(--gold); }
.notice { min-height: 20px; color: var(--gold); font-size: 14px; font-weight: 600; line-height: 1.35; }

@media (max-width: 400px) {
  .menu-inner { width: calc(100vw - 24px); max-height: calc(100svh - 24px); overflow-y: auto; touch-action: pan-y; padding: 4px; }
  .tagline { margin: 10px 0 18px; }
  .menu-economy { margin: -6px 0 10px; }
  .mode-button { margin-top: 7px; padding: 11px 12px; }
  .controls-hint { margin-top: 15px; }
}

@media (max-width: 380px) {
  .hud-top { gap: 7px; padding-left: 8px; padding-right: 8px; }
  .hud-chip { padding: 7px 9px; border-radius: 11px; }
  .hud-chip .chip-value { font-size: 18px; }
  .hud-economy { gap: 5px; }
  .hud-economy .economy-chip { padding: 5px 6px; }
  .hud-actions { gap: 5px; }
  .icon-btn { width: 40px; height: 40px; }
  .shop-panel { width: 100%; padding: 19px 15px; }
  .heart-panel { width: 100%; max-height: calc(100svh - env(safe-area-inset-top) - env(safe-area-inset-bottom) - 20px); padding: 22px 18px; }
  .shop-card { gap: 8px; padding: 10px; }
  .shop-name { font-size: 12px; }
  .shop-grant { font-size: 13px; }
  .shop-price { font-size: 12px; }
}

/* ================================================ 접근성: 모션 감소 */
@media (prefers-reduced-motion: reduce) {
  .overlay, #hud, #hud::before, .hud-top, .menu-inner { transition: none; }
  .hud-top, .menu-inner { transform: none; }
  .overlay.active > .panel { animation: none; }
  .game-title { animation: none; }
  .panel, .menu-inner { animation: none; }
  .combo.pulse { animation: none; }
  .newbest.visible { animation: none; }
  .loader-ring { animation-duration: 2s; }
  .progress-bar-fill { transition: none; }
  .fever-gauge.full { animation: none; }
  .fever-gauge-fill { transition: none; }
  .btn-reward::after { animation: none; }
  .ad-modal { animation: none; }
  .ad-visual-glow { animation: none; }
  .ad-btn-reward { animation: none; }
  .ad-progress-fill { transition: none; }
  .shop-card { transition: none; }
  .tutorial-card, .milestone-toast.visible { animation: none; }
}
