/* Title flow background and start-screen presentation. */
body.title-background-active {
    background: #6fcdf4;
}

body.title-background-active .screen {
    z-index: 1;
}

.title-background-layer {
    position: fixed;
    inset: 0;
    z-index: 0;
    overflow: hidden;
    pointer-events: none;
    background: #8bd8ff;
}

.title-background-layer::before,
.title-background-layer::after {
    content: "";
    position: absolute;
    inset: 0;
    pointer-events: none;
}

.title-background-layer::before {
    z-index: 0;
    background-image: url("../assets/title/title-background.jpg");
    background-position: center center;
    background-size: cover;
    transform: scale(1.035);
    animation: titleBackgroundDrift 18s ease-in-out infinite alternate;
}

.title-background-layer::after {
    z-index: 1;
    background:
        radial-gradient(circle at 18% 76%, rgba(226, 255, 145, 0.18), transparent 27%),
        radial-gradient(circle at 82% 18%, rgba(255, 255, 255, 0.20), transparent 25%),
        linear-gradient(90deg, rgba(2, 19, 31, 0.32), rgba(255, 255, 255, 0.02) 48%, rgba(12, 36, 44, 0.22)),
        linear-gradient(180deg, rgba(255, 255, 255, 0.02), rgba(3, 20, 26, 0.46));
}

.title-petal-canvas {
    position: absolute;
    inset: 0;
    z-index: 2;
    width: 100%;
    height: 100%;
}

#start-screen,
#match-mode-screen,
#online-room-screen {
    background: transparent;
}

#start-screen .start-container {
    z-index: 4;
    width: 540px;
    max-width: none;
    padding: 42px 38px 34px;
    color: #fff7d6;
    background:
        linear-gradient(180deg, rgba(21, 79, 67, 0.42), rgba(15, 44, 38, 0.50)),
        rgba(12, 38, 34, 0.25);
    border: 1px solid rgba(255, 240, 167, 0.58);
    border-radius: 12px;
    box-shadow:
        0 24px 58px rgba(3, 24, 28, 0.42),
        inset 0 1px 0 rgba(255, 255, 255, 0.20),
        inset 0 -1px 0 rgba(255, 211, 98, 0.22);
    backdrop-filter: blur(7px) saturate(1.12);
}

#start-screen .start-container.screen-scale-target {
    width: 540px;
}

#start-screen .start-container::before {
    content: "";
    position: absolute;
    inset: 10px;
    z-index: -1;
    border: 1px solid rgba(255, 232, 137, 0.22);
    border-radius: 8px;
}

#start-screen .game-title {
    margin-bottom: 18px;
    color: #fff1ad;
    font-size: 3.35rem;
    line-height: 1;
    text-shadow:
        0 2px 0 rgba(96, 55, 7, 0.65),
        0 0 22px rgba(255, 234, 142, 0.54),
        0 12px 24px rgba(1, 18, 23, 0.36);
    animation: titleGoldGlow 2.8s ease-in-out infinite alternate;
}

#start-screen .card-animation {
    height: 108px;
    margin: 10px 0 18px;
    transform: translateY(-10px);
}

#start-screen .game-description {
    margin: 0 0 26px;
    color: rgba(255, 247, 205, 0.94);
    font-size: 1.18rem;
    font-weight: 800;
    letter-spacing: 0;
    text-shadow:
        0 2px 8px rgba(0, 18, 25, 0.55),
        0 0 18px rgba(255, 230, 126, 0.26);
}

#start-screen .floating-card {
    width: 56px;
    height: 82px;
    bottom: 22px;
    color: #fff6c7;
    border: 1px solid rgba(255, 232, 142, 0.70);
    border-radius: 9px;
    background:
        linear-gradient(180deg, rgba(255, 237, 137, 0.26), rgba(30, 103, 79, 0.30)),
        rgba(10, 52, 47, 0.55);
    box-shadow:
        0 10px 22px rgba(3, 23, 28, 0.36),
        inset 0 1px 0 rgba(255, 255, 255, 0.24);
    text-shadow: 0 2px 8px rgba(1, 14, 18, 0.65);
}

#start-screen .floating-card:nth-child(1) {
    background:
        linear-gradient(180deg, rgba(255, 220, 230, 0.72), rgba(243, 93, 135, 0.64)),
        rgba(178, 50, 88, 0.58);
}

#start-screen .floating-card:nth-child(3) {
    background:
        linear-gradient(180deg, rgba(255, 247, 175, 0.78), rgba(238, 172, 47, 0.68)),
        rgba(178, 114, 20, 0.58);
}

#start-screen .floating-card:nth-child(2) {
    background:
        linear-gradient(180deg, rgba(194, 240, 255, 0.74), rgba(75, 154, 238, 0.66)),
        rgba(31, 105, 189, 0.58);
}

#start-screen .floating-card:nth-child(4) {
    background:
        linear-gradient(180deg, rgba(204, 255, 197, 0.72), rgba(69, 185, 102, 0.66)),
        rgba(38, 126, 71, 0.58);
}

#start-screen .floating-card:nth-child(5) {
    background:
        linear-gradient(180deg, rgba(239, 215, 255, 0.74), rgba(169, 99, 233, 0.66)),
        rgba(103, 61, 171, 0.58);
}

#start-screen .start-btn {
    min-width: 240px;
    padding: 17px 34px;
    color: #2d1b04;
    border: 1px solid rgba(255, 249, 184, 0.88);
    background: linear-gradient(180deg, #fff2a8, #e6b241 50%, #9b6419);
    box-shadow:
        0 14px 26px rgba(10, 40, 18, 0.32),
        inset 0 1px 0 rgba(255, 255, 255, 0.68),
        inset 0 -2px 0 rgba(73, 39, 3, 0.38);
    text-shadow: 0 1px 0 rgba(255, 255, 255, 0.36);
}

#start-screen .start-btn:hover {
    box-shadow:
        0 18px 32px rgba(10, 40, 18, 0.40),
        0 0 24px rgba(255, 224, 93, 0.36),
        inset 0 1px 0 rgba(255, 255, 255, 0.74);
}

#start-screen .test-play-btn {
    color: #f7f4df;
    background: rgba(13, 56, 50, 0.78);
    border: 1px solid rgba(255, 237, 160, 0.45);
    box-shadow: 0 8px 18px rgba(2, 18, 23, 0.28);
}

#start-screen .test-play-btn:hover {
    background: rgba(21, 83, 69, 0.90);
}

#start-screen .rulebook-open-btn,
#start-screen .deck-list-open-btn {
    color: #fff4c7;
    border: 1px solid rgba(255, 233, 151, 0.54);
    background: rgba(9, 46, 45, 0.66);
    box-shadow: 0 12px 26px rgba(2, 19, 25, 0.34);
    backdrop-filter: blur(5px);
}

#start-screen .rulebook-open-btn:hover,
#start-screen .deck-list-open-btn:hover {
    background: rgba(18, 73, 61, 0.82);
}

#match-mode-screen .match-mode-container,
#online-room-screen .online-room-container {
    background:
        linear-gradient(180deg, rgba(12, 58, 53, 0.68), rgba(7, 30, 35, 0.72)),
        rgba(12, 38, 34, 0.22);
    border-color: rgba(255, 236, 165, 0.45);
    box-shadow: 0 24px 60px rgba(3, 24, 28, 0.40);
}

@keyframes titleBackgroundDrift {
    from { transform: scale(1.035) translate3d(-0.7%, -0.5%, 0); }
    to { transform: scale(1.045) translate3d(0.7%, 0.5%, 0); }
}

@keyframes titleGoldGlow {
    from {
        text-shadow:
            0 2px 0 rgba(96, 55, 7, 0.65),
            0 0 14px rgba(255, 234, 142, 0.42),
            0 12px 24px rgba(1, 18, 23, 0.36);
    }
    to {
        text-shadow:
            0 2px 0 rgba(96, 55, 7, 0.65),
            0 0 28px rgba(255, 234, 142, 0.70),
            0 12px 24px rgba(1, 18, 23, 0.36);
    }
}

@media (max-width: 720px) {
    .title-background-layer::before {
        background-position: 43% center;
    }

    #start-screen .start-container {
        width: 500px;
        padding: 34px 28px 30px;
    }

    #start-screen .start-container.screen-scale-target {
        width: 500px;
    }

    #start-screen .game-title {
        font-size: 2.45rem;
    }

    #start-screen .card-animation {
        height: 90px;
        margin: 8px 0 16px;
        transform: translateY(-8px);
    }

    #start-screen .game-description {
        margin-bottom: 22px;
        font-size: 1.05rem;
    }

    #start-screen .floating-card {
        width: 48px;
        height: 72px;
        bottom: 18px;
    }
}

@media (prefers-reduced-motion: reduce) {
    .title-background-layer::before,
    #start-screen .game-title {
        animation: none;
    }
}
