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

:root {
    --primary-green: #2d7d50;
    --light-green: #8bc34a;
    --sky-blue: #87ceeb;
    --cream: #fef9e7;
    --warm-brown: #8b6f47;
    --text-dark: #2c3e50;
    --text-light: #ffffff;
    --card-bg: #ffffff;
    --accent-pink: #ff9999;
    --shadow: rgba(0, 0, 0, 0.1);
}

body {
    font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;
    background: linear-gradient(to bottom, #e3f2fd 0%, #fff9e6 50%, #ffebcd 100%);
    color: var(--text-dark);
    line-height: 1.6;
    overflow-x: hidden;
    position: relative;
    min-height: 100vh;
}

/* Animated clouds background */
.clouds {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    overflow: hidden;
    z-index: -1;
}

.clouds::before,
.clouds::after {
    content: '';
    position: absolute;
    width: 200px;
    height: 60px;
    background: rgba(255, 255, 255, 0.3);
    border-radius: 100px;
    animation: float 30s infinite ease-in-out;
}

.clouds::before {
    top: 10%;
    left: -200px;
    animation-delay: 0s;
}

.clouds::after {
    top: 30%;
    left: -200px;
    animation-delay: 15s;
}

@keyframes float {
    0%, 100% { transform: translateX(0) translateY(0); }
    50% { transform: translateX(calc(100vw + 200px)) translateY(-20px); }
}

/* Soot Sprites (Susuwatari) Animation */
.soot-sprites {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    pointer-events: none; /* container doesn't capture clicks, individual sprites will */
    z-index: 1;
}

.soot-sprite {
    position: absolute;
    width: 30px;
    height: 30px;
    background: radial-gradient(circle, #1a1a1a 0%, #000000 70%);
    border-radius: 50%;
    opacity: 0.85;
    animation: sootFloat 15s infinite ease-in-out;
    filter: blur(0.8px) contrast(1.3) drop-shadow(0 2px 4px rgba(0, 0, 0, 0.5));
    box-shadow: 
        0 0 10px rgba(0, 0, 0, 0.8),
        inset 0 0 4px rgba(0, 0, 0, 0.6),
        inset 2px 2px 3px rgba(40, 40, 40, 0.3);
    pointer-events: auto; /* allow clicking each soot */
    cursor: pointer;
}

/* Fuzzy soot texture - multiple layers for realistic fuzz */
.soot-sprite {
    background: 
        radial-gradient(circle at 35% 25%, #3a3a3a 0%, transparent 40%),
        radial-gradient(circle at 65% 30%, #2a2a2a 0%, transparent 45%),
        radial-gradient(circle at 25% 55%, #1a1a1a 0%, transparent 50%),
        radial-gradient(circle at 70% 60%, #252525 0%, transparent 48%),
        radial-gradient(circle at 45% 75%, #0a0a0a 0%, transparent 55%),
        radial-gradient(circle at 50% 50%, #1a1a1a 0%, transparent 65%),
        radial-gradient(circle, #050505 0%, #000000 100%);
    border-radius: 47% 53% 49% 51% / 53% 47% 51% 49%;
}

/* Add fuzzy texture with pseudo-elements for limbs */
.soot-sprite::before,
.soot-sprite::after {
    pointer-events: none;
}

/* Eyes for soot sprites - large, wide-set white eyes with black pupils */
.soot-sprite::before {
    content: '';
    position: absolute;
    width: 9px;
    height: 9px;
    background: 
        radial-gradient(circle at 45% 45%, #000000 0%, #000000 30%, #ffffff 30%, #ffffff 100%);
    border-radius: 50%;
    top: 7px;
    left: 5px;
    animation: blink 4s infinite;
    z-index: 2;
    box-shadow: 
        0 0 3px rgba(255, 255, 255, 0.7),
        inset -1px -1px 1px rgba(0, 0, 0, 0.2);
}

.soot-sprite::after {
    content: '';
    position: absolute;
    width: 9px;
    height: 9px;
    background: 
        radial-gradient(circle at 45% 45%, #000000 0%, #000000 30%, #ffffff 30%, #ffffff 100%);
    border-radius: 50%;
    top: 7px;
    right: 5px;
    animation: blink 4s infinite 0.3s;
    z-index: 2;
    box-shadow: 
        0 0 3px rgba(255, 255, 255, 0.7),
        inset -1px -1px 1px rgba(0, 0, 0, 0.2);
}

/* Wiry, stick-like limbs */
.soot-limbs {
    position: absolute;
    width: 100%;
    height: 100%;
    top: 0;
    left: 0;
    animation: limbsWave 2s infinite ease-in-out;
}

.soot-limbs::before {
    content: '';
    position: absolute;
    width: 1px;
    height: 12px;
    background: linear-gradient(to bottom, #000000 0%, transparent 100%);
    bottom: -8px;
    left: 35%;
    transform-origin: top;
    animation: limbWiggle 1.5s infinite ease-in-out;
}

.soot-limbs::after {
    content: '';
    position: absolute;
    width: 1px;
    height: 12px;
    background: linear-gradient(to bottom, #000000 0%, transparent 100%);
    bottom: -8px;
    right: 35%;
    transform-origin: top;
    animation: limbWiggle 1.5s infinite ease-in-out 0.3s;
}

@keyframes limbWiggle {
    0%, 100% {
        transform: rotate(-5deg);
    }
    50% {
        transform: rotate(5deg);
    }
}

@keyframes limbsWave {
    0%, 100% {
        transform: translateY(0);
    }
    50% {
        transform: translateY(-2px);
    }
}

@keyframes sootFloat {
    0% {
        transform: translateY(100vh) translateX(0) rotate(0deg) scale(1);
        opacity: 0;
        border-radius: 47% 53% 49% 51% / 53% 47% 51% 49%;
    }
    5% {
        opacity: 0.9;
    }
    15% {
        transform: translateY(85vh) translateX(-15px) rotate(45deg) scale(1.08);
        border-radius: 53% 47% 51% 49% / 47% 53% 49% 51%;
    }
    25% {
        border-radius: 52% 48% 48% 52% / 48% 52% 48% 52%;
        transform: translateY(75vh) translateX(20px) rotate(90deg) scale(0.95);
    }
    35% {
        transform: translateY(65vh) translateX(5px) rotate(135deg) scale(1.05);
        border-radius: 49% 51% 53% 47% / 51% 49% 47% 53%;
    }
    50% {
        border-radius: 50% 50% 52% 48% / 52% 48% 50% 50%;
        transform: translateY(50vh) translateX(35px) rotate(180deg) scale(0.92);
    }
    60% {
        transform: translateY(40vh) translateX(15px) rotate(225deg) scale(1.03);
        border-radius: 48% 52% 47% 53% / 53% 47% 52% 48%;
    }
    75% {
        border-radius: 48% 52% 48% 52% / 50% 50% 52% 48%;
        transform: translateY(25vh) translateX(45px) rotate(270deg) scale(1.0);
    }
    85% {
        transform: translateY(15vh) translateX(30px) rotate(315deg) scale(1.06);
        border-radius: 51% 49% 52% 48% / 48% 52% 49% 51%;
    }
    95% {
        opacity: 0.9;
    }
    100% {
        transform: translateY(-100px) translateX(50px) rotate(360deg) scale(1);
        opacity: 0;
        border-radius: 52% 48% 50% 50% / 48% 52% 48% 52%;
    }
}

@keyframes blink {
    0%, 100% { 
        opacity: 1;
        transform: scaleY(1);
    }
    48%, 52% { 
        opacity: 1;
        transform: scaleY(1);
    }
    50% { 
        opacity: 0.2;
        transform: scaleY(0.1);
    }
}

/* Kodama (Tree Spirits) Animation */
.kodama-container {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    pointer-events: none;
    z-index: 1;
}

.kodama {
    position: absolute;
    width: 40px;
    height: 50px;
    background: rgba(255, 255, 255, 0.9);
    border-radius: 20px 20px 15px 15px;
    animation: kodamaShake 4s infinite ease-in-out;
}

.kodama::before {
    content: '';
    position: absolute;
    width: 6px;
    height: 6px;
    background: #333;
    border-radius: 50%;
    top: 15px;
    left: 12px;
    animation: kodamaBlink 5s infinite;
}

.kodama::after {
    content: '';
    position: absolute;
    width: 6px;
    height: 6px;
    background: #333;
    border-radius: 50%;
    top: 15px;
    right: 12px;
    animation: kodamaBlink 5s infinite 0.3s;
}

@keyframes kodamaShake {
    0%, 100% {
        transform: rotate(-5deg);
    }
    50% {
        transform: rotate(5deg);
    }
}

@keyframes kodamaBlink {
    0%, 90%, 100% {
        opacity: 1;
    }
    95% {
        opacity: 0;
    }
}

/* Floating Leaves Animation */
.leaves {
    position: fixed;
    top: -100px;
    left: 0;
    width: 100%;
    height: 100%;
    pointer-events: none;
    z-index: 1;
}

.leaf {
    position: absolute;
    width: 20px;
    height: 20px;
    background: linear-gradient(135deg, #8bc34a 0%, #689f38 100%);
    clip-path: polygon(50% 0%, 100% 50%, 50% 100%, 0% 50%);
    animation: leafFall 12s infinite linear;
    opacity: 0.7;
}

.leaf::before {
    content: '';
    position: absolute;
    width: 2px;
    height: 8px;
    background: #558b2f;
    top: -8px;
    left: 50%;
    transform: translateX(-50%);
}

@keyframes leafFall {
    0% {
        transform: translateY(0) rotate(0deg) translateX(0);
        opacity: 0;
    }
    10% {
        opacity: 0.7;
    }
    90% {
        opacity: 0.7;
    }
    100% {
        transform: translateY(110vh) rotate(720deg) translateX(100px);
        opacity: 0;
    }
}

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

/* Header */
header {
    background: linear-gradient(135deg, var(--primary-green) 0%, var(--light-green) 100%);
    padding: 50px 0;
    text-align: center;
    box-shadow: 0 4px 20px var(--shadow);
    position: relative;
}

.logo {
    font-size: 3.5rem;
    font-weight: 900;
    letter-spacing: 6px;
    color: var(--text-light);
    text-shadow: 2px 2px 4px rgba(0, 0, 0, 0.2);
    margin-bottom: 10px;
}

.tagline {
    color: var(--cream);
    font-size: 1.2rem;
    letter-spacing: 2px;
    font-weight: 300;
}

.back-btn {
    display: inline-block;
    margin-top: 15px;
    padding: 12px 24px;
    background: rgba(255, 255, 255, 0.2);
    border: 2px solid var(--cream);
    color: var(--cream);
    text-decoration: none;
    border-radius: 25px;
    transition: all 0.3s ease;
    font-weight: 600;
}

.back-btn:hover {
    background: var(--cream);
    color: var(--primary-green);
    transform: translateY(-2px);
    box-shadow: 0 5px 15px rgba(0, 0, 0, 0.2);
}

/* Loading */
.loading {
    text-align: center;
    padding: 80px 20px;
}

.spinner {
    border: 4px solid rgba(45, 125, 80, 0.1);
    border-top: 4px solid var(--primary-green);
    border-radius: 50%;
    width: 60px;
    height: 60px;
    animation: spin 1s linear infinite;
    margin: 0 auto 20px;
}

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

/* Films Grid */
.films-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(320px, 1fr));
    gap: 30px;
    padding: 60px 0;
}

.film-card {
    background: var(--card-bg);
    border-radius: 20px;
    overflow: hidden;
    cursor: pointer;
    transition: all 0.4s ease;
    box-shadow: 0 4px 15px var(--shadow);
    position: relative;
}

.film-card::before {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: linear-gradient(135deg, rgba(45, 125, 80, 0.1), rgba(139, 195, 74, 0.1));
    opacity: 0;
    transition: opacity 0.4s ease;
    z-index: 1;
}

.film-card:hover::before {
    opacity: 1;
}

.film-card:hover {
    transform: translateY(-15px) scale(1.02);
    box-shadow: 0 15px 40px rgba(0, 0, 0, 0.2);
}

.film-image {
    width: 100%;
    height: 450px;
    object-fit: cover;
    display: block;
}

.film-content {
    padding: 25px;
    position: relative;
    z-index: 2;
}

.release-year {
    display: inline-block;
    background: var(--primary-green);
    color: var(--text-light);
    padding: 5px 15px;
    border-radius: 20px;
    font-weight: 700;
    font-size: 0.85rem;
    margin-bottom: 12px;
}

.film-card h2 {
    font-size: 1.8rem;
    margin-bottom: 8px;
    color: var(--primary-green);
}

.original-title {
    font-size: 0.95rem;
    color: var(--warm-brown);
    font-style: italic;
    margin-bottom: 15px;
}

.film-info {
    display: flex;
    flex-direction: column;
    gap: 10px;
    margin: 20px 0;
}

.info-item {
    display: flex;
    align-items: center;
    gap: 10px;
    color: var(--text-dark);
    font-size: 0.95rem;
}

.info-label {
    color: var(--primary-green);
    font-weight: 600;
}

.rt-score {
    display: inline-flex;
    align-items: center;
    gap: 5px;
    background: var(--accent-pink);
    color: white;
    padding: 5px 12px;
    border-radius: 15px;
    font-weight: 600;
    font-size: 0.9rem;
}

.description {
    color: #555;
    font-size: 0.95rem;
    line-height: 1.6;
    margin-top: 15px;
    display: -webkit-box;
    -webkit-line-clamp: 4;
    -webkit-box-orient: vertical;
    overflow: hidden;
}

/* Film Detail Page */
.film-detail {
    padding: 40px 0;
}

.detail-hero {
    position: relative;
    border-radius: 20px;
    overflow: hidden;
    margin-bottom: 40px;
    box-shadow: 0 10px 40px var(--shadow);
}

.detail-banner {
    width: 100%;
    height: 400px;
    object-fit: cover;
}

.detail-overlay {
    position: absolute;
    bottom: 0;
    left: 0;
    right: 0;
    background: linear-gradient(to top, rgba(0,0,0,0.9) 0%, transparent 100%);
    padding: 40px;
    color: white;
}

.detail-header {
    background: var(--card-bg);
    border-radius: 20px;
    padding: 40px;
    margin-bottom: 30px;
    box-shadow: 0 4px 20px var(--shadow);
}

.detail-header h2 {
    font-size: 3rem;
    color: var(--primary-green);
    margin-bottom: 10px;
}

.detail-original-title {
    font-size: 1.3rem;
    color: var(--warm-brown);
    font-style: italic;
    margin-bottom: 30px;
}


.detail-info {
    background: var(--card-bg);
    border-radius: 20px;
    padding: 40px;
    margin-bottom: 30px;
    box-shadow: 0 4px 20px var(--shadow);
}

.info-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
    gap: 25px;
    margin: 30px 0;
}

.info-box {
    background: linear-gradient(135deg, #e8f5e9, #f1f8e9);
    padding: 20px;
    border-radius: 15px;
    text-align: center;
    border: 2px solid var(--light-green);
}

.info-box-label {
    color: var(--primary-green);
    font-weight: 700;
    font-size: 0.85rem;
    text-transform: uppercase;
    letter-spacing: 1px;
    margin-bottom: 8px;
}

.info-box-value {
    color: var(--text-dark);
    font-size: 1.2rem;
    font-weight: 600;
}

.detail-description {
    background: linear-gradient(135deg, #fff9e6, #fffef0);
    padding: 30px;
    border-left: 5px solid var(--primary-green);
    margin: 30px 0;
    line-height: 1.9;
    color: var(--text-dark);
    border-radius: 10px;
    font-size: 1.05rem;
}

/* Characters Section */
.characters-section,
.additional-section {
    margin-top: 40px;
    background: var(--card-bg);
    border-radius: 20px;
    padding: 40px;
    box-shadow: 0 4px 20px var(--shadow);
}

.section-title {
    font-size: 2.2rem;
    color: var(--primary-green);
    margin-bottom: 30px;
    text-align: center;
    position: relative;
    padding-bottom: 15px;
}

.section-title::after {
    content: '';
    position: absolute;
    bottom: 0;
    left: 50%;
    transform: translateX(-50%);
    width: 100px;
    height: 3px;
    background: var(--light-green);
    border-radius: 3px;
}

.characters-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
    gap: 25px;
}

.character-card {
    background: linear-gradient(135deg, #e8f5e9, #ffffff);
    border: 2px solid var(--light-green);
    border-radius: 15px;
    padding: 25px;
    transition: all 0.3s ease;
}

.character-card:hover {
    transform: translateY(-5px);
    box-shadow: 0 8px 25px var(--shadow);
    border-color: var(--primary-green);
}

.character-card h4 {
    color: var(--primary-green);
    font-size: 1.4rem;
    margin-bottom: 15px;
    padding-bottom: 10px;
    border-bottom: 2px solid var(--light-green);
}

.character-avatar {
    width: 80px;
    height: 80px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 2rem;
    font-weight: 700;
    color: white;
    margin: 0 auto 15px;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.15);
}

.avatar-female {
    background: linear-gradient(135deg, #ff9a9e 0%, #fecfef 100%);
}

.avatar-male {
    background: linear-gradient(135deg, #a1c4fd 0%, #c2e9fb 100%);
}

.avatar-neutral {
    background: linear-gradient(135deg, #ffeaa7 0%, #fdcb6e 100%);
}

.character-details {
    display: flex;
    flex-direction: column;
    gap: 10px;
    font-size: 0.95rem;
}

.character-detail-item {
    display: flex;
    justify-content: space-between;
    padding: 8px 0;
}

.detail-label {
    color: var(--warm-brown);
    font-weight: 600;
}

.detail-value {
    color: var(--text-dark);
    text-align: right;
}

.species-link {
    color: var(--primary-green);
    text-decoration: none;
    font-weight: 600;
    border-bottom: 2px solid transparent;
    transition: all 0.3s ease;
}

.species-link:hover {
    color: var(--light-green);
    border-bottom-color: var(--light-green);
}

/* Species Hero Section */
.species-hero {
    border-radius: 20px;
    padding: 80px 40px;
    margin-bottom: 40px;
    text-align: center;
    box-shadow: 0 10px 40px var(--shadow);
    position: relative;
    overflow: hidden;
}

.species-hero::before {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: url('data:image/svg+xml,<svg width="100" height="100" xmlns="http://www.w3.org/2000/svg"><circle cx="50" cy="50" r="40" fill="rgba(255,255,255,0.1)"/></svg>') repeat;
    opacity: 0.3;
    z-index: 1;
}

.species-hero-content {
    position: relative;
    z-index: 2;
}

.species-hero-mammal {
    background: linear-gradient(135deg, #8ec5fc 0%, #e0c3fc 100%);
}

.species-hero-spirit {
    background: linear-gradient(135deg, #ffecd2 0%, #fcb69f 100%);
}

.species-hero-bird {
    background: linear-gradient(135deg, #a8edea 0%, #fed6e3 100%);
}

.species-hero-default {
    background: linear-gradient(135deg, var(--primary-green) 0%, var(--light-green) 100%);
}

.species-hero-title {
    font-size: 3.5rem;
    color: white;
    text-shadow: 2px 2px 8px rgba(0, 0, 0, 0.2);
    margin-bottom: 15px;
    font-weight: 900;
}

.species-hero-subtitle {
    font-size: 1.5rem;
    color: rgba(255, 255, 255, 0.95);
    text-shadow: 1px 1px 4px rgba(0, 0, 0, 0.2);
    font-weight: 300;
    letter-spacing: 2px;
}

/* Additional Info Section */
.info-section {
    margin-bottom: 35px;
}

.info-section:last-child {
    margin-bottom: 0;
}

.info-section h4 {
    color: var(--primary-green);
    font-size: 1.5rem;
    margin-bottom: 20px;
    padding-left: 15px;
    border-left: 4px solid var(--light-green);
}

.info-list {
    display: flex;
    flex-wrap: wrap;
    gap: 12px;
}

.info-tag {
    background: linear-gradient(135deg, var(--primary-green), var(--light-green));
    color: white;
    padding: 10px 20px;
    border-radius: 25px;
    font-size: 0.95rem;
    font-weight: 500;
    box-shadow: 0 3px 10px rgba(45, 125, 80, 0.3);
    transition: all 0.3s ease;
}

.info-tag:hover {
    transform: translateY(-2px);
    box-shadow: 0 5px 15px rgba(45, 125, 80, 0.4);
}

/* Footer */
footer {
    background: linear-gradient(135deg, var(--primary-green) 0%, var(--light-green) 100%);
    padding: 30px 0;
    margin-top: 80px;
    text-align: center;
    box-shadow: 0 -4px 20px var(--shadow);
}

footer p {
    color: var(--cream);
    margin: 5px 0;
}

footer a {
    color: white;
    text-decoration: none;
    transition: color 0.3s ease;
    font-weight: 600;
}

footer a:hover {
    color: var(--accent-pink);
}

/* Responsive Design */
@media (max-width: 768px) {
    .logo {
        font-size: 2.5rem;
        letter-spacing: 3px;
    }
    
    .tagline {
        font-size: 1rem;
    }
    
    .films-grid {
        grid-template-columns: 1fr;
        padding: 40px 0;
    }
    
    .film-image {
        height: 400px;
    }
    
    .detail-header h2 {
        font-size: 2rem;
    }
    
    .detail-banner {
        height: 250px;
    }
    
    .detail-info,
    .characters-section,
    .additional-section {
        padding: 25px;
    }
    
    .characters-grid {
        grid-template-columns: 1fr;
    }
    
    .info-grid {
        grid-template-columns: 1fr;
    }
}

@media (max-width: 480px) {
    .logo {
        font-size: 2rem;
        letter-spacing: 2px;
    }
    
    header {
        padding: 30px 0;
    }
    
    .film-content {
        padding: 20px;
    }
    
    .film-card h2 {
        font-size: 1.5rem;
    }
    
    .film-image {
        height: 350px;
    }
    
    .species-hero {
        padding: 50px 25px;
    }
    
    .species-hero-title {
        font-size: 2rem;
    }
    
    .species-hero-subtitle {
        font-size: 1rem;
    }
}

/* Loading state for dynamic content */
.loading-item {
    background: linear-gradient(90deg, #f0f0f0 25%, #e0e0e0 50%, #f0f0f0 75%);
    background-size: 200% 100%;
    animation: shimmer 1.5s infinite;
    border-radius: 10px;
    min-height: 100px;
}

@keyframes shimmer {
    0% { background-position: 200% 0; }
    100% { background-position: -200% 0; }
}
