:root {
  --bg: #0f1115;
  --panel: #171a21;
  --text: #e8e8e8;
  --muted: #9aa0a6;
  --accent: #4fc3f7;
  --square-light: #f0d9b5;
  --square-dark: #b58863;
}

* { box-sizing: border-box; }
html, body { height: 100%; }
body { margin: 0; background: var(--bg); color: var(--text); font-family: system-ui, -apple-system, Segoe UI, Roboto, Ubuntu, Cantarell, Arial; }

.topbar { display: flex; align-items: center; justify-content: space-between; gap: 12px; padding: 12px 16px; background: var(--panel); border-bottom: 1px solid #2b3140; }
.topbar .btn { color: var(--text); text-decoration: none; background: #2b3140; padding: 8px 12px; border-radius: 8px; display: inline-block; }

.layout { display: grid; gap: 16px; padding: 16px; }
.layout.three { grid-template-columns: 300px 1fr 320px; }

.board-wrapper { position: relative; width: min(86vh, 86vw); aspect-ratio: 1; border: 4px solid #2b3140; border-radius: 10px; overflow: hidden; margin: 0 auto; background: #222; }
.board { display: grid; grid-template-columns: repeat(8, 1fr); grid-template-rows: repeat(8, 1fr); width: 100%; height: 100%; }
.square { position: relative; display: grid; place-items: center; border: 1px solid rgba(0,0,0,0.1); }
.square.light { background: var(--square-light); }
.square.dark { background: var(--square-dark); }
.square .piece { width: 78%; height: 78%; object-fit: contain; pointer-events: none; user-select: none; }
.square .coord { position: absolute; right: 4px; bottom: 2px; font-size: 11px; font-weight: 700; user-select: none; }
.square.light .coord { color: rgba(0,0,0,0.75); text-shadow: 0 1px 1px rgba(255,255,255,0.35); }
.square.dark .coord { color: rgba(255,255,255,0.9); text-shadow: 0 1px 1px rgba(0,0,0,0.6); }
.square.highlight { box-shadow: inset 0 0 0 4px rgba(79,195,247,0.55); }
.square.move-src { box-shadow: inset 0 0 0 4px #ffca28; }
.square.move-dst { box-shadow: inset 0 0 0 4px #29b6f6; }
.square.in-check { box-shadow: inset 0 0 0 4px rgba(244,67,54,0.85); }

.notations { pointer-events: none; }
.letters { position: absolute; bottom: -26px; left: 0; width: 100%; display: grid; grid-template-columns: repeat(8, 1fr); text-align: center; color: var(--muted); font-weight: 700; }
.numbers { position: absolute; top: 0; left: -26px; height: 100%; display: grid; grid-auto-rows: 1fr; align-content: space-between; justify-items: center; color: var(--muted); font-weight: 700; }

.left-tools { display: grid; gap: 16px; align-content: start; }
.center { display: grid; gap: 10px; align-content: start; justify-items: center; }
.right-info { display: grid; gap: 16px; align-content: start; }
.result-box { background: var(--panel); border: 1px solid #2b3140; border-radius: 10px; padding: 14px; }
.result { color: var(--text); }
.palette, .settings, .suggestions, .moves { background: var(--panel); border: 1px solid #2b3140; border-radius: 10px; padding: 14px; }
.palette h3, .settings h3, .suggestions h3, .moves h3 { margin: 0 0 10px; font-size: 16px; }
.pieces { display: grid; grid-template-columns: repeat(6, 1fr); gap: 8px; }
.pieces img { width: 46px; height: 46px; background: #1118; border-radius: 6px; padding: 4px; cursor: grab; }
.pieces img:active { cursor: grabbing; }
.palette-actions { display: flex; gap: 10px; margin-top: 10px; }

.group { display: grid; gap: 8px; margin-bottom: 12px; }
label { color: var(--muted); font-size: 12px; }
select, button { background: #262c3a; color: var(--text); border: 1px solid #2b3140; border-radius: 8px; padding: 8px 10px; }
button.btn { cursor: pointer; }
button.primary { background: #1085ff; border-color: #1085ff; }
small.muted { color: var(--muted); }

.thinking { display: flex; gap: 8px; align-items: center; justify-content: center; padding: 8px; }
.spinner { width: 16px; height: 16px; border: 2px solid rgba(255,255,255,0.3); border-top-color: #fff; border-radius: 50%; animation: spin 1s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }

.moves ol, #movesList { margin: 0; padding-left: 18px; max-height: 300px; overflow-y: auto; overflow-x: hidden; }

.context-menu { position: fixed; z-index: 10000; background: var(--panel); border: 1px solid #2b3140; border-radius: 8px; padding: 6px; box-shadow: 0 6px 18px rgba(0,0,0,0.4); }
.context-menu .btn { background: #2b3140; }

@media (max-width: 1100px) {
  .layout.three { grid-template-columns: 1fr; }
  .board-wrapper { width: 92vw; }
}


