/* ===== iOS 스타일 디자인 시스템 ===== */
:root {
  --primary: #007aff;            /* systemBlue */
  --primary-dark: #0062cc;
  --primary-light: #e5f0ff;      /* 선택 강조 틴트 */
  --tint-blue: rgba(0,122,255,0.12);
  --success: #34c759;
  --danger: #ff3b30;
  --warning: #ff9500;
  --bg: #f2f2f7;                 /* systemGroupedBackground */
  --card: #ffffff;
  --fill: rgba(120,120,128,0.12);     /* 세그먼트 트랙 / 입력 채움 */
  --fill-strong: rgba(120,120,128,0.22);
  --border: rgba(60,60,67,0.16);      /* 헤어라인 구분선 */
  --text: #000000;
  --text-secondary: rgba(60,60,67,0.6);
  --text-muted: rgba(60,60,67,0.34);
  --nav-bg: rgba(248,248,250,0.82);
  --shadow: 0 1px 2px rgba(0,0,0,0.05);
  --shadow-md: 0 6px 20px rgba(0,0,0,0.12);
  --shadow-seg: 0 1px 3px rgba(0,0,0,0.12), 0 1px 1px rgba(0,0,0,0.04);
  --radius: 12px;
  --radius-sm: 9px;
  --radius-lg: 16px;
}

@media (prefers-color-scheme: dark) {
  :root {
    --primary: #0a84ff;
    --primary-dark: #0a84ff;
    --primary-light: rgba(10,132,255,0.24);
    --tint-blue: rgba(10,132,255,0.24);
    --success: #30d158;
    --danger: #ff453a;
    --warning: #ff9f0a;
    --bg: #000000;
    --card: #1c1c1e;
    --fill: rgba(120,120,128,0.24);
    --fill-strong: rgba(120,120,128,0.36);
    --border: rgba(84,84,88,0.55);
    --text: #ffffff;
    --text-secondary: rgba(235,235,245,0.6);
    --text-muted: rgba(235,235,245,0.3);
    --nav-bg: rgba(28,28,30,0.8);
    --shadow: 0 1px 2px rgba(0,0,0,0.5);
    --shadow-md: 0 6px 20px rgba(0,0,0,0.5);
    --shadow-seg: 0 1px 3px rgba(0,0,0,0.5);
  }
  .leaderboard-item.rank-1 { background: linear-gradient(135deg, #3a3318, #4a401c); }
  .leaderboard-item.rank-2 { background: linear-gradient(135deg, #2a2a2c, #1f1f21); }
  .leaderboard-item.rank-3 { background: linear-gradient(135deg, #3a2a1d, #4a3320); }
  .member-badge.owner { background: rgba(255,159,10,0.22); color: #ffd60a; }
}

* { box-sizing: border-box; margin: 0; padding: 0; -webkit-tap-highlight-color: transparent; }

body {
  width: 100%;
  min-height: 100vh;
  font-family: -apple-system, BlinkMacSystemFont, 'SF Pro Text', 'Segoe UI', 'Noto Sans KR', sans-serif;
  font-size: 14px;
  letter-spacing: -0.01em;
  color: var(--text);
  background: var(--bg);
  overflow-x: hidden;
}

/* 팝업 모드: 고정 너비/높이 (사이드 패널은 가변) */
body.popup-mode { width: 400px; min-height: 580px; }
body.popup-mode .view { min-height: 580px; }

button { font-family: inherit; letter-spacing: -0.01em; }

/* ===== 뷰 전환 ===== */
.view { display: none; flex-direction: column; min-height: 100vh; }
.view.active { display: flex; }

/* ===== 로딩 ===== */
.loading-center {
  display: flex; flex-direction: column; align-items: center; justify-content: center;
  flex: 1; gap: 20px;
}
.spinner {
  width: 30px; height: 30px;
  border: 3px solid var(--fill-strong);
  border-top-color: var(--primary);
  border-radius: 50%;
  animation: spin 0.8s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }

/* ===== 로고 (앱 아이콘 스타일) ===== */
.logo-icon {
  width: 72px; height: 72px;
  background: linear-gradient(160deg, #3a9bff, #007aff);
  color: #fff; font-size: 36px; font-weight: 700;
  border-radius: 22px;
  display: flex; align-items: center; justify-content: center;
  box-shadow: 0 10px 26px rgba(0,122,255,0.4);
}
.logo-small {
  width: 28px; height: 28px;
  background: linear-gradient(160deg, #3a9bff, #007aff);
  color: #fff; font-size: 15px; font-weight: 700;
  border-radius: 8px;
  display: flex; align-items: center; justify-content: center;
  flex-shrink: 0;
}

/* ===== 로그인 ===== */
.auth-container {
  display: flex; flex-direction: column; align-items: center; justify-content: center;
  flex: 1; padding: 40px 32px; gap: 12px;
}
.app-name { font-size: 28px; font-weight: 700; color: var(--text); margin-top: 10px; letter-spacing: -0.02em; }
.app-desc { color: var(--text-secondary); font-size: 15px; text-align: center; margin-bottom: 18px; }
.btn-google {
  display: flex; align-items: center; gap: 10px;
  padding: 14px 24px;
  background: var(--card);
  border: 0.5px solid var(--border);
  border-radius: var(--radius);
  font-size: 16px; font-weight: 600; color: var(--text);
  cursor: pointer; transition: opacity 0.15s, transform 0.1s;
  box-shadow: var(--shadow); width: 100%; justify-content: center;
}
.btn-google:active { transform: scale(0.98); opacity: 0.85; }
.auth-note { color: var(--text-muted); font-size: 12px; text-align: center; }

/* ===== 헤더 (내비게이션 바) ===== */
.header {
  display: flex; align-items: center; justify-content: space-between;
  padding: 10px 12px;
  background: var(--nav-bg);
  -webkit-backdrop-filter: saturate(180%) blur(20px);
  backdrop-filter: saturate(180%) blur(20px);
  border-bottom: 0.5px solid var(--border);
  position: sticky; top: 0; z-index: 10;
  min-height: 48px;
}
.header-left { display: flex; align-items: center; gap: 8px; }
.header-right { display: flex; align-items: center; gap: 6px; }
.header-title {
  font-size: 17px; font-weight: 600; color: var(--text);
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis; max-width: 180px;
  letter-spacing: -0.02em;
}
.room-header { gap: 8px; }
.room-header-center {
  display: flex; align-items: center; gap: 6px; flex: 1; justify-content: center; min-width: 0;
}

/* ===== 버튼 ===== */
.btn-primary {
  background: var(--primary); color: #fff; border: none;
  border-radius: var(--radius); padding: 13px 18px;
  font-size: 16px; font-weight: 600; cursor: pointer;
  transition: opacity 0.15s, transform 0.1s;
}
.btn-primary:active { opacity: 0.85; transform: scale(0.98); }
.btn-primary:disabled { opacity: 0.5; }

.btn-secondary {
  background: var(--tint-blue); color: var(--primary); border: none;
  border-radius: var(--radius); padding: 13px 18px;
  font-size: 16px; font-weight: 600; cursor: pointer;
  transition: opacity 0.15s, transform 0.1s;
}
.btn-secondary:active { opacity: 0.7; transform: scale(0.98); }

.btn-danger {
  background: var(--danger); color: #fff; border: none;
  border-radius: var(--radius); padding: 13px 18px;
  font-size: 16px; font-weight: 600; cursor: pointer;
  transition: opacity 0.15s, transform 0.1s;
}
.btn-danger:active { opacity: 0.85; transform: scale(0.98); }

.btn-full { width: 100%; }

.btn-back {
  background: none; border: none; cursor: pointer;
  color: var(--primary); padding: 4px; border-radius: var(--radius-sm);
  display: flex; align-items: center;
}
.btn-back:active { opacity: 0.4; }

.btn-icon {
  background: none; border: none; cursor: pointer;
  color: var(--primary); padding: 6px; border-radius: 50%;
  display: flex; align-items: center; transition: opacity 0.15s;
}
.btn-icon:active { opacity: 0.4; }

.btn-nav {
  background: none; border: none; cursor: pointer;
  font-size: 22px; color: var(--primary); padding: 0 8px; line-height: 1;
}
.btn-nav:active { opacity: 0.4; }

/* ===== 아바타 ===== */
.avatar { width: 30px; height: 30px; border-radius: 50%; object-fit: cover; }

/* ===== 콘텐츠 영역 ===== */
.content { flex: 1; overflow-y: auto; padding: 16px; }
.form-content { padding: 18px 16px; }

/* ===== 섹션 헤더 (그룹 리스트 라벨) ===== */
.section-header { display: flex; align-items: center; justify-content: space-between; margin: 4px 4px 8px; }
.section-title { font-size: 13px; font-weight: 400; color: var(--text-secondary); text-transform: uppercase; letter-spacing: 0.02em; }

/* ===== 방 목록 (그룹 카드) ===== */
.rooms-list { display: flex; flex-direction: column; gap: 10px; }
.room-card {
  background: var(--card); border: none; border-radius: var(--radius);
  padding: 14px 36px 14px 16px; cursor: pointer; position: relative;
  transition: background 0.12s; box-shadow: var(--shadow);
}
.room-card::after {
  content: '›'; position: absolute; right: 14px; top: 50%; transform: translateY(-50%);
  color: var(--text-muted); font-size: 20px; font-weight: 500;
}
.room-card:active { background: var(--fill); }
.room-card-name { font-size: 16px; font-weight: 600; color: var(--text); margin-bottom: 4px; }
.room-card-meta { display: flex; align-items: center; gap: 10px; color: var(--text-secondary); font-size: 12px; }
.room-card-lock { color: var(--warning); }

/* ===== 하단 버튼 ===== */
.bottom-actions {
  padding: 12px 16px calc(12px + env(safe-area-inset-bottom));
  background: var(--nav-bg);
  -webkit-backdrop-filter: saturate(180%) blur(20px);
  backdrop-filter: saturate(180%) blur(20px);
  border-top: 0.5px solid var(--border);
  display: flex; gap: 10px;
}
.bottom-actions .btn-primary, .bottom-actions .btn-secondary { flex: 1; text-align: center; }

/* ===== 폼 ===== */
.form-group { margin-bottom: 18px; }
.form-label {
  display: block; font-size: 13px; font-weight: 400; color: var(--text-secondary);
  margin-bottom: 7px; letter-spacing: -0.01em;
}
.required { color: var(--danger); }
.form-input {
  width: 100%; padding: 12px 14px;
  border: none; background: var(--fill);
  border-radius: var(--radius-sm); font-size: 16px; color: var(--text);
  transition: box-shadow 0.15s; outline: none; font-family: inherit;
}
.form-input:focus { box-shadow: 0 0 0 3px var(--tint-blue); }
.form-textarea { resize: vertical; min-height: 80px; }
.form-select { cursor: pointer; }
.form-input:disabled { opacity: 0.5; cursor: not-allowed; }

/* ===== 시간 / 하루 종일 (스위치) ===== */
.time-row { display: flex; align-items: center; gap: 12px; }
.time-row .form-input { flex: 1; }
.checkbox-inline {
  display: flex; align-items: center; gap: 8px;
  font-size: 15px; font-weight: 400; color: var(--text);
  white-space: nowrap; cursor: pointer; margin: 0;
}
.checkbox-inline input[type="checkbox"] {
  appearance: none; -webkit-appearance: none;
  width: 42px; height: 25px; border-radius: 25px;
  background: var(--fill-strong); position: relative; cursor: pointer;
  transition: background 0.25s; flex-shrink: 0;
}
.checkbox-inline input[type="checkbox"]::before {
  content: ''; position: absolute; top: 2px; left: 2px;
  width: 21px; height: 21px; border-radius: 50%; background: #fff;
  box-shadow: 0 1px 3px rgba(0,0,0,0.3); transition: transform 0.25s;
}
.checkbox-inline input[type="checkbox"]:checked { background: var(--success); }
.checkbox-inline input[type="checkbox"]:checked::before { transform: translateX(17px); }

/* ===== 멤버 태그 (칩) ===== */
.tag-list { display: flex; flex-wrap: wrap; gap: 8px; }
.tag-chip {
  font-size: 14px; font-weight: 500; padding: 7px 13px; border-radius: 18px;
  border: none; background: var(--fill); color: var(--text);
  cursor: pointer; transition: all 0.15s;
}
.tag-chip:active { opacity: 0.6; }
.tag-chip.selected { background: var(--primary); color: #fff; }
.tag-empty { font-size: 14px; color: var(--text-muted); padding: 2px 0; }

/* ===== 그날 일정 목록 ===== */
.event-list { display: flex; flex-direction: column; gap: 8px; max-height: 340px; overflow-y: auto; }
.event-list-item {
  display: flex; align-items: center; gap: 8px;
  padding: 12px 14px; border: none; border-radius: var(--radius);
  background: var(--fill); cursor: pointer; transition: background 0.12s;
}
.event-list-item:active { background: var(--fill-strong); }
.eli-main { flex: 1; min-width: 0; }
.eli-title { font-size: 15px; font-weight: 600; color: var(--text); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.eli-meta { font-size: 12px; color: var(--text-secondary); margin-top: 2px; }
.eli-arrow { color: var(--text-muted); font-size: 18px; flex-shrink: 0; }
.error-msg { color: var(--danger); font-size: 13px; min-height: 16px; margin-bottom: 8px; }

/* ===== 체크인 바 ===== */
.checkin-bar {
  display: flex; align-items: center; justify-content: space-between;
  padding: 10px 16px; background: var(--card); border-bottom: 0.5px solid var(--border);
}
.checkin-status { display: flex; align-items: center; gap: 8px; }
.indicator { width: 9px; height: 9px; border-radius: 50%; flex-shrink: 0; }
.indicator.online {
  background: var(--success); box-shadow: 0 0 0 3px rgba(52,199,89,0.22);
  animation: pulse-online 2s infinite;
}
.indicator.offline { background: var(--text-muted); }
.indicator.resting { background: var(--warning); box-shadow: 0 0 0 3px rgba(255,149,0,0.22); }
@keyframes pulse-online {
  0%, 100% { box-shadow: 0 0 0 3px rgba(52,199,89,0.22); }
  50% { box-shadow: 0 0 0 5px rgba(52,199,89,0.08); }
}
.status-text { font-size: 13px; font-weight: 600; color: var(--text); }
.duration-text { font-size: 12px; color: var(--text-secondary); font-feature-settings: "tnum"; }

.btn-checkin {
  padding: 8px 16px; border: none; border-radius: 20px;
  font-size: 13px; font-weight: 600; cursor: pointer; transition: opacity 0.15s, transform 0.1s;
}
.btn-checkin:active { opacity: 0.8; transform: scale(0.96); }
.btn-checkin.enter { background: var(--primary); color: #fff; }
.btn-checkin.exit { background: rgba(255,59,48,0.14); color: var(--danger); }

.checkin-actions { display: flex; align-items: center; gap: 6px; }
.btn-rest {
  padding: 8px 14px; border: none; background: rgba(255,149,0,0.16);
  color: var(--warning); border-radius: 20px;
  font-size: 13px; font-weight: 600; cursor: pointer; transition: opacity 0.15s, transform 0.1s;
}
.btn-rest:active { opacity: 0.8; transform: scale(0.96); }
.btn-rest.resume { background: rgba(52,199,89,0.16); color: var(--success); }

/* ===== 세그먼트 컨트롤 (탭/토글 공통) ===== */
.tabs {
  display: flex; gap: 0; margin: 10px 16px 6px;
  background: var(--fill); border-radius: var(--radius-sm); padding: 2px;
}
.tab-btn {
  flex: 1; padding: 7px 4px; border: none; background: none;
  font-size: 13px; font-weight: 500; color: var(--text);
  cursor: pointer; border-radius: 7px; transition: all 0.2s;
}
.tab-btn.active { background: var(--card); color: var(--text); font-weight: 600; box-shadow: var(--shadow-seg); }
.tab-content { display: none; flex: 1; overflow-y: auto; }
.tab-content.active { display: block; }

/* ===== 달력 ===== */
.calendar-nav { display: flex; align-items: center; justify-content: space-between; padding: 10px 16px 6px; }
.cal-title { font-size: 17px; font-weight: 700; color: var(--text); letter-spacing: -0.02em; }
.cal-header-row { display: grid; grid-template-columns: repeat(7, 1fr); padding: 0 8px; margin-bottom: 2px; }
.cal-header-row span { text-align: center; font-size: 11px; font-weight: 600; color: var(--text-muted); padding: 4px 0; }
.cal-header-row span:first-child { color: var(--danger); }
.cal-header-row span:last-child { color: var(--primary); }
.cal-grid { display: grid; grid-template-columns: repeat(7, 1fr); padding: 0 8px 8px; gap: 2px; }
.cal-day {
  border-radius: var(--radius-sm); display: flex; flex-direction: column; align-items: stretch;
  padding: 3px 3px 2px; cursor: pointer; transition: background 0.1s; position: relative;
  min-height: 58px; overflow: hidden;
}
.cal-day:active:not(.empty):not(.other-month) { background: var(--fill); }
.cal-day.empty { cursor: default; }
.cal-day.other-month { opacity: 0.3; cursor: default; }
.cal-day.today .day-num {
  background: var(--primary); color: #fff; border-radius: 50%;
  width: 24px; height: 24px; display: flex; align-items: center; justify-content: center;
}
.cal-day.sunday .day-num { color: var(--danger); }
.cal-day.saturday .day-num { color: var(--primary); }
.day-num { font-size: 13px; font-weight: 500; line-height: 1; align-self: center; margin-bottom: 2px; }
.event-labels { display: flex; flex-direction: column; gap: 1px; margin-top: 1px; width: 100%; min-width: 0; }
.event-label {
  font-size: 8.5px; line-height: 1.3; padding: 1px 3px; border-radius: 3px;
  background: var(--tint-blue); color: var(--primary);
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
.ev-time { font-weight: 700; }
.event-more { font-size: 8px; color: var(--text-muted); padding-left: 3px; line-height: 1.2; }

/* ===== 멤버 목록 ===== */
.members-list { padding: 12px 16px; display: flex; flex-direction: column; gap: 8px; }
.member-item {
  display: flex; align-items: center; gap: 12px; padding: 11px 14px;
  background: var(--card); border: none; border-radius: var(--radius); box-shadow: var(--shadow);
}
.member-avatar-wrap { position: relative; flex-shrink: 0; }
.member-avatar { width: 38px; height: 38px; border-radius: 50%; object-fit: cover; }
.member-online-dot {
  position: absolute; bottom: 0; right: 0; width: 11px; height: 11px;
  border-radius: 50%; border: 2px solid var(--card);
}
.member-online-dot.online { background: var(--success); }
.member-online-dot.offline { background: var(--text-muted); }
.member-online-dot.resting { background: var(--warning); }
.member-info { flex: 1; min-width: 0; }
.member-name { font-size: 15px; font-weight: 600; color: var(--text); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.member-last-seen { font-size: 12px; color: var(--text-secondary); margin-top: 1px; }
.member-badge {
  font-size: 11px; background: var(--fill); color: var(--text-secondary);
  border-radius: 6px; padding: 3px 7px; font-weight: 600; white-space: nowrap;
}
.member-badge.owner { background: rgba(255,149,0,0.16); color: #c2780a; }

/* ===== 리더보드 기간 토글 (세그먼트) ===== */
.lb-period-toggle { display: flex; gap: 0; margin: 12px 16px 4px; background: var(--fill); border-radius: var(--radius-sm); padding: 2px; }
.lb-period-btn {
  flex: 1; padding: 7px 0; border: none; background: none; color: var(--text);
  font-size: 13px; font-weight: 500; border-radius: 7px; cursor: pointer; transition: all 0.2s;
}
.lb-period-btn.active { background: var(--card); color: var(--text); font-weight: 600; box-shadow: var(--shadow-seg); }

/* ===== 리더보드 ===== */
.leaderboard-date { text-align: center; font-size: 12px; color: var(--text-secondary); padding: 10px 0 4px; }
.leaderboard-list { padding: 8px 16px; display: flex; flex-direction: column; gap: 8px; }
.leaderboard-item {
  display: flex; align-items: center; gap: 12px; padding: 11px 14px;
  background: var(--card); border: none; border-radius: var(--radius); box-shadow: var(--shadow);
}
.leaderboard-item.rank-1 { background: linear-gradient(135deg, #fffbeb, #fef3c7); }
.leaderboard-item.rank-2 { background: linear-gradient(135deg, #f8fafc, #eef1f5); }
.leaderboard-item.rank-3 { background: linear-gradient(135deg, #fff7ed, #fde8d4); }
.rank-medal { font-size: 18px; width: 28px; text-align: center; flex-shrink: 0; }
.lb-avatar { width: 34px; height: 34px; border-radius: 50%; object-fit: cover; flex-shrink: 0; }
.lb-info { flex: 1; min-width: 0; }
.lb-name { font-size: 15px; font-weight: 600; color: var(--text); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.lb-online { font-size: 11px; color: var(--success); font-weight: 600; }
.lb-online.resting { color: var(--warning); }
.lb-duration { font-size: 15px; font-weight: 700; color: var(--primary); white-space: nowrap; font-feature-settings: "tnum"; }

/* ===== 멤버 카운트 배지 ===== */
.member-count-badge { font-size: 11px; background: var(--fill); color: var(--text-secondary); border-radius: 10px; padding: 2px 8px; font-weight: 600; }

/* ===== 모달 (바텀 시트) ===== */
.modal-overlay {
  position: fixed; inset: 0; background: rgba(0,0,0,0.4);
  display: flex; align-items: flex-end; justify-content: center; z-index: 100;
}
.modal {
  background: var(--card); border-radius: var(--radius-lg) var(--radius-lg) 0 0;
  width: 100%; max-width: 420px; box-shadow: var(--shadow-md);
  overflow: hidden; max-height: 92vh; display: flex; flex-direction: column;
  padding-top: 8px; animation: sheet-up 0.28s cubic-bezier(0.32,0.72,0,1);
}
@keyframes sheet-up { from { transform: translateY(100%); } to { transform: translateY(0); } }
.modal::before {
  content: ''; display: block; width: 36px; height: 5px; border-radius: 3px;
  background: var(--fill-strong); margin: 0 auto 6px;
}
.modal-header {
  display: flex; align-items: center; justify-content: space-between;
  padding: 8px 16px 12px; border-bottom: 0.5px solid var(--border);
}
.modal-title { font-size: 17px; font-weight: 700; letter-spacing: -0.02em; }
.modal-body { padding: 16px; overflow-y: auto; }
.modal-footer { display: flex; justify-content: flex-end; gap: 8px; padding: 12px 16px calc(16px + env(safe-area-inset-bottom)); border-top: 0.5px solid var(--border); }

/* ===== 토스트 ===== */
.toast {
  position: fixed; bottom: 24px; left: 50%;
  transform: translateX(-50%) translateY(10px);
  background: rgba(40,40,42,0.92);
  -webkit-backdrop-filter: blur(10px); backdrop-filter: blur(10px);
  color: #fff; padding: 11px 20px; border-radius: 22px;
  font-size: 14px; font-weight: 500; opacity: 0;
  transition: all 0.25s; z-index: 999; pointer-events: none; white-space: nowrap;
  box-shadow: 0 8px 24px rgba(0,0,0,0.25);
}
.toast.show { opacity: 1; transform: translateX(-50%) translateY(0); }

/* ===== 빈 상태 ===== */
.empty-state { text-align: center; color: var(--text-muted); font-size: 14px; padding: 32px 16px; }

/* ===== 메인 화면 랭킹 ===== */
.rank-section { background: var(--card); border: none; border-radius: var(--radius); box-shadow: var(--shadow); padding: 14px; margin-bottom: 16px; }
.rank-header { margin-bottom: 10px; }
.rank-title { font-size: 15px; font-weight: 700; color: var(--text); letter-spacing: -0.02em; }
.rank-toggle { display: flex; gap: 0; margin-bottom: 8px; background: var(--fill); border-radius: var(--radius-sm); padding: 2px; }
.rank-tab {
  flex: 1; padding: 6px 0; border: none; background: none; color: var(--text);
  font-size: 13px; font-weight: 500; border-radius: 7px; cursor: pointer; transition: all 0.2s;
}
.rank-tab.active { background: var(--card); color: var(--text); font-weight: 600; box-shadow: var(--shadow-seg); }
.rank-sub-toggle { display: flex; align-items: center; justify-content: space-between; gap: 8px; margin-bottom: 10px; }
.rank-period, .rank-metric { display: flex; gap: 0; background: var(--fill); border-radius: 8px; padding: 2px; }
.rank-period-btn, .rank-metric-btn {
  padding: 4px 10px; border: none; background: none; color: var(--text);
  font-size: 12px; font-weight: 500; border-radius: 6px; cursor: pointer; transition: all 0.2s;
}
.rank-period-btn.active, .rank-metric-btn.active { background: var(--card); color: var(--text); font-weight: 600; box-shadow: var(--shadow-seg); }
.rank-list { display: flex; flex-direction: column; }
.rank-row { display: flex; align-items: center; gap: 10px; padding: 9px 4px; border-bottom: 0.5px solid var(--border); }
.rank-row:last-child { border-bottom: none; }
.rank-num { font-size: 15px; width: 26px; text-align: center; flex-shrink: 0; font-weight: 600; color: var(--text-secondary); }
.rank-avatar { width: 28px; height: 28px; border-radius: 50%; object-fit: cover; flex-shrink: 0; }
.rank-main { flex: 1; min-width: 0; }
.rank-name { font-size: 14px; font-weight: 600; color: var(--text); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.rank-sub { font-size: 11px; color: var(--text-muted); }
.rank-dur { font-size: 13px; font-weight: 700; color: var(--primary); white-space: nowrap; flex-shrink: 0; font-feature-settings: "tnum"; }
.rank-note { font-size: 11px; color: var(--text-muted); text-align: center; margin-top: 10px; }
.rank-empty { font-size: 13px; color: var(--text-muted); text-align: center; padding: 16px 8px; }

/* ===== 헤더 시계 ===== */
.clock-bar {
  display: flex; align-items: center; justify-content: center;
  padding: 16px; background: var(--card); border-bottom: 0.5px solid var(--border);
}
.global-clock {
  font-size: 24px; font-weight: 700; letter-spacing: 0.5px;
  color: var(--primary);
  font-variant-numeric: tabular-nums; font-feature-settings: "tnum";
}

/* 클릭 가능한 아바타 */
.avatar.clickable { cursor: pointer; transition: opacity 0.15s; }
.avatar.clickable:active { opacity: 0.6; }

/* ===== 마이페이지 ===== */
.mypage-profile { display: flex; flex-direction: column; align-items: center; gap: 6px; padding: 20px 0 24px; }
.mypage-avatar { width: 84px; height: 84px; border-radius: 50%; object-fit: cover; box-shadow: var(--shadow); margin-bottom: 6px; }
.mypage-name { font-size: 22px; font-weight: 700; color: var(--text); letter-spacing: -0.02em; }
.mypage-email { font-size: 14px; color: var(--text-secondary); }
.mypage-card { background: var(--card); border: none; border-radius: var(--radius); box-shadow: var(--shadow); padding: 2px 16px; margin-bottom: 18px; }
.info-row { display: flex; align-items: center; justify-content: space-between; padding: 13px 0; border-bottom: 0.5px solid var(--border); }
.info-row:last-child { border-bottom: none; }
.info-label { font-size: 15px; color: var(--text); font-weight: 400; }
.info-value { font-size: 15px; color: var(--text-secondary); font-weight: 400; text-align: right; }
/* ===== 표시 방식 토글 ===== */
.mode-section { margin-bottom: 18px; }
.mode-label { font-size: 13px; color: var(--text-secondary); margin: 0 4px 7px; }
.mode-toggle { display: flex; gap: 0; background: var(--fill); border-radius: var(--radius-sm); padding: 2px; }
.mode-btn {
  flex: 1; padding: 8px 0; border: none; background: none; color: var(--text);
  font-size: 13px; font-weight: 500; border-radius: 7px; cursor: pointer; transition: all 0.2s;
}
.mode-btn.active { background: var(--card); color: var(--text); font-weight: 600; box-shadow: var(--shadow-seg); }
.mode-note { font-size: 11px; color: var(--text-muted); text-align: center; margin-top: 7px; }

.mypage-links { text-align: center; font-size: 13px; color: var(--text-muted); margin-bottom: 16px; }
.mypage-links a { color: var(--primary); text-decoration: none; }
.mypage-links a:active { opacity: 0.5; }
.mypage-links span { margin: 0 4px; color: var(--text-muted); }

/* ===== 강퇴 / 위임 버튼 ===== */
.btn-kick {
  background: none; border: none; color: var(--text-muted); font-size: 15px; font-weight: 600;
  cursor: pointer; padding: 4px 8px; border-radius: 50%; flex-shrink: 0; transition: all 0.15s;
}
.btn-kick:active { color: var(--danger); }
.btn-transfer { background: none; border: none; font-size: 15px; cursor: pointer; padding: 4px 6px; border-radius: 50%; flex-shrink: 0; transition: opacity 0.15s; }
.btn-transfer:active { opacity: 0.5; }
.danger-hint { font-size: 12px; color: var(--text-muted); text-align: center; margin-bottom: 2px; }

/* ===== 방 위험 영역 ===== */
.room-danger-zone { padding: 16px; display: flex; flex-direction: column; gap: 10px; }

/* ===== 사다리타기 게임 ===== */
.game-top { padding: 14px 16px 8px; }
.game-current { padding: 0 16px; }
.game-meta { font-size: 12px; color: var(--text-secondary); text-align: center; margin-bottom: 10px; }

.ladder-wrap { background: var(--card); border-radius: var(--radius); box-shadow: var(--shadow); padding: 12px 10px; margin-bottom: 12px; }
.ladder-tops, .ladder-bots { position: relative; min-height: 28px; }
.ladder-top {
  position: absolute; transform: translateX(-50%);
  font-size: 11px; font-weight: 600; color: var(--text);
  background: var(--fill); border: none; border-radius: 8px;
  padding: 4px 7px; cursor: pointer; white-space: nowrap;
  max-width: 70px; overflow: hidden; text-overflow: ellipsis;
  transition: all 0.15s;
}
.ladder-top.selected { background: var(--primary); color: #fff; }
.ladder-bot {
  position: absolute; transform: translateX(-50%);
  font-size: 11px; font-weight: 600; color: var(--text-secondary);
  white-space: nowrap; max-width: 70px; overflow: hidden; text-overflow: ellipsis; text-align: center;
}
.ladder-bot.win { color: var(--warning); font-weight: 700; }
.ladder-svg-box { padding: 2px 0; }
.ladder-svg { display: block; }
.ladder-line { stroke: var(--text-muted); stroke-width: 2.5; stroke-linecap: round; }
.ladder-rung { stroke: var(--text-muted); stroke-width: 2.5; stroke-linecap: round; }
.ladder-path {
  stroke: var(--primary); stroke-width: 3.5; fill: none;
  stroke-linecap: round; stroke-linejoin: round;
  stroke-dasharray: 1400; stroke-dashoffset: 1400;
  animation: ladder-draw 0.7s ease forwards;
}
@keyframes ladder-draw { to { stroke-dashoffset: 0; } }

.game-reveal, .game-mine {
  font-size: 14px; text-align: center; padding: 9px 12px;
  border-radius: 10px; background: var(--fill); margin-top: 6px;
}
.game-reveal.win, .game-mine.win { background: rgba(255,149,0,0.16); color: var(--warning); }

.game-results { display: flex; flex-direction: column; gap: 8px; }
.game-result-row { display: flex; align-items: center; gap: 10px; }
.game-result-row .form-input { flex: 1; }
.game-win-toggle { margin: 0; flex-shrink: 0; }

.game-rank-header { font-size: 13px; font-weight: 700; color: var(--text); margin: 16px 4px 8px; }
.game-rank-list { background: var(--card); border-radius: var(--radius); box-shadow: var(--shadow); padding: 4px 12px; margin: 0 16px 16px; }

/* ===== 웹 버전 레이아웃 오버라이드 ===== */
html {
  background: var(--bg);
  min-height: 100%;
}

/* 데스크톱에선 모바일 앱처럼 가운데 컬럼으로 */
@media (min-width: 540px) {
  body {
    max-width: 480px;
    margin: 0 auto;
    min-height: 100vh;
    box-shadow: 0 0 0 0.5px var(--border);
  }
}

/* 표시 방식(사이드 패널/팝업)은 확장 전용 — 웹에선 숨김 */
.mode-section { display: none !important; }

