:root {
  --bg: #fff8e7;
  --ink: #2b2d42;
  --muted: #6c757d;
  --blue: #4c6ef5;
  --blue-d: #3b5bdb;
  --yellow: #fcc419;
  --green: #40c057;
  --red: #fa5252;
  --purple: #7950f2;
  --orange: #fd7e14;
  --pink: #e64980;
  --card: #ffffff;
  --radius: 20px;
  --shadow: 0 6px 0 rgba(0, 0, 0, .08), 0 12px 30px rgba(0, 0, 0, .06);
}

* { box-sizing: border-box; }

html, body { margin: 0; }

body {
  font-family: "Nunito", "Segoe UI", system-ui, sans-serif;
  color: var(--ink);
  background: var(--bg);
  background-image: radial-gradient(#f3e3b8 1.2px, transparent 1.2px);
  background-size: 26px 26px;
  font-size: 17px;
  line-height: 1.55;
}

h1, h2, h3, h4, .brand, .btn { font-family: "Baloo 2", "Nunito", sans-serif; }
h1, h2, h3, h4 { line-height: 1.2; margin: 0 0 .5em; }

a { color: inherit; }

.hidden { display: none !important; }

/* ---------- Üst bar ---------- */
.topbar {
  position: sticky; top: 0; z-index: 20;
  display: flex; align-items: center; gap: 16px;
  padding: 10px 22px;
  background: #ffffffee;
  backdrop-filter: blur(6px);
  border-bottom: 3px solid #ffe8a1;
}
.brand { display: flex; align-items: center; gap: 8px; text-decoration: none; font-weight: 800; font-size: 1.25rem; white-space: nowrap; }
.brand-bot { font-size: 1.8rem; display: inline-block; animation: wobble 3s ease-in-out infinite; }
#nav { display: flex; gap: 6px; flex-wrap: wrap; flex: 1; justify-content: center; }
#nav a {
  text-decoration: none; padding: 7px 14px; border-radius: 999px; font-weight: 700;
  transition: background .2s, transform .2s;
}
#nav a:hover { background: #fff3bf; transform: translateY(-2px); }
#nav a.active { background: var(--blue); color: #fff; }
.icon-btn { border: none; background: #fff3bf; font-size: 1.3rem; width: 44px; height: 44px; border-radius: 50%; cursor: pointer; }

main { max-width: 1200px; margin: 0 auto; padding: 24px 20px 60px; }

.page { display: none; animation: pageIn .35s ease; }
.page.active { display: block; }
.page-title { font-size: 2.3rem; margin: 6px 0 14px; }
.page-sub { font-size: 1.1rem; margin-top: -6px; }

/* ---------- Butonlar ---------- */
.btn {
  display: inline-block; border: none; cursor: pointer; text-decoration: none;
  background: var(--blue); color: #fff; font-weight: 700; font-size: 1.1rem;
  padding: 10px 22px; border-radius: 14px;
  box-shadow: 0 5px 0 var(--blue-d);
  transition: transform .1s, box-shadow .1s, filter .2s;
}
.btn:hover { filter: brightness(1.08); }
.btn:active { transform: translateY(4px); box-shadow: 0 1px 0 var(--blue-d); }
.btn-big { font-size: 1.35rem; padding: 14px 30px; }
.btn-small { font-size: .95rem; padding: 7px 14px; border-radius: 12px; }
.btn-ghost { background: #fff; color: var(--ink); box-shadow: 0 4px 0 #dee2e6; border: 2px solid #dee2e6; }
.btn-red { background: var(--red); box-shadow: 0 4px 0 #c92a2a; }
.btn-green { background: var(--green); box-shadow: 0 4px 0 #2b8a3e; }

/* ---------- Ana sayfa ---------- */
.hero {
  display: flex; align-items: center; gap: 30px; flex-wrap: wrap; justify-content: center;
  background: linear-gradient(135deg, #4c6ef5, #7950f2);
  color: #fff; border-radius: 30px; padding: 34px; box-shadow: var(--shadow);
}
.hero-bot { font-size: 9rem; line-height: 1; animation: float 3s ease-in-out infinite; filter: drop-shadow(0 10px 10px rgba(0,0,0,.25)); }
.hero-text { max-width: 560px; }
.bubble {
  position: relative; background: #fff; color: var(--ink); padding: 18px 22px; border-radius: 22px;
  font-size: 1.2rem; margin-bottom: 22px; box-shadow: 0 6px 0 rgba(0,0,0,.12);
}
.bubble::before {
  content: ""; position: absolute; left: -16px; top: 30px;
  border: 10px solid transparent; border-right: 16px solid #fff; border-left: 0;
}
.hero .btn { background: var(--yellow); color: var(--ink); box-shadow: 0 5px 0 #e67700; }

.cards { display: grid; grid-template-columns: repeat(auto-fit, minmax(260px, 1fr)); gap: 20px; margin: 28px 0; }
.card {
  display: block; text-decoration: none; background: var(--card); border-radius: var(--radius); padding: 22px;
  box-shadow: var(--shadow); border-top: 8px solid; transition: transform .2s;
}
.card:hover { transform: translateY(-6px) rotate(-.5deg); }
.card h3 { font-size: 1.4rem; margin: 6px 0; }
.card p { margin: 0; color: #495057; }
.card-ico { font-size: 2.6rem; }
.c-yellow { border-color: var(--yellow); }
.c-blue { border-color: var(--blue); }
.c-purple { border-color: var(--purple); }
.c-green { border-color: var(--green); }
.c-orange { border-color: var(--orange); }
.c-pink { border-color: var(--pink); }

.funfact {
  display: flex; align-items: center; gap: 16px; background: #fff; border-radius: var(--radius);
  padding: 16px 22px; box-shadow: var(--shadow); border: 3px dashed var(--yellow);
}
.funfact > span { font-size: 2.2rem; }
.funfact p { flex: 1; margin: 0; font-size: 1.1rem; }

/* ---------- Dersler ---------- */
.lesson {
  display: grid; grid-template-columns: 1fr 1.15fr; gap: 26px; align-items: center;
  background: #fff; border-radius: 26px; padding: 26px; margin-bottom: 26px; box-shadow: var(--shadow);
}
.lesson h2 { font-size: 1.6rem; color: var(--blue-d); }
.lesson-visual { background: #f8f9fa; border-radius: 20px; padding: 10px; border: 2px solid #e9ecef; }
.lesson-visual svg { width: 100%; height: auto; display: block; }
.tip { background: #e7f5ff; border-left: 6px solid var(--blue); padding: 10px 14px; border-radius: 10px; margin: 10px 0; }
.status { font-weight: 800; font-size: 1.15rem; min-height: 1.6em; margin: 10px 0 0; }
.status.good { color: #2b8a3e; }
.status.bad { color: #c92a2a; }
.next-wrap { text-align: center; margin-top: 10px; }

@media (max-width: 860px) {
  .lesson { grid-template-columns: 1fr; }
  .hero-bot { font-size: 6rem; }
  .bubble::before { display: none; }
}

/* Fiziksel devre çizimleri */
.wire { fill: none; stroke: #495057; stroke-width: 5; stroke-linecap: round; stroke-linejoin: round; }
.flow {
  fill: none; stroke: #ffd43b; stroke-width: 4; stroke-linecap: round; stroke-linejoin: round;
  stroke-dasharray: 2 14; opacity: 0; transition: opacity .3s;
  animation: flow var(--flow-speed, .7s) linear infinite;
}
.flow.live { opacity: 1; }
.flow.blue { stroke: #74c0fc; }
@keyframes flow { from { stroke-dashoffset: 16; } to { stroke-dashoffset: 0; } }

.sw-lever { stroke: #343a40; stroke-width: 6; stroke-linecap: round; transition: transform .25s cubic-bezier(.5, 1.6, .5, 1); }
.sw-dot { fill: #fff; stroke: #343a40; stroke-width: 3; }
.sw-hit { fill: transparent; cursor: pointer; }
.sw-hit:hover { fill: rgba(76, 110, 245, .08); }
.sw-label { font: 800 16px "Baloo 2", sans-serif; fill: #3b5bdb; text-anchor: middle; }
.small-label { font: 700 13px "Nunito", sans-serif; fill: #868e96; text-anchor: middle; }

.bulb .glow { opacity: 0; transition: opacity .3s; }
.bulb .glass { fill: #f1f3f5; stroke: #495057; stroke-width: 3; transition: fill .3s; }
.bulb .fil { fill: none; stroke: #868e96; stroke-width: 2.5; }
.bulb.on .glow { opacity: 1; }
.bulb.on .glass { fill: #ffe066; }
.bulb.on .fil { stroke: #e67700; }

.batt-label { font: 800 15px "Baloo 2", sans-serif; fill: #fff; text-anchor: middle; }
.batt-volt { font: 800 15px "Baloo 2", sans-serif; fill: #495057; }

.led-body { fill: #ffc9c9; stroke: #c92a2a; stroke-width: 3; transition: fill .2s; }
.led-glow { transition: opacity .2s; }
.led-burnt .led-body { fill: #343a40; stroke: #212529; }
.smoke { font-size: 30px; opacity: 0; }
.led-burnt .smoke { opacity: 1; animation: smoke 1.6s ease-out infinite; }
@keyframes smoke { from { transform: translateY(0); opacity: 1; } to { transform: translateY(-30px); opacity: 0; } }

.resistor { fill: none; stroke: #e8590c; stroke-width: 5; stroke-linejoin: round; }
.slot { fill: #fff9db; stroke: #fab005; stroke-width: 3; stroke-dasharray: 6 5; }
.clip { fill: #adb5bd; stroke: #495057; stroke-width: 2; }
.slot-item { font-size: 38px; text-anchor: middle; dominant-baseline: middle; }

.btn-push { cursor: pointer; }
.btn-push .cap { transition: transform .12s; }
.btn-push.down .cap { transform: translateY(12px); }

/* Kontroller */
.controls { margin: 10px 0; }
.ctrl-row { display: flex; align-items: center; gap: 10px; margin-bottom: 8px; flex-wrap: wrap; }
.ctrl-row > span { width: 96px; font-weight: 800; white-space: nowrap; }
.chips { display: flex; gap: 6px; flex-wrap: wrap; }
.chip {
  border: 2px solid #dee2e6; background: #fff; border-radius: 999px; padding: 4px 12px;
  font-weight: 800; cursor: pointer; font-family: inherit; font-size: .95rem;
}
.chip.active { background: var(--yellow); border-color: #f59f00; }
.meter { margin: 10px 0; }
.meter-bar { height: 16px; background: #e9ecef; border-radius: 999px; overflow: hidden; position: relative; }
.meter-bar::after { content: ""; position: absolute; left: 66%; top: 0; bottom: 0; width: 3px; background: #c92a2a; }
#led-bar { height: 100%; width: 0; background: linear-gradient(90deg, #69db7c, #fcc419, #ff6b6b); transition: width .3s; }

.items { display: flex; flex-wrap: wrap; gap: 8px; margin: 10px 0; }
.item-btn {
  border: 2px solid #dee2e6; background: #fff; border-radius: 14px; padding: 6px 12px; cursor: pointer;
  font-family: inherit; font-weight: 700; font-size: .95rem; transition: transform .15s;
}
.item-btn:hover { transform: translateY(-3px); border-color: var(--blue); }
.item-btn.tested { background: #f8f9fa; }
.cond-results { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; margin-top: 10px; }
.cond-results h4 { margin-bottom: 4px; }
.tagbox { min-height: 36px; display: flex; flex-wrap: wrap; gap: 4px; }
.tag { background: #f1f3f5; border-radius: 999px; padding: 2px 10px; font-size: .9rem; font-weight: 700; }

/* Doğruluk tablosu */
.truth { border-collapse: separate; border-spacing: 0; margin: 8px 0; border-radius: 12px; overflow: hidden; box-shadow: 0 0 0 2px #dee2e6; }
.truth th, .truth td { padding: 6px 16px; text-align: center; font-weight: 800; font-size: 1.05rem; }
.truth th { background: #364fc7; color: #fff; }
.truth td { background: #fff; border-top: 1px solid #e9ecef; transition: background .2s; }
.truth tr.hl td { background: #fff3bf; }
.truth td.one { color: #2b8a3e; }
.truth td.zero { color: #adb5bd; }
.truth td.ok { color: #2b8a3e; }
.truth td.no { color: #c92a2a; }

/* ---------- Lojik devre motoru ---------- */
svg.circuit { width: 100%; height: auto; display: block; touch-action: none; user-select: none; -webkit-user-select: none; }
.circuit text { font-family: "Baloo 2", sans-serif; }
.w-path { fill: none; stroke: #adb5bd; stroke-width: 5; stroke-linecap: round; transition: stroke .2s; }
.w-path.on { stroke: #fab005; }
.w-flow { fill: none; stroke: #fff9db; stroke-width: 2.5; stroke-dasharray: 3 12; stroke-linecap: round; animation: flow .6s linear infinite; pointer-events: none; }
.w-hit { fill: none; stroke: transparent; stroke-width: 16; cursor: pointer; }
.w-sel .w-path { stroke: var(--blue); stroke-width: 7; }
.temp-wire { fill: none; stroke: var(--blue); stroke-width: 4; stroke-dasharray: 8 6; pointer-events: none; }

.node { cursor: pointer; }
.sandbox .node { cursor: grab; }
.node .stub { stroke: #495057; stroke-width: 4; stroke-linecap: round; }
.node.gate .body { fill: #e5dbff; stroke: #5f3dc4; stroke-width: 3; stroke-linejoin: round; transition: fill .2s; }
.node.gate.on .body { fill: #b197fc; }
.node.gate .extra { fill: none; stroke: #5f3dc4; stroke-width: 3; }
.node.gate .bubble-c { fill: #fff; stroke: #5f3dc4; stroke-width: 3; }
.node .glabel { font-size: 15px; font-weight: 800; fill: #5f3dc4; text-anchor: middle; }
.node.gate .mbox { fill: #fff9db; stroke: #f59f00; stroke-width: 3; stroke-dasharray: 7 5; }
.node.gate .qmark { font-size: 30px; font-weight: 800; fill: #f08c00; text-anchor: middle; }
.node.gate.mystery .glabel { fill: #e67700; }
.node.gate.mystery .ring { fill: none; stroke: #fab005; stroke-width: 2; stroke-dasharray: 5 5; }

.node.switch .body { fill: #fff; stroke: #495057; stroke-width: 3; }
.node.switch .track { fill: #ced4da; transition: fill .2s; }
.node.switch .knob { fill: #fff; stroke: #495057; stroke-width: 2.5; transition: cx .2s; }
.node.switch.on .track { fill: #51cf66; }
.node .lbl { font-size: 18px; font-weight: 800; fill: #364fc7; text-anchor: middle; }
.node .val { font-size: 16px; font-weight: 800; fill: #868e96; text-anchor: middle; }
.node.on .val { fill: #2b8a3e; }

.node.lamp .halo { fill: url(#glowYellow); opacity: 0; transition: opacity .3s; pointer-events: none; }
.node.lamp .bulbc { fill: #f1f3f5; stroke: #495057; stroke-width: 3; transition: fill .3s; }
.node.lamp .fil { fill: none; stroke: #868e96; stroke-width: 2.5; }
.node.lamp.on .halo { opacity: 1; }
.node.lamp.on .bulbc { fill: #ffe066; }
.node.lamp.on .fil { stroke: #e67700; }
.node .target { font-size: 14px; font-weight: 800; text-anchor: middle; }
.node .target.ok { fill: #2b8a3e; }
.node .target.no { fill: #c92a2a; }

.node.sel .body, .node.sel .bulbc { stroke: var(--blue); stroke-width: 5; }

.port .dot { fill: #fff; stroke: #495057; stroke-width: 2.5; }
.port .hit { fill: transparent; }
.editable .port { cursor: crosshair; }
.editable .port:hover .dot { fill: var(--yellow); r: 8; }
.locked .port { pointer-events: none; }

/* ---------- Lojik kapılar sayfası ---------- */
.gate-list { display: flex; flex-wrap: wrap; gap: 10px; margin: 14px 0 20px; }
.gate-btn {
  display: flex; flex-direction: column; align-items: center; gap: 2px;
  border: 3px solid #dee2e6; background: #fff; border-radius: 16px; padding: 8px 12px; cursor: pointer;
  font-family: "Baloo 2", sans-serif; font-weight: 800; font-size: 1rem; min-width: 110px;
  transition: transform .15s, border-color .15s;
}
.gate-btn small { font-family: "Nunito", sans-serif; color: var(--muted); font-weight: 700; }
.gate-btn svg { width: 80px; height: 44px; }
.gate-btn:hover { transform: translateY(-3px); }
.gate-btn.active { border-color: var(--purple); background: #f3f0ff; }
.gate-lab { display: grid; grid-template-columns: 1.3fr 1fr; gap: 22px; }
.gate-stage, .mission-stage, .sandbox-wrap { background: #fff; border-radius: 24px; padding: 14px; box-shadow: var(--shadow); }
.gate-info { background: #fff; border-radius: 24px; padding: 22px; box-shadow: var(--shadow); }
.gate-info h2 { color: var(--purple); font-size: 1.9rem; }
.example { background: #f3f0ff; border-radius: 14px; padding: 10px 14px; margin: 10px 0 16px; }
@media (max-width: 860px) { .gate-lab { grid-template-columns: 1fr; } }

/* ---------- Görevler ---------- */
.level-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(84px, 1fr)); gap: 10px; margin-bottom: 20px; }
.level-btn {
  position: relative; border: 3px solid #dee2e6; background: #fff; border-radius: 18px; padding: 10px 4px; cursor: pointer;
  font-family: "Baloo 2", sans-serif; font-weight: 800; font-size: 1.4rem; transition: transform .15s;
}
.level-btn small { display: block; font-size: .8rem; color: var(--muted); }
.level-btn:hover { transform: translateY(-3px); }
.level-btn.done { background: #ebfbee; border-color: #69db7c; }
.level-btn.current { border-color: var(--blue); box-shadow: 0 0 0 4px #dbe4ff; }
.mission { background: #fff; border-radius: 26px; padding: 22px; box-shadow: var(--shadow); position: relative; }
.mission-head { display: flex; justify-content: space-between; gap: 14px; flex-wrap: wrap; }
.mission-head h2 { color: var(--green); font-size: 1.8rem; margin-bottom: 4px; }
.mission-head p { margin: 0 0 10px; font-size: 1.1rem; max-width: 760px; }
.mission-btns { display: flex; gap: 8px; align-items: flex-start; }
.mission-body { display: grid; grid-template-columns: 1fr 260px; gap: 18px; align-items: start; }
.mission-stage { box-shadow: none; border: 2px solid #e9ecef; }
.mission-goal { background: #f8f9fa; border-radius: 18px; padding: 16px; }
.mission-goal h4 { margin-bottom: 6px; }
.goal-item { display: flex; align-items: center; gap: 8px; font-weight: 700; margin: 6px 0; }
.success {
  text-align: center; background: linear-gradient(135deg, #d3f9d8, #fff3bf); border-radius: 20px; padding: 18px; margin-top: 14px;
  animation: pop .5s cubic-bezier(.5, 1.8, .5, 1);
}
.success .stars { font-size: 2.4rem; letter-spacing: 6px; }
@media (max-width: 860px) { .mission-body { grid-template-columns: 1fr; } }

/* ---------- Deney masası ---------- */
.toolbar { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; margin-bottom: 10px; }
.toolbar-2 { margin-bottom: 14px; }
.pal-btn {
  display: flex; align-items: center; gap: 6px; border: 2px solid #dee2e6; background: #fff; border-radius: 14px;
  padding: 4px 12px 4px 6px; cursor: pointer; font-family: "Baloo 2", sans-serif; font-weight: 800; font-size: 1rem;
  transition: transform .15s;
}
.pal-btn:hover { transform: translateY(-2px); border-color: var(--purple); }
.pal-btn svg { width: 54px; height: 32px; }
.pal-btn .emo { font-size: 1.5rem; width: 32px; text-align: center; }
.sep { flex: 1; }
.lbl-select { font-weight: 800; }
.lbl-select select { font-family: inherit; font-size: 1rem; padding: 6px 10px; border-radius: 10px; border: 2px solid #dee2e6; }
.sandbox-wrap { padding: 0; overflow-x: auto; }
svg.sandbox { background: #fbfcfe; min-width: 880px; }
.example-note { background: #fff9db; border: 2px dashed #fab005; border-radius: 16px; padding: 12px 16px; margin-top: 14px; }
.hint-line { color: var(--muted); }

/* ---------- Yarışma ---------- */
.quiz { background: #fff; border-radius: 26px; padding: 28px; box-shadow: var(--shadow); max-width: 760px; margin: 0 auto; }
.q-progress { display: flex; gap: 6px; margin-bottom: 16px; }
.q-progress span { flex: 1; height: 10px; border-radius: 999px; background: #e9ecef; }
.q-progress span.ok { background: var(--green); }
.q-progress span.no { background: var(--red); }
.q-progress span.cur { background: var(--yellow); }
.q-text { font-size: 1.5rem; font-family: "Baloo 2", sans-serif; font-weight: 700; margin-bottom: 16px; }
.q-emoji { font-size: 3rem; text-align: center; }
.q-opts { display: grid; gap: 10px; }
.q-opt {
  text-align: left; border: 3px solid #dee2e6; background: #fff; border-radius: 16px; padding: 12px 16px;
  font-family: inherit; font-size: 1.1rem; font-weight: 700; cursor: pointer; transition: transform .1s, border-color .1s;
}
.q-opt:hover:not(:disabled) { border-color: var(--blue); transform: translateX(4px); }
.q-opt.right { background: #d3f9d8; border-color: var(--green); }
.q-opt.wrong { background: #ffe3e3; border-color: var(--red); }
.q-opt:disabled { cursor: default; }
.q-explain { margin-top: 14px; background: #e7f5ff; border-radius: 14px; padding: 12px 16px; }
.q-actions { margin-top: 16px; text-align: right; }
.q-result { text-align: center; }
.q-result .big { font-size: 4rem; }

/* ---------- Konfeti ---------- */
#confetti { position: fixed; inset: 0; pointer-events: none; z-index: 100; width: 100vw; height: 100vh; }

/* ---------- Animasyonlar ---------- */
@keyframes float { 0%, 100% { transform: translateY(0); } 50% { transform: translateY(-14px); } }
@keyframes wobble { 0%, 100% { transform: rotate(0); } 25% { transform: rotate(-10deg); } 75% { transform: rotate(10deg); } }
@keyframes pageIn { from { opacity: 0; transform: translateY(10px); } to { opacity: 1; transform: none; } }
@keyframes pop { from { transform: scale(.6); opacity: 0; } to { transform: scale(1); opacity: 1; } }

@media (max-width: 1100px) {
  .topbar { flex-wrap: wrap; justify-content: space-between; padding: 8px 14px; gap: 6px; }
  #nav { order: 3; width: 100%; flex: none; justify-content: flex-start; overflow-x: auto; flex-wrap: nowrap; padding-bottom: 4px; }
  #nav a { white-space: nowrap; padding: 5px 12px; }
  .icon-btn { width: 38px; height: 38px; font-size: 1.1rem; }
}
@media (max-width: 700px) {
  .page-title { font-size: 1.8rem; }
}
