#snake-game-container {
    display: flex;
    flex-direction: column;
    align-items: center;
    background-color: #ffffff;
    padding: 20px;
    border-radius: 10px;
    max-width: 600px;
    margin: 0 auto 40px;
    box-shadow: 0 4px 8px rgba(0, 0, 0, 0.1);
}

#game-title {
    color: #2E7D32;
    margin-bottom: 0;
    margin-top: 0;
    font-size: 26px;
}

#tab-container {
    display: flex;
    width: 100%;
    border-bottom: 2px solid #e5e7eb;
    margin-top: 15px;
    justify-content: center;
    gap: 6px;
}

.tab-button {
    padding: 5px 16px;
    cursor: pointer;
    border: none;
    background: #f3f4f6;
    font-size: 17px;
    font-weight: 500;
    color: #374151;
    border-radius: 8px 8px 0 0;
    transition: transform 0.1s ease;
}

.tab-button.active {
    background-color: #2E7D32;
    color: #ffffff;
}

/* Prevent theme hover on inactive tab */
.tab-button:not(.active):hover,
.tab-button:not(.active):focus {
    background-color: #f3f4f6;
    color: #374151;
}

/* Prevent theme hover on active tab */
.tab-button.active:hover,
.tab-button.active:focus {
    background-color: #2E7D32;
}

.tab-content {
    display: none;
    flex-direction: row;

    align-items: center;
    gap: 20px;
    justify-content: center;
}

#settings-content {
    flex-direction: column;
}

.tab-content.active {
    display: flex;
}

#game-main-panel {
    display: flex;
    flex-direction: column;
    align-items: center;
}

#game-canvas-wrapper {
    position: relative;
}

#game-canvas {
    border: 3px solid #333;
    background-color: #222;
    border-radius: 5px;
}

#game-options {
    color: #555;
    display: flex;
    flex-direction: column;
    gap: 15px;
    align-items: flex-start;
    width: 100%;
    margin-top: 15px;
}

.settings-label {
    cursor: pointer;
    display: inline-flex;
    align-items: center;
    gap: 5px;
}

.settings-row {
    display: flex;
    align-items: center;
    gap: 10px;
}

.settings-input {
    padding: 8px;
    font-size: 15px;
    border-radius: 5px;
    border: 1px solid #ccc;
    background-color: #fff;
    box-shadow: inset 0 1px 2px rgba(0, 0, 0, 0.1);
    transition: border-color 0.2s, box-shadow 0.2s;
}

select.settings-input {
    appearance: none;
    -webkit-appearance: none;
    -moz-appearance: none;
    background-image: url("data:image/svg+xml,%3Csvg width='24' height='24' viewBox='0 0 20 20' fill='none' xmlns='http://www.w3.org/2000/svg'%3E%3Cpath d='M6 8L10 12L14 8' stroke='%236B7280' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'/%3E%3C/svg%3E");
    background-repeat: no-repeat;
    background-position: right 5px center;
    background-size: 20px;
    padding-right: 35px;
    cursor: pointer;
}

input[type="number"].settings-input:hover,
select.settings-input:hover {
    border-color: #ccc;
    background-color: #fff;
    border-radius: 5px;
}

input[type="number"].settings-input:focus,
select.settings-input:focus,
input[type="number"].settings-input:active,
select.settings-input:active {
    outline: none;
    box-shadow: 0 0 0 1px rgba(46, 125, 50, 0.2);
    background-color: #fff;
    border-radius: 5px;
}

#game-options input[type="checkbox"],
#game-options input[type="radio"] {
    width: 1.1em;
    height: 1.1em;
    cursor: pointer;
    margin: 0;
    /* Reset default margin to fix alignment */
}

#timer-duration.settings-input {
    width: 50px;
}

/* Hide spinners from number input */
input[type=number].settings-input {
    -moz-appearance: textfield;
    appearance: textfield;
    text-align: center;
    background-color: #fff;
    border-radius: 5px;
    border: 1px solid #ccc;
}

input[type=number].settings-input::-webkit-inner-spin-button,
input[type=number].settings-input::-webkit-outer-spin-button {
    -webkit-appearance: none;
    margin: 0;
}

#score-container {
    display: flex;
    justify-content: space-between;
    align-items: center;
    width: 400px;
    margin-top: 8px;
    margin-bottom: 8px;
    font-size: 18px;
    font-weight: 500;
}

#timer-container {
    visibility: hidden;
    opacity: 0;
    transition: opacity 0.2s ease-in-out;
    font-size: 18px;
    font-weight: 500;
    color: #a62b12;
}

#timer-options {
    display: none;
    /* Controlled by JS */
    flex-direction: column;
    gap: 10px;
    align-items: flex-start;
    border-left: 3px solid #e5e7eb;
    padding-left: 15px;
    margin-left: 10px;
}

.settings-label-radio {
    cursor: pointer;
    display: inline-flex;
    align-items: center;
    gap: 5px;
}

#score-display,
#high-score-display {
    color: #2E7D32;
}

#game-controls {
    display: flex;
    gap: 10px;
    justify-content: center;
    margin-top: 15px;
}

.game-button {
    padding: 8px 13px;
    border: none;
    border-radius: 5px;
    font-size: 16px;
    font-weight: 500;
    cursor: pointer;
    transition: background-color 0.2s, transform 0.1s ease;
}

#start-button {
    background-color: #368639;
    color: white;
}

#start-button:hover,
#start-button:focus,
#start-button:active {
    background-color: #368639;
}

#reset-button {
    background-color: #d73529;
    color: white;
}

#reset-button:hover,
#reset-button:focus,
#reset-button:active {
    background-color: #d73529;
}

#fullscreen-button {
    background-color: #1f75d1;
    color: white;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 10px;
}

#fullscreen-button:hover,
#fullscreen-button:focus,
#fullscreen-button:active {
    background-color: #1f75d1;
}

/* --- Override theme styles and add click effect for all buttons --- */
#snake-game-container button:focus {
    outline: none;
    box-shadow: none;
}

#snake-game-container button:active {
    transform: scale(0.97);
}

#settings-actions {
    display: flex;
    gap: 10px;
    margin-top: 20px;
    width: 100%;
    justify-content: center;
}

#clear-settings-button {
    background-color: #6c757d;
    color: white;
}

#clear-settings-button:hover,
#clear-settings-button:focus,
#clear-settings-button:active {
    background-color: #6c757d;
}

#save-settings-button {
    background-color: #1f75d1;
    color: white;
}

#save-settings-button:hover,
#save-settings-button:focus,
#save-settings-button:active {
    background-color: #1f75d1;
}

#start-game-settings-button {
    background-color: #368639;
    color: white;
}

#start-game-settings-button:hover,
#start-game-settings-button:focus,
#start-game-settings-button:active {
    background-color: #368639;
}

#game-overlay {
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background-color: rgba(0, 0, 0, 0.7);
    color: white;
    display: none;
    /* Controlled by JS */
    flex-direction: column;
    align-items: center;
    justify-content: center;
    border-radius: 5px;
}

#game-over-text {
    font-size: 32px;
    font-weight: 500;
    margin-bottom: 20px;
    color: #FF5252;
}

#final-score {
    font-size: 22px;
    margin-bottom: 8px;
}

#final-time {
    font-size: 20px;
    margin-bottom: 20px;
    display: none;
    /* Hide by default, show only if timer was enabled */
}

#mobile-controls {
    display: none;
    position: relative;
    width: 150px;
    height: 150px;
}

.control-button {
    position: absolute;
    width: 100%;
    height: 100%;
    background-color: #f0f0f0;
    border: none;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    color: #333;
    transition: transform 0.1s ease, background-color 0.2s ease;
    -webkit-user-select: none;
    -ms-user-select: none;
    user-select: none;
}

/* Remove all interactive effects from mobile control buttons to override theme styles */
#snake-game-container .control-button:hover,
#snake-game-container .control-button:active,
#snake-game-container .control-button:focus {
    background-color: #f0f0f0;
    /* Match base color to prevent any visual change on interaction */
    color: #333;
    transform: none;
    outline: none;
    box-shadow: none;
}

/* Add a 'clicked' state for the press effect */
#snake-game-container .control-button.clicked {
    transform: scale(0.9);
}

#up-button {
    clip-path: polygon(50% 50%, 20% 0, 80% 0);
    border-radius: 50% 50% 0 0;
    padding-bottom: 60%;
}

#down-button {
    clip-path: polygon(50% 50%, 80% 100%, 20% 100%);
    border-radius: 0 0 50% 50%;
    padding-top: 60%;
}

#left-button {
    clip-path: polygon(50% 50%, 0 20%, 0 80%);
    border-radius: 50% 0 0 50%;
    padding-right: 70%;
}

#right-button {
    clip-path: polygon(50% 50%, 100% 80%, 100% 20%);
    border-radius: 0 50% 50% 0;
    padding-left: 70%;
}

.control-button svg {
    position: absolute;
    transform: scale(1.2);
}

.faq-list {
    margin-top: 1rem;
}

.faq-list dt {
    font-weight: 500;
    font-size: 1.1em;
}

.faq-list dd {
    margin-left: 0;
    margin-top: 0.5rem;
    margin-bottom: 1rem;
    padding-left: 1rem;
    padding-bottom: 10px;
    border-bottom: 1px dashed #ddd;
}

@media (max-width: 500px) {
    #snake-game-container {
        box-shadow: none;
        border-top: 1px solid #e0e0e0;
        border-bottom: 1px solid #e0e0e0;
        border-radius: 0;
        padding-left: 0;
        padding-right: 0;
    }

    #game-content {
        flex-direction: column;
        /* Stack game panel and controls vertically */
        align-items: center;
        gap: 8px;
    }

    #mobile-controls {
        flex-direction: column;
        gap: 15px;
        width: 250px;
        height: 250px;
        margin-top: 5px;
        /* Add some space above mobile controls */
    }

    #game-canvas {
        width: 100%;
        /* Make canvas responsive */
        height: auto;
        /* Maintain aspect ratio */
        max-width: 320px;
        /* Set a max-width for very small screens */
    }

    #score-container {
        width: 100%;
        /* Make score container responsive */
    }

    #mobile-controls {
        display: block;
    }

    #show-mobile-controls-label {
        display: none;
    }
}