/* ChessCheers — 首页样式
   视觉世界：1930 年代橡皮管动画的片头卡 / 剧场海报。
   奶油纸底、墨线描边、赭橙与芥黄点缀；靠形状与配色表达年代感，
   不使用渐变文字、玻璃拟态或高饱和霓虹，避免干扰棋盘与选项的阅读。 */

:root {
    --paper: #f2e5cd;
    --paper-2: #e9d8b8;
    --card: #fbf3e1;
    --ink: #2b1c12;
    --ink-2: #5b4634;
    --ink-3: #8b7457;
    --line: #c9b48f;
    --orange: #c2561f;
    --orange-d: #a2430f;
    --gold: #e2a63c;
    --gold-l: #f4d79b;
    --brick: #a5382b;
    --sage: #6d7c4f;
    --radius: 16px;
    --shadow-lift: 0 10px 20px rgba(43, 28, 18, .14);
}

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

html { scroll-behavior: smooth; }

body {
    min-height: 100vh;
    color: var(--ink);
    font-family: "PingFang SC", "Hiragino Sans GB", "Noto Sans CJK SC", "Microsoft YaHei", "Helvetica Neue", Arial, sans-serif;
    -webkit-font-smoothing: antialiased;
    /* 纸面质感只用大面积暖色晕染，不叠加条纹或噪点 */
    background:
        radial-gradient(1100px 720px at 50% -12%, #fdf4e3 0%, rgba(253, 244, 227, 0) 62%),
        radial-gradient(900px 620px at 102% 104%, #ecd8b4 0%, rgba(236, 216, 180, 0) 58%),
        var(--paper);
    display: flex;
    flex-direction: column;
    align-items: center;
    padding: 0 20px 40px;
}

::selection { background: var(--gold); color: var(--ink); }

/* ============ 抬头区 ============ */
.hero {
    text-align: center;
    padding: 56px 20px 14px;
    width: 100%;
    max-width: 760px;
}

/* logo 本身带手绘字，直接作为标题字使用 */
.hero-logo {
    display: block;
    width: clamp(212px, 32vw, 320px);
    height: auto;
    margin: 0 auto;
    filter: drop-shadow(0 14px 24px rgba(43, 28, 18, .18));
}
.hero-logo:not([src]) { display: none; }

/* 有 logo 时，标题文字仅保留给读屏与搜索，不重复显示 */
.hero-logo[src] + .hero-title {
    position: absolute;
    width: 1px;
    height: 1px;
    overflow: hidden;
    clip: rect(0 0 0 0);
    white-space: nowrap;
}

/* 没有 logo 时的兜底标题 */
.hero-title {
    font-size: clamp(38px, 7vw, 62px);
    font-weight: 900;
    letter-spacing: .01em;
    color: var(--ink);
    line-height: 1.08;
}

.hero-subtitle {
    margin-top: 14px;
    font-size: 15px;
    line-height: 1.7;
    color: var(--ink-2);
    letter-spacing: .04em;
}

/* ============ 顶部菜单栏 ============ */
.top-nav {
    display: flex;
    justify-content: center;
    flex-wrap: wrap;
    gap: 8px 26px;
    margin: 22px 0 30px;
}

.nav-item {
    position: relative;
    padding: 4px 2px;
    font-size: 15px;
    font-weight: 600;
    letter-spacing: .06em;
    color: var(--ink-2);
    text-decoration: none;
    transition: color .18s ease;
}
.nav-item::after {
    content: "";
    position: absolute;
    left: 0;
    right: 0;
    bottom: 0;
    height: 2px;
    background: var(--orange);
    transform: scaleX(0);
    transform-origin: left;
    transition: transform .22s cubic-bezier(.2, .8, .3, 1);
}
.nav-item:hover { color: var(--ink); }
.nav-item:hover::after { transform: scaleX(1); }

/* ============ 配置区域 ============ */
.config-section {
    width: 100%;
    max-width: 680px;
    display: flex;
    flex-direction: column;
    gap: 18px;
}

.card {
    background: var(--card);
    border: 2px solid var(--ink);
    border-radius: var(--radius);
    padding: 22px 24px;
    transition: transform .22s cubic-bezier(.2, .8, .3, 1), box-shadow .22s ease;
    /* 入场：整组卡片依次落位，只做一次 */
    animation: card-in .5s cubic-bezier(.2, .8, .3, 1) both;
}
.card:nth-of-type(2) { animation-delay: .06s; }
.card:nth-of-type(3) { animation-delay: .12s; }
.card:nth-of-type(4) { animation-delay: .18s; }

@keyframes card-in {
    from { opacity: 0; transform: translateY(14px); }
    to { opacity: 1; transform: none; }
}

/* 静态只保留墨线描边，悬停时才抬起；避免描边与阴影同时承担层级 */
.card:hover { transform: translateY(-2px); box-shadow: var(--shadow-lift); }

.card.hidden { display: none; }

.card-head {
    display: flex;
    align-items: center;
    gap: 12px;
    margin-bottom: 16px;
}

.card-index {
    display: grid;
    place-items: center;
    width: 32px;
    height: 32px;
    flex: 0 0 32px;
    border: 2px solid var(--ink);
    border-radius: 50%;
    background: var(--gold);
    font-size: 13px;
    font-weight: 800;
    font-variant-numeric: tabular-nums;
    letter-spacing: 0;
}

.card-label {
    font-size: 17px;
    font-weight: 800;
    letter-spacing: .04em;
    color: var(--ink);
}

.label-hint {
    margin-left: 6px;
    font-size: 11px;
    font-weight: 600;
    letter-spacing: .1em;
    color: var(--ink-3);
    text-transform: uppercase;
}

/* ============ 阵营选择 ============ */
.faction-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 14px;
}

.faction-pick {
    display: flex;
    flex-direction: column;
    gap: 10px;
}

.faction-flag {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    font-size: 13px;
    font-weight: 700;
    letter-spacing: .08em;
    color: var(--ink-2);
}

.flag-dot {
    width: 14px;
    height: 14px;
    border: 2px solid var(--ink);
    border-radius: 50%;
}
.side-white .flag-dot { background: #fdf8ec; }
.side-black .flag-dot { background: var(--ink); }

.flag-text { line-height: 1; }

.faction-intro {
    margin-top: 16px;
    padding: 14px 16px;
    border: 1px dashed var(--line);
    border-radius: 12px;
    background: rgba(255, 252, 243, .7);
    max-height: 220px;
    overflow-y: auto;
}

/* ============ 下拉菜单 ============ */
.config-select {
    width: 100%;
    padding: 12px 42px 12px 14px;
    border: 2px solid var(--ink);
    border-radius: 12px;
    background-color: #fffaf0;
    color: var(--ink);
    font-family: inherit;
    font-size: 15px;
    font-weight: 600;
    line-height: 1.4;
    cursor: pointer;
    appearance: none;
    -webkit-appearance: none;
    background-image: url("data:image/svg+xml;charset=utf-8,%3Csvg xmlns='http://www.w3.org/2000/svg' width='14' height='9' viewBox='0 0 14 9'%3E%3Cpath d='M1 1l6 6 6-6' fill='none' stroke='%232b1c12' stroke-width='2.2' stroke-linecap='round' stroke-linejoin='round'/%3E%3C/svg%3E");
    background-repeat: no-repeat;
    background-position: right 15px center;
    transition: background-color .18s ease;
}
.config-select:hover { background-color: #fff6e6; }
.config-select:focus-visible {
    outline: 3px solid var(--gold);
    outline-offset: 2px;
}
.config-select option { background: #fffaf0; color: var(--ink); }

/* ============ 说明文字 ============ */
.config-desc {
    margin-top: 10px;
    font-size: 13px;
    line-height: 1.65;
    color: var(--ink-2);
}

.config-desc.error {
    color: var(--brick);
    font-weight: 700;
}

.config-desc.warn {
    color: var(--orange-d);
    font-size: 12px;
}

/* ============ 棋盘预览 ============ */
.board-preview-wrap {
    margin-top: 16px;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 10px;
}

.board-preview {
    width: 100%;
    max-width: 240px;
    aspect-ratio: 1 / 1;
    border: 2px solid var(--ink);
    border-radius: 12px;
    background-size: 100% 100%;
    background-repeat: no-repeat;
    background-color: var(--paper-2);
    transition: transform .22s cubic-bezier(.2, .8, .3, 1);
}
.board-preview:hover { transform: scale(1.015); }

.board-preview.empty {
    display: grid;
    place-items: center;
    padding: 16px;
    border-style: dashed;
    color: var(--brick);
    font-size: 13px;
    font-weight: 700;
    text-align: center;
    background-image: none;
}

#board-desc { margin-top: 0; text-align: center; }

/* ============ 执棋颜色 ============ */
.sub-field {
    margin-top: 16px;
    padding-top: 16px;
    border-top: 1px dashed var(--line);
}
.sub-field.hidden { display: none; }

.sub-label {
    display: block;
    margin-bottom: 10px;
    font-size: 13px;
    font-weight: 700;
    letter-spacing: .06em;
    color: var(--ink-2);
}

/* ============ 难度强度条 ============ */
.elo-meter {
    display: flex;
    gap: 5px;
    margin-top: 16px;
}
.elo-bar {
    flex: 1 1 0;
    height: 7px;
    border: 1px solid var(--line);
    border-radius: 4px;
    background: #ecd9b6;
    transition: background .25s ease, border-color .25s ease;
}
.elo-bar.on {
    background: var(--orange);
    border-color: var(--ink);
}

/* ============ 开始按钮 ============ */
.start-btn {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 12px;
    margin-top: 8px;
    padding: 18px 24px;
    border: 2px solid var(--ink);
    border-radius: 14px;
    background: var(--orange);
    color: #fff8ec;
    font-family: inherit;
    font-size: 17px;
    font-weight: 800;
    letter-spacing: .16em;
    cursor: pointer;
    transition: transform .18s cubic-bezier(.2, .8, .3, 1), background .18s ease, box-shadow .18s ease;
}
.start-btn:hover {
    background: var(--orange-d);
    transform: translateY(-2px);
    box-shadow: var(--shadow-lift);
}
.start-btn:active { transform: translateY(0); }
.start-btn:focus-visible { outline: 3px solid var(--gold); outline-offset: 3px; }
.start-btn:disabled {
    background: var(--paper-2);
    color: var(--ink-3);
    border-style: dashed;
    cursor: not-allowed;
    transform: none;
    box-shadow: none;
}

.start-text { line-height: 1; }

.start-arrow {
    font-size: 20px;
    line-height: 1;
    transition: transform .2s ease;
}
.start-btn:hover:not(:disabled) .start-arrow { transform: translateX(4px); }

/* ============ 页脚 ============ */
.site-foot {
    margin-top: 40px;
    display: flex;
    flex-wrap: wrap;
    justify-content: center;
    gap: 8px;
    font-size: 12px;
    letter-spacing: .04em;
    color: var(--ink-3);
}

.foot-sep { opacity: .6; }

/* ============ 返回顶部 ============ */
.back-to-top {
    position: fixed;
    right: 26px;
    bottom: 26px;
    width: 44px;
    height: 44px;
    border: 2px solid var(--ink);
    border-radius: 50%;
    background: var(--card);
    color: var(--ink);
    font-size: 18px;
    cursor: pointer;
    opacity: 0;
    visibility: hidden;
    transform: translateY(8px);
    transition: opacity .22s ease, transform .22s ease, visibility .22s;
}
.back-to-top.show { opacity: 1; visibility: visible; transform: none; }
.back-to-top:hover { background: var(--gold); }
.back-to-top:focus-visible { outline: 3px solid var(--gold); outline-offset: 3px; }

/* ============ 顶部提示 ============ */
.toast {
    position: fixed;
    top: -80px;
    left: 50%;
    transform: translateX(-50%);
    max-width: min(86vw, 520px);
    padding: 12px 22px;
    border: 2px solid var(--ink);
    border-radius: 12px;
    background: var(--ink);
    color: #fdf3e0;
    font-size: 14px;
    font-weight: 600;
    line-height: 1.5;
    text-align: center;
    z-index: 400;
    transition: top .3s cubic-bezier(.2, .9, .3, 1.2);
}
.toast.show { top: 22px; }
.toast.warn { background: var(--brick); border-color: #6d1f16; }
.toast.good { background: var(--sage); border-color: #45502f; }

/* ============ 响应式 ============ */
@media (max-width: 620px) {
    body { padding: 0 14px 32px; }
    .hero { padding: 36px 8px 10px; }
    .hero-logo { width: clamp(184px, 46vw, 240px); }
    .hero-subtitle { font-size: 14px; }
    .top-nav { gap: 6px 18px; margin: 18px 0 24px; }
    .card { padding: 18px 16px; }
    .card-label { font-size: 16px; }
    .faction-grid { grid-template-columns: 1fr; gap: 12px; }
    .board-preview { max-width: 200px; }
    .start-btn { padding: 16px 18px; font-size: 16px; letter-spacing: .1em; }
    .back-to-top { right: 16px; bottom: 16px; }
}

@media (prefers-reduced-motion: reduce) {
    * { animation-duration: .01ms !important; transition-duration: .01ms !important; }
}
