/* 拼图游戏专用样式 */

/* 拼图页面容器 - 占屏幕宽度的一半 */
.puzzle-container {
    width: 50vw !important;
    max-width: 50vw !important;
    padding-left: 15px;
    padding-right: 15px;
}

.puzzle-container .puzzle-board {
    max-width: none;
    width: 100%;
}

.puzzle-container .puzzle-info-bar {
    padding: 12px 10px;
}

.puzzle-container .puzzle-info-bar .info-value {
    font-size: 20px;
}

.puzzle-info-bar {
    background: white;
    border-radius: 15px;
    padding: 15px 20px;
    box-shadow: 0 5px 20px rgba(0,0,0,0.1);
    margin-bottom: 20px;
    display: flex;
    justify-content: space-around;
    text-align: center;
}

.info-item {
    flex: 1;
}

.info-label {
    display: block;
    font-size: 12px;
    color: #999;
    margin-bottom: 4px;
}

.info-value {
    display: block;
    font-size: 24px;
    font-weight: bold;
    color: #333;
}

/* 拼图板 */
.puzzle-board-wrapper {
    background: white;
    border-radius: 15px;
    padding: 20px;
    box-shadow: 0 5px 20px rgba(0,0,0,0.1);
    margin-bottom: 20px;
    display: flex;
    justify-content: center;
}

.puzzle-board {
    display: grid;
    gap: 0;
    background: #2c3e50;
    border: 3px solid #1a252f;
    border-radius: 6px;
    padding: 0;
    width: 100%;
    max-width: 400px;
    box-shadow: 0 4px 16px rgba(0,0,0,0.3);
    overflow: hidden;
    box-sizing: content-box;
}

.puzzle-tile {
    background-size: cover;
    background-repeat: no-repeat;
    cursor: pointer;
    transition: transform 0.1s, box-shadow 0.1s;
    position: relative;
    box-shadow: inset 0 0 0 1px #ffffff;
}

.puzzle-tile:hover:not(.empty-tile) {
    transform: scale(1.03);
    box-shadow: 0 2px 10px rgba(0,0,0,0.3);
    z-index: 1;
}

.puzzle-tile:active:not(.empty-tile) {
    transform: scale(0.97);
}

.puzzle-tile.correct {
    box-shadow: inset 0 0 0 3px #2ecc71;
    z-index: 2;
}

/* 拖拽状态 */
.puzzle-tile.drag-origin {
    opacity: 0.3;
    transform: scale(0.95);
}

.puzzle-tile.dragging {
    cursor: grabbing;
    border-radius: 4px;
}

.puzzle-tile.drop-target {
    background: rgba(102, 126, 234, 0.25) !important;
    border: 2px solid #667eea !important;
    border-radius: 4px;
    animation: pulse-border 0.8s ease-in-out infinite alternate;
}

@keyframes pulse-border {
    from { box-shadow: 0 0 5px rgba(102, 126, 234, 0.3); }
    to   { box-shadow: 0 0 15px rgba(102, 126, 234, 0.6); }
}

.puzzle-tile {
    cursor: grab;
}

.puzzle-tile:active:not(.empty-tile) {
    cursor: grabbing;
}

/* 预览图 */
.puzzle-preview {
    background: white;
    border-radius: 15px;
    padding: 20px;
    box-shadow: 0 5px 20px rgba(0,0,0,0.1);
    margin-bottom: 20px;
    text-align: center;
}

.preview-title {
    font-weight: bold;
    color: #333;
    margin-bottom: 15px;
    font-size: 16px;
}

.puzzle-preview img {
    max-width: 200px;
    max-height: 200px;
    border-radius: 8px;
    box-shadow: 0 2px 8px rgba(0,0,0,0.15);
    cursor: pointer;
    transition: transform 0.3s;
}

.puzzle-preview img:hover {
    transform: scale(1.5);
}

/* 完成状态 */
.result-detail {
    margin-bottom: 25px;
}

.result-detail p {
    font-size: 18px;
    color: #555;
    margin: 10px 0;
}

.result-detail strong {
    color: #e74c3c;
    font-size: 24px;
}

/* 上传进度 */
.upload-progress {
    margin-top: 20px;
    text-align: center;
}

.progress-bar {
    width: 100%;
    height: 8px;
    background: #e0e0e0;
    border-radius: 4px;
    overflow: hidden;
    margin-bottom: 10px;
}

.progress-fill {
    height: 100%;
    width: 0%;
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    border-radius: 4px;
    transition: width 0.3s;
}

.progress-text {
    color: #666;
    font-size: 14px;
}

/* 图片预览 */
.image-preview {
    margin-top: 15px;
    text-align: center;
    padding: 15px;
    background: #f8f9fa;
    border-radius: 10px;
    border: 2px dashed #ddd;
}

.image-preview img {
    max-width: 100%;
    max-height: 250px;
    border-radius: 8px;
    box-shadow: 0 2px 8px rgba(0,0,0,0.1);
}

.preview-info {
    margin-top: 10px;
    font-size: 13px;
    color: #666;
}

.preview-info span {
    margin: 0 10px;
}

/* 文件输入样式 */
.form-control-file {
    display: block;
    width: 100%;
}

/* 预览开关复选框 - 提升特异性以覆盖 game.css 中的 label/input 默认样式 */
.create-game-box label.preview-toggle {
    display: flex;
    align-items: center;
    font-weight: bold;
    cursor: pointer;
    margin-bottom: 5px;
}

.create-game-box label.preview-toggle input[type="checkbox"] {
    width: 18px;
    height: 18px;
    min-height: 18px;
    margin: 0 8px 0 0;
    padding: 0;
    cursor: pointer;
    flex-shrink: 0;
    vertical-align: middle;
}

.create-game-box label.preview-toggle span {
    line-height: 18px;
    font-size: 14px;
}

.help-block {
    font-size: 12px;
    color: #999;
    margin-top: 5px;
}

/* 拼图平移动画 */
@keyframes tileSlide {
    from { opacity: 0.7; }
    to { opacity: 1; }
}

.puzzle-tile.moving {
    animation: tileSlide 0.15s ease;
}

/* 拼图完成 - 移除方块描边，呈现完整原图 */
.puzzle-board.puzzle-board-completed {
    border-color: #2ecc71;
    box-shadow: 0 0 30px rgba(46, 204, 113, 0.6), 0 4px 16px rgba(0,0,0,0.3);
    animation: completedPulse 1.5s ease-in-out infinite alternate;
}

.puzzle-board.puzzle-board-completed .puzzle-tile {
    box-shadow: none !important;
    cursor: default;
    animation: fadeInImage 0.6s ease;
}

@keyframes completedPulse {
    from { box-shadow: 0 0 20px rgba(46, 204, 113, 0.5), 0 4px 16px rgba(0,0,0,0.3); }
    to   { box-shadow: 0 0 40px rgba(46, 204, 113, 0.9), 0 4px 16px rgba(0,0,0,0.3); }
}

@keyframes fadeInImage {
    from { opacity: 0.5; }
    to   { opacity: 1; }
}

/* 完成提示 toast */
.success-toast {
    display: none;
    position: fixed;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    padding: 30px 50px;
    background: linear-gradient(135deg, #2ecc71 0%, #27ae60 100%);
    color: white;
    font-size: 28px;
    font-weight: bold;
    border-radius: 20px;
    box-shadow: 0 15px 50px rgba(0,0,0,0.4);
    z-index: 9999;
    text-shadow: 0 2px 4px rgba(0,0,0,0.2);
    animation: toastBounce 0.5s ease;
}

@keyframes toastBounce {
    0%   { transform: translate(-50%, -50%) scale(0.5); opacity: 0; }
    60%  { transform: translate(-50%, -50%) scale(1.1); opacity: 1; }
    100% { transform: translate(-50%, -50%) scale(1); opacity: 1; }
}