/* SECTION: Design Tokens */
:root {
  /* Palette */
  --color-bg: #050814;
  --color-bg-elevated: #090d1f;
  --color-bg-soft: #11162a;
  --color-border-subtle: rgba(255, 255, 255, 0.08);
  --color-border-strong: rgba(255, 255, 255, 0.18);

  --color-text: #f5f6ff;
  --color-text-soft: #a9b0d9;
  --color-text-muted: #737aa2;
  --color-accent: #ff6b3d;
  --color-accent-soft: rgba(255, 107, 61, 0.14);
  --color-accent-strong: #ffb347;

  --color-square-light: #f0d9b5;
  --color-square-dark: #b58863;
  --color-square-highlight: #ffecb3;
  --color-square-move: rgba(157, 255, 157, 0.7);
  --color-square-capture: rgba(255, 107, 61, 0.7);

  --shadow-soft: 0 18px 45px rgba(0, 0, 0, 0.7);
  --shadow-subtle: 0 10px 25px rgba(0, 0, 0, 0.55);

  --radius-lg: 24px;
  --radius-md: 18px;
  --radius-pill: 999px;

  --font-sans: "Space Grotesk", system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;

  --transition-fast: 150ms ease-out;
  --transition-med: 200ms ease;
}

*,
*::before,
*::after {
  box-sizing: border-box;
}

body {
  margin: 0;
  min-height: 100vh;
  font-family: var(--font-sans);
  background: radial-gradient(circle at top, #1e284b 0, #050814 45%, #020308 100%);
  color: var(--color-text);
  display: flex;
  align-items: stretch;
  justify-content: center;
}

/* SECTION: App Shell */
.app {
  max-width: 1040px;
  width: 100%;
  margin: 20px;
  padding: 20px 20px 16px;
  background: linear-gradient(135deg, rgba(255, 255, 255, 0.02), rgba(255, 255, 255, 0));
  border-radius: 28px;
  border: 1px solid rgba(255, 255, 255, 0.06);
  box-shadow: var(--shadow-soft);
  backdrop-filter: blur(28px);
  display: flex;
  flex-direction: column;
  gap: 18px;
}

.app-header {
  display: flex;
  flex-wrap: wrap;
  gap: 16px 28px;
  align-items: center;
  justify-content: space-between;
}

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

.brand-mark {
  width: 44px;
  height: 44px;
  border-radius: 18px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 28px;
  background: radial-gradient(circle at 25% 0, #fff7e6, #ffb347 38%, #ff6b3d 60%, #b52b3a 100%);
  box-shadow: 0 16px 35px rgba(0, 0, 0, 0.75);
}

.brand-title {
  margin: 0;
  font-size: 1.6rem;
  letter-spacing: -0.02em;
}

.brand-subtitle {
  margin: 2px 0 0;
  font-size: 0.86rem;
  color: var(--color-text-soft);
}

/* SECTION: Mode Panel */
.mode-panel {
  background: var(--color-bg-elevated);
  border-radius: var(--radius-lg);
  padding: 10px 14px;
  border: 1px solid var(--color-border-subtle);
  display: flex;
  flex-direction: column;
  gap: 8px;
  box-shadow: var(--shadow-subtle);
}

.mode-row {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 14px 18px;
}

.mode-row--secondary {
  justify-content: flex-end;
}

.field-group {
  display: flex;
  flex-direction: column;
  gap: 4px;
}

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

.pill-toggle {
  display: inline-flex;
  padding: 3px;
  border-radius: 999px;
  background: rgba(8, 12, 29, 0.92);
  border: 1px solid var(--color-border-subtle);
  gap: 2px;
}

.pill-toggle__option {
  border: none;
  background: transparent;
  color: var(--color-text-soft);
  padding: 6px 10px;
  border-radius: 999px;
  font-size: 0.78rem;
  font-weight: 500;
  cursor: pointer;
  transition: background var(--transition-fast), color var(--transition-fast), transform var(--transition-fast), box-shadow var(--transition-fast);
}

.pill-toggle__option:hover {
  background: rgba(255, 255, 255, 0.06);
}

.pill-toggle__option.is-active {
  background: radial-gradient(circle at top, var(--color-accent-strong), var(--color-accent));
  color: #130a05;
  box-shadow: 0 0 0 1px rgba(0, 0, 0, 0.4), 0 12px 22px rgba(0, 0, 0, 0.7);
}

.pill-toggle__option:focus-visible {
  outline: 2px solid var(--color-accent-strong);
  outline-offset: 2px;
}

/* SECTION: Buttons */
.btn {
  border-radius: var(--radius-pill);
  border: 1px solid transparent;
  font-family: inherit;
  font-size: 0.78rem;
  padding: 7px 14px;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  background: var(--color-accent);
  color: #140903;
  font-weight: 600;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  transition: transform var(--transition-fast), box-shadow var(--transition-fast), background var(--transition-fast), border-color var(--transition-fast), color var(--transition-fast);
}

.btn:hover {
  transform: translateY(-1px);
  box-shadow: 0 10px 22px rgba(0, 0, 0, 0.7);
}

.btn:active {
  transform: translateY(0);
  box-shadow: none;
}

.btn-outline {
  background: transparent;
  color: var(--color-text-soft);
  border-color: var(--color-border-strong);
}

.btn-outline:hover {
  background: rgba(255, 255, 255, 0.04);
}

.btn-ghost {
  background: rgba(255, 255, 255, 0.05);
  color: var(--color-text);
  border-color: transparent;
}

.btn-ghost:hover {
  background: rgba(255, 255, 255, 0.09);
}

.btn-inline {
  background: transparent;
  border-color: transparent;
  color: var(--color-text-muted);
  padding-inline: 0;
}

.btn-inline:hover {
  color: var(--color-accent-strong);
}

/* SECTION: Main Layout */
.app-main {
  display: grid;
  grid-template-columns: minmax(0, 1.2fr) minmax(260px, 0.9fr);
  gap: 20px;
}

.board-panel {
  background: var(--color-bg-elevated);
  border-radius: var(--radius-lg);
  border: 1px solid var(--color-border-subtle);
  padding: 14px 14px 16px;
  box-shadow: var(--shadow-subtle);
}

.board-shell {
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.board-coords {
  display: grid;
  grid-template-columns: repeat(8, 1fr);
  font-size: 0.7rem;
  color: var(--color-text-muted);
  padding-inline: 18px;
}

.board-and-ranks {
  display: grid;
  grid-template-columns: 16px minmax(0, 1fr) 16px;
  gap: 4px;
}

.board-ranks {
  display: grid;
  grid-template-rows: repeat(8, 1fr);
  font-size: 0.7rem;
  color: var(--color-text-muted);
  align-items: center;
  justify-items: center;
}

.board {
  aspect-ratio: 1 / 1;
  border-radius: 18px;
  overflow: hidden;
  display: grid;
  grid-template-columns: repeat(8, 1fr);
  grid-template-rows: repeat(8, 1fr);
  box-shadow: 0 18px 35px rgba(0, 0, 0, 0.85);
}

.square {
  position: relative;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 1.9rem;
  cursor: pointer;
  transition: background var(--transition-med), box-shadow var(--transition-med), transform var(--transition-fast);
}

.square--light {
  background: var(--color-square-light);
}

.square--dark {
  background: var(--color-square-dark);
}

.square--selected {
  box-shadow: inset 0 0 0 3px var(--color-accent);
}

.square--move::after,
.square--capture::after {
  content: "";
  position: absolute;
  border-radius: 999px;
}

.square--move::after {
  width: 22px;
  height: 22px;
  background: var(--color-square-move);
  box-shadow: 0 0 0 1px rgba(0, 0, 0, 0.32);
}

.square--capture::after {
  width: 80%;
  height: 80%;
  border: 3px solid var(--color-square-capture);
}

.square:hover {
  transform: translateY(-1px);
}

.piece {
  pointer-events: none;
  font-size: 2.1rem;
  text-shadow: 0 2px 2px rgba(0, 0, 0, 0.7);
}

/* Make white and black pieces visually distinct */
.square--light .piece[data-color="white"],
.square--dark .piece[data-color="white"] {
  color: #ffffff;
}

.square--light .piece[data-color="black"],
.square--dark .piece[data-color="black"] {
  color: #000000;
}

/* SECTION: Sidebar */
.side-panel {
  display: flex;
  flex-direction: column;
  gap: 14px;
}

.status-card {
  background: var(--color-bg-soft);
  padding: 12px 14px;
  border-radius: var(--radius-md);
  border: 1px solid var(--color-border-subtle);
  box-shadow: 0 12px 26px rgba(0, 0, 0, 0.7);
}

.panel-title {
  margin: 0 0 8px;
  font-size: 0.9rem;
  text-transform: uppercase;
  letter-spacing: 0.16em;
  color: var(--color-text-muted);
}

.status-line {
  display: flex;
  justify-content: space-between;
  align-items: center;
  font-size: 0.82rem;
  margin: 3px 0;
  color: var(--color-text-soft);
}

.status-label {
  color: var(--color-text-muted);
}

.pill {
  border-radius: 999px;
  padding: 3px 9px;
  background: rgba(255, 255, 255, 0.04);
  font-size: 0.74rem;
}

#turn-indicator {
  background: linear-gradient(135deg, #ffffff, #ffd68e);
  color: #120805;
  font-weight: 600;
}

.status-message {
  margin-top: 8px;
  font-size: 0.8rem;
  min-height: 1.1em;
  color: var(--color-accent-strong);
}

.winner-card {
  background: radial-gradient(circle at top, rgba(255, 255, 255, 0.12), rgba(255, 255, 255, 0.02));
  border-color: var(--color-accent-strong);
  box-shadow: 0 18px 40px rgba(0, 0, 0, 0.85);
  text-align: left;
}

.winner-message {
  margin: 4px 0 10px;
  font-size: 0.9rem;
  font-weight: 600;
  color: var(--color-text);
}

.move-log {
  max-height: 210px;
  overflow: auto;
  padding: 8px 10px;
  margin: 4px 0 8px;
  border-radius: 10px;
  background: rgba(4, 7, 20, 0.9);
  border: 1px solid rgba(255, 255, 255, 0.04);
  font-size: 0.78rem;
}

.move-log-entry {
  display: flex;
  justify-content: space-between;
  margin-bottom: 4px;
}

.move-log-entry span:nth-child(1) {
  color: var(--color-text-muted);
  margin-right: 6px;
}

.app-footer {
  margin-top: 2px;
  font-size: 0.8rem;
  color: var(--color-text-muted);
  display: flex;
  justify-content: space-between;
  gap: 8px;
}

/* SECTION: Responsive */
@media (max-width: 840px) {
  .app {
    margin: 10px;
    padding: 14px 14px 10px;
  }

  .app-main {
    grid-template-columns: minmax(0, 1fr);
  }

  .side-panel {
    flex-direction: row;
  }
 
  .status-card {
    flex: 1;
  }
}
 
@media (max-width: 720px) {
  .app {
    margin: 6px;
    padding: 10px;
  }

  .brand-title {
    font-size: 1.3rem;
  }

  .brand-subtitle {
    font-size: 0.78rem;
  }

  .mode-panel {
    padding: 8px 10px;
  }

  .board-panel {
    padding: 10px;
  }

  .board-coords {
    padding-inline: 10px;
    font-size: 0.6rem;
  }

  .board-and-ranks {
    grid-template-columns: 12px minmax(0, 1fr) 12px;
  }

  .board-ranks {
    font-size: 0.6rem;
  }

  .square {
    font-size: 1.6rem;
  }

  .piece {
    font-size: 1.8rem;
  }

  .move-log {
    max-height: 160px;
  }
}
 
@media (max-width: 640px) {
  .app-header {

    flex-direction: column;
    align-items: stretch;
  }

  .mode-panel {
    width: 100%;
  }

  .mode-row--secondary {
    justify-content: flex-start;
  }

  .side-panel {
    flex-direction: column;
  }

  .board {
    font-size: 1.5rem;
  }
}
