@import url(https://fonts.googleapis.com/css?family=Righteous);

/* --- 基础重置与布局 --- */
* { margin: 0; padding: 0; box-sizing: border-box; }

body {
    font-family: 'Microsoft YaHei', -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
    background: radial-gradient(at 50% 0, transparent, #080808), repeating-conic-gradient(hsla(0, 0%, 0%, .235) 0% 25%, transparent 0% 50%) 0 0 / 0.375em 0.375em, #3b3b3b;
    min-height: 100vh;
    padding: 20px;
    -webkit-font-smoothing: antialiased;
    display: flex;
    flex-direction: column;
    align-items: center;
    color: hsl(0 0% 90%);
}

.page-container { max-width: 1200px; width: 100%; position: relative; z-index: 2; flex: 1; }
.container { background: rgba(255, 255, 255, 0.03); backdrop-filter: blur(20px) saturate(1.2); border-radius: 16px; border: 1px solid rgba(255, 255, 255, 0.1); box-shadow: 0 8px 32px rgba(0, 0, 0, 0.3); overflow: hidden; }

/* --- 头部与导航 --- */
.back-btn { display: inline-block; margin-bottom: 1.5rem; color: hsl(0 0% 85%); text-decoration: none; transition: color 0.3s ease; }
.back-btn:hover { color: #fff; }

.header { text-align: center; margin-bottom: 2rem; }
.header h1 {
    font-family: 'Righteous', sans-serif; font-size: 3.5em; position: relative; line-height: 1.2; margin-bottom: 1rem;
    text-shadow: .03em .03em 0 hsla(230,40%,50%,1); display: inline-block;
}
.header h1::after {
    content: attr(data-shadow); position: absolute; top: .06em; left: .06em; width: 100%; height: 100%; z-index: -1;
    background-image: linear-gradient(45deg, transparent 45%, hsla(48,20%,90%,1) 45%, hsla(48,20%,90%,1) 55%, transparent 0);
    background-size: .05em .05em; -webkit-background-clip: text; background-clip: text; -webkit-text-fill-color: transparent;
    animation: shad-anim 60s linear infinite;
}
@keyframes shad-anim { 0% { background-position: 0 0; } 100% { background-position: 100% -100%; } }
.subtitle { font-size: 1rem; color: hsl(0 0% 75%); margin-top: 0.5rem; }

/* --- 通用组件 --- */
.section { padding: 2rem; border-bottom: 1px solid rgba(255, 255, 255, 0.1); }
.section:last-child { border-bottom: none; }

/* 按钮 */
.btn {
    cursor: pointer; border-radius: 12px; padding: 12px 30px; font-size: 1rem; font-weight: 500;
    background: transparent; border: 1px solid transparent; position: relative; color: white;
    transition: transform 0.1s ease-out, opacity 0.3s; user-select: none;
}
.btn:disabled { opacity: 0.6; cursor: not-allowed; }
.btn:active:not(:disabled) { transform: scale(0.98) translateY(1px); }
.btn:hover:not(:disabled) { transform: scale(1.02); }

.btn::before {
    content: ''; position: absolute; inset: -1px; border-radius: inherit; z-index: -1;
    background: linear-gradient(hsl(0 0% 100% / 0.18), hsl(0 0% 4% / 0.7));
    backdrop-filter: saturate(2) contrast(1) blur(10px); pointer-events: none;
}
.btn::after {
    content: ''; position: absolute; inset: -1px; border-radius: inherit; pointer-events: none;
    box-shadow: 0 0 1px 0.8px hsl(0 0% 100% / 0.8) inset;
    mask: linear-gradient(-35deg, #ffffff80, #ffffff30 30% 60%, #fff);
}
.btn-secondary { border: 1px solid rgba(255, 255, 255, 0.2); background: rgba(255, 255, 255, 0.05); color: hsl(0 0% 95%); }
.btn-secondary:hover:not(:disabled) { border-color: rgba(255, 255, 255, 0.35); background: rgba(255, 255, 255, 0.08); }

/* 输入控件 */
input[type="text"], input[type="number"], select {
    padding: 10px 12px; border-radius: 8px; border: 1px solid rgba(255, 255, 255, 0.1);
    background: rgba(255, 255, 255, 0.05); color: #fff; font-size: 0.95rem; outline: none; transition: all 0.3s ease;
}
input:hover, select:hover { background: rgba(255, 255, 255, 0.08); border-color: rgba(255, 255, 255, 0.2); }
input:focus, select:focus { border-color: #667eea; background: rgba(255, 255, 255, 0.1); }
select option { background: #1e293b; color: #e2e8f0; }

.checkbox-option {
    display: flex; align-items: center; gap: 10px; padding: 10px 12px;
    border: 1px solid rgba(255, 255, 255, 0.1); border-radius: 8px; cursor: pointer; transition: all 0.3s;
}
.checkbox-option:hover { background: rgba(255, 255, 255, 0.08); }
.checkbox-option input[type="checkbox"] { width: 18px; height: 18px; accent-color: #667eea; }

/* 数字输入框组件 */
.number-input-wrapper { position: relative; display: flex; align-items: center; }
.number-input-wrapper input { flex: 1; padding-right: 45px; }
.number-input-buttons { position: absolute; right: 2px; top: 50%; transform: translateY(-50%); display: flex; flex-direction: column; gap: 1px; }
.number-input-btn {
    width: 32px; height: 18px; background: rgba(255, 255, 255, 0.08); border: 1px solid rgba(255, 255, 255, 0.15);
    color: #e2e8f0; cursor: pointer; font-size: 10px; display: flex; align-items: center; justify-content: center;
}
.number-input-btn:first-child { border-radius: 4px 4px 0 0; }
.number-input-btn:last-child { border-radius: 0 0 4px 4px; }
.number-input-btn:hover { background: rgba(255, 255, 255, 0.15); }

/* --- 游戏布局 --- */
.game-layout { display: flex; flex-direction: column; gap: 24px; margin-bottom: 24px; }
.board-and-panel { display: grid; grid-template-columns: 1fr 340px; gap: 24px; align-items: flex-start; }
.board-stack { display: flex; flex-direction: column; gap: 20px; }
.board-card { display: flex; flex-direction: column; align-items: center; gap: 16px; width: 100%; }
#board { width: 100%; height: auto; aspect-ratio: 1/1; border-radius: 12px; box-shadow: 0 4px 16px rgba(0, 0, 0, 0.2); display: block; }

.game-actions { display: flex; gap: 10px; justify-content: center; width: 100%; }
.game-actions .btn { flex: 1; min-width: 80px; padding: 10px 16px; font-size: 0.9rem; }

/* 面板信息 */
.game-panel { display: flex; flex-direction: column; gap: 16px; }
.result-item { padding: 15px; background: rgba(255, 255, 255, 0.03); border: 1px solid rgba(255, 255, 255, 0.1); border-radius: 12px; backdrop-filter: blur(10px); }
.result-header { padding: 15px; border-radius: 12px; margin-bottom: 0; font-weight: 500; text-align: center; }
.result-header.success { background: rgba(76, 175, 80, 0.15); color: hsl(122 40% 75%); border: 1px solid rgba(76, 175, 80, 0.3); }
.result-header.error { background: rgba(244, 67, 54, 0.15); color: hsl(4 80% 75%); border: 1px solid rgba(244, 67, 54, 0.3); }

.scoreboard { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; margin-top: 8px; }
.scoreboard-item { 
    background: rgba(255, 255, 255, 0.05); 
    border: 1px solid rgba(255, 255, 255, 0.1); 
    border-radius: 8px; 
    padding: 12px; 
    text-align: center;
    color: #ffffff; /* 修复：强制夜间模式文字为白 */
}
.scoreboard-value { font-size: 1.8rem; font-weight: 700; line-height: 1.2; }
.scoreboard-detail { font-size: 0.75rem; opacity: 0.6; margin-top: 4px; }
.result-item-header { display: flex; justify-content: space-between; margin-bottom: 10px; opacity: 0.9; font-weight: 600; font-size: 0.9rem; text-transform: uppercase; }
.score-grid { display: grid; grid-template-columns: 1fr auto; gap: 6px 12px; align-items: center; font-size: 0.95rem; }

/* 设置区域 */
.settings-row { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 16px; }
.settings-group { display: flex; flex-direction: column; gap: 12px; border: 1px solid rgba(255, 255, 255, 0.12); border-radius: 12px; padding: 14px; background: rgba(255, 255, 255, 0.02); }
.settings-group > label { font-size: 0.9rem; font-weight: 600; text-transform: uppercase; opacity: 0.8; color: #e2e8f0; margin-bottom: 4px; }
.settings-group .beginner-label { color: #fbbf24; }
.settings-subgroup { display: flex; flex-direction: column; gap: 6px; }
.settings-subtitle { font-size: 0.8rem; font-weight: 600; text-transform: uppercase; opacity: 0.8; }
.settings-actions { display: flex; flex-wrap: wrap; gap: 10px; }
.settings-actions .btn { flex: 1; font-size: 0.85rem; padding: 8px; }

/* --- 规则折叠面板 --- */
.rules-collapsible { background: rgba(255, 255, 255, 0.03); border-radius: 12px; border: 1px solid rgba(255, 255, 255, 0.1); overflow: hidden; margin-top: 24px; }
.rules-toggle { width: 100%; background: rgba(102, 126, 234, 0.1); border: none; padding: 18px 24px; display: flex; justify-content: space-between; align-items: center; cursor: pointer; color: #e2e8f0; border-bottom: 1px solid rgba(255, 255, 255, 0.05); }
.rules-toggle:hover { background: rgba(102, 126, 234, 0.15); }
.rules-toggle-text { font-size: 1.2rem; font-weight: 700; }
.rules-toggle-icon { transition: transform 0.3s ease; color: #667eea; }
.rules-collapsible.collapsed .rules-toggle-icon { transform: rotate(-90deg); }
.rules-collapsible-content { max-height: 2000px; padding: 24px; transition: all 0.4s ease; }
.rules-collapsible.collapsed .rules-collapsible-content { max-height: 0; padding: 0 24px; }

.rules-content { display: grid; grid-template-columns: repeat(2, 1fr); gap: 20px; }
.rule-section { background: rgba(255, 255, 255, 0.02); border-radius: 8px; padding: 16px; border: 1px solid rgba(255, 255, 255, 0.08); }
.rule-section h4 { font-size: 1.05rem; color: #667eea; margin: 0 0 12px 0; padding-bottom: 8px; border-bottom: 1px solid rgba(102, 126, 234, 0.2); }
.rule-section ul { list-style: none; }
.rule-section li { position: relative; padding-left: 18px; margin-bottom: 10px; font-size: 0.92rem; line-height: 1.6; color: hsl(0 0% 80%); }
.rule-section li::before { content: "•"; position: absolute; left: 0; color: #667eea; font-weight: bold; }
.danger-text { color: #ef4444; }

/* --- 日间模式 (Day Mode) --- */
body.day-mode { background: #f0f4f8 url(../../../../assets/image/day-background.png) repeat; color: #2d3748; }
body.day-mode .container { background: hsla(0, 0%, 100%, 0.4); border-color: rgba(200, 200, 200, 0.4); box-shadow: 5px 3px 30px rgba(0, 0, 0, 0.1); }
body.day-mode .header h1 { color: #2d3748; text-shadow: .03em .03em 0 hsla(200, 60%, 60%, 1); }
body.day-mode .subtitle, body.day-mode .back-btn { color: #4a5568; }
body.day-mode .back-btn:hover { color: #1a202c; }

/* 修复日间模式下设置框边框不明显的问题 */
body.day-mode .settings-group {
    border: 1px solid rgba(0, 0, 0, 0.2); /* 修复：加深边框颜色 */
    background: rgba(255, 255, 255, 0.6); /* 修复：提亮背景 */
    box-shadow: 0 2px 8px rgba(0,0,0,0.05); /* 增加轻微阴影 */
}

body.day-mode .btn { background: #ffffff; color: #1a202c; border: 2px solid #cbd5e0; box-shadow: 0 2px 4px rgba(0, 0, 0, 0.05); }
body.day-mode .btn::before { background: none; }
body.day-mode .btn:hover:not(:disabled) { background: #f7fafc; border-color: #a0aec0; box-shadow: 0 4px 6px rgba(0, 0, 0, 0.1); }
body.day-mode input, body.day-mode select, body.day-mode .checkbox-option { background: rgba(255, 255, 255, 0.7); border-color: rgba(0, 0, 0, 0.2); color: #1a202c; }
body.day-mode select option { background: #ffffff; color: #2d3748; }
body.day-mode .number-input-btn { background: rgba(0, 0, 0, 0.05); border-color: rgba(0, 0, 0, 0.15); color: #2d3748; }
body.day-mode .settings-group > label { color: #2d3748; }
body.day-mode .settings-group .beginner-label { color: #d97706; }
body.day-mode #board { box-shadow: 0 4px 16px rgba(0, 0, 0, 0.1); }

/* 修复：确保日间模式下 scoreboard-item 颜色适配 */
body.day-mode .result-item, 
body.day-mode .scoreboard-item, 
body.day-mode .rules-collapsible, 
body.day-mode .rule-section {
    background: rgba(255, 255, 255, 0.6); 
    border-color: rgba(0, 0, 0, 0.1); 
    color: #2d3748; 
}

body.day-mode .rules-toggle { background: rgba(102, 126, 234, 0.1); color: #1a202c; border-bottom-color: rgba(0,0,0,0.1); }
body.day-mode .rule-section h4, body.day-mode .rule-section li::before { color: #5a67d8; }
body.day-mode .rule-section li { color: #2d3748; }
body.day-mode .danger-text { color: #dc2626; }
body.day-mode .result-header.success { background: rgba(76, 175, 80, 0.2); color: #22543d; }
body.day-mode .result-header.error { background: rgba(244, 67, 54, 0.2); color: #5f1d1a; }

/* --- 响应式设计 --- */
@media (max-width: 1200px) {
    .board-and-panel { grid-template-columns: 1fr; }
    .settings-row { grid-template-columns: repeat(2, 1fr); }
}
@media (max-width: 768px) {
    .header h1 { font-size: 2.5em; }
    .section { padding: 1.5rem; }
    .settings-row, .rules-content { grid-template-columns: 1fr; }
    .game-actions { flex-wrap: wrap; }
    .rules-toggle-text { font-size: 1.1rem; }
}
@media (max-width: 480px) {
    body { padding: 10px; }
    .header h1 { font-size: 2em; }
    .btn { padding: 12px; }
}

/* --- 滚动条 --- */
::-webkit-scrollbar { width: 8px; height: 8px; }
::-webkit-scrollbar-track { background: rgba(255, 255, 255, 0.05); border-radius: 4px; }
::-webkit-scrollbar-thumb { background: rgba(255, 255, 255, 0.2); border-radius: 4px; }
body.day-mode ::-webkit-scrollbar-thumb { background: rgba(0, 0, 0, 0.2); }

/* --- 主题切换开关 --- */
.theme-toggle { position: fixed; top: 20px; right: 20px; z-index: 1000; transform: scale(0.64); transform-origin: top right; }
.theme-toggle__checkbox { display: none; }
.theme-toggle__btn { display: block; position: relative; width: 125px; height: 70px; border-radius: 70px; border: 5px solid #1c1c1c; background-color: #3c4145; cursor: pointer; transition: all 350ms ease-in; }
.theme-toggle__btn::before { content: ''; position: absolute; top: 2px; left: 2px; width: 46px; height: 46px; border-radius: 50%; background-color: #fff; border: 5px solid #e3e3c7; transition: all 250ms ease-in; }
.theme-toggle__btn::after { content: ''; position: absolute; top: 62%; left: 39px; z-index: 10; width: 9px; height: 9px; opacity: 0; background: #fff; border-radius: 50%; box-shadow: #fff 0 0, #d3d3d3 0 0 0 3.5px; transition: opacity 100ms ease-in; }
.theme-toggle__feature { display: block; position: absolute; top: 9px; left: 52.5%; z-index: 20; width: 4px; height: 4px; border-radius: 50%; background-color: #fff; box-shadow: rgba(255,255,255,0.1) 30px -3px 0 0; animation: starry_star 5s ease-in-out infinite; }
.theme-toggle__feature::before { content: ''; position: absolute; top: -2px; left: -25px; width: 15px; height: 15px; background: #fff; border-radius: 50%; border: 4px solid #e3e3c7; box-shadow: #e3e3c7 -28px 0 0 -3px; transform-origin: -6px 130%; transition: all 250ms ease-in; }

@keyframes starry_star { 50% { background-color: rgba(255,255,255,0.1); box-shadow: #fff 30px -3px 0 0; } }
@keyframes bounceIn { 0% { opacity: 0; transform: scale(.3); } 50% { opacity: 1; transform: scale(1.1); } 100% { opacity: 1; transform: scale(1); } }

.theme-toggle__checkbox:checked + .theme-toggle__btn { background-color: #9ee3fb; border-color: #86c3d7; }
.theme-toggle__checkbox:checked + .theme-toggle__btn::before { left: 57px; background-color: #ffdf6d; border-color: #e1c348; }
.theme-toggle__checkbox:checked + .theme-toggle__btn::after { opacity: 1; animation: bounceIn 0.6s 0.1s backwards ease-in-out; }
.theme-toggle__checkbox:checked + .theme-toggle__btn .theme-toggle__feature { opacity: 0; animation: none; }

/* ===== 页脚样式 ===== */
.footer {
    position: relative;
    z-index: 1;
    width: 100%;
    padding: 2rem 1rem;
    text-align: center;
    margin-top: auto;
}

.footer p {
    margin: 0;
    font-size: 0.85rem;
    color: rgba(255, 255, 255, 0.4);
    transition: color 300ms ease-out;
}

/* 日间模式页脚样式 */
body.day-mode .footer p {
    color: rgba(0, 0, 0, 0.5);
}

/* 页脚响应式 */
@media (max-width: 768px) {
    .footer {
        padding: 1.5rem 1rem;
    }

    .footer p {
        font-size: 0.75rem;
    }
}