:root {
    --font-family: system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
    --body-bg: #f5f7f4;
    --card-bg: #ffffff;
    --accent-color: #2d572c;
    --accent-light: #93c47d;
    --accent-dark: #1a431f;
    --muted-bg: #f4f7ef;
    --text-color: #1f331c;
    --border-radius: 18px;
}

*,
*::before,
*::after {
    box-sizing: border-box;
}

body {
    font-family: var(--font-family);
    min-height: 100vh;
    margin: 0;
    background: var(--body-bg);
    color: var(--text-color);
    display: flex;
    justify-content: center;
    align-items: center;
    padding: 20px;
}

body[data-theme="green"] {
    --body-bg: radial-gradient(circle at top, #f7fcf4, #e8f4dc);
    --accent-color: #38761d;
    --accent-light: #93c47d;
    --accent-dark: #1a431f;
    --muted-bg: #f7fbef;
}

body[data-theme="purple"] {
    --body-bg: radial-gradient(circle at top, #f8f6fc, #ede7f6);
    --accent-color: #5e35b1;
    --accent-light: #9575cd;
    --accent-dark: #45248a;
    --muted-bg: #ede7f6;
}

body[data-theme="louchebem"] {
    --body-bg: radial-gradient(circle at top, #fdf7f0, #f3e5cf);
    --accent-color: #8b4513;
    --accent-light: #d97726;
    --accent-dark: #5a2d0b;
    --muted-bg: #f8ecdd;
}

body[data-theme="lyrics"] {
    --body-bg: radial-gradient(circle at top, #f5f0fa, #e8ddf5);
    --accent-color: #6a1b9a;
    --accent-light: #ab47bc;
    --accent-dark: #4a148c;
    --muted-bg: #f3ecf9;
    --text-color: #2e1045;
}

body[data-theme="cinematrix"] {
    --body-bg: radial-gradient(circle at top, #f0f4fa, #dce6f5);
    --accent-color: #1565c0;
    --accent-light: #42a5f5;
    --accent-dark: #0d47a1;
    --muted-bg: #e8f0fe;
    --text-color: #0d1b2a;
}

body[data-theme="poetry"] {
    --body-bg: radial-gradient(circle at top, #f5f0e1, #e8dcc8);
    --accent-color: #5c4033;
    --accent-light: #8b7355;
    --accent-dark: #3e2723;
    --muted-bg: #ede4d3;
    --text-color: #2c1e10;
}

body[data-theme="turing"] {
    --body-bg: radial-gradient(circle at top, #f0f7f7, #d4eded);
    --accent-color: #00695c;
    --accent-light: #26a69a;
    --accent-dark: #004d40;
    --muted-bg: #e0f2f1;
    --text-color: #1a3636;
}

body[data-theme="menu"] {
    --body-bg: radial-gradient(circle at top, #f7fcf4, #e8f4dc);
    --card-bg: #ffffff;
    --accent-color: #38761d;
    --accent-light: #93c47d;
    --accent-dark: #275c2c;
    --muted-bg: #f7fbef;
}

.page-wrapper {
    position: relative;
    width: min(780px, 100%);
    padding-top: 60px;
}

.card {
    background: var(--card-bg);
    border-radius: var(--border-radius);
    box-shadow: 0 20px 45px rgba(15, 40, 25, 0.12);
    padding: 32px;
    width: 100%;
    margin: 0 auto;
    display: flex;
    flex-direction: column;
    gap: 24px;
}

.card-title {
    margin: 0 0 24px;
    color: var(--accent-color);
    text-align: center;
    font-size: 28px;
}

.description {
    margin-top: 0;
    color: #4c5c4b;
    line-height: 1.6;
}

.module-header {
    display: flex;
    flex-direction: column;
    gap: 8px;
    margin-top: 0;
}

.module-eyebrow {
    font-size: 14px;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.08em;
    color: var(--accent-light);
}

.module-description {
    margin: 0;
    color: #566357;
    line-height: 1.6;
}

.home-button {
    position: absolute;
    top: 0;
    left: 0;
    transform: translateY(-50%);
    padding: 10px 18px;
    border-radius: 999px;
    background: var(--accent-color);
    color: #ffffff;
    text-decoration: none;
    font-weight: 600;
    box-shadow: 0 12px 24px rgba(0, 0, 0, 0.12);
    transition: transform 0.2s ease, box-shadow 0.2s ease, background 0.2s ease;
}

.home-button:hover {
    background: var(--accent-dark);
    box-shadow: 0 16px 32px rgba(0, 0, 0, 0.15);
    transform: translateY(-50%) translateY(-1px);
}

.controls,
.radio-group {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 12px;
    flex-wrap: wrap;
    margin-bottom: 20px;
}

.radio-group label {
    font-weight: 600;
    color: var(--accent-color);
}

.label {
    color: var(--accent-color);
    font-weight: 600;
}

.chip-button {
    width: 42px;
    height: 42px;
    border-radius: 12px;
    border: 1px solid rgba(0, 0, 0, 0.08);
    background: var(--muted-bg);
    color: var(--accent-color);
    font-size: 20px;
    font-weight: 600;
    cursor: pointer;
    transition: background 0.2s ease, color 0.2s ease;
}

.chip-button:hover:not(:disabled) {
    background: var(--accent-light);
    color: #ffffff;
}

.chip-button:disabled {
    opacity: 0.5;
    cursor: not-allowed;
}

.value-pill {
    min-width: 36px;
    text-align: center;
    font-weight: 700;
    font-size: 20px;
    color: var(--accent-color);
}

.primary-button {
    padding: 12px 28px;
    border: none;
    border-radius: 999px;
    background: var(--accent-color);
    color: #ffffff;
    font-weight: 600;
    cursor: pointer;
    transition: background 0.2s ease, transform 0.2s ease, box-shadow 0.2s ease;
}

.primary-button:hover:not(:disabled) {
    background: var(--accent-dark);
    transform: translateY(-1px);
    box-shadow: 0 10px 24px rgba(0, 0, 0, 0.15);
}

.primary-button:disabled {
    opacity: 0.5;
    cursor: not-allowed;
}

.result-grid,
.results-container {
    background: var(--muted-bg);
    border-radius: 16px;
    padding: 16px;
    border: 1px solid rgba(0, 0, 0, 0.05);
    min-height: 70px;
    display: flex;
    flex-wrap: wrap;
    gap: 10px;
    justify-content: center;
    align-items: center;
}

.dice-grid {
    --dice-size: 100px;
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(var(--dice-size), 1fr));
    gap: 12px;
}

.dice {
    width: var(--dice-size);
    height: var(--dice-size);
    border-radius: 12px;
    background: #faf3e0;
    display: flex;
    justify-content: center;
    align-items: center;
    border: 1px solid rgba(0, 0, 0, 0.05);
    font-size: calc(var(--dice-size) * 0.6);
}

.dice.rolling {
    animation: dice-roll 0.4s ease-out;
}

@keyframes dice-roll {
    0% { transform: scale(0.3) rotate(0deg); opacity: 0; }
    50% { transform: scale(1.1) rotate(180deg); opacity: 1; }
    100% { transform: scale(1) rotate(360deg); opacity: 1; }
}

.chip,
.word-item {
    background: #ffffff;
    padding: 6px 14px;
    border-radius: 999px;
    border: 1px solid rgba(0, 0, 0, 0.08);
    font-weight: 600;
    color: var(--accent-color);
    box-shadow: 0 4px 10px rgba(0, 0, 0, 0.05);
}

.status {
    min-height: 24px;
    font-size: 14px;
    color: var(--accent-dark);
    margin-bottom: 8px;
}

.status.error {
    color: #b71c1c;
}

.alert {
    display: none;
    color: #721c24;
    background: #f8d7da;
    border: 1px solid #f5c6cb;
    border-radius: 12px;
    padding: 12px 16px;
    width: 100%;
    text-align: center;
}

input[type="text"],
textarea {
    width: 100%;
    border-radius: 12px;
    border: 1px solid rgba(0, 0, 0, 0.15);
    padding: 12px 14px;
    font-family: inherit;
    font-size: 16px;
    color: var(--text-color);
    background: #ffffff;
    transition: border-color 0.2s ease, box-shadow 0.2s ease;
}

textarea {
    min-height: 120px;
    resize: vertical;
}

.theme-input {
    max-width: 360px;
}

input[type="text"]:focus,
textarea:focus {
    outline: none;
    border-color: var(--accent-light);
    box-shadow: 0 0 0 3px rgba(147, 196, 125, 0.25);
}

.result-panel {
    margin-top: 24px;
    border-top: 1px solid rgba(0, 0, 0, 0.08);
    padding-top: 24px;
    display: none;
}

.result-text {
    background: #1f4121;
    color: #f5ffe8;
    border-radius: 16px;
    padding: 18px;
    margin: 0;
    line-height: 1.6;
}

.menu-card {
    max-width: 460px;
    width: 100%;
    padding: 40px 32px;
}

.menu-links {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
    gap: 16px;
}

.menu-link {
    padding: 16px 18px;
    border-radius: 14px;
    text-align: center;
    text-decoration: none;
    background: var(--accent-light);
    color: #ffffff;
    font-weight: 600;
    font-size: 18px;
    box-shadow: 0 10px 24px rgba(0, 0, 0, 0.12);
    transition: transform 0.2s ease, box-shadow 0.2s ease, background 0.2s ease;
}

.menu-link:hover {
    background: var(--accent-color);
    transform: translateY(-2px);
    box-shadow: 0 16px 30px rgba(0, 0, 0, 0.15);
}

.menu-header {
    text-align: center;
    margin-bottom: 24px;
}

.menu-header p {
    margin: 8px 0 0;
    color: #4c5c4b;
}

.form-stack {
    display: flex;
    flex-direction: column;
    gap: 16px;
}

/* ── Language toggle ── */

.top-bar {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 16px;
}

.lang-toggle {
    display: flex;
    gap: 0;
    border-radius: 999px;
    overflow: hidden;
    border: 2px solid var(--accent-color);
}

.lang-toggle button {
    padding: 6px 16px;
    border: none;
    background: transparent;
    color: var(--accent-color);
    font-weight: 700;
    font-size: 14px;
    cursor: pointer;
    transition: background 0.2s, color 0.2s;
}

.lang-toggle button.active {
    background: var(--accent-color);
    color: #fff;
}

/* ── Menu categories ── */

.menu-category {
    margin-bottom: 8px;
}

.category-title {
    font-size: 13px;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.08em;
    color: var(--accent-color);
    margin: 0 0 10px;
    opacity: 0.7;
}

/* ── Doc pages ── */

body[data-theme="docs"] {
    --body-bg: radial-gradient(circle at top, #f4f6f9, #e2e8f0);
    --accent-color: #37474f;
    --accent-light: #78909c;
    --accent-dark: #263238;
    --muted-bg: #eceff1;
    --text-color: #1a2027;
    align-items: flex-start;
}

.doc-content {
    line-height: 1.8;
    font-size: 15px;
}

.doc-content h2 {
    color: var(--accent-color);
    font-size: 20px;
    margin: 28px 0 12px;
    padding-bottom: 6px;
    border-bottom: 2px solid var(--muted-bg);
}

.doc-content h2:first-child {
    margin-top: 0;
}

.doc-content p {
    margin: 0 0 12px;
    color: #4a5568;
}

.doc-content ul, .doc-content ol {
    margin: 0 0 16px;
    padding-left: 24px;
    color: #4a5568;
}

.doc-content li {
    margin-bottom: 6px;
}

.doc-content code {
    background: var(--muted-bg);
    padding: 2px 6px;
    border-radius: 4px;
    font-size: 13px;
    color: var(--accent-dark);
}

.doc-content .tech-badge {
    display: inline-block;
    background: var(--accent-color);
    color: #fff;
    padding: 3px 10px;
    border-radius: 999px;
    font-size: 12px;
    font-weight: 600;
    margin: 2px 4px 2px 0;
}

.doc-content .doc-back {
    display: inline-block;
    margin-top: 20px;
    color: var(--accent-light);
    text-decoration: none;
    font-weight: 600;
    font-size: 14px;
}

.doc-content .doc-back:hover {
    color: var(--accent-color);
}

.doc-link {
    display: block;
    text-align: center;
    margin-top: 8px;
    font-size: 13px;
    color: var(--accent-light);
    text-decoration: none;
    opacity: 0.8;
    transition: opacity 0.2s;
}

.doc-link:hover {
    opacity: 1;
    color: var(--accent-color);
}

@media (max-width: 600px) {
    .card {
        padding: 24px;
    }

    .controls {
        flex-direction: column;
    }

    .home-button {
        position: static;
        transform: none;
        display: inline-flex;
    }

    .page-wrapper {
        padding-top: 0;
    }

    .top-bar {
        margin-bottom: 12px;
    }

    .dice-grid {
        --dice-size: 80px;
    }
}

