* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
    user-select: none;
    -webkit-user-select: none;
}

:root {
    /* 琴键位置微调参数（可根据实际效果调整） */
    --piano-right: 15%;
    --piano-top: 56%;
    --piano-width: 48%;
    --piano-height: 67%;
    --piano-gap: 1.4%;
    
    /* 每个琴键的独立宽度（从上到下：Fa, Mi, Re, Do, Ti, La, So, Fa）*/
    --key-width-1: 68%;  /* Fa - 最上面 */
    --key-width-2: 73%;  /* Mi */
    --key-width-3: 77%;  /* Re */
    --key-width-4: 81%;  /* Do */
    --key-width-5: 86%;  /* Ti */
    --key-width-6: 90%;  /* La */
    --key-width-7: 94%;  /* So */
    --key-width-8: 99%;  /* Fa - 最下面 */
    
    /* 每个琴键的左侧偏移（用于透视校正）*/
    --key-left-1: 0%;   /* Fa - 最上面 */
    --key-left-2: 0%;   /* Mi */
    --key-left-3: 0%;   /* Re */
    --key-left-4: 0%;   /* Do */
    --key-left-5: 0%;   /* Ti */
    --key-left-6: 0%;   /* La */
    --key-left-7: 0%;   /* So */
    --key-left-8: 0%;   /* Fa - 最下面 */
    
    /* 每个琴键的独立高度比例（flex-grow值，默认都是1表示均分）*/
    --key-height-1: 1;   /* Fa - 最上面 */
    --key-height-2: 1;   /* Mi */
    --key-height-3: 1;   /* Re */
    --key-height-4: 1;   /* Do */
    --key-height-5: 1;   /* Ti */
    --key-height-6: 1;   /* La */
    --key-height-7: 1;   /* So */
    --key-height-8: 1;   /* Fa - 最下面 */
}

body,
html {
    width: 100%;
    height: 100%;
    overflow: hidden;
    font-family: 'Comic Sans MS', 'Chalkboard SE', sans-serif;
}

.app-container {
    width: 100vw;
    height: 56.25vw;
    /* 16:9 Aspect Ratio (9/16 = 0.5625) */
    max-height: 100vh;
    max-width: 177.78vh;
    /* 16/9 = 1.7778 */
    margin: auto;
    position: absolute;
    top: 0;
    bottom: 0;
    left: 0;
    right: 0;
    background-image: url('assets/background.png');
    background-size: cover;
    /* Crop the 1:1 image to fill the 16:9 container */
    background-repeat: no-repeat;
    background-position: center;
    display: flex;
    justify-content: center;
    align-items: center;
    /* Align to center */
}

.main-title {
    position: absolute;
    top: 5%;
    width: 100%;
    text-align: center;
    font-size: 3rem;
    color: #fff;
    text-shadow: 2px 2px 4px rgba(0, 0, 0, 0.5);
    z-index: 10;
}

.piano-slot {
    display: flex;
    justify-content: center;
    align-items: center;
    width: 100%;
    height: 100%;
    position: relative;
}

/* Adjust piano container to overlay on background */
.piano-container {
    position: absolute;
    /* 精确定位琴键区域（基于1920x1080） */
    right: var(--piano-right);
    top: var(--piano-top);
    transform: translateY(-50%);
    width: var(--piano-width);
    height: var(--piano-height);
    display: flex;
    flex-direction: column;
    justify-content: space-between;
    gap: var(--piano-gap);
    padding: 0;
}


.key {
    flex: 1;
    width: 100%;
    margin: 0;
    background: transparent;
    /* 完全透明 */
    border: none;
    border-radius: 25px;
    cursor: pointer;
    position: relative;
    transition: all 0.15s ease;
    display: flex;
    flex-direction: row;
    justify-content: flex-start;
    align-items: center;
    padding: 0;
    opacity: 0;
    /* 默认不可见 */
    font-size: 1.2rem;
    min-height: 0;
    /* 防止flex压缩问题 */
}

/* 每个琴键的独立宽度、左侧偏移和高度设置 */
.key:nth-child(1) { width: var(--key-width-1); margin-left: var(--key-left-1); flex: var(--key-height-1); } /* Fa */
.key:nth-child(2) { width: var(--key-width-2); margin-left: var(--key-left-2); flex: var(--key-height-2); } /* Mi */
.key:nth-child(3) { width: var(--key-width-3); margin-left: var(--key-left-3); flex: var(--key-height-3); } /* Re */
.key:nth-child(4) { width: var(--key-width-4); margin-left: var(--key-left-4); flex: var(--key-height-4); } /* Do */
.key:nth-child(5) { width: var(--key-width-5); margin-left: var(--key-left-5); flex: var(--key-height-5); } /* Ti */
.key:nth-child(6) { width: var(--key-width-6); margin-left: var(--key-left-6); flex: var(--key-height-6); } /* La */
.key:nth-child(7) { width: var(--key-width-7); margin-left: var(--key-left-7); flex: var(--key-height-7); } /* So */
.key:nth-child(8) { width: var(--key-width-8); margin-left: var(--key-left-8); flex: var(--key-height-8); } /* Fa */

/* 调试模式：取消下面的注释可以看到琴键边界 */
/*
.key {
    opacity: 0.3 !important;
    border: 2px dashed red !important;
}
.piano-container {
    background: rgba(255, 0, 0, 0.1) !important;
    border: 3px solid red !important;
}
*/

/* 悬停时显示半透明效果 */
.key:hover {
    opacity: 0.25;
    background: rgba(255, 255, 255, 0.35);
}

/* 激活状态 */
.key:active,
.key.active {
    opacity: 0.4;
    background: rgba(255, 255, 255, 0.6);
    transform: scale(0.98);
}

.syllable {
    font-size: 0;
    /* 隐藏文字，只保留交互区域 */
    font-weight: bold;
    color: transparent;
    pointer-events: none;
}

#fullscreenBtn {
    position: absolute;
    top: 20px;
    right: 20px;
    background: rgba(255, 255, 255, 0.8);
    border: none;
    border-radius: 50%;
    width: 50px;
    height: 50px;
    font-size: 24px;
    cursor: pointer;
    z-index: 100;
    box-shadow: 0 2px 10px rgba(0, 0, 0, 0.2);
    transition: transform 0.2s, background 0.2s;
    display: flex;
    align-items: center;
    justify-content: center;
}

#fullscreenBtn:hover {
    transform: scale(1.1);
    background: #fff;
}

/* Floating Note Animation */
.floating-note {
    position: absolute;
    font-size: 2rem;
    color: #FF5733;
    /* Default, will be overridden by JS */
    pointer-events: none;
    animation: floatUp 1.5s ease-out forwards;
    z-index: 50;
    font-weight: bold;
    text-shadow: 1px 1px 2px rgba(255, 255, 255, 0.8);
}

@keyframes floatUp {
    0% {
        transform: translateY(0) scale(0.5) rotate(0deg);
        opacity: 0;
    }

    20% {
        transform: translateY(-20px) scale(1.2) rotate(-10deg);
        opacity: 1;
    }

    100% {
        transform: translateY(-100px) scale(1) rotate(10deg);
        opacity: 0;
    }
}

/* 可爱的示波器样式 */
.oscilloscope-container {
    position: absolute;
    top: 200px;
    left: 20px;
    background: linear-gradient(135deg, #fff5f7 0%, #fffef5 100%);
    border: 4px solid #fff;
    border-radius: 20px;
    padding: 15px;
    box-shadow: 
        0 8px 20px rgba(255, 105, 180, 0.3),
        0 0 0 3px rgba(255, 182, 193, 0.5),
        inset 0 2px 10px rgba(255, 255, 255, 0.8);
    z-index: 100;
    animation: gentleBounce 3s ease-in-out infinite;
}

.oscilloscope-title {
    text-align: center;
    font-size: 1rem;
    font-weight: bold;
    color: #ff69b4;
    margin-bottom: 8px;
    text-shadow: 2px 2px 4px rgba(255, 255, 255, 0.8);
    animation: colorShift 3s ease-in-out infinite;
}

#oscilloscope {
    display: block;
    width: 300px;
    height: 150px;
    border-radius: 15px;
    background: linear-gradient(135deg, #e8f5ff 0%, #fff0f5 100%);
    box-shadow: inset 0 2px 8px rgba(0, 0, 0, 0.1);
}

@keyframes gentleBounce {
    0%, 100% {
        transform: translateY(0);
    }
    50% {
        transform: translateY(-3px);
    }
}

@keyframes colorShift {
    0%, 100% {
        color: #ff69b4;
    }
    33% {
        color: #ffa07a;
    }
    66% {
        color: #87ceeb;
    }
}