:root {
  --bg-main: #f3f1ec;
  --card-bg: #ffffff;
  --border: #e0d9cc;
  --board-light: #f0d9b5;
  --board-dark: #b58863;
  --text-main: #222;
  --text-muted: #777;
  --accent: #b58863;
  --accent-dark: #9a6f4c;
}

html,
body {
  margin: 0;
  padding: 0;
  width: 100%;
  max-width: 100%;
  overflow-x: hidden !important;
  overscroll-behavior-x: none;
}

*,
*::before,
*::after {
  box-sizing: border-box;
}

body {
  font-family: Arial, sans-serif;
  background: var(--bg-main);
  color: var(--text-main);
}

a {
  color: var(--accent-dark);
}

img {
  max-width: 100%;
  height: auto;
}

.page-wrap {
  width: 100%;
  max-width: 1220px;
  margin: 0 auto;
  padding: 16px;
  overflow-x: hidden;
}

.card {
  width: 100%;
  max-width: 100%;
  overflow: hidden;
  background: var(--card-bg);
  border: 1px solid var(--border);
  border-radius: 14px;
  padding: 14px;
  box-shadow: 0 2px 10px rgba(0,0,0,.05);
}

.btn,
button.btn {
  display: inline-block;
  max-width: 100%;
  padding: 10px 14px;
  border: 0;
  border-radius: 10px;
  font-weight: bold;
  cursor: pointer;
  text-decoration: none;
}

.btn-primary {
  background: var(--accent);
  color: #fff;
}

.btn-primary:hover {
  background: var(--accent-dark);
}

.btn-light {
  background: #f0d9b5;
  color: #222;
}

.btn-danger {
  background: #7f1d1d;
  color: #fff;
}

.btn-outline {
  background: transparent;
  border: 1px solid var(--border);
  color: #222;
}

input,
select {
  width: 100%;
  max-width: 100%;
  padding: 11px;
  border: 1px solid var(--border);
  border-radius: 10px;
  font-size: 16px;
  margin: 6px 0 12px;
}

label {
  font-weight: bold;
}

.table-wrap {
  width: 100%;
  max-width: 100%;
  overflow-x: auto;
  -webkit-overflow-scrolling: touch;
}

table {
  width: 100%;
  max-width: 100%;
  border-collapse: collapse;
}

th {
  text-align: left;
  padding: 10px;
  background: var(--accent);
  color: #fff;
}

td {
  padding: 10px;
  border-bottom: 1px solid var(--border);
}

tr:hover {
  background: #f9f6f2;
}

.topbar {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 12px;
  margin-bottom: 16px;
  max-width: 100%;
}

.game-layout,
.lobby-grid {
  width: 100%;
  max-width: 100%;
}

#board {
  max-width: 100%;
}

#board .board-b72b1 {
  max-width: 100% !important;
  margin-left: auto !important;
  margin-right: auto !important;
}

/* Chess lobby table */
.chess-lobby-table {
  width: 100%;
  border-collapse: collapse;
}

.chess-lobby-table th,
.chess-lobby-table td {
  padding: 6px 8px;
  white-space: nowrap;
}

.chess-lobby-table th:nth-child(2),
.chess-lobby-table td:nth-child(2),
.chess-lobby-table th:nth-child(3),
.chess-lobby-table td:nth-child(3),
.chess-lobby-table th:nth-child(4),
.chess-lobby-table td:nth-child(4),
.chess-lobby-table th:nth-child(5),
.chess-lobby-table td:nth-child(5) {
  width: 1%;
  text-align: center;
}

.chess-lobby-table th:nth-child(1),
.chess-lobby-table td:nth-child(1) {
  white-space: normal;
}

@media (max-width: 700px) {
  .page-wrap {
    padding: 10px;
  }

  .topbar {
    display: block;
  }

  .topbar .btn {
    margin-top: 8px;
  }

  .card {
    padding: 10px;
  }

  .lobby-grid {
    grid-template-columns: 1fr !important;
  }

  input,
  select,
  button,
  .btn {
    max-width: 100%;
  }

  .chess-lobby-table {
    font-size: 13px;
  }

  .chess-lobby-table th,
  .chess-lobby-table td {
    padding: 6px 5px;
  }

  .chess-lobby-table .btn,
  .chess-lobby-table button.btn {
    padding: 8px 10px;
    font-size: 13px;
  }
}
/* =========================================
   CHESS LOBBY TABLE FIX (OVERRIDE MOBILE BREAK)
========================================= */
.chess-lobby-table,
.chess-lobby-table thead,
.chess-lobby-table tbody,
.chess-lobby-table tr,
.chess-lobby-table th,
.chess-lobby-table td {
  display: table !important;
  width: auto !important;
}

.chess-lobby-table tr {
  display: table-row !important;
}

.chess-lobby-table th,
.chess-lobby-table td {
  display: table-cell !important;
  padding: 6px 8px;
  white-space: nowrap;
}

/* Shrink small columns */
.chess-lobby-table th:nth-child(2),
.chess-lobby-table td:nth-child(2), /* Rating */
.chess-lobby-table th:nth-child(3),
.chess-lobby-table td:nth-child(3), /* Time */
.chess-lobby-table th:nth-child(4),
.chess-lobby-table td:nth-child(4), /* Type */
.chess-lobby-table th:nth-child(5),
.chess-lobby-table td:nth-child(5) { /* Side */
  width: 1%;
  text-align: center;
}

/* Let player column expand */
.chess-lobby-table th:nth-child(1),
.chess-lobby-table td:nth-child(1) {
  white-space: normal;
}p