body {
    margin: 0;
    font-family: 'Segoe UI', Roboto, Helvetica, Arial, sans-serif;
    background: linear-gradient(135deg, #fff1eb 0%, #ace0f9 100%);
    color: #2d3436;
    min-height: 100vh;
}

#board-section {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    padding: 0 20px 20px 20px;    background-color: transparent;
}

h2 {
    margin-bottom: 10px;
    color: #2d3436;
    font-weight: 700;
}

canvas {
    background-color: #ffffff;
    border: 8px solid #ffffff;
    border-radius: 12px;
    cursor: crosshair;
    box-shadow: 0 15px 35px rgba(0,0,0,0.15);
    touch-action: none;
}

.toolbar {
    margin-bottom: 10px;
    display: flex;
    gap: 5px;
    align-items: center;
    flex-wrap: nowrap;
    overflow-x: auto;
    position: sticky;
    top: 60px;
    z-index: 1000;
    background: rgba(255, 255, 255, 0.9);
    backdrop-filter: blur(10px);
    padding: 8px 12px;
    border-radius: 12px;
    box-shadow: 0 8px 20px rgba(0,0,0,0.1);
    width: 100%;
    max-width: 800px;
    box-sizing: border-box;
    border: 1px solid rgba(255,255,255,0.5);
}

.toolbar button, .toolbar input {
    cursor: pointer;
}

.toolbar button, .tool-container button {
    padding: 5px 10px;
    border: 1px solid #dfe6e9;
    background-color: #ffffff;
    color: #636e72;
    border-radius: 6px;
    font-size: 13px;
    font-weight: 600;
    transition: all 0.2s ease;
    box-shadow: 0 2px 5px rgba(0,0,0,0.05);
}

.toolbar input[type="color"] {
    width: 40px;
    height: 40px;
    padding: 2px;
    border: 2px solid #fff;
    border-radius: 50%;
    box-shadow: 0 2px 5px rgba(0,0,0,0.1);
    vertical-align: middle;
    cursor: pointer;
}

.toolbar button:hover, .tool-container button:hover {
    background-color: #ff9f43;
    color: white;
    border-color: #ff9f43;
    transform: translateY(-2px);
    box-shadow: 0 5px 15px rgba(255, 159, 67, 0.4);
}

.toolbar button.active {
    background-color: #ee5253;
    border-color: #ee5253;
    color: white;
    transform: none;
    box-shadow: inset 0 2px 4px rgba(0,0,0,0.1);
}

.separator {
    width: 1px;
    height: 30px;
    background-color: #b2bec3;
    margin: 0 5px;
    flex-shrink: 0;
}

/* Tic Tac Toe Styles */
#tictactoe-section {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    padding: 20px;
    background-color: #e8e8e8;
    font-family: sans-serif;
    margin-top: 20px;
}

.tic-tac-toe-board {
    display: grid;
    grid-template-columns: repeat(3, 100px);
    grid-template-rows: repeat(3, 100px);
    gap: 5px;
    margin: 20px 0;
}

@media (max-width: 600px) {
    .tic-tac-toe-board {
        grid-template-columns: repeat(3, 80px);
        grid-template-rows: repeat(3, 80px);
    }
    .cell {
        font-size: 2rem;
    }
}

.cell {
    background-color: #fff;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 3rem;
    font-weight: bold;
    cursor: pointer;
    border: 2px solid #333;
    border-radius: 4px;
    user-select: none;
}

.cell:hover {
    background-color: #f9f9f9;
}

#gameStatus {
    font-size: 1.2rem;
    margin-bottom: 10px;
    font-weight: bold;
}

/* Text Editor Styles */
#editor-section {
    display: flex;
    flex-direction: column;
    align-items: center;    padding: 0 20px 50px 20px;
}

.page {
    background: white;
    width: 210mm;
    min-height: 297mm;
    padding: 25.4mm;
    box-sizing: border-box;
    box-shadow: 0 0 15px rgba(0,0,0,0.1);
    outline: none;
    font-size: 11pt;
    font-family: 'Calibri', 'Arial', sans-serif;
    line-height: 1.15;
    color: #000;
    margin: 30px auto;
    position: relative;
}

@media (max-width: 820px) {
    .page {
        width: 95%;
        padding: 20px;
        min-height: 100vh;
    }
}

#documentPage img {
    transition: all 0.2s;
}
#documentPage img.selected {
    outline: 3px solid #0056b3;
    box-shadow: 0 0 8px rgba(0,0,0,0.3);
}

.text-box {
    border: 1px dashed #999;
    min-width: 100px;
    min-height: 50px;
    background: rgba(255, 255, 255, 0.9);
    resize: both;
    overflow: hidden;
    position: absolute;
}

.text-box-content {
    width: 100%;
    height: 100%;
    padding: 10px;
    box-sizing: border-box;
    outline: none;
    overflow-y: auto;
}

.text-box-delete {
    position: absolute;
    top: 0;
    right: 0;
    width: 20px;
    height: 20px;
    background: #ff4444;
    color: white;
    text-align: center;
    line-height: 20px;
    cursor: pointer;
    font-weight: bold;
    display: none;
    z-index: 5;
    user-select: none;
}

.text-box:hover .text-box-delete {
    display: block;
}

.page.over-limit {
    border-bottom: 4px solid red;
}

.page.over-limit::after {
    content: "⚠️ End of Page Reached (Ideal A4 Size). Consider adding a new page.";
    display: block;
    color: red;
    font-weight: bold;
    font-size: 0.9rem;
    text-align: center;
    margin-top: 10px;
    padding: 5px;
}

/* Table Styles for Editor */
.page table {
    width: 100%;
    border-collapse: collapse;
    margin: 10px 0;
}
.page td, .page th {
    border: 1px solid #ccc;
    padding: 8px;
    min-width: 20px;
}

/* PDF Tools Styles */
#pdf-tools-section {
    display: flex;
    flex-direction: column;
    align-items: center;
    padding: 0 20px 20px 20px;
    background-color: transparent;    min-height: 80vh;
}

.tools-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(160px, 1fr));
    gap: 15px;
    width: 100%;
    max-width: 1400px;
}

.tools-category-header {
    width: 100%;
    max-width: 1400px;
    margin: 30px 0 15px 0;
    padding-bottom: 10px;
    border-bottom: 2px solid #dfe6e9;
    color: #6c5ce7;
    font-size: 1.2rem;
    font-weight: 700;
}

.tool-container {
    background: white;
    width: 100%;
    max-width: 800px;
    padding: 20px;
    box-sizing: border-box;
    margin-bottom: 20px;
    border-radius: 20px;
    box-shadow: 0 10px 30px rgba(0,0,0,0.05);
    border: 1px solid rgba(255, 255, 255, 0.8);
    transition: transform 0.3s ease;
    position: relative;
    overflow: hidden;
}

.tools-grid .tool-container {
    margin-bottom: 0;
    max-width: 100%;
}
.tool-container:hover {
    transform: translateY(-7px);
    box-shadow: 0 20px 40px rgba(0, 0, 0, 0.1);
    border-color: rgba(255, 255, 255, 1);
}

/* PDF Category Navigation */
.pdf-category-nav {
    display: flex;
    gap: 10px;
    margin-bottom: 20px;
    overflow-x: auto;
    padding: 5px 2px;
    width: 100%;
    max-width: 800px;
    scrollbar-width: none; /* Firefox */
}
.pdf-category-nav::-webkit-scrollbar {
    display: none; /* Chrome/Safari */
}
@media (min-width: 600px) {
    .pdf-category-nav {
        justify-content: center;
        flex-wrap: wrap;
    }
}
.cat-nav-btn {
    background: white;
    border: 1px solid #dfe6e9;
    border-radius: 50px;
    padding: 8px 16px;
    font-size: 0.9rem;
    cursor: pointer;
    white-space: nowrap;
    display: flex;
    align-items: center;
    gap: 6px;
    transition: all 0.2s;
    color: #636e72;
    box-shadow: 0 2px 5px rgba(0,0,0,0.05);
    font-weight: 600;
}
.cat-nav-btn:hover {
    background: #6c5ce7;
    border-color: #6c5ce7;
    color: white;
    transform: translateY(-2px);
    box-shadow: 0 5px 10px rgba(108, 92, 231, 0.2);
}
.cat-icon {
    font-size: 1.1rem;
}

/* PDF Sidebar Navigation */
.pdf-sidebar {
    position: fixed;
    left: 30px;
    top: 50%;
    transform: translateY(-50%);
    display: flex;
    flex-direction: column;
    gap: 15px;
    z-index: 900;
    background: rgba(255, 255, 255, 0.9);
    backdrop-filter: blur(10px);
    padding: 20px 10px;
    border-radius: 30px;
    box-shadow: 0 10px 30px rgba(0,0,0,0.1);
    border: 1px solid rgba(255,255,255,0.5);
}

.sidebar-btn {
    width: 45px;
    height: 45px;
    border-radius: 50%;
    border: 1px solid #dfe6e9;
    background: white;
    cursor: pointer;
    font-size: 1.2rem;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.2s cubic-bezier(0.175, 0.885, 0.32, 1.275);
    position: relative;
    color: #2d3436;
    box-shadow: 0 2px 5px rgba(0,0,0,0.05);
    margin-top: 0 !important;
}

.sidebar-btn:hover {
    background: #6c5ce7;
    color: white;
    border-color: #6c5ce7;
    transform: scale(1.15);
    box-shadow: 0 5px 15px rgba(108, 92, 231, 0.3);
}

.sidebar-btn::after {
    content: attr(title);
    position: absolute;
    left: 60px;
    background: #2d3436;
    color: white;
    padding: 6px 12px;
    border-radius: 6px;
    font-size: 0.85rem;
    white-space: nowrap;
    opacity: 0;
    pointer-events: none;
    transition: all 0.2s;
    font-weight: 600;
    transform: translateX(-10px);
    box-shadow: 0 4px 10px rgba(0,0,0,0.1);
}

.sidebar-btn:hover::after {
    opacity: 1;
    transform: translateX(0);
}

@media (max-width: 1300px) {
    .pdf-sidebar {
        display: none;
    }
}

/* Tool Card Mode (Grid View) */
.tools-grid .tool-container:not(.active-tool) {
    cursor: pointer;
    display: flex;
    flex-direction: column;
    justify-content: center;
    align-items: center;
    text-align: center;
    min-height: 120px;
    padding: 15px;
}

/* Hide everything except Title, Description, and Favorite Button in Grid View */
.tools-grid .tool-container:not(.active-tool) > *:not(h3):not(p):not(.favorite-btn) {
    display: none !important;
}

.tools-grid .tool-container:not(.active-tool) h3 {
    font-size: 1rem;
    margin: 5px 0;
}

.tools-grid .tool-container:not(.active-tool) p {
    font-size: 0.8rem;
}

.tools-grid .tool-container:not(.active-tool):hover {
    border: 1px solid rgba(0,0,0,0.1); /* Reset border */
}

/* Colorful accents for tools */
.tool-container::before {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 6px;
    background: linear-gradient(90deg, #a18cd1 0%, #fbc2eb 100%);
    opacity: 0.9;
}

/* Active Tool Mode (Full View) */
.tool-container.active-tool {
    cursor: default;
    transform: none !important;
    box-shadow: none;
    border: 1px solid #dfe6e9;
    padding: 30px;
    max-width: 100%;
    min-height: auto;
}

.tool-container.active-tool .favorite-btn {
    display: none !important;
}

.favorite-btn {
    position: absolute;
    top: 15px;
    right: 15px;
    background: none !important;
    border: none !important;
    font-size: 1.5rem !important;
    cursor: pointer;
    color: #dfe6e9 !important;
    transition: all 0.2s ease;
    padding: 0 !important;
    line-height: 1 !important;
    box-shadow: none !important;
    z-index: 10;
}

.favorite-btn:hover {
    transform: scale(1.2) !important;
    color: #ffeaa7 !important;
}

.favorite-btn.active {
    color: #f1c40f !important;
    text-shadow: 0 2px 5px rgba(0,0,0,0.1);
}

.info-text {
    color: #666;
    font-size: 0.9rem;
    margin-bottom: 10px;
}

/* Enhanced Button Styles for PDF Tools */
.tool-container button {
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    color: white;
    border: none;
    padding: 12px 25px;
    font-size: 1rem;
    border-radius: 50px;
    font-weight: 600;
    box-shadow: 0 4px 15px rgba(118, 75, 162, 0.3);
    transition: transform 0.2s, box-shadow 0.2s;
    margin-top: 15px;
}

.tool-container button:hover {
    transform: translateY(-2px);
    box-shadow: 0 8px 20px rgba(118, 75, 162, 0.4);
    background: linear-gradient(135deg, #764ba2 0%, #667eea 100%);
    color: white;
}

/* Enhanced Input Styles for PDF Tools */
.tool-container input[type="text"],
.tool-container input[type="password"],
.tool-container input[type="number"],
.tool-container select {
    background: #fdfdfd;
    border: 2px solid #e0e0e0;
    border-radius: 10px;
    padding: 12px;
    font-size: 1rem;
    transition: border-color 0.3s;
}

.tool-container input:focus,
.tool-container select:focus {
    border-color: #764ba2;
    outline: none;
    background: #fff;
}

.tool-container input[type="file"] {
    padding: 15px;
    background: #f8f9fa;
    border: 2px dashed #cbd5e0;
    border-radius: 12px;
    text-align: center;
    cursor: pointer;
    transition: all 0.3s;
}

.tool-container input[type="file"]:hover {
    border-color: #764ba2;
    background: #f0f4f8;
}

/* Varied colors for grid items */
.tools-grid .tool-container:nth-child(4n+1)::before { background: linear-gradient(90deg, #a18cd1 0%, #fbc2eb 100%); }
.tools-grid .tool-container:nth-child(4n+2)::before { background: linear-gradient(90deg, #84fab0 0%, #8fd3f4 100%); }
.tools-grid .tool-container:nth-child(4n+3)::before { background: linear-gradient(120deg, #f6d365 0%, #fda085 100%); }
.tools-grid .tool-container:nth-child(4n+4)::before { background: linear-gradient(120deg, #d4fc79 0%, #96e6a1 100%); }

/* Data Analytics Enhanced Styles */
.analytics-controls {
    gap: 20px;
    flex-wrap: wrap;
    display: none;
    margin-bottom: 25px;
    background: linear-gradient(to bottom right, #f8f9fa, #ffffff);
    padding: 15px;
    border-radius: 16px;
    border: 1px solid #e0e0e0;
    box-shadow: inset 0 2px 6px rgba(0,0,0,0.03);
}

.analytics-controls.visible {
    display: block;
}

.analytics-group {
    flex: 1;
    min-width: 200px;
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.analytics-group label {
    font-weight: 600;
    color: #2d3436;
    font-size: 0.9rem;
    margin-left: 4px;
}

.analytics-actions {
    width: 100%;
    display: flex;
    gap: 15px;
    margin-top: 10px;
}

.analytics-actions button {
    flex: 1;
    margin-top: 0 !important; /* Override tool-container button margin */
}

.preview-area img {
    max-width: 100%;
    margin-bottom: 10px;
    display: block;
    box-shadow: 0 0 5px rgba(0,0,0,0.2);
}

@media print {
    body * {
        visibility: hidden;
    }
    #editor-section, #editor-section *, #pdf-tools-section, #pdf-tools-section * {
        visibility: visible;
    }
    #editor-section, #pdf-tools-section {
        position: absolute;
        left: 0;
        top: 0;
        background: none;
        padding: 0;
    }
    .page {
        box-shadow: none;
        margin: 0;
        width: 100%;
    }
    .toolbar, .nav-bar, .no-print {
        display: none !important;
    }
}

/* Navigation Tabs */
.nav-bar {
    display: flex;
    justify-content: flex-start; /* Align start to prevent clipping */
    align-items: center;
    background: linear-gradient(135deg, #ff9f43, #ff6b6b);
    padding: 0;
    position: sticky;
    top: 0;
    z-index: 1100;
    height: 60px;
    box-sizing: border-box;
    box-shadow: 0 4px 20px rgba(255, 107, 107, 0.3);
    overflow-x: auto; /* Allow horizontal scroll */
    white-space: nowrap;
    backdrop-filter: blur(10px);
}

.nav-btn {
    background: none;
    border: none;
    color: rgba(255,255,255,0.9);
    padding: 8px 16px;
    margin: 0 4px;
    height: auto;
    min-height: 40px;
    border-radius: 8px;
    font-size: 0.95rem;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    cursor: pointer;
    font-weight: 700;
    transition: all 0.2s ease;
    border-bottom: none;
    display: flex;
    align-items: center;
    gap: 8px;
}

.nav-btn:hover {
    color: #fff;
    background-color: rgba(255,255,255,0.2);
    transform: translateY(-1px);
}

.nav-btn.active {
    background-color: #ffffff;
    color: #ee5253;
    box-shadow: 0 4px 12px rgba(0,0,0,0.15);
    transform: translateY(-1px);
}

/* Mobile Joystick Controls */
#mobileControls {
    position: fixed;
    bottom: 20px;
    left: 20px;
    right: 20px;
    height: 150px;
    display: flex;
    justify-content: space-between;
    align-items: flex-end;
    pointer-events: none;
    z-index: 2000;
}

#joystickZone {
    width: 120px;
    height: 120px;
    background: rgba(0, 0, 0, 0.1);
    border: 2px solid #888;
    border-radius: 50%;
    position: relative;
    display: flex;
    justify-content: center;
    align-items: center;
    pointer-events: auto;
    touch-action: none;
}

#joystickKnob {
    width: 50px;
    height: 50px;
    background: #333;
    border-radius: 50%;
    box-shadow: 0 2px 5px rgba(0,0,0,0.3);
}

#mobileDrawBtn {
    width: 80px;
    height: 80px;
    border-radius: 50%;
    background: #ff4444;
    color: white;
    font-weight: bold;
    border: 4px solid white;
    pointer-events: auto;
    box-shadow: 0 4px 8px rgba(0,0,0,0.3);
    touch-action: none;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1.2rem;
}

#mobileDrawBtn:active {
    background: #cc0000;
    transform: scale(0.95);
}

#virtualCursor {
    width: 10px;
    height: 10px;
    border: 2px solid red;
    background-color: rgba(255, 0, 0, 0.3);
    border-radius: 50%;
    position: fixed;
    pointer-events: none;
    z-index: 1500;
    transform: translate(-50%, -50%);
    display: none;
}

#mobileButtonCluster {
    display: flex;
    gap: 15px;
    align-items: center;
    pointer-events: auto;
}

#mobileSelectBtn {
    width: 80px;
    height: 80px;
    border-radius: 50%;
    background: #007bff;
    color: white;
    font-weight: bold;
    border: 4px solid white;
    box-shadow: 0 4px 8px rgba(0,0,0,0.3);
    touch-action: none;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1.2rem;
}

#mobileSelectBtn.selecting {
    background: #0056b3;
    transform: scale(0.95);
}

#mobileSelectBtn:active {
    background: #0056b3;
    transform: scale(0.95);
}

/* D-Pad Styles */
#dpadControls {
    width: 140px;
    height: 140px;
    position: relative;
    pointer-events: auto;
}
.dpad-btn {
    width: 45px;
    height: 45px;
    background: rgba(50, 50, 50, 0.8);
    border: 2px solid #fff;
    color: white;
    position: absolute;
    display: flex;
    justify-content: center;
    align-items: center;
    font-size: 1.5rem;
    border-radius: 8px;
    touch-action: none;
    cursor: pointer;
}
.dpad-btn:active {
    background: rgba(0, 0, 0, 0.9);
    transform: scale(0.95);
}
#dpadUp { top: 0; left: 47.5px; }
#dpadDown { bottom: 0; left: 47.5px; }
#dpadLeft { top: 47.5px; left: 0; }
#dpadRight { top: 47.5px; right: 0; }

/* Touchpad Styles */
#touchpadZone {
    width: 160px;
    height: 120px;
    background: rgba(40, 40, 40, 0.95);
    border: 2px solid #aaa;
    border-radius: 6px;
    position: relative;
    pointer-events: auto;
    touch-action: none;
    display: flex;
    justify-content: center;
    align-items: center;
    color: #ddd;
    font-size: 0.9rem;
    box-shadow: 0 2px 5px rgba(0,0,0,0.3);
}

/* Floating Pan Button */
.pan-btn {
    position: fixed;
    top: 140px;
    width: 50px;
    height: 50px;
    border-radius: 50%;
    background: white;
    border: none;
    font-size: 1.5rem;
    z-index: 1005;
    box-shadow: 0 4px 15px rgba(0,0,0,0.2);
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    transition: all 0.3s cubic-bezier(0.175, 0.885, 0.32, 1.275);
    color: #2d3436;
}
.pan-btn.active {
    background-color: #ff9f43;
    color: white;
}
.pan-btn:hover {
    transform: scale(1.15);
    color: #ff9f43;
}
#panBtnLeft { left: 20px; }
#panBtnRight { right: 20px; }
#panBtnCenter { left: 50%; transform: translateX(-50%); }
#panBtnCenter:hover { transform: translateX(-50%) scale(1.15); }

/* YouTube Button Styles */
.youtube-btn {
    display: flex;
    align-items: center;
    gap: 8px;
    text-decoration: none;
    color: white;
    background: rgba(255, 255, 255, 0.2);
    padding: 8px 16px;
    border-radius: 20px;
    margin: 0 15px;
    font-weight: bold;
    font-size: 0.9rem;
    transition: all 0.3s ease;
    border: 1px solid rgba(255,255,255,0.4);
}
.youtube-btn:hover {
    background: #FF0000;
    border-color: #FF0000;
    transform: scale(1.05);
    box-shadow: 0 4px 15px rgba(0,0,0,0.3);
}

/* Footer Styles */
footer {
    text-align: center;
    padding: 40px 20px;
    color: #636e72;
    font-size: 0.9rem;
    background: rgba(255,255,255,0.3);
    margin-top: auto;
}
.footer-links {
    margin-top: 10px;
    display: flex;
    justify-content: center;
    gap: 20px;
}
.footer-links a {
    color: #2d3436;
    text-decoration: none;
    font-weight: 600;
    transition: color 0.2s;
}
.footer-links a:hover {
    color: #ee5253;
}

/* Floating Image Placement Styles */
.img-placement-wrapper {
    position: absolute;
    border: 2px dashed #0984e3;
    z-index: 100;
    cursor: move;
    touch-action: none;
}
.img-placement-wrapper img {
    width: 100%;
    height: 100%;
    display: block;
    pointer-events: none;
}
.img-placement-controls {
    position: absolute;
    top: -45px;
    left: 50%;
    transform: translateX(-50%);
    background: white;
    padding: 5px;
    border-radius: 20px;
    box-shadow: 0 2px 10px rgba(0,0,0,0.2);
    display: flex;
    gap: 10px;
}
.img-placement-btn {
    width: 30px;
    height: 30px;
    border-radius: 50%;
    border: none;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    font-weight: bold;
    color: white;
    font-size: 16px;
}
.btn-confirm { background: #00b894; }
.btn-cancel { background: #d63031; }

.resize-handle {
    position: absolute;
    bottom: -10px;
    right: -10px;
    width: 20px;
    height: 20px;
    background: #0984e3;
    border-radius: 50%;
    cursor: nwse-resize;
    border: 2px solid white;
    box-shadow: 0 2px 5px rgba(0,0,0,0.2);
    touch-action: none;
}

.logo {
    display: flex;
    align-items: center;
    gap: 8px;
    font-size: 1.5rem;
    font-weight: 800;
    color: #ff6b00;
    background: #ffffff;
    margin-right: 15px;
    margin-left: 15px;
    padding: 5px 15px;
    border-radius: 8px;
    text-transform: uppercase;
    letter-spacing: 1px;
    box-shadow: 0 4px 8px rgba(0,0,0,0.2);
    cursor: pointer;
    user-select: none;
    text-decoration: none;
}

/* Modal Styles for User Guide */
.modal-overlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.5);
    z-index: 2000;
    display: flex;
    justify-content: center;
    align-items: center;
    backdrop-filter: blur(3px);
}

.modal-content {
    background: white;
    width: 90%;
    max-width: 800px;
    max-height: 85vh;
    border-radius: 16px;
    box-shadow: 0 15px 40px rgba(0,0,0,0.25);
    display: flex;
    flex-direction: column;
    overflow: hidden;
    animation: fadeIn 0.3s ease;
}

.modal-header {
    padding: 20px 25px;
    border-bottom: 1px solid #eee;
    display: flex;
    justify-content: space-between;
    align-items: center;
    background: #f8f9fa;
}

.modal-header h2 {
    margin: 0;
    font-size: 1.4rem;
    color: #2d3436;
}

.close-btn {
    background: none;
    border: none;
    font-size: 2rem;
    cursor: pointer;
    color: #636e72;
    line-height: 1;
    padding: 0 10px;
}

.close-btn:hover {
    color: #d63031;
}

.modal-body {
    padding: 25px;
    overflow-y: auto;
}

.guide-category {
    margin-bottom: 25px;
}

.guide-category h3 {
    font-size: 1.1rem;
    color: #6c5ce7;
    border-bottom: 2px solid #f1f2f6;
    padding-bottom: 8px;
    margin-bottom: 15px;
}

.guide-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(220px, 1fr));
    gap: 12px;
}

.guide-item {
    display: flex;
    align-items: center;
    gap: 12px;
    font-size: 0.95rem;
    color: #2d3436;
    background: #fff;
    padding: 10px;
    border-radius: 8px;
    border: 1px solid #eee;
    box-shadow: 0 2px 5px rgba(0,0,0,0.03);
}

.guide-item span {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    min-width: 35px;
    height: 35px;
    background: #f1f2f6;
    border-radius: 6px;
    font-weight: bold;
    font-size: 0.9rem;
    color: #2d3436;
    padding: 0 5px;
}

@keyframes fadeIn {
    from { opacity: 0; transform: translateY(10px); }
    to { opacity: 1; transform: translateY(0); }
}

/* Dark Mode Styles */
body.dark-mode {
    background: linear-gradient(135deg, #1e272e 0%, #353b48 100%);
    color: #dcdde1;
}
body.dark-mode .nav-bar {
    background: linear-gradient(90deg, #2f3640, #353b48);
}
body.dark-mode .tool-container,
body.dark-mode .modal-content,
body.dark-mode .contact-card,
body.dark-mode .blog-post {
    background-color: #2f3640;
    border-color: #4b6584;
    color: #f5f6fa;
}
body.dark-mode h1, body.dark-mode h2, body.dark-mode h3, body.dark-mode h4, body.dark-mode strong {
    color: #f5f6fa;
}
body.dark-mode .info-text, body.dark-mode p {
    color: #dcdde1;
}
body.dark-mode input[type="text"],
body.dark-mode input[type="number"],
body.dark-mode input[type="password"],
body.dark-mode input[type="email"],
body.dark-mode textarea,
body.dark-mode select {
    background-color: #353b48;
    color: #f5f6fa;
    border-color: #718093;
}
body.dark-mode .toolbar {
    background: rgba(47, 54, 64, 0.95);
    border-color: rgba(255,255,255,0.1);
}
body.dark-mode .toolbar button {
    background-color: #353b48;
    color: #dcdde1;
    border-color: #718093;
}
body.dark-mode .toolbar button:hover {
    background-color: #e1b12c;
    color: #2f3640;
}
body.dark-mode .logo {
    background: #2f3640;
    color: #fbc531;
}
body.dark-mode .tic-tac-toe-board .cell {
    background-color: #353b48;
    border-color: #718093;
    color: #f5f6fa;
}
body.dark-mode .tic-tac-toe-board .cell:hover {
    background-color: #2f3640;
}

/* Mobile Responsive Fixes */
@media (max-width: 768px) {
    .nav-bar {
        padding: 0 5px;
    }
    
    .logo span, .youtube-btn span {
        display: none; /* Compact logo and buttons */
    }
    
    .youtube-btn {
        padding: 8px;
        margin: 0 5px;
    }
    
    .nav-links-container {
        margin: 0 5px !important;
    }

    #pdf-tools-section, 
    #editor-section, 
    #board-section,
    #analytics-section,
    #math-section,
    #seo-section {
        padding: 10px 5px !important;
    }

    .toolbar {
        width: 100%;
        border-radius: 0;
        left: 0;
        right: 0;
        max-width: none;
        border-left: none;
        border-right: none;
        justify-content: flex-start;
    }

    .page {
        width: 100%;
        padding: 15px;
    }

    .analytics-actions {
        flex-direction: column;
    }
    
    .analytics-actions > * {
        width: 100% !important;
        flex: none !important;
        margin-bottom: 8px;
    }
}

/* Analytics Section Styles */
.analytics-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(400px, 1fr));
    gap: 30px;
    max-width: 1200px;
    margin: 0 auto;
}

.analytics-card {
    background: white;
    border-radius: 20px;
    padding: 30px;
    box-shadow: 0 10px 30px rgba(0,0,0,0.05);
    border: 1px solid rgba(0,0,0,0.05);
    transition: transform 0.3s ease;
}

.analytics-card:hover {
    transform: translateY(-5px);
    box-shadow: 0 15px 35px rgba(0,0,0,0.1);
}

.card-header {
    display: flex;
    align-items: center;
    gap: 15px;
    margin-bottom: 25px;
}

.icon-bg {
    width: 50px;
    height: 50px;
    border-radius: 12px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1.5rem;
}

.card-header h3 {
    margin: 0;
    font-size: 1.4rem;
    color: #2d3436;
}

.card-header p {
    margin: 5px 0 0 0;
    color: #636e72;
    font-size: 0.9rem;
}

.upload-area {
    border: 2px dashed #dfe6e9;
    border-radius: 12px;
    padding: 30px;
    text-align: center;
    cursor: pointer;
    transition: all 0.3s;
    background: #f8f9fa;
    margin-bottom: 25px;
}

.upload-area:hover {
    border-color: #6c5ce7;
    background: #f1f2f6;
}

.control-row {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(140px, 1fr));
    gap: 10px;
    margin-bottom: 15px;
}

.control-group {
    flex: 1;
    min-width: 120px;
}

.control-group label {
    display: block;
    font-size: 0.85rem;
    font-weight: 600;
    color: #636e72;
    margin-bottom: 5px;
}

.styled-select, .styled-input {
    width: 100%;
    padding: 10px;
    border: 1px solid #dfe6e9;
    border-radius: 8px;
    font-size: 0.95rem;
    background: white;
    box-sizing: border-box;
}

.action-row {
    display: flex;
    gap: 10px;
    margin-bottom: 10px;
}

.primary-btn {
    background: #6c5ce7;
    color: white;
    border: none;
    padding: 10px 20px;
    border-radius: 8px;
    cursor: pointer;
    font-weight: 600;
    flex: 1;
}

.secondary-btn {
    background: #00b894;
    color: white;
    border: none;
    padding: 10px 20px;
    border-radius: 8px;
    cursor: pointer;
    font-weight: 600;
    flex: 1;
}

.danger-btn {
    background: #ff7675;
    color: white;
    border: none;
    padding: 10px 20px;
    border-radius: 8px;
    cursor: pointer;
    font-weight: 600;
}

.stats-box {
    background: #f1f2f6;
    padding: 15px;
    border-radius: 8px;
    font-size: 0.9rem;
    color: #2d3436;
    margin-bottom: 20px;
}

.chart-wrapper {
    position: relative;
    height: 450px;
    width: 100%;
    background: #fff;
    border-radius: 12px;
    padding: 10px;
    box-shadow: 0 5px 15px rgba(0,0,0,0.05);
    overflow-x: auto;
    overflow-y: hidden;
}

.cleaner-actions-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(140px, 1fr));
    gap: 10px;
    margin-bottom: 20px;
}

.action-tile {
    background: white;
    border: 1px solid #dfe6e9;
    padding: 15px;
    border-radius: 10px;
    cursor: pointer;
    text-align: center;
    transition: all 0.2s;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 5px;
    font-weight: 600;
    color: #2d3436;
}

.action-tile:hover {
    border-color: #6c5ce7;
    background: #f8f9fa;
    transform: translateY(-2px);
}

.advanced-cleaner h4 {
    font-size: 1rem;
    margin-bottom: 10px;
    color: #2d3436;
}

.filter-row {
    display: flex;
    gap: 10px;
    margin-bottom: 10px;
}

.small-btn {
    background: #2d3436;
    color: white;
    border: none;
    padding: 0 15px;
    border-radius: 8px;
    cursor: pointer;
    font-weight: 600;
}

.full-width {
    width: 100%;
}

@media (max-width: 768px) {
    .analytics-grid {
        grid-template-columns: 1fr;
    }
    .analytics-controls.visible {
        display: grid;
        grid-template-columns: 1fr 1fr;
        gap: 8px;
        padding: 10px;
    }
    .analytics-controls .control-row,
    .analytics-controls .action-row:not(#zoomControls) {
        display: contents;
    }
    #zoomControls, #analyticsStats {
        grid-column: 1 / -1;
    }
    .analytics-controls button {
        width: 100%;
        margin: 0;
        height: 38px;
    }
    .filter-row {
        flex-direction: column;
    }
}

/* Color Palette Studio Styles */
.palette-toolbar {
    display: flex;
    justify-content: space-between;
    align-items: center;
    max-width: 1000px;
    margin: 0 auto 20px auto;
    padding: 0 10px;
}

.palette-btn {
    padding: 10px 20px;
    border: none;
    border-radius: 8px;
    font-weight: 600;
    cursor: pointer;
    transition: transform 0.2s, box-shadow 0.2s;
    font-size: 1rem;
}

.palette-btn.primary {
    background: #6c5ce7;
    color: white;
}

.palette-btn.secondary {
    background: #00b894;
    color: white;
}

.palette-btn:hover {
    transform: translateY(-2px);
    box-shadow: 0 5px 15px rgba(0,0,0,0.1);
}

.palette-workspace {
    display: flex;
    height: 500px;
    width: 100%;
    max-width: 1000px;
    margin: 0 auto;
    border-radius: 20px;
    overflow: hidden;
    box-shadow: 0 20px 40px rgba(0,0,0,0.15);
}

.color-column {
    flex: 1;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: flex-end;
    padding-bottom: 30px;
    transition: flex 0.3s ease;
    position: relative;
}

.color-column:hover {
    flex: 1.2;
}

.color-info {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 10px;
}

.color-hex {
    font-family: 'Courier New', monospace;
    font-size: 1.5rem;
    font-weight: 800;
    cursor: pointer;
    text-transform: uppercase;
    background: rgba(255,255,255,0.4);
    padding: 5px 10px;
    border-radius: 8px;
    backdrop-filter: blur(5px);
    transition: transform 0.2s;
}

.color-hex:hover {
    transform: scale(1.1);
    background: rgba(255,255,255,0.8);
}

.lock-btn {
    background: none;
    border: none;
    font-size: 1.5rem;
    cursor: pointer;
    opacity: 0.5;
    transition: all 0.2s;
}

.lock-btn:hover {
    opacity: 1;
    transform: scale(1.2);
}

.lock-btn.locked {
    opacity: 1;
}

@media (max-width: 768px) {
    .palette-workspace {
        flex-direction: column;
        height: auto;
    }
    .color-column {
        height: 100px;
        flex-direction: row;
        justify-content: space-between;
        padding: 0 20px;
        align-items: center;
    }
    .color-column:hover {
        flex: 1;
    }
    .palette-toolbar {
        flex-direction: column;
        gap: 15px;
    }
}

/* Fullscreen Chart Mode */
body.chart-fullscreen {
    overflow: hidden;
}

.analytics-card.fullscreen {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    z-index: 5000;
    border-radius: 0;
    display: flex;
    flex-direction: column;
    padding: 20px;
    background: #f8f9fa;
}

.analytics-card.fullscreen .card-header,
.analytics-card.fullscreen .upload-area {
    display: none;
}

.analytics-card.fullscreen .chart-wrapper {
    flex: 1;
    height: auto;
    min-height: 0;
}

.analytics-card.fullscreen .analytics-controls {
    max-height: 150px;
    overflow-y: auto;
    margin-bottom: 10px;
    padding: 10px;
}

/* AdSense Placeholder Styles */
.ad-slot {
    width: 100%;
    max-width: 728px;
    min-height: 90px;
    background: rgba(0,0,0,0.02); /* Subtle placeholder bg */
}
.analytics-card.fullscreen .chart-wrapper {
    flex: 1;
    height: auto;
    min-height: 0;
}

.analytics-card.fullscreen .analytics-controls {
    max-height: 150px;
    overflow-y: auto;
    margin-bottom: 10px;
    padding: 10px;
}

/* AdSense Placeholder Styles */
.ad-slot {
    width: 100%;
    max-width: 728px;
    min-height: 90px;
    background: rgba(0,0,0,0.02); /* Subtle placeholder bg */

}
