/* ==========================================================================
   Qrush 象棋 — visual theme layer
   Loaded after style.css. Keeps every existing component ID/class contract
   intact and only overrides presentation.
   ========================================================================== */

:root {
    --q-bg: #070b14;
    --q-bg-soft: #0a1120;
    --q-surface: rgba(14, 21, 36, 0.9);
    --q-surface-2: rgba(21, 31, 50, 0.92);
    --q-border: rgba(255, 255, 255, 0.08);
    --q-border-accent: rgba(108, 171, 221, 0.26);
    --q-text: #edf3fa;
    --q-muted: #93a7c0;
    --q-accent: #6caddd;
    --q-accent-strong: #a9dcf6;
    --q-red: #e05b57;
    --q-green: #4fbf8b;
    --q-blue: #6b9cff;
    --q-radius: 16px;
    --q-shadow: 0 18px 48px rgba(0, 0, 0, 0.38);
}

html {
    color-scheme: dark;
    scroll-behavior: smooth;
}

body {
    font-family: "Noto Sans SC", "PingFang SC", "Microsoft YaHei", "Segoe UI", sans-serif;
    color: var(--q-text);
    padding: clamp(10px, 2vw, 22px);
    letter-spacing: 0.01em;
    background:
        radial-gradient(900px 540px at 12% -10%, rgba(108, 171, 221, 0.16), transparent 58%),
        radial-gradient(760px 480px at 100% 0%, rgba(28, 44, 91, 0.55), transparent 56%),
        radial-gradient(900px 700px at 50% 115%, rgba(108, 171, 221, 0.08), transparent 62%),
        var(--q-bg);
    background-attachment: fixed;
}

body::before {
    content: "";
    position: fixed;
    inset: 0;
    z-index: 0;
    pointer-events: none;
    background-image:
        linear-gradient(rgba(255, 255, 255, 0.024) 1px, transparent 1px),
        linear-gradient(90deg, rgba(255, 255, 255, 0.024) 1px, transparent 1px);
    background-size: 64px 64px;
    mask-image: radial-gradient(ellipse at 50% 0%, #000 0%, transparent 72%);
    -webkit-mask-image: radial-gradient(ellipse at 50% 0%, #000 0%, transparent 72%);
}

.top-nav,
.container {
    position: relative;
    z-index: 1;
}

/* ---------- Brand + navigation ---------- */

.top-nav {
    position: sticky;
    top: 10px;
    z-index: 100;
    max-width: 1040px;
    padding: 10px 14px;
    border-radius: 16px;
    border: 1px solid rgba(108, 171, 221, 0.14);
    background: rgba(12, 16, 23, 0.82);
    box-shadow: 0 14px 38px rgba(0, 0, 0, 0.38);
    backdrop-filter: blur(18px);
    -webkit-backdrop-filter: blur(18px);
}

.nav-brand {
    display: inline-flex;
    align-items: center;
    gap: 10px;
    text-decoration: none;
    border: none;
    background: transparent;
    padding: 0;
    letter-spacing: 0;
    color: var(--q-text);
}

.nav-brand:hover {
    background: transparent;
    color: var(--q-text);
}

.brand-mark {
    width: 34px;
    height: 34px;
    display: grid;
    place-items: center;
    border-radius: 11px;
    font-family: Georgia, "Times New Roman", serif;
    font-size: 21px;
    font-weight: 700;
    color: #081827;
    background: linear-gradient(135deg, #d9f0fc 0%, #6caddd 45%, #2f6e9e 100%);
    box-shadow:
        0 6px 16px rgba(108, 171, 221, 0.28),
        inset 0 1px 0 rgba(255, 255, 255, 0.72);
}

.brand-text {
    font-size: clamp(16px, 2.6vw, 20px);
    font-weight: 700;
    letter-spacing: 0.07em;
    color: #f4f9ff;
}

.brand-text em {
    font-style: normal;
    color: var(--q-accent);
}

.nav-links {
    gap: 5px;
}

.nav-link {
    padding: 7px 11px;
    border-radius: 999px;
    font-size: 13px;
    color: #a3aebf;
    border: 1px solid transparent;
    transition: color 0.16s ease, background 0.16s ease, border-color 0.16s ease;
}

.nav-link:hover {
    color: #fff;
    background: rgba(255, 255, 255, 0.06);
}

.nav-link.active {
    color: var(--q-accent-strong);
    border-color: rgba(108, 171, 221, 0.22);
    background: linear-gradient(135deg, rgba(108, 171, 221, 0.18), rgba(108, 171, 221, 0.05));
}

.nav-user-info {
    border-left-color: rgba(255, 255, 255, 0.1);
}

.nav-username {
    color: #e9edf5;
}

.nav-logout-btn {
    border-color: rgba(255, 255, 255, 0.14);
    color: #a3aebf;
    border-radius: 999px;
}

.sound-toggle {
    border: 1px solid transparent;
}

/* ---------- Page shell + headings ---------- */

.container {
    max-width: 1040px;
    padding: clamp(18px, 3vw, 30px) clamp(14px, 3vw, 28px);
    margin-bottom: 40px;
    border-radius: 24px;
    border: 1px solid var(--q-border);
    background: linear-gradient(180deg, rgba(17, 22, 31, 0.66), rgba(9, 12, 18, 0.78));
    box-shadow: 0 30px 90px rgba(0, 0, 0, 0.35);
    backdrop-filter: blur(10px);
    -webkit-backdrop-filter: blur(10px);
}

.container.game-page {
    max-width: 860px;
}

h1 {
    font-family: "Noto Serif SC", "Songti SC", "STSong", "SimSun", serif;
    font-size: clamp(27px, 4.6vw, 40px);
    font-weight: 700;
    text-align: center;
    letter-spacing: 0.14em;
    margin: 2px 0 4px;
    color: var(--q-accent-strong);
    background: linear-gradient(180deg, #f4f9ff 0%, #a9dcf6 42%, #6caddd 100%);
    -webkit-background-clip: text;
    background-clip: text;
    -webkit-text-fill-color: transparent;
    text-shadow: 0 10px 34px rgba(108, 171, 221, 0.12);
}

.page-subtitle {
    margin: 0 0 22px;
    text-align: center;
    color: var(--q-muted);
    font-size: clamp(11px, 2vw, 13px);
    letter-spacing: 0.2em;
}

h2 {
    font-weight: 600;
    letter-spacing: 0.04em;
}

/* ---------- Buttons ---------- */

.action-btn {
    padding: 8px 15px;
    border-radius: 10px;
    border: 1px solid rgba(255, 255, 255, 0.1);
    background: linear-gradient(180deg, #232b3a, #1a202c);
    color: #dde4f0;
    font-weight: 500;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.24);
    transition: transform 0.15s ease, border-color 0.15s ease,
                box-shadow 0.15s ease, background 0.15s ease;
}

.action-btn:hover {
    transform: translateY(-1px);
    border-color: rgba(108, 171, 221, 0.45);
    background: linear-gradient(180deg, #2a3446, #1e2533);
    box-shadow: 0 9px 20px rgba(0, 0, 0, 0.34);
}

.action-btn:active {
    transform: translateY(0);
}

.action-btn.danger {
    color: #ffb7b3;
    border-color: rgba(224, 91, 87, 0.32);
    background: linear-gradient(180deg, #3a1e22, #281417);
}

.action-btn.danger:hover {
    border-color: rgba(224, 91, 87, 0.6);
    background: linear-gradient(180deg, #462329, #30181c);
}

.action-btn.success {
    color: #b6f0d3;
    border-color: rgba(79, 191, 139, 0.3);
    background: linear-gradient(180deg, #16342a, #10241d);
}

.action-btn.success:hover {
    border-color: rgba(79, 191, 139, 0.55);
}

#createBtn,
#joinBtn,
#enterBtn,
#submitBtn,
.auth-submit {
    color: #081827;
    font-weight: 700;
    border-color: rgba(255, 239, 195, 0.5);
    background: linear-gradient(135deg, #d9f0fc 0%, #6caddd 48%, #3e86b5 100%);
    box-shadow: 0 10px 24px rgba(108, 171, 221, 0.22);
}

#createBtn:hover,
#joinBtn:hover,
#enterBtn:hover,
#submitBtn:hover,
.auth-submit:hover {
    color: #06121c;
    border-color: rgba(255, 248, 220, 0.8);
    background: linear-gradient(135deg, #eaf8ff 0%, #efcd7b 48%, #4c93c4 100%);
    box-shadow: 0 14px 30px rgba(108, 171, 221, 0.3);
}

#analyzeBtn,
#reviewBtn {
    color: var(--q-accent-strong);
    border-color: rgba(108, 171, 221, 0.25);
}

#deduceBtn {
    color: #b9cdf8;
    border-color: rgba(107, 156, 255, 0.22);
}

/* ---------- Inputs ---------- */

.auth-input,
.difficulty-select,
.chat-input,
.room-input {
    color: var(--q-text);
    background: #0c1119;
    border: 1px solid rgba(255, 255, 255, 0.1);
    border-radius: 10px;
    padding: 11px 13px;
    transition: border-color 0.16s ease, box-shadow 0.16s ease;
}

.auth-input::placeholder,
.chat-input::placeholder {
    color: #657184;
}

.auth-input:focus,
.auth-input:focus-visible,
.difficulty-select:focus,
.chat-input:focus {
    outline: none;
    border-color: rgba(108, 171, 221, 0.6);
    box-shadow: 0 0 0 3px rgba(108, 171, 221, 0.12);
}

/* ---------- Game header / status ---------- */

.game-info {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    justify-content: center;
    gap: 12px;
    margin: 0 auto 14px;
    padding: 10px 14px;
    width: fit-content;
    max-width: 100%;
    border-radius: 14px;
    border: 1px solid var(--q-border);
    background: rgba(10, 14, 21, 0.55);
}

.turn-indicator {
    display: inline-flex;
    align-items: center;
    gap: 9px;
    color: var(--q-muted);
    font-size: 13px;
    letter-spacing: 0.06em;
}

.turn-indicator::before {
    content: "";
    width: 8px;
    height: 8px;
    border-radius: 50%;
    background: var(--q-accent);
    box-shadow: 0 0 12px rgba(108, 171, 221, 0.75);
    animation: qrushPulse 1.8s ease-in-out infinite;
}

.turn-red {
    color: #ff928d;
    font-weight: 700;
    text-shadow: 0 0 18px rgba(224, 91, 87, 0.35);
}

.turn-black {
    color: #cfd8e7;
    font-weight: 700;
}

.turn-red,
.turn-black {
    padding: 2px 9px;
    border-radius: 999px;
    background: rgba(255, 255, 255, 0.055);
}

.difficulty-label {
    color: var(--q-muted);
    font-size: 12px;
    letter-spacing: 0.12em;
}

#aiThinking.ai-thinking {
    margin: 0 auto 12px;
    width: fit-content;
    padding: 9px 16px;
    border-radius: 999px;
    border: 1px solid rgba(108, 171, 221, 0.24);
    background: rgba(20, 25, 35, 0.9);
    color: var(--q-accent-strong);
    box-shadow: 0 10px 30px rgba(0, 0, 0, 0.35);
}

.last-move-info {
    width: fit-content;
    max-width: 100%;
    margin: 0 auto 12px;
    padding: 8px 14px;
    border-radius: 999px;
    border: 1px solid var(--q-border);
    background: rgba(10, 14, 21, 0.55);
    color: var(--q-muted);
    font-size: 12px;
}

/* ---------- Board ---------- */

.board-wrapper {
    display: flex;
    justify-content: center;
    width: fit-content;
    max-width: 100%;
    margin: 4px auto 16px;
    padding: clamp(8px, 1.4vw, 13px);
    border-radius: 22px;
    border: 1px solid rgba(108, 171, 221, 0.18);
    background:
        linear-gradient(145deg, rgba(108, 171, 221, 0.16), rgba(0, 0, 0, 0.18) 42%),
        rgba(12, 16, 23, 0.6);
    box-shadow:
        0 26px 70px rgba(0, 0, 0, 0.48),
        inset 0 1px 0 rgba(255, 255, 255, 0.07);
}

.board-container {
    width: 630px;
    max-width: min(88vw, 630px);
    border-radius: 14px;
    box-shadow: 0 12px 34px rgba(0, 0, 0, 0.45);
}

.piece {
    filter: drop-shadow(0 4px 6px rgba(0, 0, 0, 0.34));
    transition: transform 0.16s ease, filter 0.16s ease;
}

.piece:hover {
    filter: drop-shadow(0 9px 14px rgba(0, 0, 0, 0.46));
    transform: translate(-50%, -50%) scale(1.09);
}

.piece.selected {
    outline: none;
    filter:
        drop-shadow(0 0 8px rgba(108, 171, 221, 0.95))
        drop-shadow(0 0 20px rgba(108, 171, 221, 0.45));
    transform: translate(-50%, -50%) scale(1.06);
}

.piece.capture-highlight {
    filter:
        drop-shadow(0 0 8px rgba(224, 91, 87, 0.85))
        drop-shadow(0 0 18px rgba(224, 91, 87, 0.35));
}

.piece.move-to {
    animation: qrushMoveGlow 0.7s ease-out;
    filter:
        drop-shadow(0 0 7px rgba(108, 171, 221, 0.95))
        drop-shadow(0 0 18px rgba(108, 171, 221, 0.38));
}

@keyframes qrushMoveGlow {
    0% {
        filter:
            drop-shadow(0 0 14px rgba(169, 220, 246, 1))
            drop-shadow(0 0 26px rgba(108, 171, 221, 0.55));
    }
    100% {
        filter:
            drop-shadow(0 0 7px rgba(108, 171, 221, 0.95))
            drop-shadow(0 0 18px rgba(108, 171, 221, 0.38));
    }
}

.click-area {
    border-radius: 50%;
    transition: background 0.15s ease, box-shadow 0.15s ease;
}

.click-area:hover {
    background: rgba(255, 255, 255, 0.06);
}

.click-area.valid-move::after {
    content: "";
    position: absolute;
    left: 50%;
    top: 50%;
    width: 13px;
    height: 13px;
    border-radius: 50%;
    transform: translate(-50%, -50%);
    background: rgba(108, 171, 221, 0.58);
    box-shadow: 0 0 12px rgba(108, 171, 221, 0.55);
    animation: qrushDot 1.6s ease-in-out infinite;
}

.click-area.valid-capture::after {
    width: 34px;
    height: 34px;
    background: transparent;
    border: 2px solid rgba(224, 91, 87, 0.62);
    box-shadow: 0 0 16px rgba(224, 91, 87, 0.35);
}

.click-area.last-move-from {
    box-shadow: inset 0 0 0 2px rgba(108, 171, 221, 0.28);
}

.click-area.last-move-to {
    box-shadow: inset 0 0 0 2px rgba(108, 171, 221, 0.62);
}

.move-from-marker {
    border-width: 1px;
    background: rgba(108, 171, 221, 0.18);
    border-color: rgba(108, 171, 221, 0.55);
}

/* ---------- Cards, panels, history ---------- */

.lobby-section,
.history-section,
.analyze-panel,
.review-panel,
.replay-panel,
.chat-panel,
.adjust-panel,
.data-table-wrapper,
.user-bar {
    border: 1px solid var(--q-border);
    border-radius: var(--q-radius);
    background: linear-gradient(180deg, rgba(24, 30, 42, 0.9), rgba(13, 17, 25, 0.92));
    box-shadow: 0 14px 34px rgba(0, 0, 0, 0.26);
}

.lobby-section {
    padding: 20px 22px;
    margin-top: 16px;
}

.lobby-section h2,
.history-title,
.analyze-header > span,
.review-header > span,
.chat-header > span {
    display: flex;
    align-items: center;
    gap: 9px;
    color: #eef2f9;
    font-size: 15px;
    letter-spacing: 0.05em;
}

.lobby-section h2::before,
.history-title::before {
    content: "";
    width: 4px;
    height: 15px;
    border-radius: 2px;
    background: linear-gradient(180deg, var(--q-accent-strong), #2f6e9e);
}

.lobby-hint,
.leaderboard-hint,
.auth-subtitle {
    color: var(--q-muted);
    font-size: 12.5px;
    line-height: 1.7;
}

.history-section {
    margin-top: 16px;
    padding: 14px 16px;
}

.history-header {
    align-items: center;
    padding-bottom: 4px;
}

.history-nav {
    color: var(--q-muted);
}

.hist-nav-btn {
    border: 1px solid rgba(255, 255, 255, 0.1);
    border-radius: 8px;
    background: rgba(255, 255, 255, 0.03);
    color: #cbd4e2;
    transition: background 0.15s ease, border-color 0.15s ease;
}

.hist-nav-btn:hover:not(:disabled) {
    background: rgba(108, 171, 221, 0.12);
    border-color: rgba(108, 171, 221, 0.35);
}

.history-row {
    border-radius: 9px;
    padding: 5px 8px;
    transition: background 0.14s ease;
}

.history-row:hover {
    background: rgba(255, 255, 255, 0.04);
}

.history-move.history-current {
    color: var(--q-accent-strong);
    background: rgba(108, 171, 221, 0.13);
    border-radius: 6px;
    padding: 2px 6px;
}

.history-move.history-red {
    color: #f2a09c;
}

.history-move.history-black {
    color: #c5d0e2;
}

.analyze-panel,
.review-panel {
    margin-top: 16px;
    overflow: hidden;
}

.analyze-header,
.review-header,
.chat-header {
    padding: 12px 16px;
    border-bottom: 1px solid var(--q-border);
    background: rgba(9, 13, 19, 0.45);
}

.close-btn {
    width: 30px;
    height: 30px;
    border-radius: 9px;
    border: 1px solid rgba(255, 255, 255, 0.09);
    background: rgba(255, 255, 255, 0.03);
    color: var(--q-muted);
    transition: color 0.15s ease, background 0.15s ease;
}

.close-btn:hover {
    color: #fff;
    background: rgba(255, 255, 255, 0.08);
}

.analyze-content,
.review-content {
    padding: 16px;
}

.analyze-label {
    color: var(--q-muted);
}

.analyze-desc {
    color: var(--q-accent-strong);
}

.analyze-score {
    color: #e8edf6;
}

.review-row {
    border-bottom: 1px solid rgba(255, 255, 255, 0.05);
    padding: 9px 4px;
}

.review-row:hover {
    background: rgba(255, 255, 255, 0.025);
}

.review-quality.review-excellent { color: #7ce0b0; }
.review-quality.review-good { color: #9fd3ff; }
.review-quality.review-miss { color: #f0cf7a; }
.review-quality.review-bad { color: #ff9d98; }

/* ---------- Toast messages ---------- */

.message {
    position: fixed;
    left: 50%;
    bottom: 26px;
    z-index: 1200;
    max-width: min(92vw, 560px);
    padding: 11px 18px;
    margin: 0;
    border-radius: 999px;
    border: 1px solid var(--q-border);
    background: rgba(16, 21, 30, 0.96);
    color: var(--q-text);
    font-size: 13px;
    text-align: center;
    box-shadow: 0 18px 44px rgba(0, 0, 0, 0.48);
    backdrop-filter: blur(16px);
    -webkit-backdrop-filter: blur(16px);
    opacity: 0;
    visibility: hidden;
    pointer-events: none;
    transform: translate(-50%, 14px);
    transition: opacity 0.22s ease, transform 0.22s ease, visibility 0.22s;
}

.message.show {
    opacity: 1;
    visibility: visible;
    transform: translate(-50%, 0);
}

.message.success {
    border-color: rgba(79, 191, 139, 0.38);
    color: #b9f1d6;
}

.message.error {
    border-color: rgba(224, 91, 87, 0.42);
    color: #ffc2bf;
}

.message.warning {
    border-color: rgba(108, 171, 221, 0.4);
    color: #cfe9f8;
}

/* ---------- Lobby ---------- */

.lobby-grid {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 16px;
    margin-top: 16px;
}

.lobby-card {
    position: relative;
    margin-top: 0;
    display: flex;
    flex-direction: column;
    align-items: flex-start;
    min-height: 210px;
    transition: border-color 0.18s ease, transform 0.18s ease;
}

.lobby-card:hover {
    border-color: rgba(108, 171, 221, 0.22);
    transform: translateY(-2px);
}

.lobby-card-icon {
    width: 46px;
    height: 46px;
    display: grid;
    place-items: center;
    margin-bottom: 13px;
    border-radius: 13px;
    border: 1px solid var(--q-border-accent);
    background: rgba(108, 171, 221, 0.08);
    color: var(--q-accent-strong);
    font-size: 23px;
    line-height: 1;
}

.lobby-card h2::before {
    display: none;
}

.lobby-card .lobby-hint {
    margin-top: 4px;
}

.lobby-card #createBtn {
    width: 100%;
    margin-top: auto;
}

.join-row {
    display: flex;
    gap: 8px;
    width: 100%;
    margin-top: auto;
}

.join-row .room-input {
    flex: 1;
    min-width: 0;
    font-family: ui-monospace, "Cascadia Mono", Consolas, monospace;
    letter-spacing: 0.2em;
    text-transform: uppercase;
    font-size: 15px;
}

.join-row .action-btn {
    flex: 0 0 auto;
}

.current-room-card {
    margin-top: 16px;
    border-color: rgba(108, 171, 221, 0.28);
    background:
        radial-gradient(600px 160px at 10% 0%, rgba(108, 171, 221, 0.12), transparent 70%),
        linear-gradient(180deg, rgba(30, 29, 24, 0.86), rgba(15, 17, 21, 0.92));
}

.room-info {
    margin: 10px 0 4px;
    padding: 10px 14px;
    color: var(--q-muted);
    font-size: 13px;
    border: 1px solid var(--q-border);
    border-radius: 14px;
    background: rgba(9, 14, 24, 0.62);
}

.room-card,
.play-room-card {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 12px;
}

.room-code-block {
    display: inline-flex;
    flex-direction: column;
    gap: 1px;
    padding: 7px 13px;
    border: 1px dashed rgba(108, 171, 221, 0.4);
    border-radius: 10px;
    background: rgba(0, 0, 0, 0.28);
}

.room-code-label {
    font-size: 10px;
    letter-spacing: 0.24em;
    color: var(--q-muted);
}

.room-code {
    font-family: ui-monospace, "Cascadia Mono", Consolas, monospace;
    font-size: 21px;
    font-weight: 700;
    letter-spacing: 0.2em;
    color: var(--q-accent-strong);
}

.color-badge {
    display: inline-flex;
    align-items: center;
    padding: 4px 10px;
    border-radius: 999px;
    font-size: 12px;
    border: 1px solid rgba(255, 255, 255, 0.14);
    color: #cbd4e2;
    background: rgba(255, 255, 255, 0.04);
}

.color-badge.color-red {
    color: #ffc0bd;
    border-color: rgba(224, 91, 87, 0.38);
    background: rgba(224, 91, 87, 0.12);
}

.color-badge.color-black {
    color: #d9e0eb;
    border-color: rgba(255, 255, 255, 0.2);
    background: rgba(255, 255, 255, 0.06);
}

.play-room-card {
    justify-content: center;
    margin-top: 2px;
}

.current-room-card .room-info {
    padding: 8px 0 2px;
    border: none;
    background: transparent;
}

.play-opponent {
    color: var(--q-muted);
    font-size: 13px;
}

.user-bar {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 10px;
    padding: 11px 15px;
    color: var(--q-muted);
    font-size: 13px;
}

.lobby-actions {
    display: flex;
    flex-wrap: wrap;
    gap: 9px;
    margin-top: 12px;
}

/* ---------- Auth ---------- */

.auth-container {
    max-width: 470px;
    padding: clamp(24px, 4vw, 36px);
}

.auth-hero {
    text-align: center;
    margin-bottom: 8px;
}

.auth-hero-mark {
    display: grid;
    place-items: center;
    width: 62px;
    height: 62px;
    margin: 0 auto 14px;
    border-radius: 19px;
    font-family: Georgia, "Times New Roman", serif;
    font-size: 34px;
    font-weight: 700;
    color: #081827;
    background: linear-gradient(135deg, #d9f0fc 0%, #6caddd 46%, #2f6e9e 100%);
    box-shadow:
        0 14px 34px rgba(108, 171, 221, 0.26),
        inset 0 1px 0 rgba(255, 255, 255, 0.75);
}

.auth-hero h1 {
    font-size: clamp(28px, 6vw, 36px);
    margin-bottom: 4px;
}

.auth-tagline {
    margin: 0;
    color: var(--q-accent);
    font-size: 12px;
    letter-spacing: 0.24em;
}

.auth-subtitle {
    text-align: center;
    margin: 10px 0 18px;
    color: var(--q-muted);
    letter-spacing: 0.04em;
}

.auth-tabs {
    display: flex;
    gap: 4px;
    padding: 4px;
    border: 1px solid var(--q-border);
    border-radius: 12px;
    background: rgba(5, 8, 12, 0.55);
}

.auth-tab {
    flex: 1;
    padding: 9px 10px;
    border-radius: 9px;
    border: none;
    background: transparent;
    color: var(--q-muted);
    font-weight: 500;
}

.auth-tab:hover {
    background: rgba(255, 255, 255, 0.05);
    color: #fff;
}

.auth-tab.active {
    color: #081827;
    background: linear-gradient(135deg, #bce6fa, #3e86b5);
    box-shadow: 0 6px 16px rgba(108, 171, 221, 0.2);
}

.auth-form {
    margin-top: 14px;
    display: flex;
    flex-direction: column;
    gap: 10px;
}

.auth-submit {
    width: 100%;
    padding: 12px;
    margin-top: 4px;
    font-size: 15px;
    letter-spacing: 0.1em;
}

.auth-footer {
    margin-top: 16px;
    text-align: center;
}

.auth-footer .nav-link {
    color: var(--q-muted);
    font-size: 12px;
}

/* ---------- Tables / leaderboard / admin ---------- */

.data-table-wrapper {
    margin-top: 16px;
    overflow: auto;
}

.data-table {
    width: 100%;
    border-collapse: collapse;
}

.data-table th {
    position: sticky;
    top: 0;
    z-index: 2;
    padding: 12px 14px;
    border-bottom: 1px solid rgba(108, 171, 221, 0.16);
    background: rgba(10, 14, 20, 0.96);
    color: var(--q-muted);
    font-size: 11px;
    font-weight: 500;
    letter-spacing: 0.12em;
    text-transform: uppercase;
    white-space: nowrap;
}

.data-table td {
    padding: 12px 14px;
    border-bottom: 1px solid rgba(255, 255, 255, 0.045);
    color: #dbe3ef;
    font-size: 13px;
}

.data-table tbody tr:hover {
    background: rgba(108, 171, 221, 0.05);
}

.data-table tbody tr:last-child td {
    border-bottom: none;
}

.data-table .player-cell {
    color: #f4f7fc;
    font-weight: 600;
}

.data-table .win-cell {
    color: #8de2b8;
}

.data-table .loss-cell {
    color: #ff9c97;
}

.rank-cell {
    font-size: 17px;
    text-align: center;
}

#leaderboardBody tr:nth-child(1) {
    background: linear-gradient(90deg, rgba(108, 171, 221, 0.14), transparent 70%);
}

#leaderboardBody tr:nth-child(2) {
    background: linear-gradient(90deg, rgba(190, 200, 215, 0.1), transparent 70%);
}

#leaderboardBody tr:nth-child(3) {
    background: linear-gradient(90deg, rgba(190, 130, 80, 0.12), transparent 70%);
}

#leaderboardBody tr:nth-child(-n+3) .player-cell {
    color: var(--q-accent-strong);
}

.stats-cards {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(130px, 1fr));
    gap: 12px;
    margin-bottom: 16px;
}

.stat-card {
    padding: 16px;
    border: 1px solid var(--q-border);
    border-radius: 14px;
    background: linear-gradient(180deg, rgba(24, 30, 42, 0.9), rgba(13, 17, 25, 0.92));
}

.stat-value {
    color: var(--q-accent-strong);
    font-size: 28px;
    font-weight: 700;
    line-height: 1.2;
}

.stat-label {
    color: var(--q-muted);
    font-size: 11px;
    letter-spacing: 0.14em;
}

.badge {
    display: inline-flex;
    align-items: center;
    padding: 3px 9px;
    border-radius: 999px;
    font-size: 11px;
    border: 1px solid transparent;
}

.badge-admin {
    color: #a9dcf6;
    border-color: rgba(108, 171, 221, 0.32);
    background: rgba(108, 171, 221, 0.1);
}

.badge-user {
    color: #a9b5c7;
    border-color: rgba(255, 255, 255, 0.12);
    background: rgba(255, 255, 255, 0.04);
}

/* ---------- Chat ---------- */

.chat-content {
    padding: 14px;
}

.chat-messages {
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.chat-message {
    max-width: 86%;
    padding: 8px 11px;
    border-radius: 12px;
    font-size: 13px;
    line-height: 1.55;
    background: rgba(255, 255, 255, 0.045);
}

.chat-message.chat-me {
    align-self: flex-end;
    background: rgba(108, 171, 221, 0.13);
    border: 1px solid rgba(108, 171, 221, 0.18);
}

.chat-name {
    color: var(--q-accent);
    margin-right: 6px;
}

.chat-input-area {
    display: flex;
    gap: 8px;
    margin-top: 10px;
}

.chat-send-btn {
    border-radius: 9px;
    border: 1px solid rgba(108, 171, 221, 0.3);
    background: rgba(108, 171, 221, 0.12);
    color: var(--q-accent-strong);
}

/* ---------- AI assistance switch ---------- */

.ai-assist-toggle {
    border-color: rgba(108, 171, 221, 0.24);
    background: rgba(108, 171, 221, 0.06);
    color: var(--q-accent-strong);
}

/* ---------- Remaining component accents ---------- */

.action-btn:focus {
    box-shadow: 0 0 0 3px rgba(108, 171, 221, 0.28);
}

.action-btn:focus-visible,
.auth-input:focus-visible,
.difficulty-select:focus-visible,
.nav-link:focus-visible,
.sound-toggle:focus-visible,
.ai-assist-toggle input:focus-visible {
    outline: 2px solid var(--q-accent-strong);
    outline-offset: 2px;
}

.action-btn.active {
    color: #06121c;
    border-color: rgba(169, 220, 246, 0.7);
    background: linear-gradient(135deg, #bce6fa, #6caddd);
}

.adjust-piece.selected {
    border-color: var(--q-accent);
    background: rgba(108, 171, 221, 0.16);
}

.pending-dot {
    color: var(--q-accent-strong);
    background: rgba(108, 171, 221, 0.12);
    border-color: rgba(108, 171, 221, 0.4);
}

.pending-dot::before {
    background: var(--q-accent-strong);
}

.analyze-desc,
.review-color,
.replay-color,
.chat-other .chat-name,
.deduce-title {
    color: var(--q-accent-strong);
}

.chat-header,
.analyze-header,
.review-header {
    color: var(--q-text);
}

.io-chip.active {
    color: #06121c;
    border-color: var(--q-accent-strong);
    background: var(--q-accent);
}

.auth-form {
    padding: 0;
    border: none;
    background: transparent;
    box-shadow: none;
}

.ai-assist-toggle input {
    accent-color: var(--q-accent);
}

.ai-assist-toggle input[type="checkbox"] {
    -webkit-appearance: none;
    appearance: none;
    position: relative;
    width: 34px;
    height: 19px;
    border-radius: 999px;
    border: 1px solid rgba(255, 255, 255, 0.16);
    background: rgba(255, 255, 255, 0.14);
    cursor: pointer;
    transition: background 0.18s ease, border-color 0.18s ease;
}

.ai-assist-toggle input[type="checkbox"]::after {
    content: "";
    position: absolute;
    top: 2px;
    left: 2px;
    width: 13px;
    height: 13px;
    border-radius: 50%;
    background: #f4f9ff;
    box-shadow: 0 1px 3px rgba(0, 0, 0, 0.35);
    transition: transform 0.18s ease;
}

.ai-assist-toggle input[type="checkbox"]:checked {
    border-color: rgba(108, 171, 221, 0.65);
    background: linear-gradient(90deg, #3e86b5, #6caddd);
}

.ai-assist-toggle input[type="checkbox"]:checked::after {
    transform: translateX(15px);
}

/* ---------- Motion ---------- */

@keyframes qrushPulse {
    0%, 100% { opacity: 1; transform: scale(1); }
    50% { opacity: 0.55; transform: scale(0.82); }
}

@keyframes qrushDot {
    0%, 100% { opacity: 0.55; transform: translate(-50%, -50%) scale(0.9); }
    50% { opacity: 1; transform: translate(-50%, -50%) scale(1.08); }
}

.container > *:not(.message) {
    animation: qrushRise 0.45s ease both;
}

@keyframes qrushRise {
    from { opacity: 0; transform: translateY(9px); }
    to { opacity: 1; transform: translateY(0); }
}

@media (prefers-reduced-motion: reduce) {
    *, *::before, *::after {
        animation-duration: 0.001ms !important;
        animation-iteration-count: 1 !important;
        transition-duration: 0.001ms !important;
    }
}

/* ---------- Responsive ---------- */

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

    .lobby-card {
        min-height: 0;
    }

    .lobby-card #createBtn {
        margin-top: 14px;
    }
}

@media (max-width: 640px) {
    body {
        padding: 10px;
    }

    .top-nav {
        position: static;
        flex-wrap: wrap;
        align-items: flex-start;
        gap: 8px;
        padding: 10px 12px;
    }

    .nav-links {
        width: 100%;
        overflow-x: auto;
        flex-wrap: nowrap;
        justify-content: flex-start;
        padding-bottom: 2px;
        scrollbar-width: none;
    }

    .nav-links::-webkit-scrollbar {
        display: none;
    }

    .nav-link {
        white-space: nowrap;
    }

    .nav-user-info {
        flex: 0 0 auto;
        border-left: none;
        padding-left: 0;
    }

    .brand-mark {
        width: 30px;
        height: 30px;
        font-size: 18px;
        border-radius: 10px;
    }

    .brand-text {
        font-size: 16px;
    }

    .container {
        padding: 18px 12px;
        border-radius: 18px;
    }

    h1 {
        font-size: 26px;
        letter-spacing: 0.1em;
    }

    .page-subtitle {
        margin-bottom: 16px;
    }

    .game-info {
        width: 100%;
        gap: 8px;
        padding: 8px 10px;
    }

    .board-wrapper {
        padding: 7px;
        border-radius: 16px;
    }

    .board-container {
        max-width: 86vw;
        border-radius: 10px;
    }

    .toolbar {
        gap: 6px;
    }

    .action-btn {
        padding: 8px 11px;
        font-size: 12px;
    }

    .room-card,
    .play-room-card {
        gap: 8px;
    }

    .room-code {
        font-size: 18px;
    }

    .data-table th,
    .data-table td {
        padding: 9px 10px;
    }

    .message {
        bottom: 16px;
        width: max-content;
        max-width: 94vw;
    }

    .auth-container {
        padding: 22px 16px;
    }
}

@media (max-width: 420px) {
    .brand-text em {
        display: none;
    }

    .nav-link {
        font-size: 12px;
        padding: 6px 8px;
    }

    .game-info {
        border-radius: 12px;
    }
}
