:root{ --bg:#0f172a; --card:#1e293b; --line:#334155; --text:#e2e8f0; --accent:#38bdf8; }
*{ box-sizing:border-box; }
body{ margin:0; min-height:100vh; background:radial-gradient(1000px 500px at 70% -10%,#1e3a5f,var(--bg) 55%);
      color:var(--text); font:15px/1.4 -apple-system,BlinkMacSystemFont,"Segoe UI",sans-serif;
      display:flex; flex-direction:column; align-items:center; gap:18px; padding:28px; }
h1{ font-size:26px; letter-spacing:.32em; margin:0; font-weight:800;
    background:linear-gradient(90deg,#22d3ee,#c084fc,#fb923c); -webkit-background-clip:text; background-clip:text; color:transparent; }
.arena{ display:flex; gap:18px; align-items:flex-start; justify-content:center; flex-wrap:wrap; }
.game{ display:flex; gap:18px; align-items:flex-start; }
.vbar{ display:flex; gap:12px; align-items:center; justify-content:center; }
.brand{ display:flex; align-items:center; justify-content:center; gap:12px; }
.brand-logo{ width:54px; height:54px; filter:drop-shadow(0 0 8px rgba(56,189,248,.3)); }
.btn-icon{ width:18px; height:18px; object-fit:contain; }
.editname{ font-size:11px; margin-left:8px; color:#64748b; }
.editname:hover{ color:var(--accent); }
#find-match{ display:inline-flex; align-items:center; gap:8px; background:linear-gradient(90deg,#f87171,#fb923c); color:#06283d; border:0; border-radius:9px; padding:10px 20px; font-weight:800; font-size:15px; cursor:pointer; }
#find-match:hover{ filter:brightness(1.08); }
#find-match:disabled{ opacity:.5; cursor:default; }
.match-status{ color:#94a3b8; font-size:14px; }
.vpanel{ background:var(--card); border:1px solid var(--line); border-radius:12px; padding:14px; }
.vlabel{ font-size:12px; text-transform:uppercase; letter-spacing:.06em; color:#94a3b8; margin-bottom:10px; text-align:center; }
.vlabel span{ color:var(--bad,#f87171); font-weight:700; }
.vstage{ position:relative; }
#opp-board{ border:1px solid var(--line); border-radius:8px; display:block; }
.vresult{ position:absolute; inset:0; display:none; align-items:center; justify-content:center; border-radius:8px;
          background:rgba(2,6,23,.82); font-size:20px; font-weight:800; text-align:center; }
.panel{ background:var(--card); border:1px solid var(--line); border-radius:12px; padding:14px 16px; min-width:130px; }
.panel h2{ font-size:11px; text-transform:uppercase; letter-spacing:.08em; color:#94a3b8; margin:14px 0 6px; }
.panel h2:first-child{ margin-top:0; }
.stat{ font-size:24px; font-weight:700; }
.mini{ background:#0b1220; border:1px solid var(--line); border-radius:8px; display:block; }
.next-stack{ display:flex; flex-direction:column; gap:8px; }
#board{ border:1px solid var(--line); border-radius:8px; }
.stage{ position:relative; }
#gameover{ position:absolute; inset:0; display:none; flex-direction:column; align-items:center; justify-content:center;
           background:rgba(2,6,23,.8); border-radius:8px; font-size:24px; font-weight:800; gap:8px; }
.hint{ color:#94a3b8; font-size:12px; }
.whoami{ margin:-8px 0 0; color:#94a3b8; font-size:13px; }
.whoami span{ color:var(--accent); font-weight:700; }
.lbpanel{ width:min(460px,90vw); background:var(--card); border:1px solid var(--line); border-radius:12px; padding:16px 18px; }
.lbpanel h2{ margin:0 0 10px; font-size:13px; text-transform:uppercase; letter-spacing:.08em; color:#94a3b8; }
.lbpanel ol{ list-style:none; margin:0; padding:0; }
.lbpanel li{ display:flex; align-items:center; gap:12px; padding:7px 4px; border-bottom:1px solid #243044; }
.lbpanel li:last-child{ border-bottom:0; }
.lbpanel .rank{ width:22px; color:#64748b; font-variant-numeric:tabular-nums; text-align:right; }
.lbpanel .lbname{ flex:1; font-weight:600; }
.lbpanel .lbscore{ font-variant-numeric:tabular-nums; color:var(--accent); font-weight:700; }
.lbpanel .muted{ color:#64748b; justify-content:center; }
/* discreet top-right account widget */
.account{ position:fixed; top:14px; right:16px; z-index:20; }
.account #acct-out, .account #acct-in{ display:flex; gap:8px; align-items:center; }
.account strong{ color:var(--accent); }
.linkbtn{ background:transparent; border:0; color:#94a3b8; font:inherit; font-size:13px; cursor:pointer; padding:6px 8px; border-radius:6px; }
.linkbtn:hover{ color:var(--text); }
.linkbtn.primary{ color:#06283d; background:var(--accent); font-weight:700; padding:6px 14px; }
.linkbtn.primary:hover{ filter:brightness(1.08); }

/* modal */
.modal{ position:fixed; inset:0; z-index:50; display:flex; align-items:center; justify-content:center;
        background:rgba(2,6,23,.72); backdrop-filter:blur(2px); }
.modal[hidden]{ display:none; }
.modal-card{ position:relative; width:min(360px,92vw); background:var(--card); border:1px solid var(--line);
             border-radius:14px; padding:26px 24px; display:flex; flex-direction:column; gap:10px;
             box-shadow:0 20px 60px rgba(0,0,0,.5); }
.modal-card h2{ margin:0 0 6px; font-size:20px; }
.modal-card input{ background:#0b1220; border:1px solid var(--line); color:var(--text); border-radius:9px; padding:11px 12px; font:inherit; width:100%; }
.modal-card #modal-submit{ margin-top:6px; background:var(--accent); color:#06283d; border:0; border-radius:9px; padding:12px; font-weight:700; font-size:15px; cursor:pointer; }
.modal-close{ position:absolute; top:10px; right:12px; background:transparent; border:0; color:#64748b; font-size:24px; line-height:1; cursor:pointer; }
.modal-close:hover{ color:var(--text); }
.modal-switch{ margin:4px 0 0; font-size:13px; color:#94a3b8; text-align:center; }
.modal-switch .linkbtn{ color:var(--accent); padding:2px 4px; }
.authmsg{ text-align:center; font-size:13px; min-height:16px; }
.authmsg.err{ color:#f87171; } .authmsg.ok{ color:#34d399; }

/* lower row: leaderboard + chat side by side */
.lower{ display:flex; gap:18px; align-items:flex-start; flex-wrap:wrap; justify-content:center; }
.lower .lbpanel{ width:300px; }
.chatpanel{ width:320px; background:var(--card); border:1px solid var(--line); border-radius:12px; padding:16px 18px; display:flex; flex-direction:column; }
.chatpanel h2{ margin:0 0 10px; font-size:13px; text-transform:uppercase; letter-spacing:.08em; color:#94a3b8; }
.online{ color:#34d399; font-weight:600; font-size:11px; letter-spacing:0; text-transform:none; }
.onlinenames{ color:#64748b; font-size:12px; margin:-4px 0 10px; min-height:14px; }
.chatmsgs{ height:150px; overflow-y:auto; display:flex; flex-direction:column; gap:5px; font-size:14px; margin-bottom:10px; }
.chatmsg .cn{ color:var(--accent); font-weight:700; margin-right:4px; }
.chatmsgs .muted{ color:#64748b; }
.chatform{ display:flex; gap:8px; }
.chatform input{ flex:1; background:#0b1220; border:1px solid var(--line); color:var(--text); border-radius:8px; padding:9px 11px; font:inherit; }
.chatform button{ background:var(--accent); color:#06283d; border:0; border-radius:8px; padding:9px 14px; font-weight:700; cursor:pointer; }
.lbtabs{ display:flex; gap:6px; margin-bottom:10px; }
.lbtab{ background:transparent; border:1px solid var(--line); color:#94a3b8; border-radius:8px; padding:6px 14px; font:inherit; font-weight:600; cursor:pointer; }
.lbtab.active{ background:var(--accent); color:#06283d; border-color:var(--accent); }
