/* 참가자 화면 전용 스타일 — common.css 위에 덧씌운다 (admin/stage에는 영향 없음)
   대강당 뒷자리·어두운 조명에서도 읽히도록 글자를 크게, 누르는 곳은 한눈에 보이게. */
:root {
  --bg: #f4efe6;
  --bg-deep: #ece5d8;
  --card: #fffdf9;
  --text: #1c1a16;
  --muted: #6f6859;
  --border: #e1d9ca;
  --border-strong: #c9bfae;

  --primary: #1f2d5c;
  --primary-dark: #15204a;
  --primary-soft: #e9edf7;
  --gold: #b8922e;
  --gold-light: #d8b85a;
  --gold-soft: #f6edd6;

  --ok: #2a7a4b;
  --ok-soft: #e4f2e8;
  --bad: #b3261e;
  --bad-soft: #fbe8e5;

  --radius: 14px;
  --radius-lg: 18px;
  --shadow: 0 1px 2px rgba(40, 30, 10, .06), 0 8px 22px -12px rgba(40, 30, 10, .22);
}

html { -webkit-text-size-adjust: 100%; }
body {
  display: flex; flex-direction: column; min-height: 100dvh;
  background: var(--bg);
  background-image: radial-gradient(120% 60% at 50% -10%, #fbf7ef 0%, var(--bg) 60%);
  color: var(--text);
  letter-spacing: -0.01em;
  font-size: 17px;
}

.card {
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow);
  padding: 20px;
}
.muted { color: var(--muted); }

/* ---------- 헤더: 남색 띠 + 금색 선 ---------- */
header {
  position: sticky; top: 0; z-index: 10;
  padding: 12px 18px 13px;
  background: linear-gradient(135deg, var(--primary) 0%, #2a3c78 100%);
  color: #fff;
  border-bottom: 3px solid var(--gold);
  display: flex; justify-content: space-between; align-items: center; gap: 12px;
  box-shadow: 0 4px 14px -8px rgba(21, 32, 74, .6);
}
header .title {
  font-weight: 800; font-size: 17px; letter-spacing: -0.02em;
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
header .who {
  display: inline-flex; align-items: center; gap: 7px;
  font-size: 14px; font-weight: 700; color: #fff;
  padding: 6px 12px 6px 10px;
  background: rgba(255, 255, 255, .14); border: 1px solid rgba(255, 255, 255, .22);
  border-radius: 99px;
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis; max-width: 62%;
}
#conn-dot {
  width: 8px; height: 8px; border-radius: 50%;
  background: rgba(255, 255, 255, .35); display: inline-block; flex-shrink: 0;
}
#conn-dot.on { background: #6fdc8c; box-shadow: 0 0 0 3px rgba(111, 220, 140, .25); }

main {
  flex: 1; width: 100%; max-width: 520px; margin: 0 auto;
  padding: 16px 16px calc(24px + env(safe-area-inset-bottom));
  display: flex; flex-direction: column; gap: 14px;
}

/* ---------- 공통 타이포 ---------- */
.eyebrow {
  display: inline-flex; align-items: center; gap: 8px;
  font-size: 13px; font-weight: 800; letter-spacing: .12em;
  color: var(--gold); text-transform: uppercase;
}
.eyebrow::before {
  content: ""; width: 18px; height: 2px; background: var(--gold); border-radius: 2px;
}

/* ---------- 로그인 ---------- */
#login-view { padding: 26px 22px 22px; margin-top: 4vh; }
#login-view .eyebrow { margin-bottom: 12px; }
#login-view h1 {
  font-size: 29px; font-weight: 900; line-height: 1.25; letter-spacing: -0.03em;
  color: var(--primary); margin-bottom: 8px; word-break: keep-all;
}
#login-view .sub { color: var(--muted); margin-bottom: 22px; font-size: 15.5px; line-height: 1.5; }
.field { margin-bottom: 14px; }
.field label {
  display: block; font-size: 14px; font-weight: 700; color: var(--muted);
  margin-bottom: 6px; letter-spacing: -0.01em;
}
.field input, .field select {
  width: 100%; padding: 15px 14px; font-size: 18px; font-weight: 600;
  color: var(--text); background: #fff;
  border: 1.5px solid var(--border-strong); border-radius: var(--radius);
  outline: none; transition: border-color .12s, box-shadow .12s;
  -webkit-appearance: none; appearance: none;
}
.field select {
  background-image: url("data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' width='16' height='16' viewBox='0 0 16 16'><path d='M4 6l4 4 4-4' fill='none' stroke='%231f2d5c' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'/></svg>");
  background-repeat: no-repeat; background-position: right 14px center;
  padding-right: 40px;
}
.field input:focus, .field select:focus {
  border-color: var(--primary); box-shadow: 0 0 0 3px var(--primary-soft);
}
.field input::placeholder { color: #b3aa9a; font-weight: 500; }
.rep-row {
  display: flex; align-items: center; gap: 10px; margin: 2px 0 14px;
  font-size: 16px; font-weight: 700; color: var(--text); cursor: pointer;
}
.rep-row input[type="checkbox"] { width: 22px; height: 22px; accent-color: var(--primary); }
#join-btn {
  width: 100%; padding: 17px; font-size: 18px; font-weight: 800; margin-top: 10px;
  background: var(--primary); color: #fff; border-radius: var(--radius);
  box-shadow: 0 6px 16px -8px rgba(31, 45, 92, .6);
  transition: transform .08s, background .12s;
}
#join-btn:active { transform: scale(.985); background: var(--primary-dark); }
#login-error { color: var(--bad); font-size: 15px; font-weight: 600; margin-top: 12px; min-height: 20px; text-align: center; }

/* ---------- 문제 ---------- */
#question-view { display: flex; flex-direction: column; gap: 12px; }
#q-header-card { padding: 14px 18px; position: relative; overflow: hidden; --p: 0; }
/* 남은 시간 막대: 카드 아래쪽 선이 시간에 맞춰 줄어든다 */
#q-header-card::after {
  content: ""; position: absolute; left: 0; bottom: 0; height: 5px;
  width: calc(var(--p) * 1%); background: var(--primary);
  border-radius: 0 3px 3px 0; transition: width .25s linear, background .2s;
}
#q-header-card.urgent::after { background: var(--bad); }
#q-header { display: flex; justify-content: space-between; align-items: center; gap: 12px; }
#q-no {
  display: inline-flex; align-items: center; gap: 10px;
  font-weight: 900; font-size: 22px; letter-spacing: -0.02em; color: var(--primary);
}
#q-no::before {
  content: ""; width: 10px; height: 10px; border-radius: 2px;
  background: var(--gold); transform: rotate(45deg);
}
#q-timer {
  font-weight: 900; font-size: 26px; line-height: 1;
  color: var(--primary); background: var(--primary-soft);
  padding: 10px 16px; border-radius: 99px;
  font-variant-numeric: tabular-nums; min-width: 88px; text-align: center;
}
#q-timer:empty { display: none; }
#q-timer.urgent {
  color: #fff; background: var(--bad);
  animation: pulse .9s ease-in-out infinite;
}
@keyframes pulse {
  0%, 100% { opacity: 1; }
  50% { opacity: .6; }
}

#q-body { padding: 16px 18px; }
#q-body .q-text { font-size: 19px; font-weight: 600; line-height: 1.55; white-space: pre-line; word-break: keep-all; }
#q-body .q-img { display: block; width: 100%; border-radius: var(--radius-lg); margin-top: 10px; }
#q-body .q-text + .q-img { margin-top: 10px; }

.choices { display: flex; flex-direction: column; gap: 11px; }
.choice-btn {
  position: relative; width: 100%; min-height: 64px; padding: 16px 56px 16px 14px;
  font-size: 19px; font-weight: 600; line-height: 1.4; text-align: left; color: var(--text);
  background: var(--card); border: 2px solid var(--border-strong);
  border-radius: var(--radius-lg); box-shadow: var(--shadow);
  display: flex; gap: 13px; align-items: center;
  transition: transform .08s, border-color .12s, background .12s;
  word-break: keep-all; overflow-wrap: anywhere;
}
.choice-btn:not(:disabled):active { transform: scale(.985); }
.choice-btn .num {
  flex-shrink: 0; width: 38px; height: 38px; border-radius: 50%;
  background: var(--primary-soft); color: var(--primary);
  font-weight: 800; font-size: 18px;
  display: inline-flex; align-items: center; justify-content: center;
  transition: background .12s, color .12s;
}
.choice-btn::after {
  content: ""; position: absolute; right: 16px; top: 50%;
  width: 26px; height: 26px; margin-top: -13px; border-radius: 50%;
  opacity: 0; transform: scale(.6); transition: opacity .12s, transform .12s;
  background-repeat: no-repeat; background-position: center; background-size: 16px;
}
.choice-btn.selected { border-color: var(--primary); background: var(--primary-soft); box-shadow: 0 0 0 3px rgba(31, 45, 92, .14), var(--shadow); }
.choice-btn.selected .num { background: var(--primary); color: #fff; }
.choice-btn.selected::after {
  opacity: 1; transform: scale(1); background-color: var(--primary);
  background-image: url("data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 16 16'><path d='M3.5 8.5l3 3 6-7' fill='none' stroke='white' stroke-width='2.2' stroke-linecap='round' stroke-linejoin='round'/></svg>");
}
.choice-btn:disabled { opacity: 1; cursor: default; }
.choice-btn:disabled:not(.selected) { opacity: .5; }

.ox-row { display: flex; gap: 12px; height: 44vh; min-height: 240px; }
.ox-btn {
  flex: 1; font-size: 96px; font-weight: 900; line-height: 1;
  border-radius: var(--radius-lg); border: 2px solid var(--border-strong);
  background: var(--card); box-shadow: var(--shadow);
  transition: transform .08s, border-color .12s, background .12s;
}
.ox-btn:not(:disabled):active { transform: scale(.98); }
.ox-btn.o { color: var(--primary); }
.ox-btn.x { color: var(--bad); }
.ox-btn.selected.o { border-color: var(--primary); background: var(--primary-soft); box-shadow: 0 0 0 3px rgba(31, 45, 92, .14), var(--shadow); }
.ox-btn.selected.x { border-color: var(--bad); background: var(--bad-soft); box-shadow: 0 0 0 3px rgba(179, 38, 30, .14), var(--shadow); }
.ox-btn:disabled:not(.selected) { opacity: .5; }

#submit-status {
  text-align: center; font-size: 17px; font-weight: 700; line-height: 1.45;
  padding: 14px 16px; border-radius: var(--radius);
  background: var(--bg-deep); color: var(--muted);
}
#submit-status:empty { display: none; }
#submit-status.ok { background: var(--ok-soft); color: var(--ok); border: 1.5px solid rgba(42, 122, 75, .25); }
#submit-status.bad { background: var(--bad-soft); color: var(--bad); }

/* ---------- 대기·대표 라운드 ---------- */
.center-msg { text-align: center; padding: 60px 22px 56px; }
.center-msg .eyebrow { justify-content: center; margin-bottom: 22px; }
.center-msg .eyebrow::before { display: none; }
.center-msg .big {
  font-size: 26px; font-weight: 800; line-height: 1.35; letter-spacing: -0.02em;
  color: var(--primary); margin-bottom: 12px; word-break: keep-all;
}
.center-msg .muted { font-size: 16px; line-height: 1.5; }
.dots { display: inline-flex; gap: 9px; margin-bottom: 26px; }
.dots i {
  width: 10px; height: 10px; border-radius: 50%; background: var(--gold);
  animation: breathe 1.6s ease-in-out infinite;
}
.dots i:nth-child(2) { animation-delay: .2s; }
.dots i:nth-child(3) { animation-delay: .4s; }
@keyframes breathe {
  0%, 100% { opacity: .25; }
  50% { opacity: 1; }
}
.mark {
  width: 64px; height: 64px; margin: 0 auto 22px; border-radius: 50%;
  background: var(--gold-soft); color: var(--gold);
  display: flex; align-items: center; justify-content: center;
  font-size: 26px; font-weight: 900; letter-spacing: -0.02em;
}
.mark.small { font-size: 19px; letter-spacing: -0.03em; }

/* ---------- 결과 배너 ---------- */
#result-banner { text-align: center; padding: 22px; border-radius: var(--radius-lg); font-size: 22px; font-weight: 800; }
#result-banner.correct { background: var(--ok-soft); color: var(--ok); }
#result-banner.wrong { background: var(--bad-soft); color: var(--bad); }
#result-banner.none { background: var(--bg-deep); color: var(--muted); font-size: 17px; }

/* ---------- 본인 확인 ---------- */
#confirm-overlay {
  position: fixed; inset: 0; background: rgba(28, 26, 22, .55);
  display: flex; align-items: flex-end; justify-content: center; padding: 16px; z-index: 50;
}
@media (min-width: 480px) { #confirm-overlay { align-items: center; } }
#confirm-box { max-width: 400px; width: 100%; padding: 22px 20px; }
#confirm-box .eyebrow { margin-bottom: 10px; }
#confirm-box p { margin-bottom: 18px; line-height: 1.55; font-size: 17px; font-weight: 600; }
#confirm-box .row { display: flex; flex-direction: column-reverse; gap: 8px; }
#confirm-box .row .btn { width: 100%; padding: 16px; font-size: 17px; font-weight: 800; border-radius: var(--radius); }
#confirm-box .btn { background: var(--bg-deep); color: var(--text); }
#confirm-box .btn.primary { background: var(--primary); color: #fff; }

@media (prefers-reduced-motion: reduce) {
  #q-timer.urgent, .dots i { animation: none; }
  .dots i { opacity: 1; }
}
