:root {
  --ink: #17324a;
  --muted: #5d7488;
  --accent: #e8573f;
  --gold: #e8a91c;
  --glass: rgba(255, 255, 255, 0.82);
  --line: rgba(23, 50, 74, 0.14);
  --font: 'Pretendard', 'Apple SD Gothic Neo', 'Malgun Gothic', 'Noto Sans KR', system-ui, sans-serif;
}

/* 버튼·패널을 빠르게 두 번 눌러도 화면이 확대되지 않게 (아이폰 사파리는 viewport의 user-scalable=no를 무시한다).
   모든 요소에 건다: 스크롤되는 칸 안은 바깥 값을 물려받지 않는다. touch-action을 따로 정한 곳(게임 화면·조이스틱 등)은 그 값이 이긴다.
   두 손가락 확대는 main.js에서 막는다 */
* { box-sizing: border-box; touch-action: manipulation; }

html, body {
  margin: 0;
  height: 100%;
  overflow: hidden;
  background: #cfe3f2;
  color: var(--ink);
  font-family: var(--font);
  -webkit-tap-highlight-color: transparent;
  -webkit-user-select: none;
  user-select: none;
}

[hidden] { display: none !important; }

#scene {
  position: fixed;
  inset: 0;
  width: 100%;
  height: 100%;
  display: block;
  touch-action: none;
}

/* 화면 위 정보 */
#hud {
  position: fixed;
  inset: 0;
  pointer-events: none;
}

.bar.thin { width: 100%; height: 5px; }
.bar.thin i { background: var(--ink); transition: none; }

#labels {
  position: fixed;
  inset: 0;
  overflow: hidden;
  pointer-events: none;
}

.tag {
  position: absolute;
  top: 0;
  left: 0;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 5px;
  will-change: transform;
}
.name {
  padding: 2px 8px;
  border-radius: 999px;
  background: rgba(23, 50, 74, 0.72);
  color: #fff;
  font-size: 12px;
  white-space: nowrap;
}
.tag.me .name { background: var(--accent); }
/* 스키·보드 타는 동안 내 이름표는 숨긴다 (main.js riding-self) */
body.riding-self .tag.me { visibility: hidden; }
/* 닉네임 위 칭호 */
.title-tag {
  margin-bottom: -3px;
  padding: 1px 8px;
  border-radius: 999px;
  background: rgba(255, 244, 214, 0.92);
  color: #7a4b00;
  font-size: 11px;
  font-weight: 700;
  white-space: nowrap;
}
.title-tag[hidden] { display: none; }
/* 칭호 위 랭킹 표시 (1~3위일 때 저절로) */
.rank-tag {
  margin-bottom: -3px;
  padding: 1px 8px;
  border-radius: 999px;
  background: linear-gradient(90deg, #f7c843, #ffe28a);
  color: #5a3a00;
  font-size: 11px;
  font-weight: 800;
  white-space: nowrap;
  box-shadow: 0 1px 3px rgba(0, 0, 0, 0.18);
}
.rank-tag[hidden] { display: none; }
/* 앉아서 하늘을 볼 때는 이름 위 칭호·랭킹 표시를 끈다 */
#labels.crouching .title-tag, #labels.crouching .rank-tag { display: none; }
/* 트리 공원 낙서: 1인칭이라 내 이름표는 숨기고, 다른 사람의 칭호·랭킹도 감춘다 */
#labels.doodling .tag.me { display: none; }
#labels.doodling .title-tag, #labels.doodling .rank-tag { display: none; }
#doodle-hint {
  position: fixed;
  left: 50%;
  top: calc(env(safe-area-inset-top, 0px) + 64px);
  transform: translateX(-50%);
  padding: 8px 16px;
  border-radius: 999px;
  background: rgba(16, 40, 66, 0.55);
  color: #fff;
  font-weight: 700;
  font-size: 14px;
  white-space: nowrap;
  pointer-events: none;
  z-index: 5;
}
#doodle-hint[hidden] { display: none; }
/* 낙서하는 동안 일어나기·지우기 버튼은 안내 아래, 화면 위쪽에 가로로 둔다 */
html body.doodling #actions {
  top: calc(env(safe-area-inset-top, 0px) + 108px);
  bottom: auto;
  left: 16px;
  right: 16px;
  flex-direction: row;
  justify-content: center;
  align-items: center;
}
@media (pointer: coarse) {
  /* 휴대폰은 위쪽 버튼(국기·지도·메뉴)이 두 줄이라 그 아래로 내린다 */
  #doodle-hint { top: calc(env(safe-area-inset-top, 0px) + 112px); }
  html body.doodling #actions { top: calc(env(safe-area-inset-top, 0px) + 156px); }
}
.bubble {
  position: relative;
  display: none;
  width: max-content;
  max-width: 200px;
  padding: 6px 11px;
  border-radius: 12px;
  background: #fff;
  font-size: 14px;
  line-height: 1.35;
  overflow-wrap: anywhere;
  text-align: center;
}
.bubble.show { display: block; }
.bubble::after {
  content: '';
  position: absolute;
  left: 50%;
  bottom: -4px;
  width: 9px;
  height: 9px;
  background: inherit;
  transform: translateX(-50%) rotate(45deg);
}

/* 방 버튼: 국기 + 서버 상태 색 + 방 번호와 인원 */
.flag { flex: none; width: 21px; height: 14px; border-radius: 2px; box-shadow: 0 0 0 1px rgba(0, 0, 0, 0.12); object-fit: cover; }
.server-dot { flex: none; width: 9px; height: 9px; border-radius: 50%; box-shadow: 0 0 0 2px rgba(255, 255, 255, 0.8); }
.server-dot.green { background: #2fbf5b; }
.server-dot.yellow { background: #f2b316; }
.server-dot.red { background: #e5484d; }

/* 행사 예고: 화면 위쪽 가운데, 상단 표시줄 아래 */
#top-center {
  position: fixed;
  top: max(10px, env(safe-area-inset-top));
  left: 50%;
  z-index: 3;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 6px;
  width: max-content;
  max-width: calc(100% - 32px);
  transform: translateX(-50%);
  pointer-events: none;
}
#top-center [hidden] { display: none !important; }
#event-banner {
  max-width: 100%;
  padding: 7px 16px;
  border-radius: 999px;
  background: rgba(20, 24, 48, 0.78);
  color: #ffe9a8;
  font-size: 14px;
  font-weight: 700;
  text-align: center;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
/* 눈싸움 경기 모집 공지. 눈싸움장 안에서는 참가 버튼이 붙는다. */
/* 새 버전 안내: 누르면 새로고침 */
#update-banner {
  display: flex;
  align-items: center;
  gap: 10px;
  max-width: 100%;
  padding: 6px 8px 6px 16px;
  border-radius: 999px;
  background: rgba(20, 24, 48, 0.85);
  color: #fff;
  font-size: 14px;
  font-weight: 700;
}
#update-banner[hidden] { display: none; }
/* 랭킹 공유 버튼 */
.share-button { margin-bottom: 8px; font-weight: 800; }
.share-button[hidden] { display: none; }
#update-reload {
  flex: none;
  min-height: 0;
  padding: 5px 14px;
  border: 0;
  border-radius: 999px;
  background: #47d18c;
  color: #0b3a22;
  font-size: 14px;
  font-weight: 800;
  pointer-events: auto;
  cursor: pointer;
}
/* 행사 알림: 화면 가운데에 잠시 떴다가 사라진다 */
#event-popup {
  position: fixed;
  top: 38%;
  left: 50%;
  z-index: 5;
  padding: 16px 26px;
  border-radius: 18px;
  background: rgba(20, 24, 48, 0.82);
  box-shadow: 0 8px 30px rgba(0, 0, 0, 0.35);
  color: #fff;
  font-size: 22px;
  font-weight: 800;
  text-align: center;
  white-space: nowrap;
  pointer-events: none;
  transform: translate(-50%, -50%);
  animation: event-pop 3s ease forwards;
}
@keyframes event-pop {
  0% { opacity: 0; transform: translate(-50%, -50%) scale(0.85); }
  12% { opacity: 1; transform: translate(-50%, -50%) scale(1.04); }
  20% { transform: translate(-50%, -50%) scale(1); }
  80% { opacity: 1; }
  100% { opacity: 0; transform: translate(-50%, -60%); }
}

/* 눈싸움장 조준점 */
#crosshair {
  position: fixed;
  top: 50%;
  left: 50%;
  width: 26px;
  height: 26px;
  margin: -13px 0 0 -13px;
  border: 2px solid rgba(255, 255, 255, 0.95);
  border-radius: 50%;
  box-shadow: 0 0 0 1px rgba(30, 40, 50, 0.45), inset 0 0 0 1px rgba(30, 40, 50, 0.45);
  pointer-events: none;
}
#crosshair::after {
  content: '';
  position: absolute;
  top: 50%;
  left: 50%;
  width: 4px;
  height: 4px;
  margin: -2px 0 0 -2px;
  border-radius: 50%;
  background: #fff;
  box-shadow: 0 0 0 1px rgba(30, 40, 50, 0.45);
}

.tabs {
  display: flex;
  gap: 6px;
  margin-bottom: 10px;
}
.tabs button {
  flex: 1;
  min-height: 40px;
  border: 1px solid var(--line);
  border-radius: 10px;
  background: #fff;
  font-size: 15px;
}
.tabs button[aria-selected='true'] {
  border-color: var(--ink);
  background: var(--ink);
  color: #fff;
  font-weight: 700;
}
.item-list {
  max-height: 50vh;
  margin: 0;
  padding: 0;
  overflow: auto;
  list-style: none;
  border-top: 1px solid var(--line);
}
.item-list li {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 8px 2px;
  border-bottom: 1px solid var(--line);
}
.item-list .secondary { flex: none; margin-left: auto; font-variant-numeric: tabular-nums; }
.item-list .secondary.wearing { border-color: var(--ink); background: var(--ink); color: #fff; opacity: 1; }
.swatch {
  flex: none;
  width: 40px;
  height: 40px;
  border-radius: 10px;
  border: 1px solid var(--line);
}
.swatch.thumb {
  width: 56px;
  height: 56px;
  background: linear-gradient(#eef4fa, #dde7f0);
  object-fit: cover;
}
.item-name { font-size: 15px; }
.item-kind { display: block; color: var(--muted); font-size: 12px; }
.section {
  margin: 16px 0 8px;
  font-size: 15px;
}
.slider {
  display: grid;
  grid-template-columns: 64px 1fr 40px;
  align-items: center;
  gap: 10px;
  min-height: 40px;
  font-size: 14px;
}
.slider input { width: 100%; accent-color: var(--accent); }
.slider output { color: var(--muted); font-variant-numeric: tabular-nums; text-align: right; }
#language {
  width: 100%;
  min-height: 44px;
  padding: 0 12px;
  border: 1px solid var(--line);
  border-radius: 12px;
  background: #fff;
  color: var(--ink);
  font: inherit;
  font-size: 15px;
}
.note {
  margin: 8px 0 0;
  color: var(--muted);
  font-size: 13px;
}
.code-row {
  display: flex;
  gap: 8px;
}
.code-row .primary { flex: 1; }
.code-box {
  flex: 1;
  min-width: 0;
  min-height: 46px;
  padding: 0 12px;
  border: 1px solid var(--line);
  border-radius: 12px;
  background: #fff;
  color: var(--ink);
  font: 700 18px/1 ui-monospace, 'Consolas', monospace;
  letter-spacing: 0.06em;
  text-align: center;
  outline: none;
}
.code-box:focus { border-color: var(--accent); }
.warning {
  margin: 12px 0;
  padding: 10px 12px;
  border-radius: 10px;
  background: #fdf0ec;
  color: #8a2f1d;
  font-size: 13px;
  line-height: 1.5;
}
#code-message {
  min-height: 18px;
  margin: 8px 0 0;
  color: var(--muted);
  font-size: 13px;
}

@keyframes bump {
  40% { transform: scale(1.14); }
}

#run-info {
  position: absolute;
  top: calc(max(12px, env(safe-area-inset-top)) + var(--notice-h, 0px) + var(--topbar-h, 46px) + 6px);
  left: 16px;
  right: 16px;
  display: flex;
  align-items: center;
  gap: 10px;
  max-width: 420px;
  margin: 0 auto;
  padding: 6px 12px;
  border-radius: 10px;
  background: var(--glass);
  font-size: 13px;
  font-variant-numeric: tabular-nums;
}
#timer { flex: none; width: 46px; text-align: right; }

/* 조작 안내 */
#touch-hint {
  position: fixed;
  left: 16px;
  right: 16px;
  bottom: max(26px, env(safe-area-inset-bottom));
  display: flex;
  justify-content: space-between;
  pointer-events: none;
}
.zone {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 64px;
  height: 64px;
  border-radius: 50%;
  background: rgba(255, 255, 255, 0.5);
  color: var(--ink);
  font-size: 22px;
}

#key-hint {
  position: fixed;
  left: 16px;
  right: 16px;
  bottom: calc(max(14px, env(safe-area-inset-bottom)) + 52px + var(--chat-row, 0px));
  /* 밤하늘이나 어두운 바닥 위에서도 읽히도록 밝은 바탕을 깐다 */
  width: fit-content;
  max-width: calc(100% - 32px);
  margin: 0 auto;
  padding: 2px 10px;
  border-radius: 8px;
  background: rgba(255, 255, 255, 0.72);
  color: var(--ink);
  font-size: 14px;
  text-align: center;
  pointer-events: none;
}

/* 체력이 0일 때 걷기 안내 위에 띄운다. 버튼은 그만큼 위로 올린다. */
#health-warning {
  position: fixed;
  left: 16px;
  right: 16px;
  bottom: calc(max(14px, env(safe-area-inset-bottom)) + 74px + var(--chat-row, 0px));
  width: fit-content;
  margin: 0 auto;
  padding: 3px 10px;
  border-radius: 8px;
  background: rgba(255, 255, 255, 0.88);
  color: #d62d20;
  font-size: 14px;
  font-weight: 700;
  text-align: center;
  pointer-events: none;
}
/* 모닥불 회복: 버튼 바로 위에 불꽃 원(다음 회복까지 차오름)과 남은 시간 */
#warm {
  position: fixed;
  left: 16px;
  right: 16px;
  bottom: calc(max(14px, env(safe-area-inset-bottom)) + 144px + var(--chat-row, 0px));
  width: fit-content;
  margin: 0 auto;
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 5px 14px 5px 5px;
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.9);
  box-shadow: 0 4px 14px rgba(16, 40, 64, 0.16);
  color: var(--ink);
  font-size: 15px;
  font-weight: 700;
  pointer-events: none;
}
#warm[hidden] { display: none; }
#warm-ring {
  --p: 0;
  position: relative;
  width: 34px;
  height: 34px;
  border-radius: 50%;
  background: conic-gradient(#ff8a2a calc(var(--p) * 360deg), rgba(23, 50, 74, 0.12) 0);
  display: grid;
  place-items: center;
}
#warm-ring::before {
  content: '';
  position: absolute;
  inset: 4px;
  border-radius: 50%;
  background: #fff4e6;
}
#warm-ring svg {
  position: relative;
  width: 18px;
  height: 18px;
  fill: #ff7a1a;
  animation: warm-flicker 1.4s ease-in-out infinite;
}
#warm.full #warm-ring { background: #2fbf7a; }
#warm.full #warm-ring svg { fill: #2fbf7a; animation: none; }
@keyframes warm-flicker {
  0%, 100% { transform: scale(1) rotate(-3deg); }
  50% { transform: scale(1.12, 1.18) rotate(3deg); }
}
/* 체력이 찰 때 체력바 바로 아래 오른쪽에서 나타나 살짝 떠오르는 초록 +N (체력바가 화면 맨 위라 위로는 잘린다) */
.meter { position: relative; }
.health-pop {
  position: absolute;
  right: 10px;
  top: calc(100% + 2px);
  color: #2fbf7a;
  font-size: 20px;
  font-weight: 800;
  text-shadow: 0 1px 0 #fff, 0 0 6px #fff;
  pointer-events: none;
  animation: health-pop 1.4s ease-out forwards;
}
@keyframes health-pop {
  0% { transform: translateY(6px) scale(0.6); opacity: 0; }
  15% { transform: translateY(0) scale(1.15); opacity: 1; }
  70% { opacity: 1; }
  100% { transform: translateY(-10px) scale(1); opacity: 0; }
}
.meter.healed { animation: meter-healed 0.9s ease-out; }
@keyframes meter-healed {
  0% { box-shadow: 0 0 0 0 rgba(47, 191, 122, 0.8); }
  100% { box-shadow: 0 0 0 12px rgba(47, 191, 122, 0); }
}
body.no-health #actions { bottom: calc(max(14px, env(safe-area-inset-bottom)) + 112px + var(--chat-row, 0px)); }

#joystick {
  position: fixed;
  left: 24px;
  bottom: calc(max(14px, env(safe-area-inset-bottom)) + 62px + var(--chat-row, 0px));
  z-index: 1;
  display: flex;
  align-items: center;
  justify-content: center;
  width: 120px;
  height: 120px;
  border-radius: 50%;
  background: rgba(255, 255, 255, 0.35);
  touch-action: none;
}
#joystick-knob {
  width: 52px;
  height: 52px;
  border-radius: 50%;
  background: rgba(255, 255, 255, 0.9);
  pointer-events: none;
}

#actions {
  position: fixed;
  left: 16px;
  right: 16px;
  bottom: calc(max(14px, env(safe-area-inset-bottom)) + 84px + var(--chat-row, 0px));
  z-index: 1;
  display: flex;
  justify-content: center;
  gap: 8px;
  pointer-events: none;
}
#actions button {
  min-height: 50px;
  padding: 0 22px;
  border: 0;
  border-radius: 14px;
  font-size: 17px;
  font-weight: 700;
  white-space: nowrap;
  pointer-events: auto;
}
#action { background: var(--accent); color: #fff; }
/* 자유 스케이트 점프: 오른쪽 아래 둥근 버튼 (왼쪽 조이스틱과 마주 본다) */
#skate-jump {
  position: fixed;
  right: 24px;
  bottom: calc(max(14px, env(safe-area-inset-bottom)) + 160px + var(--chat-row, 0px));
  z-index: 1;
  width: 84px;
  height: 84px;
  border: 4px solid rgba(255, 255, 255, 0.9);
  border-radius: 50%;
  background: radial-gradient(circle at 50% 35%, #8fd3ff, #2f74ad);
  color: #fff;
  font: 900 18px var(--font);
  text-shadow: 0 1px 0 rgba(23, 50, 74, 0.5);
  box-shadow: 0 4px 0 #1d5482, 0 6px 16px rgba(23, 50, 74, 0.35);
  cursor: pointer;
  touch-action: none;
  animation: skate-jump-in 0.25s ease-out;
}
#skate-jump:active { transform: translateY(3px); box-shadow: 0 1px 0 #1d5482, 0 3px 10px rgba(23, 50, 74, 0.35); }
@keyframes skate-jump-in { from { opacity: 0; transform: scale(0.7); } to { opacity: 1; transform: scale(1); } }
#action2 { background: var(--glass); color: var(--ink); }
#actions button:hover { filter: brightness(1.06); }
#action[data-kind='liftCancel'] { background: var(--ink); }
/* 처음 온 사람: 리프트 타기 버튼을 반짝이고 위에 안내 말풍선을 띄운다 (한 번 타면 사라진다) */
#action.tutorial { animation: tutorial-pulse 1.2s ease-in-out infinite; }
@keyframes tutorial-pulse {
  0%, 100% { box-shadow: 0 0 0 0 rgba(255, 216, 77, 0.95); transform: scale(1); }
  50% { box-shadow: 0 0 0 9px rgba(255, 216, 77, 0); transform: scale(1.07); }
}
#tutorial-tip {
  position: absolute;
  left: 50%;
  bottom: calc(100% + 14px);
  max-width: min(420px, calc(100vw - 32px));
  padding: 9px 14px;
  border-radius: 12px;
  background: #ffd84d;
  color: #3a2a00;
  font-size: 15px;
  font-weight: 800;
  line-height: 1.35;
  text-align: center;
  white-space: normal;
  width: max-content;
  transform: translateX(-50%);
  box-shadow: 0 4px 14px rgba(0, 0, 0, 0.22);
  animation: tutorial-bob 1.2s ease-in-out infinite;
}
#tutorial-tip::after {
  content: '';
  position: absolute;
  left: calc(50% + var(--tail, 0px));
  bottom: -6px;
  width: 12px;
  height: 12px;
  background: inherit;
  transform: translateX(-50%) rotate(45deg);
}
#tutorial-tip[hidden] { display: none; }
@keyframes tutorial-bob {
  0%, 100% { transform: translate(-50%, 0); }
  50% { transform: translate(-50%, -4px); }
}
#action[data-kind='eating'] { background: var(--ink); }
/* 기차놀이 진행 목록 버튼과 목록 창 */
#train-list { background: #ffd84d; color: #3a2a00; }
#train-list:disabled { opacity: 0.45; filter: grayscale(0.6); }
#actions button[hidden] { display: none; }
#train-rows {
  display: grid;
  gap: 8px;
  max-height: 50vh;
  margin: 4px 0 12px;
  overflow: auto;
}
.train-row {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 8px 10px;
  border: 1px solid var(--line);
  border-radius: 12px;
  background: #fff;
}
.train-row .train-name {
  flex: 1;
  min-width: 0;
  overflow: hidden;
  font-weight: 700;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.train-row .train-count { color: var(--muted, #5b7083); font-variant-numeric: tabular-nums; }
.train-row button { min-height: 38px; padding: 0 14px; }

@media (pointer: coarse) {
  /* 터치 화면: 오른쪽에 위아래로 쌓고, 채팅 줄 바로 위에 둔다 */
  #actions {
    left: 160px;
    bottom: calc(max(14px, env(safe-area-inset-bottom)) + 66px + var(--chat-row, 0px));
    flex-direction: column;
    align-items: flex-end;
  }
  body.no-health #actions { bottom: calc(max(14px, env(safe-area-inset-bottom)) + 94px + var(--chat-row, 0px)); }
  #warm { bottom: calc(max(14px, env(safe-area-inset-bottom)) + 128px + var(--chat-row, 0px)); }
  #actions button {
    max-width: 100%;
    padding: 0 16px;
    font-size: 15px;
    white-space: normal;
  }
}

.gauge {
  width: 64px;
  height: 7px;
  border-radius: 7px;
  background: rgba(23, 50, 74, 0.72);
  overflow: hidden;
}
.gauge i {
  display: block;
  width: 0;
  height: 100%;
  background: #f2b925;
}

#gallery-level-list {
  display: grid;
  gap: 8px;
  margin: 4px 0 12px;
}

/* 키오스크: 투명한 터치판. 확대돼 있는 동안 게임 버튼과 이름표는 치운다 */
#kiosk {
  position: fixed;
  inset: 0;
  z-index: 5;
  touch-action: none;
  cursor: pointer;
}
body.kiosk-open :is(#hud, #actions, #emotes, #chat-log, #chat, #top-center, #key-hint, #joystick, #labels, #health-warning) {
  visibility: hidden;
}
body.kiosk-open :is(#hud, #actions, #emotes, #chat-log, #top-center, #joystick) * { visibility: hidden; }

#toast {
  position: fixed;
  top: 24%;
  left: 50%;
  transform: translate(-50%, 6px);
  padding: 6px 14px;
  border-radius: 999px;
  background: var(--glass);
  font-size: 15px;
  font-weight: 700;
  white-space: nowrap;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.15s, transform 0.15s;
}
#toast.show { opacity: 1; transform: translate(-50%, 0); }
#toast.hit { color: var(--accent); }
#toast.coin { color: #b47a06; }

#flash {
  position: fixed;
  inset: 0;
  background: #fff;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.35s;
}
#flash.on { opacity: 1; transition: none; }

/* 선택과 결과 */
.panel-wrap {
  position: fixed;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 16px;
  background: rgba(23, 50, 74, 0.18);
}

.panel {
  width: min(440px, 100%);
  max-height: 100%;
  overflow: auto;
  padding: 24px 20px;
  border-radius: 18px;
  background: rgba(255, 255, 255, 0.94);
}
.panel h1 {
  margin: 0;
  font-size: 23px;
  text-align: center;
}
.panel.wide-panel { width: min(620px, 100%); }

/* 보석 창 */
/* #hud는 클릭을 아래로 흘려보내서, 보석 칸과 + 버튼은 따로 클릭을 받게 한다 */
#gem-box { cursor: pointer; pointer-events: auto; }
/* 결제가 열리기 전: 보석 개수만 (누를 수 없음, + 없음) */
#gem-box.count-only { cursor: default; }
#gem-box .hud-plus[hidden] { display: none; }
.hud-plus {
  flex: none;
  display: grid;
  place-items: center;
  width: 22px;
  height: 22px;
  margin-right: -4px;
  padding: 0;
  border: 0;
  border-radius: 50%;
  background: linear-gradient(180deg, #4ad391, #22a868);
  box-shadow: inset 0 -2px 0 rgba(0, 0, 0, 0.14), 0 1px 2px rgba(10, 60, 30, 0.25);
  color: #fff;
  cursor: pointer;
  pointer-events: auto;
}
.hud-plus[hidden] { display: none; }
.hud-plus svg { width: 14px; height: 14px; fill: none; stroke: currentColor; stroke-width: 2.6; stroke-linecap: round; }
.hud-plus:active { transform: translateY(1px); }
#gem-box[hidden] .hud-plus { display: none; }
/* 상점 창: 고른 칸만 보인다. 한 칸만 보일 때는 소제목을 숨긴다 (창 제목이 같은 말) */
#gem-shop[data-mode="health"] .shop-sec:not([data-sec="health"]),
#gem-shop[data-mode="gold"] .shop-sec:not([data-sec="gold"]),
#gem-shop[data-mode="gems"] .shop-sec:not([data-sec="gems"]) { display: none; }
#gem-shop:not([data-mode="all"]) .gem-head { display: none; }
.gold-packs img { border-radius: 18px; }
.gem-packs .cost { display: inline-flex; align-items: center; justify-content: center; gap: 6px; }
.gem-packs .cost .gem-mark { width: 18px; height: 16px; }
#gem-box[hidden] { display: none; }
#gem-box:focus-visible { outline: 3px solid var(--ink); outline-offset: 2px; }
.gem-body { max-height: 62vh; margin-top: 4px; padding: 2px; overflow: auto; }
.gem-head { margin: 14px 0 8px; font-size: 15px; font-weight: 800; }
.gem-head:first-child { margin-top: 0; }
.gem-cost { display: inline-flex; align-items: center; gap: 5px; font-variant-numeric: tabular-nums; }
.gem-cost .gem-mark { width: 17px; height: 15px; }
.gem-cost .coin-mark { width: 16px; height: 16px; }
.gem-refill {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 12px 14px;
  border: 1px solid var(--line);
  border-radius: 14px;
  background: #fff;
}
.gem-refill .heart {
  flex: none;
  display: grid;
  place-items: center;
  width: 40px;
  height: 40px;
  border-radius: 50%;
  background: radial-gradient(circle at 35% 30%, #ff8a8a, #e5484d 70%);
  color: #fff;
}
.gem-refill .heart svg { width: 22px; height: 22px; fill: currentColor; }
.gem-refill b { flex: 1; font-size: 15px; }
.gem-refill .secondary, .gem-exchange .secondary, .gem-packs .primary { min-height: 38px; padding: 0 14px; }
.gem-exchange, .gem-packs { display: grid; gap: 10px; margin: 0; padding: 0; list-style: none; }
.gem-exchange { grid-template-columns: repeat(3, minmax(0, 1fr)); }
.gem-exchange li {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 6px;
  padding: 12px 8px 10px;
  border: 1px solid var(--line);
  border-radius: 14px;
  background: #fff;
}
.gem-exchange .arrow { color: var(--muted, #7a8a99); font-size: 13px; line-height: 1; }
.gem-exchange .gem-cost { font-size: 15px; font-weight: 800; }
.gem-exchange .secondary { width: 100%; }
.gem-packs { grid-template-columns: repeat(3, minmax(0, 1fr)); }
.gem-packs li {
  position: relative;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 4px;
  padding: 8px 8px 10px;
  border: 1px solid var(--line);
  border-radius: 14px;
  background: #fff;
}
.gem-packs img { width: 100%; aspect-ratio: 1; object-fit: contain; }
.gem-packs b { font-size: 15px; font-variant-numeric: tabular-nums; }
.gem-packs .bonus {
  position: absolute;
  top: 6px;
  right: 6px;
  padding: 2px 7px;
  border-radius: 999px;
  background: #e5484d;
  color: #fff;
  font-size: 11px;
  font-weight: 800;
}
.gem-packs .primary { width: 100%; font-variant-numeric: tabular-nums; }
.gem-note { margin: 10px 2px 0; color: #6a7f93; font-size: 12.5px; line-height: 1.5; }
.gem-note a { color: #2f6fd0; font-weight: 700; white-space: nowrap; }
@media (max-width: 520px) {
  .gem-packs { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .gem-exchange { gap: 6px; }
  .gem-exchange li { padding: 10px 4px 8px; }
  .gem-exchange .gem-cost { font-size: 14px; }
}

/* 눈싸움장 집게 상점: 집게 그림 카드 */
#clamp-grid {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 10px;
  max-height: 58vh;
  margin: 14px 0 0;
  padding: 2px;
  overflow: auto;
  list-style: none;
}
@media (max-width: 520px) {
  #clamp-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
}
.clamp-card {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 4px;
  padding: 8px 8px 10px;
  border: 1px solid var(--line);
  border-radius: 14px;
  background: #fff;
}
.clamp-card.held { border-color: var(--ink); box-shadow: inset 0 0 0 1px var(--ink); }
.clamp-card img { width: 100%; aspect-ratio: 24 / 17; object-fit: contain; border-radius: 10px; background: #eef3f7; }
.clamp-card b { font-size: 14px; text-align: center; }
.clamp-card .secondary { width: 100%; min-height: 36px; font-variant-numeric: tabular-nums; }
.clamp-card .secondary.wearing { border-color: var(--ink); background: var(--ink); color: #fff; opacity: 1; }
.sub {
  margin: 6px 0 18px;
  color: var(--muted);
  font-size: 14px;
  text-align: center;
}

button {
  font: inherit;
  color: inherit;
  cursor: pointer;
}

.cards {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 10px;
}
.card {
  display: flex;
  flex-direction: column;
  gap: 6px;
  min-height: 120px;
  padding: 14px;
  border: 1px solid var(--line);
  border-radius: 14px;
  background: #fff;
  text-align: left;
}
.card:hover { border-color: var(--accent); }
.card b { font-size: 19px; }
.card span { color: var(--muted); font-size: 13px; line-height: 1.45; }

.stats {
  margin: 0 0 18px;
  border-top: 1px solid var(--line);
}
.stats div {
  display: flex;
  justify-content: space-between;
  padding: 9px 2px;
  border-bottom: 1px solid var(--line);
  font-size: 15px;
}
.stats dt { color: var(--muted); }
.stats dd { margin: 0; font-weight: 700; font-variant-numeric: tabular-nums; }

.primary {
  width: 100%;
  min-height: 48px;
  border: 0;
  border-radius: 12px;
  background: var(--accent);
  color: #fff;
  font-size: 16px;
  font-weight: 700;
}
.primary:hover { filter: brightness(1.06); }

.secondary {
  min-height: 42px;
  padding: 0 16px;
  border: 1px solid var(--line);
  border-radius: 12px;
  background: #fff;
  font-size: 15px;
  white-space: nowrap;
}
.secondary:hover:not(:disabled) { border-color: var(--accent); }
.secondary:disabled { opacity: 0.45; cursor: default; }
.secondary.wide { width: 100%; margin-top: 10px; }

/* 지금 나오는 곡: 위쪽 오른쪽 버튼 줄 맨 앞(방 버튼 왼쪽). 모양은 옆 버튼들과 같다. */
#now-playing {
  display: flex;
  align-items: center;
  gap: 8px;
  min-width: 0;
  max-width: 300px;
  height: 40px;
  padding: 0 5px 0 12px;
  border: 1px solid rgba(255, 255, 255, 0.75);
  border-radius: 14px;
  background: rgba(255, 255, 255, 0.86);
  box-shadow: 0 4px 14px rgba(16, 40, 64, 0.14), 0 2px 0 rgba(180, 205, 226, 0.9);
  -webkit-backdrop-filter: blur(10px);
  backdrop-filter: blur(10px);
  color: var(--ink);
  font-size: 13px;
  pointer-events: auto;
}
#now-playing[hidden] { display: none; }
.np-icon { color: var(--accent); font-weight: 700; }
/* ♪ 버튼: 누르면 막대를 접고 펼친다 */
#np-fold {
  flex: none;
  margin-left: -6px;
  width: 28px;
  height: 28px;
  padding: 0;
  border: 0;
  border-radius: 50%;
  background: transparent;
  font-size: 14px;
  line-height: 28px;
  cursor: pointer;
}
#np-fold:hover { background: rgba(43, 127, 191, 0.12); }
/* 접으면 ♪ 동그라미 하나만 남는다 */
#now-playing.folded { justify-content: center; width: 40px; padding: 0; gap: 0; }
#now-playing.folded #np-fold { margin-left: 0; }
#now-playing.folded #np-title, #now-playing.folded #np-toggle, #now-playing.folded #np-next { display: none; }
#np-title { min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
#np-toggle, #np-next {
  flex: none;
  width: 30px;
  height: 30px;
  padding: 0;
  border: 0;
  border-radius: 50%;
  background: #fff;
  font-size: 13px;
  line-height: 30px;
}
#np-toggle { margin-right: -4px; font-size: 11px; letter-spacing: -2px; }
#np-toggle:hover, #np-next:hover { background: var(--accent); color: #fff; }
/* 멈춘 동안은 곡 이름을 흐리게 */
#now-playing.paused #np-title, #now-playing.paused .np-icon { opacity: 0.5; }
/* 좁은 화면: 옆 버튼들과 같은 높이로, 펼쳐도 한 줄에 들어가게 */
@media (max-width: 700px) {
  #now-playing { height: 38px; border-radius: 13px; }
  #now-playing.folded { width: 38px; }
  #now-playing { max-width: none; }
}

/* 랭킹·옷장 같은 창이 떠 있으면 아래쪽 버튼들이 창의 닫기 버튼을 가리지 않게 숨긴다 */
body.popup-open #emotes,
body.popup-open #chat-log,
body.popup-open #actions,
body.popup-open #key-hint,
body.popup-open #touch-hint,
body.popup-open #joystick,
body.popup-open #now-playing { display: none !important; }

/* 후원 (Ko-fi) */
.support-link {
  display: flex;
  align-items: center;
  justify-content: center;
  min-height: 42px;
  margin-top: 10px;
  border-radius: 12px;
  background: #ffdd00;
  color: #1f1f1f;
  font-size: 15px;
  font-weight: 700;
  text-decoration: none;
}
.support-link:hover { filter: brightness(0.96); }
.support-link[hidden] { display: none; }
#settings-support .note { margin-bottom: 0; }

/* 입장 */
/* 불러오는 중 화면: 진행 막대와 "접속 중…"(받는 중에는 받은 용량). 받을 크기를 모르는 동안은 막대 안에서 빛줄기가 오간다.
   실패하면 막대를 거두고 안내와 다시 시도 버튼을 보인다. */
.loading-panel { text-align: center; }
.loading-bar {
  position: relative;
  height: 12px;
  margin: 20px 4px 10px;
  overflow: hidden;
  border-radius: 999px;
  background: rgba(43, 127, 191, 0.16);
  box-shadow: inset 0 1px 2px rgba(20, 60, 100, 0.18);
}
#loading-bar-fill {
  width: 0;
  height: 100%;
  border-radius: inherit;
  background: linear-gradient(180deg, #f27a63 0%, var(--accent) 100%);
  transition: width 0.25s ease-out;
}
.loading-bar.waiting #loading-bar-fill {
  width: 30%;
  transition: none;
  animation: loading-sweep 1.2s ease-in-out infinite;
}
@keyframes loading-sweep {
  from { transform: translateX(-110%); }
  to { transform: translateX(340%); }
}
#loading-text { font-variant-numeric: tabular-nums; }
/* 접속 중에는 뒤의 게임 화면을 가린다 (다시 들어올 때 리프트 앞이 비쳤다가 마지막 자리로 옮겨지는 게 보이지 않게) */
#loading { background: linear-gradient(180deg, #cfe3f1 0%, #eef4f9 100%); }
/* 출발해서 처음 받는 동안은 첫 화면 배경(눈 내리는 산)이 게임 화면을 가리고 있으니 그 위에 그대로 띄운다 */
#front-bg:not([hidden]) ~ #loading { background: none; }
#loading-problem, #loading-retry { display: none; }
#loading.failed .loading-bar, #loading.failed #loading-text { display: none; }
#loading.failed #loading-problem { display: block; margin-top: 14px; }
#loading.failed #loading-retry:not([hidden]) { display: block; margin-top: 4px; }

#entry-form label {
  display: block;
  margin-bottom: 6px;
  color: var(--muted);
  font-size: 14px;
}
input {
  -webkit-user-select: text;
  user-select: text;
}
#name {
  width: 100%;
  min-height: 46px;
  padding: 0 14px;
  border: 1px solid var(--line);
  border-radius: 12px;
  background: #fff;
  color: var(--ink);
  font: inherit;
  font-size: 16px;
  outline: none;
}
#name:focus { border-color: var(--accent); }
#name-error {
  min-height: 20px;
  margin: 6px 0 12px;
  color: var(--accent);
  font-size: 13px;
}

/* 방 목록 */
#room-list {
  max-height: 46vh;
  margin: 0 0 14px;
  padding: 0;
  overflow: auto;
  list-style: none;
  border-top: 1px solid var(--line);
}
#room-list li {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  padding: 8px 2px;
  border-bottom: 1px solid var(--line);
  font-size: 15px;
  font-variant-numeric: tabular-nums;
}
#rooms-close { width: 100%; }
#room-list .server-name { display: flex; align-items: center; gap: 8px; min-width: 0; font-weight: 700; }
#room-list .flag { width: 27px; height: 18px; }
#room-list .server-state { display: flex; align-items: center; gap: 6px; margin-left: auto; color: var(--muted); font-size: 13px; white-space: nowrap; }
#room-list li.mine { background: rgba(43, 127, 191, 0.08); }

/* 채팅 기록: 감정표현 줄 바로 위. 평소엔 마지막 한 줄, 누르면 위로 펼친다. */
#chat-log {
  position: fixed;
  left: 16px;
  right: 16px;
  bottom: calc(max(14px, env(safe-area-inset-bottom)) + 50px);
  z-index: 2;
  display: flex;
  flex-direction: column;
  max-width: 520px;
  margin: 0 auto;
  pointer-events: none;
}
#chat-log[hidden] { display: none; }
@media (max-width: 520px) {
  #chat-log { left: 8px; right: 8px; }
}
/* 채팅 기록 한 줄만큼 조이스틱·행동 버튼·안내를 위로 올린다 */
body.chat-row { --chat-row: 42px; }
/* 채팅 기록을 펼친 동안은 가려지는 조이스틱과 행동 버튼을 숨긴다 (게임 화면을 누르면 접힌다) */
body.chat-log-open #joystick,
body.chat-log-open #actions,
body.chat-log-open #key-hint,
body.chat-log-open #health-warning,
body.chat-log-open #warm { display: none !important; }
#chat-log-line {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 4px;
  width: 100%;
  min-width: 0;
  height: 34px;
  padding: 0 8px 0 13px;
  border: 1px solid rgba(255, 255, 255, 0.75);
  border-radius: 17px;
  background: var(--glass);
  color: var(--ink);
  font: inherit;
  font-size: 14px;
  text-align: left;
  cursor: pointer;
  pointer-events: auto;
  box-shadow: 0 4px 14px rgba(20, 50, 80, 0.12);
}
#chat-log-line[hidden], #chat-log-panel[hidden] { display: none; }
#chat-log-line:active { transform: scale(0.98); }
#chat-log-last .empty { color: var(--muted); }
#chat-log-last {
  min-width: 0;
  overflow: hidden;
  white-space: nowrap;
  text-overflow: ellipsis;
}
#chat-log svg {
  flex: none;
  width: 18px;
  height: 18px;
  fill: none;
  stroke: currentColor;
  stroke-width: 2.2;
  stroke-linecap: round;
  stroke-linejoin: round;
  opacity: 0.55;
}
#chat-log .who { margin-right: 6px; color: #2b7fbf; font-weight: 800; }
#chat-log .mine .who { color: var(--accent); }
/* 새 채팅이 오면 한 줄이 잠깐 밝아진다 */
#chat-log-line.fresh { animation: chat-fresh 0.9s ease-out; }
@keyframes chat-fresh {
  0% { background: #fff; transform: scale(1.04); }
  100% { background: var(--glass); transform: none; }
}
#chat-log-panel {
  display: flex;
  flex-direction: column;
  width: 100%;
  max-height: min(34vh, 280px);
  border: 1px solid rgba(255, 255, 255, 0.75);
  border-radius: 16px;
  background: var(--glass);
  color: var(--ink);
  box-shadow: 0 6px 20px rgba(20, 50, 80, 0.18);
  pointer-events: auto;
  overflow: hidden;
}
#chat-log-close {
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex: none;
  height: 36px;
  padding: 0 8px 0 13px;
  border: 0;
  border-bottom: 1px solid var(--line);
  background: transparent;
  color: var(--muted);
  font: inherit;
  font-size: 13px;
  font-weight: 700;
  cursor: pointer;
}
#chat-log-list {
  flex: 1;
  min-height: 0;
  margin: 0;
  padding: 6px 13px 10px;
  list-style: none;
  overflow-y: auto;
  overscroll-behavior: contain;
  -webkit-overflow-scrolling: touch;
  font-size: 14px;
  line-height: 1.45;
}
#chat-log-list li { padding: 3px 0; overflow-wrap: anywhere; }

/* 감정표현 */
#emotes {
  position: fixed;
  left: 16px;
  right: 16px;
  bottom: max(14px, env(safe-area-inset-bottom));
  z-index: 2;
  display: flex;
  justify-content: center;
  gap: 6px;
  max-width: 760px;
  margin: 0 auto;
  pointer-events: none;
}
#emotes[hidden] { display: none; }
#emotes button {
  display: flex;
  align-items: center;
  gap: 5px;
  min-height: 42px;
  padding: 0 14px;
  border: 1px solid var(--line);
  border-radius: 21px;
  background: var(--glass);
  color: var(--ink);
  font: inherit;
  font-size: 15px;
  font-weight: 700;
  cursor: pointer;
  pointer-events: auto;
}
#emotes button:hover { background: #fff; }
#emotes button:active { transform: scale(0.95); }
#emotes button:disabled { opacity: 0.5; cursor: default; transform: none; }
#emotes .emoji { font-size: 19px; line-height: 1; }
#emotes button { white-space: nowrap; }
/* 채팅 입력창: 감정표현 줄 자리에 나온다 */
#chat {
  position: fixed;
  left: 16px;
  right: 16px;
  bottom: max(14px, env(safe-area-inset-bottom));
  z-index: 2;
  display: flex;
  gap: 6px;
  max-width: 520px;
  margin: 0 auto;
}
#chat[hidden] { display: none; }
#chat-input {
  flex: 1;
  min-width: 0;
  min-height: 42px;
  padding: 0 14px;
  border: 1px solid var(--line);
  border-radius: 21px;
  background: var(--glass);
  color: var(--ink);
  font: inherit;
  font-size: 16px;
  outline: none;
}
#chat-input:focus { background: #fff; border-color: var(--accent); }
#chat button { min-height: 42px; border-radius: 21px; padding: 0 16px; white-space: nowrap; }
/* 휴대폰·좁은 창: 여섯 개가 한 줄에 들어가게 그림 아래에 이름을 작게 쓰고, 버튼 폭을 똑같이 나눈다
   (일본어 이름이 길어 옆으로 놓으면 760px보다 좁은 화면에서 넘쳤다) */
@media (max-width: 760px) {
  #emotes { left: 8px; right: 8px; gap: 4px; }
  #emotes button { flex: 1 1 0; min-width: 0; max-width: 74px; flex-direction: column; justify-content: center; gap: 1px; padding: 3px 2px; border-radius: 14px; font-size: 11px; line-height: 1.15; }
  #emotes .emoji { font-size: 17px; }
}
@media (max-width: 520px) {
  #chat { left: 8px; right: 8px; }
}
@media (max-width: 400px) {
  #emotes { gap: 3px; }
  #emotes button { font-size: 10px; letter-spacing: -0.02em; }
  #emotes .emoji { font-size: 16px; }
}

#banner {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  z-index: 3;
  padding: 7px 16px;
  background: var(--accent);
  color: #fff;
  font-size: 14px;
  text-align: center;
}

@media (max-width: 380px) {
  .cards { grid-template-columns: 1fr; }
  .card { min-height: 0; }
}


/* 공지: 제목을 누르면 내용이 펼쳐지는 게시판 */
.notice-list { border-top: 1px solid var(--line); }
.notice-item { border-bottom: 1px solid var(--line); }
.notice-item summary {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 12px 2px;
  font-size: 15px;
  font-weight: 700;
  cursor: pointer;
  list-style: none;
}
.notice-item summary::-webkit-details-marker { display: none; }
.notice-item summary::after { content: '▾'; margin-left: auto; color: var(--muted); }
.notice-item[open] summary::after { content: '▴'; }
/* 지난번에 본 뒤로 새로 생긴 공지 */
.notice-item.new summary > span:nth-child(2)::after {
  content: 'NEW';
  margin-left: 6px;
  padding: 1px 6px;
  border-radius: 6px;
  background: #ffd84d;
  color: #3a2a00;
  font-size: 11px;
  font-weight: 800;
  vertical-align: 2px;
}
.notice-tag {
  flex: none;
  padding: 2px 8px;
  border-radius: 999px;
  background: var(--accent);
  color: #fff;
  font-size: 12px;
}
.notice-item p {
  margin: 0 2px 12px;
  color: var(--ink);
  font-size: 14px;
  line-height: 1.6;
  white-space: pre-line;
}
.notice-item .support-link { margin: 0 0 12px; }
/* 대만 후원 금액 고르기 */
.donate-amount {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 18px;
  margin: 4px 0 18px;
}
.donate-amount .secondary { width: 52px; min-height: 52px; padding: 0; border-radius: 50%; font-size: 24px; }
#donate-value { min-width: 130px; font-size: 30px; text-align: center; font-variant-numeric: tabular-nums; }

/* 랭킹 */
.ranking-list {
  margin: 0;
  padding: 0;
  list-style: none;
  border-top: 1px solid var(--line);
}
.ranking-list li {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 9px 2px;
  border-bottom: 1px solid var(--line);
  font-size: 15px;
}
.ranking-list li.mine { background: #fff4e5; }
/* 10위까지 보여서 길면 목록 안에서 스크롤한다 */
#ranking-list, #result-ranking { max-height: 42vh; overflow-y: auto; }
.ranking-list li.empty { justify-content: center; color: var(--muted); font-size: 14px; }
.rank-badge {
  flex: none;
  width: 26px;
  height: 26px;
  border-radius: 50%;
  background: #e9edf1;
  font-size: 13px;
  font-weight: 700;
  line-height: 26px;
  text-align: center;
}
.ranking-list li:nth-child(1) .rank-badge { background: #f2c230; color: #fff; }
.ranking-list li:nth-child(2) .rank-badge { background: #aeb6bd; color: #fff; }
.ranking-list li:nth-child(3) .rank-badge { background: #c98a4a; color: #fff; }
.rank-name { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.rank-time { font-weight: 700; font-variant-numeric: tabular-nums; }
.rank-coins { width: 52px; color: var(--muted); font-size: 13px; text-align: right; font-variant-numeric: tabular-nums; }
#result-rank .new-best { color: var(--accent); font-weight: 700; }
#result .panel, #notice .panel, #ranking .panel { max-height: 92vh; overflow: auto; }
/* 도착 창: 화면이 낮으면(모바일) 랭킹 목록이 줄어들어 아래 버튼이 바로 보인다 */
/* dvh: 아이폰 사파리 아래 주소창에 가리지 않게 실제 보이는 높이로 잰다 */
#result .panel { display: flex; flex-direction: column; max-height: min(92vh, 100%); max-height: min(92dvh, 100%); }
#result .panel > * { flex: none; }
#result .panel > #result-ranking { flex: 0 1 auto; min-height: 100px; }
/* 도착 창 기록·코인 등은 좌우 두 열로 (세로 공간을 아낀다) */
#result .stats { display: grid; grid-template-columns: 1fr 1fr; column-gap: 18px; border-top: 0; }
#result .stats div { border-top: 1px solid var(--line); border-bottom: 0; font-size: 14px; }
#result .stats { border-bottom: 1px solid var(--line); }
/* 기록만 한 줄 전체, 나머지는 두 개씩 */
#result .stats div:first-child { grid-column: 1 / -1; }

/* ---------- 옷장: 위에 내 모습, 아래에 품목 카드 ---------- */
#attendance .panel { max-height: 94vh; overflow: auto; }
.panel.wardrobe {
  display: flex;
  flex-direction: column;
  width: min(580px, 100%);
  /* 아래 채팅 입력줄을 가리지 않게 */
  max-height: calc(100vh - 130px);
  padding: 18px 16px;
}
.panel.wardrobe .sub { margin: 4px 0 10px; }
#wardrobe-stage {
  display: flex;
  flex: none;
  align-items: center;
  gap: 14px;
  margin-bottom: 10px;
  padding: 6px 14px;
  border-radius: 14px;
  background: linear-gradient(#eef4fa, #dde7f0);
}
#wardrobe-portrait { flex: none; width: 92px; height: 148px; object-fit: contain; }
#wardrobe-pick { display: flex; flex: 1; flex-direction: column; align-items: flex-start; gap: 4px; min-width: 0; }
#wardrobe-name { max-width: 100%; font-size: 17px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
#wardrobe-kind { color: var(--muted); font-size: 13px; }
.ward-actions { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 6px; }
.ward-actions button { min-height: 40px; padding: 0 16px; font-variant-numeric: tabular-nums; }
#wardrobe-groups { flex: none; margin-bottom: 8px; }
#wardrobe-bar { display: flex; flex: none; align-items: center; gap: 8px; margin-bottom: 8px; }
#wardrobe-slots { display: flex; flex: 1; gap: 6px; min-width: 0; overflow-x: auto; }
#wardrobe-slots button {
  flex: none;
  min-height: 32px;
  padding: 0 14px;
  border: 1px solid var(--line);
  border-radius: 999px;
  background: #fff;
  font-size: 13px;
  white-space: nowrap;
}
#wardrobe-slots button[aria-selected='true'] { border-color: var(--accent); background: var(--accent); color: #fff; font-weight: 700; }
#wardrobe-mine { display: flex; flex: none; align-items: center; gap: 4px; color: var(--muted); font-size: 13px; cursor: pointer; }
#wardrobe-mine input { margin: 0; accent-color: var(--accent); }
#equip-note { flex: none; margin: 0 0 8px; }
#wardrobe-grid {
  display: grid;
  flex: 1 1 auto;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  align-content: start;
  gap: 8px;
  min-height: 140px;
  padding: 2px;
  overflow: auto;
}
.ward-head { grid-column: 1 / -1; margin: 6px 2px 0; color: var(--muted); font-size: 12px; }
.ward-head:first-child { margin-top: 0; }
.ward-empty { grid-column: 1 / -1; margin: 24px 0; color: var(--muted); font-size: 14px; text-align: center; }
.ward-card {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 3px;
  min-width: 0;
  padding: 6px 5px 7px;
  border: 1px solid var(--line);
  border-radius: 12px;
  background: #fff;
}
.ward-card .swatch { width: 100%; height: auto; aspect-ratio: 1; }
.ward-name {
  display: -webkit-box;
  max-width: 100%;
  min-height: 2.5em;
  overflow: hidden;
  font-size: 12px;
  line-height: 1.25;
  text-align: center;
  -webkit-box-orient: vertical;
  -webkit-line-clamp: 2;
}
.ward-tag { font-size: 12px; font-weight: 700; font-variant-numeric: tabular-nums; }
.ward-tag.owned { color: var(--muted); font-weight: 400; }
.ward-card.short .ward-tag { color: var(--muted); font-weight: 400; }
.ward-card.wearing { border-color: var(--ink); box-shadow: inset 0 0 0 1px var(--ink); }
.ward-card.picked { border-color: var(--accent); box-shadow: inset 0 0 0 2px var(--accent); }
@media (max-width: 520px) {
  .panel.wardrobe { padding: 14px 12px; }
  #wardrobe-grid { grid-template-columns: repeat(3, minmax(0, 1fr)); }
  #wardrobe-portrait { width: 76px; height: 122px; }
}

/* ---------- 출석체크 ---------- */
#attendance-grid {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 8px;
  margin: 0 0 12px;
  padding: 0;
  list-style: none;
}
.attendance-day {
  position: relative;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 4px;
  min-height: 104px;
  padding: 8px 4px;
  border: 1px solid var(--line);
  border-radius: 12px;
  background: #f4f7fa;
  text-align: center;
  font-size: 12px;
}
.attendance-day.last { grid-column: span 2; }
.attendance-day.claimed { background: #fff8e6; border-color: #f0d38a; }
.attendance-day.today { box-shadow: 0 0 0 2px var(--accent); animation: bump 0.5s ease-out; }
.attendance-day .swatch.thumb { width: 48px; height: 48px; }
.coin-mark.big { width: 30px; height: 30px; box-shadow: inset 0 0 0 4px #c78a0c; }
.gem-mark.big { width: 34px; height: 31px; }
.attendance-reward { font-weight: 700; font-variant-numeric: tabular-nums; }
.attendance-day.gift .attendance-reward { font-size: 11px; line-height: 1.25; }
#attendance-sub { white-space: pre-line; }
#attendance-tabs { display: flex; gap: 6px; margin: 0 0 10px; }
#attendance-tabs[hidden] { display: none; }
#attendance-tabs button {
  flex: 1;
  padding: 7px 8px;
  border: 1px solid var(--line);
  border-radius: 999px;
  background: #fff;
  font-size: 14px;
}
#attendance-tabs button[aria-selected='true'] { border-color: var(--ink); background: var(--ink); color: #fff; font-weight: 700; }
.attendance-stamp {
  position: absolute;
  top: 6px;
  right: 6px;
  padding: 1px 6px;
  border: 2px solid #e8453c;
  border-radius: 8px;
  color: #e8453c;
  font-size: 11px;
  font-weight: 800;
  transform: rotate(12deg);
}

/* ---------- 스키장 후원인사 목록 ---------- */
#donors .panel { max-height: 92vh; overflow: auto; }
#donors-list { max-height: 56vh; overflow: auto; margin-bottom: 12px; }
#donors .support-link { margin: 0 0 10px; }
.donor-amount { font-weight: 700; font-variant-numeric: tabular-nums; }
/* 금액 단계 색: 게시판 연출과 같은 순서 (전구 · 핑크 · 무지개 · 후광 · 서치라이트) */
.donor-amount.tier-0 { color: #b98a3a; }
.donor-amount.tier-1 { color: #e0479b; }
.donor-amount.tier-2, .donor-amount.tier-3, .donor-amount.tier-4 {
  background: linear-gradient(90deg, #ff4f6d, #ffb23f, #3fcf6e, #3f9dff, #a560ff);
  -webkit-background-clip: text;
  background-clip: text;
  color: transparent;
}
.donor-amount.tier-4 { font-size: 16px; }

/* 이어하기 코드 창: 코드 아래 짧은 안내 */
#code-issued .note { margin: 8px 0 14px; text-align: center; }

/* 게임을 열 수 없을 때 꺼 둔 시작 버튼 */
.primary:disabled { opacity: 0.45; cursor: default; filter: none; }

/* 닉네임 칸과 랜덤 닉네임 주사위 */
.name-row { display: flex; gap: 8px; }
.name-row #name { flex: 1; min-width: 0; }
#name-dice { flex: none; width: 46px; min-height: 46px; padding: 0; font-size: 22px; line-height: 1; }
#name-dice.roll { animation: dice-roll 0.35s ease-out; }
@keyframes dice-roll {
  from { transform: rotate(-220deg) scale(0.8); }
  to { transform: none; }
}

/* 설정의 지금 닉네임 (코드 칸과 같은 줄 모양, 글자는 보통 글꼴) */
.name-box {
  flex: 1;
  min-width: 0;
  min-height: 42px;
  padding: 0 12px;
  border: 1px solid var(--line);
  border-radius: 10px;
  background: #f6f8fa;
  color: var(--ink);
  font: inherit;
  font-size: 15px;
}

/* ---------- 칭호 창 ---------- */
#titles .panel { display: flex; flex-direction: column; max-height: min(92vh, 720px); }
#titles .panel .sub { margin: 4px 0 10px; }
#title-tabs { flex: none; display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); }
#title-tabs button { min-width: 0; padding: 0 4px; font-size: 13px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
/* 목록만 스크롤하고 닫기 버튼은 늘 아래에 보인다 */
#title-list { flex: 1 1 auto; min-height: 120px; margin: 0 0 4px; padding: 0; overflow: auto; list-style: none; }
#titles-close { flex: none; }
.title-head { margin: 12px 2px 6px; color: var(--muted); font-size: 12px; font-weight: 700; }
.title-row {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 8px 4px;
  border-bottom: 1px solid var(--line);
}
.title-row.locked { opacity: 0.55; }
.title-emoji { flex: none; width: 30px; font-size: 22px; text-align: center; }
.title-info { flex: 1; min-width: 0; }
.title-name { font-size: 15px; font-weight: 700; }
.title-cond { color: var(--muted); font-size: 12px; }
.title-bar { height: 5px; margin-top: 4px; border-radius: 3px; background: var(--line); overflow: hidden; }
.title-bar i { display: block; height: 100%; background: var(--gold); }
.title-row .secondary { flex: none; min-height: 34px; }
.title-row .secondary.wearing { border-color: var(--ink); background: var(--ink); color: #fff; opacity: 1; }
.title-note { padding: 6px 4px 10px; color: var(--muted); font-size: 12px; }

/* ---------- 위쪽 표시줄 ----------
   공지 띠(#top-center)가 맨 위, 그 아래 한 줄에 체력 · 골드 · 방 · 메뉴 버튼.
   공지 띠 높이는 main.js가 --notice-h로 알려 주고, 표시줄은 그만큼 내려간다. */
#top-bar {
  position: absolute;
  top: calc(max(12px, env(safe-area-inset-top)) + var(--notice-h, 0px));
  left: 14px;
  right: 14px;
  display: flex;
  flex-wrap: wrap;
  align-items: flex-start;
  gap: 8px;
  transition: top 0.2s ease;
}
.meter, #gold-box, #gem-box, #room-button, .hud-btn {
  height: 40px;
  border: 1px solid rgba(255, 255, 255, 0.75);
  border-radius: 14px;
  background: rgba(255, 255, 255, 0.86);
  box-shadow: 0 4px 14px rgba(16, 40, 64, 0.14), 0 1px 2px rgba(16, 40, 64, 0.08);
  -webkit-backdrop-filter: blur(10px);
  backdrop-filter: blur(10px);
  color: var(--ink);
}
/* 체력: 하트, 막대, 숫자 */
.meter {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 0 12px 0 8px;
}
.meter-icon {
  flex: none;
  width: 26px;
  height: 26px;
  padding: 5px;
  border-radius: 50%;
  background: linear-gradient(180deg, #ff7b7b, #e5484d);
  fill: #fff;
  box-shadow: inset 0 -2px 0 rgba(0, 0, 0, 0.12);
}
.meter-label {
  position: absolute;
  width: 1px;
  height: 1px;
  overflow: hidden;
  clip: rect(0 0 0 0);
}
.meter b {
  min-width: 30px;
  font-size: 15px;
  font-weight: 800;
  text-align: right;
  font-variant-numeric: tabular-nums;
}
.bar {
  width: min(130px, 26vw);
  height: 10px;
  border-radius: 999px;
  background: rgba(23, 50, 74, 0.12);
  box-shadow: inset 0 1px 2px rgba(23, 50, 74, 0.15);
  overflow: hidden;
}
.bar i {
  display: block;
  width: 100%;
  height: 100%;
  border-radius: 999px;
  background: linear-gradient(90deg, #2fbf7a, #5fdc9a);
  transition: width 0.15s linear, background 0.2s;
}
.bar i.low { background: linear-gradient(90deg, #e5484d, #ff8a65); }
.bar.thin { width: 100%; height: 5px; box-shadow: none; }
.bar.thin i { background: var(--ink); border-radius: 0; transition: none; }

/* 골드 */
#gold-box, #gem-box {
  display: flex;
  align-items: center;
  gap: 7px;
  padding: 0 13px 0 10px;
  font-size: 15px;
  font-weight: 800;
  font-variant-numeric: tabular-nums;
}
#gold-box.bump, #gem-box.bump { animation: bump 0.3s ease-out; }
.gem-mark {
  width: 20px;
  height: 18px;
  flex: none;
  filter: drop-shadow(0 1px 1px rgba(10, 60, 120, 0.3));
}
.coin-mark {
  width: 18px;
  height: 18px;
  border-radius: 50%;
  background: radial-gradient(circle at 35% 30%, #ffe27a, #f2b41f 55%, #d8920c);
  box-shadow: inset 0 0 0 2px rgba(176, 112, 6, 0.55), 0 1px 1px rgba(120, 70, 0, 0.25);
}

/* 방: 국기 · 서버 상태 · 방 번호. 오른쪽 메뉴 묶음 맨 앞 */
#room-button {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 0 12px;
  font: inherit;
  font-size: 14px;
  font-weight: 700;
  font-variant-numeric: tabular-nums;
  white-space: nowrap;
  cursor: pointer;
  pointer-events: auto;
}

/* 방 버튼은 맨 위 줄 오른쪽 끝. 그 아래 줄 오른쪽에 지도·메뉴 버튼, 메뉴 버튼 아래에 노래 버튼.
   메뉴 목록은 노래 버튼 아래로 펼쳐진다. */
#room-button { order: 1; margin-left: auto; }
#top-right {
  order: 2;
  position: relative;
  display: flex;
  flex-wrap: wrap;
  justify-content: flex-end;
  flex-basis: 100%;
  gap: 0 6px;
  min-width: 0;
}
/* 노래 버튼을 다음 줄로 넘기는 줄바꿈 */
#top-right::after { content: ''; order: 1; flex-basis: 100%; height: 0; }
#now-playing { order: 2; margin-top: 8px; }
.hud-btn {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 0 12px 0 10px;
  font: inherit;
  font-size: 14px;
  font-weight: 700;
  white-space: nowrap;
  cursor: pointer;
  pointer-events: auto;
  transition: background 0.15s, transform 0.1s;
}
.hud-btn svg {
  flex: none;
  width: 19px;
  height: 19px;
  fill: none;
  stroke: currentColor;
  stroke-width: 1.8;
  stroke-linecap: round;
  stroke-linejoin: round;
}
#room-button:hover, .hud-btn:hover { background: #fff; }
#room-button:active, .hud-btn:active { transform: scale(0.96); }
/* 메뉴 버튼: ☰, 펼치면 ✕ */
#menu-toggle, #map-button, #camera-button { width: 40px; padding: 0; justify-content: center; }
#map-button svg, #camera-button svg { width: 21px; height: 21px; }
/* 지도 버튼: 흰 버튼·눈밭·밤하늘 어디서나 바로 보이게 주황 바탕에 속을 채운 지도 */
#map-button, #map-button:hover {
  border-color: #ffd29a;
  background: linear-gradient(180deg, #ffad3d, #f47a12);
  box-shadow: 0 4px 14px rgba(16, 40, 64, 0.22), 0 2px 0 #b9530a;
  color: #5c2a05;
}
#map-button:hover { filter: brightness(1.07); }
#map-button svg { width: 24px; height: 24px; stroke-width: 1.7; }
#map-button svg path { fill: #fffaf0; }
/* 찍은 사진 미리보기 */
#photo .panel { width: min(620px, 100%); }
#photo-preview {
  display: block;
  width: 100%;
  max-height: 58vh;
  object-fit: contain;
  margin: 0 0 14px;
  border-radius: 12px;
  background: #0d1b2a;
  box-shadow: 0 6px 18px rgba(15, 40, 70, 0.22);
}
#photo-close { margin-top: 8px; }
#menu-toggle svg { width: 21px; height: 21px; stroke-width: 2; }
#menu-toggle .menu-close { display: none; }
#menu-toggle[aria-expanded='true'] { background: var(--ink); color: #fff; border-color: rgba(255, 255, 255, 0.25); }
#menu-toggle[aria-expanded='true'] .menu-lines { display: none; }
#menu-toggle[aria-expanded='true'] .menu-close { display: inline; }

/* 메뉴 목록: 메뉴 버튼 아래로 세로로 쌓인다. 펼칠 때 위에서부터 차례로 내려오고, 접을 때 아래부터 올라간다. */
#hud-menu-list {
  position: absolute;
  top: calc(100% + 8px);
  right: 0;
  display: flex;
  flex-direction: column;
  align-items: flex-end;
  gap: 6px;
  pointer-events: none;
}
#hud-menu-list .hud-btn {
  opacity: 0;
  visibility: hidden;
  pointer-events: none;
  transform: translateY(-12px) scale(0.92);
  transform-origin: right center;
  transition:
    opacity 0.14s ease calc((var(--n, 7) - var(--i, 0)) * 22ms),
    transform 0.16s ease calc((var(--n, 7) - var(--i, 0)) * 22ms),
    visibility 0s linear calc((var(--n, 7) - var(--i, 0)) * 22ms + 0.16s);
}
#top-right.open #hud-menu-list .hud-btn {
  opacity: 1;
  visibility: visible;
  pointer-events: auto;
  transform: none;
  transition:
    opacity 0.18s ease calc(var(--i, 0) * 35ms),
    transform 0.24s cubic-bezier(0.2, 0.9, 0.3, 1.25) calc(var(--i, 0) * 35ms),
    visibility 0s linear calc(var(--i, 0) * 35ms);
}

/* 공지는 눈에 띄게 강조색 */
#notice-button {
  border-color: rgba(255, 255, 255, 0.35);
  background: linear-gradient(180deg, #f2705a, var(--accent));
  color: #fff;
}
#notice-button:hover { background: linear-gradient(180deg, #f47d68, #ec6249); }

/* 공지 띠: 가장 위, 화면 폭에 맞춘다 */
#event-banner {
  box-shadow: 0 4px 14px rgba(10, 16, 40, 0.22);
  -webkit-backdrop-filter: blur(10px);
  backdrop-filter: blur(10px);
}

/* 좁은 화면: 체력·골드·보석·방·메뉴가 한 줄에 들어가게 방은 국기와 상태 점만 남긴다 */
@media (max-width: 700px) {
  #top-bar { left: 10px; right: 10px; gap: 6px; }
  #room-button > span:not(.server-dot) { display: none; }
}
/* 좁은 화면에서는 공지가 잘리지 않게 여러 줄로 쓴다 */
@media (max-width: 520px) {
  #top-center { width: calc(100% - 20px); max-width: none; }
  #event-banner { white-space: normal; border-radius: 16px; }
}
/* 휴대폰: 첫 줄은 긴 체력 게이지와 방 버튼, 그 아래 줄에 골드·보석, 그 아래 오른쪽에 지도·메뉴 */
@media (max-width: 600px) {
  #top-bar > .meter { order: 1; }
  .meter .bar { width: min(150px, 34vw); }
  #top-bar > #room-button { order: 2; margin-left: auto; }
  #top-bar::after { content: ''; order: 3; flex-basis: 100%; height: 0; }
  #top-bar > #gold-box { order: 4; }
  #top-bar > #gem-box { order: 5; }
  #top-bar > #olympic-go { order: 5; } /* 로컬 전용 테스트 버튼은 보석 옆 */
  #top-bar > #top-right { order: 6; flex: 1 1 0; } /* 골드·보석 줄 오른쪽 남은 자리 */
  #top-right > #now-playing { flex-shrink: 0; } /* 펼친 노래 막대는 왼쪽(골드·보석 아래 빈 자리)으로 넘쳐 늘어난다 */
}
@media (max-width: 420px) {
  .meter, #gold-box, #gem-box, #room-button, .hud-btn { height: 38px; border-radius: 13px; }
  #menu-toggle, #map-button, #camera-button { width: 38px; }
  .meter { gap: 6px; padding: 0 9px 0 6px; }
  .hud-plus { width: 22px; height: 22px; margin-right: -3px; }
  #room-button { padding: 0 10px; font-size: 13px; }
}

/* 눈덩이에 맞았을 때 화면에 붙는 눈 (3D 화면 바로 위, HUD 아래) */
.snow-hit {
  position: fixed;
  inset: 0;
  overflow: hidden;
  pointer-events: none;
}
.snow-hit-flash {
  position: absolute;
  inset: 0;
  opacity: 0;
  background: radial-gradient(circle at 50% 50%, rgba(255, 255, 255, 0.2), rgba(225, 238, 252, 0.9));
}
.snow-hit-splat {
  position: absolute;
  opacity: 0;
  filter: drop-shadow(0 3px 6px rgba(60, 90, 130, 0.25));
}

/* 첫 접속 튜토리얼: 리프트 타기 버튼만 밝게 남기고 나머지는 어둡게 덮어 못 누르게 한다 */
#tutorial-dim {
  position: fixed;
  inset: 0;
  z-index: 4;
  background: rgba(8, 14, 28, 0.62);
  touch-action: none;
}
#tutorial-dim[hidden] { display: none; }
/* 연결이 끊긴 창은 튜토리얼 덮개보다 위 (덮개가 다시 접속 버튼을 가렸다, 2026-12-03) */
#idle { z-index: 5; }
#tutorial-lift {
  position: fixed;
  min-height: 50px;
  padding: 0 22px;
  border: 0;
  border-radius: 14px;
  background: var(--accent);
  color: #fff;
  font: inherit;
  font-size: 17px;
  font-weight: 700;
  white-space: nowrap;
  cursor: pointer;
  animation: tutorial-pulse 1.2s ease-in-out infinite;
}
#tutorial-dim-tip {
  position: fixed;
  max-width: min(420px, calc(100vw - 32px));
  padding: 10px 16px;
  border-radius: 12px;
  background: #ffd84d;
  color: #3a2a00;
  font-size: 16px;
  font-weight: 800;
  line-height: 1.35;
  text-align: center;
  width: max-content;
  transform: translate(-50%, -100%);
  box-shadow: 0 4px 14px rgba(0, 0, 0, 0.3);
}
#tutorial-dim-tip::after {
  content: '';
  position: absolute;
  left: 50%;
  bottom: -6px;
  width: 12px;
  height: 12px;
  background: inherit;
  transform: translateX(-50%) rotate(45deg);
}

/* 점프 착지 버튼: 바깥 고리가 버튼 크기까지 줄어들 때 누른다 */
#landing {
  position: fixed;
  left: 50%;
  bottom: calc(max(14px, env(safe-area-inset-bottom)) + 150px);
  z-index: 3;
  width: 88px;
  height: 88px;
  margin-left: -44px;
  padding: 0;
  border: 0;
  border-radius: 50%;
  background: transparent;
  cursor: pointer;
  touch-action: manipulation;
}
#landing[hidden] { display: none; }
#landing .landing-core {
  position: absolute;
  inset: 8px;
  display: grid;
  place-items: center;
  border-radius: 50%;
  background: rgba(255, 255, 255, 0.92);
  border: 3px solid var(--accent);
  color: var(--ink);
  font: inherit;
  font-size: 15px;
  font-weight: 800;
  box-shadow: 0 4px 14px rgba(0, 0, 0, 0.25);
}
#landing .landing-ring {
  position: absolute;
  inset: 4px;
  border-radius: 50%;
  border: 5px solid var(--ring-color, #ffd84d);
  box-shadow: 0 0 14px var(--ring-color, #ffd84d), inset 0 0 8px var(--ring-color, #ffd84d);
  transform: scale(var(--ring, 2.4));
  opacity: 0.95;
  pointer-events: none;
}
/* 버튼 테도 고리와 같은 색. 누르면 그 색으로 채운다. */
#landing .landing-core { border-color: var(--ring-color, var(--accent)); transition: background 0.12s; }
#landing.pressed .landing-core { background: var(--ring-color, #ffd84d); color: #fff; text-shadow: 0 1px 2px rgba(0, 0, 0, 0.35); }
#landing.hit .landing-core { animation: landing-hit 0.35s ease-out; }
@keyframes landing-hit {
  0% { transform: scale(1); }
  40% { transform: scale(1.25); }
  100% { transform: scale(1); }
}

/* 착지 등급 글자: 화면 가운데 위쪽에 튀어나오듯 커졌다가 떠오르며 사라진다 */
#landing-grade {
  position: fixed;
  left: 50%;
  top: 30%;
  z-index: 6;
  width: 0;
  height: 0;
  pointer-events: none;
}
#landing-grade[hidden] { display: none; }
#landing-grade .grade-word {
  position: absolute;
  left: 0;
  top: 0;
  translate: -50% -50%;
  white-space: nowrap;
  font-family: 'Arial Black', 'Segoe UI', system-ui, sans-serif;
  font-size: clamp(38px, 11vw, 64px);
  font-weight: 900;
  font-style: italic;
  letter-spacing: 0.04em;
  color: var(--grade);
  /* 흰 테두리, 아래 그림자, 등급 색 빛 */
  text-shadow:
    -3px -3px 0 #fff, 3px -3px 0 #fff, -3px 3px 0 #fff, 3px 3px 0 #fff,
    0 -3px 0 #fff, 0 3px 0 #fff, -3px 0 0 #fff, 3px 0 0 #fff,
    0 7px 0 rgba(20, 40, 70, 0.35), 0 0 28px var(--grade), 0 0 48px var(--grade);
  animation: grade-pop 1.35s cubic-bezier(0.2, 1.3, 0.4, 1) forwards;
}
#landing-grade.grade-perfect .grade-word {
  font-size: clamp(44px, 13vw, 76px);
  animation: grade-pop 1.35s cubic-bezier(0.2, 1.3, 0.4, 1) forwards, grade-shine 0.35s ease-in-out infinite alternate;
}
@keyframes grade-pop {
  0% { transform: scale(0.3) rotate(-6deg); opacity: 0; }
  14% { transform: scale(1.22) rotate(2deg); opacity: 1; }
  26% { transform: scale(0.96) rotate(0deg); }
  36% { transform: scale(1); }
  72% { transform: translateY(0) scale(1); opacity: 1; }
  100% { transform: translateY(-40px) scale(1.05); opacity: 0; }
}
@keyframes grade-shine {
  from { filter: brightness(1); }
  to { filter: brightness(1.35) saturate(1.2); }
}
/* 별 조각이 사방으로 터진다 */
#landing-grade .grade-spark {
  position: absolute;
  left: 0;
  top: 0;
  width: var(--size, 12px);
  height: var(--size, 12px);
  translate: -50% -50%;
  background: radial-gradient(circle, #fff 0 22%, var(--grade) 45%);
  clip-path: polygon(50% 0, 61% 38%, 100% 50%, 61% 62%, 50% 100%, 39% 62%, 0 50%, 39% 38%);
  opacity: 0;
  animation: grade-spark 0.85s ease-out forwards;
}
@keyframes grade-spark {
  0% { transform: translate(0, 0) scale(0.5) rotate(0deg); opacity: 1; }
  45% { transform: translate(calc(var(--dx) * 0.75), calc(var(--dy) * 0.75)) scale(1.15) rotate(110deg); opacity: 1; }
  100% { transform: translate(var(--dx), var(--dy)) scale(0.3) rotate(200deg); opacity: 0; }
}
/* Perfect: 글자 뒤로 빛 고리가 퍼진다 */
#landing-grade .grade-wave {
  position: absolute;
  left: 0;
  top: 0;
  width: 120px;
  height: 120px;
  translate: -50% -50%;
  border-radius: 50%;
  border: 6px solid var(--grade);
  box-shadow: 0 0 24px var(--grade);
  animation: grade-wave 0.7s ease-out forwards;
}
@keyframes grade-wave {
  0% { transform: scale(0.2); opacity: 0.9; }
  100% { transform: scale(3.2); opacity: 0; }
}
/* 화면 가장자리가 등급 색으로 잠깐 빛난다 */
#landing-flash {
  position: fixed;
  inset: 0;
  z-index: 5;
  pointer-events: none;
  opacity: 0;
  box-shadow: inset 0 0 90px 10px var(--grade, #2fe07a);
}
#landing-flash.on { animation: landing-flash 0.7s ease-out; }
@keyframes landing-flash {
  0% { opacity: 0.85; }
  100% { opacity: 0; }
}
@media (prefers-reduced-motion: reduce) {
  #landing-grade .grade-spark, #landing-grade .grade-wave { display: none; }
}

/* 코스 지도: 설산 그림 위에 이름표와 리프트 타는 곳. 넓은 화면에서는 세로로 스크롤 없이 들어가는 만큼 크게 */
.map-panel { width: min(720px, 100%, max(430px, calc(103vh - 300px))); }
#map-view {
  margin: 10px 0;
  border-radius: 14px;
  overflow: hidden;
  background: #cfe0ef;
  box-shadow: 0 0 0 2px #fff, 0 3px 10px rgba(16, 40, 64, 0.22);
}
@media (max-width: 520px) {
  #map-view { margin: 0 -20px 10px; border-radius: 0; box-shadow: none; }
  #map > .map-panel > h1:first-child + .sub { margin-bottom: 0; }
}
#map-view svg { display: block; width: 100%; height: auto; -webkit-user-select: none; user-select: none; }
#map-view .map-label { font-family: system-ui, sans-serif; font-weight: 800; }
/* 리프트 말고는 누름을 흘려보낸다 (리프트 누르는 자리를 덮지 않게) */
#map-view .map-course, #map-view .map-stop, #map-view .map-ice { pointer-events: none; }
#map-view .map-badge rect { stroke: #ffffff; stroke-width: 3px; }
#map-view .map-course text { fill: #ffffff; }
#map-view .map-course text + text { opacity: 0.92; }
#map-view .map-tie { stroke: #17324a; stroke-width: 3px; stroke-linecap: round; }
#map-view .map-stop circle { fill: #2378c8; stroke: #ffffff; stroke-width: 4px; }
#map-view .map-stop-name rect { fill: #e3edf6; }
#map-view .map-stop-name text { fill: #3d4b58; }
#map-view .map-ice-gate { fill: #8fdcf7; stroke: #17688f; stroke-width: 3px; }
#map-view .map-ice-name rect { fill: #bfeaff; }
#map-view .map-ice-name text { fill: #0f557a; }
/* 고를 수 있는 리프트: 색 동그라미 속 의자·칸 그림, 둘레 고리가 천천히 깜빡인다 */
#map-view .map-lift { cursor: pointer; }
#map-view .map-lift:focus { outline: none; }
#map-view .map-lift-ring { fill: none; stroke: #ffffff; stroke-width: 4px; opacity: 0.4; animation: map-ring 1.6s ease-in-out infinite; }
#map-view .map-lift-dot { fill: #1769b5; stroke: #ffffff; stroke-width: 4px; }
#map-view .map-lift.gondola .map-lift-dot { fill: #d8382a; }
#map-view .map-lift-icon { fill: none; stroke: #ffffff; stroke-width: 3px; stroke-linecap: round; stroke-linejoin: round; pointer-events: none; }
#map-view .map-lift-name rect { fill: #ffffff; stroke: #17324a; }
#map-view .map-lift-name text { fill: #17324a; }
#map-view .map-lift:hover .map-lift-name rect, #map-view .map-lift:focus-visible .map-lift-name rect { fill: #ffe9a6; }
/* 고른 리프트 */
#map-view .map-lift.picked .map-lift-dot { fill: #ffd84d; stroke: #17324a; }
#map-view .map-lift.picked .map-lift-icon { stroke: #17324a; }
#map-view .map-lift.picked .map-lift-ring { fill: rgba(255, 216, 77, 0.4); stroke: #ffd84d; stroke-width: 6px; opacity: 1; animation: none; }
#map-view .map-lift.picked .map-lift-name rect { fill: #ffd84d; stroke-width: 4px; }
@keyframes map-ring { 50% { opacity: 1; } }
/* 새 스키장 지도 (olympic-map-panel.js): 위 탭 '산 전체 / 마을', 마을 장소 핀(그림 글자), 내 자리 */
#map-view .omap-tabs { display: flex; gap: 6px; padding: 8px; background: #e3edf6; }
#map-view .omap-tabs button {
  flex: 1; min-height: 38px; border: 0; border-radius: 10px; background: #ffffff; color: #3d4b58;
  font: inherit; font-weight: 800; font-size: 15px; cursor: pointer; box-shadow: 0 1px 3px rgba(16, 40, 64, 0.18);
}
#map-view .omap-tabs button[aria-selected="true"] { background: #1769b5; color: #ffffff; }
#map-view .omap svg { aspect-ratio: auto; }
#map-view .omap-spot-icon { pointer-events: none; }
#map-view .omap-spot-dot { fill: #ffffff; stroke: #17324a; stroke-width: 3px; }
#map-view .omap-here { fill: #ff5a4e; stroke: #ffffff; stroke-width: 4px; pointer-events: none; }
#map-view .omap-here-ring { fill: rgba(255, 90, 78, 0.25); stroke: #ff5a4e; stroke-width: 3px; pointer-events: none; animation: map-ring 1.6s ease-in-out infinite; }
#map-view .omap-here-name { pointer-events: none; }
#map-view .omap-here-name rect { fill: #ff5a4e; }
#map-view .omap-here-name text { fill: #ffffff; }
#map-view .omap-village-box { fill: rgba(255, 255, 255, 0.12); stroke: #ffd84d; stroke-width: 18px; stroke-dasharray: 60 30; cursor: pointer; }
#map-view .omap-village-name { pointer-events: none; }
#map-view .omap-village-name rect { fill: #ffd84d; stroke: #17324a; }
#map-view .omap-village-name text { fill: #17324a; }
/* 세로가 짧은 폰: 이동 버튼까지 한 화면에 들어오게 지도를 줄인다 */
@media (max-width: 520px) and (max-height: 640px) {
  #map-view svg { max-height: calc(100vh - 322px); }
}
/* 폰 가로: 지도는 왼쪽, 버튼은 오른쪽 */
@media (min-width: 560px) and (max-height: 520px) {
  #map > .map-panel {
    display: grid;
    grid-template-columns: auto minmax(0, 1fr);
    grid-template-rows: auto auto 1fr auto auto auto 1fr;
    column-gap: 14px;
    width: min(680px, 100%);
    padding-bottom: 10px;
  }
  #map > .map-panel > h1:first-child, #map > .map-panel > h1:first-child + .sub { grid-column: 1 / -1; }
  #map > .map-panel > h1:first-child { padding-top: 12px; font-size: 19px; }
  #map > .map-panel > h1:first-child + .sub { margin-bottom: 8px; padding-bottom: 8px; }
  #map > .map-panel > #map-view { grid-column: 1; grid-row: 3 / 8; margin: 0; }
  #map-view svg { width: auto; height: calc(100vh - 124px); max-width: 60vw; aspect-ratio: 1030 / 1004; }
  #map > .map-panel > #map-go { grid-column: 2; grid-row: 4; }
  #map > .map-panel > #map-ice { grid-column: 2; grid-row: 5; }
  #map > .map-panel > #map-close { grid-column: 2; grid-row: 6; position: static; }
}
#map-go { margin-bottom: 8px; }
#map-go:disabled { opacity: 0.5; }
/* 첫 완주 지도: 곤돌라로 이동 버튼을 반짝인다 */
#map-go.tutorial:not(:disabled) { animation: tutorial-pulse 1.2s ease-in-out infinite; }

/* ---------- 겨울 테마: 모든 창·버튼 공통 ----------
   창 위에 눈송이가 흩날리는 하늘색 머리띠, 얼음빛 테두리와 아래로 살짝 두꺼운 그림자의 버튼 (눌린 듯 들어간다). */
:root {
  --sky: #2f74ad;
  --ice: #cfe1ef;
  --ice-deep: #b4cde2;
  --frost: #f3f8fc;
  --flakes: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='440' height='76'%3E%3Cdefs%3E%3Cpath id='f' d='M0-7V7M-6.1-3.5 6.1 3.5M-6.1 3.5 6.1-3.5M-2.2-5.4 0-3.4 2.2-5.4M-2.2 5.4 0 3.4 2.2 5.4M-5.8-.6-3.4 0-5.8.6M5.8-.6 3.4 0 5.8.6' stroke='white' stroke-width='1.3' stroke-linecap='round' fill='none'/%3E%3C/defs%3E%3Cuse href='%23f' transform='translate(24 20) scale(1.3)' opacity='.55'/%3E%3Cuse href='%23f' transform='translate(78 52) scale(.8)' opacity='.4'/%3E%3Cuse href='%23f' transform='translate(150 16) scale(.7)' opacity='.45'/%3E%3Cuse href='%23f' transform='translate(292 18) scale(.8)' opacity='.45'/%3E%3Cuse href='%23f' transform='translate(372 50) scale(1.5)' opacity='.4'/%3E%3Cuse href='%23f' transform='translate(414 18) scale(.9)' opacity='.55'/%3E%3Cuse href='%23f' transform='translate(236 58) scale(.6)' opacity='.35'/%3E%3C/svg%3E");
}
.panel {
  border-radius: 22px;
  background: linear-gradient(180deg, #e9f4fd 0, #fff 180px);
  box-shadow: 0 18px 40px rgba(15, 40, 70, 0.26), inset 0 0 0 2px rgba(255, 255, 255, 0.9);
}
/* 창 제목: 눈송이 머리띠. 바로 아래 설명(.sub)도 같은 띠 안에 넣는다. */
.panel > h1:first-child {
  margin: -24px -20px 14px;
  padding: 22px 20px 14px;
  background: var(--flakes) center / 440px 76px no-repeat, var(--sky);
  color: #fff;
  text-shadow: 0 2px 0 rgba(0, 0, 0, 0.14);
  letter-spacing: 0.5px;
}
.panel > h1:first-child:has(+ .sub) { margin-bottom: 0; padding-bottom: 4px; }
.panel > h1:first-child + .sub {
  margin: 0 -20px 14px;
  padding: 2px 20px 14px;
  background: var(--sky);
  color: rgba(255, 255, 255, 0.88);
  font-size: 13px;
}
.section { color: var(--sky); }

/* 버튼 */
.primary {
  border-radius: 14px;
  box-shadow: 0 3px 0 #b8432f;
  transition: transform 0.08s, box-shadow 0.08s;
}
.primary:active { transform: translateY(2px); box-shadow: 0 1px 0 #b8432f; }
.secondary {
  border: 0;
  border-radius: 14px;
  background: #fff;
  box-shadow: 0 0 0 1.5px var(--ice), 0 3px 0 var(--ice-deep);
  color: var(--sky);
  font-weight: 700;
  transition: transform 0.08s, box-shadow 0.08s;
}
.secondary:hover:not(:disabled) { box-shadow: 0 0 0 1.5px #8fb8d8, 0 3px 0 var(--ice-deep); }
.secondary:active:not(:disabled) { transform: translateY(2px); box-shadow: 0 0 0 1.5px var(--ice), 0 1px 0 var(--ice-deep); }
.secondary.wide { margin-top: 12px; }

/* 탭: 얼음빛 칩, 고른 칸은 남색으로 */
.tabs button {
  border: 0;
  border-radius: 12px;
  background: #fff;
  box-shadow: 0 0 0 1.5px var(--ice);
  color: #3a5873;
  font-weight: 600;
}
.tabs button[aria-selected='true'] {
  background: var(--ink);
  color: #fff;
  box-shadow: 0 3px 0 #0d2133;
}

/* 고르는 카드 (스키/보드 고르기 등) */
.card { border: 0; border-radius: 16px; box-shadow: 0 0 0 1.5px var(--ice), 0 3px 0 var(--ice-deep); }
.card:hover { box-shadow: 0 0 0 2px #8fb8d8, 0 3px 0 var(--ice-deep); }

/* 순위 목록: 줄마다 둥근 얼음 카드, 1~3위는 메달색 */
.ranking-list { display: flex; flex-direction: column; gap: 5px; border-top: 0; }
.ranking-list li { padding: 7px 10px; border-bottom: 0; border-radius: 12px; background: var(--frost); }
.ranking-list li:nth-child(1):not(.empty) { background: #fff7dc; }
.ranking-list li.mine { background: #fff1e0; box-shadow: inset 0 0 0 1.5px #f0c08a; }
.ranking-list li:nth-child(1) .rank-badge { box-shadow: 0 2px 0 #c99a12; }
.ranking-list li:nth-child(2) .rank-badge { box-shadow: 0 2px 0 #8a939a; }
.ranking-list li:nth-child(3) .rank-badge { box-shadow: 0 2px 0 #a26a33; }
.rank-badge { width: 28px; height: 28px; line-height: 28px; }
.rank-name { font-weight: 600; }

/* 입력칸·고르기 */
#name, #language, .panel input[type='text'] { border-color: var(--ice); border-width: 1.5px; }
#name:focus { border-color: var(--sky); }

/* 화면 위 버튼: 유리 위에 얼음빛 아래 테두리 */
.meter, #gold-box, #gem-box, #room-button, .hud-btn { box-shadow: 0 4px 14px rgba(16, 40, 64, 0.14), 0 2px 0 rgba(180, 205, 226, 0.9); }

/* ---------- 랭킹 창 ---------- */
#ranking h1::before { content: '🏆 '; }
/* 스키/보드: 알약 모양 토글 */
.seg {
  display: flex;
  gap: 0;
  margin-bottom: 12px;
  padding: 4px;
  border-radius: 999px;
  background: #dcebf7;
  box-shadow: inset 0 1px 3px rgba(20, 60, 100, 0.18);
}
.seg button {
  flex: 1;
  min-height: 38px;
  border: 0;
  border-radius: 999px;
  background: transparent;
  color: #4b6a85;
  font-size: 15px;
  font-weight: 600;
}
.seg button[aria-selected='true'] { background: #fff; color: var(--ink); font-weight: 800; box-shadow: 0 2px 6px rgba(20, 60, 100, 0.2); }
/* 등급 넘기기 */
.grade-picker { display: flex; align-items: center; gap: 10px; margin-bottom: 8px; }
.grade-arrow {
  flex: none;
  width: 42px;
  height: 42px;
  border: 0;
  border-radius: 50%;
  background: #fff;
  box-shadow: 0 0 0 1.5px var(--ice), 0 3px 0 var(--ice-deep);
  color: var(--sky);
  font-size: 16px;
  line-height: 1;
}
.grade-arrow:active { transform: translateY(2px); box-shadow: 0 0 0 1.5px var(--ice), 0 1px 0 var(--ice-deep); }
.grade-name {
  flex: 1;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 10px;
  height: 46px;
  border-radius: 14px;
  background: #fff;
  box-shadow: 0 0 0 1.5px var(--ice);
  font-size: 19px;
  font-weight: 800;
}
/* 슬로프 표지: 초급 녹색 원, 중급 파란 네모, 상급 빨간 마름모, 최상급 검은 마름모 */
.slope-sign { flex: none; display: inline-block; width: 20px; height: 20px; }
.slope-sign.easy { border-radius: 50%; background: #3f9d5f; }
.slope-sign.normal { border-radius: 3px; background: #2b7fbf; }
.slope-sign.hard, .slope-sign.expert { border-radius: 3px; background: #d4363a; transform: rotate(45deg) scale(0.82); }
.slope-sign.expert { background: #1e2128; }
.grade-dots { display: flex; justify-content: center; gap: 6px; margin-bottom: 10px; }
.grade-dots i { width: 6px; height: 6px; border-radius: 3px; background: #c7dbeb; transition: width 0.15s; }
.grade-dots i.on { width: 16px; background: var(--sky); }
/* 코스 칩: 동물 그림 위, 이름 아래인 작은 타일. 한 등급에 4개까지 휴대폰 한 줄에 들어간다. */
.course-chips { display: flex; justify-content: center; gap: 6px; margin-bottom: 12px; }
.course-chips button {
  flex: 0 1 76px;
  min-width: 0;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 3px;
  padding: 7px 4px 6px;
  border: 0;
  border-radius: 14px;
  background: #fff;
  box-shadow: 0 0 0 1.5px var(--ice), 0 3px 0 var(--ice-deep);
  color: #3a5873;
  font-size: 13px;
  font-weight: 700;
  line-height: 1.2;
}
.course-chips button > span:last-child { max-width: 100%; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.course-chips button[aria-selected='true'] { background: var(--ink); color: #fff; box-shadow: 0 3px 0 #0d2133; }
.course-chips button:active { transform: translateY(2px); }
.course-icon { flex: none; display: inline-flex; width: 34px; height: 34px; padding: 3px; border-radius: 50%; background: #fff; box-shadow: 0 0 0 1px var(--ice); }
.course-icon svg { width: 100%; height: 100%; }
/* 내 기록: 리프트권처럼 점선 테두리 */
#ranking-mine {
  margin: 12px 0 0;
  padding: 10px 14px;
  border: 1.5px dashed #e8a35a;
  border-radius: 12px;
  background: #fff1e0;
  color: var(--ink);
  font-size: 14px;
  font-weight: 600;
  text-align: center;
}
/* 랭킹 창은 화면 높이 안에 들어가게: 목록만 줄어들고 그 안에서 스크롤 (닫기 버튼이 늘 보인다) */
#ranking .panel { display: flex; flex-direction: column; max-height: min(92vh, 100%); max-height: min(92dvh, 100%); }
#ranking .panel > * { flex: none; }
#ranking .panel > #ranking-list { flex: 0 1 auto; min-height: 76px; max-height: none; overflow-y: auto; }
/* 여백이 다른 창: 머리띠가 창 끝에 딱 맞게 */
.panel.wardrobe > h1:first-child { margin: -14px -12px 0; padding: 18px 12px 4px; }
.panel.wardrobe > h1:first-child + .sub { margin: 0 -12px 10px; padding: 2px 12px 12px; }
#titles .panel > h1:first-child + .sub { margin: 0 -20px 12px; }

/* ---------- 명예의 전당 ---------- */
/* 랭킹 창 머리띠 오른쪽 위의 단상 버튼 */
#ranking .panel { position: relative; }
.hall-open {
  position: absolute;
  top: 12px;
  right: 12px;
  width: 42px;
  height: 42px;
  padding: 4px;
  border: 0;
  border-radius: 50%;
  background: #fff8dc;
  box-shadow: 0 0 0 2px #f2c230, 0 3px 0 #b8862b;
}
.hall-open svg { display: block; width: 100%; height: 100%; }
.hall-open span { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }
.hall-open:active { transform: translateY(2px); box-shadow: 0 0 0 2px #f2c230, 0 1px 0 #b8862b; }
/* 전당 창: 머리띠만 금빛 */
#hall h1::before { content: '👑 '; }
#hall .panel > h1:first-child { background-color: #b07d22; }
#hall .panel > h1:first-child + .sub { background: #b07d22; }
/* 시상대 랭킹 창 (피겨·스키점프): 이번 달 / 명예의 전당 탭 */
#podium-ranking h1::before { content: '🏆 '; }
/* 제목이 길어(스키점프 랭킹) 오른쪽 위 ✕와 겹치지 않게 양옆을 비운다 */
#podium-ranking .panel > h1:first-child { padding-left: 50px; padding-right: 50px; }
@media (max-width: 380px) { #podium-ranking .panel > h1:first-child { font-size: 20px; } }
#podium-ranking .panel { max-height: 92vh; max-height: 92dvh; overflow: auto; }
#podium-ranking-list { max-height: 42vh; overflow-y: auto; }
.podium-mine-label { margin: 12px 0 6px; color: var(--sky); font-size: 13px; font-weight: 800; }
/* 내 순위 줄은 순위와 상관없이 기본 동그라미 */
.ranking-list.podium-mine li:nth-child(1) .rank-badge { background: #ffd9a8; color: var(--ink); box-shadow: none; }
.podium-hall-month { margin-bottom: 12px; }
.podium-hall-month h2 { margin: 0 0 6px; color: #9a6a12; font-size: 15px; font-weight: 800; }
#podium-ranking-hall-note { margin: 0 0 10px; text-align: center; }
/* 연도·월 고르기 */
.season-pick { display: flex; gap: 8px; margin-bottom: 12px; }
.season-pick select {
  flex: 1;
  min-width: 0;
  min-height: 44px;
  padding: 0 12px;
  border: 0;
  border-radius: 14px;
  background: #fff;
  box-shadow: 0 0 0 1.5px #e8cf8f, 0 3px 0 #d9b76a;
  color: var(--ink);
  font: inherit;
  font-size: 16px;
  font-weight: 800;
  text-align: center;
}
.season-pick select:disabled { opacity: 0.55; }
#hall-note { margin: 0 0 10px; text-align: center; }
/* 화면 높이 안에 들어가게: 목록만 줄어들고 그 안에서 스크롤 */
#hall .panel { display: flex; flex-direction: column; max-height: min(92vh, 100%); max-height: min(92dvh, 100%); overflow: auto; }
#hall .panel > * { flex: none; }
#hall .panel > #hall-list { flex: 0 1 auto; min-height: 76px; overflow-y: auto; }
.ranking-list li.empty { text-align: center; }

/* ---------- 창 닫기: 머리띠 오른쪽 위 ✕, 아래 닫기 버튼은 창 바닥에 붙는다 ---------- */
.panel { position: relative; }
.panel-x {
  position: absolute;
  top: 12px;
  right: 12px;
  z-index: 3;
  display: flex;
  align-items: center;
  justify-content: center;
  width: 38px;
  height: 38px;
  padding: 0;
  border: 0;
  border-radius: 50%;
  background: #fff;
  box-shadow: 0 0 0 2px rgba(255, 255, 255, 0.55), 0 3px 0 #1d5482, 0 4px 10px rgba(10, 40, 70, 0.25);
  color: var(--sky);
  transition: transform 0.08s, box-shadow 0.08s;
}
.panel-x svg { width: 20px; height: 20px; fill: none; stroke: currentColor; stroke-width: 3.2; stroke-linecap: round; }
.panel-x:hover { color: var(--accent); }
.panel-x:active { transform: translateY(2px); box-shadow: 0 0 0 2px rgba(255, 255, 255, 0.55), 0 1px 0 #1d5482; }
/* 명예의 전당(금빛 머리띠)에서는 금빛으로 */
#hall .panel-x { color: #9a6a12; box-shadow: 0 0 0 2px #f2c230, 0 3px 0 #7d5510, 0 4px 10px rgba(60, 40, 10, 0.25); }
.panel.wardrobe .panel-x { top: 8px; right: 8px; }
/* 랭킹 창의 단상 버튼은 왼쪽 위로 (오른쪽 위는 ✕) */
.hall-open { right: auto; left: 12px; }
/* 내용이 길면 내용만 스크롤되고 아래 닫기 버튼은 늘 보인다 (위로 흰 그늘을 드리워 내용과 겹쳐 보이지 않게) */
.panel > button[id$='-close'] {
  position: sticky;
  bottom: 0;
  z-index: 2;
  box-shadow: 0 0 0 1.5px var(--ice), 0 3px 0 var(--ice-deep), 0 -14px 14px 2px #fff;
}
.panel > button.primary[id$='-close'] { box-shadow: 0 3px 0 #b8432f, 0 -14px 14px 2px #fff; }
/* 사진 창은 스크롤할 내용이 없어 흰 그늘이 위 '사진 저장' 버튼을 덮기만 한다 */
.panel > button#photo-close { box-shadow: 0 0 0 1.5px var(--ice), 0 3px 0 var(--ice-deep); }

/* ---------- 설정: 칸 제목을 왼쪽에 붙여 한 줄씩 ---------- */
.settings-grid {
  display: grid;
  grid-template-columns: max-content minmax(0, 1fr);
  align-items: center;
  gap: 10px 12px;
  margin-bottom: 12px;
}
.settings-grid > label, .settings-grid > .links-label { color: var(--sky); font-size: 14px; font-weight: 700; }
/* 설정: 스레드·홈페이지로 가는 버튼 (새 탭) */
.settings-links { display: flex; gap: 8px; }
.settings-link {
  flex: 1;
  min-width: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  min-height: 42px;
  padding: 0 10px;
  border-radius: 12px;
  color: #fff;
  font-size: 14px;
  font-weight: 700;
  text-decoration: none;
  white-space: nowrap;
}
.settings-link:hover { filter: brightness(1.15); }
.settings-link.threads { background: #101010; }
.settings-link.threads b { font-size: 20px; font-weight: 800; line-height: 1; margin-top: -2px; }
.settings-link.home { background: var(--accent); }
.settings-link svg { width: 18px; height: 18px; fill: currentColor; flex: none; }
.slider-ctl { display: flex; align-items: center; gap: 8px; min-height: 36px; }
.slider-ctl input { flex: 1; min-width: 0; accent-color: var(--accent); }
.slider-ctl output { width: 38px; color: var(--muted); font-size: 13px; text-align: right; font-variant-numeric: tabular-nums; }
.settings-grid .code-row { margin: 0; }
.settings-grid #language { min-height: 42px; }

/* ---------- 국가 고르기 ---------- */
.country-button, .country-option {
  display: flex;
  align-items: center;
  gap: 10px;
  width: 100%;
  min-height: 46px;
  padding: 0 14px;
  border: 1px solid var(--line);
  border-radius: 12px;
  background: #fff;
  color: var(--ink);
  font: inherit;
  font-size: 16px;
  text-align: left;
  box-shadow: none;
}
.settings-grid .country-button { min-height: 42px; font-size: 15px; }
#entry-country-row { margin-bottom: 14px; }
.country-flag {
  flex: none;
  width: 28px;
  height: 21px;
  border-radius: 3px;
  object-fit: cover;
  box-shadow: 0 0 0 1px rgba(23, 50, 74, 0.15);
}
.country-name { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.country-more { flex: none; color: var(--muted); font-size: 13px; }
#country-panel { z-index: 30; }
#country-panel .panel { display: flex; flex-direction: column; height: min(640px, 100%); }
#country-search {
  flex: none;
  width: 100%;
  min-height: 46px;
  margin-bottom: 10px;
  padding: 0 14px;
  border: 1px solid var(--line);
  border-radius: 12px;
  background: #fff;
  color: var(--ink);
  font: inherit;
  font-size: 16px;
  outline: none;
}
#country-search:focus { border-color: var(--sky); }
#country-list {
  flex: 1;
  min-height: 0;
  margin: 0 0 12px;
  padding: 0;
  overflow: auto;
  list-style: none;
  border-radius: 12px;
  background: var(--frost);
  box-shadow: inset 0 0 0 1.5px var(--ice);
}
#country-list li { margin: 0; }
#country-list .country-option { min-height: 44px; border: 0; border-radius: 0; background: transparent; }
#country-list li + li .country-option { border-top: 1px solid var(--ice); }
#country-list .country-option:hover { background: #fff; }
#country-list .country-option.on { background: var(--sky); color: #fff; font-weight: 700; }
#country-list .empty { padding: 18px 14px; color: var(--muted); text-align: center; }
/* ---------- 뉴스 창 ---------- */
#news .panel { max-height: min(92vh, 100%); max-height: min(92dvh, 100%); }
.news-intro { display: grid; gap: 10px; margin-bottom: 14px; }
#news-video { width: 100%; aspect-ratio: 16 / 9; border-radius: 14px; background: #0f2236; }
#news-home { display: flex; align-items: center; justify-content: center; text-decoration: none; }
#news-posts { display: grid; gap: 12px; margin-bottom: 12px; }
#news-posts:empty { display: none; }
.news-post { display: block; width: 100%; max-width: 540px; height: 420px; margin: 0 auto; border: 0; border-radius: 12px; background: #fff; }
#news-empty { margin: 4px 0 14px; text-align: center; }
/* 안 본 새 소식: 버튼 오른쪽 위 빨간 점 */
.hud-btn.has-new { position: relative; }
.hud-btn.has-new::after {
  content: '';
  position: absolute;
  top: 3px;
  right: 3px;
  width: 9px;
  height: 9px;
  border-radius: 50%;
  background: #ff3b30;
  box-shadow: 0 0 0 2px #fff;
}

/* 켜고 끄는 스위치 (설정) */
.switch { position: relative; display: inline-flex; align-items: center; width: 52px; height: 30px; cursor: pointer; }
.switch input { position: absolute; inset: 0; margin: 0; opacity: 0; cursor: pointer; }
.switch-track {
  width: 52px;
  height: 30px;
  border-radius: 15px;
  background: var(--ice-deep);
  transition: background 0.15s;
}
.switch-track::after {
  content: '';
  position: absolute;
  top: 3px;
  left: 3px;
  width: 24px;
  height: 24px;
  border-radius: 50%;
  background: #fff;
  box-shadow: 0 1px 3px rgba(15, 40, 70, 0.3);
  transition: transform 0.15s;
}
.switch input:checked + .switch-track { background: var(--accent); }
.switch input:checked + .switch-track::after { transform: translateX(22px); }
.switch input:focus-visible + .switch-track { outline: 2px solid var(--sky); outline-offset: 2px; }
/* 명예의 전당: 닉네임 앞 국기 */
.rank-flag { width: 20px; height: 15px; margin-right: 6px; border-radius: 2px; object-fit: cover; vertical-align: -2px; box-shadow: 0 0 0 1px rgba(23, 50, 74, 0.15); }
/* 접어 두는 칸 (이어하기 코드) */
.fold { margin-bottom: 12px; border-radius: 14px; background: var(--frost); box-shadow: inset 0 0 0 1.5px var(--ice); }
.fold > summary {
  display: flex;
  align-items: center;
  justify-content: space-between;
  min-height: 44px;
  padding: 0 14px;
  color: var(--sky);
  font-size: 14px;
  font-weight: 700;
  list-style: none;
  cursor: pointer;
}
.fold > summary::-webkit-details-marker { display: none; }
.fold > summary::after { content: '▾'; font-size: 13px; transition: transform 0.15s; }
.fold[open] > summary::after { transform: rotate(180deg); }
.fold[open] { padding: 0 12px 10px; }
.fold[open] > summary { padding: 0 2px; }
.fold .section { margin: 4px 0 6px; font-size: 13px; }
/* 표기 설정: 왼쪽 글, 오른쪽 끝에 스위치 */
.fold .settings-grid.toggles { grid-template-columns: minmax(0, 1fr) max-content; margin: 2px 2px 0; }
#code-message:empty { display: none; }
#settings-support { margin-bottom: 4px; }
#settings-support .support-link { margin: 0; }

/* 문의하기 */
.inquiry-open { margin-top: 12px; }
.inquiry-form { display: flex; flex-direction: column; gap: 8px; margin-top: 10px; }
#inquiry-subject, #inquiry-category, #inquiry-body {
  width: 100%;
  padding: 10px 12px;
  border: 1px solid var(--line);
  border-radius: 12px;
  background: #fff;
  color: var(--ink);
  font: inherit;
  font-size: 16px;
  outline: none;
}
#inquiry-subject, #inquiry-category { min-height: 46px; }
#inquiry-body { min-height: 150px; resize: vertical; line-height: 1.5; }
#inquiry-subject:focus, #inquiry-body:focus { border-color: var(--accent); }
.inquiry-count { margin: -2px 2px 0; text-align: right; font-size: 12px; color: var(--muted, #6b7c8c); }
.inquiry-message { min-height: 1em; margin: 0 2px; font-size: 13px; color: var(--muted); }

/* SNS 계정 연동 (설정 > 계정, 첫 화면) */
.sns-sub { margin: -2px 0 8px; font-size: 13px; color: var(--muted); }
.sns-row { display: flex; flex-wrap: wrap; gap: 8px; }
.sns-btn {
  flex: 1 1 140px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  min-height: 44px;
  padding: 0 14px;
  border-radius: 12px;
  font: inherit;
  font-size: 14px;
  font-weight: 700;
  cursor: pointer;
}
.sns-btn svg { width: 20px; height: 20px; flex: none; }
.sns-btn.google { border: 1px solid #d6dde4; background: #fff; color: #1f1f1f; }
.sns-btn.line { border: 1px solid #06c755; background: #06c755; color: #fff; }
.sns-btn.linked { box-shadow: inset 0 0 0 2px var(--accent); }
.sns-btn:disabled { opacity: 0.5; cursor: default; }
.sns-message { min-height: 1em; margin: 6px 2px 0; font-size: 13px; color: var(--muted); }
.entry-sns { margin-top: 10px; }
/* 첫 화면 ↔ SNS로 처음 온 사람의 닉네임·국가 정하기 창 (같은 창, client/js/main.js setSnsPick) */
#entry:not(.sns-pick) [data-mode="pick"], #entry.sns-pick [data-mode="start"] { display: none !important; }
#entry.sns-pick #entry-form > h1:first-child { margin-bottom: 14px; padding-bottom: 14px; }

/* 설정 맨 아래 이용약관·개인정보처리방침 */
.legal-links { margin: 10px 0 0; text-align: center; font-size: 12px; color: var(--muted); }
.legal-links a { color: var(--muted); }

/* ---------- 각인 작업대: 장비 고르기 · 윗면/바닥 · 판 미리보기 · 사진 공유 | 스티커 또는 글자 · 색 · 폰트 · 크기 ---------- */
.panel.engrave-panel {
  display: flex;
  flex-direction: column;
  width: min(600px, 100%);
  max-height: min(calc(100vh - 32px), 100%);
  max-height: min(calc(100dvh - 32px), 100%);
  padding: 18px 16px 16px;
}
.panel.engrave-panel > h1:first-child { margin: -18px -16px 0; padding: 18px 50px 4px; }
.panel.engrave-panel > h1:first-child + .sub { margin: 0 -16px 10px; padding: 2px 16px 12px; text-align: center; }
.panel.engrave-panel .panel-x { top: 8px; right: 8px; }
.engrave-body { flex: 1 1 auto; min-height: 0; overflow-y: auto; padding: 2px; }
.engrave-gear { display: flex; gap: 8px; margin-bottom: 8px; padding: 2px 2px 4px; overflow-x: auto; }
.engrave-card {
  display: flex;
  flex: none;
  flex-direction: column;
  align-items: center;
  gap: 2px;
  width: 78px;
  padding: 5px 4px 6px;
  border: 1px solid var(--line);
  border-radius: 12px;
  background: #fff;
}
.engrave-card img { width: 64px; height: 64px; object-fit: contain; }
.engrave-card span {
  display: -webkit-box;
  max-width: 100%;
  overflow: hidden;
  font-size: 11px;
  line-height: 1.2;
  text-align: center;
  -webkit-box-orient: vertical;
  -webkit-line-clamp: 2;
}
.engrave-card.picked { border-color: var(--accent); box-shadow: inset 0 0 0 2px var(--accent); }
#engrave-view {
  display: block;
  width: 100%;
  height: 210px;
  border-radius: 14px;
  box-shadow: 0 0 0 1.5px var(--ice);
  cursor: grab;
  touch-action: none;
}
#engrave-view:active { cursor: grabbing; }
.engrave-hint { margin: 4px 0 0; color: var(--muted); font-size: 12px; text-align: center; }
.engrave-sides { display: grid; grid-template-columns: 1fr 1fr; gap: 6px; margin-bottom: 8px; }
.engrave-sides.sticker-sizes { grid-template-columns: repeat(3, 1fr); }
.engrave-sides button {
  min-height: 40px;
  border: 1px solid var(--line);
  border-radius: 12px;
  background: #fff;
  color: var(--ink);
  font: inherit;
  font-size: 14px;
  font-weight: 700;
}
.engrave-sides button[aria-pressed='true'] { border-color: var(--accent); box-shadow: inset 0 0 0 2px var(--accent); color: var(--accent); }
.sticker-count { margin-left: 4px; color: var(--muted); font-size: 12px; font-weight: 700; }
.sticker-list { display: grid; grid-template-columns: repeat(5, minmax(0, 1fr)); gap: 6px; }
.sticker-pick {
  display: flex;
  align-items: center;
  justify-content: center;
  min-width: 0;
  aspect-ratio: 1;
  padding: 4px;
  border: 1px solid var(--line);
  border-radius: 12px;
  background: #e9eff5;
  touch-action: manipulation;
}
.sticker-pick img { width: 100%; height: 100%; object-fit: contain; pointer-events: none; }
.sticker-pick:disabled { opacity: 0.45; }
#sticker-remove { margin-top: 8px; }
/* 데코 확정 전 다시 묻는 창 */
.deco-ask { position: fixed; inset: 0; z-index: 60; display: flex; align-items: center; justify-content: center; padding: 16px; background: rgba(10, 20, 35, 0.45); }
.deco-ask-box { width: min(340px, 100%); padding: 20px 16px 16px; border-radius: 18px; background: #fff; box-shadow: 0 10px 30px rgba(0, 0, 0, 0.25); text-align: center; }
.deco-ask-box p { margin: 0 0 16px; color: var(--ink); font-size: 16px; font-weight: 700; line-height: 1.5; word-break: keep-all; }
.deco-ask-buttons { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; }
.deco-ask-buttons button { min-height: 44px; }
#engrave-current {
  margin: 8px 0 0;
  padding: 8px 12px;
  border: 1.5px dashed #e8a35a;
  border-radius: 12px;
  background: #fff1e0;
  font-size: 13px;
  line-height: 1.5;
  text-align: center;
}
#engrave-current[hidden] { display: none; }
#engrave-current-text { padding: 0 6px; border-radius: 6px; background: #45525f; font-size: 17px; }
#engrave-current-text[data-color='gold'] { color: #f0c75a; }
#engrave-current-text[data-color='silver'] { color: #dfe4ea; }
#engrave-current-text[data-color='white'] { color: #fff; }
#engrave-current-text[data-color='black'] { background: #e9eef3; color: #15171c; }
.engrave-label { display: block; margin: 12px 0 6px; color: var(--sky); font-size: 13px; font-weight: 800; }
#engrave-text {
  width: 100%;
  min-height: 46px;
  padding: 0 14px;
  border: 1px solid var(--line);
  border-radius: 12px;
  background: #fff;
  color: var(--ink);
  font: inherit;
  font-size: 18px;
  font-weight: 700;
  letter-spacing: 0.5px;
  outline: none;
}
#engrave-text:focus { border-color: var(--accent); }
.engrave-colors { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 6px; }
.engrave-color, .engrave-font {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 3px;
  min-width: 0;
  min-height: 52px;
  padding: 5px 4px;
  border: 1px solid var(--line);
  border-radius: 12px;
  background: #fff;
  font-size: 12px;
}
.engrave-color i { width: 22px; height: 22px; border-radius: 50%; box-shadow: inset 0 0 0 1px rgba(0, 0, 0, 0.2); }
.engrave-color[aria-pressed='true'], .engrave-font[aria-pressed='true'] { border-color: var(--accent); box-shadow: inset 0 0 0 2px var(--accent); font-weight: 700; }
.engrave-fonts { display: grid; grid-template-columns: repeat(5, minmax(0, 1fr)); gap: 6px; }
.engrave-font b {
  max-width: 100%;
  overflow: hidden;
  color: var(--ink);
  font-size: 19px;
  font-weight: 400;
  line-height: 1.3;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.engrave-font span { color: var(--muted); font-size: 11px; }
#engrave-size { width: 100%; margin: 2px 0 4px; accent-color: var(--accent); }
#engrave-confirm { flex: none; margin-top: 12px; }
.panel.engrave-panel > #engrave-close { flex: none; }
@media (max-width: 520px) {
  .panel.engrave-panel { padding: 14px 12px 12px; }
  .panel.engrave-panel > h1:first-child { margin: -14px -12px 0; }
  .panel.engrave-panel > h1:first-child + .sub { margin: 0 -12px 8px; }
  #engrave-view { height: 180px; }
  .engrave-fonts { grid-template-columns: repeat(3, minmax(0, 1fr)); }
  .sticker-list { gap: 5px; }
}
/* 넓은 화면: 왼쪽에 장비·미리보기, 오른쪽에 글자·색·폰트·크기 (스크롤 없이 한눈에) */
@media (min-width: 760px) and (min-height: 561px) {
  .panel.engrave-panel { width: min(900px, 100%); }
  .engrave-body { display: grid; grid-template-columns: minmax(0, 1.1fr) minmax(0, 1fr); gap: 18px; align-items: start; }
  #engrave-view { height: 240px; }
  .engrave-form .engrave-label:first-child { margin-top: 0; }
}
/* 가로로 눕힌 휴대폰: 같은 두 칸을 더 촘촘하게, 아래 두 버튼은 한 줄 */
@media (min-width: 560px) and (max-height: 560px) {
  #engrave.panel-wrap { padding: 8px 12px; }
  .panel.engrave-panel {
    display: grid;
    grid-template-columns: minmax(0, 1fr) minmax(0, 1fr);
    grid-template-rows: auto auto minmax(0, 1fr) auto;
    column-gap: 10px;
    width: min(900px, 100%);
    max-height: 100%;
    padding: 8px 12px 10px;
  }
  .panel.engrave-panel > h1:first-child { grid-column: 1 / -1; margin: -8px -12px 0; padding: 8px 50px 0; font-size: 17px; }
  .panel.engrave-panel > h1:first-child + .sub { grid-column: 1 / -1; margin: 0 -12px 6px; padding: 0 12px 6px; font-size: 12px; }
  .panel.engrave-panel .panel-x { top: 4px; right: 6px; width: 32px; height: 32px; }
  .engrave-body { grid-column: 1 / -1; display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 1fr); gap: 12px; overflow: hidden; }
  .engrave-look, .engrave-form { min-height: 0; overflow-y: auto; padding: 2px; }
  .engrave-gear { margin-bottom: 4px; padding-bottom: 2px; }
  .engrave-card { flex-direction: row; width: auto; max-width: 150px; padding: 3px 8px 3px 3px; }
  .engrave-card img { width: 34px; height: 34px; }
  #engrave-view { height: 140px; }
  .engrave-hint { margin-top: 2px; font-size: 11px; }
  #engrave-current { margin-top: 4px; padding: 4px 8px; font-size: 11px; line-height: 1.4; }
  .engrave-label { margin: 4px 0 3px; font-size: 12px; }
  .engrave-form .engrave-label:first-child { margin-top: 0; }
  #engrave-text { min-height: 38px; font-size: 16px; }
  .engrave-color, .engrave-font { min-height: 38px; padding: 3px; gap: 1px; }
  .engrave-color { flex-direction: row; gap: 5px; }
  .engrave-color i { width: 16px; height: 16px; }
  .engrave-fonts { grid-template-columns: repeat(5, minmax(0, 1fr)); gap: 4px; }
  .engrave-font b { font-size: 15px; }
  .engrave-font span { font-size: 10px; }
  #engrave-size { margin: 0; }
  .engrave-sides { margin-bottom: 4px; }
  .engrave-sides button { min-height: 32px; font-size: 13px; }
  #sticker-remove { min-height: 34px; margin-top: 4px; }
  .sticker-list { grid-template-columns: repeat(7, minmax(0, 1fr)); gap: 4px; }
  .sticker-pick { padding: 2px; border-radius: 8px; }
  #engrave-confirm, .panel.engrave-panel > #engrave-close { position: static; min-height: 40px; margin-top: 8px; box-shadow: 0 3px 0 #b8432f; }
  .panel.engrave-panel > #engrave-close { box-shadow: 0 0 0 1.5px var(--ice), 0 3px 0 var(--ice-deep); }
}

/* ---------- 튜닝 창 (정비소 스키·보드 튜닝기) ---------- */
.panel.tuning-panel { width: min(440px, 100%); max-height: min(calc(100vh - 32px), 100%); max-height: min(calc(100dvh - 32px), 100%); overflow-y: auto; }
.panel.tuning-panel > h1:first-child + .sub { text-align: center; }
.tuning-row { margin-top: 14px; }
.tuning-row:first-child { margin-top: 2px; }
.tuning-head { display: flex; align-items: baseline; gap: 8px; margin-bottom: 6px; }
.tuning-head b { color: var(--sky); font-size: 16px; font-weight: 800; white-space: nowrap; }
.tuning-head span { flex: 0 1 auto; min-width: 0; color: var(--muted); font-size: 12px; }
.tuning-head em { flex: 1 1 auto; color: var(--muted); font-size: 12px; font-style: normal; white-space: nowrap; }
.tuning-head em::before { content: '· '; }
.tuning-head strong { color: var(--ink); font-size: 16px; font-weight: 800; font-variant-numeric: tabular-nums; white-space: nowrap; }
.tuning-head strong[data-change='up'] { color: var(--accent); }
.tuning-head strong[data-change='down'] { color: var(--muted); }
.tuning-line { display: flex; align-items: center; gap: 8px; }
.tuning-step {
  flex: none;
  width: 44px;
  height: 44px;
  padding: 0;
  border: 0;
  border-radius: 12px;
  background: #fff;
  box-shadow: 0 0 0 1.5px var(--ice), 0 3px 0 var(--ice-deep);
  color: var(--sky);
  font-size: 24px;
  font-weight: 800;
  line-height: 1;
  cursor: pointer;
  touch-action: manipulation;
}
.tuning-step:active:not(:disabled) { transform: translateY(2px); box-shadow: 0 0 0 1.5px var(--ice), 0 1px 0 var(--ice-deep); }
.tuning-step:disabled { opacity: 0.35; cursor: default; }
.tuning-bar { flex: 1 1 auto; display: grid; grid-template-columns: repeat(15, minmax(0, 1fr)); gap: 3px; min-width: 0; }
.tuning-bar i { position: relative; height: 22px; border-radius: 4px; background: var(--ice); }
.tuning-bar i.on { background: var(--sky); }
.tuning-bar i.up { background: var(--accent); }
.tuning-bar i.down { background: transparent; box-shadow: inset 0 0 0 2px var(--ice-deep); }
/* 기본값 칸: 아래 작은 세모 */
.tuning-bar i.base::after {
  content: '';
  position: absolute;
  left: 50%;
  bottom: -8px;
  margin-left: -5px;
  border: 5px solid transparent;
  border-top: 0;
  border-bottom-color: var(--gold);
}
#tuning-left { margin: 18px 0 0; padding: 8px 12px; border-radius: 12px; background: var(--frost); color: var(--muted); font-size: 14px; font-weight: 700; text-align: center; }
#tuning-left[data-spare='1'] { background: #fff3d6; color: #9a6a12; }
#tuning-confirm { width: 100%; margin-top: 12px; }
@media (max-width: 380px) {
  .tuning-step { width: 40px; height: 40px; }
  .tuning-bar { gap: 2px; }
}
/* 가로로 눕힌 휴대폰: 능력치 한 줄에 이름·값(왼쪽)과 막대(오른쪽), 아래 남은 점수·적용·닫기는 한 줄 */
@media (min-width: 560px) and (max-height: 560px) {
  #tuning.panel-wrap { padding: 8px 12px; }
  .panel.tuning-panel {
    display: grid;
    grid-template-columns: minmax(0, 1fr) minmax(0, 1.3fr) minmax(0, 0.8fr);
    column-gap: 10px;
    align-items: center;
    width: min(700px, 100%);
    max-height: 100%;
    padding: 8px 12px 10px;
  }
  .panel.tuning-panel > h1:first-child { grid-column: 1 / -1; margin: -8px -12px 0; padding: 8px 50px 0; font-size: 17px; }
  .panel.tuning-panel > h1:first-child + .sub { grid-column: 1 / -1; margin: 0 -12px 6px; padding: 0 12px 6px; font-size: 12px; }
  .panel.tuning-panel .panel-x { top: 4px; right: 6px; width: 32px; height: 32px; }
  #tuning-stats { grid-column: 1 / -1; }
  .tuning-row, .tuning-row:first-child {
    display: grid;
    grid-template-columns: 210px minmax(0, 1fr);
    column-gap: 10px;
    align-items: center;
    margin-top: 6px;
  }
  .tuning-head { margin: 0; }
  .tuning-head span { display: none; }
  .tuning-head em::before { content: ''; }
  .tuning-step { width: 38px; height: 38px; font-size: 20px; }
  .tuning-bar i { height: 20px; }
  .tuning-bar i.base::after { bottom: -7px; }
  #tuning-left { margin: 10px 0 0; padding: 0 8px; min-height: 44px; display: flex; align-items: center; justify-content: center; font-size: 13px; }
  #tuning-confirm { margin-top: 10px; }
  .panel.tuning-panel > #tuning-close { margin-top: 10px; position: static; box-shadow: 0 0 0 1.5px var(--ice), 0 3px 0 var(--ice-deep); }
}
/* ---------- 장비 전시대: 전시대를 크게 보는 동안 아래 막대에서 장비 바꾸기·사진 공유 ---------- */
.showcase-bar {
  position: fixed;
  left: 50%;
  bottom: 0;
  transform: translateX(-50%);
  width: min(760px, 100%);
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px 12px calc(10px + env(safe-area-inset-bottom));
  border-radius: 18px 18px 0 0;
  background: rgba(255, 255, 255, 0.94);
}
#showcase-list { flex: 1 1 auto; min-width: 0; display: flex; gap: 8px; overflow-x: auto; padding: 2px; }
.showcase-buttons { flex: none; display: flex; flex-direction: column; gap: 8px; }
.showcase-buttons button { min-width: 108px; }
@media (orientation: portrait) {
  .showcase-bar { flex-direction: column; align-items: stretch; }
  .showcase-buttons { flex-direction: row; }
  .showcase-buttons button { flex: 1; }
}
@media (max-height: 500px) and (orientation: landscape) {
  .showcase-bar { padding-top: 6px; padding-bottom: calc(6px + env(safe-area-inset-bottom)); }
  #showcase-list .engrave-card { flex-direction: row; width: auto; max-width: 150px; padding: 3px 8px 3px 3px; }
  #showcase-list .engrave-card img { width: 34px; height: 34px; }
  .showcase-buttons { flex-direction: row; }
}

/* CrazyGames판(html.portal): 외부 링크·외부 로그인·결제·후원·소식은 쓰지 않는다 (포털 규정) */
.portal #entry-sns,
.portal .settings-links,
.portal .legal-links,
.portal #news-button,
.portal .support-link,
.portal #gem-refund-link,
.portal #code-details h2[data-i18n="settings.sns"],
.portal .sns-sub,
.portal .sns-row,
.portal #sns-message { display: none !important; }
/* 보상형 광고 줄: 체력 채우기 줄과 같은 모양, 아이콘만 영상 */
.gem-refill.ad-row { margin-top: 10px; }
#ad-gems.ad-row { margin: 0 0 12px; }
.gem-refill .ad-mark { background: radial-gradient(circle at 35% 30%, #8dbcf3, #3f7fd6 70%); }
.gem-refill .ad-button { min-width: 92px; font-variant-numeric: tabular-nums; }

/* ---------- 첫 화면·스키장 고르기 배경 (3D를 띄우기 전, 그림 파일 없이) ---------- */
#front-bg {
  position: fixed;
  inset: 0;
  overflow: hidden;
  pointer-events: none;
  background: linear-gradient(180deg, #6fa8de 0%, #a9d0f0 45%, #dcecf9 70%, #f6fbff 100%);
}
#front-bg[hidden] { display: none; }
.front-hills {
  position: absolute;
  left: 0;
  right: 0;
  bottom: 0;
  width: 100%;
  height: 48%;
}
.front-hills .far { fill: #8fb6da; }
.front-hills .cap { fill: #f4f9ff; }
.front-hills .near { fill: #bfd8ee; }
.front-hills .snow { fill: #f6fbff; }
/* 내리는 눈: 크기가 다른 점 세 겹을 다른 빠르기로 내린다 */
.front-snow {
  position: absolute;
  inset: -200px 0 0;
  background-image:
    radial-gradient(circle, rgba(255, 255, 255, 0.95) 0 2px, transparent 3px),
    radial-gradient(circle, rgba(255, 255, 255, 0.8) 0 1.5px, transparent 2.5px),
    radial-gradient(circle, rgba(255, 255, 255, 0.7) 0 1px, transparent 2px);
  background-size: 180px 200px, 120px 140px, 70px 90px;
  background-position: 20px 0, 60px 30px, 10px 50px;
  animation: front-snow 14s linear infinite;
}
@keyframes front-snow {
  to { background-position: 60px 200px, 30px 170px, 40px 140px; }
}
@media (prefers-reduced-motion: reduce) {
  .front-snow { animation: none; }
}

/* 스키장 고르기: 왼쪽은 작은 그림·이름 목록(상자 없이 줄과 고른 줄 표시), 오른쪽은 고른 스키장 설명 */
.lobby-panel { width: min(700px, 100%); }
.lobby-panel h1 { margin-bottom: 16px; }
.lobby-body {
  display: grid;
  grid-template-columns: minmax(0, 220px) minmax(0, 1fr);
  gap: 18px;
  margin-bottom: 16px;
}
#lobby-list {
  margin: 0;
  padding: 0;
  list-style: none;
  border-top: 1px solid var(--line);
}
.lobby-resort {
  position: relative;
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px 6px 10px 12px;
  border-bottom: 1px solid var(--line);
  color: var(--muted);
  cursor: pointer;
  outline: none;
}
.lobby-resort.selected { color: var(--ink); }
.lobby-resort.selected::before {
  content: '';
  position: absolute;
  left: 0;
  top: 10px;
  bottom: 10px;
  width: 4px;
  border-radius: 2px;
  background: var(--accent);
}
.lobby-resort:focus-visible .lobby-row-name { text-decoration: underline; text-underline-offset: 3px; }
.lobby-thumb {
  position: relative;
  flex: none;
  overflow: hidden;
  width: 64px;
  height: 42px;
  border-radius: 8px;
  background: #cfe3f2;
}
.lobby-thumb img { display: block; width: 100%; height: 100%; object-fit: cover; }
.lobby-resort:not(.selected) .lobby-thumb { opacity: 0.75; }
.lobby-row-name {
  min-width: 0;
  font-size: 15px;
  font-weight: 700;
  line-height: 1.3;
  word-break: keep-all;
}
.lobby-row-name small {
  display: block;
  margin-top: 2px;
  color: #93a4b4;
  font-size: 12px;
  font-weight: 600;
}
/* 오픈 준비중 그림: 산 그림자와 자물쇠 */
.soon-art, .lobby-hero.soon-art { background: linear-gradient(180deg, #5d7a98 0%, #8fa9c1 100%); }
.soon-hills { position: absolute; left: 0; right: 0; bottom: 0; width: 100%; height: 75%; }
.soon-hills path { fill: rgba(255, 255, 255, 0.24); }
.soon-lock {
  position: absolute;
  top: 50%;
  left: 50%;
  display: grid;
  place-items: center;
  width: 22px;
  height: 22px;
  border-radius: 50%;
  background: rgba(255, 255, 255, 0.25);
  transform: translate(-50%, -50%);
}
.soon-lock svg { width: 13px; height: 13px; fill: none; stroke: #fff; stroke-width: 2.2; }
.lobby-hero .soon-lock { width: 44px; height: 44px; }
.lobby-hero .soon-lock svg { width: 22px; height: 22px; }

/* 설명 */
.lobby-info h2 { margin: 12px 2px 10px; font-size: 18px; }
.lobby-hero {
  position: relative;
  overflow: hidden;
  aspect-ratio: 16 / 9;
  border-radius: 12px;
  background: #cfe3f2;
}
.lobby-hero img { display: block; width: 100%; height: 100%; object-fit: cover; }
.lobby-acts {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 8px 12px;
  margin: 0;
  padding: 0;
  list-style: none;
}
.lobby-acts li {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 14px;
  font-weight: 700;
}
.lobby-acts svg {
  flex: none;
  width: 30px;
  height: 30px;
  padding: 6px;
  border-radius: 50%;
  background: #fde9e4;
  fill: none;
  stroke: var(--accent);
  stroke-width: 2;
  stroke-linecap: round;
  stroke-linejoin: round;
}
.lobby-soon-note { margin: 0 2px; color: var(--muted); font-size: 14px; }
#lobby-go:disabled { opacity: 0.45; cursor: default; }

/* 좁은 화면(세로 폰): 목록 칸을 좁히고 그림을 이름 위에 */
@media (max-width: 560px) {
  .lobby-body { grid-template-columns: 104px minmax(0, 1fr); gap: 12px; }
  .lobby-resort { flex-direction: column; align-items: stretch; gap: 6px; padding: 10px 4px 10px 10px; }
  .lobby-resort.selected::before { top: 10px; bottom: 10px; }
  .lobby-thumb { width: 100%; height: auto; aspect-ratio: 16 / 10; }
  .lobby-row-name { font-size: 13px; }
  .lobby-row-name small { font-size: 11px; }
  .lobby-acts { grid-template-columns: minmax(0, 1fr); gap: 8px; }
  .lobby-acts li { font-size: 13px; }
}

/* ---------- 스키장 고르기 화면의 체력·골드·보석 (2026-12-04) ----------
   게임 화면 위쪽의 체력·골드·보석 칸을 그대로 보이고, 메뉴·방 버튼 등 나머지는 숨긴다 (front.js가 body.lobby-mode를 단다).
   고르기 창 위로 올리고, 보석 상점·알림·안내 띠는 그보다 위에 띄운다 */
body.lobby-mode #hud { z-index: 2; }
body.lobby-mode #hud > :not(#top-bar),
body.lobby-mode #top-bar > :not(.meter):not(#gold-box):not(#gem-box) { display: none !important; }
body.lobby-mode #gem-shop { z-index: 3; }
body.lobby-mode #toast,
body.lobby-mode #banner { z-index: 4; }
body.lobby-mode #lobby { padding-top: calc(max(12px, env(safe-area-inset-top)) + 56px); }

/* 지도 창 왼쪽 위 스키장 변경: ✕와 같은 흰 단추에 글자를 붙인 알약 */
.panel-x.map-resort { right: auto; left: 12px; width: auto; gap: 5px; padding: 0 13px 0 10px; border-radius: 19px; font-size: 13px; font-weight: 800; white-space: nowrap; }
.panel-x.map-resort svg { width: 17px; height: 17px; stroke-width: 2.6; stroke-linejoin: round; }
.panel-x.map-resort[hidden] { display: none; }
/* 좁은 화면(모바일)에서는 제목을 가리지 않게 글자를 두 줄로 작게 (번역의 줄바꿈 자리에서 나눈다, 넓은 화면은 한 줄) */
@media (max-width: 560px) {
  .panel-x.map-resort { gap: 4px; padding: 0 10px 0 8px; font-size: 10.5px; line-height: 1.08; white-space: pre-line; text-align: left; }
  .panel-x.map-resort svg { width: 15px; height: 15px; }
}

/* CrazyGames 계정으로 처음 온 사람: 닉네임 칸에 CrazyGames 이름이 들어가 고칠 수 없다 (주사위 없음) */
#entry.name-locked #name { background: #eef3f8; color: #3d556b; cursor: default; }
