/* Reset and Base Styles */
* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

body {
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Oxygen, Ubuntu, Cantarell, sans-serif;
    line-height: 1.5;
    color: #e2e8f0;
    background: linear-gradient(135deg, #1a202c 0%, #2d3748 50%, #1a202c 100%);
    min-height: 100vh;
    margin: 0;
    padding: 0;
}

.container {
    max-width: 1200px;
    margin: 0 auto;
    padding: 0 20px;
}

/* Header Styles */
.header {
    background: rgba(26, 32, 44, 0.95);
    backdrop-filter: blur(10px);
    border-bottom: 1px solid #4a5568;
    padding: 0.75rem 0;
    position: relative;
    z-index: 100;
}

.header-container {
    max-width: 1200px;
    margin: 0 auto;
    padding: 0 20px;
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.logo-section {
    display: flex;
    align-items: center;
    gap: 12px;
}

.logo-link {
    display: flex;
    align-items: center;
    gap: 12px;
    text-decoration: none;
    color: inherit;
}

.logo-link:hover {
    opacity: 0.8;
}

.logo svg {
    border-radius: 8px;
    box-shadow: 0 2px 8px rgba(37, 99, 235, 0.2);
}

.site-title {
    font-size: 1.5rem;
    font-weight: 700;
    color: #e2e8f0;
    margin: 0;
}

.header-actions {
    display: flex;
    align-items: center;
    gap: 16px;
}

.share-btn, .lang-btn {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 8px 16px;
    background: #2d3748;
    border: 1px solid #4a5568;
    border-radius: 8px;
    color: #e2e8f0;
    text-decoration: none;
    font-size: 0.875rem;
    font-weight: 500;
    cursor: pointer;
    transition: all 0.2s ease;
}

.share-btn:hover, .lang-btn:hover {
    background: #4a5568;
    border-color: #718096;
    transform: translateY(-1px);
}

.language-selector {
    position: relative;
}

.lang-dropdown {
    position: absolute;
    top: calc(100% + 8px);
    right: 0;
    background: #2d3748;
    border: 1px solid #4a5568;
    border-radius: 8px;
    box-shadow: 0 10px 25px rgba(0, 0, 0, 0.3);
    min-width: 450px;
    max-height: 300px;
    overflow-y: auto;
    opacity: 0;
    visibility: hidden;
    transform: translateY(-10px);
    transition: all 0.2s ease;
    z-index: 1000;
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 0;
}

.lang-dropdown.active {
    opacity: 1;
    visibility: visible;
    transform: translateY(0);
}

.lang-dropdown a {
    display: block;
    padding: 8px 16px;
    color: #e2e8f0;
    text-decoration: none;
    font-size: 0.875rem;
    transition: background-color 0.2s ease;
    white-space: nowrap;
}

.lang-dropdown a:hover {
    background: #4a5568;
}

.lang-column {
    display: flex;
    flex-direction: column;
}

/* Share Dropdown */
.header-actions {
    position: relative;
}

.share-dropdown {
    position: absolute;
    top: calc(100% + 8px);
    right: 0;
    background: #2d3748;
    border: 1px solid #4a5568;
    border-radius: 8px;
    box-shadow: 0 10px 25px rgba(0, 0, 0, 0.3);
    min-width: 160px;
    opacity: 0;
    visibility: hidden;
    transform: translateY(-10px);
    transition: all 0.2s ease;
    z-index: 1000;
    display: flex;
    flex-direction: column;
}

.share-dropdown.show {
    opacity: 1;
    visibility: visible;
    transform: translateY(0);
}

.share-option {
    background: none;
    border: none;
    color: #e2e8f0;
    padding: 12px 16px;
    text-align: left;
    cursor: pointer;
    transition: background-color 0.2s ease;
    font-size: 14px;
    display: flex;
    align-items: center;
    gap: 8px;
}

.share-option:hover {
    background: #4a5568;
}

.share-option:first-child {
    border-radius: 8px 8px 0 0;
}

.share-option:last-child {
    border-radius: 0 0 8px 8px;
}

/* Main Content */
.main-content {
    padding: 1rem 0 0.5rem 0;
}

.game-container {
    max-width: 1000px;
    margin: 0 auto;
    padding: 0 20px;
}

/* Game Mode Selector */
.game-mode-selector {
    display: flex;
    justify-content: center;
    align-items: center;
    gap: 16px;
    margin-bottom: 1rem;
    flex-wrap: wrap;
}



.mode-btn {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 10px 20px;
    background: #2d3748;
    border: 2px solid #4a5568;
    border-radius: 12px;
    color: #a0aec0;
    font-size: 0.95rem;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.3s ease;
    box-shadow: 0 2px 4px rgba(0, 0, 0, 0.1);
    white-space: nowrap;
}

.mode-btn:hover {
    border-color: #3b82f6;
    color: #3b82f6;
    transform: translateY(-1px);
    box-shadow: 0 4px 12px rgba(59, 130, 246, 0.15);
}

.mode-btn.active {
    background: #3b82f6;
    border-color: #3b82f6;
    color: white;
    transform: translateY(-1px);
    box-shadow: 0 4px 12px rgba(59, 130, 246, 0.25);
}

/* Game Board Container */
.game-board-container {
    background: #2d3748;
    border-radius: 16px;
    box-shadow: 0 4px 20px rgba(0, 0, 0, 0.2);
    padding: 1.5rem;
    margin-bottom: 0.5rem;
    border: 1px solid #4a5568;
}

.game-mode {
    display: none;
}

.game-mode.active {
    display: block;
}

/* Online Game Layout Optimization */
.online-game {
    display: flex;
    flex-direction: column;
    height: 100vh;
    max-height: 100vh;
    overflow: hidden;
    background: #1a202c;
}

/* Game Info - Compact Header */
.game-info {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin: 0;
    padding: 0.5rem 1rem;
    border-bottom: 1px solid #4a5568;
    flex-wrap: wrap;
    gap: 0.5rem;
    flex-shrink: 0;
    background: #1a202c;
    z-index: 10;
}

.player-info {
    display: flex;
    align-items: center;
    gap: 1.5rem;
    flex-wrap: wrap;
}

.player {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 10px 14px;
    background: #1a202c;
    border-radius: 12px;
    transition: all 0.3s ease;
    border: 2px solid transparent;
}

.player.active {
    background: #2b6cb0;
    border: 2px solid #3b82f6;
}

.player-avatar {
    width: 36px;
    height: 36px;
    background: #4a5568;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    color: #a0aec0;
}

.player-details {
    display: flex;
    flex-direction: column;
}

.player-name {
    font-weight: 600;
    color: #e2e8f0;
    font-size: 0.9rem;
}

.player-color {
    font-size: 0.8rem;
    color: #a0aec0;
}

.vs-indicator {
    font-weight: 700;
    color: #718096;
    font-size: 1.1rem;
}

.game-controls {
    display: flex;
    gap: 8px;
    flex-wrap: wrap;
}

.control-btn {
    display: flex;
    align-items: center;
    gap: 6px;
    padding: 8px 14px;
    background: #1a202c;
    border: 1px solid #4a5568;
    border-radius: 8px;
    color: #e2e8f0;
    font-size: 0.8rem;
    font-weight: 500;
    cursor: pointer;
    transition: all 0.2s ease;
    white-space: nowrap;
}

.control-btn:hover:not(:disabled) {
    background: #2d3748;
    border-color: #718096;
}

.control-btn:disabled {
    opacity: 0.5;
    cursor: not-allowed;
}

.difficulty-selector-controls {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 8px 14px;
    background: #1a202c;
    border: 1px solid #4a5568;
    border-radius: 8px;
    color: #e2e8f0;
    font-size: 0.8rem;
    font-weight: 500;
    margin-right: 12px;
}

.difficulty-selector-controls.active {
    display: flex;
}

.difficulty-selector-controls label {
    color: #a0aec0;
    white-space: nowrap;
}

/* 移动端隐藏AI Difficulty标签 */
@media (max-width: 768px) {
    .difficulty-selector-controls label {
        display: none;
    }

    .difficulty-selector-controls {
        margin-right: 8px;
        padding: 8px 10px;
    }
}

.difficulty-selector-controls select {
    padding: 4px 8px;
    border: 1px solid #4a5568;
    border-radius: 4px;
    background: #2d3748;
    color: #e2e8f0;
    font-size: 0.75rem;
    cursor: pointer;
    min-width: 80px;
}

.primary-btn {
    background: #3b82f6 !important;
    color: white !important;
    border: 1px solid #3b82f6 !important;
}

.primary-btn:hover {
    background: #2563eb !important;
    border-color: #2563eb !important;
}

.secondary-btn {
    background: #6b7280 !important;
    color: white !important;
    border: 1px solid #6b7280 !important;
}

.secondary-btn:hover {
    background: #4b5563 !important;
    border-color: #4b5563 !important;
}

/* Board Wrapper - Default (AI Mode) */
.board-wrapper {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    margin: 1rem 0 0.5rem 0;
    padding: 1rem;
    background: #1a202c;
    border-radius: 12px;
    border: 1px solid #4a5568;
    position: relative;
    text-align: center;
}

/* Board Wrapper - Online Game Optimized */
.online-game .board-wrapper {
    flex: 1;
    height: calc(100vh - 140px);
    max-height: calc(100vh - 140px);
    min-height: 400px; /* Ensure minimum height */
    margin: 0;
    padding: 0.5rem;
    background: #8B4513; /* Wood background color */
    border: 2px solid #654321;
    border-radius: 8px;
    justify-content: center;
    align-items: center;
    overflow: hidden;
    display: flex;
    flex-direction: column;
}

#gameBoard, #onlineBoard {
    border: 2px solid #4a5568;
    border-radius: 8px;
    cursor: crosshair;
    background: #f7fafc;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.2);
    display: block;
    margin: 0 auto;
}

/* Online Board - Maximized Display */
.online-game #onlineBoard {
    width: auto !important;
    height: auto !important;
    max-width: min(95vw, calc(100vh - 160px)) !important;
    max-height: min(calc(100vh - 160px), 95vw) !important;
    aspect-ratio: 1 / 1;
    border-radius: 4px;
}

/* Game Notifications */
.game-notifications {
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    background: rgba(255, 255, 255, 0.95);
    color: #1a202c;
    padding: 1rem 2rem;
    border-radius: 12px;
    border: 2px solid #3b82f6;
    font-size: 1.1rem;
    font-weight: 700;
    text-align: center;
    box-shadow: 0 8px 25px rgba(0, 0, 0, 0.5);
    backdrop-filter: blur(10px);
    opacity: 0;
    visibility: hidden;
    transition: all 0.3s ease;
    z-index: 1000;
    max-width: 300px;
    word-wrap: break-word;
}

.game-notifications.show {
    opacity: 1;
    visibility: visible;
}

.game-notifications.success {
    border-color: #10b981;
    background: rgba(220, 252, 231, 0.95);
    color: #064e3b;
}

.game-notifications.error {
    border-color: #ef4444;
    background: rgba(254, 226, 226, 0.95);
    color: #7f1d1d;
}

.game-notifications.warning {
    border-color: #f59e0b;
    background: rgba(255, 251, 235, 0.95);
    color: #78350f;
}

/* Fullscreen Mode */
.fullscreen-mode {
    position: fixed !important;
    top: 0 !important;
    left: 0 !important;
    width: 100vw !important;
    height: 100vh !important;
    background: #1a202c !important;
    z-index: 9999 !important;
    display: flex !important;
    flex-direction: column !important;
    justify-content: flex-start !important;
    align-items: center !important;
    margin: 0 !important;
    padding: 0 !important;
    box-sizing: border-box !important;
    overflow: hidden !important;
}

/* Hide body scrollbar when in fullscreen */
body.fullscreen-active {
    overflow: hidden !important;
}

.fullscreen-mode .game-info {
    width: 100% !important;
    max-width: 1200px !important;
    margin: 0.25rem auto 0.25rem auto !important;
    flex-shrink: 0;
    padding: 0.5rem 1rem !important;
    background: rgba(45, 55, 72, 0.8) !important;
    border-radius: 8px !important;
    display: flex !important;
    justify-content: space-between !important;
    align-items: center !important;
    position: relative !important;
}

.fullscreen-mode .board-wrapper {
    flex: 1;
    display: flex !important;
    flex-direction: column !important;
    justify-content: flex-start !important;
    align-items: center !important;
    width: 100% !important;
    height: calc(100vh - 80px) !important;
    max-width: none !important;
    max-height: none !important;
    margin: 0 !important;
    padding: 0.5rem 0 0 0 !important;
    background: transparent !important;
    border: none !important;
}

.fullscreen-mode canvas {
    width: auto !important;
    height: auto !important;
    max-width: min(95vw, calc(100vh - 90px)) !important;
    max-height: min(calc(100vh - 90px), 95vw) !important;
    border-radius: 8px !important;
    aspect-ratio: 1 / 1 !important;
    display: block !important;
    margin: 0 auto !important;
}

.fullscreen-mode .game-notifications {
    font-size: 1.2rem !important;
    padding: 1.5rem 2.5rem !important;
    max-width: 400px !important;
    border-width: 3px !important;
}

.fullscreen-mode .player-info {
    justify-content: center !important;
    align-items: center !important;
    gap: 2rem !important;
    flex-wrap: nowrap !important;
}

.fullscreen-mode .game-controls {
    justify-content: center !important;
    align-items: center !important;
    gap: 1rem !important;
    flex-wrap: wrap !important;
}

.fullscreen-mode .control-btn {
    padding: 10px 20px !important;
    font-size: 0.9rem !important;
}

.fullscreen-mode .difficulty-selector-controls {
    padding: 10px 16px !important;
    font-size: 0.9rem !important;
}

.fullscreen-mode .difficulty-selector-controls select {
    padding: 6px 10px !important;
    font-size: 0.85rem !important;
}

/* Force top alignment in fullscreen mode for all screen sizes */
.fullscreen-mode .board-wrapper {
    align-items: flex-start !important;
    justify-content: center !important;
}

/* Override any center alignment in fullscreen */
.fullscreen-mode .board-wrapper,
.fullscreen-mode .board-wrapper * {
    align-items: flex-start !important;
}

/* Ensure canvas stays at top in fullscreen */
.fullscreen-mode canvas {
    align-self: flex-start !important;
    margin-top: 0 !important;
    vertical-align: top !important;
}

/* Force top alignment for all small screens in fullscreen */
@media (max-width: 768px) {
    .fullscreen-mode canvas {
        position: relative !important;
        top: 0 !important;
        transform: none !important;
        vertical-align: top !important;
    }
}

/* Ensure fullscreen takes full viewport */
.fullscreen-mode {
    width: 100vw !important;
    height: 100vh !important;
    max-width: 100vw !important;
    max-height: 100vh !important;
}

/* Hide any potential scrollbars in fullscreen */
.fullscreen-mode * {
    scrollbar-width: none !important;
    -ms-overflow-style: none !important;
}

.fullscreen-mode *::-webkit-scrollbar {
    display: none !important;
}

/* Additional fullscreen optimizations for all screen sizes */
@media (max-width: 768px) {
    .fullscreen-mode .board-wrapper {
        flex-direction: column !important;
        justify-content: flex-start !important;
        align-items: center !important;
        padding: 0.5rem 0 0 0 !important;
    }

    .fullscreen-mode canvas {
        max-width: min(96vw, calc(100vh - 95px)) !important;
        max-height: min(calc(100vh - 95px), 96vw) !important;
        width: auto !important;
        height: auto !important;
        display: block !important;
        margin: 0 auto 0 auto !important;
        align-self: flex-start !important;
        order: 1 !important;
    }
}

@media (min-width: 769px) {
    .fullscreen-mode .board-wrapper {
        align-items: flex-start !important;
        justify-content: flex-start !important;
    }

    .fullscreen-mode canvas {
        max-width: min(96vw, calc(100vh - 90px)) !important;
        max-height: calc(100vh - 90px) !important;
    }
}



/* Difficulty Selector */
.difficulty-selector {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 12px;
    margin-top: 1rem;
}

.difficulty-selector label {
    font-weight: 500;
    color: #374151;
}

.difficulty-selector select {
    padding: 8px 12px;
    border: 1px solid #e5e7eb;
    border-radius: 6px;
    background: white;
    color: #374151;
    font-size: 0.875rem;
    cursor: pointer;
}

/* Online Lobby */
.online-lobby {
    display: flex;
    flex-direction: column;
    gap: 2rem;
}

/* Top Section with Create and Join Private */
.lobby-top-section {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 2rem;
}

/* Public Rooms Section - Full Width */
.public-rooms-section {
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    color: white;
    padding: 2rem;
    border-radius: 16px;
    box-shadow: 0 8px 25px rgba(102, 126, 234, 0.3);
}

.public-rooms-section h3 {
    color: white;
    margin-bottom: 1.5rem;
    font-size: 1.4rem;
    text-align: center;
}

.public-rooms-section .room-list {
    background: rgba(255, 255, 255, 0.1);
    border-radius: 12px;
    padding: 1.5rem;
    backdrop-filter: blur(10px);
    min-height: 200px;
}

.public-rooms-section .no-rooms {
    color: rgba(255, 255, 255, 0.9);
    text-align: center;
    padding: 3rem;
    font-style: italic;
    font-size: 1.1rem;
}

.public-rooms-section .room-list-footer {
    margin-top: 1rem;
    text-align: center;
}

.public-rooms-section .room-list-footer small {
    color: rgba(255, 255, 255, 0.8);
    font-style: italic;
    font-size: 0.9rem;
}





.room-list-footer {
    margin-top: 0.5rem;
    text-align: center;
}

.room-list-footer small {
    color: rgba(255, 255, 255, 0.8);
    font-style: italic;
}

/* Disconnection Dialog */
.disconnection-dialog {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.8);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 10000;
    backdrop-filter: blur(5px);
}

.dialog-content {
    background: white;
    padding: 2rem;
    border-radius: 16px;
    box-shadow: 0 20px 40px rgba(0, 0, 0, 0.3);
    text-align: center;
    max-width: 400px;
    width: 90%;
    animation: dialogSlideIn 0.3s ease-out;
}

@keyframes dialogSlideIn {
    from {
        opacity: 0;
        transform: translateY(-20px) scale(0.95);
    }
    to {
        opacity: 1;
        transform: translateY(0) scale(1);
    }
}

.dialog-content h3 {
    margin: 0 0 1rem 0;
    color: #e74c3c;
    font-size: 1.3rem;
}

.dialog-content p {
    margin: 0 0 1.5rem 0;
    color: #666;
    line-height: 1.5;
}

.dialog-actions {
    display: flex;
    gap: 1rem;
    margin-bottom: 1rem;
}

.wait-btn, .leave-btn {
    flex: 1;
    padding: 0.75rem 1rem;
    border: none;
    border-radius: 8px;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.3s ease;
    font-size: 0.9rem;
}

.wait-btn {
    background: #3498db;
    color: white;
}

.wait-btn:hover {
    background: #2980b9;
    transform: translateY(-1px);
}

.leave-btn {
    background: #e74c3c;
    color: white;
}

.leave-btn:hover {
    background: #c0392b;
    transform: translateY(-1px);
}

.countdown {
    font-size: 0.8rem;
    color: #999;
    font-style: italic;
}

/* Rematch Dialog */
.rematch-dialog {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.8);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 10000;
    backdrop-filter: blur(5px);
}

.rematch-dialog .dialog-content {
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    color: white;
    padding: 2rem;
    border-radius: 16px;
    box-shadow: 0 20px 40px rgba(0, 0, 0, 0.3);
    text-align: center;
    max-width: 400px;
    width: 90%;
    animation: dialogSlideIn 0.3s ease-out;
}

.rematch-dialog h3 {
    margin: 0 0 1rem 0;
    color: white;
    font-size: 1.3rem;
}

.rematch-dialog p {
    margin: 0 0 1rem 0;
    color: rgba(255, 255, 255, 0.9);
    line-height: 1.5;
}

.accept-btn, .decline-btn {
    flex: 1;
    padding: 0.75rem 1rem;
    border: none;
    border-radius: 8px;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.3s ease;
    font-size: 0.9rem;
}

.accept-btn {
    background: #27ae60;
    color: white;
}

.accept-btn:hover {
    background: #229954;
    transform: translateY(-1px);
}

.decline-btn {
    background: #e74c3c;
    color: white;
}

.decline-btn:hover {
    background: #c0392b;
    transform: translateY(-1px);
}

.rematch-dialog .countdown {
    color: rgba(255, 255, 255, 0.8);
    margin-top: 1rem;
}

/* Mobile responsiveness for dialog */
@media (max-width: 768px) {
    .dialog-content {
        padding: 1.5rem;
        margin: 1rem;
    }

    .dialog-actions {
        flex-direction: column;
    }

    .wait-btn, .leave-btn {
        font-size: 0.85rem;
        padding: 0.6rem 0.8rem;
    }

    /* Mobile Online Game Optimization */
    .online-game {
        height: 100vh;
        max-height: 100vh;
    }

    .online-game .game-info {
        padding: 0.25rem 0.5rem;
        flex-wrap: wrap;
        gap: 0.25rem;
    }

    .online-game .board-wrapper {
        height: calc(100vh - 100px);
        max-height: calc(100vh - 100px);
        min-height: 300px;
        padding: 0.25rem;
        background: #8B4513; /* Ensure wood background on mobile */
        border: 1px solid #654321;
    }

    .online-game #onlineBoard {
        max-width: min(98vw, calc(100vh - 120px)) !important;
        max-height: min(calc(100vh - 120px), 98vw) !important;
    }

    .online-game .game-status {
        padding: 0.25rem 0.5rem;
        font-size: 0.85rem;
    }

    /* Mobile Online Lobby */
    .lobby-top-section {
        grid-template-columns: 1fr;
        gap: 1rem;
    }

    .public-rooms-section {
        padding: 1rem;
    }

    .public-rooms-section h3 {
        font-size: 1.2rem;
        margin-bottom: 1rem;
    }

    .public-rooms-section .room-list {
        padding: 1rem;
        min-height: 150px;
    }

    .public-rooms-section .no-rooms {
        padding: 2rem 1rem;
        font-size: 1rem;
    }
}

.lobby-section {
    background: #f8fafc;
    padding: 1.5rem;
    border-radius: 12px;
    border: 1px solid #e5e7eb;
}

.lobby-section h3 {
    margin-bottom: 1rem;
    color: #1f2937;
    font-size: 1.1rem;
    font-weight: 600;
}

.room-creation {
    display: flex;
    flex-direction: column;
    gap: 12px;
}

.room-creation input {
    padding: 10px 12px;
    border: 1px solid #e5e7eb;
    border-radius: 6px;
    font-size: 0.875rem;
}

.room-options {
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.checkbox-label {
    display: flex;
    align-items: center;
    gap: 8px;
    cursor: pointer;
    font-size: 0.875rem;
}

.checkbox-label input[type="checkbox"] {
    width: 16px;
    height: 16px;
}

.room-list {
    max-height: 200px;
    overflow-y: auto;
    margin-bottom: 1rem;
}

.room-item {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 12px;
    background: white;
    border: 1px solid #e5e7eb;
    border-radius: 8px;
    margin-bottom: 8px;
}

.room-info {
    display: flex;
    flex-direction: column;
}

.room-name {
    font-weight: 500;
    color: #1f2937;
}

.room-players {
    font-size: 0.875rem;
    color: #6b7280;
}

.join-btn {
    padding: 6px 12px;
    background: #10b981;
    color: white;
    border: none;
    border-radius: 6px;
    font-size: 0.875rem;
    cursor: pointer;
    transition: background-color 0.2s ease;
}

.join-btn:hover {
    background: #059669;
}

.join-private {
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.join-private input {
    padding: 8px 12px;
    border: 1px solid #e5e7eb;
    border-radius: 6px;
    font-size: 0.875rem;
}

.game-status {
    text-align: center;
    margin: 0;
    padding: 0.5rem;
    background: #fef3c7;
    border-top: 1px solid #f59e0b;
    flex-shrink: 0;
}

/* Online Game Status - Compact Footer */
.online-game .game-status {
    margin: 0;
    padding: 0.5rem 1rem;
    background: #1a202c;
    border-top: 1px solid #4a5568;
    color: #e2e8f0;
    border-radius: 8px;
    color: #92400e;
    font-weight: 500;
}

/* Content Section */
.content-section {
    background: #2d3748;
    padding: 3rem 0;
    margin-top: 1rem;
}

.content-grid {
    display: grid;
    grid-template-columns: 1fr;
    gap: 3rem;
    max-width: 1000px;
    margin: 0 auto;
    padding: 0 20px;
}

.content-block {
    background: #1a202c;
    padding: 2rem;
    border-radius: 16px;
    border: 1px solid #4a5568;
}

.content-block h2 {
    color: #e2e8f0;
    font-size: 1.75rem;
    font-weight: 700;
    margin-bottom: 1.5rem;
    border-bottom: 3px solid #3b82f6;
    padding-bottom: 0.5rem;
}

.content-block h3 {
    color: #cbd5e0;
    font-size: 1.25rem;
    font-weight: 600;
    margin-bottom: 0.75rem;
}

.content-block p {
    color: #a0aec0;
    line-height: 1.7;
    margin-bottom: 1rem;
}

/* Rules List */
.rules-list {
    display: grid;
    gap: 1.5rem;
}

.rule-item {
    background: #2d3748;
    padding: 1.5rem;
    border-radius: 12px;
    border: 1px solid #4a5568;
    box-shadow: 0 2px 4px rgba(0, 0, 0, 0.2);
}

/* Strategy Tips */
.strategy-tips {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(250px, 1fr));
    gap: 1.5rem;
}

.tip-item {
    background: #2d3748;
    padding: 1.5rem;
    border-radius: 12px;
    border-top: 4px solid #10b981;
    box-shadow: 0 2px 4px rgba(0, 0, 0, 0.2);
}

/* Features Grid */
.features-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(280px, 1fr));
    gap: 1.5rem;
}

.feature-item {
    background: #2d3748;
    padding: 1.5rem;
    border-radius: 12px;
    text-align: center;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.2);
    transition: transform 0.2s ease, box-shadow 0.2s ease;
}

.feature-item:hover {
    transform: translateY(-2px);
    box-shadow: 0 4px 16px rgba(0, 0, 0, 0.3);
}

.feature-item h3 {
    font-size: 1.1rem;
    margin-bottom: 0.75rem;
    color: #e2e8f0;
}

/* Comparison Table */
.comparison-table {
    overflow-x: auto;
    background: #2d3748;
    border-radius: 12px;
    box-shadow: 0 2px 4px rgba(0, 0, 0, 0.2);
}

.comparison-table table {
    width: 100%;
    border-collapse: collapse;
}

.comparison-table th,
.comparison-table td {
    padding: 12px 16px;
    text-align: left;
    border-bottom: 1px solid #4a5568;
    color: #e2e8f0;
}

.comparison-table th {
    background: #1a202c;
    font-weight: 600;
    color: #cbd5e0;
}

.comparison-table tr:hover {
    background: #374151;
}

.comparison-table td strong {
    color: #3b82f6;
}

/* FAQ List */
.faq-list {
    display: grid;
    gap: 1rem;
}

.faq-item {
    background: #2d3748;
    padding: 1.5rem;
    border-radius: 12px;
    border: 1px solid #4a5568;
    box-shadow: 0 2px 4px rgba(0, 0, 0, 0.2);
}

.faq-item h3 {
    color: #e2e8f0;
    margin-bottom: 0.75rem;
    font-size: 1.1rem;
}

/* Contact Form Styles */
.contact-form {
    max-width: 600px;
    margin: 0 auto;
}

.form-group {
    margin-bottom: 1.5rem;
}

.form-group label {
    display: block;
    margin-bottom: 0.5rem;
    font-weight: 600;
    color: #2d3748;
}

.form-group input,
.form-group select,
.form-group textarea {
    width: 100%;
    padding: 0.75rem;
    border: 2px solid #e2e8f0;
    border-radius: 8px;
    font-size: 1rem;
    transition: border-color 0.3s ease;
    box-sizing: border-box;
}

.form-group input:focus,
.form-group select:focus,
.form-group textarea:focus {
    outline: none;
    border-color: #3b82f6;
    box-shadow: 0 0 0 3px rgba(59, 130, 246, 0.1);
}

.submit-btn {
    background: #3b82f6;
    color: white;
    padding: 0.75rem 2rem;
    border: none;
    border-radius: 8px;
    font-size: 1rem;
    font-weight: 600;
    cursor: pointer;
    transition: background-color 0.3s ease;
}

.submit-btn:hover {
    background: #2563eb;
}

/* Navigation Active State */
.nav a.active {
    color: #3b82f6;
    font-weight: 600;
}

/* Content Grid for Contact Page - specific class */
.contact-content-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(300px, 1fr));
    gap: 2rem;
    margin: 2rem 0;
}

/* Footer */
.footer {
    background: #1f2937;
    color: #d1d5db;
    padding: 3rem 0 1rem;
    margin-top: 4rem;
}

.footer-content {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(250px, 1fr));
    gap: 2rem;
    margin-bottom: 2rem;
}

.footer-section h3 {
    color: white;
    font-size: 1.1rem;
    font-weight: 600;
    margin-bottom: 1rem;
}

.footer-section p {
    line-height: 1.6;
    color: #9ca3af;
}

.footer-section ul {
    list-style: none;
}

.footer-section ul li {
    margin-bottom: 0.5rem;
}

.footer-section ul li a {
    color: #d1d5db;
    text-decoration: none;
    transition: color 0.2s ease;
}

.footer-section ul li a:hover {
    color: #3b82f6;
}

.footer-bottom {
    border-top: 1px solid #374151;
    padding-top: 1rem;
    text-align: center;
    color: #9ca3af;
    font-size: 0.875rem;
}

/* Responsive Design */
@media (max-width: 768px) {
    .header-container {
        padding: 0 16px;
    }

    .header-actions {
        gap: 12px;
    }

    .share-btn, .lang-btn {
        padding: 6px 12px;
        font-size: 0.8rem;
    }

    .game-mode-selector {
        flex-direction: row;
        gap: 8px;
        margin-bottom: 1rem;
        justify-content: center;
    }

    .mode-btn {
        flex: 1;
        max-width: 140px;
        justify-content: center;
        padding: 10px 12px;
        font-size: 0.8rem;
    }

    .difficulty-selector-controls {
        flex-direction: column;
        gap: 6px;
        padding: 10px;
        text-align: center;
    }

    .difficulty-selector-controls select {
        min-width: 120px;
    }

    .game-board-container {
        padding: 0.5rem;
        margin-bottom: 0.5rem;
    }

    .game-info {
        flex-direction: column;
        gap: 0.75rem;
        text-align: center;
        margin-bottom: 0.75rem;
    }

    .player-info {
        justify-content: center;
        gap: 1rem;
    }

    .game-controls {
        justify-content: center;
        gap: 6px;
    }

    .control-btn {
        padding: 8px 12px;
        font-size: 0.75rem;
    }

    .online-lobby {
        grid-template-columns: 1fr;
        gap: 1rem;
    }

    .lobby-section {
        padding: 1rem;
    }

    #gameBoard, #onlineBoard {
        width: 100%;
        max-width: 350px;
        height: auto;
    }

    .board-wrapper {
        margin: 0.5rem 0;
        padding: 0.25rem;
    }

    .content-section {
        padding: 2rem 0;
    }

    .content-grid {
        padding: 0 16px;
        gap: 2rem;
    }

    .content-block {
        padding: 1.5rem;
    }

    .features-grid {
        grid-template-columns: 1fr;
    }

    .strategy-tips {
        grid-template-columns: 1fr;
    }

    .footer-content {
        grid-template-columns: 1fr;
        text-align: center;
    }

    .game-notifications {
        max-width: 250px;
        padding: 0.75rem 1.5rem;
        font-size: 1rem;
    }
}

@media (max-width: 443px) {
    .main-content {
        padding: 0.25rem 0;
    }

    .game-container {
        padding: 0 8px;
    }

    .game-mode-selector {
        margin-bottom: 0.5rem;
        gap: 6px;
    }

    .mode-btn {
        padding: 8px 10px;
        font-size: 0.75rem;
        max-width: 120px;
    }

    .game-board-container {
        padding: 0.25rem;
        margin-bottom: 0.25rem;
    }

    .game-info {
        margin-bottom: 0.5rem;
        gap: 0.5rem;
    }

    .board-wrapper {
        margin: 0.25rem 0;
        padding: 0.1rem;
        justify-content: flex-start !important;
        align-items: flex-start !important;
    }

    #gameBoard, #onlineBoard {
        max-width: 95vw;
    }

    .content-section {
        padding: 1.5rem 0;
    }

    /* Fix content overflow on very small screens */
    .content-grid {
        padding: 0 12px !important;
        gap: 1rem !important;
    }

    .content-block {
        padding: 1rem 0.75rem !important;
        margin: 0 !important;
        border-radius: 8px !important;
        box-sizing: border-box !important;
        max-width: 100% !important;
        overflow: hidden !important;
    }

    .content-block h2 {
        font-size: 1.2rem !important;
        margin-bottom: 0.75rem !important;
    }

    .content-block p {
        font-size: 0.85rem !important;
        line-height: 1.4 !important;
    }

    .features-grid {
        grid-template-columns: 1fr !important;
        gap: 0.75rem !important;
    }

    .feature-item {
        padding: 0.75rem !important;
        border-radius: 6px !important;
    }

    .strategy-tips {
        grid-template-columns: 1fr !important;
        gap: 0.75rem !important;
    }

    .tip-item {
        padding: 0.75rem !important;
        border-radius: 6px !important;
    }

    /* Small screen fullscreen mode - top aligned */
    .fullscreen-mode {
        justify-content: flex-start !important;
        align-items: center !important;
        padding: 0.25rem !important;
    }

    .fullscreen-mode .game-info {
        margin: 0.25rem auto 0.25rem auto !important;
        width: calc(100% - 0.5rem) !important;
        padding: 0.5rem 0.75rem !important;
    }

    .fullscreen-mode .board-wrapper {
        align-items: flex-start !important;
        justify-content: center !important;
        padding-top: 0.5rem !important;
    }

    .fullscreen-mode canvas {
        align-self: flex-start !important;
    }

    .fullscreen-mode .board-wrapper {
        height: calc(100vh - 90px) !important;
        width: 100% !important;
        justify-content: center !important;
        align-items: flex-start !important;
        padding: 0.5rem 0 0 0 !important;
    }

    .fullscreen-mode canvas {
        max-width: 90vw !important;
        max-height: calc(100vh - 100px) !important;
        align-self: flex-start !important;
        display: block !important;
        margin: 0 auto !important;
    }
}

/* Fix canvas aspect ratio for medium screens */
@media (min-width: 444px) and (max-width: 767px) {
    .fullscreen-mode canvas {
        max-width: min(90vw, calc(100vh - 90px)) !important;
        max-height: min(calc(100vh - 90px), 90vw) !important;
        width: auto !important;
        height: auto !important;
        display: block !important;
        margin: 0 auto !important;
    }
}

/* Additional media queries to ensure top alignment */
@media (max-width: 600px) {
    .fullscreen-mode .board-wrapper {
        flex-direction: column !important;
        justify-content: flex-start !important;
        align-items: center !important;
        padding-top: 0.5rem !important;
    }

    .fullscreen-mode canvas {
        max-width: min(88vw, calc(100vh - 100px)) !important;
        max-height: min(calc(100vh - 100px), 88vw) !important;
        display: block !important;
        margin: 0 auto 0 auto !important;
        align-self: flex-start !important;
        order: 1 !important;
    }
}

@media (max-width: 480px) {
    .fullscreen-mode .board-wrapper {
        flex-direction: column !important;
        justify-content: flex-start !important;
        align-items: center !important;
        padding-top: 0.25rem !important;
    }

    .fullscreen-mode canvas {
        max-width: min(85vw, calc(100vh - 100px)) !important;
        max-height: min(calc(100vh - 100px), 85vw) !important;
        display: block !important;
        margin: 0 auto 0 auto !important;
        align-self: flex-start !important;
        order: 1 !important;
    }
}

@media (max-width: 480px) {
    .header {
        padding: 0.5rem 0;
    }

    .header-container {
        padding: 0 12px;
    }

    .site-title {
        font-size: 1.2rem;
    }

    .share-btn, .lang-btn {
        padding: 6px 10px;
        font-size: 0.75rem;
    }

    .main-content {
        padding: 0.5rem 0;
    }

    .game-container {
        padding: 0 12px;
    }

    .game-board-container {
        padding: 0.75rem;
        border-radius: 12px;
    }

    .mode-btn {
        max-width: 250px;
        padding: 10px 14px;
        font-size: 0.85rem;
    }

    .control-btn {
        padding: 6px 10px;
        font-size: 0.7rem;
        gap: 4px;
    }

    .player {
        padding: 8px 12px;
        gap: 8px;
    }

    .player-avatar {
        width: 32px;
        height: 32px;
    }

    .player-name {
        font-size: 0.85rem;
    }

    .player-color {
        font-size: 0.75rem;
    }

    .content-block {
        padding: 1rem;
        border-radius: 12px;
    }

    .content-block h2 {
        font-size: 1.4rem;
    }

    #gameBoard, #onlineBoard {
        max-width: 300px;
    }

    .board-wrapper {
        padding: 0.25rem;
    }

    .game-notifications {
        max-width: 220px;
        padding: 0.5rem 1rem;
        font-size: 0.9rem;
    }

    .lobby-section {
        padding: 0.75rem;
    }

    .room-creation input,
    .join-private input {
        padding: 8px 10px;
        font-size: 0.8rem;
    }

    .lang-dropdown {
        min-width: 120px;
        max-height: 250px;
    }
}

/* Animations */
@keyframes fadeIn {
    from {
        opacity: 0;
        transform: translateY(20px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

.game-mode {
    animation: fadeIn 0.3s ease-out;
}

/* Game Board Hover Effects */
#gameBoard:hover, #onlineBoard:hover {
    box-shadow: 0 6px 20px rgba(0, 0, 0, 0.15);
}

/* Button Loading State */
.btn-loading {
    position: relative;
    color: transparent !important;
}

.btn-loading::after {
    content: '';
    position: absolute;
    top: 50%;
    left: 50%;
    width: 16px;
    height: 16px;
    margin: -8px 0 0 -8px;
    border: 2px solid transparent;
    border-top: 2px solid currentColor;
    border-radius: 50%;
    animation: spin 1s linear infinite;
}

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