/* ==========================================================================
   Page layouts: home · how it works · leaderboard · profile · collections · auth · play
   ========================================================================== */

/* ---------------------------------------------------------------- how it works */
.how-grid { display: grid; grid-template-columns: 240px 1fr; gap: var(--s-8); }
.how-toc { position: sticky; top: calc(var(--nav-h) + 32px); align-self: start; display: grid; gap: 10px; }
.how-toc a { font-size: 0.8rem; color: var(--muted); transition: color var(--t-fast); }
.how-toc a:hover { color: var(--accent); }
.prose { max-width: 70ch; }
.prose section + section { margin-top: var(--s-8); padding-top: var(--s-7); border-top: 1px solid var(--line); }
.prose h2 { margin-bottom: var(--s-4); }
.prose p { color: var(--muted); }
.prose p + p, .prose p + ul, .prose ul + p { margin-top: var(--s-4); }
.prose ul.dash li { position: relative; padding-left: 22px; color: var(--muted); }
.prose ul.dash li + li { margin-top: 10px; }
.prose ul.dash li::before { content: ''; position: absolute; left: 0; top: 0.75em; width: 10px; height: 1px; background: var(--accent); }
.prose strong { color: var(--text); font-weight: 500; }
.formula { margin: var(--s-5) 0; padding: var(--s-5); border-radius: var(--r-2); background: var(--bg-2); font-family: var(--font-display); font-size: 1.3rem; line-height: 1.7; }
.formula .label { display: block; margin-bottom: var(--s-2); font-family: var(--font-ui); }
.status-list { display: grid; gap: var(--s-3); margin-top: var(--s-5); }
.status-list li { display: grid; grid-template-columns: 270px 1fr; gap: var(--s-4); padding: var(--s-4); border-radius: var(--r-2); background: var(--bg-2); align-items: start; }
@media (max-width: 860px) { .how-grid { grid-template-columns: 1fr; } .how-toc { position: static; display: flex; flex-wrap: wrap; gap: 16px; } .status-list li { grid-template-columns: 1fr; } }

/* ---------------------------------------------------------------- leaderboard */
.lb-controls { display: flex; justify-content: space-between; gap: var(--s-4); flex-wrap: wrap; margin-bottom: var(--s-6); }
.lb-table-wrap { background: var(--bg-2); border-radius: var(--r-2); padding: var(--s-5) var(--s-4); overflow-x: auto; }
.lb-metric { font-family: var(--font-display); font-size: 1.4rem; }
.lb-podium { display: grid; grid-template-columns: repeat(3, 1fr); gap: var(--s-4); margin-bottom: var(--s-6); }
.podium-card { padding: var(--s-5); border-radius: var(--r-2); background: var(--bg-2); display: grid; gap: var(--s-3); position: relative; overflow: hidden; }
.podium-card.first { background: linear-gradient(160deg, rgba(105, 170, 193, 0.12), var(--bg-2) 60%); }
.podium-card .place { font-family: var(--font-display); font-size: 3rem; line-height: 1; color: var(--accent); }
.podium-card .metric { font-family: var(--font-display); font-size: 1.9rem; line-height: 1; }
@media (max-width: 760px) { .lb-podium { grid-template-columns: 1fr; } }

/* ---------------------------------------------------------------- profile */
.profile-head { display: grid; grid-template-columns: auto 1fr auto; gap: var(--s-6); align-items: center; padding-block: clamp(48px, 7vw, 88px) var(--s-7); border-bottom: 1px solid var(--line); }
.profile-head .h1 { margin-top: 6px; }
.profile-meta { display: flex; flex-wrap: wrap; gap: var(--s-2) var(--s-5); margin-top: var(--s-3); color: var(--muted); font-size: 0.86rem; }
.profile-bio { margin-top: var(--s-4); max-width: 60ch; color: var(--muted); }
.stat-grid { display: grid; grid-template-columns: repeat(4, 1fr); gap: 1px; background: var(--line); border-radius: var(--r-2); overflow: hidden; margin-block: var(--s-7); }
.stat { background: var(--bg); padding: var(--s-5); display: grid; gap: 8px; }
.stat .v { font-family: var(--font-display); font-size: clamp(1.8rem, 3vw, 2.5rem); line-height: 1; }
.stat .v.accent { color: var(--accent); }
.profile-cols { display: grid; grid-template-columns: 1fr; gap: var(--s-8); }
.recent-list li { display: grid; grid-template-columns: 90px 1fr auto auto; align-items: center; gap: var(--s-4); padding: 16px 0; border-bottom: 1px solid var(--line); }
.result-tag { font-size: 0.68rem; font-weight: 600; letter-spacing: 0.16em; text-transform: uppercase; }
.result-win { color: var(--success); }
.result-loss { color: var(--error); }
.result-draw { color: var(--muted); }
@media (max-width: 860px) {
  .profile-head { grid-template-columns: auto 1fr; }
  .profile-head > :last-child { grid-column: 1 / -1; }
  .stat-grid { grid-template-columns: 1fr 1fr; }
  .recent-list li { grid-template-columns: 70px 1fr auto; }
  .recent-list li > :nth-child(3) { display: none; }
}

/* ---------------------------------------------------------------- collections */
.filters { display: flex; justify-content: space-between; align-items: center; gap: var(--s-4); flex-wrap: wrap; margin-bottom: var(--s-6); }

/* ---------------------------------------------------------------- auth */
.auth-wrap { display: grid; place-items: start center; min-height: calc(100vh - var(--nav-h)); padding-top: clamp(32px, 8vh, 96px); }
.auth-panel { width: 100%; padding: 0 var(--gutter) var(--s-7); display: grid; justify-items: center; }
.auth-card { width: min(440px, 100%); padding: var(--s-6); border: 1px solid var(--line); border-radius: var(--r-3); background: var(--bg-2); }
.auth-card .tabs { margin: var(--s-5) 0 var(--s-6); }
.auth-card .btn-block { margin-top: var(--s-5); }

/* ---------------------------------------------------------------- play / matchmaking */
.play-grid { display: grid; grid-template-columns: 1.15fr 0.85fr; gap: var(--s-5); align-items: stretch; }
.mode-card { position: relative; padding: var(--s-6); border-radius: var(--r-2); background: var(--bg-2); display: flex; flex-direction: column; gap: var(--s-4); min-height: 260px; }
.mode-card .icon-wrap { width: 48px; height: 48px; border-radius: 50%; display: grid; place-items: center; border: 1px solid var(--accent-line); color: var(--accent); }
.mode-card .actions { margin-top: auto; display: flex; gap: var(--s-3); flex-wrap: wrap; }
.mode-quick { grid-row: span 2; background: linear-gradient(160deg, rgba(105, 170, 193, 0.10), var(--bg-2) 55%); min-height: 540px; }
.mode-quick .h2 { max-width: 12ch; }
.mode-side { display: grid; gap: var(--s-5); }
.join-form { display: flex; gap: var(--s-3); }
.join-form .input { flex: 1; min-width: 0; }
@media (max-width: 900px) { .play-grid { grid-template-columns: 1fr; } .mode-quick { min-height: 360px; } }

.mm-stage { min-height: calc(100vh - var(--nav-h) - 120px); display: grid; place-items: center; text-align: center; padding-block: var(--s-8); }
.mm-orbit { position: relative; width: 220px; height: 220px; margin: 0 auto var(--s-6); display: grid; place-items: center; }
.mm-orbit::before, .mm-orbit::after { content: ''; position: absolute; inset: 0; border-radius: 50%; border: 1px solid var(--accent-line); animation: ring 2.8s var(--ease) infinite; }
.mm-orbit::after { animation-delay: 1.4s; }
@keyframes ring { 0% { transform: scale(0.55); opacity: 0.9; } 100% { transform: scale(1.15); opacity: 0; } }
.mm-orbit .avatar { --size: 104px; position: relative; z-index: 1; }
.mm-timer { font-family: var(--font-display); font-size: 3rem; line-height: 1; margin-top: var(--s-3); }
.mm-actions { margin-top: var(--s-6); display: flex; gap: var(--s-3); justify-content: center; flex-wrap: wrap; }
.found-versus { display: flex; align-items: center; justify-content: center; gap: clamp(20px, 6vw, 72px); margin: var(--s-6) 0; }
.found-versus .who { display: grid; gap: var(--s-3); justify-items: center; animation: rise-in 600ms var(--ease) both; }
.found-versus .who:last-child { animation-delay: 120ms; }
.found-versus .avatar { --size: 112px; }
.found-versus .vs { font-family: var(--font-display); font-style: italic; font-size: 2.6rem; color: var(--accent); }
.room-code { font-family: var(--font-display); font-size: clamp(3rem, 9vw, 5.5rem); letter-spacing: 0.24em; line-height: 1; margin: var(--s-4) 0; padding-left: 0.24em; }

/* ---------------------------------------------------------------- wallet sign-in */
.auth-sub { margin-top: var(--s-4); }
.wallet-list { display: grid; gap: 10px; margin-top: var(--s-6); }
.wallet-btn {
  display: grid;
  grid-template-columns: 40px 1fr auto 18px;
  align-items: center;
  gap: 14px;
  width: 100%;
  min-height: 64px;
  padding: 10px 16px;
  border: 1px solid var(--line-2);
  border-radius: var(--r-2);
  background: var(--bg-2);
  cursor: pointer;
  text-align: left;
  transition: border-color var(--t-fast), background-color var(--t-fast), transform var(--t-fast) var(--ease);
}
.wallet-btn:hover { border-color: var(--accent-line); background: var(--card); }
.wallet-btn:active { transform: scale(0.99); }
.wallet-btn[disabled] { opacity: 0.45; cursor: progress; }
.wallet-btn.busy { opacity: 1; border-color: var(--accent); }
.wallet-btn .icon { width: 16px; height: 16px; color: var(--muted); }
.wallet-mono { width: 40px; height: 40px; border-radius: 50%; display: grid; place-items: center; font-family: var(--font-display); font-size: 1.2rem; color: var(--accent); border: 1px solid var(--accent-line); }
.wallet-name { font-weight: 500; }
.wallet-missing { background: transparent; }
.wallet-missing .wallet-mono { color: var(--muted); border-color: var(--line-2); }
.auth-status { display: flex; align-items: center; gap: 10px; min-height: 1.6em; margin-top: var(--s-4); font-size: 0.86rem; color: var(--muted); }
.auth-status.error { color: var(--error); }
.auth-status.ok { color: var(--success); }
.auth-status .icon { width: 16px; height: 16px; }
.auth-fine { margin-top: var(--s-6); }
.wallet-chip { display: inline-flex; align-items: center; gap: 8px; font-family: ui-monospace, 'SFMono-Regular', Consolas, monospace; font-size: 0.8rem; }
.wallet-chip button { border: 0; background: none; color: var(--muted); cursor: pointer; padding: 2px; display: inline-grid; }
.wallet-chip button:hover { color: var(--accent); }
.wallet-chip .icon { width: 14px; height: 14px; }

/* ==========================================================================
   Theme overrides (teal / steel-blue, Sora + Geist Mono)
   ========================================================================== */
.podium-card .place, .podium-card .metric, .lb-metric, .stat .v, .mm-timer, .room-code { font-family: var(--font-mono); letter-spacing: -0.03em; }
.podium-card .place { font-size: 2rem; }
.podium-card .metric { font-size: 1.5rem; }
.lb-metric { font-size: 1.1rem; }
.stat .v { font-size: clamp(1.5rem, 2.4vw, 2rem); }
.stat .v.accent { color: var(--success); }
.formula { font-family: var(--font-mono); font-size: 1rem; line-height: 1.7; }
.mm-orbit::before, .mm-orbit::after { border-color: rgba(105, 170, 193, 0.5); }
.found-versus .vs { font-family: var(--font-mono); font-style: normal; font-size: 1.4rem; text-transform: uppercase; }
.room-code { letter-spacing: 0.14em; padding-left: 0.14em; font-size: clamp(2.6rem, 8vw, 4.6rem); color: var(--accent); }
.mode-quick { background: linear-gradient(160deg, rgba(105, 170, 193, 0.14), var(--bg-2) 55%); }
.podium-card.first { background: linear-gradient(160deg, rgba(105, 170, 193, 0.16), var(--bg-2) 60%); border-color: var(--accent-line); }
.wallet-mono { font-family: var(--font-display); font-weight: 700; color: var(--accent); }
.wallet-btn { background: var(--bg-2); }

.how-h { margin-bottom: var(--s-3); }

/* calmer play page + auth card */
.mode-card { min-height: 0; padding: var(--s-5); gap: var(--s-3); background: var(--bg-2); }
.mode-quick { background: var(--bg-2); min-height: 0; }
.mode-quick .h2 { font-size: 1.5rem; max-width: none; }
.mode-card .actions { margin-top: var(--s-3); }
.auth-card .h1 { font-size: 1.6rem; }
.auth-fine { margin-top: var(--s-4); color: var(--faint); }
.auth-sub { font-size: 0.92rem; }
