:root {
    /* Color Palette */
    --primary-color: #4a90e2;
    --primary-dark: #357abd;
    --secondary-color: #50e3c2;
    --accent-color: #ff6b6b;
    --text-color: #333333;
    --text-light: #666666;
    --bg-color: #f4f6f8;
    --card-bg: #ffffff;
    --border-color: #e1e4e8;
    --input-bg: #f9fafb;
    
    /* Feedback Colors */
    --success-bg: #d4edda;
    --success-text: #155724;
    --error-bg: #f8d7da;
    --error-text: #721c24;
    --info-text: #0c5460;
    --info-bg: #d1ecf1;
    
    /* Spacing & Sizing */
    --spacing-xs: 4px;
    --spacing-sm: 8px;
    --spacing-md: 16px;
    --spacing-lg: 24px;
    --border-radius: 12px;
    --touch-target: 48px;
    
    /* Shadows */
    --shadow-sm: 0 2px 4px rgba(0,0,0,0.05);
    --shadow-md: 0 4px 6px rgba(0,0,0,0.1);
    --shadow-lg: 0 10px 15px rgba(0,0,0,0.1);
}

[data-theme="dark"] {
    --primary-color: #64b5f6;
    --primary-dark: #42a5f5;
    --text-color: #e0e0e0;
    --text-light: #a0a0a0;
    --bg-color: #121212;
    --card-bg: #1e1e1e;
    --border-color: #333333;
    --input-bg: #2c2c2c;
    --shadow-sm: 0 2px 4px rgba(0,0,0,0.3);
    --shadow-md: 0 4px 6px rgba(0,0,0,0.4);
    --info-text: #99c2ff;
    --info-bg: #1e2a3a;
    --success-bg: #1b4d2e;
    --success-text: #a3cfbb;
    --error-bg: #5a1e22;
    --error-text: #ea868f;
}

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

/* Remove arrows in Chrome/Safari/Edge */
input[type="number"]::-webkit-outer-spin-button,
input[type="number"]::-webkit-inner-spin-button {
    -webkit-appearance: none;
    margin: 0;
}

/* Remove arrows in Firefox */
input[type="number"] {
    -moz-appearance: textfield;
}

body {
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
    background-color: var(--bg-color);
    color: var(--text-color);
    line-height: 1.6;
    transition: background-color 0.3s ease, color 0.3s ease;
    padding: var(--spacing-md);
    min-height: 100vh;
    display: flex;
    flex-direction: column;
    align-items: center;
}

/* Typography */
.logo {
    font-family: 'Fredoka', sans-serif;
    font-size: 2.5rem;
    font-weight: 700;
    margin: 0;
    line-height: 1.2;
    letter-spacing: -0.5px;
    display: inline-flex;
    align-items: center;
}

.logo-primary {
    color: var(--primary-color);
}

.logo-secondary {
    color: var(--accent-color);
    position: relative;
}

/* Add a subtle shine/gradient effect */
.logo-secondary::after {
    content: '';
    position: absolute;
    top: 50%;
    left: 50%;
    width: 120%;
    height: 120%;
    background: radial-gradient(circle, rgba(255, 107, 107, 0.2) 0%, transparent 70%);
    transform: translate(-50%, -50%);
    z-index: -1;
    border-radius: 50%;
}

@media (min-width: 600px) {
    .logo {
        font-size: 3.5rem;
    }
}

p {
    color: var(--text-light);
    font-size: 0.95rem;
}

/* Header */
header {
    width: 100%;
    max-width: 800px;
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: var(--spacing-lg);
    padding: var(--spacing-sm);
}

.controls {
    display: flex;
    gap: var(--spacing-sm);
}

button.icon-btn {
    background: var(--card-bg);
    border: 1px solid var(--border-color);
    border-radius: 50%;
    width: 40px;
    height: 40px;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    color: var(--text-color);
    font-size: 1.2rem;
    transition: all 0.2s ease;
    box-shadow: var(--shadow-sm);
}

button.icon-btn:hover {
    transform: translateY(-2px);
    box-shadow: var(--shadow-md);
    border-color: var(--primary-color);
}

/* Layout Container */
.game-container {
    width: 100%;
    max-width: 900px;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: var(--spacing-lg);
}

/* Instructions Card */
.instructions {
    background: var(--card-bg);
    padding: var(--spacing-sm);
    border-radius: var(--border-radius);
    box-shadow: var(--shadow-sm);
    width: 100%;
    max-width: 600px;
    text-align: center;
    border: 1px solid var(--border-color);
}

.btn-text {
    background: none;
    border: none;
    color: var(--primary-color);
    font-size: 1rem;
    font-weight: 600;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    width: 100%;
    padding: 8px;
}

.rules-content {
    margin-top: 8px;
    overflow: hidden;
    transition: max-height 0.3s ease-out;
}

.rules-content.hidden {
    display: none;
}

/* Game Board Grid */
.board {
    display: grid;
    grid-template-columns: repeat(2, 1fr); /* Mobile: 2 columns */
    gap: var(--spacing-sm);
    width: 100%;
    padding: 0 4px; /* Tiny padding on edges */
}

/* Tablet Breakpoint */
@media (min-width: 600px) {
    .board {
        grid-template-columns: repeat(3, 1fr); /* Tablet: 3 columns */
        gap: var(--spacing-md);
    }

    .bank-cell {
        flex: 0 0 56px;
    }

    .bank-cell input {
        height: 56px;
        font-size: 1.2rem;
    }
}

/* Desktop Breakpoint */
@media (min-width: 1024px) {
    .board {
        grid-template-columns: repeat(4, 1fr); /* Desktop: 4 columns */
    }
}

/* Game Cell */
.cell {
    background: var(--card-bg);
    border-radius: var(--border-radius);
    padding: var(--spacing-sm); /* Reduced padding */
    box-shadow: var(--shadow-md);
    display: flex;
    flex-direction: column;
    gap: 4px; /* Reduced gap */
    border: 2px solid transparent;
    transition: transform 0.2s ease, box-shadow 0.2s ease;
}

.cell:hover {
    transform: translateY(-2px);
    box-shadow: var(--shadow-lg);
}

.target-number {
    font-size: 1.25rem; /* Smaller on mobile */
    font-weight: 700;
    color: var(--primary-color);
    text-align: center;
    padding-bottom: 4px;
    border-bottom: 1px solid var(--bg-color); /* Thinner border */
}

/* Equation Inputs */
.equation {
    display: flex;
    gap: 2px; /* Tighter gap */
    align-items: center;
}

.equation input, .equation select {
    width: 100%;
    height: 40px; /* Slightly smaller height */
    border: 1px solid var(--border-color);
    border-radius: 6px;
    text-align: center;
    font-size: 0.9rem; /* Smaller font */
    background: var(--input-bg);
    color: var(--text-color);
    outline: none;
    padding: 0; /* Remove default padding */
    transition: border-color 0.2s;
    -moz-appearance: textfield;
}

.equation input:focus, .equation select:focus, .bank-cell input:focus {
    border-color: var(--primary-color);
    box-shadow: 0 0 0 3px rgba(74, 144, 226, 0.1);
}

/* Number Bank */
.number-bank {
    display: flex;
    flex-wrap: wrap;
    gap: 8px; /* Slightly more gap for clarity */
    justify-content: center;
    background: var(--card-bg);
    padding: var(--spacing-md);
    border-radius: var(--border-radius);
    box-shadow: var(--shadow-md);
    width: 100%;
    max-width: 600px;
}

.bank-cell {
    flex: 0 0 44px; /* Smaller fixed width for mobile */
    position: relative; /* For potential future styling */
}

.bank-cell input {
    width: 100%;
    height: 44px;
    border: 1px solid var(--border-color);
    border-radius: 50%; /* Make them circular or very rounded */
    text-align: center;
    font-size: 1.1rem;
    font-weight: bold;
    background: var(--input-bg);
    color: var(--text-color);
    padding: 0;
    transition: all 0.2s ease;
    box-shadow: var(--shadow-sm);
}

.bank-cell input:focus {
    transform: translateY(-2px);
    box-shadow: var(--shadow-md);
    background: #ffffff;
}

.bank-cell input.fixed-number {
    background-color: var(--bg-color);
    color: var(--primary-dark);
    font-weight: 900;
    cursor: default;
    border: 2px solid var(--border-color);
}

.bank-cell input.fixed-number:focus {
    box-shadow: none;
    transform: none;
    border-color: var(--border-color);
}

/* Actions */
.actions {
    display: flex;
    flex-wrap: wrap;
    justify-content: center;
    gap: 16px;
    width: 100%;
    margin-top: var(--spacing-md);
}

.btn-check {
    background: linear-gradient(135deg, var(--secondary-color), var(--primary-color));
    color: white;
    border: none;
    padding: 14px 32px; /* Slightly smaller padding */
    font-size: 1rem;
    font-weight: bold;
    border-radius: 50px;
    cursor: pointer;
    box-shadow: var(--shadow-md);
    transition: transform 0.2s, box-shadow 0.2s;
    min-width: 200px;
}

.btn-check:hover {
    transform: translateY(-2px);
    box-shadow: var(--shadow-lg);
    filter: brightness(1.1);
}

.btn-check:active {
    transform: scale(0.98);
}

.btn-secondary {
    background: transparent;
    color: var(--primary-color);
    border: 2px solid var(--primary-color);
    padding: 12px 24px;
    font-size: 1rem;
    font-weight: bold;
    border-radius: 50px;
    cursor: pointer;
    box-shadow: var(--shadow-sm);
    transition: all 0.2s;
    min-width: 160px;
}

.btn-secondary:hover {
    background: var(--primary-color);
    color: white;
    transform: translateY(-2px);
    box-shadow: var(--shadow-md);
}

.btn-secondary:active {
    transform: scale(0.98);
}

/* Messages */
#message {
    min-height: 24px;
    font-weight: 600;
    text-align: center;
    padding: var(--spacing-sm);
    border-radius: var(--border-radius);
    width: 100%;
    margin-top: var(--spacing-md);
}

.msg-info {
    color: var(--info-text);
    background-color: var(--info-bg);
    border: 1px solid var(--info-text);
}

.msg-success {
    color: var(--success-text);
    background-color: var(--success-bg);
    border: 1px solid var(--success-text);
}

.msg-error {
    color: var(--error-text);
    background-color: var(--error-bg);
    border: 1px solid var(--error-text);
}

/* Validation Styles Override */
.cell.success {
    background-color: var(--success-bg) !important;
    border-color: var(--success-text);
}

.cell.error {
    background-color: var(--error-bg) !important;
    border-color: var(--error-text);
}
