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

body {
    font-family: 'Roboto', sans-serif;
    color: #f5f6f5;
    background: #1a1e2e;
    line-height: 1.6;
    overflow-x: hidden;
    touch-action: auto;
}

/* Trail Canvas */
#trail-canvas {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    z-index: 1;
    pointer-events: none;
    display: none;
}

@media (min-width: 769px) {
    #trail-canvas {
        display: block;
    }
}

/* Navbar */
header {
    position: fixed;
    width: 100%;
    top: 0;
    z-index: 1000;
    background: rgba(26, 30, 46, 0.9);
    backdrop-filter: blur(12px);
    border-bottom: 1px solid rgba(255, 255, 255, 0.2);
    transition: padding 0.3s, background 0.3s;
}

header.scrolled {
    padding: 12px 0;
    background: rgba(26, 30, 46, 0.95);
    box-shadow: 0 4px 10px rgba(0, 0, 0, 0.3);
}

nav {
    max-width: 1440px;
    margin: 0 auto;
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 20px 32px;
}

nav h1 {
    font-family: 'Montserrat', sans-serif;
    font-size: 2rem;
    font-weight: 700;
    color: #4db6ac;
    transition: color 0.3s;
}

.nav-links {
    display: flex;
    align-items: center;
    gap: 32px;
}

.nav-links a {
    font-family: 'Montserrat', sans-serif;
    color: #f5f6f5;
    text-decoration: none;
    font-size: 1.2rem;
    font-weight: 500;
    position: relative;
    padding: 8px 0;
    transition: color 0.3s, transform 0.2s;
}

.nav-links a::after {
    content: '';
    position: absolute;
    width: 0;
    height: 2px;
    bottom: -2px;
    left: 0;
    background: #4db6ac;
    transition: width 0.3s ease;
}

.nav-links a:hover::after,
.nav-links a.active::after {
    width: 100%;
}

.nav-links a:hover {
    color: #4db6ac;
    transform: scale(1.05);
    text-shadow: 0 0 5px rgba(77, 182, 172, 0.3);
}

.nav-links a.active {
    color: #4db6ac;
}

.menu-toggle {
    display: none;
    font-size: 1.8rem;
    background: none;
    border: none;
    color: #f5f6f5;
    cursor: pointer;
    padding: 8px;
    transition: color 0.3s, transform 0.2s;
}

.menu-toggle:hover {
    color: #4db6ac;
    transform: scale(1.1);
}

.menu-toggle:focus {
    outline: 2px solid #4db6ac;
    outline-offset: 2px;
}

.menu-toggle.active::before {
    content: '✕';
}

/* Mobile Menu */
@media (max-width: 768px) {
    .nav-links {
        display: none;
        flex-direction: column;
        position: absolute;
        top: 100%;
        left: 0;
        width: 100%;
        background: rgba(26, 30, 46, 0.95);
        backdrop-filter: blur(12px);
        padding: 24px 0;
        transform: translateY(-10px);
        opacity: 0;
        transition: transform 0.3s ease, opacity 0.3s ease;
    }

    .nav-links.active {
        display: flex;
        transform: translateY(0);
        opacity: 1;
    }

    .nav-links a {
        font-size: 1.5rem;
        padding: 12px 0;
        opacity: 0;
        transform: translateY(10px);
        transition: opacity 0.3s ease, transform 0.3s ease;
    }

    .nav-links.active a {
        opacity: 1;
        transform: translateY(0);
    }

    .nav-links a:nth-child(1) { transition-delay: 0.1s; }
    .nav-links a:nth-child(2) { transition-delay: 0.15s; }
    .nav-links a:nth-child(3) { transition-delay: 0.2s; }
    .nav-links a:nth-child(4) { transition-delay: 0.25s; }
    .nav-links a:nth-child(5) { transition-delay: 0.3s; }
    .nav-links a:nth-child(6) { transition-delay: 0.35s; }

    .menu-toggle {
        display: block;
    }
}

/* Hero Section */
#home {
    min-height: 100vh;
    display: flex;
    align-items: center;
    justify-content: center;
    position: relative;
    text-align: center;
    padding: 32px;
    overflow: hidden;
}

#home canvas {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    z-index: 0;
    background: #1a1e2e;
    display: none;
}

@media (min-width: 769px) {
    #home canvas {
        display: block;
    }
}

#home::after {
    content: '';
    position: absolute;
    bottom: 0;
    left: 0;
    width: 100%;
    height: 100px;
    background: linear-gradient(to top, rgba(26, 30, 46, 0.5), transparent);
    z-index: 1;
}

#home .hero-content {
    max-width: 900px;
    position: relative;
    z-index: 2;
    opacity: 0;
    transform: translateY(20px);
    transition: opacity 0.8s ease-out 0.5s, transform 0.8s ease-out 0.5s;
}

#home.visible .hero-content {
    opacity: 1;
    transform: translateY(0);
}

#home h2 {
    font-family: 'Montserrat', sans-serif;
    font-size: 4rem;
    font-weight: 700;
    color: #f5f6f5;
    margin-bottom: 24px;
    text-shadow: 0 0 10px rgba(77, 182, 172, 0.3);
}

#home p {
    font-size: 1.5rem;
    color: #d8dee9;
    margin-bottom: 32px;
}

#home a {
    display: inline-block;
    padding: 14px 36px;
    font-size: 1.1rem;
    font-weight: 500;
    text-decoration: none;
    color: #1a1e2e;
    background: #4db6ac;
    border-radius: 8px;
    transition: background 0.3s, transform 0.2s, box-shadow 0.3s;
}

#home a:hover {
    background: #4ba39a;
    transform: translateY(-2px);
    box-shadow: 0 4px 15px rgba(77, 182, 172, 0.5);
    text-shadow: 0 0 5px rgba(255, 255, 255, 0.3);
}

#home a:focus {
    outline: 2px solid #4db6ac;
    outline-offset: 2px;
}

@media (max-width: 768px) {
    #home h2 {
        font-size: 2.5rem;
    }

    #home p {
        font-size: 1.25rem;
    }

    #home a {
        padding: 12px 32px;
        font-size: 1rem;
    }
}

/* About Section */
#about {
    padding: 100px 32px;
    background: rgba(26, 30, 46, 0.5);
    backdrop-filter: blur(8px);
    text-align: center;
    opacity: 0;
    transform: translateY(20px);
    transition: opacity 0.8s ease-out, transform 0.8s ease-out;
}

#about.visible {
    opacity: 1;
    transform: translateY(0);
}

#about h2 {
    font-family: 'Montserrat', sans-serif;
    font-size: 2.5rem;
    font-weight: 700;
    color: #4db6ac;
    margin-bottom: 24px;
}

#about p {
    max-width: 800px;
    margin: 0 auto;
    font-size: 1.125rem;
    color: #d8dee9;
}

/* Portfolio Section */
#portfolio {
    padding: 100px 32px;
    background: #1a1e2e;
    opacity: 0;
    transform: translateY(20px);
    transition: opacity 0.8s ease-out, transform 0.8s ease-out;
}

#portfolio.visible {
    opacity: 1;
    transform: translateY(0);
}

#portfolio h2 {
    font-family: 'Montserrat', sans-serif;
    font-size: 2.5rem;
    font-weight: 700;
    color: #4db6ac;
    text-align: center;
    margin-bottom: 48px;
}

.portfolio-grid {
    max-width: 1440px;
    margin: 0 auto;
    display: grid;
    grid-template-columns: 1fr;
    gap: 32px;
}

.portfolio-card {
    background: rgba(255, 255, 255, 0.15);
    backdrop-filter: blur(8px);
    padding: 24px;
    border-radius: 12px;
    border: 1px solid rgba(255, 255, 255, 0.15);
    text-align: center;
    opacity: 0;
    transform: scale(0.95);
    transition: opacity 0.5s ease-out, transform 0.5s ease-out, box-shadow 0.3s;
}

.portfolio-card.visible {
    opacity: 1;
    transform: scale(1);
}

.portfolio-card:nth-child(1) { transition-delay: 0.1s; }
.portfolio-card:nth-child(2) { transition-delay: 0.2s; }
.portfolio-card:nth-child(3) { transition-delay: 0.3s; }

.portfolio-card:hover {
    transform: scale(1.02);
    box-shadow: 0 6px 20px rgba(0, 0, 0, 0.2);
}

.portfolio-card h3 {
    font-family: 'Montserrat', sans-serif;
    font-size: 1.5rem;
    font-weight: 600;
    color: #f5f6f5;
    margin-bottom: 16px;
}

.portfolio-card p {
    color: #d8dee9;
    font-size: 1rem;
}

/* Services Section */
#services {
    cursor: default;
    padding: 100px 32px;
    background: #1a1e2e;
    opacity: 0;
    transform: translateY(20px);
    transition: opacity 0.8s ease-out, transform 0.8s ease-out;
}

#services.visible {
    opacity: 1;
    transform: translateY(0);
}

#services h2 {
    font-family: 'Montserrat', sans-serif;
    font-size: 2.5rem;
    font-weight: 700;
    color: #4db6ac;
    text-align: center;
    margin-bottom: 48px;
}

.services-grid {
    cursor: default;
    max-width: 1440px;
    margin: 0 auto;
    display: grid;
    grid-template-columns: 1fr;
    gap: 20px;
}

.service-card {
    position: relative;
    overflow: hidden;
    border-radius: 12px;
    border: 1px solid rgba(255, 255, 255, 0.15);
    min-height: 200px;
    aspect-ratio: 16/9;
    opacity: 0;
    transform: scale(0.95);
    transition: opacity 0.5s ease-out, transform 0.5s ease-out, box-shadow 0.3s;
}

.service-card.visible {
    opacity: 1;
    transform: scale(1);
}

.service-card:nth-child(1) { transition-delay: 0.1s; }
.service-card:nth-child(2) { transition-delay: 0.15s; }
.service-card:nth-child(3) { transition-delay: 0.2s; }
.service-card:nth-child(4) { transition-delay: 0.25s; }
.service-card:nth-child(5) { transition-delay: 0.3s; }
.service-card:nth-child(6) { transition-delay: 0.35s; }
.service-card:nth-child(7) { transition-delay: 0.4s; }
.service-card:nth-child(8) { transition-delay: 0.45s; }
.service-card:nth-child(9) { transition-delay: 0.5s; }
.service-card:nth-child(10) { transition-delay: 0.55s; }
.service-card:nth-child(11) { transition-delay: 0.6s; }
.service-card:nth-child(12) { transition-delay: 0.65s; }
.service-card:nth-child(13) { transition-delay: 0.7s; }
.service-card:nth-child(14) { transition-delay: 0.75s; }

.service-card:hover {
    transform: scale(1.02);
    box-shadow: 0 6px 20px rgba(0, 0, 0, 0.2);
}

.service-video {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    object-fit: cover;
    z-index: -1;
    opacity: 0;
    display: none;
    transition: opacity 0.3s ease;
}

.service-card:hover .service-video {
    opacity: 1;
    display: block;
}

.service-card-content {
    position: relative;
    z-index: 1;
    padding: 24px;
    background: rgba(26, 30, 46, 0.7);
    backdrop-filter: blur(12px);
    height: 100%;
    display: flex;
    flex-direction: column;
    justify-content: center;
    text-align: center;
}

.service-card-content h3 {
    font-family: 'Montserrat', sans-serif;
    font-size: 1.5rem;
    font-weight: 600;
    color: #f5f6f5;
    margin-bottom: 16px;
    text-shadow: 0 2px 4px rgba(0, 0, 0, 0.5);
}

.service-card-content p {
    color: #d8dee9;
    font-size: 1rem;
    text-shadow: 0 2px 4px rgba(0, 0, 0, 0.5);
}

/* Contact Section */
#contact {
    padding: 100px 32px;
    background: rgba(26, 30, 46, 0.5);
    backdrop-filter: blur(8px);
    text-align: center;
    opacity: 0;
    transform: translateY(20px);
    transition: opacity 0.8s ease-out, transform 0.8s ease-out;
}

#contact.visible {
    opacity: 1;
    transform: translateY(0);
}

#contact h2 {
    font-family: 'Montserrat', sans-serif;
    font-size: 2.5rem;
    font-weight: 700;
    color: #4db6ac;
    margin-bottom: 32px;
}

#contact form {
    max-width: 600px;
    margin: 0 auto;
    padding: 24px;
    background: rgba(26, 30, 46, 0.6);
    backdrop-filter: blur(12px);
    border-radius: 12px;
    border: 1px solid rgba(77, 182, 172, 0.3);
    display: flex;
    flex-direction: column;
    gap: 16px;
    position: relative;
    box-shadow: 0 4px 20px rgba(0, 0, 0, 0.2);
}

#contact input,
#contact textarea {
    padding: 12px 16px;
    border: 1px solid rgba(77, 182, 172, 0.2);
    border-radius: 8px;
    font-size: 1rem;
    background: rgba(255, 255, 255, 0.05);
    backdrop-filter: blur(8px);
    color: #f5f6f5;
    transition: border-color 0.3s ease-in-out, box-shadow 0.3s ease-in-out;
}

#contact input:focus,
#contact textarea:focus {
    border-color: #80cbc4;
    box-shadow: 0 0 8px rgba(77, 182, 172, 0.5);
    outline: none;
}

#contact input:invalid:not(:focus),
#contact textarea:invalid:not(:focus) {
    border-color: #26a69a;
}

#contact textarea {
    height: 140px;
    resize: vertical;
}

#contact button {
    padding: 12px 32px;
    min-width: 120px;
    font-size: 1rem;
    font-weight: 500;
    color: #f5f6f5;
    background: rgba(77, 182, 172, 0.2);
    backdrop-filter: blur(8px);
    border: 1px solid rgba(77, 182, 172, 0.3);
    border-radius: 8px;
    cursor: pointer;
    transition: background 0.3s ease-in-out, transform 0.3s ease-in-out, box-shadow 0.3s ease-in-out;
    position: relative;
    z-index: 1;
}

#contact button:hover {
    background: linear-gradient(45deg, #4db6ac, #80cbc4);
    transform: scale(1.03);
    box-shadow: 0 0 10px rgba(77, 182, 172, 0.5);
}

#contact button:focus {
    outline: 2px solid #80cbc4;
    outline-offset: 2px;
}

#contact button:disabled {
    background: rgba(255, 255, 255, 0.2);
    border: 1px solid rgba(255, 255, 255, 0.2);
    cursor: not-allowed;
    transform: none;
    box-shadow: none;
}

.spinner {
    display: none;
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    width: 24px;
    height: 24px;
    border: 3px solid rgba(77, 182, 172, 0.3);
    border-top: 3px solid #4db6ac;
    border-radius: 50%;
    animation: spin 1s linear infinite;
    z-index: 2;
}

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

#form-message {
    display: none;
    margin-top: 16px;
    padding: 12px;
    border-radius: 8px;
    font-size: 1rem;
    background: rgba(26, 30, 46, 0.6);
    backdrop-filter: blur(12px);
    border: 1px solid rgba(77, 182, 172, 0.3);
    box-shadow: 0 4px 20px rgba(0, 0, 0, 0.2);
    opacity: 0;
    transition: opacity 0.3s ease-in-out;
}

#form-message.success,
#form-message.error {
    display: block;
    opacity: 1;
}

#form-message.success {
    color: #4db6ac;
}

#form-message.error {
    color: #80cbc4;
}

/* Contact Info */
.contact-info {
    display: flex;
    flex-direction: row;
    justify-content: center;
    flex-wrap: wrap;
    gap: 24px;
    margin: 24px 0;
}

.contact-item {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 8px 16px;
    background: rgba(255, 255, 255, 0.1);
    backdrop-filter: blur(8px);
    border: 1px solid rgba(77, 182, 172, 0.3);
    border-radius: 8px;
    color: #f5f6f5;
    font-size: 1rem;
    text-decoration: none;
    transition: background 0.3s ease, transform 0.3s ease, box-shadow 0.3s ease;
    z-index: 2;
}

.contact-item i {
    font-size: 1.1rem;
}

.contact-item:hover {
    background: #4db6ac;
    transform: scale(1.05);
    box-shadow: 0 0 10px rgba(77, 182, 172, 0.5);
}

.contact-item:focus {
    outline: 2px solid #80cbc4;
    outline-offset: 2px;
}

/* Social Links */
.social-links {
    display: flex;
    justify-content: center;
    gap: 16px;
    margin-top: 24px;
}

.social-link {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 40px;
    height: 40px;
    background: rgba(255, 255, 255, 0.1);
    backdrop-filter: blur(8px);
    border: 1px solid rgba(77, 182, 172, 0.3);
    border-radius: 50%;
    color: #f5f6f5;
    font-size: 1.2rem;
    text-decoration: none;
    transition: background 0.3s ease, transform 0.3s ease, box-shadow 0.3s ease;
    z-index: 2;
}

.social-link:hover {
    background: #4db6ac;
    transform: scale(1.1);
    box-shadow: 0 0 10px rgba(77, 182, 172, 0.5);
}

.social-link:focus {
    outline: 2px solid #80cbc4;
    outline-offset: 2px;
}

@media (max-width: 768px) {
    #contact form {
        padding: 20px;
    }

    #contact input,
    #contact textarea {
        padding: 10px 14px;
        font-size: 0.95rem;
    }

    #contact button {
        padding: 10px 28px;
        font-size: 0.95rem;
    }

    .spinner {
        width: 20px;
        height: 20px;
    }

    #form-message {
        padding: 10px;
        font-size: 0.95rem;
    }

    .contact-info {
        gap: 16px;
        margin: 20px 0;
    }

    .contact-item {
        padding: 8px 14px;
        font-size: 0.95rem;
    }

    .contact-item i {
        font-size: 1rem;
    }

    .social-links {
        gap: 12px;
        margin-top: 20px;
    }

    .social-link {
        width: 36px;
        height: 36px;
        font-size: 1.1rem;
    }

    .services-grid {
        gap: 16px;
    }

    .service-card {
        min-height: 180px;
    }

    .service-card-content {
        padding: 20px;
    }

    .service-card-content h3 {
        font-size: 1.3rem;
    }

    .service-card-content p {
        font-size: 0.9rem;
    }
}

@media (max-width: 480px) {
    .contact-info {
        flex-direction: column;
        gap: 12px;
    }
}

/* Responsive Design */
@media (min-width: 768px) {
    nav h1 {
        font-size: 2rem;
    }

    .nav-links a {
        font-size: 1.2rem;
    }

    .portfolio-grid {
        grid-template-columns: repeat(3, 1fr);
    }

    .services-grid {
        grid-template-columns: repeat(3, 1fr);
    }

    #about h2,
    #portfolio h2,
    #services h2,
    #contact h2 {
        font-size: 2.75rem;
    }
}

@media (min-width: 1200px) {
    .services-grid {
        grid-template-columns: repeat(4, 1fr);
    }
}

/* Back-to-Top Button */
#back-to-top {
    position: fixed;
    bottom: 24px;
    right: 24px;
    z-index: 2;
    background: #4db6ac;
    color: #1a1e2e;
    padding: 12px;
    border-radius: 10px;
    text-decoration: none;
    font-size: 1.25rem;
    opacity: 0;
    transition: opacity 0.3s, transform 0.2s;
}

#back-to-top.visible {
    opacity: 1;
}

#back-to-top:hover {
    transform: scale(1.1);
    box-shadow: 0 4px 15px rgba(77, 182, 172, 0.3);
}

#location {
    display: flex;
    position: relative;
    align-items: center;
    justify-items: center;
    justify-content: center;
    flex-wrap: wrap;
    width: 10%;
    gap: 24px;
    margin: 24px 0;
}

.location {
    display: flex;
    position: relative;
    justify-content: center;
}

/* Footer */
footer {
    background: rgba(26, 30, 46, 0.8);
    backdrop-filter: blur(8px);
    color: #d8dee9;
    text-align: center;
    padding: 24px;
    font-size: 0.875rem;
}

#icon {
    display: flex;
    position: absolute;
    top: 30px;
    right: 10%;
}

.powered-by {
    display: flex;
    position: absolute;
    top: 30px;
    right: 13.5%;
}

/* Ultra small screens (below 400px) */
@media (max-width: 400px) {
    nav h1 {
        font-size: 1.5rem;
    }

    .nav-links a {
        font-size: 1rem;
        padding: 10px 0;
    }

    #home h2 {
        font-size: 2rem;
    }

    #home p {
        font-size: 1rem;
    }

    #home a {
        padding: 10px 24px;
        font-size: 0.9rem;
    }

    #about h2,
    #portfolio h2,
    #services h2,
    #contact h2 {
        font-size: 2rem;
    }

    .portfolio-grid,
    .services-grid {
        grid-template-columns: 1fr !important;
    }

    .contact-item {
        font-size: 0.9rem;
        padding: 6px 12px;
    }

    .contact-info {
        flex-direction: column;
        gap: 12px;
    }

    .social-link {
        width: 32px;
        height: 32px;
        font-size: 1rem;
    }

    footer {
        font-size: 0.75rem;
    }

    #icon,
    .powered-by {
        position: static;
        display: block;
        text-align: center;
        margin: 12px auto 0;
    }
}

/* Fix #location on mobile to be full width and centered */
@media (max-width: 768px) {
    #location {
        width: 100%;
        justify-content: center;
        gap: 16px;
    }

    #icon,
    .powered-by {
        top: auto;
        bottom: 10px;
        right: auto;
        position: relative;
        justify-content: center;
        text-align: center;
    }
}

/* Improve touch targets on mobile */
@media (max-width: 768px) {
    a,
    button {
        padding: 14px;
    }
}

html, body {
    overscroll-behavior: auto;
    touch-action: auto;
}