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

html {
    overflow-x: hidden;
}

body {
    background: #0a0806;
    background-image: radial-gradient(ellipse at 50% 50%, #1a1410 0%, #0a0806 70%);
    color: #e0d4c0;
    font-family: 'Source Serif 4', serif;
    font-weight: 400;
    font-size: clamp(0.9rem, 1.1vw, 1rem);
    line-height: 1.8;
    overflow-x: hidden;
    position: relative;
    min-height: 100vh;
}

/* Noise texture overlay */
body::before {
    content: '';
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    pointer-events: none;
    z-index: 0;
    opacity: 0.04;
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='200' height='200'%3E%3Cfilter id='n'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='0.8' numOctaves='4'/%3E%3C/filter%3E%3Crect width='200' height='200' filter='url(%23n)'/%3E%3C/svg%3E");
    background-size: 200px 200px;
}

/* Gold thread connections */
.gold-threads {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    pointer-events: none;
    z-index: 2;
}

.thread {
    stroke-dasharray: 400;
    stroke-dashoffset: 400;
    transition: stroke-dashoffset 2s ease-in-out;
}

.thread.drawn {
    stroke-dashoffset: 0;
}

/* Forge Glow */
.forge-glow {
    position: fixed;
    bottom: -200px;
    left: 50%;
    transform: translateX(-50%);
    width: 600px;
    height: 600px;
    border-radius: 50%;
    background: radial-gradient(circle, rgba(184, 150, 10, 0.08) 0%, transparent 70%);
    pointer-events: none;
    z-index: 1;
    opacity: 0;
    transition: opacity 1s ease;
}

.forge-glow.active {
    opacity: 1;
}

.forge-glow.bright {
    background: radial-gradient(circle, rgba(184, 150, 10, 0.12) 0%, transparent 70%);
}

/* Brass Motifs */
.brass-motif {
    position: absolute;
    pointer-events: none;
    z-index: 1;
}

.motif-1 {
    top: 45vh;
    right: 5vw;
}

.motif-2 {
    top: 120vh;
    left: 3vw;
}

/* Door Section */
.door-section {
    min-height: 100vh;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    position: relative;
    z-index: 5;
}

.door-title {
    font-family: 'Libre Baskerville', serif;
    font-weight: 400;
    font-style: italic;
    font-size: clamp(2rem, 4vw, 3rem);
    color: #b8960a;
    opacity: 0;
    animation: doorFade 1.5s ease-out 1s forwards;
}

.door-japanese {
    font-family: 'Libre Baskerville', serif;
    font-weight: 700;
    font-size: clamp(1.5rem, 3vw, 2rem);
    color: #d4b020;
    margin-top: 12px;
    opacity: 0;
    animation: doorFade 1.2s ease-out 1.8s forwards;
}

.door-subtitle {
    font-family: 'JetBrains Mono', monospace;
    font-weight: 400;
    font-size: 0.7rem;
    letter-spacing: 0.08em;
    text-transform: uppercase;
    color: rgba(184, 150, 10, 0.5);
    margin-top: 20px;
    opacity: 0;
    animation: doorFade 1s ease-out 2.5s forwards;
}

@keyframes doorFade {
    from { opacity: 0; transform: translateY(8px); }
    to { opacity: 1; transform: translateY(0); }
}

/* Armory Sections */
.armory-section {
    position: relative;
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
    gap: 30px;
    padding: 60px 40px;
    max-width: 1100px;
    margin: 0 auto;
    z-index: 5;
}

.defensive-section {
    gap: 50px;
}

.strategy-section {
    display: block;
    padding: 60px 40px;
}

/* Parchment Fragment */
.fragment {
    position: relative;
    background: #f0e8d4;
    padding: 30px 24px;
    transform: rotate(var(--rot, 0deg));
    clip-path: var(--clip);
    box-shadow: 0 4px 16px rgba(20, 12, 4, 0.6);
    color: #2a2218;
    opacity: 0;
    transition: opacity 0.6s ease-out, transform 0.6s ease-out;
}

.fragment.revealed {
    opacity: 1;
}

/* Fragment paper noise */
.fragment::before {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    opacity: 0.05;
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='100' height='100'%3E%3Cfilter id='n'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='1.2' numOctaves='3'/%3E%3C/filter%3E%3Crect width='100' height='100' filter='url(%23n)'/%3E%3C/svg%3E");
    background-size: 100px 100px;
    pointer-events: none;
}

/* Burn marks on some corners */
.fragment:nth-child(odd)::after {
    content: '';
    position: absolute;
    bottom: 0;
    right: 0;
    width: 60px;
    height: 60px;
    background: radial-gradient(circle at 100% 100%, rgba(60, 30, 0, 0.3) 0%, transparent 70%);
    pointer-events: none;
}

/* Fragment sizes */
.fragment-sm {
    max-width: 320px;
}

.fragment-xs {
    max-width: 260px;
}

.fragment-lg {
    max-width: 500px;
}

.fragment-xl {
    max-width: 900px;
    margin: 0 auto;
}

/* Fragment watermark */
.fragment-watermark {
    position: absolute;
    top: 50%;
    left: 50%;
    width: 120px;
    height: 120px;
    transform: translate(-50%, -50%);
    border-radius: 40% 60% 55% 45% / 55% 40% 60% 45%;
    background: rgba(184, 150, 10, 0.06);
    pointer-events: none;
}

/* Wax Seal */
.wax-seal {
    position: absolute;
    top: 12px;
    right: 16px;
    width: 40px;
    height: 40px;
    border-radius: 50%;
    background: #8a4a20;
    border: 2px solid #b8960a;
    display: flex;
    align-items: center;
    justify-content: center;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.4);
    transform: scale(1.2);
    transition: transform 0.4s cubic-bezier(0.175, 0.885, 0.32, 1.275);
    z-index: 3;
}

.fragment.revealed .wax-seal {
    transform: scale(1);
}

.wax-seal span {
    font-family: 'Libre Baskerville', serif;
    font-weight: 700;
    font-size: 0.85rem;
    color: #d4b020;
}

/* Fragment Code */
.fragment-code {
    display: block;
    font-family: 'JetBrains Mono', monospace;
    font-weight: 400;
    font-size: 0.7rem;
    letter-spacing: 0.08em;
    text-transform: uppercase;
    color: #b8960a;
    margin-bottom: 12px;
}

/* Fragment Title */
.fragment-title {
    font-family: 'Libre Baskerville', serif;
    font-weight: 700;
    font-size: clamp(1.4rem, 2.5vw, 2rem);
    color: #2a2218;
    margin-bottom: 12px;
    line-height: 1.3;
}

/* Fragment Body */
.fragment-body {
    font-family: 'Source Serif 4', serif;
    font-weight: 400;
    color: #2a2218;
    line-height: 1.8;
}

/* Strategy Diagram */
.strategy-diagram {
    margin: 20px 0;
    overflow-x: auto;
}

.strategy-svg {
    width: 100%;
    max-width: 600px;
    height: auto;
}

/* Closing Section */
.closing-section {
    min-height: 50vh;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    text-align: center;
    padding: 60px 20px;
    position: relative;
    z-index: 5;
}

.closing-text {
    font-family: 'Libre Baskerville', serif;
    font-weight: 400;
    font-style: italic;
    font-size: clamp(1.1rem, 2vw, 1.5rem);
    color: #b8960a;
    line-height: 2;
    opacity: 0;
    transition: opacity 1s ease;
}

.closing-text.visible {
    opacity: 1;
}

.closing-kanji {
    font-family: 'Libre Baskerville', serif;
    font-weight: 700;
    font-size: 1.5rem;
    color: #d4b020;
    margin-top: 30px;
    opacity: 0;
    transition: opacity 1s ease 0.5s;
}

.closing-text.visible ~ .closing-kanji {
    opacity: 0.6;
}

/* Responsive */
@media (max-width: 768px) {
    .armory-section {
        grid-template-columns: 1fr;
        padding: 40px 20px;
    }

    .fragment {
        max-width: 100%;
        transform: rotate(0deg);
    }

    .fragment-sm,
    .fragment-xs,
    .fragment-lg,
    .fragment-xl {
        max-width: 100%;
    }

    .brass-motif {
        display: none;
    }
}
