:root {
  --navy: #122a52;
  --navy-2: #1c3a6e;
  --blue: #2f6bff;
  --blue-soft: #eaf1ff;
  --ink: #14213d;
  --muted: #6b7790;
  --line: #e4e9f2;
  --bg: #f5f7fb;
  --white: #ffffff;
  --gold: #ffb020;
  --heart: #ff4d6d;
  --shadow: 0 6px 24px rgba(18, 42, 82, 0.10);
}

* { box-sizing: border-box; }
html, body { margin: 0; padding: 0; }
body {
  font-family: "Pretendard", -apple-system, "Apple SD Gothic Neo", "Malgun Gothic", system-ui, sans-serif;
  background: var(--bg);
  color: var(--ink);
  -webkit-font-smoothing: antialiased;
}
a { color: inherit; }

/* ---------- 공통 헤더 ---------- */
.topbar {
  background: linear-gradient(100deg, var(--navy), var(--navy-2));
  color: #fff;
  padding: 16px 20px;
  display: flex;
  align-items: center;
  gap: 12px;
  box-shadow: var(--shadow);
}
.topbar h1 { font-size: 18px; margin: 0; font-weight: 800; letter-spacing: -0.3px; }
.topbar .count-pill {
  margin-left: auto;
  background: rgba(255,255,255,0.16);
  padding: 6px 14px;
  border-radius: 999px;
  font-weight: 700;
  font-size: 14px;
}

/* ---------- 참가자(제출) 페이지 ---------- */
.wrap { max-width: 640px; margin: 0 auto; padding: 18px 16px 60px; }

.card-form {
  background: var(--white);
  border-radius: 18px;
  padding: 20px;
  box-shadow: var(--shadow);
  margin-bottom: 22px;
}
.card-form h2 { margin: 0 0 4px; font-size: 19px; }
.card-form p.sub { margin: 0 0 16px; color: var(--muted); font-size: 13px; }
.field { margin-bottom: 12px; }
.field label { display: block; font-size: 13px; font-weight: 700; margin-bottom: 6px; color: var(--navy); }
.field input {
  width: 100%;
  padding: 13px 14px;
  border: 1.5px solid var(--line);
  border-radius: 12px;
  font-size: 16px; /* iOS 확대 방지 */
  outline: none;
  transition: border-color .15s;
}
.field input:focus { border-color: var(--blue); }
.btn {
  width: 100%;
  padding: 14px;
  border: none;
  border-radius: 12px;
  background: var(--blue);
  color: #fff;
  font-size: 16px;
  font-weight: 800;
  cursor: pointer;
  transition: transform .05s, filter .15s;
}
.btn:active { transform: scale(0.98); }
.btn:disabled { background: #9fb4d8; cursor: not-allowed; }
.form-msg { text-align: center; font-size: 13px; margin-top: 10px; min-height: 18px; }
.form-msg.ok { color: #1a9d5a; }
.form-msg.err { color: #d6324a; }

.section-title { font-size: 15px; font-weight: 800; color: var(--navy); margin: 4px 2px 12px; }

.list { display: flex; flex-direction: column; gap: 14px; }
.entry {
  background: var(--white);
  border-radius: 16px;
  overflow: hidden;
  box-shadow: var(--shadow);
  border: 1px solid var(--line);
}
.entry .thumb {
  position: relative;
  width: 100%;
  aspect-ratio: 16 / 10;          /* 노트북 화면비 */
  background: #f0f3f9;
  overflow: hidden;
  border-bottom: 1px solid var(--line);
}
.entry .thumb iframe {
  position: absolute; top: 0; left: 0;
  width: 1280px; height: 800px;   /* 데스크탑 폭으로 렌더 후 축소 */
  border: 0; transform-origin: 0 0;
  pointer-events: none;           /* 목록 스크롤 방해 방지 */
  background: #fff;
}
.entry .thumb .open-overlay {
  position: absolute; inset: 0;
  display: flex; align-items: flex-end; justify-content: flex-end;
  padding: 10px;
}
.entry .thumb .open-overlay a {
  background: rgba(18,42,82,0.85); color: #fff;
  text-decoration: none; font-size: 12px; font-weight: 700;
  padding: 7px 11px; border-radius: 999px;
}
.entry .body { padding: 12px 14px; display: flex; align-items: center; gap: 10px; }
.entry .name { font-weight: 800; font-size: 15px; flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.like-btn {
  display: inline-flex; align-items: center; gap: 7px;
  background: var(--blue-soft); color: var(--blue);
  border: none; border-radius: 999px; padding: 9px 15px;
  font-size: 15px; font-weight: 800; cursor: pointer;
  transition: transform .08s;
}
.like-btn .heart { font-size: 17px; }
.like-btn:active { transform: scale(1.12); }
.like-btn.liked { background: #ffe3ea; color: var(--heart); }

.empty { text-align: center; color: var(--muted); padding: 40px 0; font-size: 14px; }

/* ---------- 벽(프로젝터) 페이지 ---------- */
body.wall { background: #0c1a33; }
.wall-top {
  display: flex; align-items: center; gap: 20px;
  padding: 18px 26px; color: #fff;
}
.wall-top h1 { font-size: 22px; margin: 0; font-weight: 800; }
.wall-top .count-pill { background: rgba(255,255,255,0.14); }
.qr-box {
  margin-left: auto;
  display: flex; align-items: center; gap: 20px;
  background: #fff; color: var(--ink);
  padding: 16px 24px 16px 16px; border-radius: 18px;
  box-shadow: var(--shadow);
}
.qr-box #qrcode img, .qr-box #qrcode canvas { display: block; border-radius: 6px; }
.qr-box .qr-text { font-size: 16px; line-height: 1.45; }
.qr-box .qr-text b { display: block; font-size: 24px; color: var(--navy); margin-bottom: 4px; }
.qr-box .qr-text .url { font-size: 17px; color: var(--blue); font-weight: 700; word-break: break-all; max-width: 340px; }

.submit-cta {
  margin-left: auto;
  background: #fff; color: var(--ink);
  padding: 18px 30px; border-radius: 18px;
  box-shadow: var(--shadow); text-align: right;
}
.submit-cta-label { font-size: 24px; font-weight: 800; color: var(--navy); margin-bottom: 6px; }
.submit-cta-url { font-size: 36px; font-weight: 900; color: var(--blue); word-break: break-all; letter-spacing: -0.5px; }

.grid {
  display: flex; flex-wrap: wrap; gap: 18px;
  padding: 6px 26px 40px;
  align-items: flex-start;
}
.tile {
  flex: 1 1 480px; max-width: 640px;
  background: #fff; border-radius: 16px; overflow: hidden;
  box-shadow: 0 8px 30px rgba(0,0,0,0.35);
  display: flex; flex-direction: column;
  transition: box-shadow .2s, transform .2s;
}
.tile.crowned { outline: 4px solid var(--gold); box-shadow: 0 0 0 4px var(--gold), 0 10px 40px rgba(255,176,32,.5); }
.tile-head {
  display: flex; align-items: center; gap: 10px;
  padding: 11px 14px; background: var(--navy); color: #fff;
}
.tile-head .rank {
  width: 26px; height: 26px; border-radius: 8px;
  background: rgba(255,255,255,0.16);
  display: flex; align-items: center; justify-content: center;
  font-weight: 800; font-size: 13px; flex: 0 0 auto;
}
.tile-head .tname { font-weight: 800; font-size: 15px; flex: 1; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.tile-head .tlikes { font-weight: 800; font-size: 15px; color: #ffd1da; white-space: nowrap; }
.tile-head .crown { font-size: 17px; }
.tile-screen { position: relative; width: 100%; aspect-ratio: 16 / 10; overflow: hidden; background: #fff; }
.tile-screen iframe { position: absolute; top: 0; left: 0; width: 1280px; height: 800px; border: 0; transform-origin: 0 0; }
.tile-foot { display: flex; gap: 8px; padding: 9px 12px; background: #f6f8fc; border-top: 1px solid var(--line); }
.tile-foot button {
  flex: 1; border: none; border-radius: 9px; padding: 8px;
  font-weight: 700; font-size: 13px; cursor: pointer;
}
.tile-foot .spot { background: var(--blue-soft); color: var(--blue); }
.tile-foot .crownbtn { background: #fff4dc; color: #b07400; }

/* 스포트라이트 모달 */
.modal-back {
  position: fixed; inset: 0; background: rgba(6,14,28,0.92);
  display: none; align-items: center; justify-content: center; z-index: 50;
  padding: 24px;
}
.modal-back.show { display: flex; }
.modal {
  width: min(1100px, 96vw); height: min(88vh, 900px);
  background: #fff; border-radius: 18px; overflow: hidden;
  display: flex; flex-direction: column; box-shadow: 0 20px 80px rgba(0,0,0,.6);
}
.modal-head {
  display: flex; align-items: center; gap: 14px;
  padding: 14px 18px; background: var(--navy); color: #fff;
}
.modal-head h3 { margin: 0; font-size: 18px; flex: 1; }
.modal-head .mlikes { color: #ffd1da; font-weight: 800; }
.modal-head .close { background: rgba(255,255,255,.16); border: none; color: #fff; font-size: 18px; width: 38px; height: 38px; border-radius: 10px; cursor: pointer; }
.modal iframe { flex: 1; width: 100%; border: 0; }

.wall-empty { color: #aebfdc; text-align: center; width: 100%; padding: 80px 0; font-size: 17px; }

@media (max-width: 600px) {
  .wall-top { flex-wrap: wrap; }
  .qr-box { margin-left: 0; }
}

/* ---------- 뷰 전환 / 갤러리 (참가자) ---------- */
.hidden { display: none !important; }
.goto-gallery { text-align: center; font-size: 13px; color: var(--muted); margin: 18px 0 0; }
.goto-gallery a { color: var(--blue); font-weight: 700; text-decoration: none; }
.gallery-hero {
  background: linear-gradient(120deg, var(--blue), #5a86ff);
  color: #fff; border-radius: 18px; padding: 20px 22px; margin-bottom: 18px;
  box-shadow: var(--shadow);
}
.gallery-hero h2 { margin: 0 0 6px; font-size: 20px; }
.gallery-hero p { margin: 0; font-size: 13.5px; line-height: 1.6; opacity: .95; }
.mine-tag {
  display: inline-block; font-size: 10.5px; font-weight: 800; vertical-align: middle;
  background: var(--blue-soft); color: var(--blue); padding: 2px 7px; border-radius: 999px; margin-left: 4px;
}
.promo-banner {
  display: flex; align-items: center; gap: 14px;
  margin-top: 22px; padding: 16px 18px;
  background: #fff7ed; border: 1.5px solid #ffd8a8; border-radius: 16px;
  text-decoration: none; color: var(--ink); box-shadow: var(--shadow);
  transition: transform .1s;
}
.promo-banner:active { transform: scale(.99); }
.promo-banner .promo-emoji { font-size: 30px; }
.promo-banner .promo-text b { display: block; font-size: 15px; color: #b45309; }
.promo-banner .promo-text small { color: #c2410c; font-weight: 700; }

/* ---------- 🏆 1등 발표 연출 (벽) ---------- */
.winner-back {
  position: fixed; inset: 0; z-index: 80;
  display: none; align-items: center; justify-content: center;
  background: radial-gradient(circle at 50% 30%, rgba(28,58,110,.92), rgba(6,14,28,.97));
  padding: 24px;
}
.winner-back.show { display: flex; }
.winner-back #confetti { position: absolute; inset: 0; width: 100%; height: 100%; pointer-events: none; }
.winner-card {
  position: relative; z-index: 1;
  width: min(720px, 94vw);
  background: #fff; border-radius: 22px; padding: 28px 28px 24px;
  text-align: center; box-shadow: 0 24px 80px rgba(0,0,0,.6);
  animation: winpop .4s cubic-bezier(.2,1.2,.4,1);
}
@keyframes winpop { from { transform: scale(.8); opacity: 0; } to { transform: scale(1); opacity: 1; } }
.winner-card .close {
  position: absolute; top: 14px; right: 14px;
  background: #eef1f7; border: none; width: 36px; height: 36px; border-radius: 10px;
  font-size: 16px; cursor: pointer; color: var(--muted);
}
.winner-badge {
  display: inline-block; background: var(--gold); color: #5a3c00;
  font-weight: 800; font-size: 15px; padding: 7px 18px; border-radius: 999px; margin-bottom: 12px;
}
.winner-name { font-size: 30px; margin: 4px 0 16px; color: var(--navy); }
.winner-preview {
  position: relative; width: 100%; aspect-ratio: 16 / 10;
  border-radius: 14px; overflow: hidden;
  border: 1px solid var(--line); background: #f6f8fc; margin-bottom: 16px;
}
.winner-preview iframe { position: absolute; top: 0; left: 0; width: 1280px; height: 800px; border: 0; transform-origin: 0 0; }
.winner-coffee { font-size: 22px; font-weight: 800; color: var(--ink); margin-bottom: 18px; }
.winner-coffee b { color: #ff6a00; }
.winner-promo {
  display: inline-flex; align-items: center; gap: 16px;
  background: #fff7ed; border: 1.5px solid #ffd8a8; border-radius: 16px; padding: 14px 20px;
}
.winner-promo #wqr img, .winner-promo #wqr canvas { display: block; border-radius: 8px; }
.winner-promo-text { text-align: left; }
.winner-promo-text b { display: block; font-size: 15px; color: #b45309; }
.winner-promo-text small { color: var(--blue); font-weight: 700; }
.winner-guide { color: var(--muted); margin: 0 0 18px; font-size: 14px; }
