:root {
  --bg: #0b1020;
  --panel: #141b33;
  --panel2: #1d2749;
  --line: #2b3764;
  --text: #eef2ff;
  --muted: #9aa6d1;
  --cyan: #3ee8ff;
  --orange: #ffb347;
  --green: #5ee87a;
  --red: #ff5d6c;
  --gold: #ffd84a;
  --radius: 18px;
  --font-head: 'Baloo 2', 'Nunito', system-ui, sans-serif;
  --font-body: 'Nunito', system-ui, sans-serif;
}

* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }
html, body {
  margin: 0; height: 100%; background: var(--bg); color: var(--text);
  font-family: var(--font-body); overflow: hidden; overscroll-behavior: none;
  touch-action: none; user-select: none; -webkit-user-select: none;
}
#app { position: fixed; inset: 0; }
#gl { position: absolute; inset: 0; width: 100%; height: 100%; display: block; }
.hidden { display: none !important; }

h1, h2, h3 { font-family: var(--font-head); margin: 0; line-height: 1.1; }
button { font-family: var(--font-body); font-weight: 800; cursor: pointer; border: 0; }

.btn {
  background: var(--cyan); color: #06232a; border-radius: 999px;
  padding: 14px 28px; font-size: 18px; box-shadow: 0 6px 0 #1aa3b8;
  transition: transform .08s, box-shadow .08s;
}
.btn:active { transform: translateY(4px); box-shadow: 0 2px 0 #1aa3b8; }
.btn.secondary { background: var(--panel2); color: var(--text); box-shadow: 0 6px 0 #0d1330; }
.btn.secondary:active { box-shadow: 0 2px 0 #0d1330; }
.btn.orange { background: var(--orange); color: #3a2200; box-shadow: 0 6px 0 #c77f1d; }
.btn.orange:active { box-shadow: 0 2px 0 #c77f1d; }
.btn.small { padding: 10px 18px; font-size: 15px; }
.btn:disabled { opacity: .45; cursor: default; transform: none; }

/* ---------- 2D ekranlar ---------- */
#screens { position: absolute; inset: 0; pointer-events: none; }
.screen {
  position: absolute; inset: 0; pointer-events: auto; overflow: auto;
  padding: max(16px, env(safe-area-inset-top)) max(16px, env(safe-area-inset-right))
           max(16px, env(safe-area-inset-bottom)) max(16px, env(safe-area-inset-left));
  background: radial-gradient(1200px 700px at 50% -10%, #1b2a5a 0%, var(--bg) 60%);
  display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 18px;
  animation: fadein .4s ease;
}
@keyframes fadein { from { opacity: 0 } to { opacity: 1 } }

.title-logo { text-align: center; }
.title-logo .pre { color: var(--muted); letter-spacing: .3em; font-weight: 900; font-size: 13px; }
.title-logo h1 { font-size: clamp(38px, 9vw, 84px); color: var(--cyan); text-shadow: 0 0 30px rgba(62,232,255,.4); }
.title-logo h1 span { color: var(--orange); }
.title-logo .sub { color: var(--text); font-size: clamp(16px, 3vw, 24px); font-weight: 700; margin-top: 4px; }
.title-foot { color: var(--muted); font-size: 13px; text-align: center; max-width: 520px; }
.stack { display: flex; flex-direction: column; gap: 12px; align-items: center; }
.row { display: flex; gap: 10px; flex-wrap: wrap; justify-content: center; align-items: center; }

/* Harita */
#map-wrap { width: min(100%, 980px); display: flex; flex-direction: column; gap: 10px; }
#map-head { display: flex; justify-content: space-between; align-items: center; gap: 10px; flex-wrap: wrap; }
#map-head h2 { font-size: 26px; color: var(--cyan); }
#map-svg { width: 100%; height: auto; display: block; border-radius: var(--radius); background: #0e1a3a; }
.city { cursor: pointer; }
.city circle.ring { fill: none; stroke-width: 3; }
.city.locked { opacity: .55; cursor: not-allowed; }
.city.done circle.dot { fill: var(--green); }
.city.open circle.dot { fill: var(--orange); }
.city.open circle.ring { stroke: var(--orange); animation: pulse 1.4s infinite; transform-box: fill-box; transform-origin: center; }
.city text { font-family: var(--font-head); font-weight: 800; fill: #fff; font-size: 20px; pointer-events: none; }
.city text.form { font-size: 14px; fill: var(--muted); font-family: var(--font-body); font-weight: 700; }
@keyframes pulse { 0% { transform: scale(1); opacity: 1 } 100% { transform: scale(2.2); opacity: 0 } }
.legend { display: flex; gap: 14px; flex-wrap: wrap; color: var(--muted); font-size: 13px; font-weight: 700; }
.legend i { display: inline-block; width: 12px; height: 12px; border-radius: 50%; margin-right: 5px; vertical-align: -1px; }

/* ---------- HUD ---------- */
#hud { position: absolute; inset: 0; pointer-events: none; }
#hud-top {
  position: absolute; top: max(10px, env(safe-area-inset-top)); left: 12px; right: 12px;
  display: flex; justify-content: space-between; align-items: flex-start; gap: 10px;
}
#objective {
  background: rgba(11,16,32,.75); border: 2px solid var(--line); border-radius: 14px;
  padding: 8px 14px; font-weight: 800; font-size: 14px; max-width: 60%; backdrop-filter: blur(6px);
}
#objective::before { content: '🎯 '; }
#inventory { display: flex; gap: 6px; flex-wrap: wrap; justify-content: flex-end; }
#btn-exit { pointer-events: auto; color: var(--muted); padding: 5px 12px; flex: none; }
#btn-exit:active { color: var(--red); }
.chip {
  display: flex; align-items: center; gap: 6px; background: rgba(11,16,32,.75); border: 2px solid var(--line);
  border-radius: 999px; padding: 5px 12px 5px 6px; font-weight: 900; font-size: 15px; backdrop-filter: blur(6px);
}
.chip .ball { width: 24px; height: 24px; border-radius: 50%; display: grid; place-items: center; font-size: 13px; color: #111; font-weight: 900; }
.chip.bump { animation: bump .3s; }
@keyframes bump { 50% { transform: scale(1.25) } }

#prompt {
  position: absolute; bottom: 150px; left: 50%; transform: translateX(-50%);
  background: rgba(11,16,32,.85); border: 2px solid var(--cyan); border-radius: 999px;
  padding: 8px 16px 8px 8px; font-weight: 900; display: flex; align-items: center; gap: 10px; font-size: 15px;
}
#prompt .key { background: var(--cyan); color: #06232a; border-radius: 8px; padding: 2px 9px; }

#touch-left, #touch-right { position: absolute; bottom: 0; top: 40%; pointer-events: auto; display: none; }
#touch-left { left: 0; width: 55%; }
#touch-right { right: 0; width: 45%; }
@media (pointer: coarse) { #touch-left, #touch-right { display: block; } #prompt .key { display: none; } }
#joy-base {
  position: absolute; width: 120px; height: 120px; border-radius: 50%; left: 30px; bottom: 40px;
  background: rgba(255,255,255,.08); border: 2px solid rgba(255,255,255,.25); display: none;
}
#joy-knob { position: absolute; width: 54px; height: 54px; border-radius: 50%; left: 31px; top: 31px; background: rgba(62,232,255,.7); }
.tbtn {
  position: absolute; border-radius: 50%; width: 64px; height: 64px; font-size: 22px; font-weight: 900;
  background: rgba(255,255,255,.12); border: 2px solid rgba(255,255,255,.35); color: #fff;
}
.tbtn:active { background: rgba(62,232,255,.5); }
.tbtn.big { width: 86px; height: 86px; right: 28px; bottom: 40px; font-size: 34px; }
#btn-interact { right: 128px; bottom: 60px; background: rgba(62,232,255,.25); border-color: var(--cyan); }

/* ---------- Diyalog ---------- */
#dialog { position: absolute; inset: 0; display: flex; align-items: flex-end; justify-content: center; padding: 12px; z-index: 20; }
#dialog-box {
  width: min(100%, 760px); background: rgba(14,20,45,.96); border: 2px solid var(--line); border-radius: var(--radius);
  display: flex; gap: 14px; padding: 14px; box-shadow: 0 10px 40px rgba(0,0,0,.5); cursor: pointer;
  margin-bottom: max(6px, env(safe-area-inset-bottom)); animation: up .25s ease;
}
@keyframes up { from { transform: translateY(20px); opacity: 0 } }
#portrait { width: 66px; height: 66px; border-radius: 16px; flex: none; display: grid; place-items: center; font-size: 34px; background: var(--panel2); border: 3px solid var(--cyan); }
#portrait.aria { border-color: var(--cyan); background: #0d3a44; }
#portrait.anti { border-color: var(--red); background: #3d0d1a; animation: glitch .6s infinite; }
#portrait.elif { border-color: var(--orange); background: #3d2a0d; }
#portrait.you { border-color: var(--green); background: #0d3d1d; }
#portrait.sys { border-color: var(--muted); background: var(--panel2); }
@keyframes glitch { 0%,100% { transform: translate(0) } 20% { transform: translate(-2px,1px) } 40% { transform: translate(2px,-1px) } 60% { transform: translate(-1px,-2px) } }
#dialog-body { flex: 1; min-width: 0; }
#speaker { font-family: var(--font-head); font-weight: 800; color: var(--cyan); font-size: 16px; }
#portrait.anti ~ #dialog-body #speaker, .anti #speaker { color: var(--red); }
#dialog-text { font-size: 17px; line-height: 1.45; min-height: 48px; font-weight: 700; }
#dialog-next { color: var(--muted); font-size: 12px; text-align: right; font-weight: 900; animation: blink 1s infinite; }
@keyframes blink { 50% { opacity: .3 } }
#dialog-options { display: flex; flex-direction: column; gap: 8px; margin-top: 10px; }
#dialog-options button { background: var(--panel2); color: var(--text); border: 2px solid var(--line); border-radius: 12px; padding: 10px 14px; text-align: left; font-size: 15px; }
#dialog-options button:hover, #dialog-options button:active { border-color: var(--cyan); }

/* ---------- Modal (test, bulmaca) ---------- */
#modal { position: absolute; inset: 0; background: rgba(5,8,20,.8); display: flex; align-items: center; justify-content: center; padding: 10px; z-index: 30; backdrop-filter: blur(4px); }
#modal-card {
  width: min(100%, 760px); max-height: 100%; overflow: auto; background: var(--panel); border: 2px solid var(--line);
  border-radius: var(--radius); padding: 16px; display: flex; flex-direction: column; gap: 12px; animation: up .25s ease;
}
#modal-card h2 { color: var(--cyan); font-size: 22px; }
#modal-card .hint { color: var(--muted); font-size: 14px; font-weight: 700; }
#modal-card canvas { width: 100%; display: block; border-radius: 14px; background: #0a0f24; touch-action: none; }
.status { min-height: 44px; display: flex; align-items: center; gap: 10px; background: var(--panel2); border-radius: 12px; padding: 8px 12px; font-weight: 800; font-size: 15px; }
.status .mini { width: 30px; height: 30px; border-radius: 9px; display: grid; place-items: center; flex: none; background: #0d3a44; border: 2px solid var(--cyan); }
.status.ok { border: 2px solid var(--green); }
.status.bad { border: 2px solid var(--red); }
.modal-foot { display: flex; gap: 10px; justify-content: space-between; flex-wrap: wrap; align-items: center; }

/* Test */
.quiz-progress { display: flex; gap: 6px; }
.quiz-progress i { flex: 1; height: 8px; border-radius: 4px; background: var(--line); }
.quiz-progress i.done { background: var(--cyan); }
.quiz-q { font-size: 19px; font-weight: 800; line-height: 1.4; }
.quiz-opts { display: flex; flex-direction: column; gap: 8px; }
.quiz-opts button { background: var(--panel2); color: var(--text); border: 2px solid var(--line); border-radius: 12px; padding: 12px 14px; text-align: left; font-size: 16px; font-weight: 700; }
.quiz-opts button:not(:disabled):hover { border-color: var(--cyan); }
.quiz-opts button.correct { border-color: var(--green); background: #12381f; }
.quiz-opts button.wrong { border-color: var(--red); background: #3d1220; }
.quiz-opts button.picked { border-color: var(--cyan); }
.result-big { font-family: var(--font-head); font-size: 44px; color: var(--gold); text-align: center; }

/* Müze */
#museum-ui { position: absolute; inset: 0; pointer-events: none; display: flex; flex-direction: column; justify-content: space-between; padding: 14px; }
#museum-ui > * { pointer-events: auto; }
.card-row { display: flex; gap: 8px; flex-wrap: wrap; justify-content: center; }
.card-btn { background: var(--panel2); color: var(--text); border: 2px solid var(--line); border-radius: 12px; padding: 10px 14px; font-size: 15px; }
.card-btn.active { border-color: var(--gold); color: var(--gold); }
.card-btn.locked { opacity: .4; }
#museum-info { background: rgba(14,20,45,.9); border: 2px solid var(--line); border-radius: 14px; padding: 12px 14px; max-width: 520px; margin: 0 auto; font-weight: 700; }
#museum-info h3 { color: var(--gold); font-size: 22px; }

/* Fabrika bulmacası (İzmir) */
.screen.factory { justify-content: stretch; align-items: stretch; gap: 8px; padding: 10px; background: #0b1020; }
.f-top { display: flex; justify-content: space-between; align-items: flex-start; gap: 10px; }
.f-top b { font-family: var(--font-head); font-size: 20px; color: var(--cyan); }
.f-top .chip { white-space: nowrap; flex: none; }
#f-canvas-wrap { flex: 1; min-height: 180px; border-radius: 14px; overflow: hidden; background: #0a0f24; border: 2px solid var(--line); }
#f-canvas { display: block; touch-action: none; }
.f-palette { display: flex; gap: 6px; flex-wrap: wrap; }
.pal { background: var(--panel2); color: var(--text); border: 2px solid var(--line); border-radius: 12px; padding: 8px 10px; font-size: 13px; display: flex; align-items: center; gap: 6px; }
.pal .ico { font-size: 20px; }
.pal.active { border-color: var(--cyan); background: #0d3a44; }
.pal:active { transform: scale(.97); }

/* Drone oyunu (Konya) */
.screen.drone { padding: 0; background: #2a1d12; display: block; }
#ph-canvas { display: block; touch-action: none; }

/* Tepkime terazisi (Ankara) */
.bl-eq { display: flex; flex-wrap: wrap; justify-content: center; align-items: center; gap: 8px; }
.bl-term { display: flex; align-items: center; gap: 6px; background: var(--panel2); border: 2px solid var(--line); border-radius: 12px; padding: 6px 10px; }
.bl-coef { display: flex; align-items: center; gap: 4px; }
.bl-coef button { width: 30px; height: 30px; border-radius: 8px; background: var(--line); color: var(--text); font-size: 18px; }
.bl-coef b { min-width: 22px; text-align: center; font-size: 20px; color: var(--orange); }
.bl-formula { font-family: var(--font-head); font-size: 22px; font-weight: 800; }
.bl-plus, .bl-arrow { font-size: 22px; font-weight: 900; color: var(--muted); }
.bl-arrow { color: var(--cyan); }

/* Epilog */
.epilog-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(150px, 1fr)); gap: 10px; width: 100%; }
.stat { background: var(--panel2); border: 2px solid var(--line); border-radius: 14px; padding: 12px; text-align: center; }
.stat .big { font-family: var(--font-head); font-size: 34px; color: var(--cyan); line-height: 1; }
.stat .big.gold { color: var(--gold); }
.stat .lbl { color: var(--muted); font-size: 12px; font-weight: 800; margin-top: 4px; }
#cert-canvas { width: 100%; max-width: 760px; border-radius: 12px; border: 2px solid var(--line); background: #fff; }
.name-row { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; justify-content: center; }
.name-row input { font-family: var(--font-body); font-weight: 800; font-size: 16px; padding: 10px 14px; border-radius: 12px; border: 2px solid var(--line); background: var(--panel2); color: var(--text); min-width: 220px; }

/* Toast ve geçiş */
#toast {
  position: absolute; top: 70px; left: 50%; transform: translateX(-50%); background: var(--panel2); border: 2px solid var(--orange);
  border-radius: 999px; padding: 8px 16px; font-weight: 900; z-index: 40; animation: up .25s ease; max-width: 90%; text-align: center;
}
#fade { position: absolute; inset: 0; background: #000; opacity: 0; pointer-events: none; transition: opacity .5s; z-index: 50; }
#fade.on { opacity: 1; pointer-events: auto; }

.panel { background: var(--panel); border: 2px solid var(--line); border-radius: var(--radius); padding: 16px; width: min(100%, 640px); }
.panel p { margin: 6px 0; line-height: 1.5; font-weight: 700; }
.kv { display: grid; grid-template-columns: 1fr auto; gap: 6px 14px; font-weight: 800; }
.kv span:last-child { color: var(--cyan); }
