:root {
    --app-bg: #101723;
    --panel-bg: rgba(16, 24, 38, 0.92);
    --panel-border: rgba(255, 255, 255, 0.08);
    --text-primary: #edf2f7;
    --text-muted: #98a5b3;
    --accent-gold: #f4c96b;
    --accent-blue: #7dd3fc;
    --accent-green: #4dd4a8;
    --accent-red: #ff7c72;
    --accent-amber: #efb34f;
    --board-wood-dark: #5b3d24;
    --board-wood-mid: #825934;
    --board-wood-light: #b18155;
    --square-light-a: #f3e3bf;
    --square-light-b: #dbc394;
    --square-dark-a: #7b9450;
    --square-dark-b: #5c7338;
    --coord-light: rgba(91, 58, 29, 0.55);
    --coord-dark: rgba(255, 244, 223, 0.64);
    --legal-ring: rgba(39, 167, 114, 0.9);
    --selected-ring: rgba(224, 145, 45, 0.95);
    --move-ring: rgba(86, 173, 255, 0.92);
    --piece-white-fill: #fff8ea;
    --piece-white-stroke: #3b2816;
    --piece-white-detail: #6b4a29;
    --piece-black-fill: #202223;
    --piece-black-stroke: #f1dfc1;
    --piece-black-detail: #f1dfc1;
    --piece-white-filter: drop-shadow(0 4px 6px rgba(0, 0, 0, 0.28));
    --piece-black-filter: drop-shadow(0 4px 6px rgba(0, 0, 0, 0.36));
    --logo-width: clamp(168px, 42vw, 275px);
    --shell-padding-x: 16px;
    --shell-padding-bottom: 112px;
    --dock-gap: 10px;
    --dock-padding: 10px;
}

html,
body {
    margin: 0;
    background:
        radial-gradient(circle at top, rgba(64, 92, 132, 0.16), transparent 35%),
        linear-gradient(180deg, #0f1725, #0c111b 40%, #111827);
    color: var(--text-primary);
}

body {
    min-height: 100vh;
    font-family: "Segoe UI", "PingFang SC", "Microsoft YaHei", sans-serif;
}

body.drawer-open {
    overflow: hidden;
}

.app-shell {
    max-width: 560px;
    margin: 0 auto;
    padding: 16px var(--shell-padding-x) var(--shell-padding-bottom);
}

.app-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 18px;
    margin-bottom: 18px;
}

.app-mobile-header {
    position: sticky;
    top: 0;
    z-index: 20;
    padding: 4px 0 10px;
    background: linear-gradient(180deg, rgba(12, 17, 27, 0.95), rgba(12, 17, 27, 0.68), transparent);
    backdrop-filter: blur(14px);
}

.brand-lockup {
    flex: 0 0 auto;
    display: flex;
    align-items: center;
    min-height: 56px;
}

.brand-logo {
    display: block;
    width: min(var(--logo-width), 100%);
    height: auto;
    aspect-ratio: 275 / 128;
    object-fit: contain;
}

#auth-container {
    flex: 1 1 auto;
    display: flex;
    justify-content: flex-end;
    min-width: 0;
}

.toolbar-cluster {
    display: flex;
    align-items: center;
    gap: 10px;
    flex-wrap: wrap;
    justify-content: flex-end;
}

.guest-header-note {
    display: inline-flex;
    align-items: center;
    gap: 10px;
    min-height: 40px;
    padding: 0 14px;
    border-radius: 14px;
    border: 1px solid rgba(255, 255, 255, 0.08);
    background: rgba(17, 24, 39, 0.72);
    color: var(--text-muted);
    font-size: 0.88rem;
    font-weight: 600;
}

.guest-header-dot {
    width: 8px;
    height: 8px;
    border-radius: 50%;
    background: var(--accent-amber);
    box-shadow: 0 0 0 4px rgba(245, 193, 90, 0.12);
    flex: 0 0 auto;
}

.account-card {
    padding: 8px 12px;
    border-radius: 14px;
    border: 1px solid var(--panel-border);
    background: rgba(17, 24, 39, 0.88);
    min-height: 40px;
    display: flex;
    align-items: center;
}

.account-name {
    font-weight: 700;
    font-size: 0.95rem;
}

.header-icon-row {
    display: flex;
    gap: 8px;
}

.layout-grid {
    display: grid;
    grid-template-columns: minmax(0, 1fr) 360px;
    gap: 18px;
    align-items: start;
}

.game-mobile-layout {
    display: flex;
    flex-direction: column;
    gap: 14px;
}

.guest-panel {
    display: flex;
    justify-content: center;
    margin-bottom: 18px;
}

.guest-card {
    width: min(720px, 100%);
    padding: 28px;
    border-radius: 24px;
    border: 1px solid var(--panel-border);
    background:
        radial-gradient(circle at top left, rgba(125, 211, 252, 0.08), transparent 34%),
        linear-gradient(180deg, rgba(17, 24, 39, 0.96), rgba(12, 18, 28, 0.98));
    box-shadow: 0 24px 44px rgba(0, 0, 0, 0.22);
}

.guest-kicker {
    color: var(--accent-blue);
    font-size: 0.78rem;
    font-weight: 800;
    text-transform: uppercase;
    letter-spacing: 0.08em;
}

.guest-card h2 {
    margin: 10px 0 12px;
    font-size: clamp(1.4rem, 3vw, 2rem);
    line-height: 1.1;
}

.guest-card p {
    margin: 0;
    color: var(--text-muted);
    font-size: 0.98rem;
}

.guest-actions {
    display: flex;
    gap: 10px;
    margin-top: 18px;
    flex-wrap: wrap;
}

.guest-card-mobile {
    border-radius: 28px;
}

.board-column {
    min-width: 0;
    display: flex;
    flex-direction: column;
    align-items: center;
}

.mobile-status-panel {
    border-radius: 24px;
    padding: 12px;
    display: grid;
    gap: 8px;
}

.stats-grid-mobile {
    grid-template-columns: repeat(3, minmax(0, 1fr));
    gap: 8px;
}

.mobile-board-panel {
    gap: 10px;
}

.app-dock {
    position: fixed;
    left: 50%;
    bottom: 14px;
    z-index: 40;
    width: min(calc(100vw - 24px), 528px);
    transform: translateX(-50%);
    display: grid;
    grid-template-columns: repeat(4, minmax(0, 1fr));
    gap: var(--dock-gap);
    padding: var(--dock-padding);
    border-radius: 24px;
    background: rgba(10, 16, 26, 0.92);
    border: 1px solid rgba(255, 255, 255, 0.08);
    box-shadow: 0 18px 40px rgba(0, 0, 0, 0.34);
    backdrop-filter: blur(18px);
}

.dock-btn {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 5px;
    min-height: 58px;
    border: 0;
    border-radius: 18px;
    background: rgba(255, 255, 255, 0.04);
    color: var(--text-primary);
    cursor: pointer;
    transition: transform 140ms ease, background 140ms ease;
}

.dock-btn:hover {
    transform: translateY(-1px);
    background: rgba(125, 211, 252, 0.12);
}

.dock-icon {
    font-size: 0.72rem;
    font-weight: 900;
    letter-spacing: 0.08em;
    text-transform: uppercase;
    color: var(--accent-blue);
}

.dock-label {
    font-size: 0.78rem;
    font-weight: 700;
}

@media (max-width: 920px) {
    :root {
        --logo-width: clamp(176px, 38vw, 248px);
    }

    .app-shell {
        max-width: 620px;
    }
}

.side-column {
    display: flex;
    flex-direction: column;
    gap: 14px;
}

.panel-card {
    background: var(--panel-bg);
    border: 1px solid var(--panel-border);
    border-radius: 18px;
    padding: 14px;
    box-shadow: 0 18px 35px rgba(0, 0, 0, 0.18);
}

.panel-head {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 12px;
}

.panel-head h2 {
    margin: 0;
    font-size: 1rem;
    font-weight: 800;
    letter-spacing: 0.01em;
}

.status-line {
    font-size: 1rem;
    font-weight: 600;
    margin: 0;
    min-height: 1.3em;
    line-height: 1.3;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.turn-line {
    color: var(--text-muted);
    font-size: 0.9rem;
    margin: 0;
    min-height: 1.2em;
    line-height: 1.2;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.stats-grid {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 10px;
}

.stat-card {
    padding: 12px;
    border-radius: 14px;
    background: rgba(8, 13, 22, 0.68);
    border: 1px solid rgba(255, 255, 255, 0.05);
    min-width: 0;
}

.stat-card-wide {
    grid-column: 1 / -1;
}

.stat-label {
    font-size: 0.74rem;
    color: var(--text-muted);
    text-transform: uppercase;
    letter-spacing: 0.05em;
}

.stat-value {
    margin-top: 4px;
    font-size: 1.35rem;
    font-weight: 800;
    line-height: 1.05;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.stat-value-gold {
    color: var(--accent-gold);
}

.stat-value-blue {
    color: var(--accent-blue);
}

.control-stack {
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.field-label {
    color: var(--text-muted);
    font-size: 0.78rem;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.05em;
}

.ui-select {
    width: 100%;
    padding: 10px 12px;
    border-radius: 12px;
    border: 1px solid rgba(255, 255, 255, 0.08);
    background: rgba(17, 24, 39, 0.96);
    color: var(--text-primary);
    font-size: 0.92rem;
    outline: none;
}

.ui-select:focus {
    border-color: rgba(125, 211, 252, 0.58);
    box-shadow: 0 0 0 3px rgba(125, 211, 252, 0.14);
}

.ui-input,
.ui-textarea {
    width: 100%;
    padding: 10px 12px;
    border-radius: 12px;
    border: 1px solid rgba(255, 255, 255, 0.08);
    background: rgba(17, 24, 39, 0.96);
    color: var(--text-primary);
    font-size: 0.92rem;
    outline: none;
    box-sizing: border-box;
}

.ui-input:focus,
.ui-textarea:focus {
    border-color: rgba(125, 211, 252, 0.58);
    box-shadow: 0 0 0 3px rgba(125, 211, 252, 0.14);
}

.ui-textarea {
    resize: vertical;
    min-height: 88px;
}

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

.button-grid-actions {
    margin-top: 0;
}

.button-span-2 {
    grid-column: 1 / -1;
}

.ui-btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    min-height: 40px;
    padding: 0 14px;
    border: 0;
    border-radius: 12px;
    font-size: 0.9rem;
    font-weight: 800;
    line-height: 1;
    letter-spacing: 0.01em;
    cursor: pointer;
    transition: transform 140ms ease, opacity 140ms ease, background 140ms ease;
}

.ui-btn:hover:not(:disabled) {
    transform: translateY(-1px);
}

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

.ui-btn-primary {
    background: linear-gradient(135deg, #3b82f6, #2563eb);
    color: white;
}

.ui-btn-success {
    background: linear-gradient(135deg, #16a34a, #15803d);
    color: white;
}

.ui-btn-danger {
    background: linear-gradient(135deg, #e11d48, #be123c);
    color: white;
}

.ui-btn-warning {
    background: linear-gradient(135deg, #f5c15a, #e7a72e);
    color: #23180d;
}

.ui-btn-neutral {
    background: linear-gradient(135deg, #465364, #374151);
    color: white;
}

.icon-btn {
    width: 40px;
    height: 40px;
    border: 1px solid rgba(255, 255, 255, 0.08);
    border-radius: 12px;
    background: rgba(17, 24, 39, 0.9);
    color: var(--text-primary);
    font-size: 1.1rem;
    font-weight: 700;
    cursor: pointer;
    transition: transform 140ms ease, background 140ms ease, border-color 140ms ease;
}

.icon-btn:hover {
    transform: translateY(-1px);
    background: rgba(30, 41, 59, 0.96);
    border-color: rgba(125, 211, 252, 0.3);
}

.icon-btn-dark {
    background: rgba(8, 14, 24, 0.6);
}

#chessboard {
    width: 100%;
    max-width: 760px;
}

#board-stage {
    width: min(100%, calc(100vw - (var(--shell-padding-x) * 2)), 760px);
}

.board-shell {
    position: relative;
    padding: 16px;
    border-radius: 28px;
    background:
        radial-gradient(circle at top left, rgba(255, 255, 255, 0.14), transparent 36%),
        linear-gradient(145deg, var(--board-wood-light), var(--board-wood-mid) 42%, var(--board-wood-dark));
    box-shadow:
        inset 0 1px 0 rgba(255, 255, 255, 0.2),
        0 28px 60px rgba(0, 0, 0, 0.35);
}

.board-frame {
    padding: 9px;
    border-radius: 18px;
    background:
        linear-gradient(145deg, rgba(255, 244, 223, 0.24), rgba(0, 0, 0, 0.22)),
        linear-gradient(145deg, #8f6138, #5f3f23);
    box-shadow:
        inset 0 1px 0 rgba(255, 255, 255, 0.22),
        inset 0 -2px 8px rgba(0, 0, 0, 0.2);
}

.board-grid {
    width: 100%;
    border-collapse: collapse;
    overflow: hidden;
    border-radius: 10px;
    table-layout: fixed;
}

.board-grid tr {
    height: 12.5%;
}

.board-square {
    position: relative;
    width: 12.5%;
    height: clamp(44px, 9vw, 88px);
    cursor: pointer;
    user-select: none;
    transition: transform 120ms ease, box-shadow 120ms ease;
}

.board-square:hover {
    z-index: 1;
    box-shadow: inset 0 0 0 999px rgba(255, 255, 255, 0.05);
}

.square-light {
    background:
        radial-gradient(circle at top left, rgba(255, 255, 255, 0.18), transparent 42%),
        linear-gradient(135deg, var(--square-light-a), var(--square-light-b));
}

.square-dark {
    background:
        radial-gradient(circle at top left, rgba(255, 255, 255, 0.12), transparent 38%),
        linear-gradient(135deg, var(--square-dark-a), var(--square-dark-b));
}

.highlight-legal {
    box-shadow:
        inset 0 0 0 4px var(--legal-ring),
        inset 0 0 0 999px rgba(39, 167, 114, 0.08);
}

.highlight-selected {
    box-shadow:
        inset 0 0 0 4px var(--selected-ring),
        inset 0 0 0 999px rgba(224, 145, 45, 0.1);
}

.highlight-last-move,
.highlight-ai-move {
    box-shadow:
        inset 0 0 0 4px var(--move-ring),
        inset 0 0 0 999px rgba(86, 173, 255, 0.12);
}

.piece {
    position: absolute;
    inset: 0;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 6px;
}

.piece-svg {
    width: 100%;
    height: 100%;
    overflow: visible;
}

.piece-glyph {
    font-family: "Segoe UI Symbol", "Noto Sans Symbols 2", "DejaVu Sans", serif;
    font-size: 54px;
    font-weight: 700;
    paint-order: stroke fill;
    stroke-linejoin: round;
}

.piece-shadow {
    fill: rgba(0, 0, 0, 0.18);
}

.piece-svg-w {
    filter: var(--piece-white-filter);
}

.piece-svg-b {
    filter: var(--piece-black-filter);
}

.piece-svg-w .piece-main,
.piece-svg-w .piece-accent {
    fill: var(--piece-white-fill);
    stroke: var(--piece-white-stroke);
    stroke-width: 2.4;
    stroke-linejoin: round;
    stroke-linecap: round;
}

.piece-svg-w .piece-detail {
    fill: none;
    stroke: var(--piece-white-detail);
    stroke-width: 2.05;
    stroke-linecap: round;
    stroke-linejoin: round;
}

.piece-svg-w .piece-detail-fill {
    fill: var(--piece-white-detail);
}

.piece-svg-b .piece-main,
.piece-svg-b .piece-accent {
    fill: var(--piece-black-fill);
    stroke: var(--piece-black-stroke);
    stroke-width: 2.3;
    stroke-linejoin: round;
    stroke-linecap: round;
}

.piece-svg-b .piece-detail {
    fill: none;
    stroke: var(--piece-black-detail);
    stroke-width: 2;
    stroke-linecap: round;
    stroke-linejoin: round;
}

.piece-svg-b .piece-detail-fill {
    fill: var(--piece-black-detail);
}

.piece-svg-w .piece-glyph {
    fill: var(--piece-white-fill);
    stroke: var(--piece-white-stroke);
    stroke-width: 1.6;
}

.piece-svg-b .piece-glyph {
    fill: var(--piece-black-fill);
    stroke: var(--piece-black-stroke);
    stroke-width: 1.5;
}

.board-coord {
    position: absolute;
    font-size: 0.72rem;
    font-weight: 800;
    letter-spacing: 0.02em;
    pointer-events: none;
}

.board-coord-rank {
    top: 4px;
    left: 6px;
}

.board-coord-file {
    right: 6px;
    bottom: 4px;
}

.coord-on-light {
    color: var(--coord-light);
}

.coord-on-dark {
    color: var(--coord-dark);
}

#chessboard[data-board-theme="walnut"] {
    --board-wood-dark: #5b3d24;
    --board-wood-mid: #825934;
    --board-wood-light: #b18155;
    --square-light-a: #f3e3bf;
    --square-light-b: #dbc394;
    --square-dark-a: #7b9450;
    --square-dark-b: #5c7338;
    --coord-light: rgba(91, 58, 29, 0.55);
    --coord-dark: rgba(255, 244, 223, 0.64);
}

#chessboard[data-board-theme="slate"] {
    --board-wood-dark: #253042;
    --board-wood-mid: #36465f;
    --board-wood-light: #536785;
    --square-light-a: #d6dde6;
    --square-light-b: #c0ccd9;
    --square-dark-a: #72839a;
    --square-dark-b: #51627b;
    --coord-light: rgba(31, 41, 55, 0.48);
    --coord-dark: rgba(241, 245, 249, 0.74);
}

#chessboard[data-board-theme="midnight"] {
    --board-wood-dark: #091321;
    --board-wood-mid: #16253d;
    --board-wood-light: #22385c;
    --square-light-a: #4d7aa8;
    --square-light-b: #325776;
    --square-dark-a: #102238;
    --square-dark-b: #081626;
    --coord-light: rgba(224, 242, 254, 0.64);
    --coord-dark: rgba(186, 230, 253, 0.6);
}

#chessboard[data-board-theme="ivory"] {
    --board-wood-dark: #a78657;
    --board-wood-mid: #c9ab77;
    --board-wood-light: #e5d5b5;
    --square-light-a: #fff9ef;
    --square-light-b: #f2e9d4;
    --square-dark-a: #c7a86b;
    --square-dark-b: #ab8a52;
    --coord-light: rgba(117, 79, 29, 0.5);
    --coord-dark: rgba(255, 248, 236, 0.7);
}

#chessboard[data-board-theme="terracotta"] {
    --board-wood-dark: #6e2f24;
    --board-wood-mid: #94473b;
    --board-wood-light: #c56d58;
    --square-light-a: #f3cab4;
    --square-light-b: #e0af95;
    --square-dark-a: #bf6a47;
    --square-dark-b: #8f472a;
    --coord-light: rgba(109, 43, 22, 0.58);
    --coord-dark: rgba(255, 236, 224, 0.72);
}

#chessboard[data-piece-theme="traditional"] {
    --piece-white-fill: #fff8ea;
    --piece-white-stroke: #3b2816;
    --piece-white-detail: #6b4a29;
    --piece-black-fill: #202223;
    --piece-black-stroke: #f1dfc1;
    --piece-black-detail: #f1dfc1;
    --piece-white-filter: drop-shadow(0 4px 6px rgba(0, 0, 0, 0.28));
    --piece-black-filter: drop-shadow(0 4px 6px rgba(0, 0, 0, 0.36));
}

.status-banner {
    margin-top: 12px;
    padding: 12px 14px;
    border-radius: 14px;
    background: linear-gradient(135deg, rgba(28, 63, 108, 0.92), rgba(35, 120, 186, 0.92));
    color: #eef7ff;
    font-size: 0.92rem;
    font-weight: 700;
    box-shadow: 0 18px 35px rgba(0, 0, 0, 0.25);
}

.profile-card {
    display: flex;
    flex-direction: column;
    gap: 12px;
}

.profile-head {
    display: flex;
    gap: 12px;
    align-items: center;
}

.profile-avatar {
    width: 56px;
    height: 56px;
    border-radius: 50%;
    background: linear-gradient(135deg, #3b82f6, #1f2937);
    background-size: cover;
    background-position: center;
    border: 2px solid rgba(255, 255, 255, 0.12);
    display: flex;
    align-items: center;
    justify-content: center;
    font-weight: 800;
    color: white;
}

.profile-name {
    font-size: 1rem;
    font-weight: 800;
}

.profile-subline {
    color: var(--text-muted);
    font-size: 0.82rem;
}

.profile-divider {
    height: 1px;
    background: rgba(255, 255, 255, 0.08);
}

.drawer-backdrop {
    position: fixed;
    inset: 0;
    z-index: 70;
    background: rgba(4, 9, 17, 0.58);
    backdrop-filter: blur(14px);
}

.side-drawer {
    position: fixed;
    width: min(100vw, 460px);
    z-index: 80;
    pointer-events: none;
    transition: transform 240ms ease;
}

.side-drawer.is-open {
    pointer-events: auto;
}

.side-drawer-right {
    inset: 0 0 0 auto;
    transform: translateX(100%);
}

.side-drawer-left {
    inset: 0 auto 0 0;
    transform: translateX(-100%);
}

.side-drawer-right.is-open,
.side-drawer-left.is-open {
    transform: translateX(0);
}

.profile-drawer-shell {
    height: 100%;
    display: flex;
    flex-direction: column;
    background:
        radial-gradient(circle at top left, rgba(91, 173, 255, 0.12), transparent 28%),
        linear-gradient(180deg, rgba(14, 21, 34, 0.98), rgba(9, 14, 23, 0.98));
    border-left: 1px solid rgba(255, 255, 255, 0.08);
    box-shadow: -18px 0 48px rgba(0, 0, 0, 0.32);
}

.side-drawer-left .profile-drawer-shell {
    border-left: 0;
    border-right: 1px solid rgba(255, 255, 255, 0.08);
    box-shadow: 18px 0 48px rgba(0, 0, 0, 0.32);
}

.profile-drawer-header {
    display: flex;
    align-items: flex-start;
    justify-content: space-between;
    gap: 14px;
    padding: 22px 20px 16px;
}

.profile-drawer-header h2 {
    margin: 4px 0 6px;
    font-size: 1.5rem;
    font-weight: 900;
    letter-spacing: -0.03em;
}

.profile-drawer-header p {
    margin: 0;
    color: var(--text-muted);
    font-size: 0.9rem;
    line-height: 1.45;
}

.drawer-kicker {
    color: var(--accent-blue);
    font-size: 0.76rem;
    font-weight: 800;
    letter-spacing: 0.08em;
    text-transform: uppercase;
}

.profile-drawer-scroll {
    flex: 1;
    overflow-y: auto;
    padding: 0 20px 20px;
    display: flex;
    flex-direction: column;
    gap: 14px;
}

.drawer-panel {
    padding: 16px;
    border-radius: 20px;
    background: rgba(13, 20, 31, 0.76);
    border: 1px solid rgba(255, 255, 255, 0.06);
    box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.04);
}

.drawer-panel .panel-head {
    margin-bottom: 10px;
}

.drawer-panel .panel-head h3 {
    margin: 0;
    font-size: 0.98rem;
    font-weight: 800;
}

.profile-card-drawer {
    gap: 16px;
}

.profile-head-drawer {
    align-items: center;
}

.profile-avatar-large {
    width: 72px;
    height: 72px;
    font-size: 1.4rem;
}

.profile-name-large {
    font-size: 1.15rem;
}

.profile-bio-preview {
    display: flex;
    flex-direction: column;
    gap: 8px;
    padding: 12px;
    border-radius: 16px;
    background: rgba(255, 255, 255, 0.04);
}

.profile-bio-text {
    color: var(--text-primary);
    font-size: 0.92rem;
    line-height: 1.55;
    white-space: pre-wrap;
    word-break: break-word;
}

.profile-drawer-footer {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 10px;
    padding: 16px 20px 20px;
    border-top: 1px solid rgba(255, 255, 255, 0.08);
    background: rgba(9, 14, 23, 0.92);
}

.profile-drawer-footer-wide {
    grid-template-columns: repeat(3, minmax(0, 1fr));
}

.sheet-backdrop {
    position: fixed;
    inset: 0;
    z-index: 60;
    background: rgba(4, 9, 17, 0.54);
    backdrop-filter: blur(10px);
}

.mobile-sheet {
    position: fixed;
    left: 0;
    right: 0;
    bottom: 0;
    z-index: 65;
    transform: translateY(100%);
    transition: transform 240ms ease;
    pointer-events: none;
}

.mobile-sheet.is-open {
    transform: translateY(0);
    pointer-events: auto;
}

.sheet-shell {
    width: min(100%, 560px);
    margin: 0 auto;
    max-height: min(78vh, 720px);
    display: flex;
    flex-direction: column;
    border-radius: 28px 28px 0 0;
    background:
        radial-gradient(circle at top, rgba(91, 173, 255, 0.12), transparent 28%),
        linear-gradient(180deg, rgba(14, 21, 34, 0.98), rgba(9, 14, 23, 0.98));
    border: 1px solid rgba(255, 255, 255, 0.08);
    border-bottom: 0;
    box-shadow: 0 -18px 48px rgba(0, 0, 0, 0.38);
}

.sheet-grabber {
    width: 46px;
    height: 5px;
    margin: 10px auto 6px;
    border-radius: 999px;
    background: rgba(255, 255, 255, 0.18);
}

.sheet-header {
    display: flex;
    align-items: flex-start;
    justify-content: space-between;
    gap: 12px;
    padding: 8px 16px 14px;
}

.sheet-header h2 {
    margin: 4px 0 0;
    font-size: 1.2rem;
    font-weight: 900;
    letter-spacing: -0.03em;
}

.sheet-scroll {
    overflow-y: auto;
    padding: 0 16px 18px;
}

.leaderboard-list {
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.leaderboard-row {
    display: grid;
    grid-template-columns: 28px 42px 1fr auto;
    gap: 10px;
    align-items: center;
    padding: 10px;
    border-radius: 14px;
    background: rgba(8, 13, 22, 0.58);
    border: 1px solid rgba(255, 255, 255, 0.05);
}

.leaderboard-rank {
    text-align: center;
    font-weight: 800;
    color: var(--accent-gold);
}

.leaderboard-avatar {
    width: 42px;
    height: 42px;
    border-radius: 50%;
    background: linear-gradient(135deg, #475569, #1f2937);
    background-size: cover;
    background-position: center;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 0.9rem;
    font-weight: 800;
    color: white;
}

.leaderboard-name {
    font-weight: 700;
}

.leaderboard-meta {
    font-size: 0.78rem;
    color: var(--text-muted);
}

.leaderboard-points {
    text-align: right;
    font-weight: 800;
    color: var(--accent-gold);
}

.status-banner.show {
    animation: banner-slide 850ms ease;
}

.board-overlay {
    position: absolute;
    inset: 0;
    display: flex;
    align-items: center;
    justify-content: center;
    pointer-events: none;
    border-radius: 28px;
    background: radial-gradient(circle, rgba(9, 18, 30, 0.08), rgba(9, 18, 30, 0.45));
}

.board-overlay-text {
    padding: 16px 24px;
    border-radius: 999px;
    font-size: clamp(1.25rem, 3.6vw, 2.35rem);
    font-weight: 900;
    letter-spacing: 0.06em;
    text-transform: uppercase;
    background: rgba(11, 20, 34, 0.8);
    color: #fff8e7;
    box-shadow: 0 20px 40px rgba(0, 0, 0, 0.35);
}

.board-overlay.show .board-overlay-text {
    animation: overlay-pop 1200ms ease forwards;
}

.event-toast {
    position: fixed;
    top: 18px;
    right: 18px;
    z-index: 50;
    max-width: min(380px, calc(100vw - 24px));
    padding: 12px 16px;
    border-radius: 16px;
    background: linear-gradient(135deg, rgba(20, 29, 45, 0.96), rgba(41, 58, 86, 0.96));
    color: #f6f8fb;
    font-size: 0.9rem;
    font-weight: 700;
    box-shadow: 0 24px 48px rgba(0, 0, 0, 0.35);
}

.event-toast.show {
    animation: toast-pop 2400ms ease forwards;
}

.result-modal-backdrop {
    z-index: 90;
    background: rgba(3, 8, 15, 0.72);
    backdrop-filter: blur(16px);
}

.result-modal-card {
    width: min(100%, 420px);
    padding: 22px;
    border-radius: 28px;
    border: 1px solid rgba(255, 255, 255, 0.08);
    background:
        radial-gradient(circle at top, rgba(125, 211, 252, 0.12), transparent 34%),
        linear-gradient(180deg, rgba(18, 27, 42, 0.98), rgba(10, 16, 26, 0.98));
    box-shadow: 0 26px 64px rgba(0, 0, 0, 0.38);
}

.result-badge {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    min-height: 30px;
    padding: 0 12px;
    border-radius: 999px;
    font-size: 0.74rem;
    font-weight: 900;
    letter-spacing: 0.08em;
    text-transform: uppercase;
    color: #eff6ff;
    background: rgba(59, 130, 246, 0.2);
    border: 1px solid rgba(125, 211, 252, 0.28);
}

.result-badge.is-win {
    background: rgba(34, 197, 94, 0.18);
    border-color: rgba(74, 222, 128, 0.28);
    color: #dcfce7;
}

.result-badge.is-loss {
    background: rgba(244, 63, 94, 0.16);
    border-color: rgba(253, 164, 175, 0.26);
    color: #ffe4e6;
}

.result-badge.is-draw {
    background: rgba(245, 158, 11, 0.16);
    border-color: rgba(252, 211, 77, 0.24);
    color: #fef3c7;
}

.result-title {
    margin: 16px 0 8px;
    font-size: clamp(1.8rem, 5vw, 2.4rem);
    line-height: 1;
    letter-spacing: -0.04em;
    font-weight: 900;
}

.result-message {
    margin: 0;
    color: var(--text-muted);
    font-size: 0.96rem;
    line-height: 1.55;
}

.result-actions {
    display: grid;
    grid-template-columns: repeat(3, minmax(0, 1fr));
    gap: 10px;
    margin-top: 22px;
}

.board-check {
    animation: board-alert 800ms ease;
}

.board-win {
    animation: board-win 1100ms ease;
}

.board-loss {
    animation: board-loss 1100ms ease;
}

.board-draw {
    animation: board-draw 1100ms ease;
}

@keyframes banner-slide {
    0% { opacity: 0; transform: translateY(-8px) scale(0.98); }
    20% { opacity: 1; transform: translateY(0) scale(1); }
    100% { opacity: 1; transform: translateY(0) scale(1); }
}

@keyframes overlay-pop {
    0% { opacity: 0; transform: scale(0.82); }
    18% { opacity: 1; transform: scale(1); }
    82% { opacity: 1; transform: scale(1); }
    100% { opacity: 0; transform: scale(1.04); }
}

@keyframes toast-pop {
    0% { opacity: 0; transform: translateY(-8px) scale(0.96); }
    12% { opacity: 1; transform: translateY(0) scale(1); }
    82% { opacity: 1; transform: translateY(0) scale(1); }
    100% { opacity: 0; transform: translateY(-12px) scale(0.98); }
}

@keyframes board-alert {
    0%, 100% { transform: translateX(0); }
    15% { transform: translateX(-6px); }
    30% { transform: translateX(6px); }
    45% { transform: translateX(-4px); }
    60% { transform: translateX(4px); }
    75% { transform: translateX(-2px); }
}

@keyframes board-win {
    0% { filter: saturate(1); transform: scale(1); }
    30% { filter: saturate(1.24); transform: scale(1.01); }
    100% { filter: saturate(1); transform: scale(1); }
}

@keyframes board-loss {
    0% { filter: hue-rotate(0deg); opacity: 1; }
    30% { filter: hue-rotate(-18deg); opacity: 0.92; }
    100% { filter: hue-rotate(0deg); opacity: 1; }
}

@keyframes board-draw {
    0% { opacity: 1; }
    50% { opacity: 0.84; }
    100% { opacity: 1; }
}

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

    .side-column {
        display: grid;
        grid-template-columns: repeat(2, minmax(0, 1fr));
        gap: 12px;
    }
}

@media (max-width: 760px) {
    :root {
        --logo-width: clamp(170px, 62vw, 248px);
        --shell-padding-x: 12px;
        --shell-padding-bottom: 108px;
        --dock-gap: 8px;
        --dock-padding: 8px;
    }

    .app-shell {
        max-width: 100%;
    }

    .app-header {
        flex-direction: column;
        align-items: stretch;
        gap: 12px;
    }

    .brand-lockup {
        justify-content: center;
        min-height: 0;
    }

    .brand-logo {
        width: min(var(--logo-width), 82vw);
    }

    .toolbar-cluster {
        justify-content: space-between;
    }

    .guest-header-note {
        width: 100%;
        justify-content: center;
    }

    .header-icon-row {
        margin-left: auto;
    }

    .account-card {
        flex: 1;
        text-align: left;
    }

    .side-column {
        grid-template-columns: 1fr;
    }

    .panel-card {
        padding: 12px;
        border-radius: 16px;
    }

    .mobile-status-panel {
        padding: 10px;
        gap: 6px;
        border-radius: 20px;
    }

    .stats-grid-mobile {
        grid-template-columns: 72px 72px minmax(0, 1fr);
        gap: 6px;
    }

    .stats-grid-mobile .stat-card {
        padding: 8px 9px;
        border-radius: 12px;
    }

    .stats-grid-mobile .stat-label {
        font-size: 0.62rem;
        letter-spacing: 0.04em;
    }

    .stats-grid-mobile .stat-value {
        margin-top: 3px;
        font-size: 1rem;
    }

    #player-record {
        font-size: 0.84rem;
        letter-spacing: -0.01em;
    }

    .guest-card {
        padding: 18px;
        border-radius: 18px;
    }

    .button-grid,
    .button-grid-actions {
        grid-template-columns: repeat(2, minmax(0, 1fr));
    }

    .ui-btn {
        min-height: 38px;
        padding: 0 12px;
        font-size: 0.84rem;
        border-radius: 10px;
    }

    .ui-select {
        padding: 9px 11px;
        font-size: 0.88rem;
    }

    .board-shell {
        padding: 10px;
        border-radius: 20px;
    }

    .board-frame {
        padding: 6px;
        border-radius: 14px;
    }

    .piece {
        padding: 3px;
    }

    .board-square {
        height: clamp(38px, 11vw, 64px);
    }

    .board-coord {
        font-size: 0.58rem;
    }

    .board-overlay {
        border-radius: 20px;
    }

    .status-banner {
        padding: 10px 12px;
        font-size: 0.85rem;
    }

    .event-toast {
        top: 10px;
        right: 10px;
        left: 10px;
        max-width: none;
    }

    .result-modal-card {
        width: 100%;
        padding: 20px 18px 18px;
        border-radius: 24px 24px 0 0;
    }

    .result-actions {
        grid-template-columns: 1fr;
    }

    .app-dock {
        left: var(--shell-padding-x);
        right: var(--shell-padding-x);
        bottom: 10px;
        width: auto;
        transform: none;
        border-radius: 20px;
    }

    .dock-btn {
        min-height: 52px;
        border-radius: 16px;
    }

    .sheet-shell {
        width: 100%;
        border-radius: 24px 24px 0 0;
    }

    .guest-actions {
        flex-direction: column;
    }

    .side-drawer {
        width: 100vw;
    }

    .profile-drawer-header {
        padding: 18px 16px 12px;
    }

    .profile-drawer-scroll {
        padding: 0 16px 16px;
    }

    .drawer-panel {
        padding: 14px;
        border-radius: 18px;
    }

    .profile-drawer-footer {
        grid-template-columns: 1fr;
        padding: 14px 16px 16px;
    }

    .profile-drawer-footer-wide {
        grid-template-columns: 1fr;
    }
}

@media (max-width: 460px) {
    :root {
        --logo-width: clamp(152px, 64vw, 220px);
        --shell-padding-x: 10px;
        --shell-padding-bottom: 104px;
        --dock-gap: 6px;
        --dock-padding: 7px;
    }

    .button-grid,
    .button-grid-actions {
        grid-template-columns: 1fr;
    }

    .button-span-2 {
        grid-column: auto;
    }

    .stats-grid {
        grid-template-columns: 1fr;
    }

    .stat-card-wide {
        grid-column: auto;
    }

    .stats-grid-mobile {
        grid-template-columns: 66px 66px minmax(0, 1fr);
        gap: 5px;
    }

    .stats-grid-mobile .stat-card {
        padding: 7px 8px;
    }

    .stats-grid-mobile .stat-label {
        font-size: 0.58rem;
    }

    .stats-grid-mobile .stat-value {
        font-size: 0.92rem;
    }

    #player-record {
        font-size: 0.76rem;
    }

    .ui-btn {
        width: 100%;
    }

    .board-square {
        height: clamp(34px, 11.5vw, 52px);
    }

    .dock-btn {
        min-height: 48px;
        gap: 4px;
    }

    .dock-icon {
        font-size: 0.66rem;
    }

    .dock-label {
        font-size: 0.72rem;
    }
}

@media (max-width: 390px) {
    :root {
        --logo-width: clamp(144px, 60vw, 196px);
        --shell-padding-x: 8px;
        --shell-padding-bottom: 100px;
        --dock-gap: 5px;
        --dock-padding: 6px;
    }

    .app-header {
        gap: 10px;
        margin-bottom: 14px;
    }

    .guest-header-note {
        min-height: 36px;
        padding: 0 10px;
        font-size: 0.76rem;
    }

    .mobile-status-panel {
        padding: 8px;
        gap: 5px;
    }

    .status-line {
        font-size: 0.9rem;
    }

    .turn-line {
        font-size: 0.78rem;
    }

    .stats-grid-mobile {
        grid-template-columns: 60px 60px minmax(0, 1fr);
        gap: 4px;
    }

    .stats-grid-mobile .stat-card {
        padding: 6px 7px;
        border-radius: 10px;
    }

    .stats-grid-mobile .stat-label {
        font-size: 0.54rem;
    }

    .stats-grid-mobile .stat-value {
        font-size: 0.86rem;
    }

    #player-record {
        font-size: 0.72rem;
    }

    .board-square {
        height: clamp(32px, 11.2vw, 46px);
    }

    .app-dock {
        bottom: 8px;
        border-radius: 18px;
    }

    .dock-btn {
        min-height: 44px;
        border-radius: 14px;
    }

    .dock-label {
        font-size: 0.68rem;
    }
}

@media (max-width: 340px) {
    :root {
        --logo-width: clamp(132px, 56vw, 176px);
    }

    .stats-grid-mobile {
        grid-template-columns: 56px 56px minmax(0, 1fr);
    }

    .board-square {
        height: clamp(30px, 10.9vw, 42px);
    }

    .dock-icon {
        font-size: 0.6rem;
    }

    .dock-label {
        font-size: 0.64rem;
    }
}
