:root{
  --ink:#17203a; --muted:#5a6480; --paper:#ffffff; --bg:#f5f7ff;
  --blue:#4b6cff; --blue-dark:#3450d6; --pink:#ff6b9a; --yellow:#ffc93c;
  --green:#22b07d; --line:#e3e8f7; --shadow:0 8px 24px rgba(43,61,120,.10);
  --radius:20px;
}
*{box-sizing:border-box}
html{scroll-behavior:smooth}
body{margin:0;background:var(--bg);color:var(--ink);font-family:"Trebuchet MS",system-ui,-apple-system,"Segoe UI",sans-serif;line-height:1.5}
a{color:var(--blue);text-decoration:none}
a:hover{text-decoration:underline}
[hidden]{display:none!important}
.sr-only{position:absolute;width:1px;height:1px;padding:0;margin:-1px;overflow:hidden;clip:rect(0,0,0,0);white-space:nowrap;border:0}

.topbar{position:sticky;top:0;z-index:50;display:flex;align-items:center;gap:14px;flex-wrap:wrap;padding:10px 20px;background:rgba(255,255,255,.94);backdrop-filter:blur(8px);border-bottom:1px solid var(--line)}
.brand{display:flex;align-items:center;gap:10px;font-weight:900;font-size:20px;color:var(--ink)}
.logo{border-radius:12px}
.nav{display:flex;gap:16px;flex:1;justify-content:center;font-weight:700;font-size:15px}
.nav a{color:var(--muted)}
.lang-wrap select{font:inherit;font-weight:700;padding:8px 10px;border:1px solid var(--line);border-radius:12px;background:#fff;color:var(--ink)}

.hero{display:grid;grid-template-columns:1.2fr .8fr;gap:24px;align-items:center;max-width:1100px;margin:0 auto;padding:54px 20px 30px}
.tag{display:inline-block;background:#eef1ff;color:var(--blue-dark);font-weight:800;font-size:14px;padding:6px 12px;border-radius:999px}
.hero h1{font-size:clamp(34px,5vw,58px);line-height:1.08;margin:14px 0 12px;letter-spacing:-1px}
.lead{font-size:19px;color:var(--muted);max-width:560px}
.hero-actions{display:flex;gap:12px;flex-wrap:wrap;margin-top:24px}
.hero-art{display:flex;justify-content:center}
.hero-art img{width:100%;max-width:380px;height:auto}

.btn{display:inline-flex;align-items:center;justify-content:center;gap:8px;border:0;border-radius:14px;padding:14px 22px;font:inherit;font-weight:900;font-size:16px;cursor:pointer;text-decoration:none;transition:transform .12s ease,box-shadow .12s ease}
.btn:hover{text-decoration:none;transform:translateY(-2px)}
.btn-primary{background:var(--blue);color:#fff;box-shadow:0 6px 0 var(--blue-dark)}
.btn-primary:active{transform:translateY(2px);box-shadow:0 3px 0 var(--blue-dark)}
.btn-ghost{background:#fff;color:var(--blue-dark);border:2px solid #dbe2ff}
.btn-small{padding:9px 14px;font-size:14px;border-radius:11px}

.section{max-width:1100px;margin:0 auto;padding:44px 20px}
.section-alt{background:#eef2ff;border-radius:32px;max-width:none;padding-left:max(20px,calc((100% - 1060px)/2));padding-right:max(20px,calc((100% - 1060px)/2))}
.section-head{text-align:center;margin-bottom:26px}
.section-head h2{font-size:clamp(26px,4vw,38px);margin:0 0 8px}
.sub{color:var(--muted);margin:0;font-size:17px}

.grid{display:grid;grid-template-columns:repeat(auto-fit,minmax(220px,1fr));gap:18px}
.world-card{background:#fff;border:1px solid var(--line);border-radius:var(--radius);padding:18px;box-shadow:var(--shadow);cursor:pointer;transition:transform .15s ease}
.world-card:hover{transform:translateY(-4px)}
.world-card .wc-top{display:flex;align-items:center;gap:12px}
.world-card .emoji{font-size:34px;width:54px;height:54px;display:grid;place-items:center;background:#f0f3ff;border-radius:16px}
.world-card h3{margin:0;font-size:19px}
.world-card p{color:var(--muted);font-size:14px;margin:6px 0 12px}
.stars{font-size:20px;letter-spacing:2px;color:var(--yellow)}
.lock-tag{font-size:12px;color:var(--muted)}

#play{scroll-margin-top:70px}
.puzzle-card{background:#fff;border-radius:var(--radius);box-shadow:var(--shadow);padding:22px;margin-top:12px;border:1px solid var(--line)}
.puzzle-card h2{margin-top:0}
.concept{background:#f7f9ff;border-left:5px solid var(--blue);padding:12px 14px;border-radius:0 12px 12px 0;margin:12px 0}
.opts{display:grid;gap:10px;margin:14px 0}
.opt,.order-item{padding:13px 16px;border:2px solid #dbe2ff;background:#fff;border-radius:13px;font:inherit;font-weight:700;font-size:16px;cursor:pointer;text-align:start}
.opt:hover,.order-item:hover{border-color:var(--blue)}
.opt.right{background:#e6f9f1;border-color:var(--green);color:#0c7a55}
.opt.wrong{background:#ffedf1;border-color:var(--pink);color:#b3214a}
.opt:disabled{cursor:default}
.order-list{display:flex;flex-wrap:wrap;gap:10px;min-height:56px;padding:12px;background:#f7f9ff;border-radius:14px;margin-bottom:12px}
.order-item{background:#fff}
.puzzle-msg{font-weight:800;min-height:28px}
.code-snippet{display:grid;gap:10px;grid-template-columns:repeat(auto-fit,minmax(180px,1fr));margin-top:16px}
.code-snippet pre{background:#17203a;color:#dfe8ff;border-radius:14px;padding:14px;font-size:13px;overflow:auto;margin:0}
.code-snippet .label{font-size:12px;color:var(--muted);font-weight:800;display:block;margin-bottom:6px;text-transform:uppercase}

.lab-wrap{background:#fff;border:1px solid var(--line);border-radius:var(--radius);box-shadow:var(--shadow);overflow:hidden}
.lab-toolbar{display:flex;gap:10px;flex-wrap:wrap;padding:14px;border-bottom:1px solid var(--line)}
.lab-main{display:grid;grid-template-columns:1.25fr .75fr}
.lab-left{min-width:0}
.blockly-host{width:100%;height:520px}
.lab-right{padding:14px;border-inline-start:1px solid var(--line);min-width:0}
.stage-card{background:#f7f9ff;border-radius:14px;padding:12px}
.stage-head{font-weight:900;margin-bottom:8px}
.stage{position:relative;height:190px;background:linear-gradient(#dff3ff,#eefbdd);border:2px dashed #b9c8f5;border-radius:12px;overflow:hidden}
.actor{position:absolute;left:12px;bottom:12px;font-size:38px;transition:left .35s ease,bottom .35s ease}
.bubble{position:absolute;top:12px;inset-inline-end:12px;background:#fff;border-radius:12px;padding:8px 12px;font-weight:800;box-shadow:var(--shadow);max-width:160px}
.stage-log{margin-top:8px;font-size:13px;color:var(--muted);min-height:20px}
.code-tabs{display:flex;gap:6px;margin:14px 0 6px}
.tab{border:0;background:#eef1ff;color:var(--muted);font:inherit;font-weight:800;font-size:13px;padding:8px 12px;border-radius:10px 10px 0 0;cursor:pointer}
.tab.active{background:var(--blue);color:#fff}
.code-box{background:#17203a;color:#dfe8ff;border-radius:0 12px 12px 12px;padding:12px;font-size:12.5px;min-height:120px;overflow:auto;margin:0}
.tiny{font-size:12.5px;color:var(--muted)}

.locked{text-align:center;background:#fff;border:2px dashed #dbe2ff;border-radius:var(--radius);padding:30px;font-weight:800;color:var(--muted)}
.cert-card{background:#fff;border:10px solid #ffd76a;border-radius:18px;padding:28px;text-align:center;box-shadow:var(--shadow);max-width:720px;margin:auto}
.cert-top{font-weight:900;color:var(--blue-dark);letter-spacing:2px}
.cert-card h3{font-size:30px;margin:10px 0}
.cert-card input{font:inherit;font-size:20px;padding:10px 14px;border:2px dashed #b9c8f5;border-radius:12px;width:min(100%,320px);text-align:center}
.cert-date{color:var(--muted);margin-top:18px}

.info-grid{display:grid;grid-template-columns:repeat(auto-fit,minmax(240px,1fr));gap:18px}
.info-card{background:#fff;border:1px solid var(--line);border-radius:var(--radius);padding:20px;box-shadow:var(--shadow)}
.info-card h3{margin-top:0}
.info-card ul{padding-inline-start:20px;margin:0}
.info-card li{margin-bottom:8px}
.footer{text-align:center;padding:28px 20px;color:var(--muted);font-size:14px}

html[dir="rtl"] .concept{border-left:0;border-right:5px solid var(--blue);border-radius:12px 0 0 12px}
html[dir="rtl"] .lab-right{border-inline-start:0;border-inline-end:1px solid var(--line)}
html[dir="rtl"] .opt,html[dir="rtl"] .order-item{text-align:right}

@media (max-width:880px){
  .hero{grid-template-columns:1fr;padding-top:30px}
  .hero-art{order:-1}
  .nav{order:3;width:100%;justify-content:flex-start;gap:12px;overflow:auto}
  .lab-main{grid-template-columns:1fr}
  .lab-right{border-inline-start:0;border-top:1px solid var(--line)}
  .blockly-host{height:420px}
}
@media print{
  .topbar,.nav,.hero-actions,.lab-wrap,.section-head,.btn,.footer{display:none!important}
  body{background:#fff}
  .cert-card{border:8px solid #ffd76a;box-shadow:none}
}
