/* 修复iPad Safari和移动设备图片显示问题 */
* {
    box-sizing: border-box;
    margin: 0;
    padding: 0;
}

@font-face {
    font-family: "Jolly";
    src: url('https://www.xiaozhangyu.vip/fonts/jollyregular.woff') format('woff');
}

@font-face {
    font-family: "Jolly";
    src: url('https://www.xiaozhangyu.vip/fonts/jollybold.woff') format('woff');
    font-weight: bold;
}

@font-face {
    font-family: "Jolly";
    src: url('https://www.xiaozhangyu.vip/fonts/jollyitalic.woff') format('woff');
    font-style: italic;
}

body {
    font-family: Jolly, 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;
    background: linear-gradient(135deg, #1DB799, #26B88B, #2FB97C);
    color: #fff;
    min-height: 100vh;
    display: flex;
    flex-direction: column;
    padding: 15px;
    -webkit-user-select: none;
    -moz-user-select: none;
    -ms-user-select: none;
    user-select: none;
    -webkit-touch-callout: none;
    -webkit-tap-highlight-color: transparent;
    touch-action: manipulation;
    overflow-x: hidden;
}

/* 顶部菜单样式 */
.top-navbar {
    background: rgba(255, 255, 255, 0.2);
    -webkit-backdrop-filter: blur(10px);
    backdrop-filter: blur(10px);
    border-radius: 12px;
    margin-bottom: 20px;
    padding: 12px 20px;
    display: flex;
    justify-content: space-between;
    align-items: center;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.1);
    overflow: visible;
    position: fixed;
    top: 15px;
    left: 15px;
    right: 15px;
    z-index: 1000;
    transition: all 0.3s ease;
}

.top-navbar.scrolled {
    flex-direction: column;
    width: auto;
    right: 5px;
    left: auto;
    padding: 10px;
    align-items: flex-end;
    gap: 5px;
}

.top-navbar.scrolled .nav-left, 
.top-navbar.scrolled .nav-right {
    flex-direction: column;
    gap: 5px;
    width: 100%;
}

.top-navbar.scrolled .nav-left a, 
.top-navbar.scrolled .nav-right a {
    justify-content: flex-end;
    padding: 8px 10px;
}

.top-navbar.scrolled .nav-left a span, 
.top-navbar.scrolled .nav-right a span {
    display: none;
}

.top-navbar.scrolled .nav-left {
    order: 2;
}

.top-navbar.scrolled .nav-right {
    order: 1;
}

.nav-left, .nav-right {
    display: flex;
    align-items: center;
    gap: 10px;
}

.nav-left a, .nav-right a {
    color: #f0f8ff;
    text-decoration: none;
    font-size: 16px;
    transition: all 0.3s;
    display: flex;
    align-items: center;
    gap: 8px;
    cursor: pointer;
    padding: 8px 12px;
    border-radius: 8px;
}

.nav-left a:hover, .nav-right a:hover {
    color: #ffd700;
    background: rgba(255, 255, 255, 0.25);
    transform: translateY(-2px);
}

.nav-icon {
    font-size: 22px;
    width: 20px;
    text-align: center;
}

/* 隐藏文字 */
.nav-left a span, .nav-right a span {
    display: none;
}

/* 游戏容器样式 */
.container {
    max-width: 1300px;
    width: 100%;
    background-color: hsl(147deg 30.77% 84.71%);
    border-radius: 12px;
    box-shadow: 0 4px 15px rgba(0, 0, 0, 0.1);
    border: 1px solid rgba(255, 255, 255, 0.3);
    overflow: hidden;
    margin: 90px auto 20px;
    padding: 20px;
    position: relative;
}

/* 游戏区域装饰点 */
.container::before,
.container::after {
    content: '';
    position: absolute;
    width: 25px;
    height: 25px;
    border-radius: 5px 15px 5px 15px;
    z-index: 1;
    opacity: 0.8;
    filter: blur(0.5px);
    animation: float 6s ease-in-out infinite;
}

.container::before {
    top: -8px;
    right: -8px;
    background: #ffd700;
}

.container::after {
    bottom: -8px;
    left: -8px;
    background: #ff6b6b;
    border-radius: 5px 15px 5px 15px;
}

@keyframes float {
    0%, 100% {
        transform: translateY(0) scale(1);
    }
    50% {
        transform: translateY(-3px) scale(1.1);
    }
}

.loading {
    display: none;
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    background: rgba(76, 175, 80, 0.7);
    color: white;
    padding: 15px 25px;
    border-radius: 10px;
    font-size: 1.2rem;
}

/* 关键修复：游戏区域和画布容器 */
.game-area {
    position: relative;
    width: 100%;
    border-radius: 10px;
    overflow: hidden;
    margin-bottom: 20px;
    display: flex;
    justify-content: center;
    align-items: center;
    /* 添加最大高度限制 */
    max-height:80vh;
    min-height: 400px;
}

.canvas-container {
    background: #fff;
    border-radius: 10px;
    box-shadow: 0 4px 15px rgba(0, 0, 0, 0.2);
    padding: 15px;
    position: relative;
    overflow: auto;
    display: flex;
    justify-content: center;
    align-items: center;
    max-width: 100%;
    max-height: 100%;
    /* 关键修复：添加固定宽高比容器 */
    width: 100%;
    aspect-ratio: 16/9;
}

canvas {
    display: block;
    border-radius: 8px;
    background: #f8f9fa;
    cursor: grab;
    /* 关键修复：确保画布保持比例 */
    max-width: 100%;
    max-height: 100%;
    width: auto;
    height: auto;
    object-fit: contain;
}

/* 控制区域样式 */
.controls {
    display: flex;
    justify-content: center;
    flex-wrap: wrap;
    gap: 12px;
    margin-top: 20px;
    padding: 15px;
    background: rgba(255, 255, 255, 0.1);
    border-radius: 15px;
}

.control-btn {
    background: linear-gradient(to right, #47b47d, #3a9c69);
    border: none;
    color: white;
    padding: 12px 20px;
    font-size: 1rem;
    border-radius: 50px;
    cursor: pointer;
    transition: all 0.3s ease;
    box-shadow: 0 4px 15px rgba(0, 0, 0, 0.2);
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    width: 50px;
    height: 50px;
    /* 确保触摸友好 */
    min-width: 50px;
    min-height: 50px;
}

.control-btn.active {
    background: linear-gradient(to right, #ff8a00, #e52e71);
    transform: translateY(-2px);
    box-shadow: 0 6px 20px rgba(229, 46, 113, 0.4);
}

.control-btn:hover:not(:disabled) {
    transform: translateY(-3px);
    box-shadow: 0 6px 20px rgba(0, 0, 0, 0.3);
}

.control-btn:active:not(:disabled) {
    transform: translateY(1px);
}

.control-btn:disabled {
    opacity: 0.5;
    cursor: not-allowed;
    transform: none;
    box-shadow: 0 2px 5px rgba(0, 0, 0, 0.1);
}

.control-btn i {
    font-size: 1.1rem;
}

/* 颜色选择框美化 */
.colors-dropdown {
    position: fixed;
    background: rgba(255, 255, 255, 0.95);
    backdrop-filter: blur(10px);
    border-radius: 15px;
    padding: 15px;
    box-shadow: 0 10px 30px rgba(0, 0, 0, 0.2);
    z-index: 1100;
    display: none;
    border: 2px solid rgba(255, 255, 255, 0.5);
}

.colors-dropdown.show {
    display: block;
    animation: fadeIn 0.3s ease-out;
}

@keyframes fadeIn {
    from { opacity: 0; transform: translateY(-10px); }
    to { opacity: 1; transform: translateY(0); }
}

.colors-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 15px;
    padding-bottom: 10px;
    border-bottom: 1px solid rgba(0, 0, 0, 0.1);
}

.colors-title {
    font-size: 1.2rem;
    color: #1a73d9;
    font-weight: bold;
}

.close-colors {
    background: none;
    border: none;
    font-size: 1.5rem;
    cursor: pointer;
    color: #888;
    transition: color 0.3s;
}

.close-colors:hover {
    color: #ff6b6b;
}

.colors-grid {
    display: grid;
    grid-template-columns: repeat(5, 1fr);
    gap: 12px;
    padding: 10px;
}

.color-item {
    width: 40px;
    height: 40px;
    border-radius: 10px;
    cursor: pointer;
    transition: all 0.3s ease;
    border: 3px solid transparent;
    box-shadow: 0 4px 8px rgba(0, 0, 0, 0.1);
    position: relative;
}

.color-item:hover {
    transform: scale(1.15);
    box-shadow: 0 6px 12px rgba(0, 0, 0, 0.2);
}

.color-item.active {
    border-color: #fff;
    transform: scale(1.2);
    box-shadow: 0 0 15px rgba(255, 255, 255, 0.8);
}

.color-item.active::after {
    content: '✓';
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    color: white;
    font-size: 1.2rem;
    text-shadow: 0 0 5px rgba(0, 0, 0, 0.5);
}

/* 自定义颜色选择器 */
.custom-color {
    margin-top: 15px;
    padding-top: 15px;
    border-top: 1px solid rgba(0, 0, 0, 0.1);
}

.custom-color-label {
    display: block;
    margin-bottom: 8px;
    font-size: 0.9rem;
    color: #1a73d9;
    text-align: center;
}

.custom-color-input {
    width: 100%;
    height: 40px;
    border: none;
    border-radius: 8px;
    cursor: pointer;
    box-shadow: 0 4px 8px rgba(0, 0, 0, 0.1);
}

/* 文件输入样式 */
.file-input {
    display: none;
}

/* 翻页按钮样式 */
.page-nav-buttons {
    position: fixed;
    bottom: 30px;
    left: 0;
    right: 0;
    display: flex;
    justify-content: space-between;
    padding: 0 30px;
    z-index: 999;
    pointer-events: none;
}

.page-nav-btn {
    width: 60px;
    height: 60px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 24px;
    color: #fff;
    cursor: pointer;
    opacity: 0.7;
    transition: all 0.3s ease;
    box-shadow: 0 4px 15px rgba(0, 0, 0, 0.3);
    pointer-events: auto;
    background: linear-gradient(145deg, #47b47d, #3a9c69);
}

.page-nav-btn:hover {
    opacity: 1;
    transform: scale(1.1);
    box-shadow: 0 6px 20px rgba(0, 0, 0, 0.4);
}

.page-nav-btn a {
    color: white;
    text-decoration: none;
    display: flex;
    align-items: center;
    justify-content: center;
    width: 100%;
    height: 100%;
}

/* 帮助弹窗样式 */
.modal {
    display: none;
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.7);
    z-index: 2000;
    justify-content: center;
    align-items: center;
    backdrop-filter: blur(5px);
}

.modal-content {
    background: linear-gradient(135deg, #418577, #5ba897);
    padding: 30px;
    border-radius: 18px;
    width: 90%;
    max-width: 500px;
    box-shadow: 0 10px 30px rgba(0, 0, 0, 0.5);
    position: relative;
    border: 1px solid rgba(255, 255, 255, 0.2);
    animation: modalFadeIn 0.3s ease-out;
    overflow: hidden;
    font-family: 'Jolly Lodger', sans-serif;
}

@keyframes modalFadeIn {
    from { opacity: 0; transform: scale(0.9); }
    to { opacity: 1; transform: scale(1); }
}

.modal-content h2 {
    color: #ffd700;
    margin-bottom: 15px;
    border-bottom: 2px solid rgba(255, 255, 255, 0.3);
    padding-bottom: 10px;
    text-align: center;
}

.modal-content p {
    margin-bottom: 15px;
    line-height: 1.6;
    color: #f0f8ff;
}

.close-help {
    position: absolute;
    top: -20px;
    right: 20px;
    font-size: 80px;
    cursor: pointer;
    color: #f0f8ff;
    transition: color 0.3s;
    font-family: "Jolly";
}

.close-help:hover {
    color: #ffd700;
}

.copyright {
    text-align: center;
    color: #3F786B;
    font-size: 20px;
    margin-top: 20px;
    font-family: Jolly;
}

.bianhao {
    text-align:left;
    color:#f0f8ff;
    font-size:16px;
    font-family:Jolly;
}

/* 新添加的样式 */
/* 画笔粗细选择框 */
.brush-sizes-dropdown {
    position: fixed;
    background: rgba(255, 255, 255, 0.95);
    backdrop-filter: blur(10px);
    border-radius: 15px;
    padding: 15px;
    box-shadow: 0 10px 30px rgba(0, 0, 0, 0.2);
    z-index: 1100;
    display: none;
    border: 2px solid rgba(255, 255, 255, 0.5);
    width: 280px;
}

.brush-sizes-dropdown.show {
    display: block;
    animation: fadeIn 0.3s ease-out;
}

.brush-sizes-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 15px;
    padding-bottom: 10px;
    border-bottom: 1px solid rgba(0, 0, 0, 0.1);
}

.brush-sizes-title {
    font-size: 1.2rem;
    color: #1a73d9;
    font-weight: bold;
}

.close-brush-sizes {
    background: none;
    border: none;
    font-size: 1.5rem;
    cursor: pointer;
    color: #888;
    transition: color 0.3s;
}

.close-brush-sizes:hover {
    color: #ff6b6b;
}

.brush-sizes-grid {
    display: grid;
    grid-template-columns: repeat(4, 1fr);
    gap: 12px;
    padding: 10px;
}

.brush-size-item {
    width: 50px;
    height: 50px;
    border-radius: 50%;
    background: rgba(255, 255, 255, 0.2);
    border: 2px solid rgba(255, 255, 255, 0.5);
    color: white;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    transition: all 0.3s;
    font-size: 14px;
    position: relative;
}

.brush-size-item:hover {
    transform: scale(1.1);
    background: rgba(255, 255, 255, 0.3);
}

.brush-size-item.active {
    background: rgba(255, 255, 255, 0.4);
    border-color: #ffd700;
    transform: scale(1.1);
}

.brush-size-item::before {
    content: '';
    position: absolute;
    width: 60%;
    height: 60%;
    background: var(--current-color, #ffffff);
    border-radius: 50%;
    opacity: 0.7;
}

.brush-size-item[data-size="1"]::before {
    width: 10%;
    height: 10%;
}

.brush-size-item[data-size="3"]::before {
    width: 20%;
    height: 20%;
}

.brush-size-item[data-size="5"]::before {
    width: 30%;
    height: 30%;
}

.brush-size-item[data-size="8"]::before {
    width: 40%;
    height: 40%;
}

.brush-size-item[data-size="10"]::before {
    width: 50%;
    height: 50%;
}

.brush-size-item[data-size="15"]::before {
    width: 60%;
    height: 60%;
}

.brush-size-item[data-size="20"]::before {
    width: 70%;
    height: 70%;
}

.brush-size-item[data-size="25"]::before {
    width: 80%;
    height: 80%;
}

/* 透明度控制区域 */
.opacity-control {
    margin-top: 15px;
    padding: 15px 10px 5px;
    border-top: 1px solid rgba(0, 0, 0, 0.1);
}

.opacity-label {
    display: block;
    margin-bottom: 8px;
    font-size: 0.9rem;
    color: #1a73d9;
    text-align: center;
}

.opacity-slider-container {
    display: flex;
    align-items: center;
    gap: 10px;
}

.opacity-slider {
    flex: 1;
    height: 8px;
    -webkit-appearance: none;
    appearance: none;
    background: linear-gradient(to right, rgba(0,0,0,0.1), currentColor);
    border-radius: 4px;
    outline: none;
}

.opacity-slider::-webkit-slider-thumb {
    -webkit-appearance: none;
    appearance: none;
    width: 20px;
    height: 20px;
    border-radius: 50%;
    background: white;
    border: 2px solid currentColor;
    cursor: pointer;
    box-shadow: 0 2px 5px rgba(0,0,0,0.2);
}

.opacity-slider::-moz-range-thumb {
    width: 20px;
    height: 20px;
    border-radius: 50%;
    background: white;
    border: 2px solid currentColor;
    cursor: pointer;
    box-shadow: 0 2px 5px rgba(0,0,0,0.2);
}

.opacity-value {
    width: 40px;
    text-align: center;
    font-size: 0.9rem;
    color: #1a73d9;
    font-weight: bold;
}

/* 放大状态指示器 */
.zoom-indicator {
    position: absolute;
    top: 10px;
    right: 10px;
    background: rgba(0, 0, 0, 0.7);
    color: white;
    padding: 5px 10px;
    border-radius: 15px;
    font-size: 14px;
    z-index: 100;
    display: none;
}

/* 移动端适配 */
@media (max-width: 768px) {
    .top-navbar {
        padding: 12px 15px;
    }
    
    .nav-left a, .nav-right a {
        padding: 12px;
        width: 50px;
        height: 50px;
        justify-content: center;
    }
    
    .nav-icon {
        font-size: 24px;
    }
    
    .nav-left, .nav-right {
        gap: 12px;
    }
    
    .container {
        margin-top: 80px;
        padding: 15px;
    }
    
    .controls {
        gap: 12px;
        padding: 12px;
    }
    
    .control-btn {
        width: 55px;
        height: 55px;
        font-size: 1.2rem;
    }
    
    .control-btn i {
        font-size: 1.3rem;
    }
    
    .page-nav-buttons {
        padding: 0 20px;
    }
    
    .page-nav-btn {
        width: 60px;
        height: 60px;
        font-size: 24px;
    }
    
    .colors-grid {
        grid-template-columns: repeat(4, 1fr);
        gap: 12px;
    }
    
    .color-item {
        width: 45px;
        height: 45px;
    }

    .brush-sizes-grid {
        grid-template-columns: repeat(3, 1fr);
        gap: 12px;
    }

    .brush-size-item {
        width: 50px;
        height: 50px;
        font-size: 14px;
    }
    
    /* 关键修复：移动端画布容器 */
    .game-area {
        max-height: 60vh;
        min-height: 300px;
    }
    
    .canvas-container {
        aspect-ratio: 4/3;
        padding: 10px;
    }
}

@media (max-width: 480px) {
    .top-navbar {
        padding: 10px 12px;
    }
    
    .nav-left a, .nav-right a {
        padding: 10px;
        width: 48px;
        height: 48px;
    }
    
    .nav-icon {
        font-size: 22px;
    }
    
    .container {
        margin-top: 80px;
        padding: 12px;
    }
    
    .controls {
        gap: 10px;
        padding: 10px;
    }
    
    .control-btn {
        width: 55px;
        height: 55px;
        font-size: 1.1rem;
    }
    
    .control-btn i {
        font-size: 1.2rem;
    }
    
    .page-nav-buttons {
        padding: 0 15px;
    }

    .page-nav-btn {
        width: 55px;
        height: 55px;
        font-size: 22px;
    }
    
    .colors-grid {
        grid-template-columns: repeat(3, 1fr);
        gap: 10px;
    }
    
    .color-item {
        width: 40px;
        height: 40px;
    }

    .brush-sizes-grid {
        grid-template-columns: repeat(2, 1fr);
        gap: 10px;
    }

    .brush-size-item {
        width: 45px;
        height: 45px;
        font-size: 12px;
    }
    
    /* 关键修复：小屏幕画布容器 */
    .game-area {
        max-height: 50vh;
        min-height: 250px;
    }
    
    .canvas-container {
        aspect-ratio: 1/1;
        padding: 8px;
    }
}