body {
    font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;
    background-color: #ffffff;
    color: #121213;
    margin: 0;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    min-height: 100vh;
    padding: 10px;
}

header {
    width: 100%;
    max-width: 420px;
    border-bottom: 1px solid #3a3a3c;
    padding: 12px 0;
    margin-bottom: 16px;
}

h1 {
    text-align: center;
    font-size: 36px;
    font-weight: 700;
    letter-spacing: 0.2rem;
}

.game-container {
    display: flex;
    flex-direction: column;
    align-items: center;
    width: 100%;
    max-width: 420px;
}

.stats {
    display: flex;
    justify-content: space-between;
    width: 100%;
    margin-bottom: 16px;
    font-size: 1.2rem;
    color: #555;
    font-weight: 600;
}

.settings-menu {
    width: 100%;
    background-color: #f8f9fa;
    border: 2px solid #e9ecef;
    border-radius: 12px;
    padding: 12px 16px;
    margin-bottom: 16px;
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.settings-title {
    margin: 0;
    font-size: 1rem;
    font-weight: 700;
    letter-spacing: 0.08em;
    text-transform: uppercase;
    color: #333;
    text-align: center;
}

.settings-row {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
}

.settings-label {
    font-size: 0.95rem;
    font-weight: 600;
    color: #555;
}

.settings-select {
    font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;
    font-size: 0.95rem;
    font-weight: 600;
    color: #333;
    background-color: #ffffff;
    border: 2px solid #ccc;
    border-radius: 6px;
    padding: 6px 10px;
    cursor: pointer;
    transition: border-color 0.2s ease, box-shadow 0.2s ease;
}

.settings-select:hover,
.settings-select:focus {
    border-color: #2ecc71;
    outline: none;
    box-shadow: 0 0 0 3px rgba(46, 204, 113, 0.2);
}

.canvas-wrapper {
    width: 100%;
    display: flex;
    justify-content: center;
    align-items: center;
    margin-bottom: 16px;
}

#snake-canvas {
    background-color: #f8f9fa;
    border: 3px solid #3a3a3c;
    border-radius: 12px;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.1);
    max-width: 100%;
    height: auto;
    touch-action: none;
}

.controls-dpad {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 6px;
    margin-top: 8px;
    margin-bottom: 8px;
}

.dpad-row {
    display: flex;
    gap: 12px;
}

.dpad-btn {
    width: 52px;
    height: 52px;
    font-size: 1.2rem;
    font-weight: bold;
    background-color: #f0f0f0;
    color: #333;
    border: 2px solid #ccc;
    border-radius: 8px;
    cursor: pointer;
    user-select: none;
    transition: background-color 0.15s, transform 0.1s;
    display: flex;
    align-items: center;
    justify-content: center;
}

.dpad-btn:active {
    background-color: #ddd;
    transform: scale(0.95);
}

.restart-button {
    margin-top: 16px;
    padding: 12px 24px;
    font-size: 1rem;
    font-weight: 700;
    letter-spacing: 0.04em;
    text-transform: uppercase;
    background-color: #2ecc71;
    color: white;
    border: none;
    border-radius: 6px;
    cursor: pointer;
    box-shadow: 0 2px 6px rgba(0, 0, 0, 0.12);
    transition: background-color 0.2s ease, transform 0.1s ease, box-shadow 0.2s ease;
}

.restart-button:hover {
    background-color: #27ae60;
    box-shadow: 0 4px 10px rgba(0, 0, 0, 0.16);
}

.restart-button:active {
    transform: translateY(1px);
}

.restart-button:disabled {
    background-color: #95a5a6;
    cursor: not-allowed;
    box-shadow: none;
}

.restart-button:disabled:hover {
    background-color: #95a5a6;
    box-shadow: none;
}

.restart-button:focus-visible {
    outline: 3px solid rgba(46, 204, 113, 0.35);
    outline-offset: 2px;
}

.message {
    position: fixed;
    top: 20px;
    background-color: #333;
    color: #ffffff;
    padding: 16px 32px;
    border-radius: 6px;
    font-weight: 700;
    font-size: 1.25rem;
    opacity: 0;
    pointer-events: none;
    transition: opacity 0.3s;
    z-index: 1000;
    text-align: center;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.2);
}

.message.show {
    opacity: 1;
}

.message.win {
    background-color: #538d4e;
    color: #ffffff;
}

.message.lose {
    background-color: #e74c3c;
    color: #ffffff;
}

.nav-toggle {
    display: none;
    position: fixed;
    top: 20px;
    left: 20px;
    z-index: 1300;
    border: none;
    border-radius: 6px;
    padding: 2px 6px;
    background: transparent;
    color: #2196F3;
    font-size: 2rem;
    font-weight: 600;
    cursor: pointer;
}

#current-page {
    color: #246daf;
}

.sidenav-wrapper {
    width: 200px;
    position: fixed;
    z-index: 1;
    top: 20px;
    left: 20px;
}

.sidenav {
    width: 200px;
    background: #eee;
    overflow-x: hidden;
    padding: 8px 0;
}

.sidenav a {
    padding: 6px 8px 6px 16px;
    text-decoration: none;
    font-size: 19px;
    color: #2196F3;
    display: block;
}

.sidenav a:hover {
    color: #064579;
}

@media (max-width: 768px) {
    .nav-toggle {
        display: block;
    }

    .sidenav-wrapper {
        top: 0;
        left: 0;
        height: 100%;
        padding-top: 72px;
        transform: translateX(-110%);
        z-index: 1200;
        transition: transform 0.2s ease;
    }

    .sidenav {
        box-shadow: 2px 0 12px rgba(0, 0, 0, 0.15);
    }

    .sidenav-wrapper.is-open {
        transform: translateX(0);
    }
}

/* Dark mode */
html.dark-mode body {
    background-color: #121213;
    color: #ffffff;
}

html.dark-mode .stats,
html.dark-mode .settings-label {
    color: #aaaaaa;
}

html.dark-mode .settings-menu {
    background-color: #1e1f22;
    border-color: #333;
}

html.dark-mode .settings-title {
    color: #dddddd;
}

html.dark-mode .settings-select {
    background-color: #121213;
    color: #eeeeee;
    border-color: #555;
}

html.dark-mode #snake-canvas {
    background-color: #1e1f22;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.45);
}

html.dark-mode .dpad-btn {
    background-color: #333;
    color: #eeeeee;
    border-color: #555;
}

html.dark-mode .dpad-btn:active {
    background-color: #444;
}

html.dark-mode .sidenav {
    background: #222;
}

html.dark-mode .sidenav a:hover {
    color: #7ab8ff;
}

html.dark-mode #current-page {
    color: #5aa9e6;
}
