/* ===================================
   SCHACH ONLINE - STYLES
   =================================== */

:root {
    --primary: rgb(162, 76, 255);
    --primary-rgb: 162, 76, 255;
    --board-light: #f0d9b5;
    --board-dark: #b58863;
    --highlight-from: rgba(255, 255, 0, 0.5);
    --highlight-to: rgba(255, 255, 0, 0.5);
    --valid-move: rgba(0, 0, 0, 0.15);
    --check-color: rgba(255, 0, 0, 0.5);
}

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

body {
    min-height: 100vh;
    display: flex;
    flex-direction: column;
    align-items: center;
    padding-bottom: 2rem;
}

/* ===================================
   DIALOGS
   =================================== */

.mode-dialog,
.online-dialog {
    background: rgba(30, 30, 40, 0.95);
    backdrop-filter: blur(10px);
    border: 1px solid rgba(255, 255, 255, 0.1);
    border-radius: 16px;
    padding: 2rem;
    max-width: 400px;
    width: 90%;
    margin: 6rem auto 2rem;
    text-align: center;
    display: flex;
    flex-direction: column;
    align-items: center;
}

/* Fix for snow-wrapper conflict with w-100 buttons */
.mode-dialog .snow-wrapper,
.online-dialog .snow-wrapper {
    width: 100%;
    margin-bottom: 1rem;
}

.mode-dialog h2,
.online-dialog h2 {
    margin-bottom: 1.5rem;
    color: #fff;
    width: 100%;
}

.page-title-animate {
    text-align: center;
    width: 100%;
    margin-top: 2rem !important;
}

.or-divider {
    text-align: center;
    color: #888;
    margin: 1rem 0;
}

/* Time Control Grid */
.time-control-grid {
    display: grid;
    grid-template-columns: repeat(4, 1fr);
    gap: 8px;
}

.time-btn {
    background: rgba(255, 255, 255, 0.1);
    border: 2px solid rgba(255, 255, 255, 0.2);
    color: #fff;
    padding: 0.75rem 0.5rem;
    border-radius: 8px;
    cursor: pointer;
    transition: all 0.2s ease;
    font-weight: 500;
}

.time-btn:hover {
    background: rgba(255, 255, 255, 0.2);
    border-color: rgba(255, 255, 255, 0.4);
}

.time-btn.active {
    background: var(--primary);
    border-color: var(--primary);
}

.custom-time-row {
    display: flex;
    align-items: center;
    gap: 10px;
    justify-content: center;
}

.custom-time-row input {
    width: 80px;
    text-align: center;
}

.custom-time-row span {
    color: #888;
    font-size: 1.2rem;
}

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

.game-container {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 1rem;
    padding: 1rem;
}

.status-display {
    text-align: center;
    font-size: 1.2rem;
    padding: 0.75rem 1.5rem;
    background: rgba(0, 0, 0, 0.3);
    border-radius: 8px;
    margin-bottom: 1rem;
}

.status-display.check {
    background: rgba(255, 0, 0, 0.3);
    animation: pulse-check 1s infinite;
}

@keyframes pulse-check {

    0%,
    100% {
        box-shadow: 0 0 0 0 rgba(255, 0, 0, 0.4);
    }

    50% {
        box-shadow: 0 0 20px 5px rgba(255, 0, 0, 0.4);
    }
}

/* ===================================
   PLAYER INFO
   =================================== */

.player-info {
    display: flex;
    align-items: center;
    justify-content: space-between;
    width: 100%;
    max-width: 480px;
    padding: 0.5rem 1rem;
    background: rgba(0, 0, 0, 0.2);
    border-radius: 8px;
}

.player-timer {
    font-family: 'Roboto Mono', monospace;
    font-size: 1.5rem;
    font-weight: bold;
    padding: 0.5rem 1rem;
    background: rgba(0, 0, 0, 0.3);
    border-radius: 6px;
    min-width: 90px;
    text-align: center;
}

.player-timer.active {
    background: rgba(var(--primary-rgb), 0.3);
    box-shadow: 0 0 15px rgba(var(--primary-rgb), 0.5);
}

.player-timer.low-time {
    background: rgba(255, 50, 50, 0.4);
    animation: timer-warning 0.5s infinite;
}

@keyframes timer-warning {

    0%,
    100% {
        opacity: 1;
    }

    50% {
        opacity: 0.6;
    }
}

.captured-pieces {
    display: flex;
    flex-wrap: wrap;
    gap: 2px;
    font-size: 1.2rem;
}

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

.chess-board {
    display: grid;
    grid-template-columns: repeat(8, 1fr);
    grid-template-rows: repeat(8, 1fr);
    width: min(90vw, 480px);
    height: min(90vw, 480px);
    border: 4px solid rgba(0, 0, 0, 0.5);
    border-radius: 4px;
    box-shadow: 0 10px 40px rgba(0, 0, 0, 0.5);
    position: relative;
}

.chess-board.flipped {
    transform: rotate(180deg);
}

.chess-board.flipped .square {
    transform: rotate(180deg);
}

.square {
    display: flex;
    justify-content: center;
    align-items: center;
    position: relative;
    cursor: pointer;
    user-select: none;
    transition: background-color 0.15s ease;
}

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

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

/* Coordinates */
.square .coord-file,
.square .coord-rank {
    position: absolute;
    font-size: 0.65rem;
    font-weight: bold;
    opacity: 0.7;
    pointer-events: none;
}

.square.light .coord-file,
.square.light .coord-rank {
    color: var(--board-dark);
}

.square.dark .coord-file,
.square.dark .coord-rank {
    color: var(--board-light);
}

.square .coord-file {
    bottom: 2px;
    right: 4px;
}

.square .coord-rank {
    top: 2px;
    left: 4px;
}

/* Highlights */
.square.selected {
    background-color: rgba(255, 255, 0, 0.6) !important;
}

.square.last-move-from,
.square.last-move-to {
    background-color: var(--highlight-from) !important;
}

.square.valid-move::after {
    content: '';
    position: absolute;
    width: 30%;
    height: 30%;
    background: var(--valid-move);
    border-radius: 50%;
}

.square.valid-capture::after {
    content: '';
    position: absolute;
    width: 100%;
    height: 100%;
    border: 4px solid var(--valid-move);
    border-radius: 50%;
    box-sizing: border-box;
}

.square.in-check {
    background: radial-gradient(circle, var(--check-color), transparent 70%) !important;
}

/* Pieces */
.piece {
    font-size: clamp(2rem, 8vw, 3.5rem);
    line-height: 1;
    cursor: grab;
    transition: transform 0.1s ease;
    text-shadow: 2px 2px 4px rgba(0, 0, 0, 0.3);
}

.piece:active {
    cursor: grabbing;
}

.piece.white {
    color: #fff;
    text-shadow:
        1px 1px 0 #000,
        -1px 1px 0 #000,
        1px -1px 0 #000,
        -1px -1px 0 #000,
        2px 2px 4px rgba(0, 0, 0, 0.5);
}

.piece.black {
    color: #333;
    text-shadow:
        1px 1px 0 rgba(255, 255, 255, 0.3),
        2px 2px 4px rgba(0, 0, 0, 0.3);
}

/* Piece Styles */
.pieces-modern .piece {
    filter: drop-shadow(3px 3px 2px rgba(0, 0, 0, 0.5));
}

.pieces-minimalist .piece {
    font-family: Arial, sans-serif;
    text-shadow: none;
}

.pieces-minimalist .piece.white {
    color: #f5f5f5;
    -webkit-text-stroke: 1px #333;
}

.pieces-minimalist .piece.black {
    color: #2a2a2a;
}

/* Dragging */
.piece.dragging {
    position: fixed;
    pointer-events: none;
    z-index: 1000;
    transform: scale(1.2);
    opacity: 0.9;
}

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

.board-classic {
    --board-light: #f0d9b5;
    --board-dark: #b58863;
}

.board-green {
    --board-light: #ffffdd;
    --board-dark: #86a666;
}

.board-blue {
    --board-light: #dee3e6;
    --board-dark: #8ca2ad;
}

.board-purple {
    --board-light: #e8d0f0;
    --board-dark: #9b72cf;
}

.board-wood {
    --board-light: #e8c99b;
    --board-dark: #a17a4d;
}

.board-dark {
    --board-light: #4a4a4a;
    --board-dark: #2a2a2a;
}

/* ===================================
   BACKGROUND THEMES
   =================================== */

.theme-default {
    background: linear-gradient(135deg, #1a1a2e 0%, #16213e 50%, #0f3460 100%);
}

.theme-digital {
    background: linear-gradient(135deg, #0a0a0a 0%, #1a1a2e 50%, #0d0d1a 100%);
}

.theme-ocean {
    background: linear-gradient(135deg, #0077b6 0%, #00b4d8 50%, #90e0ef 100%);
}

.theme-sunset {
    background: linear-gradient(135deg, #ff6b6b 0%, #feca57 50%, #ff9ff3 100%);
}

.theme-forest {
    background: linear-gradient(135deg, #1a472a 0%, #2d5a3f 50%, #3d6b4f 100%);
}

.theme-elegant {
    background: linear-gradient(135deg, #2c2c2c 0%, #1a1a1a 50%, #0d0d0d 100%);
}

/* ===================================
   INVITE SECTION
   =================================== */

.invite-flex {
    display: flex;
    gap: 10px;
    justify-content: center;
    align-items: center;
}

.invite-flex input {
    max-width: 200px;
    background: rgba(255, 255, 255, 0.1);
    border: 1px solid rgba(255, 255, 255, 0.2);
    color: #fff;
}

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

.game-controls {
    display: flex;
    gap: 1rem;
    justify-content: center;
    flex-wrap: wrap;
}

/* ===================================
   PROMOTION MODAL
   =================================== */

.promotion-options {
    display: flex;
    justify-content: center;
    gap: 1rem;
}

.promotion-btn {
    width: 60px;
    height: 60px;
    border: 2px solid #555;
    border-radius: 8px;
    background: rgba(255, 255, 255, 0.1);
    cursor: pointer;
    transition: all 0.2s ease;
}

.promotion-btn:hover {
    background: rgba(var(--primary-rgb), 0.3);
    border-color: var(--primary);
    transform: scale(1.1);
}

.promotion-btn .piece-symbol {
    font-size: 2.5rem;
}

/* ===================================
   SETTINGS BUTTON
   =================================== */

#settings-button {
    position: fixed;
    bottom: 2rem;
    right: 2rem;
    font-size: 1.5rem;
    color: rgba(255, 255, 255, 0.7);
    background: rgba(0, 0, 0, 0.3);
    border-radius: 50%;
    width: 4rem;
    height: 4rem;
    z-index: 10000;
    display: flex;
    justify-content: center;
    align-items: center;
    border: none;
    cursor: pointer;
}

#settings-button:hover {
    color: white;
    background: rgba(0, 0, 0, 0.6);
}

/* ===================================
   SETTINGS MODAL (Timer-inspired)
   =================================== */

.modal-content {
    background-color: #2a2a2e;
    color: #f1f1f1;
}

.modal-header {
    border-bottom: 1px solid #444;
}

.btn-close {
    background-color: #fff;
}

.modal-subtitle {
    color: #ccc;
    font-weight: bold;
    margin-bottom: 0.5rem;
}

/* Tabs */
.nav-tabs {
    border-bottom: 1px solid #444;
}

.nav-tabs .nav-link {
    color: #aaa;
    border: none;
}

.nav-tabs .nav-link.active {
    color: #fff;
    background-color: #3a3a3e;
    border-bottom: 1px solid #3a3a3e;
}

.nav-tabs .nav-link:hover {
    color: #fff;
    border-color: transparent;
}

.tab-content {
    padding-top: 1rem;
}

/* Theme Swatches */
.theme-options {
    display: flex;
    justify-content: center;
    flex-wrap: wrap;
    gap: 15px;
    padding: 0.5rem 0;
}

.theme-swatch {
    width: 50px;
    height: 50px;
    border-radius: 50%;
    border: 3px solid #fff;
    cursor: pointer;
    transition: transform 0.2s ease, border-color 0.2s;
}

.theme-swatch:hover {
    transform: scale(1.1);
}

.theme-swatch.active {
    border-color: #ffc107;
    box-shadow: 0 0 15px rgba(255, 193, 7, 0.5);
}

.theme-default {
    background: linear-gradient(135deg, #1a1a2e, #0f3460);
}

.theme-digital {
    background: linear-gradient(135deg, #0a0a0a, #1a1a2e);
}

.theme-ocean {
    background: linear-gradient(135deg, #0077b6, #90e0ef);
}

.theme-sunset {
    background: linear-gradient(135deg, #ff6b6b, #feca57);
}

.theme-forest {
    background: linear-gradient(135deg, #1a472a, #3d6b4f);
}

.theme-elegant {
    background: linear-gradient(135deg, #2c2c2c, #0d0d0d);
}

.custom-color-swatch {
    width: 50px;
    height: 50px;
    border-radius: 50%;
    border: 3px solid #fff;
    cursor: pointer;
    display: flex;
    justify-content: center;
    align-items: center;
    font-size: 1.5rem;
    background: conic-gradient(red, yellow, lime, aqua, blue, magenta, red);
    position: relative;
    overflow: hidden;
    transition: transform 0.2s ease;
}

.custom-color-swatch:hover {
    transform: scale(1.1);
}

.custom-color-swatch i {
    color: white;
    text-shadow: 0 0 3px black;
}

.custom-color-swatch input[type="color"] {
    position: absolute;
    width: 100px;
    height: 100px;
    top: -25px;
    left: -25px;
    opacity: 0;
    cursor: pointer;
}

/* Piece Style Options */
.piece-style-options {
    display: grid;
    grid-template-columns: repeat(2, 1fr);
    gap: 15px;
    padding: 0.5rem 0;
}

.piece-style-btn {
    background: rgba(255, 255, 255, 0.1);
    border: 2px solid rgba(255, 255, 255, 0.2);
    border-radius: 12px;
    padding: 1rem;
    cursor: pointer;
    transition: all 0.2s ease;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 0.5rem;
}

.piece-style-btn:hover {
    background: rgba(255, 255, 255, 0.2);
}

.piece-style-btn.active {
    border-color: #ffc107;
    box-shadow: 0 0 15px rgba(255, 193, 7, 0.3);
}

.piece-preview {
    font-size: 1.8rem;
}

.style-name {
    font-size: 0.85rem;
    color: #ccc;
}

/* Board Style Options */
.board-style-options {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 15px;
    padding: 0.5rem 0;
}

.board-style-btn {
    background: rgba(255, 255, 255, 0.05);
    border: 2px solid rgba(255, 255, 255, 0.2);
    border-radius: 12px;
    padding: 0.75rem;
    cursor: pointer;
    transition: all 0.2s ease;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 0.5rem;
}

.board-style-btn:hover {
    background: rgba(255, 255, 255, 0.15);
}

.board-style-btn.active {
    border-color: #ffc107;
    box-shadow: 0 0 15px rgba(255, 193, 7, 0.3);
}

.board-preview {
    display: grid;
    grid-template-columns: repeat(2, 1fr);
    width: 40px;
    height: 40px;
    border-radius: 4px;
    overflow: hidden;
}

.preview-light,
.preview-dark {
    width: 20px;
    height: 20px;
}

.board-style-btn span {
    font-size: 0.75rem;
    color: #ccc;
}

/* Custom Board Colors */
.custom-board-colors {
    display: flex;
    justify-content: center;
    gap: 2rem;
    padding: 0.5rem 0;
}

.color-input-group {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 0.5rem;
}

.color-input-group label {
    font-size: 0.85rem;
    color: #aaa;
}

.color-input-group input[type="color"] {
    width: 50px;
    height: 40px;
    border: none;
    border-radius: 8px;
    cursor: pointer;
}

/* List Items */
.list-group-item {
    padding-left: 0;
    padding-right: 0;
}

.form-check-label {
    cursor: pointer;
}

/* Forms */
.modal-content .form-control {
    background-color: #3a3a3e;
    color: #fff;
    border-color: #555;
}

.modal-content .form-control:focus {
    background-color: #3a3a3e;
    color: #fff;
    border-color: var(--primary);
    box-shadow: 0 0 0 0.25rem rgba(var(--primary-rgb), 0.25);
}

.modal-content .form-control::placeholder {
    color: #888;
}

/* ===================================
   RESPONSIVE
   =================================== */

@media (max-width: 768px) {
    .page-title-animate {
        font-size: 1.8rem !important;
        margin-top: 1rem !important;
    }

    .mode-dialog,
    .online-dialog {
        margin: 4rem auto 1rem;
        padding: 1.5rem;
        width: 95%;
    }

    .mode-dialog h2,
    .online-dialog h2 {
        font-size: 1.4rem;
    }

    .time-control-grid {
        grid-template-columns: repeat(4, 1fr);
        gap: 6px;
    }

    .time-btn {
        padding: 0.5rem 0.25rem;
        font-size: 0.85rem;
    }

    .chess-board {
        width: min(92vw, 400px);
        height: min(92vw, 400px);
    }

    .piece {
        font-size: clamp(1.8rem, 9vw, 3rem);
    }

    .player-info {
        max-width: 92vw;
        padding: 0.4rem 0.8rem;
    }

    .player-timer {
        font-size: 1.1rem;
        padding: 0.3rem 0.6rem;
        min-width: 70px;
    }

    .status-display {
        font-size: 1rem;
        padding: 0.5rem 1rem;
    }

    .game-controls {
        gap: 0.5rem;
    }

    .game-controls .btn {
        padding: 0.5rem 0.75rem !important;
        font-size: 0.9rem !important;
    }

    #settings-button {
        width: 3rem;
        height: 3rem;
        font-size: 1.2rem;
        bottom: 1rem;
        right: 1rem;
    }
}

@media (max-width: 480px) {
    .page-title-animate {
        font-size: 1.5rem !important;
    }

    .mode-dialog,
    .online-dialog {
        margin: 3rem auto 1rem;
        padding: 1rem;
    }

    .time-control-grid {
        grid-template-columns: repeat(4, 1fr);
        gap: 4px;
    }

    .time-btn {
        padding: 0.4rem 0.2rem;
        font-size: 0.75rem;
    }

    .chess-board {
        width: 96vw;
        height: 96vw;
        border-width: 2px;
    }

    .piece {
        font-size: clamp(1.5rem, 10vw, 2.5rem);
    }

    .square .coord-file,
    .square .coord-rank {
        font-size: 0.5rem;
    }

    .player-info {
        flex-direction: row;
        gap: 0.5rem;
    }

    .player-timer {
        font-size: 1rem;
        min-width: 60px;
    }

    .captured-pieces {
        font-size: 0.9rem;
    }

    .game-controls {
        flex-direction: column;
        width: 100%;
    }

    .game-controls .btn {
        width: 100%;
    }

    .board-style-options {
        grid-template-columns: repeat(2, 1fr);
    }

    .piece-style-options {
        grid-template-columns: repeat(2, 1fr);
        gap: 10px;
    }
}

/* ===================================
   TOAST NOTIFICATIONS
   =================================== */

.toast-container {
    position: fixed;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    z-index: 10001;
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
    pointer-events: none;
}

.game-toast {
    background: rgba(30, 30, 40, 0.95);
    backdrop-filter: blur(10px);
    border: 1px solid rgba(255, 255, 255, 0.2);
    border-radius: 12px;
    padding: 1.2rem 2rem;
    display: flex;
    align-items: center;
    gap: 1rem;
    color: #fff;
    box-shadow: 0 15px 40px rgba(0, 0, 0, 0.5);
    animation: fadeInScale 0.3s cubic-bezier(0.175, 0.885, 0.32, 1.275);
    pointer-events: auto;
    max-width: 90vw;
}

.game-toast.with-actions {
    flex-direction: column;
    text-align: center;
}

.game-toast .toast-message {
    font-size: 1.1rem;
    font-weight: 500;
}

.game-toast .toast-actions {
    display: flex;
    gap: 1rem;
    margin-top: 1rem;
}

.game-toast .toast-actions .btn {
    padding: 0.5rem 1.5rem !important;
    font-size: 0.95rem !important;
    min-height: auto !important;
    border-radius: 8px;
}

@keyframes fadeInScale {
    from {
        opacity: 0;
        transform: scale(0.9);
    }

    to {
        opacity: 1;
        transform: scale(1);
    }
}

@keyframes fadeOutScale {
    from {
        opacity: 1;
        transform: scale(1);
    }

    to {
        opacity: 0;
        transform: scale(0.9);
    }
}

.game-toast.hiding {
    animation: fadeOutScale 0.2s ease-in forwards;
}