body {
    display: flex;
    justify-content: center;
    align-items: center;
    min-height: 100vh;
    margin: 0;
    background: radial-gradient(circle at top, #3a3a3a, #151515 65%);
    font-family: "Segoe UI", Tahoma, Geneva, Verdana, sans-serif;
    color: white;
}

* {
    box-sizing: border-box;
}

.container {
    text-align: center;
    padding: 30px 20px 40px;
}

h1 {
    margin-bottom: 8px;
}

p {
    margin-bottom: 20px;
    color: #cfcfcf;
    font-size: 14px;
}

.controls {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
    gap: 12px;
    margin: 0 auto 24px;
    max-width: 720px;
    padding: 14px 16px;
    background: rgba(255, 255, 255, 0.06);
    border: 1px solid rgba(255, 255, 255, 0.1);
    border-radius: 12px;
    backdrop-filter: blur(6px);
}

.controls label {
    display: grid;
    gap: 6px;
    font-size: 12px;
    letter-spacing: 0.3px;
}

.controls input[type="range"] {
    width: 100%;
}

.hint {
    align-self: center;
    font-size: 12px;
    color: #f0d9a6;
    text-transform: uppercase;
    letter-spacing: 1px;
}

.piano {
    display: flex;
    justify-content: center;
    background: linear-gradient(180deg, #1d1d1d, #0f0f0f);
    padding: 20px 20px 10px 20px;
    border-radius: 14px;
    box-shadow: 0 14px 40px rgba(0, 0, 0, 0.6);
    position: relative;
}

.key {
    position: relative;
    cursor: pointer;
    border-radius: 0 0 5px 5px;
    transition: background 0.1s, transform 0.05s;
    display: flex;
    align-items: flex-end;
    justify-content: center;
    padding-bottom: 10px;
    font-size: 12px;
    font-weight: bold;
    user-select: none;
    -webkit-user-select: none;
}

.key.white {
    width: 60px;
    height: 250px;
    background: linear-gradient(to bottom, #fff 0%, #e7e7e7 100%);
    border: 1px solid #bbb;
    border-top: none;
    border-bottom: 4px solid #bbb;
    color: #777;
    z-index: 1;
}

.key.white:active, .key.white.active {
    background: linear-gradient(to bottom, #f0f0f0 0%, #d8d8d8 100%);
    box-shadow: inset 0 0 5px rgba(0, 0, 0, 0.2);
    transform: translateY(2px);
    border-bottom: 2px solid #bbb;
}

.key.black {
    width: 40px;
    height: 150px;
    background: linear-gradient(to bottom, #2c2c2c 0%, #000 100%);
    border: 1px solid #000;
    border-bottom: 4px solid #111;
    margin-left: -20px;
    margin-right: -20px;
    z-index: 2;
    color: #fff;
    padding-bottom: 20px;
}

.key.black:active, .key.black.active {
    background: linear-gradient(to bottom, #1f1f1f 0%, #000 100%);
    box-shadow: inset 0 0 5px rgba(255, 255, 255, 0.2);
    transform: translateY(2px);
    border-bottom: 2px solid #111;
}

.key span {
    pointer-events: none;
}

@media (max-width: 760px) {
    .piano {
        transform: scale(0.86);
    }
}

@media (max-width: 520px) {
    .piano {
        transform: scale(0.74);
    }
}

.pedal-label {
    display: inline-block;
    color: #ff4d4d; /* 빨강 (안 누름) */
    font-weight: bold;
    transition: color 0.1s, transform 0.1s;
    pointer-events: auto !important;
    cursor: pointer;
    padding: 5px 10px;
    user-select: none;
}

.pedal-label.active {
    color: #4dff4d; /* 초록 (누름) */
    text-shadow: 0 0 5px #4dff4d;
}

.pedal-label:hover {
    cursor: pointer;
    transform: scale(1.1);
}

/* --- Mobile Orientation Warning --- */
#portrait-warning {
    display: none;
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.95);
    z-index: 9999;
    justify-content: center;
    align-items: center;
    text-align: center;
    padding: 20px;
}

#portrait-warning .message {
    color: white;
    font-size: 1.2rem;
    line-height: 1.6;
    animation: fadeIn 0.5s ease-out;
}

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

/* Portrait Mode Detection */
@media (orientation: portrait) and (max-width: 768px) {
    #portrait-warning {
        display: flex;
    }
    .container {
        filter: blur(5px);
    }
}
