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

body {
    font-family: 'Microsoft YaHei', sans-serif;
    background: linear-gradient(135deg, #ff9a9e 0%, #fecfef 50%, #fecfef 100%);
    min-height: 100vh;
    display: flex;
    justify-content: center;
    align-items: center;
    user-select: none;
    overflow-x: hidden;
}

.game-container {
    background: rgba(255, 255, 255, 0.95);
    border-radius: 20px;
    box-shadow: 0 20px 40px rgba(0,0,0,0.3);
    padding: 20px;
    text-align: center;
    max-width: 1000px;
    width: 95%;
}

h1 {
    color: #333;
    margin-bottom: 15px;
    font-size: 2.2em;
    text-shadow: 2px 2px 4px rgba(0,0,0,0.1);
    background: linear-gradient(135deg, #ff9a9e 0%, #fecfef 100%);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
}

.game-info {
    display: flex;
    justify-content: space-around;
    align-items: center;
    margin: 15px 0;
    padding: 12px;
    background: linear-gradient(135deg, #ff9a9e 0%, #fecfef 100%);
    border-radius: 10px;
    color: white;
    flex-wrap: wrap;
    gap: 10px;
}

.info-item {
    display: flex;
    flex-direction: column;
    align-items: center;
    min-width: 80px;
}

.info-label {
    font-size: 0.8em;
    opacity: 0.9;
    margin-bottom: 3px;
}

.info-value {
    font-size: 1.1em;
    font-weight: bold;
}

.pattern-selector {
    margin: 15px 0;
    display: flex;
    justify-content: center;
    gap: 10px;
    flex-wrap: wrap;
}

.pattern-btn {
    background: linear-gradient(135deg, #a8edea 0%, #fed6e3 100%);
    color: #333;
    border: none;
    padding: 8px 16px;
    border-radius: 15px;
    cursor: pointer;
    font-size: 14px;
    font-weight: bold;
    transition: all 0.3s ease;
    box-shadow: 0 4px 15px rgba(0,0,0,0.2);
}

.pattern-btn:hover {
    transform: translateY(-2px);
    box-shadow: 0 6px 20px rgba(0,0,0,0.3);
}

.pattern-btn.active {
    background: linear-gradient(135deg, #ff9a9e 0%, #fecfef 100%);
    color: white;
    transform: translateY(-2px);
}

.tools-panel {
    display: flex;
    justify-content: space-around;
    margin: 20px 0;
    gap: 20px;
    flex-wrap: wrap;
}

.color-palette {
    background: white;
    border-radius: 15px;
    padding: 15px;
    box-shadow: 0 5px 15px rgba(0,0,0,0.1);
    flex: 1;
    min-width: 250px;
}

.color-palette h3 {
    margin-bottom: 10px;
    color: #333;
    font-size: 1.1em;
}

.color-grid {
    display: grid;
    grid-template-columns: repeat(8, 1fr);
    gap: 5px;
    margin-bottom: 15px;
}

.color-swatch {
    width: 30px;
    height: 30px;
    border-radius: 50%;
    cursor: pointer;
    border: 3px solid transparent;
    transition: all 0.3s ease;
}

.color-swatch:hover {
    transform: scale(1.1);
    box-shadow: 0 4px 12px rgba(0,0,0,0.3);
}

.color-swatch.selected {
    border-color: #333;
    transform: scale(1.2);
}

.color-controls {
    display: flex;
    align-items: center;
    gap: 10px;
    justify-content: center;
}

.color-controls label {
    font-size: 0.9em;
    color: #666;
}

.color-controls input[type="color"] {
    width: 40px;
    height: 30px;
    border: none;
    border-radius: 5px;
    cursor: pointer;
}

.brush-tools {
    background: white;
    border-radius: 15px;
    padding: 15px;
    box-shadow: 0 5px 15px rgba(0,0,0,0.1);
    flex: 1;
    min-width: 200px;
}

.brush-tools h3 {
    margin-bottom: 10px;
    color: #333;
    font-size: 1.1em;
}

.tool-group {
    margin: 10px 0;
    display: flex;
    align-items: center;
    gap: 10px;
    justify-content: center;
    flex-wrap: wrap;
}

.tool-group label {
    font-size: 0.9em;
    color: #666;
    white-space: nowrap;
}

.tool-group input[type="range"] {
    flex: 1;
    min-width: 80px;
}

#brushSizeDisplay {
    background: #f0f0f0;
    padding: 2px 8px;
    border-radius: 10px;
    font-size: 0.8em;
    color: #666;
    min-width: 40px;
}

.tool-btn {
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    color: white;
    border: none;
    padding: 8px 12px;
    border-radius: 10px;
    cursor: pointer;
    font-size: 12px;
    transition: all 0.3s ease;
    margin: 2px;
}

.tool-btn:hover {
    transform: translateY(-2px);
    box-shadow: 0 4px 12px rgba(0,0,0,0.3);
}

.tool-btn.active {
    background: linear-gradient(135deg, #ff9a9e 0%, #fecfef 100%);
}

.controls {
    margin: 15px 0;
    display: flex;
    justify-content: center;
    gap: 10px;
    flex-wrap: wrap;
}

button {
    background: linear-gradient(135deg, #ff9a9e 0%, #fecfef 100%);
    color: white;
    border: none;
    padding: 10px 20px;
    border-radius: 20px;
    cursor: pointer;
    font-size: 14px;
    font-weight: bold;
    transition: all 0.3s ease;
    box-shadow: 0 4px 15px rgba(0,0,0,0.2);
}

button:hover {
    transform: translateY(-2px);
    box-shadow: 0 6px 20px rgba(0,0,0,0.3);
}

button:active {
    transform: translateY(0);
}

button:disabled {
    opacity: 0.5;
    cursor: not-allowed;
    transform: none;
}

.canvas-container {
    position: relative;
    display: inline-block;
    margin: 20px 0;
    border-radius: 15px;
    overflow: hidden;
    box-shadow: 0 10px 25px rgba(0,0,0,0.3);
    background: white;
}

#coloringCanvas, #patternCanvas {
    display: block;
    cursor: crosshair;
    border-radius: 15px;
}

#patternCanvas {
    position: absolute;
    top: 0;
    left: 0;
    pointer-events: none;
    opacity: 0.3;
    z-index: 1;
}

#coloringCanvas {
    position: relative;
    z-index: 2;
    background: white;
}

.canvas-overlay {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    pointer-events: none;
    z-index: 3;
}

.progress-panel {
    margin: 15px 0;
    background: white;
    border-radius: 15px;
    padding: 15px;
    box-shadow: 0 5px 15px rgba(0,0,0,0.1);
}

.progress-info {
    display: flex;
    align-items: center;
    gap: 15px;
    justify-content: center;
}

.progress-bar {
    flex: 1;
    height: 12px;
    background: #e0e0e0;
    border-radius: 6px;
    overflow: hidden;
    max-width: 300px;
}

.progress-fill {
    height: 100%;
    background: linear-gradient(135deg, #ff9a9e 0%, #fecfef 100%);
    width: 0%;
    transition: width 0.3s ease;
    border-radius: 6px;
}

#progressPercent {
    font-weight: bold;
    color: #333;
    min-width: 40px;
}

.gallery-modal, .completion-popup {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.8);
    display: flex;
    justify-content: center;
    align-items: center;
    z-index: 1000;
    animation: fadeIn 0.3s ease;
}

.gallery-content, .completion-content {
    background: white;
    border-radius: 20px;
    padding: 30px;
    text-align: center;
    box-shadow: 0 20px 40px rgba(0,0,0,0.3);
    animation: slideIn 0.3s ease;
    max-width: 80%;
    max-height: 80%;
    overflow-y: auto;
}

@keyframes fadeIn {
    from { opacity: 0; }
    to { opacity: 1; }
}

@keyframes slideIn {
    from {
        opacity: 0;
        transform: translateY(-50px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

.gallery-content h2, .completion-content h2 {
    color: #333;
    margin-bottom: 20px;
    font-size: 1.8em;
}

.gallery-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(150px, 1fr));
    gap: 15px;
    margin: 20px 0;
    max-height: 400px;
    overflow-y: auto;
}

.gallery-item {
    border-radius: 10px;
    overflow: hidden;
    box-shadow: 0 5px 15px rgba(0,0,0,0.2);
    cursor: pointer;
    transition: transform 0.3s ease;
    position: relative;
}

.gallery-item:hover {
    transform: scale(1.05);
}

.gallery-item img {
    width: 100%;
    height: 150px;
    object-fit: cover;
}

.gallery-item .item-info {
    position: absolute;
    bottom: 0;
    left: 0;
    right: 0;
    background: rgba(0, 0, 0, 0.7);
    color: white;
    padding: 5px;
    font-size: 0.8em;
}

.gallery-actions, .completion-actions {
    margin-top: 20px;
    display: flex;
    justify-content: center;
    gap: 10px;
    flex-wrap: wrap;
}

.completion-stats {
    margin: 20px 0;
    padding: 20px;
    background: linear-gradient(135deg, #ff9a9e 0%, #fecfef 100%);
    border-radius: 15px;
    color: white;
}

.completion-stats div {
    margin: 8px 0;
    font-size: 1.1em;
}

.completion-preview {
    margin: 20px 0;
    border-radius: 10px;
    overflow: hidden;
    display: inline-block;
    box-shadow: 0 5px 15px rgba(0,0,0,0.2);
}

.completion-preview canvas {
    display: block;
    max-width: 200px;
    max-height: 200px;
}

.instructions {
    margin-top: 20px;
    padding: 20px;
    background: linear-gradient(135deg, #a8edea 0%, #fed6e3 100%);
    border-radius: 15px;
    color: #333;
    text-align: left;
}

.instructions h3 {
    margin-bottom: 15px;
    font-size: 1.3em;
    text-align: center;
    color: #333;
}

.instructions ul {
    margin-left: 20px;
    line-height: 1.6;
}

.instructions li {
    margin: 8px 0;
}

.instructions li strong {
    color: #ff6b9d;
}

/* 响应式设计 */
@media (max-width: 768px) {
    .game-container {
        padding: 15px;
        width: 98%;
    }
    
    h1 {
        font-size: 1.8em;
    }
    
    .tools-panel {
        flex-direction: column;
        gap: 15px;
    }
    
    .color-palette, .brush-tools {
        min-width: auto;
    }
    
    .color-grid {
        grid-template-columns: repeat(6, 1fr);
    }
    
    .color-swatch {
        width: 25px;
        height: 25px;
    }
    
    #coloringCanvas, #patternCanvas {
        max-width: 100%;
        height: auto;
    }
    
    .pattern-selector {
        flex-direction: column;
        gap: 8px;
    }
    
    .controls {
        flex-wrap: wrap;
        gap: 8px;
    }
    
    button {
        padding: 8px 16px;
        font-size: 12px;
    }
    
    .instructions {
        text-align: center;
        padding: 15px;
    }
    
    .instructions ul {
        margin-left: 0;
        list-style-position: inside;
    }
    
    .instructions li {
        font-size: 0.9em;
    }
    
    .gallery-grid {
        grid-template-columns: repeat(auto-fill, minmax(120px, 1fr));
    }
    
    .gallery-content, .completion-content {
        padding: 20px;
        max-width: 95%;
        max-height: 90%;
    }
}

@media (max-width: 480px) {
    .game-info {
        flex-direction: column;
        gap: 5px;
    }
    
    .info-item {
        min-width: 60px;
    }
    
    .info-label {
        font-size: 0.7em;
    }
    
    .info-value {
        font-size: 1em;
    }
    
    .color-grid {
        grid-template-columns: repeat(4, 1fr);
    }
    
    .color-swatch {
        width: 20px;
        height: 20px;
    }
    
    .tool-group {
        flex-direction: column;
        gap: 5px;
    }
    
    .progress-info {
        flex-direction: column;
        gap: 10px;
    }
    
    .gallery-grid {
        grid-template-columns: repeat(2, 1fr);
    }
}