/* ── SOOP 챌린지배틀 공통 스타일 ─────────────────────── */
@import url('https://cdn.jsdelivr.net/gh/orioncactus/pretendard@v1.3.9/dist/web/variable/pretendardvariable-dynamic-subset.min.css');

:root {
  --bg: #0b0f14;
  --bg-soft: #111722;
  --card: #151d2a;
  --card-2: #1a2433;
  --line: #263245;
  --text: #e8eef7;
  --text-dim: #93a3b8;
  --accent: #1ec997;
  --accent-2: #17a980;
  --accent-soft: rgba(30, 201, 151, 0.12);
  --gold: #ffc94d;
  --danger: #ff6b6b;
  --blue: #4da3ff;
  --radius: 14px;
  --shadow: 0 10px 30px rgba(0, 0, 0, 0.35);
}

* { box-sizing: border-box; }
html, body { margin: 0; padding: 0; }
body {
  background:
    radial-gradient(1200px 600px at 80% -10%, rgba(30, 201, 151, 0.08), transparent 60%),
    radial-gradient(900px 500px at -10% 110%, rgba(77, 163, 255, 0.06), transparent 60%),
    var(--bg);
  color: var(--text);
  font-family: 'Pretendard Variable', Pretendard, 'Malgun Gothic', -apple-system, sans-serif;
  min-height: 100vh;
  line-height: 1.5;
}

a { color: var(--accent); text-decoration: none; }
button { font-family: inherit; }

.container { max-width: 1080px; margin: 0 auto; padding: 24px 20px 64px; }

/* ── 헤더 ── */
.topbar {
  display: flex; align-items: center; justify-content: space-between; gap: 10px;
  padding: 14px 0; margin-bottom: 20px;
}
.brand { display: flex; align-items: center; gap: 10px; font-weight: 800; font-size: 18px; color: var(--text); }
.brand .logo {
  width: 34px; height: 34px; border-radius: 9px; display: inline-flex; align-items: center; justify-content: center;
  background: linear-gradient(135deg, var(--accent), #0f8f6b); color: #04110c; font-weight: 900; font-size: 16px;
}
.brand small { color: var(--text-dim); font-weight: 600; font-size: 12px; }

.userchip { display: flex; align-items: center; gap: 10px; background: var(--card); border: 1px solid var(--line); padding: 6px 12px 6px 6px; border-radius: 999px; }
.userchip .nick { font-weight: 700; font-size: 14px; }
.userchip .sub { color: var(--text-dim); font-size: 12px; }

.avatar { border-radius: 50%; object-fit: cover; background: var(--card-2); }
.avatar-fallback {
  display: inline-flex; align-items: center; justify-content: center;
  width: 40px; height: 40px; border-radius: 50%;
  background: linear-gradient(135deg, #2a3a52, #1c2838); color: var(--text-dim); font-weight: 800;
}

/* ── 카드/버튼/입력 ── */
.card {
  background: var(--card); border: 1px solid var(--line); border-radius: var(--radius);
  padding: 22px; box-shadow: var(--shadow);
}
.card h2 { margin: 0 0 6px; font-size: 18px; }
.card h3 { margin: 0 0 10px; font-size: 15px; }
.card .desc { color: var(--text-dim); font-size: 13px; margin: 0 0 14px; }

.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  background: var(--card-2); color: var(--text); border: 1px solid var(--line);
  padding: 10px 16px; border-radius: 10px; font-size: 14px; font-weight: 700; cursor: pointer;
  transition: transform 0.06s ease, background 0.15s ease, border-color 0.15s ease;
}
.btn:hover { border-color: var(--accent-2); }
.btn:active { transform: translateY(1px); }
.btn:disabled { opacity: 0.5; cursor: not-allowed; }
.btn-primary { background: linear-gradient(135deg, var(--accent), var(--accent-2)); border: none; color: #04110c; }
.btn-primary:hover { filter: brightness(1.08); }
.btn-danger { background: rgba(255, 107, 107, 0.12); border-color: rgba(255, 107, 107, 0.4); color: var(--danger); }
.btn-ghost { background: transparent; }
.btn-sm { padding: 6px 10px; font-size: 12px; border-radius: 8px; }
.btn-lg { padding: 14px 22px; font-size: 16px; border-radius: 12px; }
.btn-block { width: 100%; }

.input, select.input {
  width: 100%; background: var(--bg-soft); color: var(--text);
  border: 1px solid var(--line); border-radius: 10px; padding: 10px 12px; font-size: 14px; font-family: inherit;
  outline: none; transition: border-color 0.15s ease;
}
.input:focus { border-color: var(--accent-2); }
.input::placeholder { color: #5b6b80; }
label.field { display: block; margin-bottom: 12px; }
label.field .lbl { display: block; font-size: 12px; font-weight: 700; color: var(--text-dim); margin-bottom: 6px; }

.row { display: flex; gap: 10px; align-items: center; }
.row.wrap { flex-wrap: wrap; }
.grow { flex: 1; }
.muted { color: var(--text-dim); font-size: 13px; }
.mono { font-family: Consolas, 'Courier New', monospace; }

.badge {
  display: inline-flex; align-items: center; gap: 5px; padding: 3px 9px; border-radius: 999px;
  font-size: 11px; font-weight: 800; letter-spacing: 0.02em;
  background: var(--card-2); color: var(--text-dim); border: 1px solid var(--line);
}
.badge-live { background: rgba(255, 77, 90, 0.14); border-color: rgba(255, 77, 90, 0.45); color: #ff7b85; }
.badge-on { background: var(--accent-soft); border-color: rgba(30, 201, 151, 0.4); color: var(--accent); }
.badge-owner { background: rgba(255, 201, 77, 0.12); border-color: rgba(255, 201, 77, 0.4); color: var(--gold); }
.badge-demo { background: rgba(77, 163, 255, 0.12); border-color: rgba(77, 163, 255, 0.4); color: var(--blue); }

.dot { width: 8px; height: 8px; border-radius: 50%; display: inline-block; }
.dot-on { background: var(--accent); box-shadow: 0 0 8px var(--accent); }
.dot-off { background: #55657c; }

/* ── 랜딩 ── */
.hero { text-align: center; padding: 60px 20px 30px; }
.hero h1 { font-size: 40px; margin: 0 0 12px; line-height: 1.2; }
.hero h1 .accent { color: var(--accent); }
.hero p { color: var(--text-dim); font-size: 16px; margin: 0 auto 28px; max-width: 560px; }
.features { display: grid; grid-template-columns: repeat(auto-fit, minmax(220px, 1fr)); gap: 14px; margin: 34px auto 0; max-width: 860px; text-align: left; }
.feature { background: var(--card); border: 1px solid var(--line); border-radius: var(--radius); padding: 18px; }
.feature .ico { font-size: 22px; margin-bottom: 8px; }
.feature b { display: block; margin-bottom: 4px; font-size: 14px; }
.feature span { color: var(--text-dim); font-size: 13px; }

.login-panel { max-width: 420px; margin: 26px auto 0; }
.soop-btn {
  background: linear-gradient(135deg, #1ec997, #0f9dbb); border: none; color: #03120d;
  font-size: 16px; font-weight: 800; width: 100%; padding: 15px; border-radius: 12px; cursor: pointer;
}
.soop-btn:hover { filter: brightness(1.07); }
.divider { display: flex; align-items: center; gap: 12px; color: #5b6b80; font-size: 12px; margin: 18px 0; }
.divider::before, .divider::after { content: ''; height: 1px; background: var(--line); flex: 1; }

/* ── 메인 (방 생성/참가) ── */
.main-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 18px; margin-top: 10px; }
@media (max-width: 760px) { .main-grid { grid-template-columns: 1fr; } }
.big-ico { font-size: 28px; margin-bottom: 10px; }

.room-list { margin-top: 18px; display: flex; flex-direction: column; gap: 10px; }
.room-item {
  display: flex; align-items: center; gap: 14px; background: var(--card); border: 1px solid var(--line);
  border-radius: 12px; padding: 14px 16px; cursor: pointer; transition: border-color 0.15s ease;
}
.room-item:hover { border-color: var(--accent-2); }
.room-item .code { font-weight: 800; letter-spacing: 0.12em; color: var(--accent); font-size: 15px; }
.room-item .title { font-weight: 700; }

.notice { background: rgba(255, 201, 77, 0.08); border: 1px solid rgba(255, 201, 77, 0.3); border-radius: 12px; padding: 14px 16px; font-size: 13px; margin-bottom: 16px; }
.error-box { background: rgba(255, 107, 107, 0.1); border: 1px solid rgba(255, 107, 107, 0.35); border-radius: 12px; padding: 14px 16px; font-size: 13px; margin-bottom: 16px; color: #ffb3b3; }

/* ── 방 대시보드 ── */
/* 좌측 컬럼 440px = 기존 400px + 10% — 오버레이 설정 세그먼트가 2줄로 접히지 않게 */
.room-grid { display: grid; grid-template-columns: 440px 1fr; gap: 18px; align-items: start; margin-top: 18px; }
@media (max-width: 1020px) { .room-grid { grid-template-columns: 1fr; } }
.stack { display: flex; flex-direction: column; gap: 18px; }

/* 방 헤더 */
.room-head {
  display: flex; align-items: center; justify-content: space-between; gap: 18px; flex-wrap: wrap;
  background: linear-gradient(135deg, rgba(30, 201, 151, 0.09), rgba(77, 163, 255, 0.05)), var(--card);
  border: 1px solid var(--line); border-radius: var(--radius); padding: 18px 22px; box-shadow: var(--shadow);
}
.rh-left { min-width: 0; }
.rh-title-row { display: flex; align-items: center; gap: 10px; min-width: 0; }
.rh-title-row h1 { margin: 0; font-size: 22px; line-height: 1.3; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.rh-meta { display: flex; align-items: center; gap: 8px; margin-top: 8px; flex-wrap: wrap; }
.rh-right { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; }

.invite-box {
  display: flex; align-items: center; gap: 10px;
  background: var(--bg-soft); border: 1px solid var(--line); border-radius: 12px; padding: 8px 12px;
}
.invite-box .invite-lbl { font-size: 11px; font-weight: 800; color: var(--text-dim); letter-spacing: 0.04em; }

/* 카드 공통 헤더 */
.card-head { display: flex; align-items: center; gap: 8px; margin-bottom: 6px; }
.card-head .ico { font-size: 17px; }
.card-head h3 { margin: 0; font-size: 15px; }

.btn-icon { padding: 10px 12px; font-size: 14px; line-height: 1; }

/* 오버레이 URL 마스킹 입력 */
.overlay-url input[type='password'] { letter-spacing: 0.15em; }

/* OBS 가이드 아코디언 */
.obs-guide { margin-top: 12px; border: 1px dashed var(--line); border-radius: 10px; padding: 10px 14px; }
.obs-guide summary { cursor: pointer; font-size: 13px; font-weight: 700; color: var(--text-dim); user-select: none; }
.obs-guide summary:hover { color: var(--text); }
.obs-guide ol { margin: 10px 0 4px; padding-left: 18px; font-size: 13px; color: var(--text-dim); display: flex; flex-direction: column; gap: 5px; }
.obs-guide b { color: var(--text); }

/* 현황 빈 상태 안내 */
.empty-hint {
  border: 1px dashed var(--line); border-radius: 12px; padding: 16px 18px; margin-bottom: 12px;
  font-size: 13px; color: var(--text-dim); background: var(--bg-soft);
}
.empty-hint b { color: var(--accent); }

/* 후원 수신 플래시 */
.stand-card { overflow: hidden; }
.stand-card.flash { animation: stand-flash 0.9s ease-out; }
@keyframes stand-flash {
  0% { box-shadow: inset 0 0 0 2px var(--accent); background: rgba(30, 201, 151, 0.10); }
  100% { box-shadow: inset 0 0 0 0 transparent; }
}
.stand-gift-float {
  position: absolute; right: 16px; top: 10px; font-size: 14px; font-weight: 900; color: var(--accent);
  animation: stand-gift-up 1.4s ease-out forwards; pointer-events: none;
}
@keyframes stand-gift-up {
  0% { transform: translateY(4px); opacity: 0; }
  20% { transform: translateY(0); opacity: 1; }
  100% { transform: translateY(-24px); opacity: 0; }
}

.code-pill {
  display: inline-flex; align-items: center; gap: 8px; background: var(--accent-soft);
  border: 1px solid rgba(30, 201, 151, 0.35); color: var(--accent); font-weight: 800; letter-spacing: 0.14em;
  padding: 6px 14px; border-radius: 999px; font-size: 15px; cursor: pointer;
}
.code-pill:hover { filter: brightness(1.1); }

/* ── 오버레이 배치 설정 ─────────────────────────────── */
.ov-config { display: flex; flex-direction: column; gap: 8px; margin-bottom: 12px; }
.ovc-row { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }
.ovc-lbl { font-size: 12px; font-weight: 700; color: var(--text-dim); flex: none; }
/* ── 도전미션 목록 (5줄 노출 + 스크롤, on/off 토글) ───── */
/* 한 줄 = 패딩 16 + 내용 24 + 테두리 2 ≈ 42px, gap 8px → 5줄 = 42*5 + 8*4 = 242px */
.mission-scroll {
  max-height: 242px; overflow-y: auto; padding-right: 4px;
  scrollbar-width: thin; scrollbar-color: var(--line) transparent;
}
.mission-scroll::-webkit-scrollbar { width: 8px; }
.mission-scroll::-webkit-scrollbar-thumb { background: var(--line); border-radius: 4px; }

.mission-row { cursor: pointer; transition: border-color 0.15s, background 0.15s; }
.mission-row:hover { border-color: var(--accent); }
.mission-row.on { border-color: var(--accent); background: var(--accent-soft); }
.mission-title { min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.mission-cnt { flex: none; font-variant-numeric: tabular-nums; font-size: 12px; }

.switch {
  flex: none; width: 38px; height: 22px; border-radius: 999px; padding: 0;
  background: var(--card-2); border: 1px solid var(--line); cursor: pointer;
  position: relative; transition: background 0.18s, border-color 0.18s;
}
.switch > span {
  position: absolute; top: 2px; left: 2px; width: 16px; height: 16px; border-radius: 50%;
  background: var(--text-dim); transition: transform 0.18s, background 0.18s;
}
.switch.on { background: var(--accent); border-color: var(--accent); }
.switch.on > span { transform: translateX(16px); background: #04110c; }
.switch:disabled { opacity: 0.5; cursor: progress; }
.switch:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }

/* 본문 안에 섞이는 보조 동작 (파괴적 동작은 눈에 덜 띄게) */
.btn-link {
  background: none; border: none; padding: 0; cursor: pointer;
  color: var(--text-dim); font-size: 12px; font-weight: 700; text-decoration: underline;
  text-underline-offset: 2px;
}
.btn-link:hover { color: var(--danger); }
.btn-link:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; border-radius: 3px; }

.ovc-group { display: flex; align-items: center; gap: 8px; }
.ovc-group.hidden { display: none; }
.ov-config .seg button { font-size: 12px; padding: 5px 9px; }

.ov-place { display: flex; align-items: center; gap: 14px; margin-bottom: 12px; }
.ov-frame {
  position: relative; width: 176px; height: 99px; flex: none;
  background: repeating-linear-gradient(45deg, #171d27 0 8px, #141a23 8px 16px);
  border: 1px solid var(--line); border-radius: 8px; overflow: hidden;
}
.ov-frame-cap {
  position: absolute; right: 6px; bottom: 4px;
  font-size: 9.5px; color: #56637a; font-weight: 700; letter-spacing: 0.02em;
}
.ov-zone {
  position: absolute; border-radius: 4px;
  background: rgba(30, 201, 151, 0.28); border: 1px solid var(--accent);
  transition: all 0.25s cubic-bezier(0.22, 1, 0.36, 1);
}
.ov-sizebox { min-width: 0; }
.ovs-lbl { font-size: 11.5px; font-weight: 700; color: var(--text-dim); }
.ovs-val { font-size: 19px; font-weight: 900; color: var(--accent); font-variant-numeric: tabular-nums; line-height: 1.3; }
.ovs-desc { margin: 2px 0 0; font-size: 12px; color: var(--text-dim); line-height: 1.45; }

@media (max-width: 560px) {
  .ov-place { flex-direction: column; align-items: flex-start; }
}

.overlay-url { display: flex; gap: 8px; }
.overlay-url input { flex: 1; font-size: 12px; color: var(--text-dim); }

.seg { display: flex; background: var(--bg-soft); border: 1px solid var(--line); border-radius: 10px; padding: 3px; gap: 3px; }
.seg button {
  flex: 1; background: transparent; border: none; color: var(--text-dim); font-weight: 700; font-size: 13px;
  padding: 7px 4px; border-radius: 8px; cursor: pointer;
  white-space: nowrap; /* 버튼 이름이 두 줄로 접히지 않게 */
}
.seg button.active { background: var(--accent); color: #04110c; }

.plist { display: flex; flex-direction: column; gap: 8px; }
.plist-item { display: flex; align-items: center; gap: 10px; background: var(--bg-soft); border: 1px solid var(--line); border-radius: 10px; padding: 8px 12px; font-size: 13px; }

/* 실시간 현황 카드 */
.standings { display: flex; flex-direction: column; gap: 12px; }
.stand-card {
  position: relative; background: var(--card); border: 1px solid var(--line); border-radius: var(--radius);
  padding: 16px 18px; transition: border-color 0.2s ease;
}
.stand-card.rank-1 { border-color: rgba(255, 201, 77, 0.55); background: linear-gradient(180deg, rgba(255, 201, 77, 0.06), var(--card)); }
.stand-head { display: flex; align-items: center; gap: 12px; }
.rank-num { font-size: 20px; font-weight: 900; width: 34px; text-align: center; color: var(--text-dim); }
.rank-1 .rank-num { color: var(--gold); }
.stand-head .who { flex: 1; min-width: 0; }
.stand-head .nick { font-weight: 800; font-size: 15px; display: flex; align-items: center; gap: 7px; }
.stand-head .mission { color: var(--text-dim); font-size: 12px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.stand-sum { text-align: right; }
.stand-sum .num { font-size: 20px; font-weight: 900; color: var(--accent); }
.stand-sum .unit { font-size: 11px; color: var(--text-dim); }
.chip { display: inline-block; padding: 1px 8px; border-radius: 999px; font-size: 10px; font-weight: 800; }
.chip-active { background: var(--accent-soft); color: var(--accent); }
.chip-success { background: rgba(77, 163, 255, 0.15); color: var(--blue); }
.chip-fail { background: rgba(255, 107, 107, 0.15); color: var(--danger); }
.chip-idle { background: var(--card-2); color: var(--text-dim); }

.top-donors { margin-top: 10px; border-top: 1px dashed var(--line); padding-top: 10px; display: flex; flex-direction: column; gap: 5px; }
.top-row { display: flex; align-items: center; gap: 8px; font-size: 12px; }
.top-row .medal { width: 20px; text-align: center; }
.top-row .tnick { flex: 1; min-width: 0; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; color: var(--text); }
.top-row .tcnt { color: var(--text-dim); font-weight: 700; }

.goalbar { margin-top: 8px; height: 6px; border-radius: 4px; background: var(--bg-soft); overflow: hidden; }
.goalbar > div { height: 100%; background: linear-gradient(90deg, var(--accent), var(--accent-2)); border-radius: 4px; transition: width 0.5s ease; }

/* ── 토스트 ── */
/* ── 후원 안내 바 + 후원 모달 ───────────────────────── */
.support-bar {
  display: flex; align-items: center; gap: 12px;
  background: linear-gradient(135deg, var(--accent-soft), rgba(77, 163, 255, 0.07));
  border: 1px solid var(--line); border-radius: 12px;
  padding: 11px 14px; margin-bottom: 20px;
}
.support-bar .sb-ico { font-size: 20px; flex: none; line-height: 1; }
.support-bar .sb-txt { min-width: 0; font-size: 13px; line-height: 1.5; }
.support-bar .sb-txt b { display: block; color: var(--text); font-weight: 800; }
.support-bar .sb-txt span { color: var(--text-dim); }
.support-bar .sb-btn { flex: none; margin-left: auto; white-space: nowrap; }

.modal-backdrop {
  position: fixed; inset: 0; z-index: 9998;
  background: rgba(4, 8, 14, 0.72); backdrop-filter: blur(3px);
  display: flex; align-items: center; justify-content: center; padding: 20px;
  animation: fade-in 0.16s ease-out;
}
@keyframes fade-in { from { opacity: 0; } to { opacity: 1; } }
.modal {
  background: var(--card); border: 1px solid var(--line); border-radius: var(--radius);
  box-shadow: var(--shadow); padding: 20px 22px 18px;
  width: 100%; max-width: 520px; max-height: 90vh; overflow-y: auto;
}
.modal-head { display: flex; align-items: center; gap: 10px; margin-bottom: 8px; }
.modal-head h3 { margin: 0; font-size: 18px; font-weight: 800; }
.modal-head .btn-icon { margin-left: auto; }
.modal-desc { margin: 0 0 16px; font-size: 13.5px; color: var(--text-dim); line-height: 1.6; }
.modal-desc b { color: var(--text); }
.modal-foot { margin: 14px 0 0; font-size: 12px; color: var(--text-dim); text-align: center; }

.sp-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
.sp-card {
  display: flex; flex-direction: column; align-items: center; gap: 4px;
  background: var(--bg-soft); border: 1px solid var(--line); border-radius: 12px;
  padding: 12px; color: var(--text); text-decoration: none;
  transition: border-color 0.15s, transform 0.15s;
}
.sp-card:hover { border-color: var(--accent); transform: translateY(-2px); }
.sp-card:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }
.sp-card img {
  width: 100%; aspect-ratio: 1; object-fit: contain;
  background: #fff; border-radius: 8px; padding: 6px;
}
.sp-card b { font-size: 13.5px; font-weight: 800; margin-top: 6px; }
.sp-card span { font-size: 11.5px; color: var(--text-dim); }

@media (max-width: 520px) {
  .support-bar { flex-wrap: wrap; }
  .support-bar .sb-btn { margin-left: 0; width: 100%; }
  .sp-grid { grid-template-columns: 1fr; }
}

#toast-host { position: fixed; right: 18px; bottom: 18px; display: flex; flex-direction: column; gap: 8px; z-index: 9999; }
.toast {
  background: var(--card-2); border: 1px solid var(--line); color: var(--text);
  padding: 11px 16px; border-radius: 10px; font-size: 13px; font-weight: 600; box-shadow: var(--shadow);
  opacity: 0; transform: translateY(8px); transition: all 0.25s ease; max-width: 340px;
}
.toast.show { opacity: 1; transform: translateY(0); }
.toast-error { border-color: rgba(255, 107, 107, 0.5); }
.toast-success { border-color: rgba(30, 201, 151, 0.5); }

.hidden { display: none !important; }
.spin { display: inline-block; width: 14px; height: 14px; border: 2px solid var(--line); border-top-color: var(--accent); border-radius: 50%; animation: spin 0.8s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }
