/**
 * ChessMaster - Main Stylesheet
 * Modern chess-themed design with smooth animations
 */

/* ===== CSS VARIABLES ===== */
:root {
    /* Chess-themed color palette */
    --color-primary: #C49A56;
    /* Gold */
    --color-primary-dark: #A67C3F;
    --color-secondary: #2C3E50;
    /* Dark blue-gray */
    --color-accent: #E74C3C;
    /* Red accent */
    --color-success: #27AE60;
    --color-warning: #F39C12;
    --color-danger: #E74C3C;

    /* Board colors */
    --color-square-light: #F0D9B5;
    --color-square-dark: #B58863;

    /* Neutral colors */
    --color-dark: #1a1a1a;
    --color-gray-dark: #2c2c2c;
    --color-gray: #4a4a4a;
    --color-gray-light: #e0e0e0;
    --color-light: #f8f9fa;
    --color-white: #ffffff;

    /* Typography */
    --font-primary: 'Inter', sans-serif;
    --font-display: 'Playfair Display', serif;

    /* Spacing */
    --spacing-xs: 0.5rem;
    --spacing-sm: 1rem;
    --spacing-md: 1.5rem;
    --spacing-lg: 2rem;
    --spacing-xl: 3rem;

    /* Border radius */
    --radius-sm: 0.25rem;
    --radius-md: 0.5rem;
    --radius-lg: 1rem;

    /* Shadows */
    --shadow-sm: 0 2px 4px rgba(0, 0, 0, 0.1);
    --shadow-md: 0 4px 12px rgba(0, 0, 0, 0.15);
    --shadow-lg: 0 8px 24px rgba(0, 0, 0, 0.2);
    --shadow-xl: 0 16px 48px rgba(0, 0, 0, 0.3);

    /* Transitions */
    --transition-fast: 0.15s ease;
    --transition-base: 0.3s ease;
    --transition-slow: 0.5s ease;
}

/* ===== GLOBAL RESET ===== */
* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

html {
    font-size: 16px;
    scroll-behavior: smooth;
}

body {
    font-family: var(--font-primary);
    background: linear-gradient(-45deg, #0a0a0a, #1a1a1a, #0f0f0f, #252525);
    background-size: 400% 400%;
    animation: gradient 15s ease infinite;
    color: var(--color-light);
    line-height: 1.6;
    min-height: 100vh;
    overflow-x: hidden;
}

@keyframes gradient {
    0% {
        background-position: 0% 50%;
    }

    50% {
        background-position: 100% 50%;
    }

    100% {
        background-position: 0% 50%;
    }
}

/* ===== TYPOGRAPHY ===== */
h1,
h2,
h3,
h4,
h5,
h6 {
    font-weight: 700;
    line-height: 1.3;
    margin-bottom: var(--spacing-sm);
    color: var(--color-white);
}

h1 {
    font-size: 2.5rem;
    font-family: var(--font-display);
}

h2 {
    font-size: 2rem;
}

h3 {
    font-size: 1.75rem;
}

h4 {
    font-size: 1.5rem;
}

h5 {
    font-size: 1.25rem;
}

h6 {
    font-size: 1rem;
}

p {
    margin-bottom: var(--spacing-sm);
}

a {
    color: var(--color-primary);
    text-decoration: none;
    transition: color var(--transition-fast);
}

a:hover {
    color: var(--color-primary-dark);
}

/* ===== CONTAINER ===== */
.container {
    max-width: 1200px;
    margin: 0 auto;
    padding: 0 var(--spacing-md);
}

.container-fluid {
    width: 100%;
    padding: 0 var(--spacing-md);
}

/* ===== NAVBAR ===== */
.navbar {
    background: rgba(26, 26, 26, 0.85);
    backdrop-filter: blur(20px) saturate(180%);
    border-bottom: 1px solid rgba(196, 154, 86, 0.3);
    padding: var(--spacing-sm) 0;
    position: sticky;
    top: 0;
    z-index: 1000;
    box-shadow: 0 8px 32px rgba(0, 0, 0, 0.3);
    transition: all var(--transition-base);
}

.navbar:hover {
    background: rgba(26, 26, 26, 0.95);
    box-shadow: 0 8px 32px rgba(196, 154, 86, 0.15);
}

.navbar .container {
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.navbar-brand .logo {
    display: flex;
    align-items: center;
    gap: var(--spacing-xs);
    font-size: 1.5rem;
    font-weight: 700;
    color: var(--color-primary);
    font-family: var(--font-display);
    transition: transform var(--transition-base);
}

.navbar-brand .logo:hover {
    transform: scale(1.05);
    color: var(--color-primary);
}

.navbar-brand .logo i {
    font-size: 1.8rem;
}

.navbar-toggler {
    display: none;
    background: transparent;
    border: 2px solid var(--color-primary);
    color: var(--color-primary);
    font-size: 1.5rem;
    padding: var(--spacing-xs) var(--spacing-sm);
    cursor: pointer;
    border-radius: var(--radius-md);
    transition: all var(--transition-fast);
}

.navbar-toggler:hover {
    background: var(--color-primary);
    color: var(--color-dark);
}

.navbar-menu {
    display: flex;
    align-items: center;
    gap: var(--spacing-lg);
}

.navbar-nav {
    display: flex;
    list-style: none;
    gap: var(--spacing-md);
    align-items: center;
}

.navbar-right {
    margin-left: auto;
}

.nav-link {
    display: flex;
    align-items: center;
    gap: var(--spacing-xs);
    padding: var(--spacing-xs) var(--spacing-sm);
    color: var(--color-light);
    border-radius: var(--radius-md);
    transition: all var(--transition-fast);
    font-weight: 500;
}

.nav-link:hover,
.nav-item.active .nav-link {
    background: rgba(196, 154, 86, 0.1);
    color: var(--color-primary);
}

.admin-link {
    background: rgba(231, 76, 60, 0.1);
    border: 1px solid var(--color-accent);
}

.admin-link:hover {
    background: var(--color-accent);
    color: var(--color-white);
}

/* Dropdown */
.dropdown {
    position: relative;
}

.dropdown-toggle::after {
    content: '\f078';
    font-family: 'Font Awesome 6 Free';
    font-weight: 900;
    margin-left: var(--spacing-xs);
    font-size: 0.75rem;
}

.dropdown-menu {
    display: none;
    position: absolute;
    top: 100%;
    right: 0;
    background: var(--color-gray-dark);
    border: 1px solid rgba(196, 154, 86, 0.2);
    border-radius: var(--radius-md);
    min-width: 200px;
    margin-top: var(--spacing-xs);
    list-style: none;
    box-shadow: var(--shadow-lg);
    overflow: hidden;
    z-index: 1000;
}

.dropdown.show .dropdown-menu {
    display: block;
}

.dropdown-menu li a {
    display: flex;
    align-items: center;
    gap: var(--spacing-xs);
    padding: var(--spacing-sm);
    color: var(--color-light);
    transition: background var(--transition-fast);
}

.dropdown-menu li a:hover {
    background: rgba(196, 154, 86, 0.1);
    color: var(--color-primary);
}

/* ===== BUTTONS ===== */
.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: var(--spacing-xs);
    padding: var(--spacing-sm) var(--spacing-md);
    border: none;
    border-radius: var(--radius-md);
    font-weight: 600;
    font-size: 1rem;
    cursor: pointer;
    transition: all var(--transition-base);
    text-decoration: none;
    position: relative;
    overflow: hidden;
}

.btn::before {
    content: '';
    position: absolute;
    top: 50%;
    left: 50%;
    width: 0;
    height: 0;
    border-radius: 50%;
    background: rgba(255, 255, 255, 0.2);
    transform: translate(-50%, -50%);
    transition: width 0.6s, height 0.6s;
}

.btn:hover::before {
    width: 300px;
    height: 300px;
}

.btn-primary {
    background: linear-gradient(135deg, var(--color-primary) 0%, var(--color-primary-dark) 100%);
    color: var(--color-dark);
    box-shadow: var(--shadow-sm);
}

.btn-primary:hover {
    transform: translateY(-2px);
    box-shadow: var(--shadow-md);
    color: var(--color-dark);
}

.btn-secondary {
    background: var(--color-gray-dark);
    color: var(--color-light);
    border: 1px solid var(--color-gray);
}

.btn-secondary:hover {
    background: var(--color-gray);
    color: var(--color-white);
}

.btn-danger {
    background: var(--color-danger);
    color: var(--color-white);
}

.btn-danger:hover {
    background: #c0392b;
}

.btn-success {
    background: var(--color-success);
    color: var(--color-white);
}

.btn-lg {
    padding: var(--spacing-md) var(--spacing-lg);
    font-size: 1.125rem;
}

.btn-sm {
    padding: 0.5rem 1rem;
    font-size: 0.875rem;
}

.btn-block {
    width: 100%;
}

/* ===== CARDS ===== */
.card {
    background: rgba(255, 255, 255, 0.05);
    border: 1px solid rgba(255, 255, 255, 0.1);
    border-radius: var(--radius-lg);
    padding: var(--spacing-lg);
    box-shadow: var(--shadow-md);
    transition: all var(--transition-base);
    backdrop-filter: blur(10px);
    position: relative;
    overflow: hidden;
}

.card::before {
    content: '';
    position: absolute;
    top: -50%;
    left: -50%;
    width: 200%;
    height: 200%;
    background: radial-gradient(circle, rgba(196, 154, 86, 0.1) 0%, transparent 70%);
    opacity: 0;
    transition: opacity var(--transition-base);
    pointer-events: none;
    /* FIX: Don't block clicks! */
}

.card:hover::before {
    opacity: 1;
}

.card:hover {
    transform: translateY(-8px) scale(1.02);
    box-shadow: 0 12px 40px rgba(196, 154, 86, 0.2);
    border-color: rgba(196, 154, 86, 0.4);
}

.card-header {
    padding-bottom: var(--spacing-md);
    margin-bottom: var(--spacing-md);
    border-bottom: 1px solid rgba(255, 255, 255, 0.1);
}

.card-title {
    font-size: 1.5rem;
    color: var(--color-primary);
    display: flex;
    align-items: center;
    gap: var(--spacing-sm);
}

.card-body {
    color: var(--color-light);
}

/* ===== FORMS ===== */
.form-group {
    margin-bottom: var(--spacing-md);
}

.form-label {
    display: block;
    margin-bottom: var(--spacing-xs);
    font-weight: 500;
    color: var(--color-light);
}

.form-control {
    width: 100%;
    padding: var(--spacing-sm);
    background: rgba(255, 255, 255, 0.05);
    border: 1px solid rgba(255, 255, 255, 0.1);
    border-radius: var(--radius-md);
    color: var(--color-light);
    font-size: 1rem;
    transition: all var(--transition-base);
}

.form-control:focus {
    outline: none;
    border-color: var(--color-primary);
    background: rgba(255, 255, 255, 0.08);
    box-shadow: 0 0 0 3px rgba(196, 154, 86, 0.1);
}

.form-control::placeholder {
    color: rgba(255, 255, 255, 0.3);
}

select.form-control {
    cursor: pointer;
}

/* ===== CHESS BOARD ===== */
.chess-container {
    display: flex;
    gap: var(--spacing-lg);
    padding: var(--spacing-xl) 0;
}

.chess-board-wrapper {
    flex: 1;
    display: flex;
    flex-direction: column;
    align-items: center;
}

.chess-board {
    display: grid;
    grid-template-columns: repeat(8, 80px);
    grid-template-rows: repeat(8, 80px);
    width: 640px;
    height: 640px;
    border: 4px solid var(--color-primary);
    border-radius: var(--radius-md);
    box-shadow: var(--shadow-xl);
    background: var(--color-square-light);
}

.chess-square {
    width: 80px;
    height: 80px;
    display: flex;
    align-items: center;
    justify-content: center;
    position: relative;
    cursor: pointer;
    transition: all var(--transition-fast);
    box-sizing: border-box;
}

.chess-square:nth-child(even) {
    background: var(--color-square-dark);
}

.chess-square:nth-child(odd) {
    background: var(--color-square-light);
}

/* Make sure alternating pattern works */
.chess-square:nth-child(16n+9),
.chess-square:nth-child(16n+11),
.chess-square:nth-child(16n+13),
.chess-square:nth-child(16n+15),
.chess-square:nth-child(16n+2),
.chess-square:nth-child(16n+4),
.chess-square:nth-child(16n+6),
.chess-square:nth-child(16n+8) {
    background: var(--color-square-dark);
}

.chess-square:nth-child(16n+1),
.chess-square:nth-child(16n+3),
.chess-square:nth-child(16n+5),
.chess-square:nth-child(16n+7),
.chess-square:nth-child(16n+10),
.chess-square:nth-child(16n+12),
.chess-square:nth-child(16n+14),
.chess-square:nth-child(16n+16) {
    background: var(--color-square-light);
}

.chess-square:hover {
    filter: brightness(1.1);
}

.chess-square.selected {
    background: rgba(196, 154, 86, 0.5) !important;
    box-shadow: inset 0 0 10px rgba(196, 154, 86, 0.8);
}

.chess-square.valid-move::after {
    content: '';
    position: absolute;
    width: 30%;
    height: 30%;
    background: rgba(39, 174, 96, 0.6);
    border-radius: 50%;
}

.chess-square.capture::after {
    content: '';
    position: absolute;
    width: 80%;
    height: 80%;
    border: 3px solid rgba(231, 76, 60, 0.6);
    border-radius: 50%;
}

/* Chess.com style move hints */
.chess-square.valid-move-hint::after {
    content: '';
    position: absolute;
    width: 28%;
    height: 28%;
    background: radial-gradient(circle, rgba(0, 0, 0, 0.25) 0%, rgba(0, 0, 0, 0.15) 100%);
    border-radius: 50%;
    z-index: 5;
    pointer-events: none;
}

.chess-square.capture-hint::after {
    content: '';
    position: absolute;
    width: 100%;
    height: 100%;
    border: 5px solid rgba(0, 0, 0, 0.15);
    border-radius: 50%;
    box-sizing: border-box;
    z-index: 5;
    pointer-events: none;
}

/* Chess.com style last move highlight */
.chess-square.last-move-from,
.chess-square.last-move-to {
    background: rgba(255, 255, 0, 0.5) !important;
}

.chess-square.last-move-from.light,
.chess-square.last-move-to.light {
    background: rgba(247, 247, 130, 0.8) !important;
}

.chess-square.last-move-from.dark,
.chess-square.last-move-to.dark {
    background: rgba(187, 203, 43, 0.8) !important;
}

.chess-piece {
    font-size: 3.5rem;
    user-select: none;
    animation: pieceAppear 0.3s ease;
    filter: drop-shadow(2px 2px 4px rgba(0, 0, 0, 0.3));
}

@keyframes pieceAppear {
    from {
        transform: scale(0);
        opacity: 0;
    }

    to {
        transform: scale(1);
        opacity: 1;
    }
}

/* White pieces - white interior */
.piece-white {
    color: #fff;
    text-shadow:
        -1px -1px 0 #000,
        1px -1px 0 #000,
        -1px 1px 0 #000,
        1px 1px 0 #000;
}

/* Black pieces - black interior */
.piece-black {
    color: #000;
    text-shadow:
        -1px -1px 0 #fff,
        1px -1px 0 #fff,
        -1px 1px 0 #fff,
        1px 1px 0 #fff;
}

/* ===== GAME INFO PANEL ===== */
.game-info {
    flex: 0 0 300px;
    display: flex;
    flex-direction: column;
    gap: var(--spacing-md);
}

.move-history {
    background: rgba(255, 255, 255, 0.03);
    border: 1px solid rgba(255, 255, 255, 0.1);
    border-radius: var(--radius-lg);
    padding: var(--spacing-md);
    max-height: 400px;
    overflow-y: auto;
}

.move-list {
    list-style: none;
}

.move-item {
    padding: var(--spacing-xs);
    margin-bottom: var(--spacing-xs);
    background: rgba(255, 255, 255, 0.05);
    border-radius: var(--radius-sm);
    font-family: 'Courier New', monospace;
}

/* ===== FOOTER ===== */
.footer {
    background: rgba(26, 26, 26, 0.95);
    border-top: 1px solid rgba(196, 154, 86, 0.2);
    padding: var(--spacing-xl) 0 var(--spacing-md);
    margin-top: auto;
}

.footer-content {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(250px, 1fr));
    gap: var(--spacing-lg);
    margin-bottom: var(--spacing-lg);
}

.footer-section h3,
.footer-section h4 {
    color: var(--color-primary);
    margin-bottom: var(--spacing-sm);
}

.footer-links,
.footer-stats {
    list-style: none;
}

.footer-links li,
.footer-stats li {
    margin-bottom: var(--spacing-xs);
}

.footer-links a {
    color: var(--color-light);
    transition: color var(--transition-fast);
}

.footer-links a:hover {
    color: var(--color-primary);
}

.footer-bottom {
    border-top: 1px solid rgba(255, 255, 255, 0.1);
    padding-top: var(--spacing-md);
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.language-selector {
    display: flex;
    align-items: center;
    gap: var(--spacing-sm);
}

.language-select {
    padding: var(--spacing-xs) var(--spacing-sm);
    background: rgba(255, 255, 255, 0.05);
    border: 1px solid rgba(255, 255, 255, 0.1);
    border-radius: var(--radius-md);
    color: var(--color-light);
    cursor: pointer;
    transition: all var(--transition-base);
}

.language-select:focus {
    outline: none;
    border-color: var(--color-primary);
}

.copyright {
    color: rgba(255, 255, 255, 0.5);
    font-size: 0.875rem;
}

/* ===== HERO SECTION ===== */
.hero {
    text-align: center;
    padding: var(--spacing-xl) 0;
    background: linear-gradient(135deg, rgba(196, 154, 86, 0.1) 0%, rgba(44, 62, 80, 0.1) 100%);
    border-radius: var(--radius-lg);
    margin: var(--spacing-lg) 0;
}

.hero h1 {
    font-size: 3.5rem;
    margin-bottom: var(--spacing-md);
    background: linear-gradient(135deg, var(--color-primary) 0%, #fff 100%);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
}

.hero p {
    font-size: 1.25rem;
    color: var(--color-gray-light);
    margin-bottom: var(--spacing-lg);
}

/* ===== UTILITY CLASSES ===== */
.text-center {
    text-align: center;
}

.text-right {
    text-align: right;
}

.text-primary {
    color: var(--color-primary);
}

.text-danger {
    color: var(--color-danger);
}

.text-success {
    color: var(--color-success);
}

.text-muted {
    color: rgba(255, 255, 255, 0.5);
}

.mt-1 {
    margin-top: var(--spacing-sm);
}

.mt-2 {
    margin-top: var(--spacing-md);
}

.mt-3 {
    margin-top: var(--spacing-lg);
}

.mb-1 {
    margin-bottom: var(--spacing-sm);
}

.mb-2 {
    margin-bottom: var(--spacing-md);
}

.mb-3 {
    margin-bottom: var(--spacing-lg);
}

.p-1 {
    padding: var(--spacing-sm);
}

.p-2 {
    padding: var(--spacing-md);
}

.p-3 {
    padding: var(--spacing-lg);
}

.d-flex {
    display: flex;
}

.flex-column {
    flex-direction: column;
}

.align-center {
    align-items: center;
}

.justify-center {
    justify-content: center;
}

.gap-1 {
    gap: var(--spacing-sm);
}

.gap-2 {
    gap: var(--spacing-md);
}

.gap-3 {
    gap: var(--spacing-lg);
}

/* ===== RESPONSIVE DESIGN ===== */
@media (max-width: 992px) {
    .chess-container {
        flex-direction: column;
    }

    .game-info {
        flex: 1;
        width: 100%;
    }
}

@media (max-width: 768px) {
    .navbar-toggler {
        display: block;
    }

    .navbar-menu {
        display: none;
        position: absolute;
        top: 100%;
        left: 0;
        right: 0;
        background: rgba(26, 26, 26, 0.98);
        border-top: 1px solid rgba(196, 154, 86, 0.2);
        padding: var(--spacing-md);
        flex-direction: column;
        align-items: stretch;
    }

    .navbar-menu.active {
        display: flex;
    }

    .navbar-nav {
        flex-direction: column;
        width: 100%;
    }

    .nav-link {
        width: 100%;
    }

    .footer-bottom {
        flex-direction: column;
        gap: var(--spacing-md);
        text-align: center;
    }

    .hero h1 {
        font-size: 2.5rem;
    }
}

@media (max-width: 576px) {
    html {
        font-size: 14px;
    }

    .chess-piece {
        font-size: 2.5rem;
    }
}

/* ===== ANIMATIONS ===== */
@keyframes fadeIn {
    from {
        opacity: 0;
        transform: translateY(20px);
    }

    to {
        opacity: 1;
        transform: translateY(0);
    }
}

.fade-in {
    animation: fadeIn 0.5s ease;
}

/* ===== SCROLLBAR ===== */
::-webkit-scrollbar {
    width: 10px;
}

::-webkit-scrollbar-track {
    background: var(--color-gray-dark);
}

::-webkit-scrollbar-thumb {
    background: var(--color-primary);
    border-radius: var(--radius-md);
}

::-webkit-scrollbar-thumb:hover {
    background: var(--color-primary-dark);
}

/* ===== MOBILE RESPONSIVE ===== */

/* Tablet and Below (max-width: 1024px) */
@media (max-width: 1024px) {
    .container {
        padding: 0 1rem;
        max-width: 100%;
    }

    .game-container {
        flex-direction: column;
        gap: 1rem;
    }

    .game-info {
        width: 100%;
        order: 2;
    }

    .chess-board-container {
        width: 100%;
        order: 1;
    }
}

/* Mobile Landscape and Tablet Portrait (max-width: 768px) */
@media (max-width: 768px) {
    html {
        font-size: 14px;
    }

    /* Navigation */
    .navbar {
        padding: 0.5rem 1rem;
        flex-wrap: wrap;
    }

    .navbar .logo {
        font-size: 1.2rem;
    }

    .navbar .nav-links {
        flex-wrap: wrap;
        gap: 0.5rem;
        justify-content: center;
    }

    .navbar .nav-links a {
        padding: 0.4rem 0.8rem;
        font-size: 0.85rem;
    }

    /* Page Header */
    .page-header h1 {
        font-size: 1.8rem;
    }

    .page-header p {
        font-size: 0.95rem;
    }

    /* Cards Grid */
    .cards-grid,
    .game-modes {
        grid-template-columns: 1fr;
        gap: 1rem;
    }

    .card {
        margin-bottom: 1rem;
    }

    .card-header h3,
    .card-title {
        font-size: 1.1rem;
    }

    /* Chess Board */
    .chess-board {
        width: 100%;
        max-width: calc(100vw - 2rem);
        height: auto;
        aspect-ratio: 1;
        grid-template-columns: repeat(8, 1fr);
        grid-template-rows: repeat(8, 1fr);
        border-width: 2px;
    }

    .chess-square {
        width: 100%;
        height: 100%;
        padding-bottom: 0;
        position: relative;
    }

    .chess-piece {
        font-size: 2.5rem !important;
        position: absolute;
        top: 50%;
        left: 50%;
        transform: translate(-50%, -50%);
    }

    /* Game Info Panel */
    .game-info {
        display: flex;
        flex-direction: row;
        flex-wrap: wrap;
        gap: 0.5rem;
    }

    .game-info .card {
        flex: 1;
        min-width: 150px;
    }

    /* Move History */
    .move-history {
        max-height: 150px;
    }

    /* Buttons */
    .btn {
        padding: 0.6rem 1rem;
        font-size: 0.9rem;
    }

    /* Game buttons row */
    .game-container>div>div[style*="display: flex"] {
        flex-wrap: wrap;
        gap: 0.5rem !important;
    }

    .game-container button {
        flex: 1;
        min-width: 100px;
    }

    /* Forms */
    .form-control {
        padding: 0.6rem;
        font-size: 0.95rem;
    }

    /* Auth pages */
    .auth-container {
        padding: 1rem;
        max-width: 100%;
    }

    .auth-card {
        padding: 1.5rem;
    }
}

/* Mobile Portrait (max-width: 480px) */
@media (max-width: 480px) {
    html {
        font-size: 13px;
    }

    body {
        padding-bottom: 60px;
    }

    /* Navigation - Stack vertically on very small screens */
    .navbar {
        padding: 0.5rem;
    }

    .navbar .logo {
        font-size: 1rem;
        width: 100%;
        text-align: center;
        margin-bottom: 0.5rem;
    }

    .navbar .nav-links {
        width: 100%;
        justify-content: center;
        gap: 0.3rem;
    }

    .navbar .nav-links a {
        padding: 0.3rem 0.5rem;
        font-size: 0.75rem;
    }

    /* Page headers */
    .page-header {
        padding: 1rem 0;
    }

    .page-header h1 {
        font-size: 1.5rem;
    }

    /* Chess Board - Full width */
    .chess-board {
        max-width: calc(100vw - 1rem);
        margin: 0 auto;
    }

    .chess-piece {
        font-size: 2rem !important;
    }

    /* Cards */
    .card {
        border-radius: 0.5rem;
    }

    .card-header {
        padding: 0.75rem;
    }

    .card-body {
        padding: 0.75rem;
    }

    /* Game buttons - Stack vertically */
    div[style*="margin-top: 1rem"][style*="display: flex"] {
        flex-direction: column !important;
    }

    #newGameBtn,
    #undoBtn,
    #resignBtn {
        width: 100%;
    }

    /* Move history compact */
    .move-history {
        max-height: 120px;
    }

    .move-row {
        font-size: 0.85rem;
        padding: 0.2rem 0;
    }

    /* Captured pieces */
    .captured-pieces {
        font-size: 1.2rem;
    }

    /* Toast notifications */
    .toast-notification {
        left: 10px !important;
        right: 10px !important;
        transform: none !important;
        max-width: none !important;
    }

    /* Game over modal */
    .game-over-modal-overlay .game-over-modal {
        min-width: auto !important;
        width: 90vw !important;
        padding: 1.5rem !important;
    }

    .game-over-modal h2 {
        font-size: 1.5rem !important;
    }

    .game-over-modal button {
        padding: 10px 16px !important;
        font-size: 0.9rem !important;
    }

    /* Difficulty modal */
    #difficultyModal>div {
        min-width: auto !important;
        width: 90vw !important;
        padding: 1.5rem !important;
    }

    /* Tables */
    table {
        font-size: 0.85rem;
    }

    th,
    td {
        padding: 0.5rem 0.3rem;
    }

    /* Lobby */
    .lobby-container {
        padding: 0.5rem;
    }

    .game-list-item {
        flex-direction: column;
        align-items: flex-start;
        gap: 0.5rem;
    }

    /* Footer */
    footer {
        padding: 1rem;
        font-size: 0.85rem;
    }
}

/* Very Small Devices (max-width: 360px) */
@media (max-width: 360px) {
    .chess-piece {
        font-size: 1.6rem !important;
    }

    .navbar .nav-links a {
        padding: 0.25rem 0.4rem;
        font-size: 0.7rem;
    }

    .btn {
        padding: 0.5rem 0.8rem;
        font-size: 0.8rem;
    }
}

/* Landscape orientation fix for mobile */
@media (max-height: 500px) and (orientation: landscape) {
    .chess-board {
        max-height: 80vh;
        width: auto;
        aspect-ratio: 1;
    }

    .game-container {
        flex-direction: row;
    }

    .game-info {
        max-width: 200px;
        overflow-y: auto;
    }
}

/* Touch-friendly enhancements */
@media (hover: none) and (pointer: coarse) {
    .chess-square {
        /* Larger touch target */
        min-height: 40px;
    }

    .btn:active {
        transform: scale(0.95);
    }

    .chess-square:active {
        opacity: 0.8;
    }

    /* Remove hover effects on touch devices */
    .chess-square:hover {
        background: inherit;
    }

    .chess-square.light:hover {
        background: var(--color-square-light);
    }

    .chess-square.dark:hover {
        background: var(--color-square-dark);
    }
}