:root {
  --bg: #030712;
  --bg-soft: #16282b;
  --panel: rgba(15,23,42,0.85);
  --panel-strong: rgba(17,24,39,0.95);
  --text: #f5f7fa;
  --muted: #a7b0bc;
  --accent: #3b82f6;
  --accent-strong: #2563eb;
  --accent-soft: rgba(157, 92, 47, 0.12);
  --light-square: #d8c3a5;
  --dark-square: #8d6e63;
  --selected: #2d6a4f;
  --last-move: rgba(255, 208, 109, 0.5);
  --danger: #a43a2b;
  --success: #2d6a4f;
  --shadow: 0 24px 60px rgba(0, 0, 0, 0.24);
  --radius: 24px;
  --serif: "Times New Roman", serif;
  --sans: "Trebuchet MS", "Gill Sans", sans-serif;
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  min-height: 100vh;
  font-family: "Inter", sans-serif;
  color: #fefcf4;
  background:
    radial-gradient(circle at top left, rgba(214, 144, 71, 0.18), transparent 36%),
    radial-gradient(circle at bottom right, rgba(132, 55, 28, 0.22), transparent 32%),
    linear-gradient(135deg, #102024 0%, #162d31 52%, #091012 100%);
}

button,
input,
select {
  font: inherit;
}

.page-shell {
  width: min(1600px, calc(100% - 32px));
  margin: 0 auto;
  padding: 28px 0 36px;
}

.hero {
  display: grid;
  grid-template-columns: 1.2fr 0.8fr;
  gap: 20px;
  margin-bottom: 24px;
  padding: 26px 30px;
  border: 1px solid rgba(255, 255, 255, 0.12);
  border-radius: calc(var(--radius) + 6px);
  background: linear-gradient(135deg, rgba(255, 245, 227, 0.12), rgba(255, 255, 255, 0.04));
  box-shadow: var(--shadow);
  backdrop-filter: blur(12px);
}

.eyebrow,
.label {
  margin: 0 0 6px;
  font-size: 0.78rem;
  letter-spacing: 0.16em;
  text-transform: uppercase;
  opacity: 0.72;
}

.hero h1 {
  margin: 0 0 12px;
  font-family: var(--serif);
  font-size: clamp(2rem, 4vw, 3.5rem);
  line-height: 1.02;
}

.hero-copy {
  max-width: 56ch;
  margin: 0;
  font-size: 1rem;
  line-height: 1.7;
  color: rgba(255, 250, 241, 0.8);
}

.hero-badges {
  display: flex;
  flex-wrap: wrap;
  align-content: flex-start;
  justify-content: flex-end;
  gap: 12px;
}

.hero-badges span,
.status-chip {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 10px 14px;
  border-radius: 999px;
  background: rgba(255, 245, 227, 0.12);
  border: 1px solid rgba(255, 255, 255, 0.12);
}

.app-grid {
  display: grid;
  grid-template-columns: minmax(0, 1.8fr) 340px;
  gap: 24px;
  align-items: start;
}

.panel {
  color: var(--text);
  backdrop-filter: blur(18px);
  background: linear-gradient(180deg, var(--panel-strong), var(--panel));
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  border: 1px solid rgba(255,255, 255, 0.08);
}

.board-panel {
  padding: 18px;
}

.board-toolbar,
.status-strip,
.panel-head,
.toolbar-actions,
.field-grid,
.join-row,
.mode-switcher,
.status-meta,
.roster-grid,
.captured-grid {
  display: flex;
  gap: 12px;
}

.board-toolbar,
.status-strip,
.panel-head {
  align-items: center;
  justify-content: space-between;
}

.panel-head h3,
.board-toolbar h2 {
  margin: 0;
  font-family: var(--serif);
}

.board-stage {
  position: relative;
  padding: 18px 0;
}

.board {
  position: relative;
  width: min(100%, 88vh);
  max-width: 900px;
  aspect-ratio: 1;
  margin: 0 auto;
  display: grid;
  grid-template-columns: repeat(8, 1fr);
  grid-template-rows: repeat(8, 1fr);
  border-radius: 32px;
  overflow: hidden;
  background: linear-gradient(145deg, #0b1220, #111827);
  padding: 18px;
  box-shadow:
    inset 0 0 0 1px rgba(255, 255, 255, 0.08),
    0 30px 80px rgba(0, 0, 0, 0.5);
}

.square {
  position: relative;
  border: 0;
  margin: 0;
  padding: 0;

  width: 100%;
  height: 100%;

  aspect-ratio: 1;

  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  transition: transform 120ms ease, filter 120ms ease;
}

.square.light {
  background: linear-gradient(145deg, #f7e5ca, var(--light-square));
}

.square.dark {
  background: linear-gradient(145deg, #c79565, var(--dark-square));
}

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

.square.selected::after,
.square.legal-target::after,
.square.last-move::before,
.square.check-square::before {
  content: "";
  position: absolute;
  inset: 10%;
  border-radius: 18px;
  pointer-events: none;
}

.square.last-move::before {
  inset: 8%;
  background: var(--last-move);
}

.square.selected::after {
  border: 4px solid rgba(45, 106, 79, 0.92);
}

.square.legal-target::after {
  inset: 36%;
  border-radius: 999px;
  background: rgba(22, 40, 43, 0.35);
}

.square.capture-target::after {
  inset: 10%;
  border: 4px solid rgba(164, 58, 43, 0.75);
  background: transparent;
}

.square.check-square::before {
  inset: 7%;
  background: rgba(164, 58, 43, 0.24);
  border: 3px solid rgba(164, 58, 43, 0.6);
}

.coordinate {
  position: absolute;
  left: 8px;
  top: 6px;
  font-size: 0.68rem;
  font-weight: 700;
  opacity: 0.45;
  text-transform: uppercase;
}

.piece {
  position: relative;
  z-index: 1;
  font-size: clamp(2rem, 5vw, 3.6rem);
  line-height: 1;
  user-select: none;
  transform: translateY(-2px);
  text-shadow: 0 4px 10px rgba(0, 0, 0, 0.18);
}

.piece.white {
  color: #ffffff;
  text-shadow: 0 0 12px rgba(255,255,255,0.25), 0 4px 12px rgba(0, 0, 0, 0.4);
}

.piece.black {
  color: #0f172a;
  text-shadow: 0 3px 10px rgba(0, 0, 0, 0.5);
}

.status-message,
.muted-copy {
  margin: 0;
  line-height: 1.6;
  color: var(--muted);
}

.sidebar {
  display: grid;
  gap: 18px;

  position: sticky;
  top: 20px;

  align-self: start;
}

.sidebar .panel {
  padding: 18px;
}

.mode-button,
.primary-button,
.secondary-button,
.ghost-button {
  appearance: none;
  border: 0;
  border-radius: 16px;
  padding: 12px 16px;
  cursor: pointer;
  transition: transform 120ms ease, opacity 120ms ease, background 120ms ease;
}

.mode-button {
  flex: 1;
  color: var(--text);
  background: rgba(157, 92, 47, 0.08);
}

.mode-button.active {
  background: linear-gradient(135deg, #3b82f6, #2563eb);
  color: #fffaf0;
}

.primary-button {
  color: #fffaf0;
  background: linear-gradient(135deg, #3b82f6, #2563eb);
}

.secondary-button {
  color: var(--text);
  background: rgba(26, 49, 53, 0.08);
}

.ghost-button {
  color: var(--danger);
  background: rgba(164, 58, 43, 0.1);
}

.mode-button:hover,
.primary-button:hover,
.secondary-button:hover,
.ghost-button:hover,
.square:hover {
  transform: translateY(-1px);
}

.field,
.control-stack {
  display: grid;
  gap: 10px;
}

.field span {
  color: var(--muted);
  font-size: 0.92rem;
}

.field input,
.field select {
  width: 100%;
  padding: 12px 14px;
  border: 1px solid rgba(255, 255, 255, 0.1);
  border-radius: 14px;
  color: white;
  background: rgba(255, 255, 255, 0.06);
}

.control-stack {
  margin-top: 14px;
}

.join-row > * {
  flex: 1;
}

.join-row button {
  flex: 0 0 auto;
}

.roster-grid,
.captured-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
}

.roster-card,
.spectator-panel,
.captured-row,
.move-history,
.modal-card {
  border-radius: 18px;
  background: rgba(255, 252, 244, 0.04);
  border: 1px solid rgba(255,255,255,0.08);
  backdrop-filter: blur(12px);
}

.roster-card {
  padding: 14px;
}

.roster-role,
.captured-label {
  display: block;
  margin-bottom: 4px;
  font-size: 0.78rem;
  letter-spacing: 0.14em;
  text-transform: uppercase;
  color: var(--muted);
}

.spectator-panel {
  margin-top: 14px;
  padding: 14px;
}

.spectator-list,
.move-history {
  margin: 0;
  padding-left: 18px;
}

.spectator-list li,
.move-history li {
  padding: 4px 0;
  color: var(--text);
}

.captured-row {
  min-height: 52px;
  padding: 10px 12px;
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 6px;
}

.captured-piece {
  font-size: 1.55rem;
}

.move-history {
  max-height: 240px;
  overflow: auto;
  padding: 12px 18px 12px 34px;
}

.toast-host {
  position: fixed;
  top: 20px;
  right: 20px;
  display: grid;
  gap: 10px;
  z-index: 50;
}

.toast {
  min-width: 240px;
  max-width: 360px;
  padding: 14px 16px;
  border-radius: 18px;
  color: #fffaf0;
  background: rgba(15, 27, 29, 0.92);
  box-shadow: var(--shadow);
  animation: toast-in 180ms ease;
}

.toast.success {
  background: rgba(45, 106, 79, 0.96);
}

.toast.error {
  background: rgba(164, 58, 43, 0.96);
}

.modal {
  position: fixed;
  inset: 0;
  display: grid;
  place-items: center;
  padding: 24px;
  background: rgba(5, 9, 10, 0.52);
  z-index: 60;
}

.modal-card {
  width: min(100%, 420px);
  padding: 22px;
}

.promotion-options {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 10px;
  margin-top: 16px;
}

.promotion-button {
  border: 0;
  border-radius: 18px;
  background: rgba(157, 92, 47, 0.08);
  padding: 18px 0;
  font-size: 2rem;
  cursor: pointer;
}

.hidden {
  display: none !important;
}

.about-section {
  margin-top: 32px;
  padding: 28px;
}
.about-section .panel-head {
  justify-content: center;
  flex-direction: column;
  text-align: center;
}
.about-grid {
  display: grid;
  grid-template-columns: repeat(
    auto-fit,
    minmax(250px, 1fr)
  );
  gap: 20px;
}

.about-card {
  padding: 20px;
  border-radius: 16px;

  background: rgba(255,255,255,.04);

  border: 1px solid rgba(255,255,255,.08);
}

.about-card h4 {
  margin-top: 0;
}

.footer {
  text-align: center;

  padding: 40px 0 20px;

  color: rgba(255,255,255,.55);
}





@keyframes toast-in {
  from {
    opacity: 0;
    transform: translateY(-8px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

@media (max-width: 1080px) {
  .hero,
  .app-grid {
    grid-template-columns: 1fr;
  }

  .hero-badges {
    justify-content: flex-start;
  }
}

@media (max-width: 720px) {
  .page-shell {
    width: min(100% - 18px, 100%);
    padding-top: 18px;
  }

  .hero,
  .board-panel,
  .sidebar .panel {
    border-radius: 22px;
    padding: 16px;
  }

  .roster-grid,
  .captured-grid,
  .field-grid,
  .status-strip,
  .board-toolbar {
    display: grid;
    grid-template-columns: 1fr;
  }

  .board {
    padding: 10px;
    border-radius: 22px;
  }
}
