* {
    box-sizing: border-box;
}

body {
    margin: 0;
    font-family: "Segoe UI", Arial, sans-serif;
    color: #1f1f35;
    background:
        radial-gradient(circle at 15% 20%, #fff2b8 0, transparent 28%),
        radial-gradient(circle at 85% 15%, #cfd9ff 0, transparent 30%),
        linear-gradient(135deg, #fff7df, #f3f6ff);
    min-height: 100vh;
}

.home-page {
    max-width: 1480px;
    margin: 0 auto;
    padding: 28px 32px 60px;
}

.hero-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 34px;
}

.logo {
    text-decoration: none;
    font-size: 34px;
    font-weight: 900;
    color: #5b2fd6;
}

.logo span {
    font-size: 20px;
}

.header-nav {
    display: flex;
    align-items: center;
    gap: 16px;
}

.header-nav a {
    text-decoration: none;
    color: #2f2f46;
    font-weight: 800;
    background: rgba(255, 255, 255, 0.7);
    padding: 13px 18px;
    border-radius: 18px;
}

.header-nav .login-btn {
    background: linear-gradient(135deg, #7c3aed, #5b7cfa);
    color: white;
}

.hero-section {
    min-height: 230px;
    border-radius: 34px;
    padding: 54px 64px;
    margin-bottom: 28px;
    background:
        linear-gradient(90deg, rgba(255,244,196,.95), rgba(226,232,255,.85)),
        url("/static/stories/img/hero-bg.jpg");
    background-size: cover;
    background-position: center;
    box-shadow: 0 24px 60px rgba(91, 47, 214, 0.12);
}

.hero-content h1 {
    margin: 0 0 18px;
    font-size: 58px;
    line-height: 1;
    color: #2c185c;
}

.hero-content p {
    max-width: 620px;
    font-size: 22px;
    line-height: 1.55;
    margin: 0;
    color: #3f3f56;
}

.generator-section {
    display: grid;
    grid-template-columns: minmax(0, 2fr) 420px;
    gap: 28px;
    align-items: start;
}

.characters-panel,
.settings-panel {
    background: rgba(255,255,255,0.88);
    border: 1px solid rgba(255,255,255,0.9);
    border-radius: 34px;
    padding: 28px;
    box-shadow: 0 24px 60px rgba(31, 31, 53, 0.1);
}

.characters-panel h2,
.settings-panel h2 {
    margin: 0 0 24px;
    font-size: 22px;
    color: #43208f;
}

.selected-heroes {
    background: #f8fafc;
    border: 1px solid #e5e7eb;
    border-radius: 18px;
    padding: 16px;
    margin-bottom: 22px;
    color: #6b7280;
    font-weight: 700;
}

.field-group {
    margin-bottom: 22px;
}

.field-group label {
    display: block;
    margin-bottom: 10px;
    font-weight: 900;
}

.field-group select,
.field-group input {
    width: 100%;
    padding: 16px 18px;
    border-radius: 16px;
    border: 1px solid #d7dce7;
    font-size: 16px;
    background: white;
}

.create-btn {
    width: 100%;
    border: 0;
    border-radius: 22px;
    padding: 20px;
    cursor: pointer;
    background: linear-gradient(135deg, #7c3aed, #ec4899, #fb923c);
    color: white;
    font-size: 20px;
    font-weight: 900;
    box-shadow: 0 18px 35px rgba(236, 72, 153, 0.25);
}
.characters-grid {
    display: flex;
    gap: 18px;
    overflow-x: auto;
    padding: 4px 4px 18px;
    scroll-snap-type: x mandatory;
    scrollbar-width: none;
    -ms-overflow-style: none;
}

.characters-grid::-webkit-scrollbar {
    display: none;
}
.characters-grid::-webkit-scrollbar-track {
    background: #f1f5f9;
    border-radius: 999px;
}

.characters-grid::-webkit-scrollbar-thumb {
    background: linear-gradient(135deg, #7c3aed, #ec4899);
    border-radius: 999px;
}

.character-card {
    flex: 0 0 calc((100% - 54px) / 4);
    scroll-snap-align: start;
}

.character-card {
    position: relative;
    cursor: pointer;
    background: #fff;
    border: 2px solid #e5e7eb;
    border-radius: 22px;
    padding: 14px;
    text-align: center;
}

.character-card input {
    display: none;
}

.character-image {
    height: 150px;
    border-radius: 18px;
    background: #f8fafc;
    overflow: hidden;
    margin-bottom: 10px;
}

.character-image img {
    width: 100%;
    height: 100%;
    object-fit: contain;
}

.character-card span {
    font-weight: 900;
}

.character-card:has(input:checked) {
    border-color: #7c3aed;
    box-shadow: 0 18px 35px rgba(124, 58, 237, .22);
}
.characters-slider {
    position: relative;
}

.slider-btn {
    position: absolute;
    top: 50%;
    transform: translateY(-50%);

    width: 52px;
    height: 52px;

    border: none;
    border-radius: 50%;

    background: white;
    color: #7c3aed;

    font-size: 24px;
    font-weight: 900;

    cursor: pointer;

    box-shadow: 0 10px 30px rgba(0,0,0,.15);

    z-index: 10;

    transition: .3s;
}

.slider-btn:hover {
    transform: translateY(-50%) scale(1.1);
    background: #7c3aed;
    color: white;
}

.slider-prev {
    left: -25px;
}

.slider-next {
    right: -25px;
}
.slider-btn {
    position: absolute;
    top: 50%;
    transform: translateY(-50%);
    width: 58px;
    height: 58px;
    border: 0;
    border-radius: 50%;
    cursor: pointer;
    z-index: 10;

    background:
        linear-gradient(135deg, rgba(255,255,255,.95), rgba(245,243,255,.9));
    box-shadow:
        0 18px 35px rgba(91, 47, 214, .22),
        inset 0 0 0 1px rgba(255,255,255,.9);

    display: flex;
    align-items: center;
    justify-content: center;

    transition: .25s ease;
}

.slider-btn span {
    width: 38px;
    height: 38px;
    border-radius: 50%;
    background: linear-gradient(135deg, #7c3aed, #ec4899);
    color: white;
    font-size: 38px;
    line-height: 32px;
    font-weight: 900;
    display: flex;
    align-items: center;
    justify-content: center;
    padding-bottom: 5px;
}

.slider-btn:hover {
    transform: translateY(-50%) scale(1.08);
    box-shadow:
        0 22px 45px rgba(236, 72, 153, .28),
        inset 0 0 0 1px rgba(255,255,255,.9);
}

.slider-btn:active {
    transform: translateY(-50%) scale(.96);
}

.slider-prev {
    left: -29px;
}

.slider-next {
    right: -29px;
}
.empty-team {
    color: #6b7280;
    font-weight: 700;
}

.team-member {
    display: flex;
    align-items: center;
    gap: 12px;
}

.team-member-avatar {
    width: 48px;
    height: 48px;
    flex-shrink: 0;
    overflow: hidden;
    border-radius: 50%;
}

.team-member-avatar img {
    width: 100%;
    height: 100%;
    object-fit: cover;
    display: block;
}

.team-member-name {
    font-weight: 700;
}
.selected-heroes {
    overflow: hidden;
}

.team-member {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 10px 12px;
    margin-bottom: 10px;
    background: #fff;
    border-radius: 14px;
    border: 1px solid #e5e7eb;
}

.team-member-avatar {
    width: 42px;
    height: 42px;
    min-width: 42px;
    border-radius: 50%;
    overflow: hidden;
}

.team-member-avatar img {
    width: 100%;
    height: 100%;
    object-fit: cover;
    display: block;
}
.team-member {
    position: relative;
}

.team-member-name {
    flex: 1;
}

.remove-hero-btn {
    width: 28px;
    height: 28px;
    border: none;
    border-radius: 50%;
    background: #f3f4f6;
    color: #6b7280;
    cursor: pointer;
    font-weight: 900;
}

.remove-hero-btn:hover {
    background: #ef4444;
    color: white;
}
.generation-status {
    margin-top: 20px;
    padding: 18px;
    border-radius: 16px;
    background: rgba(255,255,255,.9);
    border: 1px solid #ececec;
    box-shadow: 0 10px 30px rgba(0,0,0,.08);
    animation: fadeIn .3s ease;
}

.generation-title{
    font-size:20px;
    font-weight:700;
    color:#5b2dd8;
    margin-bottom:8px;
}

.generation-text{
    color:#666;
    line-height:1.6;
}

@keyframes fadeIn{
    from{
        opacity:0;
        transform:translateY(10px);
    }
    to{
        opacity:1;
        transform:translateY(0);
    }
}
create-btn:disabled {
    opacity: 0.75;
    cursor: not-allowed;
}
.generation-progress {
    margin: 18px 0 24px;
    padding: 16px;
    border-radius: 18px;
    background: #f8fafc;
    border: 1px solid #e5e7eb;
}

.generation-progress-title {
    font-weight: 900;
    color: #5b2dd8;
    margin-bottom: 12px;
}

.progress-bar {
    width: 100%;
    height: 12px;
    background: #e5e7eb;
    border-radius: 999px;
    overflow: hidden;
    margin-bottom: 10px;
}

.progress-fill {
    width: 0%;
    height: 100%;
    border-radius: 999px;
    background: linear-gradient(135deg, #7c3aed, #ec4899, #fb923c);
    transition: width .5s ease;
}

.progress-text {
    font-size: 14px;
    font-weight: 700;
    color: #6b7280;
}
.create-btn:disabled {
    background: #cfd6dd;
    color: #8a94a3;
    cursor: not-allowed;
    box-shadow: none;
    transform: none;
    opacity: .85;
}

.create-btn:disabled:hover {
    background: #cfd6dd;
    transform: none;
}
.heroes-warning {
    margin-top: 12px;
    text-align: center;
    font-size: 14px;
    color: #e67e22;
    font-weight: 500;
    transition: .25s;
}

.heroes-warning.hidden {
    opacity: 0;
    visibility: hidden;
    height: 0;
    margin-top: 0;
}
.story-result {
    margin-top: 32px;
    padding: 28px;
    border-radius: 24px;
    background: #fffaf0;
    box-shadow: 0 12px 35px rgba(0, 0, 0, 0.08);
}

.story-result h2 {
    margin-bottom: 18px;
    font-size: 28px;
    color: #3b2f2f;
}

.story-text {
    font-size: 18px;
    line-height: 1.7;
    color: #3b2f2f;
    white-space: pre-line;
}
.progress-top {
    display: flex;
    justify-content: space-between;
    gap: 16px;
    margin-bottom: 10px;
    font-size: 14px;
    font-weight: 600;
}

#progressPercent {
    color: #7c5cff;
    white-space: nowrap;
}

.progress-bar {
    width: 100%;
    height: 12px;
    background: #e8edf3;
    border-radius: 999px;
    overflow: hidden;
}

.progress-fill {
    width: 0%;
    height: 100%;
    border-radius: 999px;
    background: linear-gradient(90deg, #7c5cff, #ffb347);
    transition: width 0.4s ease;
}
.reset-btn {
    margin-top: 12px;
    width: 100%;
    padding: 14px 24px;
    border: none;
    border-radius: 16px;
    background: #eef1f5;
    color: #6b7280;
    font-size: 16px;
    font-weight: 700;
    cursor: pointer;
    transition: .2s;
}

.reset-btn:hover {
    background: #e1e6ee;
}

@media (max-width: 1000px) {
    .generator-section {
        grid-template-columns: 1fr;
    }

    .hero-header {
        flex-direction: column;
        gap: 18px;
        align-items: flex-start;
    }

    .hero-content h1 {
        font-size: 42px;
    }
}
@media (max-width: 900px) {
    .character-card {
        flex-basis: calc((100% - 18px) / 2);
    }
}

@media (max-width: 520px) {
    .character-card {
        flex-basis: 85%;
    }
}