/* Color Palette */
:root {
    --deep-purple: #5B2E6F;
    --bright-pink: #E85B9F;
    --soft-lavender: #D8C9E8;
    --black: #1A1A1A;
    --light-gray: #F5F2F8;
    --charcoal: #3D3D3D;
    --gold: #C4A86F;
    --neon-pink: #FF1493;
}

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

html, body {
    font-family: 'Times New Roman', serif;
    background:
        linear-gradient(135deg, rgba(10, 10, 26, 0.4) 0%, rgba(26, 10, 46, 0.95) 50%, rgba(15, 15, 32, 0.4) 100%),
        url('assets/amelia-bkgrnd.png');
    background-size: auto;
    background-position: center, center top;
    background-repeat: no-repeat, no-repeat;
    background-attachment: fixed, fixed;
    color: var(--black);
    line-height: 1;
    min-height: 100vh;
    position: relative;
}

@keyframes gradientShift {
    0% {
        background-position: 0% 50%;
    }
    50% {
        background-position: 100% 50%;
    }
    100% {
        background-position: 0% 50%;
    }
}

/* Animated accent lines */
body::before {
    content: '';
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background:
        repeating-linear-gradient(
            0deg,
            rgba(255, 20, 147, 0.04) 0px,
            rgba(255, 20, 147, 0.04) 1px,
            transparent 1px,
            transparent 1px
        );
    animation: scanlines 8s linear infinite;
    pointer-events: none;
    z-index: 1;
}

@keyframes scanlines {
    0% {
        transform: translateY(0);
    }
    100% {
        transform: translateY(10px);
    }
}

/* Pulsing glow accent */
body::after {
    content: '';
    position: fixed;
    top: 0;
    left: 50%;
    transform: translateX(-50%);
    width: 200%;
    height: 100%;
    background: radial-gradient(ellipse at center, rgba(255, 20, 147, 0.15) 0%, transparent 70%);
    animation: glowPulse 6s ease-in-out infinite;
    pointer-events: none;
    z-index: 0;
}

@keyframes glowPulse {
    0%, 100% {
        opacity: 0.3;
        filter: blur(40px);
    }
    50% {
        opacity: 0.6;
        filter: blur(60px);
    }
}

/* Typography */
h1, h2, h3 {
    font-family: 'Felipa', cursive;
    color: var(--deep-purple);
    margin-bottom: .1rem;
}

h1 {
    font-size: 3rem;
    margin-top: .1rem;
}

h2 {
    font-size: 1.75rem;
    margin-bottom: .1rem;
    margin-top: .1rem;
}

p {
    font-size: 1rem;
    color: var(--charcoal);
}

a {
    color: var(--bright-pink);
    text-decoration: none;
    transition: color 0.2s ease, text-shadow 0.2s ease;
}

a:hover {
    text-decoration: none;
    color: var(--neon-pink);
    text-shadow: 0 0 8px rgba(255, 20, 147, 0.6);
}

/* Navigation Bar */
.navbar {
    margin-top: 1rem;
    padding-top: .2rem;
    border-top: 1px solid rgba(255, 20, 147, 0.3);
    display: flex;
    justify-content: center;
    align-items: center;
    gap: 2rem;
}

.navbar-brand {
    font-family: 'New Rocker', cursive;
    font-size: 1.2rem;
    font-weight: bold;
    color: var(--neon-pink);
    text-shadow: 0 0 15px rgba(255, 20, 147, 0.6);
    letter-spacing: 0.1em;
}

.navbar-links {
    display: flex;
    gap: 2rem;
}

.navbar-links a {
    color: #b8a8c8;
    font-size: 0.9rem;
    transition: all 0.3s ease;
    position: relative;
}

.navbar-links a::after {
    content: '';
    position: absolute;
    bottom: -5px;
    left: 0;
    width: 0;
    height: 2px;
    background: var(--neon-pink);
    transition: width 0.3s ease;
}

.navbar-links a:hover {
    color: var(--neon-pink);
    text-shadow: 0 0 10px rgba(255, 20, 147, 0.6);
}

.navbar-links a:hover::after {
    width: 100%;
}

/* Layout */
.container {
    max-width: 1000px;
    margin: 0 auto;
    padding: 1.25rem;
}

.header {
    text-align: center;
    margin-bottom: 3rem;
    padding: 3rem 2rem;
    background: linear-gradient(180deg, rgba(98, 11, 133, 0.6) 0%, rgba(91, 46, 111, 0.2) 100%);
    border-top: 2px solid var(--neon-pink);
    border-bottom: 2px solid var(--neon-pink);
    position: relative;
    overflow: hidden;
}

.header::before {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    height: 1px;
    background: linear-gradient(90deg, transparent, var(--neon-pink), transparent);
    opacity: 0.5;
}

.header h1 {
    margin-bottom: 0.5rem;
    color: var(--neon-pink);
    text-shadow: 0 0 20px rgba(255, 20, 147, 0.5), 0 0 40px rgba(91, 46, 111, 0.3);
    font-size: 2.8rem;
    letter-spacing: 0.05em;
}

.subtitle {
    font-size: 1.1rem;
    color: #b8a8c8;
    max-width: 600px;
    margin: 0.75rem auto 0;
    text-shadow: 0 0 10px rgba(232, 91, 159, 0.2);
}

.builder {
    display: flex;
    flex-direction: column;
    gap: 3rem;
}

.builder-content {
    display: grid;
    grid-template-columns: 2fr 3fr;
    gap: 3rem;
}

.builder-left {
    display: flex;
    flex-direction: column;
    gap: 1rem;
}

.builder-right {
    display: flex;
    flex-direction: column;
    gap: 1rem;
}

/* Selector Sections */
.selector-section {
    background: white;
    padding: 1.25rem;
    border-radius: 8px;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.08);
}

.selector-section h2 {
    margin-top: 0;
    color: var(--deep-purple);
}

/* Collapsible sections */
.selector-section.collapsible .section-header {
    cursor: pointer;
    user-select: none;
    display: flex;
    align-items: center;
    gap: 0.75rem;
}

.selector-section.collapsible .section-header:hover {
    color: var(--bright-pink);
}

.selector-section.collapsible .chevron {
    display: inline-block;
    transition: transform 0.2s ease;
    font-size: 1.2rem;
}

.selector-section.collapsible.collapsed .chevron {
    transform: rotate(-90deg);
}

.selector-section.collapsible.collapsed .character-grid,
.selector-section.collapsible.collapsed .background-grid {
    display: none;
}

/* Character Grid */
.character-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(90px, 1fr));
    gap: 1rem;
}

.character-item {
    aspect-ratio: 1 / 1;
    border: 3px solid var(--soft-lavender);
    border-radius: 8px;
    cursor: pointer;
    overflow: hidden;
    transition: all 0.2s ease;
    background: white;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 0.5rem;
}

.character-item:hover {
    border-color: var(--bright-pink);
    transform: scale(1.05);
    box-shadow: 0 4px 12px rgba(232, 91, 159, 0.2);
}

.character-item.selected {
    border-color: var(--bright-pink);
    background: rgba(232, 91, 159, 0.05);
    box-shadow: 0 0 0 3px rgba(232, 91, 159, 0.1);
}

.character-item img,
.character-item svg {
    width: 100%;
    height: 100%;
    object-fit: contain;
}

/* Background Grid */
.background-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(100px, 1fr));
    gap: 1rem;
}

.background-item {
    aspect-ratio: 4 / 3;
    border: 3px solid var(--soft-lavender);
    border-radius: 8px;
    cursor: pointer;
    overflow: hidden;
    transition: all 0.2s ease;
    background: white;
    display: flex;
    align-items: center;
    justify-content: center;
}

.background-item:hover {
    border-color: var(--bright-pink);
    transform: scale(1.05);
    box-shadow: 0 4px 12px rgba(232, 91, 159, 0.2);
}

.background-item.selected {
    border-color: var(--bright-pink);
    box-shadow: 0 0 0 3px rgba(232, 91, 159, 0.1);
}

.background-item img,
.background-item svg {
    width: 100%;
    height: 100%;
    object-fit: cover;
}

/* Name Input */
.name-input-wrapper {
    position: relative;
    margin-bottom: 1rem;
}

.name-input {
    width: 100%;
    padding: 1rem;
    font-size: 1rem;
    border: 2px solid var(--soft-lavender);
    border-radius: 6px;
    font-family: 'Times New Roman', serif;
    transition: border-color 0.2s ease;
}

.name-input:focus {
    outline: none;
    border-color: var(--bright-pink);
    box-shadow: 0 0 0 3px rgba(232, 91, 159, 0.1);
}

.char-counter {
    display: block;
    font-size: 0.875rem;
    color: var(--charcoal);
    margin-top: 0.5rem;
    text-align: right;
}

.error-message {
    color: #d9534f;
    font-size: 0.875rem;
    margin-top: 0.5rem;
    min-height: 1.2rem;
}

/* Preview Section */
.preview-section {
    background: white;
    padding: 1.25rem;
    border-radius: 8px;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.08);
}

.preview-container {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 1rem;
}

#previewCanvas {
    border: 2px solid var(--soft-lavender);
    border-radius: 8px;
    max-width: 100%;
    height: auto;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.1);
}

.preview-note {
    font-size: 0.875rem;
    color: var(--charcoal);
    font-style: italic;
}

/* CTA Section */
.cta-section {
    text-align: center;
    padding: 1.25rem;
    background: white;
    border-radius: 8px;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.08);
}

.buy-button {
    padding: 1rem 2rem;
    font-size: 1.1rem;
    font-family: 'Felipa', cursive;
    font-weight: bold;
    border: none;
    border-radius: 6px;
    cursor: pointer;
    transition: all 0.2s ease;
    margin-bottom: 1rem;
}

.buy-button:not(:disabled) {
    background-color: var(--bright-pink);
    color: white;
    box-shadow: 0 0 20px rgba(232, 91, 159, 0.6), 0 0 40px rgba(255, 20, 147, 0.3), inset 0 0 10px rgba(255, 255, 255, 0.2);
    border: 1px solid rgba(255, 20, 147, 0.5);
    transition: all 0.3s ease;
}

.buy-button:not(:disabled):hover {
    background-color: var(--neon-pink);
    transform: translateY(-3px);
    box-shadow: 0 0 30px rgba(255, 20, 147, 0.8), 0 0 60px rgba(255, 20, 147, 0.5), inset 0 0 15px rgba(255, 255, 255, 0.3);
    border-color: rgba(255, 20, 147, 0.8);
}

.buy-button:not(:disabled):active {
    transform: translateY(0);
}

.buy-button:disabled {
    background-color: var(--soft-lavender);
    color: var(--charcoal);
    cursor: not-allowed;
    opacity: 0.6;
}

.legal-text {
    font-size: 0.875rem;
    color: #a8a0c8;
}

.legal-text a {
    color: var(--bright-pink);
    transition: all 0.2s ease;
}

.legal-text a:hover {
    color: var(--neon-pink);
    text-shadow: 0 0 8px rgba(255, 20, 147, 0.5);
}

/* Footer */
.footer {
    text-align: center;
    margin-top: 3rem;
    padding-top: 2rem;
    padding-bottom: 2rem;
    border-top: 2px solid var(--neon-pink);
    color: #b8a8c8;
    font-size: 0.875rem;
    position: relative;
}

.footer::before {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    height: 1px;
    background: linear-gradient(90deg, transparent, var(--neon-pink), transparent);
    opacity: 0.5;
}

.footer nav {
    margin-bottom: 1rem;
}

.footer nav a {
    margin: 0 1rem;
    color: var(--bright-pink);
    transition: color 0.2s ease, text-shadow 0.2s ease;
}

.footer nav a:hover {
    color: var(--neon-pink);
    text-shadow: 0 0 10px rgba(255, 20, 147, 0.5);
}

/* Responsive */
@media (max-width: 1024px) {
    .builder-content {
        grid-template-columns: 1fr;
    }
}

@media (max-width: 768px) {
    .container {
        padding: 1rem;
    }

    h1 {
        font-size: 2rem;
    }

    h2 {
        font-size: 1.5rem;
    }

    .character-grid {
        grid-template-columns: repeat(auto-fit, minmax(75px, 1fr));
    }

    .background-grid {
        grid-template-columns: repeat(auto-fit, minmax(80px, 1fr));
    }

    #previewCanvas {
        width: 100%;
        height: auto;
    }

    .buy-button {
        width: 100%;
    }
}
