/* Dokuz Kale — gece krallığı teması.
   Doktrin (pati'den): tek ekran, sıfır kaydırma; 100dvh + flex; yükseklik tabanlı kısma;
   prefers-reduced-motion tüm animasyonları keser. */

:root {
  --gece: #1c2440;
  --gece-koyu: #141a2e;
  --panel: #232f52;
  --panel-acik: #2c3a63;
  --kagit: #fdf8ef;
  --murekkep: #27324e;
  --cizgi: #3a4a78;
  --altin: #f4b63f;
  --iyi: #3f9d63;
  --kotu: #d95d5d;
  --yazi: #e7ecff;
  --kale-renk: #f4b63f; /* aktif kalenin rengi JS'ten gelir */
}

* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }
html, body { margin: 0; padding: 0; }
body {
  background: var(--gece-koyu);
  color: var(--yazi);
  font-family: ui-rounded, "Trebuchet MS", "Comic Sans MS", system-ui, sans-serif;
  overflow: hidden;
}

#wrap { display: flex; justify-content: center; height: 100dvh; }
#stage {
  width: min(100vw, 560px);
  height: 100dvh;
  display: flex;
  flex-direction: column;
  padding: env(safe-area-inset-top) env(safe-area-inset-right) env(safe-area-inset-bottom) env(safe-area-inset-left);
}

button {
  font: inherit;
  color: inherit;
  border: none;
  background: none;
  cursor: pointer;
  touch-action: manipulation;
}

/* ---------- Üst çubuk ---------- */
#topbar {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 8px 12px;
  flex: 0 0 auto;
}
.marka { font-weight: 800; letter-spacing: .4px; font-size: 17px; color: var(--altin); }
.chip {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  background: var(--panel);
  border: 1.5px solid var(--cizgi);
  border-radius: 999px;
  padding: 3px 10px;
  font-size: 13px;
  font-weight: 700;
}
svg.mini { width: 14px; height: 14px; vertical-align: -2px; }
.chip svg.mini { width: 15px; height: 15px; }
#cYildiz .mini { color: var(--altin); }
#cTas .mini { color: #7cd6c3; }
.bosluk { flex: 1; }
.ikonBtn {
  width: 36px; height: 36px;
  display: grid; place-items: center;
  background: var(--panel);
  border: 1.5px solid var(--cizgi);
  border-radius: 12px;
  color: var(--yazi);
}
.ikonBtn svg { width: 20px; height: 20px; }
.ikonBtn.kapali { opacity: .45; }
.ikonBtn:active { transform: scale(.94); }

/* ---------- Ana ekran: harita ---------- */
#ana {
  flex: 1;
  display: flex;
  flex-direction: column;
  min-height: 0;
  padding: 0 12px 10px;
  gap: 8px;
}
#harita {
  position: relative;
  flex: 1;
  min-height: 0;
  border: 2px solid var(--cizgi);
  border-radius: 20px;
  overflow: hidden;
  background: var(--gece);
}
#harita-fon, #harita-fon svg { position: absolute; inset: 0; width: 100%; height: 100%; }
#harita-fon svg { object-fit: cover; }
#kale-katman { position: absolute; inset: 0; }
.kale-nokta {
  position: absolute;
  transform: translate(-50%, -50%);
  width: 19%;
  max-width: 92px;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 0;
  transition: transform .15s;
}
.kale-nokta:active { transform: translate(-50%, -50%) scale(.93); }
.kale-nokta svg { width: 100%; height: auto; display: block; }
.kale-nokta .kale-ad {
  font-size: 10.5px;
  font-weight: 800;
  background: rgba(20, 26, 46, .82);
  border: 1px solid var(--cizgi);
  padding: 2px 7px;
  border-radius: 999px;
  white-space: nowrap;
  margin-top: -6px;
}
.kale-nokta.isikli .kale-ad { border-color: var(--kale-renk); }
.kale-nokta .yildizlar { display: flex; gap: 1px; margin-top: 2px; }
.kale-nokta .yildizlar svg { width: 12px; height: 12px; color: var(--altin); }
.kale-nokta .yildizlar svg.bos { color: #4a5470; }
#harita-soz {
  margin: 0;
  text-align: center;
  font-size: 13.5px;
  opacity: .85;
  min-height: 18px;
}

/* ---------- Alt bar çekmeceleri ---------- */
#alt-bar { display: flex; gap: 10px; flex: 0 0 auto; }
.cekmece {
  flex: 1;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  background: var(--panel);
  border: 2px solid var(--cizgi);
  border-radius: 16px;
  padding: 10px;
  font-weight: 800;
  font-size: 14px;
  color: var(--yazi);
  position: relative;
}
.cekmece:active { transform: scale(.97); }
.cekmece-ikon svg { width: 22px; height: 22px; display: block; color: var(--altin); }
.cekmece b {
  background: var(--altin);
  color: var(--murekkep);
  font-size: 11.5px;
  border-radius: 999px;
  padding: 1px 7px;
}

/* ---------- Oyun ekranı ---------- */
#oyun {
  flex: 1;
  display: flex;
  flex-direction: column;
  min-height: 0;
  padding: 0 12px 10px;
  gap: 8px;
}
#oyun-bar { display: flex; align-items: center; gap: 8px; flex: 0 0 auto; }
#oyun-kale-adi { font-weight: 800; font-size: 15.5px; color: var(--kale-renk); }
#kat-chip {
  background: var(--panel);
  border: 1.5px solid var(--kale-renk);
  border-radius: 999px;
  padding: 3px 10px;
  font-size: 12.5px;
  font-weight: 800;
}
#oyun-adi-chip {
  background: var(--panel);
  border: 1.5px solid var(--cizgi);
  border-radius: 999px;
  padding: 3px 10px;
  font-size: 12px;
  font-weight: 700;
  max-width: 40vw;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.oyun-listesi {
  display: flex;
  flex-wrap: wrap;
  gap: 5px;
  justify-content: center;
  margin: 8px 0;
}
.oyun-listesi span {
  background: var(--gece);
  border: 1.5px solid var(--cizgi);
  border-radius: 999px;
  padding: 3px 9px;
  font-size: 11.5px;
  font-weight: 700;
}
#ilerleme { display: flex; gap: 5px; flex: 0 0 auto; }
#ilerleme i {
  flex: 1;
  height: 7px;
  border-radius: 4px;
  background: var(--panel-acik);
  border: 1px solid var(--cizgi);
}
#ilerleme i.oldu { background: var(--kale-renk); border-color: var(--kale-renk); }
#ilerleme i.hatali { background: #8a6b4a; }

#gorev-alani {
  flex: 1;
  min-height: 0;
  display: flex;
  flex-direction: column;
  gap: 8px;
}
#soru-kutu {
  background: var(--panel);
  border: 2px solid var(--cizgi);
  border-radius: 18px;
  padding: 10px 12px;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 6px;
  flex: 0 1 auto;
  min-height: 0;
}
#soru-metin { margin: 0; font-size: 15px; font-weight: 700; text-align: center; line-height: 1.35; }
#soru-gorsel { display: flex; justify-content: center; min-height: 0; }
#soru-gorsel svg { height: clamp(64px, 16dvh, 150px); width: auto; max-width: 100%; }
#soru-gorsel .sk-yuz-buyuk { height: clamp(90px, 18dvh, 160px); }
#soru-gorsel .sk-hedef { height: clamp(60px, 12dvh, 96px); }
#soru-gorsel .sk-raflar { height: clamp(96px, 19dvh, 170px); }
#soru-gorsel:empty { display: none; }

/* Mantık fenerleri: HTML flex, adlar kendi kutusunda */
.fener-sira { display: flex; justify-content: center; gap: 12px; flex-wrap: wrap; }
.fener { display: flex; flex-direction: column; align-items: center; gap: 1px; width: 30%; max-width: 110px; }
#soru-gorsel .fener-svg { width: clamp(48px, 11dvh, 72px); height: auto; }
.fener-ad { font-size: 12.5px; font-weight: 700; text-align: center; line-height: 1.15; }
.fener-durum { font-size: 11px; font-weight: 800; letter-spacing: .3px; }
.fener-durum.ac { color: var(--iyi); }
.fener-durum.ka { color: var(--kotu); }

.boyali-kelime {
  font-size: clamp(34px, 11vw, 56px);
  font-weight: 900;
  letter-spacing: 2px;
  text-shadow: 0 2px 0 rgba(20, 26, 46, .6);
}
.kopru-kelime {
  font-size: clamp(28px, 9vw, 44px);
  font-weight: 900;
  letter-spacing: 1px;
  display: flex;
  align-items: center;
}
.kopru-kelime b { color: var(--altin); text-decoration: underline; }
.son-harf-rozet {
  margin-left: 10px;
  font-size: 16px;
  background: var(--altin);
  color: var(--murekkep);
  border-radius: 10px;
  padding: 3px 9px;
}

#sure-cubugu {
  width: 100%;
  height: 9px;
  background: var(--gece-koyu);
  border-radius: 6px;
  overflow: hidden;
  border: 1px solid var(--cizgi);
}
#sure-dolgu {
  height: 100%;
  width: 100%;
  background: linear-gradient(90deg, var(--iyi), var(--altin));
  transform-origin: left;
}

/* ---------- Seçenekler ---------- */
#secenekler {
  flex: 1;
  min-height: 0;
  display: grid;
  gap: 8px;
  align-content: center;
}
#secenekler.duzen-1 { grid-template-columns: 1fr; }
#secenekler.duzen-cumle { grid-template-columns: 1fr; align-content: center; gap: 7px; }
#secenekler.duzen-cumle .secenek { flex-direction: row; justify-content: flex-start; text-align: left; padding: 10px 14px; font-size: 14.5px; font-weight: 700; line-height: 1.3; }
#secenekler.duzen-2, #secenekler.duzen-izgara-2 { grid-template-columns: 1fr 1fr; }
#secenekler.duzen-liste { grid-template-columns: 1fr 1fr; }
#secenekler.duzen-izgara-3 { grid-template-columns: repeat(3, 1fr); }
#secenekler.duzen-izgara-4 { grid-template-columns: repeat(4, 1fr); }
#secenekler.duzen-izgara-5 { grid-template-columns: repeat(5, 1fr); }

.secenek {
  background: var(--panel);
  border: 2.5px solid var(--cizgi);
  border-radius: 16px;
  padding: 8px;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 4px;
  color: var(--yazi);
  font-weight: 800;
  font-size: 15px;
  min-height: 0;
}
.secenek svg { width: 100%; height: auto; max-height: 13dvh; }
.secenek .secenek-ikon { width: 26px; height: 26px; }
.secenek:active { transform: scale(.96); }
.secenek.secili { border-color: var(--altin); background: var(--panel-acik); box-shadow: 0 0 0 2px var(--altin) inset; }
.secenek.dogru { border-color: var(--iyi); background: #274a37; }
.secenek.yanlis { border-color: var(--kotu); animation: sars .4s; }
.secenek.parla { animation: parla 1s ease-in-out 2; }
.secenek:disabled { opacity: .8; }

/* Işık Sırası lambaları */
.secenek.lamba { background: var(--gece); }
.secenek.lamba.yanik { --lamba-govde: var(--altin); --lamba-isik: #fff6d8; background: var(--panel-acik); border-color: var(--altin); }
.secenek.lamba svg { max-height: 11dvh; }

@keyframes sars {
  0%, 100% { transform: translateX(0); }
  25% { transform: translateX(-6px); }
  75% { transform: translateX(6px); }
}
@keyframes parla {
  0%, 100% { box-shadow: 0 0 0 0 transparent; }
  50% { box-shadow: 0 0 0 4px var(--iyi); }
}

/* ---------- Alt satır: ipucu + onay ---------- */
#alt-satir {
  flex: 0 0 auto;
  display: flex;
  flex-direction: column;
  gap: 6px;
  min-height: 40px;
  justify-content: center;
}
#ipucu {
  margin: 0;
  text-align: center;
  font-size: 13.5px;
  background: #3a3320;
  border: 1.5px solid var(--altin);
  border-radius: 12px;
  padding: 7px 10px;
  color: #ffe9b0;
}
.buyuk-btn {
  background: var(--altin);
  color: var(--murekkep);
  font-weight: 900;
  font-size: 16px;
  border-radius: 14px;
  padding: 11px;
  border-bottom: 3px solid #b8842a;
}
.buyuk-btn:active { transform: translateY(1px); }
.buyuk-btn:disabled { opacity: .5; }
.kucuk-btn {
  align-self: center;
  display: inline-flex;
  align-items: center;
  gap: 6px;
  background: var(--panel);
  border: 1.5px solid var(--cizgi);
  border-radius: 999px;
  padding: 6px 14px;
  font-size: 13px;
  font-weight: 700;
  color: var(--yazi);
}
.kucuk-btn svg { width: 15px; height: 15px; }

/* ---------- Kaplama ---------- */
#kaplama {
  position: fixed;
  inset: 0;
  background: rgba(12, 16, 30, .82);
  display: grid;
  place-items: center;
  padding: 16px;
  z-index: 50;
}
#kaplama-icerik {
  width: min(92vw, 440px);
  max-height: 92dvh;
  overflow: auto;
  background: var(--panel);
  border: 2px solid var(--cizgi);
  border-radius: 22px;
  padding: 18px;
  text-align: center;
  animation: kaplamaGel .25s ease-out;
}
@keyframes kaplamaGel {
  from { transform: translateY(14px) scale(.97); opacity: 0; }
  to { transform: none; opacity: 1; }
}
#kaplama-icerik h2 { margin: 4px 0 6px; font-size: 20px; color: var(--altin); }
#kaplama-icerik h2.kale-baslik { color: var(--kale-renk); }
#kaplama-icerik p { margin: 6px 0; font-size: 14.5px; line-height: 1.45; }
#kaplama-icerik .soz { font-style: italic; opacity: .92; }
.golge-portre { width: min(130px, 30vw); margin: 4px auto; }
.golge-portre svg { width: 100%; height: auto; }
.golge-portre.yenik { filter: grayscale(.6); opacity: .7; transform: rotate(6deg); }
.kaplama-btnler { display: flex; gap: 8px; margin-top: 12px; }
.kaplama-btnler .buyuk-btn { flex: 1; }
.kaplama-btnler .kucuk-btn { flex: 0 0 auto; }

/* Taş kazanımı */
.tas-sahne { display: flex; justify-content: center; margin: 6px 0; }
.tas-sahne svg { width: min(150px, 34vw); height: auto; animation: tasDogus .8s ease-out; }
@keyframes tasDogus {
  0% { transform: scale(.2) rotate(-30deg); opacity: 0; }
  60% { transform: scale(1.15) rotate(6deg); }
  100% { transform: scale(1) rotate(0); opacity: 1; }
}
.zafer-yildizlar { display: flex; justify-content: center; gap: 6px; margin: 8px 0; }
.zafer-yildizlar svg { width: 40px; height: 40px; color: var(--altin); }
.zafer-yildizlar svg.bos { color: #4a5470; }

/* Sandık + rozet vitrini */
.vitrin {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 10px;
  margin: 10px 0;
}
.vitrin-oge { display: flex; flex-direction: column; align-items: center; gap: 3px; }
.vitrin-oge svg { width: 100%; max-width: 84px; height: auto; }
.vitrin-oge span { font-size: 11.5px; font-weight: 700; line-height: 1.25; }
.vitrin-oge .alt-not { font-size: 10.5px; opacity: .7; font-weight: 600; }
.vitrin-oge .alt-not svg { width: 15px; height: 15px; color: var(--altin); vertical-align: -2px; }
.vitrin-oge .alt-not svg.bos { color: #4a5470; }
.vitrin-oge.sonuk span { opacity: .55; }
.ilerleme-cubuk {
  width: 100%;
  height: 6px;
  background: var(--gece-koyu);
  border-radius: 4px;
  overflow: hidden;
}
.ilerleme-cubuk i { display: block; height: 100%; background: var(--altin); }
.rozet-grup-baslik {
  text-align: left;
  font-size: 12.5px;
  font-weight: 800;
  opacity: .75;
  margin: 10px 0 2px;
  text-transform: uppercase;
  letter-spacing: .6px;
}

/* Rehber */
.rehber-madde {
  display: flex;
  align-items: center;
  gap: 10px;
  text-align: left;
  margin: 10px 0;
}
.rehber-madde svg { width: 34px; height: 34px; flex: 0 0 auto; color: var(--altin); }
.rehber-madde p { margin: 0; font-size: 14px; }

/* Eğitim işaretçisi */
.egitim-el {
  position: absolute;
  width: 40px;
  height: 40px;
  pointer-events: none;
  z-index: 60;
  animation: elNabiz 1s infinite;
}
.egitim-el svg { width: 100%; height: 100%; color: var(--altin); filter: drop-shadow(0 2px 4px rgba(0,0,0,.6)); }
@keyframes elNabiz {
  0%, 100% { transform: translateY(0) scale(1); }
  50% { transform: translateY(-7px) scale(1.12); }
}

/* Gösteri: tam ekran kısa olay kartı */
#gosteri {
  position: fixed;
  inset: 0;
  display: grid;
  place-items: center;
  z-index: 70;
  pointer-events: none;
}
.gosteri-kart {
  background: var(--gece);
  border: 2px solid var(--kale-renk);
  border-radius: 20px;
  padding: 16px 22px;
  text-align: center;
  max-width: 84vw;
  animation: gosteriGel .3s ease-out;
  box-shadow: 0 10px 40px rgba(0, 0, 0, .5);
}
.gosteri-kart .buyuk { font-size: 22px; font-weight: 900; color: var(--altin); }
.gosteri-kart .kucuk { font-size: 14px; margin-top: 4px; opacity: .9; }
@keyframes gosteriGel {
  from { transform: scale(.8); opacity: 0; }
  to { transform: none; opacity: 1; }
}

/* Konfeti */
.konfeti {
  position: fixed;
  top: -12px;
  width: 9px;
  height: 13px;
  border-radius: 2px;
  z-index: 80;
  pointer-events: none;
  animation: konfetiDus linear forwards;
}
@keyframes konfetiDus {
  to { transform: translateY(105dvh) rotate(540deg); opacity: .7; }
}

.gizli { display: none !important; }
.perde { visibility: hidden; }
.secenek.hazir { min-height: 72px; border-style: dashed; border-color: var(--altin); }

/* ---------- Sıkışık ekranlar ---------- */
@media (max-height: 700px) {
  #soru-metin { font-size: 13.5px; }
  #soru-gorsel svg { height: clamp(54px, 13dvh, 110px); }
  .secenek svg { max-height: 10dvh; }
  .boyali-kelime { font-size: clamp(28px, 9vw, 42px); }
  #topbar { padding: 6px 10px; }
}
@media (max-height: 590px) {
  .marka { display: none; }
  #soru-gorsel svg { height: clamp(44px, 11dvh, 84px); }
  .secenek { padding: 5px; border-radius: 12px; }
  .secenek svg { max-height: 8.5dvh; }
  #kaplama-icerik { padding: 12px; }
}
@media (max-width: 380px) {
  .kale-nokta .kale-ad { font-size: 9px; }
  .cekmece { font-size: 12.5px; }
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation: none !important; transition: none !important; }
}
