:root {
  --bg-1: #0d1321;
  --bg-2: #171f32;
  --panel: rgba(17, 23, 35, 0.74);
  --panel-border: rgba(255, 255, 255, 0.12);
  --text: #edf3ff;
  --muted: #a9b9d3;
  --gold: #f7d58d;
  --board-light: #f0d9b5;
  --board-dark: #b58863;
  --shadow: rgba(0, 0, 0, 0.35);
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  min-height: 100vh;
  display: grid;
  place-items: start center;
  background:
    radial-gradient(circle at top, rgba(77, 121, 255, 0.2), transparent 35%),
    linear-gradient(135deg, var(--bg-1), var(--bg-2));
  color: var(--text);
  font-family: "Segoe UI", Tahoma, Geneva, Verdana, sans-serif;
}

.page-shell {
  width: min(1100px, calc(100% - 32px));
  padding: 32px 22px 40px;
}

.hero {
  display: flex;
  align-items: end;
  justify-content: space-between;
  gap: 20px;
  margin-bottom: 28px;
}

.brand-block h1 {
  margin: 0;
  font-size: clamp(2.3rem, 4vw, 4rem);
  letter-spacing: -0.04em;
}

.eyebrow {
  margin: 0 0 8px;
  color: var(--gold);
  font-size: 0.78rem;
  text-transform: uppercase;
  letter-spacing: 0.18em;
}

.status-card,
.info-card,
.board-panel {
  background: var(--panel);
  border: 1px solid var(--panel-border);
  box-shadow: 0 20px 45px var(--shadow);
  backdrop-filter: blur(12px);
}

.status-card {
  padding: 16px 20px;
  border-radius: 18px;
  min-width: 180px;
  text-align: center;
}

.status-card strong {
  display: block;
  margin-top: 6px;
  font-size: 1.1rem;
}

.status-label {
  color: var(--muted);
  font-size: 0.78rem;
  letter-spacing: 0.12em;
  text-transform: uppercase;
}

.game-layout {
  display: grid;
  grid-template-columns: minmax(280px, 1.35fr) minmax(220px, 0.65fr);
  gap: 24px;
  align-items: start;
}

.board-panel {
  border-radius: 28px;
  padding: 20px;
}

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

.panel-header h2,
.info-card h3 {
  margin: 0;
}

button {
  border: none;
  border-radius: 999px;
  background: linear-gradient(135deg, #f7d58d, #c99747);
  color: #1a1206;
  font-weight: 700;
  padding: 0.8rem 1.2rem;
  cursor: pointer;
  transition: transform 0.2s ease, box-shadow 0.2s ease;
}

button:hover {
  transform: translateY(-1px);
  box-shadow: 0 10px 20px rgba(247, 213, 141, 0.3);
}

.mode-label {
  display: block;
  margin: 12px 0 8px;
  color: var(--muted);
  font-size: 0.95rem;
}

select {
  width: 100%;
  border: 1px solid var(--panel-border);
  border-radius: 12px;
  padding: 12px 14px;
  background: #171f32;
  color: var(--text);
  font: inherit;
  cursor: pointer;
}

select:focus-visible {
  outline: 3px solid var(--gold);
  outline-offset: 3px;
}

.rating-note {
  margin: 10px 0 0;
  color: var(--muted);
  font-size: 0.82rem;
  line-height: 1.45;
}

.chessboard {
  width: min(100%, 720px, max(280px, calc(100vh - 260px)));
  aspect-ratio: 1;
  border-collapse: collapse;
  border-radius: 18px;
  overflow: hidden;
  border: 8px solid rgba(17, 23, 35, 0.78);
  box-shadow: 0 20px 30px rgba(0, 0, 0, 0.18);
}

.square {
  width: 12.5%;
  height: 12.5%;
  position: relative;
  text-align: center;
  font-size: clamp(2rem, 3.5vw, 4rem);
  line-height: 1;
  user-select: none;
  cursor: pointer;
  transition: filter 0.2s ease, box-shadow 0.2s ease;
}

.square:hover {
  filter: brightness(1.06);
}

.square:focus-visible {
  outline: 4px solid #f7d58d;
  outline-offset: -5px;
  z-index: 1;
}

.square.selected {
  box-shadow: inset 0 0 0 5px rgba(255, 224, 105, 0.9);
}

.square.legal-move::after,
.square.legal-capture::after {
  content: "";
  position: absolute;
  z-index: 1;
  pointer-events: none;
}

.square.legal-move::after {
  width: 24%;
  aspect-ratio: 1;
  top: 38%;
  left: 38%;
  border-radius: 50%;
  background: rgba(35, 45, 34, 0.35);
}

.square.legal-capture::after {
  inset: 4px;
  border: 5px solid rgba(190, 53, 45, 0.68);
  border-radius: 50%;
}

.square.in-check {
  background-image: radial-gradient(circle, rgba(234, 72, 64, 0.75), transparent 72%);
}

.piece {
  position: relative;
  z-index: 2;
  cursor: grab;
}

.piece:active {
  cursor: grabbing;
}

.square.drag-over {
  box-shadow: inset 0 0 0 5px rgba(255, 224, 105, 0.9);
}

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

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

.piece {
  display: inline-block;
  filter: drop-shadow(0 5px 8px rgba(0, 0, 0, 0.25));
}

.piece.white {
  color: #f7f7f5;
}

.piece.black {
  color: #121212;
}

.info-panel {
  display: grid;
  gap: 18px;
}

.info-card {
  border-radius: 22px;
  padding: 20px 18px;
}

.meta-list {
  list-style: none;
  padding: 0;
  margin: 18px 0 0;
  display: grid;
  gap: 12px;
}

.meta-list li {
  display: flex;
  justify-content: space-between;
  gap: 14px;
  color: var(--muted);
  border-bottom: 1px solid rgba(255, 255, 255, 0.08);
  padding-bottom: 10px;
}

.meta-list li:last-child {
  border-bottom: none;
  padding-bottom: 0;
}

.meta-list strong {
  color: var(--text);
}

.info-card p:last-child {
  margin-bottom: 0;
  color: var(--muted);
  line-height: 1.6;
}

@media (max-width: 760px) {
  .hero {
    flex-direction: column;
    align-items: flex-start;
  }

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

  .page-shell {
    padding-top: 20px;
  }
}