: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;
  --danger: #7f1d1d;
}

html, body {
  margin: 0;
  padding: 0;
  width: 100%;
  max-width: 100%;
  overflow-x: hidden;
}

*, *::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); }

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

.card {
  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;
  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-outline { background: transparent; border: 1px solid var(--border); color: #222; }
.btn-danger { background: var(--danger); color: #fff; }

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

label { font-weight: bold; }

table { 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); }

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

.game-layout {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 320px;
  gap: 16px;
}

.board-card {
  display: flex;
  flex-direction: column;
  align-items: center;
}

.checkers-board {
  width: min(92vw, 560px);
  aspect-ratio: 1 / 1;
  display: grid;
  grid-template-columns: repeat(8, 1fr);
  grid-template-rows: repeat(8, 1fr);
  border: 8px solid #7b4a1d;
  border-radius: 12px;
  overflow: hidden;
  touch-action: manipulation;
  user-select: none;
  box-shadow: 0 10px 30px rgba(0,0,0,.18);
}

.checkers-square {
  position: relative;
  display: flex;
  align-items: center;
  justify-content: center;
}

.checkers-square.light { background: var(--board-light); }
.checkers-square.dark { background: var(--board-dark); }

.checkers-piece {
  width: 76%;
  height: 76%;
  border-radius: 50%;
  cursor: pointer;
  box-shadow: inset 0 4px 8px rgba(255,255,255,.28), inset 0 -5px 8px rgba(0,0,0,.25), 0 5px 10px rgba(0,0,0,.25);
  border: 3px solid rgba(255,255,255,.38);
}

.checkers-piece.black { background: radial-gradient(circle at 35% 25%, #555, #111 65%); }
.checkers-piece.red { background: radial-gradient(circle at 35% 25%, #ff7878, #9c1111 65%); }

.checkers-piece.king::after {
  content: "♔";
  color: #f8e6a0;
  font-size: 42px;
  font-weight: bold;
  position: absolute;
  text-shadow: 0 2px 3px rgba(0,0,0,.5);
}

.checkers-square.selected { outline: 4px solid #f7c948; outline-offset: -4px; }
.checkers-square.move::before {
  content: "";
  position: absolute;
  width: 24%;
  height: 24%;
  border-radius: 50%;
  background: rgba(0,0,0,.35);
}
.checkers-square.capture { outline: 4px solid rgba(220, 53, 69, .85); outline-offset: -4px; }

.status-box {
  padding: 10px;
  text-align: center;
  font-weight: bold;
}

.move-list {
  max-height: 300px;
  overflow-y: auto;
  border: 1px solid var(--border);
  padding: 10px;
  border-radius: 10px;
}

.lobby-chat-messages {
  height: 260px;
  overflow-y: auto;
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 10px;
  background: #fff;
}
.lobby-chat-line { margin-bottom: 7px; word-break: break-word; }
.lobby-chat-line small { color: #777; }
.lobby-chat-system { color: #7b4a1d; font-style: italic; }
.lobby-chat-form { display: flex; gap: 8px; margin-top: 10px; }
.lobby-chat-form input { margin: 0; }

@media (max-width: 900px) {
  .game-layout { grid-template-columns: 1fr; }
}

@media (max-width: 700px) {
  .page-wrap { padding: 10px; }
  .topbar { display: block; }
  .topbar .btn { margin-top: 8px; }
  .card { padding: 10px; }
  table, thead, tbody, th, td, tr { display: block; width: 100%; }
  thead { display: none; }
  tr { margin-bottom: 12px; padding: 10px; border: 1px solid var(--border); border-radius: 10px; background: #fff; }
  td { display: flex; justify-content: space-between; gap: 12px; padding: 7px 0; border-bottom: 1px solid var(--border); }
  td:last-child { border-bottom: 0; }
  .lobby-chat-form { display: block; }
  .lobby-chat-form button { width: 100%; margin-top: 8px; }
#board,
.checkers-board,
.checkers-square,
.checkers-piece {
  touch-action: none;
  -webkit-user-select: none;
  user-select: none;
  -webkit-touch-callout: none;
}

.checkers-board {
  overscroll-behavior: contain;
}
html,
body {
  overscroll-behavior: none;
}

#board,
.checkers-board,
.checkers-square,
.checkers-piece {
  touch-action: none !important;
  -webkit-user-select: none !important;
  user-select: none !important;
  -webkit-touch-callout: none !important;
}

.checkers-piece {
  -webkit-user-drag: none !important;
}
}


.checkers-board,
.checkers-square,
.checkers-piece {
  touch-action: none;
  -webkit-user-select: none;
  user-select: none;
  -webkit-touch-callout: none;
}

.checkers-piece {
  cursor: grab;
}

.checkers-piece:active {
  cursor: grabbing;
}


/* Bubble notifications */
.notify-wrap{
  position:fixed;
  top:20px;
  right:20px;
  z-index:99999;
  display:flex;
  flex-direction:column;
  gap:10px;
}
.notify-bubble{
  background:#ffffff;
  color:#222;
  border-radius:14px;
  padding:14px 18px;
  box-shadow:0 10px 30px rgba(0,0,0,.18);
  font-weight:700;
  max-width:320px;
  border:1px solid rgba(0,0,0,.08);
  animation:notifySlide .2s ease-out;
}
.notify-bubble.error{
  border-left:6px solid #ff4d4f;
}
.notify-bubble.success{
  border-left:6px solid #28a745;
}
@keyframes notifySlide{
  from{transform:translateX(30px);opacity:0;}
  to{transform:translateX(0);opacity:1;}
}

/* HTG VISUAL FIX: match large rounded checkerboard reference image */
.board-row,
.board-shell,
.board-card {
  width: 100% !important;
  max-width: 100% !important;
  overflow: hidden !important;
  box-sizing: border-box !important;
}

.board-frame,
.checkers-board-frame {
  width: 100% !important;
  max-width: min(100%, 760px) !important;
  aspect-ratio: 1 / 1 !important;
  margin: 0 auto !important;
  padding: 5px !important;
  box-sizing: border-box !important;
  display: flex !important;
  align-items: stretch !important;
  justify-content: stretch !important;
  background: #2c2c2c !important;
  border: 0 !important;
  border-radius: 28px !important;
  overflow: hidden !important;
  box-shadow: 0 8px 22px rgba(20,20,20,.10) !important;
}

.board-area {
  flex: 1 1 auto !important;
  width: 100% !important;
  height: auto !important;
  min-width: 0 !important;
  min-height: 0 !important;
  border-radius: 22px !important;
  overflow: hidden !important;
  box-sizing: border-box !important;
}

#board,
.checkers-board {
  width: 100% !important;
  height: 100% !important;
  max-width: 100% !important;
  min-width: 0 !important;
  aspect-ratio: 1 / 1 !important;
  margin: 0 !important;
  padding: 0 !important;
  border: 0 !important;
  border-radius: 0 !important;
  overflow: hidden !important;
  box-sizing: border-box !important;
  display: grid !important;
  grid-template-columns: repeat(8, minmax(0, 1fr)) !important;
  grid-template-rows: repeat(8, minmax(0, 1fr)) !important;
  background: var(--light-square) !important;
}

.checkers-square,
#board .square {
  width: 100% !important;
  height: 100% !important;
  min-width: 0 !important;
  min-height: 0 !important;
  box-sizing: border-box !important;
  position: relative !important;
  overflow: visible !important;
}

.checkers-square.light,
#board .square.light {
  background: #f4e5c8 !important;
}

.checkers-square.dark,
#board .square.dark {
  background: #b9855f !important;
}

.checkers-piece {
  width: 78% !important;
  height: 78% !important;
  left: 11% !important;
  top: 11% !important;
  position: absolute !important;
  border-radius: 50% !important;
  box-sizing: border-box !important;
  border: 0 !important;
  transform: translateZ(0) !important;
  box-shadow:
    inset 0 9px 12px rgba(255,255,255,.30),
    inset 0 -9px 14px rgba(0,0,0,.26),
    0 4px 7px rgba(0,0,0,.22) !important;
}

.checkers-piece.red {
  background:
    radial-gradient(circle at 34% 24%, rgba(255,255,255,.50) 0%, rgba(255,255,255,.12) 20%, transparent 34%),
    radial-gradient(circle at 50% 54%, #e45f65 0%, #c62d39 56%, #8f1622 100%) !important;
}

.checkers-piece.black {
  background:
    radial-gradient(circle at 34% 24%, rgba(255,255,255,.34) 0%, rgba(255,255,255,.09) 20%, transparent 34%),
    radial-gradient(circle at 50% 54%, #4b4b4b 0%, #1b1b1b 58%, #050505 100%) !important;
}

.checkers-piece::before {
  content: "";
  position: absolute;
  inset: 8%;
  border-radius: 50%;
  border: 1px solid rgba(255,255,255,.16);
  box-shadow: inset 0 0 0 1px rgba(0,0,0,.10);
  pointer-events: none;
}

.checkers-piece.king::after {
  content: "♛";
  position: absolute;
  inset: 0;
  display: grid;
  place-items: center;
  color: rgba(255,255,255,.98);
  font: 900 118%/1 Arial, Helvetica, sans-serif;
  text-shadow:
    0 1px 2px rgba(0,0,0,.85),
    0 0 6px rgba(0,0,0,.55);
  pointer-events: none;
  z-index: 5;
}

@media (max-width: 760px) {
  .board-frame,
  .checkers-board-frame {
    padding: 5px !important;
    border-radius: 26px !important;
  }

  .board-area {
    border-radius: 21px !important;
  }

  .checkers-piece {
    width: 78% !important;
    height: 78% !important;
    left: 11% !important;
    top: 11% !important;
  }
}

@media (max-width: 430px) {
  .board-frame,
  .checkers-board-frame {
    padding: 4px !important;
    border-radius: 24px !important;
  }

  .board-area {
    border-radius: 20px !important;
  }

  .checkers-piece {
    width: 80% !important;
    height: 80% !important;
    left: 10% !important;
    top: 10% !important;
  }
}


/* HTG FIX: make checkers a little smaller while preserving the same board look */
.checkers-piece {
  width: 72% !important;
  height: 72% !important;
  left: 14% !important;
  top: 14% !important;
}

@media (max-width: 760px) {
  .checkers-piece {
    width: 72% !important;
    height: 72% !important;
    left: 14% !important;
    top: 14% !important;
  }
}

@media (max-width: 430px) {
  .checkers-piece {
    width: 74% !important;
    height: 74% !important;
    left: 13% !important;
    top: 13% !important;
  }
}
