:root {
    --game-primary: #1e3a8a;
    --game-secondary: #d4a017;
    --ch-ink: #f8f4ea;
    --ch-light: #e8dcc4;
    --ch-dark: #3f6b4e;
    --ch-panel: #0f1a14;
}

body.ch-page {
    margin: 0;
    min-height: 100vh;
    font-family: "Rockwell", "Rockwell Nova", "Roboto Slab", serif;
    color: var(--ch-ink);
    background:
        radial-gradient(circle at 12% 8%, rgba(30, 58, 138, 0.35), transparent 42%),
        radial-gradient(circle at 88% 18%, rgba(212, 160, 23, 0.16), transparent 48%),
        linear-gradient(180deg, #0b1220 0%, #14532d 55%, #07140c 100%);
}

body.ch-page.game-menu-active {
    overflow-y: auto;
    overflow-x: hidden;
}

body.ch-page.game-menu-active #game-header,
body.ch-page.game-menu-active #game-header {
    display: none !important;
}

.ch-page .game-screen {
    display: none;
    min-height: 100vh;
}

.ch-page .game-screen.active {
    display: block;
}

body.ch-page.with-game-header .ch-shell {
    padding-top: 5.5rem;
}

.ch-shell {
    max-width: min(1100px, 96vw);
    margin: 0 auto;
    padding: 1.1rem 0.75rem 2.5rem;
}

.ch-layout {
    display: grid;
    grid-template-columns: minmax(0, 1fr) 260px;
    gap: 1.1rem;
    align-items: start;
}

.ch-hud {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 0.75rem;
    margin: 0 auto 0.85rem;
    padding: 0.55rem 0.7rem;
    background: linear-gradient(180deg, #1e3a8a, #0f172a);
    border: 3px solid #07140c;
    border-radius: 12px;
    box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.08), 0 10px 24px rgba(0, 0, 0, 0.35);
}

.ch-lcd {
    min-width: 5.4rem;
    padding: 0.2rem 0.45rem;
    background: #140414;
    color: #f5c518;
    font-family: "Courier New", ui-monospace, monospace;
    font-size: 1.15rem;
    font-weight: 700;
    letter-spacing: 0.04em;
    text-align: center;
    border-radius: 6px;
    box-shadow: inset 0 0 0 2px #1e3a8a, inset 0 8px 16px rgba(0, 0, 0, 0.45);
}

.ch-lcd span {
    display: block;
    font-size: 0.62rem;
    letter-spacing: 0.12em;
    text-transform: uppercase;
    color: #93c5fd;
}

.ch-toolbar {
    display: flex;
    flex-wrap: wrap;
    justify-content: center;
    gap: 0.45rem;
    margin: 0 auto 0.85rem;
}

.ch-chip {
    padding: 0.45rem 0.7rem;
    border-radius: 999px;
    background: rgba(255, 255, 255, 0.08);
    color: #fde68a;
    font-weight: 700;
}

.ch-chip.is-check {
    background: #b91c1c;
    color: #fff;
}

.ch-tool-btn {
    display: inline-flex;
    align-items: center;
    gap: 0.4rem;
    padding: 0.5rem 0.75rem;
    border-radius: 999px;
    border: 1px solid rgba(212, 160, 23, 0.28);
    background: rgba(15, 26, 20, 0.7);
    color: #f8fafc;
    font-weight: 700;
    cursor: pointer;
}

.ch-tool-btn:hover {
    border-color: #d4a017;
    color: #f5c518;
}

.ch-tool-btn:disabled {
    opacity: 0.45;
    cursor: not-allowed;
}

.ch-board-wrap {
    display: flex;
    justify-content: center;
}

.ch-board-frame {
    display: grid;
    grid-template-columns: 1.1rem 1fr;
    grid-template-rows: 1fr 1.1rem;
    gap: 0.15rem;
}

.ch-ranks,
.ch-files {
    display: grid;
    color: #fde68a;
    font-size: 0.72rem;
    font-weight: 700;
}

.ch-ranks {
    grid-template-rows: repeat(8, 1fr);
    align-items: center;
    justify-items: center;
}

.ch-files {
    grid-column: 2;
    grid-template-columns: repeat(8, 1fr);
    justify-items: center;
}

.ch-board {
    width: min(72vh, 92vw, 560px);
    height: min(72vh, 92vw, 560px);
    display: grid;
    grid-template-columns: repeat(8, 1fr);
    grid-template-rows: repeat(8, 1fr);
    border: 4px solid #07140c;
    border-radius: 8px;
    overflow: hidden;
    box-shadow: 0 18px 40px rgba(0, 0, 0, 0.45);
}

.ch-square {
    position: relative;
    display: flex;
    align-items: center;
    justify-content: center;
    margin: 0;
    padding: 0;
    border: 0;
    cursor: pointer;
    user-select: none;
}

.ch-square.light { background: var(--ch-light); }
.ch-square.dark { background: var(--ch-dark); }

.ch-square.is-last {
    box-shadow: inset 0 0 0 4px rgba(245, 197, 24, 0.72);
}

.ch-square.is-selected {
    box-shadow: inset 0 0 0 4px #1d4ed8;
}

.ch-square.is-check {
    background: #dc2626 !important;
}

.ch-square.is-legal::after {
    content: '';
    width: 28%;
    height: 28%;
    border-radius: 50%;
    background: rgba(15, 23, 42, 0.32);
    position: absolute;
}

.ch-square.is-capture::after {
    width: 72%;
    height: 72%;
    background: transparent;
    border: 4px solid rgba(185, 28, 28, 0.7);
}

.ch-piece {
    font-size: clamp(1.35rem, 7vw, 2.7rem);
    line-height: 1;
    pointer-events: none;
    filter: drop-shadow(0 2px 1px rgba(0, 0, 0, 0.45));
    font-family: "Font Awesome 7 Pro", "Font Awesome 6 Pro", "Font Awesome 6 Free" !important;
    font-weight: 900 !important;
    font-style: normal !important;
}

.ch-piece.white {
    color: #f7f1de;
    -webkit-text-stroke: 1px rgba(30, 27, 45, 0.45);
}

.ch-piece.black {
    color: #1a1528;
    -webkit-text-stroke: 1px rgba(212, 160, 23, 0.35);
}

.ch-captured {
    min-height: 1.6rem;
    display: flex;
    flex-wrap: wrap;
    gap: 0.2rem;
    margin: 0.4rem 0;
    font-size: 1rem;
}

.ch-captured .ch-piece {
    font-size: 1.05rem;
    -webkit-text-stroke: 0;
}

.ch-side {
    background: rgba(7, 20, 12, 0.72);
    border: 1px solid rgba(245, 197, 24, 0.2);
    border-radius: 14px;
    padding: 0.85rem;
}

.ch-side h3 {
    margin: 0 0 0.55rem;
    color: #f5c518;
    font-size: 0.95rem;
}

.ch-moves {
    max-height: 280px;
    overflow: auto;
    font-family: "Courier New", ui-monospace, monospace;
    font-size: 0.92rem;
    line-height: 1.55;
    color: #e2e8f0;
}

.ch-moves ol {
    margin: 0;
    padding-left: 1.4rem;
}

.ch-hint {
    margin: 0.85rem 0 0;
    text-align: center;
    color: #d9f99d;
}

.ch-settings-panel {
    background: rgba(15, 23, 42, 0.72);
    border: 1px solid rgba(255, 255, 255, 0.09);
    border-radius: 16px;
    padding: 1rem 1.1rem;
}

.ch-settings-panel__title {
    font-weight: 700;
    margin-bottom: 0.55rem;
    color: #f5c518;
}

.ch-settings-panel__label {
    margin: 0.35rem 0 0.4rem;
    font-weight: 600;
}

.ch-settings-panel__buttons {
    display: flex;
    flex-wrap: wrap;
    gap: 0.45rem;
    margin-bottom: 0.75rem;
}

.ch-settings-toggle {
    display: flex;
    align-items: center;
    gap: 0.55rem;
    font-weight: 600;
    margin: 0.35rem 0;
}

.ch-captured {
    min-height: 1.6rem;
    display: flex;
    flex-wrap: wrap;
    gap: 0.2rem;
    margin: 0.4rem 0;
}

.difficulty-pill {
    border: 1px solid rgba(255, 255, 255, 0.14);
    border-radius: 999px;
    padding: 0.5rem 0.85rem;
    background: rgba(255, 255, 255, 0.05);
    color: #f8fafc;
    font-weight: 600;
    cursor: pointer;
}

.difficulty-pill.is-selected {
    background: #f5c518;
    color: #1e1b4b;
    border-color: #f5c518;
}

.ch-settings-toggle {
    display: flex;
    align-items: center;
    gap: 0.55rem;
    font-weight: 600;
    margin: 0.35rem 0;
}

.modal {
    display: none;
    position: fixed;
    inset: 0;
    background: rgba(0, 0, 0, 0.72);
    z-index: 12000;
    align-items: center;
    justify-content: center;
    padding: 1rem;
}

.modal.active { display: flex; }

.modal-content {
    background: #fff;
    color: #1a1a1a;
    border-radius: 1rem;
    max-width: 640px;
    width: 100%;
    max-height: 90vh;
    overflow-y: auto;
}

.modal-large { max-width: 760px; }

.modal-header,
.modal-footer {
    padding: 1.1rem 1.4rem;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 0.75rem;
}

.modal-header { border-bottom: 2px solid #eee; }
.modal-header h2 { margin: 0; color: #1e3a8a; font-size: 1.35rem; }

.modal-close {
    background: #fff;
    border: 2px solid #1e3a8a;
    color: #1e3a8a;
    border-radius: 8px;
    cursor: pointer;
    padding: 0.35rem 0.55rem;
}

.modal-body { padding: 1.2rem 1.4rem; }
.modal-footer { border-top: 2px solid #eee; justify-content: flex-end; }

.help-section { margin-bottom: 1.1rem; }
.help-section h3 { color: #1e3a8a; margin: 0 0 0.4rem; }
.help-section ul { margin: 0.3rem 0 0; padding-left: 1.2rem; }

.stats-grid {
    display: grid;
    grid-template-columns: repeat(2, 1fr);
    gap: 0.75rem;
    margin-bottom: 1rem;
}

.stat-card {
    background: #f8fafc;
    border-radius: 12px;
    padding: 0.85rem;
    text-align: center;
}

.stat-value { font-size: 1.6rem; color: #1e3a8a; font-weight: 700; }
.stat-label { color: #64748b; font-size: 0.85rem; }

.win-stats {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 0.6rem;
    text-align: center;
}

.win-stat strong { display: block; font-size: 1.35rem; color: #1e3a8a; }
.win-stat span { color: #64748b; font-size: 0.82rem; }

.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 0.4rem;
    padding: 0.65rem 1.1rem;
    border-radius: 0.55rem;
    border: 2px solid transparent;
    font-weight: 700;
    cursor: pointer;
}

.btn-primary { background: #1e3a8a; color: #fff; }
.btn-secondary { background: #fff; color: #1e3a8a; border-color: #1e3a8a; }

.ch-promo {
    display: flex;
    justify-content: center;
    gap: 0.5rem;
}

.ch-promo button {
    width: 3.4rem;
    height: 3.4rem;
    font-size: 1.6rem;
    border-radius: 10px;
    border: 2px solid #1e3a8a;
    background: #e8dcc4;
    cursor: pointer;
}

.ch-thinking {
    color: #fde68a;
    font-weight: 700;
}

@media (max-width: 840px) {
    .ch-layout { grid-template-columns: 1fr; }
    .ch-side { order: 2; }
    .ch-moves { max-height: 160px; }
    .ch-tool-btn span { display: none; }
}
