:root {
  --bg: #0b0f14;
  --panel: #101722;
  --panel2: #0f141d;
  --text: #e9eef6;
  --muted: #9fb0c6;
  --border: rgba(255, 255, 255, 0.08);
  --shadow: 0 12px 30px rgba(0, 0, 0, 0.45);
  --radius: 16px;
  --chipHuman: #ff5b6e;
  --chipBot: #e9eef6;
  --chipFree: #f0c24b;
  --warn: #f0c24b;
  --danger: #ff5b6e;
}

* {
  box-sizing: border-box
}

html,
body {
  height: 100%
}

body {
  margin: 0;
  font-family: ui-sans-serif, system-ui, -apple-system, Segoe UI, Roboto, Arial, sans-serif;
  background: radial-gradient(1200px 700px at 20% 0%, #16243a 0%, var(--bg) 55%);
  color: var(--text);
}

.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 14px 18px;
  border-bottom: 1px solid var(--border);
  background: rgba(10, 14, 20, 0.7);
  backdrop-filter: blur(10px);
  position: sticky;
  top: 0;
  z-index: 10;
}

.brand {
  display: flex;
  flex-direction: column;
  gap: 2px
}

.brand__title {
  font-size: 18px;
  font-weight: 800;
  letter-spacing: 0.2px
}

.brand__sub {
  font-size: 12px;
  color: var(--muted)
}

.topbar__actions {
  display: flex;
  gap: 10px;
  align-items: center
}

.btn {
  border: 1px solid var(--border);
  background: rgba(255, 255, 255, 0.04);
  color: var(--text);
  padding: 9px 12px;
  border-radius: 12px;
  cursor: pointer;
  box-shadow: 0 6px 16px rgba(0, 0, 0, 0.22);
  transition: transform 140ms ease, background 140ms ease, border 140ms ease, opacity 140ms ease;
  font-weight: 600;
  font-size: 13px;
}

.btn:hover {
  transform: translateY(-1px);
  background: rgba(255, 255, 255, 0.07)
}

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

.btn:disabled {
  opacity: 0.45;
  cursor: not-allowed;
  transform: none
}

.btn--primary {
  background: rgba(46, 163, 255, 0.15);
  border-color: rgba(46, 163, 255, 0.35)
}

.btn--warn {
  background: rgba(240, 194, 75, 0.14);
  border-color: rgba(240, 194, 75, 0.38)
}

.layout {
  display: grid;
  grid-template-columns: 1fr 340px;
  gap: 14px;
  padding: 14px;
  max-width: 1400px;
  margin: 0 auto;
}

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

  .sidebar {
    order: 2
  }
}

.boardPanel,
.sidebar>div {
  background: linear-gradient(180deg, rgba(255, 255, 255, 0.06), rgba(255, 255, 255, 0.03));
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
}

.boardPanel {
  padding: 12px
}

.boardHeader {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 10px;
  margin-bottom: 10px
}

.status {
  font-size: 14px;
  color: var(--text);
  font-weight: 700
}

.chipsLegend {
  display: flex;
  gap: 10px;
  flex-wrap: wrap;
  justify-content: flex-end
}

.legendItem {
  display: inline-flex;
  gap: 6px;
  align-items: center;
  color: var(--muted);
  font-size: 12px
}

.board {
  display: grid;
  grid-template-columns: repeat(10, 1fr);
  gap: 6px;
  user-select: none;
}

.cell {
  position: relative;
  width: 100%;
  padding-top: 140%;
  /* aspect ratio like a card */
  border-radius: 12px;
  border: 1px solid rgba(255, 255, 255, 0.10);
  overflow: hidden;
  background: rgba(255, 255, 255, 0.03);
  box-shadow: inset 0 0 0 1px rgba(0, 0, 0, 0.25);
  cursor: default;
  transition: transform 120ms ease, box-shadow 120ms ease, border 120ms ease, filter 120ms ease;
}

.cell--clickable {
  cursor: pointer
}

.cell--clickable:hover {
  transform: translateY(-1px);
  border-color: rgba(255, 255, 255, 0.18)
}

.cell__img {
  position: absolute;
  inset: 0;
  background-size: cover;
  background-position: center;
  filter: saturate(1.05) contrast(1.05);
}

.corner {
  position: absolute;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  font-weight: 900;
  letter-spacing: 0.8px;
  font-size: 12px;
  color: rgba(255, 255, 255, 0.85);
  background:
    radial-gradient(380px 220px at 30% 20%, rgba(240, 194, 75, 0.35), rgba(255, 255, 255, 0.03) 55%),
    rgba(255, 255, 255, 0.03);
}

.corner small {
  display: block;
  font-weight: 700;
  color: rgba(255, 255, 255, 0.70);
  letter-spacing: 0.2px
}

.chip {
  width: 14px;
  height: 14px;
  border-radius: 999px;
  display: inline-block;
  box-shadow: 0 2px 7px rgba(0, 0, 0, 0.35);
}

.chip--human {
  background: var(--chipHuman)
}

.chip--bot {
  background: var(--chipBot)
}

.chip--free {
  background: var(--chipFree)
}

.chipOnCell {
  position: absolute;
  width: 52%;
  height: 52%;
  border-radius: 999px;
  left: 50%;
  top: 50%;
  transform: translate(-50%, -50%);
  box-shadow: 0 10px 22px rgba(0, 0, 0, 0.52);
  border: 2px solid rgba(255, 255, 255, 0.12);
  background: rgba(255, 255, 255, 0.06);
}

.chipOnCell::before {
  content: "";
  position: absolute;
  inset: 10%;
  border-radius: 999px;
  background: radial-gradient(circle at 30% 30%, rgba(255, 255, 255, 0.45), rgba(255, 255, 255, 0.05) 55%);
}

.chipOnCell--human {
  background: radial-gradient(circle at 30% 30%, rgba(46, 163, 255, 0.95), rgba(46, 163, 255, 0.30) 62%)
}

.chipOnCell--bot {
  background: radial-gradient(circle at 30% 30%, rgba(73, 209, 122, 0.95), rgba(73, 209, 122, 0.28) 62%)
}

.lockBadge {
  position: absolute;
  right: 6px;
  top: 6px;
  font-size: 10px;
  padding: 4px 6px;
  border-radius: 999px;
  background: rgba(0, 0, 0, 0.45);
  border: 1px solid rgba(255, 255, 255, 0.12);
  color: rgba(255, 255, 255, 0.86);
}

.validPulse {
  box-shadow: 0 0 0 2px rgba(46, 163, 255, 0.55), 0 0 28px rgba(46, 163, 255, 0.25);
  border-color: rgba(46, 163, 255, 0.65);
  animation: pulse 900ms ease-in-out infinite;
}

.validRemove {
  box-shadow: 0 0 0 2px rgba(255, 91, 110, 0.55), 0 0 28px rgba(255, 91, 110, 0.25);
  border-color: rgba(255, 91, 110, 0.65);
  animation: pulse 900ms ease-in-out infinite;
}

@keyframes pulse {

  0%,
  100% {
    filter: none;
  }

  50% {
    filter: brightness(0.72) contrast(1.15) saturate(1.3) hue-rotate(-12deg);
  }
}


.toast {
  margin-top: 10px;
  min-height: 22px;
  color: rgba(255, 255, 255, 0.9);
  font-weight: 700;
  font-size: 13px;
}

.sidebar {
  display: flex;
  flex-direction: column;
  gap: 12px
}

.sidebar>div {
  padding: 12px
}

.panelTitle {
  font-size: 12px;
  color: var(--muted);
  font-weight: 800;
  letter-spacing: 0.7px;
  text-transform: uppercase;
  margin-bottom: 10px
}

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

.handCard {
  position: relative;
  padding-top: 140%;
  border-radius: 14px;
  overflow: hidden;
  border: 1px solid rgba(255, 255, 255, 0.12);
  background: rgba(255, 255, 255, 0.03);
  cursor: pointer;
  transition: transform 120ms ease, border 120ms ease, box-shadow 120ms ease;
}

.handCard:hover {
  transform: translateY(-2px);
  border-color: rgba(255, 255, 255, 0.22)
}

.handCard--selected {
  box-shadow: 0 0 0 2px rgba(46, 163, 255, 0.55), 0 0 24px rgba(46, 163, 255, 0.25);
  border-color: rgba(46, 163, 255, 0.65)
}

.handCard--dead {
  opacity: 0.65
}

.handCard__img {
  position: absolute;
  inset: 0;
  background-size: cover;
  background-position: center
}

.handCard__badge {
  position: absolute;
  left: 6px;
  top: 6px;
  font-size: 10px;
  padding: 4px 6px;
  border-radius: 999px;
  background: rgba(0, 0, 0, 0.48);
  border: 1px solid rgba(255, 255, 255, 0.12);
}

.handActions {
  display: flex;
  gap: 8px;
  margin-top: 10px
}

.hint {
  margin-top: 10px;
  color: rgba(255, 255, 255, 0.85);
  font-size: 12px;
  line-height: 1.35
}

.scoreRow {
  display: flex;
  gap: 10px
}

.scoreBox {
  flex: 1;
  background: rgba(0, 0, 0, 0.22);
  border: 1px solid rgba(255, 255, 255, 0.10);
  border-radius: 14px;
  padding: 12px
}

.scoreLabel {
  font-size: 12px;
  color: var(--muted);
  font-weight: 800
}

.scoreValue {
  font-size: 24px;
  font-weight: 900;
  margin-top: 4px
}

.smallStats {
  margin-top: 10px;
  display: flex;
  justify-content: space-between;
  color: rgba(255, 255, 255, 0.80);
  font-size: 12px
}

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

.log {
  max-height: 220px;
  overflow: auto;
  display: flex;
  flex-direction: column;
  gap: 8px;
  padding-right: 6px
}

.logItem {
  font-size: 12px;
  color: rgba(255, 255, 255, 0.86);
  line-height: 1.35
}

.logItem .t {
  color: var(--muted)
}

.modal {
  position: fixed;
  inset: 0;
  display: none;
  z-index: 50
}

.modal--open {
  display: block
}

.modal__backdrop {
  position: absolute;
  inset: 0;
  background: rgba(0, 0, 0, 0.55)
}

.modal__card {
  position: absolute;
  left: 50%;
  top: 50%;
  transform: translate(-50%, -50%);
  width: min(720px, calc(100% - 24px));
  max-height: calc(100% - 24px);
  overflow: auto;
  background: #111;
  border: 1px solid var(--border);
  border-radius: 18px;
  box-shadow: var(--shadow)
}

.rulesTop {
  display: flex;
  gap: 12px;
  align-items: center;
}

.rulesJacks {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
}

.ruleCardImg {
  width: 56px;
  height: 78px;
  object-fit: contain;
  border-radius: 8px;
  background: rgba(255, 255, 255, .04);
  padding: 4px;
}

.rulesMini {
  font-size: 14px;
  line-height: 1.25;
  opacity: .95;
}

.rulesHr {
  border: 0;
  height: 1px;
  background: rgba(255, 255, 255, .12);
  margin: 12px 0;
}

.rulesList {
  margin: 0;
  padding-left: 18px;
}

.modal__header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 12px 12px 0 12px
}

.modal__title {
  font-weight: 900
}

.modal__body {
  padding: 12px
}

.modal__body p {
  color: rgba(255, 255, 255, 0.88);
  line-height: 1.5
}

.modal__body ul {
  color: rgba(255, 255, 255, 0.86)
}

.modal__body code {
  background: rgba(0, 0, 0, 0.25);
  padding: 2px 6px;
  border-radius: 8px;
  border: 1px solid rgba(255, 255, 255, 0.10)
}

/* UPDATES */

.chipOnCellImg {
  position: absolute;
  inset: 0;
  margin: auto;

  width: 58%;
  height: 58%;
  object-fit: cover;
  /* IMPORTANT */
  border-radius: 50%;
  /* FORCE CIRCLE */
  overflow: hidden;
  /* CLIP IMAGE */
  object-fit: contain;

  /* VISIBILITY BOOST */
  filter:
    drop-shadow(0 3px 6px rgba(0, 0, 0, .6)) drop-shadow(0 0 0 rgba(0, 0, 0, 0));

  /* white outline illusion */
  background: radial-gradient(circle, rgba(255, 255, 255, .85) 0%, rgba(255, 255, 255, .85) 55%, transparent 56%);
  border-radius: 50%;

  pointer-events: none;
}

.cell--occupied .cell__img {
  opacity: 0.72;
}

.lockBadge {
  background: #ffd700;
  color: #000;
  font-weight: 700;
  font-size: 10px;
  padding: 2px 6px;
  border-radius: 10px;
  box-shadow: 0 2px 4px rgba(0, 0, 0, .4);
}

.cell--occupied .chipOnCellImg {
  animation: none;
}

.cell--occupied .chipOnCellImg.locked {
  filter:
    drop-shadow(0 0 6px rgba(255, 215, 0, .9)) drop-shadow(0 3px 6px rgba(0, 0, 0, .6));
}

.cell__img {
  z-index: 1;
}

.chipOnCellImg {
  z-index: 3;
}

.lockBadge {
  z-index: 4;
}

.chipOnCellImg {
  filter: brightness(1.18) contrast(1.12) saturate(1.05) drop-shadow(0 3px 6px rgba(0, 0, 0, .6));
}

/* LOGS CLICKABLE */

/* clickable log rows */
.logItem--clickable {
  cursor: pointer;
}

.logItem--clickable:hover {
  filter: brightness(1.12);
  text-decoration: underline;
}

/* board focus flash */
.boardFlash {
  animation: boardFlash 160ms ease-out;
}

@keyframes boardFlash {
  from {
    filter: brightness(1.05);
  }

  to {
    filter: none;
  }
}

/* last move highlight */
.cell--lastMove {
  position: relative;
  z-index: 2;
  outline: 3px solid rgba(0, 160, 255, 0.95);
  outline-offset: -3px;
  box-shadow: inset 0 0 18px rgba(0, 160, 255, 0.45);
  animation: lastMovePulse 900ms ease-in-out 2;
}

.cell--lastMovePlace {
  outline-color: rgba(0, 190, 120, 0.95);
  box-shadow: inset 0 0 18px rgba(0, 190, 120, 0.45);
}

.cell--lastMoveRemove {
  outline-color: rgba(255, 80, 80, 0.98);
  box-shadow: inset 0 0 18px rgba(255, 80, 80, 0.45);
}

.cell--lastMoveRemove::after {
  content: "✕";
  position: absolute;
  inset: 0;
  display: grid;
  place-items: center;
  font-size: 28px;
  font-weight: 800;
  color: rgba(255, 80, 80, 0.95);
  text-shadow: 0 2px 6px rgba(0, 0, 0, 0.55);
  pointer-events: none;
}

@keyframes lastMovePulse {
  0% {
    transform: scale(1);
  }

  50% {
    transform: scale(1.02);
  }

  100% {
    transform: scale(1);
  }
}

.logItem--focused {
  outline: 2px solid rgba(0, 160, 255, 0.65);
  outline-offset: 2px;
  border-radius: 8px;
  background: rgba(0, 160, 255, 0.10);
}

/* Mobile */

/* --- Mobile tuning: smaller hand cards + less rounding --- */
@media (max-width: 560px) {
  .board {
    gap: 4px;
  }

  /* board cells: less rounded on mobile */
  .cell {
    border-radius: 8px;
  }

  /* hand: make cards smaller + less rounded */
  .hand {
    grid-template-columns: repeat(3, 1fr);
    gap: 6px;
  }

  .handCard {
    border-radius: 10px;
    padding-top: 130%;
    /* slightly shorter than 140% */
  }

  .handCard__img {
    background-size: cover;
  }

  /* buttons wrap nicer */
  .handActions {
    flex-wrap: wrap;
  }
}

/* extra small phones */
@media (max-width: 380px) {
  .hand {
    grid-template-columns: repeat(2, 1fr);
  }

  .handCard {
    border-radius: 9px;
    padding-top: 128%;
  }
}

/* ---------- MOBILE FIXES (hand too big + rounding) ---------- */
@media (max-width: 560px) {

  /* tighter page padding */
  .layout {
    padding: 10px;
    gap: 10px;
  }

  .boardPanel {
    padding: 10px;
  }

  .sidebar>div {
    padding: 10px;
  }

  /* reduce the "too rounded" feel */
  .cell {
    border-radius: 9px;
  }

  .handCard {
    border-radius: 10px;
  }

  /* ✅ make hand cards smaller by using more columns */
  .hand {
    grid-template-columns: repeat(4, minmax(0, 1fr));
    gap: 6px;
  }

  /* optional: make selection glow less huge on small screens */
  .handCard--selected {
    box-shadow: 0 0 0 2px rgba(46, 163, 255, 0.45), 0 0 16px rgba(46, 163, 255, 0.18);
  }

  /* top bar buttons fit nicer */
  .topbar {
    padding: 12px 12px;
  }

  .btn {
    padding: 8px 10px;
    font-size: 12px;
    border-radius: 11px;
  }
}
