:root {
  --ink: #141414;
  --ink-2: #4a4458;
  --ink-3: #7a7389;
  --accent: #6C4CE0;
  --accent-2: #5536c8;
  --accent-soft: #efeafd;
  --card: #ffffff;
  --line: #e7e2f3;
  --ok: #1f8a4c;
  --ok-soft: #e3f5ea;
  --warn: #b4580f;
  --shadow: 0 10px 30px rgba(60, 40, 120, .12), 0 2px 6px rgba(60, 40, 120, .06);
  --radius: 22px;
  --font: "Pretendard Variable", Pretendard, -apple-system, BlinkMacSystemFont, "Apple SD Gothic Neo",
    "Malgun Gothic", "맑은 고딕", "Noto Sans KR", system-ui, sans-serif;
}
* { box-sizing: border-box; }
html, body { margin: 0; padding: 0; }
body {
  font-family: var(--font);
  color: var(--ink);
  background: #e9dcf5 linear-gradient(135deg, #C9B8F0 0%, #F2B5DA 50%, #A9D2F5 100%) fixed;
  min-height: 100vh;
  -webkit-font-smoothing: antialiased;
  word-break: keep-all;
  overflow-wrap: anywhere;
}
button, input, textarea, select { font-family: inherit; color: inherit; }
button { cursor: pointer; }
.kicker {
  font-size: 15px; font-weight: 700; letter-spacing: -.01em; color: var(--ink-2);
}
.kicker::before {
  content: ""; display: inline-block; width: 8px; height: 8px; border-radius: 50%;
  background: var(--accent); margin-right: 8px; vertical-align: middle; position: relative; top: -1px;
}
.card {
  background: var(--card); border-radius: var(--radius); box-shadow: var(--shadow);
}
.btn {
  border: 0; border-radius: 14px; padding: 14px 22px; font-size: 17px; font-weight: 700;
  background: var(--accent); color: #fff; transition: transform .08s, background .15s, opacity .15s;
}
.btn:hover { background: var(--accent-2); }
.btn:active { transform: scale(.97); }
.btn:disabled { opacity: .45; cursor: default; transform: none; }
.btn.ghost { background: var(--accent-soft); color: var(--accent-2); }
.btn.ghost:hover { background: #e2d9fb; }
.btn.plain { background: #f3f1f7; color: var(--ink); }
.btn.plain:hover { background: #e9e5f1; }
.btn.danger { background: #fdeceb; color: #b42318; }
.btn.danger:hover { background: #fbd9d6; }
.hidden { display: none !important; }
:focus-visible { outline: 3px solid var(--accent); outline-offset: 2px; }

/* ---------------- 참가자 페이지 ---------------- */
.p-wrap { max-width: 520px; margin: 0 auto; padding: 18px 16px 40px; }
.p-top { display: flex; justify-content: space-between; align-items: center; margin-bottom: 18px; }
.p-card { padding: 26px 22px 24px; }
.p-badge {
  display: inline-block; background: var(--accent); color: #fff; font-weight: 800; font-size: 15px;
  padding: 6px 14px; border-radius: 999px; margin-bottom: 12px;
}
.p-title { font-size: 28px; font-weight: 800; letter-spacing: -.03em; margin: 0 0 8px; line-height: 1.25; }
.p-gbadge { background: var(--accent-soft); color: var(--accent-2); padding: 2px 10px; border-radius: 999px; }
.p-desc { font-size: 16px; color: var(--ink-2); line-height: 1.6; margin: 0 0 18px; }
.p-groups { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; margin-top: 6px; }
.p-gbtn {
  border: 2px solid var(--line); border-radius: 16px; background: #fbfaff; padding: 15px 12px;
  display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 4px;
  font-size: 22px; font-weight: 800; color: var(--ink); transition: transform .08s, border-color .15s, background .15s;
}
.p-gbtn:hover, .p-gbtn:focus-visible { border-color: var(--accent); background: #fff; }
.p-gbtn:active { transform: scale(.97); }
.p-gbtn .st { font-size: 13px; font-weight: 700; color: var(--ink-3); }
.p-gbtn.yes { border-color: rgba(31,138,76,.35); background: #f6fcf8; }
.p-gbtn.yes .st { color: var(--ok); }
.p-text {
  width: 100%; min-height: 150px; resize: vertical; border: 2px solid var(--line); border-radius: 16px;
  padding: 14px 16px; font-size: 18px; line-height: 1.55; background: #fbfaff;
}
.p-text:focus { outline: none; border-color: var(--accent); background: #fff; }
.p-row { display: flex; justify-content: space-between; align-items: center; margin: 8px 2px 16px; font-size: 14px; color: var(--ink-3); }
.p-count.over { color: #b42318; font-weight: 700; }
.p-submit { width: 100%; font-size: 19px; padding: 17px; }
.p-msg { min-height: 22px; margin-top: 12px; font-size: 15px; color: #b42318; text-align: center; }
.p-done-head { display: flex; align-items: center; gap: 10px; font-size: 22px; font-weight: 800; margin: 0 0 14px; letter-spacing: -.02em; }
.p-check {
  width: 34px; height: 34px; flex: none; border-radius: 50%; background: var(--ok-soft); color: var(--ok);
  display: grid; place-items: center; font-size: 20px; font-weight: 900;
}
.p-quote {
  background: #f7f4ff; border-radius: 16px; padding: 18px; font-size: 19px; line-height: 1.6;
  white-space: pre-wrap; border-left: 5px solid var(--accent); margin-bottom: 16px;
}
.p-note { font-size: 14px; color: var(--ink-3); line-height: 1.6; margin: 0 0 16px; }
.p-center { text-align: center; padding: 40px 22px; }
.p-center .p-title { font-size: 24px; }
.p-icon { font-size: 44px; margin-bottom: 10px; }
.p-foot { text-align: center; color: var(--ink-2); font-size: 13px; margin-top: 22px; opacity: .8; }

/* ---------------- 진행자 화면 ---------------- */
body.host { height: 100vh; overflow: hidden; }
.h-app { height: 100vh; display: flex; flex-direction: column; padding: 2.2vh 2.4vw 2.6vh; gap: 2vh; }
.h-bar { display: grid; grid-template-columns: 1fr auto 1fr; align-items: center; }
.h-bar .kicker { font-size: clamp(14px, 1.15vw, 22px); }
.h-tabs { display: flex; gap: 6px; background: rgba(255,255,255,.55); padding: 6px; border-radius: 999px; box-shadow: var(--shadow); }
.h-tab {
  border: 0; background: transparent; border-radius: 999px; padding: 1.1vh 1.8vw;
  font-size: clamp(15px, 1.25vw, 24px); font-weight: 700; color: var(--ink-2);
}
.h-tab .key { font-size: .7em; opacity: .55; margin-left: 6px; font-weight: 600; }
.h-tab.on { background: var(--ink); color: #fff; }
.h-tab.on .key { opacity: .7; }
.h-right { justify-self: end; display: flex; gap: 8px; align-items: center; }
.h-admin-btn {
  border: 0; background: rgba(255,255,255,.55); color: var(--ink-2); border-radius: 999px;
  padding: 9px 16px; font-size: clamp(13px, .9vw, 16px); font-weight: 600;
}
.h-admin-btn:hover { background: #fff; }
.h-main { flex: 1; min-height: 0; position: relative; }
.h-pane { position: absolute; inset: 0; display: flex; flex-direction: column; gap: 2vh; }

/* 타이머 */
.t-layout { flex: 1; min-height: 0; display: flex; gap: 2vw; }
.t-card { flex: 1; min-width: 0; padding: 3vh 3vw; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 2.4vh; position: relative; }
.t-label { font-size: clamp(18px, 1.6vw, 32px); font-weight: 700; color: var(--ink-2); }
.t-time {
  font-size: min(30vh, 19vw); font-weight: 800; line-height: .95; letter-spacing: -.04em;
  font-variant-numeric: tabular-nums; color: var(--ink);
}
.t-time.low { color: var(--accent); }
.t-done {
  font-size: clamp(26px, 3.4vw, 64px); font-weight: 800; color: var(--accent); letter-spacing: -.03em;
}
.t-card.ended { animation: pulse 1.6s ease-in-out infinite; }
@keyframes pulse {
  0%, 100% { box-shadow: var(--shadow), 0 0 0 0 rgba(108, 76, 224, .0); }
  50% { box-shadow: var(--shadow), 0 0 0 1.4vw rgba(108, 76, 224, .28); }
}
.t-ctrl { display: flex; gap: 1vw; flex-wrap: wrap; justify-content: center; }
.t-ctrl .btn { font-size: clamp(16px, 1.35vw, 26px); padding: 1.4vh 1.8vw; border-radius: 16px; }
.t-ctrl .btn.main { min-width: 11vw; }
.t-sound { position: absolute; top: 2vh; right: 1.6vw; border: 0; background: #f3f1f7; color: var(--ink-3); border-radius: 999px; padding: 6px 14px; font-size: clamp(12px, .85vw, 15px); font-weight: 600; }
.t-sound.on { background: var(--accent-soft); color: var(--accent-2); }
.t-qrbtn { position: absolute; top: 2vh; left: 1.6vw; border: 0; background: #f3f1f7; color: var(--ink-3); border-radius: 999px; padding: 6px 14px; font-size: clamp(12px, .85vw, 15px); font-weight: 600; }
.t-qrbtn.on { background: var(--accent-soft); color: var(--accent-2); }
.phases { display: grid; grid-template-columns: 8fr 4fr 3fr; gap: 1vw; }
.phase {
  background: rgba(255,255,255,.6); border-radius: 18px; padding: 1.6vh 1.4vw; position: relative; overflow: hidden;
  transition: background .3s, transform .3s, box-shadow .3s;
}
.phase .fill { position: absolute; left: 0; top: 0; bottom: 0; width: 0; background: rgba(108, 76, 224, .12); transition: width .5s linear; }
.phase .pt { position: relative; font-size: clamp(13px, 1vw, 20px); font-weight: 700; color: var(--ink-3); }
.phase .pn { position: relative; font-size: clamp(16px, 1.45vw, 30px); font-weight: 800; color: var(--ink-2); margin-top: .4vh; letter-spacing: -.02em; }
.phase.on { background: #fff; box-shadow: var(--shadow); }
.phase.on .pt { color: var(--accent); }
.phase.on .pn { color: var(--ink); }
.phase.past { opacity: .6; }
.chips { display: flex; flex-wrap: wrap; gap: .7vw; justify-content: center; align-items: center; }
.chips .lbl { font-size: clamp(17px, 1.35vw, 26px); font-weight: 700; color: var(--ink-2); margin-right: .4vw; }
.chip {
  background: rgba(255,255,255,.6); border-radius: 999px; padding: .9vh 1.2vw; font-size: clamp(15px, 1.2vw, 24px);
  font-weight: 700; color: var(--ink-3); min-width: 5.5vw; text-align: center;
}
.chip.yes { background: #fff; color: var(--ok); box-shadow: 0 2px 8px rgba(31,138,76,.15); }
.chip.locked { background: var(--ink); color: #fff; }

/* 타이머 옆 QR 띠 */
.qr-strip { width: clamp(300px, 26vw, 520px); flex: none; padding: 2vh 1.2vw; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 1.2vh; }
.qr-strip h3 { margin: 0; font-size: clamp(14px, 1.05vw, 20px); text-align: center; color: var(--ink-2); }
.qr-strip .grid { flex: 1; min-height: 0; width: 100%; display: flex; flex-direction: column; align-items: center; justify-content: center; }
.qr-mini { width: 100%; height: 100%; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 1vh; min-height: 0; }
.qr-mini .qimg { flex: 1; min-height: 0; width: 100%; display: flex; align-items: center; justify-content: center; }
.qr-mini .qimg svg { width: min(100%, 42vh); height: auto; aspect-ratio: 1 / 1; max-height: 100%; display: block; }
.qr-mini b { font-size: clamp(15px, 1.15vw, 22px); line-height: 1.2; flex: none; color: var(--accent-2); }

/* QR 모드 */
.qr-head { text-align: center; }
.qr-head h2 { margin: 0; font-size: clamp(22px, 2vw, 40px); letter-spacing: -.03em; }
.qr-head p { margin: .6vh 0 0; font-size: clamp(17px, 1.35vw, 26px); color: var(--ink-2); }
.qr-grid { flex: 1; min-height: 0; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 1.8vh; }
.qr-cell { flex: 1; min-height: 0; width: min(90vw, 66vh); padding: 2.2vh 2vw 1.8vh; display: flex; flex-direction: column; align-items: center; justify-content: center; }
.qr-cell .qimg { flex: 1; min-height: 0; width: 100%; display: flex; align-items: center; justify-content: center; }
.qr-cell .qimg svg { height: 100%; width: auto; max-width: 100%; aspect-ratio: 1 / 1; display: block; }
.qr-cell b { font-size: clamp(20px, 1.8vw, 36px); font-weight: 800; letter-spacing: -.03em; margin-top: .8vh; color: var(--accent-2); }
.qr-cell b.yes, .qr-mini b.yes { color: var(--ok); }
.qr-fallback { font-size: 12px; word-break: break-all; color: var(--ink-3); }

/* 질문판 */
.b-bar { display: flex; justify-content: space-between; align-items: center; gap: 1vw; }
.b-bar h2 { margin: 0; font-size: clamp(22px, 2vw, 40px); letter-spacing: -.03em; }
.b-bar .sub { font-size: clamp(17px, 1.35vw, 26px); color: var(--ink-2); margin-left: 1vw; font-weight: 600; }
.b-actions { display: flex; gap: .8vw; }
.b-actions .btn { font-size: clamp(15px, 1.15vw, 22px); padding: 1.2vh 1.5vw; }
.b-grid { flex: 1; min-height: 0; display: grid; gap: 2vh 1.6vw; }
.tile {
  position: relative; border: 0; border-radius: 28px; box-shadow: var(--shadow);
  display: flex; align-items: center; justify-content: center; flex-direction: column;
  font-size: clamp(34px, 4.6vw, 96px); font-weight: 800; letter-spacing: -.03em;
  transition: transform .18s, opacity .25s, box-shadow .2s, filter .2s; min-height: 0;
}
.tile:hover { transform: translateY(-4px) scale(1.015); }
.tile .num {
  position: absolute; top: 1.6vh; left: 1.2vw; font-size: clamp(18px, 1.6vw, 32px); font-weight: 700;
  background: rgba(255,255,255,.85); color: var(--ink); border-radius: 999px; padding: .3vh .8vw;
}
.tile .done { font-size: clamp(18px, 1.5vw, 28px); font-weight: 700; margin-top: .8vh; display: none; }
.tile.revealed {
  background: rgba(255,255,255,.55) !important;
  color: var(--ink-3) !important;
  border: 2px dashed rgba(20,20,20,.18);
  box-shadow: none;
}
.tile.revealed .done { display: block; }
.tile.spot { transform: scale(1.06); box-shadow: 0 0 0 .6vw #fff, var(--shadow); }
.b-empty { flex: 1; display: grid; place-items: center; text-align: center; padding: 4vh; }
.b-empty h3 { font-size: clamp(24px, 2.4vw, 48px); margin: 0 0 1.4vh; letter-spacing: -.03em; }
.b-empty p { font-size: clamp(16px, 1.3vw, 26px); color: var(--ink-2); margin: 0 auto 3vh; line-height: 1.6; max-width: 40em; }
.b-empty .btn { font-size: clamp(18px, 1.6vw, 30px); padding: 1.8vh 3vw; }
.b-note { background: #fff8e6; color: #7a4b00; border-radius: 14px; padding: 1vh 1.2vw; font-size: clamp(13px, .95vw, 18px); font-weight: 600; display: flex; align-items: center; gap: 1vw; }
.b-note .btn { font-size: inherit; padding: .7vh 1vw; }

/* 공개 화면 */
.reveal { position: fixed; inset: 0; z-index: 50; display: grid; place-items: center; padding: 5vh 5vw; perspective: 1600px; }
.reveal .rc {
  width: min(84vw, 1600px); min-height: 60vh; max-height: 88vh; background: #fff; border-radius: 36px;
  box-shadow: 0 30px 80px rgba(0,0,0,.25); padding: 6vh 5vw 5vh; display: flex; flex-direction: column;
  animation: flipIn .7s cubic-bezier(.2,.8,.2,1) both; transform-origin: center;
}
@keyframes flipIn {
  0% { transform: rotateY(-80deg) scale(.6); opacity: 0; }
  60% { opacity: 1; }
  100% { transform: rotateY(0) scale(1); opacity: 1; }
}
.rc-top { display: flex; justify-content: space-between; align-items: center; }
.rc-color { display: inline-flex; align-items: center; gap: .8vw; font-size: clamp(18px, 1.6vw, 32px); font-weight: 800; }
.rc-color i { width: 1.6vw; height: 1.6vw; min-width: 18px; min-height: 18px; border-radius: 50%; display: inline-block; border: 1.5px solid rgba(20,20,20,.18); }
.rc-text {
  flex: 1; display: flex; align-items: center; justify-content: center; text-align: center;
  font-weight: 800; letter-spacing: -.035em; line-height: 1.38; white-space: pre-wrap; padding: 3vh 0;
}
.rc-foot { display: flex; justify-content: center; gap: 1vw; }
.rc-foot .btn { font-size: clamp(16px, 1.25vw, 24px); padding: 1.3vh 2vw; }

/* PIN */
.pin-wrap { position: fixed; inset: 0; display: grid; place-items: center; z-index: 80; padding: 16px; }
.pin-card { width: min(420px, 100%); padding: 34px 30px; text-align: center; }
.pin-card h1 { font-size: 26px; margin: 10px 0 6px; letter-spacing: -.03em; }
.pin-card p { color: var(--ink-2); margin: 0 0 20px; }
.pin-card input {
  width: 100%; font-size: 30px; letter-spacing: .4em; text-align: center; padding: 12px; border-radius: 14px;
  border: 2px solid var(--line); margin-bottom: 14px; font-weight: 800;
}
.pin-card input:focus { outline: none; border-color: var(--accent); }
.pin-card .btn { width: 100%; }
.pin-err { color: #b42318; min-height: 22px; margin-top: 10px; font-size: 15px; }

/* 관리 서랍 */
.drawer-bg { position: fixed; inset: 0; background: rgba(20,20,20,.3); z-index: 60; }
.drawer {
  position: fixed; top: 0; right: 0; bottom: 0; width: min(560px, 100vw); background: #fff; z-index: 61;
  box-shadow: -10px 0 40px rgba(0,0,0,.15); display: flex; flex-direction: column; font-size: 15px;
}
.dr-head { display: flex; justify-content: space-between; align-items: center; padding: 18px 22px; border-bottom: 1px solid var(--line); }
.dr-head h2 { margin: 0; font-size: 20px; }
.dr-body { flex: 1; overflow-y: auto; padding: 16px 22px 30px; }
.dr-sec { margin-bottom: 22px; }
.dr-sec h3 { font-size: 14px; color: var(--ink-3); margin: 0 0 10px; font-weight: 700; }
.dr-row { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; margin-bottom: 8px; }
.dr-row .btn { font-size: 14px; padding: 9px 14px; border-radius: 10px; }
.dr-row select, .dr-row input[type=number] { font-size: 15px; padding: 8px 10px; border-radius: 10px; border: 1px solid var(--line); }
.q-item { border: 1px solid var(--line); border-radius: 14px; padding: 12px 14px; margin-bottom: 10px; }
.q-item .qh { display: flex; justify-content: space-between; align-items: center; margin-bottom: 6px; }
.q-item .qg { font-weight: 800; }
.q-item .qt { white-space: pre-wrap; line-height: 1.55; }
.q-item .qe { color: var(--ink-3); }
.q-item .qtime { font-size: 12px; color: var(--ink-3); }
.q-item textarea { width: 100%; min-height: 80px; border: 1px solid var(--line); border-radius: 10px; padding: 8px 10px; font-size: 15px; line-height: 1.5; margin: 6px 0; }
.q-item .acts { display: flex; gap: 6px; justify-content: flex-end; margin-top: 6px; }
.q-item .acts .btn { font-size: 13px; padding: 7px 12px; border-radius: 9px; }
.dr-msg { font-size: 14px; color: var(--accent-2); min-height: 20px; }
.toast {
  position: fixed; left: 50%; bottom: 3vh; transform: translateX(-50%); background: var(--ink); color: #fff;
  padding: 12px 22px; border-radius: 999px; font-size: 16px; font-weight: 600; z-index: 90; box-shadow: var(--shadow);
}
.net-warn { position: fixed; left: 50%; top: 1vh; transform: translateX(-50%); background: #fff3e0; color: #8a4b00; border-radius: 999px; padding: 6px 16px; font-size: 14px; font-weight: 600; z-index: 70; }
body.admin-only .h-app { display: none !important; }
body.admin-only #drawer-bg { display: none !important; }
body.admin-only #drawer {
  position: static;
  width: min(680px, 100%);
  height: 100vh;
  margin: 0 auto;
  box-shadow: var(--shadow);
}
body.admin-only #admin-close { display: none !important; }
