/* ====================================
   Reset & Tokens
   ==================================== */

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

:root {
    --bg-global-start: #0F1510;
    --bg-global-end: #050805;
    --bg-surface: #1A221E;
    --bg-surface-hover: #202a25;
    --bg-input: #252C28;

    --accent: #2FD45E;
    --accent-hover: #33FF66;
    --accent-dim: #1a5c2e;

    --text-main: #FFFFFF;
    --text-secondary: #8E9B95;
    --text-muted: #5c6660;
    --text-on-accent: #050805;

    --danger: #ef4444;
    --warning: #f59e0b;

    --border-fine: rgba(255, 255, 255, 0.06);

    --radius-card: 18px;
    --radius-pill: 999px;

    --shadow-card: 0 4px 20px rgba(0, 0, 0, 0.3);
    --shadow-glow: 0 0 30px rgba(47, 212, 94, 0.25);

    --section-pad-y: 120px;
}

html { scroll-behavior: smooth; }

body {
    font-family: 'Inter', system-ui, -apple-system, BlinkMacSystemFont, sans-serif;
    background: linear-gradient(180deg, var(--bg-global-start) 0%, var(--bg-global-end) 100%);
    color: var(--text-main);
    line-height: 1.5;
    overflow-x: hidden;
    min-height: 100vh;
}

@media (max-width: 900px) { :root { --section-pad-y: 80px; } }
@media (max-width: 600px) { :root { --section-pad-y: 64px; } }

.section {
    padding: var(--section-pad-y) clamp(20px, 5vw, 80px);
    max-width: 1440px;
    margin: 0 auto;
    width: 100%;
}

.eyebrow {
    font-size: 11px;
    font-weight: 600;
    letter-spacing: 2px;
    text-transform: uppercase;
    color: var(--text-muted);
    display: inline-flex;
    align-items: center;
    gap: 8px;
}
.eyebrow::before {
    content: '';
    width: 6px; height: 6px;
    border-radius: 50%;
    background: var(--accent);
    box-shadow: 0 0 8px var(--accent);
}

h1, h2, h3 { font-weight: 700; letter-spacing: -0.02em; }
h2 { font-size: clamp(28px, 4vw, 48px); margin: 12px 0 16px; line-height: 1.1; }
h3 { font-size: 16px; font-weight: 600; }

p { color: var(--text-secondary); font-size: 15px; line-height: 1.6; max-width: 60ch; }

a { color: var(--accent); text-decoration: none; }

.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    padding: 14px 28px;
    border-radius: var(--radius-pill);
    font-size: 15px;
    font-weight: 600;
    cursor: pointer;
    border: none;
    transition: transform 0.2s, box-shadow 0.2s, background 0.2s;
    text-decoration: none;
}
.btn:hover { transform: translateY(-2px); }
.btn-primary {
    background: var(--accent);
    color: var(--text-on-accent);
    box-shadow: 0 4px 16px rgba(47, 212, 94, 0.35);
}
.btn-primary:hover {
    background: var(--accent-hover);
    box-shadow: 0 8px 28px rgba(47, 212, 94, 0.55);
}
.btn-secondary {
    background: transparent;
    color: var(--text-main);
    border: 1px solid var(--border-fine);
}
.btn-secondary:hover {
    background: rgba(255, 255, 255, 0.04);
    border-color: var(--accent);
}

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

/* ====================================
   Hero
   ==================================== */

.hero {
    position: relative;
    height: 100vh;
    min-height: 640px;
    display: flex;
    align-items: center;
    justify-content: center;
    text-align: center;
    overflow: hidden;
    padding: 0 clamp(20px, 5vw, 80px);
}

.hero-bg {
    position: absolute;
    inset: 0;
    width: 100%;
    height: 100%;
    opacity: 0.22;
    z-index: 0;
    image-rendering: pixelated;
}

.hero-glow {
    position: absolute;
    inset: 0;
    background: radial-gradient(circle at 50% 45%, rgba(47, 212, 94, 0.14), transparent 55%);
    pointer-events: none;
    z-index: 1;
}

.hero-content {
    position: relative;
    z-index: 2;
    max-width: 900px;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 18px;
}

.hero-title {
    font-size: clamp(48px, 7vw, 96px);
    font-weight: 700;
    line-height: 1;
    letter-spacing: -0.04em;
    background: linear-gradient(180deg, #ffffff 0%, var(--accent) 140%);
    -webkit-background-clip: text;
    background-clip: text;
    color: transparent;
    margin: 4px 0;
}

.hero-sub {
    font-size: clamp(15px, 1.8vw, 18px);
    color: var(--text-secondary);
    max-width: 640px;
}
.hero-sub strong { color: var(--text-main); font-weight: 600; }

.hero-cta {
    display: flex;
    gap: 14px;
    margin-top: 14px;
    flex-wrap: wrap;
    justify-content: center;
}

.hero-scroll-cue {
    position: absolute;
    bottom: 32px;
    left: 50%;
    transform: translateX(-50%);
    color: var(--text-muted);
    font-size: 28px;
    text-decoration: none;
    animation: bounce 1.8s ease-in-out infinite;
    z-index: 2;
}
@keyframes bounce {
    0%, 100% { transform: translateX(-50%) translateY(0); opacity: 0.5; }
    50% { transform: translateX(-50%) translateY(10px); opacity: 1; }
}

/* ====================================
   Section Concept
   ==================================== */

.section-concept {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 60px;
    align-items: center;
}
@media (max-width: 900px) {
    .section-concept { grid-template-columns: 1fr; gap: 40px; }
}

.concept-left { display: flex; flex-direction: column; gap: 16px; }
.concept-left p { margin-top: 4px; }
.concept-left code, .bs-tag {
    font-family: 'Consolas', 'Menlo', monospace;
    background: var(--bg-input);
    padding: 2px 8px;
    border-radius: 5px;
    color: var(--accent);
    font-size: 13px;
}
.concept-left p strong { color: var(--text-main); }
.concept-left p em { color: var(--accent); font-style: normal; }

.concept-right {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 16px;
}
.concept-right canvas {
    width: 300px;
    height: 300px;
    background: #0a0f0c;
    border: 1px solid var(--border-fine);
    border-radius: var(--radius-card);
    image-rendering: pixelated;
}
.concept-meta { display: flex; gap: 10px; }
.bs-tag { font-size: 13px; padding: 4px 12px; }
.concept-hint { font-size: 12px; color: var(--text-muted); }

/* ====================================
   Section Modes
   ==================================== */

.section-head {
    text-align: center;
    margin-bottom: 60px;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 12px;
}
.section-head p { max-width: 700px; }

.tier { margin-bottom: 60px; }
.tier:last-child { margin-bottom: 0; }

.tier-head {
    display: flex;
    align-items: center;
    gap: 16px;
    margin-bottom: 24px;
    padding-bottom: 12px;
    border-bottom: 1px solid var(--border-fine);
}
.tier-tag {
    font-size: 10px;
    font-weight: 700;
    letter-spacing: 1.5px;
    padding: 4px 10px;
    border-radius: 999px;
    border: 1px solid transparent;
}
.tier-tag.tier-a { background: rgba(47, 212, 94, 0.12); color: var(--accent); border-color: rgba(47, 212, 94, 0.3); }
.tier-tag.tier-b { background: rgba(245, 158, 11, 0.12); color: var(--warning); border-color: rgba(245, 158, 11, 0.3); }
.tier-tag.tier-c { background: rgba(168, 85, 247, 0.12); color: #a855f7; border-color: rgba(168, 85, 247, 0.3); }
.tier-head h3 { font-size: 18px; color: var(--text-main); }

.mode-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(220px, 1fr));
    gap: 14px;
}

.mode-card {
    background: var(--bg-surface);
    border: 1px solid var(--border-fine);
    border-left: 3px solid var(--accent);
    border-radius: var(--radius-card);
    padding: 16px;
    display: flex;
    flex-direction: column;
    gap: 10px;
    transition: transform 0.2s, border-color 0.2s, box-shadow 0.2s;
    overflow: hidden;
}
.mode-card:hover {
    transform: translateY(-4px);
    border-color: var(--accent);
    box-shadow: var(--shadow-glow);
}
.mode-card .mc-head {
    display: flex;
    align-items: center;
    gap: 10px;
}
.mode-card .mc-emoji { font-size: 22px; line-height: 1; }
.mode-card .mc-name { font-size: 14px; font-weight: 600; color: var(--text-main); }
.mode-card canvas {
    width: 100%;
    height: 140px;
    background: #0a0f0c;
    border-radius: 8px;
    image-rendering: pixelated;
    display: block;
}
.mode-card .mc-tag { font-size: 11px; color: var(--text-muted); line-height: 1.4; }

/* ====================================
   Section Rules
   ==================================== */

.rules-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(160px, 1fr));
    gap: 12px;
    margin-bottom: 80px;
}
.rule-card {
    background: var(--bg-surface);
    border: 1px solid var(--border-fine);
    border-radius: 12px;
    padding: 10px;
    display: flex;
    flex-direction: column;
    gap: 8px;
    transition: transform 0.2s, border-color 0.2s, box-shadow 0.2s;
}
.rule-card:hover { border-color: var(--accent); transform: translateY(-2px); box-shadow: var(--shadow-glow); }
.rule-card .r-name { font-size: 12px; font-weight: 600; color: var(--text-main); }
.rule-card .r-notation { font-family: 'Consolas', monospace; font-size: 10px; color: var(--accent); }
.rule-card canvas { width: 100%; height: 110px; background: #0a0f0c; border-radius: 6px; image-rendering: pixelated; display: block; }

.builder-demo {
    background: var(--bg-surface);
    border: 1px solid var(--border-fine);
    border-radius: var(--radius-card);
    padding: 32px;
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 40px;
    align-items: center;
}
@media (max-width: 900px) { .builder-demo { grid-template-columns: 1fr; padding: 24px; } }
.builder-left { display: flex; flex-direction: column; gap: 14px; }
.builder-left h3 { font-size: 22px; }
.builder-current { font-size: 13px; color: var(--text-secondary); }
.builder-current code {
    font-family: 'Consolas', monospace;
    background: var(--bg-input);
    color: var(--accent);
    padding: 4px 10px;
    border-radius: 6px;
    font-size: 14px;
    margin-left: 8px;
}

.builder-right { display: flex; flex-direction: column; gap: 10px; }
.bs-line { display: flex; align-items: center; gap: 10px; }
.bs-label { font-size: 11px; font-weight: 700; color: var(--accent); width: 12px; }
.bs-grid {
    display: grid;
    grid-template-columns: repeat(9, 1fr);
    gap: 3px;
    flex: 1;
}
.bs-cell {
    aspect-ratio: 1;
    background: var(--bg-input);
    border: 1px solid var(--border-fine);
    border-radius: 4px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 10px;
    color: var(--text-muted);
    transition: all 0.2s;
}
.bs-cell.on {
    background: rgba(47, 212, 94, 0.18);
    border-color: rgba(47, 212, 94, 0.5);
    color: var(--accent);
    font-weight: 600;
}
.builder-right canvas {
    width: 100%;
    height: 140px;
    background: #0a0f0c;
    border-radius: 8px;
    image-rendering: pixelated;
    margin-top: 6px;
}

/* ====================================
   Section Patterns
   ==================================== */

.patterns-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(160px, 1fr));
    gap: 12px;
}

.pattern-card {
    background: var(--bg-surface);
    border: 1px solid var(--border-fine);
    border-radius: 12px;
    padding: 10px;
    display: flex;
    flex-direction: column;
    gap: 6px;
    transition: transform 0.2s, border-color 0.2s, box-shadow 0.2s;
    cursor: default;
}
.pattern-card:hover {
    transform: translateY(-3px);
    border-color: var(--accent);
    box-shadow: var(--shadow-glow);
}

.pattern-card .pc-eyebrow { font-size: 9px; text-transform: uppercase; letter-spacing: 1px; color: var(--text-muted); }
.pattern-card .pc-name { font-size: 13px; font-weight: 600; color: var(--text-main); }
.pattern-card canvas {
    width: 100%;
    height: 110px;
    background: #0a0f0c;
    border-radius: 6px;
    image-rendering: pixelated;
    display: block;
}

/* ====================================
   Section Stats
   ==================================== */

.stats-demo {
    background: var(--bg-surface);
    border: 1px solid var(--border-fine);
    border-radius: var(--radius-card);
    padding: 28px 32px;
    display: grid;
    grid-template-columns: minmax(280px, 1fr) 2fr;
    gap: 32px;
    align-items: center;
}
@media (max-width: 900px) {
    .stats-demo { grid-template-columns: 1fr; padding: 20px; }
}

.stats-chips {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 14px 18px;
}
.chip { display: flex; flex-direction: column; gap: 2px; min-width: 0; }
.chip-lbl {
    font-size: 9px;
    text-transform: uppercase;
    letter-spacing: 0.6px;
    color: var(--text-muted);
    display: flex; align-items: center; gap: 5px;
    white-space: nowrap;
}
.chip-val {
    font-size: 22px;
    font-weight: 700;
    color: var(--text-main);
    font-variant-numeric: tabular-nums;
    line-height: 1.1;
}
.chip-val.births { color: var(--accent); text-shadow: 0 0 12px rgba(47, 212, 94, 0.3); }
.chip-val.deaths { color: var(--danger); }
.chip-val.neutral { color: var(--text-secondary); }

.stats-graph { display: flex; flex-direction: column; gap: 8px; }
.sg-head { display: flex; justify-content: space-between; align-items: center; gap: 10px; }
.sg-legend {
    font-size: 10px;
    color: var(--text-muted);
    font-variant-numeric: tabular-nums;
}
.sg-legend strong { color: var(--text-main); margin: 0 2px; }
.stats-graph canvas {
    width: 100%;
    height: 120px;
    background: rgba(255, 255, 255, 0.02);
    border-radius: 8px;
    display: block;
}

/* ====================================
   Section Tech
   ==================================== */

.section-tech {
    background: rgba(47, 212, 94, 0.02);
    border-top: 1px solid var(--border-fine);
    border-bottom: 1px solid var(--border-fine);
    padding-top: 64px;
    padding-bottom: 64px;
}
.tech-strip {
    display: grid;
    grid-template-columns: repeat(4, 1fr);
    gap: 24px;
}
@media (max-width: 700px) { .tech-strip { grid-template-columns: repeat(2, 1fr); } }
.tech-chip {
    text-align: center;
    padding: 18px;
    background: var(--bg-surface);
    border: 1px solid var(--border-fine);
    border-radius: 14px;
}
.tc-num {
    font-size: clamp(20px, 2.6vw, 32px);
    font-weight: 700;
    color: var(--accent);
    font-variant-numeric: tabular-nums;
    margin-bottom: 4px;
}
.tc-lbl {
    font-size: 11px;
    text-transform: uppercase;
    letter-spacing: 1px;
    color: var(--text-muted);
}

/* ====================================
   Section CTA
   ==================================== */

.section-cta {
    min-height: 60vh;
    display: flex;
    align-items: center;
    justify-content: center;
    text-align: center;
}
.cta-card {
    max-width: 700px;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 18px;
    padding: 40px;
}
.cta-card h2 { font-size: clamp(36px, 5vw, 64px); }
.cta-card p { font-size: 17px; max-width: 540px; }
.btn-huge {
    height: 64px;
    padding: 0 36px;
    font-size: 18px;
    margin-top: 14px;
}

/* ====================================
   Footer
   ==================================== */

.foot {
    border-top: 1px solid var(--border-fine);
    padding: 24px 0;
    background: rgba(0, 0, 0, 0.25);
}
.foot-inner {
    max-width: 1440px;
    margin: 0 auto;
    padding: 0 clamp(20px, 5vw, 80px);
    display: flex;
    justify-content: space-between;
    align-items: center;
    flex-wrap: wrap;
    gap: 16px;
    font-size: 12px;
    color: var(--text-muted);
}
.foot-credit { font-weight: 500; }
.foot-links { display: flex; gap: 18px; flex-wrap: wrap; }
.foot-links a { color: var(--text-secondary); text-decoration: none; transition: color 0.2s; }
.foot-links a:hover { color: var(--accent); }
.foot-version { color: var(--accent); opacity: 0.6; font-family: 'Consolas', monospace; letter-spacing: 0.3px; }

/* ====================================
   Language Switcher (landing)
   ==================================== */

.lang-switcher { position: relative; }
.lang-current {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    height: 32px;
    padding: 0 12px;
    background: rgba(26, 34, 30, 0.85);
    backdrop-filter: blur(6px);
    border: 1px solid var(--border-fine);
    border-radius: 999px;
    color: var(--text-secondary);
    font-size: 12px;
    font-weight: 600;
    letter-spacing: 0.4px;
    cursor: pointer;
    transition: background 0.2s, color 0.2s;
    font-family: inherit;
}
.lang-current:hover { background: var(--bg-surface-hover); color: var(--text-main); }
.lang-current .lang-flag { font-size: 15px; line-height: 1; }
.lang-current .lang-caret { color: var(--text-muted); font-size: 10px; }

.lang-menu {
    position: absolute;
    right: 0;
    top: calc(100% + 6px);
    min-width: 150px;
    list-style: none;
    margin: 0;
    padding: 4px;
    background: var(--bg-surface);
    border: 1px solid var(--border-fine);
    border-radius: 10px;
    box-shadow: 0 8px 22px rgba(0, 0, 0, 0.5);
    z-index: 40;
}
.lang-menu[hidden] { display: none; }
.lang-menu li {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 8px 10px;
    border-radius: 6px;
    font-size: 13px;
    color: var(--text-main);
    cursor: pointer;
    transition: background 0.15s;
}
.lang-menu li:hover { background: var(--bg-surface-hover); }
.lang-menu li.active { color: var(--accent); background: rgba(47, 212, 94, 0.08); }
.lang-menu li .lang-flag { font-size: 15px; line-height: 1; }
.lang-menu li .lang-name { flex: 1; }
.lang-menu li .lang-check { color: var(--accent); opacity: 0; }
.lang-menu li.active .lang-check { opacity: 1; }

.landing-lang-switcher {
    position: absolute;
    top: 20px;
    right: 20px;
    z-index: 5;
}
