:root { --ink: #3d3226; --mute: #8a7a66; --bg: #fff8ee; --card: #fff; --acc: #f97316; --ok: #16a34a; --bad: #ef4444; --line: #eadfcc; }
* { box-sizing: border-box; }
body { margin: 0; font: 17px/1.55 system-ui, -apple-system, Segoe UI, sans-serif; color: var(--ink); background: var(--bg); }
a { color: inherit; }
h1, h2, h3 { line-height: 1.15; letter-spacing: -.01em; }
.top { position: sticky; top: 0; z-index: 20; display: flex; align-items: center; gap: 24px; padding: 12px 28px; background: rgba(255, 248, 238, .85); backdrop-filter: blur(10px); border-bottom: 1px solid var(--line); }
.logo { font-weight: 800; font-size: 22px; text-decoration: none; } .logo b { color: var(--acc); }
.top nav { display: flex; gap: 18px; align-items: center; margin-left: auto; } .top nav a { text-decoration: none; font-weight: 600; }
.btn-mini { background: var(--ink); color: #fff !important; padding: 6px 14px; border-radius: 99px; }
.xp { width: 120px; height: 22px; background: var(--line); border-radius: 99px; position: relative; overflow: hidden; }
.xp i { position: absolute; inset: 0 auto 0 0; background: linear-gradient(90deg, #fbbf24, var(--ok)); transition: width .6s; }
.xp span { position: relative; z-index: 1; font-size: 12px; font-weight: 700; display: block; text-align: center; line-height: 22px; }
.btn { display: inline-block; background: var(--acc); color: #fff; border: 0; padding: 13px 24px; border-radius: 14px; font: 700 16px system-ui; cursor: pointer; text-decoration: none; box-shadow: 0 4px 0 #c2410c; transition: transform .12s; }
.btn:hover { transform: translateY(-2px); } .btn:active { transform: translateY(2px); box-shadow: 0 1px 0 #c2410c; }
.btn.ghost { background: #fff; color: var(--ink); box-shadow: 0 4px 0 var(--line); border: 2px solid var(--line); }
.btn.small { padding: 7px 14px; font-size: 14px; }

.hero { position: relative; min-height: 640px; display: grid; grid-template-columns: 1fr 1.1fr; align-items: center; overflow: hidden; background: radial-gradient(circle at 70% 50%, #ffe7c7, var(--bg) 60%); }
#town3d { grid-column: 2; grid-row: 1; width: 100%; height: 640px; display: block; }
.hero-txt { grid-column: 1; grid-row: 1; }
.hero-txt { position: relative; padding: 40px 0 40px 6vw; max-width: 620px; animation: rise .8s both; }
.hero h1 { font-size: clamp(36px, 5vw, 64px); margin: 0 0 16px; } .hero em { color: var(--acc); font-style: normal; }
.lever { display: block; margin: 22px 0; font-weight: 700; background: #fff; padding: 14px 18px; border-radius: 16px; border: 2px solid var(--line); }
.lever input { width: 100%; } .lever span { display: block; font-weight: 500; color: var(--mute); font-size: 14px; }
.cta { display: flex; gap: 12px; flex-wrap: wrap; }
input[type=range] { accent-color: var(--acc); height: 26px; cursor: pointer; }

.grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(270px, 1fr)); gap: 22px; padding: 40px 6vw 80px; }
.card { position: relative; background: var(--card); border-radius: 22px; overflow: hidden; text-decoration: none; box-shadow: 0 6px 0 var(--line); border: 2px solid var(--line); animation: rise .6s both; animation-delay: var(--d); transition: transform .2s; }
.card:hover { transform: translateY(-6px) rotate(-.5deg); }
.thumb { height: 160px; background: #f3e5cf center/cover; position: relative; transition: transform .5s; }
.card:hover .thumb { transform: scale(1.06); }
.thumb span { position: absolute; left: 14px; bottom: -22px; font-size: 34px; background: #fff; border-radius: 50%; width: 56px; height: 56px; display: grid; place-items: center; box-shadow: 0 3px 10px #0002; }
.card h3 { margin: 30px 18px 6px; font-size: 19px; } .card p { margin: 0 18px 20px; color: var(--mute); font-size: 15px; }
.score { position: absolute; top: 12px; right: 12px; background: #fff; padding: 3px 10px; border-radius: 99px; font-size: 13px; color: var(--bad); }
.score.ok { color: var(--ok); }

.lesson-hero, .test-hero { min-height: 420px; background: #e9d8bd center/cover; display: flex; align-items: flex-end; position: relative; animation: kb 22s ease-in-out infinite alternate; }
.lesson-hero::after, .test-hero::after { content: ''; position: absolute; inset: 0; background: linear-gradient(transparent 30%, rgba(30, 20, 10, .75)); }
.lesson-hero > div, .test-hero > div { position: relative; z-index: 1; color: #fff; padding: 40px 6vw; max-width: 900px; animation: rise .7s both; }
.lesson-hero h1, .test-hero h1 { font-size: clamp(32px, 4.5vw, 54px); margin: 6px 0; }
.lesson-hero p, .test-hero p { font-size: 20px; opacity: .92; margin: 0; }
.ico { font-size: 44px; }
@keyframes kb { from { background-size: 105%; background-position: 40% 50%; } to { background-size: 118%; background-position: 60% 40%; } }
@keyframes rise { from { opacity: 0; transform: translateY(24px); } }

section.cards, section.sim, section.other, .quiz-wrap, .pager { max-width: 1100px; margin: 0 auto; padding: 40px 24px 0; }
.deck { position: relative; height: 290px; perspective: 1200px; }
.lc { position: absolute; inset: 0 auto 0 50%; width: min(560px, 90%); margin-left: calc(min(560px, 90%) / -2); background: #fff; border-radius: 24px; padding: 30px 34px; border: 2px solid var(--line); box-shadow: 0 10px 30px #6b4a2a1a; transition: transform .55s cubic-bezier(.2, .8, .2, 1.2), opacity .4s; transform: translateX(calc(var(--o) * 40px)) translateZ(calc(var(--o) * -80px)) rotateY(calc(var(--o) * -6deg)); z-index: calc(10 - var(--o)); }
.lc[data-pos=past] { transform: translateX(-120%) rotate(-12deg); opacity: 0; pointer-events: none; }
.lc[data-pos=next] { cursor: pointer; opacity: calc(1 - var(--o) * .25); }
.lc b { display: inline-grid; place-items: center; width: 34px; height: 34px; border-radius: 50%; background: var(--acc); color: #fff; }
.lc h3 { font-size: 24px; margin: 12px 0 8px; } .lc p { margin: 0; font-size: 18px; }
.deck-nav { display: flex; justify-content: center; align-items: center; gap: 16px; margin-top: 16px; }
.deck-nav button { width: 46px; height: 46px; border-radius: 50%; border: 2px solid var(--line); background: #fff; font-size: 20px; cursor: pointer; }
#dots i { display: inline-block; width: 9px; height: 9px; border-radius: 9px; background: var(--line); margin: 0 3px; transition: .3s; } #dots i.on { width: 26px; background: var(--acc); }

.sim h2, .quiz-wrap h2 { font-size: 28px; }
.sim-grid, .pp { display: grid; grid-template-columns: 330px 1fr; gap: 24px; background: #fff; border-radius: 24px; padding: 24px; border: 2px solid var(--line); }
.controls label { display: block; font-weight: 700; margin-bottom: 14px; } .controls input { width: 100%; }
.controls output { display: block; color: var(--acc); font-size: 14px; }
.stats { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; margin: 16px 0; }
.stats div { background: var(--bg); border-radius: 12px; padding: 8px 12px; } .stats small { color: var(--mute); display: block; font-size: 12px; } .stats b { font-size: 24px; }
.explain { color: var(--mute); font-size: 15px; min-height: 3em; }
.viz { display: flex; flex-direction: column; gap: 10px; min-width: 0; }
.chart { width: 100%; height: 300px; }
.town { background: linear-gradient(#e0f2fe, #f0fdf4); border-radius: 16px; padding: 10px; min-height: 110px; }
.shops, .queue { display: flex; flex-wrap: wrap; gap: 2px; min-height: 40px; font-size: 26px; }
.queue { font-size: 20px; border-top: 2px dashed #fca5a5; padding-top: 4px; }
.shops span, .queue span { animation: pop .35s both; display: inline-block; }
.shops span.bye, .queue span.bye { animation: drop .3s both; }
@keyframes pop { from { transform: scale(0) translateY(10px); } 70% { transform: scale(1.3); } }
@keyframes drop { to { transform: scale(0) rotate(40deg); opacity: 0; } }

.bars .bar { margin-bottom: 14px; } .bars .bar > div { position: relative; height: 26px; margin: 3px 0; background: var(--bg); border-radius: 8px; overflow: hidden; }
.bars i { position: absolute; inset: 0 auto 0 0; border-radius: 8px; transition: width .5s cubic-bezier(.2, .8, .2, 1.2); } .bars span { position: relative; padding-left: 8px; font-size: 14px; line-height: 26px; font-weight: 600; }
i.g { background: #86efac; } i.r { background: #fca5a5; }
.legend i { display: inline-block; width: 14px; height: 14px; border-radius: 4px; vertical-align: middle; margin: 0 4px 0 12px; }

.lanes { display: grid; grid-template-columns: 1fr 1fr; gap: 20px; margin-top: 18px; }
.lane { background: #fff; border: 2px solid var(--line); border-radius: 20px; padding: 18px; }
.lane h4 { margin: 0 0 10px; font-size: 19px; }
.track { position: relative; height: 44px; background: repeating-linear-gradient(90deg, #f3e5cf 0 20px, #fbf2e4 20px 40px); border-radius: 12px; }
.hen { position: absolute; left: 0; top: 4px; font-size: 28px; transform: translateX(-10%); transition: left .05s linear; }
.ctr { display: flex; justify-content: space-between; font-weight: 800; font-size: 22px; margin: 8px 0; }
.lane ol { padding-left: 22px; font-size: 14px; margin: 0; } .lane li { transition: .3s; color: var(--mute); } .lane li small { opacity: .7; }
.lane li.doing { color: var(--acc); font-weight: 700; transform: translateX(6px); } .lane li.done { color: var(--ok); text-decoration: line-through; }
.verdict { font-size: 18px; background: #fff7ed; padding: 14px 18px; border-radius: 14px; } .verdict:empty { display: none; }

.other { } .other h4 { margin: 0; color: var(--mute); text-transform: uppercase; font-size: 13px; letter-spacing: .08em; }
.other p { background: #fff; border-left: 5px solid #94a3b8; padding: 14px 18px; border-radius: 10px; }

.q { background: #fff; border-radius: 24px; padding: 26px; border: 2px solid var(--line); animation: rise .4s both; }
.qhead { display: flex; justify-content: space-between; color: var(--mute); font-size: 14px; position: relative; padding-bottom: 10px; }
.qhead i { position: absolute; left: 0; bottom: 0; height: 4px; background: var(--acc); border-radius: 4px; transition: width .4s; }
.tag { background: var(--bg); padding: 2px 10px; border-radius: 99px; }
.q h3 { font-size: 23px; }
.ans { display: grid; gap: 10px; }
.ans button { text-align: left; font: 600 17px system-ui; padding: 14px 18px; border-radius: 14px; border: 2px solid var(--line); background: var(--bg); cursor: pointer; transition: .15s; color: var(--ink); }
.ans button:hover:not(:disabled) { border-color: var(--acc); transform: translateX(4px); }
.ans button.right { background: #dcfce7; border-color: var(--ok); animation: pulse .5s; }
.ans button.wrong { background: #fee2e2; border-color: var(--bad); animation: shake .4s; }
@keyframes shake { 25% { transform: translateX(-8px); } 75% { transform: translateX(8px); } }
@keyframes pulse { 50% { transform: scale(1.03); } }
.why { opacity: 0; max-height: 0; transition: .4s; overflow: hidden; } .why.show { opacity: 1; max-height: 300px; margin-top: 16px; }
.why .btn { margin-left: 10px; }
.result { text-align: center; background: #fff; border-radius: 24px; padding: 34px; border: 2px solid var(--line); animation: rise .5s both; }
.result .btn { margin: 6px; }
.ring { width: 160px; height: 160px; margin: 0 auto; border-radius: 50%; display: grid; place-items: center; background: conic-gradient(var(--bad) calc(var(--p) * 1%), var(--line) 0); }
.result.pass .ring { background: conic-gradient(var(--ok) calc(var(--p) * 1%), var(--line) 0); }
.ring b { width: 120px; height: 120px; background: #fff; border-radius: 50%; display: grid; place-items: center; font-size: 34px; }
.pager { display: flex; justify-content: space-between; padding-bottom: 80px; } .pager a { font-weight: 700; text-decoration: none; color: var(--acc); }
.confetti { position: fixed; inset: 0; pointer-events: none; z-index: 99; }
#toast { position: fixed; bottom: 24px; left: 50%; transform: translate(-50%, 120px); background: var(--ink); color: #fff; padding: 12px 20px; border-radius: 12px; transition: .3s; z-index: 50; max-width: 90vw; }
#toast.show { transform: translate(-50%, 0); } #toast.err { background: var(--bad); cursor: pointer; }

@media (max-width: 820px) {
  .hero { grid-template-columns: 1fr; min-height: 0; } #town3d { grid-column: 1; grid-row: 1; height: 340px; } .hero-txt { grid-column: 1; grid-row: 2; }
  .hero-txt { padding: 20px 24px; } .sim-grid, .pp, .lanes { grid-template-columns: 1fr; }
  .deck { height: 340px; } .top { padding: 10px 14px; gap: 10px; } .xp { width: 60px; }
}
@media (prefers-reduced-motion: reduce) { *, *::before, *::after { animation: none !important; transition: none !important; } }

.bd { background: #fff; border-radius: 24px; padding: 24px; border: 2px solid var(--line); }
.bd-row { margin-bottom: 16px; } .bd-row b { display: block; margin-bottom: 6px; }
.stack { display: flex; height: 38px; background: var(--bg); border-radius: 10px; overflow: hidden; }
.stack i { flex-grow: 0; flex-shrink: 0; animation: grow .7s both cubic-bezier(.2,.8,.2,1.1); transform-origin: left; }
@keyframes grow { from { transform: scaleX(0); } }
.bd-legend { display: flex; flex-wrap: wrap; gap: 6px 16px; font-size: 14px; color: var(--mute); }
.bd-legend i { display: inline-block; width: 12px; height: 12px; border-radius: 3px; margin-right: 6px; vertical-align: middle; }
.bd-zoom { display: block; margin-top: 12px; font-weight: 600; }
