:root {
  --cq-blue: #38bdf8;
  --cq-blue-glow: rgba(56, 189, 248, 0.4);
  --cq-red: #f43f5e;
  --cq-red-glow: rgba(244, 63, 94, 0.4);
  --cq-yellow: #facc15;
  --cq-yellow-glow: rgba(250, 204, 21, 0.4);
  --cq-panel: rgba(15, 23, 42, 0.92);
  --cq-panel-border: rgba(255, 255, 255, 0.12);
  --cq-glass: rgba(30, 41, 59, 0.65);
}

.game-crazy-quokka { --game-color: 47, 190, 205; }

/* ── 대결 신청 팝업 (Challenge Prompt) ── */
.cq-challenge-prompt {
  position: fixed;
  inset: 0;
  z-index: 12000;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 20px;
  background: rgba(5, 8, 18, 0.75);
  backdrop-filter: blur(8px);
  -webkit-backdrop-filter: blur(8px);
}
.cq-challenge-card {
  width: min(430px, 92vw);
  padding: 26px;
  border: 1px solid rgba(255, 255, 255, 0.16);
  border-radius: 22px;
  color: #fff;
  background: linear-gradient(145deg, #1e293b 0%, #0f172a 100%);
  text-align: center;
  box-shadow: 0 25px 80px rgba(0, 0, 0, 0.7), 0 0 0 1px rgba(255, 255, 255, 0.06);
}
.cq-challenge-card h3 {
  margin: 0 0 10px;
  font-size: 23px;
  font-weight: 850;
  letter-spacing: -0.02em;
  background: linear-gradient(135deg, #fff 40%, #7dd3fc 100%);
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
}
.cq-challenge-card p { margin: 0 0 10px; color: #cbd5e1; font-size: 14px; line-height: 1.5; }
.cq-challenge-time {
  margin-bottom: 16px;
  color: var(--cq-yellow);
  font-size: 13px;
  font-weight: 850;
  font-variant-numeric: tabular-nums;
  letter-spacing: 0.02em;
  text-shadow: 0 0 10px rgba(250, 204, 21, 0.4);
}
.cq-challenge-card > div { display: flex; justify-content: center; gap: 10px; }
.cq-challenge-card > .cq-challenge-time { display: block; }

/* ── 루트 컨테이너 (Root Container) ── */
#crazyQuokkaRoot {
  position: absolute;
  inset: 0;
  z-index: 50;
  display: none;
  align-items: center;
  justify-content: center;
  width: 100%;
  height: 100%;
  padding: 10px;
  color: #fff;
  background:
    radial-gradient(circle at 20% 15%, rgba(56, 189, 248, 0.20), transparent 36%),
    radial-gradient(circle at 85% 80%, rgba(244, 63, 94, 0.16), transparent 34%),
    radial-gradient(circle at 50% 50%, rgba(15, 23, 42, 0.85), transparent 70%),
    rgba(6, 10, 20, 0.96);
  font-family: Inter, system-ui, -apple-system, sans-serif;
  outline: none;
  container-type: size;
}

#crazyQuokkaRoot.cq-visible { display: flex; }
#crazyQuokkaRoot * { box-sizing: border-box; }

/* ── 글래스모피즘 메인 패널 (Panels) ── */
.cq-panel {
  width: min(780px, 96%);
  max-height: 96%;
  overflow: hidden;
  padding: clamp(10px, 1.8cqh, 16px);
  border: 1px solid var(--cq-panel-border);
  border-radius: 20px;
  background: var(--cq-panel);
  backdrop-filter: blur(20px);
  -webkit-backdrop-filter: blur(20px);
  box-shadow: 0 24px 70px rgba(0, 0, 0, 0.65), 0 0 0 1px rgba(255, 255, 255, 0.05), inset 0 1px 0 rgba(255, 255, 255, 0.1);
}

.cq-title-row,
.cq-lobby-footer,
.cq-mode-row,
.cq-team-row,
.cq-result-actions {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
}

.cq-title-row { justify-content: space-between; margin-bottom: clamp(6px, 1.2cqh, 10px); }
.cq-title-row h2 {
  margin: 0;
  font-size: clamp(17px, 2.8cqw, 22px);
  font-weight: 850;
  letter-spacing: -0.03em;
  background: linear-gradient(135deg, #ffffff 40%, #7dd3fc 100%);
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  filter: drop-shadow(0 2px 8px rgba(56, 189, 248, 0.3));
}
.cq-title-actions { display: flex; align-items: center; gap: 6px; }
/* 로비 제목 아래 설명(맵·인원·시간)은 제목 폭 기준 가운데 정렬 */
.cq-title-block { text-align: center; }
/* 로비 제목 옆 확대·설명 버튼은 같은 상자·글꼴을 쓴다(.cq-fullscreen-btn의 소형 HUD 크기를 덮는다). */
.cq-title-actions .cq-btn {
  min-width: 0;
  height: auto;
  min-height: 31px;
  padding: 6px 12px;
  border-radius: 9px;
  font-size: 11.5px;
  font-weight: 750;
}
/* .cq-fullscreen-btn이 뒤에서 배경·글자색을 덮으므로 설명 버튼과 같은 색을 다시 지정한다. */
.cq-title-actions .cq-btn-info {
  color: #bae6fd;
  border-color: rgba(56, 189, 248, 0.45);
  background: rgba(14, 165, 233, 0.16);
}
.cq-subtitle {
  color: #94a3b8;
  font-size: 11px;
  font-weight: 600;
  letter-spacing: -0.01em;
  margin-top: 1px;
}

/* ── 모던 아케이드 버튼 (Buttons) ── */
.cq-btn {
  min-height: 31px;
  padding: 6px 12px;
  border: 1px solid rgba(148, 163, 184, 0.24);
  border-radius: 9px;
  color: #f1f5f9;
  background: rgba(30, 41, 59, 0.75);
  font: inherit;
  font-size: 11.5px;
  font-weight: 750;
  cursor: pointer;
  box-shadow: 0 1px 3px rgba(0, 0, 0, 0.25), inset 0 1px 0 rgba(255, 255, 255, 0.08);
  transition: transform 0.08s ease, background 0.14s ease, border-color 0.14s ease, box-shadow 0.14s ease, color 0.14s ease;
  user-select: none;
  -webkit-user-select: none;
}
.cq-btn:not(:disabled):hover {
  border-color: #38bdf8;
  background: rgba(51, 65, 85, 0.9);
  color: #ffffff;
  box-shadow: 0 0 14px rgba(56, 189, 248, 0.25), 0 2px 6px rgba(0, 0, 0, 0.3);
}
.cq-btn:not(:disabled):active {
  transform: translateY(1px) scale(0.975);
  background: #0f172a;
  box-shadow: inset 0 2px 5px rgba(0, 0, 0, 0.5);
}
.cq-btn:disabled { opacity: 0.42; cursor: default; transform: none; box-shadow: none; }
.cq-btn-primary {
  color: #ffffff;
  border-color: rgba(125, 211, 252, 0.6);
  background: linear-gradient(135deg, #0284c7 0%, #0ea5e9 100%);
  box-shadow: 0 4px 14px rgba(14, 165, 233, 0.35), inset 0 1px 0 rgba(255, 255, 255, 0.35);
  font-weight: 800;
}
.cq-btn-primary:not(:disabled):hover {
  border-color: #bae6fd;
  background: linear-gradient(135deg, #0369a1 0%, #38bdf8 100%);
  box-shadow: 0 6px 20px rgba(14, 165, 233, 0.5), inset 0 1px 0 rgba(255, 255, 255, 0.4);
}
.cq-btn-primary:not(:disabled):active {
  background: linear-gradient(135deg, #075985 0%, #0284c7 100%);
  box-shadow: inset 0 2px 6px rgba(0, 0, 0, 0.45);
}
.cq-btn-danger {
  color: #fecdd3;
  background: rgba(244, 63, 94, 0.14);
  border-color: rgba(244, 63, 94, 0.4);
}
.cq-btn-danger:not(:disabled):hover {
  background: rgba(244, 63, 94, 0.28);
  border-color: #f43f5e;
  color: #ffffff;
  box-shadow: 0 0 14px rgba(244, 63, 94, 0.35);
}
.cq-btn-info {
  color: #bae6fd;
  border-color: rgba(56, 189, 248, 0.45);
  background: rgba(14, 165, 233, 0.16);
}
.cq-btn-info:not(:disabled):hover {
  border-color: #7dd3fc;
  background: rgba(14, 165, 233, 0.32);
  color: #ffffff;
  box-shadow: 0 0 14px rgba(56, 189, 248, 0.35);
}
.cq-btn.cq-active {
  background: rgba(14, 165, 233, 0.22);
  border-color: #38bdf8;
  color: #38bdf8;
  box-shadow: 0 0 12px rgba(56, 189, 248, 0.3), inset 0 0 8px rgba(56, 189, 248, 0.2);
}
.cq-btn.cq-blue { border-color: rgba(56, 189, 248, 0.55); color: #bae6fd; }
.cq-btn.cq-blue.cq-active {
  background: rgba(14, 165, 233, 0.25);
  border-color: #38bdf8;
  color: #ffffff;
  box-shadow: 0 0 16px rgba(56, 189, 248, 0.4);
}
.cq-btn.cq-red { border-color: rgba(244, 63, 94, 0.55); color: #fecdd3; }
.cq-btn.cq-red.cq-active {
  background: rgba(244, 63, 94, 0.25);
  border-color: #f43f5e;
  color: #ffffff;
  box-shadow: 0 0 16px rgba(244, 63, 94, 0.4);
}

.cq-lobby-panel {
  width: min(720px, 96%);
  display: flex;
  flex-direction: column;
  height: auto;
  max-height: 96%;
  box-sizing: border-box;
}
.cq-title-row,
.cq-lobby-settings,
.cq-player-heading,
.cq-lobby-footer {
  flex-shrink: 0;
}
.cq-lobby-settings {
  display: flex;
  align-items: center;
  gap: 6px;
  min-height: 36px;
  margin-bottom: 8px;
  padding: 4px 8px;
  border-radius: 10px;
  background: rgba(15, 23, 42, 0.65);
  border: 1px solid rgba(255, 255, 255, 0.08);
  box-shadow: inset 0 1px 3px rgba(0, 0, 0, 0.35);
  flex-wrap: wrap;
  row-gap: 5px;
}
.cq-setting-label {
  color: #94a3b8;
  font-size: 10.5px;
  font-weight: 850;
  letter-spacing: 0.04em;
  text-transform: uppercase;
}
.cq-mode-row, .cq-team-row { gap: 5px; flex-wrap: nowrap; }
.cq-map-row { display: flex; align-items: center; gap: 6px; margin-left: auto; }
/* 라운드·팀 선택은 모드 줄 오른쪽 끝에 붙여, 아래 줄 맵 선택과 오른쪽 가장자리를 맞춘다. */
.cq-setting-group { display: flex; align-items: center; gap: 6px; margin-left: auto; }
.cq-map-select {
  min-height: 29px;
  max-width: 180px;
  padding: 4px 22px 4px 8px;
  border: 1px solid rgba(148, 163, 184, 0.28);
  border-radius: 7px;
  color: #f8fafc;
  background: #0f172a;
  font: inherit;
  font-size: 11px;
  font-weight: 750;
  cursor: pointer;
  transition: border-color 0.15s, box-shadow 0.15s;
}
.cq-map-select:hover:not(:disabled) {
  border-color: #38bdf8;
  box-shadow: 0 0 8px rgba(56, 189, 248, 0.25);
}
.cq-map-select:disabled { opacity: 0.65; cursor: default; }
.cq-player-heading {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin: 0 2px 5px;
  color: #cbd5e1;
  font-size: 11.5px;
  font-weight: 700;
}
.cq-player-heading span {
  color: #94a3b8;
  font-size: 10.5px;
  font-weight: 700;
  background: rgba(255, 255, 255, 0.06);
  padding: 1px 6px;
  border-radius: 5px;
}
.cq-player-list {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 6px;
  padding-right: 2px;
}
.cq-player-card {
  display: grid;
  grid-template-columns: 30px minmax(0, 1fr) auto;
  align-items: center;
  gap: 8px;
  min-height: 42px;
  padding: 4px 8px;
  border: 1px solid rgba(255, 255, 255, 0.08);
  border-radius: 10px;
  background: rgba(15, 23, 42, 0.6);
  box-shadow: 0 2px 6px rgba(0, 0, 0, 0.25);
  transition: border-color 0.15s, background 0.15s, transform 0.12s;
}
.cq-player-card:hover {
  background: rgba(30, 41, 59, 0.6);
  border-color: rgba(255, 255, 255, 0.14);
}
.cq-player-card.cq-team-blue {
  box-shadow: inset 3px 0 #38bdf8, 0 2px 8px rgba(0, 0, 0, 0.25);
  border-color: rgba(56, 189, 248, 0.2);
}
.cq-player-card.cq-team-red {
  box-shadow: inset 3px 0 #f43f5e, 0 2px 8px rgba(0, 0, 0, 0.25);
  border-color: rgba(244, 63, 94, 0.2);
}
.cq-player-avatar {
  width: 28px;
  height: 28px;
  border-radius: 50%;
  object-fit: cover;
  background: #1e293b;
  border: 1.5px solid rgba(255, 255, 255, 0.14);
  box-shadow: 0 2px 5px rgba(0, 0, 0, 0.35);
}
.cq-avatar-fallback {
  display: grid;
  place-items: center;
  color: #fff;
  background: var(--cq-avatar-color);
  font-size: 12px;
  font-weight: 900;
  text-shadow: 0 1px 2px rgba(0, 0, 0, 0.5);
}
.cq-player-name {
  min-width: 0;
  overflow: hidden;
  white-space: nowrap;
  text-overflow: ellipsis;
  font-size: 11.5px;
  font-weight: 750;
  color: #f1f5f9;
}
.cq-me {
  margin-left: 4px;
  color: #fde047;
  font-size: 10px;
  font-weight: 850;
  background: rgba(250, 204, 21, 0.15);
  padding: 1px 4px;
  border-radius: 4px;
}
.cq-owner {
  color: var(--cq-yellow);
  margin-left: 5px;
  font-size: 12px;
  filter: drop-shadow(0 0 4px rgba(250, 204, 21, 0.6));
}
.cq-ready {
  color: #34d399;
  font-size: 11px;
  font-weight: 850;
  letter-spacing: 0.05em;
  background: rgba(16, 185, 129, 0.16);
  border: 1px solid rgba(16, 185, 129, 0.35);
  padding: 3px 8px;
  border-radius: 6px;
  box-shadow: 0 0 10px rgba(16, 185, 129, 0.2);
}
.cq-waiting {
  color: #94a3b8;
  font-size: 11px;
  font-weight: 650;
  background: rgba(148, 163, 184, 0.1);
  border: 1px solid rgba(148, 163, 184, 0.2);
  padding: 3px 8px;
  border-radius: 6px;
}
.cq-lobby-footer { justify-content: flex-end; margin-top: 8px; flex-wrap: nowrap; gap: 6px; }
/* 혼자하기 AI 봇 카드·추가 버튼 */
.cq-bot-tools { display: flex; align-items: center; gap: 4px; min-width: 0; }
.cq-bot-tag {
  color: #c4b5fd;
  font-size: 10.5px;
  font-weight: 850;
  white-space: nowrap;
  background: rgba(139, 92, 246, 0.16);
  border: 1px solid rgba(139, 92, 246, 0.35);
  padding: 2px 6px;
  border-radius: 6px;
}
.cq-bot-btn {
  min-width: 22px;
  min-height: 22px;
  padding: 0 5px;
  border: 1px solid rgba(255, 255, 255, 0.14);
  border-radius: 6px;
  background: rgba(15, 23, 42, 0.85);
  color: #e2e8f0;
  font-size: 10.5px;
  font-weight: 800;
  white-space: nowrap;
  cursor: pointer;
}
.cq-bot-btn:hover { border-color: rgba(255, 255, 255, 0.35); background: rgba(30, 41, 59, 0.9); }
.cq-unrated { color: #fbbf24; font-weight: 800; }
/* AI 추가 버튼은 참가자 머리줄에 둬 로비 높이를 늘리지 않는다 */
.cq-bot-add { display: flex; gap: 4px; margin: 0 auto 0 8px; min-width: 0; }
.cq-lobby-help { margin-right: auto; color: #94a3b8; font-size: 11px; font-weight: 600; }
.cq-info-panel[hidden] { display: none; }
/* 설명 패널은 로비 패널(flex column, overflow:hidden) 안에서 남는 높이만 쓰고 내용은 안에서 스크롤한다.
   전체 설명을 줄 수 제한 없이 보여 주되 아래 참가자·READY 줄을 밀어내지 않는다. */
.cq-info-panel {
  display: flex;
  flex-direction: column;
  /* 탭 + 내용 최소 60px 아래로는 줄지 않는다. 더 좁은 화면(비확대 360폭)에서는 기존처럼 아래 줄이
     패널 밖으로 밀리고, 설명 패널 자체는 잘라서 다른 줄과 겹치지 않게 한다. */
  min-height: 118px;
  overflow: hidden;
  margin: 0 0 10px;
  padding: 10px;
  border: 1px solid rgba(56, 189, 248, 0.25);
  border-radius: 14px;
  background: linear-gradient(135deg, rgba(15, 23, 42, 0.85) 0%, rgba(30, 41, 59, 0.7) 100%);
  box-shadow: inset 0 1px 3px rgba(0, 0, 0, 0.35);
}
.cq-info-tabs { display: flex; flex-shrink: 0; gap: 6px; margin-bottom: 8px; }
.cq-info-tab {
  min-height: 28px;
  padding: 4px 12px;
  border: 1px solid rgba(148, 163, 184, 0.25);
  border-radius: 8px;
  color: #94a3b8;
  background: rgba(15, 23, 42, 0.55);
  font: inherit;
  font-size: 11px;
  font-weight: 800;
  cursor: pointer;
  transition: all 0.14s ease;
}
.cq-info-tab:hover { border-color: rgba(56, 189, 248, 0.6); color: #e0f2fe; }
.cq-info-tab.cq-active {
  color: #ffffff;
  border-color: #38bdf8;
  background: rgba(14, 165, 233, 0.25);
  box-shadow: 0 0 10px rgba(56, 189, 248, 0.3);
}
.cq-info-content {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  /* 높이가 줄어든 스크롤 격자에서 auto 행은 남은 높이로 눌려 글자가 겹친다. 행은 항상 내용 높이. */
  grid-auto-rows: max-content;
  gap: 8px;
  min-height: 60px;
  overflow-y: auto;
  overscroll-behavior: contain;
  padding-right: 3px;
  scrollbar-width: thin;
  scrollbar-color: rgba(56, 189, 248, 0.45) transparent;
}
.cq-info-content::-webkit-scrollbar { width: 6px; }
.cq-info-content::-webkit-scrollbar-thumb { border-radius: 3px; background: rgba(56, 189, 248, 0.45); }
.cq-info-card {
  display: grid;
  grid-template-columns: 48px minmax(0, 1fr);
  align-items: center;
  gap: 8px;
  min-width: 0;
  min-height: 52px;
  padding: 5px 8px;
  border: 1px solid rgba(255, 255, 255, 0.08);
  border-radius: 10px;
  background: rgba(15, 23, 42, 0.45);
  box-shadow: 0 2px 5px rgba(0, 0, 0, 0.2);
}
.cq-info-item-icon { display: block; width: 48px; height: 48px; image-rendering: auto; }
.cq-info-copy { min-width: 0; }
.cq-info-copy strong {
  display: block;
  overflow: hidden;
  color: #f8fafc;
  font-size: 11px;
  font-weight: 850;
  white-space: nowrap;
  text-overflow: ellipsis;
}
.cq-info-copy p {
  margin: 2px 0 0;
  color: #94a3b8;
  font-size: 9.5px;
  line-height: 1.3;
  word-break: keep-all;
  overflow-wrap: anywhere;
}
.cq-info-copy small { display: block; margin-top: 2px; color: #38bdf8; font-size: 9px; font-weight: 700; }
.cq-info-character-card { grid-template-columns: 44px minmax(0, 1fr); }
/* 맵 탭: 배치도 미리보기(가로형 64×48) */
/* 미리보기 56×42 */
.cq-info-map-card { grid-template-columns: 56px minmax(0, 1fr); }
.cq-info-map-thumb { display: block; width: 56px; height: 42px; border-radius: 5px; background: rgba(2, 6, 23, 0.55); }
.cq-info-copy .cq-info-map-size { display: inline; margin: 0 0 0 2px; color: #64748b; font-size: 9px; font-weight: 700; }
.cq-info-character-sprite {
  width: 44px;
  height: 44px;
  background-repeat: no-repeat;
  background-size: 400% 400%;
  background-position: 0 0;
  image-rendering: auto;
}

/* ── 에셋 로딩 게이트 (전원 READY → 캐릭터 선택 사이) ── */
.cq-loading-panel {
  width: min(720px, 96%);
  display: flex;
  flex-direction: column;
  height: auto;
  max-height: 96%;
}
.cq-load-total {
  display: grid;
  grid-template-columns: auto minmax(0, 1fr) auto;
  align-items: center;
  gap: 8px;
  flex-shrink: 0;
  margin-bottom: clamp(5px, 1.2cqh, 9px);
  padding: 5px 9px;
  border-radius: 10px;
  background: rgba(15, 23, 42, 0.65);
  border: 1px solid rgba(255, 255, 255, 0.08);
  box-shadow: inset 0 1px 3px rgba(0, 0, 0, 0.35);
}
.cq-load-total-label {
  color: #94a3b8;
  font-size: 10.5px;
  font-weight: 850;
  letter-spacing: 0.02em;
  white-space: nowrap;
}
.cq-load-list {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(230px, 1fr));
  align-content: start;
  gap: 5px;
  min-height: 0;
  overflow: hidden;
}
.cq-load-row {
  display: grid;
  grid-template-columns: minmax(0, 1.15fr) minmax(40px, 1fr) auto;
  align-items: center;
  gap: 7px;
  min-height: 30px;
  padding: 3px 8px;
  border: 1px solid rgba(255, 255, 255, 0.08);
  border-radius: 9px;
  background: rgba(15, 23, 42, 0.6);
  box-shadow: 0 2px 6px rgba(0, 0, 0, 0.25);
}
.cq-load-name {
  min-width: 0;
  color: #e2e8f0;
  font-size: 11px;
  font-weight: 750;
  line-height: 1.2;
  overflow-wrap: anywhere;
  word-break: break-word;
}
.cq-load-bar {
  height: 6px;
  border-radius: 99px;
  background: rgba(148, 163, 184, 0.22);
  overflow: hidden;
  box-shadow: inset 0 1px 2px rgba(0, 0, 0, 0.45);
}
.cq-load-bar-total { height: 9px; }
.cq-load-fill {
  display: block;
  height: 100%;
  width: 0;
  border-radius: 99px;
  background: linear-gradient(90deg, #38bdf8, #22d3ee);
  transition: width 0.2s ease;
}
.cq-load-value {
  min-width: 36px;
  text-align: right;
  color: #94a3b8;
  font-size: 10px;
  font-weight: 800;
  font-variant-numeric: tabular-nums;
  white-space: nowrap;
}
.cq-load-row.cq-load-done { border-color: rgba(74, 222, 128, 0.28); }
.cq-load-row.cq-load-done .cq-load-fill { background: linear-gradient(90deg, #22c55e, #4ade80); }
.cq-load-row.cq-load-done .cq-load-value { color: #4ade80; }
.cq-load-row.cq-load-offline { opacity: 0.55; }
.cq-load-row.cq-load-offline .cq-load-value { color: #f87171; }

.cq-select-panel { width: min(780px, 98%); }
.cq-select-timer {
  font-size: clamp(26px, 5cqw, 40px);
  font-weight: 950;
  color: var(--cq-yellow);
  font-variant-numeric: tabular-nums;
  letter-spacing: -0.02em;
  text-shadow: 0 0 24px rgba(250, 204, 21, 0.5), 0 2px 4px rgba(0, 0, 0, 0.5);
}
.cq-character-grid {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: clamp(8px, 1.6cqh, 12px);
  max-width: 720px;
  margin: 0 auto;
}
.cq-character-card {
  position: relative;
  aspect-ratio: 1;
  min-width: 0;
  overflow: hidden;
  padding: 8px;
  border: 2px solid rgba(148, 163, 184, 0.22);
  border-radius: 14px;
  color: #fff;
  background: linear-gradient(180deg, rgba(30, 41, 59, 0.8) 0%, rgba(15, 23, 42, 0.95) 100%);
  font: inherit;
  text-align: center;
  cursor: pointer;
  box-shadow: 0 6px 18px rgba(0, 0, 0, 0.35), inset 0 1px 0 rgba(255, 255, 255, 0.1);
  transition: transform 0.12s ease, border-color 0.15s ease, box-shadow 0.15s ease, background 0.15s ease;
}
.cq-character-card:hover:not(:disabled) {
  border-color: #38bdf8;
  background: linear-gradient(180deg, rgba(42, 60, 88, 0.85) 0%, rgba(15, 23, 42, 0.95) 100%);
  box-shadow: 0 8px 24px rgba(14, 165, 233, 0.3), inset 0 1px 0 rgba(255, 255, 255, 0.2);
  transform: translateY(-2px);
}
.cq-character-card:active:not(:disabled) { transform: scale(0.965); }
.cq-character-card.cq-cursor {
  border-color: var(--cq-yellow);
  box-shadow: 0 0 20px rgba(250, 204, 21, 0.45), inset 0 0 10px rgba(250, 204, 21, 0.15);
  transform: scale(1.02);
}
.cq-character-card.cq-taken { filter: saturate(0.35); opacity: 0.5; cursor: default; }
.cq-character-card.cq-mine {
  border-color: #34d399;
  box-shadow: 0 0 24px rgba(52, 211, 153, 0.45), inset 0 0 12px rgba(52, 211, 153, 0.18);
  opacity: 1;
  filter: none;
}
.cq-character-sprite {
  width: min(74%, 100px);
  aspect-ratio: 1;
  margin: -3px auto -2px;
  background-repeat: no-repeat;
  background-size: 400% 400%;
  background-position: 0 0;
  image-rendering: auto;
  filter: drop-shadow(0 4px 10px rgba(0, 0, 0, 0.45));
}
.cq-character-name {
  overflow: hidden;
  white-space: nowrap;
  text-overflow: ellipsis;
  font-size: clamp(11px, 2.1cqw, 14px);
  font-weight: 850;
  letter-spacing: -0.01em;
  color: #f8fafc;
}
.cq-character-skill {
  display: -webkit-box;
  overflow: hidden;
  margin-top: 2px;
  color: #94a3b8;
  font-size: 9.5px;
  line-height: 1.25;
  -webkit-box-orient: vertical;
  -webkit-line-clamp: 2;
}
.cq-character-lock {
  position: absolute;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 8px;
  background: rgba(5, 8, 16, 0.68);
  backdrop-filter: blur(2px);
  font-size: 11px;
  font-weight: 850;
  letter-spacing: 0.02em;
  color: #cbd5e1;
}
.cq-select-footer {
  display: grid;
  grid-template-columns: 1fr auto;
  align-items: center;
  min-height: 26px;
  margin-top: 8px;
  color: #94a3b8;
  font-size: 11px;
}
.cq-select-footer > span:first-child { min-width: 1px; }
.cq-select-help { color: #cbd5e1; text-align: right; font-size: 11px; font-weight: 600; }

.cq-game-shell {
  position: relative;
  display: grid;
  grid-template-rows: auto minmax(0, 1fr);
  width: 100%;
  height: 100%;
  overflow: hidden;
  border: 1px solid rgba(255, 255, 255, 0.12);
  border-radius: 0;
  background: #080d1a;
  box-shadow: 0 25px 90px rgba(0, 0, 0, 0.7);
}
.cq-game-shell.cq-square { grid-template-rows: 1fr; }
.cq-game-shell.cq-square .cq-hud { display: none; }

.cq-side {
  position: absolute;
  top: 0;
  bottom: 0;
  width: min(136px, 12%);
  display: none;
  flex-direction: column;
  justify-content: center;
  gap: 8px;
  padding: 14px 10px;
  pointer-events: none;
  z-index: 2;
}
.cq-side-left { left: 0; align-items: flex-start; }
.cq-side-right { right: 0; align-items: flex-end; text-align: right; }
.cq-game-shell.cq-square .cq-side { display: flex; }
.cq-side .cq-hud-chip {
  pointer-events: auto;
  font-size: 11px;
  padding: 5px 8px;
  border-radius: 8px;
  max-width: 100%;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.cq-side .cq-clock {
  font: 900 clamp(18px, 2.6vw, 26px)/1 'DM Mono', monospace;
  color: #fff;
  font-variant-numeric: tabular-nums;
  letter-spacing: 0.04em;
}
.cq-side .cq-round-info {
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  gap: 4px;
  font-size: 10px;
}
.cq-side-left .cq-side-status {
  display: flex;
  flex-direction: column;
  gap: 6px;
  align-items: flex-start;
  width: 100%;
}
.cq-side-right .cq-side-controls {
  display: flex;
  flex-direction: column;
  gap: 6px;
  align-items: flex-end;
  width: 100%;
}
.cq-side .cq-fullscreen-btn {
  pointer-events: auto;
  min-width: 28px;
  height: 28px;
  padding: 2px 6px;
  border-radius: 8px;
  font-size: 13px;
}

@media (pointer: coarse), (max-width: 760px) {
  .cq-game-shell.cq-square { grid-template-rows: auto minmax(0, 1fr); }
  .cq-game-shell.cq-square .cq-hud { display: grid; }
  .cq-game-shell.cq-square .cq-side { display: none !important; }
}

/* 상단 HUD 바 */
.cq-hud {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto minmax(0, 1fr);
  align-items: center;
  gap: 6px;
  min-height: 32px;
  padding: 4px 10px;
  background: rgba(11, 18, 33, 0.94);
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
  border-bottom: 1px solid rgba(255, 255, 255, 0.08);
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.3);
}
.cq-hud-left, .cq-hud-right { display: flex; align-items: center; gap: 5px; min-width: 0; }
.cq-hud-left { overflow: hidden; }
.cq-hud-center { display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 1px; }
.cq-round-info {
  display: flex;
  align-items: center;
  gap: 4px;
  font-size: 9px;
  font-weight: 850;
  letter-spacing: 0.04em;
  color: #cbd5e1;
  text-transform: uppercase;
}
.cq-round-badge {
  padding: 2px 5px;
  border-radius: 5px;
  background: rgba(255, 255, 255, 0.08);
  border: 1px solid rgba(255, 255, 255, 0.1);
  font-size: 8px;
  letter-spacing: 0.05em;
}
.cq-score-blue { color: #38bdf8; font-weight: 950; text-shadow: 0 0 8px rgba(56, 189, 248, 0.5); }
.cq-score-red { color: #f43f5e; font-weight: 950; text-shadow: 0 0 8px rgba(244, 63, 94, 0.5); }
.cq-score-divider { opacity: 0.5; margin: 0 2px; }
.cq-hud-right { justify-content: flex-end; }
.cq-hud-chip {
  padding: 3px 7px;
  border-radius: 6px;
  background: rgba(255, 255, 255, 0.06);
  border: 1px solid rgba(255, 255, 255, 0.08);
  font-size: 9px;
  font-weight: 750;
  color: #e2e8f0;
  white-space: nowrap;
  box-shadow: 0 1px 2px rgba(0, 0, 0, 0.2);
}
.cq-clock {
  font: 900 clamp(15px, 2.2vw, 21px)/1 'DM Mono', monospace;
  color: #fff;
  font-variant-numeric: tabular-nums;
  letter-spacing: 0.04em;
}
.cq-clock.cq-warning {
  color: #f43f5e;
  text-shadow: 0 0 12px rgba(244, 63, 94, 0.8);
  animation: cqPulse 0.5s infinite alternate;
}
@keyframes cqPulse { to { transform: scale(1.08); filter: brightness(1.35); } }

/* ── 스테이지 래퍼 & 캔버스 (Stage & Canvas) ── */
.cq-stage-wrap {
  position: relative;
  min-height: 0;
  overflow: hidden;
  display: flex;
  align-items: center;
  justify-content: center;
  background: #0a0f1d;
}
.cq-canvas {
  display: block;
  width: auto;
  height: 100%;
  max-width: 100%;
  max-height: 100%;
  margin: auto;
  image-rendering: auto;
  outline: none;
  box-shadow: 0 8px 32px rgba(0, 0, 0, 0.65);
}

/* ── 카운트다운 & 세레머니 배너 (Banners) ── */
.cq-countdown-banner {
  position: absolute;
  inset: 0;
  z-index: 3;
  display: grid;
  place-items: center;
  pointer-events: none;
  color: #fff;
  font: 950 clamp(76px, 18cqw, 190px)/1 Inter, system-ui, sans-serif;
  letter-spacing: -0.05em;
  text-shadow: 0 4px 0 #0284c7, 0 8px 0 #0369a1, 0 12px 36px rgba(14, 165, 233, 0.75);
  opacity: 0;
  transform: scale(0.78);
  transition: opacity 0.12s ease, transform 0.16s cubic-bezier(0.2, 0.85, 0.25, 1.25), color 0.12s ease;
}
.cq-countdown-banner.cq-show { opacity: 1; transform: scale(1); }
.cq-countdown-banner.cq-start {
  color: #fef08a;
  letter-spacing: -0.03em;
  text-shadow: 0 4px 0 #d97706, 0 8px 0 #b45309, 0 12px 40px rgba(245, 158, 11, 0.85);
}
.cq-celebration-banner {
  position: absolute;
  left: 50%;
  top: 8%;
  z-index: 3;
  pointer-events: none;
  color: #f43f5e;
  font: 950 clamp(28px, 6cqw, 64px)/1 Inter, system-ui, sans-serif;
  letter-spacing: -0.04em;
  text-shadow: 0 4px 0 #9f1239, 0 8px 28px rgba(244, 63, 94, 0.85);
  opacity: 0;
  transform: translateX(-50%) translateY(-8px) scale(0.86);
  transition: opacity 0.15s ease, transform 0.2s cubic-bezier(0.2, 0.85, 0.25, 1.2);
}
.cq-celebration-banner.cq-show { opacity: 1; transform: translateX(-50%) translateY(0) scale(1); }

/* ── 인게임 채팅 입력창 (Game Chat Input) ── */
.cq-chat-input {
  position: absolute;
  left: 50%;
  bottom: 22px;
  z-index: 5;
  display: none;
  width: min(520px, 82%);
  transform: translateX(-50%);
  padding: 13px 18px;
  border: 2px solid #38bdf8;
  border-radius: 18px;
  color: #fff;
  background: rgba(10, 16, 30, 0.94);
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
  outline: none;
  font: 600 15px Inter, sans-serif;
  box-shadow: 0 10px 40px rgba(0, 0, 0, 0.65), 0 0 18px rgba(56, 189, 248, 0.35);
  transition: border-color 0.15s, box-shadow 0.15s;
}
.cq-chat-input:focus {
  border-color: #7dd3fc;
  box-shadow: 0 10px 40px rgba(0, 0, 0, 0.7), 0 0 24px rgba(56, 189, 248, 0.55);
}
.cq-chat-input.cq-open { display: block; }

/* ── 결과 화면 오버레이 (Result Overlay) ── */
.cq-result {
  position: absolute;
  inset: 0;
  z-index: 8;
  display: flex;
  align-items: center;
  justify-content: center;
  background: rgba(4, 7, 15, 0.78);
  backdrop-filter: blur(8px);
  -webkit-backdrop-filter: blur(8px);
}
.cq-result-card {
  width: min(520px, 86%);
  padding: 30px;
  border: 1px solid rgba(255, 255, 255, 0.14);
  border-radius: 24px;
  background: rgba(15, 23, 42, 0.95);
  backdrop-filter: blur(20px);
  -webkit-backdrop-filter: blur(20px);
  text-align: center;
  box-shadow: 0 25px 80px rgba(0, 0, 0, 0.75), 0 0 0 1px rgba(255, 255, 255, 0.06);
}
.cq-result-card h2 {
  margin: 0 0 8px;
  font-size: 32px;
  font-weight: 900;
  letter-spacing: -0.03em;
  background: linear-gradient(135deg, #ffffff 40%, #7dd3fc 100%);
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
}
.cq-result-score {
  font-size: 22px;
  font-weight: 950;
  margin: 4px 0 16px;
  color: var(--cq-yellow);
  letter-spacing: 0.04em;
  text-shadow: 0 0 16px rgba(250, 204, 21, 0.5);
}
.cq-result-teams {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 12px;
  margin: 18px 0 16px;
}
.cq-result-team {
  min-height: 96px;
  padding: 14px 12px;
  border: 1px solid rgba(255, 255, 255, 0.12);
  border-radius: 16px;
  background: rgba(255, 255, 255, 0.04);
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.25);
}
.cq-result-team h3 { margin: 0 0 8px; font-size: 14px; font-weight: 850; letter-spacing: -0.01em; }
.cq-result-team p { margin: 0; color: #fff; font-size: 13px; line-height: 1.5; word-break: keep-all; overflow-wrap: anywhere; }
.cq-result-winners {
  border-color: rgba(16, 185, 129, 0.55);
  background: linear-gradient(180deg, rgba(16, 185, 129, 0.20), rgba(16, 185, 129, 0.05));
  box-shadow: 0 0 20px rgba(16, 185, 129, 0.15);
}
.cq-result-winners h3 { color: #34d399; }
.cq-result-losers {
  border-color: rgba(56, 189, 248, 0.45);
  background: linear-gradient(180deg, rgba(56, 189, 248, 0.15), rgba(56, 189, 248, 0.04));
}
.cq-result-losers h3 { color: #38bdf8; }
.cq-result-names { margin: 16px 0 18px; color: #cbd5e1; font-size: 13px; line-height: 1.5; font-weight: 600; }

/* ── 전체화면 & 축소 버튼 (Fullscreen Controls) ── */
.cq-fullscreen-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 18px;
  height: 18px;
  padding: 1px 4px;
  border: 1px solid rgba(255, 255, 255, 0.22);
  border-radius: 5px;
  background: rgba(255, 255, 255, 0.08);
  color: #cbd5e1;
  font-size: 9px;
  font-weight: 800;
  cursor: pointer;
  transition: all 0.15s;
  user-select: none;
  -webkit-user-select: none;
}
.cq-fullscreen-btn:hover {
  background: rgba(255, 255, 255, 0.2);
  color: #fff;
  border-color: #38bdf8;
  box-shadow: 0 0 8px rgba(56, 189, 248, 0.35);
}

#crazyQuokkaRoot.cq-fullscreen {
  position: fixed !important;
  inset: 0 !important;
  width: 100vw !important;
  height: 100vh !important;
  /* 모바일 Chrome 주소창 표시 중에는 100vh가 실제 보이는 영역보다 커서 하단 가상패드가 잘린다. */
  height: 100dvh !important;
  z-index: 99999 !important;
  border-radius: 0 !important;
  padding: 0 !important;
}

.cq-minimize-btn {
  position: absolute;
  top: 10px;
  right: 10px;
  z-index: 100;
  background: rgba(15, 23, 42, 0.9);
  color: #38bdf8;
  border: 1px solid rgba(56, 189, 248, 0.6);
  border-radius: 8px;
  padding: 6px 14px;
  font-size: 12px;
  font-weight: 850;
  cursor: pointer;
  display: none;
  backdrop-filter: blur(10px);
  -webkit-backdrop-filter: blur(10px);
  box-shadow: 0 4px 14px rgba(0, 0, 0, 0.5), 0 0 10px rgba(56, 189, 248, 0.25);
  transition: all 0.15s ease;
}
.cq-minimize-btn:hover {
  background: rgba(30, 41, 59, 0.95);
  color: #fff;
  border-color: #38bdf8;
  box-shadow: 0 0 16px rgba(56, 189, 248, 0.5);
}
/* 확대 중 축소 버튼은 루트 「축소」(#crazyQuokkaMinimizeBtn) 하나다(framework §18.3, 2026-09-29).
   로비·로딩·선택·HUD 안의 ⛶/⤢ 토글은 확대 중에 숨긴다. JS(ensureMinimizeBtn)가 그 버튼을 흐름 배치 자리 —
   경기 화면은 HUD 오른쪽 칸, 로비·로딩·선택은 제목 줄 버튼 묶음 — 에 넣는다. 예전에는 루트 절대 배치라
   경기 화면에서 시계(「3:」만 보임)·모드 표시·HUD ⤢ 버튼을 덮었다. HUD에서는 줄 높이에 맞춘 작은 크기로 둔다. */
#crazyQuokkaRoot.cq-fullscreen .cq-fullscreen-btn { display: none; }
.cq-title-actions .cq-minimize-btn {
  position: static;
  min-height: 31px;
  padding: 6px 12px;
  border-radius: 9px;
  font-size: 11.5px;
  font-weight: 750;
  box-shadow: none;
}
.cq-hud .cq-minimize-btn {
  position: static;
  flex: 0 0 auto;
  padding: 3px 10px;
  border-radius: 7px;
  font-size: 11px;
  line-height: 1.2;
}
/* fitHud()가 HUD 한 줄의 제 폭(max-content)을 잴 때만 붙는다(framework §18.6). */
.cq-hud.cq-hud-measure { width: max-content; }

#crazyQuokkaExtFsBtn {
  background: rgba(14, 165, 233, 0.2);
  color: #7dd3fc;
  border: 1px solid rgba(56, 189, 248, 0.5);
  padding: 8px 16px;
  border-radius: 10px;
  font-weight: 800;
  margin-top: 5px;
  cursor: pointer;
  display: none;
  transition: background 0.2s, border-color 0.2s;
}
#crazyQuokkaExtFsBtn:hover {
  background: rgba(14, 165, 233, 0.35);
  border-color: #38bdf8;
}

.cq-mobile-controls { display: none; }

/* ── 컨테이너 반응형 (Container Queries) ── */
@container (max-width: 760px) {
  .cq-panel { max-height: calc(100% - 10px); padding: 10px; }
  .cq-title-row { margin-bottom: 7px; }
  .cq-title-row h2 { font-size: 20px; }
  .cq-lobby-panel { width: calc(100% - 10px); }
  .cq-lobby-settings { min-height: 34px; margin-bottom: 6px; padding: 4px 6px; flex-wrap: wrap; }
  .cq-map-row { margin-left: 0; }
  .cq-setting-group { margin-left: 0; }
  .cq-map-select { max-width: 170px; }
  .cq-info-content { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .cq-player-card { min-height: 42px; }
  .cq-character-grid { max-width: min(100%, 420px); gap: 6px; }
  .cq-character-sprite { width: min(68%, 82px); }
  .cq-hud { grid-template-columns: minmax(0, 1fr) auto auto; min-height: 26px; padding: 3px 6px; }
  .cq-hud-right .cq-hud-chip { display: none; }
  .cq-hud-left { gap: 3px; }
  .cq-hud-chip { padding: 2px 4px; font-size: 8px; }
  .cq-clock { font-size: clamp(12px, 3.5cqw, 16px); }
}

@container (max-height: 420px) {
  .cq-panel { max-height: calc(100% - 6px); padding: 6px; }
  .cq-title-row { margin-bottom: 4px; }
  .cq-title-row h2 { font-size: 17px; }
  .cq-subtitle { font-size: 9px; }
  .cq-lobby-settings { min-height: 28px; margin-bottom: 4px; padding: 3px 5px; }
  .cq-map-select { min-height: 25px; padding: 3px 18px 3px 5px; font-size: 10px; }
  .cq-info-panel { min-height: 96px; margin-bottom: 4px; padding: 5px; }
  .cq-info-tabs { margin-bottom: 4px; }
  .cq-info-tab { min-height: 23px; padding: 3px 8px; font-size: 9px; }
  .cq-info-content { gap: 3px; }
  .cq-info-card { grid-template-columns: 34px minmax(0, 1fr); min-height: 37px; gap: 4px; padding: 2px 4px; }
  .cq-info-item-icon { width: 34px; height: 34px; }
  .cq-info-character-sprite { width: 34px; height: 34px; }
  .cq-info-map-card { grid-template-columns: 46px minmax(0, 1fr); }
  .cq-info-map-thumb { width: 46px; height: 34px; }
  .cq-info-copy strong { font-size: 9px; }
  .cq-info-copy p, .cq-info-copy small { margin-top: 1px; font-size: 8px; line-height: 1.15; }
  .cq-load-total { min-height: 22px; margin-bottom: 4px; padding: 3px 6px; gap: 5px; }
  .cq-load-total-label { font-size: 9px; }
  .cq-load-list { gap: 3px; grid-template-columns: repeat(auto-fit, minmax(200px, 1fr)); }
  .cq-load-row { min-height: 22px; padding: 2px 6px; gap: 5px; border-radius: 7px; }
  .cq-load-name { font-size: 9.5px; }
  .cq-load-value { min-width: 32px; font-size: 9px; }
  .cq-load-bar { height: 5px; }
  .cq-load-bar-total { height: 7px; }
  .cq-player-card { min-height: 34px; padding: 3px 6px; }
  .cq-player-avatar { width: 25px; height: 25px; }
  .cq-player-name, .cq-ready, .cq-waiting { font-size: 10px; }
  .cq-character-grid { gap: 3px; }
  .cq-character-card { padding: 3px; border-radius: 8px; }
  .cq-character-sprite { width: min(62%, 60px); margin: -2px auto -4px; }
  .cq-character-name { font-size: 10px; }
  .cq-character-skill { display: none; }
  .cq-select-footer { min-height: 19px; margin-top: 3px; }
  .cq-select-help { font-size: 9px; }
  .cq-btn { min-height: 27px; padding: 4px 7px; font-size: 10px; }
}

/* ── 모바일 터치 및 좁은 화면 (Mobile Touch Controls) ── */
@media (pointer: coarse), (max-width: 760px) {
  #crazyQuokkaRoot { padding: 0; }
  .cq-panel, .cq-game-shell { width: 100%; max-height: 100%; border-radius: 0; }
  .cq-panel { min-height: 0; padding: 12px; }
  .cq-character-grid { grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 6px; }
  .cq-character-card { padding: 6px; }
  .cq-character-sprite { height: auto; }
  .cq-hud { grid-template-columns: minmax(0, 1fr) auto auto; padding: 3px 6px; min-height: 24px; }
  .cq-hud-right .cq-hud-chip { display: none; }
  .cq-stage-wrap { padding-bottom: clamp(120px, 25vh, 150px); }
  .cq-chat-input { bottom: 155px; }

  /* 가상패드 */
  .cq-mobile-controls {
    position: absolute;
    inset: auto 0 0;
    z-index: 10;
    display: flex;
    justify-content: space-between;
    align-items: flex-end;
    padding: 8px 12px 12px;
    pointer-events: none;
    touch-action: none;
    user-select: none;
    -webkit-user-select: none;
    -webkit-touch-callout: none;   /* 길게 누르기 복사·저장 메뉴(iOS) */
    -webkit-tap-highlight-color: transparent;
  }

  /* 확대(전체화면) + 터치: 브라우저 주소창/제스처 바에 물풍선·액션 버튼이 잘리지 않게 패드를 올린다. */
  #crazyQuokkaRoot.cq-fullscreen .cq-mobile-controls {
    padding-bottom: calc(44px + env(safe-area-inset-bottom, 0px));
  }
  #crazyQuokkaRoot.cq-fullscreen .cq-stage-wrap {
    padding-bottom: clamp(164px, 28vh, 194px);
  }
  #crazyQuokkaRoot.cq-fullscreen .cq-chat-input {
    bottom: calc(187px + env(safe-area-inset-bottom, 0px));
  }

  /* 왼쪽: 아날로그 조이스틱 */
  .cq-joystick-wrap {
    position: relative;
    width: 124px;
    height: 124px;
    pointer-events: auto;
    touch-action: none;
    display: flex;
    align-items: center;
    justify-content: center;
  }
  .cq-joystick-base {
    position: relative;
    width: 114px;
    height: 114px;
    border-radius: 50%;
    background: radial-gradient(circle, rgba(20, 30, 55, 0.78) 0%, rgba(10, 16, 32, 0.94) 100%);
    border: 2px solid rgba(56, 189, 248, 0.35);
    box-shadow: 0 4px 18px rgba(0, 0, 0, 0.6), inset 0 0 14px rgba(56, 189, 248, 0.15);
    display: flex;
    align-items: center;
    justify-content: center;
    touch-action: none;
    transition: border-color 0.15s, box-shadow 0.15s;
  }
  .cq-joystick-base.cq-active {
    border-color: rgba(56, 189, 248, 0.85);
    box-shadow: 0 4px 22px rgba(0, 0, 0, 0.7), 0 0 18px rgba(56, 189, 248, 0.4), inset 0 0 18px rgba(56, 189, 248, 0.28);
  }
  .cq-joy-dir {
    position: absolute;
    color: rgba(255, 255, 255, 0.35);
    font-size: 11px;
    font-weight: 900;
    pointer-events: auto;
    cursor: pointer;
    touch-action: none;
    transition: color 0.1s, transform 0.1s;
    user-select: none;
    -webkit-user-select: none;
    padding: 4px;
  }
  .cq-joy-dir.cq-dir-up { top: 4px; left: 50%; transform: translateX(-50%); }
  .cq-joy-dir.cq-dir-left { left: 6px; top: 50%; transform: translateY(-50%); }
  .cq-joy-dir.cq-dir-right { right: 6px; top: 50%; transform: translateY(-50%); }
  .cq-joy-dir.cq-dir-down { bottom: 4px; left: 50%; transform: translateX(-50%); }

  .cq-joy-dir.cq-dir-active {
    color: #38bdf8;
    text-shadow: 0 0 10px rgba(56, 189, 248, 0.95);
    transform: scale(1.3) translateX(-50%);
  }
  .cq-joy-dir.cq-dir-left.cq-dir-active,
  .cq-joy-dir.cq-dir-right.cq-dir-active {
    transform: scale(1.3) translateY(-50%);
  }

  .cq-joystick-knob {
    position: absolute;
    width: 48px;
    height: 48px;
    border-radius: 50%;
    background: radial-gradient(circle at 35% 35%, #334155 0%, #0f172a 100%);
    border: 2px solid rgba(255, 255, 255, 0.5);
    box-shadow: 0 4px 14px rgba(0, 0, 0, 0.65), inset 0 2px 4px rgba(255, 255, 255, 0.25);
    display: flex;
    align-items: center;
    justify-content: center;
    pointer-events: none;
    will-change: transform;
    transform: translate3d(0, 0, 0);
    transition: transform 0.08s cubic-bezier(0.1, 0.9, 0.2, 1);
  }
  .cq-joystick-base.cq-active .cq-joystick-knob {
    border-color: #38bdf8;
    box-shadow: 0 4px 16px rgba(0, 0, 0, 0.75), 0 0 14px rgba(56, 189, 248, 0.65);
    transition: none;
  }
  .cq-knob-core {
    width: 18px;
    height: 18px;
    border-radius: 50%;
    background: radial-gradient(circle, rgba(56, 189, 248, 0.85) 0%, rgba(14, 165, 233, 0.5) 100%);
    box-shadow: inset 0 1px 2px rgba(255, 255, 255, 0.45);
  }

  /* 오른쪽: 액션 버튼 클러스터 */
  .cq-mobile-actions {
    position: relative;
    width: 165px;
    height: 130px;
    pointer-events: auto;
    display: grid;
    grid-template-columns: 46px 46px 56px;
    grid-template-rows: 46px 56px;
    gap: 7px;
    align-items: center;
    justify-content: end;
  }

  .cq-touch-btn {
    position: relative;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    border-radius: 50%;
    color: #fff;
    font-family: inherit;
    font-weight: 800;
    text-align: center;
    touch-action: none;
    user-select: none;
    -webkit-user-select: none;
    cursor: pointer;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.5), inset 0 1px 2px rgba(255, 255, 255, 0.25);
    transition: transform 0.08s, box-shadow 0.08s, filter 0.08s;
    -webkit-tap-highlight-color: transparent;
  }
  .cq-touch-btn:active, .cq-touch-btn.cq-touch-active {
    transform: scale(0.90);
    filter: brightness(1.3);
  }

  /* 1. 소모품 버튼 (Item / C) */
  .cq-touch-item {
    grid-column: 1;
    grid-row: 1;
    width: 46px;
    height: 46px;
    background: radial-gradient(circle at 35% 35%, #f97316, #9a3412);
    border: 2px solid rgba(254, 215, 170, 0.6);
  }
  .cq-touch-item:active, .cq-touch-item.cq-touch-active {
    box-shadow: 0 0 16px rgba(249, 115, 22, 0.9);
  }

  /* 2. 스킬 버튼 (Skill / X) */
  .cq-touch-skill {
    grid-column: 2;
    grid-row: 1;
    width: 46px;
    height: 46px;
    background: radial-gradient(circle at 35% 35%, #a855f7, #6b21a8);
    border: 2px solid rgba(233, 213, 255, 0.6);
  }
  .cq-touch-skill:active, .cq-touch-skill.cq-touch-active {
    box-shadow: 0 0 16px rgba(168, 85, 247, 0.9);
  }
  .cq-touch-skill.cq-cooldown {
    filter: grayscale(0.7) opacity(0.65);
  }
  .cq-touch-skill-cd {
    position: absolute;
    inset: 0;
    border-radius: 50%;
    background: rgba(0, 0, 0, 0.68);
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 13px;
    font-weight: 950;
    color: #facc15;
  }

  /* 3. 능력/탈것 액션 버튼 (Action / Z) */
  .cq-touch-action {
    grid-column: 2;
    grid-row: 2;
    width: 48px;
    height: 48px;
    background: radial-gradient(circle at 35% 35%, #14b8a6, #0f766e);
    border: 2px solid rgba(153, 246, 228, 0.6);
  }
  .cq-touch-action:active, .cq-touch-action.cq-touch-active {
    box-shadow: 0 0 16px rgba(20, 184, 166, 0.9);
  }

  /* 4. 물풍선 버튼 (Bomb / Space) */
  .cq-touch-bomb {
    grid-column: 3;
    grid-row: 2;
    width: 58px;
    height: 58px;
    background: radial-gradient(circle at 35% 35%, #0284c7, #0369a1);
    border: 2.5px solid rgba(186, 230, 253, 0.85);
    box-shadow: 0 4px 16px rgba(0, 0, 0, 0.6), 0 0 14px rgba(14, 165, 233, 0.45);
  }
  .cq-touch-bomb:active, .cq-touch-bomb.cq-touch-active {
    box-shadow: 0 0 22px rgba(56, 189, 248, 1);
  }

  .cq-touch-icon { font-size: 18px; line-height: 1; }
  .cq-touch-bomb .cq-touch-icon { font-size: 24px; }
  .cq-touch-label {
    font-size: 8.5px;
    font-weight: 850;
    letter-spacing: -0.02em;
    margin-top: 1px;
    opacity: 0.95;
    text-shadow: 0 1px 2px rgba(0, 0, 0, 0.85);
    white-space: nowrap;
  }
  .cq-touch-key {
    position: absolute;
    top: -4px;
    right: -4px;
    font-size: 8px;
    font-weight: 950;
    padding: 1px 4px;
    border-radius: 4px;
    background: rgba(10, 16, 30, 0.85);
    border: 1px solid rgba(255, 255, 255, 0.35);
    color: #facc15;
    pointer-events: none;
  }
}

@media (pointer: coarse) and (orientation: landscape) and (max-height: 500px), (max-height: 500px) and (max-width: 900px) {
  .cq-hud { min-height: 20px; padding: 1px 5px; }
  .cq-clock { font-size: 11px; }
  .cq-stage-wrap { padding-bottom: 90px; }
  .cq-mobile-controls { padding: 4px 10px 8px; }
  .cq-joystick-wrap { width: 100px; height: 100px; }
  .cq-joystick-base { width: 92px; height: 92px; }
  .cq-joystick-knob { width: 40px; height: 40px; }
  .cq-knob-core { width: 15px; height: 15px; }
  .cq-mobile-actions { width: 140px; height: 100px; gap: 5px; grid-template-columns: 38px 38px 46px; grid-template-rows: 38px 46px; }
  .cq-touch-item, .cq-touch-skill { width: 38px; height: 38px; }
  .cq-touch-action { width: 40px; height: 40px; }
  .cq-touch-bomb { width: 46px; height: 46px; }
  .cq-touch-icon { font-size: 15px; }
  .cq-touch-bomb .cq-touch-icon { font-size: 19px; }
  .cq-touch-label { font-size: 7.5px; }
  .cq-chat-input { bottom: 98px; }

  /* 가로·저높이에서는 세로 공간이 부족하므로 확대 전용 여백을 세로 모드보다 작게 다시 지정한다.
     (위 세로 블록의 #crazyQuokkaRoot.cq-fullscreen 규칙이 더 구체적이라 재선언이 필요하다.) */
  #crazyQuokkaRoot.cq-fullscreen .cq-mobile-controls {
    padding-bottom: calc(14px + env(safe-area-inset-bottom, 0px));
  }
  #crazyQuokkaRoot.cq-fullscreen .cq-stage-wrap {
    padding-bottom: 100px;
  }
  #crazyQuokkaRoot.cq-fullscreen .cq-chat-input {
    bottom: calc(104px + env(safe-area-inset-bottom, 0px));
  }
}

/* ── 관전자 뷰 (Spectator View): 가상패드 제거 및 무대 전체 확장 ── */
.cq-stage-wrap.cq-spectator-view {
  padding-bottom: 0 !important;
}
.cq-stage-wrap.cq-spectator-view .cq-mobile-controls {
  display: none !important;
}

/* ── 모바일 환경 비확대 상태 (Mobile Non-Fullscreen Embedded View: 모바일 영상 영역 내 최적화) ── */
@media (max-width: 768px), (pointer: coarse) {
  /* 0. 상단 HUD 바: 절반 크기로 초슬림화하여 캔버스(맵) 시야 대폭 확장 */
  #crazyQuokkaRoot:not(.cq-fullscreen) .cq-hud {
    min-height: 15px !important;
    padding: 1px 6px !important;
    gap: 4px !important;
  }
  #crazyQuokkaRoot:not(.cq-fullscreen) .cq-clock {
    font-size: 10px !important;
    letter-spacing: 0.02em !important;
    line-height: 1 !important;
  }
  #crazyQuokkaRoot:not(.cq-fullscreen) .cq-round-info {
    font-size: 7px !important;
    gap: 2px !important;
  }
  #crazyQuokkaRoot:not(.cq-fullscreen) .cq-round-badge {
    padding: 0 3px !important;
    font-size: 6.5px !important;
    border-radius: 3px !important;
  }
  #crazyQuokkaRoot:not(.cq-fullscreen) .cq-hud-chip {
    padding: 1px 4px !important;
    font-size: 7px !important;
    border-radius: 4px !important;
  }
  #crazyQuokkaRoot:not(.cq-fullscreen) .cq-fullscreen-btn {
    min-width: 16px !important;
    height: 16px !important;
    padding: 1px 3px !important;
    font-size: 8px !important;
    border-radius: 4px !important;
  }
  /* 비확대 모바일 로비에서도 확대·설명 버튼 크기를 같게 둔다. */
  #crazyQuokkaRoot:not(.cq-fullscreen) .cq-title-actions .cq-btn {
    min-width: 0 !important;
    height: auto !important;
    min-height: 22px !important;
    padding: 2px 8px !important;
    font-size: 10px !important;
    border-radius: 6px !important;
  }

  /* 1. 게임 화면: 하단 패딩을 없애 캔버스가 영상 영역 전체에 크게 나오도록 보장 */
  #crazyQuokkaRoot:not(.cq-fullscreen) .cq-stage-wrap {
    padding-bottom: 0 !important;
  }

  /* 2. 가상패드: 비확대 상태에서는 캔버스를 가리지 않도록 컴팩트 오버레이 */
  #crazyQuokkaRoot:not(.cq-fullscreen) .cq-mobile-controls {
    padding: 4px 8px 6px;
    opacity: 0.85;
  }

  #crazyQuokkaRoot:not(.cq-fullscreen) .cq-joystick-wrap {
    width: 76px;
    height: 76px;
  }

  #crazyQuokkaRoot:not(.cq-fullscreen) .cq-joystick-base {
    width: 70px;
    height: 70px;
    background: radial-gradient(circle, rgba(20, 30, 55, 0.68) 0%, rgba(10, 16, 32, 0.9) 100%);
    border-width: 1.5px;
  }

  #crazyQuokkaRoot:not(.cq-fullscreen) .cq-joystick-knob {
    width: 30px;
    height: 30px;
    border-width: 1.5px;
  }

  #crazyQuokkaRoot:not(.cq-fullscreen) .cq-knob-core {
    width: 12px;
    height: 12px;
  }

  #crazyQuokkaRoot:not(.cq-fullscreen) .cq-joy-dir {
    font-size: 8px;
    padding: 2px;
  }

  #crazyQuokkaRoot:not(.cq-fullscreen) .cq-mobile-actions {
    width: 112px;
    height: 82px;
    gap: 4px;
    grid-template-columns: 32px 32px 42px;
    grid-template-rows: 32px 42px;
  }

  #crazyQuokkaRoot:not(.cq-fullscreen) .cq-touch-item,
  #crazyQuokkaRoot:not(.cq-fullscreen) .cq-touch-skill {
    width: 32px;
    height: 32px;
    border-width: 1.5px;
  }

  #crazyQuokkaRoot:not(.cq-fullscreen) .cq-touch-action {
    width: 34px;
    height: 34px;
    border-width: 1.5px;
  }

  #crazyQuokkaRoot:not(.cq-fullscreen) .cq-touch-bomb {
    width: 42px;
    height: 42px;
    border-width: 2px;
  }

  #crazyQuokkaRoot:not(.cq-fullscreen) .cq-touch-icon {
    font-size: 13px;
  }

  #crazyQuokkaRoot:not(.cq-fullscreen) .cq-touch-bomb .cq-touch-icon {
    font-size: 17px;
  }

  #crazyQuokkaRoot:not(.cq-fullscreen) .cq-touch-label {
    font-size: 7px;
    margin-top: 0;
  }

  #crazyQuokkaRoot:not(.cq-fullscreen) .cq-touch-key {
    display: none;
  }

  #crazyQuokkaRoot:not(.cq-fullscreen) .cq-chat-input {
    bottom: 88px;
  }

  /* 3. 로비 화면: 비확대 영상 영역에서도 참가 버튼이 절대 잘리지 않도록 정돈 */
  #crazyQuokkaRoot:not(.cq-fullscreen) .cq-lobby-panel {
    width: 100% !important;
    height: 100% !important;
    max-height: 100% !important;
    padding: 6px 10px !important;
    border-radius: 0 !important;
  }

  #crazyQuokkaRoot:not(.cq-fullscreen) .cq-panel {
    overflow-y: auto !important;
  }

  /* 3-1. 로딩 게이트: 낮은 세로 영상 영역(약 360×203)에서도 6명이 잘리지 않게 압축한다 */
  #crazyQuokkaRoot:not(.cq-fullscreen) .cq-loading-panel {
    width: 100% !important;
    height: 100% !important;
    max-height: 100% !important;
    padding: 6px 10px !important;
    border-radius: 0 !important;
    overflow: hidden !important;
  }

  #crazyQuokkaRoot:not(.cq-fullscreen) .cq-load-total {
    min-height: 20px !important;
    margin-bottom: 3px !important;
    padding: 2px 6px !important;
    gap: 5px !important;
  }

  #crazyQuokkaRoot:not(.cq-fullscreen) .cq-load-total-label {
    font-size: 8.5px !important;
  }

  #crazyQuokkaRoot:not(.cq-fullscreen) .cq-load-list {
    gap: 3px !important;
    grid-template-columns: repeat(auto-fit, minmax(150px, 1fr)) !important;
  }

  #crazyQuokkaRoot:not(.cq-fullscreen) .cq-load-row {
    min-height: 19px !important;
    padding: 1px 5px !important;
    gap: 5px !important;
    border-radius: 6px !important;
  }

  #crazyQuokkaRoot:not(.cq-fullscreen) .cq-load-name {
    font-size: 9px !important;
    line-height: 1.1 !important;
  }

  #crazyQuokkaRoot:not(.cq-fullscreen) .cq-load-name .cq-me {
    margin-left: 2px !important;
    padding: 0 2px !important;
    font-size: 8px !important;
  }

  #crazyQuokkaRoot:not(.cq-fullscreen) .cq-load-value {
    min-width: 28px !important;
    font-size: 8.5px !important;
  }

  #crazyQuokkaRoot:not(.cq-fullscreen) .cq-load-bar { height: 4px !important; }
  #crazyQuokkaRoot:not(.cq-fullscreen) .cq-load-bar-total { height: 6px !important; }

  #crazyQuokkaRoot:not(.cq-fullscreen) .cq-title-row {
    margin-bottom: 3px !important;
  }

  #crazyQuokkaRoot:not(.cq-fullscreen) .cq-title-row h2 {
    font-size: 15px !important;
  }

  #crazyQuokkaRoot:not(.cq-fullscreen) .cq-subtitle {
    font-size: 9px !important;
    margin-top: 1px !important;
  }

  #crazyQuokkaRoot:not(.cq-fullscreen) .cq-lobby-settings {
    min-height: 24px !important;
    margin-bottom: 4px !important;
    padding: 2px 6px !important;
    gap: 4px !important;
  }

  #crazyQuokkaRoot:not(.cq-fullscreen) .cq-setting-label {
    font-size: 9px !important;
  }

  #crazyQuokkaRoot:not(.cq-fullscreen) .cq-lobby-settings .cq-btn {
    min-height: 22px !important;
    padding: 2px 7px !important;
    font-size: 10px !important;
  }

  #crazyQuokkaRoot:not(.cq-fullscreen) .cq-map-select {
    min-height: 22px !important;
    padding: 2px 18px 2px 6px !important;
    font-size: 10px !important;
    max-width: 130px !important;
  }

  #crazyQuokkaRoot:not(.cq-fullscreen) .cq-player-heading {
    margin: 0 2px 3px !important;
    font-size: 10px !important;
  }

  #crazyQuokkaRoot:not(.cq-fullscreen) .cq-player-card {
    min-height: 28px !important;
    padding: 2px 6px !important;
    gap: 6px !important;
    border-radius: 8px !important;
  }

  #crazyQuokkaRoot:not(.cq-fullscreen) .cq-player-avatar {
    width: 22px !important;
    height: 22px !important;
  }

  #crazyQuokkaRoot:not(.cq-fullscreen) .cq-player-name,
  #crazyQuokkaRoot:not(.cq-fullscreen) .cq-ready,
  #crazyQuokkaRoot:not(.cq-fullscreen) .cq-waiting,
  #crazyQuokkaRoot:not(.cq-fullscreen) .cq-bot-tag {
    font-size: 10px !important;
  }

  #crazyQuokkaRoot:not(.cq-fullscreen) .cq-bot-btn {
    min-width: 18px !important;
    min-height: 18px !important;
    font-size: 9.5px !important;
  }

  #crazyQuokkaRoot:not(.cq-fullscreen) .cq-lobby-footer {
    margin-top: auto !important;
    padding-top: 4px !important;
    gap: 6px !important;
  }

  #crazyQuokkaRoot:not(.cq-fullscreen) .cq-lobby-help {
    display: none !important;
  }

  #crazyQuokkaRoot:not(.cq-fullscreen) .cq-lobby-footer .cq-btn {
    min-height: 28px !important;
    padding: 4px 14px !important;
    font-size: 12px !important;
    font-weight: 850 !important;
  }
}

/* 개인전 다판 순위 점수 */
.cq-score-mine { color: #fde047; font-weight: 950; }
.cq-score-top { color: #e2e8f0; font-weight: 900; }
.cq-points { list-style: none; margin: 4px auto 14px; padding: 0; display: grid; gap: 4px; max-width: 320px; text-align: left; }
.cq-points li { display: grid; grid-template-columns: 40px 1fr auto; align-items: center; gap: 8px; padding: 4px 10px; border-radius: 8px; background: rgba(255, 255, 255, 0.06); font-size: 13px; font-weight: 850; }
.cq-points li.cq-points-top { background: rgba(250, 204, 21, 0.16); color: var(--cq-yellow); }
.cq-points li.cq-points-me .cq-points-name { color: #fde047; }
.cq-points-rank { opacity: 0.8; }
.cq-points-name { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.cq-points-value { font-variant-numeric: tabular-nums; }
@media (max-height: 460px) {
  .cq-points { gap: 2px; margin: 2px auto 8px; }
  .cq-points li { padding: 2px 8px; font-size: 11px; }
}
