:root {
  --purple: #7b3fe4;
  --purple-d: #5b2bb5;
  --yellow: #ffd93d;
  --green: #22c55e;
  --red: #ef4444;
  --ink: #1e1b3a;
  --panel: rgba(255, 255, 255, 0.96);
  --font: "Trebuchet MS", "Segoe UI", "Nunito", Arial, sans-serif;
}
* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }
html, body {
  margin: 0; height: 100%; overflow: hidden;
  background: #9fd3ff; color: var(--ink);
  font-family: var(--font);
  user-select: none; -webkit-user-select: none;
  touch-action: none;
}
#game, #game canvas { position: fixed; inset: 0; width: 100%; height: 100%; display: block; }
.hidden { display: none !important; }

/* ---------- Butonlar ---------- */
.btn {
  font-family: var(--font); font-weight: 800; font-size: 18px;
  border: none; border-radius: 16px; padding: 12px 20px; cursor: pointer;
  background: #fff; color: var(--ink);
  box-shadow: 0 5px 0 #c9c3e6, 0 8px 18px rgba(0,0,0,0.12);
  transition: transform 0.08s, box-shadow 0.08s, filter 0.15s;
}
.btn:hover { filter: brightness(1.05); transform: translateY(-1px); }
.btn:active { transform: translateY(4px); box-shadow: 0 1px 0 #c9c3e6; }
.btn.primary { background: linear-gradient(180deg, #8f5bff, var(--purple)); color: #fff; box-shadow: 0 5px 0 #4a1fa0, 0 8px 18px rgba(91,43,181,0.35); }
.btn.primary:active { box-shadow: 0 1px 0 #4a1fa0; }
.btn.danger { background: #fff0f0; color: #c62828; box-shadow: 0 5px 0 #f3b9b9; }
.btn.big { font-size: 22px; padding: 16px 26px; }
.btn.small { font-size: 14px; padding: 8px 12px; border-radius: 12px; box-shadow: 0 3px 0 #c9c3e6; }
.btn.small.off { opacity: 0.5; text-decoration: line-through; }
.btn:focus-visible { outline: 3px solid var(--yellow); outline-offset: 2px; }
.icon-btn {
  width: 44px; height: 44px; border-radius: 14px; border: none; cursor: pointer;
  background: rgba(255,255,255,0.9); font-size: 20px; box-shadow: 0 3px 0 rgba(0,0,0,0.15);
}

/* ---------- Ekranlar ---------- */
.screen {
  position: fixed; inset: 0; display: none;
  align-items: center; justify-content: center;
  padding: 16px; z-index: 20;
}
.screen.active { display: flex; }
.screen.dim { background: rgba(20, 12, 50, 0.45); backdrop-filter: blur(2px); }
.screen.transparent { pointer-events: none; }
.panel {
  background: var(--panel); border-radius: 28px; padding: 26px;
  box-shadow: 0 20px 50px rgba(20, 10, 60, 0.3), inset 0 -6px 0 rgba(0,0,0,0.06);
  max-width: 100%; max-height: 100%; overflow: auto;
  animation: pop 0.28s cubic-bezier(.2,1.4,.5,1);
}
@keyframes pop { from { transform: scale(0.85); opacity: 0; } to { transform: scale(1); opacity: 1; } }
.panel h2 { margin: 0 0 14px; font-size: 28px; text-align: center; color: var(--purple-d); }
.small-panel { width: 440px; text-align: center; }
.menu-buttons { display: flex; flex-direction: column; gap: 12px; margin-top: 14px; }
.menu-buttons.row { flex-direction: row; justify-content: center; }
.menu-small { display: flex; gap: 8px; justify-content: center; margin-top: 16px; flex-wrap: wrap; }

/* Başlık */
.title-panel { width: 420px; text-align: center; }
.logo h1 { margin: 4px 0 6px; font-size: 40px; line-height: 1; color: #e30a17; text-shadow: 0 3px 0 #ffd6d9; }
.logo h1 span { color: var(--purple-d); font-size: 34px; text-shadow: 0 3px 0 #e2d6ff; }
.logo-flag { font-size: 44px; display: block; animation: wave 2s ease-in-out infinite; }
@keyframes wave { 0%,100% { transform: rotate(-6deg); } 50% { transform: rotate(6deg); } }
.subtitle { margin: 6px 0 10px; font-size: 16px; color: #5b5680; }
.save-info { font-size: 15px; color: #4b4570; background: #f3efff; border-radius: 14px; padding: 8px 12px; margin: 8px 0 4px; }
.save-info:empty { display: none; }

/* Karakter */
#scr-char { flex-direction: column; justify-content: space-between; padding: 20px 16px 28px; }
.char-top { text-align: center; padding: 14px 22px; }
.char-top h2 { margin-bottom: 8px; }
.panel.slim { border-radius: 22px; }
.name-label { font-weight: 800; font-size: 16px; }
.name-label input {
  font-family: var(--font); font-size: 17px; font-weight: 700; padding: 8px 12px;
  border-radius: 12px; border: 3px solid #d9d0ff; outline: none; width: 190px; margin-left: 6px;
}
.name-label input:focus { border-color: var(--purple); }
.char-choices { display: flex; gap: min(22vw, 220px); justify-content: center; width: 100%; }
.char-card {
  font-family: var(--font); cursor: pointer; border: none; border-radius: 22px;
  background: rgba(255,255,255,0.95); padding: 12px 26px; min-width: 140px;
  display: flex; flex-direction: column; align-items: center; gap: 2px;
  box-shadow: 0 6px 0 #c9c3e6, 0 10px 24px rgba(0,0,0,0.15); font-size: 20px;
  transition: transform 0.1s;
}
.char-card:hover { transform: translateY(-3px) scale(1.04); }
.char-card.selected { outline: 4px solid var(--yellow); }
.char-emoji { font-size: 34px; }

/* İl seçimi */
.levels-panel { width: min(1100px, 100%); height: min(760px, 100%); display: flex; flex-direction: column; padding: 18px; }
.levels-head { display: flex; align-items: center; gap: 12px; }
.levels-head h2 { margin: 0; flex: 1; text-align: left; }
.levels-summary { font-weight: 800; color: #5b5680; font-size: 15px; }
.legend { display: flex; flex-wrap: wrap; gap: 6px 12px; margin: 10px 0; font-size: 13px; font-weight: 700; }
.legend span { display: inline-flex; align-items: center; gap: 5px; }
.legend i { width: 12px; height: 12px; border-radius: 4px; display: inline-block; }
.levels-scroll { flex: 1; min-height: 0; overflow-y: auto; overflow-x: hidden; padding-right: 2px; }
/* Türkiye haritası */
.tr-map-wrap { position: relative; background: linear-gradient(180deg, #d7ecff, #eaf5ff); border-radius: 18px; padding: 8px; box-shadow: inset 0 -4px 0 rgba(0,0,0,0.04); }
.tr-map { display: block; width: 100%; height: auto; overflow: visible; }
.tr-map .prov { stroke: #fff; stroke-width: 1.2; stroke-linejoin: round; transition: filter 0.12s, opacity 0.12s; }
.tr-map .prov.open { cursor: pointer; }
.tr-map .prov.open:hover, .tr-map .prov.open.hover { filter: brightness(1.18) drop-shadow(0 0 4px rgba(255,255,255,0.9)); }
.tr-map .prov.locked { fill: #d8d3e4; }
.tr-map .prov.todo { fill-opacity: 0.55; }
.tr-map .prov.current { stroke: #7b3fe4; stroke-width: 3.2; animation: provPulse 1.2s infinite alternate; }
@keyframes provPulse { from { fill-opacity: 0.45; } to { fill-opacity: 0.95; } }
.tr-map .plbl { font: 800 11px var(--font); fill: #fff; text-anchor: middle; dominant-baseline: central; pointer-events: none; paint-order: stroke; stroke: rgba(0,0,0,0.35); stroke-width: 2.4px; }
.tr-map .plbl.locked { fill: #a39dbb; stroke: none; }
.tr-map .pin { pointer-events: none; }
.map-tip {
  position: absolute; pointer-events: none; transform: translate(-50%, calc(-100% - 12px));
  background: #fff; color: var(--ink); border-radius: 12px; padding: 6px 10px; font-weight: 800; font-size: 14px;
  box-shadow: 0 6px 18px rgba(0,0,0,0.18); white-space: nowrap; z-index: 2;
}
.map-tip .st { color: #f5a400; margin-left: 4px; }
.map-tip .sub { display: block; font-size: 12px; font-weight: 700; color: #6b6690; }
.map-hint { text-align: center; font-size: 14px; font-weight: 800; color: #6b6690; margin: 10px 0 8px; }
.level-grid {
  display: grid; gap: 8px; padding: 4px 4px 10px;
  grid-template-columns: repeat(auto-fill, minmax(112px, 1fr)); align-content: start;
}
.level {
  position: relative; border: none; cursor: pointer; font-family: var(--font);
  border-radius: 14px; padding: 8px 6px 6px; background: #fff; text-align: center;
  border-top: 6px solid var(--rc, #888); box-shadow: 0 3px 0 #ddd8ef, 0 4px 10px rgba(0,0,0,0.06);
  min-height: 78px; transition: transform 0.08s;
}
.level:hover:not(.locked) { transform: translateY(-2px); }
.level .plate { font-size: 13px; font-weight: 900; color: #fff; background: var(--rc, #888); border-radius: 8px; padding: 1px 7px; display: inline-block; }
.level .lname { display: block; font-weight: 800; font-size: 14px; margin-top: 4px; line-height: 1.1; color: var(--ink); overflow-wrap: anywhere; hyphens: auto; }
.level .lstars { display: block; font-size: 13px; color: #f5a400; letter-spacing: 1px; margin-top: 2px; min-height: 16px; }
.level.locked { background: #eeeaf5; cursor: not-allowed; opacity: 0.65; }
.level.locked .lname { color: #8a85a8; }
.level.current { outline: 3px solid var(--purple); animation: pulse 1.4s infinite; }
@keyframes pulse { 0%,100% { box-shadow: 0 0 0 0 rgba(123,63,228,0.5); } 50% { box-shadow: 0 0 0 6px rgba(123,63,228,0); } }
.level .cp { position: absolute; top: 4px; right: 6px; font-size: 13px; }

/* Nasıl oynanır */
.howto { width: 620px; }
.howto ul { padding-left: 20px; margin: 0 0 18px; font-size: 17px; line-height: 1.5; }
.howto li { margin-bottom: 8px; }
.howto .btn { display: block; margin: 0 auto; }

/* Bölüm girişi */
.intro-banner {
  display: flex; align-items: center; gap: 18px;
  background: rgba(255,255,255,0.96); border-radius: 26px; padding: 18px 30px;
  box-shadow: 0 16px 40px rgba(0,0,0,0.25);
  animation: slideIn 0.5s cubic-bezier(.2,1.3,.5,1);
}
@keyframes slideIn { from { transform: translateY(-40px) scale(0.8); opacity: 0; } to { transform: none; opacity: 1; } }
.intro-plate { font-size: 44px; font-weight: 900; color: #fff; background: #1f3b73; border-radius: 14px; padding: 6px 14px; border: 4px solid #fff; box-shadow: 0 0 0 3px #1f3b73; }
.intro-name { font-size: 44px; font-weight: 900; color: var(--purple-d); line-height: 1; }
.intro-meta { font-size: 17px; font-weight: 700; color: #5b5680; margin-top: 6px; }

/* HUD */
#hud {
  position: fixed; top: 0; left: 0; right: 0; z-index: 10;
  display: flex; align-items: flex-start; justify-content: space-between; gap: 10px;
  padding: 10px 14px; pointer-events: none;
}
#hud > * { pointer-events: auto; }
.hearts { display: flex; flex-wrap: wrap; gap: 2px; max-width: 300px; font-size: 26px; filter: drop-shadow(0 2px 0 rgba(0,0,0,0.2)); }
.hearts .h { display: inline-block; transition: transform 0.2s; }
.hearts .h.lost { filter: grayscale(1); opacity: 0.35; }
.hearts .hc { display: none; }
.hearts .h.pop { animation: heartpop 0.6s; }
@keyframes heartpop { 0% { transform: scale(1); } 40% { transform: scale(1.6); } 100% { transform: scale(1); } }
.hearts.shake { animation: shake 0.5s; }
@keyframes shake { 0%,100% { transform: translateX(0); } 20%,60% { transform: translateX(-6px); } 40%,80% { transform: translateX(6px); } }
.hud-left, .hud-right { flex: none; }
.hud-center { flex: 1; min-width: 0; max-width: 420px; text-align: center; }
.hud-province {
  display: inline-block; max-width: 100%; overflow: hidden; text-overflow: ellipsis; vertical-align: top;
  white-space: nowrap; background: rgba(255,255,255,0.92); border-radius: 14px; padding: 6px 14px;
  font-weight: 900; font-size: 18px; box-shadow: 0 3px 0 rgba(0,0,0,0.12);
}
.hud-province .rg { font-size: 13px; font-weight: 700; color: #6b6690; margin-left: 6px; }
.progress { height: 10px; background: rgba(255,255,255,0.7); border-radius: 10px; margin: 8px auto 0; overflow: hidden; max-width: 320px; }
.progress-bar { height: 100%; width: 0; background: linear-gradient(90deg, #ffd93d, #ff8a00); border-radius: 10px; transition: width 0.2s; }
.hud-right { display: flex; gap: 8px; align-items: center; }
.hud-stat { background: rgba(255,255,255,0.92); border-radius: 14px; padding: 8px 12px; font-weight: 900; font-size: 17px; box-shadow: 0 3px 0 rgba(0,0,0,0.12); white-space: nowrap; }

/* Dokunmatik */
#touch { position: fixed; left: 0; right: 0; bottom: 0; z-index: 9; display: flex; justify-content: space-between; align-items: flex-end; padding: 16px 20px 22px; pointer-events: none; }
.touch-left { display: flex; gap: 14px; }
.touch-btn {
  pointer-events: auto; width: 76px; height: 76px; border-radius: 50%; border: none;
  background: rgba(255,255,255,0.78); font-size: 30px; font-weight: 900; color: var(--purple-d);
  box-shadow: 0 5px 0 rgba(0,0,0,0.18); touch-action: none;
}
.touch-btn.jump { width: 92px; height: 92px; font-size: 38px; background: rgba(255,217,61,0.9); }
.touch-btn.pressed { transform: translateY(3px); box-shadow: 0 2px 0 rgba(0,0,0,0.18); }

/* Soru paneli */
.question-panel { width: 680px; padding: 22px 24px; }
.q-head { display: flex; align-items: center; gap: 10px; margin-bottom: 10px; }
.q-badge { background: var(--purple); color: #fff; font-weight: 900; border-radius: 12px; padding: 5px 12px; font-size: 15px; }
.q-badge.bonus { background: linear-gradient(90deg, #ffb300, #ff7a00); }
.q-province { flex: 1; font-weight: 800; color: #5b5680; font-size: 16px; }
.q-time { font-weight: 900; font-size: 22px; color: var(--purple-d); min-width: 36px; text-align: right; }
.q-time.warn { color: var(--red); animation: pulseText 0.5s infinite alternate; }
@keyframes pulseText { from { transform: scale(1); } to { transform: scale(1.2); } }
.timer { height: 10px; border-radius: 10px; background: #ece7fb; overflow: hidden; }
.timer-bar { height: 100%; width: 100%; background: linear-gradient(90deg, #22c55e, #84cc16); border-radius: 10px; }
.timer-bar.warn { background: linear-gradient(90deg, #ef4444, #f97316); }
.bonus-note { margin-top: 12px; background: #fff6d6; border: 2px dashed #ffb300; border-radius: 14px; padding: 8px 12px; font-size: 15px; font-weight: 700; color: #8a5a00; }
.q-text { font-size: 25px; font-weight: 800; line-height: 1.3; margin: 18px 4px 18px; color: var(--ink); }
.q-options { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
.opt {
  font-family: var(--font); display: flex; align-items: center; gap: 10px; text-align: left;
  border: 3px solid #e3dcfb; background: #fff; border-radius: 16px; padding: 12px 14px;
  font-size: 19px; font-weight: 800; color: var(--ink); cursor: pointer;
  box-shadow: 0 4px 0 #e3dcfb; transition: transform 0.08s, background 0.15s, border-color 0.15s;
  min-height: 60px;
}
.opt:hover:not(:disabled) { border-color: var(--purple); transform: translateY(-2px); }
.opt:disabled { cursor: default; }
.opt .k { flex: none; width: 32px; height: 32px; border-radius: 10px; background: #efe9ff; color: var(--purple-d); display: flex; align-items: center; justify-content: center; font-size: 16px; }
.opt.correct { background: #dcfce7; border-color: var(--green); box-shadow: 0 4px 0 #86efac; }
.opt.correct .k { background: var(--green); color: #fff; }
.opt.wrong { background: #fee2e2; border-color: var(--red); box-shadow: 0 4px 0 #fca5a5; animation: shake 0.4s; }
.opt.wrong .k { background: var(--red); color: #fff; }
.opt.dim { opacity: 0.5; }
.q-feedback { margin-top: 16px; text-align: center; }
.q-result { font-size: 24px; font-weight: 900; margin-bottom: 6px; }
.q-result.ok { color: #15803d; }
.q-result.bad { color: #b91c1c; }
.q-fact { background: #f3efff; border-radius: 14px; padding: 10px 14px; font-size: 17px; line-height: 1.4; margin-bottom: 14px; text-align: left; }
.q-fact::before { content: "💡 "; }
.q-fact:empty { display: none; }

/* Sonuç ekranları */
.stars { font-size: 54px; color: #f5a400; letter-spacing: 6px; text-shadow: 0 3px 0 #ffe29a; }
.stars .off { color: #ddd6ee; text-shadow: none; }
.stats { font-size: 18px; line-height: 1.6; background: #f6f3ff; border-radius: 16px; padding: 10px 14px; }
.note { font-size: 16px; font-weight: 700; color: #7a5a00; margin-top: 10px; }
.note:empty { display: none; }
.big-emoji { font-size: 60px; }

/* Bildirim */
.toast {
  position: fixed; top: 64px; left: 50%; transform: translate(-50%, -20px); z-index: 30;
  background: #fff; color: var(--purple-d); font-weight: 900; font-size: 28px;
  border-radius: 20px; padding: 12px 24px; box-shadow: 0 12px 30px rgba(0,0,0,0.25);
  opacity: 0; pointer-events: none; transition: opacity 0.25s, transform 0.25s; white-space: nowrap;
}
.toast.show { opacity: 1; transform: translate(-50%, 0); }
.toast.life { color: #e11d48; }

.loading { position: fixed; inset: 0; display: flex; align-items: center; justify-content: center; font-size: 26px; font-weight: 900; color: #fff; background: #7b3fe4; z-index: 50; }
.loading.error { font-size: 20px; padding: 24px; text-align: center; line-height: 1.5; }

/* Mobil */
@media (max-width: 640px) {
  .panel { padding: 18px; border-radius: 22px; }
  .logo h1 { font-size: 32px; } .logo h1 span { font-size: 28px; }
  .q-text { font-size: 20px; margin: 12px 2px; }
  .q-options { grid-template-columns: 1fr; gap: 8px; }
  .opt { font-size: 17px; min-height: 50px; padding: 8px 12px; }
  .intro-name { font-size: 30px; } .intro-plate { font-size: 30px; }
  .hearts { font-size: 18px; max-width: 110px; }
  #hud { padding: 8px 10px; gap: 6px; }
  .hud-right { gap: 5px; } .icon-btn { width: 38px; height: 38px; font-size: 17px; }
  .hud-province { font-size: 14px; } .hud-province .rg { display: none; }
  .hud-stat { font-size: 14px; padding: 6px 8px; }
  .level-grid { grid-template-columns: repeat(auto-fill, minmax(88px, 1fr)); gap: 6px; }
  .level .lname { font-size: 12px; }
  .tr-map .plbl { font-size: 15px; }
  .tr-map-wrap { padding: 4px; border-radius: 12px; overflow-x: auto; overflow-y: hidden; -webkit-overflow-scrolling: touch; }
  .tr-map { width: 640px; max-width: none; }
  .tr-map .prov { stroke-width: 1.6; }
  .map-hint { font-size: 12px; }
  .levels-head { flex-wrap: wrap; }
  .levels-head h2 { font-size: 22px; }
  .levels-summary { width: 100%; font-size: 13px; }
  .toast { font-size: 22px; top: 96px; }
  .char-choices { gap: 20px; }
  .touch-btn { width: 64px; height: 64px; } .touch-btn.jump { width: 80px; height: 80px; }
}
@media (max-width: 480px) {
  #hud { flex-wrap: wrap; }
  .hearts { max-width: none; }
  .hearts .h { display: none; }
  .hearts .hc { display: inline-block; background: rgba(255,255,255,0.92); border-radius: 14px; padding: 7px 10px; font-size: 15px; font-weight: 900; color: #e11d48; box-shadow: 0 3px 0 rgba(0,0,0,0.12); }
  .hud-center { order: 3; flex: 1 1 100%; max-width: none; }
  .toast { top: 116px; }
}
@media (max-height: 520px) {
  .question-panel { padding: 12px 16px; }
  .q-text { font-size: 18px; margin: 8px 2px; }
  .opt { min-height: 42px; padding: 6px 10px; font-size: 16px; }
  .q-options { gap: 6px; }
  .question-panel.answered .opt.dim, .question-panel.answered .bonus-note, .question-panel.answered .timer { display: none; }
  .q-feedback { margin-top: 8px; } .q-result { font-size: 19px; } .q-fact { font-size: 15px; margin-bottom: 8px; }
}
