@keyframes spin {
    0% {
        transform: translate(-50%, -50%) rotate(0deg);
    }

    100% {
        transform: translate(-50%, -50%) rotate(360deg);
    }
}

.cell.loading {
    position: relative;
    pointer-events: none;
    opacity: 0.6;
}

.cell.loading::after {
    content: "";
    position: absolute;
    top: 50%;
    left: 50%;
    width: 20px;
    height: 20px;
    border: 3px solid rgba(0, 0, 0, 0.15);
    border-top-color: #00979D;
    border-radius: 50%;
    animation: spin 0.7s linear infinite;
    transform: translate(-50%, -50%);
}

:root {
    --arduino-blue: #00979D;
    --arduino-blue-light: #4fbfc3;
    --led-off-gray: #e5e5e7;
    --led-off-border: #c7c7cc;
    --led-on-red: #d32f2f;
    --led-on-red-border: #b71c1c;
    --text-primary: #1d1d1f;
    --text-secondary: #6e6e73;
}

body {
    margin: 0;
    padding: 0;
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
    background: #f9f9fb;
    color: var(--text-primary);
    display: flex;
    flex-direction: column;
    align-items: center;
    -webkit-font-smoothing: antialiased;
}

h2 {
    margin-top: 32px;
    font-size: 28px;
    font-weight: 800;
    text-align: center;
    letter-spacing: -0.01em;
    color: var(--arduino-blue);
}

.grid-wrapper {
    margin-top: 22px;
    padding: 16px;
    background: #ffffff;
    border-radius: 22px;
    border: 1px solid #e5e5e7;
    width: min(94%, 460px);
}

.grid {
    display: grid;
    grid-template-columns: repeat(12, 1fr);
    gap: 6px;
}

.cell {
    width: 100%;
    padding-top: 100%;
    position: relative;
    border-radius: 10px;
    border: 1px solid var(--led-off-border);
    cursor: pointer;
    background: var(--led-off-gray);
    transition: background 0.15s ease, transform 0.1s ease, border-color 0.15s ease;
}

.cell span {
    position: absolute;
    inset: 0;
    display: flex;
    justify-content: center;
    align-items: center;
    font-size: 11px;
    color: var(--text-secondary);
    font-weight: 600;
    pointer-events: none;
}

.cell:active {
    transform: scale(0.94);
}

.on {
    background: var(--led-on-red);
    border-color: var(--led-on-red-border);
}

.on span {
    color: #ffffff;
}

button.clear-btn,
button.refresh-btn,
button.mode-btn {
    margin-top: 20px;
    padding: 14px 28px;
    font-size: 17px;
    font-weight: 600;
    border: none;
    border-radius: 14px;
    cursor: pointer;
    color: #ffffff;
    transition: background 0.2s, transform 0.1s;
}

button.refresh-btn {
    background: var(--arduino-blue);
}

button.clear-btn {
    background: #C13A22;
}

button.clear-btn:hover {
    background: var(--arduino-blue-light);
}

button.clear-btn:active {
    transform: scale(0.95);
}

button.mode-btn {
    background: #00979D;
}

button.mode-btn.timer {
    background: #2d7dc7;
}