/* Home page: hero, live-duel preview, how it works, dashboard. */

/* ---------- hero ---------- */
.hero {
  position: relative;
  display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 1fr); gap: var(--s7); align-items: center;
  padding: var(--s5) 0 var(--s4);
}
.hero::before {
  /* soft accent glow behind the hero; very low contrast in both themes */
  content: ""; position: absolute; z-index: -1; pointer-events: none;
  inset: -140px -10% -60px 30%;
  background: radial-gradient(closest-side, var(--glow), transparent);
}
.wordmark {
  display: block;
  font-family: var(--font-mono); font-weight: 600; letter-spacing: -0.045em; line-height: 1;
  font-size: clamp(40px, 6.4vw, 68px);
}
.wordmark span { color: var(--accent); }
.wordmark .caret {
  display: inline-block; width: .5em; height: .09em; margin-left: .08em; vertical-align: baseline;
  background: var(--accent); animation: caret 1.1s steps(1) infinite;
}
@keyframes caret { 50% { opacity: 0; } }
.tagline { margin-top: var(--s5); font-size: clamp(18px, 2.1vw, 21px); line-height: 1.45; color: var(--text-strong); max-width: 30ch; letter-spacing: -0.01em; }
.hero .lede { margin-top: var(--s3); max-width: 46ch; }
.hero-actions { margin-top: var(--s6); display: grid; gap: var(--s4); justify-items: start; }
.hero-join { display: grid; gap: var(--s2); width: 100%; max-width: 380px; }
.hero-join label { margin: 0; }
.hero-join .inline-form input { flex: 1 1 120px; }

/* ---------- the live-duel preview (static, no API) ---------- */
.duel-mock {
  margin: 0; border: 1px solid var(--line-strong); border-radius: 16px; overflow: hidden;
  background: var(--surface); box-shadow: 0 30px 80px -40px rgba(0, 0, 0, .55), var(--shadow);
  font-size: 13px;
}
.dm-head { display: flex; align-items: center; gap: var(--s3); padding: var(--s3) var(--s4); border-bottom: 1px solid var(--line); background: var(--surface-2); }
.dm-live { display: inline-flex; align-items: center; gap: var(--s2); color: var(--text-strong); font-weight: 600; font-size: 12px; }
.dm-head .chip { background: var(--surface); }
.dm-head .dm-code { margin-left: auto; font-family: var(--font-mono); font-size: 12px; letter-spacing: .12em; color: var(--muted); }
.dm-versus { display: grid; grid-template-columns: 1fr auto 1fr; align-items: center; gap: var(--s3); padding: var(--s5) var(--s4) var(--s4); }
.dm-player { display: grid; gap: 2px; min-width: 0; }
.dm-player .handle { font-size: 15px; overflow: hidden; text-overflow: ellipsis; }
.dm-player .r { font-family: var(--font-mono); font-size: 12px; color: var(--muted); }
.dm-player.right { text-align: right; }
.dm-clock { text-align: center; }
.dm-timer { font-family: var(--font-mono); font-size: 34px; font-weight: 500; color: var(--text-strong); letter-spacing: -0.03em; line-height: 1; font-variant-numeric: tabular-nums; }
.dm-score { margin-top: var(--s2); font-family: var(--font-mono); font-size: 13px; color: var(--muted); font-variant-numeric: tabular-nums; }
.dm-score b { color: var(--text-strong); font-weight: 600; }
.dm-board { display: grid; grid-template-columns: 32px minmax(0, 1fr) 64px 64px; gap: var(--s2) var(--s3); align-items: center; padding: 0 var(--s4) var(--s4); }
.dm-board .h { font-size: 11px; color: var(--muted); text-align: center; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.dm-board .h.left { text-align: left; }
.dm-letter {
  display: grid; place-items: center; width: 32px; height: 32px; border-radius: var(--r);
  background: var(--surface-2); border: 1px solid var(--line); font-family: var(--font-mono); font-weight: 600; color: var(--text-strong);
}
.dm-prob { min-width: 0; }
.dm-prob .n { color: var(--text-strong); font-weight: 500; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; display: block; }
.dm-prob .m { font-family: var(--font-mono); font-size: 11px; color: var(--muted); }
.dm-board .cell { min-width: 0; height: 40px; }
.dm-foot { padding: var(--s3) var(--s4); border-top: 1px solid var(--line); color: var(--muted); font-size: 12px; display: flex; justify-content: space-between; gap: var(--s3); }

/* ---------- how it works ---------- */
.section-head { display: flex; justify-content: space-between; align-items: flex-end; gap: var(--s3); flex-wrap: wrap; margin-bottom: var(--s5); }
.section-head h2 { font-size: 22px; letter-spacing: -0.02em; }
.steps { list-style: none; margin: 0; padding: 0; display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: var(--s4); counter-reset: step; }
.step { display: grid; gap: var(--s2); align-content: start; }
.step-num {
  display: grid; place-items: center; width: 28px; height: 28px; margin-bottom: var(--s2); border-radius: 50%;
  border: 1px solid var(--line-strong); font-family: var(--font-mono); font-size: 13px; color: var(--accent);
}
.step h3 { font-size: 16px; }
.step p { color: var(--muted); font-size: 14px; }
.step .term {
  margin-top: var(--s3); padding: var(--s2) var(--s3); border-radius: var(--r); background: var(--surface-2); border: 1px solid var(--line);
  font-family: var(--font-mono); font-size: 12px; color: var(--muted); overflow-wrap: anywhere;
}
.step .term .ok { color: var(--accent); }
.step .term .ce { color: var(--warn); }

/* ---------- logged-in home ---------- */
.home-head { display: flex; justify-content: space-between; align-items: flex-end; gap: var(--s4) var(--s6); flex-wrap: wrap; }
.home-head h1 { font-size: 30px; letter-spacing: -0.025em; }
.home-head h1 .handle { font-weight: 600; letter-spacing: -0.03em; }
.home-head .lede { margin-top: var(--s2); }
.home-join { display: grid; gap: var(--s2); }
.home-join label { margin: 0; }

/* Dashboard: stats and friends side by side (same height), recent matches full width below. */
.dash { display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 1fr); gap: var(--s4); align-items: stretch; }
.dash > .panel { display: flex; flex-direction: column; }
.dash > .recent { grid-column: 1 / -1; }
.panel-head .count {
  display: inline-grid; place-items: center; min-width: 20px; height: 20px; padding: 0 6px; margin-left: var(--s2); border-radius: 999px;
  background: var(--accent-soft); color: var(--accent); font: 600 11px var(--font-mono); vertical-align: 2px;
}

.stat-grid { display: grid; grid-template-columns: 1fr 1fr; }
.stat { padding: var(--s4) var(--s5); border-bottom: 1px solid var(--line); min-width: 0; }
.stat:nth-child(odd) { border-right: 1px solid var(--line); }
.stat .kpi { font-size: 24px; }
.stat .kpi-label { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.spark-wrap { flex: 1; display: grid; align-items: end; padding: var(--s4) var(--s5) var(--s5); min-height: 88px; }
.spark-wrap p { align-self: center; }
.spark { display: block; width: 100%; height: 56px; }
.spark .line { fill: none; stroke: var(--accent); stroke-width: 2; vector-effect: non-scaling-stroke; }
.spark .area { fill: var(--accent-soft); stroke: none; }

.recent-list { list-style: none; margin: 0; padding: 0; }
.recent-list > li {
  display: grid; grid-template-columns: 64px minmax(0, 1fr) 150px 72px 72px; align-items: center; gap: var(--s4);
  min-height: 52px; padding: 0 var(--s5); border-bottom: 1px solid var(--line); font-size: 14px;
  transition: background var(--fast);
}
.recent-list > li:hover { background: var(--surface-hover); }
.recent-list > li:last-child { border-bottom: 0; }
.recent-list .opp { min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.recent-list .with { color: var(--muted); }
.recent-mode, .recent-when { font-size: 13px; color: var(--muted); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.recent-when { font-family: var(--font-mono); font-size: 12px; text-align: right; font-variant-numeric: tabular-nums; }
.recent-list .match-code { justify-self: end; }
.result-badge {
  display: inline-grid; place-items: center; height: 24px; border-radius: var(--r-sm);
  font: 600 12px var(--font-mono); background: var(--surface-2); color: var(--muted); font-variant-numeric: tabular-nums;
}
.result-badge.win { background: var(--accent-soft); color: var(--accent); }
.result-badge.loss { color: var(--danger); background: var(--danger-soft); }
.match-code { font-family: var(--font-mono); font-size: 12px; color: var(--muted); border-bottom-color: transparent; }
.match-code:hover { color: var(--text-strong); }
.inline-empty { display: flex; align-items: center; gap: var(--s4); padding: var(--s5); color: var(--muted); font-size: 14px; }
.inline-empty strong { color: var(--text-strong); font-weight: 600; display: block; }
.inline-empty .grow { flex: 1; min-width: 0; }
.inline-empty .empty-icon { display: grid; place-items: center; flex: none; width: 40px; height: 40px; border-radius: 50%; background: var(--surface-2); }

@media (max-width: 900px) {
  .hero { grid-template-columns: 1fr; gap: var(--s6); padding-top: 0; }
  .hero::before { inset: -80px -20% 40% -20%; }
}
@media (max-width: 720px) {
  .steps { grid-template-columns: 1fr; }
  .dm-board { grid-template-columns: 28px minmax(0, 1fr) 54px 54px; gap: var(--s2); }
  .dm-letter { width: 28px; height: 28px; }
  .dm-timer { font-size: 28px; }
  .hero-actions .btn.big { width: 100%; }
  .hero-actions, .hero-join { justify-items: stretch; max-width: none; }
}

@media (max-width: 860px) {
  .recent-list > li { grid-template-columns: 56px minmax(0, 1fr) 64px 64px; }
  .recent-mode { display: none; }
}
@media (max-width: 720px) {
  .dash { grid-template-columns: minmax(0, 1fr); }
  .home-head h1 { font-size: 24px; }
  .home-join { width: 100%; }
  .home-join .inline-form { flex-wrap: nowrap; }
  .home-join .inline-form.code input { flex: 1 1 auto; }
  .recent-list > li { grid-template-columns: 52px minmax(0, 1fr) 60px; gap: var(--s3); padding: 0 var(--s4); }
  .recent-when { display: none; }
  .stat { padding: var(--s3) var(--s4); }
  .spark-wrap { padding: var(--s3) var(--s4) var(--s4); }
  .inline-empty { flex-wrap: wrap; padding: var(--s4); }
  .inline-empty .empty-icon { display: none; }
  .inline-empty .grow { flex-basis: 100%; }
}
