/* 代码保护 - 禁止用户选择和拖拽 */
body {
  -webkit-touch-callout: none;
  -webkit-user-select: none;
  -moz-user-select: none;
  -ms-user-select: none;
  user-select: none;
}

img, canvas {
  -webkit-user-drag: none;
  user-drag: none;
  pointer-events: none;
}

/* 原有样式 */
* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

body {
    font-family: 'Segoe UI', 'Microsoft YaHei', sans-serif;
    background: linear-gradient(135deg, #fffbf8 0%, #fff5eb 100%);
    min-height: 100vh;
    display: flex;
    flex-direction: column;
    align-items: center;
    padding: 15px;
    overflow-x: hidden;
    position: relative;
}

.game-logo {
    position: fixed;
    top: 10px;
    left: 15px;
    font-size: 1rem;
    color: rgba(51, 51, 51, 0.9);
    font-weight: bold;
    z-index: 1000;
    pointer-events: none;
}

.top-section {
    display: flex;
    align-items: center;
    justify-content: space-between;
    flex-wrap: wrap;
    width: 100%;
    max-width: 1200px;
    margin-bottom: 8px;
}

header {
    flex-shrink: 0;
    align-self: flex-start;
}

h1 {
    color: #666666;
    font-size: 2.2rem;
    font-weight: 800;
    margin: 0;
    letter-spacing: 2px;
    font-family: 'PingFang SC', 'Microsoft YaHei', sans-serif;
    text-shadow: 2px 2px 4px rgba(66, 153, 225, 0.3);
}

.controls {
    background: #f8f9fa;
    border-radius: 15px;
    padding: 15px 20px;
    box-shadow: 0 4px 15px rgba(0, 0, 0, 0.1);
    display: flex;
    flex-wrap: wrap;
    gap: 10px;
    align-items: center;
    justify-content: flex-end;
    max-width: 800px;
    border: 1px solid #e9ecef;
}

.control-group {
    display: flex;
    flex-direction: column;
    gap: 4px;
}

.control-group label {
    font-weight: 600;
    color: #495057;
    font-size: 0.8rem;
}

.control-group input[type="file"] {
    padding: 6px;
    border: 2px dashed #007bff;
    border-radius: 6px;
    cursor: pointer;
    background: #ffffff;
    font-size: 0.8rem;
    transition: all 0.3s ease;
}

.control-group input[type="file"]:hover {
    border-color: #0056b3;
    background: #f0f8ff;
}

.control-group input[type="number"] {
    padding: 8px 12px;
    border: 2px solid #ced4da;
    border-radius: 6px;
    font-size: 0.9rem;
    width: 70px;
    transition: all 0.3s ease;
}

.control-group input[type="number"]:focus {
    outline: none;
    border-color: #007bff;
    box-shadow: 0 0 0 0.2rem rgba(0, 123, 255, 0.25);
}

.btn {
    padding: 10px 20px;
    border: none;
    border-radius: 20px;
    font-size: 0.9rem;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.3s ease;
    text-transform: uppercase;
    letter-spacing: 1px;
}

.btn-primary {
    background: #007bff;
    color: #fff;
    box-shadow: 0 4px 10px rgba(0, 123, 255, 0.3);
}

.btn-primary:hover {
    transform: translateY(-2px);
    background: #0069d9;
    box-shadow: 0 6px 15px rgba(0, 123, 255, 0.4);
}

.btn-secondary {
    background: #6c757d;
    color: #fff;
    box-shadow: 0 4px 10px rgba(108, 117, 125, 0.3);
}

.btn-secondary:hover {
    transform: translateY(-2px);
    background: #5a6268;
    box-shadow: 0 6px 15px rgba(108, 117, 125, 0.4);
}

.btn-success {
    background: #28a745;
    color: #fff;
    box-shadow: 0 4px 10px rgba(40, 167, 69, 0.3);
}

.btn-success:hover {
    transform: translateY(-2px);
    background: #218838;
    box-shadow: 0 6px 15px rgba(40, 167, 69, 0.4);
}

.btn-info {
    background: #17a2b8;
    color: white;
}

.btn-info:hover {
    background: #138496;
    transform: translateY(-2px);
}

.btn-warning {
    background: #ffc107;
    color: #333;
}

.btn-warning:hover {
    background: #e0a800;
    transform: translateY(-2px);
}

.btn-warning:disabled {
    opacity: 0.5;
    cursor: not-allowed;
    transform: none;
}

.btn-back {
    background: #ff8c69;
    color: white;
}

.btn-back:hover {
    background: #e67a52;
    transform: translateY(-2px);
}

.game-info {
    background: #f8f9fa;
    border-radius: 15px;
    padding: 8px 20px;
    box-shadow: 0 4px 15px rgba(0, 0, 0, 0.1);
    margin-bottom: 8px;
    display: flex;
    justify-content: space-between;
    align-items: center;
    max-width: 1200px;
    width: 100%;
    border: 1px solid #e9ecef;
    box-sizing: border-box;
}

.info-group-left {
    display: flex;
    gap: 20px;
    align-items: center;
}

.info-item {
    display: flex;
    flex-direction: column;
    align-items: center;
}

.info-item .label {
    font-size: 0.85rem;
    color: #6c757d;
    margin-bottom: 5px;
}

.info-item .value {
    font-size: 1.5rem;
    font-weight: 700;
    color: #007bff;
}

.score-display {
    background: #ffffff;
    border-radius: 15px;
    padding: 10px 20px;
    display: flex;
    flex-direction: row;
    align-items: center;
    gap: 12px;
    box-shadow: 0 4px 15px rgba(0, 0, 0, 0.1);
    border: 2px solid #e9ecef;
    min-width: 200px;
}

.squirrel-animation {
    width: 60px;
    height: 60px;
    margin-bottom: 0;
    overflow: hidden;
    border-radius: 10px;
    animation: squirrelPulse 3s ease-in-out infinite;
    position: relative;
    flex-shrink: 0;
}

.squirrel-img {
    width: 100%;
    height: 100%;
    object-fit: cover;
    display: block;
    position: absolute;
    top: 0;
    left: 0;
}

.squirrel-img-front {
    z-index: 2;
}

.squirrel-img-back {
    z-index: 1;
    visibility: hidden;
}

@keyframes squirrelPulse {
    0% {
        transform: scale(1) rotate(0deg);
    }
    20% {
        transform: scale(1.15) rotate(-4deg);
    }
    40% {
        transform: scale(0.90) rotate(4deg);
    }
    60% {
        transform: scale(1.10) rotate(-2deg);
    }
    80% {
        transform: scale(0.95) rotate(2deg);
    }
    100% {
        transform: scale(1) rotate(0deg);
    }
}

.score-label {
    font-size: 0.85rem;
    color: #6c757d;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 1px;
    margin-bottom: 4px;
    text-align: left;
}

.score-value {
    font-size: 1.8rem;
    font-weight: 800;
    line-height: 1;
    color: #007bff;
    filter: url(#wave);
}

.game-container {
    display: flex;
    justify-content: center;
    align-items: flex-start;
}

.main-game-wrapper {
    display: flex;
    gap: 20px;
    flex-wrap: wrap;
    justify-content: center;
    align-items: center;
    background: #f8f9fa;
    border-radius: 15px;
    padding: 20px;
    box-shadow: 0 4px 15px rgba(0, 0, 0, 0.1);
    width: 100%;
    max-width: 1400px;
    border: 1px solid #e9ecef;
    box-sizing: border-box;
    position: relative;
}

.puzzle-area {
    background: #ffffff;
    border-radius: 15px;
    padding: 20px;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.08);
    border: 1px solid #e9ecef;
}

.puzzle-grid {
    display: grid;
    gap: 2px;
    background: #dee2e6;
    padding: 2px;
    border-radius: 8px;
    position: relative;
    overflow: visible;
}

.puzzle-cell {
    background: #ffffff;
    border: 1px solid #ced4da;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 0.8rem;
    color: #6c757d;
}

.puzzle-piece {
    position: absolute;
    cursor: grab;
    transition: all 0.3s ease;
    user-select: none;
    border: 2px solid #ffffff;
    box-shadow: 0 4px 10px rgba(0, 0, 0, 0.15);
    border-radius: 4px;
}

.puzzle-piece:hover {
    z-index: 100;
    box-shadow: 0 6px 15px rgba(0, 0, 0, 0.25);
    transform: translateY(-2px);
}

.puzzle-piece.dragging {
    cursor: grabbing;
    z-index: 1000;
    opacity: 0.9;
    box-shadow: 0 8px 20px rgba(0, 0, 0, 0.35);
    transform: translateY(-4px);
}

.puzzle-piece.disabled {
    pointer-events: none;
    opacity: 0.5;
}

.preview-area {
    background: #ffffff;
    border-radius: 15px;
    padding: 15px;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.08);
    text-align: center;
    border: 1px solid #e9ecef;
    width: 350px;
    min-height: 400px;
    display: flex;
    flex-direction: column;
    justify-content: flex-start;
    align-items: center;
    flex-shrink: 0;
}

.preview-area h3 {
    color: #495057;
    margin-bottom: 15px;
    font-size: 1.2rem;
}

.preview-image {
    max-width: 300px;
    max-height: 300px;
    border-radius: 8px;
    box-shadow: 0 4px 10px rgba(0, 0, 0, 0.15);
    transition: all 0.3s ease;
    display: block;
    margin: 0 auto;
}

.preview-image:hover {
    transform: scale(1.02);
    box-shadow: 0 6px 15px rgba(0, 0, 0, 0.25);
}

.preview-timer {
    background: #fff3cd;
    border: 1px solid #ffc107;
    border-radius: 8px;
    padding: 10px;
    margin-bottom: 15px;
    text-align: center;
}

.preview-timer p {
    margin: 0;
    color: #856404;
    font-weight: bold;
}

.preview-timer span {
    color: #d39e00;
    font-size: 1.2em;
}

.hint {
    margin-top: 15px;
    padding: 15px;
    background: #e7f3ff;
    border-radius: 8px;
    color: #004085;
    font-size: 0.9rem;
    border-left: 4px solid #007bff;
}

.complete-overlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.7);
    display: none;
    justify-content: center;
    align-items: center;
    z-index: 2000;
}

.complete-overlay.show {
    display: flex;
}

.complete-modal {
    background: #ffffff;
    border-radius: 20px;
    padding: 50px;
    text-align: center;
    color: #495057;
    animation: popIn 0.5s ease;
    box-shadow: 0 20px 40px rgba(0, 0, 0, 0.15);
    max-width: 500px;
    width: 90%;
    border: 1px solid #e9ecef;
}

@keyframes popIn {
    0% {
        transform: scale(0.5);
        opacity: 0;
    }
    100% {
        transform: scale(1);
        opacity: 1;
    }
}

.complete-modal h2 {
    font-size: 3rem;
    margin-bottom: 20px;
    color: #28a745;
}

.complete-modal p {
    font-size: 1.2rem;
    margin-bottom: 30px;
    color: #6c757d;
}

@media (max-width: 768px) {
    .game-container {
        flex-direction: column;
        align-items: center;
    }

    h1 {
        font-size: 1.8rem;
    }

    .controls {
        padding: 15px;
    }

    .game-info {
        flex-direction: column;
        gap: 20px;
    }

    .info-group-left {
        flex-wrap: wrap;
        justify-content: center;
    }

    .score-display {
        width: 100%;
        min-width: auto;
    }
}

.footer-text {
    margin-top: 20px;
    padding: 15px;
    text-align: center;
    font-size: 0.9rem;
    color: #6c757d;
    background: #f8f9fa;
    border-radius: 15px;
    max-width: 1200px;
    width: 100%;
    box-sizing: border-box;
    margin-bottom: 15px;
}

/* 音乐控制容器 */
.music-controls {
    position: fixed;
    top: 10px;
    right: 10px;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 3px;
    z-index: 1000;
    background: transparent;
    border-radius: 15px;
    padding: 5px 8px;
    border: none;
}

.music-buttons {
    display: flex;
    gap: 5px;
    align-items: center;
}

.music-btn {
    width: 30px;
    height: 30px;
    border-radius: 50%;
    background: rgba(102, 126, 234, 0.1);
    border: 2px solid #667eea;
    box-shadow: 0 2px 6px rgba(0, 0, 0, 0.1);
    cursor: pointer;
    font-size: 1rem;
    transition: all 0.3s ease;
    display: flex;
    align-items: center;
    justify-content: center;
}

.music-btn:hover {
    transform: scale(1.1);
    box-shadow: 0 3px 10px rgba(0, 0, 0, 0.2);
}

.music-btn.active {
    background: #667eea;
    color: white;
}

.music-btn-small {
    width: 24px;
    height: 24px;
    font-size: 1rem;
    color: #adb5bd;
}

.music-name {
    font-size: 0.65rem;
    color: #667eea;
    font-weight: 600;
    text-align: center;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    max-width: 100px;
}

/* 漂浮拼图碎片 */
.floating-puzzle {
    position: fixed;
    font-size: 4rem;
    opacity: 0.15;
    pointer-events: none;
    z-index: 0;
    animation: float 20s infinite ease-in-out;
}

@keyframes float {
    0%, 100% {
        transform: translateY(0) rotate(0deg);
    }
    25% {
        transform: translateY(-30px) rotate(90deg);
    }
    50% {
        transform: translateY(0) rotate(180deg);
    }
    75% {
        transform: translateY(30px) rotate(270deg);
    }
}

/* 粒子效果 */
.particle {
    position: fixed;
    width: 25px;
    height: 25px;
    background: rgba(102, 126, 234, 0.15);
    border-radius: 50%;
    pointer-events: none;
    z-index: 0;
    animation: particleFloat 15s infinite ease-in-out;
}

@keyframes particleFloat {
    0%, 100% {
        transform: translateY(0) scale(1);
        opacity: 0.1;
    }
    50% {
        transform: translateY(-100px) scale(1.5);
        opacity: 0.2;
    }
}

/* 几何图形 */
.geometric {
    position: fixed;
    pointer-events: none;
    z-index: 0;
    opacity: 0.15;
    animation: geometricRotate 25s infinite linear;
}

@keyframes geometricRotate {
    0% {
        transform: rotate(0deg) scale(1);
    }
    50% {
        transform: rotate(180deg) scale(1.2);
    }
    100% {
        transform: rotate(360deg) scale(1);
    }
}
