/* Theme Variables */
:root {
    --bg-color: #1e1e24;
    --container-bg: #2b2b36;
    --text-color: #f5f5f5;
    --primary-color: #4da8da;
    --primary-hover: #3b8bb8;
    --key-bg: #3f3f4e;
    --key-border: #5a5a70;
    --key-hover: #4a4a5c;
    --key-text: #aaa;
    --btn-text: #1e1e24;

    --key-bg-dim: #32323f;
    --key-border-dim: #404052;
    --key-text-dim: #777;
}

body.light-mode {
    --bg-color: #f0f2f5;
    --container-bg: #ffffff;
    --text-color: #333333;
    --primary-color: #0078d7;
    --primary-hover: #005a9e;
    --key-bg: #e1e1e1;
    --key-border: #cccccc;
    --key-hover: #d1d1d1;
    --key-text: #555555;
    --btn-text: #ffffff;

    --key-bg-dim: #f2f2f2;
    --key-border-dim: #e6e6e6;
    --key-text-dim: #999999;
}

body {
    font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;
    background-color: var(--bg-color);
    color: var(--text-color);
    margin: 0;
    min-height: 100vh;
    position: relative;
    transition: background-color 0.3s, color 0.3s;
}

.main-wrapper {
    display: flex;
    justify-content: center;
    align-items: center;
    min-height: 100vh;
    width: 100%;
}

.container {
    text-align: center;
    background-color: var(--container-bg);
    padding: 3rem;
    border-radius: 12px;
    box-shadow: 0 8px 32px rgba(0,0,0,0.5);
    transition: background-color 0.3s, box-shadow 0.3s;
}

body.light-mode .container {
    box-shadow: 0 8px 32px rgba(0,0,0,0.1);
}

h1 {
    margin-top: 0;
    color: var(--primary-color);
    font-size: 2.5rem;
    margin-bottom: 1.5rem;
}

.controls {
    margin-bottom: 2.5rem;
}

button {
    background-color: var(--primary-color);
    color: var(--btn-text);
    border: none;
    padding: 12px 24px;
    font-size: 1.2rem;
    font-weight: bold;
    border-radius: 8px;
    cursor: pointer;
    transition: background-color 0.2s, transform 0.1s;
}

button:hover {
    background-color: var(--primary-hover);
}

button:active {
    transform: scale(0.95);
}

.danger-btn {
    background-color: #af3830;
    color: #fff;
    margin-left: 10px;
}

.danger-btn:hover {
    background-color: #d32f2f;
}

.score-display {
    margin-top: 15px;
    font-size: 1.4rem;
    font-weight: bold;
}

#score {
    color: var(--primary-color);
}

.message {
    margin-top: 20px;
    min-height: 28px;
    font-size: 1.2rem;
    font-weight: bold;
    color: var(--text-color);
}

.message.correct {
    color: #4caf50;
}

.message.incorrect {
    color: #f44336;
}

.settings-panel {
    margin-bottom: 2.5rem;
    background-color: var(--key-bg-dim);
    padding: 15px;
    border-radius: 12px;
    border: 1px solid var(--key-border-dim);
    display: flex;
    justify-content: center;
}

.sliders-grid {
    display: flex;
    flex-wrap: wrap;
    gap: 15px;
    justify-content: center;
}

.slider-group {
    display: flex;
    flex-direction: column;
    align-items: center;
    width: 150px;
}

.slider-group label {
    font-size: 0.85rem;
    margin-bottom: 5px;
    color: var(--text-color);
    white-space: nowrap;
}

.slider-group input[type=range] {
    width: 100%;
    cursor: pointer;
}

body.mobile-mode .keyboard-char {
    display: none !important;
}

body.mobile-mode .key .notation {
    font-size: 1.3rem;
    margin-top: 0;
}

body.mobile-mode .key br {
    display: none;
}

.keyboard-container {
    display: flex;
    flex-direction: column;
    gap: 15px;
}

.keyboard-row {
    display: flex;
    justify-content: center;
    gap: 40px;
}

.keyboard-row.middle-row {
    margin-left: 20px;
}
.keyboard-row.bottom-row {
    margin-left: 40px;
}

.key-group {
    display: flex;
    gap: 15px;
}

.key {
    width: 70px;
    height: 70px;
    background-color: var(--key-bg);
    border: 2px solid var(--key-border);
    border-radius: 10px;
    display: flex;
    flex-direction: column;
    justify-content: center;
    align-items: center;
    font-size: 1.5rem;
    font-weight: bold;
    cursor: pointer;
    transition: all 0.1s;
    user-select: none;
    box-shadow: 0 4px 6px rgba(0,0,0,0.2);
}

.key .keyboard-char {
    font-size: 1.5rem;
    font-weight: bold;
    color: inherit; /* inherit from .key */
}

.key .notation {
    font-size: 0.95rem;
    color: var(--key-text);
    margin-top: 4px;
    font-weight: normal;
}

.key:hover {
    background-color: var(--key-hover);
}

.top-row .key, .bottom-row .key {
    background-color: var(--key-bg-dim);
    border-color: var(--key-border-dim);
    color: var(--key-text-dim);
}
.top-row .key .notation, .bottom-row .key .notation {
    color: var(--key-text-dim);
}

.top-row .key:hover, .bottom-row .key:hover {
    background-color: var(--key-hover);
}

.key.active,
.top-row .key.active,
.bottom-row .key.active {
    background-color: var(--primary-color);
    border-color: var(--primary-color);
    color: var(--btn-text);
    transform: translateY(4px);
    box-shadow: 0 0px 2px rgba(0,0,0,0.2);
}

.key.active .notation,
.top-row .key.active .notation,
.bottom-row .key.active .notation {
    color: var(--btn-text);
}

.key.training-glow {
    box-shadow: 0 0 20px var(--primary-color), inset 0 0 10px rgba(77, 168, 218, 0.5);
    border-color: var(--primary-color);
}

/* Theme Toggle */
.theme-toggle {
    position: absolute;
    bottom: 30px;
    right: 30px;
    width: 55px;
    height: 55px;
    border-radius: 50%;
    font-size: 1.6rem;
    display: flex;
    justify-content: center;
    align-items: center;
    background-color: var(--container-bg);
    color: var(--text-color);
    border: 1px solid var(--key-border);
    box-shadow: 0 6px 15px rgba(0,0,0,0.3);
    z-index: 1000;
    padding: 0;
    cursor: pointer;
    transition: all 0.3s cubic-bezier(0.25, 0.8, 0.25, 1);
}
.theme-toggle:hover {
    transform: translateY(-3px) scale(1.05);
    box-shadow: 0 8px 20px rgba(0,0,0,0.4);
}
body.light-mode .theme-toggle {
    box-shadow: 0 6px 15px rgba(0,0,0,0.1);
}
body.light-mode .theme-toggle:hover {
    box-shadow: 0 8px 20px rgba(0,0,0,0.15);
}

/* Top Controls */
.view-toggle-btn {
    position: absolute;
    top: 30px;
    left: 30px;
    width: 45px;
    height: 45px;
    border-radius: 50%;
    font-size: 1.3rem;
    display: flex;
    justify-content: center;
    align-items: center;
    background-color: var(--container-bg);
    color: var(--text-color);
    border: 1px solid var(--key-border);
    box-shadow: 0 6px 15px rgba(0,0,0,0.3);
    z-index: 1000;
    padding: 0;
    cursor: pointer;
    transition: all 0.3s cubic-bezier(0.25, 0.8, 0.25, 1);
}

.view-toggle-btn:hover {
    transform: translateY(-3px) scale(1.05);
    box-shadow: 0 8px 20px rgba(0,0,0,0.4);
}

body.light-mode .view-toggle-btn {
    box-shadow: 0 6px 15px rgba(0,0,0,0.1);
}

body.light-mode .view-toggle-btn:hover {
    box-shadow: 0 8px 20px rgba(0,0,0,0.15);
}

.top-controls-container {
    position: absolute;
    top: 30px;
    right: 30px;
    z-index: 1000;
    display: flex;
    gap: 15px;
}

.styled-btn {
    appearance: none;
    background-color: var(--container-bg);
    color: var(--text-color);
    border: 1px solid var(--key-border);
    padding: 12px 25px;
    width: 120px;
    text-align: center;
    font-size: 1rem;
    font-weight: 600;
    letter-spacing: 0.5px;
    border-radius: 30px;
    cursor: pointer;
    box-shadow: 0 6px 15px rgba(0, 0, 0, 0.2), 0 0 8px rgba(77, 168, 218, 0.2);
    transition: all 0.3s cubic-bezier(0.25, 0.8, 0.25, 1);
    outline: none;
}

.styled-btn:hover, .styled-btn:focus {
    border-color: var(--primary-color);
    box-shadow: 0 8px 20px rgba(0, 0, 0, 0.3), 0 0 15px rgba(77, 168, 218, 0.6);
    transform: translateY(-3px);
}
.styled-btn:active {
    transform: translateY(-3px) scale(0.95);
}
body.light-mode .styled-btn {
    box-shadow: 0 6px 15px rgba(0, 0, 0, 0.08), 0 0 8px rgba(0, 120, 215, 0.15);
}
body.light-mode .styled-btn:hover, body.light-mode .styled-btn:focus {
    border-color: var(--primary-color);
    box-shadow: 0 8px 20px rgba(0, 0, 0, 0.12), 0 0 15px rgba(0, 120, 215, 0.4);
}
body.light-mode .styled-btn:active {
    transform: translateY(-3px) scale(0.95);
}

.styled-select {
    appearance: none;
    background-color: var(--container-bg);
    color: var(--text-color);
    border: 1px solid var(--key-border);
    padding: 12px 45px 12px 25px;
    font-size: 1rem;
    font-weight: 600;
    letter-spacing: 0.5px;
    border-radius: 30px;
    cursor: pointer;
    box-shadow: 0 6px 15px rgba(0, 0, 0, 0.2), 0 0 8px rgba(77, 168, 218, 0.2); /* Soft Glow */
    transition: all 0.3s cubic-bezier(0.25, 0.8, 0.25, 1);
    outline: none;
    /* Custom arrow */
    background-image: url('data:image/svg+xml;utf8,<svg fill="%23aaa" height="24" viewBox="0 0 24 24" width="24" xmlns="http://www.w3.org/2000/svg"><path d="M7 10l5 5 5-5z"/><path d="M0 0h24v24H0z" fill="none"/></svg>');
    background-repeat: no-repeat;
    background-position: right 15px center;
}

.styled-select:hover, .styled-select:focus {
    border-color: var(--primary-color);
    box-shadow: 0 8px 20px rgba(0, 0, 0, 0.3), 0 0 15px rgba(77, 168, 218, 0.6);
    transform: translateY(-3px);
}
body.light-mode .styled-select {
    box-shadow: 0 6px 15px rgba(0, 0, 0, 0.08), 0 0 8px rgba(0, 120, 215, 0.15);
}
body.light-mode .styled-select:hover, body.light-mode .styled-select:focus {
    border-color: var(--primary-color);
    box-shadow: 0 8px 20px rgba(0, 0, 0, 0.12), 0 0 15px rgba(0, 120, 215, 0.4);
}

/* Mobile Portrait Optimization */
@media (max-width: 768px) {
    .container {
        padding: 1.5rem 1rem;
        margin-top: 80px; /* Space for top absolute controls */
        width: 95%;
        box-sizing: border-box;
    }

    h1 {
        font-size: 1.8rem;
        margin-bottom: 1rem;
    }

    button {
        padding: 10px 16px;
        font-size: 1rem;
    }

    .keyboard-row {
        gap: 10px;
    }

    .keyboard-row.middle-row {
        margin-left: 15px;
    }

    .keyboard-row.bottom-row {
        margin-left: 30px;
    }

    .key-group {
        gap: 4px;
    }

    .key {
        width: 36px;
        height: 48px;
        border-radius: 6px;
    }

    .key .keyboard-char {
        font-size: 1.1rem;
    }

    .key .notation {
        font-size: 0.7rem;
        margin-top: 2px;
    }

    body.mobile-mode .key .notation {
        font-size: 0.9rem;
    }

    /* Top Controls */
    .view-toggle-btn {
        top: 15px;
        left: 15px;
        width: 40px;
        height: 40px;
        font-size: 1.1rem;
    }

    .top-controls-container {
        top: 15px;
        right: 15px;
        gap: 10px;
    }

    .styled-select {
        padding: 8px 30px 8px 15px;
        font-size: 0.85rem;
        background-position: right 10px center;
        background-size: 16px;
    }

    .theme-toggle {
        bottom: 15px;
        right: 15px;
        width: 45px;
        height: 45px;
        font-size: 1.3rem;
    }
}

@media (max-width: 400px) {
    .key {
        width: 32px;
        height: 42px;
    }
    .keyboard-row {
        gap: 6px;
    }
    .key-group {
        gap: 3px;
    }
    .keyboard-row.middle-row {
        margin-left: 10px;
    }
    .keyboard-row.bottom-row {
        margin-left: 20px;
    }
    .key .notation {
        font-size: 0.65rem;
    }
    body.mobile-mode .key .notation {
        font-size: 0.8rem;
    }
}
