:root {
  --ink: #0F2140;
  --ink-2: #16305A;
  --ink-3: #1D3A69;
  --line: #2B4876;
  --paper: #EDF1F7;
  --mute: #93A6C3;
  --signal: #FFCC1A;
  --signal-ink: #1A1400;
  --live: #FF5A4E;

  --num: "Big Shoulders Display", "Pretendard Variable", Pretendard, sans-serif;
  --sans: "Pretendard Variable", Pretendard, -apple-system, BlinkMacSystemFont, "Apple SD Gothic Neo", "Noto Sans KR", sans-serif;

  --gutter: 16px;
  --radius-lg: 22px;
  --radius-sm: 10px;
}

*, *::before, *::after { box-sizing: border-box; }

html { -webkit-text-size-adjust: 100%; scroll-behavior: smooth; }

body {
  margin: 0;
  background: var(--ink);
  color: var(--paper);
  font-family: var(--sans);
  font-size: 16px;
  line-height: 1.6;
  word-break: keep-all;
  overflow-wrap: anywhere;
  -webkit-font-smoothing: antialiased;
  padding-bottom: env(safe-area-inset-bottom);
}

[hidden] { display: none !important; }
a { color: inherit; }
b { font-weight: 700; }
h1, h2, h3, p, ol, ul, dl, dd, fieldset { margin: 0; padding: 0; }
ol, ul { list-style: none; }

:focus-visible { outline: 3px solid var(--signal); outline-offset: 3px; border-radius: 4px; }

.wrap {
  width: 100%;
  max-width: 1120px;
  margin-inline: auto;
  padding-inline: var(--gutter);
}

/* Top bar */
.topbar {
  position: sticky;
  top: 0;
  z-index: 10;
  background: rgba(15, 33, 64, 0.92);
  backdrop-filter: blur(10px);
  -webkit-backdrop-filter: blur(10px);
  border-bottom: 1px solid var(--line);
}
.topbar-in {
  display: flex;
  align-items: center;
  gap: 12px;
  height: 52px;
}
.mark {
  display: grid;
  place-items: center;
  width: 32px;
  height: 32px;
  border-radius: 8px;
  background: var(--signal);
  color: var(--ink);
  font-family: var(--num);
  font-weight: 800;
  font-size: 19px;
  line-height: 1;
  text-decoration: none;
}
.live {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 14px;
  font-weight: 600;
}
.live-dot {
  width: 9px;
  height: 9px;
  border-radius: 50%;
  background: var(--live);
  box-shadow: 0 0 0 0 rgba(255, 90, 78, 0.6);
  animation: beacon 1.8s ease-out infinite;
}
.live.is-over .live-dot { background: var(--mute); animation: none; }
.owner {
  margin-left: auto;
  font-size: 14px;
  color: var(--mute);
  text-decoration: none;
}
.owner:hover { color: var(--paper); }

@keyframes beacon {
  0% { box-shadow: 0 0 0 0 rgba(255, 90, 78, 0.55); }
  70% { box-shadow: 0 0 0 9px rgba(255, 90, 78, 0); }
  100% { box-shadow: 0 0 0 0 rgba(255, 90, 78, 0); }
}

/* Hero */
.hero {
  display: grid;
  gap: 36px;
  padding-top: 36px;
  padding-bottom: 32px;
}
.hero h1 {
  font-size: clamp(28px, 8vw, 58px);
  line-height: 1.22;
  font-weight: 800;
  letter-spacing: -0.035em;
  text-wrap: balance;
  max-width: 17em;
}
.hero .ph { white-space: nowrap; }
.sub {
  margin-top: 16px;
  font-size: 17px;
  color: var(--mute);
  font-weight: 500;
}

.sr {
  position: absolute;
  width: 1px;
  height: 1px;
  overflow: hidden;
  clip: rect(0 0 0 0);
  white-space: nowrap;
}

.clock { container-type: inline-size; }
.clock-label {
  display: flex;
  justify-content: space-between;
  gap: 12px;
  font-size: 14px;
  font-weight: 600;
  color: var(--mute);
  font-variant-numeric: tabular-nums;
}
.clock-label #elapsedLabel { color: var(--paper); }
.clock-num {
  font-family: var(--num);
  font-weight: 800;
  font-size: 27.5cqi;
  line-height: 0.92;
  letter-spacing: 0;
  margin-top: 4px;
  white-space: nowrap;
  color: var(--paper);
}
.clock-num .d { display: inline-block; width: 0.5em; text-align: center; }
.clock-num .c { display: inline-block; width: 0.26em; text-align: center; color: var(--mute); transform: translateY(-0.06em); }
.clock-num.is-over { color: var(--mute); font-family: var(--sans); font-size: 20cqi; letter-spacing: -0.04em; }

.ruler {
  position: relative;
  height: 14px;
  margin-top: 16px;
  background: var(--ink-2);
  border-radius: 3px;
  overflow: hidden;
}
.ruler-fill {
  position: absolute;
  inset: 0 auto 0 0;
  width: 0;
  background: var(--paper);
  transition: width 1s linear;
}
.ruler-ticks {
  position: absolute;
  inset: 0;
  background-image: repeating-linear-gradient(to right, transparent 0, transparent calc(100% / 24 - 1px), var(--ink) calc(100% / 24 - 1px), var(--ink) calc(100% / 24));
}
.ruler-ends {
  display: flex;
  justify-content: space-between;
  gap: 8px;
  margin-top: 8px;
  font-size: 12.5px;
  color: var(--mute);
  font-variant-numeric: tabular-nums;
}

/* Revenue board */
.board-sec { padding-bottom: 12px; }
.board {
  background: var(--signal);
  color: var(--signal-ink);
  border-radius: var(--radius-lg);
  padding: 22px 20px 20px;
  display: grid;
  gap: 24px;
}
.board-main { container-type: inline-size; min-width: 0; }
.board-title {
  font-size: 16px;
  font-weight: 700;
  letter-spacing: -0.01em;
}
.total {
  display: flex;
  align-items: flex-start;
  margin-top: 6px;
  font-family: var(--num);
  font-weight: 800;
  line-height: 0.9;
  white-space: nowrap;
}
.won {
  font-family: var(--sans);
  font-weight: 800;
  font-size: 9cqi;
  margin-top: 0.35em;
  margin-right: 0.08em;
}
.total-num { font-size: 26cqi; letter-spacing: -0.005em; }
.total-num .d { display: inline-block; width: 0.5em; text-align: center; }
.total-num .c { display: inline-block; width: 0.2em; text-align: left; }
.total.bump .total-num { animation: bump 0.9s ease-out; }
@keyframes bump {
  0% { color: var(--ink); }
  30% { color: #7A5A00; }
  100% { color: inherit; }
}

.goal { margin-top: 18px; }
.bar {
  position: relative;
  height: 12px;
  border-radius: 999px;
  overflow: hidden;
}
.bar > span {
  position: absolute;
  inset: 0 auto 0 0;
  width: 0;
  border-radius: inherit;
  transition: width 1.2s cubic-bezier(.2,.7,.2,1);
}
.bar-goal { background: rgba(15, 33, 64, 0.16); }
.bar-goal > span { background: var(--ink); min-width: 12px; }
.goal-text {
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  margin-top: 10px;
  font-size: 15px;
  font-variant-numeric: tabular-nums;
}
.pct { font-family: var(--num); font-weight: 800; font-size: 26px; line-height: 1; }

.streams {
  display: grid;
  border-top: 2px solid var(--signal-ink);
}
.streams > div {
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  gap: 12px;
  padding: 11px 0;
  border-bottom: 1px solid rgba(26, 20, 0, 0.18);
}
.streams dt { font-size: 15px; font-weight: 500; }
.streams dd { font-size: 17px; font-weight: 700; font-variant-numeric: tabular-nums; letter-spacing: -0.01em; }

.spend { margin-top: 18px; }
.spend-text {
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  gap: 12px;
  font-size: 15px;
  font-variant-numeric: tabular-nums;
}
.spend-text > span:last-child { color: rgba(26, 20, 0, 0.7); }
.spend-text b { color: var(--signal-ink); }
.bar-spend { height: 6px; margin-top: 8px; background: rgba(15, 33, 64, 0.16); }
.bar-spend > span { background: #C2261B; }
.updated {
  margin-top: 16px;
  font-size: 13px;
  color: rgba(26, 20, 0, 0.66);
  font-variant-numeric: tabular-nums;
}

/* Agents and log */
.ops {
  display: grid;
  gap: 44px;
  padding-top: 44px;
  padding-bottom: 12px;
}
.sec-title {
  font-size: 22px;
  font-weight: 800;
  letter-spacing: -0.03em;
  line-height: 1.3;
}
.sec-sub { margin-top: 4px; font-size: 14px; color: var(--mute); }

.agents {
  margin-top: 16px;
  border: 1px solid var(--line);
  border-radius: var(--radius-sm);
  overflow: hidden;
}
.agent {
  display: grid;
  grid-template-columns: 34px 1fr;
  column-gap: 12px;
  padding: 14px 14px 15px;
  background: var(--ink-2);
}
.agent + .agent { border-top: 1px solid var(--line); }
.agent-id {
  display: grid;
  place-items: center;
  width: 34px;
  height: 34px;
  border-radius: 8px;
  background: var(--ink);
  border: 1px solid var(--line);
  font-family: var(--num);
  font-weight: 800;
  font-size: 18px;
  line-height: 1;
  color: var(--mute);
}
.agent-head {
  display: flex;
  align-items: center;
  gap: 8px;
  min-width: 0;
}
.agent-name { font-size: 17px; font-weight: 700; letter-spacing: -0.02em; }
.agent-state {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  margin-left: auto;
  font-size: 12.5px;
  font-weight: 600;
  color: var(--mute);
  white-space: nowrap;
}
.agent-role { font-size: 13px; color: var(--mute); line-height: 1.45; }
.agent-task { margin-top: 8px; font-size: 15px; line-height: 1.5; grid-column: 2; }

.dot {
  position: relative;
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: #5E7394;
}
.is-working .dot { background: var(--signal); }
.is-working .dot::after {
  content: "";
  position: absolute;
  inset: -4px;
  border-radius: 50%;
  border: 2px solid var(--signal);
  opacity: 0;
  animation: ping 1.6s ease-out infinite;
}
.is-working .agent-state { color: var(--signal); }
.is-working .agent-id { color: var(--signal); border-color: rgba(255, 204, 26, 0.45); }
.is-done .dot { display: none; }
.is-done .agent-state { color: var(--paper); }
.check { display: none; width: 12px; height: 12px; }
.is-done .check { display: block; }

@keyframes ping {
  0% { transform: scale(0.6); opacity: 0.9; }
  100% { transform: scale(1.5); opacity: 0; }
}

.log { margin-top: 16px; position: relative; }
.log-item {
  display: grid;
  grid-template-columns: 50px 1fr;
  column-gap: 12px;
  padding: 12px 0 14px;
  border-top: 1px solid var(--line);
}
.log-item:last-child { border-bottom: 1px solid var(--line); }
.log-time {
  font-size: 14px;
  font-weight: 700;
  font-variant-numeric: tabular-nums;
  color: var(--paper);
  padding-top: 1px;
}
.log-tag {
  display: inline-block;
  margin-right: 8px;
  padding: 1px 8px;
  border-radius: 6px;
  background: var(--ink-3);
  color: var(--mute);
  font-size: 12.5px;
  font-weight: 600;
  vertical-align: 1px;
}
.log-text { font-size: 15px; line-height: 1.6; }
.log-item.is-new { animation: arrive 2.4s ease-out; }
@keyframes arrive {
  0% { background: rgba(255, 204, 26, 0.18); }
  100% { background: transparent; }
}
.log-empty { padding: 16px 0; color: var(--mute); font-size: 15px; }
.log-day {
  padding: 18px 0 8px;
  font-size: 13px;
  font-weight: 700;
  color: var(--mute);
}
.log-day:first-child { padding-top: 0; }

.more {
  margin-top: 12px;
  width: 100%;
  height: 46px;
  border-radius: var(--radius-sm);
  border: 1px solid var(--line);
  background: transparent;
  color: var(--paper);
  font: 600 15px/1 var(--sans);
  cursor: pointer;
}
.more:hover { background: var(--ink-2); }

/* Games */
.games-sec { padding-top: 8px; padding-bottom: 8px; }
.games-head {
  display: grid;
  grid-template-columns: 1fr auto;
  align-items: end;
  column-gap: 16px;
  padding-top: 20px;
  border-top: 2px solid var(--paper);
}
.games-title { font-size: 18px; font-weight: 800; letter-spacing: -0.03em; grid-column: 1; grid-row: 1; }
.games-sub { grid-column: 1; grid-row: 2; font-size: 14px; color: var(--mute); margin-top: 2px; }
.games-count {
  grid-column: 2;
  grid-row: 1 / span 2;
  display: flex;
  align-items: baseline;
  gap: 4px;
  font-family: var(--num);
  font-weight: 800;
  line-height: 0.85;
}
.games-count b { font-size: 96px; font-weight: 800; }
.games-count span { font-family: var(--sans); font-size: 22px; font-weight: 800; }

.games {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 10px;
  margin-top: 18px;
}
.games-empty { grid-column: 1 / -1; padding: 20px 0; color: var(--mute); }
.game-card {
  display: flex;
  flex-direction: column;
  height: 100%;
  min-height: 176px;
  padding: 14px 14px 14px;
  border-radius: 16px;
  border: 1px solid var(--line);
  background: var(--ink-2);
  color: var(--paper);
  text-decoration: none;
}
.game-top { display: flex; align-items: flex-start; justify-content: space-between; gap: 8px; }
.game-emoji { font-size: 36px; line-height: 1; }
.game-no {
  padding: 1px 6px;
  border-radius: 5px;
  background: var(--ink);
  color: var(--mute);
  font-family: var(--num);
  font-weight: 800;
  font-size: 13px;
  line-height: 1.4;
  letter-spacing: 0.02em;
  white-space: nowrap;
}
.game-title { margin-top: 12px; font-size: 17px; font-weight: 800; line-height: 1.3; letter-spacing: -0.03em; }
.game-desc {
  margin-top: 6px;
  font-size: 13.5px;
  line-height: 1.5;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
}
.game-meta { margin-top: 6px; font-size: 12.5px; line-height: 1.45; color: var(--mute); }
.game-state { display: flex; align-items: center; gap: 7px; margin-top: auto; padding-top: 10px; font-size: 13.5px; font-weight: 700; color: var(--signal); }
.game-go {
  display: flex;
  align-items: center;
  justify-content: center;
  min-height: 40px;
  margin-top: auto;
  border-radius: 10px;
  background: var(--ink);
  color: var(--paper);
  font-size: 15px;
  font-weight: 800;
}
.game-desc + .game-go, .game-meta + .game-go, .game-title + .game-go { margin-top: 12px; }
.game-state + .game-meta { margin-top: 2px; }

.is-live .game-card { background: var(--paper); border-color: var(--paper); color: var(--ink); }
.is-live .game-no { background: var(--signal); color: var(--signal-ink); }
.is-live .game-meta { color: #4A5D7C; }
.is-live .game-card:active { transform: scale(0.98); }
.is-building .game-card { border-style: dashed; background: transparent; }
.is-building .game-emoji { filter: grayscale(0.6); opacity: 0.7; }
.is-building .game-state .dot { background: var(--signal); }
.is-building .game-state .dot::after {
  content: "";
  position: absolute;
  inset: -4px;
  border-radius: 50%;
  border: 2px solid var(--signal);
  opacity: 0;
  animation: ping 1.6s ease-out infinite;
}
.is-voting .game-card { border: 1.5px dashed var(--signal); background: transparent; }
.is-voting .game-state { color: var(--paper); font-weight: 600; line-height: 1.45; }

/* Lobby ad: 게임 카드와 떨어뜨린다 */
.ad-sec:empty { display: none; }
.ad-sec { padding-top: 48px; }
.ad-sec .f-ad { padding-top: 12px; border-top: 1px solid var(--line); }
.ad-sec .f-ad__label { display: block; margin-bottom: 6px; font-size: 11px; font-weight: 600; color: var(--mute); }
.ad-sec .f-ad:has(ins[data-ad-status="unfilled"]) { display: none; }

/* Transparency note and footer */
.note { padding-top: 36px; }
.note ul {
  display: grid;
  gap: 6px;
  padding: 16px 0 0;
  border-top: 1px solid var(--line);
}
.note li {
  position: relative;
  padding-left: 14px;
  font-size: 13.5px;
  color: var(--mute);
  line-height: 1.55;
}
.note li::before {
  content: "";
  position: absolute;
  left: 0;
  top: 0.68em;
  width: 5px;
  height: 5px;
  background: var(--mute);
  border-radius: 1px;
}

.foot { padding-top: 32px; padding-bottom: 96px; font-size: 14px; color: var(--mute); }
.foot-links { display: flex; flex-wrap: wrap; gap: 8px 20px; }
.foot-links a { color: var(--paper); text-underline-offset: 3px; }
.biz {
  display: grid;
  gap: 2px;
  margin-top: 20px;
  font-size: 12.5px;
  line-height: 1.6;
}
.biz > div { display: flex; gap: 8px; }
.biz dt { flex: none; }
.biz dt::after { content: ":"; }

/* Wider screens */
@media (min-width: 720px) {
  :root { --gutter: 28px; }
  .hero { padding-top: 56px; }
  .board { padding: 28px; }
  .games { grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 14px; }
}

@media (min-width: 960px) {
  .hero {
    grid-template-columns: 1.25fr 1fr;
    align-items: end;
    gap: 56px;
    padding-top: 72px;
    padding-bottom: 48px;
  }
  .board {
    grid-template-columns: 1.35fr 1fr;
    gap: 48px;
    padding: 36px 40px;
    align-items: start;
  }
  .total-num { font-size: 21cqi; }
  .won { font-size: 7cqi; }
  .games { grid-template-columns: repeat(4, minmax(0, 1fr)); }
  .games-count b { font-size: 120px; }
  .ops {
    grid-template-columns: 1fr 1.15fr;
    gap: 48px;
    align-items: start;
    padding-top: 64px;
  }
}

@media (prefers-reduced-motion: reduce) {
  html { scroll-behavior: auto; }
  *, *::before, *::after {
    animation: none !important;
    transition: none !important;
  }
}
