@charset "UTF-8";
:root {
    --primary-color: #8B4513; /* 棕色 */
    --bg-color: #F4A460; /* 沙色 */
    --accent-color: #FFD700; /* 金色 */
    --neutral-color: #E0E0E0; /* 浅灰 */
    --text-color: #333333;
    --font-family: 'Helvetica Neue', Helvetica, Arial, sans-serif;
}

body {
    margin: 0;
    padding: 0;
    font-family: var(--font-family);
    background-color: var(--bg-color);
    background-image: linear-gradient(rgba(244, 164, 96, 0.8), rgba(244, 164, 96, 0.8)), url('assets/%E6%97%A7%E7%89%A9%E4%BB%93%E5%BA%93.png');
    background-size: cover;
    background-position: center;
    background-attachment: fixed;
    color: var(--text-color);
    font-size: 18px;
}

#app {
    width: 100%;
    min-height: 100vh;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
}

.screen {
    display: none;
    width: 100%;
    max-width: 600px;
    height: 100vh;
    padding: 20px;
    box-sizing: border-box;
    flex-direction: column;
}

.screen.active {
    display: flex;
}

/* 登录界面 */
.login-container {
    background-color: var(--neutral-color);
    padding: 40px;
    border-radius: 20px;
    box-shadow: 0 10px 20px rgba(0,0,0,0.1);
    text-align: center;
    margin: auto;
}

h1 {
    font-size: 2.5rem;
    color: var(--primary-color);
    margin-bottom: 10px;
}

.subtitle {
    font-size: 1.2rem;
    color: #666;
    margin-bottom: 30px;
}

.form-group {
    margin-bottom: 20px;
    text-align: left;
}

label {
    display: block;
    font-size: 1.2rem;
    margin-bottom: 8px;
    font-weight: bold;
    color: var(--primary-color);
}

input {
    width: 100%;
    padding: 15px;
    font-size: 1.2rem;
    border: 2px solid #ddd;
    border-radius: 10px;
    box-sizing: border-box;
    outline: none;
}

input:focus {
    border-color: var(--primary-color);
}

button {
    cursor: pointer;
    font-size: 1.2rem;
    border: none;
    border-radius: 10px;
    padding: 15px 30px;
    font-weight: bold;
    transition: transform 0.1s, background-color 0.2s;
    color: #333;
}

button:active {
    transform: scale(0.95);
}

.btn-primary {
    background-color: var(--accent-color);
}

.btn-primary:hover {
    background-color: #e6c200;
}

.btn-large {
    width: 100%;
    font-size: 1.5rem;
    margin-top: 20px;
}

.btn-secondary {
    background-color: var(--primary-color);
    color: white;
}

.btn-secondary:hover {
    background-color: #6b340e;
}

.btn-tool {
    background-color: #FFA500;
    color: white;
    width: 100%;
    margin-top: 10px;
}

/* 头部 */
header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    background-color: var(--neutral-color);
    padding: 15px 20px;
    border-radius: 15px;
    margin-bottom: 20px;
    box-shadow: 0 4px 6px rgba(0,0,0,0.05);
}

.user-info, .stats {
    font-size: 1.2rem;
    font-weight: bold;
    color: var(--primary-color);
}

/* 关卡选择 */
.level-selection h2 {
    text-align: center;
    color: var(--primary-color);
    font-size: 2rem;
}

.chapters {
    display: flex;
    flex-direction: column;
    gap: 20px;
}

.chapter-box {
    background-color: var(--neutral-color);
    border-radius: 15px;
    padding: 15px;
    box-shadow: 0 4px 6px rgba(0,0,0,0.05);
}

.chapter-title {
    font-size: 1.5rem;
    font-weight: bold;
    margin-bottom: 10px;
    color: var(--primary-color);
}

.levels-grid {
    display: grid;
    grid-template-columns: repeat(4, 1fr);
    gap: 10px;
}

.level-btn {
    background-color: var(--primary-color);
    color: white;
    padding: 15px 0;
    font-size: 1.2rem;
    border-radius: 10px;
}

.level-btn.locked {
    background-color: #ccc;
    color: #666;
    cursor: not-allowed;
}

/* 游戏界面 */
.game-header {
    flex-wrap: wrap;
    gap: 10px;
}

.game-stats {
    display: flex;
    gap: 15px;
    font-size: 1.2rem;
    font-weight: bold;
    color: var(--primary-color);
}

.timer {
    color: #d32f2f;
}

.board-container {
    flex: 1;
    display: flex;
    flex-direction: column;
    justify-content: flex-start;
    align-items: center;
    background-color: rgba(255, 255, 255, 0.5);
    border-radius: 10px;
    padding: 10px;
    margin-bottom: 5px;
    gap: 10px;
    width: 100%;
    overflow-y: auto;
}

.board-section {
    width: 100%;
    max-width: 350px; /* 缩小整体最大宽度 */
}

.board-title {
    text-align: center;
    margin: 0 0 5px 0;
    font-size: 1rem; /* 缩小标题字体 */
    color: var(--primary-color);
}

.puzzle-board {
    display: grid;
    gap: 2px;
    width: 100%;
    aspect-ratio: 1 / 1;
    margin: 0 auto;
    background-color: rgba(139, 69, 19, 0.3);
    border: 3px solid var(--primary-color);
    border-radius: 5px;
}

.pieces-pool {
    display: grid;
    gap: 5px;
    width: 100%;
    padding: 5px;
    background-color: rgba(255, 215, 0, 0.2);
    border: 3px solid var(--accent-color);
    border-radius: 5px;
    box-sizing: border-box;
}

/* 碎片池中的容器 */
.pool-slot {
    width: 100%;
    aspect-ratio: 1 / 1;
    box-sizing: border-box;
    display: flex;
    justify-content: center;
    align-items: center;
}

/* 拼图槽位（空白区域） */
.puzzle-slot {
    width: 100%;
    height: 100%;
    background-color: rgba(255, 255, 255, 0.5);
    border: 1px dashed rgba(139, 69, 19, 0.5);
    box-sizing: border-box;
    cursor: pointer;
    transition: background-color 0.2s;
    display: flex;
    justify-content: center;
    align-items: center;
}

.puzzle-slot:hover {
    background-color: rgba(255, 255, 255, 0.8);
}

.puzzle-slot.highlight {
    background-color: rgba(255, 215, 0, 0.5);
    border: 2px solid var(--accent-color);
}

/* 拼图碎片 */
.puzzle-piece {
    width: 100%;
    height: 100%;
    background-size: cover;
    background-position: center;
    background-repeat: no-repeat;
    box-sizing: border-box;
    border: 1px solid rgba(255,255,255,0.5);
    transition: transform 0.2s, box-shadow 0.2s;
    position: relative;
    cursor: pointer;
}

/* 针对在候选池中的碎片，强制使其具有固定大小的响应式表现，或者让其填满 pool-slot */
.pool-slot .puzzle-piece {
    width: 100%;
    height: 100%;
}

.puzzle-piece.selected {
    border: 3px solid var(--accent-color);
    transform: scale(0.95);
    box-shadow: 0 0 10px var(--accent-color);
    z-index: 10;
}

.puzzle-piece.correct {
    border: none;
    cursor: default;
}

.puzzle-piece.hinted {
    animation: flashHint 1s ease-in-out;
}

@keyframes flashHint {
    0% { box-shadow: 0 0 0 transparent; }
    50% { box-shadow: 0 0 20px #00ff00 inset; }
    100% { box-shadow: 0 0 0 transparent; }
}

/* 弹窗 */
.modal {
    display: none;
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background-color: rgba(0,0,0,0.7);
    z-index: 1000;
    justify-content: center;
    align-items: center;
}

/* 原图参考 */
.tools-container {
    display: flex;
    justify-content: center;
    align-items: center;
    gap: 20px;
    margin-top: 10px;
    padding-bottom: 10px;
}

.reference-preview {
    display: flex;
    flex-direction: column;
    align-items: center;
    cursor: pointer;
    transition: transform 0.2s;
}

.reference-preview:hover {
    transform: scale(1.05);
}

#reference-thumb {
    width: 60px;
    height: 60px;
    object-fit: contain;
    border: 2px solid var(--primary-color);
    border-radius: 5px;
    background-color: rgba(255, 255, 255, 0.8);
    box-shadow: 0 2px 5px rgba(0,0,0,0.2);
}

.reference-preview span {
    font-size: 0.8rem;
    color: var(--primary-color);
    font-weight: bold;
    margin-top: 5px;
}

.modal.active {
    display: flex;
}

.modal-content {
    background-color: var(--neutral-color);
    padding: 30px;
    border-radius: 20px;
    text-align: center;
    min-width: 300px;
    max-width: 90%;
    box-shadow: 0 10px 25px rgba(0,0,0,0.5);
}

.modal-content h2 {
    color: var(--primary-color);
    font-size: 2rem;
    margin-top: 0;
}

.modal-actions {
    margin-top: 20px;
    display: flex;
    gap: 10px;
    justify-content: center;
}

.story-content {
    text-align: left;
}

.story-content h2 {
    text-align: center;
}

.story-image-container {
    width: 100%;
    height: 200px;
    margin-bottom: 15px;
    display: flex;
    justify-content: center;
    align-items: center;
    background-color: #fff;
    border-radius: 10px;
    overflow: hidden;
}

.story-image-container img {
    max-width: 100%;
    max-height: 100%;
    object-fit: contain;
}

#story-text {
    font-size: 1.1rem;
    line-height: 1.6;
    color: #444;
    max-height: 150px;
    overflow-y: auto;
    padding: 10px;
    background-color: rgba(255,255,255,0.5);
    border-radius: 5px;
}

.level-card:hover {
    transform: translateY(-5px);
    box-shadow: 0 6px 12px rgba(0,0,0,0.15);
}

.level-card.locked {
    background-color: #f5f5f5;
    color: #999;
    cursor: not-allowed;
    border-color: #ddd;
}

.level-card.locked img {
    filter: grayscale(100%) opacity(0.5);
}