:root {
  --bg-page: #0b1220;
  --phone-bg: #0f172a;
  --card: #ffffff;
  --card-text: #1e293b;
  --muted: #64748b;
  --line: #e2e8f0;
  --primary: #4f46e5;
  --primary-hover: #4338ca;
  --explain: #0ea5e9;
  --star: #f59e0b;
  --star-off: #cbd5e1;
  --chip-active: #4f46e5;
  --ok: #16a34a;
  --lock: #94a3b8;
  --radius: 16px;
}

* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }
[hidden] { display: none !important; }

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

body {
  font-family: "Inter", -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
  background:
    radial-gradient(900px 500px at 50% -20%, #1e293b, transparent),
    var(--bg-page);
  min-height: 100vh;
  display: flex;
  justify-content: center;
  align-items: stretch;
  padding: 0;
  color: #e2e8f0;
}

/* ---- Telefon çerçevesi: masaüstünde bile dar dikey sütun ---- */
.phone {
  position: relative;
  width: 100%;
  max-width: 430px;
  min-height: 100vh;
  background: var(--phone-bg);
  display: flex;
  flex-direction: column;
  overflow: hidden;
}
@media (min-width: 480px) {
  body { align-items: center; padding: 24px 0; }
  .phone {
    min-height: auto;
    height: min(880px, calc(100vh - 48px));
    border-radius: 30px;
    box-shadow: 0 30px 70px rgba(0,0,0,0.5), 0 0 0 10px #1e293b, 0 0 0 11px #334155;
  }
}

.screen {
  flex: 1;
  display: flex;
  flex-direction: column;
  padding: 22px 18px 18px;
  overflow-y: auto;
  -webkit-overflow-scrolling: touch;
}

/* ---- Marka ---- */
.brand { display: flex; align-items: center; gap: 10px; }
.brand-mark {
  display: grid; place-items: center;
  width: 38px; height: 38px; border-radius: 11px;
  background: linear-gradient(135deg, #6366f1, #8b5cf6);
  font-weight: 800; font-size: 14px; color: #fff; letter-spacing: 0.5px;
}
.brand-name { font-weight: 700; font-size: 17px; color: #f1f5f9; }

/* ======================= HOME ======================= */
.home-head { margin-bottom: 18px; }
.home-tagline { margin: 12px 2px 0; color: #94a3b8; font-size: 14px; line-height: 1.5; }

.overall {
  background: #111c33;
  border: 1px solid #1e293b;
  border-radius: 14px;
  padding: 14px 16px;
  margin-bottom: 20px;
}
.overall-top { display: flex; justify-content: space-between; font-size: 13px; color: #cbd5e1; font-weight: 600; }
.overall-bar { height: 9px; background: #1e293b; border-radius: 999px; margin: 9px 0 6px; overflow: hidden; }
.overall-fill { height: 100%; width: 0%; background: linear-gradient(90deg, #6366f1, #22c55e); border-radius: 999px; transition: width 0.5s ease; }
.overall-sub { font-size: 12px; color: #94a3b8; }

/* ---- Seviye haritası (oyunvari kareler) ---- */
.map { display: flex; flex-direction: column; gap: 14px; flex: 1; }

.tile {
  position: relative;
  display: flex; align-items: center; gap: 14px;
  background: #111c33;
  border: 1px solid #24324d;
  border-radius: 16px;
  padding: 14px;
  cursor: pointer;
  transition: transform 0.08s ease, border-color 0.15s ease, background 0.15s ease;
  text-align: left;
  width: 100%;
  color: inherit;
  font-family: inherit;
}
.tile:active { transform: scale(0.99); }
.tile.unlocked:hover { border-color: var(--primary); }
.tile.locked { opacity: 0.55; cursor: not-allowed; }
.tile.done { border-color: #16a34a; background: #0f2a1c; }

.tile-num {
  flex-shrink: 0;
  width: 54px; height: 54px; border-radius: 14px;
  display: grid; place-items: center;
  font-size: 22px; font-weight: 800; color: #fff;
  background: linear-gradient(135deg, #6366f1, #8b5cf6);
}
.tile.locked .tile-num { background: #334155; }
.tile.done .tile-num { background: linear-gradient(135deg, #22c55e, #16a34a); }

.tile-body { flex: 1; min-width: 0; }
.tile-name { font-weight: 700; font-size: 15px; color: #f1f5f9; }
.tile-cefr { font-size: 12px; color: #94a3b8; margin-left: 6px; font-weight: 500; }
.tile-meta { font-size: 12px; color: #94a3b8; margin-top: 4px; }
.tile-bar { height: 6px; background: #1e293b; border-radius: 999px; margin-top: 8px; overflow: hidden; }
.tile-fill { height: 100%; width: 0%; background: linear-gradient(90deg, #6366f1, #22c55e); border-radius: 999px; transition: width 0.4s ease; }
.tile-state { flex-shrink: 0; font-size: 20px; }

.home-actions { margin-top: 20px; display: flex; flex-direction: column; gap: 10px; }

/* ======================= AŞAMA GRIDI ======================= */
.stage-grid {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 12px;
  padding-bottom: 10px;
}
.stage-tile {
  position: relative;
  aspect-ratio: 1 / 1;
  border-radius: 14px;
  border: 1px solid #24324d;
  background: #111c33;
  display: flex; flex-direction: column; align-items: center; justify-content: center;
  gap: 4px; cursor: pointer; color: #e2e8f0; font-family: inherit;
  transition: transform 0.08s ease, border-color 0.15s ease;
}
.stage-tile:active { transform: scale(0.96); }
.stage-tile.unlocked:hover { border-color: var(--primary); }
.stage-tile.locked { opacity: 0.45; cursor: not-allowed; }
.stage-tile.done { border-color: #16a34a; background: #0f2a1c; }
.stage-tile.current { border-color: var(--primary); box-shadow: 0 0 0 2px rgba(79,70,229,0.35); }
.stage-num { font-size: 20px; font-weight: 800; }
.stage-mini { font-size: 10px; color: #94a3b8; }
.stage-dots { display: flex; gap: 3px; margin-top: 2px; }
.stage-dot { width: 5px; height: 5px; border-radius: 50%; background: #334155; }
.stage-dot.on { background: var(--star); }
.stage-lock { font-size: 18px; }
.stage-check { position: absolute; top: 6px; right: 8px; color: #22c55e; font-size: 13px; font-weight: 800; }

/* ======================= PRACTICE ======================= */
.practice { padding-bottom: 0; }
.practice-head {
  display: flex; align-items: center; gap: 12px;
  padding-bottom: 14px;
}
.icon-btn {
  border: none; background: #1e293b; color: #e2e8f0;
  width: 38px; height: 38px; border-radius: 11px; font-size: 20px;
  cursor: pointer; flex-shrink: 0;
}
.icon-btn:hover { background: #334155; }
.practice-title { flex: 1; min-width: 0; display: flex; flex-direction: column; }
.pt-level { font-size: 12px; color: #94a3b8; font-weight: 600; }
.pt-skill { font-size: 15px; color: #f1f5f9; font-weight: 700; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.pt-box { font-size: 13px; color: #94a3b8; background: #1e293b; padding: 6px 10px; border-radius: 999px; flex-shrink: 0; }

/* Kart */
.card {
  background: var(--card);
  color: var(--card-text);
  border-radius: var(--radius);
  padding: 22px 20px;
  display: flex; flex-direction: column; gap: 16px;
  flex: 1;
  overflow-y: auto;
}
.prompt-label {
  font-size: 12px; font-weight: 600; text-transform: uppercase;
  letter-spacing: 0.5px; color: var(--muted);
}
.tr-sentence { font-size: 26px; font-weight: 800; line-height: 1.35; margin: 0; color: #0f172a; }

/* Dokunulabilir kelime ipucu */
.gloss {
  cursor: pointer;
  border-bottom: 2px dotted #a5b4fc;
  transition: color 0.1s ease;
}
.gloss:hover, .gloss:active { color: var(--primary); border-bottom-color: var(--primary); }

.gloss-tip {
  position: absolute;
  transform: translate(-50%, -100%);
  background: #0f172a;
  color: #fff;
  font-size: 14px;
  font-weight: 600;
  padding: 7px 12px;
  border-radius: 9px;
  white-space: nowrap;
  z-index: 30;
  box-shadow: 0 8px 24px rgba(0,0,0,0.35);
  opacity: 0;
  transition: opacity 0.12s ease;
}
.gloss-tip.show { opacity: 1; }
.gloss-tip::after {
  content: "";
  position: absolute; left: 50%; top: 100%; transform: translateX(-50%);
  border: 6px solid transparent; border-top-color: #0f172a;
}

/* İngilizce cevap + seslendirme */
.en-row { display: flex; align-items: flex-start; gap: 10px; }
.en-row .en-sentence { flex: 1; }
.speak-btn {
  flex-shrink: 0;
  border: none; background: #eef2ff; color: #4f46e5;
  width: 42px; height: 42px; border-radius: 11px; font-size: 20px;
  cursor: pointer; transition: background 0.12s ease, transform 0.08s ease;
}
.speak-btn:hover { background: #e0e7ff; }
.speak-btn:active { transform: scale(0.92); }
.speak-btn.speaking { background: #4f46e5; color: #fff; }

/* Önceki performans şeridi */
.history {
  display: flex; align-items: center; flex-wrap: wrap; gap: 8px;
  background: #f8fafc; border: 1px solid var(--line);
  border-radius: 10px; padding: 8px 12px; margin-top: -4px;
}
.hist-label { font-size: 12px; color: var(--muted); font-weight: 600; }
.hist-stars { font-size: 16px; letter-spacing: 1px; }
.hist-stars .hs-on { color: var(--star); }
.hist-stars .hs-off { color: var(--star-off); }
.hist-tags { display: flex; flex-wrap: wrap; gap: 6px; }
.hist-tag {
  font-size: 11px; font-weight: 600; color: #9a3412;
  background: #ffedd5; border: 1px solid #fed7aa;
  padding: 3px 8px; border-radius: 999px;
}

.reveal { border-top: 1px solid var(--line); padding-top: 16px; animation: fade 0.22s ease; }
@keyframes fade { from { opacity: 0; transform: translateY(6px);} to { opacity: 1; transform: none; } }

.tense-badge {
  display: inline-block; font-size: 12px; font-weight: 600;
  color: var(--primary); background: #eef2ff; padding: 5px 12px;
  border-radius: 999px; margin-bottom: 10px;
}
.en-sentence { font-size: 22px; font-weight: 700; margin: 0; color: #4f46e5; line-height: 1.35; }

.rating-block { display: flex; flex-direction: column; gap: 6px; }
.rating-title { font-weight: 700; font-size: 15px; }
.stars { display: flex; gap: 4px; }
.star {
  background: none; border: none; cursor: pointer; padding: 2px;
  font-size: 36px; line-height: 1; color: var(--star-off);
  transition: color 0.1s ease, transform 0.08s ease;
}
.star:active { transform: scale(1.2); }
.star.on { color: var(--star); }
.rating-hint { font-size: 12px; color: var(--muted); }

.error-block {
  background: #fff7ed; border: 1px solid #fed7aa; border-radius: 14px;
  padding: 14px; display: flex; flex-direction: column; gap: 10px;
  animation: fade 0.2s ease;
}
.error-title { font-weight: 700; font-size: 14px; color: #9a3412; }
.error-options { display: flex; flex-wrap: wrap; gap: 8px; }
.chip {
  border: 1px solid var(--line); background: #fff; color: var(--card-text);
  border-radius: 999px; padding: 8px 13px; font-size: 13px; font-weight: 500;
  cursor: pointer; font-family: inherit; transition: all 0.12s ease;
}
.chip:hover { border-color: var(--chip-active); color: var(--chip-active); }
.chip.active { background: var(--chip-active); border-color: var(--chip-active); color: #fff; }

.explanation-title { font-weight: 700; font-size: 15px; margin-bottom: 6px; color: #0f172a; }
.explanation-text { margin: 0; font-size: 15px; line-height: 1.6; color: #334155; }

/* Aksiyon barı (alt sabit) */
.actions {
  padding: 14px 0 4px;
  display: flex; flex-direction: column; gap: 10px;
}
.actions.sticky { position: sticky; bottom: 0; background: linear-gradient(to top, var(--phone-bg) 70%, transparent); }
.actions-row { display: flex; gap: 10px; }
.actions-row .btn { flex: 1; }

/* Butonlar */
.btn {
  border: none; border-radius: 12px; padding: 14px 18px;
  font-size: 15px; font-weight: 700; cursor: pointer; font-family: inherit;
  transition: background 0.15s ease, transform 0.05s ease;
}
.btn:active { transform: translateY(1px); }
.btn-block { width: 100%; }
.btn-sm { padding: 10px 14px; font-size: 13px; font-weight: 600; }
.btn-primary { background: var(--primary); color: #fff; }
.btn-primary:hover { background: var(--primary-hover); }
.btn-explain { background: #e0f2fe; color: #0369a1; }
.btn-explain:hover { background: #bae6fd; }
.btn-ghost { background: #1e293b; color: #cbd5e1; }
.btn-ghost:hover { background: #334155; }

/* Toast */
.toast {
  position: absolute; left: 50%; bottom: 24px; transform: translateX(-50%) translateY(20px);
  background: #16a34a; color: #fff; padding: 12px 18px; border-radius: 12px;
  font-weight: 700; font-size: 14px; box-shadow: 0 10px 30px rgba(0,0,0,0.4);
  opacity: 0; transition: opacity 0.25s ease, transform 0.25s ease; pointer-events: none;
  max-width: 90%; text-align: center;
}
.toast.show { opacity: 1; transform: translateX(-50%) translateY(0); }

@media (max-width: 380px) {
  .tr-sentence { font-size: 23px; }
  .en-sentence { font-size: 20px; }
  .star { font-size: 32px; }
}
