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

/* 1. 引入字体 */
@font-face {
  font-family: myFont;
  src: url("./琴素材/FZFWZhuZiAYuanJWB.ttf") format("truetype");
  font-weight: normal;
  font-style: normal;
  font-display: swap;
}

/* 2. 全局强制应用 */
* {
  font-family: myFont !important;
}
html, body {
  font-family: myFont !important;
}

button {
    border: none;
    outline: none;
    background: none;
    cursor: pointer;
}

body {
    font-family: Arial, sans-serif;
    background-image: url('琴素材/背景.png');
    background-size: cover;
    background-position: center;
    background-repeat: no-repeat;
    min-height: 100vh;
    display: flex;
    justify-content: center;
    align-items: center;
}

.container {
    background-color: transparent;
    border-radius: 20px;
    padding: 30px;
    width: 90%;
    max-width: 1200px;
    transition: all 0.3s ease;
    display: flex;
    gap: 30px;
    position: relative;
}

.hidden {
    display: none !important;
}

/* 左侧边栏 */
.left-sidebar {
    position: fixed;
    top: 10px;
    left: 10px;
    flex-direction: column;
    gap: 10px;
    align-items: center;
    z-index: 1000;
    margin: 0;
    padding: 0;
    background: none;
    border: none;
}

.sidebar-btn {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 8px;
    background: none;
    border: none;
    cursor: pointer;
    padding: 10px;
    border-radius: 10px;
    transition: all 0.2s ease;
}

.sidebar-btn:hover {
    transform: scale(1.05);
}

.sidebar-btn img {
    width: 50px;
    height: 50px;
    object-fit: contain;
    padding: 8px; /* 控制底板大小 */
    box-sizing: border-box;

    background-image: url(琴素材/声明和设置公用的底板.png);
    background-size: 100% 100%;
    background-repeat: no-repeat;
    background-position: center;
}

.sidebar-btn span {
    font-size: 20px;
    color: #ffffff;
    font-weight: 500;
    text-shadow: 0 0 0 #000, 0 0 1px #000, 0 0 1px #000;
}

/* 钢琴容器 */
.piano-container {
    flex: 1;
    display: flex;
    justify-content: center;
    align-items: center;
    position: relative;
}

.piano-circle {
    display: flex;
    flex-direction: column;
    gap: 30px;
    align-items: center;
}

/* 八度行 */
.octave-row {
    display: flex;
    gap: 25px;
    justify-content: center;
    position: relative;
    padding: 20px 0;
}

.octave-row::before {
    content: '';
    position: absolute;
    top: 40px;
    left: -90px;
    right: 0;
    bottom: 0;
    background-image: 
        linear-gradient(to bottom, #ffffff9e 1px, transparent 1px),
        linear-gradient(to bottom, #ffffff9e 1px, transparent 1px),
        linear-gradient(to bottom,#ffffff9e 1px, transparent 1px),
        linear-gradient(to bottom, #ffffff9e 1px, transparent 1px),
        linear-gradient(to bottom, #ffffff9e 1px, transparent 1px);
    background-size: 100% 33.33%;
    background-position: 0 10%, 0 25%, 0 40%, 0 55%, 0 70%;
    background-repeat: no-repeat;
    opacity: 0.3;
    z-index: 0;
}

/* 钢琴键样式 */
.piano-key {
    position: relative;
    width: 90px;
    height: 90px;
    background-image: url('琴素材/音符按钮底板.png');
    background-size: contain;
    background-repeat: no-repeat;
    background-position: center;
    cursor: pointer;
    transition: all 0.2s ease;
    display: flex;
    justify-content: center;
    align-items: center;
    z-index: 1;
}

/* 设置界面选中音符按键样式 */
#settings-container .piano-key.selected {
    position: relative;
}

#settings-container .piano-key.selected::before {
    content: '';
    position: absolute;
    top: -15px;
    left: -15px;
    right: -15px;
    bottom: -15px;
    background-image: url('琴素材/选中.png');
    background-size: contain;
    background-repeat: no-repeat;
    background-position: center;
    z-index: 1;
}

.piano-key:hover {
    transform: scale(1.05);
}

.piano-key.active {

    background-image: url('琴素材/点击特效.gif');
    background-size: 120% 120%;
    transform: scale(0.95);
}

.key-content {
    text-align: center;
    color: white;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 4px;
}

.note-name {
    font-size: 20px;
    font-weight: bold;
    color: #3498db;
}

.piano-key.active .note-name {
    color: white;
    text-shadow: 
        -1px -1px 0 #3498db,
        1px -1px 0 #3498db,
        -1px 1px 0 #3498db,
        1px 1px 0 #3498db,
        -2px 0 0 #3498db,
        2px 0 0 #3498db,
        0 -2px 0 #3498db,
        0 2px 0 #3498db;
}

.note-solfege {
    font-size: 15px;
    color: #000000;
}

.key-binding {
    margin-top: 5px;
    display: flex;
    justify-content: center;
    align-items: center;
}

.key-binding img {
    width: 20px;
    height: 20px;
    object-fit: contain;
}

/* 键位图标容器 */
.key-icon-container {
    position: relative;
    display: flex;
    flex-direction: column;
    align-items: center;
}

.key-icon {
    margin-top: 5px;
    display: flex;
    justify-content: center;
    align-items: center;
}

.octave-icon {
    position: absolute;
    left: -80px;
    top: 50%;
    transform: translateY(-50%);
    display: flex;
    justify-content: center;
    align-items: center;
}

.octave-icon img {
    width: 60px;
    height: 60px;
    object-fit: contain;
}

.key-icon img {
    width: 20px;
    height: 20px;
    object-fit: contain;
}

/* 人物元素 */
.character-container {
    position: fixed;
    bottom: 20px;
    right: 20px;
    z-index: 100;
}

.character {
    position: relative;
    width: 200px;
    height: 200px;
    display: flex;
    flex-direction: column;
    align-items: center;
}

.character img {
    width: 150px;
    height: auto;
    object-fit: contain;
    transition: transform 0.3s ease;
}

.character-note {
    position: absolute;
    bottom: 100%;
    left: 50%;
    transform: translateX(-50%);
    background-color: rgba(255, 255, 255, 0.8);
    border-radius: 15px;
    padding: 5px 15px;
    font-size: 18px;
    font-weight: bold;
    color: #3498db;
    opacity: 0;
    transition: opacity 0.3s ease;
    text-shadow: 1px 1px 1px rgba(0,0,0,0.1);
    white-space: nowrap;
    z-index: 10;
}

.character-note.show {
    opacity: 1;
    animation: float 1s ease-in-out;
}

/* 手机版适配：人物显示在左下角，下面，中间对齐 */
@media (max-width: 768px) {
    .character-container {
        top: 70%;
        left:  80%;

    }
    
    .character {
        width: 120px;
        height: 120px;
    }
    
    .character img {
        width: 80px;
    }
    
    .character-note {
        font-size: 12px;
        padding: 2px 8px;
        top: auto;
        bottom: 100%;
    }
}

@keyframes float {
    0% {
        transform: translateX(-50%) translateY(0);
    }
    50% {
        transform: translateX(-50%) translateY(-10px);
    }
    100% {
        transform: translateX(-50%) translateY(0);
    }
}

/* 设置界面样式 */
#settings-container {
    background-color: #e3f2fd;
    background-image: url('琴素材/背景上的蝴蝶气球.png');
    background-size: 200px;
    background-repeat: repeat;
    border-radius: 0;
    padding: 40px;
    width: 100vw;
    height: 100vh;
    max-width: none;
    min-height: none;
    display: flex;
    flex-direction: column;
    position: relative;
    overflow: hidden;
}

#settings-container::before {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    opacity: 0.15;
    z-index: 0;
}

.settings-header {
    display: flex;
    justify-content: center;
    align-items: center;
    padding-bottom: 50px;
    border-bottom: 2px dashed #90caf9;
    position: relative;
    z-index: 1;
}

.settings-instruction {
    text-align: center;
    margin-bottom: 40px;
    font-size: 16px;
    color: #555;
    position: relative;
    z-index: 1;
}

.settings-piano {
    flex: 1;
    display: flex;
    flex-direction: column;
    gap: 30px;
    align-items: center;
    justify-content: center;
    position: relative;
    z-index: 1;
}

.settings-title {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 5px;
    text-align: center;
    position: absolute;
    bottom: -15px;
    padding: 0 15px;
    z-index: 2;
}

.settings-title img {
    width: 40px;
    height: 40px;
    object-fit: contain;
    margin-bottom: 5px;
}

.settings-title h2 {
    color: #333;
    font-size: 18px;
    background-color: #fff9c4;
    padding: 8px 20px;
    border-radius: 20px;
    margin: 0;
}

.close-btn {
    position: absolute;
    top: 20px;
    right: 20px;
    z-index: 1000;
}

#close-settings:hover {
    background-color: transparent;
    transform: none;
}

.settings-instruction {
    text-align: center;
    margin-bottom: 40px;
    font-size: 16px;
    color: #555;
}

.settings-piano {
    flex: 1;
    display: flex;
    flex-direction: column;
    gap: 30px;
    align-items: center;
    justify-content: center;
}

.settings-footer {
    margin-top: 40px;
    display: flex;
    justify-content: flex-end;
}

.back-btn {
    background-color: #fff;
    border: 1px solid #ddd;
    padding: 10px 20px;
    border-radius: 20px;
    font-size: 14px;
    color: #333;
    cursor: pointer;
    transition: all 0.2s ease;
}

.back-btn:hover {
    background-color: #f5f5f5;
    transform: scale(1.05);
}

/* 键位冲突提示 */
.key-conflict {
    position: relative;
}

.key-conflict::before {
    content: '';
    position: absolute;
    top: -15px;
    left: -15px;
    right: -15px;
    bottom: -15px;
    background-image: url('琴素材/红圈.png');
    background-size: contain;
    background-repeat: no-repeat;
    background-position: center;
    z-index: 1;
}

.key-conflict::after {
    content: '';
    position: absolute;
    top: -10px;
    right: -10px;
    width: 20px;
    height: 20px;
    background-image: url('琴素材/感叹号.png');
    background-size: contain;
    background-repeat: no-repeat;
    background-position: center;
    z-index: 2;
}

@keyframes pulse {
    0% {
        transform: scale(1);
        opacity: 1;
    }
    50% {
        transform: scale(1.2);
        opacity: 0.8;
    }
    100% {
        transform: scale(1);
        opacity: 1;
    }
}

/* 禁止绑定提示 */
.forbidden-binding {
    border: 2px solid #f44336 !important;
    box-shadow: 0 0 10px rgba(244, 67, 54, 0.5) !important;
}

/* 提示弹窗样式 */
.tooltip {
    position: fixed;
    top: 20%;
    left: 50%;
    transform: translateX(-50%);
    background-image: url('琴素材/提示底板.png');
    background-size: contain;
    background-repeat: no-repeat;
    background-position: center;
    padding: 20px 40px;
    z-index: 1000;
    animation: fadeIn 0.3s ease;
    text-align: center;
    min-width: 300px;
    height: 60px;
    display: flex;
    align-items: center;
    justify-content: center;
}

.tooltip-content {
    display: flex;
    justify-content: center;
    align-items: center;
    height: 100%;
}

.tooltip-content p {
    margin: 0;
    font-size: 16px;
    text-align: center;
    color: #333;
    font-weight: 500;
}

/* 声明界面样式 */
#about-container {
    background-color: #fff9e6;
    border: 2px solid #e6d2a3;
    border-radius: 20px;
    padding: 40px;
    width: 80vw;
    max-width: 600px;
    min-height: 400px;
    display: flex;
    flex-direction: column;
    position: fixed;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    z-index: 1000;
    overflow: hidden;
    justify-content: center;
    align-items: center;
    box-shadow: 0 4px 20px rgba(0,0,0,0.1);
}

#about-container::before {
    content: '✿------------------------------------------✿';
    position: absolute;
    top: 90px;
    left: 0;
    right: 0;
    text-align: center;
    color: #e6d2a3;
    font-size: 14px;
    letter-spacing: 2px;
}

.about-content {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    width: 90%;
    position: relative;
    z-index: 1;
    margin-top: 20px;
}

.about-title {
    color: #d4af37;
    font-size: 24px;
    margin-bottom: 30px;
    text-align: center;
    font-weight: bold;
    text-shadow: 1px 1px 1px rgba(0,0,0,0.1);
}

.about-text {
    background-color: white;
    border-radius: 15px;
    padding: 25px;
    margin-bottom: 30px;
    text-align: left;
    line-height: 1.6;
    font-size: 16px;
    color: #333;
    width: 100%;
    box-shadow: 0 2px 10px rgba(0,0,0,0.05);
}

.confirm-btn {
    background: none;
    border: none;
    cursor: pointer;
    transition: all 0.2s ease;
}

.confirm-btn:hover {
    transform: scale(1.05);
}

.confirm-btn img {
    width: 150px;
    height: auto;
    object-fit: contain;
}

#close-about {
    position: absolute;
    top: -15px;
    right: -15px;
    z-index: 1001;
    width: 40px;
    height: 40px;
    display: flex;
    align-items: center;
    justify-content: center;
}

#close-about img {
    width: 40px;
    height: 40px;
    object-fit: contain;
}

/* 提示弹窗样式 */
.tooltip {
    background-image: url('琴素材/提示底板.png');
    background-size: contain;
    background-repeat: no-repeat;
    background-position: center;
    padding: 20px 40px;
    z-index: 1000;
    text-align: center;
    min-width: 300px;
    height: 60px;
    display: flex;
    align-items: center;
    justify-content: center;
}

.tooltip-content {
    display: flex;
    justify-content: center;
    align-items: center;
    height: 100%;
}

.tooltip-content p {
    margin: 0;
    font-size: 16px;
    text-align: center;
    color: #c59830;
    font-weight: 500;
}

/* 按钮样式 */
.btn {
    background: none;
    border: none;
    cursor: pointer;
    padding: 10px;
    border-radius: 10px;
    transition: all 0.2s ease;
}

.btn:hover {
    background-color: rgba(0, 0, 0, 0.1);
    transform: scale(1.05);
}

.btn img {
    width: 30px;
    height: 30px;
    object-fit: contain;
}

/* 动画效果 */
@keyframes fadeIn {
    from {
        opacity: 0;
        transform: translate(-50%, -50%) scale(0.9);
    }
    to {
        opacity: 1;
        transform: translate(-50%, -50%) scale(1);
    }
}

/* 响应式设计 */
@media (max-width: 768px) {
    .container {
        flex-direction: column;
        align-items: center;
        padding: 20px;
        width: 95%;
    }
    
    .left-sidebar {
        flex-direction: row;
        gap: 15px;
    }
    
    .piano-key {
        width: 60px;
        height: 60px;
    }
    
    .octave-row {
        gap: 15px;
    }
    
    .key-content {
        font-size: 12px;
    }
    
    .note-name {
        font-size: 12px;
    }
    
    .note-solfege {
        font-size: 10px;
    }
    
    .key-binding {
        font-size: 14px;
    }
}

@media (max-width: 480px) {
    .piano-key {
        width: 50px;
        height: 50px;
    }
    
    .octave-row {
        gap: 10px;
    }
    
    .key-binding-list {
        grid-template-columns: 1fr;
    }
}



@media screen and (max-width: 768px) {

    .key-icon, 
    .key-icon img, 
    .gamepad-icon,
    .key-binding {
        display: none !important;
        visibility: hidden !important;
        pointer-events: none !important;
    }

    .container {
        flex-direction: column;
        align-items: center;
        padding: 5px;
        width: 100%;
        height: 100vh;
        justify-content: flex-start;
        overflow: hidden;
    }

    .left-sidebar {
        position: relative;
        top: 0;
        margin: 10px 0 0 0;
        flex-direction: row;
        justify-content: center;
        width: 100%;
        gap: 15px;
        z-index: 100;
    }

    .sidebar-btn img { width: 32px; height: 32px; }
    .sidebar-btn span { font-size: 12px; }

    .piano-container {
        width: 100%;
        height: 420px; 
        margin-top: -45px; 
        display: flex;
        justify-content: center;
        align-items: center;
        position: relative;
        pointer-events: none; 
    }

    .piano-circle {
        position: relative;
        width: 320px;
        height: 320px;
        transform: scale(1.1); 
    }

    .octave-row {
        position: absolute;
        inset: 0;
        display: flex;
        justify-content: center;
        align-items: center;
        pointer-events: none; 
    }

    .octave-icon {
        top: -15px;
        width: 18px;
        height: 18px;
        pointer-events: none !important; 
        z-index: -1;
    }

    .key-icon-container {
        position: absolute;
        left: 50%;
        top: 50%;
        margin-left: -22px; 
        margin-top: -22px;
        pointer-events: auto; 
    }

    .piano-key {
        width: 44px;
        height: 44px;
        display: flex;
        justify-content: center;
        align-items: center;
    }

    .key-content {
        display: flex;
        flex-direction: column;
        align-items: center;
        justify-content: center;
    }

    .note-name { font-size: 14px; margin-bottom: 2px; }
    .note-solfege { font-size: 11px; }

    .key-icon-container:nth-child(1) { --i: 0; }
    .key-icon-container:nth-child(2) { --i: 1; }
    .key-icon-container:nth-child(3) { --i: 2; }
    .key-icon-container:nth-child(4) { --i: 3; }
    .key-icon-container:nth-child(5) { --i: 4; }
    .key-icon-container:nth-child(6) { --i: 5; }
    .key-icon-container:nth-child(7) { --i: 6; }

    .octave-row:nth-child(1) .key-icon-container { --radius: 135px; } 
    .octave-row:nth-child(2) .key-icon-container { --radius: 90px; }  
    .octave-row:nth-child(3) .key-icon-container { --radius: 45px; }  

    .key-icon-container {
        transform: rotate(calc(var(--i) * 360deg / 7 - 90deg)) 
                   translate(var(--radius)) 
                   rotate(calc(var(--i) * -360deg / 7 + 90deg));
    }
}
