/* Satranç - sadece bu oyuna ait görünüş */

/* ---------- Satranç saatleri ---------- */
.tahta-kolon {
  display: flex;
  flex-direction: column;
  gap: 8px;
  max-width: 580px;
  width: 100%;
  margin: 0 auto;
}
.saat {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 6px 14px;
  border-radius: 12px;
  background: var(--yuzey);
  box-shadow: inset 0 0 0 1px var(--cizgi);
  color: var(--soluk);
  transition: background 0.2s, color 0.2s;
}
.saat[hidden] { display: none; }
.saat-ad { font-weight: 700; }
.saat-sure {
  font-size: 1.5rem;
  font-variant-numeric: tabular-nums;
  letter-spacing: 0.02em;
}
/* Sırası gelen oyuncunun saati: ana renkte */
.saat.aktif {
  background: var(--ana);
  color: var(--ana-uzeri);
  box-shadow: none;
}
/* Son 20 saniye: kırmızı */
.saat.az .saat-sure { color: var(--hata); }
.saat.aktif.az {
  background: var(--hata);
  color: var(--ana-uzeri);
}
.saat.aktif.az .saat-sure { color: inherit; }

.bilgi select {
  font: inherit;
  color: var(--yazi);
  background: transparent;
  border: none;
  font-weight: 700;
  cursor: pointer;
}
.bilgi select option { background: var(--yuzey); }

.duzen {
  display: grid;
  grid-template-columns: minmax(0, 580px) minmax(200px, 1fr);
  gap: 16px;
  align-items: start;
}
@media (max-width: 760px) {
  .duzen { grid-template-columns: 1fr; }
}

/* ---------- Tahta temaları ----------
   Kare renkleri oyunun kendi içerik rengi (sabit olabilir).
   --cerceve: tahtanın kenarı, --cerceve-isik: kenardaki parlama */
.tahta-sarici,
.tahta-sarici[data-tahta="mor"] {
  --acik-kare: #ebe6fb;
  --koyu-kare: #9a89dd;
  --cerceve: #4b3c96;
  --cerceve-isik: #7c6bd0;
  --doku: none;
}
.tahta-sarici[data-tahta="ahsap"] {
  --acik-kare: #edd5ae;
  --koyu-kare: #a9774f;
  --cerceve: #5a3b22;
  --cerceve-isik: #8a5d38;
  /* hafif ahşap damarı */
  --doku: repeating-linear-gradient(100deg, rgba(90, 50, 20, 0.05) 0 2px, transparent 2px 7px);
}
.tahta-sarici[data-tahta="yesil"] {
  --acik-kare: #e9eed2;
  --koyu-kare: #7b9c5b;
  --cerceve: #3f5530;
  --cerceve-isik: #63804a;
  --doku: none;
}
.tahta-sarici[data-tahta="mavi"] {
  --acik-kare: #e1e9f2;
  --koyu-kare: #7896ba;
  --cerceve: #344c6c;
  --cerceve-isik: #55729a;
  --doku: none;
}
/* Karanlık temada mor tahta biraz kısılır (diğerleri zaten koyu çerçeveli) */
[data-tema="karanlik"] .tahta-sarici[data-tahta="mor"] {
  --acik-kare: #a99fd6;
  --koyu-kare: #5d4f9e;
  --cerceve: #2c2360;
  --cerceve-isik: #4a3d8f;
}

.tahta-sarici {
  position: relative;
  width: 100%;
  max-width: 580px;
  margin: 0 auto;
  padding: clamp(6px, 1.8vw, 12px);
  border-radius: 16px;
  background: linear-gradient(145deg, var(--cerceve-isik), var(--cerceve) 55%);
  box-shadow: /* dış gölge yok (Batu) */
    inset 0 1px 0 rgba(255, 255, 255, 0.25),
    inset 0 -2px 0 rgba(0, 0, 0, 0.25);
  box-sizing: border-box;
}

.tahta {
  display: grid;
  grid-template-columns: repeat(8, minmax(0, 1fr));
  grid-template-rows: repeat(8, minmax(0, 1fr));
  aspect-ratio: 1;
  border-radius: 6px;
  overflow: hidden;
  box-shadow: 0 0 0 1px rgba(0, 0, 0, 0.35), inset 0 0 12px rgba(0, 0, 0, 0.15);
  user-select: none;
  touch-action: manipulation;
  direction: ltr; /* Arapça gibi sağdan sola dillerde tahta ters dönmesin */
}

.kare {
  position: relative;
  display: flex;
  align-items: center;
  justify-content: center;
  border: none;
  padding: 0;
  margin: 0;
  background-color: var(--acik-kare);
  background-image: var(--doku), linear-gradient(135deg, rgba(255, 255, 255, 0.14), rgba(0, 0, 0, 0.04));
  cursor: pointer;
}
.kare.koyu { background-color: var(--koyu-kare); }
.kare:focus-visible { outline: 3px solid #ffd640; outline-offset: -3px; z-index: 1; }

/* ---------- Taşlar (çizimler: taslar.js) ---------- */
.renk-tanim { position: absolute; }

.tas {
  width: 88%;
  height: 88%;
  pointer-events: none;
  transition: transform 0.15s ease;
  filter: drop-shadow(0 2px 1.5px rgba(0, 0, 0, 0.35));
}
.tas svg { display: block; width: 100%; height: 100%; }
.tas .g { stroke-width: 2.6; stroke-linejoin: round; }
.tas .d { fill: none; stroke-width: 2.4; stroke-linecap: round; }

.tas.w .g { fill: url(#tas-beyaz); stroke: #2a2438; }
.tas.w .d { stroke: #6d6481; }
.tas.w .e { fill: #2a2438; }
.tas.w .p { fill: rgba(255, 255, 255, 0.85); }

.tas.b .g { fill: url(#tas-siyah); stroke: #0b0910; }
.tas.b .d { stroke: #9a92b8; }
.tas.b .e { fill: #d9d3ee; }
.tas.b .p { fill: rgba(255, 255, 255, 0.2); }

/* Fareyle üstüne gelince ve seçilince taş hafifçe kalkar */
@media (hover: hover) {
  .kare:hover .tas { transform: translateY(-2px) scale(1.03); }
}
.kare.secili .tas {
  transform: translateY(-3px) scale(1.07);
  filter: drop-shadow(0 6px 4px rgba(0, 0, 0, 0.35));
}
/* Son oynanan taş yerine otururken küçük bir hareket */
.tas.yeni { animation: tas-otur 0.22s ease-out; }
@keyframes tas-otur {
  from { transform: scale(1.15); }
  to { transform: scale(1); }
}
@media (prefers-reduced-motion: reduce) {
  .tas, .tas.yeni { transition: none; animation: none; }
}

/* Koordinatlar: açık karede koyu, koyu karede açık renk */
.koordinat {
  position: absolute;
  font-family: var(--font);
  font-size: clamp(0.5rem, 1.8vw, 0.72rem);
  font-weight: 800;
  color: var(--koyu-kare);
  pointer-events: none;
}
.kare.koyu .koordinat { color: var(--acik-kare); }
.koordinat.dosya { right: 3px; bottom: 1px; }
.koordinat.sira { left: 3px; top: 2px; }

/* ---------- İşaretler ---------- */
.kare.son-hamle { box-shadow: inset 0 0 0 100px rgba(255, 214, 64, 0.38); }
.kare.secili { box-shadow: inset 0 0 0 100px rgba(108, 76, 241, 0.42); }
.kare.sah-tehdit {
  box-shadow: none;
  background-image: radial-gradient(circle, rgba(255, 60, 70, 0.95) 0%, rgba(230, 40, 55, 0.55) 45%, transparent 75%);
}

.kare.hedef::after {
  content: "";
  position: absolute;
  width: 30%;
  height: 30%;
  border-radius: 50%;
  background: rgba(20, 18, 32, 0.3);
}
.kare.hedef.yeme::after {
  width: 92%;
  height: 92%;
  background: transparent;
  border: 5px solid rgba(20, 18, 32, 0.32);
  box-sizing: border-box;
}
@media (hover: hover) {
  .kare.hedef:hover::after { background: rgba(20, 18, 32, 0.45); }
  .kare.hedef.yeme:hover::after { background: transparent; border-color: rgba(20, 18, 32, 0.5); }
}

/* ---------- Terfi seçimi ---------- */
.terfi {
  position: absolute;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  background: rgba(19, 18, 28, 0.5);
  border-radius: 16px;
}
.terfi[hidden] { display: none; }
.terfi .kutu { text-align: center; }
.terfi p { margin: 0 0 10px; font-weight: 600; }
.terfi-secenekler { display: flex; gap: 8px; }
.terfi-secenekler .kare {
  width: 60px;
  height: 60px;
  border-radius: 12px;
  background: var(--acik-kare);
  box-shadow: inset 0 0 0 2px var(--koyu-kare);
}
.terfi-secenekler .kare:hover { background: var(--koyu-kare); }

/* ---------- Yan panel ---------- */
.yan { padding: 16px; }
.durum {
  font-weight: 700;
  margin-bottom: 10px;
}
.durum.bitti { color: var(--ana); }
.hamle-listesi {
  margin: 0;
  padding-left: 2.2em;
  max-height: 420px;
  overflow-y: auto;
  font-variant-numeric: tabular-nums;
  font-size: 0.95rem;
  color: var(--soluk);
}
.hamle-listesi li span { display: inline-block; min-width: 5.5em; color: var(--yazi); direction: ltr; }
@media (max-width: 760px) {
  .hamle-listesi { max-height: 160px; }
}

/* ---------- Türler (turler.js) ---------- */
/* Türün kısa kuralı (yan kutuda, durumun üstünde) */
.tur-kural {
  margin: 0 0 12px;
  padding: 8px 10px;
  border-radius: 10px;
  background: var(--ana-acik);
  color: var(--yazi);
  font-size: 0.88rem;
  line-height: 1.4;
}
/* Çılgın Satranç: eldeki taşlar (tahtanın üstünde siyahın, altında beyazın) */
.el {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 6px;
  width: 100%;
  max-width: 580px;
  min-height: 48px;
  margin: 6px auto;
  padding: 4px 8px;
  border-radius: 12px;
  border: 1px solid var(--cizgi);
  background: var(--yuzey);
  box-sizing: border-box;
}
.el-bos { color: var(--soluk); font-size: 0.85rem; }
.el-tas {
  position: relative;
  width: 42px;
  height: 42px;
  padding: 0;
  border: 2px solid transparent;
  border-radius: 10px;
  background: var(--arka);
  cursor: pointer;
  display: grid;
  place-items: center;
}
.el-tas .tas { width: 90%; height: 90%; }
.el-tas b {
  position: absolute;
  right: -4px;
  bottom: -4px;
  min-width: 18px;
  padding: 0 4px;
  border-radius: 999px;
  background: var(--ana);
  color: var(--ana-uzeri);
  font-size: 0.72rem;
  line-height: 18px;
  text-align: center;
}
.el-tas:disabled { cursor: default; opacity: 0.6; }
.el-tas.secili { border-color: var(--ana); background: var(--ana-acik); }
.el-tas:focus-visible { outline: 3px solid var(--ana); outline-offset: 2px; }
