:root {
  --ink: #111418;
  --paper: #f4f1eb;
  --muted: #70736f;
  --line: rgba(17, 20, 24, .12);
  --panel: rgba(255, 255, 255, .64);
  --lime: #c5ef63;
  --coral: #ff806d;
  --blue: #6876ff;
  --shadow: 0 22px 80px rgba(26, 32, 42, .10);
}

* { box-sizing: border-box; }
html { background: var(--paper); }
body { margin: 0; color: var(--ink); font-family: "Space Grotesk", sans-serif; min-height: 100vh; overflow-x: hidden; }
button, input { font: inherit; }
button { cursor: pointer; }
.hidden { display: none !important; }
.ambient { position: fixed; border-radius: 50%; filter: blur(1px); pointer-events: none; z-index: -1; }
.ambient-one { width: 460px; height: 460px; right: -170px; top: 80px; background: rgba(197, 239, 99, .38); }
.ambient-two { width: 380px; height: 380px; left: -230px; bottom: -80px; background: rgba(104, 118, 255, .12); }
.topbar { height: 78px; padding: 0 clamp(22px, 5vw, 72px); display: flex; align-items: center; justify-content: space-between; border-bottom: 1px solid var(--line); position: relative; z-index: 2; }
.brand { display: flex; align-items: center; gap: 11px; text-decoration: none; color: var(--ink); font-weight: 700; letter-spacing: .16em; font-size: 14px; }
.brand-mark { width: 31px; height: 31px; display: grid; place-items: center; border: 2px solid var(--ink); border-radius: 9px; font-size: 17px; letter-spacing: 0; transform: rotate(-7deg); }
.topbar-right { display: flex; align-items: center; gap: 20px; }
.connection-status { color: var(--muted); font: 11px "DM Mono", monospace; }
.connection-status i { width: 7px; height: 7px; display: inline-block; border-radius: 50%; background: #f2b84b; margin-right: 7px; }
.page-shell { max-width: 1300px; margin: 0 auto; padding: clamp(54px, 8vw, 108px) clamp(20px, 5vw, 72px) 80px; }
.intro-copy { max-width: 780px; margin-bottom: 52px; }
.eyebrow, .mini-label, .hud-label { font: 500 10px "DM Mono", monospace; letter-spacing: .16em; color: var(--muted); margin: 0 0 14px; }
h1, h2, p { margin-top: 0; }
h1 { font-size: clamp(54px, 8.1vw, 112px); line-height: .88; letter-spacing: -.08em; margin: 0 0 26px; font-weight: 600; }
h1 em { color: var(--blue); font-style: normal; }
h2 { font-size: 21px; letter-spacing: -.04em; margin: 0; }
.intro-text { max-width: 535px; color: #575c61; line-height: 1.6; font-size: 15px; }
.feature-row { display: flex; gap: 25px; margin-top: 31px; color: var(--muted); font: 12px "DM Mono", monospace; }
.feature-row b { color: var(--ink); font-size: 16px; margin-right: 5px; }
.lobby-grid { display: grid; grid-template-columns: minmax(0, .9fr) minmax(0, 1.1fr); gap: 18px; align-items: stretch; }
.panel { background: var(--panel); border: 1px solid rgba(255,255,255,.76); box-shadow: var(--shadow); border-radius: 25px; backdrop-filter: blur(13px); }
.auth-panel, .mode-panel { min-height: 370px; padding: 29px; }
.panel-heading { display: flex; align-items: flex-start; justify-content: space-between; margin-bottom: 27px; }
.panel-number { color: var(--muted); font: 11px "DM Mono", monospace; }
.status-dot { width: 12px; height: 12px; background: var(--lime); border-radius: 50%; box-shadow: 0 0 0 6px rgba(197, 239, 99, .18); }
.tabs { display: flex; gap: 18px; border-bottom: 1px solid var(--line); margin-bottom: 20px; }
.tab { border: 0; background: transparent; color: var(--muted); padding: 0 0 10px; font-size: 13px; position: relative; }
.tab.active { color: var(--ink); }
.tab.active::after { content: ""; position: absolute; height: 2px; background: var(--ink); bottom: -1px; left: 0; right: 0; }
.auth-form { display: grid; gap: 13px; }
label { display: grid; gap: 6px; color: #555b61; font-size: 12px; }
label small { color: var(--muted); font-size: 10px; }
input { width: 100%; border: 1px solid var(--line); background: rgba(255,255,255,.62); border-radius: 10px; padding: 11px 12px; color: var(--ink); outline: none; }
input:focus { border-color: var(--blue); box-shadow: 0 0 0 3px rgba(104,118,255,.12); }
.button { border: 0; border-radius: 999px; padding: 12px 17px; display: inline-flex; align-items: center; justify-content: center; gap: 15px; font-size: 12px; transition: transform .2s, box-shadow .2s, background .2s; }
.button:hover { transform: translateY(-2px); }
.button-primary { color: white; background: var(--ink); margin-top: 4px; }
.button-accent { color: var(--ink); background: var(--lime); box-shadow: 0 10px 25px rgba(147, 190, 59, .21); }
.button-secondary { color: var(--ink); background: rgba(255,255,255,.65); border: 1px solid var(--line); }
.button-quiet { color: var(--muted); background: transparent; padding: 8px 0; }
.full-button { width: 100%; margin-top: 18px; }
.form-message { min-height: 16px; color: var(--coral); font-size: 11px; line-height: 1.4; margin: 12px 0 0; }
.account-state { padding: 12px 14px; border-radius: 12px; background: rgba(197,239,99,.23); font-size: 13px; margin-bottom: 16px; }
.mode-cards { display: grid; gap: 10px; }
.mode-card { width: 100%; display: grid; grid-template-columns: 41px 1fr auto; align-items: center; gap: 14px; text-align: left; border: 1px solid transparent; border-radius: 15px; padding: 15px 16px; color: var(--ink); background: rgba(255,255,255,.34); }
.mode-card:hover, .mode-card.selected { border-color: rgba(104,118,255,.34); background: rgba(255,255,255,.72); }
.mode-icon { width: 36px; height: 36px; display: grid; place-items: center; border-radius: 11px; color: var(--blue); background: rgba(104,118,255,.11); font-size: 20px; }
.mode-card strong { display: block; font-size: 13px; margin-bottom: 4px; }
.mode-card small { display: block; color: var(--muted); font-size: 11px; }
.arrow { color: var(--muted); font-size: 18px; }
.mode-details { margin-top: 23px; }
.upload-row { display: flex; align-items: center; gap: 14px; }
.avatar-preview { width: 60px; height: 60px; display: grid; place-items: center; flex: 0 0 60px; border: 3px solid var(--ink); border-radius: 17px; background: var(--coral); color: var(--ink); font-weight: 700; font-size: 22px; background-size: cover; background-position: center; }
.muted { color: var(--muted); font-size: 12px; line-height: 1.5; }
.upload-row .muted { margin-bottom: 8px; }
.file-button { display: inline-block; color: var(--blue); font-size: 11px; cursor: pointer; }
.file-button input { display: none; }
.match-actions { display: flex; gap: 10px; margin-top: 22px; align-items: center; flex-wrap: wrap; }
.join-row { display: flex; gap: 7px; flex: 1; min-width: 205px; }
.join-row input { max-width: 110px; font: 12px "DM Mono", monospace; letter-spacing: .12em; text-transform: uppercase; }
kbd { padding: 2px 5px; border: 1px solid var(--line); border-bottom-width: 2px; border-radius: 4px; background: rgba(255,255,255,.7); font: 10px "DM Mono", monospace; }
.leaderboard-wrap { margin-top: 18px; padding: 28px 29px; }
.compact-heading { margin-bottom: 18px; }
.leaderboard { display: grid; gap: 2px; }
.leader-row { display: grid; grid-template-columns: 36px 1fr 100px 100px; padding: 11px 0; border-top: 1px solid var(--line); align-items: center; font-size: 12px; }
.leader-row span:first-child { font: 11px "DM Mono", monospace; color: var(--muted); }
.leader-row .score { text-align: right; font: 13px "DM Mono", monospace; }
.leader-row .level { text-align: right; color: var(--muted); font: 11px "DM Mono", monospace; }
.game-screen { padding-top: 4px; }
.game-toolbar { display: flex; align-items: center; justify-content: space-between; margin-bottom: 18px; }
.game-title { display: flex; gap: 9px; align-items: center; font: 11px "DM Mono", monospace; letter-spacing: .12em; }
.live-pill { color: #fff; background: var(--coral); border-radius: 99px; padding: 4px 7px; font-size: 9px; }
.game-hint { color: var(--muted); font-size: 12px; }
.game-stage { padding: 18px; background: #161922; border-color: rgba(255,255,255,.05); box-shadow: 0 30px 100px rgba(17,20,24,.25); }
.hud { display: flex; justify-content: space-between; padding: 0 10px 15px; color: #f1f3f1; }
.hud > div { display: grid; gap: 3px; }
.hud-label { color: #838994; margin: 0; font-size: 9px; }
.hud strong { font: 15px "DM Mono", monospace; letter-spacing: .06em; }
.canvas-wrap { position: relative; overflow: hidden; border-radius: 14px; background: #202531; }
#gameCanvas { display: block; width: 100%; height: auto; aspect-ratio: 16 / 9; image-rendering: auto; }
.game-overlay { position: absolute; inset: 0; display: grid; place-content: center; justify-items: center; text-align: center; padding: 25px; background: rgba(22,25,34,.86); }
.game-overlay h2 { color: #fff; font-size: 40px; margin-bottom: 10px; }
.game-overlay .eyebrow { color: var(--lime); }
.overlay-actions { display: flex; gap: 10px; margin-top: 18px; }
.versus-scorebar { display: flex; justify-content: space-between; align-items: center; padding: 14px 8px 0; color: #f1f3f1; font: 11px "DM Mono", monospace; }
.versus-scorebar > div { display: flex; align-items: center; gap: 9px; }
.versus-scorebar b { font-family: "Space Grotesk", sans-serif; font-weight: 500; }
.versus-scorebar strong { font-size: 15px; }
.versus-scorebar > div:first-child strong { margin-left: 14px; }
.player-chip { width: 8px; height: 8px; border-radius: 50%; display: inline-block; }
.player-one { background: var(--coral); } .player-two { background: var(--lime); }
.versus-label { color: #777d88; }
.toast { position: fixed; left: 50%; bottom: 25px; transform: translate(-50%, 20px); opacity: 0; pointer-events: none; padding: 12px 16px; border-radius: 10px; color: #fff; background: var(--ink); font-size: 12px; transition: .25s; z-index: 10; }
.toast.visible { opacity: 1; transform: translate(-50%, 0); }

@media (max-width: 850px) {
  .lobby-grid { grid-template-columns: 1fr; }
  .intro-copy { margin-bottom: 38px; }
}
@media (max-width: 570px) {
  .topbar { height: 65px; }
  .connection-status { display: none; }
  h1 { font-size: 59px; }
  .page-shell { padding-top: 57px; }
  .auth-panel, .mode-panel, .leaderboard-wrap { padding: 22px; }
  .feature-row { gap: 13px; }
  .game-toolbar { align-items: flex-start; gap: 10px; }
  .game-hint { display: none; }
  .hud { gap: 12px; overflow: auto; }
  .hud strong { font-size: 12px; }
  .versus-scorebar { font-size: 9px; }
  .versus-scorebar > div { gap: 5px; }
  .leader-row { grid-template-columns: 30px 1fr 75px 70px; }
}
