/* ===== Font ===== */
@font-face{
  font-family: "NanumHumanHeavy";
  src: url("https://raw.githubusercontent.com/Yuhisa-Kr/WebCardGame/main/NanumHumanHeavy.ttf") format("truetype");
  font-weight: 100 900;
  font-style: normal;
  font-display: swap;
}

:root{
  --bg:#1a1322;
  --accent:#c3a9e0;

  --panel: rgba(255,255,255,0.06);
  --panel-2: rgba(255,255,255,0.08);
  --line: rgba(255,255,255,0.10);
  --text: rgba(255,255,255,0.92);
  --muted: rgba(255,255,255,0.70);

  --shadow: 0 18px 60px rgba(0,0,0,0.65);

  --illust-shift-y: -140px;
  --ui-shift-y: 140px;
  --group-shift-y: 100px;

  /* 랭킹 컬럼 폭 + 좌측 이동 */
  --rank-col1: 100px;
  --rank-col3: 120px;
  --rank-shift-x: -20px;
}

*{ box-sizing:border-box; }
html, body{ height:100%; }

body{
  margin:0;
  min-height:100vh;
  color: var(--text);
  background:
    radial-gradient(1100px 700px at 50% 0%, rgba(195,169,224,0.14), transparent 55%),
    radial-gradient(1200px 800px at 50% 100%, rgba(195,169,224,0.10), transparent 60%),
    radial-gradient(800px 500px at 15% 30%, rgba(195,169,224,0.06), transparent 55%),
    var(--bg);

  padding: 22px;
  overflow: hidden;

  font-family: "NanumHumanHeavy", system-ui, -apple-system, Segoe UI, Roboto, sans-serif;
}

/* ===== Titles ===== */
.title{
  font-size: 54px;
  font-weight: 1100;
  letter-spacing: 0.6px;
  margin: 0;
  text-shadow: 0 0 28px rgba(0,0,0,0.60);
  position: relative;
  z-index: 3;
}

.subtitle{
  margin: 0 0 10px;
  font-size: 18px;
  font-weight: 900;
  color: var(--muted);
  line-height: 1.5;
  text-shadow: 0 0 18px rgba(0,0,0,0.60);
  position: relative;
  z-index: 3;
}

/* ===== Panel + Illust Group ===== */
.panelWrap{
  position: fixed;
  left: 50%;
  top: 50%;
  transform: translate(-50%, -50%) translateY(var(--group-shift-y));
  z-index: 2;

  width: min(720px, 92vw);
  height: 720px;
  max-height: calc(100vh - 220px);

  isolation: isolate;
}

/* ✅ Illust */
.lobbyIllust{
  position: absolute;
  left: 50%;
  top: 50%;
  transform: translate(-50%, -50%) translateY(var(--illust-shift-y));
  z-index: 1;

  width: 720px;
  max-width: 92vw;
  height: auto;

  pointer-events: none;
  -webkit-user-select: none;
  user-select: none;

  filter: drop-shadow(0 22px 60px rgba(0,0,0,0.55));
}

.uiStack{
  position: absolute;
  left: 50%;
  top: 50%;
  transform: translate(-50%, -50%) translateY(var(--ui-shift-y));
  z-index: 5;

  width: min(520px, 100%);
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 10px;
  text-align: center;
}

.panel{
  width: 100%;
  padding: 18px;
  border-radius: 22px;
  background: rgba(0,0,0,0.14);
  border: 1px solid rgba(255,255,255,0.10);
  box-shadow: 0 18px 60px rgba(0,0,0,0.35);
  -webkit-backdrop-filter: blur(6px);
  backdrop-filter: blur(6px);

  position: relative;
  z-index: 2;
}

.btns{
  display:flex;
  flex-direction:column;
  gap: 12px;
  margin-top: 6px;
}

button{
  width: 100%;
  cursor:pointer;
  border: 0;
  border-radius: 16px;
  padding: 14px 18px;
  font-weight: 1100;
  letter-spacing: 0.3px;
  background: var(--accent);
  color: #110b18;
  box-shadow: 0 10px 26px rgba(0,0,0,0.35);
  transition: transform .08s ease, filter .08s ease;
  -webkit-user-select: none;
  user-select:none;
  font-family: inherit;
}
button:hover{ transform: translateY(-1px); filter: brightness(1.03); }
button:active{ transform: translateY(0px); filter: brightness(0.98); }

.ghost{
  background: rgba(255,255,255,0.10);
  color: rgba(255,255,255,0.92);
  border: 1px solid rgba(255,255,255,0.14);
  box-shadow:none;
}

/* ===== Modal Overlay ===== */
.overlay{
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,0.62);
  -webkit-backdrop-filter: blur(7px);
  backdrop-filter: blur(7px);
  display:none;
  align-items:center;
  justify-content:center;
  padding: 18px;
  z-index: 999;
}
.overlay.open{ display:flex; }

.modal{
  width: min(720px, 100%);
  max-height: min(78vh, 760px);
  display:flex;
  flex-direction:column;
  gap: 12px;
  padding: 16px 16px 14px;
  border-radius: 22px;
  background: rgba(26,19,34,0.92);
  border: 1px solid rgba(255,255,255,0.12);
  box-shadow: var(--shadow);
}

/* Journey Slab 전용: 더 큰 높이 허용 */
.modal.modal--journeySlab{
  height: auto;
  max-height: 96vh;
}

.modalHeader{
  display:flex;
  align-items:center;
  justify-content:center;
  padding: 6px 8px 2px;
}
.modalTitleCenter{
  font-size: 18px;
  font-weight: 1100;
  color: rgba(255,255,255,0.92);
  letter-spacing: 0.3px;
  text-shadow: 0 0 18px rgba(0,0,0,0.55);
  text-align:center;
  width: 100%;
}

/* ✅ modalBody는 "스크롤 컨테이너를 담는 박스" (자체는 스크롤 X) */
.modalBody{
  background: rgba(255,255,255,0.05);
  border: 1px solid rgba(255,255,255,0.10);
  border-radius: 16px;
  padding: 14px 14px;
  text-align:left;

  overflow: hidden;     /* ✅ 중요: 내부 스크롤만 사용 */
  flex: 1 1 auto;       /* ✅ 중요: 모달 안에서 늘어날 수 있어야 함 */
  min-height: 0;        /* ✅ 중요: flex + overflow 안정화 */

  color: rgba(255,255,255,0.86);
  line-height: 1.6;
}

/* Journey Slab일 때는 modalBody가 남는 높이를 먹지 않게 */
.modal.modal--journeySlab #modalBody{
  flex: 0 0 auto;   /* ✅ 핵심: 내용만큼만 */
  height: auto;
  min-height: 0;
}

/* ✅ 실제 스크롤은 이 래퍼에서만 */
.modalScroll{
  overflow: auto;
  max-height: min(56vh, 520px);  /* “가이드/제작자” 스크롤 높이 */
  padding-right: 6px;
}

/* 드래그 스크롤 UX */
.dragScrollY{ cursor: grab; }
.dragScrollY.dragging{
  cursor: grabbing;
  -webkit-user-select: none;
  user-select: none;
}

/* modalScroll도 드래그 커서 동일 적용 */
.modalScroll{ cursor: grab; }
.modalScroll.dragging{
  cursor: grabbing;
  -webkit-user-select: none;
  user-select: none;
}

.modalBody h3{
  margin: 0 0 8px;
  font-size: 14px;
  color: rgba(255,255,255,0.88);
}
.modalBody p{
  margin: 0 0 10px;
  color: rgba(255,255,255,0.78);
}
.modalBody ul{
  margin: 8px 0 12px 18px;
  padding: 0;
  color: rgba(255,255,255,0.78);
}
.modalBody li{ margin: 6px 0; }

.guideDivider{
  height: 1px;
  width: 100%;
  margin: 4px 0 14px;
  background: rgba(255,255,255,0.12);
  border-radius: 999px;
}

.modalFooter{
  display:flex;
  justify-content:center;
  padding-top: 2px;
}
.closeBtn{
  width: min(240px, 100%);
}

/* Scrollbar (modalScroll) */
.modalScroll::-webkit-scrollbar{ width: 10px; }
.modalScroll::-webkit-scrollbar-thumb{
  background: rgba(195,169,224,0.18);
  border-radius: 999px;
  border: 2px solid rgba(0,0,0,0.12);
}
.modalScroll::-webkit-scrollbar-track{
  background: rgba(0,0,0,0.16);
  border-radius: 999px;
}

/* ===== Ranking ===== */
.rankBox{
  display:flex;
  flex-direction:column;
  gap: 10px;
}

/* 헤더는 고정(스크롤 X) */
.rankHeader{
  display:grid;
  grid-template-columns: var(--rank-col1) 1fr var(--rank-col3);
  gap: 10px;
  padding: 10px 12px;
  border-radius: 14px;
  background: rgba(195,169,224,0.10);
  border: 1px solid rgba(195,169,224,0.18);
  color: rgba(255,255,255,0.88);
  font-weight: 1100;
  align-items:center;
}

/* ✅ 여기만 스크롤 + 높이 고정 */
.rankList{
  overflow: auto;
  max-height: min(44vh, 420px);
  padding-right: 6px;

  /* 드래그 스크롤 감도/안정 */
  cursor: grab;
}
.rankList.dragging{
  cursor: grabbing;
  -webkit-user-select: none;
  user-select: none;
}

/* 행 */
.rankRow{
  display:grid;
  grid-template-columns: var(--rank-col1) 1fr var(--rank-col3);
  gap: 10px;

  padding: 10px 12px;
  border-radius: 14px;
  background: rgba(255,255,255,0.04);
  border: 1px solid rgba(255,255,255,0.08);
  color: rgba(255,255,255,0.86);
  margin-top: 10px;

  align-items:center;
  font-variant-numeric: tabular-nums;
}

/* 컬럼 정렬 + 좌측 이동 */
.col-rank{
  display:grid;
  place-items: center;
  transform: translateX(var(--rank-shift-x));
}
.col-score{
  text-align: center;
  transform: translateX(var(--rank-shift-x));
}
.col-name{ text-align: left; }

.rankRow .name{ color: rgba(255,255,255,0.92); font-weight: 1000; }
.rankRow .score{ color: rgba(255,255,255,0.90); font-weight: 1100; }

/* 노트는 리스트 밖 */
.rankNote{
  flex: 0 0 auto;
  margin: 0;
  opacity: 0.85;
  text-align: center;
}

/* 스크롤바 (rankList) */
.rankList::-webkit-scrollbar{ width: 10px; }
.rankList::-webkit-scrollbar-thumb{
  background: rgba(195,169,224,0.18);
  border-radius: 999px;
  border: 2px solid rgba(0,0,0,0.12);
}
.rankList::-webkit-scrollbar-track{
  background: rgba(0,0,0,0.16);
  border-radius: 999px;
}

/* ===== My Rank (Fixed bottom inside rankBox) ===== */
.myRankBox{
  flex: 0 0 auto;
  display: flex;
  flex-direction: column;
  gap: 8px;

  margin-top: 6px;
  padding-top: 12px;
  border-top: 1px solid rgba(255,255,255,0.10);
}

.myRankTitle{
  margin: 0;
  text-align: center;
  opacity: 0.90;
  font-weight: 1100;
}

.myRankRow{
  margin-top: 0; /* rankRow 기본 margin-top(10px) 제거 */
  background: rgba(195,169,224,0.08);
  border: 1px solid rgba(195,169,224,0.20);
}

/* ===== Creator ===== */
.creatorBody{ text-align:center; }

.makerSymbol{
  width: min(220px, 62%);
  height: auto;
  display:block;
  margin: 10px auto 10px;
  -webkit-user-select: none;
  user-select:none;
  filter: drop-shadow(0 10px 24px rgba(0,0,0,0.55));
}

.creatorBrand{
  margin: 4px 0 10px;
  font-size: 28px;
  font-weight: 1100;
  letter-spacing: 0.3px;
  color: rgba(255,255,255,0.92);
}

.creatorLink{
  display:inline-block;
  color: rgba(195,169,224,0.95);
  text-decoration: none;
  font-weight: 1000;
  border-bottom: 1px solid rgba(195,169,224,0.45);
  padding-bottom: 1px;
}
.creatorLink:hover{
  filter: brightness(1.08);
  border-bottom-color: rgba(195,169,224,0.80);
}

@media (max-width: 520px){
  .title{ font-size: 42px; }
  .subtitle{ font-size: 16px; }

  .panelWrap{
    height: 620px;
    max-height: calc(100vh - 200px);
  }

  :root{
    --rank-col1: 72px;
    --rank-col3: 96px;
  }
}

/* ===== BGM Toggle Button ===== */
.bgm-toggle{
  position: fixed;
  top: 22px;
  right: 22px;
  width: 44px;
  height: 44px;
  padding: 0;
  border: 0;
  background: transparent;
  cursor: pointer;
  z-index: 2000;
  opacity: 0.85;
  -webkit-tap-highlight-color: transparent;
}

.bgm-toggle:hover{ opacity: 1; }

.bgm-toggle img{
  width: 100%;
  height: 100%;
  display: block;
}

/* ===== Auth Actions (Sign in / Sign up) ===== */
/* guest/user wrapper */
.auth-guest, .auth-user{
  display:flex;
  align-items:center;
  gap: 6px;
}

/* nickname label */
.auth-name{
  font: inherit;
  font-weight: 1100;
  color: rgba(255,255,255,0.88);
  text-shadow: 0 0 12px rgba(0,0,0,0.35);
  max-width: 180px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  -webkit-user-select: none;
  user-select: none;

  display: inline-block; /* ✅ 중요: width 계산 안정화 */
  flex-shrink: 0;        /* ✅ 글자 폭 줄어듦 방지 */
}

.auth-actions{
  position: fixed;
  top: 30px;
  right: 40px;
  transform: translateX(-54px); /* BGM 버튼 왼쪽으로 이동 */
  display: flex;
  align-items: center;
  gap: 6px;
  z-index: 2000;
  opacity: 0.9;
  white-space: nowrap;
}

.auth-btn{
  background: none;
  border: 0;
  padding: 0;
  font: inherit;
  font-weight: 900;
  color: rgba(255,255,255,0.85);
  cursor: pointer;
  -webkit-user-select: none;
  user-select: none;
  white-space: nowrap;
}

.auth-btn:hover{
  color: rgba(195,169,224,1);
  text-shadow: 0 0 12px rgba(195,169,224,0.45);
}

.auth-divider{
  opacity: 0.5;
}

/* ===== Auth Modal UI ===== */
.authForm{
  display:flex;
  flex-direction:column;
  gap: 12px;
}

.authField{
  display:flex;
  flex-direction:column;
  gap: 6px;
}

.authLabel{
  font-size: 13px;
  opacity: 0.88;
  font-weight: 1000;
}

.authInput{
  width: 100%;
  border-radius: 14px;
  padding: 12px 12px;
  border: 1px solid rgba(255,255,255,0.12);
  background: rgba(0,0,0,0.22);
  color: rgba(255,255,255,0.92);
  outline: none;
  font-family: inherit;
  font-weight: 900;
  -webkit-user-select: text;
  user-select: text;
}
.authInput:focus{
  border-color: rgba(195,169,224,0.40);
  box-shadow: 0 0 0 3px rgba(195,169,224,0.10);
}

.authHint{
  margin: 0;
  font-size: 12px;
  opacity: 0.72;
  line-height: 1.5;
}

.authMsg{
  margin: 0;
  font-size: 13px;
  line-height: 1.55;
  padding: 10px 12px;
  border-radius: 14px;
  border: 1px solid rgba(255,255,255,0.10);
  background: rgba(255,255,255,0.04);
}
.authMsg.ok{
  border-color: rgba(195,169,224,0.30);
  background: rgba(195,169,224,0.08);
}
.authMsg.err{
  border-color: rgba(255,120,120,0.25);
  background: rgba(255,120,120,0.07);
}

.authRow{
  display:flex;
  gap: 10px;
  align-items:center;
  justify-content: space-between;
  flex-wrap: wrap;
}

.authLinkBtn{
  background: none;
  border: 0;
  padding: 0;
  color: rgba(195,169,224,0.95);
  cursor: pointer;
  font: inherit;
  font-weight: 1000;
  text-decoration: none;
  border-bottom: 1px solid rgba(195,169,224,0.45);
}
.authLinkBtn:hover{
  border-bottom-color: rgba(195,169,224,0.85);
  filter: brightness(1.08);
}

.authBtnWide{
  width: 100%;
}

.authBtnRow{
  display:flex;
  gap: 10px;
}
.authBtnRow button{
  width: 100%;
}

.authSubRow{
  display: flex;
  justify-content: center;
}

/* Journey Slab: modalBody padding 제거해서 석판이 가로 꽉 차게 */
.modalBody.modalBodyNoPad{
  padding: 0;
  background: transparent;
  border: none;
}