:root {
  --bg: #0a0a16;
  --bg2: #12122a;
  --panel: #1a1a35;
  --panel2: #23234a;
  --accent: #7c4dff;
  --accent2: #00e5ff;
  --pink: #ff2e88;
  --green: #18e06f;
  --yellow: #ffd23f;
  --text: #e8e8ff;
  --muted: #9090b8;
  --border: #2c2c55;
  --shadow: 0 10px 40px rgba(0,0,0,.5);
}

* { box-sizing: border-box; margin: 0; padding: 0; }
html, body { height: 100%; }
body {
  font-family: 'Segoe UI', system-ui, -apple-system, sans-serif;
  background: var(--bg);
  color: var(--text);
  min-height: 100vh;
  overflow-x: hidden;
}
.hidden { display: none !important; }
button { font-family: inherit; cursor: pointer; }
a { color: var(--accent2); }

/* ===================== LOADERS ===================== */
@keyframes spin { to { transform: rotate(360deg); } }
@keyframes bob { 0%, 100% { transform: translateY(0); } 50% { transform: translateY(-9px); } }
.boot-loader {
  position: fixed; inset: 0; z-index: 1000;
  display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 16px;
  background: radial-gradient(circle at 20% 20%, #1d1147 0%, var(--bg) 60%);
}
.boot-loader.hidden { display: none !important; }
.loader-emoji { font-size: 44px; animation: bob 1.4s ease-in-out infinite; }
.loader-spinner {
  width: 46px; height: 46px; border-radius: 50%;
  border: 4px solid rgba(124, 77, 255, .25); border-top-color: var(--accent); border-right-color: var(--accent2);
  animation: spin .8s linear infinite;
}
.loader-text { color: var(--muted); font-size: 14px; max-width: 300px; text-align: center; padding: 0 20px; }
.btn-spin {
  display: inline-block; width: 14px; height: 14px; vertical-align: -2px; margin-right: 7px;
  border: 2px solid rgba(255, 255, 255, .4); border-top-color: #fff; border-radius: 50%;
  animation: spin .7s linear infinite;
}
.view-loading { display: flex; flex-direction: column; align-items: center; gap: 12px; padding: 48px 0; }

/* ===================== SHARED GAME AUDIO + JUICE ===================== */
.gz-mixer { margin-left: auto; display: flex; gap: 12px; align-items: center; }
.gz-mixer label { display: inline-flex; align-items: center; gap: 4px; font-size: 13px; color: var(--muted); }
.gz-mixer input[type=range] { width: 72px; accent-color: var(--accent); cursor: pointer; vertical-align: middle; }

@keyframes gz-pop { 0% { transform: scale(.6); } 60% { transform: scale(1.18); } 100% { transform: scale(1); } }
@keyframes gz-shake { 0%,100% { transform: translateX(0); } 20% { transform: translateX(-5px); } 40% { transform: translateX(5px); } 60% { transform: translateX(-3px); } 80% { transform: translateX(3px); } }
@keyframes gz-flash { 0% { filter: brightness(2.4); } 100% { filter: brightness(1); } }
@keyframes gz-float-up { 0% { opacity: 1; transform: translateY(0) scale(1); } 100% { opacity: 0; transform: translateY(-46px) scale(1.35); } }
@keyframes gz-pulse { 0%,100% { transform: scale(1); } 50% { transform: scale(1.06); } }
.gz-pop { animation: gz-pop .25s ease-out; }
.gz-shake { animation: gz-shake .35s ease; }
.gz-flash { animation: gz-flash .3s ease-out; }
.gz-pulse { animation: gz-pulse 1.2s ease-in-out infinite; }
/* floating score/combo popup (parent should be position:relative) */
.gz-popup { position: absolute; pointer-events: none; font-weight: 800; color: var(--yellow); text-shadow: 0 2px 6px #000; animation: gz-float-up .8s ease-out forwards; z-index: 6; white-space: nowrap; }
/* reusable powerup chips + combo + level banner */
.gz-powerups { display: flex; gap: 6px; flex-wrap: wrap; justify-content: center; min-height: 22px; }
.gz-pchip { font-size: 12px; font-weight: 700; padding: 3px 9px; border-radius: 20px; background: var(--panel2); border: 1px solid var(--accent); animation: gz-pop .25s; }
.gz-combo { font-weight: 800; color: var(--pink); display: inline-block; }
.gz-level-banner { font-size: 22px; font-weight: 800; color: var(--accent2); text-align: center; animation: gz-pop .3s; }
/* keyboard cursor highlight (games toggle this on the focused cell/column) */
.kb-cursor { outline: 3px solid var(--accent2) !important; outline-offset: -1px; box-shadow: 0 0 12px var(--accent2); position: relative; z-index: 3; }
.kb-hint { color: var(--muted); font-size: 12px; text-align: center; margin-top: 6px; }
.kb-hint kbd { background: var(--panel2); border: 1px solid var(--border); border-radius: 5px; padding: 1px 6px; font-size: 11px; }

/* ===================== TOPBAR: search · volume · shortcuts ===================== */
.topbar-search { position: relative; flex: 1 1 180px; max-width: 280px; }
.topbar-search input {
  width: 100%; background: var(--bg2); border: 1px solid var(--border); border-radius: 20px;
  padding: 8px 14px; color: var(--text); font-size: 13px;
}
.topbar-search input:focus { outline: none; border-color: var(--accent); }
.search-results {
  position: absolute; top: calc(100% + 6px); left: 0; right: 0; z-index: 40;
  background: var(--panel); border: 1px solid var(--border); border-radius: 12px; overflow: hidden; box-shadow: var(--shadow);
}
.search-item { padding: 10px 14px; cursor: pointer; font-size: 14px; display: flex; align-items: center; gap: 4px; }
.search-item:hover, .search-item.sel { background: var(--accent); color: #fff; }
.search-tag { font-size: 10px; font-weight: 700; background: rgba(255,46,136,.25); color: var(--pink); padding: 1px 6px; border-radius: 10px; margin-left: auto; }
.search-item.sel .search-tag { color: #fff; }
.search-empty { padding: 10px 14px; color: var(--muted); font-size: 13px; }
.topbar-vol { display: flex; align-items: center; }
.topbar-vol .gz-mixer { margin-left: 0; }
.topbar-vol .gz-mixer input[type=range] { width: 56px; }

/* shortcuts modal */
.modal-overlay { position: fixed; inset: 0; z-index: 400; background: rgba(5,5,16,.82); display: flex; align-items: center; justify-content: center; padding: 20px; }
.modal-panel { background: var(--panel); border: 1px solid var(--border); border-radius: 16px; padding: 26px; width: 100%; max-width: 560px; box-shadow: var(--shadow); }
.modal-panel h2 { margin-bottom: 16px; }
.modal-panel h3 { color: var(--accent2); font-size: 14px; text-transform: uppercase; letter-spacing: 1px; margin-bottom: 8px; }
.kb-cols { display: grid; grid-template-columns: 1fr 1fr; gap: 24px; margin-bottom: 20px; }
.kb-list div { display: flex; align-items: center; gap: 6px; padding: 4px 0; font-size: 14px; }
.kb-list span { color: var(--muted); }
.kb-list .kb-note { color: var(--muted); font-size: 12px; font-style: italic; }
kbd { background: var(--panel2); border: 1px solid var(--border); border-bottom-width: 2px; border-radius: 6px; padding: 2px 7px; font-size: 12px; font-family: inherit; color: var(--text); }
@media (max-width: 560px) { .kb-cols { grid-template-columns: 1fr; gap: 14px; } }

/* fit games in the viewport — cap canvas height so play area + controls stay on one screen */
canvas { max-height: 64vh; }
.game-stage { gap: 12px; }

/* ===================== GAME REQUESTS ===================== */
.req-form { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; max-width: 640px; margin-bottom: 20px; }
.req-form input[type=text] { flex: 1 1 200px; }
.req-anon { display: inline-flex; align-items: center; gap: 5px; font-size: 13px; color: var(--muted); }
.req-msg { flex-basis: 100%; font-size: 13px; min-height: 16px; }
.req-board { display: flex; flex-direction: column; gap: 10px; max-width: 640px; }
.req-card { display: flex; gap: 14px; align-items: center; background: var(--panel); border: 1px solid var(--border); border-radius: 12px; padding: 12px 16px; }
.req-vote { display: flex; flex-direction: column; align-items: center; min-width: 50px; background: var(--bg2); border: 1px solid var(--border); border-radius: 10px; padding: 6px 0; color: var(--muted); cursor: pointer; transition: .15s; }
.req-vote:hover { border-color: var(--accent); color: var(--text); }
.req-vote.voted { border-color: var(--accent); background: rgba(124,77,255,.18); color: var(--accent2); }
.req-arrow { font-size: 12px; line-height: 1; }
.req-count { font-size: 16px; }
.req-body { flex: 1; min-width: 0; }
.req-title { font-weight: 700; }
.req-detail { color: var(--muted); font-size: 13px; margin: 2px 0; word-break: break-word; }
.req-by { color: var(--muted); font-size: 12px; }

/* ===================== PROFILES ===================== */
.user-name.clickable { cursor: pointer; }
.user-name.clickable:hover { color: var(--accent2); }
.profile-card { max-width: 640px; background: var(--panel); border: 1px solid var(--border); border-radius: 16px; padding: 24px; }
.profile-card > h1 { font-size: 24px; }
.pf-head { display: flex; align-items: center; gap: 16px; }
.pf-avatar { font-size: 50px; width: 80px; height: 80px; display: flex; align-items: center; justify-content: center; background: var(--bg2); border-radius: 50%; border: 2px solid var(--accent); flex: 0 0 auto; }
.pf-head h1 { font-size: 26px; }
.pf-since { color: var(--muted); font-size: 13px; }
.pf-bio { margin: 14px 0; }
.pf-badges { display: flex; flex-wrap: wrap; gap: 8px; margin: 14px 0; }
.pf-badge { font-size: 12px; font-weight: 700; background: var(--panel2); border: 1px solid var(--accent); border-radius: 20px; padding: 4px 10px; }
.pf-stats { display: grid; grid-template-columns: repeat(auto-fit, minmax(88px, 1fr)); gap: 10px; margin: 16px 0; }
.pf-stat { background: var(--bg2); border: 1px solid var(--border); border-radius: 10px; padding: 12px; text-align: center; }
.pf-stat b { display: block; font-size: 22px; color: var(--accent2); }
.pf-stat span { color: var(--muted); font-size: 12px; }
.profile-card h2 { font-size: 16px; margin: 18px 0 8px; color: var(--accent2); }
.pf-rows { display: flex; flex-direction: column; gap: 6px; }
.pf-row { display: flex; justify-content: space-between; gap: 12px; background: var(--bg2); border: 1px solid var(--border); border-radius: 9px; padding: 8px 12px; font-size: 14px; }
.pf-row b { color: var(--yellow); }
.pf-cta { margin-top: 18px; }
.pf-share { color: var(--muted); font-size: 13px; margin: 12px 0; max-width: 640px; word-break: break-all; }
.profile-edit { max-width: 640px; background: var(--panel); border: 1px solid var(--border); border-radius: 16px; padding: 20px; margin-top: 16px; }
.profile-edit h2 { font-size: 16px; margin-bottom: 12px; }
.pf-edit-row { display: flex; flex-direction: column; gap: 4px; margin-bottom: 12px; }
.pf-edit-row label { font-size: 13px; color: var(--muted); }
.pf-edit-row input { width: 100%; }
.pf-public { display: flex; align-items: center; gap: 6px; font-size: 13px; color: var(--muted); margin-bottom: 14px; }

/* ===================== AUTH ===================== */
.auth-screen {
  position: fixed; inset: 0;
  display: flex; flex-direction: column; align-items: center;
  gap: 30px; padding: 6vh 20px 48px; overflow-y: auto;
  background: radial-gradient(circle at 20% 20%, #1d1147 0%, var(--bg) 60%);
  z-index: 100;
}
.seo-landing { position: relative; max-width: 760px; width: 100%; line-height: 1.6; }
.seo-landing h1 { font-size: 26px; margin-bottom: 12px; text-align: center; }
.seo-landing h2 { font-size: 19px; margin: 26px 0 10px; color: var(--accent2); }
.seo-landing h3 { font-size: 15px; margin: 16px 0 4px; }
.seo-landing p { color: var(--muted); margin-bottom: 10px; }
.seo-games { list-style: none; display: grid; grid-template-columns: repeat(auto-fill, minmax(210px, 1fr)); gap: 8px; padding: 0; margin: 8px 0; }
.seo-games li { background: var(--panel); border: 1px solid var(--border); border-radius: 10px; padding: 10px 12px; font-size: 13px; color: var(--muted); }
.seo-landing strong { color: var(--text); }
.seo-props { list-style: none; display: flex; flex-wrap: wrap; gap: 8px; padding: 0; margin: 4px 0 18px; }
.seo-props li { background: var(--panel2); border: 1px solid var(--border); border-radius: 30px; padding: 6px 14px; font-size: 13px; font-weight: 600; color: var(--text); }
.seo-games a { color: inherit; text-decoration: none; }
.seo-games a:hover strong { color: var(--accent2); }

/* Per-game landing pages (/play/*) */
.seo-page { line-height: 1.65; }
.seo-crumb { font-size: 13px; color: var(--muted); margin-bottom: 14px; }
.seo-crumb a { color: var(--muted); }
.seo-page h1 { font-size: 30px; margin-bottom: 6px; }
.seo-page h2 { font-size: 20px; margin: 28px 0 10px; color: var(--accent2); }
.seo-tags { color: var(--muted); font-size: 13px; margin-bottom: 14px; }
.seo-intro { color: var(--text); max-width: 720px; margin-bottom: 18px; }
.seo-cta { display: inline-block; text-decoration: none; padding: 14px 28px; font-size: 17px; border-radius: 12px; }
.seo-how { margin: 4px 0 4px 20px; color: var(--text); }
.seo-how li { margin: 6px 0; }
.seo-related, .seo-game-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); gap: 12px; margin-top: 8px; }
.seo-related-card, .seo-game-card {
  background: var(--panel); border: 1px solid var(--border); border-radius: 12px;
  padding: 14px; text-decoration: none; color: var(--text); text-align: center; transition: .15s;
}
.seo-related-card { display: flex; align-items: center; gap: 8px; text-align: left; }
.seo-related-card span, .seo-game-card .emoji { font-size: 22px; }
.seo-game-card .emoji { font-size: 40px; display: block; margin-bottom: 8px; }
.seo-game-card h3 { font-size: 17px; margin-bottom: 4px; }
.seo-game-card p { color: var(--muted); font-size: 12px; }
.seo-related-card:hover, .seo-game-card:hover { border-color: var(--accent); transform: translateY(-3px); }
.auth-bg {
  position: absolute; inset: 0;
  background-image:
    radial-gradient(circle at 80% 70%, rgba(124,77,255,.25), transparent 40%),
    radial-gradient(circle at 15% 80%, rgba(0,229,255,.18), transparent 40%);
  pointer-events: none;
}
.auth-card {
  position: relative;
  width: 360px; max-width: 92vw;
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: 20px;
  padding: 34px 30px;
  box-shadow: var(--shadow);
  text-align: center;
}
.logo { font-size: 30px; font-weight: 800; margin-bottom: 6px; }
.logo span {
  background: linear-gradient(90deg, var(--accent), var(--accent2));
  -webkit-background-clip: text; background-clip: text; color: transparent;
}
.tagline { color: var(--muted); font-size: 14px; margin-bottom: 22px; }
.auth-tabs { display: flex; background: var(--bg2); border-radius: 12px; padding: 4px; margin-bottom: 18px; }
.auth-tab {
  flex: 1; padding: 10px; border: none; background: transparent;
  color: var(--muted); font-weight: 600; border-radius: 9px; transition: .15s;
}
.auth-tab.active { background: var(--accent); color: #fff; }
#auth-form { display: flex; flex-direction: column; gap: 12px; }
input[type=text], input[type=email], input[type=password] {
  background: var(--bg2); border: 1px solid var(--border);
  border-radius: 11px; padding: 13px 15px; color: var(--text); font-size: 15px;
}
input:focus { outline: none; border-color: var(--accent); }
/* Keep autofilled fields on-theme instead of the browser's white box. */
input:-webkit-autofill, input:-webkit-autofill:hover, input:-webkit-autofill:focus {
  -webkit-text-fill-color: var(--text);
  -webkit-box-shadow: 0 0 0 1000px var(--bg2) inset;
  caret-color: var(--text);
}
.btn-primary {
  background: linear-gradient(90deg, var(--accent), var(--pink));
  color: #fff; border: none; padding: 13px; border-radius: 11px;
  font-size: 16px; font-weight: 700; transition: .15s;
}
.btn-primary:hover { filter: brightness(1.1); transform: translateY(-1px); }
.btn-primary:active { transform: translateY(0); }
.auth-error { color: var(--pink); font-size: 13px; min-height: 16px; }
.auth-hint { color: var(--muted); font-size: 12px; margin-top: 14px; }

/* ===================== APP SHELL ===================== */
.app { display: flex; flex-direction: column; min-height: 100vh; }
.topbar {
  display: flex; align-items: center; gap: 20px;
  padding: 14px 26px; background: var(--bg2);
  border-bottom: 1px solid var(--border); position: sticky; top: 0; z-index: 20;
}
.brand { font-size: 22px; font-weight: 800; cursor: pointer; }
.nav { display: flex; gap: 6px; margin-left: 10px; }
.nav-btn {
  background: transparent; border: none; color: var(--muted);
  padding: 9px 16px; border-radius: 9px; font-weight: 600; font-size: 14px;
}
.nav-btn:hover { color: var(--text); background: var(--panel); }
.nav-btn.active { color: #fff; background: var(--accent); }
.user-box { margin-left: auto; display: flex; align-items: center; gap: 12px; }
.user-name { font-weight: 700; }
.user-stats { color: var(--muted); font-size: 13px; }
.btn-ghost {
  background: var(--panel); border: 1px solid var(--border);
  color: var(--text); padding: 8px 14px; border-radius: 9px; font-size: 13px;
}
.btn-ghost:hover { border-color: var(--accent); }
.main { flex: 1; padding: 30px 26px; max-width: 1100px; width: 100%; margin: 0 auto; min-width: 0; overflow-x: hidden; }
.footer { text-align: center; color: var(--muted); font-size: 13px; padding: 24px; }

/* ===================== LOBBY ===================== */
.section-title { font-size: 26px; font-weight: 800; margin-bottom: 4px; }
.section-sub { color: var(--muted); margin-bottom: 24px; }
.game-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(210px, 1fr)); gap: 18px; }
.game-card {
  background: var(--panel); border: 1px solid var(--border);
  border-radius: 16px; padding: 22px; cursor: pointer;
  transition: .18s; position: relative; overflow: hidden;
}
.game-card:hover { transform: translateY(-4px); border-color: var(--accent); box-shadow: var(--shadow); }
.game-card .emoji { font-size: 46px; display: block; margin-bottom: 12px; }
.game-card h3 { font-size: 18px; margin-bottom: 5px; }
.game-card p { color: var(--muted); font-size: 13px; line-height: 1.4; }
.badge {
  position: absolute; top: 14px; right: 14px;
  font-size: 11px; font-weight: 700; padding: 4px 9px; border-radius: 20px;
}
.card-leader { margin-top: 10px; font-size: 12px; color: var(--yellow); min-height: 16px; }
.card-leader b { color: var(--text); }
.badge.solo { background: rgba(0,229,255,.15); color: var(--accent2); }
.badge.mp { background: rgba(255,46,136,.18); color: var(--pink); }

/* ===================== GAME VIEW ===================== */
.game-header { display: flex; align-items: center; gap: 14px; margin-bottom: 20px; }
.back-btn { background: var(--panel); border: 1px solid var(--border); color: var(--text); padding: 9px 15px; border-radius: 10px; font-weight: 600; }
.back-btn:hover { border-color: var(--accent); }
.game-title { font-size: 24px; font-weight: 800; }
.game-stage { display: flex; flex-direction: column; align-items: center; gap: 16px; width: 100%; min-width: 0; max-width: 100%; }
.scorebar { display: flex; gap: 24px; font-size: 16px; font-weight: 600; }
.scorebar b { color: var(--accent2); }
canvas { background: #07070f; border-radius: 12px; border: 1px solid var(--border); touch-action: none; display: block; max-width: 100%; height: auto; }
.controls-hint { color: var(--muted); font-size: 13px; text-align: center; }
.btn { background: var(--accent); color: #fff; border: none; padding: 10px 20px; border-radius: 10px; font-weight: 700; }
.btn:hover { filter: brightness(1.1); }
.btn.secondary { background: var(--panel2); }
.overlay-msg {
  position: absolute; inset: 0; display: flex; flex-direction: column;
  align-items: center; justify-content: center; gap: 14px;
  background: rgba(7,7,15,.82); border-radius: 12px; text-align: center;
}
.overlay-msg h2 { font-size: 30px; }
.stage-wrap { position: relative; display: inline-block; max-width: 100%; }

/* 2048 */
.grid2048 { display: grid; grid-template-columns: repeat(4, 80px); grid-gap: 10px; background: var(--panel2); padding: 12px; border-radius: 12px; }
.tile2048 { width: 80px; height: 80px; border-radius: 8px; display: flex; align-items: center; justify-content: center; font-weight: 800; font-size: 26px; background: #2a2a4a; transition: .1s; }

/* memory */
.mem-grid { display: grid; gap: 10px; }
.mem-card { width: 78px; height: 78px; border-radius: 10px; background: var(--panel2); display: flex; align-items: center; justify-content: center; font-size: 34px; cursor: pointer; border: 2px solid var(--border); transition: .15s; }
.mem-card.flipped { background: var(--accent); }
.mem-card.matched { background: var(--green); cursor: default; }

/* minesweeper */
.ms-grid { display: grid; gap: 3px; background: var(--panel2); padding: 8px; border-radius: 10px; user-select: none; }
.ms-cell { width: 32px; height: 32px; background: #2e2e54; border-radius: 5px; display: flex; align-items: center; justify-content: center; font-weight: 800; font-size: 16px; cursor: pointer; }
.ms-cell.revealed { background: #14142b; cursor: default; }
.ms-cell.mine { background: var(--pink); }

/* tic tac toe / multiplayer boards */
.ttt-board { display: grid; grid-template-columns: repeat(3, 96px); grid-template-rows: repeat(3, 96px); gap: 8px; }
.ttt-cell { background: var(--panel2); border-radius: 12px; display: flex; align-items: center; justify-content: center; font-size: 52px; font-weight: 800; cursor: pointer; border: 2px solid transparent; transition: .12s; }
.ttt-cell:hover { border-color: var(--accent); }
.ttt-cell.x { color: var(--accent2); }
.ttt-cell.o { color: var(--pink); }

.c4-board { display: grid; grid-template-columns: repeat(7, 56px); gap: 6px; background: var(--accent); padding: 10px; border-radius: 14px; }
.c4-cell { width: 56px; height: 56px; border-radius: 50%; background: #0b0b1a; cursor: pointer; transition: .1s; }
.c4-cell.r { background: radial-gradient(circle at 35% 30%, #ff6b6b, #d61f1f); }
.c4-cell.y { background: radial-gradient(circle at 35% 30%, #ffe26b, #e0b900); }
.c4-col:hover .c4-cell:first-child { box-shadow: inset 0 0 0 3px #fff5; }
.c4-cell.c4-win { box-shadow: 0 0 0 3px #fff, 0 0 14px 2px #fff; }

.rps-choices { display: flex; gap: 18px; }
.rps-btn { font-size: 50px; background: var(--panel2); border: 2px solid var(--border); border-radius: 16px; width: 100px; height: 100px; transition: .15s; }
.rps-btn:hover:not(:disabled) { border-color: var(--accent); transform: translateY(-4px); }
.rps-btn:disabled { opacity: .4; cursor: default; }
.rps-btn.chosen { border-color: var(--green); background: rgba(24,224,111,.15); }

/* multiplayer lobby */
.mp-games { display: flex; gap: 12px; flex-wrap: wrap; margin-bottom: 24px; }
.mp-game-pick { background: var(--panel); border: 2px solid var(--border); border-radius: 14px; padding: 16px 22px; min-width: 150px; text-align: center; }
.mp-game-pick.active { border-color: var(--accent); }
.mp-game-pick .emoji { font-size: 34px; display: block; margin-bottom: 6px; }
.room-list { display: flex; flex-direction: column; gap: 10px; margin-top: 14px; }
.room-row { display: flex; align-items: center; gap: 14px; background: var(--panel); border: 1px solid var(--border); border-radius: 12px; padding: 14px 18px; }
.room-row .host { font-weight: 700; }
.room-row .game-tag { color: var(--muted); font-size: 13px; }
.room-row button { margin-left: auto; }
.empty-note { color: var(--muted); padding: 18px 0; }

/* status / turn indicator */
.turn-indicator { font-size: 17px; font-weight: 700; padding: 8px 18px; border-radius: 30px; background: var(--panel); border: 1px solid var(--border); }
.turn-indicator.you { border-color: var(--green); color: var(--green); }
.turn-indicator.them { border-color: var(--yellow); color: var(--yellow); }
.players-row { display: flex; gap: 18px; align-items: center; font-size: 15px; }
.player-chip { padding: 7px 14px; border-radius: 30px; background: var(--panel); border: 1px solid var(--border); font-weight: 600; }
.player-chip.me { border-color: var(--accent2); }

/* chat */
.chat-box { width: 100%; max-width: 420px; background: var(--panel); border: 1px solid var(--border); border-radius: 12px; padding: 12px; }
.chat-log { height: 130px; overflow-y: auto; font-size: 13px; display: flex; flex-direction: column; gap: 4px; margin-bottom: 8px; }
.chat-log .me { color: var(--accent2); }
.chat-input-row { display: flex; gap: 8px; }
.chat-input-row input { flex: 1; padding: 9px 12px; }
.room-code { font-family: monospace; background: var(--bg2); padding: 4px 10px; border-radius: 7px; letter-spacing: 2px; color: var(--yellow); }

/* among us */
.role-card { width: 100%; max-width: 420px; text-align: center; padding: 16px; border-radius: 14px; border: 2px solid var(--border); background: var(--panel); font-size: 18px; }
.role-card.crew { border-color: var(--accent2); }
.role-card.impostor { border-color: #ff4d6d; }
.role-card .role-sub { font-size: 13px; color: var(--muted); font-weight: 500; margin-top: 4px; }
.au-players { display: flex; flex-wrap: wrap; gap: 10px; justify-content: center; }
.player-chip.crew { border-color: var(--accent2); }
.player-chip.impostor { border-color: #ff4d6d; color: #ff8fa3; }
.player-chip.dead { opacity: .45; text-decoration: line-through; }
.au-actions { flex-wrap: wrap; justify-content: center; }
.task-bar { width: 100%; max-width: 420px; height: 14px; background: var(--bg2); border: 1px solid var(--border); border-radius: 30px; overflow: hidden; }
.task-fill { height: 100%; background: var(--green); transition: width .3s; }
.vote-btn { background: var(--panel2); color: var(--text); border: 1px solid var(--border); padding: 9px 16px; border-radius: 10px; font-weight: 700; cursor: pointer; }
.vote-btn:hover:not(:disabled) { border-color: var(--accent); }
.vote-btn.chosen { border-color: var(--green); color: var(--green); }
.vote-btn:disabled { opacity: .45; cursor: default; }
.vote-btn.kill { margin-left: 8px; background: #ff4d6d; color: #fff; border: none; padding: 4px 12px; font-size: 13px; }

/* five nights at freddy's */
.fnaf-office { display: flex; gap: 14px; align-items: stretch; width: 100%; max-width: 560px; background: #07070f; border: 1px solid var(--border); border-radius: 14px; padding: 16px; transition: filter .3s; }
.fnaf-office.fnaf-dark { filter: brightness(.35); }
.fnaf-side { display: flex; flex-direction: column; gap: 10px; justify-content: center; }
.fnaf-door.active { background: #ff4d6d; }
.fnaf-center { flex: 1; display: flex; flex-direction: column; gap: 10px; align-items: center; justify-content: flex-start; }
.fnaf-view { width: 100%; min-height: 120px; display: flex; align-items: center; justify-content: center; font-size: 40px; background: var(--bg2); border-radius: 10px; text-align: center; padding: 10px; }
.fnaf-view .fnaf-warn { font-size: 18px; font-weight: 800; color: #ff4d6d; }
.fnaf-view .fnaf-ok { font-size: 16px; font-weight: 700; color: var(--green); }
.fnaf-cams { width: 100%; background: var(--panel); border: 1px solid var(--border); border-radius: 10px; padding: 10px; font-size: 13px; }
.fnaf-cam-row { display: flex; justify-content: space-between; padding: 4px 0; color: var(--muted); }
.fnaf-over { color: #ff4d6d; }
.fnaf-win { color: var(--green); }
.fnaf-jump { font-size: 72px; line-height: 1; margin-bottom: 6px; }

/* papa's pizzeria */
.papas-play { display: flex; flex-direction: column; align-items: center; gap: 16px; width: 100%; max-width: 440px; }
.papas-ticket { background: var(--panel); border: 1px solid var(--border); border-radius: 10px; padding: 12px 16px; text-align: center; width: 100%; }
.papas-ticket .ticket-row { font-size: 22px; margin-top: 6px; letter-spacing: 4px; }
.pizza { position: relative; width: 180px; height: 180px; border-radius: 50%; background: radial-gradient(circle, #e8a33d 0%, #d98324 60%, #b5651d 100%); border: 8px solid #c9882e; display: flex; align-items: center; justify-content: center; }
.pizza-base { font-size: 0; }
.pizza-toppings { position: absolute; inset: 18px; display: flex; flex-wrap: wrap; align-items: center; justify-content: center; gap: 6px; font-size: 24px; }
.papas-tray { display: flex; flex-wrap: wrap; gap: 10px; justify-content: center; }
.topping-btn { font-size: 26px; padding: 8px 12px; }
.topping-btn.active { background: var(--green); color: #07070f; }
.bake-track { position: relative; width: 100%; height: 26px; background: var(--bg2); border: 1px solid var(--border); border-radius: 30px; overflow: hidden; }
.bake-zone { position: absolute; top: 0; height: 100%; background: rgba(24,224,111,.35); border-left: 2px solid var(--green); border-right: 2px solid var(--green); }
.bake-fill { height: 100%; background: linear-gradient(90deg, #ffd23f, #ff6a00); width: 0; }
.papas-stars { font-size: 40px; letter-spacing: 4px; }

/* leaderboard */
.lb-table { width: 100%; border-collapse: collapse; background: var(--panel); border-radius: 14px; overflow: hidden; }
.lb-table th, .lb-table td { padding: 13px 18px; text-align: left; }
.lb-table th { background: var(--panel2); color: var(--muted); font-size: 13px; text-transform: uppercase; letter-spacing: 1px; }
.lb-table tr:nth-child(even) td { background: rgba(255,255,255,.02); }
.lb-table .rank { font-weight: 800; color: var(--yellow); width: 50px; }
.lb-table tr.me-row td { background: rgba(124,77,255,.18); }

.toast { position: fixed; bottom: 24px; left: 50%; transform: translateX(-50%); background: var(--panel2); border: 1px solid var(--accent); color: var(--text); padding: 12px 22px; border-radius: 12px; box-shadow: var(--shadow); z-index: 200; font-weight: 600; }

/* ===================== Spireborne (deck-builder) ===================== */
.sb-title { font-size: 22px; font-weight: 800; text-align: center; margin: 4px 0 2px;
  background: linear-gradient(90deg, var(--accent), var(--accent2)); -webkit-background-clip: text; background-clip: text; color: transparent; }
.sb-floor { text-align: center; color: var(--yellow); font-weight: 700; letter-spacing: 1px; margin: 2px 0 8px; }

.sb-classes { display: flex; gap: 14px; flex-wrap: wrap; justify-content: center; margin: 10px 0; }
.sb-class { background: var(--panel); border: 1px solid var(--border); border-radius: 14px; padding: 18px; width: 230px; text-align: center; }
.sb-class h3 { margin-bottom: 6px; }
.sb-class p { color: var(--muted); font-size: 13px; min-height: 38px; margin-bottom: 12px; }

/* combatant panels */
.sb-enemy, .sb-you { background: var(--panel); border: 1px solid var(--border); border-radius: 14px;
  padding: 12px 16px; margin: 8px 0; display: flex; flex-direction: column; gap: 8px; }
.sb-enemy.elite { border-color: var(--accent); box-shadow: 0 0 0 1px var(--accent) inset; }
.sb-enemy.boss { border-color: var(--pink); box-shadow: 0 0 18px rgba(255,46,136,.35); }
.sb-enemy-name { font-size: 18px; font-weight: 800; }
.sb-you { border-color: var(--accent2); }
.sb-you-meta { display: flex; gap: 16px; align-items: center; color: var(--muted); font-size: 14px; }
.sb-energy { color: var(--yellow); font-weight: 800; font-size: 16px; }

.sb-intent-wrap { display: flex; align-items: center; gap: 8px; }
.sb-intent-label { color: var(--muted); font-size: 12px; text-transform: uppercase; letter-spacing: 1px; }
.sb-intent { font-size: 18px; font-weight: 800; color: var(--pink); }

/* hp bar */
.sb-hpbar { position: relative; height: 22px; background: var(--bg2); border: 1px solid var(--border);
  border-radius: 30px; overflow: hidden; }
.sb-hpfill { height: 100%; background: linear-gradient(90deg, #18e06f, #0fa85a); transition: width .25s; }
.sb-hplabel { position: absolute; inset: 0; display: flex; align-items: center; justify-content: center;
  font-size: 12px; font-weight: 700; text-shadow: 0 1px 2px rgba(0,0,0,.6); }

/* status chips */
.sb-statuses { display: flex; gap: 6px; flex-wrap: wrap; }
.sb-chip { font-size: 12px; font-weight: 700; padding: 3px 8px; border-radius: 20px; background: var(--panel2); border: 1px solid var(--border); }
.sb-chip.block { background: rgba(0,229,255,.18); border-color: var(--accent2); }
.sb-chip.strength { background: rgba(255,210,63,.18); border-color: var(--yellow); }
.sb-chip.vulnerable { background: rgba(255,46,136,.18); border-color: var(--pink); }
.sb-chip.weak { background: rgba(144,144,184,.2); }
.sb-chip.poison { background: rgba(24,224,111,.18); border-color: var(--green); }
.sb-chip.none { opacity: .4; }

.sb-relics { display: flex; gap: 6px; flex-wrap: wrap; }
.sb-relic { font-size: 12px; padding: 3px 8px; border-radius: 8px; background: var(--panel2); border: 1px solid var(--accent); cursor: help; }

/* hand + cards */
.sb-hand { display: flex; gap: 10px; flex-wrap: wrap; justify-content: center; margin: 12px 0; }
.sb-card { position: relative; width: 132px; min-height: 150px; background: var(--panel2); border: 1px solid var(--border);
  border-radius: 12px; padding: 12px 10px 10px; display: flex; flex-direction: column; gap: 4px; transition: transform .12s, box-shadow .12s; }
.sb-card.attack { border-top: 4px solid var(--pink); }
.sb-card.skill { border-top: 4px solid var(--accent2); }
.sb-card.power { border-top: 4px solid var(--yellow); }
.sb-card.playable { cursor: pointer; }
.sb-card.playable:hover { transform: translateY(-6px); box-shadow: var(--shadow); border-color: var(--accent); }
.sb-card.disabled { opacity: .45; filter: grayscale(.4); }
.sb-card.selected { outline: 2px solid var(--green); transform: translateY(-6px); }
.sb-card-cost { position: absolute; top: -10px; left: -10px; width: 28px; height: 28px; border-radius: 50%;
  background: var(--accent); color: #fff; font-weight: 800; display: flex; align-items: center; justify-content: center; box-shadow: var(--shadow); }
.sb-card-name { font-weight: 800; font-size: 15px; }
.sb-card-type { font-size: 10px; text-transform: uppercase; letter-spacing: 1px; color: var(--muted); }
.sb-card-desc { font-size: 12px; color: var(--text); line-height: 1.35; }

.sb-relic-options { display: flex; gap: 14px; flex-wrap: wrap; justify-content: center; margin: 12px 0; }
.sb-relic-card { width: 220px; background: var(--panel2); border: 1px solid var(--accent); border-radius: 12px; padding: 14px; cursor: pointer; transition: transform .12s; }
.sb-relic-card:hover { transform: translateY(-4px); border-color: var(--accent2); }
.sb-relic-card h4 { margin-bottom: 6px; }
.sb-relic-card p { font-size: 13px; color: var(--muted); }

.sb-score { text-align: center; font-size: 16px; margin: 8px 0; }

/* combat log */
.sb-log { background: var(--bg2); border: 1px solid var(--border); border-radius: 12px; padding: 10px 14px;
  max-height: 160px; overflow-y: auto; margin-top: 10px; font-size: 13px; }
.sb-log-line { padding: 2px 0; color: var(--muted); border-bottom: 1px solid rgba(255,255,255,.03); }
.sb-log-line:last-child { color: var(--text); }

/* daily leaderboard overlay */
.sb-overlay { position: fixed; inset: 0; background: rgba(5,5,16,.78); display: flex; align-items: center; justify-content: center; z-index: 300; padding: 20px; }
.sb-lb-panel { background: var(--panel); border: 1px solid var(--border); border-radius: 16px; padding: 22px; width: 100%; max-width: 460px; box-shadow: var(--shadow); display: flex; flex-direction: column; gap: 14px; }

/* ===================== Responsive layout ===================== */
/* Fluid game boards — shrink to fit any screen, overriding JS inline column sizes. */
.grid2048 { grid-template-columns: repeat(4, 1fr) !important; width: min(92vw, 340px); }
.tile2048 { width: 100%; height: auto; aspect-ratio: 1; font-size: clamp(16px, 6vw, 26px); }
.mem-grid { grid-template-columns: repeat(4, 1fr) !important; width: min(92vw, 340px); }
.mem-card { width: 100%; height: auto; aspect-ratio: 1; font-size: clamp(22px, 8vw, 34px); }
.ms-grid { grid-template-columns: repeat(9, 1fr) !important; width: min(95vw, 330px); }
.ms-cell { width: 100%; height: auto; aspect-ratio: 1; font-size: clamp(11px, 3.6vw, 16px); }
.c4-board { grid-template-columns: repeat(7, 1fr) !important; width: min(94vw, 420px); }
.c4-cell { width: 100%; height: auto; aspect-ratio: 1; }
.ttt-board { grid-template-columns: repeat(3, min(96px, 26vw)); grid-template-rows: repeat(3, min(96px, 26vw)); }
.ttt-cell { font-size: clamp(36px, 12vw, 52px); }
.rps-btn { width: clamp(72px, 24vw, 100px); height: clamp(72px, 24vw, 100px); font-size: clamp(36px, 11vw, 50px); }

@media (max-width: 900px) {
  .main { padding: 24px 18px; }
  .topbar { padding: 12px 18px; gap: 14px; }
}

@media (max-width: 640px) {
  /* topbar wraps; the nav scrolls horizontally so every item stays reachable */
  .topbar { flex-wrap: wrap; gap: 8px 10px; padding: 10px 12px; }
  .brand { font-size: 19px; }
  .nav { order: 3; flex: 1 1 100%; margin-left: 0; overflow-x: auto; -webkit-overflow-scrolling: touch; padding-bottom: 2px; }
  .nav-btn { padding: 8px 12px; font-size: 13px; white-space: nowrap; }
  .user-box { margin-left: auto; gap: 8px; }
  .user-stats { display: none; }
  .main { padding: 16px 12px; }
  .section-title { font-size: 20px; }
  .game-title { font-size: 19px; }
  .section-sub { font-size: 13px; margin-bottom: 16px; }
  .game-grid { grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); gap: 12px; }
  .game-card { padding: 16px; }
  .game-card .emoji { font-size: 38px; }
  .game-header { gap: 10px; margin-bottom: 14px; }
  .scorebar { gap: 12px 16px; font-size: 14px; flex-wrap: wrap; justify-content: center; }
  .lb-table th, .lb-table td { padding: 9px 8px; font-size: 12px; }
  .lb-table .rank { width: 30px; }
  .sb-card { width: 104px; min-height: 132px; }
  .sb-class { width: 100%; max-width: 280px; }
  .sb-hand { gap: 6px; }
  .friend-add, .game-help, .chat-box, .admin-view .friend-add { max-width: 100%; }
  .friend-row .btn, .friend-row .btn.secondary { margin-left: 0; }
  .admin-stats { grid-template-columns: repeat(auto-fit, minmax(108px, 1fr)); }
  .admin-stat b { font-size: 22px; }
  .fnaf-office { flex-direction: column; }
  .mp-game-pick { min-width: 120px; flex: 1; }
}

@media (max-width: 380px) {
  .nav-btn { padding: 7px 9px; font-size: 12px; }
  .game-grid { grid-template-columns: 1fr 1fr; }
  .rps-choices { gap: 10px; }
}

/* Breakout: audio mixer + in-overlay leaderboard */
.bk-mixer { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; justify-content: center; color: var(--muted); font-size: 13px; }
.bk-mixer label { display: inline-flex; align-items: center; gap: 4px; }
.bk-mixer input[type="range"] { width: 110px; accent-color: var(--accent); cursor: pointer; }
.bk-board { margin-top: 14px; min-width: 250px; font-size: 13px; }
.bk-board h3 { margin: 8px 0 4px; font-size: 16px; }
.bk-lb { width: 100%; border-collapse: collapse; }
.bk-lb th, .bk-lb td { padding: 3px 8px; text-align: left; }
.bk-lb th:nth-child(3), .bk-lb td:nth-child(3),
.bk-lb th:nth-child(4), .bk-lb td:nth-child(4) { text-align: right; }
.bk-lb tbody tr:nth-child(odd) { background: rgba(255, 255, 255, 0.04); }
.bk-lb .me-row { background: rgba(124, 77, 255, 0.28); font-weight: 700; }
.bk-rank { margin: 6px 0 0; opacity: 0.85; }

/* How-to-play panel */
.game-help {
  max-width: 560px; margin: 16px auto 0; width: 100%;
  background: var(--panel); border: 1px solid var(--border); border-radius: 12px;
}
.game-help > summary {
  cursor: pointer; padding: 12px 16px; font-weight: 700; list-style: none;
  user-select: none; color: var(--accent2);
}
.game-help > summary::-webkit-details-marker { display: none; }
.game-help > summary::before { content: "▸ "; color: var(--muted); }
.game-help[open] > summary::before { content: "▾ "; }
.game-help-body { padding: 0 18px 14px; font-size: 14px; line-height: 1.5; color: var(--text); }
.game-help-body p { margin: 6px 0; }
.game-help-body ul { margin: 6px 0 6px 18px; padding: 0; }
.game-help-body li { margin: 3px 0; }
.game-help-body .gh-tip { color: var(--muted); margin-top: 10px; }

/* Leaderboards */
.lb-heading { font-size: 20px; margin: 26px 0 6px; }
.lb-tabs { display: flex; flex-wrap: wrap; gap: 8px; margin: 10px 0 14px; }
.lb-tab {
  background: var(--panel); color: var(--muted); border: 1px solid var(--border);
  border-radius: 20px; padding: 7px 14px; font-size: 13px; font-weight: 600; cursor: pointer; transition: .15s;
}
.lb-tab:hover { border-color: var(--accent); color: var(--text); }
.lb-tab.active { background: var(--accent); color: #fff; border-color: var(--accent); }
.lb-game-board { min-height: 60px; }

/* Admin panel */
.admin-stats { display: grid; grid-template-columns: repeat(auto-fit, minmax(140px, 1fr)); gap: 12px; margin: 8px 0 20px; }
.admin-stat {
  background: var(--panel); border: 1px solid var(--border); border-radius: 12px;
  padding: 16px; text-align: center;
}
.admin-stat b { display: block; font-size: 28px; color: var(--accent2); }
.admin-stat span { color: var(--muted); font-size: 13px; }
.admin-view .friend-row .badge { margin-left: 6px; }
.admin-view .friend-row.admin-resolved { opacity: 0.5; }
.admin-view .friend-add { max-width: 560px; flex-wrap: wrap; }
.announce {
  background: linear-gradient(90deg, var(--accent), var(--pink)); color: #fff;
  text-align: center; padding: 10px 16px; font-weight: 600; font-size: 14px;
}

/* Friends & social */
.nav-badge {
  display: inline-block; min-width: 18px; padding: 0 5px; margin-left: 4px;
  background: var(--pink, #ff2e88); color: #fff; border-radius: 9px;
  font-size: 11px; font-weight: 700; text-align: center; line-height: 18px;
}
.friend-add { display: flex; gap: 8px; margin: 8px 0 20px; max-width: 420px; }
.friend-add input { flex: 1; }
.friend-row {
  display: flex; align-items: center; gap: 10px; flex-wrap: wrap;
  background: var(--panel); border: 1px solid var(--border);
  border-radius: 11px; padding: 10px 14px; margin-bottom: 8px;
}
.friend-name { font-weight: 700; }
.friend-row .game-tag { color: var(--muted); font-size: 13px; }
.friend-row .btn, .friend-row .btn.secondary { padding: 6px 12px; font-size: 13px; margin-left: auto; }
.friend-row .btn + .btn { margin-left: 6px; }
.friend-sel {
  background: var(--bg2); color: var(--text); border: 1px solid var(--border);
  border-radius: 9px; padding: 6px 8px; font-size: 13px; margin-left: auto;
}
.friend-sel + .btn { margin-left: 6px; }
.dot { width: 9px; height: 9px; border-radius: 50%; background: #555; display: inline-block; flex: 0 0 auto; }
.dot.on { background: #18e06f; box-shadow: 0 0 6px #18e06f; }
.report-form {
  display: flex; gap: 8px; align-items: center; flex-wrap: wrap;
  background: var(--panel2); border-radius: 11px; padding: 10px 14px; margin: -4px 0 10px;
}
.report-form input { flex: 1; min-width: 140px; }
