/* style.css */

/* =========================================
   1. 默认主题 (清爽蓝)
   ========================================= */
:root {
    --primary-bg: linear-gradient(135deg, #fdfbfb 0%, #ebedee 100%);
    --container-bg: #ffffff;
    --primary-color: #0984e3;       /* 蔚蓝 */
    --primary-light: #74b9ff;
    --primary-hover: #0769b5;
    --accent-color: #ff7675;        /* 珊瑚红 */
    --text-main: #2d3436;
    --text-secondary: #636e72;
    --border-color: #dfe6e9;
    --shadow-soft: 0 10px 25px rgba(0, 0, 0, 0.05);
    --bottle-default-color: #f1f2f6;
    --bottle-stroke: #2d3436; /* 默认瓶子描边色 */
    
    /* 默认按钮 */
    --btn-blue: linear-gradient(135deg, #0984e3, #74b9ff);
    --btn-green: linear-gradient(135deg, #00b894, #55efc4);
    --btn-red: linear-gradient(135deg, #d63031, #ff7675);
    --btn-gray: #b2bec3;
}

/* =========================================
   2. 多主题包
   ========================================= */

/* 🌙 暗夜模式 (新增) */
body.theme-dark {
    --primary-bg: linear-gradient(135deg, #2d3436 0%, #000000 100%);
    --container-bg: #2d3436; /* 卡片背景变深 */
    --primary-color: #74b9ff; /* 主色调变亮以便阅读 */
    --primary-light: #0984e3;
    --primary-hover: #a29bfe;
    --accent-color: #ff7675;
    --text-main: #dfe6e9;    /* 文字变白 */
    --text-secondary: #b2bec3;
    --border-color: #636e72;
    --shadow-soft: 0 10px 25px rgba(0, 0, 0, 0.5);
    --bottle-default-color: #636e72; /* 空瓶子颜色 */
    --bottle-stroke: #dfe6e9; /* 瓶子描边变白 */
    
    --btn-blue: linear-gradient(135deg, #0984e3, #00cec9);
}

/* 🏮 春节/元旦 (喜庆红金) */
body.theme-cny {
    --primary-bg: linear-gradient(135deg, #fff0f0 0%, #fff5e6 100%);
    --primary-color: #d63031;
    --primary-light: #fab1a0;
    --primary-hover: #b71c1c;
    --accent-color: #fdcb6e;
    --btn-blue: linear-gradient(135deg, #d63031, #e17055);
}

/* 🎋 端午节 (竹林绿意) */
body.theme-dragon {
    --primary-bg: linear-gradient(135deg, #f0fff4 0%, #e6fffa 100%);
    --primary-color: #00b894;
    --primary-light: #55efc4;
    --primary-hover: #008c70;
    --accent-color: #ffeaa7;
    --btn-blue: linear-gradient(135deg, #00b894, #00cec9);
}

/* 💑 七夕/520 (浪漫粉紫) */
body.theme-love {
    --primary-bg: linear-gradient(135deg, #fff0f5 0%, #fff5f7 100%);
    --primary-color: #e84393;
    --primary-light: #fd79a8;
    --primary-hover: #d63031;
    --accent-color: #81ecec;
    --btn-blue: linear-gradient(135deg, #e84393, #fd79a8);
}

/* 🌕 中秋节 (深邃夜蓝) */
body.theme-moon {
    --primary-bg: linear-gradient(135deg, #f1f2f6 0%, #dfe4ea 100%);
    --primary-color: #2f3542;
    --primary-light: #57606f;
    --primary-hover: #1e272e;
    --accent-color: #f1c40f;
    --btn-blue: linear-gradient(135deg, #2f3542, #57606f);
}

/* 🇨🇳 国庆节 (盛世华诞 - 红黄) */
body.theme-national {
    --primary-bg: linear-gradient(135deg, #fff8f8 0%, #fffdf0 100%);
    --primary-color: #c0392b;
    --primary-light: #e74c3c;
    --primary-hover: #a93226;
    --accent-color: #f1c40f;
    --btn-blue: linear-gradient(135deg, #c0392b, #e74c3c);
}


/* =========================================
   3. 核心布局样式 (变量化)
   ========================================= */
body {
    font-family: 'Nunito', "PingFang SC", "Microsoft YaHei", sans-serif;
    background: var(--primary-bg);
    color: var(--text-main);
    margin: 0;
    padding: 20px;
    display: flex;
    justify-content: center;
    align-items: flex-start;
    min-height: 100vh;
    box-sizing: border-box;
    transition: background 0.5s ease, color 0.3s ease;
}

.container {
    max-width: 950px;
    width: 100%;
    margin: 20px auto;
    padding: 30px;
    background-color: var(--container-bg); /* 适配暗色 */
    border-radius: 24px;
    box-shadow: var(--shadow-soft);
    text-align: center;
    transition: all 0.3s ease;
    position: relative;
    overflow: hidden;
}

/* 主题选择器 */
.header-controls {
    position: absolute;
    top: 20px;
    right: 20px;
    z-index: 50;
}

.theme-selector-wrapper {
    display: flex;
    align-items: center;
    background: var(--container-bg); /* 适配暗色 */
    padding: 5px 10px;
    border-radius: 20px;
    border: 1px solid var(--border-color);
    box-shadow: 0 2px 5px rgba(0,0,0,0.05);
    transition: all 0.2s;
}

.theme-selector-wrapper:hover {
    border-color: var(--primary-color);
    transform: translateY(-1px);
}

.theme-icon { margin-right: 5px; font-size: 1.1rem; }

#theme-selector {
    border: none;
    background: transparent;
    font-family: inherit;
    font-size: 0.9rem;
    font-weight: bold;
    color: var(--text-main); /* 适配暗色 */
    cursor: pointer;
    outline: none;
}
#theme-selector option {
    background-color: var(--container-bg);
    color: var(--text-main);
}


h1 {
    font-family: 'ZCOOL KuaiLe', cursive, sans-serif;
    font-size: 2.2em;
    color: var(--text-main);
    margin: 10px 0 5px;
    letter-spacing: 1px;
}

.description {
    color: var(--text-secondary);
    margin-bottom: 25px;
    font-size: 0.95em;
    background: rgba(0,0,0,0.03); /* 适配暗色 */
    display: inline-block;
    padding: 6px 16px;
    border-radius: 20px;
}

.ticker-wrap {
    background: #fff3cd;
    color: #856404;
    padding: 8px 0;
    font-size: 0.9em;
    font-weight: 600;
    border-radius: 8px;
    margin: 15px 0;
    box-shadow: inset 0 0 5px rgba(0,0,0,0.05);
}
/* 暗色模式下跑马灯微调 */
body.theme-dark .ticker-wrap { background: #443805; color: #f1c40f; }

.tab-nav {
    display: flex;
    justify-content: center;
    gap: 10px;
    margin-bottom: 20px;
    padding: 5px;
    background: rgba(0,0,0,0.05); /* 适配暗色 */
    border-radius: 50px;
    width: fit-content;
    margin-left: auto;
    margin-right: auto;
}

.tab-btn {
    padding: 10px 25px;
    border: none;
    background: transparent;
    cursor: pointer;
    font-size: 1rem;
    font-weight: 700;
    color: var(--text-secondary); /* 适配暗色 */
    border-radius: 40px;
    transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    outline: none;
}
.tab-btn:hover { color: var(--text-main); }
.tab-btn.active {
    background-color: var(--container-bg); 
    color: var(--primary-color);
    box-shadow: 0 4px 10px rgba(0,0,0,0.08); transform: scale(1.05);
}

.action-btn {
    padding: 10px 22px;
    border: none;
    border-radius: 12px;
    color: white;
    font-size: 0.95rem;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.2s;
    background: var(--btn-blue);
    box-shadow: 0 4px 6px rgba(0,0,0,0.1);
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 6px;
}
.action-btn:hover { transform: translateY(-2px); box-shadow: 0 6px 12px rgba(0,0,0,0.15); filter: brightness(1.05); }
.action-btn:active { transform: translateY(0); }
.danger-btn { background: var(--btn-red); }
.edit-btn { background: var(--btn-green); }
.secondary-btn { background: var(--btn-gray); color: #2d3436; }
.outline-style { background: transparent; border: 2px solid var(--primary-color); color: var(--primary-color); box-shadow: none; }
.outline-style:hover { background: var(--primary-color); color: white; }
.icon-only { padding: 10px; border-radius: 50%; width: 40px; height: 40px; font-size: 1.2rem; }

.bottle-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(90px, 1fr));
    gap: 20px;
    justify-content: center;
    margin-bottom: 30px;
    padding: 10px;
    min-height: 200px;
}

.bottle-container {
    position: relative; padding: 15px 5px; display: flex; flex-direction: column;
    align-items: center; cursor: pointer; border-radius: 16px; 
    background: var(--container-bg); /* 适配暗色 */
    transition: all 0.3s cubic-bezier(0.25, 0.8, 0.25, 1); border: 2px solid transparent;
}
.bottle-container:hover { transform: translateY(-5px); box-shadow: var(--shadow-soft); border-color: var(--border-color); }

#bottles-section.edit-mode .bottle-container { cursor: grab; box-shadow: 0 0 0 2px var(--accent-color); animation: none; }
#bottles-section.edit-mode .bottle-container:active { cursor: grabbing; }
.bottle-container.dragging { opacity: 0.4; transform: scale(0.9); border-color: var(--primary-color); }
.bottle-container.drag-over { border-color: var(--primary-color); transform: scale(1.05); }

.bottle-svg { width: 70px; height: 70px; margin-bottom: 10px; filter: drop-shadow(0 4px 6px rgba(0,0,0,0.1)); }
.bottle-outline { fill: none; stroke: var(--bottle-stroke); stroke-width: 2; stroke-linecap: round; } /* 描边颜色变量化 */
.bottle-liquid { transition: y 0.4s ease, height 0.4s ease, fill 0.3s ease; }
.bottle-name { font-size: 0.85em; font-weight: 600; color: var(--text-main); width: 100%; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; pointer-events: none;}

/* 预设库样式 */
.library-tabs { display: flex; gap: 10px; margin-bottom: 15px; flex-wrap: wrap; justify-content: center; }
.library-tab-btn {
    padding: 8px 16px; border: 1px solid var(--border-color); 
    background: var(--container-bg); /* 适配暗色 */
    border-radius: 20px; cursor: pointer; transition: all 0.2s; color: var(--text-secondary);
}
.library-tab-btn.active { background: var(--primary-color); color: white; border-color: var(--primary-color); }
.library-content {
    display: flex; flex-wrap: wrap; gap: 10px; justify-content: center;
    max-height: 300px; overflow-y: auto; padding: 5px;
}
.library-item {
    background: rgba(0,0,0,0.05); /* 适配暗色 */
    padding: 8px 15px; border-radius: 12px; cursor: pointer;
    font-size: 0.9rem; transition: all 0.2s; border: 1px solid transparent; color: var(--text-main);
}
.library-item:hover { background: var(--primary-light); color: white; transform: translateY(-2px); }
.library-item:active { transform: scale(0.95); }

.color-palette {
    position: absolute; display: none; background-color: white; border-radius: 50px;
    padding: 8px 12px; z-index: 1000; display: flex; gap: 8px;
    box-shadow: 0 10px 20px rgba(0,0,0,0.15); animation: popIn 0.2s cubic-bezier(0.175, 0.885, 0.32, 1.275);
}
@keyframes popIn { from { opacity: 0; transform: scale(0.8); } to { opacity: 1; transform: scale(1); } }
.color-swatch {
    width: 32px; height: 32px; border-radius: 50%; cursor: pointer;
    border: 3px solid white; box-shadow: 0 2px 5px rgba(0,0,0,0.1); transition: transform 0.2s;
}
.color-swatch:hover { transform: scale(1.2); }

.game-header { display: flex; justify-content: space-between; align-items: center; margin-bottom: 20px; padding: 0 20px; }
.play-controls, .edit-controls {
    background: rgba(0,0,0,0.03); /* 适配暗色 */
    padding: 15px; border-radius: 20px; margin-bottom: 25px;
    display: flex; justify-content: center; align-items: center; gap: 20px; flex-wrap: wrap;
}
.big-play-btn { padding: 12px 30px; font-size: 1.1rem; background: var(--btn-blue); }
.dice-display {
    font-size: 2.5em; width: 60px; height: 60px; display: flex; align-items: center; justify-content: center;
    background: var(--container-bg); border-radius: 12px; box-shadow: inset 0 2px 5px rgba(0,0,0,0.05);
    color: var(--primary-color); font-weight: bold;
}

#game-board-wrapper {
    position: relative; max-width: 800px; margin: 0 auto; aspect-ratio: 10 / 5; 
    background: rgba(0,0,0,0.05); /* 适配暗色 */
    padding: 10px; border-radius: 16px;
}
#game-board { display: grid; grid-template-columns: repeat(10, 1fr); grid-template-rows: repeat(5, 1fr); width: 100%; height: 100%; gap: 6px; }
.game-cell {
    position: relative; z-index: 10; display: flex; justify-content: center; align-items: center; text-align: center;
    font-size: clamp(0.6rem, 1.2vw, 0.9rem); padding: 4px; line-height: 1.2; border-radius: 8px;
    box-shadow: 0 2px 0 rgba(0,0,0,0.05); transition: transform 0.2s; user-select: none; 
    color: #444; /* 这里格子内的文字如果是浅色背景，需要保持深色文字，除非完全反转 */
    overflow: hidden;
}
/* 暗色模式下，普通格子需要调整 */
body.theme-dark .game-cell { color: #333; border-color: #555; } /* 格子内部保持浅色背景，所以文字还是深色 */

.game-cell.editable { cursor: grab; }
.game-cell.editable:hover { box-shadow: 0 0 0 2px var(--primary-color) inset; }
.game-cell.selected { box-shadow: 0 0 0 3px var(--accent-color); transform: scale(1.05); z-index: 20; }
.game-cell.dragging { opacity: 0.5; cursor: grabbing; }
.grid-placeholder { border: 2px dashed var(--border-color); border-radius: 8px; transition: background-color 0.2s; }
.grid-placeholder.drag-over { background-color: var(--primary-light); border-color: var(--primary-color); }

/* 棋盘颜色修正 - 确保所有模式下都好看 */
.cell-type-task { background-color: #ffffff; border: 1px solid #e0e0e0; }
.cell-type-action { background-color: #d4edda; color: #155724; border: 1px solid #c3e6cb; }
.cell-type-special { background-color: #f8d7da; color: #721c24; border: 1px solid #f5c6cb; }
.cell-type-start { background-color: #cce5ff; color: #004085; border: 1px solid #b8daff; font-weight: bold; }
.cell-type-end { background-color: #e2e3e5; color: #383d41; border: 1px solid #d6d8db; font-weight: bold; }

/* 暗夜模式下的特殊格子微调 (降低亮度避免刺眼) */
body.theme-dark .cell-type-task { background-color: #b2bec3; border-color: #636e72; }
body.theme-dark .cell-type-action { background-color: #81c784; color: #000; }
body.theme-dark .cell-type-special { background-color: #e57373; color: #000; }
body.theme-dark .cell-type-start { background-color: #74b9ff; color: #000; }
body.theme-dark .cell-type-end { background-color: #a4b0be; color: #000; }


.cell-type-center {
    background-color: transparent; border: none; box-shadow: none; 
    color: var(--primary-color); font-family: 'ZCOOL KuaiLe', cursive; 
    font-size: clamp(2rem, 8vw, 5rem); opacity: 0.15; pointer-events: none; 
    z-index: 0; display: flex; justify-content: center; align-items: center; white-space: nowrap;
}

#player-piece {
    position: absolute; width: 24px; height: 24px; background-color: var(--accent-color);
    border: 3px solid white; border-radius: 50%; box-shadow: 0 4px 8px rgba(0,0,0,0.3);
    z-index: 30; transform: translate(-50%, -50%);
    transition: top 0.5s cubic-bezier(0.175, 0.885, 0.32, 1.275), left 0.5s cubic-bezier(0.175, 0.885, 0.32, 1.275);
}
#player-piece::after {
    content: ''; position: absolute; top: -50%; left: -50%; width: 200%; height: 200%;
    border-radius: 50%; background: var(--accent-color); opacity: 0.4; animation: pulse 2s infinite;
}
@keyframes pulse { 0% { transform: scale(0.5); opacity: 0.8; } 100% { transform: scale(1.5); opacity: 0; } }

.modal-overlay {
    position: fixed; top: 0; left: 0; width: 100%; height: 100%;
    background: rgba(0, 0, 0, 0.7); backdrop-filter: blur(5px);
    display: flex; justify-content: center; align-items: center; z-index: 1000;
}
.modal-content, .info-modal-content {
    background: var(--container-bg); /* 适配暗色 */
    padding: 30px; border-radius: 24px; box-shadow: 0 20px 40px rgba(0,0,0,0.2);
    border: none; width: 90%; max-width: 420px; display: flex; flex-direction: column; gap: 15px;
}
.fade-in-up { animation: fadeInUp 0.3s ease-out forwards; }
@keyframes fadeInUp { from { opacity: 0; transform: translateY(20px); } to { opacity: 1; transform: translateY(0); } }

.modal-content h3, .info-modal-content h2 { margin: 0 0 10px; text-align: center; color: var(--text-main); }
.modal-content label { text-align: left; font-weight: bold; color: var(--text-secondary); }
.modal-content input, .modal-content select {
    width: 100%; padding: 12px 15px; 
    border: 2px solid var(--border-color); 
    border-radius: 12px; font-size: 1rem;
    transition: border-color 0.2s; box-sizing: border-box;
    background: var(--container-bg); color: var(--text-main); /* 适配暗色 */
}
.modal-content input:focus, .modal-content select:focus { border-color: var(--primary-color); outline: none; }
.modal-buttons { display: flex; justify-content: space-between; flex-wrap: wrap; gap: 10px; margin-top: 10px; }

.info-modal-content { text-align: center; }
.modal-header-icon { font-size: 3rem; margin-bottom: 10px; }
.info-scroll-area {
    max-height: 300px; overflow-y: auto; margin-bottom: 20px; text-align: left;
    font-size: 0.9rem; padding-right: 5px; color: var(--text-secondary); line-height: 1.6;
}
.highlight-text { color: #d63031; background: #ffeaa7; padding: 5px; border-radius: 4px; }
.contact-buttons-container { display: flex; justify-content: center; gap: 15px; margin: 10px 0 20px; }
.contact-button {
    text-decoration: none; color: #fff; background-color: #2d3436;
    padding: 8px 16px; border-radius: 20px; font-size: 0.85rem; transition: background 0.2s;
}
.contact-button:hover { background-color: var(--primary-color); }
#info-modal-close {
    width: 100%; padding: 12px; background: var(--primary-color); color: white;
    border: none; border-radius: 12px; font-size: 1.1rem; font-weight: bold; cursor: pointer; transition: background 0.2s;
}
#info-modal-close:hover { background: var(--primary-hover); }

@media (max-width: 600px) {
    .container { padding: 15px; margin: 10px; width: 95%; }
    h1 { font-size: 1.8em; }
    .bottle-svg { width: 50px; height: 50px; }
    #game-board { gap: 2px; }
    .game-cell { font-size: 0.5rem; border-radius: 4px; box-shadow: none; border-width: 0.5px; }
    .action-btn { padding: 8px 14px; font-size: 0.85rem; }
    .modal-content { padding: 20px; }
    .tab-btn { padding: 8px 15px; font-size: 0.9rem; }
}