:root {
    --primary-color: #8ab4f8;
    --primary-dark: #4285f4;
    --bg-light: #f8f9fa;
    --bg-dark: #1a1a1a;
    --text-light: #202124;
    --text-dark: #e8eaed;
    --surface-light: #ffffff;
    --surface-dark: #2d2d2d;
    --border-light: #dadce0;
    --border-dark: #3c4043;
    --accent-light: #f1f3f4;
    --accent-dark: #303134;
}

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

body {
    font-family: 'Font', 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;
    background: linear-gradient(135deg, var(--bg-light), var(--accent-light));
    color: var(--text-light);
    padding: 20px;
    display: flex;
    flex-direction: column;
    align-items: center;
    min-height: 100vh;
    transition: all 0.3s ease;
}

@media (prefers-color-scheme: dark) {
    body {
        background: linear-gradient(135deg, var(--bg-dark), var(--accent-dark));
        color: var(--text-dark);
    }
}

.controls {
    display: flex;
    gap: 24px;
    margin-bottom: 3px;
    flex-wrap: wrap;
    justify-content: center;
    align-items: center;
}

@media (prefers-color-scheme: dark) {
    /*.controls {
        background: var(--surface-dark);
        border-color: var(--border-dark);
        box-shadow: 0 4px 24px rgba(0, 0, 0, 0.3);
    }*/
}

.control-group {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 8px;
}

.control-group label {
    font-weight: 600;
    font-size: 0.9em;
    opacity: 0.8;
}

input[type="number"] {
    width: 70px;
    padding: 12px;
    border: 2px solid var(--border-light);
    border-radius: 8px;
    text-align: center;
    font-size: 16px;
    background: var(--accent-light);
    color: var(--text-light);
    transition: all 0.3s ease;
}

input[type="number"]:disabled {
    opacity: 0.5;
    cursor: not-allowed;
    background: var(--accent-light);
    color: var(--text-light);
}

input[type="number"]:focus:not(:disabled) {
    outline: none;
    border-color: var(--primary-color);
    box-shadow: 0 0 0 3px rgba(138, 180, 248, 0.2);
}

@media (prefers-color-scheme: dark) {
    input[type="number"] {
        background: var(--accent-dark);
        color: var(--text-dark);
        border-color: var(--border-dark);
    }

    input[type="number"]:disabled {
        background: var(--accent-dark);
        color: var(--text-dark);
    }
}

input[type="color"] {
    width: 30px;
    height: 30px;
    border: 2px solid var(--border-light);
    cursor: pointer;
    transition: all 0.3s ease;
}

input[type="color"]:hover {
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.2);
}

@media (prefers-color-scheme: dark) {
    input[type="color"] {
        border-color: var(--border-dark);
    }
}

.reset {
    padding: 12px 20px;
    background: linear-gradient(45deg, #ff6b6b, #ee5a52);
    color: white;
    border: none;
    border-radius: 8px;
    cursor: pointer;
    font-size: 16px;
    font-weight: 600;
    transition: all 0.3s ease;
    opacity: 0.3;
}

.reset:hover {
    transform: translateY(-2px);
    box-shadow: 0 6px 16px rgba(238, 90, 82, 0.3);
}

.debug-info {
    background: linear-gradient(45deg, var(--primary-color), var(--primary-dark));
    color: white;
    padding: 12px 16px;
    border-radius: 8px;
    font-size: 0.85em;
    font-weight: 500;
    box-shadow: 0 2px 8px rgba(138, 180, 248, 0.3);
}

.status {
    display: flex;
    gap: 24px;
    margin-bottom: 10px;
    text-align: center;
    flex-wrap: wrap;
    justify-content: center;
}

#rate-limit-status {
    color: var(--primary-color);
    font-weight: 600;
    font-size: 0.8rem;
    transition: all 0.3s ease;
}

#rate-limit-status.can-paint {
    background: linear-gradient(45deg, var(--primary-color), var(--primary-dark));
    box-shadow: 0 4px 16px rgba(138, 180, 248, 0.3);
}

#pixel-count {
    background: linear-gradient(45deg, #4ecdc4, #44a08d);
    color: white;
    padding: 12px 20px;
    border-radius: 12px;
    font-weight: 600;
    font-size: 0.95em;
    box-shadow: 0 4px 16px rgba(78, 205, 196, 0.3);
}

.container {
    display: grid;
    grid-template-rows: repeat(var(--sizeofgridr), 1fr);
    grid-template-columns: repeat(var(--sizeofgridc), 1fr);
    gap: 0;
    background: rgba(138, 180, 248, 0.1);
    backdrop-filter: blur(20px);
    -webkit-backdrop-filter: blur(20px);
    padding: 12px;
    border-radius: 20px;
    box-shadow: 0 8px 32px rgba(138, 180, 248, 0.3);
    border: 2px solid rgba(138, 180, 248, 0.2);
    max-width: 90vw;
    max-height: 70vh;
    margin-bottom: 30px;
    position: relative;
    overflow: hidden;
}

/* only for this size of grid*/
.pixel[data-pixel-index="19"] {
    border-top-right-radius: inherit;
}

.pixel[data-pixel-index="380"] {
    border-bottom-left-radius: inherit;
}

.pixel[data-pixel-index="399"] {
    border-bottom-right-radius: inherit;
}

.pixel[data-pixel-index="0"] {
    border-top-left-radius: inherit;
}

.container::before {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: linear-gradient(45deg, var(--primary-color), var(--primary-dark));
    opacity: 0.05;
    border-radius: inherit;
    z-index: -1;
}

@media (prefers-color-scheme: dark) {
    .container {
        background: rgba(138, 180, 248, 0.08);
        border-color: rgba(138, 180, 248, 0.15);
        box-shadow: 0 8px 32px rgba(138, 180, 248, 0.2);
    }
}

.pixel {
    width: 20px;
    height: 20px;
    background-color: #f8f9fa;
    cursor: pointer;
    transition: all 0.15s cubic-bezier(0.4, 0, 0.2, 1);
    border: none;
    position: relative;
    aspect-ratio: 1;
}

.pixel:hover {
    transform: scale(1.1);
    z-index: 10;
    box-shadow:
        0 0 0 1px rgba(138, 180, 248, 1),
        0 2px 8px rgba(138, 180, 248, 1);
    filter: brightness(1.1);
    border: 1px solid rgba(138, 180, 248, 1);
}

/*.pixel.painted {
    box-shadow:
        inset 0 1px 2px rgba(0, 0, 0, 0.1),
        0 0 0 0.5px rgba(0, 0, 0, 0.1);
}*/

.pixel.painted:hover {
    box-shadow:
        inset 0 1px 2px rgba(0, 0, 0, 0.1),
        0 0 0 1px rgba(138, 180, 248, 0.6),
        0 2px 8px rgba(138, 180, 248, 0.3);
}


@media (prefers-color-scheme: dark) {
    .pixel {
        background-color: #2d2d2d;
    }

    /*.pixel.painted {
        box-shadow:
            inset 0 1px 2px rgba(255, 255, 255, 0.05),
            0 0 0 0.5px rgba(255, 255, 255, 0.1);
    }*/

    .pixel.painted:hover {
        box-shadow:
            inset 0 1px 2px rgba(255, 255, 255, 0.05),
            0 0 0 1px rgba(138, 180, 248, 0.6),
            0 2px 8px rgba(138, 180, 248, 0.3);
    }
}

.explanation {
    max-width: 600px;
    text-align: center;
    background: var(--surface-light);
    padding: 24px;
    border-radius: 16px;
    box-shadow: 0 4px 24px rgba(0, 0, 0, 0.1);
    border: 1px solid var(--border-light);
    margin-bottom: 30px;
}

@media (prefers-color-scheme: dark) {
    .explanation {
        background: var(--surface-dark);
        border-color: var(--border-dark);
        box-shadow: 0 4px 24px rgba(0, 0, 0, 0.3);
    }
}

.explanation h3 {
    font-size: 1.4em;
    font-weight: 600;
    margin-bottom: 12px;
    color: var(--primary-color);
}

.explanation p {
    font-size: 1.05em;
    line-height: 1.6;
    opacity: 0.9;
    margin-bottom: 20px;
}

.features {
    display: flex;
    gap: 16px;
    justify-content: center;
    flex-wrap: wrap;
}

.feature {
    background: var(--accent-light);
    padding: 8px 16px;
    border-radius: 20px;
    font-size: 0.9em;
    font-weight: 500;
    border: 1px solid var(--border-light);
    transition: all 0.3s ease;
}

.feature:hover {
    background: var(--primary-color);
    color: white;
    transform: translateY(-2px);
    box-shadow: 0 4px 12px rgba(138, 180, 248, 0.3);
}

.explainer {
    color: var(--text-light);
    font-size: 1.15em;
    margin-bottom: 10px;
    text-align: center;
}

@media (prefers-color-scheme: dark) {
    .feature {
        background: var(--accent-dark);
        border-color: var(--border-dark);
    }

    .explainer {
        color: var(--text-dark);
    }
}

@media (max-width: 768px) {
    .controls {
        flex-direction: column;
        gap: 16px;
    }

    .pixel {
        width: 15px;
        height: 15px;
    }

    .pixel:hover {
        transform: scale(1.1);
    }

    .container {
        padding: 8px;
    }

    .header h1 {
        font-size: 2.2em;
    }

    .explainer {
        font-size: 1em;
    }

    .features {
        gap: 12px;
    }
}

@media (max-width: 480px) {
    .pixel {
        width: 12px;
        height: 12px;
    }

    .pixel:hover {
        transform: scale(1.02);
        box-shadow:
            0 0 0 0.5px rgba(138, 180, 248, 0.6),
            0 1px 4px rgba(138, 180, 248, 0.3);
    }

    .container {
        padding: 6px;
        border-radius: 16px;
    }

    .status {
        flex-direction: column;
        gap: 12px;
    }

    .header h1 {
        font-size: 2em;
    }

    .explanation {
        padding: 16px;
    }

    .features {
        flex-direction: column;
        align-items: center;
    }

    .feature {
        min-width: 120px;
    }
}