/* ============================================================
   PRO10 · DOCK LAYOUT + PERFORMANCE GUARD  (마지막에 로드)
   ============================================================ */
:root {
  --jh-edge: 10px;
  --jh-gap: 8px;
  --jh-safe: env(safe-area-inset-bottom, 0px);
  --jh-b-ck: 0px;
  --jh-b-k: 0px;
  --jh-b-row: 0px;
  --jh-fab-w: 0px;
  --jh-stack: 0px;
}

/* ───────────── 1. 하단 고정 요소: 겹치지 않는 도크 ───────────── */
/* 맨 아래: 쿠키/동의 바 */
html body .ck {
  left: 50% !important; right: auto !important;
  bottom: calc(var(--jh-safe) + var(--jh-edge) + var(--jh-b-ck)) !important;
  z-index: 70 !important;
}

/* 그 위: 카린 (게임 밖에서만. 게임 안에서는 모달 안에 인라인으로 표시) */
html body #jhKarin:not(.game-active):not(.karin-inline) {
  position: fixed !important;
  right: calc(var(--jh-edge) + env(safe-area-inset-right, 0px)) !important;
  left: auto !important;
  bottom: calc(var(--jh-safe) + var(--jh-edge) + var(--jh-b-k)) !important;
  width: min(300px, calc(100vw - (var(--jh-edge) * 2))) !important;
  z-index: 60 !important;
}

/* 그 위 한 줄: LIVE POINTS (왼쪽) + 게임 방법 (오른쪽) */
html body #pf {
  position: fixed !important;
  left: calc(var(--jh-edge) + env(safe-area-inset-left, 0px)) !important;
  right: auto !important;
  bottom: calc(var(--jh-safe) + var(--jh-edge) + var(--jh-b-row)) !important;
  width: 280px !important;
  max-width: calc(100vw - (var(--jh-edge) * 2)) !important;
  z-index: 55 !important;
  display: flex !important; flex-direction: column;
  max-height: min(52vh, 360px);
}
html body #pf > ul, html body #pf > #pfLounge { overflow-y: auto; -webkit-overflow-scrolling: touch; overscroll-behavior: contain; min-height: 0; }
html body #pf.min { max-height: none; }
html body #htFab {
  position: fixed !important;
  right: calc(var(--jh-edge) + env(safe-area-inset-right, 0px)) !important;
  left: auto !important;
  bottom: calc(var(--jh-safe) + var(--jh-edge) + var(--jh-b-row)) !important;
  z-index: 55 !important;
  height: 44px !important;
  white-space: nowrap;
}

/* PC: LIVE POINTS는 왼쪽 맨 아래(카린은 오른쪽이라 겹치지 않음) */
@media (min-width: 761px) {
  html body #pf { bottom: calc(var(--jh-safe) + 18px + var(--jh-b-ck)) !important; left: 18px !important; }
}

/* 모바일: LIVE POINTS가 '게임 방법' 버튼 옆 남는 폭만 사용 */
@media (max-width: 760px) {
  html body #pf {
    width: auto !important;
    right: calc(var(--jh-edge) + var(--jh-fab-w) + var(--jh-gap) + env(safe-area-inset-right, 0px)) !important;
    max-width: none !important;
  }
  html body #pf header { padding: 9px 12px; }
  html body #pf .pftabs button { white-space: nowrap; padding: 8px 6px; font-size: 11px; }
  html body #pf .pftabs { gap: 6px; }
  html body #pf .pfnote { display: none; }
  html body #htFab { padding: 0 14px 0 6px !important; }
}

/* 모달/게이트/환영창이 열리면 도크 전체를 숨겨서 겹침 방지 */
html.jh-modal #pf,
html.jh-modal #htFab,
html.jh-modal #jhKarin:not(.game-active):not(.karin-inline),
html.jh-modal .ck {
  opacity: 0 !important; visibility: hidden !important; pointer-events: none !important;
}

/* 토스트는 항상 도크 바로 위, 가장 위 레이어 */
html body #toast, html body .toast {
  position: fixed !important;
  left: 50% !important; right: auto !important;
  bottom: calc(var(--jh-safe) + var(--jh-edge) + var(--jh-stack) + 6px) !important;
  transform: translateX(-50%) !important;
  max-width: calc(100vw - 24px) !important;
  z-index: 120 !important;
  pointer-events: none;
}
html.jh-modal body #toast, html.jh-modal body .toast { bottom: calc(var(--jh-safe) + 24px) !important; }

/* 도크가 페이지 맨 아래 내용을 가리지 않도록 여백 확보 */
html body footer { padding-bottom: calc(var(--jh-stack) + var(--jh-safe) + 14px) !important; }

/* ───────────── 카린 카드 내부: 버튼 잘림/넘침 수정 ───────────── */
html body .jh-karin { overflow: hidden; }
html body .jh-karin .karin-dialog { min-width: 0; }
html body .jh-karin .karin-head { display: grid; grid-template-columns: minmax(0, 1fr) auto; align-items: center; gap: 6px; }
html body .jh-karin .karin-name { min-width: 0; overflow: hidden; text-overflow: ellipsis; }
html body .jh-karin .karin-name small { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
html body .jh-karin .karin-actions { flex: none; }
html body .jh-karin .karin-actions button { min-width: 38px; padding: 5px 6px; }
html body .jh-karin .karin-copy p { overflow-wrap: anywhere; }
html body .jh-karin.is-collapsed { width: auto !important; }

/* ───────────── 2. 성능 ───────────── */
/* 필름 그레인/노이즈 오버레이: 전체 화면 blend → 가장 큰 렉 원인 (3겹 중복이었음) */
html body::after { display: none !important; content: none !important; }
html body:after { display: none !important; }
html body::before { animation: none !important; transform: none !important; }
html .site-backdrop { animation: none !important; filter: none !important; }
#glow, #spot { mix-blend-mode: normal !important; }
#glow { opacity: .6; }
@media (hover: none), (pointer: coarse) { #glow, #spot { display: none !important; } }

/* 화면 밖 / 숨은 탭 → 모든 애니메이션 일시정지 */
html.jh-hidden *, html.jh-hidden *::before, html.jh-hidden *::after,
.jh-off, .jh-off *, .jh-off *::before, .jh-off *::after { animation-play-state: paused !important; }

/* 화면 밖 게임 카드는 렌더링 생략 (57장 → 보이는 것만 그림). 섹션 단위는 오히려 느려져서 카드 단위로만 적용 */
@supports (content-visibility: auto) {
  .game-card { content-visibility: auto; contain-intrinsic-size: auto 240px; }
}
.game-card { contain: layout style; }

/* 모바일/터치: 비용 큰 효과 정리 (보기에는 거의 차이 없음) */
@media (max-width: 900px), (hover: none) {
  html *, html *::before, html *::after { -webkit-backdrop-filter: none !important; backdrop-filter: none !important; }
  .site-header { background: rgba(8, 6, 14, .97) !important; }
  #pf { background: rgba(14, 9, 12, .97) !important; }
  .jh-karin { background: linear-gradient(110deg, rgba(36,23,16,.98), rgba(13,11,12,.99)) !important; }
  .modal-backdrop { background: rgba(6, 4, 10, .94) !important; }
  #toast, .toast { background: #e7c98f !important; }
  /* 색/배경 위치를 계속 다시 그리는 장식 애니메이션 정지 */
  .neon-ban-bg, .neon-big, .neon-ban-1, .neon-ban-2, .neon-ban-glow,
  .tt-banner-shine, .rank-card-shine, .rank-header-glow, .hero::before, .hero::after,
  .hero h1 em, .section-heading h2 em, .art-symbol, .game-card-art .art-symbol,
  .button-gold, .suit, .brand-mark { animation: none !important; }
  .game-card:hover { transform: none !important; }
}
html.jh-lowend .neon-ban-scan, html.jh-lowend .neon-btn, html.jh-lowend .rank-boss,
html.jh-lowend .rank-avatar-boss, html.jh-lowend .rank-crown { animation: none !important; }

/* 모션 줄이기 설정 존중 */
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation-duration: .01ms !important; animation-iteration-count: 1 !important; transition-duration: .01ms !important; scroll-behavior: auto !important; }
}

/* 터치 반응: 300ms 지연/더블탭 줌 방지 */
button, a, .game-card, .filter, .choice { touch-action: manipulation; -webkit-tap-highlight-color: transparent; }

/* 카린 초상화: 도크 안에서 머리가 잘리지 않도록 */
html body .jh-karin:not(.game-active):not(.karin-inline) .karin-portrait-wrap { width: 64px; flex: 0 0 64px; min-height: 92px; margin: 0; align-self: center; }
html body .jh-karin:not(.game-active):not(.karin-inline) .karin-portrait-stage { max-width: 64px; }
html body .jh-karin:not(.game-active):not(.karin-inline) .karin-portrait { max-height: 94px; }
