@font-face {
    font-family: 'Chess Display';
    src: url('../fonts/playfair-display.woff2') format('woff2');
    font-weight: 600 700;
    font-style: normal;
    font-display: swap;
}

:root {
    --bg: #0c0f14;
    --bg-panel: #15191f;
    --bg-panel-2: #1c2129;
    --bg-panel-3: #232933;
    --border: #2a3038;
    --text: #e7e5df;
    --text-muted: #8d8f95;
    --accent: #c2a06b;
    --accent-dark: #a3824f;
    --accent-glow: rgba(194, 160, 107, .28);
    --success: #4a9d6f;
    --danger: #c65a4a;
    --warning: #d99a3d;

    --font-body: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
    --font-display: 'Chess Display', Georgia, 'Times New Roman', serif;

    --square-light: #EEEED2;
    --square-dark: #769656;
}

* { box-sizing: border-box; }

html, body {
    margin: 0;
    padding: 0;
    background: var(--bg);
    color: var(--text);
    font-family: var(--font-body);
}

h1, h2, h3 {
    font-family: var(--font-display);
    font-weight: 700;
    letter-spacing: .01em;
}


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

.navbar {
    position: sticky;
    top: 0;
    z-index: 100;
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 0.85rem 1.5rem;
    background: var(--bg-panel);
    border-bottom: 1px solid var(--border);
    gap: .5rem;
}
.navbar .brand {
    font-weight: 700;
    font-size: 1.2rem;
    display: flex;
    align-items: center;
    gap: .5rem;
    color: var(--text);
    flex-shrink: 0;
}
.navbar .brand:hover { text-decoration: none; color: var(--text); }
.navbar nav { display: flex; align-items: center; gap: 1.1rem; flex-wrap: wrap; flex: 1; justify-content: flex-end; }
.navbar nav a:not(.btn) { color: var(--text-muted); font-weight: 500; }
.navbar nav a:not(.btn):hover { color: var(--text); text-decoration: none; }
.navbar .nav-links { display: flex; align-items: center; gap: 1.1rem; flex-wrap: wrap; }
.navbar .nav-auth { display: flex; align-items: center; gap: .6rem; padding-left: 1rem; margin-left: .2rem; border-left: 1px solid var(--border); }
.navbar .user-pill {
    background: var(--bg-panel-2);
    border: 1px solid var(--border);
    padding: .35rem .8rem;
    border-radius: 999px;
    font-size: .9rem;
    color: var(--text-muted);
}

/* --- Mobile nav toggle --- */
.nav-toggle {
    display: none;
    flex-direction: column;
    justify-content: center;
    align-items: center;
    gap: 4px;
    width: 2.3rem;
    height: 2.3rem;
    background: var(--bg-panel-2);
    border: 1px solid var(--border);
    border-radius: .4rem;
    cursor: pointer;
    padding: 0;
    flex-shrink: 0;
}
.nav-toggle:hover { border-color: #3a4756; }
.nav-toggle span {
    display: block;
    width: 1.1rem;
    height: 2px;
    background: var(--text);
    border-radius: 1px;
    transition: transform .2s ease, opacity .2s ease;
}
.nav-toggle[aria-expanded="true"] span:nth-child(1) { transform: translateY(6px) rotate(45deg); }
.nav-toggle[aria-expanded="true"] span:nth-child(2) { opacity: 0; }
.nav-toggle[aria-expanded="true"] span:nth-child(3) { transform: translateY(-6px) rotate(-45deg); }

/* 621px–860px: tablet — hamburger dropdown from the top navbar. Below that,
   the phone-sized bottom app bar (further down this file) takes over instead. */
@media (max-width: 860px) and (min-width: 621px) {
    .nav-toggle { display: flex; }
    .navbar nav#siteNav {
        display: none;
        position: absolute;
        top: 100%;
        left: 0;
        right: 0;
        flex-direction: column;
        align-items: stretch;
        background: var(--bg-panel);
        border-bottom: 1px solid var(--border);
        box-shadow: 0 16px 28px rgba(0,0,0,.4);
        padding: .25rem 1.5rem 1.15rem;
    }
    .navbar nav#siteNav.open { display: flex; animation: navDrop .18s ease; }
    .navbar .nav-links { flex-direction: column; align-items: stretch; gap: 0; }
    .navbar .nav-links a { padding: .7rem .1rem; border-bottom: 1px solid var(--border); }
    .navbar .nav-auth {
        flex-direction: column;
        align-items: stretch;
        border-left: none;
        border-top: 1px solid var(--border);
        margin: .5rem 0 0;
        padding: .85rem 0 0;
        gap: .6rem;
    }
    .navbar .nav-auth form { display: block !important; }
    .navbar .nav-auth .btn,
    .navbar .nav-auth .user-pill { width: 100%; text-align: center; }
}
@keyframes navDrop { from { opacity: 0; transform: translateY(-6px); } to { opacity: 1; transform: translateY(0); } }

/* --- Phone-sized: native-app-style bottom tab bar instead of a top menu --- */
.mobile-tabbar {
    display: none;
    position: fixed;
    left: 0; right: 0; bottom: 0;
    z-index: 150;
    align-items: stretch;
    background: var(--bg-panel);
    border-top: 1px solid var(--border);
    padding: .3rem .2rem calc(.3rem + env(safe-area-inset-bottom, 0px));
    box-shadow: 0 -10px 26px rgba(0,0,0,.4);
}
.mobile-tabbar .tab-item {
    flex: 1;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: .2rem;
    padding: .4rem .1rem;
    border: none;
    background: none;
    color: var(--text-muted);
    font-size: .66rem;
    font-weight: 600;
    font-family: inherit;
    cursor: pointer;
    border-radius: .6rem;
    transition: color .15s ease;
}
.mobile-tabbar .tab-item i { font-size: 1.2rem; line-height: 1; }
.mobile-tabbar .tab-item:hover,
.mobile-tabbar .tab-item:active { color: var(--text); text-decoration: none; }
.mobile-tabbar .tab-item.active { color: var(--accent); }

.more-sheet { display: none; position: fixed; inset: 0; z-index: 190; }
.more-sheet.show { display: block; }
.more-sheet-backdrop { position: absolute; inset: 0; background: rgba(6,8,11,.72); animation: fadeIn .15s ease; }
.more-sheet-panel {
    position: absolute;
    left: 0; right: 0; bottom: 0;
    background: var(--bg-panel);
    border-top: 1px solid var(--border);
    border-radius: 1rem 1rem 0 0;
    padding: .5rem 1.25rem calc(1.25rem + env(safe-area-inset-bottom, 0px));
    box-shadow: 0 -14px 34px rgba(0,0,0,.5);
    animation: sheetUp .2s cubic-bezier(.16,1,.3,1);
    max-height: 70vh;
    overflow-y: auto;
}
@keyframes sheetUp { from { transform: translateY(100%); } to { transform: translateY(0); } }
.more-sheet-handle { width: 2.5rem; height: 4px; background: var(--border); border-radius: 999px; margin: .5rem auto 1rem; }
.more-sheet-link {
    display: flex;
    align-items: center;
    gap: .8rem;
    padding: .85rem .15rem;
    color: var(--text);
    font-weight: 500;
    font-size: .96rem;
    border-bottom: 1px solid var(--border);
}
.more-sheet-link:last-of-type { border-bottom: none; }
.more-sheet-link i { width: 1.3rem; text-align: center; color: var(--accent); }
.more-sheet-link:hover { text-decoration: none; color: var(--accent); }
.more-sheet-divider { height: 1px; background: var(--border); margin: .35rem 0; }

@media (max-width: 620px) {
    .navbar .nav-toggle,
    .navbar nav#siteNav { display: none !important; }
    .mobile-tabbar { display: flex; }
    body { padding-bottom: calc(60px + env(safe-area-inset-bottom, 0px)); }
    .share-overlay { padding-bottom: calc(1.25rem + 60px + env(safe-area-inset-bottom, 0px)); }
}
.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: .4rem;
    border: 1px solid var(--border);
    background: var(--bg-panel-2);
    color: var(--text);
    padding: .55rem 1rem;
    border-radius: .5rem;
    font-size: .92rem;
    font-weight: 500;
    cursor: pointer;
    transition: background .15s ease, border-color .15s ease, transform .1s ease, box-shadow .15s ease;
}
.btn:hover { background: #29333f; border-color: #3a4756; text-decoration: none; }
.btn:active { transform: translateY(1px); }
.btn:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }
.btn-primary { background: linear-gradient(135deg, #dcb87c, var(--accent)); border: 1px solid #e8caa0; color: #191308; font-weight: 700; box-shadow: 0 2px 10px rgba(194,160,107,.35); }
.btn-primary:hover { background: linear-gradient(135deg, #e8caa0, #dcb87c); box-shadow: 0 4px 16px rgba(194,160,107,.45); }
.btn-outline-accent { background: transparent; border: 1px solid var(--accent); color: var(--accent); }
.btn-outline-accent:hover { background: var(--accent-glow); color: var(--text); border-color: var(--accent); }
.btn-danger { background: var(--danger); border-color: var(--danger); color: #fff; }
.btn-danger:hover { background: #d8402f; }
.btn-block { width: 100%; }
.btn-sm { padding: .3rem .6rem; font-size: .8rem; }
.btn[disabled] { opacity: .45; cursor: not-allowed; transform: none !important; box-shadow: none !important; }

.container { max-width: 1180px; margin: 0 auto; padding: 1.5rem 1rem 3rem; }

.hero { text-align: center; margin-bottom: 1.5rem; }
.hero h1 { margin: 0 0 .35rem; font-size: 1.6rem; text-wrap: balance; }
.hero p { text-wrap: balance; }

.table-responsive { width: 100%; overflow-x: auto; -webkit-overflow-scrolling: touch; }

.site-footer { border-top: 1px solid var(--border); margin-top: 1rem; }

@media (max-width: 600px) {
    .container { padding: 1.1rem .8rem 2.25rem; }
    .hero h1 { font-size: 1.35rem; }
    .hero p { font-size: .92rem; }
    .stat-box { min-width: 100px; padding: .8rem; }
    .stat-box .num { font-size: 1.3rem; }
    .history-table th, .history-table td,
    .leaderboard-table th, .leaderboard-table td { padding: .5rem .55rem; font-size: .84rem; }
    .room-header { flex-direction: column; align-items: stretch; text-align: center; }
    .room-header .btn { width: 100%; }
    .palette { grid-template-columns: repeat(5, 1fr); }
}
.hero p { color: var(--text-muted); margin: 0; }

.game-layout {
    display: grid;
    grid-template-columns: minmax(320px, 560px) 320px;
    gap: 1.5rem;
    align-items: start;
    justify-content: center;
}
@media (max-width: 940px) {
    .game-layout { grid-template-columns: 1fr; }
}

.board-panel { display: flex; flex-direction: column; align-items: center; gap: .75rem; }

.board-wrap {
    position: relative;
    width: 100%;
    max-width: 560px;
    aspect-ratio: 1 / 1;
}

#board {
    display: grid;
    grid-template-columns: repeat(8, 1fr);
    grid-template-rows: repeat(8, 1fr);
    width: 100%;
    height: 100%;
    border: 4px solid #0a0e13;
    border-radius: 8px;
    overflow: hidden;
    box-shadow: 0 12px 34px rgba(0,0,0,.45), 0 2px 8px rgba(0,0,0,.3);
    user-select: none;
}

.square {
    position: relative;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: background-color .35s ease, box-shadow .15s ease;
}
.square.light { background: var(--square-light); }
.square.dark { background: var(--square-dark); }
.square.highlight-move { box-shadow: inset 0 0 0 3px rgba(255, 205, 60, .85); background-image: linear-gradient(rgba(255,205,60,.28), rgba(255,205,60,.28)); }
.square.highlight-check { box-shadow: inset 0 0 0 3px rgba(231, 76, 60, .95); animation: checkPulse 1s ease-in-out infinite; }
.square.selected { box-shadow: inset 0 0 0 3px rgba(194, 160, 107, .95); background-image: linear-gradient(rgba(194,160,107,.22), rgba(194,160,107,.22)); }

@keyframes checkPulse {
    0%, 100% { box-shadow: inset 0 0 0 3px rgba(231,76,60,.95), inset 0 0 18px rgba(231,76,60,.15); }
    50% { box-shadow: inset 0 0 0 3px rgba(231,76,60,.6), inset 0 0 28px rgba(231,76,60,.45); }
}

.square .dot {
    position: absolute;
    width: 28%;
    height: 28%;
    border-radius: 50%;
    background: rgba(0,0,0,.28);
    pointer-events: none;
    animation: dotIn .12s ease-out;
}
.square .dot.capture {
    width: 100%;
    height: 100%;
    background: transparent;
    box-shadow: inset 0 0 0 4px rgba(0,0,0,.3);
    border-radius: 0;
}
@keyframes dotIn { from { transform: scale(0); opacity: 0; } to { transform: scale(1); opacity: 1; } }

.square .coord {
    position: absolute;
    font-size: .6rem;
    font-weight: 700;
    opacity: .55;
    pointer-events: none;
}
.square .coord.file { bottom: 2px; right: 4px; }
.square .coord.rank { top: 2px; left: 3px; }
.square.light .coord { color: var(--square-dark); }
.square.dark .coord { color: var(--square-light); }

.piece {
    font-size: min(9vw, 46px);
    line-height: 1;
    cursor: grab;
    filter: drop-shadow(0 2px 1px rgba(0,0,0,.35));
}
.piece.white { color: #fbfbfb; -webkit-text-stroke: 1px #33322e; }
.piece.black { color: #16130f; }
.piece.dragging { opacity: .35; }
.piece:active { cursor: grabbing; }
.piece-sliding { position: relative; z-index: 20; }
.piece-captured { opacity: 0; transform: scale(.4) rotate(12deg); }

/* --- Piece styles (purely CSS re-treatments of the same glyphs) --- */
#board.pieces-classic .piece.white { color: #fbfbfb; -webkit-text-stroke: 1px #33322e; filter: drop-shadow(0 2px 1px rgba(0,0,0,.35)); }
#board.pieces-classic .piece.black { color: #16130f; -webkit-text-stroke: 0; filter: drop-shadow(0 2px 1px rgba(0,0,0,.35)); }

#board.pieces-bold .piece.white { color: #ffffff; -webkit-text-stroke: 2px #1a1a1a; filter: drop-shadow(0 3px 2px rgba(0,0,0,.5)); }
#board.pieces-bold .piece.black { color: #0a0a0a; -webkit-text-stroke: 1.5px #f4f4f4; filter: drop-shadow(0 3px 2px rgba(0,0,0,.5)); }

#board.pieces-neon .piece.white { color: #eafcff; -webkit-text-stroke: 1px #17c9e6; filter: drop-shadow(0 0 6px #38e1ff) drop-shadow(0 0 2px #38e1ff); }
#board.pieces-neon .piece.black { color: #2a0a33; -webkit-text-stroke: 1px #d94fff; filter: drop-shadow(0 0 6px #d94fff) drop-shadow(0 0 2px #d94fff); }

#board.pieces-minimal .piece.white { color: #fafafa; -webkit-text-stroke: 0; filter: none; }
#board.pieces-minimal .piece.black { color: #1c1c1c; -webkit-text-stroke: 0; filter: none; }

.promotion-overlay {
    position: absolute;
    inset: 0;
    background: rgba(10, 14, 19, .82);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 30;
    animation: fadeIn .15s ease;
}
@keyframes fadeIn { from { opacity: 0; } to { opacity: 1; } }
.promotion-box {
    background: var(--bg-panel);
    border: 1px solid var(--border);
    border-radius: .6rem;
    padding: 1.1rem;
    text-align: center;
    box-shadow: 0 12px 32px rgba(0,0,0,.5);
    animation: popIn .18s cubic-bezier(.16,1,.3,1);
}
@keyframes popIn { from { opacity: 0; transform: scale(.85); } to { opacity: 1; transform: scale(1); } }
.promotion-box p { margin: 0 0 .7rem; color: var(--text-muted); font-size: .85rem; }
.promotion-choices { display: flex; gap: .5rem; }
.promotion-choices button {
    font-size: 2rem;
    width: 3.2rem;
    height: 3.2rem;
    border-radius: .5rem;
    border: 1px solid var(--border);
    background: var(--bg-panel-2);
    color: var(--text);
    cursor: pointer;
    transition: background .15s ease, transform .1s ease, border-color .15s ease;
}
.promotion-choices button:hover { background: var(--accent); border-color: var(--accent); transform: translateY(-2px); }

/* --- Share / snapshot modal --- */
.share-overlay {
    position: fixed;
    inset: 0;
    background: rgba(6, 8, 11, .93);
    backdrop-filter: blur(6px);
    -webkit-backdrop-filter: blur(6px);
    display: none;
    align-items: center;
    justify-content: center;
    padding: 1.25rem;
    z-index: 200;
    animation: fadeIn .15s ease;
}
.share-overlay.show { display: flex; }
.share-modal {
    position: relative;
    width: 100%;
    max-width: 400px;
    max-height: 90vh;
    overflow-y: auto;
    background: var(--bg-panel);
    border: 1px solid var(--border);
    border-radius: .7rem;
    padding: 1.5rem;
    box-shadow: 0 20px 50px rgba(0,0,0,.55);
    animation: popIn .18s cubic-bezier(.16,1,.3,1);
}
.share-close {
    position: absolute;
    top: .7rem;
    right: .7rem;
    width: 1.9rem;
    height: 1.9rem;
    border-radius: 50%;
    border: 1px solid var(--border);
    background: var(--bg-panel-2);
    color: var(--text-muted);
    font-size: 1.15rem;
    line-height: 1;
    cursor: pointer;
}
.share-close:hover { color: var(--text); border-color: #3a4756; }
.share-title { margin: 0 2rem .9rem 0; font-size: 1.05rem; }
.share-preview {
    display: flex;
    justify-content: center;
    margin-bottom: .9rem;
    border-radius: .5rem;
    overflow: hidden;
    border: 1px solid var(--border);
}
.share-preview-canvas { width: 100%; height: auto; display: block; }
.share-status { min-height: 1.1rem; font-size: .82rem; color: var(--text-muted); margin-bottom: .5rem; }
.share-status.error { color: var(--danger); }
.share-link-row { display: flex; gap: .5rem; margin-bottom: .7rem; }
.share-link-input {
    flex: 1;
    min-width: 0;
    padding: .5rem .65rem;
    border-radius: .4rem;
    border: 1px solid var(--border);
    background: var(--bg-panel-2);
    color: var(--text);
    font-size: .82rem;
}
.share-actions-row { display: flex; gap: .5rem; margin-bottom: 1rem; }
.share-actions-row .btn { flex: 1; }
.share-social-row { display: flex; gap: .55rem; justify-content: center; }
.share-social-btn {
    width: 2.6rem;
    height: 2.6rem;
    border-radius: 50%;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    background: var(--bg-panel-2);
    border: 1px solid var(--border);
    color: var(--text-muted);
    font-size: 1.05rem;
    transition: transform .12s ease, color .15s ease, border-color .15s ease;
}
.share-social-btn:hover { transform: translateY(-2px); text-decoration: none; border-color: var(--accent); }
.share-social-btn.wa:hover { color: #25D366; }
.share-social-btn.tw:hover { color: #e7e5df; }
.share-social-btn.fb:hover { color: #1877F2; }
.share-social-btn.tg:hover { color: #29A9EA; }
.share-social-btn.em:hover { color: var(--accent); }

.status-bar {
    display: flex;
    align-items: center;
    justify-content: space-between;
    width: 100%;
    max-width: 560px;
    background: var(--bg-panel);
    border: 1px solid var(--border);
    border-radius: .5rem;
    padding: .6rem .9rem;
    font-size: .92rem;
}
.status-bar .turn-indicator { display: flex; align-items: center; gap: .5rem; }
.status-dot { width: .65rem; height: .65rem; border-radius: 50%; background: var(--text-muted); transition: background .2s ease; }
.status-dot.thinking { background: var(--warning); animation: pulse 1s infinite; box-shadow: 0 0 8px rgba(241,196,15,.6); }
@keyframes pulse { 0%,100% { opacity:1; } 50% { opacity:.35; } }

#timer { font-variant-numeric: tabular-nums; color: var(--text-muted); font-size: .88rem; }

.thinking-dots { display: none; align-items: center; gap: 3px; margin-left: .1rem; }
.thinking-dots.show { display: inline-flex; }
.thinking-dots span {
    width: 4px; height: 4px; border-radius: 50%;
    background: var(--warning);
    opacity: .3;
    animation: dotBounce 1s infinite ease-in-out;
}
.thinking-dots span:nth-child(2) { animation-delay: .15s; }
.thinking-dots span:nth-child(3) { animation-delay: .3s; }
@keyframes dotBounce {
    0%, 80%, 100% { opacity: .25; transform: translateY(0); }
    40% { opacity: 1; transform: translateY(-2px); }
}

/* --- Player identity rows (above/below the board) --- */
.player-row {
    display: flex;
    align-items: center;
    justify-content: space-between;
    width: 100%;
    max-width: 560px;
    background: var(--bg-panel);
    border: 1px solid var(--border);
    border-radius: .5rem;
    padding: .55rem .8rem;
    transition: border-color .2s ease, box-shadow .2s ease, background .2s ease;
}
.player-row.active {
    border-color: var(--accent);
    box-shadow: 0 0 0 1px var(--accent-glow), 0 0 16px var(--accent-glow);
    background: linear-gradient(180deg, rgba(194,160,107,.08), transparent);
}
.player-identity { display: flex; align-items: center; gap: .6rem; min-width: 0; }
.player-glyph {
    font-size: 1.7rem;
    line-height: 1;
    width: 2.1rem;
    height: 2.1rem;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: 50%;
    background: var(--bg-panel-2);
    border: 1px solid var(--border);
    flex-shrink: 0;
}
.player-meta { display: flex; flex-direction: column; min-width: 0; }
.player-name { font-weight: 600; font-size: .92rem; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.player-sub { font-size: .76rem; color: var(--text-muted); white-space: nowrap; }
.player-captured { display: flex; align-items: center; gap: .1rem; font-size: 1.05rem; min-height: 1.4rem; flex-wrap: wrap; justify-content: flex-end; }
.player-captured .cap-piece { opacity: .9; display: inline-block; }
.player-captured .cap-adv {
    margin-left: .3rem;
    font-size: .72rem;
    font-weight: 700;
    color: var(--success);
    background: rgba(46,204,113,.15);
    border-radius: 999px;
    padding: .05rem .4rem;
}


.panel {
    background: var(--bg-panel);
    border: 1px solid var(--border);
    border-radius: .6rem;
    padding: 1rem;
    margin-bottom: 1rem;
    box-shadow: 0 1px 3px rgba(0,0,0,.2);
    transition: border-color .2s ease;
}
.panel h3 { margin: 0 0 .75rem; font-size: 1rem; color: var(--text-muted); text-transform: uppercase; letter-spacing: .04em; }
.panel .field { margin-bottom: .85rem; }
.panel label { display: block; font-size: .82rem; color: var(--text-muted); margin-bottom: .3rem; }
.panel select, .panel input[type=text] {
    width: 100%;
    padding: .5rem .6rem;
    background: var(--bg-panel-2);
    border: 1px solid var(--border);
    color: var(--text);
    border-radius: .4rem;
    transition: border-color .15s ease, box-shadow .15s ease;
}
.panel select:focus, .panel input[type=text]:focus {
    outline: none;
    border-color: var(--accent);
    box-shadow: 0 0 0 3px var(--accent-glow);
}
.color-toggle { display: flex; gap: .5rem; }
.color-toggle button {
    flex: 1;
    padding: .5rem;
    border-radius: .4rem;
    border: 1px solid var(--border);
    background: var(--bg-panel-2);
    color: var(--text);
    cursor: pointer;
    transition: background .15s ease, border-color .15s ease, transform .1s ease;
}
.color-toggle button:hover { border-color: #3a4756; }
.color-toggle button:active { transform: translateY(1px); }
.color-toggle button.active { border-color: var(--accent); background: rgba(194,160,107,.15); box-shadow: 0 0 0 1px var(--accent-glow); }

.action-row { display: flex; gap: .5rem; margin-top: .5rem; }
.action-row .btn { flex: 1; }

.move-list {
    max-height: 260px;
    overflow-y: auto;
    font-family: "SFMono-Regular", Consolas, "Liberation Mono", Menlo, monospace;
    font-size: .88rem;
    scrollbar-width: thin;
    scrollbar-color: var(--border) transparent;
}
.move-list::-webkit-scrollbar { width: 8px; }
.move-list::-webkit-scrollbar-thumb { background: var(--border); border-radius: 999px; }
.move-list table { width: 100%; border-collapse: collapse; }
.move-list tr { animation: rowIn .2s ease; }
@keyframes rowIn { from { opacity: 0; transform: translateY(-3px); } to { opacity: 1; transform: translateY(0); } }
.move-list tr:last-child { background: rgba(194,160,107,.06); }
.move-list td { padding: .3rem .4rem; border-bottom: 1px solid var(--border); }
.move-list td.num { color: var(--text-muted); width: 2rem; }
.move-list .empty-hint { color: var(--text-muted); font-style: italic; padding: .5rem .3rem; }

.result-banner {
    display: none;
    width: 100%;
    max-width: 560px;
    padding: .9rem 1rem;
    border-radius: .5rem;
    text-align: center;
    font-weight: 600;
    font-size: 1.05rem;
}
.result-banner.show { display: block; animation: bannerIn .25s cubic-bezier(.16,1,.3,1); }
@keyframes bannerIn { from { opacity: 0; transform: translateY(-8px) scale(.98); } to { opacity: 1; transform: translateY(0) scale(1); } }
.result-banner.win { background: rgba(46,204,113,.15); border: 1px solid var(--success); color: var(--success); }
.result-banner.loss { background: rgba(231,76,60,.15); border: 1px solid var(--danger); color: var(--danger); }
.result-banner.draw { background: rgba(241,196,15,.15); border: 1px solid var(--warning); color: var(--warning); }

.alert { padding: .75rem 1rem; border-radius: .5rem; margin-bottom: 1rem; }
.alert-error { background: rgba(231,76,60,.15); border: 1px solid var(--danger); color: #ff8a7a; }
.alert-success { background: rgba(46,204,113,.15); border: 1px solid var(--success); color: #7ee6ab; }

.auth-wrap { max-width: 400px; margin: 3rem auto; }
.auth-card { background: var(--bg-panel); border: 1px solid var(--border); border-radius: .6rem; padding: 1.75rem; }
.auth-card h1 { font-size: 1.3rem; margin-top: 0; }
.form-group { margin-bottom: 1rem; }
.form-group label { display: block; font-size: .85rem; color: var(--text-muted); margin-bottom: .3rem; }
.form-group input {
    width: 100%;
    padding: .6rem .7rem;
    background: var(--bg-panel-2);
    border: 1px solid var(--border);
    color: var(--text);
    border-radius: .4rem;
}
.auth-footer { text-align: center; margin-top: 1rem; color: var(--text-muted); font-size: .9rem; }

.history-table { width: 100%; border-collapse: collapse; background: var(--bg-panel); border: 1px solid var(--border); border-radius: .6rem; overflow: hidden; }
.history-table th, .history-table td { padding: .6rem .8rem; border-bottom: 1px solid var(--border); text-align: left; font-size: .9rem; }
.history-table th { color: var(--text-muted); font-weight: 600; }
.badge { display: inline-block; padding: .15rem .55rem; border-radius: 999px; font-size: .78rem; font-weight: 600; }
.badge-win { background: rgba(46,204,113,.2); color: var(--success); }
.badge-loss { background: rgba(231,76,60,.2); color: var(--danger); }
.badge-draw { background: rgba(241,196,15,.2); color: var(--warning); }
.badge-abandoned { background: rgba(147,161,179,.2); color: var(--text-muted); }

.stats-row { display: flex; gap: 1rem; margin-bottom: 1.5rem; flex-wrap: wrap; }
.stat-box { flex: 1; min-width: 120px; background: var(--bg-panel); border: 1px solid var(--border); border-radius: .6rem; padding: 1rem; text-align: center; }
.stat-box .num { font-size: 1.6rem; font-weight: 700; }
.stat-box .label { color: var(--text-muted); font-size: .82rem; }

.footer-note { text-align: center; color: var(--text-muted); font-size: .82rem; margin: 0; padding: 1.25rem 1rem; }

/* --- Rooms (multiplayer) --- */
.room-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    flex-wrap: wrap;
    gap: 1rem;
    max-width: 900px;
    margin: 0 auto 1.5rem;
}
.room-title { margin: 0 0 .25rem; font-size: 1.4rem; }
.room-meta { color: var(--text-muted); display: flex; align-items: center; gap: .6rem; font-size: .9rem; }

.chat-box {
    height: 220px;
    overflow-y: auto;
    background: var(--bg-panel-2);
    border: 1px solid var(--border);
    border-radius: .4rem;
    padding: .6rem;
    margin-bottom: .6rem;
    font-size: .87rem;
    display: flex;
    flex-direction: column;
    gap: .35rem;
}
.chat-message { line-height: 1.4; word-break: break-word; animation: rowIn .15s ease; }
.chat-sender { font-weight: 700; color: var(--accent); }
.chat-role-spectator .chat-sender { color: var(--text-muted); }
.chat-text { color: var(--text); }
.chat-input-row { display: flex; gap: .4rem; }
.chat-input-row input {
    flex: 1;
    padding: .5rem .6rem;
    background: var(--bg-panel-2);
    border: 1px solid var(--border);
    color: var(--text);
    border-radius: .4rem;
}
.chat-input-row input:focus { outline: none; border-color: var(--accent); box-shadow: 0 0 0 3px var(--accent-glow); }


.room-actions { max-width: 640px; margin: 0 auto 1.75rem; display: flex; gap: .6rem; flex-wrap: wrap; justify-content: center; align-items: center; }
.room-actions-alert { max-width: 520px; margin: 0 auto 1rem; }
.room-actions-code { display: flex; gap: .4rem; }
.room-actions-code input {
    padding: .5rem .7rem;
    background: var(--bg-panel-2);
    border: 1px solid var(--border);
    color: var(--text);
    border-radius: .4rem;
}
.room-list-empty { color: var(--text-muted); grid-column: 1 / -1; text-align: center; }
.room-list { display: grid; grid-template-columns: repeat(auto-fill, minmax(240px, 1fr)); gap: 1rem; max-width: 1000px; margin: 0 auto; }
.room-card { background: var(--bg-panel); border: 1px solid var(--border); border-radius: .6rem; padding: 1rem; }
.room-card .room-card-title { font-weight: 700; margin-bottom: .3rem; }
.room-card .room-card-meta { color: var(--text-muted); font-size: .82rem; margin-bottom: .7rem; }

.leaderboard-table { width: 100%; border-collapse: collapse; background: var(--bg-panel); border: 1px solid var(--border); border-radius: .6rem; overflow: hidden; }
.leaderboard-table th, .leaderboard-table td { padding: .55rem .8rem; border-bottom: 1px solid var(--border); text-align: left; font-size: .9rem; }
.leaderboard-table th { color: var(--text-muted); }
.leaderboard-table tr:first-child td { color: #ffd76a; font-weight: 700; }

/* --- Set Up Board editor --- */
.palette { display: grid; grid-template-columns: repeat(6, 1fr); gap: .4rem; margin-bottom: .4rem; }
.palette-piece {
    background: var(--bg-panel-2);
    border: 1px solid var(--border);
    border-radius: .4rem;
    padding: .3rem 0;
    cursor: pointer;
    font-size: 1.6rem;
    line-height: 1;
    transition: border-color .15s ease, background .15s ease;
}
.palette-piece:hover { border-color: var(--accent); }
.palette-piece.active { border-color: var(--accent); background: rgba(194,160,107,.18); box-shadow: 0 0 0 1px var(--accent-glow); }
.palette-piece .piece { cursor: pointer; pointer-events: none; font-size: 1.6rem; }
.palette-hint { font-size: .78rem; color: var(--text-muted); margin-bottom: 1rem; }
.turn-toggle { display: flex; gap: .5rem; }
.turn-toggle button {
    flex: 1; padding: .5rem; border-radius: .4rem; border: 1px solid var(--border);
    background: var(--bg-panel-2); color: var(--text); cursor: pointer;
}
.turn-toggle button.active { border-color: var(--accent); background: rgba(194,160,107,.15); }
