:root {
    --bg-color: #0f172a;
    --bg-secondary: #1e293b;
    --text-primary: #f8fafc;
    --text-secondary: #94a3b8;
    --accent-color: #a855f7;
    --accent-hover: #c084fc;
    --card-bg: rgba(30, 41, 59, 0.8);
    --card-border: rgba(255, 255, 255, 0.1);
    --board-light: #e8d4b8;
    --board-dark: #b58863;
    --player-color: #3b82f6;
    --enemy-color: #ef4444;
    --highlight-move: rgba(59, 130, 246, 0.4);
    --highlight-threat: rgba(239, 68, 68, 0.35);
    --highlight-capture: rgba(245, 158, 11, 0.5);
    --font-main: 'Outfit', sans-serif;
}

* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

body {
    font-family: var(--font-main);
    background-color: var(--bg-color);
    color: var(--text-primary);
    min-height: 100vh;
    overflow: hidden;
}

.background-animation {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: radial-gradient(circle at 50% 50%, #1e293b 0%, #0f172a 100%);
    z-index: -1;
}

/* Home Button */
.home-btn {
    position: fixed;
    top: 1rem;
    left: 1rem;
    width: 48px;
    height: 48px;
    background: var(--card-bg);
    border: 1px solid var(--card-border);
    border-radius: 12px;
    display: flex;
    align-items: center;
    justify-content: center;
    color: var(--text-secondary);
    text-decoration: none;
    transition: all 0.3s ease;
    z-index: 100;
    backdrop-filter: blur(10px);
}

.home-btn:hover {
    background: var(--accent-color);
    color: white;
    transform: scale(1.05);
}

.home-btn svg {
    width: 24px;
    height: 24px;
}

/* Screens */
.screen {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    display: none;
    justify-content: center;
    align-items: center;
    padding: 2rem;
    padding-top: 80px;
    overflow-y: auto;
}

.screen.active {
    display: flex;
    animation: fadeIn 0.5s ease-out;
}

@keyframes fadeIn {
    from {
        opacity: 0;
    }

    to {
        opacity: 1;
    }
}

/* Menu Screen */
.menu-container {
    display: flex;
    flex-direction: column;
    align-items: center;
    text-align: center;
    max-width: 600px;
    width: 100%;
    margin: auto;
}

.game-title {
    font-size: 3.5rem;
    font-weight: 700;
    margin-bottom: 0.5rem;
    background: linear-gradient(135deg, var(--accent-color), #f472b6);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    animation: glow 2s ease-in-out infinite alternate;
}

@keyframes glow {
    from {
        filter: drop-shadow(0 0 10px rgba(168, 85, 247, 0.5));
    }

    to {
        filter: drop-shadow(0 0 20px rgba(168, 85, 247, 0.8));
    }
}

.subtitle {
    font-size: 1.25rem;
    color: var(--text-secondary);
    margin-bottom: 3rem;
}

.menu-section {
    margin-bottom: 2.5rem;
}

.menu-section h2 {
    font-size: 1.1rem;
    color: var(--text-secondary);
    text-transform: uppercase;
    letter-spacing: 0.1em;
    margin-bottom: 1rem;
}

/* Piece Selection */
.piece-selection {
    display: flex;
    gap: 1rem;
    justify-content: center;
    flex-wrap: wrap;
}

.piece-btn {
    background: var(--card-bg);
    border: 2px solid var(--card-border);
    border-radius: 16px;
    padding: 1.5rem 2rem;
    cursor: pointer;
    transition: all 0.3s ease;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 0.5rem;
    min-width: 120px;
}

.piece-btn:hover {
    border-color: var(--accent-color);
    transform: translateY(-4px);
}

.piece-btn.selected {
    border-color: var(--accent-color);
    background: rgba(168, 85, 247, 0.2);
    box-shadow: 0 0 20px rgba(168, 85, 247, 0.3);
}

.piece-icon {
    font-size: 3rem;
    color: var(--player-color);
}

.piece-name {
    font-size: 1.1rem;
    font-weight: 600;
    color: var(--text-primary);
}

.piece-desc {
    font-size: 0.8rem;
    color: var(--text-secondary);
}

/* Difficulty Selection */
.difficulty-selection {
    display: flex;
    gap: 1rem;
    justify-content: center;
    flex-wrap: wrap;
}

.diff-btn {
    background: var(--card-bg);
    border: 2px solid var(--card-border);
    border-radius: 12px;
    padding: 1rem 1.5rem;
    cursor: pointer;
    transition: all 0.3s ease;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 0.3rem;
    min-width: 100px;
}

.diff-btn:hover {
    border-color: var(--accent-color);
}

.diff-btn.selected {
    border-color: var(--accent-color);
    background: rgba(168, 85, 247, 0.2);
}

.diff-name {
    font-size: 1rem;
    font-weight: 600;
    color: var(--text-primary);
}

.diff-stars {
    font-size: 0.9rem;
    color: #f59e0b;
}

/* Primary Button */
.primary-btn {
    background: linear-gradient(135deg, var(--accent-color), #9333ea);
    border: none;
    border-radius: 16px;
    padding: 1rem 3rem;
    font-family: var(--font-main);
    font-size: 1.2rem;
    font-weight: 600;
    color: white;
    cursor: pointer;
    transition: all 0.3s ease;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 0.5rem;
    margin-top: 1rem;
}

.primary-btn:hover:not(:disabled) {
    transform: translateY(-2px);
    box-shadow: 0 10px 30px rgba(168, 85, 247, 0.4);
}

.primary-btn:disabled {
    opacity: 0.5;
    cursor: not-allowed;
}

.btn-arrow {
    font-size: 1.4rem;
}

/* Menu Buttons Container */
.menu-buttons {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 1rem;
    width: 100%;
    margin-top: 2rem;
}

/* Secondary Button */
.secondary-btn {
    background: transparent;
    border: 2px solid var(--card-border);
    border-radius: 16px;
    padding: 0.75rem 2rem;
    font-family: var(--font-main);
    font-size: 1rem;
    font-weight: 500;
    color: var(--text-secondary);
    cursor: pointer;
    transition: all 0.3s ease;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 0.5rem;
}

.secondary-btn:hover {
    border-color: var(--accent-color);
    color: var(--text-primary);
}

/* Game Screen */
.game-header {
    position: fixed;
    top: 1rem;
    left: 50%;
    transform: translateX(-50%);
    display: flex;
    gap: 1.5rem;
    z-index: 10;
}

.stat-box {
    background: var(--card-bg);
    border: 1px solid var(--card-border);
    border-radius: 12px;
    padding: 0.75rem 1.5rem;
    display: flex;
    flex-direction: column;
    align-items: center;
    backdrop-filter: blur(10px);
}

.stat-label {
    font-size: 0.75rem;
    color: var(--text-secondary);
    text-transform: uppercase;
    letter-spacing: 0.05em;
}

.stat-value {
    font-size: 1.5rem;
    font-weight: 700;
    color: var(--accent-color);
}

/* Chess Board */
.board-container {
    position: relative;
    display: flex;
    justify-content: center;
    align-items: center;
}

.chess-board {
    display: grid;
    grid-template-columns: repeat(8, 1fr);
    grid-template-rows: repeat(8, 1fr);
    width: min(80vmin, 560px);
    height: min(80vmin, 560px);
    border: 4px solid var(--card-border);
    border-radius: 8px;
    overflow: hidden;
    box-shadow: 0 20px 60px rgba(0, 0, 0, 0.5);
}

.board-overlay {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    pointer-events: none;
    z-index: 5;
}

.square {
    position: relative;
    display: flex;
    justify-content: center;
    align-items: center;
    font-size: min(8vmin, 56px);
    cursor: pointer;
    transition: background-color 0.2s ease;
    user-select: none;
}

.square.light {
    background-color: var(--board-light);
}

.square.dark {
    background-color: var(--board-dark);
}

.square.highlight-move {
    background-color: var(--highlight-move) !important;
}

.square.highlight-threat {
    box-shadow: inset 0 0 0 4px var(--highlight-threat);
}

.square.highlight-capture {
    background-color: var(--highlight-capture) !important;
}

.square.highlight-last-move {
    box-shadow: inset 0 0 0 3px rgba(168, 85, 247, 0.6);
}

.square.selected {
    box-shadow: inset 0 0 0 4px var(--player-color);
}
/* Goal row highlight - subtle pulse animation */
.square.goal-row {
    animation: goalRowPulse 2s ease-in-out infinite;
}

.square.goal-row.light {
    background: linear-gradient(135deg, #e8d4b8 0%, #fef3c7 50%, #e8d4b8 100%);
    background-size: 200% 200%;
}

.square.goal-row.dark {
    background: linear-gradient(135deg, #b58863 0%, #d97706 50%, #b58863 100%);
    background-size: 200% 200%;
}

@keyframes goalRowPulse {
    0%, 100% {
        box-shadow: inset 0 0 8px rgba(250, 204, 21, 0.3);
        background-position: 0% 50%;
    }
    50% {
        box-shadow: inset 0 0 15px rgba(250, 204, 21, 0.5);
        background-position: 100% 50%;
    }
}

.piece {
    position: absolute;
    width: 100%;
    height: 100%;
    display: flex;
    justify-content: center;
    align-items: center;
    transition: transform 0.1s ease;
    z-index: 2;
}

.piece.player {
    color: var(--player-color);
    filter: drop-shadow(0 2px 4px rgba(0, 0, 0, 0.5));
}

.piece.enemy {
    color: var(--enemy-color);
    filter: drop-shadow(0 2px 4px rgba(0, 0, 0, 0.5));
}

.piece.moving {
    animation: pieceMove 0.3s ease-out;
}

@keyframes pieceMove {
    0% {
        transform: scale(1.2);
    }

    100% {
        transform: scale(1);
    }
}

.piece.captured {
    animation: pieceCaptured 0.4s ease-out forwards;
}

@keyframes pieceCaptured {
    0% {
        transform: scale(1);
        opacity: 1;
    }

    50% {
        transform: scale(1.3) rotate(15deg);
    }

    100% {
        transform: scale(0);
        opacity: 0;
    }
}

/* Move indicator dot */
.move-dot {
    position: absolute;
    width: 25%;
    height: 25%;
    background: var(--player-color);
    border-radius: 50%;
    opacity: 0.7;
    z-index: 1;
}

/* Game Footer */
.game-footer {
    position: fixed;
    bottom: 1.5rem;
    left: 50%;
    transform: translateX(-50%);
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 1rem;
    z-index: 10;
}

.power-ups {
    display: flex;
    gap: 0.75rem;
}

.power-up-btn {
    background: var(--card-bg);
    border: 2px solid var(--card-border);
    border-radius: 12px;
    padding: 0.75rem 1rem;
    cursor: pointer;
    transition: all 0.3s ease;
    display: flex;
    align-items: center;
    gap: 0.5rem;
    font-family: var(--font-main);
    color: var(--text-primary);
    font-size: 0.9rem;
}

.power-up-btn:hover:not(:disabled) {
    border-color: #10b981;
    background: rgba(16, 185, 129, 0.2);
}

.power-up-btn:disabled {
    opacity: 0.5;
    cursor: not-allowed;
}

.power-up-btn .uses {
    background: rgba(16, 185, 129, 0.3);
    padding: 0.2rem 0.5rem;
    border-radius: 6px;
    font-size: 0.75rem;
    color: #10b981;
}

.turn-indicator {
    background: var(--card-bg);
    border: 1px solid var(--card-border);
    border-radius: 20px;
    padding: 0.5rem 1.5rem;
    font-size: 0.9rem;
    color: var(--text-secondary);
    backdrop-filter: blur(10px);
}

.turn-indicator.player-turn {
    color: var(--player-color);
    border-color: var(--player-color);
}

.turn-indicator.enemy-turn {
    color: var(--enemy-color);
    border-color: var(--enemy-color);
}

/* Power-up Selection Screen */
.powerup-container {
    text-align: center;
    max-width: 700px;
    width: 100%;
}

.powerup-container h2 {
    font-size: 2.5rem;
    margin-bottom: 0.5rem;
    color: #10b981;
}

.powerup-container p {
    color: var(--text-secondary);
    margin-bottom: 2rem;
}

.powerup-choices {
    display: flex;
    gap: 1.5rem;
    justify-content: center;
    flex-wrap: wrap;
}

.powerup-card {
    background: var(--card-bg);
    border: 2px solid var(--card-border);
    border-radius: 16px;
    padding: 2rem 1.5rem;
    cursor: pointer;
    transition: all 0.3s ease;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 0.75rem;
    min-width: 180px;
    max-width: 200px;
}

.powerup-card:hover {
    border-color: #10b981;
    transform: translateY(-6px);
    box-shadow: 0 15px 40px rgba(16, 185, 129, 0.2);
}

.powerup-card .powerup-icon {
    font-size: 3rem;
}

.powerup-card .powerup-name {
    font-size: 1.1rem;
    font-weight: 600;
    color: var(--text-primary);
}

.powerup-card .powerup-desc {
    font-size: 0.85rem;
    color: var(--text-secondary);
    text-align: center;
    line-height: 1.4;
}

/* Game Over Screen */
.gameover-container {
    text-align: center;
    max-width: 500px;
    width: 100%;
}

.gameover-container h1 {
    font-size: 3rem;
    margin-bottom: 2rem;
    color: var(--enemy-color);
}

.final-stats {
    display: flex;
    justify-content: center;
    gap: 3rem;
    margin-bottom: 2rem;
}

.final-stat {
    display: flex;
    flex-direction: column;
    align-items: center;
}

.final-label {
    font-size: 0.9rem;
    color: var(--text-secondary);
    text-transform: uppercase;
    letter-spacing: 0.05em;
}

.final-value {
    font-size: 3rem;
    font-weight: 700;
    color: var(--accent-color);
}

/* Board transition animation */
.board-transition {
    animation: boardSlide 0.8s ease-in-out;
}

@keyframes boardSlide {
    0% {
        transform: translateY(0);
        opacity: 1;
    }

    40% {
        transform: translateY(50px);
        opacity: 0;
    }

    60% {
        transform: translateY(-50px);
        opacity: 0;
    }

    100% {
        transform: translateY(0);
        opacity: 1;
    }
}

/* Responsive */
@media (max-width: 600px) {
    .game-title {
        font-size: 2.5rem;
    }

    .piece-selection {
        flex-direction: column;
        align-items: center;
    }

    .piece-btn {
        width: 100%;
        max-width: 200px;
    }

    .game-header {
        gap: 0.75rem;
    }

    .stat-box {
        padding: 0.5rem 1rem;
    }

    .stat-value {
        font-size: 1.2rem;
    }

    .chess-board {
        width: 90vmin;
        height: 90vmin;
    }

    .square {
        font-size: 10vmin;
    }
}

/* Smooth piece movement animation */
.piece.piece-animate {
    animation: pieceSlide 0.25s ease-out forwards;
}

@keyframes pieceSlide {
    0% {
        transform: translate(var(--move-from-x, 0), var(--move-from-y, 0));
    }

    100% {
        transform: translate(0, 0);
    }
}

/* ==================== ENHANCED MOBILE RESPONSIVE ==================== */

/* Tablet and small laptops */
@media (max-width: 768px) {
    .screen {
        padding: 1rem;
    }

    .menu-container {
        padding: 0 0.5rem;
    }

    .game-title {
        font-size: 2.2rem;
    }

    .subtitle {
        font-size: 1rem;
        margin-bottom: 2rem;
    }

    .menu-section {
        margin-bottom: 1.5rem;
    }

    .menu-section h2 {
        font-size: 0.9rem;
    }

    .difficulty-selection {
        gap: 0.5rem;
    }

    .diff-btn {
        padding: 0.75rem 1rem;
        min-width: 80px;
    }

    .primary-btn {
        padding: 0.875rem 2rem;
        font-size: 1.1rem;
    }

    .chess-board {
        width: min(85vmin, 480px);
        height: min(85vmin, 480px);
        border-width: 3px;
    }

    .powerup-choices {
        gap: 1rem;
    }

    .powerup-card {
        padding: 1.5rem 1rem;
        min-width: 150px;
    }
}

/* Mobile phones */
@media (max-width: 480px) {
    .home-btn {
        width: 40px;
        height: 40px;
        top: 0.5rem;
        left: 0.5rem;
        border-radius: 10px;
    }

    .home-btn svg {
        width: 20px;
        height: 20px;
    }

    .screen {
        padding: 0.5rem;
        overflow-y: auto;
    }

    .game-title {
        font-size: 1.8rem;
        margin-bottom: 0.25rem;
    }

    .subtitle {
        font-size: 0.9rem;
        margin-bottom: 1.5rem;
    }

    .menu-section {
        margin-bottom: 1.25rem;
    }

    .menu-section h2 {
        font-size: 0.8rem;
        margin-bottom: 0.75rem;
    }

    .piece-selection {
        gap: 0.75rem;
    }

    .piece-btn {
        padding: 1rem 1.5rem;
        border-radius: 12px;
        min-width: 100px;
        max-width: none;
        width: auto;
    }

    .piece-icon {
        font-size: 2.2rem;
    }

    .piece-name {
        font-size: 1rem;
    }

    .piece-desc {
        font-size: 0.7rem;
    }

    .difficulty-selection {
        width: 100%;
        justify-content: space-between;
    }

    .diff-btn {
        flex: 1;
        padding: 0.6rem 0.5rem;
        min-width: 0;
        border-radius: 10px;
    }

    .diff-name {
        font-size: 0.85rem;
    }

    .diff-stars {
        font-size: 0.75rem;
    }

    .primary-btn {
        width: 100%;
        max-width: 280px;
        padding: 0.875rem 1.5rem;
        font-size: 1rem;
        border-radius: 12px;
    }

    /* Game screen mobile */
    .game-header {
        top: 0.5rem;
        gap: 0.4rem;
        width: calc(100% - 60px);
        justify-content: center;
    }

    .stat-box {
        padding: 0.4rem 0.6rem;
        border-radius: 8px;
        min-width: 60px;
    }

    .stat-label {
        font-size: 0.6rem;
        letter-spacing: 0;
    }

    .stat-value {
        font-size: 1rem;
    }

    /* Chessboard mobile - maximize screen usage */
    .board-container {
        margin-top: 50px;
    }

    .chess-board {
        width: calc(100vw - 16px);
        height: calc(100vw - 16px);
        max-width: 95vmin;
        max-height: 95vmin;
        border-width: 2px;
        border-radius: 6px;
    }

    .square {
        font-size: calc((100vw - 16px) / 8 * 0.7);
    }

    .move-dot {
        width: 20%;
        height: 20%;
    }

    /* Game footer mobile */
    .game-footer {
        bottom: 0.5rem;
        gap: 0.5rem;
        width: 100%;
        padding: 0 0.5rem;
    }

    .power-ups {
        flex-wrap: wrap;
        justify-content: center;
        gap: 0.4rem;
    }

    .power-up-btn {
        padding: 0.5rem 0.75rem;
        font-size: 0.75rem;
        border-radius: 8px;
    }

    .power-up-btn .uses {
        padding: 0.15rem 0.35rem;
        font-size: 0.65rem;
    }

    .turn-indicator {
        padding: 0.4rem 1rem;
        font-size: 0.8rem;
        border-radius: 15px;
    }

    /* Power-up selection mobile */
    .powerup-container h2 {
        font-size: 1.8rem;
    }

    .powerup-container p {
        font-size: 0.9rem;
        margin-bottom: 1.5rem;
    }

    .powerup-choices {
        flex-direction: column;
        align-items: center;
        gap: 0.75rem;
    }

    .powerup-card {
        width: 100%;
        max-width: 280px;
        padding: 1.25rem 1rem;
        flex-direction: row;
        gap: 1rem;
        text-align: left;
    }

    .powerup-card .powerup-icon {
        font-size: 2rem;
    }

    .powerup-card .powerup-name {
        font-size: 1rem;
    }

    .powerup-card .powerup-desc {
        font-size: 0.75rem;
        text-align: left;
    }

    /* Game over mobile */
    .gameover-container h1 {
        font-size: 2rem;
        margin-bottom: 1.5rem;
    }

    .final-stats {
        gap: 2rem;
        margin-bottom: 1.5rem;
    }

    .final-value {
        font-size: 2.2rem;
    }

    .final-label {
        font-size: 0.8rem;
    }
}

/* Very small phones */
@media (max-width: 360px) {
    .game-title {
        font-size: 1.5rem;
    }

    .piece-btn {
        padding: 0.75rem 1rem;
    }

    .piece-icon {
        font-size: 1.8rem;
    }

    .stat-box {
        padding: 0.3rem 0.5rem;
        min-width: 50px;
    }

    .stat-value {
        font-size: 0.9rem;
    }

    .chess-board {
        width: calc(100vw - 8px);
        height: calc(100vw - 8px);
    }
}

/* Landscape mobile */
@media (max-height: 500px) and (orientation: landscape) {
    .screen {
        padding: 0.5rem;
    }

    .menu-container {
        display: flex;
        flex-wrap: wrap;
        gap: 1rem;
        justify-content: center;
        align-items: center;
    }

    .game-title {
        width: 100%;
        font-size: 1.5rem;
        margin-bottom: 0;
    }

    .subtitle {
        display: none;
    }

    .menu-section {
        margin-bottom: 0;
    }

    .piece-selection {
        flex-direction: row;
    }

    .piece-btn {
        padding: 0.5rem 0.75rem;
    }

    .piece-icon {
        font-size: 1.5rem;
    }

    .piece-name,
    .piece-desc {
        font-size: 0.7rem;
    }

    .game-header {
        top: 0.25rem;
    }

    .board-container {
        margin-top: 35px;
    }

    .chess-board {
        width: min(70vh, 70vw);
        height: min(70vh, 70vw);
    }

    .game-footer {
        bottom: 0.25rem;
    }
}

/* Touch-friendly improvements */
@media (hover: none) and (pointer: coarse) {
    .square {
        cursor: default;
    }

    .square:active {
        opacity: 0.8;
    }

    .piece-btn:active,
    .diff-btn:active,
    .primary-btn:active,
    .powerup-card:active {
        transform: scale(0.98);
    }
}

/* ==================== DEFEAT VISUALIZATION ==================== */

/* Killer piece highlight with animated glow */
.killer-piece {
    animation: killerGlow 0.5s ease-in-out infinite alternate;
    filter: drop-shadow(0 0 15px rgba(239, 68, 68, 0.8)) !important;
}

.killer-square {
    animation: killerSquare 0.5s ease-in-out infinite alternate;
}

@keyframes killerGlow {
    0% {
        transform: scale(1);
        filter: drop-shadow(0 0 10px rgba(239, 68, 68, 0.6));
    }

    100% {
        transform: scale(1.1);
        filter: drop-shadow(0 0 20px rgba(239, 68, 68, 1));
    }
}

@keyframes killerSquare {
    0% {
        box-shadow: inset 0 0 0 4px rgba(239, 68, 68, 0.6);
    }

    100% {
        box-shadow: inset 0 0 0 6px rgba(239, 68, 68, 1);
    }
}

/* Defeat reason message */
.defeat-reason {
    font-size: 1.3rem;
    color: var(--enemy-color);
    margin-bottom: 1.5rem;
    font-weight: 500;
    animation: fadeInUp 0.5s ease-out;
}

@keyframes fadeInUp {
    from {
        opacity: 0;
        transform: translateY(10px);
    }

    to {
        opacity: 1;
        transform: translateY(0);
    }
}

/* ==================== MENU BUTTONS ==================== */

.menu-buttons {
    display: flex;
    flex-direction: column;
    gap: 1rem;
    align-items: center;
    margin-top: 1.5rem;
}

.secondary-btn {
    background: transparent;
    border: 2px solid var(--card-border);
    border-radius: 12px;
    padding: 0.75rem 2rem;
    font-family: var(--font-main);
    font-size: 1rem;
    font-weight: 500;
    color: var(--text-secondary);
    cursor: pointer;
    transition: all 0.3s ease;
}

.secondary-btn:hover {
    border-color: var(--accent-color);
    color: var(--accent-color);
    transform: translateY(-2px);
}

/* ==================== RULES SCREEN ==================== */

.rules-container {
    text-align: center;
    max-width: 700px;
    width: 100%;
    max-height: 90vh;
    overflow-y: auto;
    padding: 1rem;
}

.rules-container h1 {
    font-size: 2.5rem;
    margin-bottom: 2rem;
    background: linear-gradient(135deg, var(--accent-color), #f472b6);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
}

.rules-section {
    background: var(--card-bg);
    border: 1px solid var(--card-border);
    border-radius: 16px;
    padding: 1.5rem;
    margin-bottom: 1.5rem;
    text-align: left;
}

.rules-section h2 {
    font-size: 1.3rem;
    margin-bottom: 1rem;
    color: var(--accent-color);
}

.rules-section p {
    color: var(--text-secondary);
    line-height: 1.6;
    margin-bottom: 0.75rem;
}

/* Scoring Table */
.scoring-table {
    width: 100%;
    border-collapse: collapse;
    margin: 1rem 0;
    background: rgba(0, 0, 0, 0.2);
    border-radius: 8px;
    overflow: hidden;
}

.scoring-table th,
.scoring-table td {
    padding: 0.75rem;
    text-align: center;
    border-bottom: 1px solid var(--card-border);
}

.scoring-table th {
    background: rgba(168, 85, 247, 0.2);
    color: var(--accent-color);
    font-weight: 600;
    text-transform: uppercase;
    font-size: 0.8rem;
    letter-spacing: 0.05em;
}

.scoring-table td {
    color: var(--text-primary);
}

.scoring-table tr:last-child td {
    border-bottom: none;
}

.scoring-table .piece-symbol {
    font-size: 1.5rem;
    color: var(--enemy-color);
}

.scoring-tips {
    background: rgba(16, 185, 129, 0.1);
    border: 1px solid rgba(16, 185, 129, 0.3);
    border-radius: 8px;
    padding: 1rem;
    margin-top: 1rem;
}

.scoring-tips p {
    margin-bottom: 0.5rem;
    color: #10b981;
}

.scoring-tips p:last-child {
    margin-bottom: 0;
}

/* Demo Area */
.demo-area {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 1rem;
}

.demo-board {
    display: grid;
    grid-template-columns: repeat(8, 1fr);
    grid-template-rows: repeat(8, 1fr);
    width: 280px;
    height: 280px;
    border: 3px solid var(--card-border);
    border-radius: 8px;
    overflow: hidden;
}

.demo-board .square {
    font-size: 28px;
}

.demo-controls {
    display: flex;
    flex-wrap: wrap;
    gap: 0.5rem;
    justify-content: center;
}

.demo-btn {
    background: var(--card-bg);
    border: 1px solid var(--card-border);
    border-radius: 8px;
    padding: 0.5rem 1rem;
    font-family: var(--font-main);
    font-size: 0.85rem;
    color: var(--text-primary);
    cursor: pointer;
    transition: all 0.3s ease;
}

.demo-btn:hover {
    border-color: var(--accent-color);
    background: rgba(168, 85, 247, 0.2);
}

.demo-btn.active {
    border-color: #10b981;
    background: rgba(16, 185, 129, 0.2);
}

.demo-message {
    font-size: 1.1rem;
    color: var(--accent-color);
    min-height: 1.5rem;
    font-weight: 500;
}

/* Rules responsive */
@media (max-width: 600px) {
    .rules-container h1 {
        font-size: 2rem;
    }

    .rules-section {
        padding: 1rem;
    }

    .rules-section h2 {
        font-size: 1.1rem;
    }

    .demo-board {
        width: 220px;
        height: 220px;
    }

    .demo-board .square {
        font-size: 22px;
    }

    .demo-btn {
        font-size: 0.75rem;
        padding: 0.4rem 0.8rem;
    }
}

/* ==================== MULTIPLAYER STYLES ==================== */

/* Mode Selection */
.mode-selection {
    display: flex;
    gap: 1.5rem;
    justify-content: center;
    margin-bottom: 2rem;
}

.mode-btn {
    display: flex;
    flex-direction: column;
    align-items: center;
    padding: 2rem 3rem;
    background: var(--card-bg);
    border: 2px solid var(--card-border);
    border-radius: 16px;
    cursor: pointer;
    transition: all 0.3s ease;
    color: var(--text-primary);
    font-family: var(--font-main);
}

.mode-btn:hover {
    border-color: var(--accent-color);
    transform: translateY(-5px);
    box-shadow: 0 10px 30px rgba(168, 85, 247, 0.3);
}

.mode-icon {
    font-size: 3rem;
    margin-bottom: 0.5rem;
}

.mode-name {
    font-size: 1.3rem;
    font-weight: 600;
    margin-bottom: 0.25rem;
}

.mode-desc {
    font-size: 0.9rem;
    color: var(--text-secondary);
}

.multi-options {
    display: flex;
    flex-direction: column;
    gap: 1rem;
    margin-bottom: 2rem;
    width: 100%;
    max-width: 400px;
}

.multi-options .mode-btn {
    flex-direction: row;
    justify-content: flex-start;
    gap: 1rem;
    padding: 1.5rem;
}

.multi-options .mode-icon {
    font-size: 2rem;
    margin-bottom: 0;
}

.time-selection {
    display: flex;
    gap: 0.75rem;
    justify-content: center;
    flex-wrap: wrap;
}

.time-btn {
    padding: 0.75rem 1.5rem;
    background: var(--card-bg);
    border: 2px solid var(--card-border);
    border-radius: 12px;
    color: var(--text-primary);
    font-size: 1rem;
    font-weight: 500;
    font-family: var(--font-main);
    cursor: pointer;
    transition: all 0.3s ease;
}

.time-btn:hover {
    border-color: var(--accent-color);
}

.time-btn.selected {
    background: var(--accent-color);
    border-color: var(--accent-color);
}

.toggle-option {
    display: flex;
    align-items: center;
    gap: 1rem;
    justify-content: center;
    cursor: pointer;
}

.toggle-option input {
    display: none;
}

.toggle-slider {
    width: 50px;
    height: 28px;
    background: var(--card-border);
    border-radius: 14px;
    position: relative;
    transition: all 0.3s ease;
}

.toggle-slider::before {
    content: '';
    position: absolute;
    top: 3px;
    left: 3px;
    width: 22px;
    height: 22px;
    background: white;
    border-radius: 50%;
    transition: all 0.3s ease;
}

.toggle-option input:checked+.toggle-slider {
    background: var(--accent-color);
}

.toggle-option input:checked+.toggle-slider::before {
    left: 25px;
}

.toggle-label {
    font-size: 1rem;
    color: var(--text-primary);
}

.join-form {
    margin-bottom: 1.5rem;
}

.room-code-input {
    width: 200px;
    padding: 1rem;
    font-size: 2rem;
    font-weight: 700;
    font-family: var(--font-main);
    text-align: center;
    text-transform: uppercase;
    letter-spacing: 0.3em;
    background: var(--card-bg);
    border: 2px solid var(--card-border);
    border-radius: 12px;
    color: var(--text-primary);
    outline: none;
    transition: all 0.3s ease;
}

.room-code-input:focus {
    border-color: var(--accent-color);
}

.room-code-input::placeholder {
    color: var(--text-secondary);
    letter-spacing: 0.5em;
}

.join-hint {
    font-size: 0.85rem;
    color: var(--text-secondary);
    margin-top: 0.5rem;
}

.error-message {
    color: #ef4444;
    font-size: 0.9rem;
    margin-bottom: 1rem;
    min-height: 1.2rem;
}

.room-code-display {
    text-align: center;
    margin-bottom: 2rem;
}

.room-code-display p {
    color: var(--text-secondary);
    margin-bottom: 0.5rem;
}

.room-code-big {
    font-size: 3rem;
    font-weight: 700;
    letter-spacing: 0.3em;
    color: var(--accent-color);
    background: var(--card-bg);
    padding: 1rem 2rem;
    border-radius: 12px;
    display: inline-block;
}

.room-code-hint {
    font-size: 0.85rem;
    color: var(--text-secondary);
    margin-top: 0.5rem;
}

.room-settings-display {
    display: flex;
    flex-wrap: wrap;
    gap: 1rem;
    justify-content: center;
    margin-bottom: 2rem;
    padding: 1rem;
    background: var(--card-bg);
    border-radius: 12px;
}

.setting-item {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    padding: 0.5rem 1rem;
    background: rgba(0, 0, 0, 0.2);
    border-radius: 8px;
}

.setting-icon {
    font-size: 1.5rem;
}

.setting-label {
    color: var(--text-secondary);
}

.players-list {
    width: 100%;
    max-width: 400px;
    margin-bottom: 2rem;
}

.players-list h3 {
    font-size: 1.1rem;
    color: var(--text-secondary);
    margin-bottom: 1rem;
    text-align: center;
}

.player-item {
    display: flex;
    align-items: center;
    gap: 1rem;
    padding: 1rem;
    background: var(--card-bg);
    border: 1px solid var(--card-border);
    border-radius: 12px;
    margin-bottom: 0.5rem;
}

.player-item.host {
    border-color: var(--accent-color);
}

.player-item.waiting {
    opacity: 0.6;
}

.player-icon {
    font-size: 1.5rem;
}

.player-name {
    flex: 1;
    font-weight: 500;
}

.player-status {
    font-size: 0.85rem;
    padding: 0.25rem 0.75rem;
    border-radius: 12px;
}

.player-status.ready {
    background: rgba(16, 185, 129, 0.2);
    color: #10b981;
}

.timer-box {
    background: rgba(239, 68, 68, 0.2) !important;
    border-color: rgba(239, 68, 68, 0.5) !important;
}

.timer-value {
    color: #ef4444 !important;
    font-variant-numeric: tabular-nums;
}

.timer-value.warning {
    animation: timerPulse 0.5s ease-in-out infinite;
}

@keyframes timerPulse {

    0%,
    100% {
        opacity: 1;
    }

    50% {
        opacity: 0.5;
    }
}

.opponent-bar {
    position: absolute;
    top: 70px;
    left: 50%;
    transform: translateX(-50%);
    display: flex;
    align-items: center;
    gap: 1rem;
    padding: 0.5rem 1.5rem;
    background: var(--card-bg);
    border: 1px solid var(--card-border);
    border-radius: 25px;
    font-size: 0.9rem;
    z-index: 10;
}

.opponent-label {
    color: var(--text-secondary);
}

.opponent-name {
    font-weight: 600;
    color: var(--enemy-color);
}

.opponent-score-label,
.opponent-round-label {
    color: var(--text-secondary);
    margin-left: 1rem;
}

.opponent-score,
.opponent-round {
    font-weight: 600;
    color: var(--text-primary);
}

.speed-bonus-popup {
    position: fixed;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    padding: 1rem 2rem;
    background: linear-gradient(135deg, #f59e0b, #eab308);
    border-radius: 12px;
    font-size: 1.5rem;
    font-weight: 700;
    color: #1e293b;
    z-index: 1000;
    animation: speedBonusAnim 2s ease-out forwards;
}

@keyframes speedBonusAnim {
    0% {
        opacity: 0;
        transform: translate(-50%, -50%) scale(0.5);
    }

    20% {
        opacity: 1;
        transform: translate(-50%, -50%) scale(1.1);
    }

    30% {
        transform: translate(-50%, -50%) scale(1);
    }

    80% {
        opacity: 1;
    }

    100% {
        opacity: 0;
        transform: translate(-50%, -100%) scale(0.8);
    }
}

.waiting-spinner {
    font-size: 3rem;
    animation: spin 2s linear infinite;
    margin-top: 1rem;
}

@keyframes spin {
    from {
        transform: rotate(0deg);
    }

    to {
        transform: rotate(360deg);
    }
}

.results-container {
    text-align: center;
    max-width: 600px;
    width: 100%;
}

.results-container h1 {
    font-size: 2.5rem;
    margin-bottom: 2rem;
}

.results-players {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 2rem;
    margin-bottom: 2rem;
}

.player-result {
    padding: 1.5rem 2rem;
    background: var(--card-bg);
    border: 2px solid var(--card-border);
    border-radius: 16px;
    min-width: 180px;
    position: relative;
}

.player-result.winner {
    border-color: #f59e0b;
    background: rgba(245, 158, 11, 0.1);
}

.result-crown {
    position: absolute;
    top: -20px;
    left: 50%;
    transform: translateX(-50%);
    font-size: 2rem;
}

.result-name {
    font-size: 1.1rem;
    font-weight: 600;
    margin-bottom: 0.5rem;
}

.result-score {
    font-size: 2.5rem;
    font-weight: 700;
    color: var(--accent-color);
}

.result-rounds {
    font-size: 0.9rem;
    color: var(--text-secondary);
}

.vs-divider {
    font-size: 1.5rem;
    font-weight: 700;
    color: var(--text-secondary);
}

.overlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.8);
    display: flex;
    justify-content: center;
    align-items: center;
    z-index: 2000;
}

.overlay-content {
    background: var(--card-bg);
    padding: 2rem;
    border-radius: 16px;
    text-align: center;
    max-width: 400px;
}

.overlay-content h2 {
    margin-bottom: 1rem;
}

.overlay-content p {
    color: var(--text-secondary);
    margin-bottom: 1.5rem;
}

@media (max-width: 600px) {
    .mode-selection {
        flex-direction: column;
    }

    .mode-btn {
        padding: 1.5rem 2rem;
    }

    .mode-icon {
        font-size: 2rem;
    }

    .room-code-big {
        font-size: 2rem;
        letter-spacing: 0.2em;
    }

    .results-players {
        flex-direction: column;
        gap: 1rem;
    }

    .opponent-bar {
        flex-wrap: wrap;
        padding: 0.5rem 1rem;
        gap: 0.5rem;
        font-size: 0.8rem;
    }
}
/* Tutorial Overlay */
.tutorial-overlay {
    z-index: 200;
}

.tutorial-content {
    max-width: 500px;
}

.tutorial-subtitle {
    color: var(--text-secondary);
    margin-bottom: 1.5rem;
}

.tutorial-demo-board {
    margin: 1.5rem auto;
    width: min(60vmin, 300px);
    height: min(60vmin, 300px);
}

.tutorial-btn {
    margin-top: 1.5rem;
}
/* Matchmaking Button */
.matchmaking-btn {
    background: linear-gradient(135deg, rgba(245, 158, 11, 0.2), rgba(168, 85, 247, 0.2));
    border-color: #f59e0b;
}

.matchmaking-btn:hover {
    border-color: #fbbf24;
    background: linear-gradient(135deg, rgba(245, 158, 11, 0.3), rgba(168, 85, 247, 0.3));
}

/* Matchmaking Queue Animation */
.matchmaking-animation {
    display: flex;
    justify-content: center;
    align-items: center;
    margin: 2rem 0;
}

.spinner {
    width: 60px;
    height: 60px;
    border: 4px solid var(--card-border);
    border-top-color: var(--accent-color);
    border-radius: 50%;
    animation: spin 1s linear infinite;
}

@keyframes spin {
    0% { transform: rotate(0deg); }
    100% { transform: rotate(360deg); }
}

.matchmaking-status {
    color: var(--text-secondary);
    font-size: 1.1rem;
    margin-bottom: 2rem;
    animation: pulse-text 2s ease-in-out infinite;
}

@keyframes pulse-text {
    0%, 100% { opacity: 0.7; }
    50% { opacity: 1; }
}