/* 3D Blok Kodlama — yeniden tasarım (v2) */
:root {
  --bg: #ecfeff;
  --bg-2: #cffafe;
  --surface: #ffffff;
  --surface-2: #f0fdff;
  --ink: #0c2a3a;
  --ink-soft: #4b6b7c;
  --line: #cfe8ef;
  --brand: #0891b2;
  --brand-2: #0e7490;
  --good: #16a34a;
  --bad: #ef4444;
  --warn: #f59e0b;
  --gold: #fbbf24;
  --radius: 18px;
  --shadow: 0 10px 30px rgba(49, 46, 129, .12);
  --shadow-sm: 0 2px 8px rgba(49, 46, 129, .10);
  --font: "Nunito", "Segoe UI", system-ui, -apple-system, "Helvetica Neue", Arial, sans-serif;
}
body.dark {
  --bg: #07161d;
  --bg-2: #0b2530;
  --surface: #0f2833;
  --surface-2: #14394a;
  --ink: #e6faff;
  --ink-soft: #8fc3d4;
  --line: #1f4b5e;
  --shadow: 0 10px 30px rgba(0, 0, 0, .45);
  --shadow-sm: 0 2px 8px rgba(0, 0, 0, .4);
}
* { box-sizing: border-box; }
html, body { height: 100%; }
body {
  margin: 0; font-family: var(--font); color: var(--ink);
  background: radial-gradient(1200px 600px at 10% -10%, var(--bg-2), transparent 60%), var(--bg);
  -webkit-tap-highlight-color: transparent;
}
button { font-family: inherit; cursor: pointer; }
.hidden { display: none !important; }

.app { min-height: 100%; display: flex; flex-direction: column; }

/* ---------- üst çubuk ---------- */
.topbar {
  display: grid; grid-template-columns: auto 1fr auto; align-items: center; gap: 14px;
  padding: 10px 18px; background: var(--surface); border-bottom: 1px solid var(--line);
  box-shadow: var(--shadow-sm); position: sticky; top: 0; z-index: 20;
}
.brand { display: flex; align-items: center; gap: 10px; }
.brand-logo { font-size: 28px; filter: drop-shadow(0 2px 3px rgba(79, 70, 229, .35)); }
.brand-text { display: grid; line-height: 1.1; }
.brand-text b { font-size: 16px; letter-spacing: .2px; }
.brand-text small { color: var(--ink-soft); font-size: 11px; font-weight: 700; }

.level-nav { display: flex; align-items: center; justify-content: center; gap: 8px; min-width: 0; }
.level-picker {
  display: grid; text-align: left; line-height: 1.15; padding: 7px 18px; min-width: 190px;
  border: 2px solid var(--line); border-radius: 14px; background: var(--surface-2); color: var(--ink);
  transition: transform .12s, border-color .12s, box-shadow .12s;
}
.level-picker:hover { border-color: var(--brand); transform: translateY(-1px); box-shadow: var(--shadow-sm); }
.lp-name { font-weight: 900; font-size: 16px; }
.lp-meta { font-size: 11px; font-weight: 800; color: var(--ink-soft); }
.icon-btn {
  width: 38px; height: 38px; border-radius: 12px; border: 2px solid var(--line); background: var(--surface-2);
  color: var(--ink); font-size: 18px; font-weight: 900; display: inline-grid; place-items: center; padding: 0;
  transition: transform .12s, border-color .12s, background .12s;
}
.icon-btn:hover:not(:disabled) { border-color: var(--brand); transform: translateY(-1px); }
.icon-btn:disabled { opacity: .4; cursor: not-allowed; }

.top-stats { display: flex; align-items: center; gap: 10px; }
.progress-pill { display: grid; gap: 3px; min-width: 120px; font-size: 11px; font-weight: 800; color: var(--ink-soft); }
.progress-bar { height: 8px; border-radius: 99px; background: var(--line); overflow: hidden; }
.progress-bar i { display: block; height: 100%; width: 0; background: linear-gradient(90deg, var(--brand), var(--brand-2)); border-radius: 99px; transition: width .5s cubic-bezier(.2, .8, .2, 1); }
.xp-pill { padding: 7px 12px; border-radius: 99px; background: linear-gradient(135deg, #fde68a, #fbbf24); color: #7c2d12; font-weight: 900; font-size: 13px; white-space: nowrap; box-shadow: var(--shadow-sm); }

/* ---------- ana yerleşim ---------- */
.layout {
  flex: 1; display: grid; grid-template-columns: minmax(340px, 560px) minmax(0, 1fr); gap: 16px; padding: 16px 18px 20px;
  align-items: start; max-width: 1500px; width: 100%; margin: 0 auto;
}
.stage-card, .workspace-card {
  background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); box-shadow: var(--shadow); padding: 14px;
}
.stage-head { display: flex; justify-content: space-between; align-items: flex-start; gap: 10px; margin-bottom: 10px; }
.stage-title h2 { margin: 0; font-size: 20px; font-weight: 900; }
.stage-hint { margin: 3px 0 0; font-size: 13px; line-height: 1.4; color: var(--ink-soft); font-weight: 700; min-height: 18px; }
.stars { display: flex; gap: 2px; font-size: 24px; line-height: 1; }
.stars .star { color: var(--line); transition: color .3s, transform .3s; }
.stars .star.on { color: var(--gold); text-shadow: 0 2px 8px rgba(251, 191, 36, .6); transform: scale(1.08); }

.canvas-wrap {
  position: relative; width: 100%; aspect-ratio: 1 / 1; border-radius: 16px; overflow: hidden;
  background: #0b3b4f; box-shadow: inset 0 0 0 3px rgba(255, 255, 255, .1), 0 6px 18px rgba(0, 0, 0, .22);
}
.canvas-wrap canvas { width: 100%; height: 100%; display: block; touch-action: none; }
.canvas-wrap.shake { animation: shake .4s; }
@keyframes shake { 0%, 100% { transform: translateX(0); } 20% { transform: translateX(-8px); } 40% { transform: translateX(7px); } 60% { transform: translateX(-5px); } 80% { transform: translateX(4px); } }
.toast {
  position: absolute; left: 50%; bottom: 14px; transform: translate(-50%, 20px); opacity: 0; pointer-events: none;
  background: rgba(15, 23, 42, .88); color: #fff; padding: 9px 16px; border-radius: 99px; font-weight: 800; font-size: 14px;
  max-width: 92%; text-align: center; transition: opacity .25s, transform .25s;
}
.toast.show { opacity: 1; transform: translate(-50%, 0); }
.toast.bad { background: rgba(185, 28, 28, .92); }
.toast.good { background: rgba(21, 128, 61, .92); }

.controls { display: flex; gap: 8px; margin-top: 12px; flex-wrap: wrap; }
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px; padding: 11px 16px; border-radius: 14px;
  border: 2px solid transparent; font-weight: 900; font-size: 15px; color: #fff; transition: transform .12s, box-shadow .12s, filter .12s;
}
.btn:hover:not(:disabled) { transform: translateY(-2px); }
.btn:active:not(:disabled) { transform: translateY(0); }
.btn:disabled { opacity: .5; cursor: not-allowed; }
.btn-run { flex: 1; background: linear-gradient(135deg, #22c55e, #16a34a); box-shadow: 0 6px 14px rgba(22, 163, 74, .35); font-size: 16px; }
.btn-ghost { background: var(--surface-2); color: var(--ink); border-color: var(--line); }
.btn-ghost:hover:not(:disabled) { border-color: var(--brand); }
.btn-compact { padding: 9px 14px; font-size: 13px; }
.status-row { display: flex; justify-content: space-between; align-items: center; gap: 10px; margin-top: 10px; min-height: 22px; }
.status { font-size: 13px; font-weight: 800; color: var(--ink-soft); }
.status.bad { color: var(--bad); } .status.good { color: var(--good); }
.block-counter { font-size: 12px; font-weight: 900; padding: 3px 10px; border-radius: 99px; background: var(--surface-2); color: var(--ink-soft); border: 1px solid var(--line); }
.block-counter.over { background: #fee2e2; color: #b91c1c; border-color: #fecaca; }
.block-counter:empty { display: none; }

/* ---------- blok editörü ---------- */
.workspace-card { display: flex; flex-direction: column; min-height: 560px; position: relative; }
.ws-head { display: flex; justify-content: space-between; align-items: center; gap: 10px; margin-bottom: 8px; }
.ws-head h3 { margin: 0; font-size: 16px; font-weight: 900; }
.ws-tools { display: flex; align-items: center; gap: 10px; }
.ws-help { font-size: 12px; font-weight: 700; color: var(--ink-soft); }
.blockly-host { flex: 1; min-height: 480px; border-radius: 14px; overflow: hidden; border: 2px solid var(--line); background: var(--surface-2); }
.ws-loading { position: absolute; inset: 56px 14px 14px; display: grid; place-items: center; font-weight: 800; color: var(--ink-soft); background: var(--surface-2); border-radius: 14px; }
.ws-loading.hidden { display: none; }
.blocklyHighlightedConnectionPath { stroke: #fbbf24 !important; }

/* ---------- modallar ---------- */
.modal { position: fixed; inset: 0; z-index: 100; display: grid; place-items: center; padding: 16px; }
.modal-backdrop { position: absolute; inset: 0; background: rgba(15, 16, 40, .6); backdrop-filter: blur(3px); }
.modal-card {
  position: relative; background: var(--surface); border-radius: 22px; box-shadow: 0 24px 60px rgba(0, 0, 0, .35);
  width: min(560px, 100%); max-height: 92vh; overflow: auto; padding: 22px; animation: pop .28s cubic-bezier(.2, .9, .3, 1.2);
}
@keyframes pop { from { transform: scale(.88); opacity: 0; } to { transform: scale(1); opacity: 1; } }
.modal-head { display: flex; justify-content: space-between; align-items: center; margin-bottom: 12px; }
.modal-head h3 { margin: 0; font-size: 20px; font-weight: 900; }
.picker-card { width: min(880px, 100%); }
.picker-group { margin-bottom: 16px; }
.picker-group h4 { margin: 0 0 8px; font-size: 14px; font-weight: 900; display: flex; align-items: center; gap: 8px; }
.picker-group h4 small { color: var(--ink-soft); font-weight: 800; }
.picker-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(72px, 1fr)); gap: 8px; }
.tile {
  position: relative; display: grid; gap: 2px; justify-items: center; padding: 8px 4px 6px; border-radius: 14px;
  border: 2px solid var(--line); background: var(--surface-2); color: var(--ink); font-weight: 900; transition: transform .12s, border-color .12s;
}
.tile:hover:not(:disabled) { transform: translateY(-2px); border-color: var(--brand); }
.tile .t-num { font-size: 18px; }
.tile .t-size { font-size: 10px; color: var(--ink-soft); font-weight: 800; }
.tile .t-stars { font-size: 11px; letter-spacing: 1px; color: var(--line); }
.tile .t-stars b { color: var(--gold); font-weight: 400; }
.tile.done { border-color: #86efac; background: color-mix(in srgb, #22c55e 14%, var(--surface-2)); }
.tile.current { border-color: var(--brand); box-shadow: 0 0 0 3px color-mix(in srgb, var(--brand) 25%, transparent); }
.tile:disabled { opacity: .45; cursor: not-allowed; }
.tile .lock { position: absolute; top: 4px; right: 5px; font-size: 11px; }

.result-card { text-align: center; overflow: hidden; }
.result-card .confetti { position: absolute; inset: 0; width: 100%; height: 100%; pointer-events: none; }
.result-emoji { font-size: 54px; animation: bounce .8s infinite alternate; position: relative; }
@keyframes bounce { from { transform: translateY(0); } to { transform: translateY(-8px); } }
.result-card h3 { margin: 4px 0 6px; font-size: 22px; font-weight: 900; position: relative; }
.result-stars { display: flex; justify-content: center; gap: 6px; font-size: 44px; line-height: 1; margin: 6px 0; position: relative; }
.result-stars span { color: var(--line); transform: scale(.6); opacity: .5; transition: all .45s cubic-bezier(.2, .9, .3, 1.5); }
.result-stars span.on { color: var(--gold); transform: scale(1); opacity: 1; text-shadow: 0 4px 14px rgba(251, 191, 36, .7); }
.result-text { margin: 4px 0 12px; color: var(--ink-soft); font-weight: 700; line-height: 1.5; position: relative; }
.result-stats { display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px; margin-bottom: 14px; position: relative; }
.result-stats > div { background: var(--surface-2); border: 1px solid var(--line); border-radius: 14px; padding: 10px 6px; }
.result-stats b { display: block; font-size: 22px; font-weight: 900; }
.result-stats small { color: var(--ink-soft); font-weight: 800; }
.result-actions { display: flex; gap: 8px; justify-content: center; flex-wrap: wrap; position: relative; }

/* ---------- mobil ---------- */
@media (max-width: 1000px) {
  .layout { grid-template-columns: 1fr; padding: 10px; }
  .stage-card { max-width: 560px; margin: 0 auto; width: 100%; }
  .workspace-card { min-height: 460px; }
  .blockly-host { min-height: 380px; }
}
@media (max-width: 640px) {
  .topbar { grid-template-columns: 1fr auto; padding: 8px 10px; }
  .brand-text small, .progress-pill { display: none; }
  .level-nav { grid-column: 1 / -1; order: 3; }
  .level-picker { flex: 1; min-width: 0; text-align: center; }
  .ws-help { display: none; }
  .btn { padding: 11px 12px; }
}
@media (prefers-reduced-motion: reduce) { * { animation: none !important; transition: none !important; } }

/* ---------- blok paleti (dokun/tıkla ekle) ---------- */
.palette { display: flex; flex-wrap: wrap; gap: 8px; margin-bottom: 10px; }
.pal-btn {
  display: inline-flex; align-items: center; gap: 6px; padding: 9px 13px; border-radius: 14px; border: 0; color: #fff;
  font-weight: 900; font-size: 14px; box-shadow: 0 3px 0 rgba(0, 0, 0, .22); transition: transform .1s, box-shadow .1s, filter .1s;
}
.pal-btn:hover { filter: brightness(1.08); transform: translateY(-1px); }
.pal-btn:active { transform: translateY(2px); box-shadow: 0 1px 0 rgba(0, 0, 0, .22); }
.pal-motion { background: #3b82f6; } .pal-turn { background: #a855f7; } .pal-loop { background: #f59e0b; } .pal-logic { background: #ec4899; }
.pal-tip { align-self: center; font-size: 12px; font-weight: 700; color: var(--ink-soft); }

/* ---------- ilk açılış yönlendirmesi ---------- */
.coach {
  position: absolute; right: 22px; top: 126px; z-index: 6; width: min(270px, calc(100% - 44px)); background: var(--surface); color: var(--ink);
  border: 2px solid var(--brand); border-radius: 16px; padding: 12px 14px; box-shadow: var(--shadow); animation: pop .3s cubic-bezier(.2, .9, .3, 1.2);
}
.coach b:first-child { display: block; margin-bottom: 4px; font-size: 14px; }
.coach ol { margin: 0 0 8px; padding-left: 18px; font-size: 13px; font-weight: 700; line-height: 1.5; color: var(--ink-soft); }
.coach.hidden { display: none; }
@media (max-width: 640px) { .coach { top: auto; bottom: 10px; right: 10px; } }

/* =====================================================================
   Blok editörü (v3): mıknatıs gibi yapışan, Scratch/Code.org tarzı bloklar
   ===================================================================== */
.workspace-card { min-height: 560px; }
.ed-ws {
  position: relative; flex: 1; min-height: 440px; overflow: auto; padding: 18px 16px 40px; border-radius: 14px;
  border: 2px dashed var(--line); --dent: var(--surface-2); touch-action: pan-y;
  background: radial-gradient(circle, color-mix(in srgb, var(--ink-soft) 28%, transparent) 1.2px, transparent 1.5px) 0 0 / 22px 22px, var(--surface-2);
  transition: border-color .15s, background-color .15s;
}
.ed-ws.ed-active { border-color: var(--brand); border-style: solid; }
.ed-ws.ed-trash { border-color: var(--bad); background-color: color-mix(in srgb, var(--bad) 10%, var(--surface-2)); }

/* BAŞLA kutusu */
.ed-prog { width: fit-content; min-width: min(100%, 290px); max-width: 100%; }
.ed-hat {
  position: relative; z-index: 2; width: fit-content; min-width: 170px; padding: 11px 20px 9px; border-radius: 24px 24px 6px 6px;
  background: #22c55e; color: #fff; font-weight: 900; font-size: 15px; box-shadow: inset 0 -3px rgba(0, 0, 0, .18);
}
.ed-prog-body {
  --dent: color-mix(in srgb, #22c55e 12%, var(--surface-2)); min-height: 72px; padding: 10px 12px 8px;
  border-left: 18px solid #22c55e; border-bottom: 14px solid #22c55e; border-radius: 0 0 0 16px;
  background: color-mix(in srgb, #22c55e 12%, var(--surface-2));
}
.ed-hat::after {
  content: ''; position: absolute; left: 18px; bottom: -6px; width: 22px; height: 7px; background: #22c55e; border-radius: 0 0 8px 8px; z-index: 3; display: none;
}

/* bloklar */
.ed-list { min-height: 8px; }
.ed-blk { position: relative; color: #fff; font-weight: 900; font-size: 15px; --bc: #3b82f6; }
.ed-motion { --bc: #3b82f6; } .ed-turn { --bc: #a855f7; } .ed-loop { --bc: #f59e0b; } .ed-logic { --bc: #ec4899; }
.ed-head {
  position: relative; display: flex; align-items: center; gap: 8px; padding: 11px 16px; border-radius: 8px; background: var(--bc);
  box-shadow: inset 0 -3px rgba(0, 0, 0, .2); cursor: grab; user-select: none; -webkit-user-select: none; touch-action: none; white-space: nowrap;
}
.ed-head:active { cursor: grabbing; }
.ed-head::before { /* üstte çentik (öndeki bloğun çıkıntısı buraya oturur) */
  content: ''; position: absolute; left: 18px; top: 0; width: 22px; height: 7px; background: var(--dent); border-radius: 0 0 8px 8px; z-index: 1;
}
.ed-blk:not(.ed-c) > .ed-head::after, .ed-c > .ed-foot::after { /* altta çıkıntı (mıknatıs tırnağı) */
  content: ''; position: absolute; left: 18px; bottom: -6px; width: 22px; height: 7px; background: var(--bc); border-radius: 0 0 8px 8px; z-index: 3;
}
.ed-blk + .ed-blk { margin-top: 0; }

/* döngü / koşul kutuları */
.ed-c { background: var(--bc); border-radius: 8px; box-shadow: inset 0 -3px rgba(0, 0, 0, .2); }
.ed-c > .ed-head { background: transparent; box-shadow: none; border-radius: 8px 8px 0 0; }
.ed-slot {
  --dent: color-mix(in srgb, var(--bc) 22%, var(--surface-2)); margin-left: 16px; padding: 8px 8px 8px 10px;
  background: color-mix(in srgb, var(--bc) 22%, var(--surface-2)); min-height: 44px;
}
.ed-sep { padding: 7px 16px; font-size: 13px; }
.ed-foot { position: relative; height: 16px; }
.ed-num, .ed-sel {
  border: 0; border-radius: 8px; padding: 4px 8px; font: inherit; font-weight: 900; color: #78350f; background: #fff7ed; cursor: pointer;
}
.ed-num { width: 56px; text-align: center; }
.ed-empty {
  color: var(--ink-soft); font-weight: 800; font-size: 13px; padding: 12px; border: 2px dashed var(--line); border-radius: 8px; text-align: center; background: transparent;
}

/* durumlar */
.ed-dragging { opacity: .3; }
.ed-sel-on > .ed-head { outline: 3px solid #fde047; outline-offset: 1px; }
.ed-run > .ed-head { outline: 3px solid #fff; box-shadow: 0 0 0 5px #fbbf24, inset 0 -3px rgba(0, 0, 0, .2); filter: brightness(1.15); }
.ed-pop { animation: ed-pop .35s cubic-bezier(.2, .9, .3, 1.4); }
@keyframes ed-pop { 0% { transform: scale(.85); } 60% { transform: scale(1.05); } 100% { transform: scale(1); } }
.ed-dropline {
  position: absolute; height: 6px; border-radius: 99px; background: var(--brand); pointer-events: none; z-index: 10;
  box-shadow: 0 0 0 3px rgba(79, 70, 229, .25), 0 0 16px rgba(79, 70, 229, .7);
}
.ed-ghost {
  position: fixed; z-index: 1000; pointer-events: none; padding: 10px 16px; border-radius: 10px; color: #fff; font-weight: 900; font-size: 15px;
  background: var(--bc); box-shadow: 0 12px 26px rgba(0, 0, 0, .35); transform: rotate(-2deg); white-space: nowrap;
}
.pal-btn { touch-action: none; user-select: none; -webkit-user-select: none; cursor: grab; }
@media (max-width: 1000px) { .ed-ws { min-height: 380px; } }

/* ---------- 3D'ye özgü: oturum süresi/XP, Çık ve Ödev Ver düğmeleri ---------- */
.chip { padding: 7px 12px; border-radius: 99px; font-weight: 900; font-size: 13px; white-space: nowrap; box-shadow: var(--shadow-sm); }
.chip-timer { background: #e0f2fe; color: #075985; border: 1px solid #7dd3fc; }
.chip-xp { background: linear-gradient(135deg, #fde68a, #fbbf24); color: #7c2d12; }
.btn-top { padding: 8px 13px; font-size: 13px; border-radius: 12px; color: #fff; border: 0; font-weight: 900; box-shadow: var(--shadow-sm); }
.btn-assign { background: linear-gradient(135deg, #0891b2, #0e7490); }
.btn-exit { background: linear-gradient(135deg, #ef4444, #dc2626); }
.btn-top:hover { filter: brightness(1.07); transform: translateY(-1px); }

/* =====================================================================
   v4 — köklü görsel yenileme: lacivert üst şerit, cam kartlar, kabartmalı düğmeler
   (yalnızca görsel; oyun/editör mantığı değişmedi)
   ===================================================================== */
:root {
  --bg: #eef4ff; --bg-2: #dbe8ff; --surface: #ffffff; --surface-2: #f1f6ff;
  --ink: #0b2447; --ink-soft: #5b7096; --line: #d3e1fb;
  --brand: #2563eb; --brand-2: #1d4ed8;
  --navy-1: #0a1738; --navy-2: #12285c;
  --radius: 26px;
  --shadow: 0 16px 34px rgba(15, 45, 92, .14);
  --shadow-sm: 0 4px 10px rgba(15, 45, 92, .10);
}
body:not(.dark) {
  background:
    radial-gradient(900px 500px at 8% -10%, #ffffff 0%, transparent 60%),
    radial-gradient(700px 500px at 100% 110%, #c7dcff 0%, transparent 60%),
    radial-gradient(circle, rgba(37, 99, 235, .10) 1.2px, transparent 1.6px) 0 0 / 26px 26px,
    linear-gradient(160deg, #eef4ff, #dbe8ff);
  background-attachment: fixed;
}
.topbar {
  margin: 10px 12px 0; border-radius: 24px; border: 1px solid rgba(255, 255, 255, .1); border-bottom: 1px solid rgba(255, 255, 255, .1);
  background: linear-gradient(165deg, var(--navy-1), var(--navy-2)); box-shadow: 0 14px 30px rgba(11, 36, 71, .3), inset 0 1px 0 rgba(255, 255, 255, .14);
  color: #fff; top: 8px;
}
.brand-text b { color: #fff; }
.brand-text small { color: #aac2ee; }
.brand-logo { filter: drop-shadow(0 3px 6px rgba(0, 0, 0, .4)); }
.level-picker { background: rgba(255, 255, 255, .1); border-color: rgba(255, 255, 255, .2); color: #fff; }
.level-picker:hover { border-color: #7fb0ff; background: rgba(255, 255, 255, .18); }
.lp-meta { color: #aac2ee; }
.icon-btn { background: linear-gradient(145deg, #4cc3ee, #1d8fd0); border: 0; color: #fff; box-shadow: 0 4px 0 rgba(0, 0, 0, .28); }
.icon-btn:hover:not(:disabled) { border: 0; filter: brightness(1.08); }
.icon-btn:active:not(:disabled) { transform: translateY(3px); box-shadow: 0 1px 0 rgba(0, 0, 0, .28); }
.progress-pill { color: #d5e3ff; }
.progress-bar { background: rgba(255, 255, 255, .18); height: 10px; box-shadow: inset 0 1px 3px rgba(0, 0, 0, .3); }
.progress-bar i { background: linear-gradient(90deg, #4ade80, #22d3ee); }
.chip-timer { background: rgba(255, 255, 255, .14); color: #fff; border-color: rgba(255, 255, 255, .22); }

.stage-card, .workspace-card {
  background: linear-gradient(170deg, #ffffff, #f1f6ff); border: 1px solid var(--line); border-radius: var(--radius); box-shadow: var(--shadow);
}
body.dark .stage-card, body.dark .workspace-card { background: var(--surface); border-color: var(--line); }
.stage-title h2 { font-size: 21px; }
.stars { font-size: 28px; filter: drop-shadow(0 2px 3px rgba(180, 83, 9, .25)); }

.canvas-wrap {
  border-radius: 22px; background: #0a1738; border: 1px solid rgba(255, 255, 255, .14);
  box-shadow: 0 20px 40px rgba(11, 36, 71, .4), inset 0 0 0 3px rgba(255, 255, 255, .08);
}
.toast { background: rgba(8, 18, 44, .9); border: 1px solid rgba(255, 255, 255, .18); }

.btn { border-radius: 16px; border: 0; }
.btn-run { background: linear-gradient(180deg, #22d398, #16a34a); box-shadow: 0 5px 0 #0f6b32, 0 10px 18px rgba(21, 128, 61, .32); }
.btn-run:hover:not(:disabled) { filter: brightness(1.06); }
.btn-run:active:not(:disabled) { transform: translateY(3px); box-shadow: 0 2px 0 #0f6b32; }
.btn-ghost { background: #fff; color: var(--ink); border: 2px solid var(--line); box-shadow: 0 4px 0 #c3d3ef; }
body.dark .btn-ghost { background: var(--surface-2); box-shadow: 0 4px 0 rgba(0, 0, 0, .35); }
.btn-ghost:hover:not(:disabled) { border-color: var(--brand); }
.btn-ghost:active:not(:disabled) { transform: translateY(3px); box-shadow: 0 1px 0 #c3d3ef; }
.status { font-weight: 900; }

.ws-head h3 { font-size: 17px; }
.ed-ws { border-radius: 18px; }
.pal-btn { border-radius: 16px; padding: 10px 14px; box-shadow: 0 4px 0 rgba(0, 0, 0, .25), inset 0 1px 0 rgba(255, 255, 255, .35); }
.pal-motion { background: linear-gradient(145deg, #60a5fa, #2563eb); }
.pal-turn { background: linear-gradient(145deg, #c084fc, #9333ea); }
.pal-loop { background: linear-gradient(145deg, #fbbf24, #ea8a04); }
.pal-logic { background: linear-gradient(145deg, #f472b6, #db2777); }
.ed-hat { background: linear-gradient(145deg, #34d399, #16a34a); }

.modal-backdrop { background: rgba(8, 18, 44, .62); backdrop-filter: blur(4px); }
.modal-card { background: linear-gradient(170deg, #ffffff, #f1f6ff); border: 1px solid var(--line); border-radius: 28px; }
body.dark .modal-card { background: var(--surface); }
.tile { border-radius: 16px; background: #fff; }
body.dark .tile { background: var(--surface-2); }
.result-stats > div { border-radius: 16px; }

/* =====================================================================
   v5 — oyun alanı büyük, program (blok) alanı minimal
   ===================================================================== */
.layout {
  grid-template-columns: minmax(0, 1fr) clamp(290px, 27vw, 380px); gap: 12px; padding: 12px 14px 16px; max-width: 1800px; align-items: start;
}
.stage-card { padding: 10px 12px 12px; }
.stage-head { margin-bottom: 6px; }
.stage-title h2 { font-size: 18px; }
.stage-hint { font-size: 12.5px; min-height: 0; }
.stars { font-size: 24px; }
/* oyun alanı: sığdığı kadar büyük kare */
.canvas-wrap {
  width: min(100%, calc(100vh - 235px)); min-width: min(100%, 360px); margin: 0 auto; border-radius: 18px;
}
.controls { margin-top: 8px; gap: 6px; justify-content: center; }
.btn { padding: 8px 14px; font-size: 14px; border-radius: 13px; }
.btn-run { flex: 0 1 auto; min-width: 150px; font-size: 15px; }
.btn-compact { padding: 7px 12px; font-size: 12.5px; }
.status-row { margin-top: 6px; min-height: 18px; }

/* program alanı: sade, küçük bloklar */
.workspace-card { min-height: 0; padding: 10px; border-radius: 20px; position: sticky; top: 76px; max-height: calc(100vh - 92px); }
.ws-head { margin-bottom: 6px; }
.ws-head h3 { font-size: 14px; }
.ws-help { display: none; }
.palette { gap: 5px; margin-bottom: 6px; }
.pal-btn {
  padding: 5px 9px; border-radius: 10px; font-size: 12.5px; gap: 4px; box-shadow: 0 2px 0 rgba(0, 0, 0, .22);
}
.pal-btn:active { transform: translateY(1px); box-shadow: 0 1px 0 rgba(0, 0, 0, .22); }
.ed-ws { min-height: 220px; max-height: calc(100vh - 220px); padding: 8px 8px 20px; border-radius: 14px; border-width: 1px; overflow: auto; }
.ed-prog { min-width: min(100%, 200px); }
.ed-hat { min-width: 120px; padding: 6px 12px 5px; font-size: 12.5px; border-radius: 14px 14px 4px 4px; }
.ed-prog-body { min-height: 36px; padding: 5px 6px 4px; border-left-width: 8px; border-bottom-width: 8px; border-radius: 0 0 0 10px; }
.ed-blk { font-size: 12.5px; }
.ed-head { padding: 5px 10px; gap: 6px; border-radius: 6px; box-shadow: inset 0 -2px rgba(0, 0, 0, .2); }
.ed-head::before { left: 12px; width: 14px; height: 4px; border-radius: 0 0 5px 5px; }
.ed-blk:not(.ed-c) > .ed-head::after, .ed-c > .ed-foot::after { left: 12px; bottom: -4px; width: 14px; height: 4px; border-radius: 0 0 5px 5px; }
.ed-c { border-radius: 6px; box-shadow: inset 0 -2px rgba(0, 0, 0, .2); }
.ed-c > .ed-head { border-radius: 6px 6px 0 0; }
.ed-slot { margin-left: 10px; padding: 4px 4px 4px 6px; min-height: 28px; }
.ed-sep { padding: 4px 10px; font-size: 11.5px; }
.ed-foot { height: 8px; }
.ed-num, .ed-sel { padding: 1px 5px; font-size: 12px; border-radius: 6px; }
.ed-num { width: 42px; }
.ed-empty { padding: 6px; font-size: 11.5px; border-width: 1px; }
.ed-dropline { height: 4px; }
.ed-ghost { padding: 5px 11px; font-size: 12.5px; }
.coach { top: 88px; right: 14px; width: min(230px, calc(100% - 28px)); padding: 9px 11px; }
.coach ol { font-size: 12px; line-height: 1.4; }
@media (max-width: 1000px) {
  .layout { grid-template-columns: 1fr; padding: 8px; }
  .stage-card { max-width: none; }
  .canvas-wrap { width: min(100%, 72vh); }
  .workspace-card { position: static; max-height: none; }
  .ed-ws { max-height: none; min-height: 200px; }
}

/* v6 — program alanı daha geniş ve ferah (oyun alanı hâlâ büyük) */
.layout { grid-template-columns: minmax(0, 1.25fr) minmax(380px, 1fr); max-width: 1900px; }
.workspace-card { padding: 14px; max-height: calc(100vh - 92px); min-height: calc(100vh - 150px); }
.ws-head h3 { font-size: 16px; }
.palette { gap: 7px; margin-bottom: 10px; }
.pal-btn { padding: 8px 13px; font-size: 13.5px; border-radius: 12px; }
.ed-ws { flex: 1; min-height: 340px; max-height: none; padding: 14px 14px 30px; border-width: 2px; }
.ed-prog { min-width: min(100%, 300px); }
.ed-hat { min-width: 150px; padding: 8px 16px 7px; font-size: 14px; }
.ed-prog-body { min-height: 56px; padding: 8px 10px 6px; border-left-width: 12px; border-bottom-width: 12px; }
.ed-blk { font-size: 14px; }
.ed-head { padding: 8px 14px; gap: 8px; }
.ed-slot { margin-left: 14px; padding: 6px 6px 6px 8px; min-height: 36px; }
.ed-foot { height: 12px; }
.ed-num, .ed-sel { padding: 3px 7px; font-size: 13px; }
.ed-num { width: 50px; }
.ed-empty { padding: 10px; font-size: 12.5px; }
.ed-ghost { font-size: 14px; padding: 8px 14px; }
@media (max-width: 1000px) {
  .layout { grid-template-columns: 1fr; }
  .workspace-card { min-height: 0; }
  .ed-ws { min-height: 300px; }
}

/* v7 — büyük ızgaralarda geniş ekran oyun alanı */
.canvas-wrap { transition: aspect-ratio .25s ease; }
.canvas-wrap[data-shape="mid"] { aspect-ratio: 4 / 3; width: min(100%, calc((100vh - 235px) * 1.333)); }
.canvas-wrap[data-shape="wide"] { aspect-ratio: 16 / 9; width: min(100%, calc((100vh - 235px) * 1.778)); }
@media (max-width: 1000px) {
  .canvas-wrap[data-shape="mid"] { width: 100%; }
  .canvas-wrap[data-shape="wide"] { width: 100%; }
}
