:root {
  color-scheme: light;
  --bg: #f7f8f9;
  --panel: #ffffff;
  --border: #e3e4e8;
  --border-strong: #cfd1d7;
  --text: #1b1c20;
  --text-2: #5d6068;
  --text-3: #8b8f98;
  --accent: #00bfb2;
  --accent-hover: #00aa9e;
  --accent-soft: #e6f8f7;
  --accent-text: #00857c;
  --danger: #d1453b;
  --radius: 8px;
  --shadow: 0 1px 2px rgba(20, 21, 30, 0.04);
}

* { box-sizing: border-box; }
[hidden] { display: none !important; }

html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font-family: "Pretendard Variable", Pretendard, -apple-system, BlinkMacSystemFont, "Apple SD Gothic Neo", "Malgun Gothic", sans-serif;
  font-size: 14px;
  line-height: 1.5;
  word-break: keep-all;
  -webkit-font-smoothing: antialiased;
}
h1 { margin: 0; font-size: 22px; font-weight: 600; letter-spacing: -0.02em; }
.muted { color: var(--text-2); }
button, input, select { font: inherit; color: inherit; }

/* 공통 컨트롤 */
.btn {
  height: 34px;
  padding: 0 14px;
  border: 1px solid var(--border);
  border-radius: 6px;
  background: var(--panel);
  font-weight: 500;
  cursor: pointer;
  white-space: nowrap;
  transition: background-color .12s, border-color .12s, opacity .12s;
}
.btn:hover { background: #f4f5f7; }
.btn.primary { background: var(--accent); border-color: var(--accent); color: #fff; font-weight: 600; }
.btn.primary:hover { background: var(--accent-hover); }
.btn:disabled { opacity: .4; cursor: not-allowed; }
.btn.primary:disabled:hover { background: var(--accent); }
.btn.ghost { border-color: transparent; background: transparent; color: var(--text-2); padding: 0 10px; }
.btn.ghost:hover { background: #eef0f2; color: var(--text); }

input, select {
  width: 100%;
  height: 38px;
  padding: 0 12px;
  border: 1px solid var(--border);
  border-radius: 6px;
  background: var(--panel);
  outline: none;
  transition: border-color .12s, box-shadow .12s;
}
select {
  appearance: none;
  padding-right: 32px;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' viewBox='0 0 12 12'%3E%3Cpath d='M3 4.5l3 3 3-3' fill='none' stroke='%238b8f98' stroke-width='1.5' stroke-linecap='round' stroke-linejoin='round'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 10px center;
  text-overflow: ellipsis;
  cursor: pointer;
}
select:has(option[value=""]:checked) { color: var(--text-3); }
input::placeholder { color: var(--text-3); }
input:hover, select:hover { border-color: var(--border-strong); }
input:focus, select:focus, .btn:focus-visible, .slogan:focus-visible, .slot:focus-visible {
  border-color: var(--accent);
  box-shadow: 0 0 0 3px rgba(0, 191, 178, .22);
  outline: none;
}

/* 1단계: 참여자 정보 */
.narrow { max-width: 720px; margin: 0 auto; padding: 72px 24px 48px; }
.page-head { margin-bottom: 24px; }
.page-head p { margin: 6px 0 0; }
.card {
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 8px 24px 24px;
}
.field { padding: 16px 0 0; }
.field label { display: block; margin-bottom: 6px; font-size: 13px; font-weight: 500; }
.hint { margin: 6px 0 0; font-size: 12px; color: var(--text-3); }
.error { margin: 6px 0 0; font-size: 12px; color: var(--danger); }
.error:empty { display: none; }
.team-selects { display: flex; gap: 8px; }
.team-selects select { flex: 1 1 0; min-width: 0; }
.actions { display: flex; justify-content: flex-end; margin-top: 24px; }

.badge {
  display: inline-flex;
  align-items: center;
  height: 20px;
  padding: 0 7px;
  border-radius: 4px;
  background: var(--accent-soft);
  color: var(--accent-text);
  font-size: 12px;
  font-weight: 600;
  letter-spacing: 0;
  white-space: nowrap;
}
h1 .badge { margin-left: 4px; vertical-align: 3px; }
.notice {
  display: flex;
  gap: 12px;
  align-items: flex-start;
  margin-bottom: 16px;
  padding: 14px 16px;
  border: 1px solid var(--accent);
  border-radius: var(--radius);
  background: var(--accent-soft);
}
.notice svg { flex: none; margin-top: 1px; color: var(--accent-text); }
.notice strong { display: block; font-weight: 600; }
.notice p { margin: 2px 0 0; color: var(--text-2); font-size: 13px; }

/* 2단계: 슬로건 선택 */
.vote-bar {
  position: sticky;
  top: 0;
  z-index: 10;
  background: rgba(255, 255, 255, .92);
  backdrop-filter: saturate(180%) blur(12px);
  -webkit-backdrop-filter: saturate(180%) blur(12px);
  border-bottom: 1px solid var(--border);
}
.vote-bar-inner {
  max-width: 760px;
  margin: 0 auto;
  padding: 10px 24px;
  display: grid;
  grid-template-columns: auto minmax(0, 1fr) auto;
  grid-template-areas: "back title submit" "slots slots slots";
  align-items: center;
  gap: 8px 12px;
}
#back { grid-area: back; margin-left: -10px; }
.vote-title { grid-area: title; display: flex; align-items: baseline; gap: 8px; white-space: nowrap; }
.counter { color: var(--text-3); font-variant-numeric: tabular-nums; }
.counter b { color: var(--accent-text); font-weight: 600; }
.vote-submit { grid-area: submit; display: flex; align-items: center; gap: 12px; }
.error.inline { margin: 0; }

.slots { grid-area: slots; display: grid; gap: 4px; }
.slot {
  display: flex;
  align-items: center;
  gap: 8px;
  height: 30px;
  padding: 0 8px 0 6px;
  border: 1px solid var(--accent);
  border-radius: 6px;
  background: var(--accent-soft);
  text-align: left;
  cursor: pointer;
  min-width: 0;
}
.slot-n {
  flex: none;
  width: 18px; height: 18px;
  border-radius: 4px;
  background: var(--accent);
  color: #fff;
  font-size: 11px;
  font-weight: 600;
  display: grid;
  place-items: center;
}
.slot-text { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.slot-x { flex: none; color: var(--text-3); font-size: 16px; line-height: 1; }
.slot:hover .slot-x { color: var(--text); }
.slot.empty { border: 1px dashed var(--border-strong); background: transparent; cursor: default; }
.slot.empty .slot-n { background: #eceef1; color: var(--text-3); }
.slot.empty .slot-x { display: none; }

.grid {
  max-width: 760px;
  margin: 0 auto;
  padding: 16px 24px 64px;
  display: grid;
  gap: 6px;
}
.slogan {
  display: flex;
  align-items: flex-start;
  gap: 8px;
  padding: 10px 12px;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: var(--panel);
  text-align: left;
  line-height: 1.45;
  word-break: keep-all;
  overflow-wrap: anywhere;
  cursor: pointer;
  transition: border-color .12s, background-color .12s, opacity .12s;
}
.slogan:hover { border-color: var(--border-strong); }
.slogan.on { border-color: var(--accent); background: var(--accent-soft); }
.slogan:disabled { opacity: .45; cursor: not-allowed; }
.slogan:disabled:hover { border-color: var(--border); }
.box {
  flex: none;
  width: 16px; height: 16px;
  margin-top: 2px;
  border: 1px solid var(--border-strong);
  border-radius: 4px;
  display: grid;
  place-items: center;
  font-size: 10px;
  font-weight: 700;
  color: #fff;
}
.slogan.on .box { background: var(--accent); border-color: var(--accent); }

/* 3단계: 완료 */
.done { text-align: center; padding-top: 120px; }
.done-sub { margin: 8px 0 0; }
.done-icon {
  width: 44px; height: 44px;
  margin: 0 auto 20px;
  border-radius: 50%;
  background: var(--accent-soft);
  color: var(--accent-text);
  display: grid;
  place-items: center;
}
.pick-list {
  max-width: 480px;
  margin: 28px auto 0;
  padding: 0;
  list-style: none;
  counter-reset: pick;
  text-align: left;
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: var(--radius);
}
.pick-list li {
  counter-increment: pick;
  display: flex;
  gap: 12px;
  padding: 12px 16px;
  word-break: keep-all;
}
.pick-list li + li { border-top: 1px solid var(--border); }
.pick-list li::before { content: counter(pick); color: var(--text-3); font-variant-numeric: tabular-nums; }

/* 관리자 */
.num { font-variant-numeric: tabular-nums; }
.login { max-width: 400px; padding-top: 120px; }
.login h1 { font-size: 18px; padding-top: 16px; }
.wide { max-width: 1200px; margin: 0 auto; padding: 48px 24px 64px; }
.result-head { display: flex; align-items: flex-end; justify-content: space-between; gap: 16px; }
.result-head p { margin: 4px 0 0; }
.result-head b { color: var(--text); font-weight: 600; }
.tabs { display: flex; gap: 20px; margin: 24px 0 16px; border-bottom: 1px solid var(--border); }
.tab {
  position: relative;
  padding: 8px 0 10px;
  border: 0;
  background: none;
  color: var(--text-2);
  font-weight: 500;
  cursor: pointer;
}
.tab:hover { color: var(--text); }
.tab[aria-selected="true"] { color: var(--text); }
.tab[aria-selected="true"]::after {
  content: "";
  position: absolute;
  left: 0; right: 0; bottom: -1px;
  height: 2px;
  background: var(--accent);
}
.tab-count { margin-left: 4px; color: var(--text-3); font-weight: 400; font-variant-numeric: tabular-nums; }
.no-data { padding: 40px 0; text-align: center; }

.rank-list, .people-list {
  margin: 0;
  padding: 0;
  list-style: none;
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
}
.rank-list:empty, .people-list:empty { display: none; }
.rank-row {
  display: grid;
  grid-template-columns: 32px minmax(0, 1fr) 96px;
  align-items: center;
  gap: 12px;
  padding: 10px 16px;
}
.rank-row + .rank-row, .person + .person { border-top: 1px solid var(--border); }
.rank { color: var(--text-3); text-align: right; }
.rank-row.top .rank { color: var(--accent-text); font-weight: 600; }
.rank-body { display: grid; gap: 6px; min-width: 0; }
.rank-text { word-break: keep-all; }
.bar { height: 4px; border-radius: 2px; background: #eef0f2; overflow: hidden; }
.bar i { display: block; height: 100%; background: var(--accent); border-radius: 2px; }
.votes { display: flex; justify-content: flex-end; align-items: baseline; gap: 8px; white-space: nowrap; }
.votes b { font-weight: 600; }
.votes span { color: var(--text-3); font-size: 12px; min-width: 32px; text-align: right; }

.person {
  display: grid;
  grid-template-columns: 300px minmax(0, 1fr);
  gap: 24px;
  padding: 14px 16px;
}
.who { display: grid; gap: 2px; align-content: start; min-width: 0; }
.who-top { display: flex; align-items: baseline; justify-content: space-between; gap: 8px; }
.time { color: var(--text-3); font-size: 12px; }
.team, .email { color: var(--text-2); font-size: 13px; overflow-wrap: anywhere; }
.email { color: var(--text-3); }
.picks { margin: 0; padding: 0; list-style: none; counter-reset: pick; display: grid; gap: 4px; }
.picks li { counter-increment: pick; display: flex; gap: 10px; word-break: keep-all; }
.picks li::before { content: counter(pick); color: var(--text-3); font-variant-numeric: tabular-nums; }

@media (max-width: 640px) {
  .narrow { padding: 40px 16px 32px; }
  .card { padding: 4px 16px 20px; }
  .team-selects { flex-direction: column; }
  .team-selects select { flex: none; }
  .actions .btn { width: 100%; height: 40px; }

  .vote-bar-inner { padding: 8px 16px; gap: 6px 12px; }
  .slot { height: 28px; font-size: 13px; }
  .vote-submit { gap: 8px; }
  .error.inline { max-width: 40vw; font-size: 11px; line-height: 1.3; }

  .grid { padding: 12px 16px 48px; gap: 6px; }
  .slogan { padding: 9px 10px; gap: 6px; font-size: 13px; }
  .box { width: 14px; height: 14px; margin-top: 2px; font-size: 9px; }
  .done { padding-top: 80px; }

  .login { padding-top: 64px; }
  .wide { padding: 32px 16px 48px; }
  .rank-row { grid-template-columns: 24px minmax(0, 1fr) auto; gap: 10px; padding: 10px 12px; }
  .person { grid-template-columns: minmax(0, 1fr); gap: 10px; padding: 12px; }
}
