/* Import modern fonts */
@import url('https://fonts.googleapis.com/css2?family=Unbounded:wght@300;500;700;900&display=swap');
@import url('https://fonts.googleapis.com/css2?family=Space+Grotesk:wght@300;400;500;700&display=swap');
@import url('https://fonts.googleapis.com/css2?family=DM+Sans:ital,wght@0,400;0,500;0,700;1,400&display=swap');

/* Color Variables */
:root {
    --yellow: #ffde00;  /* Updated yellow */
    --blue: #4b7be8;    /* Blue for accents only */
    --dark: #38383b;    /* Text color */
    --pink: #ec6de2;
    --light-text: #f6f5f3;
    --background: #5e5e5e;
    --surface: #ffffff;
    --shadow: rgba(0, 0, 0, 0.08);
}

/* General improvements */
body, .main-content, .loading-page {
    padding-top: env(safe-area-inset-top, 0px);
}

body {
    font-family: 'Space Grotesk', sans-serif;
    background-color: var(--background);
    color: var(--dark);
    margin: 0;
    padding: 0;
    min-height: 100vh;
    height: 100vh;
    display: flex;
    flex-direction: column;
    align-items: center;
    box-sizing: border-box;
    overflow: hidden;
    line-height: 1.4;
}

.container {
    width: 100vw;
    height: 100vh;
    margin: 0;
    padding: 0;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: flex-start;
    padding-top: 0;
    box-sizing: border-box;
    overflow-y: auto;
    scrollbar-width: none;
    -ms-overflow-style: none;
    height: 100vh;
    overflow: hidden;
}

.container::-webkit-scrollbar {
    display: none; /* Chrome, Safari, Opera */
}

.content-container {
    max-width: 480px;
    width: 100%;
    max-height: 100vh;
    padding: 8px 0 0 0;
    gap: 8px;
    flex-shrink: 1;
    box-sizing: border-box;
    position: relative;
    z-index: 1;
    flex: 1;
    grid-column: 4 / span 6;
    grid-row: 1 / span 12;
}

/* Typography updates */
h1, h2, h3, h4, h5, h6 {
    margin: 0;
}

h1 {
    font-family: 'Unbounded', cursive;
    font-weight: 900;
    font-size: 3.5rem;
    letter-spacing: -1px;
    text-transform: uppercase;
    color: var(--dark);
    margin-bottom: 5px;
    position: relative;
    z-index: 5;
}

h3 {
    font-family: 'Unbounded', cursive;
    font-weight: 900;
    font-size: 1.5rem;
    letter-spacing: -1px;
    text-transform: uppercase;
    color: var(--light-text);
    margin-bottom: 5px;
    position: relative;
    z-index: 5;
}

h1 .header-pink {
    color: var(--light-text);
}

h1 .header-yellow {
    color: var(--yellow);
}

h1 .header-blue {
    color: var(--dark);
}

h2 {
    font-family: 'DM Sans', sans-serif;
    font-size: 1.5rem;
    font-weight: 500;
    letter-spacing: 0.5px;
    color: var(--light-text);
    margin-bottom: 0;
    position: relative;
    z-index: 5;
}

.header-blue {
    color: var(--light-text);
    position: relative;
}

.header-blue::after {
    content: "";
    position: absolute;
    bottom: -2px;
    left: 0;
    width: 100%;
    height: 6px;
    background-color: var(--blue);
    opacity: 0.4;
    z-index: -1;
}

/* App description */
.app-description {
    margin: 4px 0;
    padding: 0 10px;
    font-size: 0.95rem;
    color: var(--light-text);
    line-height: 1.3;
    text-align: center;
}

.app-description p::before,
.app-description p::after {
    content: '';
    display: none;
}

/* Image container */
.cassie-image {
    margin: 4px auto 24px auto;
    padding: 12px 0;
    position: relative;
    z-index: 0;
    width: 100%;
    display: flex;
    justify-content: center;
    align-items: center;
    transition: transform 0.3s cubic-bezier(0.175, 0.885, 0.32, 1.275);
}

.cassie-image img {
    width: 150px;
    height: auto;
    border-radius: 18px;
    box-shadow: 12px 12px 0 var(--yellow);
    object-fit: contain;
    transition: all 0.3s cubic-bezier(0.175, 0.885, 0.32, 1.275);
    transform: rotate(-2deg);
}

.cassie-image img:hover {
    transform: rotate(2deg) translateY(-5px);
    box-shadow: 15px 15px 0 var(--yellow);
}

/* Form elements */
form {
    display: flex;
    flex-direction: column;
    align-items: center;
    width: 100%;
    gap: 8px;
    margin: 0;
    position: relative;
    z-index: 1;
}

input[type="text"] {
    width: 100%;
    max-width: 260px;
    margin: 0 auto;
    text-align: center;
    font-size: 17px;
    padding: 12px 16px;
    border-radius: 10px;
    border: 2px solid var(--yellow);
    background-color: var(--surface);
    transition: all 0.2s ease;
    box-shadow: 5px 5px 0 var(--dark);
    font-family: 'Space Grotesk', sans-serif;
    font-weight: 500;
}

input[type="text"]:focus {
    outline: none;
    border-color: var(--yellow);
    box-shadow: 8px 8px 0 var(--dark);
    transform: translateY(-2px);
}

input[type="text"]::placeholder {
    color: var(--dark);
    opacity: 0.6;
}

.preferences {
    gap: 4px;
    margin: 2px auto;
    text-align: left;
    width: 100%;
    max-width: 260px;
    display: flex;
    flex-direction: column;
    align-items: center;
    position: relative;
    z-index: 1;
}

.preference-item {
    display: flex;
    align-items: center;
    gap: 8px;
    width: 100%;
    justify-content: flex-start;
    padding: 0;
    border-radius: 8px;
    transition: all 0.2s ease;
    position: relative;
    white-space: nowrap;
}

.preference-item:hover {
    transform: translateX(5px);
}

.preference-item input[type="checkbox"] {
    width: 20px;
    height: 20px;
    margin: 0;
    accent-color: var(--yellow);
    cursor: pointer;
    border: 2px solid var(--dark);
}

.preference-item label {
    margin: 0;
    cursor: pointer;
    font-size: 0.98rem;
    color: var(--light-text);
    transition: color 0.2s ease;
    font-weight: 500;
    white-space: nowrap;
}

.preference-item:hover label {
    color: var(--dark);
    text-decoration: underline;
    text-decoration-color: var(--yellow);
    text-decoration-thickness: 2px;
    text-underline-offset: 3px;
}

/* Spotify button */
.spotify-button-container {
    margin: 4px auto 0 auto;
    text-align: center;
    width: 100%;
}

.spotify-button {
    font-family: 'Unbounded', cursive;
    background-color: var(--yellow);
    color: var(--dark);
    border: none;
    padding: 10px 18px;
    border-radius: 10px;
    cursor: pointer;
    font-size: 1rem;
    font-weight: 700;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    transition: all 0.2s cubic-bezier(0.175, 0.885, 0.32, 1.275);
    box-shadow: 5px 5px 0 var(--dark);
    text-decoration: none;
    margin: 0 auto;
    width: fit-content;
    min-width: 120px;
    letter-spacing: 0.5px;
    text-transform: lowercase;
    position: relative;
    overflow: hidden;
}

.spotify-button:hover {
    transform: translateY(-3px);
    box-shadow: 8px 8px 0 var(--dark);
    color: var(--dark);
}

.spotify-button:hover::after {
    right: -10px;
}

.spotify-button::after {
    content: "";
    position: absolute;
    bottom: 0;
    right: 100%;
    width: 100%;
    height: 3px;
    background-color: var(--blue);
    transition: right 0.3s ease;
}

.spotify-logo {
    display: inline-block;
    width: 18px;
    height: 18px;
    background-size: contain;
    background-repeat: no-repeat;
    background-position: center;
}

/* Authentication info */
.auth-info {
    margin: 2px 0;
    padding: 0 8px;
    font-size: 0.8rem;
    line-height: 1.4;
    color: var(--light-text);
    max-width: 320px;
}

.auth-info p {
    position: relative;
    padding: 6px;
    background-color: rgba(255, 222, 0, 0.1);
    border-radius: 8px;
    border-left: 3px solid var(--yellow);
}

/* Subtle link styling */
.subtle-link {
    color: var(--light-text);
    text-decoration: none;
    font-size: 0.85rem;
    transition: all 0.2s ease;
    margin-top: 10px;
    display: inline-block;
    padding: 5px 10px;
    border-radius: 8px;
    font-family: 'Space Grotesk', sans-serif;
}

.subtle-link:hover {
    color: var(--dark);
    background-color: rgba(255, 222, 0, 0.2);
    text-decoration: none;
}

/* Loading page styles */
.loading-page {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    width: 100%;
    height: 100%;
    position: relative;
    z-index: 1;
    padding: 0px;
    box-sizing: border-box;
}

.loading-messages {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 6px;
    background: none;
    box-shadow: none;
    z-index: 100;
    position: fixed;
    top: calc(env(safe-area-inset-top, 0px) + 16px);
    left: 50%;
    bottom: 85vh;
    transform: translateX(-50%);
    width: 100vw;
    max-width: 460px;
    margin: 0;
    padding: 0 10px;
    text-align: center;
    pointer-events: none;
    min-height: 3.5em;
}

#loading-message {
    font-family: 'DM Sans', sans-serif;
    font-size: 1.3rem;
    color: var(--light-text);
    margin: 0;
    line-height: 1.2;
    white-space: pre-line;
    min-height: 2.8em;
}

.loading-image-wrapper {
    position: fixed;
    left: 50%;
    bottom: 0;
    transform: translateX(-50%);
    width: auto;
    height: 100vh;
    max-height: 100vh;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: flex-end;
    z-index: 2;
    pointer-events: none;
    padding-top: 80px;
}

.loading-bg-image {
    position: relative;
    width: auto;
    height: 100%;
    display: flex;
    align-items: flex-end;
    justify-content: center;
}

.loading-bg-image img {
    height: 85vh;
    width: auto;
    max-height: 100vh;
    object-fit: contain;
    display: block;
}

.loading-starbolts {
    position: absolute;
    left: 50%;
    top: 51%; /* Adjust as needed for chest */
    transform: translate(-50%, -50%);
    width: 70px;
    height: 70px;
    display: flex;
    align-items: center;
    justify-content: center;
    pointer-events: none;
    z-index: 3;
}

.loading-starbolt {
    position: absolute;
    width: 70px;
    height: 70px;
    opacity: 0;
    z-index: 2;
    transition: opacity 0.5s ease-in-out, transform 0.5s ease-in-out;
    transform: scale(0.8);
    pointer-events: none;
    will-change: opacity, transform;
}

.loading-starbolt.active {
    opacity: 1;
    transform: scale(1.15);
    animation: pulse-starbolt 1.5s ease-in-out infinite;
    z-index: 4;
}

.loading-starbolt.fading {
    opacity: 0;
    transform: scale(1.05);
    z-index: 3;
    transition: opacity 0.5s ease-in-out, transform 0.5s ease-in-out;
}

@keyframes pulse-starbolt {
    0% { transform: scale(1.15); }
    50% { transform: scale(1.35); }
    100% { transform: scale(1.15); }
}

.loading-starbolt img {
    width: 100%;
    height: 100%;
    object-fit: contain;
}

/* Result page styling */
.result-container {
    height: 100vh;
    display: flex;
    color: var(--light-text);
    flex-direction: column;
    align-items: center;
    justify-content: center;
    padding: 20px;
}

.playlist-image {
    margin: 25px auto;
    position: relative;
    z-index: 0;
    width: 100%;
    display: flex;
    justify-content: center;
    align-items: center;
}

.playlist-image img {
    width: 260px;
    height: 260px;
    margin-bottom: 15px;
    border-radius: 16px;
    box-shadow: 12px 12px 0 var(--yellow);
    object-fit: cover;
    transition: all 0.4s cubic-bezier(0.175, 0.885, 0.32, 1.275);
    transform: rotate(-3deg);
}

.playlist-image img:hover {
    transform: rotate(3deg) translateY(-5px);
    box-shadow: 15px 15px 0 var(--yellow);
}

.result-actions {
    margin-top: 25px;
    display: flex;
    justify-content: center;
    gap: 20px;
}

/* Mobile responsiveness improvements */
@media (max-width: 768px) {
    .header-content { max-width: 98vw; }
    h1 { font-size: 2.5rem; }
    .cassie-image img { width: 160px; }
    .content-container { max-width: 98vw; }
}

@media (max-width: 480px) {
    .header-bg { min-height: 90px; }
    h1 { font-size: 2rem; }
    h2 { font-size: 1.2rem; }
    .cassie-image img { width: 140px; }
    .content-container { padding: 2px 0 0 0; }
}

@media (max-width: 600px) {
    .loading-messages {
        max-width: 90vw;
        font-size: 0.95rem;
        bottom: 85vh;
    }
    .loading-image-wrapper {
        padding-top: 140px;
    }
}

/* --- HEADER AREA --- */
.header-bg {
    width: 100vw;
    min-height: 140px;
    background: transparent;
    position: relative;
    z-index: 10;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: flex-end;
    box-shadow: none;
    clip-path: none;
    padding-top: 20px;
}

.header-content {
    width: 100%;
    max-width: 700px;
    padding: 0 16px 8px 16px;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: flex-end;
}

/* --- STICKER COLLAGE --- */
.sticker-collage {
    position: absolute;
    top: 0;
    left: 0;
    width: 100vw;
    height: 100vh;
    pointer-events: none;
    z-index: 0;
    display: grid;
    grid-template-columns: repeat(12, 1fr);
    grid-template-rows: repeat(12, 1fr);
}

.sticker-collage img {
    position: relative;
    opacity: 0.9;
    filter: drop-shadow(0 4px 8px rgba(0,0,0,0.1));
    user-select: none;
    transition: transform 0.5s cubic-bezier(0.175, 0.885, 0.32, 1.275);
    z-index: 1;
    width: 100%;
    height: auto;
    max-width: 240px;
    transform-origin: center;
}

/* Position stickers in grid cells, avoiding center content area */
.sticker1  { grid-column: 2; grid-row: 2; transform: rotate(-10deg); }
.sticker5  { grid-column: 3; grid-row: 5; transform: rotate(15deg); }
.sticker8  { grid-column: 1; grid-row: 7; transform: rotate(-5deg); }
.sticker4  { grid-column: 2; grid-row: 10; transform: rotate(8deg); }
.sticker6  { grid-column: 11; grid-row: 2; transform: rotate(12deg); }
.sticker2  { grid-column: 11; grid-row: 5; transform: rotate(-8deg); }
.sticker3  { grid-column: 12; grid-row: 8; transform: rotate(6deg); }
.sticker7  { grid-column: 11; grid-row: 11; transform: rotate(-15deg); }

/* Add a subtle hover animation for the stickers */
.sticker-collage img:hover {
    transform: scale(1.1) rotate(-5deg);
    z-index: 10;
}

/* Ensure content container stays in the center safe zone */
.content-container {
    grid-column: 4 / span 6;
    grid-row: 1 / span 12;
    z-index: 1;
}

@media (max-width: 900px) {
    .sticker-collage img { max-width: 160px !important; }
    .content-container {
        grid-column: 3 / span 8;
    }
}

@media (max-width: 600px) {
    .sticker-collage img { max-width: 100px !important; }
    .content-container {
        grid-column: 2 / span 10;
    }
}

/* Add top corner decoration using stars */
.corner-decoration {
    position: absolute;
    top: 10px;
    left: 10px;
    width: 80px;
    height: 80px;
    z-index: 3;
    opacity: 0.8;
}

/* Add special styling for error messages */
.error-message {
    background-color: rgba(255, 235, 59, 0.2);
    border-left: 4px solid var(--yellow);
    padding: 10px 15px;
    border-radius: 8px;
    margin: 10px 0;
    color: var(--dark);
    font-weight: 500;
}

/* Create noise texture overlay for more personality */
.noise-overlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 100vw;
    height: 100vh;
    background-image: url('data:image/svg+xml;base64,PHN2ZyB4bWxucz0iaHR0cDovL3d3dy53My5vcmcvMjAwMC9zdmciIHdpZHRoPSIzMDAiIGhlaWdodD0iMzAwIj48ZmlsdGVyIGlkPSJhIiB4PSIwIiB5PSIwIj48ZmVUdXJidWxlbmNlIHR5cGU9ImZyYWN0YWxOb2lzZSIgYmFzZUZyZXF1ZW5jeT0iLjc1IiBzdGl0Y2hUaWxlcz0ic3RpdGNoIi8+PGZlQ29sb3JNYXRyaXggdHlwZT0ic2F0dXJhdGUiIHZhbHVlcz0iMCIvPjwvZmlsdGVyPjxwYXRoIGZpbHRlcj0idXJsKCNhKSIgb3BhY2l0eT0iLjA1IiBkPSJNMCAwaDMwMHYzMDBIMHoiLz48L3N2Zz4=');
    pointer-events: none;
    z-index: 9999;
    opacity: 0 5;
}

.loading-message-line {
    display: inline-block;
    background: #ffde00;
    color: #38383b;
    font-size: 1.1em;
    font-family: 'DM Sans', 'Space Grotesk', sans-serif;
    padding: 0px 0px 0px 0px;
    margin: 0;
    border-radius: 2px -8px 3px 7px;
    font-weight: 700;
    letter-spacing: 0.01em;
    line-height: 1;
    filter: url(#rough-sharpie);
    position: relative;
    box-shadow: 0 2px 8px rgba(0,0,0,0.07);
    overflow: hidden;
    white-space: nowrap;
    width: auto;
    max-width: none;
}

.loading-message-line::after {
    content: '';
    position: absolute;
    inset: 0;
    pointer-events: none;
    background-image: url('data:image/svg+xml;utf8,<svg width="60" height="20" xmlns="http://www.w3.org/2000/svg"><filter id="noise"><feTurbulence type="fractalNoise" baseFrequency="0.8" numOctaves="2" stitchTiles="stitch"/></filter><rect width="100%" height="100%" filter="url(%23noise)" opacity="0.13"/></svg>');
    background-size: cover;
    opacity: 0.18;
    z-index: 2;
}