
@import url('https://fonts.googleapis.com/css2?family=Vazirmatn:wght@300;400;500;600;700;800&display=swap');

:root {
    --night: #100e18;
    --gold: #c6a56b;
    --gold-light: #e6c88f;
    --stone: #29242b;
    --text: #eee5d6;
}

* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

html {
    min-height: 100%;
    background: var(--night);
}

body {
    min-height: 100vh;
    font-family: 'Vazirmatn', sans-serif;
    background: var(--night);
    color: var(--text);
    overflow-x: hidden;
}

button,
a {
    font: inherit;
}

.kingdom {
    position: relative;
    min-height: 100vh;
    min-height: 100svh;
    display: flex;
    align-items: center;
    justify-content: center;
    flex-direction: column;
    isolation: isolate;
    overflow: hidden;
    padding: 50px 20px 38px;
    background:
        linear-gradient(180deg,
            #11101b 0%,
            #191725 43%,
            #211d27 72%,
            #100e18 100%);
}

/* SKY */

.sky {
    position: absolute;
    inset: 0;
    z-index: -3;
    overflow: hidden;
}

.moon {
    position: absolute;
    width: 145px;
    height: 145px;
    top: 8%;
    left: 16%;
    border-radius: 50%;
    background:
        radial-gradient(circle at 35% 35%,
            #f5e8c9 0%,
            #d9c69e 55%,
            #a99473 100%);
    box-shadow:
        0 0 35px rgba(227, 205, 159, .18),
        0 0 100px rgba(227, 205, 159, .12);
    opacity: .9;
}

.moon::before,
.moon::after {
    content: "";
    position: absolute;
    border-radius: 50%;
    background: rgba(119, 100, 76, .12);
}

.moon::before {
    width: 26px;
    height: 19px;
    top: 31px;
    left: 34px;
    transform: rotate(-25deg);
}

.moon::after {
    width: 17px;
    height: 17px;
    right: 29px;
    bottom: 35px;
}

.moon-glow {
    position: absolute;
    width: 320px;
    height: 320px;
    top: calc(8% - 87px);
    left: calc(16% - 87px);
    border-radius: 50%;
    background: rgba(204, 180, 133, .055);
    filter: blur(35px);
}

.stars {
    position: absolute;
    inset: 0;
}

.star {
    position: absolute;
    width: 2px;
    height: 2px;
    border-radius: 50%;
    background: #f5e7ca;
    opacity: .65;
    animation: twinkle 3s ease-in-out infinite alternate;
}

.star:nth-child(3n) {
    width: 3px;
    height: 3px;
}

.star:nth-child(4n) {
    animation-duration: 4.5s;
}

@keyframes twinkle {
    from { opacity: .2; transform: scale(.8); }
    to { opacity: .9; transform: scale(1.3); }
}

/* CLOUDS */

.cloud {
    position: absolute;
    width: 340px;
    height: 70px;
    border-radius: 50%;
    background: rgba(72, 66, 80, .18);
    filter: blur(22px);
    animation: cloud-drift 32s linear infinite alternate;
}

.cloud-one {
    top: 26%;
    left: -70px;
}

.cloud-two {
    top: 40%;
    right: -100px;
    width: 440px;
    animation-duration: 42s;
    animation-direction: alternate-reverse;
}

.cloud-three {
    top: 15%;
    left: 48%;
    width: 250px;
    opacity: .5;
    animation-duration: 37s;
}

@keyframes cloud-drift {
    from { transform: translateX(-35px); }
    to { transform: translateX(70px); }
}

/* MOUNTAINS */

.mountain {
    position: absolute;
    bottom: 19%;
    width: 0;
    height: 0;
    border-left: 260px solid transparent;
    border-right: 260px solid transparent;
    border-bottom: 300px solid #211e2a;
    opacity: .75;
}

.mountain::after {
    content: "";
    position: absolute;
    top: 80px;
    left: -110px;
    width: 0;
    height: 0;
    border-left: 110px solid transparent;
    border-right: 110px solid transparent;
    border-bottom: 180px solid rgba(10, 10, 17, .32);
}

.mountain-back {
    left: -90px;
    transform: scale(.85);
    border-bottom-color: #25212d;
}

.mountain-front {
    right: -100px;
    transform: scale(1.1);
    border-bottom-color: #1b1924;
}

/* SCENE */

.scene {
    position: absolute;
    inset: 0;
    z-index: -2;
    overflow: hidden;
    pointer-events: none;
}

/* CASTLE */

.castle-area {
    position: absolute;
    width: 440px;
    height: 370px;
    top: 17%;
    left: 50%;
    transform: translateX(-50%);
    z-index: 2;
}

.castle-glow {
    position: absolute;
    width: 100%;
    height: 100%;
    top: 15%;
    background: radial-gradient(ellipse,
        rgba(197, 155, 91, .12),
        transparent 68%);
    filter: blur(24px);
}

.castle {
    position: absolute;
    width: 100%;
    height: 100%;
    bottom: 0;
}

.castle-main {
    position: absolute;
    width: 240px;
    height: 175px;
    left: 100px;
    bottom: 0;
    background: linear-gradient(90deg, #29242c, #48404a 50%, #29242c);
    clip-path: polygon(8% 0, 92% 0, 100% 100%, 0 100%);
    border-top: 2px solid #655663;
}

.castle-main::before {
    content: "";
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 12px;
    background: repeating-linear-gradient(
        90deg,
        #3b333e 0 22px,
        #625462 22px 30px
    );
}

.castle-window {
    position: absolute;
    width: 15px;
    height: 30px;
    border-radius: 10px 10px 0 0;
    background: #d9a85e;
    box-shadow: 0 0 13px rgba(241, 177, 83, .7);
    animation: window-glow 4s ease-in-out infinite alternate;
}

.window-one { top: 55px; left: 44px; }
.window-two { top: 55px; right: 44px; animation-delay: 1s; }
.window-three { top: 100px; left: 82px; animation-delay: 2s; }
.window-four { top: 100px; right: 82px; animation-delay: .5s; }

.castle-door {
    position: absolute;
    bottom: 0;
    left: 50%;
    width: 38px;
    height: 65px;
    transform: translateX(-50%);
    border-radius: 22px 22px 0 0;
    background: #17141c;
    border: 2px solid #65515a;
}

@keyframes window-glow {
    from { opacity: .65; box-shadow: 0 0 8px rgba(241, 177, 83, .4); }
    to { opacity: 1; box-shadow: 0 0 17px rgba(241, 177, 83, .85); }
}

/* TOWERS */

.castle-tower {
    position: absolute;
    bottom: 70px;
    width: 78px;
    height: 190px;
    background: linear-gradient(90deg, #28232b, #514653 50%, #29242c);
    border-top: 3px solid #685767;
}

.tower-left { left: 40px; height: 170px; }

.tower-center {
    left: 181px;
    bottom: 155px;
    width: 78px;
    height: 190px;
}

.tower-right { right: 40px; height: 170px; }

.tower-roof {
    position: absolute;
    top: -62px;
    left: -12px;
    width: 0;
    height: 0;
    border-left: 51px solid transparent;
    border-right: 51px solid transparent;
    border-bottom: 65px solid #302735;
}

.tower-roof::after {
    content: "";
    position: absolute;
    left: -43px;
    top: 15px;
    width: 86px;
    height: 4px;
    background: #756073;
    transform: rotate(-1deg);
}

.tower-window {
    position: absolute;
    top: 42px;
    left: 50%;
    width: 15px;
    height: 29px;
    transform: translateX(-50%);
    border-radius: 10px 10px 0 0;
    background: #dca95d;
    box-shadow: 0 0 14px rgba(239, 176, 87, .75);
}

.tower-flag {
    position: absolute;
    top: -82px;
    left: 50%;
    width: 2px;
    height: 27px;
    background: #9a8b8c;
}

.tower-flag span {
    position: absolute;
    top: 1px;
    left: 1px;
    width: 30px;
    height: 18px;
    background: #773c43;
    clip-path: polygon(0 0, 100% 0, 82% 50%, 100% 100%, 0 100%);
    transform-origin: left center;
    animation: flag-wave 2.5s ease-in-out infinite alternate;
}

@keyframes flag-wave {
    from { transform: skewY(3deg) scaleX(1); }
    to { transform: skewY(-8deg) scaleX(.88); }
}

.castle-wall {
    position: absolute;
    bottom: 0;
    width: 70px;
    height: 70px;
    background: #39313b;
    border-top: 5px solid #5b4d5c;
}

.wall-left { left: 0; }
.wall-right { right: 0; }

/* RAVENS */

.ravens {
    position: absolute;
    top: 23%;
    left: 0;
    width: 100%;
    height: 100px;
}

.raven {
    position: absolute;
    color: #090910;
    font-size: 28px;
    animation: raven-flight 8s ease-in-out infinite;
}

.raven-one { left: 23%; top: 10px; }
.raven-two { left: 72%; top: 30px; animation-delay: 2s; font-size: 22px; }
.raven-three { left: 80%; top: 0; animation-delay: 4s; font-size: 18px; }

@keyframes raven-flight {
    0%, 100% { transform: translate(0, 0) rotate(-10deg); }
    50% { transform: translate(35px, -15px) rotate(12deg); }
}

/* BRIDGE */

.bridge-area {
    position: absolute;
    top: 48%;
    bottom: auto;
    left: 50%;
    width: min(760px, 95vw);
    height: 300px;
    transform: translateX(-50%);
    z-index: 4;
}

.bridge {
    position: absolute;
    inset: 0;
}

.bridge-road {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 65px;
    background:
        repeating-linear-gradient(
            90deg,
            transparent 0 47px,
            rgba(20, 16, 23, .55) 47px 50px
        ),
        linear-gradient(
            180deg,
            #81717b 0%,
            #5d505d 25%,
            #39313d 100%
        );
    clip-path: polygon(0 0, 100% 0, 88% 100%, 12% 100%);
    border-top: 3px solid #a08c91;
    box-shadow: 0 12px 20px rgba(0, 0, 0, .5);
}

.bridge-arch {
    position: absolute;
    top: 43px;
    left: 17%;
    width: 66%;
    height: 190px;
    border: 24px solid #49404b;
    border-top: 0;
    border-radius: 0 0 50% 50%;
    box-shadow:
        inset 0 -15px 20px rgba(0, 0, 0, .4),
        0 12px 15px rgba(0, 0, 0, .3);
}

.bridge-rail {
    position: absolute;
    top: 8px;
    width: 100%;
    height: 55px;
    border: none;
    border-top: 8px solid #81717b;
    border-bottom: 5px solid #39313d;
    background: repeating-linear-gradient(
        90deg,
        #514652 0 42px,
        #716170 42px 48px
    );
    clip-path: polygon(0 0, 100% 0, 88% 100%, 12% 100%);
}

.rail-left {
    transform: translateY(-15px) scaleY(.7);
    opacity: .95;
}

.rail-right {
    transform: translateY(18px) scaleY(.7);
    opacity: .55;
}

.bridge-stones {
    position: absolute;
    top: 55px;
    left: 7%;
    width: 86%;
    height: 14px;
    background: repeating-linear-gradient(
        90deg,
        transparent 0 37px,
        rgba(15, 13, 19, .7) 37px 40px
    );
}

.bridge::before,
.bridge::after {
    content: "";
    position: absolute;
    top: 55px;
    width: 42px;
    height: 145px;
    background: linear-gradient(
        90deg,
        #302a35,
        #635563,
        #38313d
    );
    border-left: 2px solid #786875;
    border-right: 2px solid #211d27;
}

.bridge::before { left: 17%; }
.bridge::after { right: 17%; }

/* RESPONSIVE BRIDGE */

@media (max-width: 700px) {
    .bridge-area {
        top: 48%;
        bottom: auto;
        width: 115vw;
        height: 230px;
        transform: translateX(-50%) scale(.85);
        transform-origin: top center;
    }
}

@media (max-width: 390px) {
    .bridge-area {
        top: 49%;
        bottom: auto;
        transform: translateX(-50%) scale(.68);
    }
}

/* FOG */

.valley-fog {
    position: absolute;
    width: 700px;
    height: 90px;
    border-radius: 50%;
    background: rgba(163, 151, 164, .12);
    filter: blur(30px);
    animation: fog-move 18s ease-in-out infinite alternate;
}

.fog-one { bottom: 23%; left: -150px; }
.fog-two { bottom: 17%; right: -170px; animation-delay: 3s; }
.fog-three { bottom: 30%; left: 35%; width: 450px; opacity: .6; animation-delay: 6s; }

@keyframes fog-move {
    from { transform: translateX(-50px); opacity: .3; }
    to { transform: translateX(90px); opacity: .8; }
}

/* FOREGROUND */

.foreground {
    position: absolute;
    bottom: 0;
    width: 100%;
    height: 19%;
    background: linear-gradient(180deg, #25202a, #100e18);
    border-top: 2px solid rgba(124, 105, 119, .22);
}

.torch {
    position: absolute;
    top: -72px;
    width: 8px;
    height: 80px;
    background: linear-gradient(90deg, #4a3431, #8d6b50, #392b2a);
    border-radius: 3px;
}

.torch-left { left: 16%; }
.torch-right { right: 16%; }

.torch-flame {
    position: absolute;
    top: -22px;
    left: -8px;
    width: 24px;
    height: 32px;
    border-radius: 50% 50% 45% 45%;
    background: radial-gradient(ellipse at 50% 70%,
        #fff1ae 0%,
        #f3a64e 35%,
        #c45a35 68%,
        transparent 72%);
    filter: drop-shadow(0 0 13px rgba(242, 145, 63, .8));
    transform-origin: center bottom;
    animation: flame .16s ease-in-out infinite alternate;
}

@keyframes flame {
    from { transform: rotate(-5deg) scale(.9, 1); }
    to { transform: rotate(6deg) scale(1.05, 1.1); }
}

.grass {
    position: absolute;
    bottom: 0;
    width: 150px;
    height: 50px;
    opacity: .5;
    background: repeating-linear-gradient(
        80deg,
        transparent 0 8px,
        #35303a 8px 10px,
        transparent 10px 15px
    );
}

.grass-one { left: 5%; }
.grass-two { right: 7%; transform: scale(1.2); }
.grass-three { left: 42%; transform: scale(.7); }

/* CONTENT */

.content {
    position: relative;
    z-index: 10;
    width: min(100%, 650px);
    margin-top: auto;
    margin-bottom: auto;
    padding-top: 340px;
    text-align: center;
}

.error-number {
    font-size: clamp(76px, 11vw, 118px);
    line-height: 1;
    font-weight: 800;
    letter-spacing: 8px;
    color: transparent;
    background: linear-gradient(180deg, #e8c98e, #98764e 75%, #6e594d);
    background-clip: text;
    -webkit-background-clip: text;
    filter: drop-shadow(0 7px 18px rgba(0, 0, 0, .5));
}

.divider {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 15px;
    margin: 17px auto 12px;
}

.divider span {
    width: 65px;
    height: 1px;
    background: linear-gradient(90deg, transparent, #a88a61);
}

.divider span:last-child {
    transform: rotate(180deg);
}

.divider i {
    color: var(--gold-light);
    font-style: normal;
    font-size: 15px;
}

.content h1 {
    font-size: clamp(24px, 4vw, 34px);
    font-weight: 600;
    color: #f0e4cf;
    text-shadow: 0 3px 15px rgba(0, 0, 0, .8);
    margin-bottom: 12px;
}

.description {
    color: #e2d2b9;
    font-size: 16px;
    font-weight: 400;
    margin-bottom: 7px;
    text-shadow: 0 2px 8px #000;
}

.sub-description {
    color: #a99ba0;
    font-size: 13px;
    font-weight: 300;
    text-shadow: 0 2px 8px #000;
}

/* BUTTONS */

.actions {
    display: flex;
    justify-content: center;
    align-items: center;
    flex-wrap: wrap;
    gap: 13px;
    margin-top: 30px;
}

.action-button {
    min-height: 48px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 9px;
    padding: 0 22px;
    border-radius: 5px;
    text-decoration: none;
    cursor: pointer;
    font-size: 13px;
    transition: .3s ease;
}

.home-button {
    color: #211a1b;
    background: linear-gradient(135deg, #e1c18a, #b58d5c);
    border: 1px solid rgba(255, 230, 180, .35);
    box-shadow: 0 5px 20px rgba(160, 117, 63, .15);
}

.home-button:hover {
    transform: translateY(-3px);
    box-shadow: 0 8px 25px rgba(190, 145, 83, .3);
    background: linear-gradient(135deg, #f0d6a6, #c69c68);
}

.back-button {
    color: #d6c8b6;
    background: rgba(35, 29, 39, .7);
    border: 1px solid rgba(197, 165, 107, .35);
}

.back-button:hover {
    color: #f3d9ac;
    border-color: #c6a56b;
    background: rgba(68, 54, 60, .8);
    transform: translateY(-3px);
}

.button-icon {
    font-size: 20px;
    line-height: 1;
}

.footer-note {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 12px;
    margin-top: 36px;
    color: rgba(207, 185, 151, .5);
    font-size: 9px;
    letter-spacing: 3px;
    direction: ltr;
}

.footer-note span {
    width: 24px;
    height: 1px;
    background: rgba(197, 165, 107, .3);
}

/* VIGNETTE */

.vignette {
    position: absolute;
    inset: 0;
    z-index: 8;
    pointer-events: none;
    background:
        linear-gradient(90deg, rgba(8, 7, 13, .2), transparent 25%, transparent 75%, rgba(8, 7, 13, .2)),
        linear-gradient(0deg, rgba(8, 7, 13, .48), transparent 35%, transparent 75%, rgba(8, 7, 13, .18));
}

/* RESPONSIVE */

@media (min-width: 1500px) {
    .castle-area {
        transform: translateX(-50%) scale(1.12);
        transform-origin: bottom center;
    }

    .bridge-area {
        transform: translateX(-50%) scale(1.12);
    }
}

@media (max-width: 700px) {
    .kingdom {
        padding: 30px 16px 28px;
        min-height: 100svh;
    }

    .moon {
        width: 95px;
        height: 95px;
        top: 7%;
        left: 9%;
    }

    .moon-glow {
        width: 220px;
        height: 220px;
        top: calc(7% - 62px);
        left: calc(9% - 62px);
    }

    .castle-area {
        top: 19%;
        transform: translateX(-50%) scale(.73);
        transform-origin: top center;
    }

    .bridge-area {
        top: 48%;
        bottom: auto;
        transform: translateX(-50%) scale(.7);
        transform-origin: top center;
    }

    .ravens {
        top: 25%;
    }

    .raven-one { left: 12%; }
    .raven-two { left: 80%; }
    .raven-three { left: 87%; }

    .content {
        padding-top: 275px;
        padding-bottom: 10px;
    }

    .error-number {
        font-size: clamp(72px, 18vw, 100px);
    }

    .content h1 {
        font-size: 25px;
    }

    .description {
        font-size: 14px;
    }

    .sub-description {
        font-size: 12px;
    }

    .actions {
        gap: 10px;
        margin-top: 24px;
    }

    .action-button {
        min-height: 45px;
        padding: 0 16px;
        font-size: 12px;
    }

    .footer-note {
        margin-top: 27px;
        font-size: 8px;
    }

    .foreground {
        height: 16%;
    }
}

@media (max-width: 390px) {
    .castle-area {
        top: 18%;
        transform: translateX(-50%) scale(.62);
    }

    .bridge-area {
        top: 49%;
        bottom: auto;
        transform: translateX(-50%) scale(.58);
    }

    .content {
        padding-top: 250px;
    }

    .content h1 {
        font-size: 22px;
    }

    .actions {
        flex-direction: column;
        width: 100%;
    }

    .action-button {
        width: min(100%, 260px);
    }

    .footer-note {
        letter-spacing: 2px;
    }
}

@media (max-height: 700px) and (min-width: 701px) {
    .kingdom {
        padding-top: 20px;
        padding-bottom: 20px;
    }

    .castle-area {
        top: 10%;
        transform: translateX(-50%) scale(.75);
        transform-origin: top center;
    }

    .bridge-area {
        top: 48%;
        bottom: auto;
        transform: translateX(-50%) scale(.8);
    }

    .content {
        padding-top: 220px;
    }

    .error-number {
        font-size: 76px;
    }

    .footer-note {
        margin-top: 20px;
    }
}

@media (prefers-reduced-motion: reduce) {
    *,
    *::before,
    *::after {
        animation-duration: .01ms !important;
        animation-iteration-count: 1 !important;
        scroll-behavior: auto !important;
    }
}

/* =================================
   MOBILE FINAL FIX
================================= */

@media (max-width: 700px) {

    .kingdom {
        min-height: 100svh;
        padding: 12px 12px;
    }

    /* قلعه */
    .castle-area {
        top: 22%;
        transform: translateX(-50%) scale(.73);
        transform-origin: top center;
    }

    /* پل */
    .bridge-area {
        top: 56%;
        bottom: auto;
        transform: translateX(-50%) scale(.85);
        transform-origin: top center;
    }

    /* پایه‌های پل */
    .bridge::before,
    .bridge::after {
        height: 180px;
    }

    /* محتوای صفحه */
    .content {
        padding-top: 220px;
        padding-bottom: 0;
        margin-top: auto;
        margin-bottom: auto;
    }

    .divider {
        margin: 10px auto 8px;
    }

    .content h1 {
        margin-bottom: 6px;
    }

    .description {
        margin-bottom: 4px;
    }

    .actions {
        margin-top: 15px;
        gap: 9px;
        flex-direction: row;
        flex-wrap: nowrap;
        width: 100%;
    }

    .action-button {
        flex: 1;
        min-width: 0;
        min-height: 43px;
        padding: 0 5px;
        font-size: 11px;
        gap: 5px;
        white-space: nowrap;
    }

    .button-icon {
        font-size: 16px;
    }

    .footer-note {
        display: none;
    }
}

/* گوشی‌های کوچک */
@media (max-width: 390px) {

    .kingdom {
        padding: 8px 10px;
    }

    .castle-area {
        top: 22%;
        transform: translateX(-50%) scale(.62);
    }

    .bridge-area {
        top: 59%;
        bottom: auto;
        transform: translateX(-50%) scale(.68);
    }

    .bridge::before,
    .bridge::after {
        height: 180px;
    }

    .content {
        padding-top: 205px;
    }

    .error-number {
        font-size: 72px;
        letter-spacing: 5px;
    }

    .content h1 {
        font-size: 21px;
        margin-bottom: 5px;
    }

    .description {
        font-size: 13px;
    }

    .sub-description {
        font-size: 11px;
    }

    .actions {
        margin-top: 13px;
        gap: 7px;
    }

    .action-button {
        min-height: 42px;
        font-size: 10px;
    }
}
