/* style.css — Chess with AI */

:root {
  color-scheme: dark;
  --bg: #14171f;
  --bg-grad-1: #1b2030;
  --bg-grad-2: #0f1218;
  --surface: #1f2530;
  --surface-2: #262d3b;
  --border: #333c4d;
  --text: #e8edf5;
  --text-dim: #9aa6bd;
  --accent: #6ea8ff;
  --accent-2: #4c7fd6;

  --sq-light: #cfd8e8;
  --sq-dark: #5b6b87;
  --w-piece: #fbfcfe;
  --w-outline: #1a1f2b;
  --b-piece: #20242e;
  --b-outline: #0a0c12;

  --hl-last: rgba(255, 213, 92, 0.32);
  --hl-check: rgba(244, 78, 78, 0.42);
  --hl-select: rgba(110, 168, 255, 0.95);
  --hl-move: rgba(110, 168, 255, 0.45);
  --hl-move-cap: rgba(244, 130, 78, 0.92);

  --btn-bg: #2a3140;
  --btn-bg-hover: #353f52;
  --btn-text: #e8edf5;
}

@media (prefers-color-scheme: light) {
  :root {
    color-scheme: light;
    --bg: #eef1f7;
    --bg-grad-1: #f6f8fc;
    --bg-grad-2: #e2e7f1;
    --surface: #ffffff;
    --surface-2: #f3f5fa;
    --border: #d6dce8;
    --text: #1f2633;
    --text-dim: #5c6679;
    --accent: #3a6fd6;
    --accent-2: #2c54a8;

    --sq-light: #e9eef7;
    --sq-dark: #7a8aab;
    --w-piece: #ffffff;
    --w-outline: #2a2f3b;
    --b-piece: #2c3240;
    --b-outline: #0a0c12;

    --hl-last: rgba(255, 196, 64, 0.45);
    --hl-check: rgba(220, 60, 60, 0.38);
    --hl-select: rgba(58, 111, 214, 0.95);
    --hl-move: rgba(58, 111, 214, 0.5);
    --hl-move-cap: rgba(220, 110, 60, 0.9);

    --btn-bg: #e6eaf3;
    --btn-bg-hover: #d8dfee;
    --btn-text: #1f2633;
  }
}

html[data-theme="dark"] {
  color-scheme: dark;
  --bg: #14171f;
  --bg-grad-1: #1b2030;
  --bg-grad-2: #0f1218;
  --surface: #1f2530;
  --surface-2: #262d3b;
  --border: #333c4d;
  --text: #e8edf5;
  --text-dim: #9aa6bd;
  --accent: #6ea8ff;
  --accent-2: #4c7fd6;
  --sq-light: #cfd8e8;
  --sq-dark: #5b6b87;
  --w-piece: #fbfcfe;
  --w-outline: #1a1f2b;
  --b-piece: #20242e;
  --b-outline: #0a0c12;
  --hl-last: rgba(255, 213, 92, 0.32);
  --hl-check: rgba(244, 78, 78, 0.42);
  --hl-select: rgba(110, 168, 255, 0.95);
  --hl-move: rgba(110, 168, 255, 0.45);
  --hl-move-cap: rgba(244, 130, 78, 0.92);
  --btn-bg: #2a3140;
  --btn-bg-hover: #353f52;
  --btn-text: #e8edf5;
}

html[data-theme="light"] {
  color-scheme: light;
  --bg: #eef1f7;
  --bg-grad-1: #f6f8fc;
  --bg-grad-2: #e2e7f1;
  --surface: #ffffff;
  --surface-2: #f3f5fa;
  --border: #d6dce8;
  --text: #1f2633;
  --text-dim: #5c6679;
  --accent: #3a6fd6;
  --accent-2: #2c54a8;
  --sq-light: #e9eef7;
  --sq-dark: #7a8aab;
  --w-piece: #ffffff;
  --w-outline: #2a2f3b;
  --b-piece: #2c3240;
  --b-outline: #0a0c12;
  --hl-last: rgba(255, 196, 64, 0.45);
  --hl-check: rgba(220, 60, 60, 0.38);
  --hl-select: rgba(58, 111, 214, 0.95);
  --hl-move: rgba(58, 111, 214, 0.5);
  --hl-move-cap: rgba(220, 110, 60, 0.9);
  --btn-bg: #e6eaf3;
  --btn-bg-hover: #d8dfee;
  --btn-text: #1f2633;
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  padding: 0;
  height: 100%;
}

body {
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
  background:
    radial-gradient(1200px 600px at 50% -10%, var(--bg-grad-1), transparent 60%),
    linear-gradient(180deg, var(--bg-grad-1), var(--bg-grad-2));
  color: var(--text);
  display: flex;
  flex-direction: column;
  align-items: center;
  min-height: 100%;
  padding: 12px;
  gap: 12px;
  -webkit-font-smoothing: antialiased;
}

#hdr {
  width: 100%;
  max-width: 760px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  flex-wrap: wrap;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 14px;
  padding: 10px 14px;
  box-shadow: 0 6px 20px rgba(0, 0, 0, 0.18);
}

.hdr-left {
  display: flex;
  align-items: center;
  gap: 10px;
  flex: 1 1 auto;
  min-width: 200px;
}

.logo {
  font-size: 26px;
  line-height: 1;
  color: var(--accent);
  filter: drop-shadow(0 2px 4px rgba(0,0,0,0.3));
}

.lvl-group {
  display: flex;
  align-items: center;
  gap: 8px;
  background: var(--surface-2);
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 5px 10px;
}

.lvl-label {
  font-size: 12px;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  color: var(--text-dim);
  font-weight: 600;
}

#diff {
  -webkit-appearance: none;
  appearance: none;
  width: 110px;
  height: 6px;
  border-radius: 6px;
  background: linear-gradient(90deg, var(--accent-2), var(--accent));
  outline: none;
  cursor: pointer;
}

#diff::-webkit-slider-thumb {
  -webkit-appearance: none;
  appearance: none;
  width: 18px;
  height: 18px;
  border-radius: 50%;
  background: var(--text);
  border: 2px solid var(--accent);
  box-shadow: 0 2px 5px rgba(0,0,0,0.35);
  transition: transform 0.12s ease;
}
#diff::-webkit-slider-thumb:hover { transform: scale(1.12); }
#diff::-moz-range-thumb {
  width: 16px;
  height: 16px;
  border-radius: 50%;
  background: var(--text);
  border: 2px solid var(--accent);
  cursor: pointer;
}

.lvl-val {
  min-width: 22px;
  text-align: center;
  font-weight: 700;
  font-variant-numeric: tabular-nums;
  color: var(--accent);
}

#status {
  font-size: 14px;
  font-weight: 600;
  color: var(--text);
  text-align: center;
  flex: 1 1 auto;
  min-width: 120px;
}

.hdr-right {
  display: flex;
  gap: 8px;
}

#hdr button {
  font: inherit;
  font-weight: 600;
  font-size: 13px;
  color: var(--btn-text);
  background: var(--btn-bg);
  border: 1px solid var(--border);
  border-radius: 9px;
  padding: 7px 14px;
  cursor: pointer;
  transition: background 0.14s ease, transform 0.12s ease, border-color 0.14s ease;
  -webkit-tap-highlight-color: transparent;
}
#hdr button:hover { background: var(--btn-bg-hover); }
#hdr button:active { transform: translateY(1px); }
#hdr button:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }

#playArea {
  width: 100%;
  max-width: 760px;
  display: flex;
  justify-content: center;
  align-items: center;
  flex: 0 1 auto;
}

#board {
  display: block;
  border-radius: 12px;
  background: var(--surface);
  box-shadow: 0 14px 40px rgba(0, 0, 0, 0.35), 0 2px 0 rgba(255,255,255,0.03) inset;
  touch-action: none;
  cursor: pointer;
}

#ftr {
  width: 100%;
  max-width: 760px;
  display: flex;
  flex-direction: column;
  gap: 8px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 10px 14px;
  font-size: 13px;
  min-height: 56px;
}

#captured {
  display: flex;
  justify-content: space-between;
  gap: 12px;
  font-size: 22px;
  line-height: 1;
  min-height: 24px;
}
#captured .wcap { color: var(--w-piece); -webkit-text-stroke: 1px var(--w-outline); letter-spacing: 2px; }
#captured .bcap { color: var(--b-piece); -webkit-text-stroke: 1px var(--b-outline); letter-spacing: 2px; }

#history {
  color: var(--text-dim);
  font-variant-numeric: tabular-nums;
  line-height: 1.5;
  max-height: 64px;
  overflow: auto;
  word-break: break-word;
}

#promo {
  position: fixed;
  inset: 0;
  display: none;
  align-items: center;
  justify-content: center;
  background: rgba(8, 10, 16, 0.66);
  backdrop-filter: blur(4px);
  z-index: 50;
  animation: fade 0.16s ease;
}
#promo.show { display: flex; }

@keyframes fade { from { opacity: 0; } to { opacity: 1; } }

#promo .promo-label {
  position: absolute;
  top: calc(50% - 120px);
  left: 50%;
  transform: translateX(-50%);
  font-size: 14px;
  font-weight: 600;
  color: var(--text);
  letter-spacing: 0.03em;
  text-transform: uppercase;
}

.promo-row {
  display: flex;
  gap: 14px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 16px;
  padding: 18px 22px;
  box-shadow: 0 18px 50px rgba(0,0,0,0.5);
}

.promo-btn {
  width: 64px;
  height: 64px;
  font-size: 46px;
  line-height: 1;
  display: flex;
  align-items: center;
  justify-content: center;
  background: var(--surface-2);
  border: 1px solid var(--border);
  border-radius: 12px;
  cursor: pointer;
  transition: transform 0.12s ease, background 0.14s ease, border-color 0.14s ease;
  -webkit-tap-highlight-color: transparent;
}
.promo-btn:hover { background: var(--btn-bg-hover); transform: translateY(-2px); }
.promo-btn:active { transform: translateY(0); }
.promo-btn:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }

@media (max-width: 480px) {
  #hdr { flex-direction: column; align-items: stretch; padding: 10px; }
  .hdr-left, .hdr-right { justify-content: center; }
  #status { text-align: center; }
  .promo-btn { width: 56px; height: 56px; font-size: 40px; }
  #ftr { font-size: 12px; }
}
