/* =========================================================
   모임 게임 진행 도구 — 공통 스타일
   디자인 토큰 + 공통 컴포넌트 (밝은 톤 + 파스텔)
   ※ 빌드 도구/외부 CSS 프레임워크 없이 단독 동작 (오프라인 우선)
   ========================================================= */

:root {
  /* 배경 */
  --bg-base: #FFF9F4;        /* 크림 (전체 배경) */
  --bg-card: #FFFFFF;        /* 카드 */
  --bg-soft: #FFF1E6;        /* 부드러운 강조 영역 */

  /* 텍스트 */
  --text-primary: #3D3D3D;
  --text-secondary: #7A7A7A;
  --text-muted: #B5B5B5;

  /* 포인트 컬러 (파스텔) */
  --accent-coral: #FFB5A7;
  --accent-mint: #B5EAD7;
  --accent-lemon: #FFE5B4;
  --accent-lavender: #C7CEEA;
  --accent-peach: #FFDAC1;
  --accent-pink: #FFB7CE;

  /* 팀 컬러 (최대 6팀) */
  --team-1: #FFB5A7;  /* 코랄 */
  --team-2: #B5EAD7;  /* 민트 */
  --team-3: #FFE5B4;  /* 레몬 */
  --team-4: #C7CEEA;  /* 라벤더 */
  --team-5: #FFB7CE;  /* 핑크 */
  --team-6: #B5D8FF;  /* 스카이 */

  /* 보더/구분선 */
  --border-soft: #F0E6DC;
  --border-medium: #E0D5C9;

  /* 그림자 (소프트) */
  --shadow-card: 0 4px 16px rgba(80, 60, 40, 0.08);
  --shadow-pop: 0 8px 32px rgba(80, 60, 40, 0.14);

  /* 전환 */
  --ease: cubic-bezier(0.4, 0, 0.2, 1);
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  padding: 0;
  height: 100%;
}

body {
  background: #000;            /* 무대 바깥 레터박스 */
  overflow: hidden;
  font-family: "Pretendard Variable", Pretendard, -apple-system, BlinkMacSystemFont,
    "Apple SD Gothic Neo", "Malgun Gothic", "맑은 고딕", system-ui, sans-serif;
  color: var(--text-primary);
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
}

/* =========================================================
   16:9 무대 (1920×1080 기준, JS로 scale)
   ========================================================= */
.stage {
  position: fixed;
  left: 50%;
  top: 50%;
  width: 1920px;
  height: 1080px;
  transform: translate(-50%, -50%) scale(var(--scale, 1));
  transform-origin: center center;
  background: var(--bg-base);
  overflow: hidden;
  display: flex;
  flex-direction: column;
}

/* 무대 내부 안전 여백 */
.stage-pad {
  flex: 1;
  display: flex;
  flex-direction: column;
  padding: 64px 88px;
  min-height: 0;
}

/* =========================================================
   화면 전환 (rule → play → result 등)
   ========================================================= */
/* 비활성 화면 숨김. :not(.active)는 .col/.row(display:flex) 유틸리티보다
   명시도가 높아야 하므로 단일 .screen 대신 :not(.active)로 지정. */
.screen { flex: 1; min-height: 0; flex-direction: column; }
.screen:not(.active) { display: none !important; }
.screen.active { display: flex; animation: fadeIn 0.35s var(--ease); }

@keyframes fadeIn {
  from { opacity: 0; transform: translateY(12px); }
  to   { opacity: 1; transform: translateY(0); }
}

/* =========================================================
   타이포 헬퍼 (1920px 기준)
   ========================================================= */
.t-hero    { font-size: 120px; font-weight: 800; line-height: 1.1; }
.t-title   { font-size: 72px;  font-weight: 800; line-height: 1.15; }
.t-card    { font-size: 48px;  font-weight: 700; }
.t-handle  { font-size: 36px;  font-weight: 600; }
.t-body    { font-size: 32px;  font-weight: 400; line-height: 1.5; }
.t-sub     { font-size: 28px;  font-weight: 400; color: var(--text-secondary); }
.t-mega    { font-size: 220px; font-weight: 800; line-height: 1; }
.t-question{ font-size: 200px; font-weight: 700; line-height: 1.1; }

.text-secondary { color: var(--text-secondary); }
.text-muted { color: var(--text-muted); }
.center { text-align: center; }
.fill { flex: 1; min-height: 0; }
.col { display: flex; flex-direction: column; }
.row { display: flex; flex-direction: row; }
.center-all { display: flex; align-items: center; justify-content: center; }
.gap-sm { gap: 16px; } .gap-md { gap: 28px; } .gap-lg { gap: 48px; }
.between { justify-content: space-between; }
.items-center { align-items: center; }
.justify-center { justify-content: center; }
.wrap { flex-wrap: wrap; }
.mt-auto { margin-top: auto; }

/* =========================================================
   카드
   ========================================================= */
.card {
  background: var(--bg-card);
  border: 2px solid var(--border-soft);
  border-radius: 24px;
  box-shadow: var(--shadow-card);
  padding: 40px;
  transition: transform 0.25s var(--ease), box-shadow 0.25s var(--ease);
}
.card-hover { cursor: pointer; }
.card-hover:hover {
  transform: translateY(-8px);
  box-shadow: var(--shadow-pop);
}
.card.completed { opacity: 0.62; }

/* =========================================================
   버튼 (필 형태, 큼직하게)
   ========================================================= */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 14px;
  min-height: 80px;
  padding: 0 44px;
  border: none;
  border-radius: 100px;
  background: var(--bg-soft);
  color: var(--text-primary);
  font-family: inherit;
  font-size: 36px;
  font-weight: 600;
  cursor: pointer;
  box-shadow: var(--shadow-card);
  transition: transform 0.18s var(--ease), box-shadow 0.18s var(--ease), filter 0.18s var(--ease);
  user-select: none;
  white-space: nowrap;
  text-decoration: none;
}
.btn:hover { transform: translateY(-3px); box-shadow: var(--shadow-pop); }
.btn:active { transform: translateY(0) scale(0.98); }
.btn:disabled { opacity: 0.4; cursor: not-allowed; transform: none; box-shadow: none; }

.btn-primary  { background: var(--accent-coral); }
.btn-mint     { background: var(--accent-mint); }
.btn-lemon    { background: var(--accent-lemon); }
.btn-lavender { background: var(--accent-lavender); }
.btn-ghost    { background: rgba(255,255,255,0.7); border: 2px solid var(--border-medium); box-shadow: none; }
.btn-lg  { min-height: 110px; font-size: 48px; padding: 0 64px; }
.btn-xl  { min-height: 150px; font-size: 64px; padding: 0 80px; }
.btn-sm  { min-height: 56px; font-size: 26px; padding: 0 28px; }
.btn-block { width: 100%; }

/* =========================================================
   메뉴로(홈) 버튼 — nav.js가 주입
   ========================================================= */
.home-btn {
  position: absolute;
  top: 32px;
  right: 40px;
  z-index: 40;
  min-height: 58px;
  padding: 0 26px;
  font-size: 26px;
  font-weight: 600;
  border: none;
  border-radius: 100px;
  background: rgba(255, 255, 255, 0.7);
  color: var(--text-secondary);
  backdrop-filter: blur(6px);
  cursor: pointer;
  box-shadow: var(--shadow-card);
  transition: background 0.2s var(--ease), color 0.2s var(--ease);
}
.home-btn:hover { background: #fff; color: var(--text-primary); }

/* 게임 상단 헤더: 우측 컨트롤이 우상단 홈 버튼과 겹치지 않도록 여백 확보 */
.game-bar { padding-right: 200px; }

/* 결과 점수 목록: 최대 6팀까지 한 화면(1080px)에 들어가도록 컴팩트하게 */
.result-list { gap: 14px; width: 100%; align-items: center; }
.result-list .card { padding: 16px 40px; }
.result-list .t-card { font-size: 40px; }

/* =========================================================
   팀 채점 바 (ui.mountTeamScoring)
   ========================================================= */
.team-bar { display: flex; gap: 20px; flex-wrap: wrap; justify-content: center; }
.team-btn {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 6px;
  min-width: 200px;
  max-width: 360px;
  min-height: 110px;
  padding: 16px 26px;
  border: 3px solid rgba(0,0,0,0.06);
  border-radius: 28px;
  background: var(--team-color, var(--accent-coral));
  color: #3D3D3D;
  font-family: inherit;
  cursor: pointer;
  box-shadow: var(--shadow-card);
  transition: transform 0.18s var(--ease), box-shadow 0.18s var(--ease);
}
.team-btn:hover { transform: translateY(-4px); box-shadow: var(--shadow-pop); }
.team-btn:active { transform: scale(0.97); }
/* 긴 팀명도 줄바꿈되어 버튼 밖으로 넘치지 않도록 */
.team-btn .team-name {
  font-size: 36px; font-weight: 700; line-height: 1.2; text-align: center;
  word-break: keep-all; overflow-wrap: anywhere;
}
.team-btn .team-pts { font-size: 26px; font-weight: 600; opacity: 0.7; }

/* 점수 +N 플로팅 피드백 */
.point-float {
  position: fixed;
  z-index: 80;
  font-size: 72px;
  font-weight: 800;
  color: var(--text-primary);
  pointer-events: none;
  text-shadow: 0 2px 8px rgba(255,255,255,0.8);
  animation: floatUp 1s var(--ease) forwards;
}
@keyframes floatUp {
  0%   { opacity: 0; transform: translate(-50%, 0) scale(0.6); }
  20%  { opacity: 1; transform: translate(-50%, -30px) scale(1.1); }
  100% { opacity: 0; transform: translate(-50%, -160px) scale(1); }
}

/* =========================================================
   타이머 (timer.js)
   ========================================================= */
.timer {
  font-variant-numeric: tabular-nums;
  font-feature-settings: "tnum";
  font-size: 160px;
  font-weight: 800;
  line-height: 1;
  color: var(--text-primary);
}
.timer.warn { color: #E8896B; }
.timer.danger { color: #D9534F; animation: pulse 0.6s var(--ease) infinite alternate; }
@keyframes pulse { from { transform: scale(1); } to { transform: scale(1.06); } }

/* =========================================================
   모달 / 오버레이 (ui.confirmDialog)
   ========================================================= */
.overlay {
  position: fixed;
  inset: 0;
  z-index: 100;
  display: flex;
  align-items: center;
  justify-content: center;
  background: rgba(255, 249, 244, 0.82);
  backdrop-filter: blur(8px);
  animation: fadeIn 0.2s var(--ease);
}
.modal {
  background: var(--bg-card);
  border-radius: 32px;
  box-shadow: var(--shadow-pop);
  padding: 64px 72px;
  max-width: 1100px;
  text-align: center;
  display: flex;
  flex-direction: column;
  gap: 40px;
  align-items: center;
}
.modal .modal-msg { font-size: 44px; font-weight: 600; line-height: 1.4; white-space: pre-line; }
.modal .modal-actions { display: flex; gap: 24px; }

/* 토스트 */
.toast {
  position: fixed;
  left: 50%;
  bottom: 80px;
  transform: translateX(-50%);
  z-index: 120;
  background: rgba(61,61,61,0.92);
  color: #fff;
  font-size: 30px;
  font-weight: 600;
  padding: 22px 44px;
  border-radius: 100px;
  box-shadow: var(--shadow-pop);
  animation: toastIn 0.25s var(--ease);
  pointer-events: none;   /* 알림은 클릭을 가로채지 않음 (아래 버튼 클릭 보장) */
}
@keyframes toastIn { from { opacity: 0; transform: translate(-50%, 20px); } to { opacity: 1; transform: translate(-50%, 0); } }

/* =========================================================
   진행 표시 / 뱃지 / 칩
   ========================================================= */
.badge {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 8px 22px;
  border-radius: 100px;
  background: var(--bg-soft);
  font-size: 26px;
  font-weight: 600;
  color: var(--text-secondary);
}
.badge-done { background: var(--accent-mint); color: #2E6B53; }
.chip {
  padding: 10px 26px;
  border-radius: 100px;
  background: var(--bg-soft);
  font-size: 28px;
  font-weight: 600;
}

.counter {
  font-variant-numeric: tabular-nums;
  font-size: 40px;
  font-weight: 700;
  color: var(--text-secondary);
}

/* 글자 수 칸 (이모티콘 퀴즈 힌트 등) */
.letter-boxes { display: flex; gap: 18px; justify-content: center; }
.letter-box {
  width: 84px; height: 100px;
  border-radius: 18px;
  background: var(--bg-soft);
  border: 3px solid var(--border-medium);
}

/* 입력 */
.field {
  font-family: inherit;
  font-size: 36px;
  padding: 18px 28px;
  border: 3px solid var(--border-medium);
  border-radius: 20px;
  background: #fff;
  color: var(--text-primary);
  outline: none;
  transition: border-color 0.2s var(--ease);
}
.field:focus { border-color: var(--accent-coral); }

/* 미디어/오디오 (audio.js) */
.audio-player { display: flex; flex-direction: column; gap: 32px; align-items: center; width: 100%; }
.rate-group { display: flex; gap: 16px; }
.rate-btn {
  min-width: 130px; min-height: 84px;
  border: 3px solid var(--border-medium);
  border-radius: 24px;
  background: #fff;
  font-family: inherit; font-size: 38px; font-weight: 700;
  color: var(--text-secondary);
  cursor: pointer;
  transition: all 0.18s var(--ease);
}
.rate-btn.active { background: var(--accent-lavender); color: var(--text-primary); border-color: transparent; }
.rate-btn:hover { transform: translateY(-3px); }

.seek {
  width: 100%;
  height: 28px;
  border-radius: 100px;
  background: var(--bg-soft);
  position: relative;
  cursor: pointer;
  overflow: hidden;
}
.seek-fill { position: absolute; left: 0; top: 0; bottom: 0; width: 0; background: var(--accent-coral); border-radius: 100px; }
.seek-time { display: flex; justify-content: space-between; width: 100%; font-size: 26px; color: var(--text-secondary); font-variant-numeric: tabular-nums; }

.play-btn {
  width: 200px; height: 200px;
  border-radius: 50%;
  border: none;
  background: var(--accent-coral);
  color: #fff;
  font-size: 88px;
  cursor: pointer;
  box-shadow: var(--shadow-pop);
  transition: transform 0.18s var(--ease);
  display: flex; align-items: center; justify-content: center;
}
.play-btn:hover { transform: scale(1.05); }

/* 컨페티 (reveal) */
.confetti {
  position: fixed;
  top: -60px;
  z-index: 90;
  font-size: 56px;
  pointer-events: none;
  animation: fall linear forwards;
}
@keyframes fall {
  to { transform: translateY(120vh) rotate(720deg); opacity: 0.9; }
}

/* 유틸 */
.hidden { display: none !important; }
.grid { display: grid; }
.grid-3 { grid-template-columns: repeat(3, 1fr); }
.grid-2 { grid-template-columns: repeat(2, 1fr); }
.grow { flex: 1; }
.relative { position: relative; }
.shadow-pop { box-shadow: var(--shadow-pop); }
