/* ============================================================
   How to Play Chess — styles. Tokens, themes (light / sepia / dark),
   top bar, language menu and cards follow the JomChess design.
   ============================================================ */
:root {
    --bg-body: #0a1628;
    --bg-panel: rgba(17, 29, 51, 0.72);
    --bg-panel-solid: #111d33;
    --bg-inset: rgba(0, 0, 0, 0.18);
    --chip-bg: rgba(255, 255, 255, 0.05);
    --border: rgba(122, 139, 168, 0.16);
    --border-strong: rgba(122, 139, 168, 0.3);
    --text-primary: #e8eaf0;
    --text-secondary: #8a9bb8;
    --text-muted: #5a6d8c;
    --text-body: #a8b6cc;
    --accent: #34d399;
    --accent-hover: #6ee7b7;
    --accent-bg: rgba(52, 211, 153, 0.12);
    --success: #22c55e;
    --danger: #ef4444;
    --btn-hover: rgba(255, 255, 255, 0.09);
    --board-light: #dce4f0;
    --board-dark: #3b6dad;
    --highlight-last: rgba(212, 160, 48, 0.45);
    --highlight-select: rgba(212, 160, 48, 0.85);
    --glow-1: rgba(212, 160, 48, 0.12);
    --glow-2: rgba(59, 109, 173, 0.2);
    --grid-line: rgba(122, 139, 168, 0.055);
    --shadow-sm: 0 1px 2px rgba(0, 0, 0, 0.3);
    --shadow-md: 0 4px 12px rgba(0, 0, 0, 0.22), 0 1px 3px rgba(0, 0, 0, 0.28);
    --shadow-lg: 0 24px 48px -12px rgba(0, 0, 0, 0.5), 0 8px 16px -8px rgba(0, 0, 0, 0.4);
    --card: rgba(17, 29, 51, 0.62);
    --ink-on-accent: #04261a;
    --ease: cubic-bezier(0.22, 1, 0.36, 1);
}

[data-theme="light"] {
    --bg-body: #f3f4f7;
    --bg-panel: rgba(255, 255, 255, 0.8);
    --bg-panel-solid: #ffffff;
    --bg-inset: rgba(26, 26, 46, 0.04);
    --chip-bg: rgba(26, 26, 46, 0.05);
    --border: rgba(26, 26, 46, 0.09);
    --border-strong: rgba(26, 26, 46, 0.18);
    --text-primary: #1a1a2e;
    --text-secondary: #555770;
    --text-muted: #8a8ca0;
    --text-body: #44465a;
    --accent: #059669;
    --accent-hover: #047857;
    --accent-bg: rgba(5, 150, 105, 0.1);
    --success: #16a34a;
    --danger: #dc2626;
    --btn-hover: rgba(26, 26, 46, 0.09);
    --board-light: #f0d9b5;
    --board-dark: #b58863;
    --highlight-last: rgba(180, 130, 20, 0.35);
    --highlight-select: rgba(180, 130, 20, 0.85);
    --glow-1: rgba(212, 160, 48, 0.14);
    --glow-2: rgba(59, 109, 173, 0.1);
    --grid-line: rgba(26, 26, 46, 0.04);
    --shadow-sm: 0 1px 2px rgba(16, 24, 40, 0.06);
    --shadow-md: 0 4px 12px rgba(16, 24, 40, 0.06), 0 1px 3px rgba(16, 24, 40, 0.08);
    --shadow-lg: 0 24px 48px -12px rgba(16, 24, 40, 0.16), 0 8px 16px -8px rgba(16, 24, 40, 0.1);
    --card: rgba(255, 255, 255, 0.86);
    --ink-on-accent: #ffffff;
}

[data-theme="light"][data-tone="sepia"] {
    --bg-body: #f4ecd8;
    --bg-panel: rgba(251, 246, 233, 0.86);
    --bg-panel-solid: #fbf6e9;
    --bg-inset: rgba(91, 70, 54, 0.05);
    --chip-bg: rgba(91, 70, 54, 0.06);
    --border: rgba(91, 70, 54, 0.14);
    --border-strong: rgba(91, 70, 54, 0.26);
    --text-primary: #3b2f25;
    --text-secondary: #65543f;
    --text-muted: #8c7a62;
    --text-body: #4f4134;
    --accent: #4d7a2a;
    --accent-hover: #3f6a20;
    --accent-bg: rgba(77, 122, 42, 0.1);
    --success: #3f7d23;
    --danger: #b3261e;
    --btn-hover: rgba(91, 70, 54, 0.11);
    --board-light: #ecdcbc;
    --board-dark: #a7845e;
    --highlight-last: rgba(170, 115, 20, 0.35);
    --highlight-select: rgba(170, 115, 20, 0.85);
    --glow-1: rgba(190, 130, 40, 0.12);
    --glow-2: rgba(150, 105, 60, 0.08);
    --grid-line: rgba(91, 70, 54, 0.04);
    --shadow-md: 0 4px 12px rgba(60, 40, 20, 0.07), 0 1px 3px rgba(60, 40, 20, 0.09);
    --shadow-lg: 0 24px 48px -12px rgba(60, 40, 20, 0.18), 0 8px 16px -8px rgba(60, 40, 20, 0.11);
    --card: rgba(251, 246, 233, 0.88);
}

/* ---------- Base ---------- */
* { margin: 0; padding: 0; box-sizing: border-box; }

body {
    font-family: 'Nunito', sans-serif;
    background: var(--bg-body);
    color: var(--text-primary);
    min-height: 100vh;
    overflow-x: hidden;
    -webkit-font-smoothing: antialiased;
    transition: background 0.3s ease, color 0.3s ease;
}

button { font-family: inherit; }
a { color: inherit; }

body::before,
body::after {
    content: '';
    position: fixed;
    inset: 0;
    pointer-events: none;
    z-index: -1;
}

body::before {
    background:
        radial-gradient(600px 400px at 50% -80px, var(--glow-1), transparent 70%),
        radial-gradient(500px 500px at 90% 110%, var(--glow-2), transparent 70%),
        radial-gradient(400px 400px at 0% 60%, var(--glow-2), transparent 70%);
}

body::after {
    background-image:
        linear-gradient(var(--grid-line) 1px, transparent 1px),
        linear-gradient(90deg, var(--grid-line) 1px, transparent 1px);
    background-size: 56px 56px;
    -webkit-mask-image: radial-gradient(ellipse 70% 55% at 50% 30%, #000 30%, transparent 100%);
    mask-image: radial-gradient(ellipse 70% 55% at 50% 30%, #000 30%, transparent 100%);
}

:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }

@keyframes rise {
    from { opacity: 0; transform: translateY(12px); }
    to   { opacity: 1; transform: none; }
}

@media (prefers-reduced-motion: reduce) {
    *, *::before, *::after { animation: none !important; transition: none !important; }
}

.wrap {
    width: 100%;
    max-width: 1120px;
    margin: 0 auto;
    padding: 0 24px;
}

/* ---------- Fonts per language (as on JomChess) ---------- */
:lang(hi) body, body:lang(hi) { font-family: 'Nunito', 'Noto Sans Devanagari', sans-serif; }
:lang(ar) body, body:lang(ar) { font-family: 'Nunito', 'Noto Kufi Arabic', sans-serif; }
:lang(ta) body, body:lang(ta) { font-family: 'Nunito', 'Noto Sans Tamil', sans-serif; }
:lang(th) body, body:lang(th) { font-family: 'Nunito', 'Noto Sans Thai', sans-serif; }
:lang(zh) body, body:lang(zh) {
    font-family: 'Nunito', 'PingFang SC', 'Hiragino Sans GB', 'Microsoft YaHei', 'Noto Sans SC', 'Noto Sans CJK SC', sans-serif;
}

/* Joined or stacked scripts: no letter-spacing, no capitals, more line height */
:lang(ar) h1, :lang(ar) h2, :lang(ar) h3, :lang(ar) .sec-h,
:lang(hi) h1, :lang(hi) h2, :lang(hi) h3, :lang(hi) .sec-h,
:lang(ta) h1, :lang(ta) h2, :lang(ta) h3, :lang(ta) .sec-h,
:lang(th) h1, :lang(th) h2, :lang(th) h3, :lang(th) .sec-h,
:lang(zh) h1, :lang(zh) h2, :lang(zh) h3, :lang(zh) .sec-h {
    letter-spacing: normal;
    text-transform: none;
}

:lang(ar) h1, :lang(hi) h1, :lang(ta) h1, :lang(th) h1 { line-height: 1.35; }
.hero h1:lang(ta) { font-size: clamp(30px, 4.4vw, 50px); }
.lcard h3:lang(ta) { font-size: 16px; overflow-wrap: anywhere; }

/* ---------- Top bar ---------- */
.top {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 16px 0;
}

.brand {
    margin-inline-end: auto;
    display: flex;
    align-items: center;
    gap: 10px;
    text-decoration: none;
    color: var(--text-primary);
}

.brand-logo { height: 64px; width: auto; flex: none; }
.brand-text { padding-inline-start: 12px; border-inline-start: 1px solid var(--border-strong); }
.brand-text { font-size: 19px; font-weight: 800; letter-spacing: -0.02em; }

/* Language menu (globe dropdown) */
.lang-menu { position: relative; }

.lang-menu summary {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    height: 38px;
    padding: 0 10px 0 11px;
    border-radius: 999px;
    border: 1px solid var(--border);
    background: var(--chip-bg);
    color: var(--text-primary);
    font-size: 13.5px;
    font-weight: 700;
    cursor: pointer;
    list-style: none;
    user-select: none;
    transition: border-color 0.2s;
}

.lang-menu summary::-webkit-details-marker { display: none; }
.lang-menu summary:hover, .lang-menu[open] summary { border-color: var(--accent); }
.lm-globe { width: 18px; height: 18px; color: var(--accent); }
.lm-chev { width: 14px; height: 14px; color: var(--text-secondary); transition: transform 0.2s var(--ease); }
.lang-menu[open] .lm-chev { transform: rotate(180deg); }

.lm-list {
    position: absolute;
    top: calc(100% + 8px);
    inset-inline-end: 0;
    z-index: 60;
    min-width: 190px;
    max-height: calc(100vh - 90px);
    overflow-y: auto;
    overscroll-behavior: contain;
    padding: 6px;
    list-style: none;
    border-radius: 16px;
    border: 1px solid var(--border);
    background: var(--bg-panel-solid);
    box-shadow: var(--shadow-lg);
    animation: lm-in 0.18s var(--ease) both;
}

@keyframes lm-in {
    from { opacity: 0; transform: translateY(-6px); }
    to   { opacity: 1; transform: none; }
}

.lm-list a {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 10px;
    padding: 9px 12px;
    border-radius: 10px;
    color: var(--text-primary);
    font-size: 14.5px;
    font-weight: 600;
    text-decoration: none;
}

.lm-list a:hover, .lm-list a:focus-visible { background: var(--chip-bg); }
.lm-list a[aria-current="page"] { color: var(--accent); }
.lm-list a[aria-current="page"]::after { content: '\2713'; font-weight: 800; }

@media (max-width: 760px) {
    .lm-list {
        position: fixed;
        top: 66px;
        inset-inline: 16px;
        max-width: 440px;
        margin: 0 auto;
        min-width: 0;
        z-index: 1000;
        max-height: calc(100dvh - 90px);
        display: grid;
        grid-template-columns: minmax(0, 1fr) minmax(0, 1fr);
        gap: 2px;
    }
}

.lang-suggest {
    display: flex;
    align-items: center;
    flex-wrap: wrap;
    gap: 8px 14px;
    margin: 4px 0 8px;
    padding: 10px 12px 10px 16px;
    border-radius: 14px;
    background: var(--accent-bg);
    border: 1px solid color-mix(in srgb, var(--accent) 35%, transparent);
    font-size: 14px;
}

.lang-suggest[hidden] { display: none; }
.lang-suggest a { font-weight: 800; color: var(--accent); }

.lang-suggest button {
    margin-inline-start: auto;
    width: 28px;
    height: 28px;
    border: none;
    border-radius: 50%;
    background: transparent;
    color: var(--text-secondary);
    font-size: 18px;
    cursor: pointer;
}

/* Theme switch: sun / book / moon */
.theme-toggle {
    --ts-w: 66px;
    --ts-h: 32px;
    --ts-knob: 24px;
    position: relative;
    flex-shrink: 0;
    width: var(--ts-w);
    height: var(--ts-h);
    padding: 0;
    border-radius: 999px;
    border: 1px solid rgba(255, 255, 255, 0.12);
    background: linear-gradient(135deg, #0f172a, #312e81);
    box-shadow: inset 0 2px 6px rgba(0, 0, 0, 0.35);
    overflow: hidden;
    cursor: pointer;
    transition: background 0.4s var(--ease), border-color 0.3s;
}

[data-theme="light"] .theme-toggle {
    border-color: rgba(14, 116, 144, 0.18);
    background: linear-gradient(135deg, #7dd3fc, #fde68a);
    box-shadow: inset 0 2px 6px rgba(14, 116, 144, 0.2);
}

[data-tone="sepia"] .theme-toggle {
    border-color: rgba(120, 80, 40, 0.22);
    background: linear-gradient(135deg, #f6e7c8, #dcbf91);
}

.theme-toggle:hover { border-color: var(--accent); }

.ts-stars {
    position: absolute;
    inset: 0;
    background:
        radial-gradient(1.2px 1.2px at 22% 30%, #fff, transparent),
        radial-gradient(1px 1px at 38% 68%, #fff, transparent),
        radial-gradient(1.4px 1.4px at 14% 62%, #fff, transparent),
        radial-gradient(1px 1px at 48% 26%, #fff, transparent);
    opacity: 0.85;
    transition: opacity 0.4s;
}

[data-theme="light"] .ts-stars { opacity: 0; }

.ts-knob {
    position: absolute;
    top: calc((var(--ts-h) - 2px - var(--ts-knob)) / 2);
    left: 3px;
    width: var(--ts-knob);
    height: var(--ts-knob);
    border-radius: 50%;
    background: #e2e8f0;
    color: #4338ca;
    box-shadow: 0 2px 6px rgba(0, 0, 0, 0.35);
    transform: translateX(calc(var(--ts-w) - 2px - 6px - var(--ts-knob)));
    transition: transform 0.45s var(--ease), background 0.35s, color 0.35s;
}

[data-theme="light"] .ts-knob { transform: translateX(0); background: #fbbf24; color: #fffbeb; box-shadow: 0 2px 8px rgba(245, 158, 11, 0.55); }
[data-tone="sepia"] .ts-knob { transform: translateX(calc((var(--ts-w) - 2px - 6px - var(--ts-knob)) / 2)); background: #8b5e34; color: #fbf1dc; }

.ts-knob svg {
    position: absolute;
    inset: 4px;
    width: calc(100% - 8px);
    height: calc(100% - 8px);
    transition: opacity 0.35s, transform 0.45s var(--ease);
}

.ts-sun, .ts-book { opacity: 0; transform: scale(0.5); }
.ts-moon { opacity: 1; }
[data-theme="light"] .ts-sun { opacity: 1; transform: none; }
[data-theme="light"] .ts-moon { opacity: 0; transform: scale(0.5); }
[data-tone="sepia"] .ts-sun { opacity: 0; transform: scale(0.5); }
[data-tone="sepia"] .ts-book { opacity: 1; transform: none; }

/* ---------- Buttons ---------- */
.btn-main {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    min-height: 46px;
    padding: 0 20px;
    border: none;
    border-radius: 12px;
    background: linear-gradient(135deg, #34d399, #059669);
    color: #fff;
    font-size: 15px;
    font-weight: 700;
    text-decoration: none;
    cursor: pointer;
    box-shadow: 0 10px 24px -10px rgba(5, 150, 105, 0.65);
    transition: transform 0.25s var(--ease), box-shadow 0.25s var(--ease);
}

[data-theme="light"] .btn-main { background: linear-gradient(135deg, #10b981, #047857); }
[data-tone="sepia"] .btn-main { background: linear-gradient(135deg, #5f8f35, #3f6a20); }
.btn-main:hover { transform: translateY(-2px); box-shadow: 0 16px 34px -10px rgba(5, 150, 105, 0.75); }
.btn-main svg { width: 18px; height: 18px; flex: none; }
.btn-main.small { min-height: 42px; padding: 0 16px; font-size: 14.5px; }

.btn-soft {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 6px;
    min-height: 42px;
    padding: 0 16px;
    border-radius: 12px;
    border: 1px solid var(--border-strong);
    background: var(--chip-bg);
    color: var(--text-primary);
    font-size: 14.5px;
    font-weight: 700;
    text-decoration: none;
    cursor: pointer;
    transition: background 0.2s, opacity 0.2s;
}

.btn-soft:hover { background: var(--btn-hover); }
.btn-soft:disabled { opacity: 0.35; cursor: default; }
[hidden] { display: none !important; }

/* ---------- Home: hero ---------- */
.hero {
    position: relative;
    display: grid;
    grid-template-columns: minmax(0, 1fr) 380px;
    gap: 48px;
    align-items: center;
    padding: 28px 0 48px;
}

.hero h1 {
    font-size: clamp(38px, 5.4vw, 62px);
    line-height: 1.06;
    font-weight: 800;
    letter-spacing: -0.045em;
    margin-bottom: 16px;
    animation: rise 0.7s var(--ease) both;
}

.grad {
    background: linear-gradient(100deg, #f2c14e 0%, #fb7185 50%, #a78bfa 95%);
    -webkit-background-clip: text;
    background-clip: text;
    color: transparent;
}

[data-theme="light"] .grad { background-image: linear-gradient(100deg, #b45309 0%, #e11d48 50%, #7c3aed 95%); }
[data-tone="sepia"] .grad { background-image: linear-gradient(100deg, #9a5a12 0%, #a9483a 50%, #7a4f7d 95%); }

.lead {
    font-size: 18px;
    line-height: 1.55;
    color: var(--text-body);
    max-width: 520px;
    margin-bottom: 24px;
    animation: rise 0.7s 0.06s var(--ease) both;
}

.ctas { display: flex; flex-wrap: wrap; gap: 10px; animation: rise 0.7s 0.12s var(--ease) both; }
.free-note { margin-top: 16px; font-size: 14px; color: var(--text-secondary); }
.free-note b { color: var(--success); }

/* ---------- Coach card ---------- */
.coach-card {
    position: relative;
    padding: 20px;
    border-radius: 24px;
    background: var(--card);
    border: 1px solid var(--border);
    box-shadow: var(--shadow-lg);
    -webkit-backdrop-filter: blur(16px);
    backdrop-filter: blur(16px);
    animation: rise 0.8s 0.1s var(--ease) both;
}

.coach-head { display: flex; align-items: center; gap: 12px; }
.coach-head strong { display: block; font-size: 17px; font-weight: 800; }
.coach-head > div { flex: 1; min-width: 0; }
.coach-step { font-size: 13px; font-weight: 700; color: var(--accent); }

.coach-face { width: 64px; height: 64px; flex: none; filter: drop-shadow(0 8px 14px rgba(0, 0, 0, 0.22)); }
.coach-face.big { width: 92px; height: 92px; }
.coach-face .cf-mouth { transform-box: fill-box; transform-origin: center; }
.coach-face.talking .cf-mouth { animation: talk 0.22s ease-in-out infinite alternate; }
.coach-face .cf-eyes { transform-box: fill-box; transform-origin: center; animation: blink 4.5s infinite; }

@keyframes talk { from { transform: scaleY(0.5); } to { transform: scaleY(1.5); } }
@keyframes blink { 0%, 94%, 100% { transform: scaleY(1); } 97% { transform: scaleY(0.1); } }

.hero-coach .coach-head { flex-direction: column; text-align: center; }

.bubble {
    position: relative;
    margin-top: 14px;
    padding: 14px 16px;
    border-radius: 18px;
    background: var(--accent-bg);
    border: 1px solid color-mix(in srgb, var(--accent) 30%, transparent);
    font-size: 16.5px;
    line-height: 1.55;
    color: var(--text-primary);
    min-height: 84px;
}

.bubble::before {
    content: '';
    position: absolute;
    top: -8px;
    inset-inline-start: 26px;
    width: 14px;
    height: 14px;
    background: inherit;
    border-top: 1px solid color-mix(in srgb, var(--accent) 30%, transparent);
    border-inline-start: 1px solid color-mix(in srgb, var(--accent) 30%, transparent);
    transform: rotate(45deg);
    background: color-mix(in srgb, var(--accent) 12%, var(--bg-panel-solid));
}

.bubble { background: color-mix(in srgb, var(--accent) 12%, var(--bg-panel-solid)); }
.hero-coach .bubble::before { inset-inline-start: calc(50% - 7px); }
.bubble.pop { animation: pop 0.35s var(--ease); }
.bubble.mood-good { border-color: color-mix(in srgb, var(--success) 55%, transparent); background: color-mix(in srgb, var(--success) 12%, var(--bg-panel-solid)); }
.bubble.mood-good::before { background: color-mix(in srgb, var(--success) 12%, var(--bg-panel-solid)); border-color: color-mix(in srgb, var(--success) 55%, transparent); }
.bubble.mood-bad { border-color: color-mix(in srgb, var(--danger) 50%, transparent); background: color-mix(in srgb, var(--danger) 9%, var(--bg-panel-solid)); }
.bubble.mood-bad::before { background: color-mix(in srgb, var(--danger) 9%, var(--bg-panel-solid)); border-color: color-mix(in srgb, var(--danger) 50%, transparent); }

@keyframes pop { from { transform: scale(0.97); opacity: 0.4; } to { transform: none; opacity: 1; } }

.progress { margin-top: 16px; height: 8px; border-radius: 999px; background: var(--chip-bg); overflow: hidden; }
.progress span { display: block; height: 100%; width: 0; border-radius: inherit; background: linear-gradient(90deg, #f2c14e, #fb7185, #a78bfa); transition: width 0.8s var(--ease); }
.progress-text { margin-top: 8px; font-size: 13.5px; font-weight: 600; color: var(--text-secondary); text-align: center; }

/* ---------- Sections and lesson tiles ---------- */
.section { padding-bottom: 40px; }

.sec-h {
    display: flex;
    align-items: center;
    gap: 12px;
    font-size: 13px;
    font-weight: 700;
    letter-spacing: 0.12em;
    text-transform: uppercase;
    color: var(--text-muted);
    margin-bottom: 16px;
}

.sec-h::before { content: ''; width: 8px; height: 8px; border-radius: 50%; background: var(--accent); }
.sec-h::after { content: ''; flex: 1; height: 1px; background: var(--border); }

/* Lesson cards: a friendly "learning path" — light card, coloured icon with its number, done tick */
.lessons {
    list-style: none;
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 12px;
}

.lessons li { display: flex; animation: rise 0.5s var(--ease) both; }
.lessons li:nth-child(n+5) { animation-delay: 0.06s; }
.lessons li:nth-child(n+9) { animation-delay: 0.12s; }

.lcard {
    position: relative;
    flex: 1;
    display: flex;
    align-items: center;
    gap: 16px;
    padding: 16px 18px;
    border-radius: 20px;
    background: var(--card);
    border: 1.5px solid var(--border);
    box-shadow: var(--shadow-md);
    color: var(--text-primary);
    text-decoration: none;
    transition: transform 0.25s var(--ease), border-color 0.25s, box-shadow 0.25s;
}

.lcard:hover, .lcard:focus-visible {
    transform: translateY(-3px);
    border-color: color-mix(in srgb, var(--g1) 55%, transparent);
    box-shadow: var(--shadow-lg);
}

.lc-icon {
    position: relative;
    flex: none;
    display: grid;
    place-items: center;
    width: 58px;
    height: 58px;
    border-radius: 18px;
    background: linear-gradient(150deg, var(--g1), var(--g2));
    color: #fff;
    font-size: 30px;
    box-shadow: 0 10px 20px -12px var(--g2);
}

[data-tone="sepia"] .lc-icon { filter: saturate(0.6) sepia(0.18); }

.lc-num {
    position: absolute;
    top: -6px;
    inset-inline-end: -6px;
    display: grid;
    place-items: center;
    min-width: 22px;
    height: 22px;
    padding: 0 5px;
    border-radius: 999px;
    background: var(--bg-panel-solid);
    color: var(--text-primary);
    border: 2px solid var(--g1);
    font-size: 11.5px;
    font-weight: 900;
}

.lc-body { flex: 1; min-width: 0; display: flex; flex-direction: column; gap: 2px; }
.lc-kicker { font-size: 12.5px; font-weight: 800; color: var(--text-muted); }
.lcard h3 { font-size: 18px; font-weight: 900; letter-spacing: -0.01em; line-height: 1.25; }
.lcard p {
    font-size: 14px;
    line-height: 1.45;
    color: var(--text-secondary);
    display: -webkit-box;
    -webkit-line-clamp: 2;
    -webkit-box-orient: vertical;
    overflow: hidden;
}

.lc-go {
    flex: none;
    display: grid;
    place-items: center;
    width: 34px;
    height: 34px;
    border-radius: 50%;
    background: var(--chip-bg);
    color: var(--text-secondary);
    font-weight: 900;
    transition: background 0.25s, color 0.25s, transform 0.25s var(--ease);
}

.lcard:hover .lc-go { background: var(--g1); color: #fff; transform: translateX(3px); }
[dir="rtl"] .lcard:hover .lc-go { transform: translateX(-3px); }
.lc-check { display: none; }
.lcard.is-done .lc-arrow { display: none; }
.lcard.is-done .lc-check { display: inline; }
.lcard.is-done .lc-go { background: var(--success); color: #fff; }

/* The lesson to do next: a soft pulsing ring */
.lcard.is-next { border-color: color-mix(in srgb, var(--accent) 60%, transparent); }
.lcard.is-next::after {
    content: '';
    position: absolute;
    inset: -5px;
    border-radius: 24px;
    border: 2px solid var(--accent);
    opacity: 0;
    animation: ring 2.4s ease-out infinite;
    pointer-events: none;
}

@keyframes ring { 0% { opacity: 0.6; transform: scale(0.98); } 100% { opacity: 0; transform: scale(1.03); } }

.play-strip {
    display: flex;
    align-items: center;
    justify-content: space-between;
    flex-wrap: wrap;
    gap: 16px 24px;
    margin-bottom: 12px;
    padding: 22px 26px;
    border-radius: 22px;
    background: var(--card);
    border: 1px solid var(--border);
    box-shadow: var(--shadow-md);
}

.play-strip h2 { font-size: 20px; font-weight: 800; letter-spacing: -0.02em; margin-bottom: 4px; }
.play-strip p { color: var(--text-secondary); font-size: 15px; max-width: 560px; }

/* ---------- Footer ---------- */
.foot {
    display: flex;
    align-items: center;
    justify-content: space-between;
    flex-wrap: wrap;
    gap: 10px 20px;
    padding: 20px 0 36px;
    font-size: 14px;
    color: var(--text-muted);
}

.foot a { color: var(--text-secondary); text-decoration: none; font-weight: 600; }
.foot a:hover { color: var(--text-primary); }

/* ---------- Lesson page ---------- */
.crumbs { display: flex; flex-wrap: wrap; gap: 8px; padding: 4px 0 14px; font-size: 14px; color: var(--text-muted); }
.crumbs a { color: var(--text-secondary); text-decoration: none; font-weight: 600; }
.crumbs a:hover { color: var(--accent); }

.lesson-head { display: flex; align-items: flex-start; gap: 18px; padding-bottom: 22px; }
.lesson-head h1 { font-size: clamp(28px, 4vw, 42px); font-weight: 800; letter-spacing: -0.035em; line-height: 1.12; margin-bottom: 8px; animation: rise 0.6s var(--ease) both; }
.lesson-head .lead { margin-bottom: 0; font-size: 17px; max-width: 720px; }
.lesson-kicker { font-size: 13px; font-weight: 800; letter-spacing: 0.08em; text-transform: uppercase; color: var(--accent); margin-bottom: 6px; }
:lang(ar) .lesson-kicker, :lang(hi) .lesson-kicker, :lang(ta) .lesson-kicker, :lang(th) .lesson-kicker, :lang(zh) .lesson-kicker { letter-spacing: normal; text-transform: none; }

.lesson-badge {
    flex: none;
    display: grid;
    place-items: center;
    width: 68px;
    height: 68px;
    border-radius: 20px;
    background: linear-gradient(155deg, var(--g1), var(--g2));
    color: #fff;
    font-size: 38px;
    box-shadow: 0 14px 28px -14px var(--g2);
}

.lesson {
    display: grid;
    grid-template-columns: minmax(0, 1fr) 380px;
    grid-template-areas: "board coach";
    gap: 24px;
    align-items: start;
}

.board-card { grid-area: board; padding: 14px; border-radius: 24px; background: var(--card); border: 1px solid var(--border); box-shadow: var(--shadow-lg); max-width: 600px; width: 100%; justify-self: center; }
.lesson-coach { grid-area: coach; position: sticky; top: 16px; }

.board {
    position: relative;
    display: grid;
    grid-template-columns: repeat(8, 1fr);
    grid-template-rows: repeat(8, 1fr);
    width: 100%;
    aspect-ratio: 1;
    border-radius: 14px;
    overflow: hidden;
    user-select: none;
    -webkit-user-select: none;
    touch-action: manipulation;
    direction: ltr;
}

.sq { position: relative; display: grid; place-items: center; cursor: pointer; }
.sq.light { background: var(--board-light); }
.sq.dark { background: var(--board-dark); }
.sq.last { box-shadow: inset 0 0 0 999px var(--highlight-last); }
.sq.hl { box-shadow: inset 0 0 0 999px rgba(250, 204, 21, 0.5); animation: glow 1.4s ease-in-out infinite alternate; }
.sq.danger { box-shadow: inset 0 0 0 999px rgba(239, 68, 68, 0.5); }
.sq.sel { box-shadow: inset 0 0 0 999px var(--highlight-select); }

@keyframes glow { from { filter: brightness(1); } to { filter: brightness(1.12); } }

.sq .pc { position: relative; z-index: 2; width: 92%; height: 92%; pointer-events: none; animation: land 0.25s var(--ease); }
@keyframes land { from { transform: scale(0.8); opacity: 0.4; } to { transform: none; opacity: 1; } }

.sq.dot::after {
    content: '';
    position: absolute;
    width: 30%;
    height: 30%;
    border-radius: 50%;
    background: rgba(20, 30, 50, 0.32);
    z-index: 3;
}

.sq.cap::after {
    content: '';
    position: absolute;
    inset: 5%;
    border-radius: 50%;
    border: 5px solid rgba(220, 38, 38, 0.6);
    z-index: 3;
}

.sq .star {
    position: absolute;
    z-index: 1;
    font-size: min(6vw, 42px);
    line-height: 1;
    color: #facc15;
    text-shadow: 0 2px 6px rgba(0, 0, 0, 0.35), 0 0 12px rgba(250, 204, 21, 0.6);
    animation: twinkle 1.6s ease-in-out infinite alternate;
}

@keyframes twinkle { from { transform: scale(0.88) rotate(-6deg); } to { transform: scale(1.05) rotate(6deg); } }

.sq .co { position: absolute; font-size: 11px; font-weight: 800; opacity: 0.75; pointer-events: none; }
.sq .co-r { top: 3px; left: 4px; }
.sq .co-f { bottom: 2px; right: 5px; }
.sq.light .co { color: var(--board-dark); }
.sq.dark .co { color: var(--board-light); }

.sq .nm { font-size: 12px; font-weight: 700; opacity: 0.55; pointer-events: none; }
.sq.light .nm { color: var(--board-dark); }
.sq.dark .nm { color: var(--board-light); }
.sq.named .nm { opacity: 1; font-size: 22px; font-weight: 900; color: #1a1300; }

.sq.good { animation: good 0.7s ease; }
.sq.bad { animation: bad 0.7s ease; }
@keyframes good { 30% { box-shadow: inset 0 0 0 999px rgba(34, 197, 94, 0.7); } }
@keyframes bad { 30% { box-shadow: inset 0 0 0 999px rgba(239, 68, 68, 0.7); } }

.board-status { min-height: 22px; margin-top: 12px; text-align: center; font-size: 14.5px; font-weight: 600; color: var(--text-secondary); }
.board-tools { display: flex; justify-content: center; margin-top: 8px; }
.board-tools:empty, .board-tools:has(> [hidden]:only-child) { display: none; }

.btn-voice {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    height: 36px;
    padding: 0 12px;
    border-radius: 999px;
    border: 1px solid var(--border-strong);
    background: var(--chip-bg);
    color: var(--text-primary);
    font-size: 13.5px;
    font-weight: 700;
    cursor: pointer;
}

.btn-voice svg { width: 17px; height: 17px; color: var(--accent); }
.btn-voice[aria-pressed="true"] { background: var(--accent); color: var(--ink-on-accent); border-color: transparent; }
.btn-voice[aria-pressed="true"] svg { color: currentColor; }

.dots { display: flex; justify-content: center; gap: 6px; margin: 14px 0 4px; }
.dots span { width: 8px; height: 8px; border-radius: 999px; background: var(--border-strong); transition: width 0.3s var(--ease), background 0.3s; }
.dots span.past { background: color-mix(in srgb, var(--accent) 55%, transparent); }
.dots span.on { width: 22px; background: var(--accent); }
.dots .dot-ex { width: auto; height: auto; background: none !important; font-size: 12px; line-height: 8px; color: var(--text-muted); }
.dots .dot-ex.on, .dots .dot-ex.past { color: var(--accent); }

.coach-nav { display: flex; justify-content: space-between; gap: 10px; margin-top: 12px; }
.coach-nav .btn-main { flex: 1; }

.done-box { display: flex; flex-direction: column; gap: 10px; margin-top: 14px; }
.done-box .done-h { font-size: 18px; font-weight: 800; }
.done-box p { color: var(--text-secondary); font-size: 14.5px; }

.lesson-coach.celebrate { animation: celebrate 0.8s var(--ease); }
.lesson-coach.celebrate::after {
    content: '\2605  \2605  \2605';
    position: absolute;
    top: -14px;
    left: 0;
    right: 0;
    text-align: center;
    font-size: 22px;
    color: #facc15;
    text-shadow: 0 2px 8px rgba(250, 204, 21, 0.5);
    animation: rise 0.6s var(--ease) both;
}

@keyframes celebrate { 30% { transform: scale(1.03) rotate(-0.6deg); } 60% { transform: scale(0.99) rotate(0.4deg); } }

.notes {
    margin-top: 32px;
    padding: 22px 26px;
    border-radius: 22px;
    background: var(--card);
    border: 1px solid var(--border);
}

.notes h2 { font-size: 19px; font-weight: 800; margin-bottom: 12px; letter-spacing: -0.02em; }
.notes ol { padding-inline-start: 22px; display: flex; flex-direction: column; gap: 8px; }
.notes li { font-size: 15.5px; line-height: 1.6; color: var(--text-body); }
.notes li::marker { color: var(--accent); font-weight: 800; }
.notes-task { margin-top: 14px; font-size: 15px; color: var(--text-secondary); }

.pager { display: flex; justify-content: space-between; gap: 14px; margin: 22px 0 6px; }
.pager-link {
    display: flex;
    flex-direction: column;
    gap: 2px;
    max-width: 48%;
    padding: 14px 18px;
    border-radius: 16px;
    border: 1px solid var(--border);
    background: var(--card);
    text-decoration: none;
    transition: border-color 0.2s, transform 0.25s var(--ease);
}

.pager-link:hover { border-color: var(--accent); transform: translateY(-2px); }
.pager-link small { font-size: 12.5px; font-weight: 700; color: var(--text-muted); }
.pager-link span { font-weight: 800; }
.pager-link.next { margin-inline-start: auto; text-align: end; }

.nf { display: flex; flex-direction: column; align-items: center; gap: 14px; padding: 60px 0; text-align: center; }
.nf h1 { font-size: 36px; font-weight: 800; }

/* Voice button: "EN" badge — the coach always speaks English */
.vbadge {
    display: inline-grid;
    place-items: center;
    height: 18px;
    padding: 0 5px;
    border-radius: 6px;
    background: var(--accent-bg);
    color: var(--accent);
    font-size: 10.5px;
    font-weight: 900;
    letter-spacing: 0.04em;
}

.btn-voice[aria-pressed="true"] .vbadge { background: rgba(255, 255, 255, 0.25); color: inherit; }

/* ---------- Responsive ---------- */
@media (max-width: 1000px) {
    .hero { grid-template-columns: minmax(0, 1fr) 330px; gap: 28px; }
    .lesson { grid-template-columns: minmax(0, 1fr) 330px; }
}

@media (max-width: 860px) {
    .lesson { grid-template-columns: 1fr; grid-template-areas: "coach" "board"; gap: 12px; }
    .lesson-coach { position: relative; top: 0; }
    .board-card { max-width: none; }
}

/* Phones: everything for a step fits on one screen — short header, coach bubble, board,
   and the Back / Next buttons in a bar fixed at the bottom */
@media (max-width: 760px) {
    .wrap { padding: 0 14px; }
    .top { padding: 8px 0; }
    .brand-logo { height: 42px; }
    .brand-text { font-size: 15px; padding-inline-start: 10px; }

    /* Home */
    .hero { grid-template-columns: 1fr; gap: 16px; padding: 6px 0 22px; text-align: center; }
    .hero h1 { font-size: clamp(30px, 9vw, 40px); margin-bottom: 10px; }
    .lead { font-size: 15.5px; margin: 0 auto 16px; }
    .ctas { justify-content: center; }
    .ctas .btn-main { width: 100%; min-height: 52px; font-size: 16px; border-radius: 16px; }
    .free-note { margin-top: 10px; font-size: 13px; }

    .hero-coach {
        display: grid;
        grid-template-columns: 52px 1fr;
        gap: 10px 12px;
        align-items: start;
        padding: 14px;
        text-align: start;
    }
    .hero-coach .coach-head { display: block; }
    .hero-coach figcaption { display: none; }
    .hero-coach .coach-face.big { width: 52px; height: 52px; }
    .hero-coach .bubble { margin: 0; min-height: 0; padding: 10px 12px; font-size: 14.5px; line-height: 1.45; }
    .hero-coach .bubble::before { top: 16px; inset-inline-start: -8px; transform: rotate(-45deg); }
    [dir="rtl"] .hero-coach .bubble::before { transform: rotate(45deg); }
    .hero-coach .progress, .hero-coach .progress-text { grid-column: 1 / -1; margin-top: 0; }

    .section { padding-bottom: 22px; }
    .sec-h { margin-bottom: 10px; }
    .lessons { grid-template-columns: 1fr; gap: 9px; }
    .lcard { padding: 11px 14px; gap: 13px; border-radius: 16px; }
    .lc-icon { width: 46px; height: 46px; font-size: 24px; border-radius: 14px; }
    .lcard h3 { font-size: 16.5px; }
    .lcard p { display: none; }
    .lc-go { width: 30px; height: 30px; }
    .play-strip { padding: 16px; gap: 12px; }
    .play-strip h2 { font-size: 17px; }
    .play-strip .btn-main { width: 100%; }
    .foot { justify-content: center; text-align: center; padding: 14px 0 24px; }

    /* Lesson */
    body:has(.lesson) { padding-bottom: calc(84px + env(safe-area-inset-bottom)); }
    /* The board matters most on a phone: it always gets the full width, so everything above it is kept small */
    body:has(.lesson) .top { padding: 6px 0; }
    body:has(.lesson) .brand-logo { height: 36px; }
    .crumbs { display: none; }
    .lesson-head { padding: 0 0 8px; }
    .lesson-badge { display: none; }
    .lesson-kicker { font-size: 11px; margin-bottom: 1px; }
    .lesson-head h1 { font-size: clamp(16px, 4.6vw, 19px); line-height: 1.25; margin: 0; letter-spacing: -0.01em; }
    .lesson-head .lead { display: none; }
    .lesson { gap: 8px; }

    /* No blur, transform or animation here: they would trap the fixed bottom bar inside the card */
    .lesson-coach,
    .lesson-coach.celebrate { padding: 10px 12px; border-radius: 16px; -webkit-backdrop-filter: none; backdrop-filter: none; animation: none; background: var(--bg-panel-solid); }
    .lesson-coach .coach-face { width: 34px; height: 34px; }
    .lesson-coach .coach-head { gap: 8px; }
    .lesson-coach .coach-head > div { display: flex; align-items: baseline; gap: 8px; }
    .lesson-coach .coach-head strong { font-size: 14px; }
    .coach-step { font-size: 12px; }
    .btn-voice { height: 30px; padding: 0 9px; gap: 5px; font-size: 12.5px; }
    .btn-voice svg { width: 15px; height: 15px; }
    .lesson-coach .bubble { margin-top: 8px; padding: 8px 12px; font-size: 14.5px; line-height: 1.42; }
    .lesson-coach .bubble::before { inset-inline-start: 12px; width: 10px; height: 10px; top: -6px; }
    .dots { display: none; }

    .coach-nav,
    .done-box,
    .board-tools {
        position: fixed;
        left: 10px;
        right: 10px;
        bottom: calc(10px + env(safe-area-inset-bottom));
        z-index: 50;
        margin: 0;
        padding: 8px;
        border-radius: 20px;
        background: color-mix(in srgb, var(--bg-panel-solid) 94%, transparent);
        border: 1px solid var(--border);
        -webkit-backdrop-filter: blur(18px) saturate(1.5);
        backdrop-filter: blur(18px) saturate(1.5);
        box-shadow: 0 14px 34px -10px rgba(0, 0, 0, 0.35);
    }
    .coach-nav .btn-soft { min-height: 50px; padding: 0 14px; }
    .coach-nav .btn-main { min-height: 50px; font-size: 16px; border-radius: 14px; }
    .done-box { flex-direction: row; flex-wrap: wrap; gap: 8px; }
    .done-box .btn-main { flex: 1 1 100%; min-height: 50px; }
    .done-box .btn-soft { flex: 1 1 100%; min-height: 40px; }
    .done-box .done-h, .done-box p { display: none; }

    /* Board: full width, almost edge to edge, no frame around it */
    /* justify-self: stretch — centred + width:auto would shrink the card to its content (an empty board became 0×0) */
    .board-card { padding: 0; margin-inline: -6px; width: auto; justify-self: stretch; background: none; border: none; box-shadow: none; border-radius: 0; }
    .board { width: 100%; border-radius: 12px; box-shadow: var(--shadow-md); }
    .board-status { margin-top: 6px; font-size: 13.5px; min-height: 0; }
    .board-status:empty { display: none; }
    .board-tools .btn-soft { width: 100%; min-height: 50px; font-size: 16px; }
    .board-card { -webkit-backdrop-filter: none; backdrop-filter: none; }

    .notes { margin-top: 18px; padding: 16px; }
    .notes h2 { font-size: 17px; }
    .notes li { font-size: 14.5px; }
}

/* Short phones (e.g. 360×640): squeeze the parts above and below the board a little more */
@media (max-width: 760px) and (max-height: 720px) {
    body:has(.lesson) .brand-logo { height: 30px; }
    body:has(.lesson) .top { padding: 4px 0; }
    .lesson-kicker { display: none; }
    .lesson-head { padding-bottom: 6px; }
    .lesson-head h1 { font-size: 15.5px; }
    .lesson-coach .bubble { min-height: 0; font-size: 14px; padding: 7px 11px; }
    .coach-nav, .done-box, .board-tools { padding: 6px; bottom: calc(6px + env(safe-area-inset-bottom)); }
    .coach-nav .btn-soft, .coach-nav .btn-main, .board-tools .btn-soft, .done-box .btn-main { min-height: 44px; }
    body:has(.lesson) { padding-bottom: calc(66px + env(safe-area-inset-bottom)); }
}

@media (max-width: 520px) {
    .brand-text { display: none; }
    .btn-voice .vl { display: none; }
    .sq .co { font-size: 9px; }
    .sq .nm { font-size: 9px; }
    .sq.named .nm { font-size: 16px; }
}
