:root {
    --bg: #08080a;
    --surface: rgba(19, 19, 23, 0.78);
    --surface-solid: #121216;
    --surface-hover: rgba(255, 255, 255, 0.06);
    --border: rgba(255, 255, 255, 0.085);
    --border-strong: rgba(255, 255, 255, 0.14);
    --text: #f7f7f8;
    --muted: #8f8f9b;
    --muted-2: #656570;
    --accent: #b9a7ff;
    --accent-2: #7e66ff;
    --accent-soft: rgba(151, 123, 255, 0.16);
    --danger: #ff6f7d;
    --light-square: #dedce2;
    --dark-square: #74717a;
    --board-radius: 18px;
    --shadow: 0 42px 90px rgba(0, 0, 0, 0.48);
    --board-size: min(70vh, 720px, 64vw);
}

* {
    box-sizing: border-box;
}

html {
    color-scheme: dark;
    background: var(--bg);
}

body {
    min-width: 320px;
    min-height: 100vh;
    margin: 0;
    overflow-x: hidden;
    background:
        radial-gradient(circle at 18% 16%, rgba(107, 80, 226, 0.11), transparent 34%),
        radial-gradient(circle at 86% 82%, rgba(169, 77, 190, 0.07), transparent 30%),
        linear-gradient(135deg, #09090b 0%, #070709 55%, #0b0a0f 100%);
    color: var(--text);
    font-family: Inter, "Segoe UI Variable Text", "Segoe UI", system-ui, -apple-system, BlinkMacSystemFont, sans-serif;
    -webkit-font-smoothing: antialiased;
}

button,
a {
    -webkit-tap-highlight-color: transparent;
}

button {
    font: inherit;
}

button:focus-visible,
a:focus-visible {
    outline: 2px solid var(--accent);
    outline-offset: 3px;
}

.ambient {
    position: fixed;
    z-index: -3;
    width: 42vw;
    aspect-ratio: 1;
    border-radius: 50%;
    filter: blur(120px);
    opacity: 0.15;
    pointer-events: none;
    animation: ambient-drift 18s ease-in-out infinite alternate;
}

.ambient--one {
    top: -18vw;
    left: -12vw;
    background: #6c4dff;
}

.ambient--two {
    right: -20vw;
    bottom: -20vw;
    background: #9d4db4;
    animation-delay: -7s;
}

.noise {
    position: fixed;
    inset: 0;
    z-index: -2;
    opacity: 0.035;
    pointer-events: none;
    background-image: url("data:image/svg+xml,%3Csvg viewBox='0 0 160 160' xmlns='http://www.w3.org/2000/svg'%3E%3Cfilter id='n'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='.95' numOctaves='4' stitchTiles='stitch'/%3E%3C/filter%3E%3Crect width='100%25' height='100%25' filter='url(%23n)' opacity='.8'/%3E%3C/svg%3E");
}

.app-shell {
    width: min(1480px, calc(100% - 48px));
    margin: 0 auto;
    padding: 26px 0 36px;
}

.topbar {
    display: flex;
    align-items: center;
    justify-content: space-between;
    min-height: 56px;
    margin-bottom: 28px;
}

.brand {
    display: inline-flex;
    align-items: center;
    gap: 12px;
    color: var(--text);
    text-decoration: none;
}

.brand-mark {
    display: grid;
    grid-template-columns: repeat(3, 4px);
    align-items: end;
    gap: 3px;
    width: 20px;
    height: 25px;
    transform: skewX(-10deg);
}

.brand-mark span {
    display: block;
    width: 4px;
    border-radius: 4px;
    background: linear-gradient(180deg, #d5caff, #846cff);
    box-shadow: 0 0 18px rgba(147, 119, 255, 0.35);
}

.brand-mark span:nth-child(1) { height: 54%; }
.brand-mark span:nth-child(2) { height: 100%; }
.brand-mark span:nth-child(3) { height: 76%; }

.brand-copy {
    display: flex;
    align-items: baseline;
    gap: 9px;
}

.brand-copy strong {
    font-family: "Segoe UI Variable Display", Inter, "Segoe UI", system-ui, sans-serif;
    font-size: 15px;
    letter-spacing: 0.22em;
}

.brand-copy small {
    color: var(--muted-2);
    font-size: 10px;
    font-weight: 700;
    letter-spacing: 0.24em;
}

.topbar-actions {
    display: flex;
    align-items: center;
    gap: 10px;
}

.icon-button,
.button,
.segmented button,
.text-button,
.promotion-button {
    border: 0;
    cursor: pointer;
}

.icon-button {
    display: grid;
    width: 42px;
    height: 42px;
    place-items: center;
    border: 1px solid var(--border);
    border-radius: 13px;
    background: rgba(255, 255, 255, 0.035);
    color: var(--muted);
    transition: border-color 220ms ease, background 220ms ease, color 220ms ease, transform 220ms cubic-bezier(.2,.8,.2,1);
}

.icon-button:hover {
    border-color: var(--border-strong);
    background: rgba(255, 255, 255, 0.065);
    color: var(--text);
    transform: translateY(-1px);
}

.icon-button svg {
    width: 18px;
    fill: currentColor;
}

.icon-button .sound-off { display: none; }
.icon-button[aria-pressed="false"] .sound-on { display: none; }
.icon-button[aria-pressed="false"] .sound-off { display: block; }

.button {
    display: inline-flex;
    min-height: 42px;
    align-items: center;
    justify-content: center;
    gap: 8px;
    padding: 0 17px;
    border-radius: 13px;
    font-size: 12px;
    font-weight: 700;
    letter-spacing: 0.01em;
    transition: transform 220ms cubic-bezier(.2,.8,.2,1), border-color 220ms ease, background 220ms ease, color 220ms ease, opacity 220ms ease;
}

.button:hover:not(:disabled) { transform: translateY(-1px); }
.button:active:not(:disabled) { transform: translateY(0) scale(0.985); }
.button:disabled { cursor: not-allowed; opacity: 0.35; }
.button svg { width: 17px; fill: currentColor; }

.button--ghost {
    border: 1px solid var(--border);
    background: rgba(255, 255, 255, 0.035);
    color: var(--text);
}

.button--ghost:hover { background: rgba(255, 255, 255, 0.07); }

.button--secondary {
    flex: 1;
    border: 1px solid var(--border);
    background: rgba(255, 255, 255, 0.045);
    color: var(--text);
}

.button--secondary:hover:not(:disabled) { background: rgba(255, 255, 255, 0.08); }

.button--danger {
    border: 1px solid rgba(255, 111, 125, 0.15);
    background: rgba(255, 111, 125, 0.06);
    color: #ff9da6;
}

.button--danger:hover { background: rgba(255, 111, 125, 0.11); }

.button--primary {
    width: 100%;
    background: linear-gradient(135deg, #b9a7ff, #8269ff);
    color: #0b0912;
    box-shadow: 0 12px 32px rgba(126, 102, 255, 0.24);
}

.game-layout {
    display: grid;
    grid-template-columns: minmax(0, var(--board-size)) 360px;
    justify-content: center;
    gap: clamp(34px, 5vw, 82px);
    align-items: center;
}

.board-stage {
    width: 100%;
    animation: stage-in 780ms cubic-bezier(.16,.85,.26,1) both;
}

.player-strip {
    display: grid;
    grid-template-columns: 43px minmax(0, auto) 1fr;
    align-items: center;
    gap: 12px;
    min-height: 60px;
}

.player-strip--opponent { margin-bottom: 12px; }
.player-strip--self { margin-top: 12px; }

.avatar {
    display: grid;
    width: 43px;
    height: 43px;
    place-items: center;
    overflow: hidden;
    border: 1px solid var(--border);
    border-radius: 14px;
    background: rgba(255, 255, 255, 0.05);
}

.avatar--player {
    color: #17131f;
    background: linear-gradient(145deg, #ece8f3, #aaa6b2);
    font-family: "Segoe UI Variable Display", "Segoe UI", system-ui, sans-serif;
    font-size: 14px;
    font-weight: 800;
}

.avatar--ai {
    position: relative;
    background: radial-gradient(circle at 50% 35%, rgba(151, 123, 255, 0.24), rgba(255,255,255,0.025) 62%);
}

.avatar--ai::before,
.avatar--ai::after,
.avatar-core {
    position: absolute;
    border-radius: 50%;
}

.avatar--ai::before {
    content: "";
    width: 23px;
    height: 23px;
    border: 1px solid rgba(185, 167, 255, 0.48);
    animation: ai-orbit 7s linear infinite;
}

.avatar--ai::after {
    content: "";
    width: 17px;
    height: 17px;
    border: 1px dashed rgba(185, 167, 255, 0.35);
    animation: ai-orbit 4s linear infinite reverse;
}

.avatar-core {
    width: 6px;
    height: 6px;
    background: var(--accent);
    box-shadow: 0 0 16px var(--accent);
}

.player-meta { min-width: 0; }

.player-name-line {
    display: flex;
    align-items: center;
    gap: 8px;
    margin-bottom: 3px;
}

.player-name-line strong {
    font-family: "Segoe UI Variable Display", Inter, "Segoe UI", system-ui, sans-serif;
    font-size: 13px;
    font-weight: 700;
}

.player-subline {
    overflow: hidden;
    color: var(--muted);
    font-size: 11px;
    text-overflow: ellipsis;
    white-space: nowrap;
    transition: color 200ms ease;
}

.badge {
    padding: 4px 6px;
    border: 1px solid rgba(185, 167, 255, 0.15);
    border-radius: 6px;
    background: var(--accent-soft);
    color: #cfc4ff;
    font-size: 8px;
    font-weight: 800;
    letter-spacing: 0.09em;
}

.turn-dot {
    width: 6px;
    height: 6px;
    border-radius: 50%;
    background: var(--accent);
    box-shadow: 0 0 12px rgba(185, 167, 255, 0.85);
    animation: turn-pulse 1.8s ease-in-out infinite;
    transition: opacity 220ms ease;
}

.turn-dot.is-inactive { opacity: 0.12; animation: none; }

.captured {
    display: flex;
    justify-content: flex-end;
    min-width: 0;
    padding-right: 2px;
    color: var(--muted-2);
    font-family: Georgia, "Times New Roman", serif;
    font-size: clamp(13px, 1.5vw, 19px);
    letter-spacing: -0.2em;
    white-space: nowrap;
}

.board-frame {
    position: relative;
    width: 100%;
    aspect-ratio: 1;
    padding: 8px;
    border: 1px solid var(--border);
    border-radius: calc(var(--board-radius) + 8px);
    background: linear-gradient(145deg, rgba(255,255,255,.055), rgba(255,255,255,.018));
    box-shadow: var(--shadow), inset 0 1px 0 rgba(255, 255, 255, 0.05);
    isolation: isolate;
}

.board-glow {
    position: absolute;
    inset: 12%;
    z-index: -1;
    border-radius: 50%;
    background: rgba(135, 105, 255, 0.2);
    filter: blur(55px);
    opacity: 0.45;
    transition: opacity 500ms ease;
}

.board-frame.is-thinking .board-glow {
    opacity: 0.85;
    animation: thinking-glow 1.6s ease-in-out infinite alternate;
}

.board {
    display: grid;
    width: 100%;
    height: 100%;
    grid-template-columns: repeat(8, 1fr);
    grid-template-rows: repeat(8, 1fr);
    overflow: hidden;
    border-radius: var(--board-radius);
    background: var(--dark-square);
    box-shadow: inset 0 0 0 1px rgba(0,0,0,.18);
    user-select: none;
    touch-action: none;
}

.square {
    position: relative;
    display: grid;
    place-items: center;
    min-width: 0;
    min-height: 0;
    border: 0;
    padding: 0;
    cursor: pointer;
    overflow: hidden;
}

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

.square::before,
.square::after {
    content: "";
    position: absolute;
    pointer-events: none;
}

.square::before {
    inset: 0;
    background: rgba(171, 149, 255, 0);
    transition: background 180ms ease;
}

.square.is-last::before { background: rgba(170, 145, 255, 0.2); }
.square.is-selected::before { background: rgba(150, 121, 255, 0.36); }
.square.is-check::before {
    background: radial-gradient(circle, rgba(255, 90, 106, 0.62), rgba(255, 68, 89, 0.18) 54%, transparent 72%);
    animation: check-pulse 1.2s ease-in-out infinite alternate;
}

.square.is-legal::after {
    z-index: 2;
    width: 16%;
    aspect-ratio: 1;
    border-radius: 50%;
    background: rgba(30, 27, 35, 0.3);
    transform: scale(0);
    animation: legal-dot 240ms cubic-bezier(.2,.8,.2,1) forwards;
}

.square.is-capture::after {
    z-index: 2;
    inset: 8%;
    width: auto;
    aspect-ratio: auto;
    border: clamp(2px, .45vw, 5px) solid rgba(49, 43, 58, 0.25);
    border-radius: 50%;
    background: transparent;
    transform: scale(0.82);
    animation: legal-ring 240ms cubic-bezier(.2,.8,.2,1) forwards;
}

.coordinate {
    position: absolute;
    z-index: 4;
    color: rgba(22, 20, 26, 0.45);
    font-size: clamp(7px, .72vw, 10px);
    font-weight: 700;
    pointer-events: none;
}

.coordinate--file { right: 6px; bottom: 4px; }
.coordinate--rank { top: 5px; left: 6px; }
.square.dark .coordinate { color: rgba(245, 243, 248, 0.48); }

.piece {
    position: relative;
    z-index: 3;
    display: grid;
    width: 88%;
    height: 88%;
    place-items: center;
    border: 0;
    background: transparent;
    color: inherit;
    cursor: grab;
    font-family: Georgia, "Times New Roman", "DejaVu Serif", serif;
    font-size: clamp(31px, calc(var(--board-size) / 10.2), 70px);
    line-height: 1;
    transform: translateZ(0) scale(1);
    transform-origin: center;
    transition: transform 160ms cubic-bezier(.2,.8,.2,1), filter 160ms ease, opacity 120ms ease;
    will-change: transform;
}

.piece:active { cursor: grabbing; }
.square:hover .piece { transform: translateZ(0) scale(1.045); }
.square.is-selected .piece { transform: translateZ(0) scale(1.07); }

.piece--white {
    color: #fbfafc;
    filter: drop-shadow(0 2px 0 rgba(58, 54, 64, .32)) drop-shadow(0 8px 8px rgba(20, 18, 23, .24));
    text-shadow: 0 0 1px #59545f;
}

.piece--black {
    color: #202026;
    filter: drop-shadow(0 2px 0 rgba(255, 255, 255, .14)) drop-shadow(0 8px 8px rgba(16, 14, 18, .25));
    text-shadow: 0 0 1px rgba(255, 255, 255, .25);
}

.piece.is-dragging {
    opacity: 0;
}

.drag-piece,
.move-ghost {
    position: fixed;
    z-index: 999;
    display: grid;
    place-items: center;
    pointer-events: none;
    font-family: Georgia, "Times New Roman", "DejaVu Serif", serif;
    line-height: 1;
    will-change: transform;
}

.drag-piece {
    filter: drop-shadow(0 18px 18px rgba(0, 0, 0, .35));
    transform: translate(-50%, -50%) scale(1.08);
}

.move-ghost {
    margin: 0;
}

.thinking-overlay {
    position: absolute;
    inset: 8px;
    z-index: 10;
    display: grid;
    place-items: center;
    border-radius: var(--board-radius);
    background: rgba(10, 9, 13, 0);
    opacity: 0;
    pointer-events: none;
    transition: opacity 250ms ease, background 250ms ease;
}

.board-frame.is-thinking .thinking-overlay {
    background: rgba(10, 9, 13, 0.06);
    opacity: 1;
}

.thinking-orbit {
    position: relative;
    width: 44px;
    height: 44px;
    opacity: 0;
    transform: scale(0.8);
    transition: opacity 220ms ease, transform 320ms cubic-bezier(.2,.8,.2,1);
}

.board-frame.is-thinking .thinking-orbit {
    opacity: 1;
    transform: scale(1);
}

.thinking-orbit span {
    position: absolute;
    inset: 0;
    border: 1px solid rgba(185, 167, 255, 0.32);
    border-top-color: var(--accent);
    border-radius: 50%;
    animation: ai-orbit 1.2s linear infinite;
}

.thinking-orbit span:nth-child(2) {
    inset: 7px;
    animation-duration: 1.8s;
    animation-direction: reverse;
}

.thinking-orbit span:nth-child(3) {
    inset: 15px;
    border-style: dashed;
    animation-duration: .85s;
}

.game-panel {
    display: flex;
    min-height: 580px;
    flex-direction: column;
    padding: 26px;
    border: 1px solid var(--border);
    border-radius: 24px;
    background: var(--surface);
    box-shadow: 0 30px 80px rgba(0, 0, 0, .25), inset 0 1px 0 rgba(255,255,255,.035);
    backdrop-filter: blur(22px);
    animation: panel-in 880ms 90ms cubic-bezier(.16,.85,.26,1) both;
}


.eyebrow,
.section-heading {
    color: var(--muted-2);
    font-size: 9px;
    font-weight: 800;
    letter-spacing: 0.15em;
}

.status-card {
    padding-bottom: 25px;
}

.status-card h1 {
    margin: 11px 0 8px;
    font-family: "Segoe UI Variable Display", Inter, "Segoe UI", system-ui, sans-serif;
    font-size: clamp(23px, 2vw, 30px);
    font-weight: 600;
    letter-spacing: -0.035em;
}

.status-card p {
    min-height: 35px;
    margin: 0;
    color: var(--muted);
    font-size: 12px;
    line-height: 1.55;
}

.status-line {
    height: 1px;
    margin-top: 23px;
    overflow: hidden;
    background: var(--border);
}

.status-line span {
    display: block;
    width: 38%;
    height: 100%;
    background: linear-gradient(90deg, transparent, var(--accent), transparent);
    transform: translateX(-100%);
    transition: transform 500ms cubic-bezier(.2,.8,.2,1);
}

.status-card.is-updated .status-line span {
    animation: status-scan 780ms ease;
}

.panel-section {
    padding: 21px 0;
    border-top: 1px solid var(--border);
}

.section-heading {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 13px;
}

.section-heading span:last-child { color: #5f5f69; }

.segmented {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 4px;
    padding: 4px;
    border: 1px solid var(--border);
    border-radius: 13px;
    background: rgba(0,0,0,.16);
}

.segmented button {
    min-height: 36px;
    border-radius: 9px;
    background: transparent;
    color: var(--muted);
    font-size: 10px;
    font-weight: 700;
    transition: color 200ms ease, background 220ms ease, box-shadow 220ms ease, transform 200ms ease;
}

.segmented button:hover { color: var(--text); }
.segmented button:active { transform: scale(.98); }
.segmented button.is-active {
    background: rgba(255,255,255,.075);
    color: var(--text);
    box-shadow: inset 0 1px 0 rgba(255,255,255,.06), 0 4px 12px rgba(0,0,0,.12);
}

.microcopy {
    margin: 9px 2px 0;
    color: var(--muted-2);
    font-size: 9px;
}

.panel-section--moves {
    display: flex;
    min-height: 210px;
    flex: 1;
    flex-direction: column;
    overflow: hidden;
}

.move-list {
    display: grid;
    max-height: 250px;
    gap: 2px;
    overflow-y: auto;
    padding-right: 5px;
    overscroll-behavior: contain;
    scrollbar-color: rgba(255,255,255,.12) transparent;
    scrollbar-width: thin;
}

.move-list::-webkit-scrollbar { width: 4px; }
.move-list::-webkit-scrollbar-thumb { border-radius: 10px; background: rgba(255,255,255,.12); }

.empty-history {
    display: grid;
    min-height: 130px;
    place-items: center;
    color: var(--muted-2);
    font-size: 10px;
}

.move-row {
    display: grid;
    grid-template-columns: 28px 1fr 1fr;
    align-items: center;
    min-height: 36px;
    padding: 0 9px;
    border-radius: 9px;
    color: #b8b8c0;
    font-size: 11px;
    animation: move-row-in 360ms cubic-bezier(.2,.8,.2,1) both;
}

.move-row:hover { background: rgba(255,255,255,.035); }
.move-number { color: #55555f; font-size: 9px; }
.move-san { font-weight: 600; }
.move-san.is-current { color: #d7ceff; }

.panel-actions {
    display: flex;
    gap: 8px;
    padding-top: 20px;
    border-top: 1px solid var(--border);
}

.modal-backdrop {
    position: fixed;
    inset: 0;
    z-index: 1200;
    display: grid;
    place-items: center;
    padding: 20px;
    background: rgba(5, 5, 7, .68);
    backdrop-filter: blur(14px);
    animation: backdrop-in 260ms ease both;
}

.modal-backdrop[hidden] { display: none; }

.modal {
    width: min(390px, 100%);
    padding: 34px;
    border: 1px solid var(--border-strong);
    border-radius: 25px;
    background: linear-gradient(160deg, rgba(28, 27, 34, .98), rgba(13, 13, 17, .98));
    box-shadow: 0 40px 100px rgba(0,0,0,.55), inset 0 1px 0 rgba(255,255,255,.06);
    text-align: center;
    animation: modal-in 420ms cubic-bezier(.16,.85,.26,1) both;
}

.modal-symbol {
    display: grid;
    width: 74px;
    height: 74px;
    place-items: center;
    margin: 0 auto 25px;
    border: 1px solid rgba(185, 167, 255, .18);
    border-radius: 23px;
    background: radial-gradient(circle, rgba(167, 142, 255, .18), rgba(255,255,255,.025));
    color: #e3ddff;
    font-family: Georgia, serif;
    font-size: 41px;
    box-shadow: 0 0 45px rgba(126,102,255,.12);
}

.modal h2 {
    margin: 10px 0 9px;
    font-family: "Segoe UI Variable Display", Inter, "Segoe UI", system-ui, sans-serif;
    font-size: 28px;
    letter-spacing: -.035em;
}

.modal p {
    margin: 0 0 25px;
    color: var(--muted);
    font-size: 12px;
    line-height: 1.6;
}

.text-button {
    margin-top: 15px;
    background: transparent;
    color: var(--muted);
    font-size: 10px;
    font-weight: 700;
}

.text-button:hover { color: var(--text); }

.modal--promotion { width: min(430px, 100%); }

.promotion-grid {
    display: grid;
    grid-template-columns: repeat(4, 1fr);
    gap: 8px;
    margin-top: 25px;
}

.promotion-button {
    display: grid;
    aspect-ratio: 1;
    place-items: center;
    border: 1px solid var(--border);
    border-radius: 16px;
    background: rgba(255,255,255,.035);
    color: #fff;
    font-family: Georgia, serif;
    font-size: 47px;
    transition: transform 220ms cubic-bezier(.2,.8,.2,1), background 220ms ease, border-color 220ms ease;
}

.promotion-button:hover {
    border-color: rgba(185,167,255,.28);
    background: var(--accent-soft);
    transform: translateY(-3px) scale(1.02);
}

@keyframes stage-in { from { opacity: 0; transform: translateY(16px) scale(.985); } to { opacity: 1; transform: translateY(0) scale(1); } }
@keyframes panel-in { from { opacity: 0; transform: translateX(18px); } to { opacity: 1; transform: translateX(0); } }

@keyframes ambient-drift {
    from { transform: translate3d(0, 0, 0) scale(1); }
    to { transform: translate3d(7vw, 4vh, 0) scale(1.12); }
}

@keyframes ai-orbit { to { transform: rotate(360deg); } }
@keyframes turn-pulse { 50% { opacity: .45; transform: scale(.75); } }
@keyframes thinking-glow { to { transform: scale(1.12); filter: blur(70px); } }
@keyframes check-pulse { to { opacity: .7; } }
@keyframes legal-dot { to { transform: scale(1); } }
@keyframes legal-ring { to { transform: scale(1); } }
@keyframes status-scan { from { transform: translateX(-110%); } to { transform: translateX(310%); } }
@keyframes move-row-in { from { opacity: 0; transform: translateY(8px); } to { opacity: 1; transform: translateY(0); } }
@keyframes backdrop-in { from { opacity: 0; } to { opacity: 1; } }
@keyframes modal-in { from { opacity: 0; transform: translateY(18px) scale(.96); } to { opacity: 1; transform: translateY(0) scale(1); } }

@media (max-width: 1100px) {
    :root { --board-size: min(64vh, 620px, 61vw); }
    .game-layout { grid-template-columns: minmax(0, var(--board-size)) 320px; gap: 34px; }
    .game-panel { padding: 22px; }
}

@media (max-width: 860px) {
    :root { --board-size: min(calc(100vw - 36px), 690px); }

    .app-shell {
        width: min(690px, calc(100% - 28px));
        padding-top: 14px;
    }

    .topbar { margin-bottom: 20px; }
    .game-layout { grid-template-columns: 1fr; gap: 30px; }
    .game-panel { min-height: 0; }
    .panel-section--moves { min-height: 180px; }
    .move-list { max-height: 210px; }
    .piece { font-size: clamp(30px, calc(var(--board-size) / 10.4), 65px); }
}

@media (max-width: 520px) {
    .app-shell { width: calc(100% - 20px); }
    .brand-copy small { display: none; }
    .topbar-actions .button--ghost { min-width: 42px; width: 42px; padding: 0; font-size: 0; }
    .topbar-actions .button--ghost::before { content: "+"; font-size: 22px; font-weight: 400; }
    .player-strip { grid-template-columns: 39px minmax(0, 1fr); }
    .avatar { width: 39px; height: 39px; border-radius: 12px; }
    .captured { grid-column: 2; justify-content: flex-start; min-height: 12px; padding: 0; font-size: 14px; }
    .player-strip { gap: 9px; }
    .player-strip--opponent { margin-bottom: 8px; }
    .player-strip--self { margin-top: 8px; }
    .board-frame { padding: 5px; border-radius: 18px; }
    .board { border-radius: 13px; }
    .piece { width: 94%; height: 94%; font-size: clamp(28px, 11.7vw, 58px); }
    .game-panel { padding: 20px; border-radius: 20px; }
    .status-card h1 { font-size: 25px; }
    .panel-actions { flex-direction: column; }
    .button--secondary, .button--danger { width: 100%; }
    .promotion-grid { grid-template-columns: repeat(2, 1fr); }
}

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

/* =========================================================
   PRISM ÉCHECS 2.0 · hub membre, XP et multijoueur
   ========================================================= */
[hidden] { display: none !important; }

.member-pill {
    display: inline-grid;
    grid-template-columns: 34px auto;
    align-items: center;
    gap: 9px;
    min-height: 42px;
    padding: 4px 12px 4px 5px;
    border: 1px solid var(--border);
    border-radius: 14px;
    background: rgba(255,255,255,.035);
    color: var(--text);
    text-decoration: none;
    transition: transform 220ms cubic-bezier(.2,.8,.2,1), background 220ms ease, border-color 220ms ease;
}
.member-pill:hover { transform: translateY(-1px); background: rgba(255,255,255,.065); border-color: var(--border-strong); }
.member-pill__avatar {
    display: grid;
    width: 32px;
    height: 32px;
    place-items: center;
    overflow: hidden;
    border-radius: 10px;
    background: linear-gradient(145deg, #ece8f3, #aaa6b2);
    color: #17131f;
    font-size: 11px;
    font-weight: 800;
}
.member-pill__avatar img, .avatar img { width: 100%; height: 100%; object-fit: cover; }
.member-pill > span:last-child { display: grid; gap: 1px; }
.member-pill strong { max-width: 130px; overflow: hidden; font-size: 11px; text-overflow: ellipsis; white-space: nowrap; }
.member-pill small { color: var(--muted-2); font-size: 8px; font-weight: 700; letter-spacing: .04em; }

.boot-view {
    display: grid;
    min-height: calc(100vh - 150px);
    place-items: center;
    align-content: center;
    gap: 24px;
    color: var(--muted);
    font-size: 11px;
    letter-spacing: .04em;
}
.boot-orbit, .waiting-orbit { position: relative; width: 64px; height: 64px; }
.boot-orbit span, .waiting-orbit span {
    position: absolute;
    inset: 0;
    border: 1px solid rgba(185,167,255,.22);
    border-top-color: var(--accent);
    border-radius: 50%;
    animation: ai-orbit 1.8s linear infinite;
}
.boot-orbit span:nth-child(2), .waiting-orbit span:nth-child(2) { inset: 9px; animation-duration: 2.5s; animation-direction: reverse; }
.boot-orbit span:nth-child(3), .waiting-orbit span:nth-child(3) { inset: 21px; border-style: dashed; animation-duration: 1.1s; }

.menu-view { width: min(1160px, 100%); margin: 0 auto; animation: stage-in 700ms cubic-bezier(.16,.85,.26,1) both; }
.menu-hero { max-width: 720px; margin: 8vh auto 42px; text-align: center; }
.menu-hero h1 {
    margin: 14px 0 14px;
    font-family: "Segoe UI Variable Display", Inter, "Segoe UI", system-ui, sans-serif;
    font-size: clamp(45px, 7vw, 88px);
    font-weight: 560;
    letter-spacing: -.065em;
    line-height: .95;
}
.menu-hero h1 span { color: #b9a7ff; text-shadow: 0 0 48px rgba(126,102,255,.22); }
.menu-hero p { max-width: 560px; margin: 0 auto; color: var(--muted); font-size: 13px; line-height: 1.65; }

.player-progress-card {
    display: grid;
    grid-template-columns: minmax(0,1fr) auto;
    gap: 14px 24px;
    align-items: center;
    width: min(750px, 100%);
    margin: 0 auto 28px;
    padding: 17px 19px;
    border: 1px solid var(--border);
    border-radius: 20px;
    background: rgba(255,255,255,.028);
    box-shadow: inset 0 1px 0 rgba(255,255,255,.035);
    backdrop-filter: blur(16px);
}
.progress-identity { display: flex; align-items: center; gap: 12px; min-width: 0; }
.progress-avatar { flex: 0 0 auto; }
.progress-identity > div:last-child { display: grid; gap: 3px; min-width: 0; }
.progress-identity strong { overflow: hidden; font-size: 13px; text-overflow: ellipsis; white-space: nowrap; }
.progress-identity span, .progress-copy span { color: var(--muted); font-size: 9px; }
.progress-copy { display: grid; justify-items: end; gap: 3px; }
.progress-copy strong { font-size: 12px; }
.xp-track { grid-column: 1 / -1; height: 3px; overflow: hidden; border-radius: 99px; background: rgba(255,255,255,.07); }
.xp-track span { display: block; width: 0; height: 100%; border-radius: inherit; background: linear-gradient(90deg,#8169ff,#c4b5ff); box-shadow: 0 0 15px rgba(185,167,255,.45); transition: width 800ms cubic-bezier(.2,.8,.2,1); }

.mode-grid { display: grid; grid-template-columns: repeat(2,minmax(0,1fr)); gap: 18px; padding-bottom: 42px; }
.mode-card {
    position: relative;
    min-height: 515px;
    overflow: hidden;
    padding: clamp(28px,4vw,44px);
    border: 1px solid var(--border);
    border-radius: 28px;
    background: linear-gradient(150deg, rgba(23,23,29,.86), rgba(13,13,17,.84));
    box-shadow: 0 30px 80px rgba(0,0,0,.25), inset 0 1px 0 rgba(255,255,255,.04);
    backdrop-filter: blur(24px);
    isolation: isolate;
    transition: transform 350ms cubic-bezier(.2,.8,.2,1), border-color 300ms ease;
}
.mode-card:hover { transform: translateY(-4px); border-color: rgba(185,167,255,.16); }
.mode-card__halo { position: absolute; z-index: -1; width: 300px; height: 300px; right: -130px; top: -150px; border-radius: 50%; background: rgba(126,102,255,.16); filter: blur(70px); transition: transform 700ms ease; }
.mode-card--multi .mode-card__halo { background: rgba(172,87,190,.12); }
.mode-card:hover .mode-card__halo { transform: scale(1.2) translate(-10px,15px); }
.mode-icon {
    display: grid;
    width: 76px;
    height: 76px;
    place-items: center;
    margin-bottom: 32px;
    border: 1px solid rgba(185,167,255,.16);
    border-radius: 23px;
    background: radial-gradient(circle,rgba(167,142,255,.15),rgba(255,255,255,.02));
    color: #eeeaff;
    font-family: Georgia, serif;
    font-size: 43px;
    box-shadow: 0 0 45px rgba(126,102,255,.08);
}
.mode-card h2 { margin: 10px 0 11px; font-size: clamp(30px,4vw,45px); font-weight: 560; letter-spacing: -.05em; }
.mode-card > p:not(.mode-note) { min-height: 62px; margin: 0 0 25px; color: var(--muted); font-size: 12px; line-height: 1.65; }
.mode-action { min-height: 48px; margin-top: 19px; }
.mode-note { margin: 14px 0 0; color: var(--muted-2); font-size: 9px; text-align: center; }
.mode-note strong { color: #cfc5ff; }

.difficulty-cards { display: grid; grid-template-columns: repeat(3,1fr); gap: 7px; }
.difficulty-cards button {
    display: grid;
    min-height: 75px;
    place-content: center;
    gap: 5px;
    border: 1px solid var(--border);
    border-radius: 15px;
    background: rgba(255,255,255,.025);
    color: var(--muted);
    cursor: pointer;
    transition: transform 220ms cubic-bezier(.2,.8,.2,1), border-color 220ms ease, background 220ms ease, color 220ms ease;
}
.difficulty-cards button:hover { transform: translateY(-2px); color: var(--text); background: rgba(255,255,255,.05); }
.difficulty-cards button.is-active { border-color: rgba(185,167,255,.27); background: var(--accent-soft); color: var(--text); box-shadow: inset 0 1px 0 rgba(255,255,255,.04); }
.difficulty-cards span { font-size: 10px; font-weight: 700; }
.difficulty-cards strong { color: #cfc5ff; font-size: 8px; letter-spacing: .04em; }

.mode-icon--network { position: relative; font-family: inherit; }
.mode-icon--network i { position: absolute; width: 8px; height: 8px; border-radius: 50%; background: #c7b9ff; box-shadow: 0 0 15px rgba(185,167,255,.55); }
.mode-icon--network i:nth-child(1) { top: 22px; left: 20px; }
.mode-icon--network i:nth-child(2) { top: 23px; right: 19px; }
.mode-icon--network i:nth-child(3) { bottom: 19px; left: 34px; }
.mode-icon--network::before, .mode-icon--network::after { content:""; position:absolute; width: 28px; height: 1px; background: rgba(185,167,255,.45); transform-origin: left center; }
.mode-icon--network::before { left: 26px; top: 27px; transform: rotate(1deg); }
.mode-icon--network::after { left: 25px; top: 30px; transform: rotate(50deg); }
.mode-icon--network i:nth-child(2)::after { content:""; position:absolute; width: 29px; height:1px; background:rgba(185,167,255,.45); transform:rotate(127deg); transform-origin:left center; }
.join-divider { display: flex; align-items: center; gap: 12px; margin: 22px 0 12px; color: var(--muted-2); font-size: 8px; font-weight: 800; letter-spacing: .14em; }
.join-divider::before,.join-divider::after { content:""; flex:1; height:1px; background:var(--border); }
.join-form { display: grid; grid-template-columns: 1fr auto; gap: 8px; }
.join-form input {
    min-width: 0;
    height: 46px;
    padding: 0 17px;
    border: 1px solid var(--border);
    border-radius: 13px;
    outline: 0;
    background: rgba(0,0,0,.18);
    color: var(--text);
    font: 700 17px/1 "Segoe UI Variable Display",Inter,sans-serif;
    letter-spacing: .25em;
    text-align: center;
    text-transform: uppercase;
    transition: border-color 220ms ease, box-shadow 220ms ease;
}
.join-form input::placeholder { color: #4e4e58; }
.join-form input:focus { border-color: rgba(185,167,255,.35); box-shadow: 0 0 0 4px rgba(126,102,255,.08); }

.game-view { animation: stage-in 600ms cubic-bezier(.16,.85,.26,1) both; }
.game-meta-section { display: grid; gap: 10px; }
.game-meta-section .section-heading { margin-bottom: 3px; }
.game-meta-row { display: flex; align-items: center; justify-content: space-between; min-height: 25px; color: var(--muted); font-size: 10px; }
.game-meta-row strong { color: #c9c9d0; font-size: 10px; }
.avatar--member { color: #17131f; background: linear-gradient(145deg,#ece8f3,#aaa6b2); font-size: 14px; font-weight: 800; }

.waiting-modal { width: min(440px,100%); }
.waiting-orbit { margin: 0 auto 27px; }
.waiting-orbit i { position:absolute; inset:27px; border-radius:50%; background:var(--accent); box-shadow:0 0 20px var(--accent); animation: turn-pulse 1.5s ease-in-out infinite; }
.party-code {
    display: grid;
    width: 100%;
    min-height: 94px;
    place-items: center;
    gap: 3px;
    margin-top: 5px;
    border: 1px solid rgba(185,167,255,.18);
    border-radius: 19px;
    background: rgba(126,102,255,.08);
    color: var(--text);
    cursor: pointer;
    transition: transform 220ms cubic-bezier(.2,.8,.2,1), background 220ms ease, border-color 220ms ease;
}
.party-code:hover { transform: translateY(-2px); background: rgba(126,102,255,.14); border-color: rgba(185,167,255,.3); }
.party-code span { font-size: 35px; font-weight: 650; letter-spacing: .22em; text-indent: .22em; }
.party-code small { color: var(--muted-2); font-size: 7px; font-weight: 800; letter-spacing: .15em; }
.xp-award { display: grid; gap: 6px; margin: -7px 0 24px; padding: 15px; border: 1px solid rgba(185,167,255,.16); border-radius: 15px; background: var(--accent-soft); }
.xp-award span { color: var(--muted); font-size: 8px; font-weight: 800; letter-spacing: .13em; }
.xp-award strong { color: #ddd5ff; font-size: 18px; }

.toast {
    position: fixed;
    z-index: 1600;
    left: 50%;
    bottom: max(24px,env(safe-area-inset-bottom));
    max-width: min(420px,calc(100% - 32px));
    padding: 12px 17px;
    border: 1px solid var(--border-strong);
    border-radius: 13px;
    background: rgba(25,24,30,.96);
    box-shadow: 0 20px 50px rgba(0,0,0,.35);
    color: var(--text);
    font-size: 10px;
    transform: translateX(-50%);
    animation: toast-in 320ms cubic-bezier(.16,.85,.26,1) both;
}
.toast.is-error { border-color: rgba(255,111,125,.25); color:#ffb0b8; }
@keyframes toast-in { from { opacity:0; transform:translate(-50%,12px) scale(.97); } to { opacity:1; transform:translate(-50%,0) scale(1); } }

@media (max-width: 860px) {
    .menu-hero { margin-top: 5vh; }
    .mode-grid { grid-template-columns: 1fr; }
    .mode-card { min-height: 0; }
    .mode-card > p:not(.mode-note) { min-height: 0; }
    .game-view .game-layout { align-items: start; }
}

@media (max-width: 620px) {
    .topbar { align-items: flex-start; }
    .member-pill { max-width: 145px; padding-right: 7px; }
    .member-pill strong { max-width: 76px; }
    .menu-hero { margin-bottom: 28px; }
    .menu-hero h1 { font-size: clamp(43px,15vw,66px); }
    .player-progress-card { grid-template-columns: 1fr; gap: 12px; }
    .progress-copy { justify-items: start; }
    .xp-track { grid-column: 1; }
    .mode-card { padding: 27px 21px; border-radius: 23px; }
    .difficulty-cards { gap: 5px; }
    .difficulty-cards button { min-height: 70px; }
    .join-form { grid-template-columns: 1fr; }
    .join-form .button { width: 100%; }
    .party-code span { font-size: 30px; }
}

@media (max-width: 520px) {
    .topbar-actions .button--ghost { min-width: auto; width: auto; padding: 0 13px; font-size: 11px; }
    .topbar-actions .button--ghost::before { content: none; }
    .member-pill { display: none !important; }
    .menu-hero h1 { letter-spacing: -.055em; }
}
