/* 代码保护 - 禁止用户选择和拖拽 */
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, #f8fff9 0%, #f0fff5 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: 20px;
}

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);
}

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

.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;
}

.info-item.rotation-control {
    margin-left: auto;
}

#toggleRotationBtn {
    background: #17a2b8 !important;
    color: #fff !important;
    box-shadow: 0 4px 10px rgba(23, 162, 184, 0.3) !important;
}

#toggleRotationBtn:hover {
    background: #138496 !important;
    box-shadow: 0 6px 15px rgba(23, 162, 184, 0.4) !important;
}

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

.main-game-wrapper {
    display: flex;
    gap: 30px;
    flex-wrap: wrap;
    justify-content: center;
    align-items: center;
    background: #f8f9fa;
    border-radius: 15px;
    padding: 30px;
    box-shadow: 0 4px 15px rgba(0, 0, 0, 0.1);
    width: 100%;
    max-width: 1200px;
    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);
}

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

.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;
}

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

.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;
}

.backend-status {
    position: fixed;
    top: 10px;
    right: 10px;
    padding: 10px 15px;
    border-radius: 5px;
    font-size: 14px;
    font-weight: bold;
    z-index: 1000;
    max-width: 300px;
    text-align: center;
    transition: opacity 0.5s;
}

.backend-status.success {
    background-color: #4caf50;
    color: white;
}

.backend-status.error {
    background-color: #f44336;
    color: white;
}

.ai-assistant-btn {
    position: fixed;
    bottom: 20px;
    right: 20px;
    padding: 12px 20px;
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    color: white;
    border: none;
    border-radius: 25px;
    font-size: 16px;
    font-weight: bold;
    cursor: pointer;
    box-shadow: 0 4px 15px rgba(0, 0, 0, 0.2);
    z-index: 1000;
    transition: all 0.3s ease;
}

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

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

.rotate-hint {
    position: absolute;
    top: 5px;
    right: 5px;
    background: rgba(255, 255, 255, 0.9);
    padding: 2px 6px;
    border-radius: 4px;
    font-size: 0.7rem;
    color: #333;
    pointer-events: none;
    display: none;
}

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

    h1 {
        font-size: 1.8rem;
    }

    .controls {
        padding: 15px;
    }

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

.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;
}
/* AI助手样式 - 放在预览图右侧 */
/* AI助手样式 */
.ai-response {
    position: fixed;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    background: rgba(255, 255, 255, 0.95);
    border-radius: 12px;
    padding: 12px;
    box-shadow: 0 10px 30px rgba(0, 0, 0, 0.3);
    z-index: 10000;
    width: 280px;
    max-height: 300px;
    overflow-y: auto;
    border: 2px solid #007bff;
    cursor: move;
    user-select: none;
    resize: both;
    min-width: 300px;
    min-height: 200px;
    text-align: left;  /* 添加这一行 */
}

/* 对话框标题区域 */
.ai-response::before {
    content: '🤖 AI助手提示（可拖动）';
    display: block;
    font-weight: bold;
    color: #007bff;
    margin-bottom: 15px;
    padding-bottom: 10px;
    border-bottom: 1px solid #e9ecef;
    cursor: move;
}

/* 拖动时的样式 */
.ai-response.dragging {
    box-shadow: 0 15px 40px rgba(0, 0, 0, 0.4);
    opacity: 0.95;
    cursor: grabbing;
}

/* 思考状态 */
.ai-thinking {
    text-align: center;
    color: #00c4ff;
    font-weight: bold;
    margin-bottom: 8px;
    padding: 6px;  /* 减小内边距 */
    background: #f0f8ff;
    border-radius: 6px;
    font-size: 0.9rem;
}

/* 结果显示 */
.ai-result {
    white-space: pre-wrap;
    line-height: 1.4;
    font-size: 0.9rem;
    color: #333;
    max-height: 200px;
    overflow-y: auto;
    padding: 5px 8px;  /* 减小内边距 */
    margin: 0;  /* 移除可能的外边距 */
    text-align: left !important;
}

/* 移动端适配 */
@media (max-width: 1400px) {
    .ai-response {
        left: auto;
        right: 20px;
        top: 50%;
        transform: translateY(-50%);
    }
}

@media (max-width: 768px) {
    .ai-response {
        left: 50%;
        top: 50%;
        transform: translate(-50%, -50%);
        width: 90%;
        max-width: 300px;
    }
}

.ai-thinking {
    text-align: center;
    color: #007bff;
    font-weight: bold;
    margin-bottom: 10px;
    padding: 10px;
    background: #f0f8ff;
}

.ai-result {
    white-space: pre-wrap;
    line-height: 1.5;
    font-size: 0.9rem;
    color: #333;
    max-height: 200px;
    overflow-y: auto;
    padding: 5px 10px;
}

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

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

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

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

.ai-assistant-btn:disabled {
    opacity: 0.5;
    cursor: not-allowed;
    transform: none;
    box-shadow: 0 2px 10px rgba(0, 0, 0, 0.1);
}

.ai-assistant-btn:disabled:hover {
    transform: none;
    box-shadow: 0 2px 10px rgba(0, 0, 0, 0.1);
}

/* 呼吸动画 */
@keyframes pulse {
    0% {
        box-shadow: 0 0 0 0 rgba(255, 193, 7, 0.7);
    }
    70% {
        box-shadow: 0 0 0 10px rgba(255, 193, 7, 0);
    }
    100% {
        box-shadow: 0 0 0 0 rgba(255, 193, 7, 0);
    }
}

/* 音乐控制容器 */
.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);
    }
}
