/* ====== Reset & Base ====== */
* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

:root {
    --primary: #20a53a;
    --primary-dark: #178a30;
    --accent: #ff8c00;
    --text: #333;
    --text-light: #666;
    --bg: #f8f9fa;
    --card: #ffffff;
    --border: #e8e8e8;
    --shadow: 0 2px 12px rgba(0, 0, 0, 0.08);
}

body {
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", "PingFang SC",
        "Hiragino Sans GB", "Microsoft YaHei", "微软雅黑", Helvetica, Arial, sans-serif;
    font-size: 16px;
    line-height: 1.8;
    color: var(--text);
    background: var(--bg);
}

a {
    color: var(--primary);
    text-decoration: none;
    transition: color 0.2s;
}

a:hover {
    color: var(--accent);
    text-decoration: underline;
}

img {
    max-width: 100%;
    display: block;
}

/* ====== Header ====== */
.site-header {
    background: linear-gradient(135deg, #20a53a 0%, #178a30 100%);
    color: #fff;
    padding: 60px 20px 50px;
    text-align: center;
    position: relative;
    overflow: hidden;
}

.site-header::before {
    content: "";
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: url("../images/code-pattern.svg") repeat;
    opacity: 0.08;
}

.site-header h1 {
    font-size: 2.4em;
    font-weight: 700;
    margin-bottom: 12px;
    position: relative;
    letter-spacing: 2px;
}

.site-header .subtitle {
    font-size: 1.1em;
    opacity: 0.92;
    position: relative;
    font-weight: 300;
}

.site-header .nav {
    margin-top: 26px;
    position: relative;
}

.site-header .nav a {
    color: #fff;
    margin: 0 14px;
    padding: 6px 14px;
    border: 1px solid rgba(255, 255, 255, 0.4);
    border-radius: 20px;
    font-size: 0.92em;
    display: inline-block;
}

.site-header .nav a:hover {
    background: rgba(255, 255, 255, 0.18);
    text-decoration: none;
}

/* ====== Main Layout ====== */
.container {
    max-width: 820px;
    margin: 0 auto;
    padding: 0 20px;
}

main {
    padding: 50px 0;
}

/* ====== Section / Article ====== */
.section {
    background: var(--card);
    border-radius: 10px;
    box-shadow: var(--shadow);
    padding: 40px;
    margin-bottom: 30px;
    transition: transform 0.25s, box-shadow 0.25s;
}

.section:hover {
    transform: translateY(-3px);
    box-shadow: 0 6px 22px rgba(0, 0, 0, 0.12);
}

.section-number {
    display: inline-block;
    background: var(--primary);
    color: #fff;
    width: 36px;
    height: 36px;
    line-height: 36px;
    text-align: center;
    border-radius: 50%;
    font-size: 0.95em;
    font-weight: 700;
    margin-right: 12px;
    vertical-align: middle;
}

.section h2 {
    display: inline-block;
    font-size: 1.6em;
    color: var(--text);
    vertical-align: middle;
    margin-bottom: 18px;
}

.section p {
    margin-bottom: 16px;
    color: var(--text);
    text-align: justify;
}

.section figure {
    margin: 24px 0;
    text-align: center;
}

.section figure img {
    border-radius: 8px;
    box-shadow: var(--shadow);
    margin: 0 auto;
}

.section figcaption {
    margin-top: 10px;
    font-size: 0.88em;
    color: var(--text-light);
}

/* ====== Inline code & lists ====== */
.code-inline {
    background: #f0f3f5;
    color: #c7254e;
    padding: 2px 6px;
    border-radius: 4px;
    font-family: "Consolas", "Courier New", monospace;
    font-size: 0.9em;
}

.section ul,
.section ol {
    margin: 0 0 16px 22px;
}

.section li {
    margin-bottom: 8px;
}

/* ====== Resource cards ====== */
.resource-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
    gap: 16px;
    margin-top: 18px;
}

.resource-card {
    background: var(--bg);
    border: 1px solid var(--border);
    border-left: 4px solid var(--primary);
    border-radius: 8px;
    padding: 18px;
    transition: border-left-color 0.2s, transform 0.2s;
}

.resource-card:hover {
    border-left-color: var(--accent);
    transform: translateY(-2px);
}

.resource-card h3 {
    font-size: 1.05em;
    color: var(--primary-dark);
    margin-bottom: 6px;
}

.resource-card p {
    font-size: 0.9em;
    color: var(--text-light);
    margin: 0;
    text-align: left;
}

/* ====== Tip / Callout box ====== */
.tip-box {
    background: #fffbe6;
    border: 1px solid #ffe58f;
    border-left: 4px solid var(--accent);
    border-radius: 6px;
    padding: 16px 20px;
    margin: 18px 0;
}

.tip-box strong {
    color: var(--accent);
}

/* ====== Footer ====== */
.site-footer {
    background: #2b2b2b;
    color: #aaa;
    text-align: center;
    padding: 30px 20px;
    font-size: 0.9em;
}

.site-footer a {
    color: #ddd;
}

.site-footer p {
    margin: 4px 0;
}

/* ====== Tetris 游戏 ====== */
.game-wrap {
    display: flex;
    flex-wrap: wrap;
    gap: 24px;
    justify-content: center;
    align-items: flex-start;
    margin-top: 20px;
}

#tetris-canvas {
    background: #0f172a;
    border: 2px solid #334155;
    border-radius: 8px;
    box-shadow: 0 4px 20px rgba(0, 0, 0, 0.25);
    max-width: 100%;
    height: auto;
    touch-action: none;
}

.game-side {
    min-width: 160px;
    display: flex;
    flex-direction: column;
    gap: 14px;
}

.game-stats {
    display: grid;
    grid-template-columns: 1fr 1fr 1fr;
    gap: 10px;
    margin-bottom: 4px;
}

.stat-box {
    background: var(--bg);
    border: 1px solid var(--border);
    border-radius: 8px;
    padding: 10px 6px;
    text-align: center;
}

.stat-box .stat-label {
    display: block;
    font-size: 0.75em;
    color: var(--text-light);
    margin-bottom: 2px;
}

.stat-box .stat-value {
    display: block;
    font-size: 1.3em;
    font-weight: 700;
    color: var(--primary-dark);
}

.game-status {
    min-height: 24px;
    font-weight: 600;
    color: var(--accent);
    text-align: center;
    font-size: 0.95em;
}

.game-help {
    font-size: 0.85em;
    color: var(--text-light);
    line-height: 1.9;
    background: var(--bg);
    border-radius: 8px;
    padding: 12px 14px;
}

.game-help kbd {
    background: #fff;
    border: 1px solid var(--border);
    border-bottom-width: 2px;
    border-radius: 4px;
    padding: 1px 6px;
    font-family: "Consolas", monospace;
    font-size: 0.85em;
    color: var(--text);
}

.game-btns {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 8px;
}

.game-btn {
    background: var(--primary);
    color: #fff;
    border: none;
    border-radius: 8px;
    padding: 14px 0;
    font-size: 1.1em;
    font-weight: 600;
    cursor: pointer;
    transition: background 0.15s, transform 0.1s;
    user-select: none;
    -webkit-user-select: none;
    touch-action: manipulation;
}

.game-btn:hover {
    background: var(--primary-dark);
}

.game-btn:active {
    transform: scale(0.94);
}

.game-btn.wide {
    grid-column: span 3;
}

.game-btn.secondary {
    background: #64748b;
}

.game-btn.secondary:hover {
    background: #475569;
}

/* ====== Responsive ====== */
@media (max-width: 600px) {
    .site-header h1 {
        font-size: 1.8em;
    }
    .section {
        padding: 24px 18px;
    }
    .section h2 {
        font-size: 1.3em;
    }
    .site-header .nav a {
        margin: 4px;
    }
}
