:root {
  --bg: #0d0e12;
  --surface: #15161c;
  --surface-2: #1b1c23;
  --surface-3: #23242d;
  --border: #282a34;
  --border-strong: #363846;
  --text: #f2f2f5;
  --muted: #a1a3b3;
  --dim: #6c6e7e;
  --accent: #ffcd4d;
  --ink: #121318;
  --good: #34d399;
  --bad: #ff5c6c;
  --fuse: #ff6a3d;
  --shove: #3fb6ff;
  --mole: #2fd3a0;
  --under: #a68bff;
  --quick: #ff4f88;
  --display: 'Bricolage Grotesque', 'Segoe UI', system-ui, sans-serif;
  --body: 'DM Sans', system-ui, -apple-system, 'Segoe UI', Roboto, sans-serif;
  --mono: 'JetBrains Mono', ui-monospace, 'Cascadia Mono', Consolas, monospace;
  --radius: 14px;
  /* legacy names still used by game styles */
  --card: var(--surface);
  --card2: var(--surface-3);
  --bg2: var(--surface-2);
  --line: var(--border);
  color-scheme: dark;
}

* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body { margin: 0; min-height: 100vh; background: var(--bg); color: var(--text); font: 400 15px/1.5 var(--body); -webkit-font-smoothing: antialiased; }
button, input { font: inherit; color: inherit; }
button { cursor: pointer; }
a { color: inherit; }
h1, h2, h3 { font-family: var(--display); font-weight: 700; letter-spacing: -0.02em; line-height: 1.1; margin: 0; }
p { margin: 0; }
.muted { color: var(--muted); }
.dim { color: var(--dim); }
.hidden { display: none !important; }
.icon { flex: none; display: block; }

/* --- top bar ------------------------------------------------------------- */
.topbar { position: sticky; top: 0; z-index: 20; display: flex; align-items: center; gap: 14px; height: 60px; padding: 0 max(20px, env(safe-area-inset-left)); background: rgba(13, 14, 18, 0.86); backdrop-filter: blur(12px); border-bottom: 1px solid var(--border); }
.logo { display: inline-flex; align-items: center; gap: 9px; font: 800 1.15rem/1 var(--display); letter-spacing: -0.03em; text-decoration: none; color: var(--text); }
.logo.big { font-size: 2rem; }
.logo-mark { display: grid; place-items: center; width: 26px; height: 26px; border-radius: 7px; background: var(--accent); color: var(--ink); }
.logo-mark .icon { fill: currentColor; stroke: none; transform: translateX(1px); }
.online { display: inline-flex; align-items: center; gap: 7px; font-size: 0.82rem; font-weight: 500; color: var(--muted); }
.online::before { content: ''; width: 7px; height: 7px; border-radius: 50%; background: var(--good); }
.online.offline::before { background: var(--bad); }
.spacer { flex: 1; }
.icon-btn { display: grid; place-items: center; width: 36px; height: 36px; border-radius: 9px; border: 1px solid transparent; background: none; color: var(--muted); }
.icon-btn:hover { background: var(--surface-2); color: var(--text); border-color: var(--border); }
.me-chip { display: flex; align-items: center; gap: 9px; height: 38px; padding: 0 12px 0 4px; border-radius: 10px; border: 1px solid var(--border); background: var(--surface); font-weight: 700; font-size: 0.9rem; max-width: 52vw; }
.me-chip:hover { border-color: var(--border-strong); background: var(--surface-2); }
.me-chip .av { width: 30px; height: 30px; font-size: 1.05rem; border-radius: 7px; }
.me-chip .nm { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.lvl { font: 700 0.7rem/1 var(--body); color: var(--muted); background: var(--surface-3); border-radius: 6px; padding: 4px 6px; white-space: nowrap; }
.streak { display: inline-flex; align-items: center; gap: 3px; font-size: 0.8rem; font-weight: 700; color: var(--fuse); white-space: nowrap; }

/* --- avatars ------------------------------------------------------------- */
.av { display: grid; place-items: center; flex: none; width: 38px; height: 38px; border-radius: 10px; background: var(--surface-3); font-size: 1.35rem; line-height: 1; }
.av.lg { width: 52px; height: 52px; font-size: 1.9rem; border-radius: 13px; }
.game-badge { --c: var(--accent); display: grid; place-items: center; flex: none; border-radius: 12px; color: var(--c); background: color-mix(in srgb, var(--c) 16%, var(--surface-2)); border: 1px solid color-mix(in srgb, var(--c) 30%, transparent); }

/* --- layout -------------------------------------------------------------- */
.view { max-width: 1120px; margin: 0 auto; padding: 28px 20px 96px; }
.boot { display: grid; place-items: center; min-height: 50vh; text-align: center; gap: 10px; }
.section { margin-top: 48px; }
.section-head { display: flex; align-items: baseline; gap: 12px; margin-bottom: 16px; flex-wrap: wrap; }
.section-head h2 { font-size: 1.3rem; }
.section-head .muted { font-size: 0.9rem; }
.grid { display: grid; gap: 14px; grid-template-columns: repeat(auto-fill, minmax(300px, 1fr)); }
.card { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); padding: 18px; }
.row { display: flex; gap: 10px; align-items: center; flex-wrap: wrap; }
.stack { display: flex; flex-direction: column; gap: 10px; }
.two-col { display: grid; gap: 24px; grid-template-columns: 1fr 1fr; }
@media (max-width: 820px) { .two-col { grid-template-columns: 1fr; } }

/* --- buttons ------------------------------------------------------------- */
.btn { --c: var(--accent); display: inline-flex; align-items: center; justify-content: center; gap: 8px; height: 40px; padding: 0 16px; border-radius: 10px; border: 1px solid transparent; background: var(--c); color: var(--ink); font-weight: 700; font-size: 0.92rem; white-space: nowrap; text-decoration: none; user-select: none; transition: filter 0.15s, background 0.15s, border-color 0.15s, transform 0.05s; }
.btn:hover { filter: brightness(1.07); }
.btn:active { transform: translateY(1px); }
.btn:disabled { opacity: 0.45; cursor: not-allowed; filter: none; transform: none; }
.btn.ghost { background: transparent; color: var(--text); border-color: var(--border-strong); }
.btn.ghost:hover { background: var(--surface-2); filter: none; }
.btn.small { height: 34px; padding: 0 12px; font-size: 0.85rem; border-radius: 9px; }
.btn.big { height: 48px; padding: 0 22px; font-size: 1rem; border-radius: 12px; }
.btn.block { width: 100%; }
.link { background: none; border: 0; padding: 0; color: var(--muted); text-decoration: underline; font-weight: 500; }

/* --- inputs -------------------------------------------------------------- */
.input { height: 40px; padding: 0 12px; border-radius: 10px; border: 1px solid var(--border-strong); background: var(--surface-2); font-weight: 500; outline: none; min-width: 0; transition: border-color 0.15s, box-shadow 0.15s; }
.input:focus { border-color: var(--accent); box-shadow: 0 0 0 3px color-mix(in srgb, var(--accent) 18%, transparent); }
.input.code { width: 7.2em; text-align: center; text-transform: uppercase; letter-spacing: 0.28em; font: 700 1.05rem var(--mono); padding-left: 0.4em; }

/* --- home ---------------------------------------------------------------- */
.hero { display: grid; grid-template-columns: 1.15fr 1fr; gap: 40px; align-items: center; padding: 20px 0 8px; }
@media (max-width: 900px) { .hero { grid-template-columns: 1fr; gap: 28px; } }
.hero h1 { font-size: clamp(2.2rem, 5vw, 3.3rem); font-weight: 800; letter-spacing: -0.035em; line-height: 1.02; }
.hero .lede { font-size: 1.05rem; color: var(--muted); margin-top: 16px; max-width: 34em; }
.join-bar { display: flex; gap: 10px; margin-top: 26px; flex-wrap: wrap; align-items: center; }
.join-bar .hint { font-size: 0.85rem; color: var(--dim); }
.daily-stack { display: grid; gap: 12px; }
.daily-card { --c: var(--accent); display: grid; grid-template-columns: auto 1fr; gap: 4px 14px; align-items: start; padding: 16px; border-radius: var(--radius); background: var(--surface); border: 1px solid var(--border); }
.daily-card .game-badge { grid-row: span 3; }
.daily-card .kicker { display: flex; align-items: center; gap: 8px; font-size: 0.75rem; font-weight: 700; letter-spacing: 0.08em; text-transform: uppercase; color: var(--c); }
.daily-card h3 { font-size: 1.15rem; }
.daily-card p { color: var(--muted); font-size: 0.9rem; }
.daily-card .foot { grid-column: 2; display: flex; align-items: center; gap: 12px; flex-wrap: wrap; margin-top: 10px; }
.daily-card .meta { font-size: 0.82rem; color: var(--dim); }
.tag { font: 700 0.66rem/1 var(--body); letter-spacing: 0.06em; text-transform: uppercase; color: var(--ink); background: var(--good); border-radius: 5px; padding: 4px 6px; }
.game-card { --c: var(--accent); display: flex; flex-direction: column; gap: 14px; padding: 18px; border-radius: var(--radius); background: var(--surface); border: 1px solid var(--border); transition: border-color 0.15s; }
.game-card:hover { border-color: color-mix(in srgb, var(--c) 45%, var(--border)); }
.game-card .top { display: flex; align-items: center; gap: 14px; }
.game-card h3 { font-size: 1.3rem; }
.game-card p { color: var(--muted); flex: 1; font-size: 0.93rem; }
.game-card .players { font-size: 0.8rem; color: var(--dim); margin-top: 3px; }
.game-card .players.live { color: var(--good); }
.room-list, .board { display: flex; flex-direction: column; gap: 6px; }
.room-row { display: flex; align-items: center; gap: 12px; padding: 10px 12px; border-radius: 12px; background: var(--surface); border: 1px solid var(--border); }
.room-row .code { font: 700 0.95rem var(--mono); letter-spacing: 0.12em; width: 4.4em; }
.room-row .info { flex: 1; min-width: 0; }
.room-row .info b { display: block; font-weight: 700; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.room-row .info span { font-size: 0.82rem; color: var(--muted); }
.pill { font: 700 0.7rem/1 var(--body); padding: 5px 8px; border-radius: 6px; background: var(--surface-3); color: var(--muted); white-space: nowrap; }
.pill.live { background: color-mix(in srgb, var(--good) 16%, transparent); color: var(--good); }
.empty { padding: 22px; text-align: center; color: var(--dim); font-size: 0.9rem; border: 1px dashed var(--border-strong); border-radius: var(--radius); }
.board-row { display: flex; align-items: center; gap: 10px; padding: 8px 12px; border-radius: 10px; background: var(--surface); border: 1px solid var(--border); }
.board-row .rk { width: 1.6em; text-align: center; font: 700 0.85rem var(--mono); color: var(--dim); }
.board-row:nth-child(1) .rk { color: var(--accent); }
.board-row .nm { flex: 1; min-width: 0; font-weight: 700; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.board-row .sc { font: 700 0.85rem var(--mono); color: var(--muted); }
.board-row.me { border-color: var(--accent); }
.board-row .av { width: 30px; height: 30px; font-size: 1rem; border-radius: 8px; }
.site-foot { margin-top: 64px; padding-top: 20px; border-top: 1px solid var(--border); color: var(--dim); font-size: 0.82rem; display: flex; gap: 16px; flex-wrap: wrap; }

/* --- modal / toasts ---------------------------------------------------- */
.modal-back { position: fixed; inset: 0; z-index: 50; display: grid; place-items: center; padding: 16px; background: rgba(6, 7, 10, 0.72); animation: fade 0.15s; }
.modal { width: min(520px, 100%); max-height: calc(100vh - 32px); overflow: hidden auto; padding: 24px; border-radius: 18px; background: var(--surface); border: 1px solid var(--border-strong); animation: pop 0.18s; }
.modal h2 { font-size: 1.45rem; margin-bottom: 8px; }
.modal .sub { color: var(--muted); font-size: 0.92rem; margin-bottom: 16px; }
.modal label.field { display: block; font-size: 0.8rem; font-weight: 700; color: var(--muted); margin: 0 0 6px; }
.avatar-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(46px, 1fr)); gap: 6px; margin: 10px 0 4px; }
.avatar-grid button { position: relative; aspect-ratio: 1; display: grid; place-items: center; border-radius: 10px; border: 1px solid var(--border); background: var(--surface-2); font-size: 1.45rem; }
.avatar-grid button:hover { border-color: var(--border-strong); }
.avatar-grid button.sel { border-color: var(--accent); box-shadow: inset 0 0 0 1px var(--accent); }
.avatar-grid button.locked { cursor: not-allowed; }
.avatar-grid button.locked > span.e { filter: grayscale(1); opacity: 0.3; }
.avatar-grid .req { position: absolute; inset: auto 0 3px; font: 700 0.56rem/1 var(--body); color: var(--muted); text-align: center; }
.xpbar { height: 6px; border-radius: 99px; background: var(--surface-3); overflow: hidden; }
.xpbar > div { height: 100%; background: var(--accent); border-radius: 99px; }
.stats { display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px; margin-top: 14px; }
.stats div { padding: 10px; border-radius: 10px; background: var(--surface-2); color: var(--muted); font-size: 0.75rem; text-align: center; }
.stats b { display: block; font: 700 1.25rem var(--display); color: var(--text); }
.toasts { position: fixed; left: 50%; bottom: 20px; z-index: 60; transform: translateX(-50%); display: flex; flex-direction: column; align-items: center; gap: 8px; width: min(92vw, 440px); pointer-events: none; }
.toast { padding: 10px 16px; border-radius: 10px; background: var(--surface-3); border: 1px solid var(--border-strong); font-weight: 500; font-size: 0.9rem; text-align: center; box-shadow: 0 12px 32px rgba(0, 0, 0, 0.45); animation: pop 0.18s; }
.toast.good { border-color: color-mix(in srgb, var(--good) 55%, var(--border)); }
.toast.bad { border-color: color-mix(in srgb, var(--bad) 60%, var(--border)); }
.toast.xp { border-color: color-mix(in srgb, var(--accent) 60%, var(--border)); color: var(--accent); }
.noscript { padding: 40px; text-align: center; }

@keyframes fade { from { opacity: 0; } }
@keyframes pop { from { transform: scale(0.96); opacity: 0; } }
@keyframes shake { 10%, 90% { transform: translate(-2px, 1px); } 20%, 80% { transform: translate(4px, -2px); } 30%, 50%, 70% { transform: translate(-6px, 2px); } 40%, 60% { transform: translate(6px, -2px); } }
@keyframes rise { from { transform: translate(-50%, -110%); opacity: 1; } to { transform: translate(-50%, -190%); opacity: 0; } }
@keyframes pulse { 50% { transform: scale(1.06); } }
@media (prefers-reduced-motion: reduce) { *, *::before, *::after { animation-duration: 0.01ms !important; transition-duration: 0.01ms !important; } }

@media (max-width: 560px) {
  .topbar { gap: 8px; padding: 0 12px; }
  .online { display: none; }
  .me-chip .nm { display: none; }
  .me-chip { padding-right: 8px; }
  .view { padding: 18px 14px 80px; }
}
