* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

html {
    height: 100%;
    background: linear-gradient(135deg, #0f0f23 0%, #1a1a2e 100%);
    overflow-x: hidden;
}

body {
    font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;
    background: linear-gradient(135deg, #0f0f23 0%, #1a1a2e 100%);
    min-height: 100vh;
    min-height: 100dvh;
    padding: 20px;
    padding-left: max(20px, env(safe-area-inset-left));
    padding-right: max(20px, env(safe-area-inset-right));
    padding-top: max(20px, env(safe-area-inset-top));
    padding-bottom: max(20px, env(safe-area-inset-bottom));
    color: #e0e0e0;
    overflow-x: hidden;
    position: relative;
    width: 100%;
    margin: 0;
}

.container {
    max-width: 1200px;
    margin: 0 auto;
    background: rgba(30, 30, 45, 0.95);
    border-radius: 20px;
    box-shadow: 0 20px 40px rgba(0, 0, 0, 0.3);
    overflow: hidden;
    backdrop-filter: blur(10px);
    border: 1px solid rgba(255, 255, 255, 0.1);
    /* Match working personal website approach */
    position: relative;
    width: 100%;
    box-sizing: border-box;
}

.header {
    background: linear-gradient(135deg, #16213e 0%, #0f3460 100%);
    color: white;
    padding: 40px;
    text-align: center;
}

.header h1 {
    font-size: 2.5rem;
    font-weight: 300;
    margin-bottom: 10px;
    letter-spacing: 2px;
}

.header p {
    font-size: 1.1rem;
    opacity: 0.9;
    font-weight: 300;
}

.projects-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(300px, 1fr));
    gap: 20px;
    padding: 40px;
}

.project-card {
    background: rgba(45, 45, 60, 0.9);
    border-radius: 15px;
    padding: 25px;
    box-shadow: 0 10px 30px rgba(0, 0, 0, 0.3);
    transition: all 0.3s ease;
    border: 1px solid rgba(255, 255, 255, 0.1);
    position: relative;
    overflow: hidden;
}

        .project-card::before {
            content: '';
            position: absolute;
            top: 0;
            left: 0;
            right: 0;
            height: 4px;
            background: linear-gradient(90deg, #00d4ff, #0099cc);
            transform: scaleX(0);
            transition: transform 0.3s ease;
        }

        .project-card:hover {
            transform: translateY(-5px);
            box-shadow: 0 20px 40px rgba(0, 0, 0, 0.5);
            background: rgba(55, 55, 70, 0.95);
        }

.project-card:hover::before {
    transform: scaleX(1);
}

.project-link {
    text-decoration: none;
    color: inherit;
    display: block;
}

        .project-title {
            font-size: 1.4rem;
            font-weight: 600;
            color: #ffffff;
            margin-bottom: 10px;
            display: flex;
            align-items: center;
        }

.project-title::before {
    margin-right: 10px;
    font-size: 1.2rem;
}

        .project-description {
            color: #b0b0b0;
            line-height: 1.6;
            font-size: 0.95rem;
        }

        .project-type {
            display: inline-block;
            background: linear-gradient(135deg, #00d4ff, #0099cc);
            color: white;
            padding: 4px 12px;
            border-radius: 20px;
            font-size: 0.8rem;
            font-weight: 500;
            margin-top: 15px;
            text-transform: uppercase;
            letter-spacing: 0.5px;
        }

        .footer {
            background: rgba(25, 25, 35, 0.9);
            padding: 30px 40px;
            text-align: center;
            border-top: 1px solid rgba(255, 255, 255, 0.1);
        }

        .footer p {
            color: #888;
            font-size: 0.9rem;
        }

@media (max-width: 768px) {
    .header h1 {
        font-size: 2rem;
    }
    
    .projects-grid {
        grid-template-columns: 1fr;
        padding: 20px;
    }
    
    .header {
        padding: 30px 20px;
    }
}

/* Animation for cards */
.project-card {
    animation: fadeInUp 0.6s ease forwards;
    opacity: 0;
    transform: translateY(30px);
}

        .project-card:nth-child(1) { animation-delay: 0.1s; }
        .project-card:nth-child(2) { animation-delay: 0.2s; }
        .project-card:nth-child(3) { animation-delay: 0.3s; }
        .project-card:nth-child(4) { animation-delay: 0.4s; }
        .project-card:nth-child(5) { animation-delay: 0.5s; }
        .project-card:nth-child(6) { animation-delay: 0.6s; }
        .project-card:nth-child(7) { animation-delay: 0.7s; }
        .project-card:nth-child(8) { animation-delay: 0.8s; }
        .project-card:nth-child(9) { animation-delay: 0.9s; }
        .project-card:nth-child(10) { animation-delay: 1.0s; }
        .project-card:nth-child(11) { animation-delay: 1.1s; }

@keyframes fadeInUp {
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

/* Page-specific styles for project pages */
.project-section {
    margin-bottom: 60px;
}

.project-title-large {
    font-size: 2rem;
    font-weight: 600;
    color: #ffffff;
    margin-bottom: 15px;
    text-align: center;
}

.project-description-large {
    color: #b0b0b0;
    line-height: 1.6;
    font-size: 1.1rem;
    text-align: center;
    margin-bottom: 30px;
}

.canvas-container {
    display: flex;
    justify-content: center;
    margin: 20px 0;
    /* Safari iOS 26 fixes to prevent white bars */
    background: transparent;
    overflow: hidden;
    position: relative;
}

/* Override CS559 framework borders completely */
canvas {
    border: 2px solid rgba(255, 255, 255, 0.2) !important;
    border-radius: 10px;
    background: rgba(20, 20, 30, 0.8);
    display: block;
    margin: 0 auto;
    overflow: hidden;
    position: relative;
    -webkit-transform: translateZ(0);
    transform: translateZ(0);
    box-sizing: border-box;
}


/* Square canvases (600x600) */
canvas#canvas1[width="600"][height="600"],
.wb-page .canvas-container div#canvas1[width="600"][height="600"] {
    width: 600px;
    height: 600px;
}

/* Square canvases (500x500) */
canvas#canvas1[width="500"],
.wb-page .canvas-container div#canvas1[width="500"] {
    width: 500px;
    height: 500px;
}

/* Square canvases (400x400) */
canvas#canvas1[width="400"],
.wb-page .canvas-container div#canvas1[width="400"] {
    width: 400px;
    height: 400px;
}

/* WB6 Canvas2 specific (670x500) */
.wb-page .canvas-container div#canvas2[width="670"] {
    width: 670px;
    height: 500px;
}

/* WB6 specific mobile fixes - prevent cutoff on real mobile devices */
@media (max-width: 768px) {
    .wb-page .canvas-container div#canvas1[width="500"] {
        width: min(400px, calc(100vw - 60px)) !important;
        height: min(400px, calc(100vw - 60px)) !important;
        max-width: 400px;
        max-height: 500px; /* Increased from 400px to prevent cutoff */
    }
    
    .wb-page .canvas-container div#canvas2[width="670"] {
        width: min(500px, calc(100vw - 60px)) !important;
        height: min(500px, calc((100vw - 60px) * 0.746)) !important; /* Increased from 373px */
        max-width: 500px;
        max-height: 500px; /* Increased from 373px to prevent cutoff */
    }
}

@media (max-width: 480px) {
    .wb-page .canvas-container div#canvas1[width="500"] {
        width: min(350px, calc(100vw - 40px)) !important;
        height: min(350px, calc(100vw - 40px)) !important;
        max-width: 350px;
        max-height: 500px; /* Increased from 350px to prevent cutoff */
    }
    
    .wb-page .canvas-container div#canvas2[width="670"] {
        width: min(400px, calc(100vw - 40px)) !important;
        height: min(500px, calc((100vw - 40px) * 0.746)) !important; /* Increased from 298px */
        max-width: 400px;
        max-height: 500px; /* Increased from 298px to prevent cutoff */
    }
}

/* Prevent canvas cutoff - ensure full height display */
.wb-page .canvas-container {
    margin-bottom: 50px;
    padding-bottom: 20px;
    min-height: fit-content;
    overflow: visible;
}

.wb-page .canvas-container div[id^="canvas"] {
    min-height: fit-content;
    overflow: visible;
}

/* Tablet responsive canvas */
@media (max-width: 1024px) {
    canvas,
    .wb-page .canvas-container div[id^="canvas"] {
        max-width: calc(100vw - 140px);
        max-height: calc(100vh - 200px);
    }
    
    /* Square canvases maintain aspect ratio */
    canvas#canvas1[width="600"][height="600"],
    .wb-page .canvas-container div#canvas1[width="600"][height="600"],
    canvas#canvas1[width="500"],
    .wb-page .canvas-container div#canvas1[width="500"],
    canvas#canvas1[width="400"],
    .wb-page .canvas-container div#canvas1[width="400"] {
        width: min(600px, calc(100vw - 140px));
        height: min(600px, calc(100vw - 140px));
    }
    
    /* WB6 Canvas2 specific responsive */
    .wb-page .canvas-container div#canvas2[width="670"] {
        width: min(670px, calc(100vw - 140px));
        height: min(500px, calc((100vw - 140px) * 0.746));
    }
}

/* Mobile responsive canvas */
@media (max-width: 768px) {
    canvas,
    .wb-page .canvas-container div[id^="canvas"] {
        max-width: calc(100vw - 120px);
        max-height: calc(100vh - 200px);
    }
    
    /* Square canvases maintain aspect ratio */
    canvas#canvas1[width="600"][height="600"],
    .wb-page .canvas-container div#canvas1[width="600"][height="600"],
    canvas#canvas1[width="500"],
    .wb-page .canvas-container div#canvas1[width="500"],
    canvas#canvas1[width="400"],
    .wb-page .canvas-container div#canvas1[width="400"] {
        width: min(600px, calc(100vw - 120px));
        height: min(600px, calc(100vw - 120px));
    }
    
    /* WB6 Canvas2 specific responsive */
    .wb-page .canvas-container div#canvas2[width="670"] {
        width: min(670px, calc(100vw - 120px));
        height: min(500px, calc((100vw - 120px) * 0.746));
    }
}

@media (max-width: 480px) {
    canvas,
    .wb-page .canvas-container div[id^="canvas"] {
        max-width: calc(100vw - 100px);
        max-height: calc(100vh - 200px);
    }
    
    /* Square canvases maintain aspect ratio */
    canvas#canvas1[width="600"][height="600"],
    .wb-page .canvas-container div#canvas1[width="600"][height="600"],
    canvas#canvas1[width="500"],
    .wb-page .canvas-container div#canvas1[width="500"],
    canvas#canvas1[width="400"],
    .wb-page .canvas-container div#canvas1[width="400"] {
        width: min(600px, calc(100vw - 100px));
        height: min(600px, calc(100vw - 100px));
    }
    
    /* WB6 Canvas2 specific responsive */
    .wb-page .canvas-container div#canvas2[width="670"] {
        width: min(670px, calc(100vw - 100px));
        height: min(500px, calc((100vw - 100px) * 0.746));
    }
}

.back-link {
    display: inline-block;
    margin: 20px 0;
    padding: 10px 20px;
    background: linear-gradient(135deg, #00d4ff, #0099cc);
    color: white;
    text-decoration: none;
    border-radius: 25px;
    font-weight: 500;
    transition: all 0.3s ease;
}

.back-link:hover {
    transform: translateY(-2px);
    box-shadow: 0 5px 15px rgba(0, 212, 255, 0.3);
}

.page-header {
    text-align: center;
    margin-bottom: 40px;
}

.page-header h1 {
    font-size: 2.5rem;
    font-weight: 300;
    margin-bottom: 10px;
    letter-spacing: 2px;
    color: #ffffff;
}

.page-header p {
    font-size: 1.1rem;
    opacity: 0.9;
    font-weight: 300;
    color: #b0b0b0;
}

/* WB page generic overrides */
.wb-page .back-link {
    position: absolute;
    top: 0px;
    left: 30px;
    z-index: 10;
}

/* Mobile-specific styles for back button */
@media (max-width: 768px) {
    .back-link {
        padding: 10px !important;
        font-size: 0 !important;
        width: 40px;
        height: 40px;
        display: flex !important;
        align-items: center;
        justify-content: center;
        border-radius: 50% !important;
        position: fixed !important;
        top: 0px !important;
        left: 15px !important;
    }
    
    .back-link::before {
        content: "←";
        font-size: 18px;
        font-weight: bold;
        line-height: 1;
    }
}

.wb-page .header {
    padding: 20px 0 10px 0 !important;
    min-height: unset !important;
}

.wb-page .page-header {
    text-align: center;
    margin-bottom: 20px;
}

.wb-page .page-header h1 {
    font-size: 1.5rem;
    font-weight: 400;
    margin-bottom: 5px;
    letter-spacing: 1px;
    color: #ffffff;
}

.wb-page .page-header p {
    font-size: 1rem;
    opacity: 0.8;
    font-weight: 300;
    color: #b0b0b0;
}

.wb-page .container {
    position: relative;
}

.wb-page .project-section {
    margin-bottom: 40px;
}

.wb-page .project-title-large {
    font-size: 1.2rem;
    font-weight: 600;
    color: #ffffff;
    margin-bottom: 10px;
    text-align: center;
}

.wb-page .project-description-large {
    color: #b0b0b0;
    line-height: 1.4;
    font-size: 1rem;
    text-align: center;
    margin-bottom: 20px;
}

.wb-page .canvas-container {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    margin: 10px 0 30px 0;
    /* Match working personal website approach */
    background: transparent;
    overflow: hidden;
    position: relative;
    width: 100%;
    max-width: 100%;
    box-sizing: border-box;
}

/* Canvas container styling */
@media (max-width: 1024px) {
    .wb-page .canvas-container {
        margin: 5px 0 20px 0;
        padding: 0 10px;
    }
}

@media (max-width: 768px) {
    .wb-page .canvas-container {
        margin: 5px 0 20px 0;
        padding: 0 10px;
    }
}

.disclaimer {
    font-size: 0.9rem;
    opacity: 0.8;
    margin-top: 5px;
    color: #b0b0b0;
}

.wb-page .controls {
    display: flex;
    justify-content: center;
    align-items: center;
    gap: 10px;
    margin-top: 10px;
    flex-wrap: wrap;
}

.wb-page .controls input[type=range] {
    width: 150px;
    accent-color: #00d4ff;
}

/* description list alignment */
.project-description-large .desc-list {
    display: inline-block; /* allow centering as a block inside centered parent */
    text-align: left;      /* left align list text */
    margin: 15px auto 0;   /* some spacing on top */
    padding-left: 20px;    /* normal bullet indent */
}

.wb-page .controls-row {
    display: flex;
    flex-wrap: wrap;
    justify-content: center;
    gap: 10px;
    margin-top: 10px;
    width: 100%;
}

.wb-page .controls-row > div {
    background: #000;
    padding: 10px 15px;
    border-radius: 8px;
    flex: 1 1 150px; /* grow to fill, but not too small */
    max-width: 150px; /* optional cap */
}

.wb-page .controls-row input[type=range] {
    accent-color: #2196F3; /* blue */
} 

#p2-controls > #world-ui-div {
    flex: 0 0 600px;
    max-width: 100%;  
}

.project-description-large .desc-list ul {
    margin-left: 20px;
    list-style-type: circle;
}

/* Safari white bars fix */
@supports (-webkit-touch-callout: none) {
    html, body {
        background-attachment: scroll !important;
    }
}

/* Mobile Controls for WB3 */
.mobile-controls {
    display: none;
    position: absolute;
    bottom: 20px;
    left: 20px;
    z-index: 10;
    pointer-events: none;
}

.mobile-shoot-controls {
    display: none;
    position: absolute;
    bottom: 20px;
    right: 20px;
    z-index: 10;
    pointer-events: none;
}

.joystick-container {
    margin-bottom: 0;
}

.joystick-base {
    width: 80px;
    height: 80px;
    background: rgba(0, 0, 0, 0.3);
    border: 2px solid rgba(255, 255, 255, 0.4);
    border-radius: 50%;
    position: relative;
    pointer-events: auto;
    touch-action: none;
}

.joystick-knob {
    width: 30px;
    height: 30px;
    background: rgba(0, 212, 255, 0.8);
    border: 2px solid rgba(255, 255, 255, 0.6);
    border-radius: 50%;
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    transition: all 0.1s ease;
    pointer-events: none;
}

.shoot-btn {
    background: rgba(255, 0, 0, 0.7);
    border: 2px solid rgba(255, 255, 255, 0.4);
    border-radius: 15px;
    color: white;
    font-size: 14px;
    font-weight: bold;
    padding: 12px 20px;
    text-align: center;
    cursor: pointer;
    user-select: none;
    pointer-events: auto;
    transition: all 0.2s ease;
    touch-action: manipulation;
    min-width: 80px;
}

.shoot-btn:active {
    background: rgba(255, 0, 0, 1);
    transform: scale(0.95);
}

/* Show mobile controls on mobile devices */
@media (max-width: 768px) {
    .mobile-controls,
    .mobile-shoot-controls {
        display: block;
    }
    
    /* Hide mobile controls on desktop */
    @media (hover: hover) {
        .mobile-controls,
        .mobile-shoot-controls {
            display: none;
        }
    }
}