* {
    box-sizing: border-box;
}

html,
body {
    margin: 0;
    padding: 0;
    min-height: 100%;

    -webkit-text-size-adjust: 100%;
    overscroll-behavior: none;
}

body {
    font-family:
        -apple-system,
        BlinkMacSystemFont,
        "Segoe UI",
        sans-serif;

    color: #fff;

    background:
        #050b16;

    overflow-x: hidden;

    user-select: none;
    -webkit-user-select: none;
    -webkit-touch-callout: none;

    touch-action: manipulation;
    overscroll-behavior: none;
}


/* =========================================================
   CHESS BACKGROUND
========================================================= */

.chess-background {
    position: fixed;

    inset: 0;

    z-index: -3;

    background-image:
        url("../../assets/chess-bg.png");

    background-size: cover;

    background-position: center;

    background-repeat: no-repeat;

    transform: scale(1.02);
}


.background-overlay {
    position: fixed;

    inset: 0;

    z-index: -2;

    pointer-events: none;

    background:
        linear-gradient(
            180deg,
            rgba(3,8,18,.38) 0%,
            rgba(4,10,23,.58) 48%,
            rgba(2,6,15,.86) 100%
        );

    backdrop-filter:
        blur(1px);
}


.background-overlay::after {
    content: "";

    position: absolute;

    inset: 0;

    background:
        radial-gradient(
            circle at center,
            transparent 15%,
            rgba(0,0,0,.32) 100%
        );
}


/* =========================================================
   GLOBAL
========================================================= */

button,
input,
select {
    font: inherit;
}
input,
select,
textarea {
    font-size: 16px;
}

button {
    cursor: pointer;

    -webkit-tap-highlight-color:
        transparent;
}

button:disabled {
    cursor:
        not-allowed;
}

.hidden {
    display:
        none !important;
}


/* =========================================================
   PAGE
========================================================= */

.page {
    width: 100%;

    min-height: 100vh;

    padding:
        14px
        18px
        36px;

    display: flex;

    flex-direction: column;

    align-items: center;
}


/* =========================================================
   TOPBAR
========================================================= */

.topbar {
    width:
        min(100%, 1240px);

    display: grid;

    grid-template-columns:
        1fr
        auto
        1fr;

    align-items: center;

    gap: 14px;

    margin-bottom: 18px;
}

.brand {
    display: flex;

    align-items: center;

    justify-content: center;

    gap: 8px;

    font-size: 22px;

    font-weight: 900;

    letter-spacing: -.3px;

    text-shadow:
        0 3px 15px
        rgba(0,0,0,.6);
}

.brand-icon {
    color: #f4d28a;

    font-size: 24px;

    text-shadow:
        0 0 15px
        rgba(245,190,80,.35);
}

.ghost-btn {
    border:
        1px solid
        rgba(255,255,255,.11);

    border-radius: 11px;

    padding:
        8px 12px;

    color: rgba(255,255,255,.88);

    background:
        rgba(7,14,29,.48);

    backdrop-filter:
        blur(12px);

    box-shadow:
        0 8px 25px
        rgba(0,0,0,.16);

    font-size: 12px;

    font-weight: 700;

    transition:
        .18s;
}

.topbar .ghost-btn:last-child {
    justify-self:
        end;
}

.ghost-btn:hover {
    background:
        rgba(40,75,125,.55);

    border-color:
        rgba(147,197,253,.3);

    transform:
        translateY(-1px);
}

.ghost-btn:active {
    transform:
        scale(.97);
}


/* =========================================================
   BUTTONS
========================================================= */

.primary-btn,
.action-btn {
    border: 0;

    border-radius: 12px;

    color: #fff;

    transition:
        transform .12s,
        background .12s,
        filter .12s,
        box-shadow .12s;
}

.primary-btn:active,
.action-btn:active {
    transform:
        scale(.97);
}

.primary-btn {
    width: 100%;

    padding:
        14px 16px;

    background:
        linear-gradient(
            135deg,
            #3b82f6,
            #2563eb
        );

    box-shadow:
        0 10px 28px
        rgba(37,99,235,.24);

    font-weight: 850;
}

.primary-btn:hover {
    filter:
        brightness(1.1);

    box-shadow:
        0 12px 32px
        rgba(37,99,235,.34);
}

.action-btn {
    padding:
        11px 14px;

    background:
        rgba(255,255,255,.075);

    border:
        1px solid
        rgba(255,255,255,.08);

    font-weight: 650;
}

.action-btn:hover {
    background:
        rgba(255,255,255,.14);
}

.action-btn.danger {
    background:
        rgba(185,28,28,.7);

    border-color:
        rgba(248,113,113,.2);
}

.action-btn.danger:hover {
    background:
        rgba(220,38,38,.9);
}

.primary-btn:disabled,
.action-btn:disabled {
    opacity: .48;

    filter:
        none;

    box-shadow:
        none;
}


/* =========================================================
   SETUP
========================================================= */

.setup {
    width: 100%;

    display: flex;

    justify-content: center;

    padding:
        8px 0 30px;
}

.setup-card {
    position: relative;

    width:
        min(100%, 560px);

    padding:
        30px;

    border-radius:
        26px;

    background:
        linear-gradient(
            145deg,
            rgba(18,34,61,.84),
            rgba(7,15,30,.78)
        );

    border:
        1px solid
        rgba(255,255,255,.14);

    backdrop-filter:
        blur(24px);

    box-shadow:
        0 35px 100px
        rgba(0,0,0,.5),

        inset 0 1px 0
        rgba(255,255,255,.08);

    text-align: center;

    overflow: hidden;
}

.setup-card::before {
    content: "";

    position: absolute;

    left: 10%;

    right: 10%;

    top: 0;

    height: 1px;

    background:
        linear-gradient(
            90deg,
            transparent,
            rgba(147,197,253,.75),
            transparent
        );
}

.setup-card::after {
    content: "";

    position: absolute;

    width: 180px;

    height: 180px;

    right: -100px;

    top: -100px;

    border-radius: 50%;

    background:
        rgba(37,99,235,.18);

    filter:
        blur(35px);

    pointer-events: none;
}


/* =========================================================
   CHESS LOGO
========================================================= */

.chess-logo {
    width: 78px;

    height: 78px;

    margin:
        0 auto 10px;

    display: flex;

    align-items: center;

    justify-content: center;

    border-radius: 23px;

    background:
        linear-gradient(
            145deg,
            rgba(255,255,255,.17),
            rgba(255,255,255,.055)
        );

    border:
        1px solid
        rgba(255,255,255,.12);

    box-shadow:
        0 14px 35px
        rgba(0,0,0,.25),

        inset 0 1px 0
        rgba(255,255,255,.12);
}

.chess-logo span {
    color: #fff;

    font-size: 55px;

    line-height: 1;

    transform:
        translateY(-2px);

    text-shadow:
        0 4px 0 #111,
        0 7px 15px
        rgba(0,0,0,.6);
}

.eyebrow {
    margin-top: 2px;

    color:
        rgba(147,197,253,.78);

    font-size: 10px;

    font-weight: 800;

    letter-spacing: 3px;
}

.setup-card h1 {
    position: relative;

    margin:
        7px 0 0;

    font-size:
        clamp(31px,8vw,44px);

    letter-spacing:
        -.8px;
}

.muted {
    margin:
        7px 0 23px;

    color:
        rgba(255,255,255,.62);

    line-height:
        1.5;

    font-size: 14px;
}


/* =========================================================
   MODE
========================================================= */

.mode-row {
    display: grid;

    grid-template-columns:
        repeat(3,1fr);

    gap: 8px;

    margin-bottom: 18px;
}

.mode-btn {
    min-height: 58px;

    display: flex;

    flex-direction: column;

    align-items: center;

    justify-content: center;

    gap: 3px;

    border:
        1px solid
        rgba(255,255,255,.1);

    border-radius: 15px;

    background:
        rgba(255,255,255,.055);

    color: #fff;

    padding: 8px;

    font-size: 12px;

    font-weight: 750;

    transition:
        .18s;
}

.mode-icon {
    font-size: 17px;
}

.mode-btn:hover {
    background:
        rgba(255,255,255,.1);

    border-color:
        rgba(147,197,253,.25);

    transform:
        translateY(-1px);
}

.mode-btn.active {
    background:
        linear-gradient(
            135deg,
            #2877ef,
            #1e55c9
        );

    border-color:
        rgba(147,197,253,.7);

    box-shadow:
        0 8px 25px
        rgba(37,99,235,.3);
}


/* =========================================================
   FORM
========================================================= */

.field {
    display: flex;

    flex-direction: column;

    gap: 7px;

    margin-bottom: 14px;

    text-align: left;
}

.field label {
    display: flex;

    align-items: center;

    justify-content: space-between;

    padding-left: 2px;

    color:
        rgba(255,255,255,.68);

    font-size: 12px;

    font-weight: 650;
}

.field select,
.room-input {
    width: 100%;

    border:
        1px solid
        rgba(255,255,255,.13);

    border-radius: 12px;

    padding:
        12px 13px;

    outline: none;

    color: #fff;

    background:
        rgba(3,9,20,.72);

    box-shadow:
        inset 0 1px 0
        rgba(255,255,255,.04);
}

.field select:focus,
.room-input:focus {
    border-color:
        #60a5fa;

    box-shadow:
        0 0 0 3px
        rgba(59,130,246,.14);
}

.field select option {
    color: #111;

    background: #fff;
}


/* =========================================================
   ONLINE PANEL
========================================================= */

.online-panel {
    margin:
        13px 0 16px;

    padding:
        17px;

    border-radius: 18px;

    background:
        linear-gradient(
            145deg,
            rgba(4,13,29,.72),
            rgba(9,20,39,.6)
        );

    border:
        1px solid
        rgba(96,165,250,.17);

    box-shadow:
        inset 0 1px 0
        rgba(255,255,255,.05);

    text-align: left;
}

.online-header {
    display: flex;

    align-items: center;

    gap: 11px;

    margin-bottom: 14px;
}

.online-header-icon {
    width: 42px;

    height: 42px;

    display: flex;

    align-items: center;

    justify-content: center;

    border-radius: 12px;

    background:
        rgba(37,99,235,.18);

    border:
        1px solid
        rgba(96,165,250,.18);

    font-size: 20px;
}

.online-header strong {
    display: block;

    font-size: 16px;

    font-weight: 850;
}

.online-header small {
    display: block;

    margin-top: 2px;

    color:
        rgba(255,255,255,.5);

    font-size: 11px;
}


/* =========================================================
   RANDOM MATCH
========================================================= */

.random-match-btn {
    width: 100%;

    min-height: 72px;

    display: flex;

    align-items: center;

    gap: 12px;

    padding:
        11px 13px;

    border:
        1px solid
        rgba(96,165,250,.34);

    border-radius: 15px;

    color: #fff;

    background:
        linear-gradient(
            135deg,
            rgba(37,99,235,.32),
            rgba(59,130,246,.09)
        );

    box-shadow:
        0 9px 25px
        rgba(37,99,235,.1);

    text-align: left;

    transition:
        transform .15s,
        background .15s,
        border-color .15s,
        box-shadow .15s;
}

.random-match-btn:hover {
    background:
        linear-gradient(
            135deg,
            rgba(37,99,235,.46),
            rgba(59,130,246,.16)
        );

    border-color:
        rgba(147,197,253,.58);

    box-shadow:
        0 12px 32px
        rgba(37,99,235,.2);

    transform:
        translateY(-1px);
}

.random-match-btn:active {
    transform:
        scale(.985);
}

.random-match-icon {
    width: 44px;

    height: 44px;

    flex:
        0 0 44px;

    display: flex;

    align-items: center;

    justify-content: center;

    border-radius: 13px;

    background:
        rgba(255,255,255,.1);

    font-size: 24px;
}

.random-match-content {
    min-width: 0;

    flex: 1;
}

.random-match-content strong {
    display: block;

    font-size: 14px;

    font-weight: 850;
}

.random-match-content small {
    display: block;

    margin-top: 3px;

    color:
        rgba(255,255,255,.56);

    font-size: 11px;

    line-height: 1.3;
}

.random-match-arrow {
    color:
        rgba(255,255,255,.52);

    font-size: 28px;

    line-height: 1;
}


/* =========================================================
   MATCHMAKING STATUS
========================================================= */

.matchmaking-status {
    min-height: 42px;

    margin-top: 9px;

    padding:
        10px 12px;

    display: flex;

    align-items: center;

    justify-content: center;

    gap: 9px;

    border-radius: 11px;

    background:
        rgba(37,99,235,.11);

    border:
        1px solid
        rgba(96,165,250,.15);

    color:
        rgba(255,255,255,.78);

    font-size: 12px;

    text-align: center;
}

.matchmaking-spinner {
    width: 15px;

    height: 15px;

    flex:
        0 0 15px;

    border-radius: 50%;

    border:
        2px solid
        rgba(255,255,255,.18);

    border-top-color:
        #60a5fa;

    animation:
        matchmakingSpin .8s linear infinite;
}

@keyframes matchmakingSpin {

    to {
        transform:
            rotate(360deg);
    }

}


/* =========================================================
   CANCEL
========================================================= */

.cancel-match-btn {
    width: 100%;

    margin-top: 8px;

    padding:
        10px;

    border:
        1px solid
        rgba(239,68,68,.25);

    border-radius: 11px;

    background:
        rgba(220,38,38,.1);

    color:
        #fca5a5;

    font-size: 12px;

    font-weight: 750;

    cursor: pointer;

    transition:
        .15s;
}

.cancel-match-btn:hover {
    background:
        rgba(220,38,38,.2);

    border-color:
        rgba(239,68,68,.4);
}


/* =========================================================
   DIVIDER
========================================================= */

.online-divider {
    display: flex;

    align-items: center;

    gap: 10px;

    margin:
        14px 0;

    color:
        rgba(255,255,255,.35);

    font-size: 10px;

    text-transform:
        uppercase;

    letter-spacing:
        1px;
}

.online-divider::before,
.online-divider::after {
    content: "";

    height: 1px;

    flex: 1;

    background:
        rgba(255,255,255,.09);
}


/* =========================================================
   CREATE ROOM
========================================================= */

.create-room-btn {
    display: flex;

    align-items: center;

    justify-content: center;

    gap: 5px;

    margin-top: 1px;
}


/* =========================================================
   JOIN
========================================================= */

.join-row {
    display: grid;

    grid-template-columns:
        1fr auto;

    gap: 8px;
}

.room-input {
    text-transform:
        uppercase;

    letter-spacing:
        2px;
}

.room-input::placeholder {
    text-transform:
        none;

    letter-spacing:
        0;
}

.join-btn {
    min-width: 105px;
}


/* =========================================================
   ROOM MESSAGE
========================================================= */

.room-message {
    min-height: 20px;

    margin-top: 10px;

    padding:
        0 2px;

    color:
        rgba(255,255,255,.65);

    font-size: 12px;

    line-height: 1.4;
}


/* =========================================================
   CREATED ROOM
========================================================= */

.created-room {
    margin-top: 15px;

    padding-top: 15px;

    border-top:
        1px solid
        rgba(255,255,255,.08);

    text-align: center;
}

.waiting-icon {
    font-size: 29px;
}

.waiting-text {
    margin:
        5px 0 9px;

    color:
        rgba(255,255,255,.68);

    font-size: 12px;
}

.room-code {
    padding:
        13px;

    border-radius: 12px;

    background:
        rgba(0,0,0,.3);

    border:
        1px solid
        rgba(255,255,255,.06);

    font-size: 27px;

    font-weight: 900;

    letter-spacing: 5px;

    text-align: center;
}

.created-room .action-btn {
    width: 100%;

    margin-top: 8px;
}


/* =========================================================
   START
========================================================= */

.start-btn {
    margin-top: 3px;
}


/* =========================================================
   GAME
========================================================= */

.game {
    width:
        min(100%, 1240px);
}


/* =========================================================
   ONLINE BAR
========================================================= */

.online-game-bar {
    display: flex;

    align-items: center;

    gap: 8px;

    margin-bottom: 12px;

    padding:
        10px 12px;

    border-radius: 13px;

    background:
        rgba(8,22,45,.68);

    border:
        1px solid
        rgba(96,165,250,.2);

    backdrop-filter:
        blur(14px);

    box-shadow:
        0 10px 30px
        rgba(0,0,0,.2);

    font-size: 12px;
}

.online-game-bar > span {
    flex: 1;

    min-width: 0;
}

.online-game-bar strong {
    letter-spacing: 2px;
}


/* =========================================================
   LAYOUT
========================================================= */

.game-layout {
    display: grid;

    grid-template-columns:
        minmax(0,1fr)
        340px;

    gap: 20px;

    align-items: start;
}

.board-area {
    min-width: 0;
}


/* =========================================================
   PLAYERS
========================================================= */

.game-head {
    display: grid;

    grid-template-columns:
        1fr
        auto
        1fr;

    align-items: center;

    gap: 10px;

    margin-bottom: 10px;
}

.player-card {
    min-width: 0;

    display: flex;

    align-items: center;

    gap: 9px;

    padding:
        10px 12px;

    border-radius: 13px;

    background:
        rgba(8,18,34,.7);

    border:
        1px solid
        rgba(255,255,255,.09);

    backdrop-filter:
        blur(12px);

    box-shadow:
        0 10px 25px
        rgba(0,0,0,.15);

    transition:
        .2s;
}

.player-card.active-clock {
    border-color:
        rgba(96,165,250,.75);

    background:
        rgba(37,99,235,.2);

    box-shadow:
        0 0 25px
        rgba(37,99,235,.16);
}

.player-card div {
    min-width: 0;

    flex: 1;
}

.player-card strong,
.player-card small {
    display: block;

    overflow: hidden;

    white-space: nowrap;

    text-overflow: ellipsis;
}

.player-card strong {
    font-size: 14px;
}

.player-card small {
    margin-top: 2px;

    color:
        rgba(255,255,255,.5);

    font-size: 11px;
}

.player-card b {
    min-width: 45px;

    font-size: 18px;

    white-space: nowrap;

    text-align: right;

    font-variant-numeric:
        tabular-nums;
}

.dot {
    width: 12px;

    height: 12px;

    flex:
        0 0 12px;

    border-radius: 50%;
}

.white-dot {
    background: #fff;

    box-shadow:
        0 0 0 2px
        rgba(255,255,255,.2);
}

.black-dot {
    background: #050505;

    box-shadow:
        0 0 0 2px
        rgba(255,255,255,.2);
}

.turn-pill {
    padding:
        8px 13px;

    border-radius: 999px;

    background:
        linear-gradient(
            135deg,
            #3b82f6,
            #1d4ed8
        );

    box-shadow:
        0 7px 22px
        rgba(37,99,235,.25);

    font-size: 12px;

    font-weight: 850;

    white-space: nowrap;
}


/* =========================================================
   BOARD
========================================================= */

.board-wrap {
    width: 100%;

    display: flex;

    justify-content: center;

    align-items: center;
}

.board {
    width:
        min(
            100%,
            700px,
            76vh
        );

    max-width: 700px;

    aspect-ratio: 1 / 1;

    display: grid;

    grid-template-columns:
        repeat(8, minmax(0,1fr));

    grid-template-rows:
        repeat(8, minmax(0,1fr));

    overflow: hidden;

    border:
        4px solid
        rgba(0,0,0,.48);

    border-radius: 10px;

    box-shadow:
        0 30px 70px
        rgba(0,0,0,.55),

        0 0 0 1px
        rgba(255,255,255,.08);

    background:
        #b58863;

    flex-shrink: 0;

        touch-action: manipulation;

    -webkit-user-select: none;
    user-select: none;

    -webkit-touch-callout: none;
}

.square {
    position: relative;

    width: 100%;
    height: 100%;

    min-width: 0;
    min-height: 0;

    padding: 0;
    border: 0;

    display: flex;

    align-items: center;
    justify-content: center;

    aspect-ratio: 1 / 1;

    touch-action: manipulation;

    -webkit-user-select: none;
    user-select: none;

    -webkit-touch-callout: none;

    -webkit-tap-highlight-color: transparent;
}


.square.light {
    background:
        #f0d9b5;
}

.square.dark {
    background:
        #b58863;
}

.square.selected {
    box-shadow:
        inset 0 0 0 4px
        #facc15 !important;
}

.square.last {
    box-shadow:
        inset 0 0 0 999px
        rgba(250,204,21,.18);
}

.square.check {
    box-shadow:
        inset 0 0 0 999px
        rgba(239,68,68,.28),

        inset 0 0 0 4px
        rgba(239,68,68,.9);
}


/* =========================================================
   PIECES
========================================================= */

.piece {
    position: relative;

    z-index: 5;

    width: 88%;

    height: 88%;

    display: flex;

    align-items: center;

    justify-content: center;

    font-family:
        "Arial Unicode MS",
        "Segoe UI Symbol",
        "Noto Sans Symbols 2",
        sans-serif;

    font-size:
        clamp(
            28px,
            6.2vmin,
            62px
        );

    line-height: 1;

    user-select: none;

    pointer-events: none;

    transform:
        translateY(-2%);

    overflow: hidden;

    white-space: nowrap;
}


/* =========================================================
   WHITE PIECES
========================================================= */

.white-piece {
    color:
        #ffffff !important;

    opacity:
        1 !important;

    -webkit-text-fill-color:
        #ffffff !important;

    -webkit-text-stroke:
        1.8px #171717;

    text-shadow:
        0 2px 0 #111,
        1px 0 0 #111,
        -1px 0 0 #111,
        0 -1px 0 #111,
        0 4px 8px
        rgba(0,0,0,.55);

    filter:
        none !important;
}


/* =========================================================
   BLACK PIECES
========================================================= */

.black-piece {
    color:
        #111111 !important;

    opacity:
        1 !important;

    -webkit-text-fill-color:
        #111111 !important;

    -webkit-text-stroke:
        1px #000;

    text-shadow:
        0 2px 3px
        rgba(255,255,255,.13),

        0 4px 7px
        rgba(0,0,0,.5);

    filter:
        none !important;
}


/* =========================================================
   COORDINATES
========================================================= */

.coord {
    position: absolute;

    z-index: 8;

    pointer-events: none;

    font-size: 10px;

    font-weight: 850;

    opacity: .72;
}

.coord.file {
    right: 4px;

    bottom: 2px;
}

.coord.rank {
    left: 4px;

    top: 2px;
}

.square.light .coord {
    color:
        rgba(70,40,20,.8);
}

.square.dark .coord {
    color:
        rgba(255,255,255,.82);
}


/* =========================================================
   SIDE PANEL
========================================================= */

.side-panel {
    min-width: 0;

    padding:
        18px;

    border-radius: 20px;

    background:
        linear-gradient(
            145deg,
            rgba(14,28,49,.78),
            rgba(5,12,25,.74)
        );

    border:
        1px solid
        rgba(255,255,255,.1);

    backdrop-filter:
        blur(18px);

    box-shadow:
        0 25px 60px
        rgba(0,0,0,.3),

        inset 0 1px 0
        rgba(255,255,255,.05);
}

.side-title {
    display: flex;

    align-items: center;

    gap: 12px;

    margin-bottom: 16px;
}

.side-piece {
    width: 48px;

    height: 48px;

    display: flex;

    align-items: center;

    justify-content: center;

    border-radius: 14px;

    background:
        rgba(255,255,255,.08);

    color: #fff;

    font-size: 33px;

    text-shadow:
        0 3px 5px
        rgba(0,0,0,.5);
}

.side-title strong {
    display: block;

    font-size: 21px;
}

.side-title small {
    display: block;

    margin-top: 2px;

    color:
        rgba(255,255,255,.5);

    font-size: 11px;
}


/* =========================================================
   MOVES
========================================================= */

.moves-panel {
    border-radius: 15px;

    background:
        rgba(0,0,0,.2);

    border:
        1px solid
        rgba(255,255,255,.07);

    overflow: hidden;
}

.moves-title {
    display: flex;

    align-items: center;

    justify-content: space-between;

    padding:
        13px 14px;

    border-bottom:
        1px solid
        rgba(255,255,255,.07);
}

.moves-title h3 {
    margin: 0;

    font-size: 15px;
}

.moves-title span {
    min-width: 26px;

    padding:
        3px 7px;

    border-radius: 999px;

    background:
        rgba(255,255,255,.09);

    text-align: center;

    font-size: 11px;
}

.moves {
    height:
        min(390px,40vh);

    overflow-y: auto;

    display: grid;

    grid-template-columns:
        1fr 1fr;

    align-content: start;

    gap: 3px;

    padding: 8px;
}

.move-row {
    display: flex;

    gap: 7px;

    padding:
        6px 7px;

    border-radius: 7px;

    background:
        rgba(255,255,255,.045);

    font-size: 13px;
}

.move-no {
    width: 26px;

    color:
        rgba(255,255,255,.35);
}


/* =========================================================
   MESSAGE
========================================================= */

.message {
    min-height: 42px;

    margin:
        12px 0;

    padding:
        10px;

    display: flex;

    align-items: center;

    justify-content: center;

    border-radius: 11px;

    background:
        rgba(255,255,255,.045);

    color:
        rgba(255,255,255,.72);

    font-size: 13px;

    text-align: center;

    line-height: 1.35;
}


/* =========================================================
   ACTIONS
========================================================= */

.actions {
    display: grid;

    grid-template-columns:
        1fr 1fr;

    gap: 8px;
}

.actions .action-btn {
    min-width: 0;
}

.actions .danger {
    grid-column:
        1 / -1;
}


/* =========================================================
   OVERLAYS
========================================================= */

.overlay {
    position: fixed;

    inset: 0;

    z-index: 1000;

    display: flex;

    align-items: center;

    justify-content: center;

    padding: 20px;

    background:
        rgba(0,0,0,.7);

    backdrop-filter:
        blur(10px);
}

.draw-card,
.result-card {
    width:
        min(100%,390px);

    padding:
        28px;

    border-radius: 22px;

    background:
        linear-gradient(
            145deg,
            #17263e,
            #0b1425
        );

    border:
        1px solid
        rgba(255,255,255,.12);

    box-shadow:
        0 30px 80px
        rgba(0,0,0,.6);

    text-align: center;
}

.draw-icon,
.result-icon {
    font-size: 56px;
}

.draw-card h2,
.result-card h2 {
    margin:
        8px 0;

    font-size: 27px;
}

.draw-card p,
.result-card p {
    margin:
        0 0 20px;

    color:
        rgba(255,255,255,.7);

    line-height:
        1.5;
}

.draw-actions,
.result-actions {
    display: flex;

    gap: 8px;
}

.draw-actions > *,
.result-actions > * {
    flex: 1;
}


/* =========================================================
   AUTHOR
========================================================= */

.author-tag {
    position: fixed;

    right: 14px;

    left: auto;

    bottom:
        calc(
            10px +
            env(safe-area-inset-bottom)
        );

    z-index: 500;

    padding:
        6px 10px;

    border-radius: 9px;

    background:
        rgba(0,0,0,.35);

    border:
        1px solid
        rgba(255,255,255,.09);

    color:
        rgba(255,255,255,.5);

    font-size: 11px;

    font-weight: 650;

    letter-spacing: .2px;

    pointer-events: none;

    backdrop-filter:
        blur(8px);

    box-shadow:
        0 5px 20px
        rgba(0,0,0,.18);
}


/* =========================================================
   DESKTOP
========================================================= */

@media (min-width: 901px) {

    .page {
        min-height: 100vh;

        padding-top: 10px;

        padding-bottom: 12px;
    }

    .topbar {
        margin-bottom: 10px;
    }

    .game {
        width:
            min(100%,1240px);
    }

    .online-game-bar {
        margin-bottom: 8px;
    }

    .board {
    width:
        min(
            100%,
            700px,
            76vh
        );

    max-width: 700px;

    aspect-ratio: 1 / 1;

    display: grid;

    grid-template-columns:
        repeat(8, minmax(0,1fr));

    grid-template-rows:
        repeat(8, minmax(0,1fr));

    overflow: hidden;

    border:
        4px solid
        rgba(0,0,0,.48);

    border-radius: 10px;

    box-shadow:
        0 30px 70px
        rgba(0,0,0,.55),

        0 0 0 1px
        rgba(255,255,255,.08);

    background:
        #b58863;

    flex-shrink: 0;

    touch-action: manipulation;

    -webkit-user-select: none;
    user-select: none;

    -webkit-touch-callout: none;
}

    .piece {
        width: 86%;

        height: 86%;

        font-size:
            clamp(
                26px,
                5.5vh,
                58px
            );

        transform:
            translateY(-1%);
    }

    .side-panel {
        max-height:
            calc(100vh - 120px);

        overflow: hidden;
    }

    .moves {
        height:
            min(
                320px,
                calc(100vh - 430px)
            );

        min-height: 120px;
    }
}


/* =========================================================
   LARGE DESKTOP
========================================================= */

@media (
    min-width: 1100px
) and (
    min-height: 800px
) {

    .page {
        padding-top: 8px;

        padding-bottom: 8px;
    }

    .topbar {
        margin-bottom: 7px;
    }

    .game-head {
        margin-bottom: 7px;
    }

    .board {
        width:
            min(
                760px,
                82vh,
                100%
            );

        max-width:
            760px;
    }

    .piece {
        font-size:
            clamp(
                30px,
                6vh,
                64px
            );
    }
}


@media (
    min-width: 1300px
) and (
    min-height: 850px
) {

    .board {
        width:
            min(
                800px,
                84vh,
                100%
            );

        max-width:
            800px;
    }

    .piece {
        font-size:
            clamp(
                32px,
                6.2vh,
                68px
            );
    }
}


/* =========================================================
   MOBILE
========================================================= */

@media (max-width: 900px) {

    .game-layout {
        grid-template-columns:
            1fr;
    }

    .side-panel {
        width: 100%;
    }

    .moves {
        height: 220px;
    }
}


@media (max-width: 700px) {

    .page {
        padding:
            8px
            8px
            28px;
    }

    .topbar {
        margin-bottom: 10px;
    }

    .brand {
        font-size: 17px;
    }

    .brand-icon {
        font-size: 19px;
    }

    .ghost-btn {
        padding:
            8px 9px;

        font-size: 11px;
    }

    .setup {
        padding-top: 3px;
    }

    .setup-card {
        padding:
            23px 15px;

        border-radius: 20px;
    }

    .chess-logo {
        width: 68px;

        height: 68px;
    }

    .chess-logo span {
        font-size: 48px;
    }

    .mode-row {
        grid-template-columns:
            1fr;
    }

    .mode-btn {
        min-height: 50px;

        flex-direction: row;

        gap: 8px;
    }

    .game-head {
        grid-template-columns:
            1fr;

        gap: 7px;
    }

    .turn-pill {
        order: -1;

        justify-self:
            center;
    }

    .board {
        width:
            min(
                100%,
                700px,
                76vh
            );

        aspect-ratio:
            1 / 1;
    }

    .piece {
        font-size:
            clamp(
                26px,
                10vw,
                58px
            );

        -webkit-text-stroke:
            1.35px #171717;
    }

    .coord {
        font-size: 8px;
    }

    .side-panel {
        padding: 13px;

        border-radius: 16px;
    }

    .moves {
        height: 190px;
    }

    .join-row {
        grid-template-columns:
            1fr;
    }

    .join-btn {
        width: 100%;
    }

    .online-game-bar {
        flex-wrap: wrap;
    }

    .online-game-bar > span {
        flex-basis: 100%;
    }

    .online-game-bar .action-btn {
        flex: 1;
    }

    .draw-actions,
    .result-actions {
        flex-direction: column;
    }

    .author-tag {
        right: 9px;

        left: auto;

        bottom:
            calc(
                7px +
                env(safe-area-inset-bottom)
            );

        font-size: 10px;

        padding:
            5px 8px;
    }
}


/* =========================================================
   VERY SMALL PHONE
========================================================= */

@media (max-width: 380px) {

    .page {
        padding-left: 5px;

        padding-right: 5px;
    }

    .board {
        width:
            96vw;
    }

    .piece {
        font-size:
            clamp(
                23px,
                9.5vw,
                44px
            );
    }

    .player-card {
        padding:
            9px 10px;
    }

    .player-card b {
        font-size: 16px;
    }

    .online-panel {
        padding:
            13px;
    }

}
/* =========================================================
   CHESS ONLINE - COMPACT
========================================================= */

.online-panel {
    padding: 12px !important;
    gap: 9px !important;
}

.online-title {
    font-size: 17px !important;
    margin-bottom: 2px !important;
}

.random-match-btn {
    min-height: 58px !important;
    padding: 10px 12px !important;
}

.random-match-icon {
    font-size: 22px !important;
}

.random-match-content strong {
    font-size: 14px !important;
}

.random-match-content small {
    font-size: 11px !important;
}

.create-room-btn {
    min-height: 42px !important;
    padding: 9px 12px !important;
}

.online-divider {
    margin: 1px 0 !important;
    font-size: 11px !important;
}

.join-row {
    gap: 7px !important;
}

.room-input {
    min-height: 40px !important;
}

.join-row .action-btn {
    min-height: 40px !important;
    padding: 8px 11px !important;
}

.room-message {
    margin-top: 2px !important;
    font-size: 11px !important;
}

.created-room {
    padding: 9px !important;
}

/* Không cho panel online tự tạo thanh cuộn */
.online-panel {
    overflow: visible !important;
    max-height: none !important;
}

/* Khi màn hình thấp */
@media (max-height: 760px) {

    .setup-card {
        padding-top: 12px !important;
        padding-bottom: 12px !important;
    }

    .online-panel {
        padding: 9px !important;
        gap: 6px !important;
    }

    .random-match-btn {
        min-height: 52px !important;
        padding: 7px 10px !important;
    }

    .create-room-btn,
    .join-row .action-btn {
        min-height: 37px !important;
    }

    .room-input {
        min-height: 37px !important;
    }
}


/* iPhone / màn hình nhỏ */
@media (max-width: 700px) {

    .online-panel {
        padding: 9px !important;
        gap: 7px !important;
    }

    .random-match-btn {
        min-height: 54px !important;
    }

    .random-match-content strong {
        font-size: 13px !important;
    }

    .random-match-content small {
        font-size: 10px !important;
    }
}