:root {
    --rhythm-bar-height: 110px;
    --min-canvas-size: 150px;
    --content-padding: 20px;
    --controls-height: 80px;
}

body {
    display: flex;
    flex-direction: column;
    align-items: center;
    background-color: white;
    background-size: cover;
    background-position: center;
    background-attachment: fixed;
    background-repeat: no-repeat;
    font-family: Arial, sans-serif;
    margin: 0;
    padding: var(--content-padding);
    min-height: 100vh;
    box-sizing: border-box;
    overflow-x: hidden;
    overflow-y: auto;
    padding-bottom: calc(var(--controls-height) + 30px); /* 为底部固定控制区域留出空间 */
    transition: background-image 0.5s ease;
}

body.bg-none {
    background-image: none;
}

body.bg-background001 {
    background-image: url('../images/desktop/001.jpg');
}

body.bg-background002 {
    background-image: url('../images/desktop/002.jpg');
}

body.bg-background003 {
    background-image: url('../images/desktop/003.jpg');
}

.controls {
    width: 100%;
    height: var(--controls-height);
    margin: 10px 0 0 0; /* 调整上下边距 */
    padding: 10px 20px;
    display: flex;
    gap: 15px;
    align-items: center;
    justify-content: center;
    flex-wrap: wrap;
    box-sizing: border-box;
    background-color: #fff;
    z-index: 1;
}

/* 底部固定控制面板样式 */
.fixed-bottom {
    position: fixed;
    bottom: 0;
    left: 0;
    margin: 0;
    box-shadow: 0 -2px 5px rgba(0, 0, 0, 0.1);
    z-index: 100;
    border-top: 1px solid #eee;
    padding: 10px 20px;
    background-color: rgba(255, 255, 255, 0.85);
    backdrop-filter: blur(5px); /* 添加模糊效果 */
}

/* 控制面板样式 */
.controls {
    width: 100%;
    height: var(--controls-height);
    margin: 10px 0 0 0; /* 调整上下边距 */
    padding: 10px 20px;
    display: flex;
    gap: 15px;
    align-items: center;
    justify-content: center;
    flex-wrap: wrap;
    box-sizing: border-box;
    background-color: #fff;
    z-index: 1;
}

/* 修改底部控制区域样式 */
.controls.fixed-bottom {
    display: flex;
    flex-wrap: nowrap;
    overflow-x: auto;
    overflow-y: hidden; /* 防止竖向滚动 */
    white-space: nowrap;
    width: 100%;
    padding: 10px;
    box-sizing: border-box;
    -webkit-overflow-scrolling: touch; /* 增强iOS滚动体验 */
    scrollbar-width: thin; /* Firefox 细滚动条 */
}

/* 确保控制元素不会缩小 */
.controls.fixed-bottom .slider-container {
    flex: 0 0 auto;
    margin-right: 12px;
    min-width: 120px;
    white-space: nowrap;
}

/* 播放按钮样式 */
.controls.fixed-bottom #playButton {
    flex: 0 0 auto;
    margin-right: 10px;
}

/* 用于推动设置按钮到最右侧的空白元素 */
.controls.fixed-bottom .spacer {
    flex: 1;
}

/* 确保设置按钮固定在最右侧 */
.controls.fixed-bottom .settings-button {
    flex: 0 0 auto;
    margin-left: 0;
    margin-right: 5px;
}

.slider-container {
    display: flex;
    flex-direction: column;
    gap: 5px;
    min-width: 120px;
}

.slider-label {
    display: flex;
    justify-content: space-between;
    align-items: center;
    font-size: 14px;
}

.value-display {
    color: #666;
}

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

select {
    padding: 4px 8px;
    border-radius: 4px;
    border: 1px solid #ddd;
}

#playButton {
    padding: 8px 12px;
    font-size: 14px;
    min-width: 60px;
    cursor: pointer;
    background-color: #4CAF50;
    color: white;
    border: none;
    border-radius: 4px;
    transition: background-color 0.3s;
}

#playButton:hover {
    background-color: #45a049;
}

.canvas-grid-container {
    display: grid;
    grid-template-columns: repeat(4, 1fr);
    grid-template-rows: 1fr;
    gap: 15px;
    width: 100%;
    max-width: 100%;
    margin-top: calc(var(--rhythm-bar-height) + 20px); /* 为顶部节奏型栏留出空间 */
    margin-bottom: 20px;
    height: auto;
    min-height: 300px;
    overflow-x: auto; /* 默认状态允许横向滚动 */
    padding: 15px;
    border-radius: 8px;
    /*background-color: rgba(250, 250, 250, 0.7);*/
    align-items: center;
    flex: 1; /* 填充可用空间 */
    position: relative;
    /*backdrop-filter: blur(3px);  添加模糊效果 */
}

.canvas-container {
    position: relative;
    display: flex;
    justify-content: center;
    align-items: center;
    background-color: rgba(249, 249, 249, 0.8);
    border-radius: 15px;
    padding: 4px; /* 减小内边距，从10px改为4px */
    box-shadow: 0 2px 10px rgba(0, 0, 0, 0.15);
    transition: all 0.3s ease;
    height: auto;
    min-height: 200px;
    aspect-ratio: 1/1;
    min-width: 200px;
    flex-shrink: 0;
    backdrop-filter: blur(2px);
}

.canvas-container:hover {
    box-shadow: 0 5px 15px rgba(0, 0, 0, 0.25);
    transform: translateY(-2px);
}

.canvas-container.active-drop-target {
    background-color: rgba(33, 150, 243, 0.2);
    box-shadow: 0 0 0 2px #2196F3;
}

canvas {
    margin: 0;
    width: 100%;
    height: 100%;
    aspect-ratio: 1/1;
    min-width: 150px;
    min-height: 150px;
    max-height: 100%;
    border-radius: 10px;
    /*background-color: #fff;*/
}

.rhythm-patterns-bar {
    position: fixed;
    width: 100%;
    height: var(--rhythm-bar-height);
    /*background-color: rgba(245, 245, 245, 0.85);*/
    /*backdrop-filter: blur(5px); /* 添加模糊效果 */
    display: flex;
    justify-content: center;
    align-items: center;
    gap: 20px;
    padding: 10px;
    box-sizing: border-box;
    overflow-x: auto;
    overflow-y: hidden;
    z-index: 10;
}

/* 顶部节奏型栏样式 */
.rhythm-patterns-bar.top-bar {
    top: 0;
    left: 0;
    box-shadow: 0 2px 10px rgba(0, 0, 0, 0.1);
}

.empty-state {
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 10px;
    text-align: center;
    color: #666;
}

.empty-state.hidden {
    display: none;
}

.empty-state-icon {
    font-size: 48px;
    color: #999;
}

.empty-state-text {
    font-size: 18px;
    font-weight: bold;
}

.empty-state-subtext {
    font-size: 14px;
}

.drop-zone {
    position: absolute;
    display: none;
    justify-content: center;
    align-items: center;
    border: 3px dashed #2196F3;
    border-radius: 15px;
    background-color: rgba(33, 150, 243, 0.1);
    z-index: 1;
}

.drop-zone.active {
    display: flex;
}

.drop-zone-text {
    font-size: 24px;
    color: #2196F3;
    font-weight: bold;
}

.language-select {
    position: static;
    margin: 0;
    box-shadow: 0 2px 8px rgba(0,0,0,0.04);
}

/* 响应式布局 */
@media (max-width: 1200px) {
    .canvas-grid-container {
        grid-template-columns: repeat(2, 1fr);
        grid-template-rows: repeat(2, auto);
        gap: 10px;
    }
}

/* 标准移动设备竖屏模式 - 2×2布局 */
@media only screen and (max-width: 767px) and (orientation: portrait) {
    .canvas-grid-container {
        grid-template-columns: repeat(2, 1fr);
        grid-template-rows: repeat(2, auto);
        gap: 10px;
    }
    
    .canvas-container {
        width: 95%;
        margin: 0 auto;
        min-height: 150px;
        min-width: 150px;
    }
    
    .rhythm-patterns-bar {
        overflow-x: auto;
        justify-content: flex-start;
        padding-left: 10px;
    }
    
    .slider-container {
        min-width: 100px;
    }
    
    /* 优化设置弹窗 */
    .settings-modal {
        width: 90vw;
        max-height: 85vh;
        overflow-y: hidden; /* 防止整体滚动 */
    }
    
    .settings-user-section {
        padding: 10px;
        margin-bottom: 8px;
        flex-wrap: wrap; /* 允许在窄屏幕上换行 */
    }
    
    #userStatus {
        font-size: 14px;
        margin-bottom: 5px;
    }
    
    .user-actions {
        margin-left: auto; /* 将按钮推到右侧 */
    }
    
    .user-actions button {
        padding: 5px 10px;
        font-size: 13px;
    }
    
    .settings-group {
        display: flex;
        flex-direction: column;
        gap: 10px;
        max-height: calc(85vh - 90px); /* 限制高度 */
        overflow-y: auto; /* 只在设置组内部允许滚动 */
        padding-right: 5px; /* 为滚动条留出空间 */
    }
    
    .settings-group .slider-container {
        width: 100%;
    }
    
    .user-actions a {
        padding: 5px 10px;
        font-size: 13px;
    }
    
    /* 更紧凑的标题 */
    .settings-modal h2 {
        font-size: 18px;
        margin: 5px 0 10px 0;
    }
    
    /* 底部控制区域优化 - 两行布局 */
    .fixed-bottom {
        padding: 8px 10px; /* 覆盖通用样式 */
    }
    
    .controls.fixed-bottom {
        flex-wrap: wrap; /* 允许换行 */
        height: auto; /* 自适应高度 */
        max-height: none; /* 移除最大高度限制 */
        padding: 8px 10px;
        justify-content: space-between; /* 两端对齐 */
        overflow-x: hidden; /* 防止横向滚动 */
        position: relative; /* 为绝对定位的子元素提供参考 */
    }
    
    /* 第一行：速度滑块 */
    .controls.fixed-bottom .slider-container:nth-child(1) {
        width: 60%; /* 速度滑块占左侧宽度 */
        min-width: auto; /* 覆盖默认最小宽度 */
        margin-right: 0;
        margin-bottom: 10px;
        order: 1; /* 显示顺序 */
    }
    
    /* 第二行：节奏型音量和节拍器音量滑块 */
    .controls.fixed-bottom .slider-container:nth-child(2),
    .controls.fixed-bottom .slider-container:nth-child(3) {
        width: 48%; /* 两个音量滑块平分宽度 */
        min-width: auto;
        margin-right: 0;
        order: 3; /* 显示顺序，在第二行 */
    }
    
    /* 调整滑块标签样式，使其更紧凑 */
    .controls.fixed-bottom .slider-label {
        font-size: 12px;
        margin-bottom: 2px;
        display: flex;
        justify-content: space-between;
    }
    
    /* 调整滑块本身的尺寸 */
    .controls.fixed-bottom input[type="range"] {
        height: 20px;
    }
    
    /* 调整值显示的样式 */
    .controls.fixed-bottom .value-display {
        font-size: 12px;
    }
    
    /* 播放按钮位于第一行右侧 */
    .controls.fixed-bottom #playButton {
        position: absolute;
        top: 8px;
        right: 60px; /* 距离右边缘的距离，留出设置按钮的空间 */
        margin: 0;
        padding: 8px 15px;
        width: 80px; /* 固定宽度 */
        font-size: 14px;
        order: 2; /* 调整显示顺序 */
    }
    
    .controls.fixed-bottom .spacer {
        display: none; /* 不需要空白元素 */
    }
    
    /* 设置按钮位于第一行最右侧 */
    .controls.fixed-bottom .settings-button {
        position: absolute;
        top: 8px;
        right: 10px; /* 贴近右边缘 */
        margin: 0;
        width: 40px;
        height: 40px;
        order: 2; /* 调整显示顺序 */
    }
    
    /* 更新body底部内边距以适应更高的控制区 */
    body {
        padding-bottom: 110px; /* 为两行控制区域留出空间，比三行时少一些 */
    }
}

/* 特小屏幕设备的额外优化 */
@media only screen and (max-width: 320px) and (orientation: portrait) {
    .controls.fixed-bottom .slider-label {
        font-size: 11px;
    }
    
    .controls.fixed-bottom .value-display {
        font-size: 11px;
    }
    
    /* 在特小屏幕上，进一步优化第一行的播放按钮 */
    .controls.fixed-bottom #playButton {
        width: 70px;
        font-size: 13px;
        right: 50px;
        padding: 6px 10px;
    }
    
    /* 为特小屏幕优化设置按钮 */
    .controls.fixed-bottom .settings-button {
        width: 36px;
        height: 36px;
        right: 8px;
    }
    
    body {
        padding-bottom: 100px; /* 略微减少内边距 */
    }
}

/* 移动设备横屏模式 - 1×4布局 */
@media only screen and (max-width: 1024px) and (orientation: landscape) {
    body {
        overflow-y: hidden; /* 防止竖向滚动 */
        height: 100vh; /* 限制高度为视口高度 */
        padding: 5px 5px calc(var(--controls-height) + 10px) 5px; /* 统一设置内边距，保留底部空间 */
    }
    
    .canvas-grid-container {
        grid-template-columns: repeat(4, 1fr);
        grid-template-rows: 1fr;
        gap: 5px; /* 进一步减小间距 */
        overflow-x: hidden; /* 移除横向滚动条 */
        overflow-y: hidden; /* 移除竖向滚动条 */
        width: 100%;
        justify-content: center;
        align-items: center;
        min-height: 120px; /* 进一步减小最小高度 */
        height: calc(100vh - 140px); /* 设置固定高度 */
        max-height: calc(100vh - 140px); /* 限制最大高度 */
        padding: 3px; /* 减小内边距 */
        margin-top: 70px; /* 调整为更小的顶部边距，与顶部栏高度匹配 */
        margin-bottom: 0;
    }
    
    .canvas-container {
        min-width: 100px; /* 进一步减小最小宽度 */
        min-height: 100px; /* 进一步减小最小高度 */
        width: 100%; /* 确保容器占满整个单元格 */
        /* height: 100%; 确保容器占满整个单元格高度 */
        margin: 0;
        padding: 2px; /* 减小内边距 */
        box-shadow: 0 1px 5px rgba(0, 0, 0, 0.1); /* 减弱阴影效果 */
    }
    
    /* 调整画布的最小尺寸 */
    canvas {
        min-width: 90px;
        min-height: 90px;
    }
    
    /* 调整顶部工具栏，使其在横屏模式下更紧凑 */
    .rhythm-patterns-bar.top-bar {
        height: 60px; /* 固定高度 */
        min-height: auto;
        padding: 3px;
    }
    
    /* 底部控制区域优化 */
    .controls.fixed-bottom {
        overflow-y: hidden; /* 明确防止竖向滚动 */
        padding: 3px 5px;
        max-height: 45px;
        height: 45px;
    }
    
    /* 调整滑块区域大小 */
    .controls.fixed-bottom .slider-container {
        min-width: 90px;
        margin-right: 5px;
        height: 40px; /* 限制高度 */
    }
    
    /* 调整滑块标签显示 */
    .controls.fixed-bottom .slider-label {
        font-size: 12px;
    }
    
    /* 确保滑块本身不会导致溢出 */
    .controls.fixed-bottom input[type="range"] {
        height: 15px;
        margin: 0;
    }
    
    /* 确保设置按钮始终保持在最右侧 */
    .controls.fixed-bottom .spacer {
        flex: 1;
        min-width: 10px;
    }
    
    /* 缩小按钮 */
    .settings-button {
        width: 35px;
        height: 35px;
        font-size: 1.2em;
        margin: 0 5px;
    }
    
    .controls.fixed-bottom .settings-button {
        margin-right: 2px;
    }
    
    /* 调整播放按钮在横屏模式下的样式 */
    .controls.fixed-bottom #playButton {
        padding: 5px 10px;
        min-width: 50px;
        margin-right: 5px;
        font-size: 13px;
    }
    
    /* 优化节奏型图标样式 */
    .rhythm-patterns-bar .rhythm-pattern-icon,
    .rhythm-patterns-bar .rhythm-action-button {
        height: 50px;
        width: 50px;
        padding: 2px;
        font-size: 0.8em;
    }
    
    .rhythm-patterns-bar .action-icon,
    .rhythm-patterns-bar .refresh-icon {
        font-size: 20px;
        margin-bottom: 2px;
    }
    
    /* 优化设置弹窗 */
    .settings-modal {
        max-width: 80vw;
        max-height: 80vh;
        overflow-y: hidden; /* 防止竖向滚动 */
    }
    
    .settings-user-section {
        padding: 8px;
        margin-bottom: 8px;
    }
    
    #userStatus {
        font-size: 14px;
    }
    
    .user-actions button {
        padding: 5px 10px;
        font-size: 12px;
    }
    
    .settings-group {
        display: grid;
        grid-template-columns: repeat(2, 1fr);
        gap: 8px;
        max-height: calc(80vh - 80px); /* 限制高度，避免内容溢出 */
        overflow-y: auto; /* 在设置组内部允许滚动 */
    }
    
    .user-actions a {
        padding: 5px 10px;
        font-size: 12px;
    }
    
    /* 更小字体和间距 */
    .settings-modal h2 {
        font-size: 18px;
        margin: 5px 0;
    }
    
    .settings-modal .slider-label {
        font-size: 12px;
    }
    
    .settings-modal select, 
    .settings-modal input {
        font-size: 12px;
    }
}

@media (max-width: 600px) {
    .slider-container {
        min-width: 100px;
    }
}

/* 预备拍倒计时样式 */
.count-in-display {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background-color: transparent;
    display: flex;
    justify-content: center;
    align-items: center;
    z-index: 1000;
    pointer-events: none; /* 允许点击穿透 */
    transition: opacity 0.3s ease;
}

.count-in-display.hidden {
    display: none;
    opacity: 0;
}

.count-in-number {
    font-size: 200px;
    font-weight: bold;
    color: rgba(0, 0, 0, 0.7);
    text-shadow: 0 0 15px rgba(255, 255, 255, 0.8), 0 0 10px rgba(255, 255, 255, 0.6);
    animation: pulse 0.5s ease-in-out;
}

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

/* 刷新按钮样式 */
.rhythm-action-button {
    position: relative;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    padding: 10px;
    background-color: rgba(76, 175, 80, 0.9);
    color: white;
    border-radius: 8px;
    cursor: pointer;
    transition: all 0.3s ease;
    box-shadow: 0 2px 5px rgba(0, 0, 0, 0.2);
    height: 80px; /* 与节奏型图标高度一致 */
    box-sizing: border-box;
}

.rhythm-action-button:hover {
    background-color: rgba(69, 160, 73, 1);
    transform: translateY(-2px);
    box-shadow: 0 4px 8px rgba(0, 0, 0, 0.25);
}

.action-icon {
    font-size: 32px;
    margin-bottom: 5px;
}

.refresh-icon {
    font-size: 38px;
    font-weight: bold;
}

/* 顶部节奏型栏优化，保留点击功能 */
.rhythm-patterns-bar {
    overflow-x: auto; /* 允许水平滚动 */
    -webkit-overflow-scrolling: touch;
    scrollbar-width: none; /* 隐藏滚动条 */
}

.rhythm-patterns-bar::-webkit-scrollbar {
    display: none; /* 隐藏滚动条 */
}

/* 横屏模式下调整底部控制区样式 */
@media only screen and (orientation: landscape) {
    .controls.fixed-bottom {
        padding: 8px 15px;
        height: auto;
        max-height: 60px;
        overflow-y: hidden; /* 防止竖向滚动 */
    }
    
    .rhythm-patterns-bar.top-bar {
        height: auto;
        min-height: 70px;
        max-height: 90px;
    }
}

/* 移动设备下调整底部控制区样式 */
@media only screen and (max-width: 767px) {
    .controls.fixed-bottom {
        padding: 5px 10px;
        overflow-y: hidden; /* 防止竖向滚动 */
    }
    
    .controls.fixed-bottom .slider-container {
        min-width: 100px;
        margin-right: 8px;
    }
    
    /* 隐藏滚动条但保留功能 */
    .controls.fixed-bottom::-webkit-scrollbar {
        height: 3px;
    }
    
    .controls.fixed-bottom::-webkit-scrollbar-thumb {
        background: rgba(0,0,0,0.2);
        border-radius: 3px;
    }
}

/* 设置按钮样式 */
.settings-button {
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1.5em;
    
    border-radius: 50%;
    
    color: white;
    border: none;
    cursor: pointer;
    margin: 0 10px;
    padding: 0;
    box-shadow: 0 2px 5px rgba(0,0,0,0.2);
}

.settings-button:hover {
    background-color: #f7f5f7;
}

/* 设置弹窗样式 */
.settings-modal {
    max-width: 500px;
    max-height: 90vh;
    overflow-y: hidden; /* 防止整体滚动 */
}

/* 设置弹窗内部滚动优化 */
.modal-content.settings-modal {
    display: flex;
    flex-direction: column;
    max-height: 90vh;
}

.settings-user-section {
    display: flex;
    flex-direction: row;
    align-items: center;
    justify-content: space-between;
    gap: 10px;
    /*padding: 15px;*/  
    margin-bottom: 15px;
    border-bottom: 1px solid #eee;
    flex-shrink: 0; /* 防止用户区域被压缩 */
}

#userStatus {
    font-size: 16px;
    font-weight: bold;
    color: #333;
    text-decoration: underline;
    cursor: pointer;
}

.user-actions {
    display: flex;
    gap: 10px;
}

/* 为已转换为链接的登录/退出按钮添加样式 */
.user-actions a {
    padding: 8px 15px;
    border: none;
    border-radius: 4px;
    cursor: pointer;
    font-size: 14px;
    transition: background-color 0.3s;
    display: inline-block;
    text-decoration: none;
}

#loginBtn {
    background-color: #4285f4;
    color: white;
    text-align: center;
}

#loginBtn:hover {
    background-color: #3367d6;
}

#logoutBtn {
    background-color: #f1f1f1;
    color: #333;
    text-align: center;
}

#logoutBtn:hover {
    background-color: #e4e4e4;
}

/* 设置弹窗样式 */
.settings-modal {
    max-width: 500px;
    max-height: 90vh;
    overflow-y: hidden; /* 防止整体滚动 */
}

/* 设置弹窗内部滚动优化 */
.modal-content.settings-modal {
    display: flex;
    flex-direction: column;
    max-height: 90vh;
}

.settings-group {
    display: flex;
    flex-direction: column;
    gap: 15px;
    flex: 1;
    overflow-y: auto; /* 允许设置组内部滚动 */
    padding-right: 5px; /* 为滚动条留出空间 */
    margin-bottom: 5px; /* 底部留出一些空间 */
}

.settings-group .slider-container {
    margin: 0;
    width: 100%;
}

/* 滚动条美化 */
.settings-group::-webkit-scrollbar {
    width: 4px;
}

.settings-group::-webkit-scrollbar-track {
    background: #f1f1f1;
    border-radius: 4px;
}

.settings-group::-webkit-scrollbar-thumb {
    background: #888;
    border-radius: 4px;
}

.settings-group::-webkit-scrollbar-thumb:hover {
    background: #555;
}

/* 响应式布局 */
@media only screen and (orientation: landscape) and (max-width: 1024px) {
    .settings-modal {
        max-width: 90vw;
    }
    
    .settings-group {
        display: grid;
        grid-template-columns: repeat(2, 1fr);
        gap: 10px;
    }
}

/* 移动设备竖屏模式 */
@media only screen and (max-width: 767px) {
    .settings-button {
        font-size: 1.2em;
    }
    
    .settings-modal {
        width: 90vw;
    }
    
    .settings-group {
        display: flex;
        flex-direction: column;
    }
} 