/* Тоғызқұмалақ 3D — заманауи этно-дизайн
   Түстер: түнгі дала (indigo), алтын (ою), көгілдір (Ясауи күмбезі), қызғылт-қызыл (Шарын) */

:root {
    --ink: #0b0c18;
    --night: #12142a;
    --night-2: #1a1c38;
    --panel: rgba(16, 17, 34, 0.78);
    --panel-solid: #15172e;
    --line: rgba(240, 200, 120, 0.2);
    --line-strong: rgba(240, 200, 120, 0.45);
    --gold: #e9b44c;
    --gold-2: #f6d78f;
    --ivory: #f7eedc;
    --muted: #b8ad98;
    --turq: #4fd1c1;
    --red: #e0703f;
    --danger: #e05a4a;
    --p0: #f0c060;
    --p1: #4fd1c1;
    --accent: #e0703f;
    --radius: 18px;
    --font-display: 'Montserrat Alternates', 'Manrope', system-ui, sans-serif;
    --font-body: 'Manrope', system-ui, -apple-system, 'Segoe UI', sans-serif;
    --shadow: 0 20px 60px rgba(0, 0, 0, 0.45);
}

* { box-sizing: border-box; margin: 0; padding: 0; }

html { scroll-behavior: smooth; }

body {
    font-family: var(--font-body);
    background: var(--ink);
    color: var(--ivory);
    overflow: hidden;
    height: 100vh;
    height: 100dvh;
    -webkit-font-smoothing: antialiased;
}

button { font: inherit; color: inherit; cursor: pointer; border: 0; background: none; }
a { color: inherit; text-decoration: none; }
[hidden] { display: none !important; }

#game-canvas { position: fixed; inset: 0; width: 100%; height: 100%; display: block; z-index: 0; touch-action: none; }

#fade {
    position: fixed; inset: 0; z-index: 90; background: var(--ink);
    opacity: 0; pointer-events: none; transition: opacity .45s ease;
}
#fade.on { opacity: 1; }

/* ---------- Ортақ элементтер ---------- */
.eyebrow {
    display: inline-flex; align-items: center; gap: .5em;
    font-size: .74rem; font-weight: 700; letter-spacing: .16em; text-transform: uppercase;
    color: var(--gold);
}
.eyebrow svg { color: var(--gold); }

.btn {
    display: inline-flex; align-items: center; justify-content: center; gap: .5em;
    padding: .85em 1.6em; border-radius: 999px;
    font-weight: 700; font-size: .95rem; letter-spacing: .01em;
    transition: transform .2s ease, box-shadow .2s ease, background .2s ease, border-color .2s;
    white-space: nowrap;
}
.btn:focus-visible, .icon-btn:focus-visible, .link-btn:focus-visible { outline: 2px solid var(--gold-2); outline-offset: 3px; }
.btn-primary {
    color: #23170a;
    background: linear-gradient(135deg, var(--gold-2), var(--gold) 55%, #c98b2a);
    box-shadow: 0 8px 26px rgba(233, 180, 76, 0.32), inset 0 1px 0 rgba(255, 255, 255, .5);
}
.btn-primary:hover { transform: translateY(-2px); box-shadow: 0 12px 34px rgba(233, 180, 76, 0.45), inset 0 1px 0 rgba(255, 255, 255, .5); }
.btn-ghost { border: 1px solid var(--line-strong); color: var(--ivory); background: rgba(255, 255, 255, .03); }
.btn-ghost:hover { border-color: var(--gold); background: rgba(233, 180, 76, .08); }
.btn-text { color: var(--muted); padding-inline: 1em; }
.btn-text:hover { color: var(--ivory); }
.btn-danger { background: var(--danger); color: #fff; }
.btn-small { padding: .6em 1.15em; font-size: .85rem; }
.btn-large { padding: 1.05em 2em; font-size: 1rem; }
.btn[disabled] { opacity: .45; cursor: not-allowed; transform: none; }

.link-btn { color: var(--muted); font-size: .85rem; text-decoration: underline; text-underline-offset: 3px; }
.link-btn:hover { color: var(--gold-2); }

.orn-divider {
    height: 28px; margin: 0 auto;
    background: var(--orn-band) repeat-x center / 56px 28px;
    opacity: .9;
}
.orn-divider.soft { background-image: var(--orn-band-soft); }

.chips { display: flex; flex-wrap: wrap; gap: 6px; list-style: none; }
.chips li {
    font-size: .75rem; font-weight: 600; color: var(--gold-2);
    padding: .3em .8em; border-radius: 999px; border: 1px solid var(--line); background: rgba(233, 180, 76, .06);
}

.muted { color: var(--muted); }

/* ---------- Басты бет ---------- */
#home {
    position: fixed; inset: 0; z-index: 20;
    overflow-y: auto; overflow-x: hidden;
    transition: opacity .6s ease, transform .6s ease;
    scrollbar-width: thin; scrollbar-color: var(--line-strong) transparent;
}
#home.away { opacity: 0; pointer-events: none; transform: scale(1.02); }

.topnav {
    position: sticky; top: 0; z-index: 5;
    display: flex; align-items: center; justify-content: space-between; gap: 16px;
    padding: 14px clamp(16px, 4vw, 48px);
    background: linear-gradient(180deg, rgba(11, 12, 24, .85), rgba(11, 12, 24, 0));
    backdrop-filter: blur(6px);
}
.brand { display: flex; align-items: center; gap: 10px; color: var(--gold); }
.brand-text { font-family: var(--font-display); font-weight: 500; font-size: 1rem; color: var(--ivory); letter-spacing: .02em; }
.brand-text b { color: var(--gold); font-weight: 600; }
.nav-links { display: flex; gap: 28px; font-weight: 600; font-size: .92rem; color: var(--muted); }
.nav-links a:hover { color: var(--gold-2); }

.hero {
    position: relative;
    min-height: calc(100vh - 64px); min-height: calc(100svh - 64px);
    display: flex; align-items: center;
    padding: 24px clamp(16px, 6vw, 96px) 80px;
    background: linear-gradient(90deg, rgba(11, 12, 24, .9) 0%, rgba(11, 12, 24, .62) 40%, rgba(11, 12, 24, 0) 72%);
}
.hero-inner { max-width: 640px; display: flex; flex-direction: column; gap: 22px; animation: rise .9s ease both; }
.hero-title {
    font-family: var(--font-display); font-weight: 600;
    font-size: clamp(2.6rem, 7.4vw, 6.2rem); line-height: .95; letter-spacing: -.02em;
    display: flex; flex-direction: column;
}
.hero-title span {
    background: linear-gradient(100deg, var(--gold-2), var(--gold) 40%, var(--red));
    -webkit-background-clip: text; background-clip: text; color: transparent;
}
.hero-lead { font-size: clamp(1rem, 1.6vw, 1.2rem); line-height: 1.65; color: #ded3bf; max-width: 34em; }
.hero-actions { display: flex; flex-wrap: wrap; gap: 12px; }
.hero-stats { display: flex; gap: clamp(18px, 3vw, 40px); margin-top: 10px; padding-top: 22px; border-top: 1px solid var(--line); }
.hero-stats dt { font-family: var(--font-display); font-size: clamp(1.4rem, 2.6vw, 2rem); color: var(--gold-2); }
.hero-stats dd { font-size: .8rem; color: var(--muted); letter-spacing: .05em; }

.scroll-hint { position: absolute; left: 50%; bottom: 26px; width: 26px; height: 42px; border: 2px solid var(--line-strong); border-radius: 14px; transform: translateX(-50%); }
.scroll-hint span { position: absolute; left: 50%; top: 8px; width: 4px; height: 8px; margin-left: -2px; border-radius: 2px; background: var(--gold); animation: scrolly 1.8s ease-in-out infinite; }

.section {
    position: relative;
    padding: clamp(56px, 8vw, 110px) clamp(16px, 6vw, 96px);
    background: var(--orn-lattice) repeat, linear-gradient(180deg, rgba(14, 15, 30, .95), rgba(14, 15, 30, .98));
}
.section-head { max-width: 720px; margin-bottom: 40px; display: flex; flex-direction: column; gap: 14px; }
.section-head h2 { font-family: var(--font-display); font-weight: 500; font-size: clamp(1.6rem, 3.4vw, 2.6rem); line-height: 1.15; }
.section-head p { color: var(--muted); line-height: 1.7; font-size: 1.02rem; }
.section-head b { color: var(--gold-2); }

/* Деңгей карталары */
.level-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(250px, 1fr)); gap: 20px; }
.level-card {
    position: relative; display: flex; flex-direction: column;
    border-radius: var(--radius); overflow: hidden;
    background: linear-gradient(180deg, rgba(255, 255, 255, .04), rgba(255, 255, 255, .015));
    border: 1px solid var(--line);
    transition: transform .3s ease, border-color .3s ease, box-shadow .3s ease;
}
.level-card:not(.locked):hover { transform: translateY(-6px); border-color: var(--accent); box-shadow: 0 18px 50px rgba(0, 0, 0, .4), 0 0 0 1px var(--accent); }
.lc-illus { position: relative; aspect-ratio: 16 / 10; overflow: hidden; }
.lc-illus svg { width: 100%; height: 100%; display: block; transition: transform .6s ease; }
.level-card:hover .lc-illus svg { transform: scale(1.05); }
.lc-illus::after { content: ''; position: absolute; inset: auto 0 0 0; height: 40%; background: linear-gradient(0deg, rgba(14, 15, 30, .9), transparent); }
.lc-num { position: absolute; left: 16px; top: 12px; z-index: 1; font-family: var(--font-display); font-size: 1.7rem; font-weight: 600; color: #fff; text-shadow: 0 2px 12px rgba(0, 0, 0, .5); }
.lc-lock { position: absolute; inset: 0; z-index: 2; display: grid; place-items: center; background: rgba(11, 12, 24, .55); color: var(--gold-2); }
.lc-lock svg { width: 34px; height: 34px; padding: 10px; box-sizing: content-box; border-radius: 50%; border: 1px solid var(--line-strong); background: rgba(11, 12, 24, .6); }
.level-card.locked .lc-illus svg { filter: grayscale(.85) brightness(.7); }
.lc-body { display: flex; flex-direction: column; gap: 10px; padding: 18px 20px 20px; flex: 1; }
.lc-body .eyebrow { color: var(--accent); }
.lc-body h3 { font-family: var(--font-display); font-weight: 500; font-size: 1.25rem; }
.lc-body p { color: var(--muted); font-size: .92rem; line-height: 1.55; }
.lc-meta { display: flex; justify-content: space-between; gap: 8px; font-size: .78rem; color: var(--muted); border-top: 1px dashed var(--line); padding-top: 10px; margin-top: auto; }
.lc-req { font-size: .82rem !important; color: var(--gold-2) !important; opacity: .8; }
.lc-progress { display: flex; flex-direction: column; gap: 6px; }
.lc-progress small { font-size: .78rem; color: var(--muted); }
.lc-bar { height: 6px; border-radius: 6px; background: rgba(255, 255, 255, .08); overflow: hidden; }
.lc-bar i { display: block; height: 100%; border-radius: inherit; background: linear-gradient(90deg, var(--accent), var(--gold-2)); transition: width .8s ease; }
.level-card .btn { margin-top: 6px; align-self: flex-start; }

.progress-strip { display: flex; flex-wrap: wrap; gap: 10px 28px; margin-top: 26px; font-size: .9rem; color: var(--muted); }
.progress-strip b { color: var(--gold-2); }
.progress-strip .demo { color: var(--turq); }

/* Жоба туралы */
.pillars { display: grid; grid-template-columns: repeat(auto-fit, minmax(260px, 1fr)); gap: 20px; }
.pillar {
    position: relative; padding: 28px 26px; border-radius: var(--radius);
    border: 1px solid var(--line); background: rgba(255, 255, 255, .025);
    display: flex; flex-direction: column; gap: 14px;
}
.pillar::before {
    content: ''; position: absolute; top: -1px; left: -1px; width: 46px; height: 46px;
    background: var(--orn-corner) no-repeat 0 0 / contain; opacity: .7;
}
.pillar-icon { width: 54px; height: 54px; display: grid; place-items: center; border-radius: 50%; color: var(--gold); border: 1px solid var(--line-strong); background: radial-gradient(circle, rgba(233, 180, 76, .16), transparent 70%); }
.pillar h3 { font-family: var(--font-display); font-weight: 500; font-size: 1.15rem; }
.pillar p { color: var(--muted); line-height: 1.65; font-size: .95rem; }

.tech { display: grid; grid-template-columns: repeat(auto-fit, minmax(240px, 1fr)); gap: 0; margin-top: 28px; border: 1px solid var(--line); border-radius: var(--radius); overflow: hidden; }
.tech-col { padding: 22px 24px; border-right: 1px solid var(--line); }
.tech-col:last-child { border-right: 0; }
.tech-col h4 { font-size: .78rem; letter-spacing: .14em; text-transform: uppercase; color: var(--turq); margin-bottom: 8px; }
.tech-col p { font-size: .92rem; color: var(--muted); line-height: 1.6; }

/* Ережелер */
.rules-list { list-style: none; counter-reset: r; display: grid; grid-template-columns: repeat(auto-fit, minmax(300px, 1fr)); gap: 16px; }
.rules-list li {
    counter-increment: r; position: relative;
    padding: 22px 22px 22px 78px; border-radius: 16px;
    background: rgba(255, 255, 255, .025); border: 1px solid var(--line);
}
.rules-list li::before {
    content: counter(r); position: absolute; left: 20px; top: 20px;
    width: 40px; height: 40px; display: grid; place-items: center;
    font-family: var(--font-display); font-weight: 600; color: #23170a;
    background: linear-gradient(135deg, var(--gold-2), var(--gold));
    clip-path: polygon(50% 0, 100% 50%, 50% 100%, 0 50%);
}
.rules-list h4 { font-family: var(--font-display); font-weight: 500; font-size: 1rem; margin-bottom: 6px; color: var(--gold-2); }
.rules-list p { color: var(--muted); line-height: 1.6; font-size: .93rem; }
.rules-list.compact { grid-template-columns: 1fr; gap: 10px; }
.rules-list.compact li { padding: 14px 16px 14px 64px; }
.rules-list.compact li::before { left: 14px; top: 14px; width: 34px; height: 34px; font-size: .85rem; }

.footer { background: #0a0b16; padding: 0 0 36px; }
.footer-inner { padding: 30px clamp(16px, 6vw, 96px) 0; display: flex; flex-direction: column; gap: 8px; font-size: .9rem; color: #d8cdb8; }
.footer-brand { display: flex; align-items: center; gap: 10px; font-family: var(--font-display); color: var(--gold); margin-bottom: 6px; }
.footer .link-btn { align-self: flex-start; margin-top: 10px; }

/* ---------- Ойын HUD ---------- */
#hud { position: fixed; inset: 0; z-index: 30; pointer-events: none; animation: fadein .6s ease both; }
#hud > * { pointer-events: auto; }
#hud .hud-hint, #hud #toasts { pointer-events: none; }

.hud-top {
    position: absolute; top: 0; left: 0; right: 0;
    display: flex; align-items: center; gap: 14px;
    padding: 14px 18px;
    background: linear-gradient(180deg, rgba(11, 12, 24, .75), rgba(11, 12, 24, 0));
}
.hud-title { display: flex; flex-direction: column; gap: 2px; min-width: 0; }
.hud-title .eyebrow { color: var(--accent); font-size: .66rem; }
.hud-title h1 { font-family: var(--font-display); font-weight: 500; font-size: 1.2rem; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.hud-actions { margin-left: auto; display: flex; gap: 8px; }

.icon-btn {
    height: 42px; min-width: 42px; padding: 0 11px;
    display: inline-flex; align-items: center; justify-content: center; gap: 6px;
    border-radius: 12px; border: 1px solid var(--line); background: var(--panel); backdrop-filter: blur(10px);
    color: var(--ivory); transition: border-color .2s, background .2s, transform .2s;
}
.icon-btn:hover { border-color: var(--gold); transform: translateY(-1px); }
.icon-btn.accent { color: #23170a; background: linear-gradient(135deg, var(--gold-2), var(--gold)); border-color: transparent; font-weight: 700; font-size: .85rem; padding: 0 14px; }

.turn-pill {
    position: absolute; left: 50%; top: 18px; transform: translateX(-50%);
    display: inline-flex; align-items: center; gap: 10px;
    padding: 10px 18px; border-radius: 999px;
    background: var(--panel); border: 1px solid var(--line); backdrop-filter: blur(10px);
    font-weight: 700; font-size: .92rem; white-space: nowrap;
}
.turn-pill .dot { width: 10px; height: 10px; border-radius: 50%; background: var(--gold); box-shadow: 0 0 12px currentColor; }
.turn-pill.p0 .dot { background: var(--p0); color: var(--p0); }
.turn-pill.p1 .dot { background: var(--p1); color: var(--p1); }
.turn-pill.lesson .dot { background: #8fe8ff; color: #8fe8ff; }
.turn-pill .timer { font-family: var(--font-display); font-size: .82rem; padding: 2px 8px; border-radius: 8px; background: rgba(255, 255, 255, .08); }
.turn-pill .timer.low { background: var(--danger); animation: pulse .6s ease infinite alternate; }
.dots { display: inline-flex; gap: 3px; }
.dots i { width: 4px; height: 4px; border-radius: 50%; background: currentColor; animation: blink 1.2s infinite; }
.dots i:nth-child(2) { animation-delay: .2s; } .dots i:nth-child(3) { animation-delay: .4s; }

.players { position: absolute; left: 18px; top: 50%; transform: translateY(-50%); display: flex; flex-direction: column; gap: 14px; width: 230px; }
.player-card {
    position: relative; padding: 14px 16px 14px; border-radius: 16px;
    background: var(--panel); border: 1px solid var(--line); backdrop-filter: blur(12px);
    display: flex; flex-direction: column; gap: 8px; transition: border-color .3s, box-shadow .3s;
}
.player-card.p0 { --pc: var(--p0); }
.player-card.p1 { --pc: var(--p1); }
.player-card.active { border-color: var(--pc); box-shadow: 0 0 0 1px var(--pc), 0 0 30px color-mix(in srgb, var(--pc) 25%, transparent); }
.pc-head { display: flex; align-items: center; gap: 10px; }
.pc-head b { display: block; font-size: .95rem; }
.pc-head small { display: block; font-size: .72rem; color: var(--muted); }
.pc-dot { width: 12px; height: 12px; border-radius: 50%; background: var(--pc); box-shadow: 0 0 10px var(--pc); flex: none; }
.pc-score { display: flex; align-items: baseline; gap: 6px; }
.pc-kazan { font-family: var(--font-display); font-size: 2rem; font-weight: 600; color: var(--pc); line-height: 1; }
.pc-score small { color: var(--muted); font-size: .8rem; }
.pc-bar { height: 5px; border-radius: 5px; background: rgba(255, 255, 255, .08); overflow: hidden; }
.pc-bar i { display: block; height: 100%; width: 0; background: var(--pc); border-radius: inherit; transition: width .4s ease; }
.pc-tuzdyk { font-size: .74rem; color: var(--pc); min-height: 0; }
.pc-tuzdyk:empty { display: none; }

/* Сабақ панелі */
.lesson-panel {
    position: absolute; right: 18px; top: 80px; width: min(380px, calc(100vw - 36px));
    padding: 20px 22px; border-radius: var(--radius);
    background: var(--panel); border: 1px solid rgba(143, 232, 255, .35); backdrop-filter: blur(14px);
    box-shadow: var(--shadow), 0 0 40px rgba(143, 232, 255, .08);
    display: flex; flex-direction: column; gap: 12px;
    animation: slidein .5s ease both;
}
.lesson-panel.done { border-color: rgba(240, 192, 96, .6); }
.lp-top { display: flex; justify-content: space-between; align-items: center; }
.lesson-panel .eyebrow { color: #8fe8ff; }
.lesson-panel h3 { font-family: var(--font-display); font-weight: 500; font-size: 1.15rem; }
.lesson-panel p { line-height: 1.6; color: #e6dcc8; font-size: .95rem; }
.lesson-panel.done p { color: var(--gold-2); }
.lp-dots { display: flex; gap: 6px; }
.lp-dots i { width: 22px; height: 4px; border-radius: 4px; background: rgba(255, 255, 255, .12); }
.lp-dots i.past { background: var(--gold); }
.lp-dots i.now { background: #8fe8ff; }
.lp-actions { display: flex; justify-content: flex-end; gap: 8px; }
.lp-actions:empty { display: none; }

/* Тосттар */
#toasts { position: absolute; left: 50%; bottom: 52px; transform: translateX(-50%); display: flex; flex-direction: column; align-items: center; gap: 8px; width: min(520px, calc(100vw - 32px)); }
.toast {
    width: 100%; padding: 12px 18px; border-radius: 14px;
    background: var(--panel-solid); border: 1px solid var(--line); box-shadow: var(--shadow);
    font-size: .92rem; line-height: 1.5; text-align: center;
    animation: toastin .35s cubic-bezier(.2, .9, .3, 1.2) both;
}
.toast.out { animation: toastout .35s ease both; }
.toast.warn { border-color: rgba(224, 112, 63, .6); }
.toast.tutor, .toast.good { text-align: left; border-color: rgba(143, 232, 255, .45); background: linear-gradient(135deg, #15203a, #141629); }
.toast.good { border-color: rgba(240, 192, 96, .6); }
.toast em { color: var(--gold-2); font-style: normal; }
.toast-head { display: flex; align-items: center; gap: 6px; font-size: .7rem; font-weight: 800; letter-spacing: .14em; text-transform: uppercase; color: #8fe8ff; margin-bottom: 4px; }
.toast.good .toast-head { color: var(--gold-2); }
.toast.cap { width: auto; padding: 8px 18px; font-weight: 700; }
.toast.cap.p0 { color: var(--p0); border-color: rgba(240, 192, 96, .5); }
.toast.cap.p1 { color: var(--p1); border-color: rgba(79, 209, 193, .5); }

.hud-hint { position: absolute; bottom: 14px; left: 50%; transform: translateX(-50%); font-size: .75rem; color: rgba(247, 238, 220, .5); white-space: nowrap; }

/* 3D белгілер */
#labels { position: fixed; inset: 0; z-index: 10; pointer-events: none; opacity: 0; transition: opacity .6s ease; }
#labels.show { opacity: 1; }
.pit-badge, .kazan-badge {
    position: absolute; left: 0; top: 0; will-change: transform;
    min-width: 28px; padding: 3px 8px; border-radius: 999px; text-align: center;
    font-family: var(--font-display); font-weight: 600; font-size: .8rem;
    background: rgba(11, 12, 24, .78); border: 1px solid var(--line-strong); color: var(--ivory);
}
.pit-badge.p0 { border-color: rgba(240, 192, 96, .55); }
.pit-badge.p1 { border-color: rgba(79, 209, 193, .55); }
.pit-badge.tuzdyk { background: var(--gold); color: #23170a; }
.pit-badge.p0.tuzdyk { background: var(--p1); }
.kazan-badge { font-size: .95rem; padding: 4px 12px; }
.kazan-badge.p0 { color: var(--p0); border-color: var(--p0); }
.kazan-badge.p1 { color: var(--p1); border-color: var(--p1); }

/* ---------- Модальды терезе ---------- */
#modal {
    position: fixed; inset: 0; z-index: 80; display: grid; place-items: center; padding: 16px;
    background: rgba(6, 7, 16, .62); backdrop-filter: blur(8px);
    opacity: 0; transition: opacity .35s ease;
}
#modal.open { opacity: 1; }
.modal-card {
    position: relative; width: min(640px, 100%); max-height: calc(100dvh - 32px); overflow-y: auto;
    border-radius: 22px; background: linear-gradient(180deg, #181a34, #111226);
    border: 1px solid var(--line-strong); box-shadow: var(--shadow);
    animation: pop .45s cubic-bezier(.2, .9, .3, 1.15) both;
    scrollbar-width: thin; scrollbar-color: var(--line-strong) transparent;
}
.modal-card::before, .modal-card::after {
    content: ''; position: absolute; width: 40px; height: 40px; z-index: 2; pointer-events: none;
    background: var(--orn-corner) no-repeat 0 0 / contain;
}
.modal-card::before { top: 8px; left: 8px; }
.modal-card::after { bottom: 8px; right: 8px; transform: rotate(180deg); }
.modal-banner { position: relative; aspect-ratio: 16 / 7; overflow: hidden; }
.modal-banner svg, .modal-banner img { width: 100%; height: 100%; object-fit: cover; display: block; }
.modal-banner::after { content: ''; position: absolute; inset: 0; background: linear-gradient(0deg, #181a34 2%, transparent 60%); }
.modal-content { padding: 40px clamp(24px, 5vw, 44px) 32px; display: flex; flex-direction: column; gap: 14px; }
.modal-banner + .modal-content { margin-top: -36px; position: relative; z-index: 1; }
.modal-content h2 { font-family: var(--font-display); font-weight: 500; font-size: clamp(1.6rem, 4vw, 2.3rem); line-height: 1.1; }
.modal-content .eyebrow { color: var(--accent); }
.modal-body { display: flex; flex-direction: column; gap: 12px; }
.modal-body p { color: #ddd2bd; line-height: 1.7; font-size: .98rem; }
.modal-body .note { color: var(--gold-2); font-size: .9rem; }
.modal-actions { display: flex; flex-wrap: wrap; gap: 10px; margin-top: 8px; }

.facts { display: grid; grid-template-columns: repeat(3, 1fr); gap: 10px; margin-top: 4px; }
.facts div { padding: 12px 14px; border-radius: 14px; border: 1px solid var(--line); background: rgba(255, 255, 255, .03); }
.facts dt { font-family: var(--font-display); color: var(--gold-2); font-size: 1.05rem; }
.facts dd { color: var(--muted); font-size: .76rem; margin-top: 2px; }

.mode-row { display: flex; align-items: center; gap: 12px; flex-wrap: wrap; font-size: .88rem; color: var(--muted); }
.segmented { display: inline-flex; padding: 4px; border-radius: 999px; border: 1px solid var(--line); background: rgba(0, 0, 0, .25); }
.segmented button { padding: .5em 1.1em; border-radius: 999px; font-size: .85rem; font-weight: 700; color: var(--muted); transition: background .2s, color .2s; }
.segmented button[aria-checked="true"] { background: var(--gold); color: #23170a; }

.final-score { display: flex; align-items: center; justify-content: center; gap: 24px; padding: 10px 0; }
.final-score div { display: flex; flex-direction: column; align-items: center; }
.final-score span { font-family: var(--font-display); font-size: 3.2rem; font-weight: 600; line-height: 1; }
.final-score small { color: var(--muted); font-size: .8rem; margin-top: 6px; }
.final-score .p0 span { color: var(--p0); }
.final-score .p1 span { color: var(--p1); }
.final-score b { font-size: 2rem; color: var(--muted); }
.lc-progress.big small { font-size: .85rem; }
.modal-card.result.won .modal-content h2 { background: linear-gradient(100deg, var(--gold-2), var(--gold)); -webkit-background-clip: text; background-clip: text; color: transparent; }

.unlock-card { display: grid; grid-template-columns: 140px 1fr; gap: 16px; align-items: center; padding: 12px; border-radius: 16px; border: 1px solid var(--accent); background: rgba(255, 255, 255, .03); animation: glow 2s ease-in-out infinite alternate; }
.uc-illus { border-radius: 12px; overflow: hidden; aspect-ratio: 16 / 10; }
.uc-illus svg { width: 100%; height: 100%; display: block; }
.unlock-card .eyebrow { color: var(--accent); }
.unlock-card h3 { font-family: var(--font-display); font-weight: 500; font-size: 1.15rem; margin: 2px 0 4px; }
.unlock-card p { font-size: .86rem !important; line-height: 1.5 !important; }

#webgl-error { position: fixed; inset: 0; z-index: 100; display: grid; place-items: center; padding: 24px; background: var(--ink); text-align: center; line-height: 1.7; }

/* ---------- Анимациялар ---------- */
@keyframes rise { from { opacity: 0; transform: translateY(24px); } to { opacity: 1; transform: none; } }
@keyframes fadein { from { opacity: 0; } to { opacity: 1; } }
@keyframes slidein { from { opacity: 0; transform: translateX(24px); } to { opacity: 1; transform: none; } }
@keyframes pop { from { opacity: 0; transform: translateY(16px) scale(.97); } to { opacity: 1; transform: none; } }
@keyframes toastin { from { opacity: 0; transform: translateY(12px) scale(.96); } to { opacity: 1; transform: none; } }
@keyframes toastout { to { opacity: 0; transform: translateY(8px); } }
@keyframes scrolly { 0% { transform: translateY(0); opacity: 1; } 70% { transform: translateY(14px); opacity: 0; } 100% { opacity: 0; } }
@keyframes pulse { to { opacity: .55; } }
@keyframes blink { 0%, 100% { opacity: .25; } 50% { opacity: 1; } }
@keyframes glow { from { box-shadow: 0 0 0 rgba(0, 0, 0, 0); } to { box-shadow: 0 0 28px color-mix(in srgb, var(--accent) 35%, transparent); } }

@media (prefers-reduced-motion: reduce) {
    *, *::before, *::after { animation-duration: .01ms !important; transition-duration: .01ms !important; }
    html { scroll-behavior: auto; }
}

/* ---------- Бейімделгіш макет ---------- */
/* Тар немесе шаршы экран: панельдер тақтаның астына/үстіне ауысады */
@media (max-width: 760px), (max-aspect-ratio: 5/4) {
    .nav-links { display: none; }
    .hero { background: linear-gradient(180deg, rgba(11, 12, 24, .55), rgba(11, 12, 24, .92) 60%); align-items: flex-end; }
    .hero-stats { flex-wrap: wrap; }
    .facts { grid-template-columns: 1fr 1fr 1fr; }
    .facts div { padding: 10px; }
    .facts dt { font-size: .9rem; }
    .tech-col { border-right: 0; border-bottom: 1px solid var(--line); }
    .tech-col:last-child { border-bottom: 0; }
    .rules-list { grid-template-columns: 1fr; }

    .hud-top { flex-wrap: wrap; padding: 10px 12px; gap: 10px; }
    .hud-title h1 { font-size: 1rem; }
    .hud-actions { gap: 6px; }
    .hud-actions .icon-btn { height: 38px; min-width: 38px; padding: 0 9px; }
    .icon-btn.accent span { display: none; }
    #btn-view { display: none; }
    .turn-pill { top: auto; bottom: 108px; font-size: .82rem; padding: 8px 14px; }
    .players { top: auto; bottom: 12px; left: 12px; right: 12px; transform: none; width: auto; flex-direction: row; gap: 10px; }
    .player-card { flex: 1; padding: 10px 12px; gap: 6px; min-width: 0; }
    .player-card.p1 { order: 2; }
    .pc-kazan { font-size: 1.5rem; }
    .pc-tuzdyk { display: none; }
    .lesson-panel { top: 70px; bottom: auto; left: 12px; right: 12px; width: auto; padding: 14px 16px; gap: 8px; }
    .lesson-panel h3 { font-size: 1rem; }
    .lesson-panel p { font-size: .88rem; }
    #toasts { bottom: 150px; }
    .hud-hint { display: none; }
    .pit-badge { font-size: .64rem; min-width: 20px; padding: 2px 5px; }
    .kazan-badge { font-size: .75rem; padding: 2px 8px; }
    .unlock-card { grid-template-columns: 1fr; }
    .final-score span { font-size: 2.4rem; }
}
