/* ===== FabuWords — Kelime Oyunu (web) ===== */
/* Mobil oyunla aynı magenta tema + harf çarkı + sürüklenen line. */

:root {
  --fw-magenta:      #e237c1;  /* seçili / dolgu (mobil 0.886,0.215,0.757) */
  --fw-magenta-dk:   #a60d8c;  /* line kontür (mobil 0.65,0.05,0.55) */
  --fw-magenta-soft: rgba(226, 55, 193, 0.14);
  --fw-selection-color: var(--fw-magenta);
  --fw-line-border-width: 22px;
  --fw-line-fill-width: 14px;
  --fw-cell:         #fff7e2;
  --fw-cell-ink:     #3a2415;
}

/* ---- Sahne kabı ---- */
.fw-game {
  max-width: 680px;
  margin: 0 auto;
  position: relative; /* bölüm paneli (.fw-chapters) bu kabın içine konumlansın — sol sidebar'ın altına taşmasın */
  padding: 72px 12px 14px;
  height: 100vh;
  height: 100dvh;
  box-sizing: border-box;
  overflow: hidden;
  display: flex;
  flex-direction: column;
  gap: 8px;
  user-select: none;
  -webkit-user-select: none;
}

/* ---- Üst bar ---- */
.fw-topbar {
  position: relative;
  display: flex;
  align-items: center;
  gap: 10px;
  justify-content: center;
}
.fw-topbar-mid { display: flex; gap: 8px; align-items: center; }
.fw-topbar > .fw-icon-btn:first-child { position: absolute; left: 0; }

.fw-icon-btn {
  width: 42px; height: 42px;
  display: inline-flex; align-items: center; justify-content: center;
  border-radius: 14px;
  background: var(--bg-card);
  box-shadow: var(--shadow-soft, 0 3px 8px rgba(58,36,21,0.12));
  font-size: 1.4rem; font-weight: 700;
  color: var(--ink, #3a2415);
  border: none; cursor: pointer; flex-shrink: 0;
  transition: transform .12s ease;
}
.fw-icon-btn:hover { transform: translateY(-2px); color: var(--ink, #3a2415); }

.fw-pill {
  display: inline-flex; align-items: center; gap: 6px;
  padding: 8px 14px;
  border-radius: 999px;
  background: var(--bg-card);
  box-shadow: var(--shadow-soft, 0 3px 8px rgba(58,36,21,0.12));
  font-family: 'Fredoka', sans-serif;
  font-weight: 600; font-size: 1rem;
  color: var(--ink, #3a2415);
  border: none; cursor: default; white-space: nowrap;
}
/* Para (altın) + Elmas (gem) sayaçları */
.fw-para, .fw-elmas {
  gap: 4px;
  padding: 8px 16px;
}
.fw-para-icon {
  color: #f5c842; /* altın (para) */
  filter: drop-shadow(0 1px 2px rgba(201,150,10,.3));
  flex-shrink: 0;
}
.fw-elmas-icon {
  color: #b06fe6; /* elmas / gem moru */
  filter: drop-shadow(0 1px 2px rgba(120,60,180,.3));
  flex-shrink: 0;
}
.fw-para.shake, .fw-elmas.shake {
  animation: fw-diamond-shake .5s ease;
}
@keyframes fw-diamond-shake {
  0%,100% { transform: translateX(0); }
  20% { transform: translateX(-6px); }
  40% { transform: translateX(6px); }
  60% { transform: translateX(-4px); }
  80% { transform: translateX(4px); }
}

/* Let language selectors use the global styles from style.css */
.fw-target-lang {
  display: none;
}

#fwChaptersToggle {
  position: absolute;
  right: 0;
}

/* ---- Bölüm şeridi ---- */
.fw-chapters {
  display: none; /* hidden by default */
  position: absolute;
  top: 124px; /* just below topbar */
  left: 12px;
  right: 12px;
  max-height: 240px;
  background: var(--bg-card, #fff7e2);
  border: 2px solid var(--frame-wood-lt, #e3b36f);
  box-shadow: 0 8px 24px rgba(58, 36, 21, 0.24);
  border-radius: 18px;
  padding: 12px;
  z-index: 100;
  flex-flow: row wrap;
  gap: 8px;
  overflow-y: auto;
  scrollbar-width: thin;
  justify-content: center;
}
.fw-chapters.open {
  display: flex;
  animation: fw-chapters-slide 0.3s cubic-bezier(0.16, 1, 0.3, 1);
}

@keyframes fw-chapters-slide {
  0% { transform: translateY(-10px); opacity: 0; }
  100% { transform: translateY(0); opacity: 1; }
}
.fw-chip {
  flex: 0 0 auto;
  width: 46px; height: 46px;
  border-radius: 14px;
  border: 2px solid var(--bg-parchment-2, #f3dfae);
  background: var(--bg-card);
  font-family: 'Fredoka', sans-serif;
  font-weight: 700; font-size: 1.05rem;
  color: var(--ink, #3a2415);
  cursor: pointer; position: relative;
  display: inline-flex; align-items: center; justify-content: center;
  transition: transform .12s ease, border-color .12s ease;
}
.fw-chip:hover:not(.locked) { transform: translateY(-2px); }
.fw-chip.active { border-color: var(--fw-magenta); box-shadow: 0 0 0 3px var(--fw-magenta-soft); }
.fw-chip.completed { background: var(--accent-green, #4caf50); color: #fff; border-color: transparent; }
.fw-chip.completed::after { content: '✓'; position: absolute; top: -4px; right: -4px; background: #fff; color: var(--accent-green,#4caf50); border-radius: 50%; width: 18px; height: 18px; font-size: .7rem; display: flex; align-items: center; justify-content: center; box-shadow: 0 1px 3px rgba(0,0,0,.2); }
.fw-chip.locked { opacity: .5; cursor: not-allowed; }
.fw-chip.locked::before { content: '🔒'; position: absolute; font-size: 1rem; }
.fw-chip.locked span { opacity: 0; }

/* ---- Tahta ---- */
.fw-board {
  flex: 1;
  min-height: 0;
  display: flex; flex-direction: column;
  justify-content: space-between;
  gap: 10px;
}

/* Crossword grid */
.fw-grid-wrap { flex: 1; min-height: 0; display: flex; align-items: center; justify-content: center; padding: 2px; }
.fw-grid {
  display: grid;
  gap: 5px;
  width: min(100%, 440px);
  max-width: 100%;
}
.fw-cell { position: relative; aspect-ratio: 1 / 1; }
.fw-cell.empty { visibility: hidden; }
.fw-cell .box {
  position: absolute; inset: 0;
  border-radius: clamp(5px, 1.6vw, 9px);
  background: var(--fw-cell);
  box-shadow: inset 0 -2px 0 rgba(58,36,21,0.08), 0 2px 4px rgba(58,36,21,0.10);
  display: flex; align-items: center; justify-content: center;
  font-family: 'Fredoka', sans-serif; font-weight: 700;
  font-size: clamp(0.9rem, 4.4vw, 1.5rem);
  color: var(--fw-cell-ink);
  text-transform: uppercase;
  transition: background .18s ease, transform .18s ease;
}
.fw-cell.active .box { background: #fff; box-shadow: inset 0 0 0 2px var(--fw-cell-word-color, var(--fw-magenta)), 0 2px 6px rgba(226,55,193,0.18); }
.fw-cell .ch { opacity: 0; transform: scale(.4); transition: opacity .18s ease, transform .18s ease; }
.fw-cell.revealed .ch { opacity: 1; transform: scale(1); }
.fw-cell.revealed .box { background: var(--fw-cell-word-color, var(--fw-magenta)); color: #fff; }
.fw-cell.pop .box { animation: fw-pop .4s ease; }
/* acrostic: dikey anahtar sütunu vurgusu (ilk-harf sütunu = anahtar kelime) */
.fw-cell.acrostic-key .box { box-shadow: inset 0 0 0 2px var(--fw-magenta), 0 2px 6px rgba(226,55,193,0.22); }
.fw-cell.acrostic-key:not(.revealed) .box { background: var(--fw-magenta-soft); }

@keyframes fw-pop {
  0% { transform: scale(.5); }
  55% { transform: scale(1.18); }
  100% { transform: scale(1); }
}

/* ---- Alt bölüm: kelime + çark ---- */
.fw-bottom { flex: 0 0 auto; display: flex; flex-direction: column; align-items: center; gap: 8px; }

/* Çark + sol/sağ güç butonları yan yana */
.fw-wheel-row {
  display: flex;
  align-items: flex-end;
  justify-content: center;
  gap: 10px;
  width: 100%;
}

/* Güç butonları (İpucu / Balta) */
.fw-power-btn {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 3px;
  padding: 10px 8px 8px;
  border-radius: 16px;
  background: var(--bg-card, #fff7e2);
  border: 2px solid var(--frame-wood-lt, #e3b36f);
  box-shadow: 0 3px 0 var(--frame-wood, #c08652), 0 4px 12px rgba(58,36,21,.12);
  cursor: pointer;
  transition: transform .12s ease, box-shadow .12s ease, opacity .12s ease;
  min-width: 52px;
  flex-shrink: 0;
  position: relative;
}
.fw-power-btn:hover:not(:disabled) {
  transform: translateY(-3px);
  box-shadow: 0 5px 0 var(--frame-wood, #c08652), 0 6px 16px rgba(58,36,21,.16);
}
.fw-power-btn:active:not(:disabled) {
  transform: translateY(1px);
  box-shadow: 0 1px 0 var(--frame-wood, #c08652);
}
.fw-power-btn:disabled {
  opacity: .4;
  cursor: not-allowed;
}
.fw-power-btn.active {
  border-color: #e0533f;
  box-shadow: 0 0 0 3px rgba(224,83,63,.3), 0 3px 0 var(--frame-wood, #c08652);
  animation: fw-axe-pulse 1.2s ease infinite;
}
.fw-power-icon {
  display: block;
}
.fw-power-count {
  font-family: 'Fredoka', sans-serif;
  font-weight: 700;
  font-size: .85rem;
  color: var(--ink, #3a2415);
  line-height: 1;
}
.fw-power-cost {
  font-family: 'Fredoka', sans-serif;
  font-weight: 600;
  font-size: .65rem;
  color: #c9960a;
  line-height: 1;
}

@keyframes fw-axe-pulse {
  0%,100% { box-shadow: 0 0 0 3px rgba(224,83,63,.3), 0 3px 0 var(--frame-wood, #c08652); }
  50% { box-shadow: 0 0 0 6px rgba(224,83,63,.2), 0 3px 0 var(--frame-wood, #c08652); }
}

/* Axe hedefleme modu — hücreler kırmızı titreşim */
.fw-grid.axe-targeting .fw-cell:not(.empty):not(.revealed) .box {
  cursor: crosshair;
  animation: fw-axe-target-pulse 1s ease infinite;
}
@keyframes fw-axe-target-pulse {
  0%,100% { box-shadow: inset 0 0 0 2px rgba(224,83,63,.4), 0 2px 4px rgba(58,36,21,.10); }
  50% { box-shadow: inset 0 0 0 3px rgba(224,83,63,.7), 0 2px 8px rgba(224,83,63,.2); }
}

/* Axe vuruş efekti */
.fw-cell.axe-hit .box {
  animation: fw-axe-hit .4s ease !important;
}
@keyframes fw-axe-hit {
  0% { transform: scale(1); }
  15% { transform: scale(0.8) rotate(-5deg); }
  40% { transform: scale(1.15) rotate(3deg); }
  100% { transform: scale(1) rotate(0deg); }
}

.fw-current { min-height: 46px; display: flex; align-items: center; justify-content: center; }
.fw-current span {
  display: inline-block;
  padding: 7px 20px; border-radius: 999px;
  background: var(--fw-selection-color); color: #fff;
  font-family: 'Fredoka', sans-serif; font-weight: 700;
  font-size: 1.4rem; letter-spacing: 2px; text-transform: uppercase;
  transform: scale(0); transition: transform .15s cubic-bezier(.34,1.56,.64,1);
  box-shadow: 0 4px 10px rgba(226,55,193,0.35);
  min-width: 40px; text-align: center;
}
.fw-current.show span { transform: scale(1); }
.fw-current.wrong span { background: #e0533f; animation: fw-shake .4s ease; }
.fw-current.correct span { background: var(--accent-green, #4caf50); }

@keyframes fw-shake {
  0%,100% { transform: scale(1) translateX(0); }
  20% { transform: scale(1) translateX(-8px); }
  40% { transform: scale(1) translateX(8px); }
  60% { transform: scale(1) translateX(-6px); }
  80% { transform: scale(1) translateX(6px); }
}

/* Harf çarkı */
.fw-wheel {
  position: relative;
  width: min(72vw, 280px);
  aspect-ratio: 1 / 1;
  margin: 0 auto;
  flex: 0 0 auto;
  touch-action: none;
  -webkit-tap-highlight-color: transparent;
}
/* Harfleri çevreleyen halka */
.fw-ring {
  position: absolute; top: 50%; left: 50%;
  width: 94%; height: 94%;
  transform: translate(-50%, -50%);
  border-radius: 50%;
  border: 3px solid rgba(255, 255, 255, 0.8);
  background: rgba(255, 255, 255, 0.14);
  box-shadow: 0 6px 18px rgba(58, 36, 21, 0.10), inset 0 1px 0 rgba(255, 255, 255, 0.6);
  z-index: 0; pointer-events: none;
}

/* Line — seçili butonun (grid) rengiyle aynı magenta */
.fw-line {
  position: absolute; inset: 0;
  width: 100%; height: 100%;
  overflow: visible;
  pointer-events: none;
  z-index: 1;
  filter: drop-shadow(0 4px 7px rgba(166, 13, 140, 0.18));
}
.fw-line-border,
.fw-line-fill {
  fill: none;
  stroke-linecap: round;
  stroke-linejoin: round;
}
.fw-line-border {
  stroke: var(--fw-selection-color);
  stroke-width: var(--fw-line-border-width);
  opacity: 1;
}
.fw-line-fill {
  stroke: var(--fw-selection-color);
  stroke-width: var(--fw-line-fill-width);
}

.fw-nodes { position: absolute; inset: 0; z-index: 2; }
.fw-node {
  position: absolute;
  display: flex; align-items: center; justify-content: center;
  border-radius: 50%;
  background: transparent;                 /* başlangıçta arka plan yok — sadece harf */
  color: var(--fw-cell-ink);
  font-family: 'Fredoka', sans-serif; font-weight: 700;
  text-transform: uppercase;
  box-shadow: none;
  cursor: pointer;
  transition: background .12s ease, color .12s ease, transform .1s ease, box-shadow .12s ease;
  will-change: transform;
  touch-action: none;
}
/* Seçilince grid rengindeki (magenta) daire oluşur */
.fw-node.selected {
  z-index: 4;
  background: var(--fw-selection-color);
  color: #fff;
  transform: scale(1.12);
  box-shadow: 0 8px 18px rgba(226,55,193,0.42), inset 0 -2px 0 rgba(166,13,140,0.18);
}
.fw-node.wrong { animation: fw-node-shake .3s ease; }

@keyframes fw-node-shake {
  0%,100% { transform: scale(1) translateX(0); }
  25% { transform: scale(1) translateX(-4px); }
  75% { transform: scale(1) translateX(4px); }
}

.fw-shuffle {
  position: absolute; left: 50%; top: 50%; transform: translate(-50%, -50%);
  width: 46px; height: 46px; border-radius: 50%;
  border: none; cursor: pointer; z-index: 3;
  background: var(--bg-card);
  box-shadow: 0 3px 8px rgba(58,36,21,0.2);
  font-size: 1.2rem;
  transition: transform .25s ease, opacity .15s ease;
}
.fw-shuffle:hover { transform: translate(-50%, -50%) rotate(180deg); }
.fw-wheel.dragging .fw-shuffle { opacity: 0; pointer-events: none; }

/* ---- Overlay (yükleniyor / sonuç) ---- */
.fw-overlay {
  position: fixed; inset: 0; z-index: 1200;
  display: flex; align-items: center; justify-content: center;
  background: rgba(40, 24, 12, 0.55); backdrop-filter: blur(3px);
  padding: 20px;
}
.fw-loading-card, .fw-result-card {
  background: var(--bg-card);
  border-radius: 22px;
  padding: 28px 26px;
  text-align: center;
  box-shadow: 0 12px 40px rgba(0,0,0,0.3);
  max-width: 380px; width: 100%;
  animation: fw-pop .35s ease;
}
.fw-result-card h2 { font-family: 'Fredoka', sans-serif; margin: 0 0 6px; color: var(--ink, #3a2415); }
.fw-result-score { font-size: 1.5rem; font-weight: 800; color: var(--fw-magenta); margin: 0 0 14px; }
.fw-result-words {
  display: flex; flex-direction: column; gap: 6px;
  margin-bottom: 18px; max-height: 220px; overflow-y: auto;
  text-align: left;
}
.fw-result-words .row {
  display: flex; justify-content: space-between; gap: 10px;
  padding: 8px 12px; border-radius: 10px;
  background: var(--bg-parchment, #fbf0d6);
  font-weight: 600;
}
.fw-result-words .row .w { color: var(--fw-magenta-dk); text-transform: uppercase; font-family: 'Fredoka', sans-serif; }
.fw-result-words .row .t { color: var(--ink, #3a2415); opacity: .8; }
.fw-result-btns { display: flex; flex-direction: column; gap: 10px; }
.fw-text-btn { background: none; border: none; color: var(--ink, #3a2415); opacity: .7; cursor: pointer; font-family: 'Nunito', sans-serif; font-weight: 700; padding: 6px; }
.fw-text-btn:hover { opacity: 1; }

/* spinner — style.css'te yoksa fallback */
.fw-loading-card .spinner {
  width: 40px; height: 40px; margin: 0 auto 12px;
  border: 4px solid var(--bg-parchment-2, #f3dfae);
  border-top-color: var(--fw-magenta);
  border-radius: 50%;
  animation: fw-spin .8s linear infinite;
}
@keyframes fw-spin { to { transform: rotate(360deg); } }

/* ---- Word Badge ---- */
.fw-word-badge-container {
  display: flex;
  justify-content: center;
  align-items: center;
  margin: 6px 0;
  flex: 0 0 auto;
}
.fw-word-badge {
  display: inline-flex;
  align-items: center;
  gap: 12px;
  padding: 8px 20px;
  border-radius: 999px;
  background: var(--bg-card, #fff7e2);
  border: 2px solid var(--fw-badge-color, var(--fw-magenta));
  box-shadow: 0 4px 12px rgba(58, 36, 21, 0.12);
  font-family: 'Fredoka', sans-serif;
  font-weight: 700;
  font-size: 1.2rem;
  color: var(--ink, #3a2415);
  animation: fw-badge-pop 0.3s cubic-bezier(0.34, 1.56, 0.64, 1);
  transition: border-color 0.2s ease;
}
.fw-word-badge-text {
  letter-spacing: 0.5px;
}
.fw-word-badge-sound {
  background: var(--bg-parchment-2, #f3dfae);
  border: none;
  border-radius: 50%;
  width: 30px;
  height: 30px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  font-size: 0.95rem;
  cursor: pointer;
  box-shadow: 0 2px 5px rgba(0,0,0,0.1);
  transition: transform 0.12s ease, background 0.12s ease;
}
.fw-word-badge-sound:hover {
  transform: scale(1.15);
  background: var(--bg-parchment, #fbf0d6);
}
.fw-word-badge-sound:active {
  transform: scale(0.95);
}

@keyframes fw-badge-pop {
  0% { transform: scale(0.85); opacity: 0; }
  100% { transform: scale(1); opacity: 1; }
}

/* ---- Mobil ---- */
@media (max-width: 760px) {
  .fw-game { padding: 70px 10px 84px; }
  .fw-wheel { width: min(62vw, 240px); }
  .fw-current span { font-size: 1.2rem; }
  .fw-power-btn { min-width: 44px; padding: 8px 6px 6px; }
  .fw-power-icon { width: 22px; height: 22px; }
  .fw-power-count { font-size: .75rem; }
  .fw-wheel-row { gap: 6px; }
}
