/* Chinese Chess (Xiangqi) styles */

.chess-page {
    background: linear-gradient(135deg, #fdf6ec 0%, #f6e5cb 100%);
}

/* ---------- Lobby ---------- */
.chess-lobby {
    padding: 2rem 0 4rem;
    max-width: 1200px;
    margin: 0 auto;
}

.chess-lobby-hero {
    text-align: center;
    margin-bottom: 2.5rem;
}

.chess-lobby-icon {
    font-size: 4rem;
}

.chess-lobby-cols {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 1.5rem;
    margin-bottom: 2rem;
}

@media (max-width: 760px) {
    .chess-lobby-cols {
        grid-template-columns: 1fr;
    }
}

.chess-card {
    padding: 1.5rem;
}

.chess-card h3 {
    margin-top: 0;
    margin-bottom: 0.5rem;
}

.chess-label {
    display: block;
    font-weight: 600;
    font-size: 0.85rem;
    margin: 0.9rem 0 0.35rem;
    color: var(--text-muted, #555);
}

.chess-card input[type="text"] {
    width: 100%;
    padding: 0.6rem 0.8rem;
    border: 1px solid #ccc;
    border-radius: 8px;
    font-size: 0.95rem;
    box-sizing: border-box;
}

.chess-select {
    width: 100%;
    padding: 0.6rem 0.8rem;
    border: 1px solid #ccc;
    border-radius: 8px;
    font-size: 0.95rem;
    background: #fff;
    box-sizing: border-box;
    cursor: pointer;
}

.chess-color-select {
    display: flex;
    gap: 0.6rem;
    margin-bottom: 1rem;
}

.color-pick {
    flex: 1;
    padding: 0.7rem;
    border: 2px solid #ddd;
    border-radius: 8px;
    cursor: pointer;
    font-weight: 700;
    background: #fff;
    transition: all 0.15s ease;
}

.color-pick.red.active {
    border-color: #d32f2f;
    background: #ffebee;
    color: #b71c1c;
}

.color-pick.black.active {
    border-color: #263238;
    background: #eceff1;
    color: #1b2a2e;
}

.btn-block {
    width: 100%;
}

.chess-error {
    color: #d32f2f;
    font-size: 0.85rem;
    min-height: 1.2em;
    margin: 0.5rem 0 0;
}

.chess-rules {
    padding: 1.5rem;
}

.chess-rules-list {
    margin: 0.5rem 0 0 1.2rem;
    line-height: 1.7;
}

.chess-muted {
    color: var(--text-muted, #777);
    font-size: 0.9rem;
}

/* ---------- Game page ---------- */
.chess-game {
    max-width: 1280px;
    margin: 0 auto;
    padding: 1.5rem 1rem 3rem;
}

.chess-game-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    flex-wrap: wrap;
    gap: 0.8rem;
    margin-bottom: 1.2rem;
}

.chess-title {
    margin: 0;
    font-size: 1.5rem;
}

.chess-sub {
    font-size: 0.9rem;
    color: var(--text-muted, #777);
    font-weight: 400;
}

.chess-room {
    margin-top: 0.4rem;
    font-size: 0.95rem;
}

.room-label { font-weight: 600; }

.room-code {
    background: #f1e2c4;
    border: 1px solid #d9c29a;
    border-radius: 6px;
    padding: 0.15rem 0.5rem;
    font-weight: 700;
    letter-spacing: 1px;
}

.chess-head-right { display: flex; gap: 0.5rem; flex-wrap: wrap; }

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

@media (max-width: 900px) {
    .chess-layout { grid-template-columns: 1fr; }
}

.chess-board-wrap {
    background: #f8e5bd;
    border: 1px solid #dcc393;
    border-radius: 12px;
    padding: 0.8rem;
    display: inline-block;
    max-width: 100%;
    box-sizing: border-box;
    box-shadow: 0 6px 20px rgba(93, 64, 55, 0.18);
    overflow-x: auto;
    overflow-y: hidden;
}

.chess-board-info { font-weight: 600; margin-bottom: 0.5rem; color: #4e342e;
        display: flex; justify-content: space-between; align-items: center; }

.zoom-controls { display: inline-flex; align-items: center; gap: 0.4rem; }

.zoom-btn {
    width: 26px; height: 26px;
    border: 1px solid #c9a95f;
    background: #fff8e7;
    color: #5d4037;
    border-radius: 6px;
    font-size: 1rem;
    line-height: 1;
    cursor: pointer;
    transition: background 0.15s ease;
}

.zoom-btn:hover { background: #f1e2c4; }

.zoom-label {
    font-size: 0.8rem;
    font-weight: 700;
    min-width: 38px;
    text-align: center;
    cursor: pointer;
    color: #5d4037;
}

.zoom-sep {
    width: 1px; height: 18px;
    background: #d9c29a;
    margin: 0 0.2rem;
}

.chess-board-wrap:fullscreen {
    width: 100vw;
    height: 100vh;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    background: #1f1710;
    cursor: default;
    overflow: hidden;
}

.chess-board-wrap:fullscreen .chess-board-info { width: min(92vw, 92vh); }

.chess-board-wrap:fullscreen .chess-turn {
    color: #e8c98a;
    margin-top: 0.6rem;
}

/* iOS fallback "fullscreen": a fixed overlay covering the viewport */
.chess-board-wrap.fullscreen-fallback {
    position: fixed;
    top: 0;
    left: 0;
    width: 100vw;
    height: 100vh;
    z-index: 9999;
    border: none;
    border-radius: 0;
    margin: 0;
    background: #1f1710;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    overflow: hidden;
    cursor: default;
    padding: 0.8rem;
}

.chess-board-wrap.fullscreen-fallback .chess-board-info { color: #e8c98a; }
.chess-board-wrap.fullscreen-fallback .chess-turn { color: #e8c98a; margin-top: 0.6rem; }
.chess-board-wrap.fullscreen-fallback .zoom-btn { color: #e8c98a; }

#chessCanvas {
    display: block;
    max-width: none;
    height: auto !important;
    border-radius: 6px;
    touch-action: manipulation;
    user-select: none;
    -webkit-user-select: none;
    -webkit-touch-callout: none;
}

.chess-turn {
    margin-top: 0.7rem;
    font-weight: 700;
    color: #4e342e;
}

.chess-turn.flash-err {
    color: #b71c1c;
}

.chess-hint {
    margin-top: 0.5rem;
    font-size: 0.78rem;
    color: var(--text-muted, #887); 
}

.chess-hint code {
    background: #f1e2c4;
    border-radius: 4px;
    padding: 0.05rem 0.35rem;
}

/* ---------- Pawn promotion picker ---------- */
.chess-promo {
    position: fixed;
    inset: 0;
    z-index: 10000;
    display: flex;
    align-items: center;
    justify-content: center;
    background: rgba(30, 20, 10, 0.55);
}

.promo-box {
    background: #fffdf8;
    border: 2px solid #c9a95f;
    border-radius: 12px;
    padding: 1.2rem 1.4rem;
    text-align: center;
    box-shadow: 0 8px 30px rgba(0, 0, 0, 0.35);
    max-width: 90vw;
}

.promo-box h3 {
    margin: 0 0 0.9rem;
    color: #5d4037;
}

.promo-btns {
    display: flex;
    gap: 0.6rem;
    flex-wrap: wrap;
    justify-content: center;
}

.promo-btn {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 0.3rem;
    padding: 0.6rem 0.9rem;
    border: 2px solid #d9c29a;
    border-radius: 10px;
    background: #fff8e7;
    cursor: pointer;
    font-weight: 700;
    color: #5d4037;
    transition: all 0.15s ease;
    min-width: 72px;
}

.promo-btn:hover {
    border-color: #b58863;
    background: #f1e2c4;
}

.promo-glyph {
    font-size: 1.7rem;
    line-height: 1;
    font-family: serif;
}

.chess-side { display: flex; flex-direction: column; gap: 1rem; }

.chess-panel {
    background: #fffdf8;
    border: 1px solid #e0cfae;
    border-radius: 10px;
    padding: 1rem;
    box-shadow: 0 2px 10px rgba(93, 64, 55, 0.08);
}

.chess-panel h3 {
    margin: 0 0 0.7rem;
    font-size: 1rem;
    border-bottom: 1px solid #eee;
    padding-bottom: 0.4rem;
}

.player-row {
    display: flex;
    align-items: center;
    gap: 0.55rem;
    padding: 0.45rem 0;
    font-size: 0.95rem;
}

.player-row .dot {
    width: 14px; height: 14px;
    border-radius: 50%;
    display: inline-block;
    border: 1px solid #ccc;
    flex: 0 0 auto;
}

.dot.red { background: #e53935; }
.dot.black { background: #37474f; }

.pname { font-weight: 600; }

.pstatus { font-size: 0.75rem; color: #b8860b; }
.pstatus.away { color: #b71c1c; }

.chess-status { font-size: 0.92rem; color: var(--text-muted, #555); min-height: 1.2em; }

.chess-actions {
    display: flex;
    gap: 0.5rem;
    flex-wrap: wrap;
    margin-top: 0.5rem;
}

.chess-history {
    max-height: 260px;
    overflow-y: auto;
    font-size: 0.85rem;
}

.hist-line {
    margin: 0;
    padding: 0.25rem 0;
    border-bottom: 1px dashed #eee;
}

.chess-overlay {
    background: #fffbe9;
    border: 2px solid #e8c26a;
    border-radius: 10px;
    padding: 1.2rem;
    text-align: center;
    box-shadow: 0 4px 18px rgba(0, 0, 0, 0.15);
}

.chess-overlay h2 { margin: 0 0 0.4rem; color: #5d4037; }

/* ---------- Join panel ---------- */
.chess-notfound {
    background: #fff3e0;
    border: 1px solid #e0b36a;
    border-radius: 12px;
    padding: 1.5rem;
    margin-bottom: 1.2rem;
    text-align: center;
}

.chess-notfound p {
    font-size: 0.95rem;
    color: var(--text-muted, #666);
    margin-bottom: 1rem;
}
.chess-join {
    background: #fff8e7;
    border: 1px dashed #c9a95f;
    border-radius: 12px;
    padding: 1.2rem;
    margin-bottom: 1.2rem;
    max-width: 420px;
}

.chess-join h3 { margin: 0 0 0.4rem; }

.chess-form-row {
    display: flex;
    gap: 0.5rem;
    margin-top: 0.6rem;
}

.chess-form-row input[type="text"] {
    flex: 1;
    padding: 0.55rem 0.7rem;
    border: 1px solid #ccc;
    border-radius: 8px;
    font-size: 0.95rem;
}

/* ---------- About Section on Chess Page ---------- */
.chess-about-section {
    margin-top: 2.5rem;
    scroll-margin-top: 85px;
}

.chess-about-card {
    background: #ffffff;
    border-radius: 16px;
    border: 1px solid rgba(0, 0, 0, 0.08);
    box-shadow: 0 10px 30px rgba(0, 0, 0, 0.05);
    padding: 2.5rem 2rem;
    overflow: hidden;
    transition: background-color 0.2s ease, border-color 0.2s ease;
}

[data-theme="dark"] .chess-about-card,
body.dark-mode .chess-about-card {
    background: #1e293b;
    border-color: #334155;
    box-shadow: 0 10px 30px rgba(0, 0, 0, 0.35);
    color: #f1f5f9;
}

.chess-about-header {
    text-align: center;
    max-width: 820px;
    margin: 0 auto 2.5rem;
}

.chess-about-badge {
    display: inline-block;
    padding: 0.35rem 0.9rem;
    font-size: 0.8rem;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.06em;
    color: #4f46e5;
    background: #eef2ff;
    border-radius: 9999px;
    margin-bottom: 0.85rem;
}

[data-theme="dark"] .chess-about-badge,
body.dark-mode .chess-about-badge {
    background: rgba(99, 102, 241, 0.2);
    color: #a5b4fc;
}

.chess-about-title {
    font-size: 2.1rem;
    font-weight: 800;
    margin-bottom: 0.75rem;
    color: var(--text-primary, #0f172a);
}

[data-theme="dark"] .chess-about-title,
body.dark-mode .chess-about-title {
    color: #f8fafc;
}

.chess-about-subtitle {
    font-size: 1.05rem;
    line-height: 1.65;
    color: var(--text-secondary, #64748b);
}

[data-theme="dark"] .chess-about-subtitle,
body.dark-mode .chess-about-subtitle {
    color: #94a3b8;
}

.chess-about-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(320px, 1fr));
    gap: 1.5rem;
    margin-bottom: 2.5rem;
}

.about-feature-box {
    background: #f8fafc;
    border: 1px solid #e2e8f0;
    border-radius: 12px;
    padding: 1.6rem;
    display: flex;
    flex-direction: column;
    transition: transform 0.2s ease, box-shadow 0.2s ease, border-color 0.2s ease;
}

[data-theme="dark"] .about-feature-box,
body.dark-mode .about-feature-box {
    background: #0f172a;
    border-color: #334155;
}

.about-feature-box:hover {
    transform: translateY(-4px);
    box-shadow: 0 10px 25px rgba(0, 0, 0, 0.08);
    border-color: #cbd5e1;
}

[data-theme="dark"] .about-feature-box:hover,
body.dark-mode .about-feature-box:hover {
    box-shadow: 0 10px 25px rgba(0, 0, 0, 0.4);
    border-color: #475569;
}

.about-feature-icon {
    font-size: 2.2rem;
    margin-bottom: 0.8rem;
    line-height: 1;
}

.about-feature-box h4 {
    font-size: 1.15rem;
    font-weight: 700;
    margin-bottom: 0.6rem;
    color: var(--text-primary, #0f172a);
}

[data-theme="dark"] .about-feature-box h4,
body.dark-mode .about-feature-box h4 {
    color: #f1f5f9;
}

.about-feature-box p {
    font-size: 0.92rem;
    line-height: 1.65;
    color: var(--text-secondary, #64748b);
    flex-grow: 1;
    margin-bottom: 1.2rem;
}

[data-theme="dark"] .about-feature-box p,
body.dark-mode .about-feature-box p {
    color: #94a3b8;
}

.about-feature-link {
    font-size: 0.88rem;
    font-weight: 600;
    color: #4f46e5;
    text-decoration: none;
    display: inline-flex;
    align-items: center;
    gap: 0.3rem;
    transition: all 0.15s ease;
}

[data-theme="dark"] .about-feature-link,
body.dark-mode .about-feature-link {
    color: #818cf8;
}

.about-feature-link:hover {
    text-decoration: underline;
    gap: 0.5rem;
}

.chess-about-details {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 2rem;
    padding: 2rem 0;
    border-top: 1px solid var(--border-color, #e2e8f0);
    border-bottom: 1px solid var(--border-color, #e2e8f0);
    margin-bottom: 2rem;
}

@media (max-width: 768px) {
    .chess-about-details {
        grid-template-columns: 1fr;
    }
}

.details-column h3 {
    font-size: 1.15rem;
    font-weight: 700;
    margin-bottom: 0.6rem;
    color: var(--text-primary, #0f172a);
}

[data-theme="dark"] .details-column h3,
body.dark-mode .details-column h3 {
    color: #f1f5f9;
}

.details-column p {
    font-size: 0.92rem;
    line-height: 1.65;
    color: var(--text-secondary, #64748b);
}

[data-theme="dark"] .details-column p,
body.dark-mode .details-column p {
    color: #94a3b8;
}

.chess-about-footer {
    display: flex;
    justify-content: center;
    align-items: center;
    text-align: center;
}

.quick-links-group {
    display: flex;
    align-items: center;
    flex-wrap: wrap;
    justify-content: center;
    gap: 0.6rem;
}

.quick-links-label {
    font-size: 0.9rem;
    font-weight: 700;
    color: var(--text-secondary, #64748b);
    margin-right: 0.5rem;
}

[data-theme="dark"] .quick-links-label,
body.dark-mode .quick-links-label {
    color: #94a3b8;
}

.quick-badge {
    display: inline-flex;
    align-items: center;
    gap: 0.35rem;
    padding: 0.45rem 0.9rem;
    background: #f1f5f9;
    border: 1px solid #cbd5e1;
    border-radius: 9999px;
    font-size: 0.85rem;
    font-weight: 600;
    color: #334155;
    text-decoration: none;
    transition: all 0.15s ease;
}

[data-theme="dark"] .quick-badge,
body.dark-mode .quick-badge {
    background: #0f172a;
    border-color: #334155;
    color: #cbd5e1;
}

.quick-badge:hover {
    background: #4f46e5;
    border-color: #4f46e5;
    color: #ffffff;
    transform: translateY(-2px);
}
