/* AI를 찾아라 — 모바일 우선 */
* { margin: 0; padding: 0; box-sizing: border-box; }

:root {
  --bg: #0f1117;
  --surface: #1a1d27;
  --surface-2: #232736;
  --text: #e8eaf0;
  --text-dim: #8b90a0;
  --accent: #7c5cff;
  --accent-hover: #6a4ce6;
  --danger: #ff5c7a;
  --ok: #4ade80;
  --radius: 14px;
}

html, body {
  height: 100%;
  background: var(--bg);
  color: var(--text);
  font-family: "Pretendard", -apple-system, "Segoe UI", "Malgun Gothic", sans-serif;
  -webkit-tap-highlight-color: transparent;
}

.screen {
  display: none;
  flex-direction: column;
  min-height: 100dvh;
  padding: 20px;
  padding-bottom: max(20px, env(safe-area-inset-bottom)); /* F15: 노치/홈인디케이터 있는 폰 대응 */
  max-width: 480px;
  margin: 0 auto;
}
.screen.active { display: flex; }

.hidden { display: none !important; }

/* 버튼 */
.btn {
  border: none;
  border-radius: var(--radius);
  padding: 16px;
  font-size: 17px;
  font-weight: 700;
  cursor: pointer;
  min-height: 52px; /* 터치 타겟 */
  transition: transform .1s, background .15s;
}
.btn:active { transform: scale(.97); }
.btn-primary { background: var(--accent); color: #fff; }
.btn-primary:hover { background: var(--accent-hover); }
.btn-secondary { background: var(--surface-2); color: var(--text); }
.btn-small { min-height: 44px; padding: 10px 16px; font-size: 15px; }

/* 홈 */
#screen-home { justify-content: center; gap: 40px; }
.home-hero { text-align: center; }
.logo {
  font-size: 56px;
  line-height: 1.1;
  font-weight: 900;
  letter-spacing: -2px;
  background: linear-gradient(135deg, #a78bfa, #7c5cff 60%, #5eead4);
  -webkit-background-clip: text;
  background-clip: text;
  color: transparent;
}
.tagline { margin-top: 12px; color: var(--text-dim); font-size: 15px; }
.home-actions { display: flex; flex-direction: column; gap: 24px; }
.join-box { display: flex; flex-direction: column; gap: 10px; }

input, textarea {
  background: var(--surface);
  border: 1.5px solid var(--surface-2);
  border-radius: var(--radius);
  padding: 14px;
  font-size: 16px;
  color: var(--text);
  outline: none;
  font-family: inherit;
}
input:focus, textarea:focus { border-color: var(--accent); }
#input-code { text-transform: uppercase; letter-spacing: 4px; text-align: center; font-weight: 700; }

.error-msg { color: var(--danger); text-align: center; margin-top: 16px; font-size: 14px; }

/* 상단바 */
.topbar {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 20px;
}
.room-label, .round-label { color: var(--text-dim); font-size: 14px; font-weight: 600; }
.room-code { font-size: 24px; font-weight: 800; letter-spacing: 4px; color: var(--accent); }
/* F15: 남은 시간 비율을 링으로 보여주는 원형 타이머 (JS가 --pct 0~1을 매초 갱신) */
.timer {
  --pct: 1;
  --ring: var(--accent);
  font-size: 15px;
  font-weight: 800;
  font-variant-numeric: tabular-nums;
  width: 44px;
  height: 44px;
  min-width: 44px; /* 터치 타겟 겸용 */
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  background:
    radial-gradient(closest-side, var(--surface) 72%, transparent 73%),
    conic-gradient(var(--ring) calc(var(--pct) * 360deg), var(--surface-2) 0deg);
}
.timer.urgent { color: var(--danger); --ring: var(--danger); }

/* F19: 프로시저럴 아바타 (해시 기반 색+표정 SVG) */
.avatar { display: inline-block; width: 28px; height: 28px; flex-shrink: 0; vertical-align: middle; }
.avatar svg { width: 100%; height: 100%; display: block; }
.avatar-sm { width: 20px; height: 20px; margin-right: 6px; }
.avatar-lg { width: 72px; height: 72px; margin: 0 auto 12px; }

/* 로비 */
.player-list { list-style: none; display: flex; flex-direction: column; gap: 8px; flex: 1; }
.player-list li {
  background: var(--surface);
  border-radius: var(--radius);
  padding: 14px 16px;
  font-weight: 600;
  display: flex;
  align-items: center;
  justify-content: space-between;
}
.player-info { display: flex; align-items: center; gap: 10px; }
.player-list .host-badge { color: var(--accent); font-size: 13px; }
.host-controls { margin-top: 16px; display: flex; flex-direction: column; gap: 10px; }
.lobby-settings { display: flex; flex-wrap: wrap; gap: 10px; }
.lobby-settings label { display: flex; flex-direction: column; gap: 4px; font-size: 13px; color: var(--text-dim); flex: 1; min-width: 100px; }
.lobby-settings select {
  background: var(--surface-2); color: var(--text); border: none; border-radius: 10px;
  padding: 10px 8px; font-size: 15px; min-height: 44px; /* 터치 타겟 */
}
.wait-msg { text-align: center; color: var(--text-dim); margin-top: 16px; font-size: 14px; }
.settings-display { text-align: center; color: var(--text-dim); margin-top: 16px; font-size: 13px; }

/* 주제 선택 */
.topic-guide { font-size: 18px; line-height: 1.4; margin-bottom: 20px; word-break: keep-all; color: var(--text-dim); }

/* 질문/답변 */
.question-text { font-size: 22px; line-height: 1.4; margin-bottom: 24px; word-break: keep-all; }
.answer-form { display: flex; flex-direction: column; gap: 10px; }
.answer-form textarea { resize: none; font-size: 17px; }
.answer-meta { display: flex; justify-content: space-between; align-items: center; }
#answer-count { color: var(--text-dim); font-size: 13px; }

/* 답변 카드 */
.answer-cards { display: flex; flex-direction: column; gap: 10px; }
.answer-card {
  background: var(--surface);
  border: 1.5px solid var(--surface-2);
  border-radius: var(--radius);
  padding: 14px 16px;
  display: flex;
  gap: 12px;
  align-items: flex-start;
}
.answer-card .card-label {
  font-weight: 800;
  color: var(--accent);
  flex-shrink: 0;
}
.answer-card.selectable { cursor: pointer; }
.answer-card.selected { border-color: var(--accent); background: var(--surface-2); }

/* 채팅 */
.chat-box {
  margin-top: 16px;
  display: flex;
  flex-direction: column;
  flex: 1;
  min-height: 160px;
  background: var(--surface);
  border-radius: var(--radius);
  overflow: hidden;
}
.chat-messages { flex: 1; overflow-y: auto; padding: 12px; font-size: 14px; display: flex; flex-direction: column; gap: 6px; }
.chat-messages .chat-name { font-weight: 700; color: var(--accent); margin-right: 6px; }
.chat-input-row { display: flex; gap: 8px; padding: 8px; border-top: 1px solid var(--surface-2); }
.chat-input-row input { flex: 1; }

/* 투표 */
.vote-guide { color: var(--text-dim); margin-bottom: 16px; font-size: 14px; }

/* 결과 */
.result-reveal, .final-banner {
  text-align: center;
  font-size: 26px;
  font-weight: 800;
  padding: 40px 0;
  line-height: 1.4;
}
.scoreboard { list-style: none; display: flex; flex-direction: column; gap: 8px; }
.scoreboard li {
  background: var(--surface);
  border-radius: var(--radius);
  padding: 12px 16px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  font-weight: 600;
}
.scoreboard .score { color: var(--accent); font-weight: 800; }
.scoreboard .score-name { display: flex; align-items: center; gap: 10px; }
.final-actions { display: flex; flex-direction: column; gap: 10px; margin-top: 24px; }
