/* ========================================================================== STYLE.CSS ========================================================================== */
/* ========================================================================== THEME TOKENS & GLOBAL FOUNDATIONS ========================================================================== */
:root {
  --primary-green: #0f9f6e;
  --primary-gold: #ca8a04;
  --primary-red: #dc2626;
  --sand-beige: #f8fbff;
  --desert-orange: #2563eb;
  --desert-brown: #1d4ed8;
  --sky-blue: #38bdf8;
  --dark-blue: #0f172a;
  --light-sand: #eef4ff;
  --bg: #f3f7fd;
  --bg-soft: #ebf1fa;
  --panel: rgba(255, 255, 255, 0.92);
  --panel-weak: #f7faff;
  --panel-strong: #ffffff;
  --text: #0f172a;
  --text-strong: #020617;
  --muted: #64748b;
  --accent: #2563eb;
  --accent-2: #0ea5e9;
  --accent-soft: rgba(37, 99, 235, 0.12);
  --danger: #dc2626;
  --warn: #d97706;
  --ok: #0f9f6e;
  --grid: #d7e0ee;
  --diag: #334155;
  --border: #d7e0ee;
  --border-strong: #c5d1e2;
  --arrow-green: #10b981;
  --arrow-yellow: #f59e0b;
  --arrow-red: #ef4444;
  --shadow-sm: 0 10px 24px rgba(15, 23, 42, 0.06);
  --shadow: 0 18px 44px rgba(15, 23, 42, 0.08);
  --shadow-lg: 0 24px 60px rgba(15, 23, 42, 0.12);
  --radius: 18px;
  --radius-sm: 14px;
  --gap: 12px;
  --font: "Calibri", "Carlito", "Segoe UI", Tahoma, Arial, sans-serif;
  --font-arabic: "Calibri", "Carlito", "Segoe UI", Tahoma, Arial, sans-serif;
  --btn-start: #2563eb;
  --btn-end: #0ea5e9;
  --btn-text: #f8fbff;
  --btn-border: rgba(255, 255, 255, 0.18);
  --btn-shadow: 0 14px 28px rgba(37, 99, 235, 0.22);
  --fs-title: 22px;
  --fs-body: 16px;
  --fs-footer: 12px;
  --board-grid: #01060e;
  --board-diag: #010b18;
  --board3d-base: #dfeafb;
  --board3d-plate: #cfdef6;
  --board3d-frame: #8aa4cb;
  --board3d-cell-light: rgba(255, 255, 255, 0.28);
  --board3d-cell-dark: rgba(110, 139, 182, 0.18);
  --board3d-grain-light: rgba(255, 255, 255, 0.10);
  --board3d-grain-dark: rgba(73, 106, 154, 0.12);
  --board3d-line: #041127;
  --surface-elev-1: rgba(255, 255, 255, 0.78);
  --surface-elev-2: rgba(255, 255, 255, 0.92);
  --surface-stroke: rgba(148, 163, 184, 0.24);
  --surface-stroke-strong: rgba(100, 116, 139, 0.34);
  --z-modal-backdrop: 2147483646;
  --z-modal: 2147483647;
  --z-game-drawer-backdrop: 2147483644;
  --z-game-drawer: 2147483645;
  --icon-dark-bg: #ffffff;
}

:root.dark {
  --bg: #020817;
  --bg-soft: #0b1220;
  --panel: rgba(15, 23, 42, 0.92);
  --panel-weak: #131d32;
  --panel-strong: #111827;
  --text: #e5eefc;
  --text-strong: #f8fbff;
  --muted: #91a4c2;
  --accent: #60a5fa;
  --accent-2: #38bdf8;
  --accent-soft: rgba(96, 165, 250, 0.18);
  --danger: #f87171;
  --warn: #fbbf24;
  --ok: #34d399;
  --grid: #243247;
  --diag: #e2e8f0;
  --border: #243247;
  --border-strong: #314156;
  --arrow-green: #34d399;
  --arrow-yellow: #fbbf24;
  --arrow-red: #f87171;
  --shadow-sm: 0 14px 28px rgba(0, 0, 0, 0.28);
  --shadow: 0 24px 58px rgba(0, 0, 0, 0.42);
  --shadow-lg: 0 32px 72px rgba(0, 0, 0, 0.52);
  --btn-start: #3b82f6;
  --btn-end: #06b6d4;
  --btn-text: #eff6ff;
  --btn-border: rgba(148, 163, 184, 0.14);
  --btn-shadow: 0 16px 34px rgba(2, 6, 23, 0.48);
  --board-grid: #bfd0e8;
  --board-diag: #f8fbff;
  --board3d-base: #223746;
  --board3d-plate: #1b2b37;
  --board3d-frame: #0d1822;
  --board3d-cell-light: rgba(96, 165, 250, 0.09);
  --board3d-cell-dark: rgba(2, 8, 23, 0.22);
  --board3d-grain-light: rgba(255, 255, 255, 0.05);
  --board3d-grain-dark: rgba(2, 8, 23, 0.22);
  --board3d-line: #e5eefc;
  --surface-elev-1: rgba(15, 23, 42, 0.82);
  --surface-elev-2: rgba(15, 23, 42, 0.94);
  --surface-stroke: rgba(148, 163, 184, 0.18);
  --surface-stroke-strong: rgba(148, 163, 184, 0.28);
}

html {
  height: 100%;
  margin: 0;
  padding: 0;
  overflow-x: hidden;
  color-scheme: light;
  font-size: var(--fs-body);
  background: var(--bg);
  color: var(--text);
  font-family: var(--font);
}

body {
  height: 100%;
  margin: 0;
  padding: 0;
  overflow-x: hidden;
  position: relative;
  z-index: 0;
  font-size: var(--fs-body);
  background: var(--bg);
  color: var(--text);
  font-family: var(--font);
}

body::before {
  content: "";
  position: fixed;
  inset: 0;
  background-size: cover;
  background-position: center;
  background-repeat: no-repeat;
  pointer-events: none;
  z-index: -1;
  background-image: radial-gradient(circle at 18% 12%, rgba(255, 255, 255, 0.92), rgba(255, 255, 255, 0) 26%), radial-gradient(circle at 84% 16%, rgba(56, 189, 248, 0.12), rgba(56, 189, 248, 0) 24%), radial-gradient(circle at 50% 100%, rgba(37, 99, 235, 0.08), rgba(37, 99, 235, 0) 34%), url("../assets/images/site-bg.webp");
  opacity: 0.28;
}

* {
  box-sizing: border-box;
}

::-webkit-scrollbar {
  width: 8px;
  height: 8px;
}

::-webkit-scrollbar-track {
  border-radius: 4px;
  background: rgba(148, 163, 184, 0.10);
}

::-webkit-scrollbar-thumb {
  background: linear-gradient(180deg, var(--btn-start), var(--btn-end));
  border: 0;
  border-radius: 999px;
}

::-webkit-scrollbar-thumb:hover {
  background: linear-gradient(180deg, #1d4ed8, #0284c7);
}

html.dark {
  color-scheme: dark;
}

::selection {
  background: rgba(37, 99, 235, 0.18);
  color: var(--text-strong);
}

img[src*="assets/icons/"]:not([src*="assets/icons/users/"]) {
  background: transparent;
  border-radius: 0;
  box-shadow: none;
}

/* ========================================================================== SHARED TYPOGRAPHY ========================================================================== */
h1,
.z-page-title,
.z-dash-title {
  font-size: var(--fs-title);
  font-weight: 800;
  line-height: 1.15;
}

h2,
h3,
.z-card h2,
.z-card h3,
.z-mode-text h2,
.z-lobby-h2 {
  font-size: var(--fs-body);
  font-weight: 800;
  line-height: 1.3;
}

small,
.z-auth-foot a {
  font-size: var(--fs-footer);
}

body,
button,
input,
select,
textarea,
td,
th,
label,
a,
p,
li,
span {
  font-family: var(--font);
}

button,
input,
select,
textarea,
td,
th,
label,
a,
p,
li,
span {
  font-size: var(--fs-body);
}

.log,
.log *,
footer,
.z-auth-foot,
.z-auth-foot a {
  font-size: var(--fs-footer);
}

/* ========================================================================== SHARED SURFACES & PANELS ========================================================================== */
.board-wrap,
.side,
.stats,
.ai-level-box,
.online-box,
.log,
.modal,
.z-card,
.z-dash-msg,
.z-dash-profile-card,
.z-dash-summary,
.z-dash-details,
.z-dash-actions-panel,
.z-mode-card,
.z-lobby-panel,
.z-auth-card,
.z-auth-seo-card,
.z-acc-menu {
  background: rgba(255, 255, 255, .92);
  box-shadow: var(--shadow);
  backdrop-filter: blur(18px);
}

/* ========================================================================== SHARED SOFT CONTROLS ========================================================================== */
.z-lang-select,
.z-nav-toggle {
  border: 1px solid var(--border);
  border-color: var(--border);
  background: rgba(255, 255, 255, 0.66);
  box-shadow: var(--shadow-sm);
}

html.dark .z-lang-select,
html.dark .z-nav-toggle {
  background: rgba(19, 29, 50, 0.88);
}

/* ========================================================================== GAME SHELL LAYOUT ========================================================================== */
:root.dark canvas#board {
  background: linear-gradient(180deg, #081121 0%, #111c33 100%);
  color: var(--text);
}

body.z-game-page .z-footer-wrap,
body.z-game-page footer,
.mode-pvp .ai-level-box,
.z-hidden,
.option-item.z-hidden,
.option-item[hidden],
.z-spectator .btn-grid,
.z-spectator #btnEndOnline,
.z-spectator #pvpVoiceBar,
.z-spectator .soufla-row {
  display: none !important;
}

.app {
  display: grid;
  grid-template-columns: 1fr 360px;
  gap: var(--gap);
  padding: var(--gap);
  height: 100dvh;
  max-width: 1400px;
  margin: 0 auto;
  direction: ltr;
}

.board-wrap {
  position: relative;
  min-height: 400px;
  direction: ltr;
  overflow: hidden;
  background: var(--panel);
  border: 1px solid var(--border);
  box-shadow: var(--shadow);
  backdrop-filter: blur(18px);
  border-radius: var(--radius);
}

canvas#board {
  width: 100%;
  height: 100%;
  display: block;
  color: var(--text);
  position: relative;
  z-index: 2;
  background: linear-gradient(180deg, #fbfdff 0%, #eef5ff 100%);
  border: 1px solid var(--board-diag);
}

#board3d {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  z-index: 1;
}

#board3d canvas {
  width: 100% !important;
  height: 100% !important;
  display: block;
}

.side {
  display: flex;
  flex-direction: column;
  gap: var(--gap);
  overflow-y: auto;
  height: 100%;
  min-width: 0;
  direction: ltr;
  min-height: 0;
  background: var(--panel);
  border: 1px solid var(--border);
  box-shadow: var(--shadow);
  backdrop-filter: blur(18px);
  border-radius: var(--radius);
  padding: 14px;
}

.lang-ar .app,
.lang-ar .board-wrap,
.lang-ar .side {
  direction: ltr;
}

/* ========================================================================== GAME HEADER & STATUS ========================================================================== */
:root.dark .status-row {
  background: linear-gradient(180deg, rgba(19, 29, 50, 0.94), rgba(17, 24, 39, 0.88));
}

.status-row {
  display: flex;
  justify-content: center;
  align-items: center;
  direction: ltr;
  gap: 6px;
  min-height: 48px;
  padding: 7px 12px;
  background: linear-gradient(180deg, rgba(255, 255, 255, 0.72), rgba(255, 255, 255, 0.42));
  border: 1px solid var(--border);
  border-radius: var(--radius);
}

.status {
  display: flex;
  align-items: center;
  gap: 8px;
  flex: 1;
  min-width: 0;
  font-size: var(--fs-body);
  color: var(--text-strong);
  font-weight: 700;
}

.status .turn-pawn {
  width: 18px;
  height: 18px;
  flex: 0 0 auto;
}

#statusTextMsg {
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  flex: 1;
  min-width: 0;
  max-width: 100%;
}

.lang-select label {
  color: var(--muted);
  white-space: nowrap;
  font-size: var(--fs-body);
}

.lang-select select {
  padding: 6px 10px;
  min-width: 110px;
  max-width: 150px;
  font-size: var(--fs-body);
}

.lang-ar .status {
  font-family: var(--font-arabic);
  text-align: right;
  direction: rtl;
}

.lang-ar .btn,
.lang-ar .log .message,
.lang-ar .modal-title {
  font-family: var(--font-arabic);
}

.lang-ar .lang-select {
  flex-direction: row-reverse;
  margin-left: 0;
  margin-right: auto;
}

.lang-ar .lang-select label {
  text-align: right;
}

.row {
  display: flex;
  gap: 8px;
  align-items: center;
  flex-wrap: wrap;
}

.muted {
  color: var(--muted);
}

.mono {
  font-family: var(--font);
}

/* ========================================================================== STATS, PRESENCE & INFO PANELS ========================================================================== */
:root.dark .stats-mobile-table th,
:root.dark .stats tbody td,
:root.dark .ai-level-prefix {
  color: #fff;
}

:root.dark .stats th {
  background: linear-gradient(135deg, #3b82f6, #06b6d4);
  color: #eff6ff;
}

body[dir="rtl"] .stats-mobile-table,
.lang-ar .stats table {
  direction: rtl;
}

:root:not(.dark) .z-presence-online {
  color: #0b6d0b !important;
  font-weight: 700;
}

:root:not(.dark) .z-presence-offline {
  color: #b10000 !important;
  font-weight: 700;
}

:root.dark .z-presence-online {
  color: #4ade80 !important;
  font-weight: 700;
}

:root.dark .z-presence-offline {
  color: #f87171 !important;
  font-weight: 700;
}

:root.dark .stats tr:nth-child(even) td {
  background: rgba(148, 163, 184, 0.06);
}

:root.dark .presence-chip {
  background: rgba(19, 29, 50, 0.92);
}

.stats {
  display: block !important;
  overflow: hidden;
  background: var(--panel);
  border: 1px solid var(--border);
  box-shadow: var(--shadow);
  backdrop-filter: blur(18px);
  border-radius: var(--radius);
}

.stats-desktop,
.mode-pvp .controls-pvp {
  display: block;
}
body.z-game-page:not(.z-mobile-on) .side .stats {
  flex-shrink: 0;
}
.stats-mobile,
.modal.z-chat-modal .modal-footer,
.controls-pool,
.controls-pvp,
.mode-pvp .controls-pvc {
  display: none;
}

.stats table {
  width: 100%;
  border-collapse: collapse;
  font-size: var(--fs-body);
}

.stats th {
  text-align: center;
  background: linear-gradient(135deg, var(--btn-start), var(--btn-end));
  color: #f8fbff;
  padding: 11px 8px;
  font-weight: 700;
  font-size: var(--fs-body);
}

.player-head {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  line-height: 1.15;
}

.player-avatar-frame {
  flex: 0 0 auto;
  width: 34px;
  height: 34px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  padding: 3px;
  border: 3px solid transparent;
  border-radius: 999px;
  background: #ffffff;
  box-shadow: var(--shadow-sm);
}

.player-avatar-frame.is-black-piece {
  border-color: #111827;
  background: #ffffff;
}

.player-avatar-frame.is-white-piece {
  border-color: #ffffff;
  background: #ffffff;
  box-shadow: 0 0 0 1px rgba(15, 23, 42, 0.16), var(--shadow-sm);
}

.player-avatar-frame.is-active-turn {
  box-shadow: 0 0 0 3px rgba(220, 38, 38, 0.92), var(--shadow-sm);
}

.player-avatar {
  width: 100%;
  height: 100%;
  display: block;
  object-fit: contain;
}

.piece-ico-frame {
  width: 28px;
  height: 28px;
  padding: 2px;
}

.stats-mobile-table .piece-ico {
  display: inline-block;
  vertical-align: -3px;
  width: 100%;
  height: 100%;
}

.stats-piece-head {
  gap: 0;
}

.stats-piece-frame {
  width: 30px;
  height: 30px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  border-radius: 999px;
  background: transparent;
}

.stats-piece-icon {
  width: 22px;
  height: 22px;
  display: block;
  object-fit: contain;
}

.stats-piece-frame .piece-ico {
  width: 22px;
  height: 22px;
}

.stats-mobile-table th {
  color: #000;
}

.stats td {
  padding: 8px;
  text-align: center;
  font-weight: 500;
  border-bottom: 1px solid var(--grid);
  font-size: var(--fs-body);
}

.stats tr:nth-child(even) td {
  background: rgba(148, 163, 184, 0.08);
}

.stats tr:last-child td,
.log-item:last-child,
.modal-body tr:last-child th,
.modal-body tr:last-child td {
  border-bottom: none;
}

.stats tbody td {
  color: var(--text-strong);
  font-weight: 700;
}

.ai-level-box {
  display: flex;
  align-items: center;
  gap: 12px;
  flex-wrap: nowrap;
  justify-content: space-between;
  width: 100%;
  line-height: 1.35;
  min-width: 0;
  background: var(--panel);
  border: 1px solid var(--border);
  box-shadow: var(--shadow);
  backdrop-filter: blur(18px);
  border-radius: var(--radius);
  font-size: var(--fs-body);
  min-height: 48px;
  padding: 10px 12px;
}

.ai-level-prefix {
  flex: 0 0 auto;
  color: var(--text-strong);
  font-weight: 700;
}

.ai-level-value {
  display: flex;
  flex: 0 1 auto;
  justify-content: flex-end;
  margin-inline: 0;
  color: var(--danger);
  font-weight: 800;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  min-width: 0;
}

body[dir="rtl"] .ai-level-value {
  justify-content: flex-start;
}

.ai-level-select {
  min-width: 118px;
  max-width: 100%;
  border-radius: 12px;
  padding: 6px 10px;
  border: 1px solid var(--border);
  background: var(--panel);
  color: var(--danger);
  font-weight: 800;
}

.ai-level-value .ai-level-select {
  max-width: min(180px, 100%);
}

.online-box {
  display: flex;
  align-items: center;
  justify-content: flex-start;
  gap: 8px;
  flex-wrap: nowrap;
  min-width: 0;
  overflow: hidden;
  background: var(--panel);
  border: 1px solid var(--border);
  box-shadow: var(--shadow);
  backdrop-filter: blur(18px);
  border-radius: var(--radius);
  min-height: 48px;
  padding: 10px 12px;
}

.presence-chip {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  min-width: 0;
  max-width: calc(50% - 4px);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  font-weight: 600;
  flex: 1 1 0;
  background: rgba(255, 255, 255, 0.72);
  border: 1px solid var(--border);
  padding: 6px 10px;
  border-radius: var(--radius);
  font-size: var(--fs-body);
}
html[dir="rtl"] .presence-chip { direction: rtl; }
html[dir="ltr"] .presence-chip { direction: ltr; }

.presence-name {
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  flex: 1 1 auto;
  order: 1;
}

.presence-status {
  flex: 0 0 auto;
  font-weight: 700;
  order: 2;
  color: var(--danger);
}

.presence-status.z-presence-online,
.presence-status.z-presence-offline {
  color: var(--danger);
}

.badge {
  display: inline-block;
  font-weight: 700;
  margin-left: 0;
  min-width: 10px;
  text-align: center;
  align-items: center;
  border-radius: 999px;
  padding: 4px 8px;
  letter-spacing: 0.02em;
  font-size: var(--fs-body);
}

.badge.ok {
  color: var(--ok);
  border: 1px solid rgba(42, 140, 95, 0.4);
  background: rgba(15, 159, 110, 0.12);
  border-color: rgba(15, 159, 110, 0.28);
}

.badge.warn {
  color: var(--warn);
  border: 1px solid rgba(217, 124, 0, 0.4);
  background: rgba(217, 119, 6, 0.12);
  border-color: rgba(217, 119, 6, 0.28);
}

.badge.err {
  color: var(--danger);
  border: 1px solid rgba(158, 0, 0, 0.4);
  background: rgba(220, 38, 38, 0.12);
  border-color: rgba(220, 38, 38, 0.28);
}

.lang-ar .stats th {
  font-family: var(--font-arabic);
  text-align: center;
}

.lang-ar .online-box,
.lang-ar body {
  direction: rtl;
  text-align: right;
}

.lang-ar .ai-level-box,
body[dir="rtl"] #aiLevelBox {
  direction: rtl;
  text-align: right;
  unicode-bidi: plaintext;
}

.lang-ar .stats td {
  text-align: center;
}

/* ========================================================================== FORM CONTROLS & BUTTONS ========================================================================== */
body.z-game-page .btn-grid .btn {
  padding-top: 6px;
  padding-bottom: 6px;
}

body.z-game-page:not(.z-mobile-on) .app {
  max-width: none;
  margin: 0;
  padding-top: 0 !important;
  padding-bottom: 0 !important;
  padding-left: clamp(8px, 1.2vw, 14px) !important;
  padding-right: clamp(2px, 0.6vw, 8px) !important;
  gap: clamp(6px, 1.1vw, 10px) !important;
  grid-template-columns: 1fr 360px;
}

body.z-game-page:not(.z-mobile-on) .board-wrap {
  margin-top: 0 !important;
  margin-bottom: 0 !important;
  height: 100%;
  min-height: 0;
}

body.z-game-page:not(.z-mobile-on) .side {
  margin-top: 0 !important;
  margin-bottom: 0 !important;
  height: 100%;
}

body.z-game-page:not(.z-mobile-on) .btn-grid {
  gap: clamp(2px, 0.6vw, 4px) !important;
  margin-top: clamp(2px, 0.6vw, 4px) !important;
}

body.z-game-page:not(.mode-pvp):not(.z-mobile-on) .btn-grid {
  grid-template-columns: repeat(6, minmax(0, 1fr));
}

body.z-game-page:not(.mode-pvp):not(.z-mobile-on) .btn-grid .btn,
.online-box .btn {
  width: 100%;
}

body.z-game-page:not(.mode-pvp):not(.z-mobile-on) #btnSettings {
  grid-column: 1 / span 3;
  grid-row: 1;
}

body.z-game-page:not(.mode-pvp):not(.z-mobile-on) #btnUndo {
  grid-column: 4 / span 3;
  grid-row: 1;
}

body.z-game-page:not(.mode-pvp):not(.z-mobile-on) #btnSave {
  grid-column: 1 / span 2;
  grid-row: 2;
}

body.z-game-page:not(.mode-pvp):not(.z-mobile-on) #btnResume {
  grid-column: 3 / span 2;
  grid-row: 2;
}

body.z-game-page:not(.mode-pvp):not(.z-mobile-on) #btnNew {
  grid-column: 5 / span 2;
  grid-row: 2;
}

:root.dark .btn.primary {
  background: linear-gradient(135deg, var(--primary-green), #007a40);
  color: #eff6ff !important;
}

:root.dark .clock {
  background: rgba(15, 23, 42, 0.82);
  color: #fecaca;
  border-bottom: 0;
}

:root.dark #btnEndKill {
  background: linear-gradient(135deg, #5a0000, #464c00) !important;
}

:root.dark .btn.secondary {
  color: var(--text) !important;
  background: linear-gradient(180deg, rgba(30, 41, 59, 0.96), rgba(17, 24, 39, 0.96)) !important;
  border-color: var(--border) !important;
}

:root.dark .btn.ghost {
  color: var(--text) !important;
  border-color: rgba(255, 255, 255, 0.16) !important;
}

:root.dark .btn.ghost:hover {
  background: rgba(255, 255, 255, 0.08);
}

:root.dark .btn,
:root.dark #btnSync,
:root.dark #btnEndOnline {
  color: #eff6ff !important;
}

.btn-grid {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 8px;
  margin-top: 8px;
}

.btn {
  font: inherit;
  cursor: pointer;
  transition: all 0.2s ease;
  text-align: center;
  text-decoration: none;
  background: linear-gradient(135deg, var(--btn-start), var(--btn-end));
  color: var(--btn-text) !important;
  border: 1px solid var(--btn-border) !important;
  border-radius: var(--radius-sm);
  padding: 11px 14px;
  font-weight: 700;
  box-shadow: var(--btn-shadow);
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  font-size: var(--fs-body);
}

.btn.small {
  box-shadow: none;
  padding: 8px 11px;
  border-radius: 12px;
  font-size: var(--fs-body);
}

.btn:hover {
  background: linear-gradient(135deg, #c86b00, #7a4a2a);
  transform: translateY(-2px);
  box-shadow: 0 4px 8px rgba(217, 124, 0, 0.3);
}

.btn:hover:not(:disabled) {
  transform: translateY(-1px);
  filter: brightness(1.03);
  box-shadow: 0 16px 30px rgba(37, 99, 235, 0.24);
}

.btn:active {
  transform: translateY(0);
}

.btn:disabled {
  opacity: 0.55;
  cursor: not-allowed;
  transform: none !important;
  box-shadow: none !important;
}

.btn.primary {
  background: linear-gradient(135deg, var(--btn-start), var(--btn-end)) !important;
}

.btn.guest {
  color: white !important;
  border: 2px solid rgba(214, 40, 40, 0.7) !important;
  display: inline-flex;
  align-items: center;
  gap: 8px;
  background: linear-gradient(135deg, #0f172a, #334155) !important;
  border-color: rgba(51, 65, 85, 0.34) !important;
}

.btn.guest:hover {
  filter: brightness(1.02);
}

.btn.adv-help {
  color: #fff !important;
  border: 2px solid rgba(155, 17, 30, 0.85) !important;
  background: linear-gradient(135deg, #7c3aed, #a855f7) !important;
  border-color: rgba(124, 58, 237, 0.24) !important;
}

.btn.adv-help:hover:not(:disabled) {
  filter: brightness(1.03);
}

.btn .btn-ico {
  flex: 0 0 auto;
  object-fit: contain;
  vertical-align: middle;
  width: 20px;
  height: 20px;
}

.btn.block {
  grid-column: 1 / -1;
  width: 100%;
  margin-top: 4px;
}


.sync-control-wrap {
  display: flex;
  flex-direction: column;
  gap: 4px;
  width: 100%;
  min-width: 0;
  align-self: stretch;
  justify-self: stretch;
}

.sync-control-wrap #btnSync {
  width: 100%;
}

.sync-issue-notice {
  display: none;
  margin: 0;
  padding: 6px 8px;
  border-radius: 10px;
  border: 1px solid rgba(220, 38, 38, 0.22);
  background: rgba(220, 38, 38, 0.08);
  color: #b91c1c;
  font-size: 12px;
  font-weight: 800;
  line-height: 1.35;
  text-align: center;
}

.sync-issue-notice.is-visible {
  display: block;
}

#btnSync {
  color: white;
  margin-top: 4px;
  border: 2px solid var(--btn-border) !important;
  border-radius: 10px;
  background: linear-gradient(135deg, var(--btn-start), var(--btn-end)) !important;
}

#btnSync.z-sync-issue {
  border-color: rgba(127, 29, 29, 0.55) !important;
  background: linear-gradient(135deg, #dc2626, #ef4444) !important;
}

#btnEndOnline {
  color: white;
  margin-top: 4px;
  background: linear-gradient(135deg, #dc2626, #ef4444) !important;
}

.timer-row {
  display: flex !important;
  justify-content: flex-start;
  align-items: center;
  gap: 8px;
  border-radius: var(--radius);
  margin-top: 0;
  padding: 6px 10px;
  background: rgba(220, 38, 38, 0.08);
  border: 1px solid rgba(220, 38, 38, 0.18);
}

.clock {
  flex: 0 0 30%;
  min-width: 0;
  font-weight: 900;
  font-family: var(--font);
  -webkit-text-stroke: 0.02em currentColor;
  paint-order: stroke fill;
  padding: 4px 4px;
  text-align: center;
  margin-left: 0px;
  font-size: var(--fs-body);
  background: rgba(255, 255, 255, 0.56);
  color: var(--danger);
  border-radius: 10px;
  text-shadow: none;
}

#btnEndKill {
  padding: 10px 16px;
  font-weight: 700;
  cursor: pointer;
  transition: all 0.2s ease;
  color: #ffffff !important;
  border-color: rgba(255, 255, 255, 0.18) !important;
  background: linear-gradient(135deg, #dc2626, #f97316) !important;
  border: 1px solid rgba(248, 113, 113, 0.22) !important;
  border-radius: var(--radius-sm);
  box-shadow: 0 12px 24px rgba(220, 38, 38, 0.22);
  font-size: var(--fs-body);
}

.timer-row #btnEndKill {
  flex: 1 1 auto;
  min-width: 0 !important;
  margin: 2px, 20px;
  opacity: 1;
}

#btnEndKill:hover {
  background: linear-gradient(135deg, rgb(93, 8, 2), rgb(102, 120, 2));
  transform: translateY(-2px);
  box-shadow: 0 4px 8px rgba(158, 0, 0, 0.4);
}

#btnEndKill[aria-disabled="true"],
#btnEndKill[aria-disabled="true"]:hover,
#btnEndKill:disabled,
#btnEndKill:disabled:hover {
  opacity: 1;
  cursor: pointer;
}

.btn.ok {
  background: linear-gradient(135deg, #059669, #10b981) !important;
}

.btn.warn {
  background: linear-gradient(135deg, #d97706, #f59e0b) !important;
}

.btn.danger {
  background: linear-gradient(135deg, #dc2626, #ef4444) !important;
}

.btn.secondary {
  background: linear-gradient(180deg, rgba(255, 255, 255, 0.88), rgba(241, 245, 249, 0.96)) !important;
  color: var(--text) !important;
  border-color: var(--border-strong) !important;
  box-shadow: var(--shadow-sm) !important;
}

.btn.ghost {
  background: transparent !important;
  color: var(--text) !important;
  border-color: var(--border) !important;
  box-shadow: none !important;
}

.btn.ok:hover,
.btn.warn:hover,
.btn.danger:hover,
.btn.secondary:hover {
  transform: translateY(-1px);
}

.btn.ghost:hover {
  transform: translateY(-1px);
  background: rgba(140, 92, 58, 0.08);
  box-shadow: none;
}

.btn[data-ico] {
  display: inline-flex;
  align-items: center;
  justify-content: center;
}

.btn[data-ico]::before {
  content: attr(data-ico);
  display: inline-block;
  margin-inline-end: 8px;
  line-height: 1;
}

.btn.ghost:hover:not(:disabled) {
  background: rgba(37, 99, 235, 0.06) !important;
}

/* ========================================================================== ACTIVITY LOG ========================================================================== */
:root.dark .log .time {
  color: #7dd3fc;
}

:root.dark .log .msg .color-word {
  color: var(--text);
}

:root.dark .log {
  background: linear-gradient(180deg, rgba(15, 23, 42, 0.96), rgba(17, 24, 39, 0.94));
}

.log {
  padding: 8px;
  height: 240px;
  min-height: 240px;
  overflow-y: auto;
  margin-top: 0;
  display: flex;
  flex-direction: column;
  overscroll-behavior-y: contain;
  overscroll-behavior-x: auto;
  -webkit-overflow-scrolling: touch;
  touch-action: pan-y;
  overflow-anchor: none;
  background: var(--panel);
  border: 1px solid var(--border);
  box-shadow: var(--shadow);
  backdrop-filter: blur(18px);
  border-radius: var(--radius);
}

.log-item {
  padding: 6px 8px;
  line-height: 1.4;
  display: flex;
  align-items: flex-start;
  border-bottom: 1px solid var(--grid);
  font-size: var(--fs-footer);
}

.log .time {
  margin-right: 8px;
  min-width: 45px;
  font-family: var(--font);
  color: var(--accent);
  font-weight: 700;
  font-size: var(--fs-footer);
}

.log .msg {
  flex: 1;
  font-size: var(--fs-footer);
  unicode-bidi: plaintext;
}

.log .msg .color-word {
  font-weight: 800;
  color: var(--diag);
}

.log .msg .actor-word {
  font-weight: 900;
  color: var(--text-strong);
}

:root.dark .log .msg .actor-word {
  color: #f8fbff;
}

.lang-ar .log-item,
.lang-ar .modal-body {
  text-align: right;
  direction: rtl;
}

.lang-ar .log .time {
  margin-right: 0;
  margin-left: 8px;
}

/* ========================================================================== MODAL DIALOGS & SETTINGS ========================================================================== */
:root.dark .modal {
  border: 3px solid var(--primary-gold);
}

:root.dark .modal-header {
  background: linear-gradient(90deg, var(--primary-green), var(--primary-gold));
}

:root.dark .apply-settings-note,
:root.dark .apply-settings-table-wrap {
  border: 1px solid rgba(255, 255, 255, 0.14);
}

:root.dark .apply-settings-table td {
  border-top: 1px solid rgba(255, 255, 255, 0.12);
}

:root.dark .modal-body th {
  color: var(--primary-gold);
}

:root.dark .settings-feedback {
  border-color: rgba(255, 255, 255, 0.15);
  background: rgba(255, 255, 255, 0.06);
}

:root.dark .z-apply-settings .modal-body {
  background: linear-gradient(180deg, rgba(59, 130, 246, 0.08), rgba(6, 182, 212, 0.04));
}

.apply-settings-wrap {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 12px;
  width: 100%;
}

.apply-settings-notes {
  width: 100%;
  max-width: 640px;
  display: flex;
  flex-direction: column;
  gap: 8px;
  align-items: center;
}

.apply-settings-note {
  width: 100%;
  padding: 10px 12px;
  border: 1px solid rgba(0, 0, 0, 0.12);
  background: transparent;
  font-weight: 800;
  line-height: 1.5;
  white-space: pre-wrap;
  text-align: center;
  border-radius: var(--radius);
}

.apply-settings-table-wrap {
  width: 100%;
  max-width: 640px;
  border: 1px solid rgba(0, 0, 0, 0.12);
  background: transparent;
  overflow: hidden;
  border-radius: var(--radius);
}

.apply-settings-changes-title {
  font-weight: 900;
  padding: 10px 12px;
  text-align: center;
}

.apply-settings-table {
  width: 100%;
  border-collapse: collapse;
  text-align: start;
}

.apply-settings-table td {
  padding: 9px 12px;
  border-top: 1px solid rgba(0, 0, 0, 0.10);
  vertical-align: top;
  font-weight: 800;
}

.apply-settings-table td.k {
  opacity: 0.9;
  width: 44%;
}

.apply-settings-table td.v,
.modal-footer .row,
.modal-footer #modalFooterButtons {
  width: 100%;
  justify-content: center !important;
}

.modal-backdrop {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  display: none;
  align-items: center;
  justify-content: center;
  padding: 16px;
  z-index: var(--z-modal-backdrop);
  background: rgba(2, 6, 23, 0.56);
  backdrop-filter: blur(10px);
}

.modal {
  display: flex;
  flex-direction: column;
  width: auto !important;
  max-width: 92vw !important;
  min-width: 280px;
  max-height: 85vh;
  overflow: hidden;
  position: relative;
  z-index: var(--z-modal);
  background: var(--panel);
  border: 1px solid var(--border);
  box-shadow: var(--shadow);
  backdrop-filter: blur(18px);
  border-radius: var(--radius);
}

.modal-header {
  flex: 0 0 auto;
  padding: 12px 16px;
  display: flex;
  justify-content: center !important;
  align-items: center;
  position: relative;
  background: linear-gradient(135deg, var(--btn-start), var(--btn-end));
  color: #f8fbff;
}

.modal-title {
  margin: 0;
  width: 100%;
  text-align: center !important;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  padding: 0 40px;
  font-size: var(--fs-title);
  font-weight: 800;
}

.modal-close {
  border: none;
  color: white;
  font-size: var(--fs-body);
  cursor: pointer;
  padding: 0;
  width: 28px;
  height: 28px;
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: 50%;
  transition: all 0.2s ease;
  position: absolute;
  right: 12px;
  top: 12px;
  background: rgba(255, 255, 255, 0.16);
}

.modal-close:hover {
  transform: rotate(90deg);
  background: rgba(255, 255, 255, 0.26);
}

#modalBackdrop[dir="rtl"] .modal-close {
  right: auto;
  left: 12px;
}

.modal-body {
  padding: 20px;
  overflow-y: auto;
  overflow-x: hidden;
  flex: 1 1 auto;
  min-height: 0;
  max-height: none;
  line-height: 1.6;
  font-size: var(--fs-body);
}

.modal.z-apply-settings {
  width: min(720px, 92vw) !important;
}

.z-apply-settings .modal-body {
  text-align: center;
  direction: inherit;
  background: linear-gradient(180deg, rgba(37, 99, 235, 0.05), rgba(14, 165, 233, 0.02));
}

.modal-footer {
  flex: 0 0 auto;
  padding: 12px 16px 16px;
  border-top: 1px solid var(--border);
  background: var(--panel);
}

.modal-body table {
  width: 100%;
  border-collapse: collapse;
}

.modal-body th {
  padding: 10px 8px;
  border-bottom: 1px solid var(--grid);
  text-align: start;
  vertical-align: top;
  font-weight: 800;
  width: 40%;
  color: var(--accent);
}

.modal-body td {
  padding: 10px 8px;
  border-bottom: 1px solid var(--grid);
  text-align: start;
  vertical-align: top;
}

.option-list {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.option-item {
  display: grid !important;
  grid-template-columns: 1fr 1fr;
  align-items: center;
  gap: 12px;
}

.option-item>div:first-child {
  text-align: start;
}

.option-item>div:last-child {
  text-align: end;
  justify-self: stretch;
}

.option-item select,
.option-item input[type="text"],
.option-item input[type="number"] {
  width: 100%;
  max-width: 100%;
}

.settings-feedback {
  margin: 8px 0 10px;
  padding: 10px 12px;
  line-height: 1.35;
  border: 1px solid rgba(0, 0, 0, 0.15);
  background: rgba(0, 0, 0, 0.04);
  border-color: rgba(148, 163, 184, 0.24);
  border-radius: var(--radius);
  font-size: var(--fs-body);
}

.settings-feedback.ok {
  border-color: rgba(15, 159, 110, 0.32);
  background: rgba(15, 159, 110, 0.08);
}

.settings-feedback.warn {
  border-color: rgba(217, 119, 6, 0.32);
  background: rgba(217, 119, 6, 0.08);
}

.modal.z-chat-modal {
  width: min(1080px, 98vw) !important;
  max-width: 98vw !important;
  height: min(94vh, 920px);
  max-height: 94vh;
}

.modal.z-chat-modal .modal-body {
  padding: 0;
  overflow: hidden;
  display: flex;
  flex-direction: column;
  min-height: 0;
}

/* ========================================================================== DIRECTION & LOCALIZATION ========================================================================== */

body[dir="rtl"] #aiLevelPrefix {
  unicode-bidi: isolate;
  direction: rtl;
}

body[dir="rtl"] #aiLevelValue {
  unicode-bidi: isolate;
  direction: auto;
}

/* ========================================================================== GAME STATE & ROLE VISIBILITY ========================================================================== */
.ui-hold body.z-game-page .timer-row,
.ui-hold body.z-game-page .soufla-row,
.ui-hold body.z-game-page #controlsWrap,
.ui-hold body.z-game-page #specBar,
.role-pending body.z-game-page.mode-pvp .timer-row,
.role-pending body.z-game-page.mode-pvp .soufla-row,
.role-pending body.z-game-page.mode-pvp #controlsWrap,
.role-pending body.z-game-page.mode-pvp #specBar,
.role-pending body.z-game-page.mode-pvp #onlinePresence {
  visibility: hidden;
  pointer-events: none;
}

.ui-hold body.z-game-page.mode-pvp .board-wrap,
.ui-hold body.z-game-page.mode-pvp #board3d,
.role-pending body.z-game-page.mode-pvp .board-wrap,
.role-pending body.z-game-page.mode-pvp #board3d,
.ui-hold body.z-game-page.mode-pvp #board,
.role-pending body.z-game-page.mode-pvp #board {
  pointer-events: none;
}

.mode-pvp .online-box {
  display: flex;
}

.z-spectator #specBar {
  display: grid !important;
}

/* ========================================================================== PVP CONTROLS & CHAT ========================================================================== */
:root.dark .pvp-chat-list {
  background: rgba(255, 255, 255, .05);
}

:root.dark .pvp-bubble {
  background: rgba(255, 255, 255, .94);
  border-color: rgba(255, 255, 255, .18);
  box-shadow: 0 2px 12px rgba(0, 0, 0, .35);
}

:root.dark .pvp-msg.me .pvp-bubble {
  background: rgba(220, 252, 231, .94);
  border-color: rgba(42, 170, 119, .30);
}

:root.dark .pvp-chat-form {
  border-top-color: rgba(255, 255, 255, .12);
}

:root.dark .pvp-chat-input {
  border-color: rgba(255, 255, 255, .18);
}

.soufla-row .btn,
.spec-bar .btn {
  width: 100%;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
}

.controls-pvc .btn {
  align-items: center;
  min-height: 46px;
  box-sizing: border-box;
  display: inline-flex !important;
  width: 100%;
  justify-content: center;
  gap: 8px;
}

.controls-pvc .btn .btn-text {
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.controls-pvp .pvp-row .btn {
  display: inline-flex !important;
  flex: 1 1 0;
  justify-content: center;
  gap: 8px;
}


.sr-only {
  position: absolute !important;
  width: 1px !important;
  height: 1px !important;
  padding: 0 !important;
  margin: -1px !important;
  overflow: hidden !important;
  clip: rect(0, 0, 0, 0) !important;
  white-space: nowrap !important;
  border: 0 !important;
}

.soufla-row {
  margin-top: 6px;
}

.controls-wrap {
  margin-top: 10px;
}

.controls-box,
.controls-pvp .pvp-row:first-child {
  margin-top: 0;
}

.controls-pvc {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 8px;
}

.controls-pvc #btnSettings,
.controls-pvc #btnUndo,
.controls-pvc #btnNew,
.controls-pvc #btnSave,
.controls-pvc #btnResume,
.controls-pvc #btnEndLocalMatch {
  grid-column: auto !important;
  grid-row: auto !important;
}

.controls-pvp .pvp-row {
  display: flex;
  gap: 8px;
  margin-top: 8px;
}

.spec-bar {
  margin-top: 6px;
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 8px;
}

#btnSoufla {
  width: 100%;
  background: #b10000 !important;
  border-color: rgba(0, 0, 0, 0.35) !important;
  color: #fff !important;
  font-weight: 900;
}

#btnSoufla:hover:not(:disabled) {
  background: #d10000 !important;
}

#btnChat[data-badge] {
  position: relative;
}

#btnChat[data-badge]::after {
  content: attr(data-badge);
  position: absolute;
  inset-inline-end: -8px;
  inset-block-start: -8px;
  min-width: 26px;
  height: 26px;
  padding: 0 6px;
  border-radius: 999px;
  background: #ef4444;
  color: #fff;
  font-weight: 900;
  line-height: 1;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  box-shadow: 0 6px 16px rgba(0, 0, 0, 0.25);
  font-size: var(--fs-body);
}

.pvp-chat {
  --pvp-chat-name-col: clamp(122px, 26%, 190px);
  flex: 1 1 auto;
  min-height: 0;
  display: flex;
  flex-direction: column;
}

.pvp-chat-list {
  flex: 1 1 auto;
  min-height: 0;
  overflow-y: auto;
  overscroll-behavior-y: contain;
  overscroll-behavior-x: auto;
  -webkit-overflow-scrolling: touch;
  padding: 8px 10px 6px;
  display: flex;
  flex-direction: column;
  gap: 6px;
  background: var(--panel-weak);
  text-align: start;
  direction: inherit;
}

.pvp-msg {
  display: flex;
  flex-direction: column;
  width: 100%;
  max-width: 100%;
  margin: 0;
}

.pvp-bubble {
  border: 1px solid rgba(0, 0, 0, .12);
  border-radius: 14px;
  display: block;
  padding: 1px 10px;
  background: rgba(255, 255, 255, .92);
  box-shadow: 0 2px 8px rgba(0, 0, 0, .06);
  word-break: break-word;
  direction: inherit;
  text-align: start;
  line-height: 1.5;
}

.pvp-chat[dir="rtl"] .pvp-bubble {
  direction: rtl;
  text-align: right;
}

.pvp-from {
  display: inline;
  font-weight: 900;
  opacity: 1;
  margin: 0;
  padding: 0;
  line-height: 1.5;
  font-size: calc(var(--fs-body) * 0.95);
  color: #7f1d1d;
  white-space: normal;
  overflow: visible;
  text-overflow: clip;
  text-align: start;
  unicode-bidi: plaintext;
  margin-inline-end: .35em;
}

.pvp-chat[dir="rtl"] .pvp-from {
  text-align: right;
}

.pvp-text {
  display: inline;
  margin: 0;
  padding: 0;
  line-height: 1.5;
  white-space: pre-wrap;
  text-align: start;
  color: #111827;
  font-weight: 500;
  unicode-bidi: plaintext;
}

.pvp-chat[dir="rtl"] .pvp-text {
  text-align: right;
}

.pvp-msg.me .pvp-bubble {
  background: rgba(220, 252, 231, .92);
  border-color: rgba(42, 170, 119, .22);
}

.pvp-chat-form {
  flex: 0 0 auto;
  display: flex;
  gap: 10px;
  padding: 10px;
  border-top: 1px solid rgba(0, 0, 0, .10);
  background: var(--panel);
}

.pvp-chat-input {
  flex: 1 1 auto;
  width: 100%;
  padding: 12px 12px;
  border-radius: 16px;
  border: 1px solid rgba(0, 0, 0, .18);
  background: var(--bg);
  color: var(--text);
}

.pvp-chat-send {
  flex: 0 0 auto;
  border-radius: 16px;
  padding: 12px 16px;
  white-space: nowrap;
}

.pvp-chat[dir="rtl"] .pvp-chat-form,
.pvp-chat[dir="rtl"] .pvp-chat-input,
.pvp-chat[dir="rtl"] .pvp-chat-list {
  direction: rtl;
}

.pvp-chat[dir="ltr"] .pvp-chat-form,
.pvp-chat[dir="ltr"] .pvp-chat-input,
.pvp-chat[dir="ltr"] .pvp-chat-list {
  direction: ltr;
}

.pvp-chat[dir="rtl"] .pvp-msg,
.pvp-chat[dir="rtl"] .pvp-bubble,
.pvp-chat[dir="rtl"] .pvp-from,
.pvp-chat[dir="rtl"] .pvp-text {
  direction: rtl;
  text-align: right;
}

.pvp-chat[dir="ltr"] .pvp-msg,
.pvp-chat[dir="ltr"] .pvp-bubble,
.pvp-chat[dir="ltr"] .pvp-from,
.pvp-chat[dir="ltr"] .pvp-text {
  direction: ltr;
  text-align: left;
}

/* ========================================================================== FOOTER ========================================================================== */
/* ========================================================================== MISCELLANEOUS GAME STYLES ========================================================================== */
:root.dark select:focus,
:root.dark button:focus,
:root.dark input:focus {
  box-shadow: 0 0 0 3px rgba(195, 144, 0, 0.3);
}

:root.dark ::-webkit-scrollbar-track {
  background: rgba(36, 50, 71, 0.82);
}

:root.dark ::-webkit-scrollbar-thumb {
  background: linear-gradient(180deg, #3b82f6, #06b6d4);
}

:root.dark ::-webkit-scrollbar-thumb:hover {
  background: linear-gradient(135deg, #007a40, var(--primary-gold));
}

:root.dark body {

  background: radial-gradient(circle at top right, rgba(56, 189, 248, 0.14), transparent 32%), radial-gradient(circle at top left, rgba(96, 165, 250, 0.14), transparent 28%), linear-gradient(180deg, rgba(10, 15, 30, 0.82), rgba(2, 8, 23, 0.96)), var(--bg);
}

:root.dark body::before {
  opacity: 0.12;
}

:root.dark select,
:root.dark button,
:root.dark input {
  background: rgba(17, 24, 39, 0.96);
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.04);
}

html.dark img[src*="assets/icons/"]:not([src*="assets/icons/users/"]) {
  background: var(--icon-dark-bg);
  border-radius: 10px;
  box-shadow: 0 6px 16px rgba(2, 6, 23, 0.26);
}

select,
button,
input {
  font: inherit;
  font-size: var(--fs-body);
  color: var(--text);
  background: var(--panel-strong);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 10px 12px;
  transition: border-color .18s ease, background-color .18s ease, box-shadow .18s ease, transform .18s ease;
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.6);
}

select:focus,
button:focus,
input:focus,
select:focus-visible,
button:focus-visible,
input:focus-visible {
  outline: none;
  border-color: var(--accent);
  box-shadow: 0 0 0 4px var(--accent-soft), var(--shadow-sm);
}

select:hover,
button:hover,
input:hover {
  border-color: var(--border-strong);
}

.mode-pvp #pvpVoiceBar {
  display: grid !important;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 8px;
}

textarea {
  font-size: var(--fs-body);
}

.turn-pawn {
  width: 20px;
  height: 20px;
}
.z-mobile-game-presence { color: var(--danger); font-weight: 700; }

body.z-spectator #btnEndKill,
body.z-spectator #btnUndo,
body.z-spectator #btnSoufla,
body.z-spectator #btnSync,
body.z-spectator #btnEndOnline,
body.z-spectator #btnEndLocalMatch,
body.z-spectator #btnNew,
body.z-spectator #btnSave,
body.z-spectator #btnResume,
body.z-spectator #btnSpk,
body.z-spectator #btnMic {
  display: none !important;
}


body.z-spectator .timer-row,
body.z-spectator .soufla-row {
  display: none !important;
}

/* Minimax-level UI refinements */
.settings-general,
.settings-list {
  max-width: 100%;
  min-width: 0;
  overflow-x: hidden;
}

.settings-list {
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.settings-row {
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(0, 220px);
  align-items: center;
  gap: 10px 14px;
  padding: 8px 0;
  border-bottom: 1px solid var(--grid);
}

.settings-row:last-child {
  border-bottom: none;
}

.settings-label {
  min-width: 0;
  color: var(--text-strong);
}

.settings-label b {
  display: block;
  font-weight: 800;
}

.settings-label small {
  display: block;
  margin-top: 3px;
  color: var(--muted);
  line-height: 1.35;
}

.settings-control {
  display: flex;
  justify-content: flex-end;
  min-width: 0;
  max-width: 100%;
}

body[dir="rtl"] .settings-control {
  justify-content: flex-start;
}

.settings-control select,
.settings-control input[type="number"] {
  width: min(100%, 220px);
  max-width: 100%;
}

.range-control {
  display: flex;
  align-items: center;
  gap: 10px;
  width: min(100%, 240px);
  min-width: 0;
}

.range-control input[type="range"] {
  flex: 1 1 auto;
  min-width: 0;
}

.range-control .mono {
  flex: 0 0 54px;
  text-align: end;
  font-weight: 800;
}

.range-control.is-disabled {
  opacity: 0.55;
}

.range-control input[type="range"]:disabled {
  cursor: not-allowed;
}

.settings-control .checkline {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  white-space: nowrap;
}

.settings-change-list {
  margin: 8px 0 0;
  padding-inline-start: 1.4em;
  line-height: 1.7;
}

.settings-change-list small,
.settings-change-note {
  display: block;
  margin-top: 4px;
  color: var(--muted);
  font-weight: 600;
}

.settings-change-arrow {
  display: inline-block;
  margin-inline: 0.35em;
  font-weight: 900;
}

.ai-level-help {
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.ai-level-help-item {
  padding: 10px 12px;
  border: 1px solid var(--border);
  border-radius: 14px;
  background: rgba(15, 23, 42, 0.035);
}

:root.dark .ai-level-help-item {
  background: rgba(255, 255, 255, 0.04);
}

.ai-level-help-item h3 {
  margin: 0 0 6px;
  font-size: var(--fs-title);
  color: var(--text-strong);
}

.ai-level-help-item p {
  margin: 0;
  line-height: 1.65;
}


@media (max-width: 560px) {
  .settings-row {
    grid-template-columns: minmax(0, 1fr) minmax(0, 44%);
    gap: 8px 10px;
  }

  .settings-label small {
    font-size: 0.86em;
  }

  .settings-control select {
    width: 100%;
  }

  .range-control {
    width: 100%;
    gap: 8px;
  }

  .range-control .mono {
    flex-basis: 46px;
  }
}

.modal.z-invite-modal #modalFooterButtons {
  display: grid !important;
  grid-template-columns: minmax(0, 1fr) minmax(0, 1fr);
  gap: 8px;
  align-items: stretch;
}

.modal.z-invite-modal #modalFooterButtons .btn {
  width: 100%;
  justify-content: center;
}

.modal.z-invite-modal #modalFooterButtons .z-invite-reject-all {
  grid-column: 1 / -1;
  background: #8b1a1a;
  color: #fff;
  border-color: #6f1515;
}

.modal.z-invite-modal #modalFooterButtons .z-invite-reject-all:hover {
  background: #741515;
  color: #fff;
}

.modal.z-invite-modal #modalFooterButtons .z-invite-accept,
.modal.z-invite-modal #modalFooterButtons .z-invite-reject {
  background: linear-gradient(180deg, rgba(255, 255, 255, 0.88), rgba(241, 245, 249, 0.96)) !important;
  color: var(--text) !important;
  border-color: var(--border-strong) !important;
  box-shadow: var(--shadow-sm) !important;
}

:root.dark .modal.z-invite-modal #modalFooterButtons .z-invite-accept,
:root.dark .modal.z-invite-modal #modalFooterButtons .z-invite-reject {
  background: linear-gradient(180deg, rgba(30, 41, 59, 0.95), rgba(15, 23, 42, 0.96)) !important;
  color: var(--text) !important;
  border-color: var(--border-strong) !important;
}
