/* Section: css/style.css — Global site styling */

:root {
  --primary-green: #006233;
  --primary-gold: #7e5d01;
  --primary-red: #760202;
  --sand-beige: #f9f5ee;
  --desert-orange: #d97c00;
  --desert-brown: #8c5c3a;
  --sky-blue: #4a8bc2;
  --dark-blue: #1a3a5f;
  --light-sand: #f7f0e0;

  --bg: #f9f0eb;
  --panel: #ffffff;
  --panel-weak: #f5eee0;
  --text: #3d2c1a;
  --muted: #8c7a65;

  --accent: var(--desert-orange);
  --danger: var(--primary-red);
  --warn: var(--desert-orange);
  --ok: #2a8c5f;

  --grid: #5f6403;
  --diag: #652a02;
  --border: #c97e05;

  --arrow-green: #2a8c5f;
  --arrow-yellow: var(--desert-orange);
  --arrow-red: var(--primary-red);

  --shadow: 0 6px 20px rgba(140, 92, 58, 0.12);
  --radius: 10px;
  --gap: 10px;

  --font: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;
  --font-arabic: 'Arial', sans-serif;

  --btn-start: var(--desert-orange);
  --btn-end: #e68900;
  --btn-text: #ffffff;
  --btn-border: rgba(255, 255, 255, 0.18);
  --btn-shadow: 0 6px 16px rgba(0, 0, 0, 0.16);
}

:root.dark {
  --bg: #061a12;
  --panel: #0b2a1d;
  --panel-weak: #103525;
  --text: #e8f1ec;
  --muted: #a8b8b0;

  --accent: var(--primary-gold);
  --danger: #ff4d4d;
  --warn: var(--primary-gold);
  --ok: #00a86b;

  --grid: #fafcf2;
  --diag: #ddded0;
  --border: #5e1500;

  --arrow-green: #00c27a;
  --arrow-yellow: var(--primary-gold);
  --arrow-red: #ff4d4d;

  --shadow: 0 6px 20px rgba(0, 0, 0, 0.45);

  --btn-start: #b38a00;
  --btn-end: #8a6a00;
  --btn-text: #1a1a1a;
  --btn-border: rgba(0, 0, 0, 0.25);
  --btn-shadow: 0 6px 18px rgba(0, 0, 0, 0.35);
}

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



body {
  position: relative;
  z-index: 0;
}

body::before {
  content: "";
  position: fixed;
  inset: 0;
  background-image: url("../assets/images/site-bg.webp");
  background-size: cover;
  background-position: center;
  background-repeat: no-repeat;
  opacity: 0.12;
  pointer-events: none;
  z-index: -1;
}

* {
  box-sizing: border-box;
}

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

.mobile-header {
  display: none;
  background: var(--panel);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  border: 2px solid var(--border);
  padding: 10px;
  gap: 8px;
  flex-direction: column;
  direction: ltr;
}

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

canvas#board {
  width: 100%;
  height: 100%;
  display: block;
  background: linear-gradient(135deg, var(--light-sand) 0%, var(--sand-beige) 100%);
  color: var(--text);
  border: 3px solid var(--desert-brown);
}

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

canvas#board {
  position: relative; 
  z-index: 2;
}

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


:root.dark canvas#board {
  background: linear-gradient(135deg, #061a12 0%, #0d3b2a 100%);
  color: #f9f5ee;
}

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

.game-title {
  font-size: 22px;
  font-weight: 800;
  text-align: center;
  margin: 0;
  padding: 8px 0;
  color: var(--btn-text);
  text-shadow: 0 1px 2px rgba(0, 0, 0, 0.1);
  border-bottom: 3px solid var(--desert-orange);
    background: linear-gradient(90deg, var(--desert-brown), var(--desert-orange), var(--desert-brown));
}

:root.dark .game-title {
  color: white;
  border-bottom: 3px solid var(--primary-green);
}

.status-row {
  display: flex;
  justify-content: center;
  align-items: center;
  direction: ltr;
  gap: 6px;
  padding: 5px 10px;
  background: var(--panel-weak);
  border-radius: var(--radius);
  border: 1px solid var(--border);
  min-height: 44px;
}

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

.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;
}


.lang-select {
  display: inline-flex;
  gap: 6px;
  align-items: center;
  margin-left: auto;
  flex: 0 0 auto;
}

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

.lang-select select {
  padding: 6px 10px;
  font-size: 13px;
  min-width: 110px;
  max-width: 150px;
}

select,
button,
input {
  font: inherit;
  color: var(--text);
  background: var(--panel-weak);
  border: 2px solid var(--border);
  border-radius: 8px;
  padding: 8px 12px;
  transition: all 0.2s ease;
}

select:focus,
button:focus,
input:focus {
  outline: none;
  border-color: var(--accent);
  box-shadow: 0 0 0 3px rgba(217, 124, 0, 0.2);
}

:root.dark select:focus,
:root.dark button:focus,
:root.dark input:focus {
  box-shadow: 0 0 0 3px rgba(195, 144, 0, 0.3);
}

.stats {
  background: var(--panel);
  border-radius: var(--radius);
  border: 2px solid var(--border);
  overflow: visible;
  box-shadow: 0 3px 10px rgba(0, 0, 0, 0.08);
  display: block !important;
}

.stats-desktop { display: block; }
.stats-mobile { display: none; }

.stats table {
  width: 100%;
  border-collapse: collapse;
  font-size: 13px;
}

.stats th {
  background: linear-gradient(90deg, var(--desert-brown), var(--desert-orange));
  color: white;
  padding: 10px 8px;
  font-weight: 600;
  text-align: center;
  font-size: 14px;
}

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

.player-ico{
  width: 18px;
  height: 18px;
  flex: 0 0 auto;
}

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

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

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

.stats tr:nth-child(even) td {
  background: var(--panel-weak);
}

.stats tr:last-child td {
  border-bottom: none;
}

.ai-state {
  display: flex;
  align-items: center;
  gap: 3px;
  flex-wrap: nowrap;
  font-size: 12.5px;
  padding: 2px 5px;
  min-width: 0;
  background: var(--panel-weak);
  border-radius: var(--radius);
  border: 1px solid var(--border);
  min-height: 44px;
}

.ai-chip {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 4px 10px;
  font-size: 12.5px;
  min-width: 0;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  background: var(--panel);
  border-radius: 20px;
  border: 1px solid var(--border);
  font-weight: 500;
}

.badge {
  display: inline-block;
  padding: 3px 7px;
  border-radius: 15px;
  font-size: 10.5px;
  font-weight: 700;
  margin-left: 0;
  min-width: 10px;
  text-align: center;
  align-items: center;
}

.badge.ok {
  background: rgba(42, 140, 95, 0.15);
  color: var(--ok);
  border: 1px solid rgba(42, 140, 95, 0.4);
 
}

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

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

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


@media (min-width: 769px) {
  body.z-game-page:not(.mode-pvp) .btn-grid {
    grid-template-columns: repeat(6, minmax(0, 1fr));
  }
  body.z-game-page:not(.mode-pvp) .btn-grid .btn{
    width: 100%;
  }
  body.z-game-page:not(.mode-pvp) #btnSettings { grid-column: 1 / span 3; grid-row: 1; }
  body.z-game-page:not(.mode-pvp) #btnUndo     { grid-column: 4 / span 3; grid-row: 1; }
  body.z-game-page:not(.mode-pvp) #btnSave     { grid-column: 1 / span 2; grid-row: 2; }
  body.z-game-page:not(.mode-pvp) #btnResume   { grid-column: 3 / span 2; grid-row: 2; }
  body.z-game-page:not(.mode-pvp) #btnNew      { grid-column: 5 / span 2; grid-row: 2; }
}

.btn {
  background: linear-gradient(90deg, var(--desert-brown), var(--desert-orange));
  color: var(--btn-text) !important;
  border: 2px solid var(--btn-border) !important;
  border-radius: 8px;
  font: inherit;
  padding: 10px 12px;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.2s ease;
  text-align: center;
  text-decoration: none;
  display: inline-block;
  font-size: 14px;
  box-shadow: var(--btn-shadow);
}


.btn.small{
  padding: 7px 10px;
  font-size: 13px;
  border-radius: 10px;
  box-shadow: none;
}


.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) {
  filter: brightness(1.03);
  transform: translateY(-1px);
}

.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(90deg, var(--desert-brown), var(--desert-orange)) !important;
}


.btn.guest{
  background: linear-gradient(135deg, #d62828, #9b111e);
  color: white !important;
  border: 2px solid rgba(214, 40, 40, 0.7) !important;
  display: inline-flex;
  align-items: center;
  gap: 8px;
}
.btn.guest:hover{
  filter: brightness(1.02);
}

.btn.adv-help{
  background: #9b111e !important;
  color: #fff !important;
  border: 2px solid rgba(155,17,30,0.85) !important;
}
.btn.adv-help:hover:not(:disabled){
  filter: brightness(1.03);
}

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


body.z-game-page .z-footer-wrap{
  display: none !important;
}


body.z-game-page footer{
  display: none !important;
}


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

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

#btnExportHuman {
  background: linear-gradient(90deg, var(--desert-brown), var(--desert-orange));
  margin-top: 8px;
  width: 100%;
}

#btnOnline,
#btnPlayOnline {
  background: linear-gradient(135deg, var(--sky-blue), #3a7bb2);
  color: white;
}

#btnSync {
  background: linear-gradient(135deg, var(--primary-green), #00a86b);
  color: white;
  margin-top: 4px;
}

#btnEndOnline,
#btnEndGame {
  background: linear-gradient(135deg, var(--primary-red), #c00);
  color: white;
  margin-top: 4px;
}

#btnPickOnline,
#btnSync,
#btnExportHuman {
  border: 2px solid var(--btn-border) !important;
  border-radius: 10px;
}

.timer-row {
  display: flex !important;
  justify-content: flex-start;
  align-items: center;
  gap: 8px;
  padding: 2px 10px;
  background: linear-gradient(90deg, rgba(158, 0, 0, 0.1), transparent);
  border-radius: var(--radius);
  border: 2px solid var(--primary-red);
  margin-top: 0;
}

.clock {
  flex: 0 0 30%;
  min-width: 0;
  font-size: 18px;
  font-weight: 700;
  font-family: monospace;
  color: var(--primary-red);
  text-shadow: 0 1px 2px rgba(0, 0, 0, 0.2);
  padding: 4px 4px;
  background: rgba(255, 255, 255, 0.1);
  border-radius: 6px;
  text-align: center;
  margin-left: 0px;
}
:root.dark .clock {
  color: white;
  border-bottom: 3px solid var(--primary-green);
}

#btnEndKill {
  background: var(--primary-red) !important;
  border: none;
  padding: 10px 16px;
  font-weight: 700;
  cursor: pointer;
  border-radius: 8px;
  transition: all 0.2s ease;
  font-size: 14px;
  box-shadow: 0 2px 4px rgba(158, 0, 0, 0.3);
  color: #ffffff !important;
  border-color: rgba(255, 255, 255, 0.18) !important;
}

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

.timer-row #btnEndKill {
  flex: 1 1 auto;
  min-width: 0 !important;
  min-width: 160px;
  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);
}

.online-box {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.online-box .btn {
  width: 100%;
}

.log {
  background: var(--panel);
  border-radius: var(--radius);
  border: 2px solid var(--border);
  padding: 8px;
  height: 240px;
  min-height: 240px;
  overflow-y: auto;
  margin-top: 0;
  display: flex;
  flex-direction: column;
}

.log-content {
  flex: 1;
  overflow-y: auto;
  min-height: 0;
}

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

.log-item:last-child {
  border-bottom: none;
}

.log .time {
  color: var(--desert-orange);
  font-weight: 600;
  margin-right: 8px;
  min-width: 45px;
  font-family: monospace;
}

:root.dark .log .time {
  color: var(--primary-gold);
}

.log .msg {
  flex: 1;
}

.modal-backdrop {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  background: rgba(0, 0, 0, 0.7);
  display: none;
  align-items: center;
  justify-content: center;
  padding: 16px;
  z-index: 10000;
  backdrop-filter: blur(5px);
}

.modal {
  background: var(--panel);
  border-radius: var(--radius);
  display: flex;
  flex-direction: column;
  box-shadow: 0 10px 40px rgba(0, 0, 0, 0.3);
  width: auto !important;
  max-width: 92vw !important;
  min-width: 280px;
  max-height: 85vh;
  overflow: hidden;
  border: 3px solid var(--desert-orange);
}

:root.dark .modal {
  border: 3px solid var(--primary-gold);
}

.modal-header {
  flex: 0 0 auto;
  background: linear-gradient(90deg, var(--desert-brown), var(--desert-orange));
  color: white;
  padding: 12px 16px;
  display: flex;
  justify-content: center !important;
  align-items: center;
  position: relative;
}

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

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

.modal-close {
  background: rgba(255, 255, 255, 0.2);
  border: none;
  color: white;
  font-size: 20px;
  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;
}

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

.modal-body {
  padding: 20px;
  overflow-y: auto;
  flex: 1 1 auto;
  min-height: 0;
  max-height: none;
  font-size: 14px;
  line-height: 1.6;
}

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

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

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

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

.modal-body th {
  font-weight: 800;
  color: var(--desert-brown);
  width: 40%;
}

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

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

.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%;
}

.lang-ar .game-title,
.lang-ar .status,
.lang-ar .btn,
.lang-ar .modal-title,
.lang-ar .stats th,
.lang-ar .ai-chip,
.lang-ar .log .message {
  font-family: var(--font-arabic);
}

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

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

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


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

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

.lang-ar .stats table {
  direction: rtl;
}

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

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

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

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

.mono {
  font-family: 'Courier New', monospace;
}

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

::-webkit-scrollbar-track {
  background: var(--panel-weak);
  border-radius: 4px;
}

::-webkit-scrollbar-thumb {
  background: linear-gradient(135deg, var(--desert-orange), var(--desert-brown));
  border-radius: 4px;
  border: 1px solid var(--border);
}

::-webkit-scrollbar-thumb:hover {
  background: linear-gradient(135deg, #c86b00, #7a4a2a);
}

:root.dark ::-webkit-scrollbar-track {
  background: var(--panel);
}

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

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



.mode-pvp #btnResume { display: none !important; }
.mode-pvp #btnChat { display: inline-flex !important; }


.mode-pvp #btnNew,
.mode-pvp #btnSave {
  display: none !important;
}



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

.z-spectator #specBar { display: flex !important; }
.z-spectator #pvpVoiceBar,
.z-spectator #pvpCompactRow,
.z-spectator .btn-grid,
.z-spectator .soufla-row,
.z-spectator #btnEndOnline,
.z-spectator #btnChat {
  display: none !important;
}

.pvp-voice-bar .btn {
  width: 100%;
  justify-content: center;
}


.pvp-compact-row {
  display: none;
  gap: 8px;
}
.mode-pvp.pvp-compact #pvpCompactRow {
  display: flex !important;
  align-items: center;
  justify-content: space-between;
}
.mode-pvp.pvp-compact #pvpVoiceBar {
  display: none !important;
}
.mode-pvp.pvp-compact .btn-grid {
  display: none !important;
}

@media (max-width: 768px) {
  .mode-pvp.pvp-compact #pvpCompactRow .btn {
    padding: 8px;
    min-width: 44px;
    justify-content: center;
  }
  .mode-pvp.pvp-compact #pvpCompactRow .btn .btn-text {
    display: none;
  }
}


.mode-pvp .ai-state { display: none !important; }



@media (max-width: 768px) {
  .app {
    grid-template-columns: 1fr;
    gap: clamp(6px, 2vw, 10px);
    padding: clamp(6px, 1.6vw, 8px);
    height: auto;
    min-height: 100dvh;
  }

  .mobile-header {
    display: flex;
  }

  .mobile-header .game-title {
    font-size: clamp(16px, 2.4vw, 18px);
    padding: 6px 0;
    margin: 0;
  }

  .mobile-header .status-row {
    padding: 6px 10px;
    margin: 0;
  }

  .board-wrap {
    min-height: 300px;
    height: min(60vh, calc(50vh + 10vw));
    max-height: min(60vh, calc(50vh + 10vw));
  }

  .side {
    display: flex;
    flex-direction: column;
    gap: 8px;
    height: auto;
    overflow: visible;
    padding: 10px;
  }


  .side .z-home-ad-title { order: 0; margin: 0; }
  .side .z-home-ad-in-side,
  .side .z-home-ad-mobile-2 { order: 7; margin: 0; }

  .side .timer-row { order: 1; margin: 0; }
  .side .soufla-row { order: 2; margin: 0; }
  .side .online-box { order: 3; }
  .side .btn-grid { order: 4; margin: 0; }
  .side .stats { order: 5; margin: 0; }
  .side .ai-state { order: 6; margin: 0; }
  .side .log { order: 7; height: clamp(120px, 26vw, 170px);
    min-height: clamp(120px, 26vw, 170px); margin: 0; }
  .side #btnExportHuman { order: 8; margin: 0; width: 100%; }

  .timer-row { padding: 8px 10px; }
  .clock { font-size: clamp(14px, 2.2vw, 16px); }
  #btnEndKill { font-size: clamp(12px, 2vw, 13px);
    padding: clamp(8px, 1.8vw, 10px) clamp(10px, 2.4vw, 12px); }

  .btn-grid {
    grid-template-columns: repeat(5, 1fr) !important;
    gap: clamp(6px, 1.2vw, 8px);
  }

  
  body.z-game-page:not(.mode-pvp) .btn-grid {
    grid-template-columns: repeat(5, minmax(0, 1fr)) !important;
    gap: clamp(4px, 0.9vw, 6px);
  }
  body.z-game-page:not(.mode-pvp) .btn-grid .btn{
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 0;
    padding: clamp(8px, 2.0vw, 10px) clamp(6px, 1.6vw, 8px);
  }
  body.z-game-page:not(.mode-pvp) .btn-grid .btn .btn-ico{
    width: 16px;
    height: 16px;
  }
  
  body.z-game-page:not(.mode-pvp) .btn-grid .btn .btn-text{
    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;
  }


  .z-home-page .btn-grid{
    grid-template-areas: "settings new undo resume save";
  }
  #btnSettings{ grid-area: settings; }
  #btnNew{ grid-area: new; }
  #btnUndo{ grid-area: undo; }
  #btnResume{ grid-area: resume; }
  #btnChat{ grid-area: resume; }
  #btnSave{ grid-area: save; }

  .stats-desktop { display: none !important; }

  .stats-mobile{
    display: block !important;
    padding: clamp(6px, 1.6vw, 8px);
    background: var(--panel);
    border: 1px solid var(--border);
    border-radius: 12px;
  }
  .stats-mobile-table{ width: 100%; border-collapse: collapse; font-size: 12px; }
  .stats-mobile-table th, .stats-mobile-table td{ padding: 7px 8px; border-bottom: 1px solid var(--grid); }
  .stats-mobile-table tr:last-child td{ border-bottom: none; }
  .stats-mobile-table th:first-child,
  .stats-mobile-table td:first-child{ color: var(--muted); font-weight: 800; text-align: start; }
  .stats-mobile-table .stats-color-head{ width: 54px; }
  .stats-mobile-table .piece{ font-size: 18px; line-height: 1; display: inline-block; }

  .ai-state { flex-wrap: wrap; align-items: center; gap: 8px; }
  .ai-state .muted { flex: 0 0 100%; font-size: 12px; }
  .ai-chip { flex: 1 1 0; justify-content: space-between; }

  .status { font-size: clamp(13px, 1.9vw, 14px); }
  .lang-select select { min-width: 96px; padding: 5px 8px; font-size: 12.5px; }
  .lang-select label { font-size: 11.5px; }

  .btn { padding: clamp(6px, 1.6vw, 8px) clamp(8px, 2.2vw, 10px);
    font-size: clamp(12px, 1.9vw, 13px); }

    
  .z-home-page .btn-grid .btn{
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 0;
    padding: clamp(10px, 2.6vw, 12px) clamp(10px, 2.8vw, 12px);
  }
  .z-home-page .btn-grid .btn .btn-text{ display: none; }
  .z-home-page .btn.keep-text .btn-text{ display: inline; }
  .z-home-page .pvp-voice-bar .btn,
  .z-home-page .spec-bar .btn{
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 0;
  }
  .z-home-page .pvp-voice-bar .btn .btn-text{ display:none; }
  .timer-row{
    display: grid;
    grid-template-columns: 1fr;
    gap: 8px;
  }
  .timer-row .clock{ justify-content: center; }
  #btnEndKill{ width: 100%; }

  .modal-body { padding: clamp(15px, 3vw, 20px);
    font-size: clamp(13px, 2vw, 14px); }
}




@media (max-width: 640px) {
  .stats-mobile{
    grid-template-columns: 1fr !important;
  }

  .stats-card{
    overflow-x: hidden !important;
    max-width: 100%;
  }

  
  .log-item,
  .log .msg,
  .status,
  .btn{
    overflow-wrap: anywhere;
    word-break: break-word;
  }
}







.btn.ok {
  background: linear-gradient(135deg, var(--primary-green), var(--ok));
}

.btn.warn {
  background: linear-gradient(135deg, var(--desert-orange), #c86b00);
}

.btn.danger {
  background: linear-gradient(135deg, var(--danger), #b31212);
}

.btn.secondary {
  background: linear-gradient(135deg, rgba(140, 92, 58, 0.14), rgba(217, 124, 0, 0.10));
  color: var(--text) !important;
  border-color: rgba(140, 92, 58, 0.25) !important;
}

.btn.ghost {
  background: transparent;
  color: var(--text) !important;
  border-color: rgba(140, 92, 58, 0.20) !important;
  box-shadow: none;
}

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

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

:root.dark .btn.secondary {
  background: linear-gradient(135deg, rgba(255, 255, 255, 0.10), rgba(255, 255, 255, 0.06));
  color: var(--text) !important;
  border-color: rgba(255, 255, 255, 0.18) !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 {
  color: white !important;
}



.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;
}


.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;
}
.soufla-row .btn{
  width: 100%;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
}


.pvp-voice-bar{
  margin-top: 6px;
  display: flex;
  gap: 8px;
}
.pvp-voice-bar .btn{
  flex: 1 1 0;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
}


.spec-bar{
  margin-top: 6px;
  display: flex;
  gap: 8px;
}
.spec-bar .btn{
  flex: 1 1 0;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
}


@media (max-width: 768px) {
  .z-spectator #specBar .btn {
    padding: 8px;
    min-width: 44px;
    justify-content: center;
  }
  .z-spectator #specBar .btn .btn-text {
    display: none;
  }
}


#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: -6px;
  inset-block-start: -6px;
  font-size: 12px;
  line-height: 1;
  padding: 2px 6px;
  border-radius: 999px;
  background: #ef4444;
  color: #fff;
  box-shadow: 0 2px 8px rgba(0,0,0,0.15);
}
