/* ============================================
   CSS 변수 (테마)
   ============================================ */
:root {
  /* 색상 */
  --primary-color: #6366f1;
  --primary-hover: #4f46e5;
  --secondary-color: #10b981;
  --danger-color: #ef4444;
  --warning-color: #f59e0b;
  
  /* 배경색 */
  --bg-primary: #f8fafc;
  --bg-secondary: #ffffff;
  --bg-dark: #1e293b;
  
  /* 텍스트 */
  --text-primary: #1e293b;
  --text-secondary: #64748b;
  --text-light: #ffffff;
  
  /* 보더 */
  --border-color: #e2e8f0;
  --border-radius: 12px;
  
  /* 그림자 */
  --shadow-sm: 0 1px 2px rgba(0, 0, 0, 0.05);
  --shadow-md: 0 4px 6px rgba(0, 0, 0, 0.1);
  --shadow-lg: 0 10px 15px rgba(0, 0, 0, 0.1);
  
  /* 폰트 */
  --font-family: 'Noto Sans KR', -apple-system, BlinkMacSystemFont, sans-serif;
  
  /* 전환 */
  --transition: all 0.3s ease;
}

/* ============================================
   기본 스타일
   ============================================ */
* {
  margin: 0;
  padding: 0;
  box-sizing: border-box;
}

html {
  /* 모바일 브라우저마다 좁은 화면에서 글자를 자동으로 키우는 정도가 달라
     (특히 Brave가 Chrome보다 크게 보임) 자동 확대를 꺼서 크기를 통일한다 */
  -webkit-text-size-adjust: 100%;
  text-size-adjust: 100%;
}

/* Brave 모바일 브라우저는 같은 화면에서도 Chrome보다 확실히 크게 보인다는
   피드백에 따라, navigator.brave.isBrave()로 감지해 전체를 80% 크기로 축소 */
html.is-brave {
  font-size: 80%;
}

body {
  font-family: var(--font-family);
  background: var(--bg-primary);
  color: var(--text-primary);
  line-height: 1.6;
  min-height: 100vh;
}

/* ============================================
   네비게이션 바
   ============================================ */
#navbar {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  background: var(--bg-secondary);
  box-shadow: var(--shadow-md);
  /* 문제 결과(z-index:1500)/모달(2000)/로딩 스피너(3000) 등은 전부 top:0의
     전체화면 오버레이라, navbar보다 z-index가 높으면 그 위를 그대로 덮어
     메뉴바가 "사라진 것처럼" 보였다. 항상 맨 위에 오도록 가장 높은 값으로. */
  z-index: 5000;
}

#navbar.hidden {
  display: none;
}

.nav-container {
  max-width: 1200px;
  margin: 0 auto;
  padding: 0 20px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  height: 60px;
}

.nav-logo {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  font-size: 1.5rem;
  font-weight: 700;
  color: var(--primary-color);
  text-decoration: none;
}

.nav-logo-mark {
  width: 26px;
  height: 26px;
}

.nav-menu {
  display: flex;
  list-style: none;
  gap: 8px;
}

.nav-link {
  padding: 8px 16px;
  color: var(--text-secondary);
  text-decoration: none;
  border-radius: 8px;
  transition: var(--transition);
}

.nav-link:hover {
  background: rgba(99, 102, 241, 0.1);
  color: var(--primary-color);
}

.nav-link.active {
  background: var(--primary-color);
  color: var(--text-light);
}

/* 모바일 햄버거 메뉴 안에서만 보이는 로그아웃 항목 (데스크톱은 .nav-user 쪽 버튼 사용) */
.nav-logout-item {
  display: none;
}

.nav-user {
  display: flex;
  align-items: center;
  gap: 12px;
}

.nav-user span {
  font-weight: 500;
}

.nav-toggle {
  display: none;
  flex-direction: column;
  gap: 4px;
  background: none;
  border: none;
  cursor: pointer;
  padding: 8px;
}

.nav-toggle span {
  width: 24px;
  height: 2px;
  background: var(--text-primary);
  transition: var(--transition);
}

/* ============================================
   버튼 스타일
   ============================================ */
.btn-primary {
  background: var(--primary-color);
  color: var(--text-light);
  border: none;
  padding: 12px 24px;
  border-radius: var(--border-radius);
  font-size: 1rem;
  font-weight: 500;
  cursor: pointer;
  transition: var(--transition);
}

.btn-primary:hover {
  background: var(--primary-hover);
  transform: translateY(-2px);
}

.btn-primary:disabled {
  opacity: 0.5;
  cursor: not-allowed;
  transform: none;
}

.btn-secondary {
  background: transparent;
  color: var(--primary-color);
  border: 2px solid var(--primary-color);
  padding: 10px 22px;
  border-radius: var(--border-radius);
  font-size: 1rem;
  font-weight: 500;
  cursor: pointer;
  transition: var(--transition);
}

.btn-secondary:hover {
  background: var(--primary-color);
  color: var(--text-light);
}

.btn-small {
  padding: 6px 12px;
  font-size: 0.875rem;
}

/* ============================================
   폼 스타일
   ============================================ */
.form-group {
  margin-bottom: 16px;
}

.form-group label {
  display: block;
  margin-bottom: 6px;
  font-weight: 500;
  color: var(--text-secondary);
}

.form-group input,
.form-group select {
  width: 100%;
  padding: 12px 16px;
  border: 2px solid var(--border-color);
  border-radius: var(--border-radius);
  font-size: 1rem;
  font-family: inherit;
  transition: var(--transition);
}

.form-group input:focus,
.form-group select:focus {
  outline: none;
  border-color: var(--primary-color);
  box-shadow: 0 0 0 3px rgba(99, 102, 241, 0.1);
}

.numpad-input {
  text-align: center;
  font-size: 1.3rem;
  font-weight: 700;
  letter-spacing: 0.15em;
  font-variant-numeric: tabular-nums;
  background: var(--bg-primary);
  cursor: default;
  margin-bottom: 10px;
}

.numpad-grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 8px;
}

.numpad-key {
  padding: 14px 0;
  font-size: 1.1rem;
  font-weight: 700;
  font-family: inherit;
  border: 2px solid var(--border-color);
  border-radius: var(--border-radius);
  background: var(--bg-secondary);
  color: var(--text-primary);
  cursor: pointer;
  transition: var(--transition);
}

.numpad-key:hover {
  border-color: var(--primary-color);
  color: var(--primary-color);
}

.numpad-key:active {
  background: var(--bg-primary);
  transform: scale(0.96);
}

.numpad-key-action {
  font-size: 0.85rem;
  color: var(--text-secondary);
}

/* ============================================
   페이지 스타일
   ============================================ */
.page {
  display: none;
  padding: 80px 20px 20px;
  max-width: 1200px;
  margin: 0 auto;
}

@media (max-width: 480px) {
  /* 모바일 브라우저(특히 Brave)는 하단 툴바가 페이지 위에 겹쳐서 그려질 때가
     있어, 화면 맨 아래 버튼이 그 뒤로 가려 안 보일 수 있다. 여유 공간을 둔다 */
  .page {
    padding-bottom: calc(90px + env(safe-area-inset-bottom, 0px));
  }
}

.page.active {
  display: block;
}

/* ============================================
   인증 페이지
   ============================================ */
.auth-container {
  max-width: 400px;
  margin: 40px auto;
  padding: 40px;
  background: var(--bg-secondary);
  border-radius: var(--border-radius);
  box-shadow: var(--shadow-lg);
}

.auth-header {
  text-align: center;
  margin-bottom: 32px;
}

.auth-header h1 {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 10px;
  font-size: 2rem;
  margin-bottom: 8px;
}

.auth-logo-mark {
  width: 40px;
  height: 40px;
}

.auth-header p {
  color: var(--text-secondary);
}

.auth-form h2 {
  margin-bottom: 24px;
  text-align: center;
}

.cf-turnstile {
  margin: 12px 0;
  display: flex;
  justify-content: center;
}

.auth-switch {
  text-align: center;
  margin-top: 16px;
  color: var(--text-secondary);
}

.checkbox-label {
  display: flex;
  align-items: center;
  gap: 6px;
  margin: 4px 0 16px;
  font-size: 0.9rem;
  color: var(--text-secondary);
  cursor: pointer;
}

.checkbox-label input[type="checkbox"] {
  width: auto;
  margin: 0;
}

.auth-switch a {
  color: var(--primary-color);
  text-decoration: none;
  font-weight: 500;
}

.nickname-status {
  display: block;
  margin-top: 4px;
  font-size: 0.875rem;
}

.nickname-status.valid {
  color: var(--secondary-color);
}

.nickname-status.invalid {
  color: var(--danger-color);
}

/* ============================================
   홈 페이지
   ============================================ */
.home-container {
  text-align: center;
}

.welcome-section {
  margin-bottom: 40px;
}

.character-preview {
  width: 150px;
  height: 200px;
  margin: 0 auto 16px;
  display: flex;
  align-items: center;
  justify-content: center;
}

.quick-actions {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
  gap: 16px;
  margin-bottom: 40px;
}

.action-card {
  background: var(--bg-secondary);
  border: none;
  padding: 32px 24px;
  border-radius: var(--border-radius);
  box-shadow: var(--shadow-md);
  cursor: pointer;
  transition: var(--transition);
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 12px;
}

.action-card:hover {
  transform: translateY(-4px);
  box-shadow: var(--shadow-lg);
}

.action-icon {
  font-size: 3rem;
}

.action-text {
  font-size: 1.1rem;
  font-weight: 500;
}

.my-stats {
  background: var(--bg-secondary);
  padding: 24px;
  border-radius: var(--border-radius);
  box-shadow: var(--shadow-md);
}

.home-tip-banner {
  display: flex;
  align-items: center;
  gap: 12px;
  background: linear-gradient(135deg, #fef3c7 0%, #fde68a 100%);
  border: 1px solid #fbbf24;
  border-radius: var(--border-radius);
  padding: 14px 18px;
  margin-bottom: 20px;
}

.home-tip-icon {
  font-size: 1.8rem;
  flex-shrink: 0;
}

.home-rival-notice {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  flex-wrap: wrap;
  background: linear-gradient(135deg, #fee2e2 0%, #fecaca 100%);
  border: 1px solid #f87171;
  border-radius: var(--border-radius);
  padding: 10px 16px;
  margin-top: 10px;
  font-size: 0.9rem;
  color: #7f1d1d;
  text-align: center;
}

.home-rival-icon {
  font-size: 1.1rem;
}

.home-tip-banner p {
  margin: 0;
  font-size: 0.88rem;
  line-height: 1.5;
  color: #78350f;
}

.home-faq {
  margin-top: 24px;
}

.home-faq h3 {
  margin-bottom: 12px;
}

.faq-item {
  background: var(--bg-secondary);
  border-radius: var(--border-radius);
  box-shadow: var(--shadow-sm);
  margin-bottom: 8px;
  overflow: hidden;
}

.faq-item summary {
  padding: 14px 16px;
  font-weight: 600;
  font-size: 0.92rem;
  cursor: pointer;
  list-style: none;
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.faq-item summary::-webkit-details-marker {
  display: none;
}

.faq-item summary::after {
  content: '+';
  font-size: 1.2rem;
  font-weight: 700;
  color: var(--primary-color);
  flex-shrink: 0;
  margin-left: 12px;
  transition: transform 0.2s ease;
}

.faq-item[open] summary::after {
  transform: rotate(45deg);
}

.faq-item p {
  padding: 0 16px 16px;
  margin: 0;
  font-size: 0.85rem;
  line-height: 1.6;
  color: var(--text-secondary);
}

.my-stats h3 {
  margin-bottom: 16px;
}

.stats-grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 16px;
}

.stat-item {
  text-align: center;
}

.stat-value {
  display: block;
  font-size: 2rem;
  font-weight: 700;
  color: var(--primary-color);
}

.stat-label {
  color: var(--text-secondary);
}

/* ============================================
   점수판
   ============================================ */
.scoreboard-container h2 {
  margin-bottom: 24px;
}

.scoreboard-tabs,
.jump-nav {
  display: flex;
  gap: 8px;
  margin-bottom: 24px;
  flex-wrap: wrap;
}

/* 탭 전환이 아니라 해당 구역으로 스크롤 이동만 하는 점수판 상단 버튼 */
.jump-nav {
  position: sticky;
  top: 66px; /* 고정 네비바(60px) 바로 아래 */
  z-index: 20;
  background: var(--bg-primary);
  padding: 8px 0;
}

.jump-nav button {
  flex: 1;
  border: 2px solid var(--border-color);
  background: var(--bg-secondary);
  color: var(--text-secondary);
  font-family: inherit;
  font-weight: 600;
  padding: 10px 12px;
  border-radius: var(--border-radius);
  box-shadow: var(--shadow-sm);
  cursor: pointer;
  transition: var(--transition);
}

.jump-nav button:hover {
  border-color: var(--primary-color);
  color: var(--primary-color);
}

.jump-nav button.mine {
  background: var(--primary-color);
  border-color: var(--primary-color);
  color: var(--text-light);
}

.ranking-section {
  margin-bottom: 40px;
  scroll-margin-top: 130px; /* 고정 네비바 + sticky jump-nav 높이만큼 여유 */
}

.ranking-section-title {
  margin-bottom: 16px;
}

/* ===== 11위~1,000위 압축 리스트 (사진 없이 닉네임+점수만) ===== */
.compact-list {
  margin-top: 8px;
  background: var(--bg-secondary);
  border-radius: var(--border-radius);
  box-shadow: var(--shadow-sm);
  overflow: hidden;
}

.compact-row {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 8px 16px;
  font-size: 0.86rem;
  border-bottom: 1px solid var(--border-color);
}

.compact-row:nth-child(even) {
  background: var(--bg-primary);
}

.compact-row:last-child {
  border-bottom: none;
}

.compact-row .rank-num {
  width: 44px;
  color: var(--text-secondary);
  font-weight: 600;
  font-variant-numeric: tabular-nums;
}

.compact-row .name {
  flex: 1;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.compact-row .score {
  font-variant-numeric: tabular-nums;
  font-weight: 700;
  color: var(--text-secondary);
}

.compact-row.mine {
  background: rgba(99, 102, 241, 0.1);
  box-shadow: inset 3px 0 0 var(--primary-color);
}

.compact-row.mine .name,
.compact-row.mine .score {
  color: var(--primary-color);
  font-weight: 700;
}

/* ===== 후원자 (전원 표시 - 사진/닉네임 잘림·생략 없음) ===== */
.sponsor-section {
  background: #fff8e1;
  border: 1px solid #f5b301;
  border-radius: var(--border-radius);
  padding: 20px;
}

.sponsor-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(76px, 1fr));
  gap: 16px 8px;
}

.sponsor-card {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 6px;
  text-align: center;
}

.sponsor-avatar {
  display: inline-flex;
  align-items: flex-end;
  justify-content: center;
  width: 42px;
  height: 56px;
  overflow: hidden;
  line-height: 0;
  background: #fff;
  border: 1.5px solid #f5b301;
  border-radius: 10px;
}

.sponsor-avatar svg {
  height: 100%;
  width: auto;
}

.sponsor-name {
  font-size: 0.78rem;
  font-weight: 600;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  max-width: 100%;
}

.tab-btn {
  padding: 12px 22px;
  background: var(--bg-secondary);
  border: 2px solid var(--border-color);
  border-radius: var(--border-radius);
  cursor: pointer;
  transition: var(--transition);
  font-family: inherit;
  font-size: 1.1rem;
  font-weight: 800;
  letter-spacing: 0.01em;
  background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
  -webkit-background-clip: text;
  background-clip: text;
  color: transparent;
  border-color: #a78bdb;
}

.tab-btn:hover {
  border-color: #764ba2;
  transform: translateY(-1px);
  box-shadow: var(--shadow-md);
}

.tab-btn.active {
  background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
  -webkit-background-clip: border-box;
  background-clip: border-box;
  color: var(--text-light);
  border-color: #764ba2;
}

.ranking-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
  gap: 16px;
}

.score-tile {
  position: relative;
  overflow: hidden;
  isolation: isolate; /* 이 카드 안에서 새 스태킹 컨텍스트를 만들어, 아바타의
                          음수 z-index가 카드 밖으로 새어나가 배경에 가려지지 않게 함 */
  background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
  color: var(--text-light);
  padding: 24px;
  border-radius: var(--border-radius);
  box-shadow: var(--shadow-md);
  transition: var(--transition);
}

.score-tile:hover {
  transform: translateY(-4px);
}

.score-tile.rank-1 {
  background: linear-gradient(135deg, #f093fb 0%, #f5576c 100%);
}

.score-tile.rank-2 {
  background: linear-gradient(135deg, #4facfe 0%, #00f2fe 100%);
}

.score-tile.rank-3 {
  background: linear-gradient(135deg, #43e97b 0%, #38f9d7 100%);
}

.tile-rank {
  font-size: 1.5rem;
  margin-bottom: 8px;
}

.tile-nickname {
  font-size: 1.2rem;
  font-weight: 700;
  margin-bottom: 4px;
}

.tile-score {
  font-size: 1.5rem;
  font-weight: 700;
}

.tile-games {
  font-size: 0.9rem;
  opacity: 0.9;
  margin-top: 4px;
}

.category-title {
  margin-bottom: 16px;
  color: var(--text-primary);
}

/* 종목별 순위 - 탭을 안 눌러도 전체 종목이 이어서 보이는 구역들 */
.category-subsection {
  margin-bottom: 28px;
  scroll-margin-top: 130px; /* 고정 네비바 + sticky jump-nav 높이만큼 여유 */
}

.category-subtitle {
  margin-bottom: 14px;
  font-size: 1.8rem;
  font-weight: 800;
  letter-spacing: 0.01em;
  background: linear-gradient(135deg, #667eea 0%, #764ba2 60%, #f0729d 100%);
  -webkit-background-clip: text;
  background-clip: text;
  color: transparent;
  text-shadow: 0 2px 12px rgba(118, 75, 162, 0.25);
}

.ranking-list {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.ranking-item {
  grid-column: 1 / -1; /* 부모(.ranking-grid)가 grid라도 한 줄 전체를 차지하는 가로 목록 행으로 표시 */
  position: relative;
  overflow: hidden;
  isolation: isolate;
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 12px 16px;
  background: var(--bg-secondary);
  border-radius: var(--border-radius);
  box-shadow: var(--shadow-sm);
}

.ranking-medal {
  font-size: 1.2rem;
  width: 40px;
}

.ranking-item.rank-1 {
  background: linear-gradient(135deg, #fef3c7 0%, #fde68a 100%);
  border: 2px solid #fbbf24;
}

.ranking-item.rank-2 {
  background: linear-gradient(135deg, #e0f2fe 0%, #bae6fd 100%);
  border: 2px solid #7dd3fc;
}

.ranking-item.rank-3 {
  background: linear-gradient(135deg, #d1fae5 0%, #a7f3d0 100%);
  border: 2px solid #6ee7b7;
}

.ranking-avatar-big {
  display: inline-flex;
  align-items: flex-end;
  height: 64px;
  width: 48px;
  overflow: hidden;
  line-height: 0;
  flex-shrink: 0;
}

/* 전체랭킹 1~3위 - 큰 포디움 카드 (4~10위는 아래 .ranking-item 목록) */
.podium {
  grid-column: 1 / -1; /* 부모(.ranking-grid)의 auto-fill 컬럼 폭에 잘리지 않고 항상 전체 너비 사용 */
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 12px;
  margin-bottom: 16px;
}

.podium-card {
  background: var(--bg-secondary);
  border: 2px solid var(--border-color);
  border-radius: var(--border-radius);
  box-shadow: var(--shadow-md);
  padding: 20px 8px 16px;
  text-align: center;
}

.podium-card.rank-1 {
  border-color: #fbbf24;
}

.podium-medal {
  font-size: 2rem;
  line-height: 1;
  margin-bottom: 8px;
}

.podium-avatar {
  display: inline-flex;
  align-items: flex-end;
  justify-content: center;
  height: 90px;
  width: 68px;
  overflow: hidden;
  line-height: 0;
  margin-bottom: 8px;
}

.podium-avatar svg {
  height: 100%;
  width: auto;
}

.podium-name {
  font-weight: 700;
  font-size: 0.9rem;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.podium-score {
  font-variant-numeric: tabular-nums;
  color: var(--primary-color);
  font-weight: 700;
  font-size: 0.95rem;
  margin-top: 2px;
}

/* 종합퀴즈 순위 - 모두를 종합퀴즈로 유도하기 위한 특별 레이아웃
   (1등 초대형 히어로 카드 + 2~10위는 3명씩 3단) */
.mixed-hero {
  grid-column: 1 / -1;
  background: linear-gradient(160deg, #fff8e1 0%, #ffe9a8 100%);
  border: 2px solid #fbbf24;
  border-radius: var(--border-radius);
  box-shadow: 0 8px 24px rgba(251, 191, 36, 0.35);
  padding: 28px 16px 24px;
  text-align: center;
  margin-bottom: 20px;
}

.mixed-hero-medal {
  font-size: 3.5rem;
  line-height: 1;
  margin-bottom: 8px;
}

.mixed-hero-avatar {
  display: inline-flex;
  align-items: flex-end;
  justify-content: center;
  height: 160px;
  width: 120px;
  overflow: hidden;
  line-height: 0;
  margin-bottom: 10px;
}

.mixed-hero-avatar svg {
  height: 100%;
  width: auto;
}

.mixed-hero-name {
  font-weight: 800;
  font-size: 1.4rem;
  color: var(--text-primary);
}

.mixed-hero-score {
  font-variant-numeric: tabular-nums;
  font-weight: 800;
  font-size: 1.6rem;
  color: #d97706;
  margin-top: 4px;
}

.mixed-row {
  grid-column: 1 / -1;
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 10px;
  margin-bottom: 10px;
}

.mixed-card {
  background: var(--bg-secondary);
  border: 1px solid var(--border-color);
  border-radius: var(--border-radius);
  box-shadow: var(--shadow-sm);
  padding: 12px 4px;
  text-align: center;
}

.mixed-card-rank {
  font-size: 0.78rem;
  font-weight: 700;
  color: var(--text-secondary);
  margin-bottom: 4px;
}

.mixed-card-avatar {
  display: inline-flex;
  align-items: flex-end;
  justify-content: center;
  height: 70px;
  width: 53px;
  overflow: hidden;
  line-height: 0;
  margin-bottom: 6px;
}

.mixed-card-avatar svg {
  height: 100%;
  width: auto;
}

.mixed-card-name {
  font-weight: 700;
  font-size: 0.8rem;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.mixed-card-score {
  font-variant-numeric: tabular-nums;
  color: var(--primary-color);
  font-weight: 700;
  font-size: 0.82rem;
  margin-top: 2px;
}

@media (max-width: 480px) {
  .mixed-hero-avatar {
    height: 120px;
    width: 90px;
  }

  .mixed-hero-name {
    font-size: 1.2rem;
  }

  .mixed-hero-score {
    font-size: 1.35rem;
  }

  .mixed-row {
    grid-template-columns: repeat(3, 1fr);
    gap: 6px;
  }

  .mixed-card {
    padding: 8px 2px;
  }

  .mixed-card-avatar {
    height: 50px;
    width: 38px;
  }

  .mixed-card-name {
    font-size: 0.68rem;
  }

  .mixed-card-score {
    font-size: 0.72rem;
  }

  .category-subtitle {
    font-size: 1.35rem;
  }

  .tab-btn {
    font-size: 0.95rem;
    padding: 10px 16px;
  }
}

.ranking-avatar-small {
  display: inline-flex;
  align-items: flex-end;
  height: 36px;
  width: 27px;
  overflow: hidden;
  line-height: 0;
  flex-shrink: 0;
}

.ranking-avatar-small svg {
  height: 100%;
  width: auto;
}

.ranking-avatar-big svg {
  height: 100%;
  width: auto;
}

.ranking-name {
  flex: 1;
  font-weight: 500;
}

.ranking-score {
  font-weight: 700;
  color: var(--primary-color);
}

/* ============================================
   퀴즈방
   ============================================ */
.quizroom-container h2 {
  margin-bottom: 24px;
}

.room-list {
  display: grid;
  gap: 16px;
  margin-top: 24px;
}

.room-card {
  background: var(--bg-secondary);
  padding: 20px;
  border-radius: var(--border-radius);
  box-shadow: var(--shadow-md);
  display: flex;
  justify-content: space-between;
  align-items: center;
  transition: all 0.2s ease;
}

.room-card.playing {
  border-left: 4px solid #ef4444;
  background: #fef2f2;
}

.room-card.my-room {
  border-left: 4px solid #6366f1;
  background: #eef2ff;
}

.room-time {
  color: var(--text-secondary);
  font-size: 0.75rem;
  margin-top: 4px;
}

.room-info h3 {
  margin-bottom: 4px;
}

.room-meta {
  color: var(--text-secondary);
  font-size: 0.9rem;
}

.room-actions {
  display: flex;
  align-items: center;
  gap: 12px;
}

.room-status {
  padding: 4px 8px;
  border-radius: 4px;
  font-size: 0.8rem;
  font-weight: 500;
}

.room-status.waiting {
  background: #dcfce7;
  color: #166534;
}

.room-status.playing {
  background: #fef3c7;
  color: #92400e;
}

.room-status.finished {
  background: #f3f4f6;
  color: #6b7280;
}

.empty-state {
  text-align: center;
  padding: 40px;
  color: var(--text-secondary);
}

/* ============================================
   설정
   ============================================ */
.settings-container h2 {
  margin-bottom: 24px;
}

.settings-card {
  background: var(--bg-secondary);
  padding: 24px;
  border-radius: var(--border-radius);
  box-shadow: var(--shadow-md);
  margin-bottom: 16px;
}

.settings-card h3 {
  margin-bottom: 16px;
}

.profile-section {
  display: flex;
  align-items: center;
  gap: 24px;
}

.profile-section .character-preview {
  margin: 0;
}

.cooldown-text {
  margin-top: 8px;
  color: var(--warning-color);
  font-size: 0.9rem;
}

.room-name-notice {
  margin-bottom: 16px;
  color: var(--text-secondary, #6b7280);
  font-size: 0.85rem;
}

.my-info p {
  margin-bottom: 8px;
}

.my-info span {
  font-weight: 700;
  color: var(--primary-color);
}

/* ============================================
   게임 화면
   ============================================ */
.game-container {
  max-width: 800px;
  margin: 0 auto;
}

.game-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 24px;
}

.game-info {
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.game-info span:first-child {
  font-weight: 700;
  font-size: 1.1rem;
}

.game-info span:last-child {
  color: var(--text-secondary);
  font-size: 0.9rem;
}

.game-timer {
  font-size: 2rem;
  font-weight: 700;
  color: var(--primary-color);
  background: var(--bg-secondary);
  padding: 8px 16px;
  border-radius: var(--border-radius);
  box-shadow: var(--shadow-sm);
}

.game-timer.next-countdown {
  font-size: 0.95rem;
  font-weight: 600;
  white-space: nowrap;
}

.game-leave-btn {
  border: 1px solid var(--border-color);
  background: var(--bg-secondary);
  color: var(--text-secondary);
  font-family: inherit;
  font-size: 0.8rem;
  font-weight: 600;
  padding: 6px 10px;
  border-radius: var(--border-radius);
  cursor: pointer;
  white-space: nowrap;
  flex-shrink: 0;
}

.game-leave-btn:hover {
  border-color: var(--text-danger, #ef4444);
  color: var(--text-danger, #ef4444);
}

.game-question {
  background: var(--bg-secondary);
  padding: 32px;
  border-radius: var(--border-radius);
  box-shadow: var(--shadow-md);
  margin-bottom: 24px;
  text-align: center;
}

/* 게임 중 참가자 닉네임/캐릭터/실시간 점수 패널 */
.live-score-panel {
  display: flex;
  gap: 8px;
  overflow-x: auto;
  /* overflow-x:auto를 주면 overflow-y도 auto로 계산되어 잘리므로,
     정답 공개 시 위로 떠오르는 점수 애니메이션이 잘리지 않도록 위쪽 여백을 넉넉히 둔다 */
  padding: 40px 2px 12px;
  margin: -36px -2px 16px;
  scrollbar-width: none; /* Firefox - 스크롤바 숨김 */
  -ms-overflow-style: none; /* 구형 Edge/IE */
}

.live-score-panel::-webkit-scrollbar {
  display: none; /* Chrome/Safari/Edge - 스크롤바 숨김 */
}

.live-score-chip {
  position: relative;
  overflow: visible;
  display: flex;
  align-items: center;
  gap: 6px;
  flex-shrink: 0;
  background: var(--bg-secondary);
  border: 1px solid var(--border-color);
  border-radius: 20px;
  padding: 4px 12px 4px 6px;
  box-shadow: var(--shadow-sm);
}

/* 정답 공개 순간 점수 증감 애니메이션 */
.live-score-chip.score-pulse-up {
  animation: scorePulseUp 0.9s ease;
}

.live-score-chip.score-pulse-down {
  animation: scorePulseDown 0.5s ease;
}

@keyframes scorePulseUp {
  0% { transform: scale(1); box-shadow: var(--shadow-sm); }
  25% { transform: scale(1.3) rotate(-3deg); box-shadow: 0 0 20px 4px rgba(34, 197, 94, 0.7); background: rgba(34, 197, 94, 0.2); border-color: #22c55e; }
  50% { transform: scale(1.15) rotate(2deg); }
  100% { transform: scale(1) rotate(0); box-shadow: var(--shadow-sm); }
}

@keyframes scorePulseDown {
  0% { transform: scale(1) translateX(0); box-shadow: var(--shadow-sm); }
  20% { transform: scale(1.1) translateX(-4px); box-shadow: 0 0 16px 3px rgba(239, 68, 68, 0.7); background: rgba(239, 68, 68, 0.2); border-color: #ef4444; }
  40% { transform: scale(1.1) translateX(4px); }
  60% { transform: scale(1.05) translateX(-2px); }
  80% { transform: scale(1.05) translateX(2px); }
  100% { transform: scale(1) translateX(0); box-shadow: var(--shadow-sm); }
}

.score-float {
  position: absolute;
  top: -4px;
  left: 50%;
  font-weight: 800;
  font-size: 1.05rem;
  pointer-events: none;
  white-space: nowrap;
  text-shadow: 0 1px 4px rgba(0, 0, 0, 0.35);
  animation: scoreFloat 1.2s ease-out forwards;
  z-index: 20;
}

.score-float.positive { color: #22c55e; }
.score-float.negative { color: #ef4444; }

@keyframes scoreFloat {
  0% { transform: translate(-50%, 0) scale(0.7); opacity: 0; }
  15% { transform: translate(-50%, -10px) scale(1.4); opacity: 1; }
  100% { transform: translate(-50%, -46px) scale(1.1); opacity: 0; }
}

.live-score-chip.is-me {
  border-color: var(--primary-color);
  background: rgba(99, 102, 241, 0.08);
}

.live-score-rank {
  font-size: 0.7rem;
  font-weight: 700;
  color: var(--text-secondary);
  min-width: 14px;
}

.live-score-avatar {
  display: inline-flex;
  align-items: flex-end;
  height: 32px;
  width: 24px;
  overflow: hidden;
  line-height: 0;
}

.live-score-avatar svg {
  height: 100%;
  width: auto;
}

.live-score-name {
  font-size: 0.8rem;
  font-weight: 600;
  white-space: nowrap;
}

.live-score-value {
  font-size: 0.8rem;
  font-weight: 700;
  color: var(--primary-color);
  white-space: nowrap;
}

.question-meta {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 8px;
}

.question-number {
  color: var(--text-secondary);
  font-size: 0.9rem;
}

/* 문제 유형 배지 - 좌측 상단, 종목별 색상 */
.category-badge {
  font-size: 0.78rem;
  font-weight: 600;
  padding: 4px 10px;
  border-radius: 999px;
  color: #fff;
  background: var(--primary-color);
  line-height: 1.2;
}
.category-badge.cat-general { background: #6366f1; }
.category-badge.cat-science { background: #0ea5e9; }
.category-badge.cat-history { background: #b45309; }
.category-badge.cat-sports { background: #16a34a; }
.category-badge.cat-entertainment { background: #db2777; }
.category-badge.cat-geography { background: #2563eb; }
.category-badge.cat-terms { background: #7c3aed; }

.game-options {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 12px;
  margin-bottom: 24px;
}

.option-btn {
  background: var(--bg-secondary);
  border: 2px solid var(--border-color);
  padding: 20px;
  border-radius: var(--border-radius);
  cursor: pointer;
  transition: var(--transition);
  display: flex;
  align-items: center;
  gap: 12px;
  font-family: inherit;
  font-size: 1rem;
  text-align: left;
}

.option-btn:hover {
  border-color: var(--primary-color);
  background: rgba(99, 102, 241, 0.05);
}

.option-btn.selected {
  border-color: var(--primary-color);
  background: var(--primary-color);
  color: var(--text-light);
}

.option-number {
  width: 32px;
  height: 32px;
  background: var(--primary-color);
  color: var(--text-light);
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  font-weight: 700;
  flex-shrink: 0;
}

.option-btn.selected .option-number {
  background: var(--text-light);
  color: var(--primary-color);
}

.vote-status {
  background: var(--bg-secondary);
  padding: 16px;
  border-radius: var(--border-radius);
  box-shadow: var(--shadow-sm);
}

.vote-counts {
  display: flex;
  justify-content: center;
  gap: 16px;
  flex-wrap: wrap;
}

/* ============================================
   대기실
   ============================================ */
.waiting-room {
  text-align: center;
}

.waiting-room h2 {
  margin-bottom: 8px;
}

.room-info-text {
  color: var(--text-secondary);
  margin-bottom: 24px;
}

.player-list {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  justify-content: center;
  margin-bottom: 24px;
}

.player-item {
  position: relative;
  overflow: hidden;
  isolation: isolate;
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 8px 52px 8px 12px; /* 오른쪽에 캐릭터 전용 여백 확보(아바타 실측 너비 ~38px + 여유) → 닉네임과 겹치지 않음 */
  background: var(--bg-secondary);
  border-radius: var(--border-radius);
  box-shadow: var(--shadow-sm);
}

.player-item.creator {
  background: #fef3c7;
  border: 1px solid #fbbf24;
}

.player-number {
  width: 24px;
  height: 24px;
  background: var(--primary-color);
  color: var(--text-light);
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 0.8rem;
  font-weight: 700;
}

.player-name {
  font-weight: 500;
}

/* 캐릭터 아바타는 항상 같은 칸 안의 다른 내용보다 뒤(맨 아래 레이어)에 깔린다.
   부모에 position:relative를 주고 아바타는 음수 z-index로 절대배치하면,
   z-index:0인 일반 흐름 콘텐츠보다 먼저 그려져 자연스럽게 배경처럼 깔린다. */
.player-avatar,
.ranking-avatar,
.tile-avatar {
  position: absolute;
  z-index: -1;
  pointer-events: none;
  line-height: 0;
}

.player-avatar,
.ranking-avatar {
  top: 0;
  right: 8px;
  height: 100%;
  display: flex;
  align-items: flex-end;
  opacity: 0.35;
}

/* 방 안 참가자 목록은 캐릭터 전용 여백이 확보되어 있어(.player-item padding) 또렷하게 보여도 됨 */
.player-avatar {
  opacity: 1;
}

.player-avatar svg,
.ranking-avatar svg {
  height: 100%;
  width: auto;
  aspect-ratio: 200 / 220; /* Character.renderSVG의 실제 viewBox 비율 (width/height 속성값 비율이 아님) */
}

/* 점수판 카드는 오른쪽 여백이 넓어서, 캐릭터가 그 공간을 꽉 채우도록 크게 배치 */
.tile-avatar {
  top: -8px;
  right: -8px;
  bottom: -8px;
  display: flex;
  align-items: flex-end;
  justify-content: flex-end;
  opacity: 0.9;
}

.tile-avatar svg {
  height: 130%;
  width: auto;
  aspect-ratio: 200 / 220;
}

.waiting-actions {
  display: flex;
  flex-direction: column;
  gap: 12px;
  align-items: center;
}

.waiting-message {
  color: var(--text-secondary);
}

.ready-status-text {
  margin-top: 8px;
  color: var(--warning-color);
  font-size: 0.9rem;
}

.host-timeout-card {
  display: flex;
  align-items: center;
  gap: 14px;
  margin-top: 4px;
  padding: 12px 18px;
  background: linear-gradient(135deg, #FFF8E7 0%, #FFECC7 100%);
  border: 1px solid #FFD98A;
  border-radius: 14px;
  box-shadow: var(--shadow-sm);
  width: 100%;
  max-width: 320px;
  transition: background 0.3s ease, border-color 0.3s ease;
}

.host-timeout-card.paused {
  background: var(--bg-secondary);
  border: 1px dashed var(--border-color);
}

.hourglass-icon.paused {
  animation: none;
  opacity: 0.5;
}

.paused-text {
  color: var(--text-secondary) !important;
  font-size: 0.95rem !important;
}

.host-timeout-card.danger {
  background: linear-gradient(135deg, #FFEBEE 0%, #FFCDD2 100%);
  border-color: #EF9A9A;
}

.hourglass-icon {
  font-size: 1.8rem;
  line-height: 1;
  animation: hourglass-flip 2.4s ease-in-out infinite;
}

@keyframes hourglass-flip {
  0%, 40% { transform: rotate(0deg); }
  55%, 95% { transform: rotate(180deg); }
  100% { transform: rotate(360deg); }
}

.host-timeout-info {
  flex: 1;
  text-align: left;
}

.host-timeout-label {
  font-size: 0.75rem;
  color: var(--text-secondary);
  margin-bottom: 2px;
}

.host-timeout-value {
  font-size: 1.1rem;
  font-weight: 700;
  color: #E65100;
  margin-bottom: 6px;
}

.host-timeout-card.danger .host-timeout-value {
  color: #C62828;
}

.host-timeout-bar {
  width: 100%;
  height: 6px;
  background: rgba(0, 0, 0, 0.08);
  border-radius: 3px;
  overflow: hidden;
}

.host-timeout-bar-fill {
  height: 100%;
  width: 100%;
  background: linear-gradient(90deg, #FFB74D, #FF7043);
  border-radius: 3px;
  transition: width 1s linear, background 0.3s ease;
}

.host-timeout-card.danger .host-timeout-bar-fill {
  background: linear-gradient(90deg, #EF5350, #C62828);
}

/* ============================================
   카운트다운
   ============================================ */
.countdown {
  text-align: center;
  padding: 60px 20px;
}

.countdown h2 {
  margin-bottom: 24px;
}

.countdown-number {
  font-size: 6rem;
  font-weight: 700;
  color: var(--primary-color);
  animation: pulse 1s ease-in-out infinite;
}

@keyframes pulse {
  0%, 100% { transform: scale(1); }
  50% { transform: scale(1.1); }
}

/* ============================================
   게임 결과
   ============================================ */
.game-result {
  text-align: center;
}

.game-result h2 {
  margin-bottom: 24px;
}

.result-list {
  display: flex;
  flex-direction: column;
  gap: 12px;
  margin-bottom: 32px;
}

.result-item {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 16px;
  background: var(--bg-secondary);
  border-radius: var(--border-radius);
  box-shadow: var(--shadow-sm);
}

.result-item.rank-1 {
  background: linear-gradient(135deg, #fef3c7 0%, #fde68a 100%);
  border: 2px solid #fbbf24;
}

.result-item.rank-2 {
  background: linear-gradient(135deg, #e0f2fe 0%, #bae6fd 100%);
  border: 2px solid #7dd3fc;
}

.result-item.rank-3 {
  background: linear-gradient(135deg, #d1fae5 0%, #a7f3d0 100%);
  border: 2px solid #6ee7b7;
}

.result-medal {
  font-size: 1.5rem;
  width: 40px;
}

.result-avatar {
  display: inline-flex;
  align-items: flex-end;
  height: 48px;
  width: 36px;
  overflow: hidden;
  line-height: 0;
  flex-shrink: 0;
}

.result-avatar svg {
  height: 100%;
  width: auto;
}

.result-name {
  flex: 1;
  font-weight: 700;
  text-align: left;
}

.result-score {
  font-weight: 700;
  color: var(--primary-color);
}

.result-accuracy {
  color: var(--text-secondary);
  font-size: 0.9rem;
}

.result-actions {
  margin-top: 24px;
}

.result-auto-return {
  margin-top: 10px;
  color: var(--text-secondary);
  font-size: 0.85rem;
}

/* ============================================
   문제 결과 - 팝업 대신 선택지 테두리 자체가 화려하게 반응한다
   ============================================ */
.game-container { position: relative; }

.option-btn { position: relative; overflow: visible; }

.option-votes {
  margin-left: auto;
  font-size: 0.78rem;
  font-weight: 700;
  color: var(--text-secondary);
  background: var(--bg-primary);
  border-radius: 999px;
  padding: 3px 10px;
  flex-shrink: 0;
  opacity: 0;
  transform: translateX(4px);
  transition: opacity 0.35s ease 0.55s, transform 0.35s ease 0.55s;
}
.game-options.revealed .option-votes { opacity: 1; transform: translateX(0); }
.game-options.revealed .option-btn:not(.correct) { opacity: 0.55; }

.option-btn.correct { border-color: #fbbf24; z-index: 1; }
.option-btn.correct .option-number { background: #fbbf24; color: #4a2c02; }
.option-btn.correct .option-votes { color: #d97706; background: hsl(38 92% 95%); }

.option-btn.correct.charging { animation: chargeSquash 700ms cubic-bezier(.4, 0, .7, 1) forwards; }
.option-btn.correct.charging::before {
  content: ''; position: absolute; inset: -2px; border-radius: 13px;
  border: 2px solid hsl(38 92% 60%); opacity: 0;
  animation: chargeRing 700ms ease-in forwards;
}
.option-btn.correct.charging::after {
  content: ''; position: absolute; inset: -16px; border-radius: 22px;
  background: radial-gradient(circle, hsl(38 92% 60% / 0.65) 0%, transparent 72%);
  opacity: 0; animation: chargeGlow 700ms ease-in forwards;
  pointer-events: none; z-index: -1;
}
@keyframes chargeSquash { 0% { transform: scale(1); } 100% { transform: scale(0.95); } }
@keyframes chargeRing { 0% { opacity: 0; box-shadow: 0 0 0 hsl(38 92% 60% / 0); } 100% { opacity: 1; box-shadow: 0 0 22px 2px hsl(38 92% 60% / 0.9); } }
@keyframes chargeGlow { 0% { opacity: 0; transform: scale(0.6); } 100% { opacity: 1; transform: scale(1); } }

.game-options.revealed .option-btn.correct { animation: correctPulse 2200ms cubic-bezier(.34, 1.56, .64, 1); }
.game-options.revealed .option-btn.correct::before {
  content: ''; position: absolute; inset: -3px; border-radius: 14px; padding: 3px;
  background: conic-gradient(from var(--ang, 0deg), #fbbf24, #f472b6, #818cf8, #34d399, #fbbf24);
  -webkit-mask: linear-gradient(#000 0 0) content-box, linear-gradient(#000 0 0);
  -webkit-mask-composite: xor; mask-composite: exclude;
  filter: drop-shadow(0 0 6px hsl(38 92% 55% / 0.7));
}
.game-options.revealed .option-btn.correct::after {
  content: ''; position: absolute; inset: -14px; border-radius: 22px;
  background: radial-gradient(circle, hsl(38 92% 60% / 0.5) 0%, transparent 70%);
  animation: glowPulse 2.6s ease-out infinite;
  pointer-events: none; z-index: -1;
}
@keyframes spin { to { --ang: 360deg; } }
@property --ang { syntax: '<angle>'; inherits: false; initial-value: 0deg; }
@keyframes correctPulse {
  0% { transform: scale(0.95); }
  35% { transform: scale(1.1); box-shadow: 0 10px 32px hsl(38 92% 50% / 0.5); }
  65% { transform: scale(0.98); }
  100% { transform: scale(1); box-shadow: 0 4px 16px hsl(38 92% 50% / 0.25); }
}
@keyframes glowPulse { 0%, 100% { opacity: 0.35; transform: scale(0.94); } 50% { opacity: 0.75; transform: scale(1.04); } }

.option-btn.correct .option-text {
  background: linear-gradient(100deg, var(--text-primary) 30%, #fff9c4 45%, #d97706 50%, var(--text-primary) 65%);
  background-size: 250% 100%;
  -webkit-background-clip: text; background-clip: text; color: transparent;
}
.game-options.revealed .option-btn.correct .option-text { animation: shimmerText 3s ease-out 1; }
@keyframes shimmerText { 0% { background-position: 200% 0; } 100% { background-position: -50% 0; } }

.ribbon {
  position: absolute; top: -8px; left: 6px;
  background: linear-gradient(135deg, #f59e0b, #f472b6); color: #fff;
  font-size: 10px; font-weight: 700; padding: 2px 8px; border-radius: 999px;
  box-shadow: 0 3px 10px hsl(330 80% 55% / 0.4);
  opacity: 0; transform: translateY(3px) scale(0.7); z-index: 2;
}
.game-options.revealed .option-btn.correct .ribbon { animation: ribbonPop 700ms cubic-bezier(.34, 1.56, .64, 1) 700ms forwards; }
@keyframes ribbonPop {
  0% { opacity: 0; transform: translateY(4px) scale(0.6); }
  60% { opacity: 1; transform: translateY(-2px) scale(1.12); }
  100% { opacity: 1; transform: translateY(0) scale(1); }
}

.option-btn.wrong-picked { border-color: var(--danger-color, #ef4444); }
.option-btn.wrong-picked .option-number { background: var(--danger-color, #ef4444); color: #fff; }
.game-options.revealed .option-btn.wrong-picked { animation: shake 600ms ease; }
@keyframes shake {
  20% { transform: translateX(-4px); } 40% { transform: translateX(3px); }
  60% { transform: translateX(-2px); } 80% { transform: translateX(1px); }
}

.confetti-piece, .emoji-piece, .petal-piece {
  position: absolute; top: 50%; left: 50%;
  pointer-events: none; z-index: 5;
}
.confetti-piece { width: 6px; height: 6px; }
.emoji-piece { font-size: 88px; line-height: 1; }
.petal-piece { top: -18px; left: 0; font-size: 15px; line-height: 1; z-index: 4; }

.crowd-pop {
  position: fixed;
  font-size: 88px; line-height: 1; opacity: 0; pointer-events: none; z-index: 99999;
}
.qmark-pop {
  position: fixed;
  font-size: 34px; font-weight: 800; color: #f97316;
  text-shadow: 0 2px 6px hsl(24 90% 40% / 0.35);
  opacity: 0; pointer-events: none; z-index: 99999;
}

@media (max-width: 480px) {
  .emoji-piece, .crowd-pop { font-size: 64px; }
  .qmark-pop { font-size: 26px; }
}

/* ============================================
   모달
   ============================================ */
.modal {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  background: rgba(0, 0, 0, 0.5);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 2000;
}

.modal.hidden {
  display: none;
}

.modal-content {
  background: var(--bg-secondary);
  padding: 32px;
  border-radius: var(--border-radius);
  box-shadow: var(--shadow-lg);
  max-width: 500px;
  width: 90%;
  max-height: 90vh;
  overflow-y: auto;
}

/* 모바일에서 모달이 화면 중앙 정렬되면 상단부가 고정 네비게이션 바(z-index 5000)
   뒤로 가려지는 문제가 있어, 모달을 네비바 아래에서 시작하도록 함 */
@media (max-width: 480px) {
  .modal {
    align-items: flex-start;
    padding-top: 70px;
  }

  .modal-content {
    max-height: calc(100vh - 90px);
    /* dvh 지원 브라우저는 주소창/툴바 상태에 따라 실제 보이는 높이로 다시 계산 */
    max-height: calc(100dvh - 90px);
    padding-bottom: calc(32px + env(safe-area-inset-bottom, 0px));
  }
}

.modal-actions {
  display: flex;
  gap: 12px;
  justify-content: flex-end;
  margin-top: 16px;
  padding-top: 12px;
  border-top: 1px solid var(--border-color);
  flex-shrink: 0;
}

/* ============================================
   캐릭터 커스터마이징
   ============================================ */
.character-modal-content {
  max-width: 500px;
  display: flex;
  flex-direction: column;
  max-height: 85vh;
}

.char-fixed-top {
  flex-shrink: 0;
}

.char-scroll-area {
  flex: 1;
  overflow-y: auto;
  min-height: 100px;
  padding-right: 4px;
}

.char-scroll-area::-webkit-scrollbar {
  width: 4px;
}

.char-scroll-area::-webkit-scrollbar-thumb {
  background: var(--border-color);
  border-radius: 2px;
}

.character-preview-large {
  width: 160px;
  height: 200px;
  margin: 0 auto 8px;
  display: flex;
  align-items: center;
  justify-content: center;
}

/* 후원자 전용 아이템 - 왕관 반짝임 + 아우라 은은한 펄스 (캐릭터가 그려지는 모든 곳에 공통 적용) */
.crown {
  animation: crownGlow 2s ease-in-out infinite;
}

@keyframes crownGlow {
  0%, 100% { filter: drop-shadow(0 0 2px rgba(255, 215, 0, 0.5)); }
  50% { filter: drop-shadow(0 0 9px rgba(255, 215, 0, 1)); }
}

.crown-sparkle {
  fill: #fff8d6;
  opacity: 0;
  animation: crownTwinkle 1.8s ease-in-out infinite;
  pointer-events: none;
}

@keyframes crownTwinkle {
  0%, 100% { opacity: 0; }
  50% { opacity: 1; }
}

.aura {
  animation: auraPulse 2.4s ease-in-out infinite;
}

@keyframes auraPulse {
  0%, 100% { opacity: 0.7; }
  50% { opacity: 1; }
}

.character-tabs {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-bottom: 16px;
  justify-content: center;
}

.char-tab {
  padding: 5px 10px;
  background: var(--bg-primary);
  border: none;
  border-radius: 6px;
  cursor: pointer;
  transition: var(--transition);
  font-family: inherit;
  font-size: 0.8rem;
}

.char-tab:hover {
  background: var(--border-color);
}

.char-tab.active {
  background: var(--primary-color);
  color: var(--text-light);
}

.char-tab-premium {
  background: linear-gradient(135deg, #FFF3D0 0%, #FFE0A3 100%);
  border: 1px solid #FFD98A;
}

.char-tab-premium.active {
  background: linear-gradient(135deg, #FFB300 0%, #FF8F00 100%);
  color: var(--text-light);
  border-color: transparent;
}

.sponsor-locked {
  width: 100%;
  text-align: center;
  padding: 24px 16px;
  background: linear-gradient(135deg, #FFF8E7 0%, #FFECC7 100%);
  border: 1px dashed #FFD98A;
  border-radius: 12px;
}

.sponsor-locked-icon {
  font-size: 2rem;
  margin-bottom: 8px;
}

.sponsor-locked-title {
  font-weight: 700;
  color: #E65100;
  margin-bottom: 6px;
}

.sponsor-locked-desc {
  font-size: 0.85rem;
  color: var(--text-secondary);
}

.character-options {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  margin-bottom: 12px;
}

.char-option {
  border: 2px solid var(--border-color);
  border-radius: 6px;
  cursor: pointer;
  transition: var(--transition);
  overflow: hidden;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: 4px;
  background: var(--bg-secondary);
  min-width: 65px;
  max-width: 65px;
  flex-shrink: 0;
  scroll-snap-align: start;
}

.char-option:hover {
  border-color: var(--primary-color);
}

.char-option.selected {
  border-color: var(--primary-color);
  box-shadow: 0 0 0 2px var(--primary-color);
  background: rgba(99, 102, 241, 0.05);
}

.char-option-preview {
  flex: 1;
  display: flex;
  align-items: center;
  justify-content: center;
}

.char-option-name {
  font-size: 0.65rem;
  text-align: center;
  margin-top: 2px;
  line-height: 1.2;
}

.option-section {
  margin-bottom: 12px;
  padding-top: 8px;
}

.option-section:first-child {
  padding-top: 0;
}

.option-section + .option-section {
  border-top: 2px solid var(--border-color);
}

.option-section-title {
  font-size: 0.8rem;
  font-weight: 600;
  color: var(--primary-color);
  margin-bottom: 6px;
  display: flex;
  align-items: center;
  gap: 6px;
}

.option-section-title::before {
  content: '';
  width: 3px;
  height: 14px;
  background: var(--primary-color);
  border-radius: 2px;
}

.option-grid {
  display: flex;
  gap: 6px;
  overflow-x: auto;
  padding-bottom: 4px;
  scroll-snap-type: x mandatory;
}

.option-grid::-webkit-scrollbar {
  height: 3px;
}

.option-grid::-webkit-scrollbar-thumb {
  background: var(--border-color);
  border-radius: 2px;
}

.color-picker {
  margin-bottom: 16px;
}

.color-picker label {
  display: block;
  margin-bottom: 8px;
  font-weight: 500;
  color: var(--text-secondary);
}

.color-options {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

.color-option {
  width: 32px;
  height: 32px;
  border-radius: 50%;
  border: 2px solid var(--border-color);
  cursor: pointer;
  transition: var(--transition);
}

.color-option:hover {
  transform: scale(1.1);
}

.color-option.selected {
  border-color: var(--text-primary);
  box-shadow: 0 0 0 2px var(--text-primary);
}

/* ============================================
   랜덤 캐릭터 버튼
   ============================================ */
.character-random-btn {
  text-align: center;
  margin-bottom: 10px;
}

.btn-random {
  background: linear-gradient(135deg, #f093fb 0%, #f5576c 100%);
  color: white;
  border: none;
  padding: 6px 18px;
  border-radius: var(--border-radius);
  font-size: 0.85rem;
  font-weight: 600;
  cursor: pointer;
  transition: var(--transition);
  font-family: inherit;
}

.btn-random:hover {
  transform: translateY(-2px);
  box-shadow: 0 4px 12px rgba(245, 87, 108, 0.4);
}

.btn-random:active {
  transform: translateY(0);
}

/* ============================================
   개인 랭킹
   ============================================ */
.mine-card {
  background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
  color: var(--text-light);
  border-radius: var(--border-radius);
  box-shadow: var(--shadow-md);
  padding: 24px 20px 20px;
  margin-bottom: 32px;
}

.mine-top {
  display: flex;
  align-items: center;
  gap: 14px;
  margin-bottom: 20px;
}

.mine-avatar {
  display: inline-flex;
  align-items: flex-end;
  justify-content: center;
  height: 64px;
  width: 48px;
  overflow: hidden;
  line-height: 0;
  background: rgba(255, 255, 255, 0.18);
  border-radius: 10px;
  flex-shrink: 0;
}

.mine-avatar svg {
  height: 100%;
  width: auto;
}

.mine-name {
  font-size: 1.2rem;
  font-weight: 700;
}

.mine-stats {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 10px;
  margin-bottom: 18px;
}

.mine-stat {
  text-align: center;
  background: rgba(255, 255, 255, 0.16);
  border-radius: 12px;
  padding: 12px 6px;
}

.mine-stat .v {
  font-size: 1.3rem;
  font-weight: 800;
  font-variant-numeric: tabular-nums;
}

.mine-stat .l {
  font-size: 0.78rem;
  opacity: 0.9;
  margin-top: 2px;
}

.mine-share-btn {
  width: 100%;
  padding: 12px;
  border: none;
  border-radius: var(--border-radius);
  background: rgba(255, 255, 255, 0.95);
  color: var(--primary-color);
  font-family: inherit;
  font-weight: 700;
  font-size: 0.95rem;
  cursor: pointer;
  transition: var(--transition);
}

.mine-share-btn:hover {
  background: #fff;
  transform: translateY(-1px);
}

.category-best,
.recent-games {
  margin-bottom: 32px;
}

.category-best h4,
.recent-games h4 {
  margin-bottom: 12px;
}

.category-list {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.category-item {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
  padding: 12px 16px;
  background: var(--bg-secondary);
  border-radius: var(--border-radius);
  box-shadow: var(--shadow-sm);
}

.category-name {
  font-size: 1.2rem;
  font-weight: 800;
  letter-spacing: 0.01em;
  background: linear-gradient(135deg, #667eea 0%, #764ba2 60%, #f0729d 100%);
  -webkit-background-clip: text;
  background-clip: text;
  color: transparent;
}

.category-score {
  font-weight: 700;
  color: var(--primary-color);
  font-size: 1rem;
  text-align: right;
  font-variant-numeric: tabular-nums;
}

.game-list {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.game-item {
  display: grid;
  grid-template-columns: minmax(64px, 1fr) 64px 52px 96px;
  align-items: center;
  gap: 8px;
  padding: 12px 16px;
  background: var(--bg-secondary);
  border-radius: var(--border-radius);
  box-shadow: var(--shadow-sm);
}

.game-category {
  font-weight: 500;
}

.game-score {
  font-weight: 700;
  color: var(--primary-color);
  text-align: right;
}

.game-accuracy {
  color: var(--secondary-color);
  text-align: right;
}

.game-date {
  color: var(--text-secondary);
  font-size: 0.85rem;
  text-align: right;
  white-space: nowrap;
}

.empty-text {
  color: var(--text-secondary);
  text-align: center;
  padding: 20px;
}

/* ============================================
   로딩 스피너
   ============================================ */
#loading-spinner {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  background: rgba(255, 255, 255, 0.9);
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  z-index: 3000;
}

#loading-spinner.hidden {
  display: none;
}

.spinner {
  width: 48px;
  height: 48px;
  border: 4px solid var(--border-color);
  border-top-color: var(--primary-color);
  border-radius: 50%;
  animation: spin 1s linear infinite;
}

@keyframes spin {
  to { transform: rotate(360deg); }
}

#loading-spinner p {
  margin-top: 16px;
  color: var(--text-secondary);
}

/* ============================================
   토스트 메시지
   ============================================ */
#toast-container {
  position: fixed;
  bottom: 20px;
  right: 20px;
  z-index: 4000;
}

.toast {
  background: var(--bg-dark);
  color: var(--text-light);
  padding: 12px 20px;
  border-radius: 8px;
  margin-top: 8px;
  box-shadow: var(--shadow-lg);
  animation: slideIn 0.3s ease;
  max-width: 300px;
}

.toast.success {
  background: var(--secondary-color);
}

.toast.error {
  background: var(--danger-color);
}

.toast.warning {
  background: var(--warning-color);
}

@keyframes slideIn {
  from {
    transform: translateX(100%);
    opacity: 0;
  }
  to {
    transform: translateX(0);
    opacity: 1;
  }
}

@keyframes slideOut {
  from {
    transform: translateX(0);
    opacity: 1;
  }
  to {
    transform: translateX(100%);
    opacity: 0;
  }
}

/* ============================================
   반응형
   ============================================ */
@media (max-width: 768px) {
  .nav-container {
    padding: 0 16px;
  }
  
  .nav-menu {
    position: fixed;
    top: 60px;
    left: 0;
    right: 0;
    background: var(--bg-secondary);
    flex-direction: column;
    padding: 16px;
    box-shadow: var(--shadow-md);
    display: none;
  }
  
  .nav-menu.active {
    display: flex;
  }
  
  .nav-toggle {
    display: flex;
  }
  
  .nav-user {
    display: none;
  }

  .nav-logout-item {
    display: block;
    margin-top: 8px;
    padding-top: 8px;
    border-top: 1px solid var(--border-color);
  }

  .nav-logout-item .nav-link {
    color: var(--danger-color);
  }

  .game-options {
    grid-template-columns: 1fr;
  }
  
  .stats-grid {
    grid-template-columns: 1fr;
    gap: 12px;
  }

  .room-card {
    flex-direction: column;
    gap: 12px;
    text-align: center;
  }
  
  .room-actions {
    width: 100%;
    justify-content: center;
  }
  
  .profile-section {
    flex-direction: column;
    text-align: center;
  }
  
  .result-item {
    flex-wrap: wrap;
  }
}

/* ============================================
   유틸리티
   ============================================ */
.hidden {
  display: none !important;
}

.text-center {
  text-align: center;
}

.mt-16 {
  margin-top: 16px;
}

.mb-16 {
  margin-bottom: 16px;
}

/* ============================================
   고유 ID & 닉네임 변경 1회 제한
   ============================================ */
.user-id-section {
  margin-top: 16px;
  padding: 12px 16px;
  background: rgba(99, 102, 241, 0.05);
  border-radius: var(--border-radius);
  border: 1px solid rgba(99, 102, 241, 0.1);
}

.user-id-label {
  font-size: 0.85rem;
  color: var(--text-secondary);
  margin-bottom: 4px;
}

.user-id-value {
  font-size: 1.1rem;
  font-weight: 700;
  color: var(--primary-color);
  font-family: 'Courier New', monospace;
  letter-spacing: 1px;
}

.nickname-notice-text {
  font-size: 0.8rem;
  color: var(--text-secondary);
  margin-bottom: 8px;
  font-style: italic;
}

.current-nickname-display {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 10px 14px;
  background: rgba(99, 102, 241, 0.05);
  border-radius: var(--border-radius);
  margin-bottom: 12px;
}

.current-nickname-display .label {
  font-size: 0.9rem;
  color: var(--text-secondary);
}

.current-nickname-display .value {
  font-size: 1rem;
  font-weight: 700;
  color: var(--primary-color);
}

.nickname-hint {
  font-size: 0.75rem;
  color: var(--text-secondary);
  margin-top: 4px;
  margin-bottom: 0;
}

.nickname-notice {
  margin-top: 8px;
  padding: 8px 12px;
  background: rgba(239, 68, 68, 0.1);
  border-radius: var(--border-radius);
  color: #ef4444;
  font-size: 0.85rem;
  text-align: center;
}

.btn-primary.disabled {
  background: #9ca3af;
  cursor: not-allowed;
  opacity: 0.7;
}

/* ============================================
   후원하기 페이지
   ============================================ */
.donate-container {
  max-width: 500px;
  margin: 0 auto;
  padding: 20px;
}

.donate-container h2 {
  text-align: center;
  margin-bottom: 24px;
  color: var(--text-primary);
}

.donate-card {
  background: white;
  border-radius: 16px;
  padding: 32px 24px;
  box-shadow: 0 4px 20px rgba(0, 0, 0, 0.08);
  text-align: center;
}

.donate-message {
  margin-bottom: 24px;
}

.donate-title {
  font-size: 1.3rem;
  font-weight: 700;
  color: var(--text-primary);
  margin-bottom: 8px;
}

.donate-subtitle {
  font-size: 0.95rem;
  color: var(--text-secondary);
}

.donate-qr-section {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 20px;
  margin-bottom: 24px;
}

.donate-qr-card {
  background: white;
  border-radius: 12px;
  padding: 16px;
  box-shadow: 0 2px 12px rgba(0, 0, 0, 0.1);
  display: inline-block;
}

.donate-qr-image {
  width: 280px;
  height: auto;
  border-radius: 8px;
  display: block;
}

.donate-hero-image {
  width: 100%;
  max-width: 420px;
  height: auto;
  border-radius: 16px;
  display: block;
  margin: 0 auto 20px;
  box-shadow: 0 6px 20px rgba(0, 0, 0, 0.15);
}

.donate-qr-info {
  text-align: center;
}

.donate-method {
  font-size: 1.1rem;
  font-weight: 700;
  color: #3C1E1E;
  margin-bottom: 4px;
}

.donate-amount {
  font-size: 1.8rem;
  font-weight: 800;
  color: var(--primary-color);
  margin-bottom: 4px;
}

.donate-name {
  font-size: 1rem;
  color: var(--text-secondary);
  margin-bottom: 8px;
}

.donate-link-section {
  margin: 20px 0;
}

.donate-link-btn {
  display: inline-block;
  padding: 14px 32px;
  background: linear-gradient(135deg, #FEE500 0%, #FFC107 100%);
  color: #3C1E1E;
  text-decoration: none;
  border-radius: 12px;
  font-size: 1.1rem;
  font-weight: 700;
  box-shadow: 0 4px 15px rgba(254, 229, 0, 0.4);
  transition: all 0.3s ease;
}

.donate-link-btn:hover {
  transform: translateY(-2px);
  box-shadow: 0 6px 20px rgba(254, 229, 0, 0.5);
}

.donate-link-btn:active {
  transform: translateY(0);
}

.donate-item-notice {
  margin: 20px 0;
  padding: 16px;
  background: #FFF9DB;
  border: 1px solid #FEE500;
  border-radius: 12px;
}

.donate-item-notice p {
  margin-bottom: 12px;
  color: var(--text-primary);
  font-weight: 500;
}

.donate-kakao-btn {
  display: inline-block;
  padding: 10px 20px;
  background: #FEE500;
  color: #3C1E1E;
  text-decoration: none;
  border-radius: 10px;
  font-weight: 700;
  transition: var(--transition);
}

.donate-kakao-btn:hover {
  transform: translateY(-2px);
}

.donate-thanks {
  margin-top: 20px;
  padding-top: 20px;
  border-top: 1px solid #eee;
}

.donate-thanks p {
  font-size: 1.2rem;
  color: var(--text-primary);
  font-weight: 600;
}

.donate-footer {
  margin-top: 20px;
  text-align: center;
}

.donate-footer p {
  font-size: 0.85rem;
  color: var(--text-secondary);
}

/* ============================================
   문제 표시 (모든 종목 공통 - 타이프 효과)
   ============================================ */
.question-display {
  text-align: center;
  margin-bottom: 20px;
}

.question-hint {
  font-size: 1rem;
  color: var(--text-secondary);
  margin-bottom: 12px;
}

.question-box {
  display: block;
  width: 100%;
  max-width: 480px;
  margin: 0 auto;
  padding: 20px 24px;
  /* 타이프 효과로 글자가 점점 늘어나도 정답 선택지가 아래로 밀리지 않도록,
     처음부터 3줄 분량(line-height 1.6 기준)의 세로 공간을 항상 확보해 둔다 */
  min-height: calc(1.6em * 3);
  box-sizing: border-box;
  background: linear-gradient(135deg, var(--primary-color) 0%, #6366f1 100%);
  color: white;
  font-size: 1.15rem;
  font-weight: 600;
  line-height: 1.6;
  text-align: left;
  border-radius: 12px;
  box-shadow: 0 4px 15px rgba(99, 102, 241, 0.3);
  word-break: keep-all;
}

.question-cursor {
  display: inline-block;
  margin-left: 2px;
  animation: questionCursorBlink 0.8s step-end infinite;
}

@keyframes questionCursorBlink {
  0%, 100% { opacity: 1; }
  50% { opacity: 0; }
}

.game-options.terms-options {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 10px;
}

@media (max-width: 480px) {
  .game-options.terms-options {
    grid-template-columns: 1fr;
  }

  .question-box {
    font-size: 0.95rem;
    padding: 12px 14px;
    min-height: calc(1.5em * 2); /* 화면에 다 보이도록 3줄→2줄 분량만 확보 */
  }

  /* ===== 모바일 게임 화면 - 스크롤 없이 한 화면에 들어오도록 여백/크기 압축 ===== */
  .game-header {
    margin-bottom: 8px;
  }

  .game-info span:first-child {
    font-size: 1rem;
  }

  .game-info span:last-child {
    font-size: 0.78rem;
  }

  .game-timer {
    font-size: 1.3rem;
    padding: 6px 12px;
  }

  .game-leave-btn {
    font-size: 0.7rem;
    padding: 4px 8px;
  }

  .live-score-panel {
    padding: 36px 2px 8px;
    margin: -32px -2px 8px;
  }

  .live-score-chip {
    padding: 3px 10px 3px 5px;
  }

  .live-score-avatar {
    height: 26px;
    width: 20px;
  }

  .live-score-name,
  .live-score-value {
    font-size: 0.72rem;
  }

  .game-question {
    padding: 12px 14px;
    margin-bottom: 8px;
  }

  .question-meta {
    margin-bottom: 2px;
  }

  .question-hint {
    font-size: 0.85rem;
    margin-bottom: 6px;
  }

  .game-options {
    gap: 6px;
    margin-bottom: 8px;
  }

  .option-btn {
    padding: 10px 12px;
    gap: 8px;
    font-size: 0.92rem;
  }
}

@media (max-width: 480px) {
  .donate-qr-image {
    width: 220px;
  }

  .donate-hero-image {
    max-width: 280px;
  }

  .donate-amount {
    font-size: 1.5rem;
  }
}

/* ============================================
   관리자 페이지 (문제 관리)
   ============================================ */
.admin-container {
  max-width: 700px;
  margin: 0 auto;
  padding: 20px;
}

.admin-container h2 {
  margin-bottom: 20px;
}

.admin-denied {
  text-align: center;
  padding: 60px 20px;
  color: var(--text-secondary);
}

.admin-category-tabs {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  margin-bottom: 20px;
}

.admin-tab-btn {
  padding: 6px 14px;
  background: var(--bg-secondary);
  border: 1px solid var(--border-color);
  border-radius: 20px;
  cursor: pointer;
  font-size: 0.85rem;
  transition: var(--transition);
}

.admin-tab-btn.active {
  background: var(--primary-color);
  color: var(--text-light);
  border-color: var(--primary-color);
}

.admin-form-card {
  background: var(--bg-secondary);
  border-radius: var(--border-radius);
  padding: 20px;
  margin-bottom: 24px;
  box-shadow: var(--shadow-sm);
}

.admin-form-card h3 {
  margin-bottom: 16px;
}

.admin-wrong-answers {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(120px, 1fr));
  gap: 8px;
}

.admin-bulk-delete-row {
  margin-bottom: 20px;
}

.btn-secondary.danger {
  color: #ef4444;
  border-color: #ef4444;
}

.admin-bulk-delete-note {
  font-size: 0.78rem;
  color: var(--text-secondary);
  margin-top: 6px;
  line-height: 1.4;
}

.admin-bulk-card {
  border: 1px dashed var(--border-color);
}

.admin-bulk-guide {
  font-size: 0.82rem;
  color: var(--text-secondary);
  line-height: 1.5;
  margin-bottom: 12px;
}

/* 관리자 - IP 관리 */
.admin-ip-list {
  display: flex;
  flex-direction: column;
  gap: 10px;
  margin-bottom: 24px;
}

.admin-ip-item {
  background: var(--bg-secondary);
  border-radius: var(--border-radius);
  padding: 12px 16px;
  box-shadow: var(--shadow-sm);
}

.admin-ip-item.banned {
  box-shadow: 0 0 0 2px #dc2626 inset;
}

.admin-ip-main {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 8px;
  margin-bottom: 4px;
}

.admin-ip-address {
  font-weight: 700;
  font-variant-numeric: tabular-nums;
}

.admin-ip-count {
  font-size: 0.82rem;
  color: var(--text-secondary);
}

.admin-ip-users {
  font-size: 0.82rem;
  color: var(--text-secondary);
  margin-bottom: 8px;
  word-break: break-all;
}

.admin-ip-warning-list {
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.admin-ip-warning-item {
  display: flex;
  gap: 10px;
  font-size: 0.8rem;
  color: var(--text-secondary);
  background: var(--bg-secondary);
  border-radius: var(--border-radius);
  padding: 8px 12px;
  flex-wrap: wrap;
}

.admin-log-list {
  display: flex;
  flex-direction: column;
  gap: 6px;
  margin-bottom: 16px;
}

.admin-log-item {
  display: flex;
  align-items: center;
  gap: 10px;
  flex-wrap: wrap;
  background: var(--bg-secondary);
  border-radius: var(--border-radius);
  padding: 8px 12px;
  font-size: 0.85rem;
}

.admin-log-name {
  font-family: 'Consolas', 'Menlo', monospace;
  font-weight: 600;
}

.admin-log-meta {
  color: var(--text-secondary);
  font-size: 0.78rem;
  margin-left: auto;
}

.admin-log-viewer {
  max-height: 420px;
  overflow: auto;
  background: #1a1a1a;
  color: #d4d4d4;
  font-family: 'Consolas', 'Menlo', monospace;
  font-size: 0.78rem;
  line-height: 1.5;
  padding: 12px;
  border-radius: var(--border-radius);
  white-space: pre-wrap;
  word-break: break-all;
}

#admin-bulk-import-text {
  width: 100%;
  font-family: 'Consolas', 'Menlo', monospace;
  font-size: 0.82rem;
  padding: 10px;
  border: 1px solid var(--border-color);
  border-radius: var(--border-radius);
  resize: vertical;
  margin-bottom: 12px;
}

.admin-form-actions {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
  margin-top: 16px;
}

#admin-bulk-sample-link,
.admin-bulk-file-label {
  display: inline-flex;
  align-items: center;
  text-decoration: none;
}

.admin-bulk-file-label {
  cursor: pointer;
}

.admin-question-list {
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.admin-empty {
  text-align: center;
  color: var(--text-secondary);
  padding: 40px 0;
}

.admin-question-item {
  background: var(--bg-secondary);
  border-radius: var(--border-radius);
  padding: 14px 16px;
  box-shadow: var(--shadow-sm);
  border-left: 4px solid var(--border-color);
}

.admin-question-item.is-admin {
  border-left-color: var(--primary-color);
}

.admin-question-item.is-disabled {
  opacity: 0.6;
  border-left-color: #B0BEC5;
}

.admin-question-badge.badge-disabled {
  background: #ECEFF1;
  color: #607D8B;
}

.admin-question-header {
  display: flex;
  gap: 8px;
  align-items: center;
  margin-bottom: 6px;
}

.admin-question-no {
  font-size: 0.72rem;
  font-weight: 700;
  color: var(--text-secondary);
  font-family: 'Consolas', 'Menlo', monospace;
}

.admin-question-badge {
  font-size: 0.7rem;
  padding: 2px 8px;
  border-radius: 10px;
  background: var(--border-color);
  color: var(--text-secondary);
}

.admin-question-item.is-admin .admin-question-badge {
  background: var(--primary-color);
  color: var(--text-light);
}

.admin-question-subcat {
  font-size: 0.75rem;
  color: var(--text-secondary);
}

.admin-question-text {
  font-weight: 600;
  margin-bottom: 6px;
}

.admin-question-correct {
  color: #2E7D32;
  font-size: 0.9rem;
  margin-bottom: 2px;
}

.admin-question-wrong {
  color: var(--text-secondary);
  font-size: 0.85rem;
}

.admin-question-actions {
  display: flex;
  gap: 8px;
  margin-top: 10px;
}

.btn-danger {
  background: #FFEBEE;
  color: #C62828;
  border: 1px solid #EF9A9A;
}

/* 관리자 - 회원 관리 (1줄 압축 테이블, 가로 스크롤 없이 화면 폭에 맞춤 - 중복 라벨은 헤더에 한 번만) */
.admin-user-table {
  display: flex;
  flex-direction: column;
  width: 100%;
}

.admin-user-header,
.admin-user-item {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 32px 44px 30px 30px 30px 30px;
  align-items: center;
  gap: 4px;
  padding: 6px 4px;
}

.admin-user-header {
  font-size: 0.7rem;
  font-weight: 700;
  color: var(--text-secondary);
  border-bottom: 2px solid var(--border-color);
  position: sticky;
  top: 0;
  background: var(--bg-secondary);
  z-index: 1;
  text-align: center;
}

.admin-user-header span:first-child {
  text-align: left;
}

.admin-user-item {
  background: var(--bg-secondary);
  border-bottom: 1px solid var(--border-color);
  font-size: 0.82rem;
  text-align: center;
}

.admin-user-item:hover {
  background: var(--bg-primary);
}

.admin-user-main {
  display: flex;
  align-items: center;
  gap: 8px;
  min-width: 0;
  text-align: left;
}

.admin-user-avatar {
  display: inline-flex;
  align-items: flex-end;
  height: 26px;
  width: 19px;
  overflow: hidden;
  line-height: 0;
  flex-shrink: 0;
}

.admin-user-avatar svg {
  height: 100%;
  width: auto;
}

.admin-user-info {
  min-width: 0;
  overflow: hidden;
}

.admin-user-nickname {
  font-weight: 600;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.admin-user-id {
  font-size: 0.68rem;
  color: var(--text-secondary);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.admin-question-badge.sponsor {
  background: #FFB300;
  color: #fff;
}

.admin-question-badge.terms {
  background: #7c3aed;
  color: #fff;
}

.admin-question-badge.bot {
  background: #64748b;
  color: #fff;
}

.admin-question-badge.blocked {
  background: #dc2626;
  color: #fff;
}

.admin-sponsor-toggle.blocked input:checked + .admin-sponsor-slider {
  background: #dc2626;
}

.admin-sponsor-toggle.terms input:checked + .admin-sponsor-slider {
  background: #7c3aed;
}

.admin-user-cell {
  font-variant-numeric: tabular-nums;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.admin-sponsor-toggle {
  display: inline-flex;
  cursor: pointer;
  justify-content: center;
}

.admin-sponsor-toggle input {
  display: none;
}

.admin-sponsor-slider {
  width: 26px;
  height: 15px;
  background: var(--border-color);
  border-radius: 9px;
  position: relative;
  transition: background 0.2s ease;
  flex-shrink: 0;
}

.admin-sponsor-slider::before {
  content: '';
  position: absolute;
  top: 2px;
  left: 2px;
  width: 11px;
  height: 11px;
  background: white;
  border-radius: 50%;
  transition: transform 0.2s ease;
  box-shadow: 0 1px 3px rgba(0, 0, 0, 0.3);
}

.admin-sponsor-toggle input:checked + .admin-sponsor-slider {
  background: #FFB300;
}

.admin-sponsor-toggle input:checked + .admin-sponsor-slider::before {
  transform: translateX(11px);
}
