:root {
  --bg-dark: #070b13;
  --bg-panel: rgba(12, 18, 28, 0.8);
  --bg-panel-strong: rgba(10, 15, 24, 0.96);
  --board-light: #ebd4a4;
  --board-dark: #6b4b3f;
  --board-accent: rgba(255, 255, 255, 0.08);
  --gold: #ffd57a;
  --gold-soft: #8de5ff;
  --cyan: #75e6ff;
  --violet: #8a7dff;
  --text: #edf7ff;
  --muted: #a7bad3;
  --green: #7ce7a8;
  --red: #ff7a7a;
  --shadow: rgba(0, 0, 0, 0.28);
}

* {
  box-sizing: border-box;
}

html,
body {
  margin: 0;
  min-height: 100%;
  font-family: "Inter", sans-serif;
  background:
    radial-gradient(circle at top, rgba(117, 230, 255, 0.18), transparent 28%),
    radial-gradient(circle at bottom right, rgba(138, 125, 255, 0.22), transparent 30%),
    linear-gradient(135deg, #070b13 0%, #0d1523 48%, #090d15 100%);
  color: var(--text);
}

body {
  position: relative;
  min-height: 100vh;
  display: grid;
  place-items: center;
  padding: 32px;
}

body::before {
  content: "";
  position: fixed;
  inset: 0;
  background: linear-gradient(120deg, rgba(117, 230, 255, 0.05), transparent 40%, rgba(138, 125, 255, 0.08));
  pointer-events: none;
}

button {
  font: inherit;
}

button:focus-visible {
  outline: 2px solid rgba(117, 230, 255, 0.8);
  outline-offset: 2px;
}

.page-shell {
  position: relative;
  width: min(1200px, 100%);
  background: linear-gradient(180deg, rgba(11, 16, 25, 0.76), rgba(8, 12, 18, 0.9));
  border: 1px solid rgba(117, 230, 255, 0.14);
  border-radius: 28px;
  box-shadow:
    0 0 0 1px rgba(117, 230, 255, 0.08),
    0 30px 90px rgba(0, 0, 0, 0.42),
    inset 0 1px 0 rgba(255, 255, 255, 0.08);
  backdrop-filter: blur(18px);
  overflow: hidden;
}

.topbar {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 20px;
  padding: 26px 28px 18px;
  border-bottom: 1px solid rgba(255, 255, 255, 0.06);
  background: linear-gradient(180deg, rgba(117, 230, 255, 0.04), rgba(255, 255, 255, 0.01));
}

.eyebrow {
  margin: 0 0 6px;
  color: var(--gold-soft);
  text-transform: uppercase;
  letter-spacing: 0.18em;
  font-size: 11px;
  font-weight: 700;
}

h1 {
  margin: 0;
  font-size: clamp(2rem, 3vw, 3.2rem);
  letter-spacing: -0.06em;
  text-shadow: 0 0 18px rgba(117, 230, 255, 0.26);
}

.header-actions {
  display: flex;
  align-items: center;
  gap: 14px;
  flex-wrap: wrap;
}

.sound-btn {
  min-width: 150px;
}

.sound-btn.muted {
  opacity: 0.8;
  border-color: rgba(255, 255, 255, 0.12);
}

.primary-btn,
.secondary-btn,
.mode-btn {
  position: relative;
  cursor: pointer;
  border: none;
  border-radius: 14px;
  transition: transform 0.18s ease, box-shadow 0.18s ease, border-color 0.18s ease, filter 0.18s ease;
}

.primary-btn:hover,
.secondary-btn:hover,
.mode-btn:hover {
  transform: translateY(-2px);
  filter: brightness(1.04);
}

.primary-btn:active,
.secondary-btn:active,
.mode-btn:active {
  transform: translateY(0);
}

.primary-btn {
  background: linear-gradient(135deg, #ffe39a, #ffbf5f 40%, #d18d42);
  color: #1d1207;
  font-weight: 800;
  padding: 12px 20px;
  box-shadow: 0 10px 28px rgba(255, 181, 76, 0.28), inset 0 1px 0 rgba(255, 255, 255, 0.5);
}

.secondary-btn {
  background: rgba(255, 255, 255, 0.04);
  color: var(--text);
  border: 1px solid rgba(117, 230, 255, 0.22);
  padding: 12px 20px;
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.06);
}

.game-layout {
  display: grid;
  grid-template-columns: 320px minmax(0, 1fr);
  gap: 28px;
  align-items: center;
  padding: 30px 22px 32px;
}

.info-panel {
  display: flex;
  flex-direction: column;
  gap: 18px;
}

.panel-card {
  background: linear-gradient(180deg, rgba(15, 22, 34, 0.95), rgba(11, 17, 27, 0.96));
  border: 1px solid rgba(117, 230, 255, 0.12);
  border-radius: 18px;
  padding: 18px 18px 16px;
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.06), 0 18px 35px rgba(2, 6, 12, 0.3);
}

.panel-card label {
  display: block;
  margin-bottom: 10px;
  color: var(--muted);
  font-size: 12px;
  text-transform: uppercase;
  letter-spacing: 0.12em;
}

.status-card h2 {
  margin: 0;
  font-size: clamp(1.5rem, 2vw, 2rem);
}

.turn-indicator {
  font-size: 1.25rem;
  font-weight: 700;
  color: var(--gold);
  text-shadow: 0 0 12px rgba(255, 213, 122, 0.36);
}

#status-text {
  margin: 0;
  color: var(--text);
  line-height: 1.5;
}

.top-banner-ad-wrap {
  padding: 18px 22px 0;
}

.ad-slot-host {
  width: 100%;
  min-height: 120px;
  display: flex;
  align-items: center;
  justify-content: center;
}

.ad-slot-host--sidebar {
  max-width: 100%;
  min-height: 250px;
}

.ad-slot {
  width: 100%;
  max-width: 970px;
  margin: 0 auto;
  border: 1px solid rgba(117, 230, 255, 0.14);
  border-radius: 18px;
  background: rgba(11, 17, 27, 0.7);
  padding: 10px;
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.05);
}

.ad-slot__label {
  font-size: 10px;
  letter-spacing: 0.14em;
  text-transform: uppercase;
  color: var(--muted);
  margin: 0 0 8px;
  text-align: center;
}

.ad-slot--sidebar {
  max-width: 100%;
  min-height: 250px;
}

.ad-slot--banner {
  min-height: 90px;
}

.buttons-panel {
  display: flex;
  gap: 12px;
  flex-wrap: wrap;
}

.mode-btn {
  flex: 1 1 0;
  min-width: 140px;
  text-align: center;
  background: linear-gradient(180deg, rgba(15, 22, 34, 0.9), rgba(10, 15, 24, 0.9));
  border: 1px solid rgba(117, 230, 255, 0.14);
  color: var(--text);
  padding: 16px 18px;
  font-weight: 700;
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.04);
}

.mode-btn.active {
  background: linear-gradient(135deg, rgba(117, 230, 255, 0.14), rgba(138, 125, 255, 0.12));
  border-color: rgba(117, 230, 255, 0.55);
  box-shadow: 0 0 0 1px rgba(117, 230, 255, 0.2), 0 12px 30px rgba(117, 230, 255, 0.12);
}

.game-over-overlay {
  position: fixed;
  inset: 0;
  display: grid;
  place-items: center;
  background: rgba(3, 6, 12, 0.72);
  backdrop-filter: blur(8px);
  opacity: 0;
  visibility: hidden;
  pointer-events: none;
  transition: opacity 0.22s ease, visibility 0.22s ease;
  z-index: 30;
}

.game-over-overlay.show {
  opacity: 1;
  visibility: visible;
  pointer-events: auto;
}

.game-over-card {
  width: min(440px, calc(100vw - 32px));
  background: linear-gradient(180deg, rgba(15, 22, 34, 0.97), rgba(8, 12, 20, 0.98));
  border: 1px solid rgba(117, 230, 255, 0.2);
  border-radius: 26px;
  padding: 28px 24px 24px;
  box-shadow: 0 24px 60px rgba(0, 0, 0, 0.45), 0 0 0 1px rgba(117, 230, 255, 0.12), inset 0 1px 0 rgba(255, 255, 255, 0.08);
  text-align: center;
}

.overlay-label {
  margin: 0 0 12px;
  color: var(--gold-soft);
  text-transform: uppercase;
  letter-spacing: 0.2em;
  font-size: 11px;
  font-weight: 800;
}

#game-over-title {
  margin: 0;
  font-size: clamp(2.2rem, 3vw, 3rem);
  letter-spacing: -0.06em;
}

#game-over-message {
  margin: 14px 0 22px;
  color: var(--text);
  font-size: 1.05rem;
  line-height: 1.6;
}

.overlay-btn {
  min-width: 180px;
}

.board-panel {
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 16px;
}

.board {
  position: relative;
  width: min(72vmin, 760px);
  height: min(72vmin, 760px);
  max-width: 100%;
  display: grid;
  grid-template-columns: repeat(8, minmax(0, 1fr));
  grid-template-rows: repeat(8, minmax(0, 1fr));
  border-radius: 24px;
  overflow: hidden;
  box-shadow:
    0 30px 80px rgba(0, 0, 0, 0.35),
    0 0 0 1px rgba(117, 230, 255, 0.2),
    inset 0 0 0 1px rgba(255, 255, 255, 0.12);
  border: 3px solid rgba(117, 230, 255, 0.18);
}

.square {
  position: relative;
  display: grid;
  place-items: center;
  width: 100%;
  height: 100%;
  aspect-ratio: 1 / 1;
  font-size: clamp(2.6rem, 4vw, 4.4rem);
  user-select: none;
  cursor: pointer;
  transition: transform 0.12s ease, box-shadow 0.12s ease, filter 0.12s ease;
}

.square.light {
  background: linear-gradient(135deg, #f3e7c9, #d9c09a);
}

.square.dark {
  background: linear-gradient(135deg, #7a5847, #4d362b);
}

.square:hover {
  filter: brightness(1.04);
  box-shadow: inset 0 0 0 3px rgba(117, 230, 255, 0.28);
}

.square.selected {
  box-shadow: inset 0 0 0 4px rgba(255, 213, 122, 0.9), 0 0 18px rgba(255, 213, 122, 0.25);
}

.square.legal::after {
  content: "";
  position: absolute;
  inset: 0;
  background: rgba(28, 165, 95, 0.22);
  pointer-events: none;
}

.square.legal .piece-target {
  opacity: 0.8;
}

.square.reachable::before {
  content: "";
  position: absolute;
  width: 22%;
  height: 22%;
  border-radius: 50%;
  background: rgba(35, 49, 70, 0.5);
  box-shadow: 0 0 0 6px rgba(255, 255, 255, 0.1);
}

.square.last-move {
  box-shadow: inset 0 0 0 3px rgba(131, 172, 255, 0.8);
}

.piece {
  display: grid;
  place-items: center;
  width: 100%;
  height: 100%;
  transform: translateY(-1px);
  text-shadow: 0 6px 12px rgba(0, 0, 0, 0.18);
}

.piece.white {
  color: #f4f7ff;
  filter: drop-shadow(0 4px 4px rgba(0, 0, 0, 0.18));
}

.piece.black {
  color: #0e1120;
  filter: drop-shadow(0 2px 5px rgba(0, 0, 0, 0.12));
}

@media (max-width: 900px) {
  body {
    padding: 18px;
  }

  .game-layout {
    grid-template-columns: 1fr;
  }

  .info-panel {
    order: 2;
  }

  .board-panel {
    order: 1;
  }

  .topbar {
    flex-direction: column;
    align-items: flex-start;
  }

  .header-actions {
    width: 100%;
    justify-content: flex-start;
    flex-wrap: wrap;
  }

  .ad-slot-host--sidebar {
    min-height: 180px;
  }
}
