/* cardgame/web/cardgame.css — 사용자 등록 모달 + 실시간 랭킹 패널 */

/* HTML UI 도 게임 캔버스와 동일한 neodgm(둥근모) 픽셀 폰트 사용 (OFL, 상업가능).
   woff2/woff 는 build_card_web.sh 가 dist/web 에 복사. */
@font-face {
  font-family: "neodgm";
  src: url("neodgm.woff2") format("woff2"),
       url("neodgm.woff") format("woff");
  font-weight: normal;
  font-style: normal;
  font-display: swap;
}
/* 전역 기본 폰트 (개별 규칙이 override 가능) */
body { font-family: "neodgm", system-ui, sans-serif; }

/* ───────── 레이아웃: 캔버스는 원래대로 중앙, 랭킹은 우상단 floating ───────── */
.cg-layout { display: contents; }   /* 레이아웃에 영향 X — 캔버스 중앙 정렬 유지 */

/* 랭킹: 우상단 반투명 floating 오버레이 (데스크탑/모바일 공통) */
#cg-ranking {
  position: fixed;
  top: 8px; right: 8px;
  z-index: 60;
  width: 200px;
  max-width: 46vw;
  max-height: 70vh;
  display: flex;
  flex-direction: column;
  background: rgba(15, 19, 26, 0.55);
  backdrop-filter: blur(3px);
  -webkit-backdrop-filter: blur(3px);
  border: 1px solid rgba(255, 212, 94, 0.35);
  border-radius: 8px;
  color: #e6e8ec;
  font-family: "neodgm", system-ui, sans-serif;
  overflow: hidden;
  box-shadow: 0 4px 18px rgba(0,0,0,0.4);
}
#cg-ranking.hidden { display: none; }
.cg-rank-head {
  display: flex; align-items: center; gap: 6px;
  padding: 7px 8px 7px 10px;
  border-bottom: 1px solid rgba(255,255,255,0.08);
}
.cg-rank-title { font-size: 14px; font-weight: bold; color: #ffd45e; flex: 0 0 auto; }
.cg-me {
  flex: 1 1 auto; font-size: 11px; color: #8fd6ff;
  overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
}
.cg-rank-close {
  flex: 0 0 auto; width: 22px; height: 22px; line-height: 20px;
  padding: 0; border: none; border-radius: 4px; cursor: pointer;
  background: rgba(255,255,255,0.08); color: #e6e8ec; font-size: 13px;
}
.cg-rank-close:hover { background: rgba(255,255,255,0.18); }
.cg-rank-list {
  list-style: none; margin: 0; padding: 4px 0;
  overflow-y: auto; flex: 1 1 auto;
}
.cg-rank-item {
  display: flex; align-items: center;
  padding: 3px 10px; font-size: 12px; gap: 6px;
}
.cg-rank-item.mine { background: rgba(120, 200, 90, 0.22); color: #c8f5a0; }
.cg-rank-no { flex: 0 0 20px; text-align: right; color: #9aa3b2; }
.cg-rank-item.mine .cg-rank-no { color: #c8f5a0; }
.cg-rank-name { flex: 1 1 auto; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.cg-rank-money { flex: 0 0 auto; color: #ffd45e; font-variant-numeric: tabular-nums; }
.cg-rank-item.mine .cg-rank-money { color: #d6ff8f; }

/* ───────── floating 컨트롤 (재도전 + 종료) ─────────
   베팅 컨트롤(▲▼/100/500/1000/MAX/ENTER)은 캔버스 내 컨트롤 패널로 이전됨.
   HTML 에는 좌상단 작은 floating 버튼(재도전·종료)만 유지. id 동일 → firebase.js 그대로. */
#cg-float-ctrls {
  position: fixed;
  left: 8px; top: 8px;
  z-index: 120;
  display: flex; flex-direction: column; gap: 8px;   /* 재도전 위 · 설정 아래 세로 스택 */
  pointer-events: none;        /* 빈 영역은 캔버스로 통과, 버튼만 auto */
  user-select: none; -webkit-user-select: none;
  -webkit-tap-highlight-color: transparent;
}
#cg-float-ctrls .btn {
  pointer-events: auto;
  margin: 0; padding: 0 10px;
  border: 2px solid rgba(200, 200, 220, 0.6);
  background: rgba(40, 40, 60, 0.55);
  color: #f0f0f0; font-weight: bold;
  font-family: -apple-system, BlinkMacSystemFont, "Helvetica Neue", sans-serif;
  border-radius: 10px;
  touch-action: manipulation; cursor: pointer;
  -webkit-tap-highlight-color: transparent;
  transition: background 0.08s, transform 0.05s;
}
#cg-float-ctrls .btn:active { background: rgba(120, 160, 220, 0.85); transform: scale(0.94); }
#cg-float-ctrls .cg-c-settings { width: 40px; height: 36px; font-size: 18px; }
/* (cg-c-retry 재도전 버튼 스타일 제거 — 기획 폐기) */

@media (pointer: coarse), (max-width: 1024px) {
  #cg-float-ctrls .cg-c-settings { width: 46px; height: 42px; font-size: 20px; }
  #cg-float-ctrls .cg-c-rank     { width: 46px; height: 42px; font-size: 18px; }
}

/* 부활/설정/랭킹 버튼은 세로 레이아웃에서 캔버스 SYS 칸으로 이동 → 플로팅 숨김
   (핸들러는 onUiAction 이 .click() 으로 재사용하므로 element 자체는 유지). */
#cg-float-ctrls { display: none !important; }

/* ───────── 모바일 가로(landscape) 안내 — 세로 강제 ─────────
   게임이 세로 레이아웃이므로 가로일 때 세로 회전 유도(이전 반전).
   (캔버스 CSS 회전은 love.js 터치 좌표를 깨므로 회전 대신 안내 오버레이 방식) */
#cg-rotate { display: none; }
@media (pointer: coarse) and (orientation: landscape) {
  #cg-rotate {
    display: flex; position: fixed; inset: 0; z-index: 99999;
    background: #0b0d12; color: #e9e9f2;
    align-items: center; justify-content: center; text-align: center;
  }
  .cg-rotate-icon { font-size: 56px; margin-bottom: 14px;
    animation: cg-rotate-spin 1.8s ease-in-out infinite; }
  .cg-rotate-text { font-size: 20px; font-weight: bold; }
  .cg-rotate-sub  { font-size: 13px; opacity: 0.7; margin-top: 8px; }
}
@keyframes cg-rotate-spin { 0%,100% { transform: rotate(0); } 50% { transform: rotate(-90deg); } }

/* 닫혔을 때 다시 열기 버튼 (우상단 작은 🏆) */
/* 랭킹 열기(🏆) — #cg-float-ctrls 좌측 스택의 설정 아래로 편입 (재도전·설정·랭킹). */
#cg-float-ctrls .cg-c-rank {
  width: 40px; height: 36px; font-size: 16px;
  color: #ffd45e; border-color: rgba(255, 212, 94, 0.5);
}
#cg-rank-open.hidden { display: none; }

/* ───────── 게임 종료 확인 (예/아니오) ───────── */
#cg-exit-confirm {
  position: fixed; inset: 0; z-index: 9500;
  display: flex; align-items: center; justify-content: center;
  background: rgba(0, 0, 0, 0.7);
}
#cg-exit-confirm.hidden { display: none; }
.cg-confirm-card {
  background: #1b212b; color: #e6e8ec;
  border: 2px solid #ffd45e; border-radius: 10px;
  padding: 24px 26px; width: 300px; max-width: 86vw; text-align: center;
  font-family: "neodgm", system-ui, sans-serif;
  box-shadow: 0 8px 40px rgba(0,0,0,0.6);
}
.cg-confirm-title { font-size: 18px; font-weight: bold; color: #ffd45e; margin-bottom: 6px; }
.cg-confirm-sub { font-size: 12px; color: #9aa3b2; margin-bottom: 18px; }
.cg-confirm-btns { display: flex; gap: 12px; }
.cg-confirm-btns button {
  flex: 1; padding: 11px 0; font-size: 15px; font-weight: bold;
  border: none; border-radius: 6px; cursor: pointer;
  font-family: "neodgm", system-ui, sans-serif;
}
#cg-exit-yes { background: #c0392b; color: #fff; }
#cg-exit-no  { background: #3a4456; color: #e6e8ec; }

/* ───────── 종료 후 리더보드 전체화면 ───────── */
#cg-endscreen {
  position: fixed; inset: 0; z-index: 9000;
  display: flex; align-items: center; justify-content: center;
  background: rgba(8, 11, 16, 0.96);
}
#cg-endscreen.hidden { display: none; }
.cg-end-inner {
  width: 360px; max-width: 92vw; max-height: 88vh;
  display: flex; flex-direction: column;
  color: #e6e8ec; font-family: "neodgm", system-ui, sans-serif;
}
.cg-end-title { font-size: 24px; font-weight: bold; color: #ffd45e; text-align: center; margin-bottom: 8px; }
.cg-end-me {
  font-size: 14px; color: #8fd6ff; text-align: center;
  padding: 8px; margin-bottom: 10px;
  background: rgba(120, 200, 90, 0.14); border-radius: 6px;
}
.cg-end-list {
  list-style: none; margin: 0; padding: 4px 0;
  overflow-y: auto; flex: 1 1 auto;
  border: 1px solid rgba(255,212,94,0.25); border-radius: 8px;
  background: rgba(15,19,26,0.6);
}
/* list item 은 랭킹 패널과 동일 클래스(.cg-rank-item 등) 재사용 — firebase.js 가 생성 */
.cg-end-back {
  margin-top: 12px; padding: 11px; font-size: 14px;
  border: 1px solid rgba(255,255,255,0.2); border-radius: 6px; cursor: pointer;
  background: rgba(255,255,255,0.06); color: #e6e8ec;
  font-family: "neodgm", system-ui, sans-serif;
}
.cg-end-back:hover { background: rgba(255,255,255,0.14); }

/* (재도전 0원 충전 버튼 스타일 #btn-retry / cg-retry-pulse 제거 — 기획 폐기) */

/* ───────── 사용자 등록 모달 ───────── */
#cg-name-modal {
  position: fixed; inset: 0;
  display: flex; align-items: center; justify-content: center;
  background: rgba(0, 0, 0, 0.82);
  z-index: 10000; /* splash(보통 9000대)보다 위 */
}
#cg-name-modal.hidden { display: none; }
.cg-modal-card {
  background: #1b212b; color: #e6e8ec;
  border: 2px solid #ffd45e; border-radius: 10px;
  padding: 28px 26px; width: 320px; max-width: 86vw;
  text-align: center;
  font-family: "neodgm", system-ui, sans-serif;
  box-shadow: 0 8px 40px rgba(0,0,0,0.6);
}
.cg-modal-title { font-size: 20px; font-weight: bold; color: #ffd45e; margin-bottom: 6px; }
.cg-modal-sub { font-size: 13px; color: #9aa3b2; margin-bottom: 18px; }
#cg-name-input {
  width: 100%; box-sizing: border-box;
  padding: 11px 12px; font-size: 17px;
  border: 1px solid #3a4456; border-radius: 6px;
  background: #0f131a; color: #fff; text-align: center;
  margin-bottom: 14px; outline: none;
}
#cg-name-input:focus { border-color: #ffd45e; }
#cg-name-ok {
  width: 100%; padding: 12px; font-size: 16px; font-weight: bold;
  border: none; border-radius: 6px; cursor: pointer;
  background: #ffd45e; color: #1b212b;
}
#cg-name-ok:disabled { opacity: 0.5; cursor: default; }
.cg-modal-msg { margin-top: 10px; font-size: 12px; color: #ff8f8f; min-height: 16px; }
