@import url('https://fonts.googleapis.com/css2?family=DM+Sans:wght@400;500;700&family=Space+Grotesk:wght@500;600;700&display=swap');

:root {
  color-scheme: dark;
  --background: #10131d;
  --surface: #1a1f2c;
  --surface-raised: #222938;
  --text: #f5f6fb;
  --muted: #a4adbf;
  --accent: #c5f36b;
  --accent-ink: #1b2510;
  --danger: #ff8c8c;
  font-family: 'DM Sans', sans-serif;
}

* { box-sizing: border-box; }
body { margin: 0; min-height: 100vh; color: var(--text); background: radial-gradient(ellipse at top, #252b3b 0, var(--background) 58%); }
h1, h2, h3 { font-family: 'Space Grotesk', sans-serif; margin-top: 0; }
h1 { font-size: clamp(2rem, 5vw, 3.2rem); margin-bottom: 1.5rem; }
h2 { font-size: 1.25rem; margin-bottom: 1rem; }
a { color: inherit; }
button, input { font: inherit; }
.panel, .home-card { background: var(--surface); border: 1px solid #ffffff14; border-radius: 20px; box-shadow: 0 20px 60px #0003; padding: 1.5rem; }
.panel { margin: 1.5rem auto; }
.narrow { max-width: 470px; margin: 8vh auto; }
.wide { max-width: 1050px; margin: 6vh auto; }
.eyebrow { color: var(--accent); font-size: .75rem; font-weight: 700; letter-spacing: .16em; text-transform: uppercase; }
.button { border: 0; border-radius: 10px; cursor: pointer; display: inline-flex; align-items: center; justify-content: center; font-weight: 700; min-height: 44px; padding: .7rem 1rem; text-decoration: none; transition: transform .15s, filter .15s; }
.button:hover { filter: brightness(1.08); transform: translateY(-1px); }
.button:disabled { cursor: not-allowed; opacity: .5; transform: none; }
.primary { color: var(--accent-ink); background: var(--accent); }
.secondary { color: var(--text); background: #394254; }
.text-link { color: var(--muted); font-size: .9rem; }
.stack { display: grid; gap: .75rem; }
label { color: var(--muted); font-size: .9rem; }
input { color: var(--text); background: #111621; border: 1px solid #ffffff24; border-radius: 9px; min-height: 46px; padding: .7rem .8rem; }
input:focus { border-color: var(--accent); outline: 2px solid #c5f36b33; }
.error { color: var(--danger); min-height: 1.2em; }
.notice { color: var(--muted); min-height: 1.4em; }
.home-page { display: grid; place-items: center; padding: 1.5rem; }
.home-card { max-width: 600px; padding: clamp(2rem, 8vw, 5rem); }
.home-card h1 { font-size: clamp(3rem, 12vw, 6rem); line-height: .96; }
.home-card h1 span { color: var(--accent); }
.home-card > p:not(.eyebrow) { color: var(--muted); line-height: 1.7; max-width: 30rem; margin-bottom: 2rem; }
.home-card .button { margin-right: 1rem; }
.page-header, .lobby-heading, .panel header { align-items: center; display: flex; justify-content: space-between; gap: 1rem; }
.page-header h1, .lobby-heading h1 { margin-bottom: 0; }
.lobby-cards { display: grid; gap: .8rem; margin-top: 1.2rem; }
.lobby-card { align-items: center; background: var(--surface-raised); border-radius: 12px; display: flex; justify-content: space-between; gap: 1rem; padding: 1rem; }
.lobby-card h2 { margin: 0 0 .25rem; }
.lobby-card p { color: var(--muted); margin: 0; }
.lobby-actions { display: flex; gap: .5rem; }
.lobby-shell { margin: 0 auto; max-width: 1240px; padding: 2rem; }
.lobby-heading { margin-bottom: 1.2rem; }
.lobby-title-row { align-items: baseline; display: flex; flex-wrap: wrap; gap: .75rem; }
.lobby-title-row h1 { margin-bottom: 0; }
.lobby-username { color: var(--accent); font-size: 1.15rem; font-weight: 700; }
.lobby-layout { display: grid; gap: 1.25rem; grid-template-columns: minmax(0, 1fr) 280px; align-items: start; }
.main-column { min-width: 0; }
.chat-panel { margin-top: 0; }
.chat-messages { background: #111621; border-radius: 10px; display: flex; flex-direction: column; gap: .55rem; height: 300px; overflow-y: auto; padding: 1rem; }
.chat-message { color: #d7dbea; overflow-wrap: anywhere; }
.chat-message strong { color: var(--accent); margin-right: .4rem; }
.chat-form { display: flex; gap: .6rem; margin-top: .8rem; }
.chat-form input { flex: 1; min-width: 0; }
.leaderboard-panel { margin-top: 1.25rem; min-width: 0; }
.leaderboard-views { display: flex; flex-wrap: wrap; gap: .5rem; }
.leaderboard-views [aria-pressed="true"] { background: var(--accent); color: var(--accent-ink); }
.leaderboard-scroll { max-height: 480px; max-width: 100%; overflow: auto; }
.leaderboard-table { border-collapse: separate; border-spacing: 0; min-width: 100%; width: max-content; }
.leaderboard-table th, .leaderboard-table td { min-width: 110px; white-space: nowrap; padding: .7rem; }
.leaderboard-table th:first-child, .leaderboard-table td:first-child { background: var(--surface); box-sizing: border-box; left: 0; max-width: 120px; min-width: 120px; position: sticky; width: 120px; z-index: 1; }
.leaderboard-table th:nth-child(2), .leaderboard-table td:nth-child(2) { background: var(--surface); box-sizing: border-box; left: 120px; max-width: 110px; min-width: 110px; position: sticky; text-align: right; width: 110px; z-index: 1; }
.leaderboard-table th { background: var(--surface); position: sticky; top: 0; z-index: 2; }
.leaderboard-table th:first-child, .leaderboard-table th:nth-child(2) { z-index: 3; }
.leaderboard-table td:nth-child(n+2), .leaderboard-table th:nth-child(n+2) { text-align: right; }
.leaderboard-table .grand-total { color: var(--accent); font-weight: 700; }
table { border-collapse: collapse; width: 100%; }
th, td { border-bottom: 1px solid #ffffff14; padding: .7rem .4rem; text-align: left; }
th:last-child, td:last-child { text-align: right; }
th { color: var(--muted); font-size: .8rem; font-weight: 500; text-transform: uppercase; }
.player-panel { margin-top: 0; max-height: 75vh; overflow-y: auto; }
.player-list { display: grid; gap: .5rem; list-style: none; margin: 0; padding: 0; }
.player-list li { align-items: center; background: var(--surface-raised); border-radius: 9px; display: flex; justify-content: space-between; gap: .5rem; padding: .65rem .7rem; }
.count { color: var(--muted); font-size: .9rem; font-weight: 400; }
.mute-button { background: transparent; border: 0; color: var(--muted); cursor: pointer; font-size: .9rem; }
.round-panel input[type="range"] { accent-color: var(--accent); display: block; width: 100%; }
.game-buttons { display: flex; flex-wrap: wrap; gap: .7rem; margin-bottom: 1.2rem; }
.round-panel header { margin-bottom: 1rem; }
.round-panel header h2 { margin: 0; }
.round-panel header span { color: var(--muted); }
.round-control-status { align-items: center; display: flex; flex-wrap: wrap; gap: .75rem; }
.live-game-panel header h2 { margin: 0; }
.live-game-panel header span { color: var(--muted); font-size: .85rem; }
.live-game-players { display: grid; gap: .75rem; list-style: none; margin: 0; max-height: 360px; overflow-y: auto; padding: 0; }
.live-game-player { align-items: center; display: grid; gap: .6rem; grid-template-columns: minmax(5rem, 8rem) minmax(0, 1fr) auto; }
.live-game-name { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.live-game-bar { background: #111621; border: 1px solid #ffffff24; border-radius: 999px; height: .8rem; overflow: hidden; }
.live-game-fill { background: var(--accent); height: 100%; }
.live-game-score { color: var(--accent); font-weight: 700; min-width: 3rem; text-align: right; }
.sr-only { height: 1px; overflow: hidden; position: absolute; width: 1px; clip: rect(0, 0, 0, 0); }
.game-page { padding: 1.5rem; }
.game-shell { margin: 0 auto; max-width: 900px; text-align: center; }
.game-shell h1 { margin: .4rem 0 1rem; }
.game-stats { align-items: center; color: var(--muted); display: flex; flex-wrap: wrap; gap: 1rem 2rem; justify-content: center; margin-bottom: 1rem; }
.game-stats strong { color: var(--accent); }
@media (max-width: 760px) {
  .lobby-shell { padding: 1rem; }
  .round-panel header { align-items: flex-start; flex-wrap: wrap; }
  .lobby-layout { grid-template-columns: 1fr; }
  .player-panel { grid-row: 1; max-height: 230px; }
  .wide { margin: 1rem; }
}
