* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

:root {
    /* Light theme colors */
    --bg-primary: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    --bg-secondary: white;
    --text-primary: #333;
    --text-secondary: #666;
    --border-color: #e8e8e8;
    --card-bg: #f9f9f9;
    --accent-primary: #667eea;
    --accent-secondary: #764ba2;
}

html[data-theme="dark"] {
    /* Dark theme colors */
    --bg-primary: linear-gradient(135deg, #1e1e2e 0%, #2d2d44 100%);
    --bg-secondary: #1f1f2e;
    --text-primary: #e0e0e0;
    --text-secondary: #b0b0b0;
    --border-color: #444;
    --card-bg: #2a2a3e;
    --accent-primary: #667eea;
    --accent-secondary: #764ba2;
}

body {
    font-family: 'Segoe UI', 'Clear Sans', 'Helvetica Neue', Arial, sans-serif;
    background: var(--bg-primary);
    min-height: 100vh;
    padding: 25px;
    display: flex;
    justify-content: center;
    align-items: center;
    color: var(--text-primary);
    transition: background 0.3s ease;
}

.theme-toggle {
    width: 32px;
    height: 32px;
    border-radius: 6px;
    border: none;
    background: var(--accent-primary);
    color: white;
    font-size: 1.1em;
    cursor: pointer;
    transition: all 0.3s ease;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 0;
    margin-top: 8px;
}

.theme-toggle:hover {
    background: var(--accent-secondary);
    transform: scale(1.05);
}

.theme-toggle-inline {
    width: 40px;
    height: 40px;
    border-radius: 8px;
    border: none;
    background: var(--accent-primary);
    color: white;
    font-size: 1.2em;
    cursor: pointer;
    transition: all 0.3s ease;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 0;
}

.theme-toggle-inline:hover {
    background: var(--accent-secondary);
    transform: scale(1.05);
}

.container {
    max-width: 1000px;
    background: var(--bg-secondary);
    border-radius: 20px;
    padding: 40px;
    box-shadow: 0 20px 60px rgba(0, 0, 0, 0.3);
    color: var(--text-primary);
}

.header {
    display: flex;
    justify-content: space-between;
    align-items: flex-start;
    margin-bottom: 35px;
    border-bottom: 3px solid var(--accent-primary);
    padding-bottom: 20px;
    gap: 20px;
}

h1 {
    font-size: 3em;
    color: var(--text-primary);
    margin: 0;
}

.game-subtitle {
    color: var(--text-secondary);
    font-size: 1.1em;
    margin-top: 8px;
}

.stats-container {
    display: flex;
    gap: 20px;
    align-items: center;
}

.stat-box {
    background: var(--card-bg);
    padding: 15px 25px;
    border-radius: 10px;
    text-align: center;
    min-width: 100px;
}

.stat-label {
    font-size: 0.9em;
    color: var(--text-secondary);
    font-weight: bold;
    text-transform: uppercase;
}

.stats-detail {
    text-align: center;
    color: var(--text-secondary);
    margin-top: 20px;
    font-style: italic;
}

.info-banner {
    background: var(--accent-primary);
    color: white;
    padding: 15px 20px;
    border-radius: 10px;
    margin: 20px 0;
    font-size: 1em;
    line-height: 1.6;
}

.game-section {
    background: var(--card-bg);
    padding: 35px;
    border-radius: 15px;
    margin-bottom: 35px;
}

.difficulty-selector {
    display: flex;
    align-items: center;
    gap: 15px;
    margin-bottom: 30px;
    flex-wrap: wrap;
}

.difficulty-selector span {
    font-weight: bold;
    color: var(--text-primary);
    font-size: 1.1em;
}

.diff-btn {
    padding: 10px 15px;
    border: 2px solid var(--border-color);
    background: var(--bg-secondary);
    border-radius: 8px;
    cursor: pointer;
    transition: all 0.3s;
    font-weight: 600;
    color: var(--text-primary);
}

.diff-btn:hover {
    border-color: var(--accent-primary);
    color: var(--accent-primary);
}

.diff-btn.active {
    background: var(--accent-primary);
    color: white;
    border-color: var(--accent-primary);
}

.problem-display {
    text-align: center;
    margin-bottom: 30px;
}

.problem-display h2 {
    color: #333;
    margin-bottom: 20px;
    font-size: 1.5em;
}

.numbers-display {
    display: flex;
    gap: 15px;
    justify-content: center;
    flex-wrap: wrap;
}

.number-box {
    width: 80px;
    height: 80px;
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    color: white;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 2em;
    font-weight: bold;
    border-radius: 12px;
    box-shadow: 0 5px 15px rgba(102, 126, 234, 0.3);
}

.input-section {
    background: var(--bg-secondary);
    border-radius: 12px;
    padding: 30px;
    margin-bottom: 30px;
    border: 1px solid var(--border-color);
}

.interactive-input > p {
    color: var(--text-secondary);
    margin-bottom: 25px;
    font-weight: 500;
    font-size: 1.1em;
}

.interactive-container {
    display: grid;
    grid-template-columns: 1.5fr 1fr;
    gap: 30px;
}

.numbers-selector h4,
.expression-builder h4 {
    color: var(--text-primary);
    margin-bottom: 15px;
    font-size: 1.2em;
    font-weight: 600;
}

.available-numbers {
    display: grid;
    grid-template-columns: repeat(2, 1fr);
    gap: 15px;
    margin-bottom: 25px;
}

.num-btn {
    padding: 20px 15px;
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    color: white;
    border: none;
    border-radius: 10px;
    font-size: 1.6em;
    font-weight: bold;
    cursor: pointer;
    transition: all 0.3s;
    box-shadow: 0 4px 12px rgba(102, 126, 234, 0.3);
}

.num-btn:hover:not(:disabled) {
    transform: translateY(-4px);
    box-shadow: 0 8px 20px rgba(102, 126, 234, 0.5);
}

.num-btn:disabled {
    opacity: 0.4;
    cursor: not-allowed;
    transform: none;
}

.expression-display {
    background: var(--card-bg);
    border: 2px solid var(--border-color);
    border-radius: 8px;
    padding: 20px;
    min-height: 80px;
    margin-bottom: 20px;
    font-size: 1.4em;
    font-family: 'Courier New', monospace;
    color: var(--text-primary);
    word-break: break-all;
    overflow-wrap: break-word;
    display: flex;
    align-items: center;
    justify-content: center;
    text-align: center;
}

.operator-buttons {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 10px;
    margin-bottom: 20px;
}

.op-btn {
    padding: 14px;
    background: var(--card-bg);
    border: 2px solid var(--border-color);
    border-radius: 8px;
    font-size: 1.3em;
    font-weight: bold;
    cursor: pointer;
    transition: all 0.3s;
    color: var(--text-primary);
}

.op-btn:hover {
    background: var(--accent-primary);
    color: white;
    border-color: var(--accent-primary);
}

.action-buttons {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 10px;
}

.action-btn {
    padding: 12px;
    border: none;
    border-radius: 8px;
    font-weight: bold;
    cursor: pointer;
    transition: all 0.3s;
    font-size: 1em;
}

.clear-btn {
    background: #ffb6c1;
    color: #c41e3a;
}

.clear-btn:hover {
    background: #ff69b4;
    color: white;
}

.backspace-btn {
    background: #ffd700;
    color: #333;
}

.backspace-btn:hover {
    background: #ffa500;
}

.submit-btn {
    background: #667eea;
    color: white;
    font-size: 1.05em;
    grid-column: 1 / -1;
}

.submit-btn:hover {
    background: #764ba2;
}

.result-message {
    margin-top: 15px;
    padding: 15px;
    border-radius: 8px;
    font-weight: bold;
    text-align: center;
    min-height: 20px;
}

.result-message.success {
    background: #d4edda;
    color: #155724;
    border: 1px solid #c3e6cb;
}

html[data-theme="dark"] .result-message.success {
    background: #1e4620;
    color: #90ee90;
}

.result-message.error {
    background: #f8d7da;
    color: #721c24;
    border: 1px solid #f5c6cb;
}

html[data-theme="dark"] .result-message.error {
    background: #5a1f1f;
    color: #ff9999;
}

.result-message.info {
    background: #d1ecf1;
    color: #0c5460;
    border: 1px solid #bee5eb;
}

html[data-theme="dark"] .result-message.info {
    background: #1a3a3f;
    color: #87ceeb;
}

.button-group {
    display: flex;
    gap: 15px;
    justify-content: center;
    margin-bottom: 35px;
    flex-wrap: wrap;
}

.primary-btn,
.secondary-btn {
    padding: 12px 30px;
    border: none;
    border-radius: 8px;
    font-size: 1.1em;
    font-weight: bold;
    cursor: pointer;
    transition: all 0.3s;
}

.primary-btn {
    background: #667eea;
    color: white;
}

.primary-btn:hover {
    background: #764ba2;
    transform: translateY(-2px);
    box-shadow: 0 5px 15px rgba(102, 126, 234, 0.3);
}

.secondary-btn {
    background: #ed9f3f;
    color: white;
    border: none;
    border-radius: 8px;
}

.secondary-btn:hover {
    background: #e08a2f;
    transform: translateY(-2px);
    box-shadow: 0 5px 15px rgba(237, 159, 63, 0.3);
}

.solution-section {
    background: #fff3cd;
    border: 2px solid #ffc107;
    border-radius: 12px;
    padding: 25px;
    margin-bottom: 30px;
}

html[data-theme="dark"] .solution-section {
    background: #5a4e1f;
    border-color: #ffc107;
}

.solution-section h3 {
    color: #856404;
    margin-bottom: 15px;
    font-size: 1.3em;
}

html[data-theme="dark"] .solution-section h3 {
    color: #ffc107;
}

.solution-display {
    background: var(--bg-secondary);
    border-radius: 8px;
    padding: 20px;
    margin-bottom: 20px;
    font-size: 1.2em;
    color: var(--text-primary);
    font-family: 'Courier New', monospace;
    min-height: 30px;
}

.instructions {
    background: var(--card-bg);
    padding: 30px;
    border-radius: 12px;
    margin-bottom: 25px;
    border-left: 4px solid var(--accent-primary);
}

.instructions h3 {
    color: var(--text-primary);
    margin-bottom: 18px;
    font-size: 1.3em;
}

.instructions ul,
.tips-section ul {
    list-style: none;
    padding: 0;
}

.instructions li,
.tips-section li {
    color: var(--text-secondary);
    margin: 15px 0;
    padding-left: 28px;
    position: relative;
    line-height: 1.7;
}

.instructions li:before,
.tips-section li:before {
    content: '✓';
    position: absolute;
    left: 0;
    color: #667eea;
    font-weight: bold;
    font-size: 1.2em;
}

.instructions ul ul,
.tips-section ul ul {
    margin-top: 12px;
    margin-left: 25px;
}

.instructions ul ul li:before,
.tips-section ul ul li:before {
    content: '→';
    color: #764ba2;
}

.tips-section {
    background: var(--card-bg);
    padding: 30px;
    border-radius: 12px;
    border-left: 4px solid var(--accent-primary);
}

.tips-section h3 {
    color: var(--text-primary);
    margin-bottom: 18px;
    font-size: 1.3em;
}

.tips-section li {
    color: #0c5460;
}

.tips-section li:before {
    color: #667eea;
}

@media (max-width: 768px) {
    body {
        padding: 15px;
    }

    .container {
        padding: 20px;
    }

    .theme-toggle {
        width: 28px;
        height: 28px;
        font-size: 1em;
    }

    h1 {
        font-size: 2em;
    }

    .game-subtitle {
        font-size: 0.95em;
    }

    .header {
        flex-direction: column;
        gap: 15px;
    }

    .stats-container {
        width: 100%;
        justify-content: space-around;
    }

    .difficulty-selector {
        flex-direction: column;
        align-items: flex-start;
    }

    .difficulty-selector span {
        margin-bottom: 10px;
    }

    .info-banner {
        font-size: 0.95em;
        padding: 12px 15px;
    }

    .game-section {
        padding: 20px;
    }

    .input-section {
        padding: 20px;
    }

    .interactive-container {
        grid-template-columns: 1fr;
    }

    .available-numbers {
        grid-template-columns: repeat(2, 1fr);
        gap: 12px;
    }

    .num-btn {
        padding: 18px 12px;
        font-size: 1.4em;
    }

    .expression-display {
        font-size: 1.2em;
        padding: 15px;
        min-height: 70px;
    }

    .operator-buttons {
        grid-template-columns: repeat(2, 1fr);
        gap: 8px;
    }

    .op-btn {
        padding: 12px;
        font-size: 1.2em;
    }

    .action-buttons {
        grid-template-columns: 1fr;
        gap: 8px;
    }

    .submit-btn {
        grid-column: 1 / -1;
    }

    .button-group {
        flex-direction: column;
        gap: 12px;
    }

    .primary-btn,
    .secondary-btn {
        width: 100%;
        padding: 12px 20px;
        font-size: 1em;
    }

    .instructions,
    .tips-section {
        padding: 20px;
        margin-bottom: 20px;
    }

    .instructions h3,
    .tips-section h3 {
        font-size: 1.15em;
        margin-bottom: 15px;
    }

    .instructions li,
    .tips-section li {
        margin: 12px 0;
        padding-left: 25px;
        font-size: 0.95em;
    }

    .solution-section {
        padding: 20px;
    }

    .solution-display {
        font-size: 1.1em;
        padding: 15px;
    }
}

@media (max-width: 480px) {
    body {
        padding: 10px;
    }

    .container {
        padding: 15px;
        border-radius: 15px;
    }

    h1 {
        font-size: 1.5em;
    }

    .game-subtitle {
        font-size: 0.9em;
    }

    .stat-box {
        min-width: 80px;
        padding: 12px 18px;
    }

    .stat-value {
        font-size: 1.6em;
    }

    .diff-btn {
        padding: 8px 12px;
        font-size: 0.9em;
    }

    .info-banner {
        font-size: 0.9em;
        padding: 10px 12px;
    }

    .game-section {
        padding: 15px;
        border-radius: 12px;
    }

    .input-section {
        padding: 15px;
    }

    .available-numbers {
        grid-template-columns: repeat(2, 1fr);
        gap: 10px;
    }

    .num-btn {
        padding: 16px 10px;
        font-size: 1.3em;
        border-radius: 8px;
    }

    .expression-display {
        font-size: 1.1em;
        padding: 12px;
        min-height: 65px;
    }

    .operator-buttons {
        grid-template-columns: repeat(2, 1fr);
        gap: 6px;
    }

    .op-btn {
        padding: 10px;
        font-size: 1.1em;
    }

    .action-buttons {
        gap: 6px;
    }

    .primary-btn,
    .secondary-btn {
        padding: 10px 15px;
        font-size: 0.95em;
    }

    .instructions,
    .tips-section {
        padding: 15px;
        margin-bottom: 15px;
    }

    .instructions h3,
    .tips-section h3 {
        font-size: 1.1em;
        margin-bottom: 12px;
    }

    .instructions li,
    .tips-section li {
        margin: 10px 0;
        padding-left: 22px;
        font-size: 0.9em;
        line-height: 1.6;
    }
}
