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

:root {
    --bg-color: #ffffff;
    --text-color: #333333;
    --nav-bg: #f8f9fa;
    --sidebar-bg: #ffffff;
    --selected-item: #0f0f0f;
    --selected-text: #f5f5f5;
    --correct-item-bg: #4CAF50;
    --correct-item-hover: #45a049;
    --border-color: #dee2e6;
    --hover-color: #007bff;
    --button-text: #0a0c0a;
}

body.dark-mode {
    --bg-color: #333333;
    --text-color: #ffffff;
    --nav-bg: #222222;
    --sidebar-bg: #2c2c2c;
    --selected-item: #b1a3a3;
    --selected-text: #0f0f0f;
    --border-color: #444444;
    --hover-color: #66b0ff;
}

body {
    font-family: Arial, sans-serif;
    min-height: 100vh;
    display: flex;
    flex-direction: column;
    background-color: var(--bg-color);
    color: var(--text-color);
    transition: all 0.3s ease;
}

a { color: var(--hover-color); }

.navbar {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 1rem;
    background-color: var(--nav-bg);
    box-shadow: 0 2px 4px rgba(0, 0, 0, 0.1);
}

.left-section, .right-section { display: flex; align-items: center; gap: 12px; }

.all-quizzes {
    color: var(--text-color);
    text-decoration: none;
    font-size: 14px;
    white-space: nowrap;
}
.all-quizzes:hover { color: var(--hover-color); }

.help-menu, .settings-menu {
    cursor: pointer;
    width: 30px;
    height: 24px;
    display: flex;
    align-items: center;
    justify-content: center;
}
.help-menu i, .settings-menu i { font-size: 24px; color: var(--text-color); }

.title-container { width: 50%; text-align: center; }
.title {
    font-size: 1.5rem;
    font-weight: bold;
    color: var(--text-color);
    text-decoration: none;
}

.sidebar {
    position: fixed;
    top: 0;
    height: 100vh;
    width: 300px;
    background-color: var(--sidebar-bg);
    box-shadow: 2px 0 5px rgba(0, 0, 0, 0.1);
    transition: 0.3s;
    z-index: 1000;
    padding: 1rem;
    color: var(--text-color);
    overflow: auto;
}
.help-sidebar { left: -300px; }
.right-sidebar { right: -300px; width: 250px; }
.help-sidebar.active { left: 0; }
.right-sidebar.active { right: 0; }

.overlay {
    position: fixed;
    top: 0; left: 0;
    width: 100%; height: 100%;
    background-color: rgba(0, 0, 0, 0.5);
    display: none;
    z-index: 999;
}
.overlay.active { display: block; }

.sidebar-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 1rem;
    padding-bottom: 1rem;
    border-bottom: 1px solid var(--border-color);
}

.close-button {
    background: none;
    border: none;
    font-size: 1.5rem;
    cursor: pointer;
    padding: 0.5rem;
    color: var(--text-color);
}

.help-content { padding: 1rem; line-height: 1.6; }
.help-content p { margin-bottom: 0.8rem; }

.content { flex: 1; padding: 0 1rem; background-color: var(--bg-color); }

#practiceBanner {
    max-width: 600px;
    margin: 12px auto 0;
    padding: 6px 10px;
    text-align: center;
    font-size: 14px;
    border: 1px solid var(--border-color);
    border-radius: 5px;
    color: var(--text-color);
}

.grid-container {
    width: 100%;
    max-width: 600px;
    margin: 20px auto;
    touch-action: manipulation;
}

.grid-row {
    border: 1px solid var(--border-color);
    padding: 1px;
    background-color: var(--bg-color);
    min-height: 44px;
    display: flex;
}

.grid-item {
    border: 1px solid var(--border-color);
    padding: 12px;
    margin: 1%;
    cursor: pointer;
    user-select: none;
    -webkit-user-select: none;
    height: 62px;
    display: flex;
    align-items: center;
    justify-content: center;
    background-color: var(--bg-color);
    font-size: 24px;
    font-weight: bold;
    transition: background-color 0.3s;
    flex: 0 0 31%;
    touch-action: manipulation;
}

.grid-item.correct { background-color: var(--correct-item-bg); color: var(--button-text); }
.grid-item.selected { background-color: var(--selected-item); color: var(--selected-text); }
.grid-item.disabled { cursor: not-allowed; opacity: 0.85; }

.text-center { text-align: center; }
.mt-3 { margin-top: 1rem; }
.button-container {
    display: flex;
    justify-content: center;
    align-items: center;
    height: 50px;
    font-size: 18px;
}

.toggle-container {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin: 1rem 0;
    padding: 0.5rem;
}

.switch { position: relative; display: inline-block; width: 60px; height: 34px; }
.switch input { opacity: 0; width: 0; height: 0; }
.slider {
    position: absolute; cursor: pointer;
    top: 0; left: 0; right: 0; bottom: 0;
    background-color: #ccc; transition: .4s; border-radius: 34px;
}
.slider:before {
    position: absolute; content: "";
    height: 26px; width: 26px; left: 4px; bottom: 4px;
    background-color: white; transition: .4s; border-radius: 50%;
}
input:checked + .slider { background-color: #2196F3; }
input:checked + .slider:before { transform: translateX(26px); }

.modal-overlay {
    display: none;
    position: fixed;
    top: 0; left: 0;
    width: 100%; height: 100%;
    background-color: rgba(0, 0, 0, 0.4);
    z-index: 1000;
}

.modal-content {
    position: fixed;
    top: 50%; left: 50%;
    transform: translate(-50%, -50%);
    color: var(--text-color);
    padding: 20px;
    border-radius: 10px;
    box-shadow: 0 2px 10px rgba(0, 0, 0, 0.3);
    max-width: 90%;
    width: 400px;
    z-index: 1001;
    background-color: var(--sidebar-bg);
}

.modal-header { font-size: 24px; font-weight: bold; margin-bottom: 20px; color: var(--correct-item-bg); }

#statistics { display: flex; }
.statistic-container { flex: 1; }
.statistic-container .statistic {
    font-size: 36px;
    display: flex; align-items: center; justify-content: center;
}
.statistic-container .label {
    font-size: 12px;
    display: flex; align-items: center; justify-content: center; text-align: center;
}

.countdown {
    font-size: 18px;
    margin: 15px 0;
    color: var(--text-color);
    min-width: 50%;
    text-align: right;
    font-weight: bold;
}

.model-row { display: flex; width: 100%; }

#winSteps {
    font-family: inherit;
    font-size: 20px;
    line-height: 1.3;
    margin: 0;
    white-space: pre-wrap;
}

.share-button {
    background-color: var(--correct-item-bg);
    color: var(--button-text);
    border: none;
    padding: 10px 20px;
    border-radius: 5px;
    cursor: pointer;
    font-size: 16px;
    margin-top: 15px;
    transition: background-color 0.3s;
}
.share-button:hover { background-color: var(--correct-item-hover); }

.close-modal {
    position: absolute;
    top: 10px; right: 10px;
    cursor: pointer;
    font-size: 20px;
    font-weight: bold;
    color: var(--text-color);
}

.footer {
    background-color: var(--nav-bg);
    padding: 1rem;
    text-align: center;
    box-shadow: 0 -2px 4px rgba(0, 0, 0, 0.1);
}
.footer a { color: var(--text-color); }

/* Temporary yellow marks, separate from a selected swap or a green solved row. */
.grid-item.try-mark { background-color: #f8b705; color: #0f0f0f; }
.button-container { justify-content: space-between; gap: 20px; }
.try-control { display: inline-flex; gap: 10px; align-items: center; cursor: pointer; }
.try-control[hidden], .try-hint[hidden] { display: none; }
.try-hint { text-align: center; font-size: 14px; line-height: 1.5; margin: 8px 0 0; }
input:focus-visible + .slider { outline: 2px solid var(--text-color); outline-offset: 3px; }
