* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

body {
    font-family: 'Arial', sans-serif;
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    display: flex;
    justify-content: center;
    align-items: center;
    min-height: 100vh;
    overflow: hidden;
    touch-action: manipulation;
}

.container {
    position: relative;
    box-shadow: 0 10px 50px rgba(0, 0, 0, 0.3);
    border-radius: 10px;
    overflow: hidden;
}

#gameCanvas {
    display: block;
    background: #70c5ce;
    touch-action: none;
}

.overlay {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.8);
    display: flex;
    justify-content: center;
    align-items: center;
    z-index: 10;
}

.overlay.hidden {
    display: none;
}

.menu {
    background: white;
    padding: 40px;
    border-radius: 15px;
    text-align: center;
    box-shadow: 0 5px 30px rgba(0, 0, 0, 0.5);
    max-width: 320px;
}

h1 {
    color: #333;
    font-size: 2.5em;
    margin-bottom: 20px;
    text-shadow: 2px 2px 4px rgba(0, 0, 0, 0.1);
}

.instructions {
    color: #666;
    margin-bottom: 30px;
    font-size: 1em;
    line-height: 1.5;
}

.instructions strong {
    color: #667eea;
}

.speed-control {
    margin-bottom: 30px;
}

.speed-control label,
.lives-control label {
    display: block;
    color: #333;
    font-weight: bold;
    margin-bottom: 15px;
    font-size: 1.1em;
}

.slider-container {
    display: flex;
    align-items: center;
    gap: 10px;
    margin-bottom: 10px;
}

.speed-label {
    color: #666;
    font-size: 0.9em;
    min-width: 35px;
}

#speedSlider {
    flex: 1;
    height: 6px;
    border-radius: 5px;
    background: #ddd;
    outline: none;
    -webkit-appearance: none;
}

#speedSlider::-webkit-slider-thumb {
    -webkit-appearance: none;
    appearance: none;
    width: 20px;
    height: 20px;
    border-radius: 50%;
    background: #667eea;
    cursor: pointer;
    transition: all 0.2s;
}

#speedSlider::-webkit-slider-thumb:hover {
    transform: scale(1.2);
    background: #764ba2;
}

#speedSlider::-moz-range-thumb {
    width: 20px;
    height: 20px;
    border-radius: 50%;
    background: #667eea;
    cursor: pointer;
    border: none;
    transition: all 0.2s;
}

#speedSlider::-moz-range-thumb:hover {
    transform: scale(1.2);
    background: #764ba2;
}

.speed-value {
    color: #667eea;
    font-weight: bold;
    font-size: 1.1em;
}

.lives-control {
    margin-bottom: 25px;
}

.lives-control .speed-value span {
    color: #ff8a65;
}

.practice-mode {
    margin-bottom: 25px;
}

.checkbox-label {
    display: flex;
    align-items: center;
    gap: 10px;
    cursor: pointer;
    color: #333;
    font-size: 1em;
    user-select: none;
}

.checkbox-label input[type="checkbox"] {
    width: 20px;
    height: 20px;
    cursor: pointer;
    accent-color: #667eea;
}

.checkbox-label span {
    font-weight: 500;
}

.game-button {
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    color: white;
    border: none;
    padding: 15px 40px;
    font-size: 1.2em;
    font-weight: bold;
    border-radius: 30px;
    cursor: pointer;
    transition: transform 0.2s, box-shadow 0.2s;
    box-shadow: 0 4px 15px rgba(102, 126, 234, 0.4);
}

.game-button:hover {
    transform: translateY(-2px);
    box-shadow: 0 6px 20px rgba(102, 126, 234, 0.6);
}

.game-button:active {
    transform: translateY(0);
}

.game-button.secondary {
    background: linear-gradient(135deg, #95a5a6 0%, #7f8c8d 100%);
    box-shadow: 0 4px 15px rgba(127, 140, 141, 0.4);
    margin-top: 10px;
}

.game-button.secondary:hover {
    box-shadow: 0 6px 20px rgba(127, 140, 141, 0.6);
}

/* Piano Configuration Styles */
.config-menu {
    max-width: 380px;
    max-height: 90vh;
    padding: 20px;
    overflow-y: auto;
}

.config-section {
    margin-bottom: 15px;
    text-align: left;
}

.config-section label {
    display: block;
    color: #333;
    font-weight: bold;
    margin-bottom: 5px;
    font-size: 0.9em;
}

.config-select {
    width: 100%;
    padding: 8px 12px;
    font-size: 0.95em;
    border: 2px solid #ddd;
    border-radius: 8px;
    background: white;
    color: #333;
    cursor: pointer;
    transition: border-color 0.2s;
    margin-bottom: 10px;
}

.config-select:hover {
    border-color: #667eea;
}

.config-select:focus {
    outline: none;
    border-color: #667eea;
    box-shadow: 0 0 0 3px rgba(102, 126, 234, 0.1);
}

.config-preview {
    background: #f8f9fa;
    padding: 12px;
    border-radius: 8px;
    margin-bottom: 15px;
    text-align: left;
}

.config-preview strong {
    color: #333;
    display: block;
    margin-bottom: 6px;
    font-size: 0.85em;
}

.config-preview p {
    color: #667eea;
    font-weight: bold;
    margin: 0;
    font-size: 0.9em;
}

/* MIDI Connection Status */
.midi-status {
    background: #f8f9fa;
    padding: 12px;
    border-radius: 8px;
    margin-bottom: 15px;
}

.status-indicator {
    display: flex;
    align-items: center;
    gap: 8px;
    font-size: 0.9em;
}

.status-dot {
    width: 10px;
    height: 10px;
    border-radius: 50%;
    background: #95a5a6;
    display: inline-block;
    transition: background 0.3s;
}

.status-dot.connected {
    background: #2ecc71;
    box-shadow: 0 0 8px rgba(46, 204, 113, 0.6);
}

.status-dot.disconnected {
    background: #e74c3c;
}

.device-list {
    margin-top: 8px;
    padding-left: 18px;
    font-size: 0.85em;
    color: #666;
}

.device-item {
    padding: 4px 0;
    color: #2ecc71;
    font-weight: 500;
}

/* Input Status on Start Screen */
.input-status {
    background: #f8f9fa;
    padding: 10px 15px;
    border-radius: 8px;
    margin-bottom: 20px;
}

.input-status .status-indicator {
    justify-content: center;
    font-size: 0.85em;
    color: #2ecc71;
    font-weight: 500;
}

/* Touch Controls */
.touch-controls {
    position: fixed;
    inset: auto 0 0 0;
    display: flex;
    gap: 8px;
    padding: 16px;
    pointer-events: none;
    z-index: 20;
    background: linear-gradient(180deg, rgba(15, 23, 42, 0) 0%, rgba(15, 23, 42, 0.35) 35%, rgba(15, 23, 42, 0.65) 100%);
    backdrop-filter: blur(4px);
}

.touch-controls.hidden {
    display: none !important;
}

.touch-button {
    flex: 1;
    pointer-events: auto;
    border: none;
    border-radius: 16px;
    font-size: 1.2em;
    font-weight: 600;
    letter-spacing: 0.04em;
    text-transform: uppercase;
    color: white;
    padding: 18px 0;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 10px;
    box-shadow: 0 12px 24px rgba(15, 23, 42, 0.35);
    touch-action: none;
    transition: transform 0.15s ease, box-shadow 0.2s ease, opacity 0.2s ease;
}

.touch-button span {
    pointer-events: none;
}

.touch-button:active,
.touch-button.touch-active {
    transform: translateY(2px);
    box-shadow: 0 6px 12px rgba(15, 23, 42, 0.45);
    opacity: 0.85;
}

.touch-button.touch-up {
    background: linear-gradient(135deg, rgba(56, 189, 248, 0.95), rgba(29, 78, 216, 0.95));
}

.touch-button.touch-down {
    background: linear-gradient(135deg, rgba(249, 115, 22, 0.95), rgba(180, 57, 33, 0.95));
}

@media (hover: hover) and (pointer: fine) {
    .touch-controls {
        display: none;
    }
}

/* HUD */
.hud {
    position: absolute;
    top: 12px;
    left: 50%;
    transform: translateX(-50%);
    z-index: 8;
    display: flex;
    gap: 12px;
    font-family: 'Arial', sans-serif;
}

.hud-item {
    background: rgba(15, 23, 42, 0.7);
    color: #f8fafc;
    padding: 8px 14px;
    border-radius: 999px;
    font-weight: 600;
    font-size: 0.95em;
    letter-spacing: 0.02em;
    box-shadow: 0 8px 16px rgba(15, 23, 42, 0.35);
}
