/* DUNESDAY — 모래 vs 강철 */
:root {
  --night: #16120d;        /* 사막의 밤 */
  --dust: #2a2219;         /* 막대 바닥 */
  --sand: #c48a47;         /* 아라키스 모래 */
  --spice: #e9b872;        /* 스파이스 빛 */
  --iron: #3b4d46;         /* 둠의 강철 */
  --verdigris: #7fb59a;    /* 녹청 */
  --bone: #efe6d6;         /* 본문 글자 */
  --ash: #a39a8c;          /* 보조 글자 */
  --rule: rgba(239, 230, 214, 0.12);
  --display: "Unbounded", "Pretendard", sans-serif;
}

* { box-sizing: border-box; margin: 0; padding: 0; }
html { -webkit-text-size-adjust: 100%; }
body {
  font-family: "Pretendard", system-ui, sans-serif;
  background: var(--night);
  color: var(--bone);
  line-height: 1.55;
}
button { font: inherit; color: inherit; cursor: pointer; border: 0; background: none; }
a { color: inherit; }
:focus-visible { outline: 2px solid var(--spice); outline-offset: 3px; }

/* ============ 전선 (히어로) ============ */
.front {
  --front: 50%;
  position: relative;
  min-height: 100svh;
  display: grid;
  grid-template-columns: 1fr 1fr;
  grid-template-rows: auto 1fr auto;
  overflow: hidden;
  isolation: isolate;
}
.front::before, .front::after {
  content: ""; position: absolute; top: 0; bottom: 0; z-index: -1;
  transition: width 1.6s cubic-bezier(.65, 0, .25, 1), left 1.6s cubic-bezier(.65, 0, .25, 1);
}
/* 모래 진영: 왼쪽 끝 ~ 경계선 */
.front::before {
  left: 0; width: var(--front);
  background:
    radial-gradient(220% 30% at 20% 112%, rgba(217, 163, 91, .9) 0 45%, transparent 45.5%),
    radial-gradient(260% 26% at 90% 116%, rgba(181, 122, 60, .9) 0 45%, transparent 45.5%),
    radial-gradient(90% 70% at 20% 10%, rgba(255, 214, 150, .35), transparent 60%),
    linear-gradient(180deg, #6b3e1a 0%, #9a5f2b 55%, #c48a47 100%);
}
/* 강철 진영: 경계선 ~ 오른쪽 끝 */
.front::after {
  left: var(--front); width: calc(100% - var(--front));
  background:
    radial-gradient(80% 60% at 70% 20%, rgba(127, 181, 154, .28), transparent 65%),
    repeating-linear-gradient(90deg, rgba(255,255,255,.025) 0 1px, transparent 1px 7px),
    linear-gradient(180deg, #1b2420 0%, #2b3a34 50%, #1a2320 100%);
}
.seam {
  position: absolute; top: 0; bottom: 0; left: var(--front); width: 3px; margin-left: -1.5px; z-index: 0;
  background: linear-gradient(180deg, transparent, var(--spice) 20%, #fff6e2 50%, var(--verdigris) 80%, transparent);
  box-shadow: 0 0 24px 4px rgba(233, 184, 114, .45);
  transition: left 1.6s cubic-bezier(.65, 0, .25, 1);
}

.front-title {
  grid-column: 1 / -1;
  text-align: center;
  padding: clamp(28px, 6vh, 64px) 16px 0;
  position: relative; z-index: 1;
}
h1 {
  font-family: var(--display);
  font-weight: 900;
  font-size: clamp(40px, 11.5vw, 168px);
  letter-spacing: -0.035em;
  line-height: .9;
  color: var(--bone);
  text-shadow: 0 4px 40px rgba(0, 0, 0, .45);
}
.front-title p { margin-top: 12px; color: rgba(239, 230, 214, .82); font-size: clamp(13px, 1.6vw, 16px); }

.camp {
  position: relative; z-index: 1;
  display: flex; flex-direction: column; align-items: center; justify-content: center;
  padding: clamp(18px, 4vh, 40px) clamp(10px, 3vw, 48px);
}
.poster-link { display: block; width: min(100%, 280px, 27vh); text-decoration: none; }
.poster-link .poster { width: 100%; transition: transform .35s cubic-bezier(.2, .8, .2, 1); }
.poster-link:hover .poster { transform: translateY(-4px); }
.play {
  position: absolute; left: 50%; bottom: 12px; transform: translateX(-50%); z-index: 1;
  padding: 6px 12px; border-radius: 99px; white-space: nowrap;
  font-size: 12px; font-weight: 700; color: var(--bone);
  background: rgba(22, 18, 13, .72); backdrop-filter: blur(6px);
}
.poster-link:hover .play, .poster-link:focus-visible .play { background: var(--bone); color: var(--night); }

.poster {
  position: relative; aspect-ratio: 2 / 3;
  border-radius: 4px; overflow: hidden;
  display: grid; place-items: center; text-align: center;
  background: rgba(0, 0, 0, .22);
  border: 1.5px dashed rgba(239, 230, 214, .35);
}
.poster.has-img { border: 0; box-shadow: 0 30px 60px -12px rgba(0, 0, 0, .7), 0 0 0 1px rgba(255, 255, 255, .08); }
.poster img { position: absolute; inset: 0; width: 100%; height: 100%; object-fit: cover; image-rendering: high-quality; }
.poster.has-img .ph { display: none; }
.ph { color: rgba(239, 230, 214, .7); font-size: 13px; line-height: 1.7; padding: 10px; }
.ph code { font-size: 11px; word-break: break-all; opacity: .8; }

.who { text-align: center; margin-top: clamp(14px, 3vh, 28px); text-shadow: 0 2px 16px rgba(0,0,0,.35); }
.who h2 { font-size: clamp(14px, 2vw, 21px); font-weight: 800; }
.share {
  display: block; margin-top: 2px;
  font-family: var(--display); font-weight: 800;
  font-size: clamp(40px, 7vw, 96px); line-height: 1.05; letter-spacing: -0.04em;
  font-variant-numeric: tabular-nums;
}
.camp.dune .share { color: #fff1d6; }
.camp.doom .share { color: #d8f0e2; }
.count { display: flex; flex-direction: column; align-items: center; gap: 2px; margin-top: 6px; }
.count .num {
  font-family: var(--display); font-weight: 500;
  font-size: clamp(17px, 2.4vw, 28px); letter-spacing: -0.02em; font-variant-numeric: tabular-nums;
  color: var(--bone);
}
.count small { font-family: "Pretendard", sans-serif; font-size: .6em; font-weight: 700; margin-left: .15em; letter-spacing: 0; opacity: .8; }
.count-label { font-size: clamp(11px, 1.3vw, 13px); color: rgba(239, 230, 214, .78); }

.front-foot {
  grid-column: 1 / -1; position: relative; z-index: 1;
  text-align: center; padding: 0 16px clamp(24px, 5vh, 48px);
}
.basis {
  display: inline-block; font-size: 13px; padding: 6px 14px; border-radius: 99px;
  background: rgba(22, 18, 13, .6); backdrop-filter: blur(6px);
}
.clock { display: flex; justify-content: center; gap: clamp(14px, 3vw, 28px); margin-top: 18px; }
.clock span { font-size: 13px; color: rgba(239, 230, 214, .8); }
.clock b {
  font-family: var(--display); font-weight: 500; font-variant-numeric: tabular-nums;
  font-size: clamp(26px, 4vw, 40px); color: var(--bone); margin-right: 3px;
}
.cd-label { margin-top: 6px; font-size: 13px; color: rgba(239, 230, 214, .75); }
.dday { font-family: var(--display); font-weight: 800; font-size: clamp(22px, 3vw, 32px); color: var(--bone); }

/* ============ 본문 ============ */
main { max-width: 880px; margin: 0 auto; padding: 0 20px 40px; }
.block { padding: 56px 0 8px; border-top: 1px solid var(--rule); }
.block:first-child { border-top: 0; }
.head { display: flex; align-items: baseline; justify-content: space-between; gap: 12px; flex-wrap: wrap; margin-bottom: 22px; }
.block h2 { font-size: clamp(22px, 3.4vw, 30px); font-weight: 800; letter-spacing: -0.02em; }
h3 { font-size: 17px; font-weight: 700; margin-bottom: 14px; }
.note { color: var(--ash); font-size: 13px; }
.empty { color: var(--ash); padding: 32px 0; }

/* 스코어: 줄다리기 */
.scoreboard { display: grid; gap: 24px; }
.metric-top { display: grid; grid-template-columns: 1fr auto 1fr; align-items: baseline; gap: 10px; margin-bottom: 8px; }
.metric-top .label { color: var(--ash); font-size: 13px; text-align: center; }
.metric-top .val-dune, .metric-top .val-doom { font-family: var(--display); font-weight: 500; font-size: clamp(14px, 2.4vw, 20px); font-variant-numeric: tabular-nums; }
.metric-top .val-dune { color: var(--spice); }
.metric-top .val-doom { color: var(--verdigris); text-align: right; }
.bar { display: flex; height: 10px; background: var(--dust); }
.bar i { display: block; height: 100%; transition: width 1s cubic-bezier(.65, 0, .25, 1); }
.bar .b-dune { background: var(--sand); }
.bar .b-doom { background: var(--iron); box-shadow: inset 2px 0 0 #fff6e2; }
.metric-bottom { display: flex; justify-content: space-between; font-size: 12px; color: var(--ash); margin-top: 6px; }
.winner { font-weight: 700; }
.winner.dune { color: var(--spice); }
.winner.doom { color: var(--verdigris); }

/* 탭 */
.tabs { display: inline-flex; gap: 2px; margin-bottom: 18px; border-bottom: 1px solid var(--rule); max-width: 100%; overflow-x: auto; overflow-y: hidden; scrollbar-width: none; }
.tabs::-webkit-scrollbar { display: none; }
.head .tabs { margin-bottom: 0; }
.tabs button { padding: 8px 14px; font-size: 14px; color: var(--ash); border-bottom: 2px solid transparent; white-space: nowrap; }
.tabs button.on { color: var(--bone); font-weight: 700; border-bottom-color: var(--spice); }

/* 표 */
table { width: 100%; border-collapse: collapse; font-size: 15px; font-variant-numeric: tabular-nums; }
th, td { padding: 13px 8px; text-align: right; border-bottom: 1px solid var(--rule); }
th:first-child, td:first-child { text-align: left; color: var(--ash); font-weight: 500; }
thead th { font-size: 13px; font-weight: 700; }
thead th.c-dune { color: var(--spice); }
thead th.c-doom { color: var(--verdigris); }
td.lead { font-weight: 800; }
td.lead::before { content: "▲ "; font-size: 10px; color: var(--spice); vertical-align: 2px; }
.na { color: #5e564b; }

.chart-wrap { position: relative; height: 320px; }

/* 투표 */
.polls { display: grid; grid-template-columns: repeat(auto-fit, minmax(300px, 1fr)); gap: 36px; }
.opts { display: flex; gap: 8px; }
.opt { flex: 1; padding: 16px 10px; font-weight: 800; font-size: 16px; border-radius: 3px; transition: transform .15s, filter .15s; }
.opt:hover { filter: brightness(1.12); }
.opt:active { transform: scale(.97); }
.opt.dune { background: var(--sand); color: #23160a; }
.opt.doom { background: var(--iron); color: #e3f1e9; box-shadow: inset 0 0 0 1px rgba(127, 181, 154, .5); }
.opt.both { background: var(--bone); color: var(--night); }
.opt[disabled] { opacity: .3; cursor: default; filter: none; transform: none; }
.opt.mine { opacity: 1; box-shadow: 0 0 0 2px var(--night), 0 0 0 4px var(--bone); }
.results { margin-top: 18px; display: grid; gap: 10px; }
.res-row { display: grid; grid-template-columns: 64px 1fr 44px; align-items: center; gap: 10px; font-size: 14px; }
.res-row .track { height: 8px; background: var(--dust); }
.res-row .fill { height: 100%; transition: width 1s cubic-bezier(.65, 0, .25, 1); }
.res-row .pct { text-align: right; font-variant-numeric: tabular-nums; font-weight: 700; }
.total { font-size: 12px; color: var(--ash); }

.toast {
  position: fixed; left: 50%; bottom: 24px; transform: translateX(-50%); z-index: 10;
  background: var(--bone); color: var(--night); padding: 11px 20px; border-radius: 3px; font-weight: 700; font-size: 14px;
}

.sources p { font-size: 14px; margin-top: 8px; max-width: 62ch; }
.sources h2 { margin-bottom: 10px; }
footer { text-align: center; color: var(--ash); font-size: 13px; padding: 24px 0 48px; }

/* ============ 모바일 ============ */
@media (max-width: 640px) {
  .front { min-height: auto; }
  .camp { padding: 18px 10px 10px; }
  .poster-link { width: 100%; }
  .play { font-size: 11px; padding: 5px 10px; bottom: 8px; }
  .front-foot { padding-top: 14px; }
  .clock { gap: 12px; }
  .block { padding-top: 44px; }
  .head { flex-direction: column; align-items: flex-start; gap: 6px; }
  th, td { padding: 11px 4px; font-size: 13px; }
  .polls { grid-template-columns: 1fr; gap: 32px; }
}

@media (prefers-reduced-motion: reduce) {
  *, .front::before, .front::after, .seam { transition: none !important; }
}
