/* styles.css */
:root {
    /* Dark Theme  */
    --bg-body: #000000;
    --bg-container: #222222;
    --text-primary: #fafafa;
    --text-secondary: #cccccc;
    --border-color: #444444;
    --accent-color: #666666;
    --accent-hover: #888888;
    --menu-overlay-bg: rgba(0, 0, 0, 0.85);
    --menu-content-bg: #222222;
    --input-bg: #333333;
    --input-border: #555555;
    --shadow-color: rgba(0, 0, 0, 0.5);
    --hamburger-bg: rgba(0, 0, 0, 0.6);
    --title-color: #ffffff;
}

[data-theme="light"] {
    /* Light Theme (Default) */
    --bg-body: #e0e0e0;
    --bg-container: #ffffff;
    --text-primary: #222222;
    --text-secondary: #555555;
    --border-color: #cccccc;
    --accent-color: #888888;
    --accent-hover: #666666;
    --menu-overlay-bg: rgba(255, 255, 255, 0.85);
    --menu-content-bg: #ffffff;
    --input-bg: #f5f5f5;
    --input-border: #dddddd;
    --shadow-color: rgba(0, 0, 0, 0.2);
    --hamburger-bg: rgba(255, 255, 255, 0.8);
    --title-color: #000000;
}

/* ==================== Loading Screen ==================== */
.loading-screen {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: var(--bg-body);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 10000;
    transition: opacity 0.3s ease;
}

.loading-screen.fade-out {
    opacity: 0;
    pointer-events: none;
}

.loading-content {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 20px;
}

.loading-logo {
    width: 120px;
    height: auto;
    animation: loadingPulse 2s ease-in-out infinite;
}

/* Dark mode: invert logo to white */
body:not([data-theme="light"]) .loading-logo {
    filter: invert(1);
}

.loading-title {
    font-size: 2.2rem;
    font-weight: 700;
    letter-spacing: 0.2em;
    color: var(--title-color);
    margin: 0;
    animation: loadingFadeIn 1s ease-out;
}

.loading-spinner {
    width: 40px;
    height: 40px;
    border: 3px solid var(--border-color);
    border-top-color: var(--text-primary);
    border-radius: 50%;
    animation: loadingSpin 1s linear infinite;
}

@keyframes loadingPulse {
    0%, 100% {
        transform: scale(1);
        opacity: 1;
    }
    50% {
        transform: scale(1.05);
        opacity: 0.8;
    }
}

@keyframes loadingFadeIn {
    from {
        opacity: 0;
        transform: translateY(10px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

@keyframes loadingSpin {
    to {
        transform: rotate(360deg);
    }
}

* { {
    box-sizing: border-box;
    -webkit-tap-highlight-color: transparent;
}

body {
    background: var(--bg-body);
    color: var(--text-primary);
    font-family: 'Inter', Arial, sans-serif;
    /* Use Inter if available, fallback to Arial */
    text-align: center;
    margin: 0;
    padding: 0;
    overflow: hidden;
    width: 100vw;
    height: 100vh;
    user-select: none;
    -webkit-user-select: none;
    transition: background 0.3s ease, color 0.3s ease;
}

h1 {
    margin-top: 30px;
    font-size: 2.5em;
}

#gameContainer {
    position: relative;
    display: flex;
    flex-direction: column;
    margin: 0;
    background: var(--bg-container);
    border: none;
    width: 100%;
    height: 100%;
    transition: background 0.3s ease;
}

#uiLayer {
    position: absolute;
    top: 100px;
    left: 0;
    width: 100%;
    padding: 10px;
    display: flex;
    flex-direction: column;
    align-items: center;
    pointer-events: none;
    /* Let clicks pass through to canvas */
    z-index: 10;
}

#uiLayer>* {
    pointer-events: auto;
    /* Re-enable clicks for buttons */
}

#gameCanvas {
    display: block;
    width: 100%;
    height: calc(100% - 100px);
    flex: 1;
    touch-action: none;
    margin-top: 100px;
}

#inventoryCanvas {
    position: absolute;
    top: 200px; /* Below toolbar (100px) + player info boxes (~90px) + gap */
    left: 0;
    width: 100%;
    height: calc(100% - 200px);
    pointer-events: none;
    touch-action: none;
}

button {
    padding: 12px 24px;
    font-size: 16px;
    margin: 8px;
    cursor: pointer;
    border: none;
    border-radius: 6px;
    background: var(--accent-color);
    color: white;
    box-shadow: 0 2px 4px var(--shadow-color);
    transition: all 0.3s;
    min-height: 44px;
}

button:hover {
    background: var(--accent-hover);
    box-shadow: 0 4px 8px var(--shadow-color);
}

button:active {
    transform: scale(0.98);
}

.logo-container {
    text-align: center;
    margin: 20px 0;
}

.logo-container img {
    max-width: 200px;
    height: auto;
}

#playerStatus {
    margin: 10px;
    font-size: 1.2em;
    font-weight: bold;
    padding: 8px;
}

/* Undo/Redo Toolbar */
#undoRedoToolbar {
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    display: flex;
    justify-content: center;
    align-items: center;
    gap: 12px;
    padding: 8px 12px;
    background: var(--bg-container);
    border-bottom: 1px solid var(--border-color);
    z-index: 5;
    min-height: 100px;
}

.undo-redo-btn {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 40px;
    height: 40px;
    padding: 0;
    margin: 0;
    background: var(--accent-color);
    color: white;
    border: none;
    border-radius: 6px;
    cursor: pointer;
    font-size: 14px;
    font-weight: 600;
    transition: all 0.2s ease;
    box-shadow: 0 2px 6px var(--shadow-color);
    min-height: auto;
}

.undo-redo-btn:hover:not(:disabled) {
    background: var(--accent-hover);
    transform: scale(1.05);
    box-shadow: 0 4px 10px var(--shadow-color);
}

.undo-redo-btn:active:not(:disabled) {
    transform: scale(0.95);
}

.undo-redo-btn:disabled {
    background: var(--border-color);
    color: var(--text-secondary);
    cursor: not-allowed;
    opacity: 0.5;
}

.undo-redo-btn svg {
    width: 18px;
    height: 18px;
    stroke-linecap: round;
    stroke-linejoin: round;
}

.player-indicator {
    font-size: 12px;
    font-weight: 700;
    padding: 4px 12px;
    border-radius: 4px;
    color: white;
    white-space: nowrap;
    min-width: 120px;
    text-align: center;
    transition: background 0.2s ease;
}

.player-indicator.player-black {
    background: #1a1a1a;
    border: 2px solid #333333;
}

.player-indicator.player-white {
    background: #e8e8e8;
    color: #333333;
    border: 2px solid #cccccc;
}

/* =====================================================
   RESPONSIVE DESIGN - Device Breakpoints
   =====================================================
   
   Device Reference:
   - iPhone SE: 375x667 (portrait), 667x375 (landscape)
   - iPhone 12/13/14: 390x844 (portrait), 844x390 (landscape)
   - iPhone 12/13/14 Pro Max: 428x926 (portrait)
   - iPad Mini: 768x1024 (portrait), 1024x768 (landscape)
   - iPad: 810x1080 (portrait), 1080x810 (landscape)
   - iPad Air: 820x1180 (portrait)
   - iPad Pro 11": 834x1194 (portrait)
   - iPad Pro 12.9": 1024x1366 (portrait)
   - Desktop: 1280+ wide
   ===================================================== */

/* Large tablets and small laptops (iPad Pro 12.9" landscape, small desktops) */
@media (max-width: 1366px) {
    .lobby-content {
        max-width: 420px;
    }
}

/* Tablets (iPad, iPad Air, iPad Pro 11") */
@media (max-width: 1024px) {
    body {
        padding: 0;
    }
    
    .lobby-content {
        max-width: 400px;
        padding: 30px 25px;
    }
    
    .lobby-logo-img {
        max-width: 100px;
    }
    
    .lobby-title {
        font-size: 2rem;
    }
}

/* Small tablets (iPad Mini portrait) */
@media (max-width: 768px) {
    body {
        padding: 0;
    }

    h1 {
        font-size: 1.8em;
        margin-top: 10px;
    }

    .logo-container img {
        max-width: 150px;
    }

    #gameContainer {
        margin: 0;
        width: 100% !important;
        max-width: none;
        height: 100% !important;
    }

    button {
        padding: 14px 28px;
        font-size: 18px;
        margin: 10px 5px;
        min-height: 48px;
        min-width: 120px;
    }

    #playerStatus {
        font-size: 1.1em;
        margin: 8px;
        padding: 10px;
    }
    
    .player-info {
        padding: 6px 10px;
        min-width: 80px;
    }
    
    .player-info .player-name {
        font-size: 0.8rem;
    }
    
    .player-info .player-rating {
        font-size: 0.65rem;
    }
    
    /* Hamburger adjustments for tablets */
    .hamburger-btn {
        bottom: 15px;
        left: 15px;
    }
    
    .hamburger-modal-content {
        width: 280px;
    }
    
    /* Lobby adjustments */
    .lobby-content {
        max-width: 360px;
        padding: 25px 20px;
    }
    
    .lobby-btn {
        padding: 14px 20px;
        font-size: 1rem;
    }
}

/* Large phones (iPhone Pro Max, larger Android) */
@media (max-width: 480px) {
    h1 {
        font-size: 1.5em;
        margin-top: 5px;
    }

    .logo-container {
        margin: 10px 0;
    }

    .logo-container img {
        max-width: 120px;
    }

    #gameContainer {
        width: 100% !important;
        margin: 0;
    }

    button {
        padding: 14px 24px;
        font-size: 16px;
        margin: 8px 4px;
        min-width: 100px;
    }

    #playerStatus {
        font-size: 1em;
        margin: 5px;
        padding: 8px;
    }
    
    /* Player info adjustments */
    .player-info {
        top: 90px; /* Below toolbar (80px min-height) + gap */
        padding: 4px 8px;
        min-width: 70px;
    }
    
    .player-info .player-name {
        font-size: 0.75rem;
    }
    
    .player-info .player-timer {
        font-size: 1rem;
        padding: 3px 6px;
    }
    
    /* Undo/Redo toolbar */
    #undoRedoToolbar {
        min-height: 80px;
        padding: 6px 10px;
        gap: 8px;
    }
    
    .undo-redo-btn {
        width: 36px;
        height: 36px;
    }
    
    .player-indicator {
        font-size: 11px;
        padding: 3px 10px;
        min-width: 100px;
    }
    
    /* Canvas adjustments */
    #gameCanvas {
        margin-top: 80px;
        height: calc(100% - 80px);
    }
    
    #inventoryCanvas {
        top: 160px; /* Below toolbar (80px) + player info boxes (~70px) + gap */
        height: calc(100% - 160px);
    }
    
    /* Hamburger menu */
    .hamburger-btn {
        bottom: 12px;
        left: 12px;
        width: 40px;
        height: 40px;
    }
    
    .hamburger-modal-content {
        width: 260px;
        max-height: 80vh;
    }
    
    /* Lobby */
    .lobby-content {
        max-width: 320px;
        padding: 20px 16px;
    }
    
    .lobby-logo-img {
        max-width: 70px;
    }
    
    .lobby-title {
        font-size: 1.6rem;
    }
    
    .lobby-btn {
        padding: 12px 16px;
        font-size: 0.95rem;
    }
    
    .lobby-footer {
        gap: 8px;
        padding: 12px 0;
    }
    
    .footer-btn {
        padding: 10px 16px;
        font-size: 0.85rem;
    }
    
    /* Online game actions */
    .online-game-actions {
        bottom: 15px;
        gap: 10px;
    }
    
    .game-action-btn {
        width: 36px;
        height: 36px;
    }
}

/* Small phones (iPhone SE, older devices) */
@media (max-width: 375px) {
    .player-info {
        padding: 3px 6px;
        min-width: 60px;
    }
    
    .player-info .player-name {
        font-size: 0.7rem;
    }
    
    .player-info .player-timer {
        font-size: 0.9rem;
    }
    
    #undoRedoToolbar {
        min-height: 70px;
        padding: 4px 8px;
        gap: 6px;
    }
    
    .undo-redo-btn {
        width: 32px;
        height: 32px;
    }
    
    .player-indicator {
        font-size: 10px;
        padding: 2px 8px;
        min-width: 90px;
    }
    
    #gameCanvas {
        margin-top: 70px;
        height: calc(100% - 70px);
    }
    
    .lobby-content {
        max-width: 300px;
        padding: 16px 12px;
    }
    
    .lobby-logo-img {
        max-width: 60px;
    }
    
    .lobby-title {
        font-size: 1.4rem;
    }
    
    .lobby-btn {
        padding: 10px 14px;
        font-size: 0.9rem;
    }
    
    .hamburger-modal-content {
        width: 240px;
    }
}

/* Landscape mode - phones */
@media (max-height: 500px) and (orientation: landscape) {
    .logo-container {
        margin: 5px 0;
    }

    .logo-container img {
        max-width: 80px;
    }

    #gameContainer {
        margin: 0;
        max-height: none;
    }

    h1 {
        font-size: 1.3em;
        margin-top: 5px;
    }

    #playerStatus {
        font-size: 0.9em;
        margin: 5px;
        padding: 5px;
    }

    button {
        padding: 10px 20px;
        font-size: 14px;
        margin: 5px 3px;
    }
    
    /* Compact toolbar in landscape */
    #undoRedoToolbar {
        min-height: 60px;
        padding: 4px 8px;
    }
    
    .undo-redo-btn {
        width: 32px;
        height: 32px;
    }
    
    .player-indicator {
        font-size: 10px;
        padding: 2px 8px;
    }
    
    /* Move player info to sides with compact layout */
    .player-info {
        top: 50%;
        transform: translateY(-50%);
        padding: 6px 8px;
        flex-direction: column;
    }
    
    .player-info-left {
        left: 5px;
    }
    
    .player-info-right {
        right: 5px;
    }
    
    #gameCanvas {
        margin-top: 60px;
        height: calc(100% - 60px);
    }
    
    #inventoryCanvas {
        top: 120px; /* Below toolbar (60px) + player info boxes (~50px) + gap */
        height: calc(100% - 120px);
    }
    
    /* Hamburger menu positioning */
    .hamburger-btn {
        bottom: 10px;
        left: 10px;
        width: 36px;
        height: 36px;
    }
    
    /* Lobby in landscape */
    .lobby-overlay {
        padding: 10px;
    }
    
    .lobby-content {
        max-width: 90%;
        max-height: 95vh;
        padding: 15px;
        overflow-y: auto;
    }
    
    .lobby-logo {
        flex-direction: row;
        gap: 15px;
        margin-bottom: 15px;
    }
    
    .lobby-logo-img {
        max-width: 50px;
    }
    
    .lobby-title {
        font-size: 1.4rem;
    }
    
    .lobby-menu {
        gap: 10px;
    }
    
    .lobby-btn {
        padding: 10px 16px;
        font-size: 0.9rem;
    }
}

/* Landscape mode - tablets (iPad Mini, iPad in landscape) */
@media (min-width: 768px) and (max-height: 768px) and (orientation: landscape) {
    #undoRedoToolbar {
        min-height: 70px;
    }
    
    #gameCanvas {
        margin-top: 70px;
        height: calc(100% - 70px);
    }
    
    .player-info {
        top: 8px;
        transform: none;
    }
    
    .lobby-content {
        max-width: 500px;
        max-height: 90vh;
    }
}

/* High DPI / Retina displays */
@media (-webkit-min-device-pixel-ratio: 2), (min-resolution: 192dpi) {
    .hamburger-line {
        height: 2px;
    }
}

/* Hamburger Menu Button */
.hamburger-btn {
    position: fixed;
    bottom: 20px;
    left: 20px;
    z-index: 2000;
    background: var(--hamburger-bg);
    border: 1px solid var(--border-color);
    border-radius: 8px;
    padding: 10px;
    cursor: pointer;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 5px;
    width: 44px;
    height: 44px;
    transition: all 0.3s ease;
    box-shadow: 0 2px 10px var(--shadow-color);
}

.hamburger-btn:hover {
    transform: scale(1.05);
    background: var(--accent-color);
    border-color: var(--accent-color);
}

.hamburger-btn:hover .hamburger-line {
    background: #fff;
}

.hamburger-line {
    width: 20px;
    height: 2px;
    background: var(--text-primary);
    transition: all 0.3s ease;
    border-radius: 1px;
}

.hamburger-btn.open .hamburger-line:nth-child(1) {
    transform: rotate(45deg) translate(5px, 5px);
}

.hamburger-btn.open .hamburger-line:nth-child(2) {
    opacity: 0;
}

.hamburger-btn.open .hamburger-line:nth-child(3) {
    transform: rotate(-45deg) translate(5px, -5px);
}

/* Hamburger Modal */
.hamburger-modal {
    position: fixed;
    bottom: 80px;
    left: 20px;
    z-index: 1999;
    background: var(--menu-content-bg);
    border: 1px solid var(--border-color);
    border-radius: 12px;
    box-shadow: 0 10px 30px var(--shadow-color);
    width: 280px;
    max-width: calc(100vw - 40px);
    opacity: 0;
    transform: translateY(20px) scale(0.95);
    pointer-events: none;
    transition: all 0.3s ease;
}

.hamburger-modal.open {
    opacity: 1;
    transform: translateY(0) scale(1);
    pointer-events: auto;
}

.hamburger-modal-content {
    padding: 0;
}

.hamburger-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 16px 20px;
    border-bottom: 1px solid var(--border-color);
}

.hamburger-title {
    font-size: 1rem;
    font-weight: 600;
    color: var(--text-primary);
}

.close-hamburger-btn {
    background: none;
    border: none;
    font-size: 1.2rem;
    cursor: pointer;
    color: var(--text-secondary);
    padding: 4px 8px;
    margin: 0;
    min-height: auto;
    width: auto;
    transition: color 0.2s;
}

.close-hamburger-btn:hover {
    color: var(--text-primary);
    background: none;
    box-shadow: none;
}

.hamburger-settings {
    padding: 16px 20px;
}

.hamburger-item {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 16px;
}

.hamburger-item:last-child {
    margin-bottom: 0;
}

.hamburger-item label {
    font-size: 0.95rem;
    color: var(--text-primary);
}

.hamburger-item .toggle-container {
    display: flex;
    align-items: center;
    gap: 8px;
}

.hamburger-item .toggle-label {
    font-size: 0.75rem;
    color: var(--text-secondary);
}

.hamburger-footer {
    padding: 16px 20px;
    border-top: 1px solid var(--border-color);
}

.hamburger-main-menu-btn {
    width: 100%;
    padding: 12px 16px;
    background: transparent;
    border: 1px solid var(--border-color);
    border-radius: 8px;
    color: var(--text-primary);
    font-size: 0.95rem;
    cursor: pointer;
    transition: all 0.2s ease;
}

.hamburger-main-menu-btn:hover {
    background: var(--accent-color);
    border-color: var(--accent-color);
    color: #fff;
}

/* Online Game Actions in Hamburger Menu */
.hamburger-online-actions {
    padding: 0 20px 16px;
}

.hamburger-online-actions.hidden {
    display: none;
}

.hamburger-separator {
    height: 1px;
    background: var(--border-color);
    margin-bottom: 16px;
}

.hamburger-action-btn {
    width: 100%;
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 12px 16px;
    margin-bottom: 8px;
    background: transparent;
    border: 1px solid var(--border-color);
    border-radius: 8px;
    color: var(--text-primary);
    font-size: 0.95rem;
    cursor: pointer;
    transition: all 0.2s ease;
}

.hamburger-action-btn:last-child {
    margin-bottom: 0;
}

.hamburger-action-btn:disabled {
    opacity: 0.5;
    cursor: not-allowed;
}

.hamburger-action-btn svg {
    flex-shrink: 0;
}

.draw-action-btn:hover:not(:disabled) {
    background: rgba(102, 170, 255, 0.1);
    border-color: #66aaff;
    color: #66aaff;
}

.resign-action-btn:hover:not(:disabled) {
    background: rgba(239, 68, 68, 0.1);
    border-color: #ef4444;
    color: #ef4444;
}

/* Confirmation Modal */
.confirm-modal {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.7);
    z-index: 10001;
    display: flex;
    justify-content: center;
    align-items: center;
    opacity: 0;
    pointer-events: none;
    transition: opacity 0.3s ease;
}

.confirm-modal.open {
    opacity: 1;
    pointer-events: auto;
}

.confirm-modal-content {
    background: var(--menu-content-bg);
    padding: 30px;
    border-radius: 12px;
    border: 1px solid var(--border-color);
    text-align: center;
    max-width: 320px;
    width: 90%;
    box-shadow: 0 10px 30px var(--shadow-color);
}

.confirm-message {
    font-size: 1.1rem;
    color: var(--text-primary);
    margin-bottom: 24px;
    line-height: 1.5;
}

.confirm-message small {
    color: var(--text-secondary);
    font-size: 0.85rem;
}

.confirm-buttons {
    display: flex;
    gap: 12px;
    justify-content: center;
}

.confirm-btn {
    padding: 12px 24px;
    border-radius: 8px;
    font-size: 0.95rem;
    cursor: pointer;
    transition: all 0.2s ease;
    min-width: 100px;
}

.confirm-yes {
    background: #ef4444;
    border: 1px solid #ef4444;
    color: #fff;
}

.confirm-yes:hover {
    background: #dc2626;
    border-color: #dc2626;
}

.confirm-no {
    background: transparent;
    border: 1px solid var(--border-color);
    color: var(--text-primary);
}

.confirm-no:hover {
    background: var(--border-color);
}

/* Legacy - kept for compatibility */
.back-to-menu-btn {
    display: none;
}

/* Player Info Displays */
.player-info {
    position: absolute;
    top: 110px; /* Below toolbar (100px min-height + 10px gap) */
    z-index: 100;
    background: var(--hamburger-bg);
    border: 1px solid var(--border-color);
    border-radius: 8px;
    padding: 8px 14px;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 2px;
    min-width: 100px;
    box-shadow: 0 2px 8px var(--shadow-color);
}

.player-info-left {
    left: 10px;
}

.player-info-right {
    right: 10px;
}

.player-info .player-name {
    font-size: 0.9rem;
    font-weight: 600;
    color: var(--text-primary);
}

.player-info .player-rating {
    font-size: 0.75rem;
    color: var(--text-secondary);
}

.player-info .player-timer {
    font-size: 1.1rem;
    font-weight: 700;
    font-family: 'Courier New', monospace;
    color: var(--text-primary);
    margin-top: 4px;
    padding: 4px 8px;
    background: rgba(0, 0, 0, 0.2);
    border-radius: 4px;
    min-width: 60px;
    text-align: center;
}

.player-info .player-timer.active {
    background: #10b981;
    color: #fff;
}

.player-info .player-timer.low-time {
    background: #ef4444;
    color: #fff;
    animation: pulse-timer 0.5s ease-in-out infinite;
}

@keyframes pulse-timer {
    0%, 100% { opacity: 1; }
    50% { opacity: 0.7; }
}

/* Time Control Select in Lobby */
.time-control-select {
    display: flex;
    flex-direction: column;
    gap: 6px;
    width: 100%;
    margin-bottom: 12px;
}

.time-control-select label {
    font-size: 0.85rem;
    color: var(--text-secondary);
}

.lobby-select {
    padding: 10px 14px;
    font-size: 1rem;
    border: 1px solid var(--border-color);
    border-radius: 8px;
    background: var(--hamburger-bg);
    color: var(--text-primary);
    cursor: pointer;
    width: 100%;
}

.lobby-select:focus {
    outline: none;
    border-color: var(--accent-color, #10b981);
}

/* Resume Button */
.resume-section {
    margin-bottom: 16px;
}

.resume-btn {
    background: linear-gradient(135deg, #10b981, #059669) !important;
    color: #fff !important;
    font-weight: 600;
}

.resume-btn:hover {
    background: linear-gradient(135deg, #059669, #047857) !important;
}

/* Menu Overlay */
#menuOverlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: var(--menu-overlay-bg);
    backdrop-filter: blur(5px);
    z-index: 2001;
    display: flex;
    justify-content: center;
    align-items: center;
    opacity: 0;
    pointer-events: none;
    transition: opacity 0.3s ease;
}

#menuOverlay.open {
    opacity: 1;
    pointer-events: auto;
}

.menu-content {
    background: var(--menu-content-bg);
    padding: 30px;
    border-radius: 12px;
    border: 1px solid var(--border-color);
    width: 90%;
    max-width: 400px;
    box-shadow: 0 10px 25px var(--shadow-color);
    text-align: center;
    transform: translateY(20px);
    transition: transform 0.3s ease, background 0.3s ease;
}

#menuOverlay.open .menu-content {
    transform: translateY(0);
}

.menu-title {
    font-size: 1.5em;
    margin-bottom: 20px;
    color: var(--text-primary);
    border-bottom: 1px solid var(--border-color);
    padding-bottom: 10px;
}

.menu-item {
    margin-bottom: 20px;
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.menu-item label {
    font-size: 1.1em;
    color: var(--text-secondary);
}

/* Controls styling */
.switch {
    position: relative;
    display: inline-block;
    width: 60px;
    height: 34px;
}

.switch input {
    opacity: 0;
    width: 0;
    height: 0;
}

.slider {
    position: absolute;
    cursor: pointer;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background-color: #ccc;
    transition: .4s;
    border-radius: 34px;
}

.slider:before {
    position: absolute;
    content: "";
    height: 26px;
    width: 26px;
    left: 4px;
    bottom: 4px;
    background-color: white;
    transition: .4s;
    border-radius: 50%;
}

input:checked+.slider {
    background-color: var(--accent-color);
}

input:focus+.slider {
    box-shadow: 0 0 1px var(--accent-color);
}

input:checked+.slider:before {
    transform: translateX(26px);
}

select {
    padding: 8px 12px;
    border-radius: 4px;
    background: var(--input-bg);
    color: var(--text-primary);
    border: 1px solid var(--input-border);
    font-size: 1em;
    outline: none;
    transition: background 0.3s ease, color 0.3s ease;
}

.menu-btn {
    width: 100%;
    margin: 10px 0;
    background: var(--input-bg);
    border: 1px solid var(--input-border);
    color: var(--text-primary);
}

.menu-btn:hover {
    background: var(--border-color);
}

.menu-btn.primary {
    background: var(--accent-color);
    border: none;
    margin-top: 20px;
    color: white;
}

.menu-btn.primary:hover {
    background: var(--accent-hover);
}

/* Rules Modal Styles */
.rules-overlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: var(--menu-overlay-bg);
    backdrop-filter: blur(5px);
    z-index: 10000;
    display: flex;
    justify-content: center;
    align-items: center;
    opacity: 0;
    pointer-events: none;
    transition: opacity 0.3s ease;
}

.rules-overlay.open {
    opacity: 1;
    pointer-events: auto;
}

.rules-modal {
    background: var(--menu-content-bg);
    border: 1px solid var(--border-color);
    border-radius: 12px;
    box-shadow: 0 10px 40px var(--shadow-color);
    width: 90%;
    max-width: 900px;
    height: 90vh;
    max-height: 800px;
    display: flex;
    flex-direction: column;
    overflow: hidden;
    transform: scale(0.9);
    transition: transform 0.3s ease;
}

.rules-overlay.open .rules-modal {
    transform: scale(1);
}

.rules-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 20px;
    border-bottom: 1px solid var(--border-color);
    flex-shrink: 0;
}

.rules-header h2 {
    margin: 0;
    font-size: 1.5em;
    color: var(--text-primary);
}

.close-rules-btn {
    background: transparent;
    border: 1px solid var(--border-color);
    color: var(--text-primary);
    font-size: 20px;
    cursor: pointer;
    padding: 0;
    width: 36px;
    height: 36px;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: 6px;
    transition: background 0.2s ease, border-color 0.2s ease;
    flex-shrink: 0;
}

.close-rules-btn:hover {
    background: var(--border-color);
    border-color: var(--accent-color);
}

.pdf-container {
    flex: 1;
    overflow: auto;
    display: flex;
    justify-content: center;
    align-items: flex-start;
    padding: 15px;
    background: var(--bg-body);
    overscroll-behavior: contain;
}

.pdf-viewer {
    display: flex;
    justify-content: center;
    align-items: flex-start;
    background: var(--menu-content-bg);
    border-radius: 8px;
    box-shadow: 0 2px 8px var(--shadow-color);
    max-width: 100%;
}

#pdfCanvas {
    display: block;
    max-width: 100%;
    height: auto;
}

.rules-footer {
    display: flex;
    justify-content: center;
    align-items: center;
    gap: 20px;
    padding: 20px;
    border-top: 1px solid var(--border-color);
    background: var(--menu-content-bg);
    flex-shrink: 0;
}

.page-nav-btn {
    padding: 10px 16px;
    font-size: 14px;
    background: var(--accent-color);
    color: white;
    border: none;
    border-radius: 6px;
    cursor: pointer;
    transition: all 0.2s ease;
    min-height: 40px;
    margin: 0;
}

.page-nav-btn:hover:not(:disabled) {
    background: var(--accent-hover);
    transform: translateY(-2px);
    box-shadow: 0 4px 8px var(--shadow-color);
}

.page-nav-btn:active:not(:disabled) {
    transform: translateY(0);
}

.page-nav-btn:disabled {
    background: var(--border-color);
    color: var(--text-secondary);
    cursor: not-allowed;
    opacity: 0.5;
}

.page-indicator {
    font-size: 14px;
    font-weight: 600;
    color: var(--text-secondary);
    min-width: 120px;
    text-align: center;
}

/* Responsive rules modal - Tablets */
@media (max-width: 768px) {
    .rules-modal {
        width: 95%;
        height: 85vh;
        max-height: 90vh;
        max-width: none;
    }

    .rules-header {
        padding: 15px;
    }

    .rules-header h2 {
        font-size: 1.3em;
    }

    .rules-footer {
        gap: 10px;
        padding: 15px;
    }

    .page-nav-btn {
        padding: 8px 12px;
        font-size: 12px;
        min-height: 36px;
    }

    .page-indicator {
        font-size: 12px;
        min-width: 100px;
    }

    .pdf-container {
        padding: 10px;
    }
}

/* Responsive rules modal - Phones */
@media (max-width: 480px) {
    .rules-modal {
        width: 98%;
        height: 85vh;
        max-height: 90vh;
        border-radius: 12px;
    }

    .rules-header {
        padding: 12px;
    }

    .rules-header h2 {
        font-size: 1.1em;
    }

    .close-rules-btn {
        width: 32px;
        height: 32px;
        font-size: 18px;
    }

    .rules-footer {
        gap: 8px;
        padding: 12px;
        flex-wrap: wrap;
    }

    .page-nav-btn {
        padding: 8px 10px;
        font-size: 11px;
        min-height: 34px;
        flex: 1;
        min-width: 60px;
    }

    .page-indicator {
        width: 100%;
        order: 3;
        font-size: 11px;
        min-width: auto;
        margin-top: 5px;
    }

    .pdf-container {
        padding: 8px;
    }
}

/* Responsive rules modal - Landscape phones */
@media (max-height: 500px) and (orientation: landscape) {
    .rules-modal {
        width: 90%;
        height: 95vh;
        max-height: 95vh;
    }
    
    .rules-header {
        padding: 10px 15px;
    }
    
    .rules-header h2 {
        font-size: 1rem;
    }
    
    .rules-footer {
        padding: 8px 15px;
    }
    
    .page-nav-btn {
        padding: 6px 10px;
        font-size: 11px;
        min-height: 32px;
    }
}

/* ===== Online Multiplayer Modal Styles ===== */
.online-overlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: var(--menu-overlay-bg);
    backdrop-filter: blur(5px);
    z-index: 3000;
    display: flex;
    justify-content: center;
    align-items: center;
    opacity: 0;
    pointer-events: none;
    transition: opacity 0.3s ease;
}

.online-overlay.open {
    opacity: 1;
    pointer-events: auto;
}

.online-modal {
    background: var(--menu-content-bg);
    border-radius: 12px;
    border: 1px solid var(--border-color);
    width: 90%;
    max-width: 400px;
    box-shadow: 0 10px 25px var(--shadow-color);
    transform: translateY(20px);
    transition: transform 0.3s ease;
}

.online-overlay.open .online-modal {
    transform: translateY(0);
}

.online-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 20px;
    border-bottom: 1px solid var(--border-color);
}

.online-header h2 {
    margin: 0;
    font-size: 1.3em;
    color: var(--text-primary);
}

.close-online-btn {
    background: transparent;
    border: 1px solid var(--border-color);
    font-size: 1.2em;
    cursor: pointer;
    color: var(--text-secondary);
    padding: 0;
    margin: 0;
    width: 32px;
    height: 32px;
    min-height: 32px;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: 6px;
    transition: background 0.2s, color 0.2s, border-color 0.2s;
    flex-shrink: 0;
}

.close-online-btn:hover {
    background: var(--border-color);
    color: var(--text-primary);
    border-color: var(--accent-color);
}

.online-content {
    padding: 20px;
}

/* Connection Status */
.connection-status {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    padding: 12px;
    background: var(--input-bg);
    border-radius: 8px;
    margin-bottom: 20px;
}

.connection-status .status-dot {
    width: 10px;
    height: 10px;
    border-radius: 50%;
    background: #f59e0b;
    animation: pulse 1.5s infinite;
}

.connection-status.connected .status-dot {
    background: #10b981;
    animation: none;
}

.connection-status.disconnected .status-dot {
    background: #ef4444;
    animation: none;
}

.connection-status .status-text {
    font-size: 0.95em;
    color: var(--text-secondary);
}

@keyframes pulse {
    0%, 100% { opacity: 1; }
    50% { opacity: 0.4; }
}

/* Room Actions */
.room-actions {
    text-align: center;
}

.online-btn {
    width: 100%;
    padding: 14px 20px;
    font-size: 1em;
    border: 1px solid var(--input-border);
    border-radius: 8px;
    background: var(--input-bg);
    color: var(--text-primary);
    cursor: pointer;
    transition: all 0.2s;
    margin: 8px 0;
}

.online-btn:hover {
    background: var(--border-color);
}

.online-btn.primary {
    background: var(--accent-color);
    border-color: var(--accent-color);
    color: white;
}

.online-btn.primary:hover {
    background: var(--accent-hover);
}

.online-btn.secondary {
    background: transparent;
    border-color: var(--border-color);
}

.online-btn.danger {
    background: #ef4444;
    border-color: #ef4444;
    color: white;
}

.online-btn.danger:hover {
    background: #dc2626;
}

.divider {
    display: flex;
    align-items: center;
    margin: 16px 0;
    color: var(--text-secondary);
}

.divider::before,
.divider::after {
    content: '';
    flex: 1;
    height: 1px;
    background: var(--border-color);
}

.divider span {
    padding: 0 12px;
    font-size: 0.9em;
}

.join-room-section {
    display: flex;
    flex-direction: column;
    gap: 10px;
}

.room-code-input {
    width: 100%;
    padding: 14px;
    font-size: 1.5em;
    text-align: center;
    text-transform: uppercase;
    letter-spacing: 0.3em;
    border: 2px solid var(--input-border);
    border-radius: 8px;
    background: var(--input-bg);
    color: var(--text-primary);
    outline: none;
    transition: border-color 0.2s;
}

.room-code-input:focus {
    border-color: var(--accent-color);
}

.room-code-input::placeholder {
    letter-spacing: normal;
    font-size: 0.7em;
    color: var(--text-secondary);
}

/* Waiting Section */
.waiting-section {
    text-align: center;
}

.room-code-display {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 8px;
    padding: 20px;
    background: var(--input-bg);
    border-radius: 12px;
    margin-bottom: 20px;
}

.room-code-label {
    font-size: 0.9em;
    color: var(--text-secondary);
}

.room-code-value {
    font-size: 2.5em;
    font-weight: bold;
    letter-spacing: 0.2em;
    color: var(--accent-color);
}

.copy-btn {
    background: var(--input-bg);
    border: 1px solid var(--border-color);
    padding: 8px 16px;
    border-radius: 6px;
    cursor: pointer;
    font-size: 1em;
    color: var(--text-primary);
    transition: background 0.2s;
    min-height: 36px;
}

.copy-btn:hover {
    background: var(--border-color);
}

.waiting-text {
    color: var(--text-secondary);
    margin-bottom: 16px;
}

.loading-spinner {
    width: 40px;
    height: 40px;
    border: 3px solid var(--border-color);
    border-top-color: var(--accent-color);
    border-radius: 50%;
    animation: spin 1s linear infinite;
    margin: 0 auto 20px;
}

@keyframes spin {
    to { transform: rotate(360deg); }
}

/* In-Game Section */
.in-game-section {
    text-align: center;
}

.game-info {
    background: var(--input-bg);
    border-radius: 12px;
    padding: 20px;
    margin-bottom: 20px;
}

.player-color {
    margin-bottom: 16px;
}

.color-label {
    display: block;
    font-size: 0.9em;
    color: var(--text-secondary);
    margin-bottom: 4px;
}

.color-value {
    font-size: 1.4em;
    font-weight: bold;
    color: var(--text-primary);
}

.color-value.black {
    color: #333;
}

[data-theme="light"] .color-value.black {
    color: #000;
}

.color-value.white {
    color: #888;
}

[data-theme="light"] .color-value.white {
    color: #666;
}

.room-info {
    margin-bottom: 16px;
    padding-bottom: 16px;
    border-bottom: 1px solid var(--border-color);
}

.room-label {
    color: var(--text-secondary);
    font-size: 0.9em;
}

.room-value {
    font-weight: bold;
    letter-spacing: 0.1em;
    color: var(--text-primary);
    margin-left: 8px;
}

.opponent-status {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
}

.opponent-status .status-dot {
    width: 8px;
    height: 8px;
    border-radius: 50%;
    background: #10b981;
}

.opponent-status.disconnected .status-dot {
    background: #f59e0b;
    animation: pulse 1.5s infinite;
}

.opponent-status .opponent-text {
    font-size: 0.9em;
    color: var(--text-secondary);
}

/* Error Message */
.error-message {
    background: #fef2f2;
    border: 1px solid #fecaca;
    color: #dc2626;
    padding: 12px;
    border-radius: 8px;
    margin-top: 16px;
    font-size: 0.9em;
}

[data-theme="dark"] .error-message,
:root .error-message {
    background: rgba(239, 68, 68, 0.1);
    border-color: rgba(239, 68, 68, 0.3);
}

/* Online indicator in player toolbar */
.online-indicator {
    display: inline-flex;
    align-items: center;
    gap: 4px;
    margin-left: 8px;
    font-size: 0.8em;
    color: var(--text-secondary);
}

.online-indicator .status-dot {
    width: 6px;
    height: 6px;
    border-radius: 50%;
    background: #10b981;
}

/* Responsive adjustments */
@media (max-width: 480px) {
    .online-modal {
        width: 95%;
    }
    
    .room-code-value {
        font-size: 2em;
    }
    
    .room-code-input {
        font-size: 1.2em;
    }
}

/* ===== End Game Popup Styles (Online Mode) ===== */
.game-over-popup {
    font-family: system-ui, -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
}

.endgame-opponent-status {
    display: flex;
    align-items: center;
    justify-content: center;
}

.endgame-btn {
    font-family: inherit;
}

.endgame-btn:disabled {
    opacity: 0.7;
}

.endgame-btn.play-again:hover:not(:disabled) {
    background-color: #059669 !important;
}

.endgame-btn.leave-room:hover {
    background-color: #dc2626 !important;
}

/* Pulse animation for waiting status */
@keyframes pulse {
    0%, 100% { opacity: 1; }
    50% { opacity: 0.4; }
}

/* ===== Main Lobby Styles ===== */
.lobby-overlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: var(--bg-body);
    z-index: 9999;
    display: flex;
    align-items: flex-start;
    justify-content: center;
    overflow-y: auto;
    transition: opacity 0.3s ease, visibility 0.3s ease, background 0.3s ease;
}

.lobby-overlay.hidden {
    opacity: 0;
    visibility: hidden;
    pointer-events: none;
}

.lobby-content {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 20px;
    padding: 20px 40px 40px;
    padding-top: 80px; /* Account for fixed header */
    max-width: 400px;
    width: 90%;
    min-height: 100vh;
    box-sizing: border-box;
}

.lobby-logo {
    text-align: center;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 16px;
    transition: opacity 0.3s ease, transform 0.3s ease;
}

/* Hide lobby logo when on sub-pages (logo is in header) */
.lobby-logo.hidden {
    display: none !important;
}

.lobby-logo-img {
    width: 120px;
    height: auto;
    transition: filter 0.3s ease;
}

/* En mode sombre (défaut), inverser le logo pour qu'il soit blanc */
[data-theme="light"] .lobby-logo-img {
    filter: none;
}

/* En mode sombre, le logo noir devient blanc via invert */
body:not([data-theme="light"]) .lobby-logo-img {
    filter: invert(1);
}

.lobby-title {
    font-size: 2.2rem;
    font-weight: 700;
    letter-spacing: 0.2em;
    color: var(--title-color);
    margin: 0;
}

.lobby-menu {
    width: 100%;
    display: flex;
    flex-direction: column;
    gap: 10px;
}

.lobby-section {
    display: flex;
    flex-direction: column;
    gap: 10px;
    width: 100%;
    /* Page transition animations */
    animation: pageEnter 0.3s ease-out;
}

/* ==================== Page Transition Animations ==================== */
@keyframes pageEnter {
    from {
        opacity: 0;
        transform: translateY(15px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

@keyframes pageExit {
    from {
        opacity: 1;
        transform: translateY(0);
    }
    to {
        opacity: 0;
        transform: translateY(-15px);
    }
}

/* Animation for lobby logo on main menu */
.lobby-logo {
    animation: logoEnter 0.5s ease-out;
}

@keyframes logoEnter {
    from {
        opacity: 0;
        transform: scale(0.9);
    }
    to {
        opacity: 1;
        transform: scale(1);
    }
}

/* Animation for menu buttons */
.mode-selection .lobby-btn {
    animation: buttonEnter 0.4s ease-out backwards;
}

.mode-selection .lobby-btn:nth-child(1) {
    animation-delay: 0.1s;
}

.mode-selection .lobby-btn:nth-child(2) {
    animation-delay: 0.2s;
}

.mode-selection .lobby-btn:nth-child(3) {
    animation-delay: 0.3s;
}

@keyframes buttonEnter {
    from {
        opacity: 0;
        transform: translateX(-20px);
    }
    to {
        opacity: 1;
        transform: translateX(0);
    }
}
}

.lobby-btn {
    width: 100%;
    padding: 14px 20px;
    background: transparent;
    border: 1px solid var(--border-color);
    border-radius: 6px;
    color: var(--text-primary);
    font-size: 0.95rem;
    font-weight: 500;
    cursor: pointer;
    transition: all 0.2s ease;
    text-align: center;
}

.lobby-btn:hover {
    background: var(--accent-color);
    border-color: var(--accent-color);
    color: #fff;
}

.lobby-btn.primary {
    background: var(--accent-color);
    border-color: var(--accent-color);
    color: #fff;
}

.lobby-btn.primary:hover {
    background: var(--accent-hover);
    border-color: var(--accent-hover);
}

.lobby-btn.secondary {
    background: transparent;
    border-color: var(--border-color);
    color: var(--text-secondary);
}

.lobby-btn.secondary:hover {
    background: var(--border-color);
    color: var(--text-primary);
}

/* Local Game Configuration */
.local-config {
    width: 100%;
}

.player-config {
    display: flex;
    flex-direction: column;
    gap: 12px;
    margin-bottom: 16px;
}

.player-config-row {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 10px;
    background: var(--input-bg);
    border-radius: 8px;
    border: 1px solid var(--border-color);
}

.player-config-label {
    font-size: 1rem;
    font-weight: 600;
    min-width: 70px;
    color: var(--text-primary);
}

.player-type-select,
.ai-level-select {
    flex: 1;
    padding: 8px 12px;
    font-size: 0.9rem;
    border: 1px solid var(--border-color);
    border-radius: 6px;
    background: var(--bg-container);
    color: var(--text-primary);
    cursor: pointer;
}

.player-type-select:focus,
.ai-level-select:focus {
    outline: none;
    border-color: var(--accent-color);
}

.time-control-config {
    margin-bottom: 16px;
}

.config-label {
    display: block;
    font-size: 0.85rem;
    color: var(--text-secondary);
    margin-bottom: 6px;
}

/* AI Options (legacy - kept for compatibility) */
.section-title {
    color: var(--text-secondary);
    font-size: 0.8rem;
    text-transform: uppercase;
    letter-spacing: 0.15em;
    margin: 10px 0 5px 0;
    text-align: center;
}

.difficulty-buttons {
    display: grid;
    grid-template-columns: repeat(2, 1fr);
    gap: 8px;
}

.diff-btn {
    padding: 12px 16px;
    background: transparent;
    border: 1px solid var(--border-color);
    border-radius: 6px;
    color: var(--text-primary);
    font-size: 0.9rem;
    cursor: pointer;
    transition: all 0.2s ease;
}

.diff-btn:hover {
    border-color: var(--accent-color);
    color: var(--accent-color);
}

.diff-btn.selected {
    background: var(--accent-color);
    border-color: var(--accent-color);
    color: #fff;
    font-weight: 600;
}

/* Online Options */
.online-options {
    width: 100%;
}

.lobby-room-actions {
    display: flex;
    flex-direction: column;
    gap: 10px;
    width: 100%;
}

.lobby-room-actions .lobby-btn.primary {
    width: 100%;
}

.lobby-connection-status {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 10px;
    padding: 12px;
    background: var(--input-bg);
    border-radius: 6px;
    margin-bottom: 10px;
}

.lobby-connection-status .status-dot {
    width: 8px;
    height: 8px;
    border-radius: 50%;
    background: #ffc107;
    animation: pulse 1.5s infinite;
}

.lobby-connection-status .status-dot.connected {
    background: var(--accent-color);
    animation: none;
}

.lobby-connection-status .status-dot.error {
    background: #f44336;
    animation: none;
}

.lobby-connection-status .status-text {
    color: var(--text-secondary);
    font-size: 0.85rem;
}

.join-section {
    text-align: center;
    margin-top: 10px;
}

.join-divider {
    color: var(--text-secondary);
    font-size: 0.8rem;
    margin: 15px 0;
}

.join-input-group {
    display: flex;
    gap: 8px;
    justify-content: center;
}

.room-input {
    width: 90px;
    padding: 12px;
    background: var(--input-bg);
    border: 1px solid var(--input-border);
    border-radius: 6px;
    color: var(--text-primary);
    font-size: 1.1rem;
    text-align: center;
    text-transform: uppercase;
    letter-spacing: 0.15em;
}

.room-input::placeholder {
    color: var(--text-secondary);
    opacity: 0.5;
}

.room-input:focus {
    outline: none;
    border-color: var(--accent-color);
}

.join-input-group .lobby-btn {
    width: auto;
    padding: 12px 20px;
}

/* Room Browser Section */
.room-browser-section {
    margin-top: 15px;
    width: 100%;
}

.room-browser-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 10px;
}

.room-browser-title {
    font-size: 0.9rem;
    font-weight: 600;
    color: var(--text-primary);
}

.refresh-btn {
    width: 32px;
    height: 32px;
    padding: 0;
    background: transparent;
    border: 1px solid var(--border-color);
    border-radius: 6px;
    color: var(--text-primary);
    font-size: 1.2rem;
    cursor: pointer;
    transition: all 0.2s ease;
    display: flex;
    align-items: center;
    justify-content: center;
    min-height: auto;
    margin: 0;
}

.refresh-btn:hover {
    background: var(--accent-color);
    border-color: var(--accent-color);
    color: #fff;
}

.refresh-btn.spinning {
    animation: spin 0.5s linear;
}

@keyframes spin {
    from { transform: rotate(0deg); }
    to { transform: rotate(360deg); }
}

/* Room Filters */
.room-filters {
    display: flex;
    flex-direction: column;
    gap: 8px;
    padding: 10px;
    background: var(--input-bg);
    border: 1px solid var(--border-color);
    border-radius: 6px;
    margin-bottom: 10px;
}

.filter-group {
    display: flex;
    align-items: center;
    gap: 8px;
    flex-wrap: wrap;
}

.filter-label {
    font-size: 0.75rem;
    color: var(--text-secondary);
    min-width: 45px;
}

.filter-checkboxes {
    display: flex;
    flex-wrap: wrap;
    gap: 6px;
}

.filter-checkboxes label {
    display: flex;
    align-items: center;
    gap: 4px;
    font-size: 0.7rem;
    color: var(--text-primary);
    cursor: pointer;
    padding: 3px 6px;
    background: var(--bg-container);
    border: 1px solid var(--border-color);
    border-radius: 4px;
    transition: all 0.2s ease;
}

.filter-checkboxes label:hover {
    border-color: var(--accent-color);
}

.filter-checkboxes input[type="checkbox"] {
    width: 12px;
    height: 12px;
    margin: 0;
    accent-color: var(--accent-color);
}

.elo-filter .elo-range {
    display: flex;
    align-items: center;
    gap: 5px;
}

.elo-input {
    width: 55px;
    padding: 4px 6px;
    background: var(--bg-container);
    border: 1px solid var(--border-color);
    border-radius: 4px;
    color: var(--text-primary);
    font-size: 0.75rem;
    text-align: center;
}

.elo-input:focus {
    outline: none;
    border-color: var(--accent-color);
}

.elo-range span {
    color: var(--text-secondary);
    font-size: 0.75rem;
}

/* Room List Table */
.room-list-container {
    max-height: 200px;
    overflow-y: auto;
    border: 1px solid var(--border-color);
    border-radius: 6px;
    background: var(--input-bg);
}

.room-list-table {
    width: 100%;
    border-collapse: collapse;
    font-size: 0.8rem;
}

.room-list-table thead {
    position: sticky;
    top: 0;
    background: var(--bg-container);
    z-index: 1;
}

.room-list-table th {
    padding: 8px 10px;
    text-align: left;
    font-weight: 600;
    color: var(--text-secondary);
    border-bottom: 1px solid var(--border-color);
    font-size: 0.75rem;
    text-transform: uppercase;
}

.room-list-table th.sortable {
    cursor: pointer;
    user-select: none;
    transition: color 0.2s ease;
}

.room-list-table th.sortable:hover {
    color: var(--accent-color);
}

.room-list-table th .sort-arrow {
    margin-left: 4px;
    font-size: 0.6rem;
}

.room-list-table th.sort-asc .sort-arrow::after {
    content: '▲';
}

.room-list-table th.sort-desc .sort-arrow::after {
    content: '▼';
}

.room-list-table tbody tr {
    cursor: pointer;
    transition: background 0.2s ease;
}

.room-list-table tbody tr:hover {
    background: var(--accent-color);
}

.room-list-table tbody tr:hover td {
    color: #fff;
}

/* Own room styling - not clickable */
.room-list-table tbody tr.own-room {
    cursor: default;
    background: rgba(102, 170, 255, 0.1);
    border-left: 3px solid #66aaff;
}

.room-list-table tbody tr.own-room:hover {
    background: rgba(102, 170, 255, 0.15);
}

.room-list-table tbody tr.own-room:hover td {
    color: var(--text-primary);
}

.room-list-table td {
    padding: 10px;
    border-bottom: 1px solid var(--border-color);
    color: var(--text-primary);
}

.room-list-table tbody tr:last-child td {
    border-bottom: none;
}

.room-list-empty {
    display: none;
    padding: 30px 15px;
    text-align: center;
    color: var(--text-secondary);
}

.room-list-empty p {
    margin: 0;
}

.room-list-empty .empty-hint {
    font-size: 0.75rem;
    margin-top: 5px;
    opacity: 0.7;
}

.room-list-container:has(tbody:empty) .room-list-table {
    display: none;
}

.room-list-container:has(tbody:empty) .room-list-empty {
    display: block;
}

/* Time control badge in room list */
.time-badge {
    display: inline-block;
    padding: 2px 6px;
    border-radius: 3px;
    font-size: 0.7rem;
    font-weight: 600;
}

.time-badge.none { background: #6b7280; color: #fff; }
.time-badge.classic { background: #3b82f6; color: #fff; }
.time-badge.rapid { background: #10b981; color: #fff; }
.time-badge.blitz { background: #f59e0b; color: #fff; }
.time-badge.bullet { background: #ef4444; color: #fff; }

/* Waiting Section */
.lobby-waiting {
    display: none;
    flex-direction: row;
    align-items: center;
    justify-content: center;
    gap: 15px;
    padding: 12px 20px;
    background: rgba(102, 170, 255, 0.1);
    border: 1px solid rgba(102, 170, 255, 0.3);
    border-radius: 8px;
    margin-bottom: 15px;
}

.lobby-waiting .waiting-animation {
    display: flex;
    align-items: center;
    gap: 10px;
    margin: 0;
}

.lobby-waiting .waiting-animation .spinner {
    width: 20px;
    height: 20px;
    border: 2px solid var(--border-color);
    border-top-color: #66aaff;
    border-radius: 50%;
    margin: 0;
    animation: spin 1s linear infinite;
}

.lobby-waiting .waiting-animation span {
    color: var(--text-secondary);
    font-size: 0.9rem;
}

.lobby-waiting .lobby-btn {
    padding: 6px 16px;
    font-size: 0.85rem;
}

.room-code-box {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 8px;
    padding: 20px;
    background: var(--input-bg);
    border: 1px solid var(--border-color);
    border-radius: 6px;
    margin-bottom: 15px;
}

.code-label {
    color: var(--text-secondary);
    font-size: 0.8rem;
    text-transform: uppercase;
    letter-spacing: 0.1em;
}

.code-value {
    font-size: 1.8rem;
    font-weight: 700;
    color: var(--accent-color);
    letter-spacing: 0.3em;
    font-family: 'Courier New', monospace;
}

.copy-btn {
    background: transparent;
    border: 1px solid var(--border-color);
    border-radius: 4px;
    color: var(--text-secondary);
    font-size: 0.8rem;
    cursor: pointer;
    padding: 6px 12px;
    transition: all 0.2s;
}

.copy-btn:hover {
    border-color: var(--accent-color);
    color: var(--accent-color);
}

.waiting-animation {
    margin: 15px 0;
}

.waiting-animation .spinner {
    width: 30px;
    height: 30px;
    border: 2px solid var(--border-color);
    border-top-color: var(--accent-color);
    border-radius: 50%;
    margin: 0 auto 10px;
    animation: spin 1s linear infinite;
}

@keyframes spin {
    to { transform: rotate(360deg); }
}

.waiting-animation p {
    color: var(--text-secondary);
    font-size: 0.9rem;
    margin: 0;
}

.lobby-error {
    padding: 10px 12px;
    background: rgba(244, 67, 54, 0.1);
    border: 1px solid rgba(244, 67, 54, 0.3);
    border-radius: 6px;
    color: #f44336;
    font-size: 0.85rem;
    margin-top: 10px;
}

/* Settings Section */
.settings-section {
    gap: 0 !important;
}

.settings-item {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 14px 0;
    border-bottom: 1px solid var(--border-color);
    color: var(--text-primary);
    font-size: 0.9rem;
}

.settings-item:last-of-type {
    border-bottom: none;
    margin-bottom: 15px;
}

.theme-toggle {
    display: flex;
    align-items: center;
    gap: 8px;
}

.theme-label {
    font-size: 0.8rem;
    color: var(--text-secondary);
}

/* Footer */
.lobby-footer {
    display: flex;
    gap: 30px;
    margin-top: 10px;
}

.footer-btn {
    background: transparent;
    border: none;
    color: var(--text-secondary);
    font-size: 0.9rem;
    cursor: pointer;
    padding: 8px 0;
    transition: color 0.2s;
    text-decoration: underline;
    text-underline-offset: 3px;
}

.footer-btn:hover {
    color: var(--text-primary);
}

/* Responsive */
@media (max-width: 480px) {
    .lobby-content {
        padding: 30px 20px;
        gap: 30px;
    }
    
    .lobby-title {
        font-size: 1.8rem;
    }
    
    .lobby-btn {
        padding: 12px 16px;
    }
}

/* User Status */
.user-status {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 10px;
    padding: 10px 14px;
    background: rgba(255, 255, 255, 0.03);
    border: 1px solid var(--border-color);
    border-radius: 8px;
    margin-bottom: 15px;
    flex-wrap: wrap;
}

.user-name {
    color: var(--text-primary);
    font-weight: 500;
    font-size: 0.95rem;
}

.user-elo {
    color: var(--accent-color);
    font-weight: 600;
    font-size: 0.85rem;
    padding: 2px 8px;
    background: rgba(74, 158, 255, 0.1);
    border-radius: 4px;
}

.user-elo:empty {
    display: none;
}

.user-action-btn {
    background: transparent;
    border: 1px solid var(--accent-color);
    color: var(--accent-color);
    padding: 6px 12px;
    border-radius: 4px;
    font-size: 0.8rem;
    cursor: pointer;
    transition: all 0.2s;
}

.user-action-btn:hover {
    background: var(--accent-color);
    color: #fff;
}

.user-stats {
    display: flex;
    gap: 12px;
    font-size: 0.8rem;
    color: var(--text-secondary);
}

/* Auth Section */
.auth-section {
    max-width: 300px;
    margin: 0 auto;
}

.auth-tabs {
    display: flex;
    gap: 0;
    margin-bottom: 20px;
    border-radius: 6px;
    overflow: hidden;
    border: 1px solid var(--border-color);
}

.auth-tab {
    flex: 1;
    padding: 10px 16px;
    background: transparent;
    border: none;
    color: var(--text-secondary);
    font-size: 0.9rem;
    cursor: pointer;
    transition: all 0.2s;
}

.auth-tab:first-child {
    border-right: 1px solid var(--border-color);
}

.auth-tab.active {
    background: var(--accent-color);
    color: #fff;
}

.auth-tab:hover:not(.active) {
    background: rgba(255, 255, 255, 0.05);
}

.auth-form {
    display: flex;
    flex-direction: column;
    gap: 12px;
}

.auth-form input {
    padding: 12px 14px;
    background: rgba(255, 255, 255, 0.05);
    border: 1px solid var(--border-color);
    border-radius: 6px;
    color: var(--text-primary);
    font-size: 0.95rem;
    outline: none;
    transition: border-color 0.2s;
}

.auth-form input::placeholder {
    color: var(--text-secondary);
}

.auth-form input:focus {
    border-color: var(--accent-color);
}

.auth-form .lobby-btn {
    margin-top: 5px;
}

#backFromAuthBtn {
    margin-top: 15px;
}

/* Profile Button */
.profile-btn {
    background: transparent;
    border: 1px solid var(--text-secondary);
    color: var(--text-secondary);
}

.profile-btn:hover {
    background: var(--text-secondary);
    color: var(--bg-body);
}

/* Profile Modal */
.profile-modal {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.7);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 10001;
}

.profile-modal-content {
    background: var(--bg-body);
    border: 1px solid var(--border-color);
    border-radius: 12px;
    padding: 30px;
    max-width: 350px;
    width: 90%;
    position: relative;
    text-align: center;
}

.profile-close-btn {
    position: absolute;
    top: 10px;
    right: 15px;
    background: transparent;
    border: 1px solid var(--border-color);
    color: var(--text-secondary);
    font-size: 1.4rem;
    cursor: pointer;
    line-height: 1;
    transition: color 0.2s, background 0.2s, border-color 0.2s;
    width: 36px;
    height: 36px;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: 6px;
    padding: 0;
}

.profile-close-btn:hover {
    color: var(--text-primary);
    background: var(--border-color);
    border-color: var(--accent-color);
}

.profile-title {
    font-size: 1.4rem;
    color: var(--text-primary);
    margin: 0 0 20px;
}

.profile-coming-soon {
    color: var(--text-secondary);
}

.profile-coming-soon p:first-child {
    font-size: 1.2rem;
    margin-bottom: 10px;
}

.coming-soon-hint {
    font-size: 0.85rem;
    opacity: 0.7;
}

/* Filter Toggle Button */
.filter-toggle {
    display: flex;
    align-items: center;
    justify-content: space-between;
    width: 100%;
    padding: 8px 12px;
    background: rgba(255, 255, 255, 0.03);
    border: 1px solid var(--border-color);
    border-radius: 6px;
    color: var(--text-secondary);
    font-size: 0.85rem;
    cursor: pointer;
    transition: all 0.2s;
    margin-bottom: 8px;
}

.filter-toggle:hover {
    background: rgba(255, 255, 255, 0.06);
    color: var(--text-primary);
}

.toggle-icon {
    font-size: 0.7rem;
    transition: transform 0.2s;
}

.filter-toggle.collapsed .toggle-icon {
    transform: rotate(-90deg);
}

.room-filters.collapsed {
    display: none;
}

/* Online Game Actions (Resign / Ex Aequo buttons) */
.online-game-actions {
    position: absolute;
    bottom: 20px;
    left: 50%;
    transform: translateX(-50%);
    display: flex;
    gap: 12px;
    z-index: 20;
}

.online-game-actions.hidden {
    display: none;
}

.game-action-btn {
    width: 40px;
    height: 40px;
    border-radius: 6px;
    border: 2px solid var(--border-color);
    background: var(--bg-container);
    color: var(--text-secondary);
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.2s;
    opacity: 0.7;
    flex-shrink: 0;
}

.game-action-btn:hover {
    opacity: 1;
    background: var(--border-color);
}

.game-action-btn:disabled {
    opacity: 0.3;
    cursor: not-allowed;
    transform: none;
}

.resign-btn:hover {
    border-color: #ff6666;
    color: #ff6666;
}

.draw-btn:hover {
    border-color: #66aaff;
    color: #66aaff;
}

/* Draw Proposal Notification */
.draw-proposal-notification {
    position: absolute;
    top: 110px;
    left: 50%;
    transform: translateX(-50%);
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 8px 16px;
    background: rgba(0, 0, 0, 0.8);
    border: 1px solid var(--border-color);
    border-radius: 20px;
    z-index: 25;
    animation: slideDown 0.3s ease;
}

.draw-proposal-notification.hidden {
    display: none;
}

@keyframes slideDown {
    from {
        opacity: 0;
        transform: translateX(-50%) translateY(-10px);
    }
    to {
        opacity: 1;
        transform: translateX(-50%) translateY(0);
    }
}

#drawProposalText {
    font-size: 0.85rem;
    color: var(--text-secondary);
}

.draw-response-btn {
    width: 28px;
    height: 28px;
    border-radius: 4px;
    border: none;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.2s;
    flex-shrink: 0;
}

.accept-btn {
    background: #4CAF50;
    color: white;
}

.accept-btn:hover {
    background: #5CBF60;
}

.decline-btn {
    background: #f44336;
    color: white;
}

.decline-btn:hover {
    background: #ff5246;
}

/* Toast notification for declined draw */
.draw-declined-toast {
    position: absolute;
    top: 110px;
    left: 50%;
    transform: translateX(-50%);
    padding: 8px 16px;
    background: rgba(244, 67, 54, 0.9);
    color: white;
    border-radius: 20px;
    font-size: 0.85rem;
    z-index: 25;
    animation: toastFade 3s ease forwards;
}

@keyframes toastFade {
    0%, 70% {
        opacity: 1;
    }
    100% {
        opacity: 0;
    }
}

/* Light theme adjustments for draw notification */
[data-theme="light"] .draw-proposal-notification {
    background: rgba(255, 255, 255, 0.95);
    border-color: #ccc;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.15);
}

[data-theme="light"] #drawProposalText {
    color: #333;
}

/* =====================================================
   HTML RULES STYLES
   Styles for the new HTML-based rules viewer
   ===================================================== */

/* Main HTML container for rules */
.rules-html-container {
    flex: 1;
    overflow: hidden;
    background: var(--bg-primary);
}

/* Loading state */
.rules-loading {
    display: flex;
    align-items: center;
    justify-content: center;
    height: 100%;
    font-size: 1rem;
    color: var(--text-secondary);
}

.rules-loading span {
    animation: pulse 1.5s ease-in-out infinite;
}

@keyframes pulse {
    0%, 100% { opacity: 0.5; }
    50% { opacity: 1; }
}

/* Error state */
.rules-error {
    display: flex;
    align-items: center;
    justify-content: center;
    height: 100%;
    padding: 20px;
    color: var(--error-color, #ff4444);
    text-align: center;
}

/* Rules content container with sidebar layout */
.rules-content {
    display: flex;
    height: 100%;
    overflow: hidden;
}

/* Sidebar navigation */
.rules-nav {
    width: 200px;
    min-width: 200px;
    background: var(--bg-container);
    border-right: 1px solid var(--border-color);
    overflow-y: auto;
    padding: 20px 0;
}

.rules-nav-list {
    list-style: none;
    margin: 0;
    padding: 0;
}

.rules-nav-link {
    display: block;
    padding: 10px 20px;
    color: var(--text-secondary);
    text-decoration: none;
    font-size: 0.9rem;
    border-left: 3px solid transparent;
    transition: all 0.2s ease;
}

.rules-nav-link:hover {
    color: var(--text-primary);
    background: rgba(255, 255, 255, 0.05);
}

.rules-nav-link.active {
    color: var(--text-primary);
    border-left-color: var(--accent-color);
    background: rgba(255, 255, 255, 0.08);
    font-weight: 600;
}

/* Main content area */
.rules-main {
    flex: 1;
    overflow-y: auto;
    padding: 30px 40px;
    scroll-behavior: smooth;
}

/* Section styling */
.rules-section {
    margin-bottom: 50px;
    padding-bottom: 30px;
    border-bottom: 1px solid var(--border-color);
}

.rules-section:last-child {
    border-bottom: none;
}

.rules-section h2 {
    font-size: 1.6rem;
    color: var(--text-primary);
    margin: 0 0 20px 0;
    padding-bottom: 10px;
    border-bottom: 2px solid var(--accent-color);
}

.rules-section h3 {
    font-size: 1.2rem;
    color: var(--text-primary);
    margin: 25px 0 15px 0;
}

.rules-section p {
    font-size: 1rem;
    line-height: 1.7;
    color: var(--text-secondary);
    margin: 0 0 15px 0;
}

/* Lists */
.rules-list {
    margin: 15px 0;
    padding-left: 25px;
    color: var(--text-secondary);
}

.rules-list li {
    margin-bottom: 10px;
    line-height: 1.6;
}

.rules-list-numbered {
    list-style-type: decimal;
}

/* Highlight boxes (for victory conditions etc) */
.rules-highlight {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 30px;
    margin: 25px 0;
    padding: 25px;
    background: rgba(255, 255, 255, 0.03);
    border-radius: 12px;
    border: 1px solid var(--border-color);
}

.rules-highlight-item {
    text-align: center;
}

.highlight-number {
    display: block;
    font-size: 3rem;
    font-weight: 700;
    color: var(--text-primary);
    line-height: 1;
}

.highlight-label {
    display: block;
    font-size: 0.9rem;
    color: var(--text-secondary);
    margin-top: 8px;
}

.rules-highlight-separator {
    font-size: 1.2rem;
    color: var(--text-secondary);
    font-weight: 600;
}

/* Note boxes */
.rules-note {
    background: rgba(255, 200, 50, 0.1);
    border-left: 4px solid #f0a500;
    padding: 15px 20px;
    margin: 20px 0;
    border-radius: 0 8px 8px 0;
}

.rules-note strong {
    color: #f0a500;
}

.rules-note-strategy {
    background: rgba(100, 200, 100, 0.1);
    border-left-color: #4caf50;
}

.rules-note-strategy strong {
    color: #4caf50;
}

/* Victory conditions */
.rules-victory-conditions {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 40px;
    margin: 30px 0;
    flex-wrap: wrap;
}

.victory-condition {
    text-align: center;
    padding: 20px 30px;
    background: rgba(255, 255, 255, 0.03);
    border-radius: 12px;
    border: 1px solid var(--border-color);
}

.victory-icon {
    font-size: 1.5rem;
    margin-bottom: 10px;
    letter-spacing: 2px;
}

.disc-icon {
    color: var(--text-primary);
}

.ring-icon {
    color: var(--text-secondary);
}

.victory-text {
    font-size: 1rem;
    color: var(--text-secondary);
}

.victory-or {
    font-size: 1.2rem;
    font-weight: 600;
    color: var(--text-secondary);
}

/* Animation placeholder styling */
.rules-animation-placeholder {
    margin: 25px 0;
    padding: 60px 30px;
    background: linear-gradient(135deg, rgba(255,255,255,0.02) 0%, rgba(255,255,255,0.05) 100%);
    border: 2px dashed var(--border-color);
    border-radius: 12px;
    text-align: center;
}

.animation-placeholder-content {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 15px;
    color: var(--text-secondary);
}

.animation-icon {
    font-size: 2.5rem;
    opacity: 0.5;
}

/* Future animation container (when implemented) */
.rules-animation {
    margin: 25px 0;
    border-radius: 12px;
    overflow: hidden;
    border: 1px solid var(--border-color);
}

.rules-animation-canvas {
    width: 100%;
    height: 300px;
    display: block;
    background: var(--bg-body);
}

.animation-controls {
    padding: 10px;
    background: var(--bg-container);
    text-align: center;
}

.animation-replay {
    padding: 8px 16px;
    font-size: 0.85rem;
}

/* Video container styling */
.rules-video-container {
    margin: 25px 0;
    border-radius: 12px;
    overflow: hidden;
    border: 1px solid var(--border-color);
    background: var(--bg-container);
    position: relative;
}

.rules-video {
    width: 100%;
    height: auto;
    display: block;
    aspect-ratio: 4 / 3;
    object-fit: contain;
    background: #000;
}

/* Placeholder shown when video not loaded */
.video-placeholder {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 15px;
    background: linear-gradient(135deg, rgba(255,255,255,0.02) 0%, rgba(255,255,255,0.05) 100%);
    color: var(--text-secondary);
    transition: opacity 0.3s ease;
}

.rules-video-container.video-loaded .video-placeholder {
    opacity: 0;
    pointer-events: none;
}

.video-icon {
    font-size: 2.5rem;
    opacity: 0.5;
}

.video-placeholder span:last-child {
    font-size: 0.9rem;
    opacity: 0.7;
}

/* Video loading state */
.rules-video-container.video-loading .video-placeholder {
    background: linear-gradient(135deg, rgba(255,255,255,0.02) 0%, rgba(255,255,255,0.05) 100%);
}

.rules-video-container.video-loading .video-icon::after {
    content: '';
    display: block;
    width: 40px;
    height: 40px;
    border: 3px solid var(--text-secondary);
    border-top-color: transparent;
    border-radius: 50%;
    animation: video-spinner 1s linear infinite;
    margin: 10px auto 0;
}

@keyframes video-spinner {
    to { transform: rotate(360deg); }
}

/* Responsive rules */
@media (max-width: 768px) {
    .rules-content {
        flex-direction: column;
    }
    
    .rules-nav {
        width: 100%;
        min-width: auto;
        border-right: none;
        border-bottom: 1px solid var(--border-color);
        padding: 10px 0;
        overflow-x: auto;
        overflow-y: visible;
        white-space: nowrap;
    }
    
    .rules-nav-list {
        display: flex;
        padding: 0 10px;
        gap: 5px;
    }
    
    .rules-nav-link {
        padding: 8px 14px;
        border-left: none;
        border-bottom: 3px solid transparent;
        border-radius: 6px 6px 0 0;
        white-space: nowrap;
        font-size: 0.85rem;
    }
    
    .rules-nav-link.active {
        border-left-color: transparent;
        border-bottom-color: var(--accent-color);
    }
    
    .rules-main {
        padding: 20px 15px;
    }
    
    .rules-section h2 {
        font-size: 1.4rem;
    }
    
    .rules-highlight {
        flex-direction: column;
        gap: 20px;
    }
    
    .rules-victory-conditions {
        flex-direction: column;
        gap: 20px;
    }
}

@media (max-width: 480px) {
    .rules-nav-link {
        padding: 6px 12px;
        font-size: 0.8rem;
    }
    
    .rules-main {
        padding: 15px 12px;
    }
    
    .rules-section h2 {
        font-size: 1.2rem;
    }
    
    .rules-section p {
        font-size: 0.95rem;
    }
    
    .highlight-number {
        font-size: 2.5rem;
    }
    
    .rules-animation-placeholder {
        padding: 40px 20px;
    }
    
    .rules-video-container {
        margin: 20px 0;
    }
}

/* Light theme adjustments */
[data-theme="light"] .rules-nav-link:hover {
    background: rgba(0, 0, 0, 0.05);
}

[data-theme="light"] .rules-nav-link.active {
    background: rgba(0, 0, 0, 0.08);
}

[data-theme="light"] .rules-highlight,
[data-theme="light"] .victory-condition {
    background: rgba(0, 0, 0, 0.03);
}

[data-theme="light"] .rules-animation-placeholder {
    background: linear-gradient(135deg, rgba(0,0,0,0.02) 0%, rgba(0,0,0,0.05) 100%);
}

[data-theme="light"] .video-placeholder {
    background: linear-gradient(135deg, rgba(0,0,0,0.02) 0%, rgba(0,0,0,0.05) 100%);
}