* {
  margin: 0;
  padding: 0;
  box-sizing: border-box;
}

:root {
  --bg-primary: #0f0f1a;
  --bg-secondary: #161625;
  --bg-panel: #1c1c30;
  --bg-button: #252540;
  --bg-button-hover: #33335a;
  --text-primary: #e8e6df;
  --text-secondary: #9896a8;
  --text-muted: #5f5d72;
  --accent-gold: #d4a843;
  --accent-green: #5cb85c;
  --accent-red: #d9534f;
  --accent-blue: #5bc0de;
  --board-light: #F0D9B5;
  --board-dark: #B58863;
  --border: #2a2a45;
}

body {
  background: var(--bg-primary);
  background-image: 
    radial-gradient(ellipse at 20% 50%, rgba(212, 168, 67, 0.03) 0%, transparent 50%),
    radial-gradient(ellipse at 80% 20%, rgba(91, 192, 222, 0.03) 0%, transparent 50%);
  color: var(--text-primary);
  font-family: 'IBM Plex Mono', monospace;
  min-height: 100vh;
  overflow-x: hidden;
}

#app {
  max-width: 1100px;
  margin: 0 auto;
  padding: 12px 16px;
}

header {
  text-align: center;
  padding: 16px 0 12px;
  border-bottom: 1px solid var(--border);
  margin-bottom: 16px;
}

header h1 {
  font-family: 'Crimson Pro', serif;
  font-size: 1.6rem;
  font-weight: 700;
  color: var(--text-primary);
  letter-spacing: 0.5px;
}

header .header-dash {
  color: var(--text-muted);
}

header .header-sub {
  font-size: 1rem;
  font-weight: 400;
  color: var(--accent-gold);
}

header .subtitle {
  font-size: 0.75rem;
  color: var(--text-secondary);
  margin-top: 4px;
  font-weight: 300;
}

#main-layout {
  display: flex;
  gap: 20px;
  align-items: flex-start;
  justify-content: center;
}

#board-container {
  flex-shrink: 0;
  position: relative;
}

#canvas {
  display: block;
  cursor: pointer;
  border-radius: 4px;
  box-shadow: 0 4px 30px rgba(0, 0, 0, 0.5);
}

#info-panel {
  flex: 1;
  max-width: 300px;
  min-width: 220px;
  display: flex;
  flex-direction: column;
  gap: 12px;
}

#turn-indicator {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px 14px;
  background: var(--bg-panel);
  border: 1px solid var(--border);
  border-radius: 6px;
  font-size: 0.9rem;
  font-weight: 600;
}

#turn-icon {
  font-size: 1.4rem;
  transition: color 0.3s;
}

#turn-icon.white {
  color: #f0f0f0;
  text-shadow: 0 0 6px rgba(255,255,255,0.4);
}

#turn-icon.black {
  color: #333;
  text-shadow: 0 0 6px rgba(0,0,0,0.6);
}

#game-status {
  font-size: 0.85rem;
  font-weight: 700;
  padding: 0 2px;
  min-height: 0;
  transition: all 0.3s;
}

#game-status.check {
  color: var(--accent-red);
}

#game-status.checkmate {
  color: var(--accent-gold);
  font-size: 1rem;
}

#game-status.draw {
  color: var(--accent-blue);
}

#captured-area {
  background: var(--bg-panel);
  border: 1px solid var(--border);
  border-radius: 6px;
  padding: 10px 12px;
}

.captured-row {
  display: flex;
  align-items: center;
  gap: 6px;
  margin-bottom: 4px;
}

.captured-row:last-child {
  margin-bottom: 0;
}

.captured-label {
  font-size: 0.7rem;
  color: var(--text-muted);
  white-space: nowrap;
}

.captured-pieces {
  font-size: 1.1rem;
  letter-spacing: 1px;
  line-height: 1.3;
  word-break: break-all;
}

#move-history-container {
  background: var(--bg-panel);
  border: 1px solid var(--border);
  border-radius: 6px;
  flex: 1;
  min-height: 120px;
  max-height: 260px;
  display: flex;
  flex-direction: column;
  overflow: hidden;
}

.move-history-label {
  font-size: 0.7rem;
  color: var(--text-muted);
  padding: 8px 12px 4px;
  text-transform: uppercase;
  letter-spacing: 1px;
}

#move-history {
  flex: 1;
  overflow-y: auto;
  padding: 4px 12px 8px;
  font-size: 0.78rem;
  line-height: 1.7;
  color: var(--text-secondary);
}

#move-history::-webkit-scrollbar {
  width: 4px;
}

#move-history::-webkit-scrollbar-track {
  background: transparent;
}

#move-history::-webkit-scrollbar-thumb {
  background: var(--border);
  border-radius: 2px;
}

.move-number {
  color: var(--text-muted);
  margin-right: 4px;
}

.move-entry {
  display: inline;
}

#controls {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 8px;
}

#controls button {
  font-family: 'IBM Plex Mono', monospace;
  font-size: 0.75rem;
  font-weight: 600;
  padding: 10px 8px;
  background: var(--bg-button);
  color: var(--text-primary);
  border: 1px solid var(--border);
  border-radius: 6px;
  cursor: pointer;
  transition: all 0.15s;
}

#controls button:hover {
  background: var(--bg-button-hover);
  border-color: var(--accent-gold);
  color: var(--accent-gold);
}

#controls button:active {
  transform: scale(0.97);
}

#btn-ai.ai-on {
  border-color: var(--accent-green);
  color: var(--accent-green);
}

/* Promotion Modal */
.modal {
  position: fixed;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  background: rgba(0, 0, 0, 0.7);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 999;
}

.modal.hidden {
  display: none;
}

.modal-content {
  background: var(--bg-panel);
  border: 2px solid var(--accent-gold);
  border-radius: 10px;
  padding: 20px 24px;
  text-align: center;
}

.modal-title {
  font-size: 1rem;
  font-weight: 700;
  margin-bottom: 16px;
  color: var(--accent-gold);
}

#promotion-choices {
  display: flex;
  gap: 12px;
  justify-content: center;
}

#promotion-choices button {
  font-size: 2.4rem;
  width: 60px;
  height: 60px;
  background: var(--bg-button);
  border: 2px solid var(--border);
  border-radius: 8px;
  cursor: pointer;
  transition: all 0.15s;
  display: flex;
  align-items: center;
  justify-content: center;
}

#promotion-choices button:hover {
  background: var(--bg-button-hover);
  border-color: var(--accent-gold);
  transform: scale(1.1);
}

footer {
  text-align: center;
  padding: 20px 0 12px;
  margin-top: 20px;
  border-top: 1px solid var(--border);
  font-size: 0.7rem;
  color: var(--text-muted);
}

footer p {
  margin: 4px 0;
}

footer a {
  color: var(--accent-gold);
  text-decoration: none;
}

footer a:hover {
  text-decoration: underline;
}

footer .dedication {
  font-style: italic;
  margin-top: 6px;
}

@media (max-width: 720px) {
  #main-layout {
    flex-direction: column;
    align-items: center;
  }

  #info-panel {
    max-width: 100%;
    width: 100%;
  }

  #move-history-container {
    max-height: 150px;
  }

  header h1 {
    font-size: 1.2rem;
  }

  header .header-sub {
    font-size: 0.85rem;
  }
}