body {
    background-color: #111;
    display: flex;
    flex-direction: column;
    justify-content: center;
    align-items: center;
    min-height: 100vh;
    margin: 0;
    font-family: sans-serif;
    color: white;
}

:root {
    --sand-colour: #ffff00;
}

.hourglass-container {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 80px;
    position: relative;
    margin-bottom: 30px;
}

.grid {
    display: grid;
    grid-template-columns: repeat(8, 20px);
    grid-template-rows: repeat(8, 20px);
    gap: 2px;
    padding: 8px;
    background: #222;
    transform: rotate(45deg);
    border: 4px solid #fff;
}

.pixel {
    width: 20px;
    height: 20px;
    background-color: #333;
    transition: background-color 0.1s;
}

.pixel.on {
    background-color: var(--sand-colour);
    box-shadow: 0 0 10px var(--sand-colour);
}

.falling-grain {
    position: absolute;
    width: 18px;
    height: 18px;
    background-color: var(--sand-colour);
    box-shadow: 0 0 10px var(--sand-colour);
    z-index: 10;
    display: none;
    transform: rotate(45deg);
}

.controls {
    background: #222;
    padding: 20px;
    border-radius: 10px;
    text-align: center;
    width: 320px;
    border: 1px solid #444;
    margin-top: 10vh;
}

input, select {
    padding: 10px;
    margin: 5px;
    border-radius: 4px;
    border: none;
    background: #333;
    color: white;
}

input:focus-visible,
select:focus-visible,
button:focus-visible {
    outline: 2px solid var(--sand-colour);
    outline-offset: 2px;
}

.btn-row {
    display: flex;
    gap: 10px;
    margin-top: 10px;
}

button {
    flex: 1;
    padding: 12px;
    border: none;
    font-weight: bold;
    cursor: pointer;
    border-radius: 5px;
}

button:disabled {
    opacity: 0.55;
    cursor: not-allowed;
}

#startBtn { background: var(--sand-colour); color: #000; }
#resetBtn { background: #444; color: #fff; }
#settingsBtn { background: #333; color: #ccc; border: 1px solid #444; }

#countdown {
    font-size: 1.5rem;
    color: var(--sand-colour);
    margin-top: 15px;
    font-family: monospace;
}

.status-message {
    min-height: 1.2em;
    margin-top: 10px;
    font-size: 0.9rem;
}

.status-error {
    color: #ff6b6b;
}

.status-success {
    color: #7CFC00;
}

.status-info {
    color: #ccc;
}

.modal-overlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.85);
    display: flex;
    justify-content: center;
    align-items: center;
    z-index: 1000;
}

.modal-content {
    background: #222;
    padding: 30px;
    border-radius: 12px;
    border: 1px solid #444;
    width: 300px;
    text-align: left;
}

.modal-content h2 {
    margin-top: 0;
    border-bottom: 1px solid #444;
    padding-bottom: 10px;
}

.setting-group {
    margin: 20px 0;
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.modal-actions {
    display: flex;
    gap: 10px;
    margin-top: 20px;
}

.secondary-btn {
    background: #444 !important;
    color: white !important;
}

.hidden {
    display: none !important;
}
