:root,
body[data-theme="light"] {
    --bg-start: #fbf8f2;
    --bg-end: #efe8dc;
    --accent: #d1a67c;
    --accent-light: rgba(209, 166, 124, 0.2);
    --text-color: #3d342f;
    --surface: rgba(255, 255, 255, 0.6);
    --board-light: #f6f1e4;
    --board-dark: #e3d8c8;
}

body[data-theme="dark"] {
    --bg-start: #2b2b2b;
    --bg-end: #1f1f1f;
    --accent: #d1a67c;
    --accent-light: rgba(209, 166, 124, 0.2);
    --text-color: #f5f5f5;
    --surface: rgba(255, 255, 255, 0.1);
    --board-light: #b58863;
    --board-dark: #7b5e40;
}

@media (prefers-color-scheme: dark) {
    :root {
        --bg-start: #2b2b2b;
        --bg-end: #1f1f1f;
        --accent: #d1a67c;
        --accent-light: rgba(209, 166, 124, 0.2);
        --text-color: #f5f5f5;
        --surface: rgba(255, 255, 255, 0.1);
        --board-light: #b58863;
        --board-dark: #7b5e40;
    }
}
/*
   Global styles in a lighter pastel palette.
*/
body {
    font-family: "Segoe UI", "Helvetica Neue", Arial, sans-serif;
    margin: 0;
    background: linear-gradient(135deg, var(--bg-start) 0%, var(--bg-end) 100%);
    color: var(--text-color);
    display: flex;
    flex-direction: column;
    align-items: center;
    padding: 10px;
}
 header {
    width: 100%;
    max-width: 480px;
    padding: 8px;
    text-align: center;
    background: var(--surface);
    color: var(--text-color);
    border: 2px solid var(--accent);
    border-radius: 8px;
    box-shadow: 0 2px 6px rgba(0, 0, 0, 0.1);
}

#authStatus {
    margin-top: 5px;
    min-height: 1.2rem;
}

#authStatus.loading::before {
    content: "";
    display: inline-block;
    width: 12px;
    height: 12px;
    border: 2px solid var(--accent);
    border-top-color: transparent;
    border-radius: 50%;
    margin-right: 5px;
    animation: auth-spin 1s linear infinite;
}

#authStatus.success {
    color: #2e7d32;
}

#authStatus.error {
    color: #c62828;
}

@keyframes auth-spin {
    to { transform: rotate(360deg); }
}
/* Unified style for buttons */
.action-button {
    padding: 10px;
    font-size: 1rem;
    border: 1px solid var(--accent);
    background: var(--accent-light);
    color: var(--text-color);
    border-radius: 8px;
    cursor: pointer;
    transition: background 0.2s, box-shadow 0.2s;
    text-decoration: none;
    display: inline-block;
}
.action-button:hover {
    background: rgba(209, 166, 124, 0.35);
    box-shadow: 0 2px 4px rgba(0, 0, 0, 0.15);
}
.action-button.muted {
    opacity: 0.5;
}

#bottomActions {
    display: flex;
    justify-content: center;
    gap: 10px;
    margin-top: 10px;
    text-align: center;
}
/* NEW CODE: list of online players and bots */
#onlinePlayersContainer {
    width: 100%;
    max-width: 480px;
    margin-bottom: 5px;
}
#onlinePlayers, #botPlayers {
    display: flex;
    flex-wrap: wrap;
    gap: 5px;
}
#onlinePlayers .action-button,
#botPlayers .action-button {
    flex: 1 1 calc(50% - 5px);
}
/* Styles for the room list */
#roomListContainer {
    width: 100%;
    max-width: 480px;
    margin-bottom: 5px;
}
 #roomListHeader {
    font-size: 1.2rem;
    margin-bottom: 10px;
}
 #roomList {
    display: flex;
    flex-direction: column;
    gap: 5px;
}
 .room-card {
    background: var(--surface);
    border: 1px solid var(--accent);
    border-radius: 8px;
    padding: 10px;
    box-shadow: 0 2px 4px rgba(0, 0, 0, 0.05);
    cursor: pointer;
    transition: transform 0.2s, box-shadow 0.2s;
}
.room-card:hover {
    transform: scale(1.02);
    box-shadow: 0 2px 6px rgba(0, 0, 0, 0.1);
}
/* Styles for main actions */
#mainActions {
    width: 100%;
    max-width: 480px;
    display: flex;
    flex-direction: column;
    gap: 5px;
    margin-bottom: 5px;
}
#mainActions .action-button,
#mainActions input {
    width: 100%;
    max-width: 480px;
    box-sizing: border-box;
}
 #pieceInfoContainer .action-button {
    background: rgba(255, 182, 193, 0.15);
}
 #mainActions input {
    padding: 10px;
    font-size: 1rem;
    border: 1px solid var(--accent);
    border-radius: 8px;
    background: var(--surface);
    color: var(--text-color);
}
/* Room info block with Leave and Restart buttons */
#roomInfo {
    width: 100%;
    max-width: 480px;
    margin-bottom: 5px;
/* CHANGED CODE: semi-transparent container */
    background: var(--surface);
    border: 1px solid var(--accent);
    border-radius: 8px;
    padding: 10px;
    display: none;
}
#roomInfoText {
    display: block;
    margin-bottom: 5px;
}
.button-container {
    display: flex;
    gap: 5px;
}
/* NEW CODE: available bots list */
#botSelectionContainer {
    margin-top: 5px;
    display: none; /* Hidden by default */
}
#botList {
    display: flex;
    flex-direction: column;
    gap: 5px;
    margin-top: 5px;
}
.bot-card {
    background: var(--surface);
    border: 1px solid var(--accent);
    border-radius: 8px;
    padding: 8px;
    box-shadow: 0 2px 4px rgba(0, 0, 0, 0.05);
    cursor: pointer;
    transition: transform 0.2s, box-shadow 0.2s;
}
.bot-card:hover {
    transform: scale(1.02);
    box-shadow: 0 2px 6px rgba(0, 0, 0, 0.1);
}
/*
    The game board is drawn by code without a background image.
*/
#board {
    display: none;
    grid-template-columns: repeat(8, 1fr);
    width: 100%;
    max-width: 480px;
    gap: 2px;
    position: relative;
    background: var(--accent);
    margin-bottom: 5px;
    padding: 2px;
    border: 2px solid var(--accent);
    border-radius: 8px;
    box-shadow: 0 2px 6px rgba(0, 0, 0, 0.1);
}

.move-trail-layer {
    position: absolute;
    inset: 0;
    pointer-events: none;
    z-index: 3;
    overflow: visible;
}

.floating-effect-layer {
    position: absolute;
    inset: 0;
    pointer-events: none;
    overflow: visible;
    z-index: 8;
}

.move-trail {
    opacity: 1;
}
 .square {
    position: relative;
    padding-top: 100%;
    overflow: hidden;
    transition: box-shadow 0.3s, outline 0.3s;
}
.square.light {
    background-color: var(--board-light);
}
.square.dark {
    background-color: var(--board-dark);
}

.floating-effect {
    position: absolute;
    left: 50%;
    top: 10%;
    transform: translate(-50%, 0) scale(1);
    opacity: 0;
    font-weight: 700;
    line-height: 1;
    pointer-events: none;
    white-space: nowrap;
    text-shadow: 0 1px 1px rgba(0, 0, 0, 0.6);
    z-index: 10;
    animation: floating-effect-rise 2s linear forwards;
}

.floating-effect--miss {
    letter-spacing: 0.05em;
}

@keyframes floating-effect-rise {
    0% {
        opacity: 0;
        transform: translate(-50%, 0) scale(0.95);
    }
    15% {
        opacity: 1;
        transform: translate(-50%, calc(-0.15 * var(--rise-distance, 48px))) scale(1);
    }
    100% {
        opacity: 0;
        transform: translate(-50%, calc(-1 * var(--rise-distance, 48px))) scale(0.75);
    }
}
/* Class for highlighting the selected piece */
.selected-effect {
    outline: 3px solid #6750A4;
    box-shadow: 0 0 8px rgba(103, 80, 164, 0.7);
    z-index: 2;
}

/* Generic inline icon sizing */
.icon {
    width: 1em;
    height: 1em;
    /* Ensure icons align with adjacent text */
    display: inline-block;
    vertical-align: middle;
}

#abilityBtn {
    width: 40px;
    height: 40px;
    padding: 0;
}

#abilityBtn .icon {
    width: 100%;
    height: 100%;
}
.available-move {
    box-shadow: inset 0 0 10px 3px rgba(50, 205, 50, 0.4);
}
.available-attack {
    box-shadow: inset 0 0 10px 3px rgba(255, 0, 0, 0.4);
}
.ability-target {
    box-shadow: inset 0 0 10px 3px rgba(255, 140, 0, 0.4);
}
/*
   Ability/damage effects:
   CHANGED CODE: replaced styles with a more "neon" look.
*/
.damage-effect {
    box-shadow: inset 0 0 15px 5px rgba(255, 50, 50, 0.7);
}
.defense-effect,
.miss-effect {
    box-shadow: inset 0 0 15px 5px rgba(146, 202, 202, 0.8);
    background: linear-gradient(135deg, rgba(100, 255, 255, 0.2), rgba(100, 255, 255, 0.05));
}
.critical-effect {
    position: relative;
    animation: critical-wave 1s ease-out;
}
@keyframes critical-wave {
    0% {
        box-shadow: 0 0 0 0 rgba(255, 0, 0, 0.9);
    }
    100% {
        box-shadow: 0 0 20px 15px rgba(255, 0, 0, 0);
    }
}
.kill-effect {
    position: relative;
    animation: kill-wave 1s ease-out;
}
@keyframes kill-wave {
    0% {
        box-shadow: 0 0 0 0 rgba(255, 0, 0, 0.8);
    }
    100% {
        box-shadow: 0 0 25px 20px rgba(255, 0, 0, 0);
    }
}
.heal-effect {
    box-shadow: 0 0 15px 5px rgba(0, 255, 80, 0.6);
}
.ability-effect {
    box-shadow: inset 0 0 15px 5px rgba(255, 140, 0, 0.8);
}
 .activated-ability {
    box-shadow: 0 0 12px 4px rgba(255, 140, 0, 0.9);
    animation: activated-pulse 1.5s infinite;
}
@keyframes activated-pulse {
    0% {
        box-shadow: 0 0 12px 4px rgba(255, 140, 0, 0.9);
    }
    50% {
        box-shadow: 0 0 20px 6px rgba(255, 120, 0, 1);
    }
    100% {
        box-shadow: 0 0 12px 4px rgba(255, 140, 0, 0.9);
    }
}
.square-content {
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1.5rem;
    touch-action: none;
    cursor: grab;
    z-index: 5;
}
/* HP bar */
.hp-bar-container {
    position: absolute;
    bottom: 2px;
    left: 2px;
    right: 2px;
    z-index: 6;
    height: 2px;
    background: #444;
    border-radius: 3px;
}
.hp-bar {
    height: 100%;
    background: #6A9E63;
    border-radius: 3px;
}
/* Styles for selected piece info */
#pieceInfoContainer {
    display: flex;
    align-items: center;
    gap: 10px;
    justify-content: flex-start;
    width: 100%;
    max-width: 480px;
    margin-bottom: 10px;
}
/* Game log */
#log {
    width: 100%;
    max-width: 480px;
    background: var(--surface);
    border-radius: 8px;
    padding: 10px;
    max-height: 150px;
    overflow-y: auto;
    text-align: left;
    font-size: 0.9rem;
    line-height: 1.4;
    display: none;
}
/* Ratings page header and container */
.ratings-header {
    position: relative;
    display: flex;
    align-items: center;
    justify-content: center;
}
.ratings-header .back-link {
    position: absolute;
    left: 16px;
    top: 50%;
    transform: translateY(-50%);
    width: auto;
}
.ratings-title {
    margin: 0;
}
.ratings-content {
    width: 100%;
    max-width: 480px;
    margin: 0 auto;
}
/* Ratings table (styled like the game) */
#ratingsBoard {
    width: 100%;
    max-width: 480px;
    margin-bottom: 10px;
    background: var(--surface);
    border: 1px solid var(--accent);
    border-radius: 8px;
    padding: 10px;
}
#ratingsBoard h3 {
    margin-top: 0;
}
table.ratings-table {
    width: 100%;
    border-collapse: collapse;
    margin-top: 5px;
}
table.ratings-table thead {
    background-color: var(--accent);
    color: var(--text-color);
}
table.ratings-table th,
table.ratings-table td {
    border: 1px solid var(--accent);
    padding: 6px;
    text-align: center;
}
table.ratings-table tr:nth-child(even) {
    background: rgba(255, 255, 255, 0.05);
}
/* Responsive for mobile devices */
@media (max-width: 480px) {
    body {
        padding: 5px;
    }
    #mainActions .action-button,
    #mainActions input {
        font-size: 0.9rem;
    }
    #onlinePlayers .action-button,
    #botPlayers .action-button {
        flex: 1 1 100%;
    }
}
 .disabled-ability {
    background: rgba(0, 0, 0, 0.25) !important;
    cursor: not-allowed;
    pointer-events: none;
}
/* Style for SVG piece images to fit the square */
.chess-piece-img {
    max-width: 90%;
    max-height: 90%;
    user-select: none;
    -webkit-user-drag: none;
}
/* Highlight player's move */
#board.player-turn {
    border-color: #4caf50;
}
/* Name change block: input styled like roomInput */
#changeNameContainer input {
    padding: 10px;
    font-size: 1rem;
    border: 1px solid var(--accent);
    border-radius: 8px;
    width: 60%;
    box-sizing: border-box;
    background: var(--surface);
    color: var(--text-color);
}

/* Skeleton loading placeholder */
.skeleton-placeholder {
    position: relative;
    overflow: hidden;
    background: linear-gradient(90deg, var(--surface) 25%, var(--accent-light) 50%, var(--surface) 75%);
    background-size: 400% 100%;
    animation: skeleton-loading 1.2s ease-in-out infinite;
    border-radius: 8px;
    width: 100%;
    height: 2.5rem;
}

@keyframes skeleton-loading {
    0% {
        background-position: 100% 0;
    }
    100% {
        background-position: -100% 0;
    }
}
