/* ═══════════════════════════════════════════════════════════════════════════
   theme.css — the NexHub look (same tokens, fonts and components as the control center).
   Loaded last. It re-maps the variable names the older game stylesheets use, so every game's chrome follows
   the palette; boards and cards keep their own colours.
═══════════════════════════════════════════════════════════════════════════ */

@font-face { font-family: 'Jakarta'; font-weight: 200 800; font-display: swap; src: url('/fonts/PlusJakartaSans-latin.woff2') format('woff2');
  unicode-range: U+0000-00FF, U+0131, U+0152-0153, U+02BB-02BC, U+02C6, U+02DA, U+02DC, U+2000-206F, U+2074, U+20AC, U+2122, U+2191, U+2193, U+2212, U+2215, U+FEFF, U+FFFD; }
@font-face { font-family: 'Jakarta'; font-weight: 200 800; font-display: swap; src: url('/fonts/PlusJakartaSans-latin-ext.woff2') format('woff2');
  unicode-range: U+0100-02AF, U+0304, U+0308, U+0329, U+1E00-1E9F, U+1EF2-1EFF, U+2020, U+20A0-20AB, U+20AD-20CF, U+2113, U+2C60-2C7F, U+A720-A7FF; }

:root {
  --nx-font-en: 'Jakarta', 'Vazirmatn', ui-sans-serif, system-ui, -apple-system, 'Segoe UI', sans-serif;
  --nx-font-fa: 'Vazirmatn', 'Jakarta', Tahoma, ui-sans-serif, system-ui, sans-serif;
  --nx-brand: #5b8dee; --nx-brand-2: #a78bfa;
  --nx-brand-grad: linear-gradient(135deg, #5b8dee 0%, #7c6cf0 55%, #a78bfa 100%);
  --nx-bg: #080b14; --nx-bg-2: #0b0f1a;
  --nx-surface: #0f1421; --nx-surface-2: #141a2a; --nx-surface-3: #1a2134; --nx-hover: #182036;
  --nx-border: rgba(148, 163, 205, .12); --nx-border-strong: rgba(148, 163, 205, .22);
  --nx-text: #e8ecf7; --nx-text-2: #a3aec8; --nx-text-3: #6b7695;
  --nx-success: #2fd09a; --nx-success-bg: rgba(47, 208, 154, .12);
  --nx-warning: #f5b544; --nx-warning-bg: rgba(245, 181, 68, .13);
  --nx-danger: #f2616b; --nx-danger-bg: rgba(242, 97, 107, .13);
  --nx-info: #4fb6f5; --nx-info-bg: rgba(79, 182, 245, .13);
  --nx-brand-bg: rgba(91, 141, 238, .14);
  --nx-shadow-sm: 0 1px 2px rgba(0, 0, 0, .35);
  --nx-shadow: 0 8px 24px -6px rgba(0, 0, 0, .45), 0 2px 6px rgba(0, 0, 0, .25);
  --nx-shadow-lg: 0 28px 70px -14px rgba(0, 0, 0, .65), 0 6px 18px rgba(0, 0, 0, .35);
  --nx-ring: 0 0 0 3px rgba(91, 141, 238, .35);
  --nx-ease: cubic-bezier(.23, 1, .32, 1);
  color-scheme: dark;

  /* the names the older stylesheets use */
  --bg: var(--nx-bg); --surface: var(--nx-surface); --surface2: var(--nx-surface-2); --surface-2: var(--nx-surface-2);
  --border: var(--nx-border); --text: var(--nx-text); --text-muted: var(--nx-text-2);
  --accent: var(--nx-brand); --accent-hover: #7aa3f5; --danger: var(--nx-danger); --warning: var(--nx-warning); --info: var(--nx-info);
}
:root[data-theme='light'] {
  --nx-bg: #f4f6fb; --nx-bg-2: #eef1f8;
  --nx-surface: #ffffff; --nx-surface-2: #f7f8fc; --nx-surface-3: #eef1f8; --nx-hover: #f1f4fb;
  --nx-border: rgba(16, 24, 48, .09); --nx-border-strong: rgba(16, 24, 48, .17);
  --nx-text: #121a2e; --nx-text-2: #4c5876; --nx-text-3: #8a94ad;
  --nx-success: #109868; --nx-success-bg: rgba(16, 152, 104, .1);
  --nx-warning: #b77905; --nx-warning-bg: rgba(212, 140, 10, .12);
  --nx-danger: #d23a45; --nx-danger-bg: rgba(210, 58, 69, .09);
  --nx-info: #1f7fc2; --nx-info-bg: rgba(31, 127, 194, .09);
  --nx-brand: #3d6fe0; --nx-brand-bg: rgba(61, 111, 224, .1);
  --nx-shadow-sm: 0 1px 2px rgba(16, 24, 48, .06);
  --nx-shadow: 0 8px 24px -8px rgba(16, 24, 48, .14), 0 2px 6px rgba(16, 24, 48, .05);
  --nx-shadow-lg: 0 30px 70px -16px rgba(16, 24, 48, .25), 0 6px 18px rgba(16, 24, 48, .08);
  --nx-ring: 0 0 0 3px rgba(61, 111, 224, .3);
  color-scheme: light;
}

/* ── page ─────────────────────────────────────────────────────────────────── */
html, body { font-family: var(--nx-font-en); font-size: 14px; line-height: 1.6; background: var(--nx-bg); color: var(--nx-text); -webkit-font-smoothing: antialiased; }
:root[lang='fa'] html, :root[lang='fa'] body, :root[lang='fa'] { --font-ui: var(--nx-font-fa); }
:root[lang='fa'] body { font-family: var(--nx-font-fa); font-size: 14.5px; line-height: 1.7; }
button, input, select, textarea { font-family: inherit; }
body::before { content: ''; position: fixed; inset: -20% -10% auto auto; width: 70vw; height: 70vh; pointer-events: none; z-index: 0;
  background: radial-gradient(closest-side, rgba(91, 141, 238, .13), transparent 70%); }
:root[dir='rtl'] body::before { inset: -20% auto auto -10%; }
:root[data-theme='light'] body::before { background: radial-gradient(closest-side, rgba(91, 141, 238, .09), transparent 70%); }
.screen { position: relative; z-index: 1; }
a { color: var(--nx-brand); text-decoration: none; }
::selection { background: rgba(91, 141, 238, .35); }
* { scrollbar-width: thin; scrollbar-color: var(--nx-border-strong) transparent; }
.i { width: 18px; height: 18px; flex: none; display: inline-block; vertical-align: -3.5px; }
.ltr { direction: ltr; unicode-bidi: isolate; }

/* ── buttons ──────────────────────────────────────────────────────────────── */
.btn { --b-bg: var(--nx-surface-2); --b-fg: var(--nx-text); --b-bd: var(--nx-border-strong);
  display: inline-flex; align-items: center; justify-content: center; gap: 8px; height: 38px; padding: 0 15px; border-radius: 10px;
  background: var(--b-bg); color: var(--b-fg); border: 1px solid var(--b-bd); font-weight: 600; font-size: 13.5px;
  cursor: pointer; white-space: nowrap; text-decoration: none; user-select: none; position: relative; touch-action: manipulation;
  transition: transform .16s var(--nx-ease), background .15s, border-color .15s, box-shadow .2s, color .15s, filter .15s; }
@media (hover: hover) and (pointer: fine) { .btn:hover:not(:disabled) { background: var(--nx-hover); color: var(--b-fg); border-color: var(--nx-border-strong); } }
.btn:active:not(:disabled) { transform: scale(.97); }
.btn:focus-visible { outline: none; box-shadow: var(--nx-ring); }
.btn:disabled, .btn.disabled { opacity: .5; cursor: not-allowed; }
.btn-primary { --b-bg: var(--nx-brand-grad); --b-fg: #fff; --b-bd: transparent; background: var(--nx-brand-grad); color: #fff; box-shadow: 0 6px 18px -6px rgba(91, 141, 238, .6); }
@media (hover: hover) and (pointer: fine) { .btn-primary:hover:not(:disabled) { background: var(--nx-brand-grad); color: #fff; filter: brightness(1.08); box-shadow: 0 10px 26px -8px rgba(91, 141, 238, .7); } }
.btn-danger { --b-bg: var(--nx-danger-bg); --b-fg: var(--nx-danger); --b-bd: transparent; background: var(--nx-danger-bg); color: var(--nx-danger); }
@media (hover: hover) and (pointer: fine) { .btn-danger:hover:not(:disabled) { background: var(--nx-danger); color: #fff; } }
.btn-outline { --b-bg: var(--nx-surface-2); background: var(--nx-surface-2); color: var(--nx-text); border: 1px solid var(--nx-border-strong); }
.btn-ghost { --b-bg: transparent; --b-bd: transparent; --b-fg: var(--nx-text-2); background: transparent; border-color: transparent; color: var(--nx-text-2); }
.btn-sm { height: 32px; padding: 0 11px; font-size: 12.8px; border-radius: 8px; gap: 6px; }
.btn-lg { height: 46px; padding: 0 22px; font-size: 15px; border-radius: 12px; }
.btn-block, .btn-full { width: 100%; }
.btn-icon { width: 38px; padding: 0; } .btn-icon.btn-sm { width: 32px; }
.btn-group { display: inline-flex; gap: 6px; flex-wrap: wrap; align-items: center; }

/* ── inputs ───────────────────────────────────────────────────────────────── */
.form-group label, .field > label { display: block; font-size: 12.8px; font-weight: 600; color: var(--nx-text-2); margin: 0 0 6px; }
input[type=text], input[type=password], input[type=number], input[type=search], input:not([type]), select, textarea {
  width: 100%; height: 40px; padding: 0 12px; border-radius: 10px; border: 1px solid var(--nx-border-strong); background: var(--nx-bg-2); color: var(--nx-text);
  font-size: 14px; transition: border-color .15s, box-shadow .2s, background .15s; outline: none; }
:root[data-theme='light'] input:not([type=checkbox]):not([type=radio]), :root[data-theme='light'] select { background: #fff; }
select { cursor: pointer; padding-inline-end: 30px; appearance: none; background-repeat: no-repeat; background-size: 14px; background-position: right 11px center;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='%238a94ad' stroke-width='2.2' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='m6 9 6 6 6-6'/%3E%3C/svg%3E"); }
:root[dir='rtl'] select { background-position: left 11px center; }
input:focus, select:focus, textarea:focus { border-color: var(--nx-brand); box-shadow: var(--nx-ring); outline: none; }
input::placeholder { color: var(--nx-text-3); }
input[type=checkbox], input[type=radio] { width: 17px; height: 17px; accent-color: var(--nx-brand); margin: 0; cursor: pointer; }
input[type=range] { height: auto; padding: 0; border: 0; background: transparent; box-shadow: none; accent-color: var(--nx-brand); }
.form-error { color: var(--nx-danger); font-size: 12.8px; min-height: 18px; margin-bottom: 8px; }
.checkbox-group label { display: flex; align-items: center; gap: 10px; color: var(--nx-text); font-weight: 500; font-size: 13.8px; }

/* ── brand ────────────────────────────────────────────────────────────────── */
.brand { display: inline-flex; align-items: center; gap: 11px; color: var(--nx-text); }
.logo { width: 34px; height: 34px; border-radius: 10px; background: var(--nx-brand-grad); display: grid; place-items: center; flex: none; box-shadow: 0 6px 18px -4px rgba(91, 141, 238, .55); font-size: 0; }
.logo svg { width: 20px; height: 20px; }
.brand-text { display: flex; flex-direction: column; line-height: 1.1; }
.brand-name { font-family: var(--nx-font-en); font-weight: 800; font-size: 16.5px; letter-spacing: -.02em; }
.brand-name b { background: var(--nx-brand-grad); -webkit-background-clip: text; background-clip: text; color: transparent; }
.brand-sub { font-size: 11.5px; color: var(--nx-text-3); font-weight: 500; margin-top: 2px; }

/* ── sign-in ──────────────────────────────────────────────────────────────── */
#auth-screen { background: none; min-height: 100vh; min-height: 100dvh; display: none; }
#auth-screen.active { display: block; }
.nx-auth { min-height: 100vh; min-height: 100dvh; display: grid; grid-template-columns: minmax(0, 1.05fr) minmax(0, 1fr); position: relative; z-index: 1; }
.nx-auth-form { display: flex; flex-direction: column; padding: 28px 32px; }
.nx-auth-top { display: flex; justify-content: space-between; align-items: center; gap: 10px; }
.nx-auth-inner { width: min(400px, 100%); margin: auto; animation: nx-rise .6s var(--nx-ease); }
.nx-auth-inner h1 { font-size: 26px; font-weight: 800; letter-spacing: -.02em; margin: 0; }
:root[lang='fa'] .nx-auth-inner h1 { letter-spacing: 0; }
.nx-sub { color: var(--nx-text-2); margin: 8px 0 26px; }
.nx-note { color: var(--nx-text-3); font-size: 12.8px; text-align: center; margin-top: 16px; }
.nx-foot { text-align: center; color: var(--nx-text-3); font-size: 12px; margin-top: 30px; }
.tab-bar { display: flex; gap: 4px; padding: 4px; background: var(--nx-surface-2); border: 1px solid var(--nx-border); border-radius: 12px; margin: 0 0 20px; }
.tab-btn { flex: 1; height: 34px; padding: 0 10px; background: none; border: 0; border-radius: 9px; color: var(--nx-text-2); cursor: pointer; font-weight: 600; font-size: 13.5px; transition: background .15s, color .15s; border-bottom: 0; }
.tab-btn.active { background: var(--nx-surface-3); color: var(--nx-text); box-shadow: var(--nx-shadow-sm); border-bottom: 0; }
.nx-auth-art { position: relative; overflow: hidden; padding: 48px; display: flex; flex-direction: column; color: #e8ecf7;
  background: radial-gradient(1200px 600px at 20% 10%, rgba(91, 141, 238, .35), transparent 60%), radial-gradient(900px 500px at 90% 100%, rgba(167, 139, 250, .35), transparent 60%), #070a14; }
.nx-grid { position: absolute; inset: 0; background-image: linear-gradient(rgba(255,255,255,.05) 1px, transparent 1px), linear-gradient(90deg, rgba(255,255,255,.05) 1px, transparent 1px);
  background-size: 46px 46px; -webkit-mask-image: radial-gradient(ellipse at center, #000 30%, transparent 75%); mask-image: radial-gradient(ellipse at center, #000 30%, transparent 75%); }
.nx-orb { position: absolute; border-radius: 50%; }
.nx-orb-1 { width: 620px; height: 620px; top: -220px; inset-inline-end: -200px; background: radial-gradient(closest-side, rgba(91, 141, 238, .55), rgba(91, 141, 238, 0)); }
.nx-orb-2 { width: 560px; height: 560px; bottom: -220px; inset-inline-start: -180px; background: radial-gradient(closest-side, rgba(167, 139, 250, .5), rgba(167, 139, 250, 0)); }
.nx-art-content { position: relative; margin-top: auto; max-width: 480px; }
.nx-art-content h2 { text-wrap: balance; font-size: 34px; line-height: 1.2; font-weight: 800; color: #fff; letter-spacing: -.02em; margin: 0; }
:root[lang='fa'] .nx-art-content h2 { letter-spacing: 0; line-height: 1.5; }
.nx-art-content p { color: #a9b4d0; font-size: 15px; margin: 12px 0 0; }
.nx-feats { display: grid; gap: 12px; margin-top: 28px; }
.nx-feat { display: flex; gap: 12px; align-items: center; color: #cfd7ea; font-size: 14px; }
.nx-feat .i { color: #8fb0ff; }
@keyframes nx-rise { from { opacity: 0; transform: translateY(8px); } to { opacity: 1; transform: none; } }
@media (max-width: 900px) { .nx-auth { grid-template-columns: minmax(0, 1fr); } .nx-auth-art { display: none; } .nx-auth-form { padding: 20px; } }

/* ── headers ──────────────────────────────────────────────────────────────── */
.lobby-header, .game-header { background: color-mix(in srgb, var(--nx-surface) 96%, transparent); border-bottom: 1px solid var(--nx-border); padding: 10px 20px; }
.lobby-header { position: sticky; top: 0; z-index: 20; }
.game-header h2 { font-size: 15px; font-weight: 700; }
.header-user { gap: 8px; flex-wrap: wrap; }
.header-user #header-username { color: var(--nx-text-2); font-size: 13px; }
.turn-indicator { height: 24px; display: inline-flex; align-items: center; padding: 0 10px; border-radius: 99px; background: var(--nx-surface-3); border: 1px solid transparent; color: var(--nx-text-2); font-weight: 600; font-size: 12px; }
.turn-indicator.my-turn { background: var(--nx-success-bg); color: var(--nx-success); border-color: transparent; }
#spectator-banner { background: var(--nx-brand-bg); border-bottom: 1px solid var(--nx-border); color: var(--nx-text); }

/* ── lobby ────────────────────────────────────────────────────────────────── */
.lobby-body { max-width: 1120px; margin: 0 auto; width: 100%; padding: 22px 18px 70px; gap: 22px; }
.lobby-create, .waiting-card, .game-card, .auth-container { background: var(--nx-surface); border: 1px solid var(--nx-border); border-radius: 16px; box-shadow: var(--nx-shadow-sm); }
.lobby-create { padding: 20px; width: 340px; }
.lobby-create h2, .section-header h2 { font-size: 16px; font-weight: 700; }
.game-card { padding: 14px 16px; transition: border-color .15s, background .15s; }
@media (hover: hover) and (pointer: fine) { .game-card:hover { border-color: var(--nx-border-strong); } }
.game-card-info h4 { font-size: 14.5px; font-weight: 700; }
.game-card-info p { color: var(--nx-text-2); font-size: 12.5px; }
.game-type-badge, .game-card-status { display: inline-flex; align-items: center; height: 22px; padding: 0 9px; border-radius: 99px; font-size: 11.8px; font-weight: 600; text-transform: none; letter-spacing: 0; background: var(--nx-surface-3); color: var(--nx-text-2); margin-top: 0; }
.status-waiting { background: var(--nx-success-bg); color: var(--nx-success); }
.status-playing { background: var(--nx-info-bg); color: var(--nx-info); }
.status-paused { background: var(--nx-warning-bg); color: var(--nx-warning); }
.saved-games-section h3 { color: var(--nx-text-2); font-size: 13px; font-weight: 700; text-transform: none; letter-spacing: 0; }
.empty-state { color: var(--nx-text-3); font-style: normal; }
.collapsible-btn { border-color: var(--nx-border-strong); color: var(--nx-text-2); border-radius: 10px; }
.game-type-description, .waiting-hint { color: var(--nx-text-2); }
.help-btn { width: 24px; height: 24px; border-radius: 50%; border: 1px solid var(--nx-border-strong); background: var(--nx-surface-2); color: var(--nx-text-2); font-weight: 700; cursor: pointer; }
.game-options { border-color: var(--nx-border-strong); border-radius: 12px; background: var(--nx-surface-2); }
.waiting-card { padding: 32px 36px; }
.players-waiting-list li { border-color: var(--nx-border); }
.lang-toggle { min-width: 56px; }

/* ── game screen ──────────────────────────────────────────────────────────── */
.game-sidebar { background: color-mix(in srgb, var(--nx-surface) 90%, transparent); border-color: var(--nx-border); }
.players-section h3, .action-section h3, .log-section h3, .chat-section h3 { color: var(--nx-text-3); font-size: 11.5px; font-weight: 700; letter-spacing: .06em; }
.player-card { background: var(--nx-surface-2); border: 1px solid var(--nx-border); border-radius: 12px; }
.player-card.active-turn { border-color: var(--nx-brand); box-shadow: 0 0 0 1px var(--nx-brand) inset; }
.player-card-money { color: var(--nx-brand); }
.player-jail-badge { border-radius: 99px; }
.game-log, .chat-messages { background: var(--nx-bg-2); border-radius: 12px; border: 1px solid var(--nx-border); }
.log-entry.type-info, .log-entry.type-move { color: var(--nx-text-2); }
.chat-form input { height: 36px; }
.board-wrapper { background: transparent; }

/* ── modals, banners, tables ──────────────────────────────────────────────── */
.modal { background: rgba(4, 6, 12, .6); }
.modal-content { background: var(--nx-surface); border: 1px solid var(--nx-border-strong); border-radius: 18px; box-shadow: var(--nx-shadow-lg); color: var(--nx-text); }
.modal-header { border-bottom: 1px solid var(--nx-border); }
.modal-close { color: var(--nx-text-2); }
.modal-footer { background: var(--nx-surface-2); border-top: 1px solid var(--nx-border); border-radius: 0 0 18px 18px; }
.conn-banner { background: var(--nx-warning); color: #1a1405; }
.spectator-count { background: var(--nx-surface-3); border-color: transparent; color: var(--nx-text-2); }
.lb th { color: var(--nx-text-3); }
.rematch-status { color: var(--nx-text-2); }
.help-overlay-content { background: var(--nx-surface); border-color: var(--nx-border-strong); border-radius: 18px; }

/* ── light theme corrections for the older stylesheets ───────────────────── */
:root[data-theme='light'] .game-log, :root[data-theme='light'] .chat-messages { background: var(--nx-surface-2); }
:root[data-theme='light'] .modal { background: rgba(16, 24, 48, .35); }
:root[data-theme='light'] .logo, :root[data-theme='light'] .btn-primary { box-shadow: 0 6px 18px -6px rgba(61, 111, 224, .45); }

/* Elements that sit on a fixed dark surface (felt, black pills) keep light text in either theme */
.pk-info, .pk-pot, .pk-meta, .pk-sidepots, .pk-bet, .pk-seat .pk-name, .hk-seat, .hk-trump, .chess-clock, .uno-pile-count { color: #e8ecf7; }
.spy-card, .spy-card .spy-card-title, .spy-card .spy-card-sub { color: #fff; }
.pk-meta, .pk-sidepots { color: rgba(255, 255, 255, .78); }
.pk-pot .pk-pot-label { color: rgba(255, 255, 255, .75); }
.log-entry.type-game { color: var(--nx-text); background: var(--nx-surface-3); }
:root[data-theme='light'] .log-entry[class*='type-'] { color: var(--nx-text-2); }
:root[data-theme='light'] .log-entry.type-game { color: var(--nx-text); }
:root[data-theme='light'] .log-entry.type-turn { color: var(--nx-text-3); }

@media (max-width: 760px) { .lobby-body { flex-direction: column; padding: 14px 12px 50px; } .lobby-create { width: 100%; } .lobby-header { padding: 8px 12px; } }
@media (prefers-reduced-motion: reduce) { .nx-auth-inner { animation: none; } }
