body {
    font-family: 'Arial', sans-serif;
    background-color: #1a1a1a; /* Dark background */
    color: #ff8c00; /* Orange text */
    display: flex;
    justify-content: center;
    align-items: center;
    min-height: 100vh;
    margin: 0;
    overflow: hidden; /* Hide scrollbars */
}

.container {
    text-align: center;
    background-color: #333; /* Slightly lighter dark for container */
    padding: 30px;
    border-radius: 15px;
    box-shadow: 0 0 20px rgba(255, 140, 0, 0.5); /* Orange glow */
    border: 3px solid #ff8c00;
    position: relative; /* Needed for absolute positioning of audio controls */
    z-index: 1; /* Ensure container is below audio controls if they overlap */
}

h1 {
    color: #ffffff; /* White heading for contrast */
    margin-bottom: 30px;
    text-shadow: 0 0 10px rgba(255, 140, 0, 0.7);
}

.input-display {
    display: flex;
    justify-content: center;
    margin-bottom: 30px;
    font-size: 2em;
    letter-spacing: 10px;
    color: #ffffff;
    text-shadow: 0 0 5px rgba(255, 140, 0, 0.8);
}

.digit {
    border: 2px solid #ff8c00;
    padding: 10px 15px;
    margin: 0 5px;
    border-radius: 5px;
    background-color: #444;
    min-width: 40px; /* Ensure consistent width */
    text-align: center;
}

.keypad {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    grid-template-rows: repeat(3, 1fr);
    gap: 15px;
    margin-bottom: 30px;
    max-width: 300px;
    margin-left: auto;
    margin-right: auto;
}

.key {
    background-color: #555;
    color: #ffffff;
    border: none;
    border-radius: 10px;
    font-size: 1.5em;
    cursor: pointer;
    transition: background-color 0.3s ease, transform 0.1s ease;
    display: flex;
    justify-content: center;
    align-items: center;
    aspect-ratio: 1 / 1; /* Make keys square */
    box-shadow: 0 5px 10px rgba(0, 0, 0, 0.3);
}

.key:hover {
    background-color: #ff8c00;
    color: #1a1a1a;
    box-shadow: 0 0 15px rgba(255, 140, 0, 0.7);
}

.key:active {
    transform: scale(0.95);
}

/* Arrow specific styles */
.key.arrow {
    background-color: #ff8c00; /* Orange for arrows */
    color: #1a1a1a; /* Dark text on orange */
    font-weight: bold;
}

.key.arrow:hover {
    background-color: #ffffff;
    color: #ff8c00;
    box-shadow: 0 0 15px rgba(255, 255, 255, 0.7);
}

/* Specific arrow button placements and content */
.keypad .arrow.up { grid-area: 1 / 2; }
.keypad .arrow.top-left { grid-area: 1 / 1; }
.keypad .arrow.top-right { grid-area: 1 / 3; }
.keypad .arrow.left { grid-area: 2 / 1; }
.keypad .arrow.middle { grid-area: 2 / 2; }
.keypad .arrow.right { grid-area: 2 / 3; }
.keypad .arrow.bottom-left { grid-area: 3 / 1; }
.keypad .arrow.bottom-right { grid-area: 3 / 3; }
.keypad .arrow.down { grid-area: 3 / 2; }

/* Control buttons (Submit/Reset) */
.controls {
    margin-top: 20px;
    display: flex;
    justify-content: center;
    gap: 20px;
}

.control-button {
    padding: 10px 20px;
    font-size: 1.2em;
    border: none;
    border-radius: 8px;
    cursor: pointer;
    transition: background-color 0.3s ease, transform 0.1s ease, box-shadow 0.3s ease;
    box-shadow: 0 4px 8px rgba(0, 0, 0, 0.3);
}

.control-button.submit {
    background-color: #28a745; /* Green for submit */
    color: #ffffff;
}

.control-button.submit:hover {
    background-color: #218838;
    transform: translateY(-2px);
    box-shadow: 0 6px 12px rgba(0, 0, 0, 0.4);
}

.control-button.reset {
    background-color: #dc3545; /* Red for reset */
    color: #ffffff;
}

.control-button.reset:hover {
    background-color: #c82333;
    transform: translateY(-2px);
    box-shadow: 0 6px 12px rgba(0, 0, 0, 0.4);
}

.control-button:active {
    transform: scale(0.98);
}

/* Volume controls */
.audio-controls-container {
    position: absolute;
    top: 20px;
    left: 20px;
    z-index: 10; /* Ensure it's above other content */
}

.audio-icon {
    background: none;
    border: none;
    font-size: 2em;
    cursor: pointer;
    color: #ff8c00;
    text-shadow: 0 0 10px rgba(255, 140, 0, 0.7);
    transition: transform 0.3s ease;
}

.audio-icon:hover {
    transform: scale(1.1);
}

.audio-settings {
    display: none; /* Hidden by default */
    background-color: #333;
    padding: 15px;
    border-radius: 10px;
    box-shadow: 0 0 15px rgba(255, 140, 0, 0.5);
    border: 2px solid #ff8c00;
    margin-top: 10px;
    flex-direction: column;
    gap: 10px;
    position: absolute;
    top: 100%; /* Position below the icon */
    left: 0;
}

.audio-controls-container.open .audio-settings {
    display: flex; /* Show when container has 'open' class */
}

.volume-slider-group {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 10px;
}

.volume-slider-group label {
    font-size: 1.1em;
    color: #ffffff;
    text-shadow: 0 0 5px rgba(255, 140, 0, 0.5);
}

.volume-slider {
    width: 150px;
    cursor: pointer;
    appearance: none; /* Override default look */
    background: #444;
    border-radius: 5px;
    height: 8px;
}

/* Status Display */
.status-display {
    font-size: 2.5em;
    font-weight: bold;
    margin-top: 20px;
    height: 1.5em; /* Reserve space to prevent layout shifts */
    display: flex;
    justify-content: center;
    align-items: center;
    opacity: 0; /* Hidden by default */
    transition: opacity 0.3s ease;
    text-shadow: 0 0 10px rgba(255, 255, 255, 0.7);
}

.status-display.access-granted {
    color: #28a745; /* Green */
}

.status-display.access-denied {
    color: #dc3545; /* Red */
}

/* Flashing animation */
@keyframes flash-green {
    0%, 100% { opacity: 1; }
    50% { opacity: 0.2; }
}

@keyframes flash-red {
    0%, 100% { opacity: 1; }
    50% { opacity: 0.2; }
}

.status-display.flashing-green {
    animation: flash-green 0.3s infinite alternate;
}

.status-display.flashing-red {
    animation: flash-red 0.3s infinite alternate;
}

/* Responsive Design */
@media (max-width: 768px) {
    body {
        padding: 10px;
    }

    .container {
        padding: 20px;
        margin: 10px;
        width: calc(100% - 20px); /* Adjust width for smaller screens */
    }

    h1 {
        font-size: 1.8em;
        margin-bottom: 20px;
    }

    .input-display {
        font-size: 1.5em;
        letter-spacing: 5px;
        margin-bottom: 20px;
    }

    .digit {
        padding: 8px 10px;
        min-width: 30px;
    }

    .keypad {
        gap: 10px;
        max-width: 250px;
    }

    .key {
        font-size: 1.2em;
        padding: 10px;
    }

    .audio-controls-container {
        top: 10px;
        left: 10px;
    }

    .audio-icon {
        font-size: 1.5em;
    }

    .audio-settings {
        padding: 10px;
        margin-top: 5px;
    }

    .volume-slider-group label {
        font-size: 0.9em;
    }

    .volume-slider {
        width: 100px;
    }

    .start-music-button {
        padding: 10px 20px;
        font-size: 1.2em;
    }

    .control-button {
        padding: 8px 15px;
        font-size: 1em;
    }

    .status-display {
        font-size: 1.8em;
    }
}

/* Slider thumb */
.volume-slider::-webkit-slider-thumb {
    appearance: none;
    width: 20px;
    height: 20px;
    background: #ff8c00;
    border-radius: 50%;
    cursor: pointer;
    box-shadow: 0 0 5px rgba(255, 140, 0, 0.7);
}

.volume-slider::-moz-range-thumb {
    width: 20px;
    height: 20px;
    background: #ff8c00;
    border-radius: 50%;
    cursor: pointer;
    box-shadow: 0 0 5px rgba(255, 140, 0, 0.7);
}

/* Style for the start music button */
.start-music-button {
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    padding: 15px 30px;
    font-size: 1.5em;
    background-color: #ff8c00;
    color: #1a1a1a;
    border: none;
    border-radius: 10px;
    cursor: pointer;
    box-shadow: 0 0 15px rgba(255, 140, 0, 0.7);
    z-index: 20; /* Ensure it's above everything else */
    transition: opacity 0.5s ease;
}

.start-music-button:hover {
    background-color: #ffffff;
    color: #ff8c00;
}

.start-music-button.hidden {
    opacity: 0;
    pointer-events: none; /* Make it unclickable when hidden */
}