/* ============================================= */
/* CSS 变量与重置样式 */
/* ============================================= */

* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

:root {
    /* 颜色变量 */
    --bg-color: #121213;
    --text-color: #ffffff;
    --border-color: #3a3a3c;
    --tile-border: #3a3a3c;
    --key-bg: #818384;
    --modal-bg: #121213;
    --modal-border: #3a3a3c;
    --correct-color: #538d4e;
    --present-color: #b59f3b;
    --absent-color: #3a3a3c;

    /* 布局变量 */
    --word-length: 5;
    --header-height: 70px;
    --max-width: 500px;
    --tile-size: 55px;
    --key-size: 43px;
    --content-max-width: 1200px;
    --card-width-single: 70%;
}

body.light-mode {
    --bg-color: #ffffff;
    --text-color: #121213;
    --border-color: #d3d6da;
    --tile-border: #d3d6da;
    --key-bg: #d3d6da;
    --modal-bg: #ffffff;
    --modal-border: #d3d6da;
    --absent-color: #787c7e;
}

body.color-blind-mode {
    --correct-color: #f5793a;
    --present-color: #85c0f9;
}

/* ============================================= */
/* 基础布局与组件 */
/* ============================================= */

body {
    font-family: 'Helvetica Neue', Arial, sans-serif;
    background-color: var(--bg-color);
    color: var(--text-color);
    display: flex;
    flex-direction: column;
    min-height: 100vh;
    transition: all 0.3s;
}

.header-center {
    flex: 1;
    text-align: center;
    min-width: 0;
}

h1 {
    font-size: 2.3rem;
    font-weight: 700;
    letter-spacing: 0.05rem;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    margin: 0;
}

/* 图标按钮 */
.icon-btn {
    background: none;
    border: none;
    color: var(--text-color);
    cursor: pointer;
    padding: 0.35rem;
    border-radius: 4px;
    transition: background 0.2s;
    display: flex;
    align-items: center;
    justify-content: center;
}

.icon-btn svg {
    width: 18px;
    height: 18px;
}

/* 主内容区域 */
main {
    flex: 1;
    display: flex;
    flex-direction: column;
    align-items: center;
    padding: 0.8rem 0.5rem 1rem;
    max-width: var(--max-width);
    margin: 0 auto;
    width: 100%;
}

/* 按钮组件 */
.btn {
    background: var(--correct-color);
    color: white;
    border: none;
    padding: 1rem 2rem;
    border-radius: 4px;
    font-weight: 700;
    cursor: pointer;
    width: 100%;
    margin-top: 1rem;
    transition: all 0.2s;
}

.btn:hover {
    opacity: 0.9;
}

.btn-secondary {
    background: #818384;
}

.btn-primary {
    background: linear-gradient(135deg, var(--correct-color), #4a7c46);
    color: white;
    border: none;
    padding: 1.5rem 4rem;
    font-size: 1.4rem;
    font-weight: bold;
    border-radius: 12px;
    cursor: pointer;
    transition: all 0.4s ease;
    box-shadow: 0 8px 25px rgba(83, 141, 78, 0.4);
    position: relative;
    overflow: hidden;
}

.btn-action {
    padding: 6px 12px;
    font-size: 0.8rem;
    font-weight: 600;
    background: #818384;
    color: white;
    border: none;
    border-radius: 4px;
    cursor: pointer;
    transition: all 0.2s;
    white-space: nowrap;
    width: auto;
}

.btn-copy {
    padding: 0.75rem 1rem;
    white-space: nowrap;
}

.btn-copy.disabled,
.btn-copy:disabled {
    background: #5a6268 !important;
    opacity: 0.6;
    cursor: not-allowed;
    transform: none !important;
}

/* 页脚 */
footer {
    background-color: var(--bg-color);
    border-top: 1px solid var(--border-color);
    padding: 1rem;
    margin-top: auto;
}

.footer-content {
    max-width: var(--max-width);
    margin: 0 auto;
    text-align: center;
}

.footer-content p {
    color: var(--text-color);
    margin-bottom: 0.5rem;
    font-size: 0.875rem;
}

.footer-links {
    display: flex;
    justify-content: center;
    align-items: center;
    gap: 0.5rem;
    flex-wrap: wrap;
    font-size: 0.875rem;
}

.footer-links a {
    color: var(--text-color);
    text-decoration: none;
    transition: opacity 0.2s;
}

.footer-links a:hover {
    opacity: 0.7;
    text-decoration: underline;
}

/* 覆盖层与模态框 */
.overlay {
    display: none;
    position: fixed;
    top: var(--header-height);
    left: 0;
    width: 100%;
    height: calc(100% - var(--header-height));
    background: var(--bg-color);
    z-index: 999;
    overflow-y: auto;
    padding: 1rem;
}

.overlay.show {
    display: block;
}

.overlay-content {
    max-width: var(--max-width);
    margin: 0 auto;
    padding: 2rem 0;
}

.overlay-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 2rem;
    padding-bottom: 1rem;
    border-bottom: 1px solid var(--border-color);
}

/* 关闭按钮 */
.close-btn {
    background: none;
    border: none;
    color: var(--text-color);
    font-size: 1.5rem;
    cursor: pointer;
    width: 40px;
    height: 40px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.2s ease;
    font-weight: 300;
}

.close-btn:hover {
    background-color: rgba(255, 255, 255, 0.1);
}

.close-btn:active {
    transform: scale(0.95);
}

/* 设置组件 */
.settings-section {
    margin-bottom: 2rem;
}

.setting-item {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 1.5rem;
    padding: 0.5rem 0;
    border-bottom: 1px solid var(--border-color);
}

.setting-group {
    display: flex;
    flex-direction: column;
}

.setting-label {
    font-size: 0.9rem;
    color: var(--text-color);
    margin-bottom: 0.25rem;
}

.setting-description {
    font-size: 0.75rem;
    color: var(--text-color);
    opacity: 0.7;
}

.setting-control {
    display: flex;
    align-items: center;
}

select {
    background: var(--bg-color);
    color: var(--text-color);
    border: 1px solid var(--border-color);
    padding: 0.5rem;
    border-radius: 4px;
}

/* 开关组件 */
.switch {
    position: relative;
    display: inline-block;
    width: 50px;
    height: 24px;
}

.switch input {
    opacity: 0;
    width: 0;
    height: 0;
}

.slider {
    position: absolute;
    cursor: pointer;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background-color: #ccc;
    transition: .4s;
    border-radius: 24px;
}

.slider:before {
    position: absolute;
    content: "";
    height: 16px;
    width: 16px;
    left: 4px;
    bottom: 4px;
    background-color: white;
    transition: .4s;
    border-radius: 50%;
}

input:checked + .slider {
    background-color: var(--correct-color);
}

input:checked + .slider:before {
    transform: translateX(26px);
}

/* 提示消息 */
#toast {
    position: fixed;
    top: 100px;
    left: 50%;
    transform: translateX(-50%);
    background: var(--bg-color);
    color: var(--text-color);
    padding: 1rem 2rem;
    border-radius: 4px;
    font-weight: 600;
    opacity: 0;
    pointer-events: none;
    transition: opacity 0.3s;
    z-index: 1000;
    border: 1px solid var(--border-color);
}

#toast.show {
    opacity: 1;
}

/* 内容区块 */
.content-section {
    margin-bottom: 2rem;
    padding: 1.5rem;
    background: var(--bg-color);
    border: 1px solid var(--border-color);
    border-radius: 8px;
}

.content-section h2 {
    font-size: 1.25rem;
    margin-bottom: 1rem;
    color: var(--text-color);
    text-align: center;
}

/* 简单页面内容 */
.simple-page-content {
    padding: 1rem 0;
    line-height: 1.6;
}

.simple-page-content h3 {
    margin-bottom: 1rem;
    color: var(--text-color);
}

.simple-page-content p {
    margin-bottom: 1rem;
    color: var(--text-color);
}

.simple-page-content ul {
    margin-left: 1.5rem;
    margin-bottom: 1rem;
}

.simple-page-content li {
    margin-bottom: 0.5rem;
    color: var(--text-color);
}

/* 动画 */
@keyframes pop {
    0% { transform: scale(1); }
    50% { transform: scale(1.1); }
    100% { transform: scale(1); }
}

@keyframes flip {
    0% {
        transform: rotateX(0);
    }
    50% {
        transform: rotateX(-90deg);
    }
    100% {
        transform: rotateX(0);
    }
}

@keyframes shake {
    0%, 100% { transform: translateX(0); }
    10%, 30%, 50%, 70%, 90% { transform: translateX(-5px); }
    20%, 40%, 60%, 80% { transform: translateX(5px); }
}

/* ============================================= */
/* 统一卡片样式 */
/* ============================================= */

/* 单行卡片容器 */
.card-container-single {
    width: var(--card-width-single);
    max-width: var(--content-max-width);
    margin: 0 auto;
    display: flex;
    flex-direction: column;
    align-items: center;
}

/* 多行卡片容器 */
.card-container-multi {
    width: 100%;
    max-width: var(--content-max-width);
    margin: 0 auto;
}

/* 通用卡片样式 */
.unified-card {
    background: var(--modal-bg);
    border: 2px solid var(--border-color);
    border-radius: 16px;
    padding: 2.5rem;
    transition: all 0.4s ease;
    position: relative;
    overflow: hidden;
    width: 100%;
    box-sizing: border-box;
}

.unified-card::before {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    width: 4px;
    height: 100%;
    background: linear-gradient(135deg, var(--correct-color), var(--present-color));
    opacity: 0;
    transition: opacity 0.3s ease;
}

.unified-card:hover::before {
    opacity: 1;
}

.unified-card:hover {
    transform: translateY(-5px);
    box-shadow: 0 15px 35px rgba(0, 0, 0, 0.15);
    border-color: var(--correct-color);
}

/* ============================================= */
/* 响应式设计 */
/* ============================================= */

/* 平板设备 (768px - 1024px) */
@media (max-width: 1024px) {
    .tile {
        font-size: 1.5rem;
    }

    .key {
        padding: 0.875rem 0.375rem;
        font-size: 0.75rem;
    }

    h1 {
        font-size: 1.1rem;
        letter-spacing: 0.03rem;
    }

    header {
        padding: 0.5rem;
    }

    .card-container-single {
        width: 85%;
    }
}

/* 手机设备 (480px - 768px) */
@media (max-width: 768px) {
    .btn-action {
        padding: 5px 10px;
        font-size: 0.75rem;
    }
    .logo-text {
        font-size: 20px;
    }

    .card-container-single {
        width: 90%;
    }

    .unified-card {
        padding: 2rem;
    }
}

/* 小屏手机设备 (< 480px) */
@media (max-width: 480px) {
    .btn-action {
        padding: 4px 8px;
        font-size: 0.7rem;
    }
    .logo-text {
        font-size: 16px;
    }

    .card-container-single {
        width: 95%;
    }

    .unified-card {
        padding: 1.5rem;
    }
}

/* 特别小的屏幕 */
@media (max-width: 360px) {
    .btn-action {
        padding: 4px 8px;
        font-size: 0.7rem;
    }
    .logo-text {
        font-size: 16px;
    }

    .unified-card {
        padding: 1.25rem;
    }
}

/* 暗色/亮色模式适配 */
body.light-mode .content-section {
    background: #ffffff;
    border-color: #e1e5e9;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.05);
}

body.light-mode .unified-card {
    background: #ffffff;
    border-color: #e1e5e9;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.05);
}

body.light-mode .unified-card:hover {
    box-shadow: 0 15px 35px rgba(0, 0, 0, 0.12);
    border-color: var(--correct-color);
}

.logo {
    display: flex;
    align-items: center;
    gap: 8px;
    text-decoration: none;
    color: var(--text-primary);
    font-size: 24px;
    font-weight: 600;
    transition: transform 0.2s;
}

.logo:hover {
    transform: scale(1.05);
}

.logo-icon {
    font-size: 28px;
}

.logo-text {
    font-weight: 400;
}

.logo-text strong {
    font-weight: 700;
    background: var(--gradient-1);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
}

/* ============================================= */
/* Game Rules Summary Color Boxes */
/* ============================================= */

.rules-summary ul li span {
    width: 20px;
    height: 20px;
    border-radius: 4px;
    flex-shrink: 0;
    display: inline-block;
}

.rules-summary ul li:nth-child(1) span {
    background-color: var(--correct-color);
    border: 2px solid var(--correct-color);
}

.rules-summary ul li:nth-child(2) span {
    background-color: var(--present-color);
    border: 2px solid var(--present-color);
}

.rules-summary ul li:nth-child(3) span {
    background-color: var(--absent-color);
    border: 2px solid var(--absent-color);
}

/* 确保在亮色模式下颜色正确 */
body.light-mode .rules-summary ul li:nth-child(3) span {
    background-color: var(--absent-color);
    border-color: var(--absent-color);
}