* { box-sizing: border-box; }
html, body { margin: 0; padding: 0; min-height: 100%; }
body {
  font-family: "Inter", system-ui, sans-serif;
  background: radial-gradient(1200px 800px at 20% -10%, #2a2320 0%, #0f0f12 50%, #09090b 100%);
  color: #ece6db;
}
h1, h2, h3 { font-family: "Playfair Display", serif; margin: 0; }
button, select, input { font: inherit; }

.screen { min-height: 100vh; padding: 24px; }

.home-wrap {
  max-width: 1120px;
  margin: 0 auto;
  min-height: calc(100vh - 48px);
  display: grid;
  place-items: center;
  gap: 28px;
}
.brand { text-align: center; }
.brand h1 { font-size: clamp(52px, 10vw, 96px); letter-spacing: 0.08em; color: #f3e7d0; }
.brand p { color: #c4b8a5; margin-top: 8px; }
.mode-cards {
  width: min(900px, 95vw);
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 18px;
}
.mode-card {
  border: 1px solid #3b3126;
  background: linear-gradient(145deg, rgba(212, 168, 67, 0.08), rgba(255, 255, 255, 0.02));
  padding: 28px;
  border-radius: 14px;
  color: #f3e7d0;
  text-align: left;
  cursor: pointer;
  transition: transform 150ms ease, box-shadow 150ms ease, border-color 150ms ease;
}
.mode-card:hover {
  transform: translateY(-3px);
  border-color: #d4a843;
  box-shadow: 0 10px 28px rgba(0, 0, 0, 0.35);
}
.mode-card h2 { margin-bottom: 8px; }
.mode-card p { color: #bba88d; margin: 0; }

.game-layout {
  max-width: 1180px;
  margin: 0 auto;
  display: grid;
  grid-template-columns: minmax(280px, 560px) minmax(280px, 1fr);
  gap: 18px;
}
.breadcrumb { color: #c7bca8; margin-bottom: 10px; }

.board-wrap {
  position: relative;
  width: min(560px, 95vw);
  aspect-ratio: 1 / 1;
}
.board {
  width: 100%;
  height: 100%;
  display: grid;
  grid-template-columns: repeat(8, 1fr);
  grid-template-rows: repeat(8, 1fr);
  border-radius: 12px;
  overflow: hidden;
  border: 2px solid #3f2f1d;
  box-shadow: 0 16px 32px rgba(0, 0, 0, 0.4);
}
.square { position: relative; display: grid; place-items: center; user-select: none; }
.square.light { background: #f0d9b5; color: #2a2a2a; }
.square.dark { background: #b58863; color: #1f1710; }
.piece {
  font-size: clamp(28px, 6vw, 54px);
  line-height: 1;
  cursor: grab;
  transition: transform 150ms ease;
  z-index: 2;
}
.piece:active { cursor: grabbing; transform: scale(1.06); }
.selected { outline: 3px solid #d4a843; outline-offset: -3px; }
.move-target::after {
  content: "";
  width: 28%;
  aspect-ratio: 1;
  border-radius: 999px;
  background: rgba(212, 168, 67, 0.6);
  position: absolute;
}
.capture-target::after {
  content: "";
  position: absolute;
  inset: 12%;
  border-radius: 999px;
  border: 3px solid rgba(212, 168, 67, 0.85);
}
.last-move { box-shadow: inset 0 0 0 100vmax rgba(212, 168, 67, 0.17); }
.in-check { box-shadow: inset 0 0 0 100vmax rgba(255, 62, 62, 0.28); }
.coord {
  position: absolute;
  font-size: 11px;
  font-weight: 600;
  opacity: 0.85;
}
.coord.rank { top: 5px; left: 6px; }
.coord.file { bottom: 5px; right: 6px; }

.side-panel {
  background: rgba(18, 18, 22, 0.8);
  border: 1px solid #2c2620;
  border-radius: 12px;
  padding: 14px;
  display: grid;
  gap: 12px;
}
.turn-indicator {
  display: flex;
  align-items: center;
  gap: 10px;
  font-weight: 600;
}
.dot {
  width: 12px; height: 12px; border-radius: 999px; display: inline-block;
  border: 1px solid rgba(255,255,255,0.45);
}
.dot.white { background: #f4f0e8; }
.dot.black { background: #242424; }

.captured { display: grid; gap: 6px; }
.captured .row {
  min-height: 30px;
  padding: 6px 8px;
  border-radius: 8px;
  background: rgba(255,255,255,0.03);
}

.history {
  border: 1px solid #2e2b24;
  border-radius: 8px;
  overflow: hidden;
}
.history h3 { padding: 10px 12px; border-bottom: 1px solid #2e2b24; font-size: 16px; }
.moves {
  max-height: 220px;
  overflow: auto;
  padding: 10px;
  font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  display: grid;
  gap: 3px;
}
.move-row {
  display: grid;
  grid-template-columns: 38px 1fr 1fr;
  gap: 8px;
  font-size: 13px;
}

.controls {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 8px;
}
.controls button, .toolbar button {
  background: #201a14;
  color: #e8dcc7;
  border: 1px solid #3f3224;
  border-radius: 8px;
  padding: 10px 12px;
  cursor: pointer;
}
.controls button:hover, .toolbar button:hover {
  border-color: #d4a843;
}

.toolbar {
  display: flex;
  align-items: center;
  gap: 10px;
  justify-content: space-between;
  flex-wrap: wrap;
}
.toolbar .left, .toolbar .right { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; }
select {
  background: #17171b;
  color: #eee5d4;
  border: 1px solid #46372b;
  border-radius: 8px;
  padding: 8px 10px;
}
.thinking {
  display: flex;
  gap: 8px;
  align-items: center;
  color: #d4a843;
  font-weight: 600;
}
.pulse {
  width: 10px; height: 10px; border-radius: 999px; background: #d4a843;
  animation: pulse 1s ease infinite;
}
@keyframes pulse {
  0% { transform: scale(0.8); opacity: 0.45; }
  50% { transform: scale(1.2); opacity: 1; }
  100% { transform: scale(0.8); opacity: 0.45; }
}

.modal {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.56);
  backdrop-filter: blur(4px);
  display: grid;
  place-items: center;
  z-index: 20;
}
.modal-card {
  width: min(92vw, 440px);
  background: #121217;
  border: 1px solid #3f3326;
  border-radius: 12px;
  padding: 18px;
  text-align: center;
  display: grid;
  gap: 12px;
}
.modal-actions {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 10px;
}
.modal-actions button {
  background: #211a14;
  border: 1px solid #453426;
  color: #e7dac4;
  padding: 10px 12px;
  border-radius: 8px;
}
.promo-grid {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 10px;
}
.promo-btn {
  font-size: 28px;
  border-radius: 8px;
  padding: 8px;
  background: #19191f;
  color: #efe7d8;
  border: 1px solid #3f3326;
}

.overlay {
  position: absolute;
  inset: 0;
  display: grid;
  place-items: center;
  background: rgba(0,0,0,0.65);
  backdrop-filter: blur(6px);
  color: #f1e4cb;
  font-size: 22px;
  font-weight: 700;
  z-index: 15;
}

[hidden] { display: none !important; }

@media (max-width: 940px) {
  .game-layout { grid-template-columns: 1fr; }
  .board-wrap { width: min(100vw - 24px, 560px); margin: 0 auto; }
  .controls { grid-template-columns: repeat(2, 1fr); }
}
@media (max-width: 680px) {
  .mode-cards { grid-template-columns: 1fr; }
  .controls { grid-template-columns: 1fr; }
  .toolbar { position: sticky; bottom: 0; padding: 8px; background: rgba(12,12,15,0.9); border-radius: 10px; }
}

