/* ===== 시청자 참여 모드 공통 ===== */
* { box-sizing: border-box; margin: 0; padding: 0; }

body {
  font-family: 'Noto Sans KR', 'Arial', sans-serif;
  background: var(--bg-tertiary);
  color: var(--text-primary);
  min-height: 100vh;
}

/* ===== SETUP 페이지 ===== */
.viewer-setup-container {
  display: flex;
  align-items: center;
  justify-content: center;
  min-height: 100vh;
  padding: 20px;
}

.viewer-setup-card {
  background: var(--bg-card);
  border: 1px solid var(--brand-border);
  border-radius: 20px;
  padding: 40px;
  width: 100%;
  max-width: 600px;
  box-shadow: 0 8px 40px rgba(0,0,0,0.15);
}

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

.back-link {
  color: var(--text-secondary);
  text-decoration: none;
  font-size: 14px;
  transition: color 0.2s;
}
.back-link:hover { color: var(--brand-primary); }

.back-link-btn {
  display: inline-block;
  padding: 8px 16px;
  background: var(--bg-secondary);
  border: 1px solid var(--brand-border);
  border-radius: 20px;
  color: var(--text-secondary);
  text-decoration: none;
  font-size: 14px;
  font-weight: 600;
  transition: all 0.2s;
}
.back-link-btn:hover {
  background: var(--brand-lightest);
  border-color: var(--brand-primary);
  color: var(--brand-primary);
}

.viewer-badge {
  background: var(--brand-lightest);
  color: var(--brand-primary);
  border: 1px solid var(--brand-border);
  border-radius: 20px;
  padding: 5px 14px;
  font-size: 13px;
  font-weight: 600;
}

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

.viewer-quiz-name {
  color: var(--brand-primary);
  font-size: 1.8rem;
  font-weight: 700;
  margin-bottom: 10px;
  line-height: 1.3;
}

.viewer-desc {
  color: var(--text-secondary);
  font-size: 14px;
  line-height: 1.6;
  margin-bottom: 30px;
}

/* ===== SETUP 섹션 ===== */
.setup-section {
  margin-bottom: 24px;
}

/* 문제 수 선택 */
.count-options-grid {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 10px;
}

.count-option {
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 10px;
  background: var(--bg-secondary);
  border: 2px solid var(--brand-border);
  border-radius: 10px;
  cursor: pointer;
  font-size: 14px;
  font-weight: 600;
  color: var(--text-primary);
  transition: all 0.2s;
  gap: 6px;
}

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

.count-option input[type="radio"] { display: none; }

.count-option:has(input:checked) {
  border-color: var(--brand-primary);
  background: var(--brand-lightest);
  color: var(--brand-primary);
}

/* 모드 선택 */
.mode-options {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 10px;
}

.mode-option {
  cursor: pointer;
}

.mode-option input[type="radio"] { display: none; }

.mode-option-content {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 14px;
  background: var(--bg-secondary);
  border: 2px solid var(--brand-border);
  border-radius: 12px;
  transition: all 0.2s;
}

.mode-option:hover .mode-option-content { border-color: var(--brand-blue-light); }

.mode-option:has(input:checked) .mode-option-content {
  border-color: var(--brand-blue-light);
  background: var(--brand-lightest);
}

.mode-option-icon { font-size: 1.5rem; flex-shrink: 0; }

.mode-option-title {
  font-weight: 700;
  font-size: 14px;
  margin-bottom: 2px;
  color: var(--text-primary);
}

.mode-option-desc {
  font-size: 12px;
  color: var(--text-secondary);
}

/* 플랫폼 선택 버튼 */
.platform-btns {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 12px;
}

.platform-btn {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 8px;
  padding: 20px;
  border: 2px solid var(--brand-border);
  border-radius: 16px;
  background: var(--bg-secondary);
  color: var(--text-primary);
  font-size: 16px;
  font-weight: 700;
  cursor: pointer;
  transition: all 0.2s;
}

.platform-icon { font-size: 1.8rem; }

.platform-favicon {
  width: 36px;
  height: 36px;
  object-fit: contain;
  border-radius: 6px;
}

.btn-favicon {
  width: 18px;
  height: 18px;
  object-fit: contain;
  vertical-align: middle;
  margin-right: 2px;
  border-radius: 3px;
}

.platform-chzzk { border-color: var(--brand-border); }
.platform-chzzk:hover { border-color: #00c73c; background: rgba(0, 199, 60, 0.08); }
.platform-chzzk.active { border-color: #00c73c; background: rgba(0, 199, 60, 0.12); color: #00c73c; }

.platform-soop { border-color: var(--brand-border); }
.platform-soop:hover { border-color: #1a6eff; background: rgba(26, 110, 255, 0.08); }
.platform-soop.active { border-color: #1a6eff; background: rgba(26, 110, 255, 0.12); color: #4d8fff; }

/* 채널 입력 영역 */
.channel-input-area {
  margin-bottom: 24px;
  background: var(--bg-secondary);
  border: 1px solid var(--brand-border);
  border-radius: 14px;
  padding: 20px;
  animation: fadeIn 0.2s ease;
}

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

.input-label {
  display: block;
  font-weight: 600;
  margin-bottom: 6px;
  color: var(--text-primary);
}

.input-hint {
  color: var(--text-secondary);
  font-size: 13px;
  margin-bottom: 12px;
  line-height: 1.5;
}
.input-hint strong { color: var(--text-primary); }

.channel-input {
  width: 100%;
  padding: 14px 16px;
  background: var(--bg-primary);
  border: 2px solid var(--brand-border);
  border-radius: 12px;
  color: var(--text-primary);
  font-size: 15px;
  outline: none;
  transition: border-color 0.2s;
  margin-bottom: 6px;
}
.channel-input:focus { border-color: var(--brand-primary); }

.input-error {
  color: #f44336;
  font-size: 13px;
  margin-bottom: 10px;
}

.delay-test-row {
  display: flex;
  align-items: center;
  gap: 10px;
  margin-top: 10px;
}

.delay-btn {
  padding: 8px 18px;
  border: none;
  border-radius: 8px;
  font-size: 0.9rem;
  font-weight: 600;
  cursor: pointer;
  transition: background 0.2s;
}

.delay-btn-start { background: var(--brand-primary, #6c63ff); color: #fff; }
.delay-btn-start:hover { opacity: 0.85; }
.delay-btn-done { background: #22c55e; color: #fff; }
.delay-btn-done:hover:not(:disabled) { opacity: 0.85; }
.delay-btn:disabled { opacity: 0.4; cursor: not-allowed; }

.delay-result {
  font-size: 1rem;
  font-weight: 700;
  color: var(--text-primary);
  min-width: 60px;
}

.delay-info {
  color: var(--text-secondary);
  font-size: 0.82rem;
}

.delay-vol-wrap {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-bottom: 14px;
  justify-content: center;
}

.quiz-start-btn:disabled {
  opacity: 0.35;
  cursor: not-allowed;
  transform: none !important;
  box-shadow: none !important;
}

.delay-optional {
  font-size: 0.8rem;
  font-weight: 400;
  color: var(--text-secondary);
}

.start-btn {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  width: 100%;
  padding: 15px;
  color: white;
  border: none;
  border-radius: 12px;
  font-size: 16px;
  font-weight: 700;
  cursor: pointer;
  margin-top: 10px;
  transition: all 0.2s;
}
.start-btn:hover {
  transform: translateY(-2px);
}

.start-btn-chzzk { background: #00c73c; }
.start-btn-chzzk:hover { background: #00a832; box-shadow: 0 5px 20px rgba(0, 199, 60, 0.4); }

.start-btn-soop { background: #1a6eff; }
.start-btn-soop:hover { background: #0d5ce0; box-shadow: 0 5px 20px rgba(26, 110, 255, 0.4); }

.viewer-info {
  display: flex;
  flex-direction: column;
  gap: 12px;
  border-top: 1px solid var(--brand-border);
  padding-top: 24px;
}

.info-item {
  display: flex;
  align-items: center;
  gap: 10px;
  color: var(--text-secondary);
  font-size: 14px;
}
.info-icon { font-size: 18px; }

/* ===== ROOM 페이지 ===== */
.viewer-room-layout {
  display: grid;
  grid-template-columns: 1fr 320px;
  min-height: 100vh;
  gap: 0;
}

/* 게임 패널 */
.game-panel {
  padding: 30px;
  display: flex;
  flex-direction: column;
  gap: 20px;
  border-right: 1px solid var(--brand-border);
}

.game-header {
  display: flex;
  justify-content: center;
  align-items: center;
}

.progress-text {
  font-size: 2rem;
  font-weight: 800;
  color: var(--brand-primary);
  letter-spacing: 0.02em;
}

/* 문제 카드 */
.question-area { flex: 1; }

.question-card {
  background: var(--bg-card);
  border: 1px solid var(--brand-border);
  border-radius: 16px;
  padding: 30px;
  position: relative;
}

/* 볼륨 슬라이더 */
.audio-vol-wrap {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 5px 10px;
  background: var(--bg-secondary);
  border: 1px solid var(--brand-border);
  border-radius: 8px;
  margin-top: 8px;
  font-size: 12px;
}

.audio-vol-slider {
  width: 80px;
  accent-color: var(--brand-primary);
  cursor: pointer;
}

.audio-vol-val {
  font-size: 11px;
  color: var(--text-secondary);
  min-width: 28px;
  text-align: right;
}

.audio-vol-note {
  font-size: 13px;
  color: var(--text-muted);
  margin-top: 8px;
  text-align: center;
}

.audio-replay-btn {
  position: absolute;
  top: 14px;
  right: 14px;
  width: 36px;
  height: 36px;
  background: var(--bg-secondary);
  border: 1px solid var(--brand-border);
  border-radius: 50%;
  font-size: 16px;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: all 0.2s;
  line-height: 1;
}
.audio-replay-btn:hover {
  background: var(--brand-lightest);
  border-color: var(--brand-primary);
  transform: scale(1.1);
}
@keyframes spin {
  from { transform: rotate(0deg); }
  to   { transform: rotate(360deg); }
}
.audio-replay-btn.spinning {
  animation: spin 0.6s ease;
}

.question-text {
  font-size: 1.5rem;
  font-weight: 700;
  line-height: 1.5;
  margin-top: 0;
  margin-bottom: 20px;
  color: var(--text-primary);
}

.question-media {
  width: 100%;
  max-height: 320px;
  object-fit: contain;
  border-radius: 10px;
  margin-bottom: 10px;
}

.question-audio {
  width: 100%;
  margin-bottom: 10px;
}

.youtube-wrap {
  position: relative;
  width: 100%;
  padding-bottom: 56.25%;
  margin-bottom: 10px;
}
.youtube-wrap iframe {
  position: absolute;
  top: 0; left: 0;
  width: 100%; height: 100%;
  border: none;
  border-radius: 10px;
}

.options-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 12px;
  margin-top: 20px;
}

.option-item {
  background: var(--bg-secondary);
  border: 1px solid var(--brand-border);
  border-radius: 10px;
  padding: 14px 16px;
  display: flex;
  align-items: center;
  gap: 10px;
  font-size: 15px;
  color: var(--text-primary);
}

.option-num {
  background: var(--brand-lightest);
  color: var(--brand-secondary);
  border-radius: 50%;
  width: 26px;
  height: 26px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 13px;
  font-weight: 700;
  flex-shrink: 0;
}

/* 정답자 배너 */
.winner-banner-toast {
  position: absolute;
  top: 24px;
  left: 50%;
  transform: translateX(-50%);
  z-index: 1;
  background: linear-gradient(135deg, var(--brand-primary), var(--brand-secondary));
  border-radius: 16px;
  padding: 14px 32px;
  display: flex;
  align-items: center;
  gap: 12px;
  color: white;
  font-size: 1.2rem;
  font-weight: 800;
  box-shadow: 0 4px 24px rgba(0,0,0,0.35);
  animation: toastFadeOut 5s ease forwards;
  white-space: nowrap;
}

@keyframes toastFadeOut {
  0% { opacity: 1; transform: translateX(-50%) translateY(0); }
  60% { opacity: 1; transform: translateX(-50%) translateY(0); }
  100% { opacity: 0; transform: translateX(-50%) translateY(-12px); }
}

.winner-banner {
  background: linear-gradient(135deg, var(--brand-primary), var(--brand-secondary));
  border-radius: 16px;
  padding: 20px 28px;
  display: flex;
  align-items: center;
  gap: 16px;
  animation: winnerPop 0.4s ease;
}

@keyframes winnerPop {
  from { transform: scale(0.8); opacity: 0; }
  to   { transform: scale(1); opacity: 1; }
}

.winner-icon { font-size: 2.5rem; }

.winner-text {
  display: flex;
  flex-direction: column;
  gap: 2px;
}

.winner-name {
  font-size: 1.5rem;
  font-weight: 700;
  color: white;
}

.winner-label {
  font-size: 14px;
  color: rgba(255,255,255,0.85);
  font-weight: 600;
}

/* 컨트롤 */
.controls {
  display: flex;
  gap: 12px;
}

.next-btn {
  flex: 1;
  padding: 14px;
  background: var(--brand-blue-light);
  color: white;
  border: none;
  border-radius: 12px;
  font-size: 16px;
  font-weight: 700;
  cursor: pointer;
  transition: all 0.2s;
}
.next-btn:hover {
  background: var(--brand-blue);
  transform: translateY(-2px);
  box-shadow: 0 5px 20px rgba(108, 99, 255, 0.4);
}

.wrong-answer-msg {
  text-align: center;
  font-size: 1rem;
  font-weight: 700;
  color: #ef4444;
  margin-bottom: 6px;
}

.streamer-answer-area {
  display: flex;
  gap: 12px;
  margin-bottom: 4px;
}

.streamer-answer-input {
  flex: 1;
  padding: 16px 20px;
  background: var(--bg-primary);
  border: 2px solid var(--brand-primary);
  border-radius: 12px;
  color: var(--text-primary);
  font-size: 1.1rem;
  outline: none;
  transition: border-color 0.2s;
}
.streamer-answer-input:focus { border-color: var(--brand-secondary); }
.streamer-answer-input::placeholder { color: var(--text-muted); }

.streamer-answer-btn {
  padding: 16px 28px;
  background: var(--brand-primary);
  color: white;
  border: none;
  border-radius: 12px;
  font-size: 1.1rem;
  font-weight: 700;
  cursor: pointer;
  transition: all 0.2s;
  white-space: nowrap;
}
.streamer-answer-btn:hover { background: var(--brand-secondary); transform: translateY(-2px); }
.streamer-answer-btn:disabled { opacity: 0.5; cursor: default; transform: none; }

.hint-btn, .skip-btn {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 6px;
  padding: 14px 10px;
  border-radius: 14px;
  font-size: 13px;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.2s;
}

.ctrl-icon { font-size: 1.4rem; line-height: 1; }
.ctrl-label { font-size: 13px; font-weight: 600; }

.hint-btn {
  background: rgba(240,192,64,0.08);
  color: #d4a820;
  border: 1.5px solid rgba(240,192,64,0.5);
}
.hint-btn:hover:not(:disabled) {
  background: rgba(240,192,64,0.18);
  border-color: #f0c040;
  color: #f0c040;
  transform: translateY(-2px);
}
.hint-btn:disabled { opacity: 0.35; cursor: default; }

.skip-btn {
  background: var(--bg-secondary);
  color: var(--text-secondary);
  border: 1.5px solid var(--brand-border);
}
.skip-btn:hover:not(:disabled) {
  border-color: var(--brand-blue-light);
  color: var(--brand-blue-light);
  background: var(--brand-lightest);
  transform: translateY(-2px);
}
.skip-btn:disabled { opacity: 0.35; cursor: default; }

.end-btn {
  padding: 8px 18px;
  background: transparent;
  color: var(--text-muted);
  border: 1px solid var(--brand-border);
  border-radius: 10px;
  font-size: 12px;
  font-weight: 500;
  cursor: pointer;
  transition: all 0.2s;
}
.end-btn:hover { border-color: #f44336; color: #f44336; background: rgba(244,67,54,0.06); }

.end-btn-area {
  display: flex;
  justify-content: flex-end;
  margin-top: -8px;
}

/* P키 단축키 표시 */
kbd {
  display: inline-block;
  padding: 1px 6px;
  background: var(--brand-lightest);
  border: 1px solid var(--brand-border);
  border-radius: 4px;
  font-size: 12px;
  font-family: monospace;
  margin-left: 4px;
  color: var(--text-secondary);
}

.hint-display {
  background: rgba(240, 192, 64, 0.1);
  border: 1px solid rgba(240, 192, 64, 0.4);
  border-radius: 12px;
  padding: 14px 20px;
  color: #f0c040;
  font-size: 16px;
  font-weight: 600;
}

/* 종료 화면 */
.finish-screen {
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 20px;
  padding: 60px 20px;
  text-align: center;
}

.finish-title {
  font-size: 2.5rem;
  font-weight: 700;
  color: var(--text-primary);
}

.back-to-list {
  padding: 14px 32px;
  background: var(--brand-primary);
  color: white;
  text-decoration: none;
  border-radius: 12px;
  font-size: 16px;
  font-weight: 700;
  transition: all 0.2s;
}
.back-to-list:hover { background: var(--brand-secondary); transform: translateY(-2px); }

.loading-spinner {
  text-align: center;
  color: var(--text-secondary);
  padding: 60px 20px;
  font-size: 16px;
}

/* 순위 패널 */
.score-panel {
  background: var(--bg-card);
  padding: 24px 20px;
  overflow-y: auto;
}

.score-title {
  font-size: 1.1rem;
  font-weight: 700;
  margin-bottom: 16px;
  padding-bottom: 12px;
  border-bottom: 1px solid var(--brand-border);
  color: var(--text-primary);
}

.scores-list {
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.no-scores {
  color: var(--text-muted);
  font-size: 14px;
  text-align: center;
  padding: 20px 0;
}

.score-item {
  display: flex;
  align-items: center;
  gap: 12px;
  background: var(--bg-secondary);
  border: 1px solid var(--brand-border);
  border-radius: 10px;
  padding: 12px 14px;
  animation: slideIn 0.3s ease;
}

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

.score-rank {
  background: var(--brand-primary);
  color: white;
  font-size: 12px;
  font-weight: 700;
  border-radius: 20px;
  padding: 3px 10px;
  white-space: nowrap;
  flex-shrink: 0;
}

.score-rank.rank-gold   { background: #FFD700; color: #333; }
.score-rank.rank-silver { background: #C0C0C0; color: #333; }
.score-rank.rank-bronze { background: #CD7F32; color: white; }

.score-info {
  display: flex;
  flex-direction: column;
  gap: 2px;
  min-width: 0;
}

.score-nickname {
  font-weight: 700;
  font-size: 15px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  color: var(--text-primary);
}

.score-question {
  color: var(--text-muted);
  font-size: 12px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

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

.answer-modal-box:focus { outline: none; }

.answer-modal-box {
  background: var(--bg-card);
  border: 2px solid var(--brand-primary);
  border-radius: 20px;
  padding: 32px 48px;
  text-align: center;
  min-width: 320px;
  max-width: 640px;
  width: 90%;
  box-shadow: 0 16px 60px rgba(0,0,0,0.4);
}

.answer-modal-text {
  font-size: 2.2rem;
  font-weight: 700;
  color: var(--brand-primary);
  margin-bottom: 20px;
  word-break: break-word;
}

.answer-modal-next-btn {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  width: 100%;
  padding: 18px;
  background: var(--brand-primary);
  color: white;
  border: none;
  border-radius: 12px;
  font-size: 1.3rem;
  font-weight: 700;
  cursor: pointer;
  margin-top: 8px;
  transition: all 0.2s;
}
.answer-modal-next-btn:hover {
  background: var(--brand-secondary);
  transform: translateY(-2px);
  box-shadow: 0 5px 20px rgba(94, 53, 177, 0.35);
}
.answer-modal-next-btn kbd {
  font-size: 13px;
  padding: 2px 8px;
  background: rgba(255,255,255,0.2);
  border: 1px solid rgba(255,255,255,0.3);
  border-radius: 5px;
  color: white;
}

/* ===== 퀴즈 시작 오버레이 ===== */
.start-overlay {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  min-height: 100vh;
  gap: 32px;
}

.delay-test-box {
  background: var(--bg-card);
  border: 1px solid var(--brand-border);
  border-radius: 16px;
  padding: 24px 32px;
  text-align: center;
  max-width: 420px;
  width: 100%;
}

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

.delay-test-desc {
  font-size: 0.85rem;
  color: var(--text-secondary);
  margin-bottom: 16px;
  line-height: 1.5;
}

.quiz-start-btn {
  display: none;
  padding: 20px 60px;
  font-size: 1.6rem;
  font-weight: 800;
  background: var(--brand-primary);
  color: white;
  border: none;
  border-radius: 16px;
  cursor: pointer;
  box-shadow: 0 4px 20px rgba(0,0,0,0.25);
  transition: transform 0.1s, box-shadow 0.1s;
  letter-spacing: 2px;
}
.quiz-start-btn:hover {
  transform: translateY(-2px);
  box-shadow: 0 8px 30px rgba(0,0,0,0.3);
}
.quiz-start-btn:active {
  transform: translateY(0);
  box-shadow: 0 2px 10px rgba(0,0,0,0.2);
}

/* 반응형 */
@media (max-width: 768px) {
  .viewer-room-layout {
    grid-template-columns: 1fr;
    grid-template-rows: 1fr auto;
  }
  .game-panel { border-right: none; border-bottom: 1px solid var(--brand-border); }
  .score-panel { max-height: 300px; }
  .options-grid { grid-template-columns: 1fr; }
}
