* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

html, body {
    height: 100%;
    background: #000000;
    touch-action: manipulation;
    -webkit-user-select: none;
    user-select: none;
    font-family: -apple-system, BlinkMacSystemFont, "SF Pro Display", "Helvetica Neue", Arial, sans-serif;
}

body {
    display: flex;
    align-items: center;
    justify-content: center;
}

.timbre-selector {
    position: fixed;
    top: 16px;
    right: 16px;
    z-index: 100;
}

#timbre-btn {
    background: rgba(44, 44, 46, 0.8);
    color: #ffffff;
    border: 1px solid rgba(255, 255, 255, 0.1);
    border-radius: 10px;
    padding: 10px 12px;
    font-size: 14px;
    font-weight: 500;
    cursor: pointer;
    min-width: 60px;
    text-align: center;
    -webkit-backdrop-filter: blur(20px);
    backdrop-filter: blur(20px);
    transition: all 0.2s ease;
}

#timbre-btn:hover {
    background: rgba(58, 58, 60, 0.9);
    border-color: rgba(255, 255, 255, 0.2);
}

#timbre-btn:active {
    background: rgba(72, 72, 74, 0.9);
    transform: scale(0.98);
}

.timbre-popup {
    display: none;
    position: absolute;
    top: 100%;
    right: 0;
    margin-top: 8px;
    background: rgba(44, 44, 46, 0.95);
    border: 1px solid rgba(255, 255, 255, 0.1);
    border-radius: 12px;
    overflow: hidden;
    min-width: 100px;
    box-shadow: 0 8px 32px rgba(0, 0, 0, 0.5);
    -webkit-backdrop-filter: blur(20px);
    backdrop-filter: blur(20px);
}

.timbre-popup.show {
    display: block;
    animation: fadeIn 0.15s ease;
}

@keyframes fadeIn {
    from {
        opacity: 0;
        transform: translateY(-8px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

.timbre-option {
    padding: 12px 16px;
    color: #ffffff;
    font-size: 14px;
    font-weight: 500;
    text-align: center;
    cursor: pointer;
    transition: background 0.15s ease;
}

.timbre-option:hover {
    background: rgba(58, 58, 60, 0.8);
}

.timbre-option:active {
    background: rgba(72, 72, 74, 0.8);
}

.timbre-option.active {
    color: #0a84ff;
    background: rgba(10, 132, 255, 0.1);
}

.keyboard {
    display: grid;
    grid-template-columns: repeat(5, 1fr);
    gap: 12px;
    padding: 20px;
    width: min(90vw, 420px);
}

.key {
    aspect-ratio: 1;
    border-radius: 14px;
    background: linear-gradient(145deg, rgba(58, 58, 60, 0.9), rgba(44, 44, 46, 0.9));
    border: 1px solid rgba(255, 255, 255, 0.08);
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 4px;
    cursor: pointer;
    transition: all 0.15s ease;
    position: relative;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.3);
}

.key:hover {
    background: linear-gradient(145deg, rgba(68, 68, 70, 0.9), rgba(54, 54, 56, 0.9));
    border-color: rgba(255, 255, 255, 0.15);
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.4);
}

.key:active, .key.pressed {
    background: linear-gradient(145deg, rgba(10, 132, 255, 0.9), rgba(0, 122, 255, 0.9));
    border-color: rgba(10, 132, 255, 0.5);
    transform: scale(0.95);
    box-shadow: 0 2px 8px rgba(10, 132, 255, 0.3);
}

.note-name {
    color: #ffffff;
    font-size: clamp(14px, 4vw, 18px);
    font-weight: 600;
    pointer-events: none;
}

.key-hint {
    color: #8e8e93;
    font-size: clamp(10px, 2.5vw, 12px);
    font-family: -apple-system, BlinkMacSystemFont, "SF Mono", "Menlo", monospace;
    pointer-events: none;
    font-weight: 500;
}

.key:active .note-name,
.key.pressed .note-name {
    color: #ffffff;
}

.key:active .key-hint,
.key.pressed .key-hint {
    color: rgba(255, 255, 255, 0.8);
}

/* 移动端横屏适配 */
@media (orientation: landscape) and (max-height: 500px) {
    .keyboard {
        gap: 14px;
        padding: 20px;
        width: min(92vw, 500px);
    }

    .note-name {
        font-size: clamp(14px, 4vw, 18px);
    }

    .key-hint {
        font-size: clamp(11px, 2.5vw, 13px);
    }
}
