/* ============================================
   SATRANÇ USTASI - Koyu Altın Tema
   ============================================ */

:root {
  /* Renkler */
  --bg-deep: #0a0908;
  --bg-dark: #13110f;
  --bg-panel: #1a1713;
  --bg-card: #221e18;
  --bg-elevated: #2a251e;
  --border: #3a3229;
  --border-strong: #4a3f33;

  --gold: #d4af37;
  --gold-bright: #f1c85a;
  --gold-deep: #8b6f1f;
  --gold-dim: rgba(212, 175, 55, 0.25);

  --text-primary: #f0e6d2;
  --text-secondary: #a89f8c;
  --text-muted: #6b6355;
  --text-dim: #4a4437;

  --accent-green: #6b8e23;
  --accent-red: #c23b22;
  --accent-blue: #4a6fa5;

  /* Tahta renkleri */
  --sq-light: #e8d4a8;
  --sq-dark: #8b6f47;
  --sq-light-hl: #f7e89a;
  --sq-dark-hl: #b79056;
  --sq-selected: rgba(212, 175, 55, 0.55);
  --sq-move: rgba(107, 142, 35, 0.42);
  --sq-capture: rgba(194, 59, 34, 0.5);
  --sq-check: rgba(220, 38, 38, 0.65);
  --sq-last: rgba(255, 220, 100, 0.35);

  --shadow-sm: 0 2px 6px rgba(0, 0, 0, 0.3);
  --shadow-md: 0 8px 24px rgba(0, 0, 0, 0.4);
  --shadow-lg: 0 20px 60px rgba(0, 0, 0, 0.6);
  --shadow-gold: 0 0 30px rgba(212, 175, 55, 0.15);

  --font-display: 'Cormorant Garamond', Georgia, serif;
  --font-body: 'Inter', -apple-system, system-ui, sans-serif;
}

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

html, body {
  height: 100%;
  overflow: hidden;
  background: var(--bg-deep);
  color: var(--text-primary);
  font-family: var(--font-body);
  font-size: 14px;
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
}

body {
  background:
    radial-gradient(ellipse at top left, rgba(212, 175, 55, 0.06), transparent 50%),
    radial-gradient(ellipse at bottom right, rgba(139, 111, 71, 0.05), transparent 50%),
    var(--bg-deep);
  background-attachment: fixed;
}

button { font-family: inherit; cursor: pointer; border: none; outline: none; background: none; color: inherit; }

/* ============================================
   UYGULAMA DÜZENİ
   ============================================ */

.app {
  display: grid;
  grid-template-columns: 280px 1fr 300px;
  gap: 18px;
  padding: 18px;
  height: 100vh;
  max-width: 1500px;
  margin: 0 auto;
}

.panel {
  display: flex;
  flex-direction: column;
  gap: 14px;
  overflow-y: auto;
  padding-right: 4px;
}

.panel::-webkit-scrollbar { width: 6px; }
.panel::-webkit-scrollbar-track { background: transparent; }
.panel::-webkit-scrollbar-thumb { background: var(--border); border-radius: 3px; }
.panel::-webkit-scrollbar-thumb:hover { background: var(--border-strong); }

/* ============================================
   MARKA / BAŞLIK
   ============================================ */

.brand {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 14px 4px 4px;
  margin-bottom: 4px;
}

.brand-mark {
  width: 46px; height: 46px;
  background: linear-gradient(135deg, var(--gold) 0%, var(--gold-deep) 100%);
  border-radius: 10px;
  display: flex; align-items: center; justify-content: center;
  font-size: 28px;
  color: var(--bg-deep);
  box-shadow: var(--shadow-sm), inset 0 1px 0 rgba(255, 255, 255, 0.3);
}

.brand-text h1 {
  font-family: var(--font-display);
  font-size: 22px;
  font-weight: 700;
  letter-spacing: 0.3px;
  color: var(--gold-bright);
  line-height: 1;
}

.brand-text .subtitle {
  font-size: 11px;
  color: var(--text-muted);
  letter-spacing: 0.6px;
  text-transform: uppercase;
  margin-top: 3px;
}

/* ============================================
   KARTLAR
   ============================================ */

.card {
  background: linear-gradient(180deg, var(--bg-card) 0%, var(--bg-panel) 100%);
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 14px 16px;
  box-shadow: var(--shadow-sm);
}

.card h3 {
  font-size: 10px;
  text-transform: uppercase;
  letter-spacing: 1.5px;
  color: var(--text-muted);
  font-weight: 600;
  margin-bottom: 12px;
}

/* ============================================
   ZORLUK SEÇİCİ
   ============================================ */

.difficulty-options {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 6px;
}

.diff-btn {
  padding: 9px 6px;
  font-size: 12px;
  font-weight: 500;
  color: var(--text-secondary);
  background: var(--bg-elevated);
  border: 1px solid var(--border);
  border-radius: 7px;
  transition: all 0.15s ease;
}

.diff-btn:hover {
  background: var(--border);
  color: var(--text-primary);
  border-color: var(--border-strong);
}

.diff-btn.active {
  background: linear-gradient(135deg, var(--gold-deep), var(--gold));
  color: var(--bg-deep);
  border-color: var(--gold-bright);
  font-weight: 600;
  box-shadow: 0 2px 8px rgba(212, 175, 55, 0.3);
}

.difficulty-info {
  margin-top: 10px;
  font-size: 11px;
  color: var(--text-muted);
  text-align: center;
  letter-spacing: 0.3px;
}

.difficulty-info .dot { margin: 0 6px; color: var(--text-dim); }

/* ============================================
   KONTROL BUTONLARI
   ============================================ */

.control-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 6px;
  margin-bottom: 10px;
}

.ctrl-btn {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  padding: 9px 10px;
  font-size: 12px;
  font-weight: 500;
  color: var(--text-secondary);
  background: var(--bg-elevated);
  border: 1px solid var(--border);
  border-radius: 7px;
  transition: all 0.15s ease;
}

.ctrl-btn:hover {
  background: var(--border);
  color: var(--text-primary);
  transform: translateY(-1px);
}

.ctrl-btn:active { transform: translateY(0); }

.ctrl-btn.primary {
  background: linear-gradient(135deg, var(--gold-deep), var(--gold));
  color: var(--bg-deep);
  border-color: var(--gold-bright);
  font-weight: 600;
}

.ctrl-btn.primary:hover {
  background: linear-gradient(135deg, var(--gold), var(--gold-bright));
  box-shadow: 0 4px 12px rgba(212, 175, 55, 0.3);
}

.ctrl-btn svg { flex-shrink: 0; }

.ctrl-btn:disabled {
  opacity: 0.4;
  cursor: not-allowed;
  transform: none !important;
}

/* ============================================
   TOGGLE ANAHTARLARI
   ============================================ */

.toggle-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 7px 0;
  font-size: 12px;
  color: var(--text-secondary);
  cursor: pointer;
}

.toggle-row input[type="checkbox"] { display: none; }

.toggle-switch {
  position: relative;
  width: 34px; height: 18px;
  background: var(--bg-elevated);
  border: 1px solid var(--border);
  border-radius: 10px;
  transition: background 0.2s;
}

.toggle-switch::after {
  content: '';
  position: absolute;
  top: 2px; left: 2px;
  width: 12px; height: 12px;
  background: var(--text-muted);
  border-radius: 50%;
  transition: all 0.2s;
}

.toggle-row input:checked + .toggle-switch {
  background: var(--gold-deep);
  border-color: var(--gold);
}

.toggle-row input:checked + .toggle-switch::after {
  transform: translateX(16px);
  background: var(--gold-bright);
}

/* ============================================
   YENEN TAŞLAR
   ============================================ */

.captured-row {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 6px 0;
  font-size: 12px;
  min-height: 32px;
}

.captured-row + .captured-row { border-top: 1px solid var(--border); }

.captured-label {
  color: var(--text-muted);
  font-weight: 500;
  width: 36px;
  flex-shrink: 0;
}

.captured-pieces {
  display: flex;
  flex: 1;
  flex-wrap: wrap;
  gap: 1px;
  min-height: 22px;
  align-items: center;
}

.captured-pieces svg {
  width: 20px; height: 20px;
  margin-left: -6px;
  filter: drop-shadow(0 1px 1px rgba(0, 0, 0, 0.4));
}

.captured-pieces svg:first-child { margin-left: 0; }

.captured-adv {
  color: var(--gold-bright);
  font-weight: 600;
  font-size: 12px;
  min-width: 24px;
  text-align: right;
}

/* ============================================
   TAHTA
   ============================================ */

.board-wrap {
  display: flex;
  flex-direction: column;
  gap: 10px;
  align-items: center;
  justify-content: center;
  min-width: 0;
}

.player-strip {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 10px 16px;
  background: linear-gradient(180deg, var(--bg-card) 0%, var(--bg-panel) 100%);
  border: 1px solid var(--border);
  border-radius: 10px;
  width: 100%;
  max-width: min(86vh, 720px);
  transition: all 0.2s;
}

.player-strip.active {
  border-color: var(--gold);
  box-shadow: 0 0 20px rgba(212, 175, 55, 0.2);
}

.player-strip.active .player-status { color: var(--gold-bright); }

.player-avatar {
  width: 38px; height: 38px;
  border-radius: 8px;
  display: flex; align-items: center; justify-content: center;
  flex-shrink: 0;
}

.player-avatar.ai {
  background: linear-gradient(135deg, #2a2a2e, #1a1a1e);
  color: var(--gold-bright);
  border: 1px solid var(--border-strong);
}

.player-avatar.human {
  background: linear-gradient(135deg, var(--gold), var(--gold-deep));
  color: var(--bg-deep);
}

.player-info { flex: 1; min-width: 0; }

.player-name {
  font-size: 14px;
  font-weight: 600;
  color: var(--text-primary);
  display: flex; align-items: center; gap: 8px;
}

#top-level-badge {
  font-size: 10px;
  padding: 2px 7px;
  background: var(--gold-deep);
  color: var(--text-primary);
  border-radius: 4px;
  font-weight: 500;
  letter-spacing: 0.3px;
}

.player-status {
  font-size: 11px;
  color: var(--text-muted);
  margin-top: 1px;
}

.player-clock {
  font-family: 'SF Mono', 'Monaco', monospace;
  font-size: 14px;
  color: var(--text-secondary);
  font-variant-numeric: tabular-nums;
}

.board-container {
  position: relative;
  width: min(86vh, 720px);
  height: min(86vh, 720px);
  perspective: 2200px;
  transform-style: preserve-3d;
}

.board {
  position: relative;
  width: 100%; height: 100%;
  display: grid;
  grid-template-columns: repeat(8, 1fr);
  grid-template-rows: repeat(8, 1fr);
  border-radius: 6px;
  overflow: hidden;
  box-shadow:
    0 0 0 2px var(--gold-deep),
    0 0 0 12px #1a1410,
    0 0 0 13px var(--gold-dim),
    0 30px 60px rgba(0, 0, 0, 0.7),
    var(--shadow-gold);
  transition: transform 0.6s cubic-bezier(0.22, 1, 0.36, 1);
  transform-origin: center center;
}

.board-container.perspective-3d .board {
  transform: rotateX(18deg) scale(0.95);
}

.board-container.flipped .board {
  transform: rotate(180deg);
}

.board-container.flipped.perspective-3d .board {
  transform: rotateX(18deg) rotate(180deg) scale(0.95);
}

/* ============================================
   KARELER
   ============================================ */

.square {
  position: relative;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  user-select: none;
  -webkit-user-select: none;
  transition: background-color 0.15s;
}

.square.light {
  background: linear-gradient(135deg, var(--sq-light) 0%, #dcc391 100%);
}

.square.dark {
  background: linear-gradient(135deg, var(--sq-dark) 0%, #755d3b 100%);
}

.square.selected {
  background: var(--sq-selected) !important;
  box-shadow: inset 0 0 0 3px var(--gold);
}

.square.last-move {
  background-color: var(--sq-last) !important;
  background-image: linear-gradient(135deg, rgba(255,220,100,0.35), rgba(212,175,55,0.25));
}

.square.in-check {
  background: radial-gradient(circle, var(--sq-check), transparent 70%) !important;
  animation: checkPulse 1.2s ease-in-out infinite;
}

@keyframes checkPulse {
  0%, 100% { box-shadow: inset 0 0 0 0 rgba(220, 38, 38, 0); }
  50% { box-shadow: inset 0 0 20px 2px rgba(220, 38, 38, 0.6); }
}

.square .piece {
  width: 90%; height: 90%;
  pointer-events: none;
  transition: transform 0.28s cubic-bezier(0.22, 1, 0.36, 1);
  filter: drop-shadow(0 3px 4px rgba(0, 0, 0, 0.45));
}

.board-container.flipped .square .piece {
  transform: rotate(180deg);
}

.square .piece.lifting {
  transform: scale(1.12) translateY(-4px);
  filter: drop-shadow(0 8px 10px rgba(0, 0, 0, 0.6));
  z-index: 5;
}

.board-container.flipped .square .piece.lifting {
  transform: rotate(180deg) scale(1.12) translateY(-4px);
}

/* Hamle noktaları */
.square .move-dot {
  position: absolute;
  width: 28%; height: 28%;
  background: radial-gradient(circle, rgba(60, 60, 60, 0.55), rgba(60, 60, 60, 0.4));
  border-radius: 50%;
  pointer-events: none;
  animation: dotPop 0.18s ease-out;
}

.square.capture-target .move-dot {
  width: 88%; height: 88%;
  background: radial-gradient(circle, transparent 55%, rgba(180, 40, 30, 0.4) 56%, rgba(180, 40, 30, 0.6) 100%);
  border-radius: 50%;
}

@keyframes dotPop {
  from { transform: scale(0); opacity: 0; }
  to { transform: scale(1); opacity: 1; }
}

/* Koordinatlar */
.square .coord {
  position: absolute;
  font-size: 10px;
  font-weight: 700;
  font-family: var(--font-body);
  opacity: 0.75;
  pointer-events: none;
  transition: color 0.15s;
}

.square.light .coord { color: #755d3b; }
.square.dark .coord { color: #e8d4a8; }

.square .coord.file { bottom: 2px; right: 4px; }
.square .coord.rank { top: 2px; left: 4px; }

.board-container.flipped .square .coord { transform: rotate(180deg); }

/* ============================================
   OYUN BİTTİ MODAL
   ============================================ */

.game-over-modal {
  position: absolute;
  inset: 0;
  background: rgba(10, 9, 8, 0.85);
  backdrop-filter: blur(8px);
  -webkit-backdrop-filter: blur(8px);
  display: none;
  align-items: center;
  justify-content: center;
  border-radius: 6px;
  z-index: 20;
  animation: fadeIn 0.3s ease-out;
}

.game-over-modal.active { display: flex; }

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

.modal-content {
  text-align: center;
  padding: 30px 40px;
  background: linear-gradient(180deg, var(--bg-card), var(--bg-panel));
  border: 1px solid var(--gold-deep);
  border-radius: 14px;
  box-shadow: var(--shadow-lg), var(--shadow-gold);
  animation: modalIn 0.4s cubic-bezier(0.22, 1, 0.36, 1);
  max-width: 80%;
}

@keyframes modalIn {
  from { opacity: 0; transform: scale(0.85) translateY(20px); }
  to { opacity: 1; transform: scale(1) translateY(0); }
}

.modal-content h2 {
  font-family: var(--font-display);
  font-size: 32px;
  font-weight: 700;
  color: var(--gold-bright);
  margin-bottom: 10px;
}

.modal-content p {
  font-size: 14px;
  color: var(--text-secondary);
  margin-bottom: 22px;
  line-height: 1.5;
}

/* ============================================
   SAĞ PANEL — DURUM, HAMLELER
   ============================================ */

.status-display {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px 12px;
  background: var(--bg-elevated);
  border-radius: 8px;
  margin-bottom: 10px;
}

.status-icon {
  width: 10px; height: 10px;
  font-size: 10px;
  line-height: 1;
  color: var(--gold-bright);
}

.status-icon.thinking { animation: think 1s ease-in-out infinite; }
@keyframes think {
  0%, 100% { opacity: 1; transform: scale(1); }
  50% { opacity: 0.4; transform: scale(1.4); }
}

.status-text {
  font-size: 13px;
  color: var(--text-primary);
  font-weight: 500;
}

/* Değerlendirme çubuğu */
.eval-bar-container {
  display: flex;
  align-items: center;
  gap: 10px;
}

.eval-bar {
  position: relative;
  flex: 1;
  height: 20px;
  background: #1a1a1a;
  border: 1px solid var(--border);
  border-radius: 4px;
  overflow: hidden;
}

.eval-bar-white, .eval-bar-black {
  position: absolute;
  left: 0; right: 0;
  transition: height 0.5s cubic-bezier(0.22, 1, 0.36, 1);
}

.eval-bar-white {
  bottom: 0;
  background: linear-gradient(180deg, #f0e6d2, #d8c9a8);
  height: 50%;
}

.eval-bar-black {
  top: 0;
  background: linear-gradient(180deg, #2a2a2a, #1a1a1a);
  height: 50%;
}

.eval-mid-line {
  position: absolute;
  left: 0; right: 0;
  top: 50%;
  height: 1px;
  background: var(--gold-deep);
  opacity: 0.5;
}

.eval-label {
  font-family: 'SF Mono', monospace;
  font-size: 12px;
  font-weight: 600;
  color: var(--text-secondary);
  min-width: 36px;
  text-align: right;
  font-variant-numeric: tabular-nums;
}

/* Hamle listesi */
.moves-list {
  max-height: 280px;
  overflow-y: auto;
  padding-right: 4px;
}

.moves-list::-webkit-scrollbar { width: 5px; }
.moves-list::-webkit-scrollbar-thumb { background: var(--border); border-radius: 2px; }

.moves-empty {
  text-align: center;
  color: var(--text-muted);
  font-size: 12px;
  padding: 20px 0;
  font-style: italic;
}

.move-row {
  display: grid;
  grid-template-columns: 28px 1fr 1fr;
  gap: 8px;
  padding: 5px 6px;
  font-size: 13px;
  font-family: 'SF Mono', monospace;
  align-items: center;
  border-radius: 4px;
}

.move-row:nth-child(odd) { background: rgba(255, 255, 255, 0.015); }

.move-num { color: var(--text-muted); font-size: 11px; font-weight: 600; }

.move-san {
  color: var(--text-primary);
  padding: 3px 6px;
  border-radius: 3px;
  cursor: pointer;
  transition: background 0.1s;
}

.move-san:hover { background: var(--bg-elevated); }
.move-san.current { background: var(--gold-dim); color: var(--gold-bright); font-weight: 600; }
.move-san.empty { color: var(--text-dim); }

.opening-name {
  font-family: var(--font-display);
  font-size: 16px;
  font-weight: 600;
  color: var(--gold-bright);
  font-style: italic;
  min-height: 22px;
}

.credits {
  margin-top: auto;
  padding: 14px 4px 6px;
  text-align: center;
  font-size: 11px;
  color: var(--text-muted);
  line-height: 1.6;
}

.credits strong { color: var(--text-secondary); }
.credits .tiny { font-size: 10px; color: var(--text-dim); margin-top: 3px; }

/* ============================================
   RESPONSİF (TABLET, MOBİL)
   ============================================ */

@media (max-width: 1100px) {
  .app {
    grid-template-columns: 1fr;
    grid-template-rows: auto auto auto;
    height: auto;
    min-height: 100vh;
    gap: 12px;
    padding: 12px;
  }

  html, body { overflow: auto; }

  .panel-left, .panel-right { order: 2; }
  .board-wrap { order: 1; }

  .board-container {
    width: min(92vw, 560px);
    height: min(92vw, 560px);
  }

  .player-strip { max-width: min(92vw, 560px); }
}

@media (max-width: 640px) {
  .app { padding: 8px; gap: 10px; }
  .brand-text h1 { font-size: 18px; }
  .brand-text .subtitle { font-size: 10px; }
  .board-container {
    width: min(96vw, 500px);
    height: min(96vw, 500px);
  }
  .player-strip { max-width: min(96vw, 500px); padding: 8px 12px; }
  .difficulty-options { grid-template-columns: 1fr 1fr 1fr; }
  .card { padding: 12px; }
  .square .coord { font-size: 8px; }
}
