: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="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 {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(60px, 1fr));
    gap: 12px;
}

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

.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-link .emoji {
    font-size: 22px;
    margin-top: 4px;
}

.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;
}

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

    .controls {
        flex-direction: column;
    }

    .home-button {
        position: static;
        transform: none;
        margin-bottom: 16px;
        display: inline-flex;
    }

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

