:root {
    color-scheme: dark light;
}

body {
    font-family: sans-serif;
    text-align: center;
    background-color: #121212;
    color: #e0e0e0;
    transition: background-color 0.3s, color 0.3s;
    display: flex;
    justify-content: center;
    align-items: center;
    min-height: 100vh;
    width: 100vw;
    margin: 0;
    overflow: auto;
}

/* --- MOBILE MODE LOCK --- */
body.mobile-mode {
    overflow: hidden; 
    touch-action: none; 
    position: fixed;
    width: 100%;
    height: 100%;
    top: 0;
    left: 0;
}

body.light-mode {
    background-color: #f0f0f0;
    color: #000;
}

/* --- TOP BUTTONS --- */
#mobile-btn, #dark-mode-toggle {
    position: fixed;
    top: 10px;
    z-index: 2000;
    padding: 8px 10px;
    font-size: 0.85em;
    cursor: pointer;
    background: #333;
    color: #fff;
    border: 1px solid #555;
    border-radius: 5px;
    width: 120px; 
    box-sizing: border-box;
    transition: background 0.3s, color 0.3s;
}

#mobile-btn { left: 10px; }
#dark-mode-toggle { right: 10px; }

body.mobile-mode #mobile-btn { display: none; }

body.light-mode #mobile-btn, 
body.light-mode #dark-mode-toggle {
    background: #ddd;
    color: #000;
    border: 1px solid #bbb;
}

/* --- APP SCREEN (Scaling Logic) --- */
#app-container {
    display: flex;
    justify-content: center;
    align-items: center;
    width: 100%;
    height: 100%;
}

#app-screen {
    width: 360px;
    height: 700px;
    display: flex;
    flex-direction: column;
    align-items: center;
    transform-origin: center center;
    flex-shrink: 0; 
    padding-top: 10px;
}

h1 { 
    margin-top: 10px; 
    margin-bottom: 5px; 
    font-size: 1.8em;
}

#audio-status {
    margin: 0px auto 10px;
    padding: 5px 10px;
    font-size: 0.85em;
    font-weight: bold;
    border-radius: 5px;
}
#audio-status.ready { color: #33dd33; }
#audio-status.error { color: #ff5555; }

/* Tighter Controls Container */
.controls-container {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 10px;
    margin-bottom: 15px;
    width: 90%;
}

.control-group {
    display: flex;
    flex-direction: column;
    align-items: flex-start;
    gap: 2px;
    width: 100%;
}

.control-group label {
    font-size: 0.85em;
    color: #aaa;
}
body.light-mode .control-group label { color: #555; }

select, input[type="text"], button {
    padding: 6px 8px;
    border-radius: 4px;
    font-size: 0.95em;
    background-color: #333;
    color: #e0e0e0;
    border: 1px solid #555;
    width: 100%;
    box-sizing: border-box;
}
body.light-mode select, body.light-mode input[type="text"], body.light-mode button {
    background-color: #fff;
    color: #000;
    border: 1px solid #ccc;
}

/* --- RANGE SLIDER STYLES --- */
input[type="range"] {
    width: 100%;
    margin: 6px 0;
    cursor: pointer;
    -webkit-appearance: none;
    background: transparent;
}
input[type="range"]:focus { outline: none; }

input[type="range"]::-webkit-slider-runnable-track {
    height: 6px;
    background: #555;
    border-radius: 3px;
}
body.light-mode input[type="range"]::-webkit-slider-runnable-track { background: #ccc; }
input[type="range"]::-webkit-slider-thumb {
    -webkit-appearance: none;
    height: 18px;
    width: 18px;
    background: #66aaff;
    border-radius: 50%;
    margin-top: -6px;
    border: none;
}
body.light-mode input[type="range"]::-webkit-slider-thumb { background: #0055cc; }

input[type="range"]::-moz-range-track {
    height: 6px;
    background: #555;
    border-radius: 3px;
}
body.light-mode input[type="range"]::-moz-range-track { background: #ccc; }
input[type="range"]::-moz-range-thumb {
    height: 18px;
    width: 18px;
    background: #66aaff;
    border-radius: 50%;
    border: none;
}
body.light-mode input[type="range"]::-moz-range-thumb { background: #0055cc; }


.sequence-player { 
    display: flex; 
    gap: 5px; 
    width: 100%;
}
.sequence-player input { flex-grow: 1; }
.sequence-player button { 
    width: 70px; 
    transition: background-color 0.2s;
}

/* NEW: Stop Mode for Sequence Button */
#play-sequence-btn.stop-mode {
    background-color: #cc4444;
    border-color: #aa3333;
}
body.light-mode #play-sequence-btn.stop-mode {
    background-color: #ff4444;
    color: #fff;
}

/* NEW: Checkbox styles */
.checkbox-label {
    display: flex;
    align-items: center;
    gap: 8px;
    margin-top: 6px;
    cursor: pointer;
    font-size: 0.85em;
    color: #aaa;
}
body.light-mode .checkbox-label { color: #555; }
.checkbox-label input[type="checkbox"] {
    width: 18px;
    height: 18px;
    margin: 0;
    cursor: pointer;
}

/* Tighter Phone layout */
.phone-container {
    background: #222;
    padding: 15px;
    border-radius: 20px;
    box-shadow: 0 10px 30px rgba(0,0,0,0.5);
    display: flex;
    flex-direction: column;
    align-items: center;
    width: 300px;
    box-sizing: border-box;
    touch-action: none; 
}
body.light-mode .phone-container {
    background: #e0e0e0;
    box-shadow: 0 10px 30px rgba(0,0,0,0.2);
}

.phone-display {
    width: 100%;
    height: 45px;
    background: #111;
    color: #66aaff;
    border-radius: 8px;
    margin-bottom: 15px;
    font-size: 1.6em;
    display: flex;
    align-items: center;
    justify-content: flex-end;
    padding: 0 10px;
    box-sizing: border-box;
    letter-spacing: 2px;
    overflow: hidden;
    white-space: nowrap;
}
body.light-mode .phone-display {
    background: #fff;
    color: #0055cc;
    border: 1px solid #ccc;
}

.numpad {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 12px;
    width: 100%;
}

.num-btn {
    background: #333;
    border: none;
    border-radius: 50%;
    width: 70px;
    height: 70px;
    font-size: 1.8em;
    color: #fff;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    line-height: 1;
    transition: transform 0.1s, background 0.1s;
    user-select: none;
    margin: 0 auto;
}
.num-btn span {
    font-size: 0.35em;
    color: #888;
    margin-top: 2px;
    pointer-events: none; 
}
body.light-mode .num-btn {
    background: #fff;
    color: #000;
    box-shadow: 0 2px 5px rgba(0,0,0,0.1);
}
body.light-mode .num-btn span { color: #666; }

.num-btn:active, .num-btn.active {
    background: #555;
    transform: scale(0.95);
}
body.light-mode .num-btn:active, body.light-mode .num-btn.active {
    background: #ddd;
}

#clear-display-btn {
    margin-top: 15px;
    width: 100%;
    cursor: pointer;
}
