:root {
  --bg: #0d1117;
  --panel: #161b22;
  --panel-2: #1c2330;
  --border: #2a3340;
  --text: #e6edf3;
  --muted: #8b97a7;
  --accent: #209ce9;   /* official nano brand blue */
  --accent-2: #1b87cc;
  --nano: #209ce9;
  --wait: #c0392b;
  --wait-2: #e74c3c;
  --go: #20c997;
  --go-2: #2ecc71;
  --gold: #f5c518;
  --radius: 14px;
  --shadow: 0 8px 30px rgba(0, 0, 0, 0.35);
}

* { box-sizing: border-box; }

body {
  margin: 0;
  font-family: "Segoe UI", system-ui, -apple-system, Roboto, Helvetica, Arial, sans-serif;
  background: radial-gradient(1200px 600px at 50% -10%, #14283f 0%, var(--bg) 60%);
  color: var(--text);
  min-height: 100vh;
  display: flex;
  flex-direction: column;
}

header {
  text-align: center;
  padding: 28px 16px 8px;
}
header h1 {
  margin: 0;
  font-size: clamp(28px, 5vw, 44px);
  letter-spacing: -0.5px;
}
#home-link { cursor: pointer; display: inline-block; outline: none; transition: opacity 0.12s ease; }
#home-link:hover { opacity: 0.85; }
#home-link:focus-visible { text-decoration: underline; }
.tagline { color: var(--muted); margin: 6px 0 0; }
.tagline strong { color: var(--nano); }
.tagline-link { color: var(--nano); font-weight: 600; text-decoration: none; }
.tagline-link:hover { text-decoration: underline; }
.brand-symbol { height: 0.82em; width: auto; vertical-align: -0.04em; }
.ticker {
  display: inline-block;
  font-size: 0.7em;
  font-weight: 700;
  letter-spacing: 0.5px;
  color: var(--nano);
  border: 1px solid rgba(32, 156, 233, 0.5);
  border-radius: 6px;
  padding: 1px 6px;
  vertical-align: 1px;
}
.footer-symbol { height: 12px; width: auto; vertical-align: -1px; opacity: 0.7; margin-right: 4px; }

main {
  width: min(960px, 92vw);
  margin: 16px auto;
  flex: 1;
}

.card {
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 20px;
  box-shadow: var(--shadow);
  margin-bottom: 18px;
}
.card h2 { margin-top: 0; }
.card h3 { margin: 0 0 12px; font-size: 16px; color: var(--muted); text-transform: uppercase; letter-spacing: 1px; }

label {
  display: block;
  margin: 14px 0;
  font-weight: 600;
}
.hint { color: var(--muted); font-weight: 400; font-size: 13px; }
input[type="text"] {
  display: block;
  width: 100%;
  margin-top: 6px;
  padding: 12px 14px;
  background: var(--panel-2);
  border: 1px solid var(--border);
  border-radius: 10px;
  color: var(--text);
  font-size: 15px;
  font-weight: 400;
}
input[type="text"]:focus { outline: none; border-color: var(--accent); }

.addr-status { display: block; margin-top: 6px; font-size: 13px; font-weight: 400; min-height: 18px; }
.addr-status.ok { color: var(--go-2); }
.addr-status.bad { color: var(--wait-2); }

button {
  background: linear-gradient(180deg, var(--accent), var(--accent-2));
  color: white;
  border: none;
  border-radius: 10px;
  padding: 13px 22px;
  font-size: 16px;
  font-weight: 700;
  cursor: pointer;
  width: 100%;
  transition: transform 0.05s ease, filter 0.15s ease;
}
button:hover { filter: brightness(1.08); }
button:active { transform: translateY(1px); }
button.secondary {
  background: var(--panel-2);
  border: 1px solid var(--border);
  color: var(--text);
  font-size: 15px;
}
button.secondary:hover { border-color: var(--accent); filter: none; }

.payout-info { color: var(--muted); font-size: 14px; margin-top: 16px; text-align: center; }
.lobby-error { color: var(--wait-2); font-size: 14px; text-align: center; min-height: 18px; margin: 10px 0 0; }

/* Lobby actions */
.lobby-actions { margin-top: 18px; }
#quick-btn { font-size: 18px; padding: 16px; }
.divider {
  display: flex; align-items: center; text-align: center;
  color: var(--muted); font-size: 13px; margin: 18px 0;
}
.divider::before, .divider::after { content: ""; flex: 1; border-bottom: 1px solid var(--border); }
.divider span { padding: 0 12px; }
.private-row { display: flex; flex-direction: column; gap: 10px; }
.join-room { display: flex; gap: 10px; }
.join-room input {
  margin-top: 0; flex: 1; text-transform: uppercase; letter-spacing: 3px;
  font-weight: 700; text-align: center;
}
.join-room button { width: auto; padding: 13px 24px; }

/* Waiting screen */
.waiting-body { color: var(--muted); text-align: center; margin: 8px 0 18px; line-height: 1.6; }
.room-code {
  font-size: 44px; font-weight: 800; letter-spacing: 10px;
  color: var(--nano); margin: 14px 0; text-indent: 10px;
}
.spinner {
  width: 34px; height: 34px; margin: 6px auto 22px;
  border: 3px solid var(--border); border-top-color: var(--accent);
  border-radius: 50%; animation: spin 0.8s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }

/* Scorebar */
.scorebar {
  display: flex; align-items: center; justify-content: center; gap: 18px;
  background: var(--panel); border: 1px solid var(--border);
  border-radius: var(--radius); padding: 12px 18px; margin-bottom: 14px;
  box-shadow: var(--shadow);
}
.score-side { display: flex; align-items: center; gap: 10px; flex: 1; }
.score-side.me { justify-content: flex-end; }
.score-side.opp { justify-content: flex-start; }
.score-name { color: var(--muted); font-weight: 600; max-width: 40vw; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.score-num { font-size: 30px; font-weight: 800; font-variant-numeric: tabular-nums; min-width: 28px; text-align: center; }
.score-side.me .score-num { color: var(--accent); }
.score-side.opp .score-num { color: var(--wait-2); }
.score-vs { color: var(--muted); font-size: 13px; text-transform: uppercase; letter-spacing: 1px; }

#quit-btn { width: auto; margin: 4px auto 0; display: block; }

/* Balance banner */
.balance-banner {
  display: inline-flex; align-items: center; gap: 7px;
  margin: 12px auto 0; padding: 6px 14px;
  background: rgba(32, 156, 233, 0.12);
  border: 1px solid rgba(32, 156, 233, 0.4);
  border-radius: 999px; font-size: 14px; color: var(--text);
}
.balance-banner strong { color: var(--nano); }
.bal-symbol { height: 13px; width: auto; }

/* Batch payout strip */
.batch-strip {
  margin: 8px auto 0;
  font-size: 13px;
  color: var(--muted);
}
.batch-strip strong { color: var(--text); }
#batch-countdown { color: var(--nano); font-variant-numeric: tabular-nums; }
.last-payout { display: block; margin-top: 4px; color: var(--gold); }
.last-payout a { color: var(--nano); }

/* Split bar */
.split-bar {
  display: flex; align-items: center; justify-content: space-between; gap: 14px;
  flex-wrap: wrap;
  background: linear-gradient(90deg, rgba(245, 197, 24, 0.16), var(--panel));
  border: 1px solid rgba(245, 197, 24, 0.5);
  border-radius: var(--radius); padding: 14px 18px; margin-bottom: 18px;
}
#split-text { font-weight: 600; }
.split-btn {
  width: auto; background: linear-gradient(180deg, var(--gold), #d9ad12);
  color: #3a2c00; padding: 11px 20px;
}
.split-btn:disabled { opacity: 0.6; cursor: default; filter: none; }

/* FAQ */
#faq h2 { margin-bottom: 6px; }
#faq details {
  border-top: 1px solid var(--border); padding: 4px 0;
}
#faq details:last-child { border-bottom: 1px solid var(--border); }
#faq summary {
  cursor: pointer; padding: 12px 4px; font-weight: 600; list-style: none;
  display: flex; align-items: center; justify-content: space-between;
}
#faq summary::-webkit-details-marker { display: none; }
#faq summary::after { content: "+"; color: var(--muted); font-size: 20px; font-weight: 400; }
#faq details[open] summary::after { content: "–"; }
#faq summary:hover { color: var(--accent); }
.faq-body { padding: 0 4px 14px; color: var(--muted); line-height: 1.6; }
.faq-body p { margin: 0 0 10px; }
.faq-body ul { margin: 0 0 10px; padding-left: 4px; list-style: none; }
.faq-body li { padding: 10px 12px; background: var(--panel-2); border-radius: 10px; margin-bottom: 8px; color: var(--text); }
.faq-body a { color: var(--nano); }
.faq-body code { background: var(--panel-2); padding: 1px 6px; border-radius: 5px; color: var(--text); }
.donate-addr { display: block; padding: 10px 12px; word-break: break-all; line-height: 1.5; color: var(--nano); background: var(--panel-2); border-radius: 8px; user-select: all; -webkit-user-select: all; cursor: text; }
.faq-body .faq-note { font-size: 13px; }
.rec {
  font-size: 11px; font-weight: 700; text-transform: uppercase; letter-spacing: 0.5px;
  background: var(--go); color: #06231a; padding: 2px 7px; border-radius: 6px; margin-left: 4px;
}
.rec.alt { background: var(--nano); color: #03263a; }

.hidden { display: none !important; }

/* Arena */
.arena {
  user-select: none;
  border-radius: var(--radius);
  height: clamp(240px, 42vh, 380px);
  display: flex;
  align-items: center;
  justify-content: center;
  text-align: center;
  cursor: pointer;
  margin-bottom: 12px;
  box-shadow: var(--shadow);
  transition: background 0.08s ease;
  border: 1px solid rgba(255, 255, 255, 0.06);
  outline: none;
}
.arena-title { font-size: clamp(32px, 7vw, 64px); font-weight: 800; line-height: 1.1; }
.arena-sub { font-size: clamp(15px, 2.5vw, 20px); opacity: 0.9; margin-top: 8px; }

.state-wait { background: linear-gradient(160deg, var(--wait-2), var(--wait)); }
.state-go { background: linear-gradient(160deg, var(--go-2), var(--go)); color: #06231a; }
.state-idle { background: linear-gradient(160deg, #30404f, #232c38); }
.state-countdown { background: linear-gradient(160deg, #3a3f8f, #2a2f6f); }
.state-early { background: linear-gradient(160deg, #6d28d9, #4c1d95); }
.state-result { background: linear-gradient(160deg, #243447, #1a2533); }

.instructions { text-align: center; color: var(--muted); margin: 4px 0 18px; }
.instructions .go-text { color: var(--go-2); font-weight: 700; }
kbd {
  background: var(--panel-2);
  border: 1px solid var(--border);
  border-bottom-width: 2px;
  border-radius: 6px;
  padding: 1px 7px;
  font-size: 13px;
}

.columns { display: grid; grid-template-columns: 1fr 1fr; gap: 18px; }
@media (max-width: 640px) { .columns { grid-template-columns: 1fr; } }
/* Leaderboard: fit as many columns as space allows (3 on wide, fewer on narrow). */
.lb-columns { grid-template-columns: repeat(auto-fit, minmax(180px, 1fr)); }
@media (max-width: 640px) { .lb-columns { grid-template-columns: 1fr; } }

.results-list, .leaderboard { list-style: none; margin: 0; padding: 0; }
.results-list li, .leaderboard li {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 9px 10px;
  border-radius: 8px;
  margin-bottom: 4px;
  background: var(--panel-2);
}
.results-list li .nm, .leaderboard li .nm { display: flex; gap: 8px; align-items: center; }
.results-list li.win { background: linear-gradient(90deg, rgba(245,197,24,0.18), var(--panel-2)); border: 1px solid rgba(245,197,24,0.4); }
.results-list li.you .nm::after, .leaderboard li.you .nm::after { content: "you"; font-size: 11px; color: var(--accent); background: rgba(78,155,255,0.15); padding: 1px 6px; border-radius: 6px; }
.results-list li.dq .ms { color: var(--wait-2); font-size: 13px; }
.ms { font-variant-numeric: tabular-nums; font-weight: 700; }
.medal { width: 22px; display: inline-block; text-align: center; }
.crown { color: var(--gold); }
.muted { color: var(--muted); }

.log { list-style: none; margin: 0; padding: 0; max-height: 180px; overflow-y: auto; font-size: 14px; }
.log li { padding: 5px 2px; border-bottom: 1px solid var(--border); color: var(--muted); }
.log li:last-child { border-bottom: none; }
.log li.good { color: var(--go-2); }
.log li.bad { color: var(--wait-2); }
.log li.gold { color: var(--gold); }
.log li a { color: var(--nano); }

footer {
  display: flex;
  justify-content: space-between;
  width: min(960px, 92vw);
  margin: 0 auto;
  padding: 16px 4px 24px;
  color: var(--muted);
  font-size: 13px;
}
.conn.online { color: var(--go-2); }
.conn.offline { color: var(--wait-2); }
.foot-left { display: inline-flex; align-items: center; gap: 6px; }
.ping-tag { color: var(--muted); font-size: 12px; }
.player-count { color: var(--muted); }
.player-count strong { color: var(--go-2); }

/* Toast pop-ups (bottom-right) */
.toasts {
  position: fixed; right: 16px; bottom: 16px; z-index: 1000;
  display: flex; flex-direction: column; gap: 10px;
  max-width: min(360px, 92vw);
}
.toast {
  background: var(--panel); border: 1px solid var(--border);
  border-left: 4px solid var(--accent); border-radius: 10px;
  padding: 12px 14px; box-shadow: var(--shadow); font-size: 14px;
  cursor: pointer; animation: toast-in 0.25s ease;
}
.toast.success { border-left-color: var(--go-2); }
.toast.error { border-left-color: var(--wait-2); }
.toast.gold { border-left-color: var(--gold); }
.toast.rank { border-left-color: #8b5cf6; }
.toast strong { color: var(--text); }
.toast a { color: var(--nano); }
.toast.fade { opacity: 0; transform: translateX(24px); transition: opacity 0.4s ease, transform 0.4s ease; }
@keyframes toast-in { from { opacity: 0; transform: translateX(24px); } to { opacity: 1; transform: none; } }

/* Live prize-fund balance (bottom-center, gently pulsing glow) */
.fund-balance {
  position: fixed; left: 50%; bottom: 12px; transform: translateX(-50%);
  z-index: 900;
  background: var(--panel); border: 1px solid rgba(32, 156, 233, 0.5);
  border-radius: 999px; padding: 6px 18px;
  color: var(--nano); font-weight: 700; font-size: 15px;
  font-variant-numeric: tabular-nums;
  animation: fund-glow 2.6s ease-in-out infinite;
}
.fund-balance .fund-label {
  color: var(--muted); font-weight: 600; font-size: 11px;
  text-transform: uppercase; letter-spacing: 0.6px; margin-right: 8px;
}
.fund-balance { cursor: pointer; }
@keyframes fund-glow {
  0%, 100% { box-shadow: 0 0 5px rgba(32, 156, 233, 0.35); }
  50% { box-shadow: 0 0 18px rgba(32, 156, 233, 0.8); }
}

/* Donation popup (opens from the fund pill) */
.fund-popup {
  position: fixed; left: 50%; bottom: 56px; transform: translateX(-50%);
  z-index: 950; width: min(360px, 92vw);
  background: var(--panel); border: 1px solid rgba(32, 156, 233, 0.5);
  border-radius: var(--radius); padding: 16px 18px 18px;
  box-shadow: var(--shadow); color: var(--text); font-size: 14px;
  animation: fund-pop 0.2s ease;
}
@keyframes fund-pop {
  from { transform: translateX(-50%) scale(0.96); opacity: 0; }
  to { transform: translateX(-50%) scale(1); opacity: 1; }
}
.fund-popup p { margin: 0 0 10px; }
.fund-popup-qr {
  display: block; width: 170px; height: 170px; margin: 0 auto 12px;
  background: #fff; padding: 8px; border-radius: 10px;
}
.fund-popup-note { color: var(--muted); margin: 12px 0 0 !important; }
.fund-popup-note strong { color: var(--nano); }
.fund-popup-close {
  position: absolute; top: 6px; right: 10px; width: auto;
  background: none; border: none; color: var(--muted);
  font-size: 22px; line-height: 1; padding: 2px 6px; cursor: pointer;
}
.fund-popup-close:hover { color: var(--text); filter: none; }

/* Center-screen donation notice (big donations) */
.center-notice {
  position: fixed; inset: 0; z-index: 1500;
  display: flex; align-items: center; justify-content: center;
  pointer-events: none; padding: 16px;
}
.center-notice-inner {
  pointer-events: auto; text-align: center;
  background: var(--panel); border: 1px solid rgba(245, 197, 24, 0.55);
  border-radius: var(--radius); padding: 28px 36px; max-width: 92vw;
  font-size: clamp(22px, 4.5vw, 40px); font-weight: 800; line-height: 1.25;
  color: var(--text); box-shadow: 0 0 50px rgba(245, 197, 24, 0.25);
  animation: center-pop 0.4s cubic-bezier(0.2, 1.4, 0.4, 1);
}
.center-notice-inner strong { color: var(--gold); }
.center-notice-actions { margin-top: 20px; }
.thanks-btn {
  background: linear-gradient(180deg, var(--accent), var(--accent-2));
  color: #fff; border: none; border-radius: 10px;
  padding: 10px 30px; font-size: 16px; font-weight: 700; cursor: pointer;
}
.thanks-btn:hover { filter: brightness(1.08); }
.center-notice.fade { opacity: 0; transition: opacity 0.6s ease; }
@keyframes center-pop { from { transform: scale(0.8); opacity: 0; } to { transform: scale(1); opacity: 1; } }

/* Feed toasts (bottom-left) — other players' payouts; subtle */
.feed-toasts {
  position: fixed; left: 16px; bottom: 16px; z-index: 1000;
  display: flex; flex-direction: column-reverse; gap: 8px;
  max-width: min(300px, 80vw); pointer-events: none;
}
.feed-toast {
  pointer-events: auto;
  background: rgba(22, 27, 34, 0.85);
  border: 1px solid var(--border);
  border-left: 3px solid var(--nano);
  border-radius: 9px; padding: 8px 12px;
  font-size: 13px; color: var(--muted);
  box-shadow: var(--shadow); cursor: pointer;
  animation: feed-in 0.3s ease;
}
.feed-toast strong { color: var(--text); }
.feed-toast.fade { opacity: 0; transform: translateX(-24px); transition: opacity 0.4s ease, transform 0.4s ease; }
@keyframes feed-in { from { opacity: 0; transform: translateX(-24px); } to { opacity: 1; transform: none; } }
