@import url('https://fonts.googleapis.com/css2?family=Poppins:wght@300;400;500;600;700&display=swap');

:root {
    --spotify-green: #1DB954;
    --spotify-green-dark: #1aa34a;
    --text: #ffffff;
    --background: #121212;
    --card-bg: rgba(255, 255, 255, 0.1);
    --shadow: 0 5px 15px rgba(0, 0, 0, 0.3);
}

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

body {
    font-family: 'Poppins', sans-serif;
    margin: 0;
    padding: 0;
    min-height: 100vh;
    background: var(--background);
    color: var(--text);
    overflow: hidden;
}

#app {
    height: 100vh;
    width: 100vw;
    position: relative;
}

.login-container {
    height: 100vh;
    width: 100vw;
    display: flex;
    flex-direction: column;
    justify-content: center;
    align-items: center;
    background: var(--background);
    transition: opacity 0.5s ease;
    padding: 20px;
    position: relative;
    overflow: hidden;
}

.welcome-message {
    font-size: 2.5em;
    font-weight: 600;
    margin-bottom: 15px;
    color: var(--spotify-green);
    text-align: center;
    opacity: 0;
    transform: translateY(20px);
    animation: slideUp 0.8s ease forwards;
    position: relative;
}

.welcome-message::after {
    content: '✨';
    position: absolute;
    top: -10px;
    right: -30px;
    font-size: 0.6em;
    animation: sparkle 2s ease-in-out infinite;
}

@keyframes sparkle {
    0%, 100% { transform: scale(1) rotate(0deg); opacity: 1; }
    50% { transform: scale(1.2) rotate(15deg); opacity: 0.7; }
}

.welcome-subtitle {
    font-size: 1.2em;
    color: rgba(255, 255, 255, 0.7);
    margin-bottom: 30px;
    text-align: center;
    opacity: 0;
    transform: translateY(20px);
    animation: slideUp 0.8s ease forwards 0.2s;
}

.spotify-login-btn {
    background: var(--spotify-green);
    color: white;
    padding: 15px 30px;
    border-radius: 50px;
    border: none;
    font-size: 1.2em;
    cursor: pointer;
    display: flex;
    align-items: center;
    gap: 10px;
    transition: all 0.3s ease;
    font-family: 'Poppins', sans-serif;
    opacity: 0;
    transform: translateY(20px);
    animation: slideUp 0.8s ease forwards 0.4s;
}

.spotify-login-btn:hover {
    background: var(--spotify-green-dark);
    transform: translateY(-2px);
    box-shadow: 0 8px 25px rgba(29, 185, 84, 0.3);
}

/* Add a subtle gradient overlay */
.login-container::after {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: radial-gradient(circle at center, transparent 0%, rgba(0,0,0,0.4) 100%);
    pointer-events: none;
}

.login-container::before {
    content: '';
    position: absolute;
    width: 200vw;
    height: 200vh;
    top: -50%;
    left: -50%;
    background: radial-gradient(circle at center, 
        var(--spotify-green) 0%,
        transparent 5%);
    opacity: 0.1;
    animation: rotate 20s linear infinite;
    pointer-events: none;
}

@keyframes rotate {
    from { transform: rotate(0deg); }
    to { transform: rotate(360deg); }
}

.story-container {
    display: none;
    height: 100vh;
    width: 100vw;
    position: relative;
    overflow: hidden;
}

.story-card {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    display: flex;
    flex-direction: column;
    justify-content: flex-start;
    padding: 20px;
    overflow-y: auto;
}

.story-card.active {
    opacity: 1;
    transform: scale(1);
}

.story-progress {
    position: sticky;
    top: 0;
    z-index: 1000;
}

.progress-bar {
    height: 3px;
    flex: 1;
    background: rgba(255, 255, 255, 0.3);
    border-radius: 3px;
    overflow: hidden;
}

.progress-fill {
    height: 100%;
    width: 0%;
    background: var(--spotify-green);
    transition: width 0.4s cubic-bezier(0.33, 1, 0.68, 1);
}

.story-content {
    max-width: 1200px;
    width: 100%;
    margin: 0 auto;
    padding: 80px 20px 100px;
    min-height: auto;
}

.story-title {
    font-size: 2em;
    font-weight: 400;
    margin-bottom: 20px;
    color: var(--text);
    -webkit-background-clip: initial;
    -webkit-text-fill-color: initial;
}

.story-subtitle {
    font-size: 1em;
    color: rgba(255, 255, 255, 0.7);
    margin-bottom: 30px;
    font-weight: 300;
}

.story-stat {
    font-size: 2.5em;
    font-weight: 400;
    margin: 20px 0;
    color: var(--spotify-green);
}

.stat-detail {
    font-size: 0.9em;
    color: rgba(255, 255, 255, 0.6);
    margin: 5px 0;
}

.artist-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(150px, 1fr));
    gap: 15px;
    margin: 20px 0;
    width: 100%;
    max-width: 600px;
}

.artist-item {
    background: rgba(255, 255, 255, 0.05);
    padding: 15px;
    border-radius: 8px;
    text-align: left;
    position: relative;
    overflow: hidden;
    min-height: clamp(100px, 15vw, 120px);
    display: flex;
    flex-direction: column;
    justify-content: flex-end;
}

.artist-item::before {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: linear-gradient(0deg, 
        rgba(0,0,0,0.95) 0%, 
        rgba(0,0,0,0.8) 30%, 
        rgba(0,0,0,0.4) 60%, 
        rgba(0,0,0,0.2) 100%);
    z-index: 1;
}

.artist-item > div {
    position: relative;
    z-index: 2;
    text-shadow: 0 2px 4px rgba(0,0,0,0.5);
    padding: 10px;
    text-align: left;
    width: 100%;
}

.artist-item .stat-detail {
    background: rgba(0,0,0,0.6);
    padding: 8px 12px;
    border-radius: 8px;
    margin-top: 15px;
    font-style: italic;
    color: rgba(255,255,255,0.9);
    backdrop-filter: blur(4px);
    -webkit-backdrop-filter: blur(4px);
    box-shadow: 0 2px 4px rgba(0,0,0,0.2);
    text-align: left;
    width: fit-content;
    max-width: 100%;
}

.artist-item .genre-tag {
    font-size: 0.9em;
    color: rgba(255, 255, 255, 0.7);
    text-align: left;
    width: 100%;
    margin-top: 5px;
}

.artist-image {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    object-fit: cover;
    z-index: 0;
    opacity: 0.8;
    transition: all 0.3s ease;
}

.artist-item:hover .artist-image {
    transform: scale(1.1);
    opacity: 1;
}

.track-artwork {
    width: 200px;
    height: 200px;
    border-radius: 10px;
    margin-bottom: 20px;
    box-shadow: 0 4px 15px rgba(0,0,0,0.3);
    transition: all 0.3s ease;
}

.track-artwork:hover {
    transform: scale(1.05);
    box-shadow: 0 8px 25px rgba(0,0,0,0.4);
}

.time-chart {
    display: grid;
    grid-template-columns: repeat(24, 1fr);
    gap: 2px;
    height: 100px;
}

.time-bar {
    width: 100%;
    background: hsl(var(--hue, 120), 70%, 50%);
    transition: 
        height 0.3s ease,
        opacity 0.2s linear;
}

@media (prefers-reduced-motion) {
    .time-bar {
        transition: none;
    }
}

.story-navigation {
    position: fixed;
    bottom: 20px;
    left: 0;
    width: 100%;
    display: flex;
    justify-content: center;
    gap: 20px;
    z-index: 100;
}

.nav-button {
    background: rgba(255, 255, 255, 0.1);
    border: none;
    color: white;
    padding: 10px 20px;
    border-radius: 25px;
    cursor: pointer;
    transition: all 0.3s ease;
}

.nav-button:hover {
    background: rgba(255, 255, 255, 0.2);
}

@keyframes slideUp {
    to {
        transform: translateY(0);
        opacity: 1;
    }
}

.loading {
    display: inline-block;
    width: 30px;
    height: 30px;
    border: 3px solid rgba(255, 255, 255, 0.3);
    border-radius: 50%;
    border-top-color: var(--spotify-green);
    animation: spin 1s ease-in-out infinite;
}

@keyframes spin {
    to { transform: rotate(360deg); }
}

/* TIME COMPARISON */
.time-comparison {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 50px;
    padding: 0 20px;
}

.time-period {
    flex: 1;
    position: relative;
}

.time-badge {
    position: absolute;
    top: -25px;
    left: 50%;
    transform: translateX(-50%);
    background: var(--spotify-green);
    padding: 5px 15px;
    border-radius: 15px;
    font-size: 0.8em;
    z-index: 2;
}

.comparison-artwork {
    width: 200px;
    height: 200px;
    background-size: cover;
    border-radius: 15px;
    position: relative;
    overflow: hidden;
    transition: transform 0.3s ease;
}

.comparison-artwork:hover {
    transform: rotate(-2deg) scale(1.05);
}

.track-overlay {
    position: absolute;
    bottom: 0;
    left: 0;
    right: 0;
    padding: 15px;
    background: linear-gradient(transparent, rgba(0,0,0,0.9));
    color: white;
}

/* GENRE CLOUD */
.genre-cloud {
    display: flex;
    flex-wrap: wrap;
    gap: 10px;
    justify-content: center;
    padding: 0 20px;
}

.genre-pill {
    padding: 12px 20px;
    border-radius: 30px;
    background: linear-gradient(
        45deg,
        hsl(var(--hue), 70%, 50%),
        hsl(var(--hue), 70%, 40%)
    );
    font-size: calc(0.9em * var(--size));
    display: flex;
    align-items: center;
    gap: 8px;
    transition: all 0.3s ease;
    cursor: pointer;
}

.genre-pill:hover {
    transform: translateY(-3px);
    opacity: 0.9;
}

.genre-count {
    font-size: 0.8em;
    opacity: 0.8;
}

.genre-crown {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 10px;
    margin-top: 20px;
    font-size: 1.2em;
    color: var(--spotify-green);
}

.year-summary {
    text-align: center;
    width: 100%;
    max-width: 1400px;
    margin: 0 auto;
    padding: 40px 20px 60px;
    display: flex;
    flex-direction: column;
    justify-content: center;
    min-height: calc(100vh - 120px);
    gap: 30px;
}

.summary-row {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(300px, 1fr));
    gap: 30px;
    width: 100%;
    max-width: 1200px;
    padding: 0 20px;
}

.summary-card {
    background: rgba(255, 255, 255, 0.03);
    border-radius: 12px;
    padding: 25px;
    display: flex;
    flex-direction: column;
    gap: 20px;
    width: 100%;
    max-width: 100%;
    margin: 0 auto;
    box-sizing: border-box;
    min-width: unset;
}

.summary-title {
    font-size: 1.2em;
    margin-bottom: 15px;
    color: var(--spotify-green);
    padding-bottom: 10px;
    border-bottom: 2px solid rgba(255,255,255,0.1);
    text-align: left;
}

.summary-hero {
    text-align: center;
    max-width: 600px;
    margin: 0 auto 40px;
    margin-bottom: -2rem;
}

.hero-image {
    width: 90px;
    height: 90px;
    border-radius: 10px;
    object-fit: cover;
}

.hero-details {
    text-align: center;
    margin-bottom: 40px;
}

.hero-name {
    text-align: center;
    font-size: 2.2em;
    margin-bottom: 10px;
}

.hero-meta {
    text-align: center;
    font-size: 1.4em;
    color: var(--spotify-green);
}

.top-list {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
    gap: 10px;
    text-align: left;
}

.summary-item {
    display: flex;
    align-items: center;
    padding: 10px;
    background: rgba(255, 255, 255, 0.03);
    border-radius: 8px;
    transition: background 0.3s ease;
    gap: 12px;
}

.summary-item:hover {
    background: rgba(255, 255, 255, 0.06);
}

.rank {
    width: 25px;
    text-align: center;
    font-weight: 500;
    opacity: 0.7;
    margin-right: 10px;
}

.summary-details {
    flex: 1;
    min-width: 0;
}

.name {
    font-size: clamp(0.9em, 3vw, 1.1em);
    font-weight: 500;
    margin-bottom: 2px;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    max-width: 95%;
}

.meta {
    font-size: clamp(0.8em, 2.5vw, 0.95em);
    opacity: 0.7;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    max-width: 95%;
}

.stats-grid {
    width: 100%;
    max-width: 1200px;
    margin: 0 auto;
    padding: 0 20px;
    text-align: center;
}

.stat-box {
    background: linear-gradient(
        45deg,
        hsl(var(--hue), 70%, 20%),
        hsl(var(--hue), 70%, 30%)
    );
    padding: 8px 16px;
    border-radius: 20px;
    text-align: center;
    display: inline-flex;
    align-items: center;
    gap: 6px;
    margin: 0 auto;
}

.stat-value {
    font-size: 1.1em;
    font-weight: 500;
    margin: 0;
    color: var(--spotify-green);
}

.stat-label {
    font-size: 0.9em;
    opacity: 0.8;
    margin: 0;
}

@media (max-width: 1200px) {
    .year-summary {
        padding: 40px 15px;
        min-height: auto;
    }
    
    .year-summary .summary-row {
        grid-template-columns: 1fr;
        gap: 40px;
        padding: 0;
    }
    
    .summary-card {
        max-width: 100%;
        padding: 25px 20px;
    }
    
    .summary-hero {
        gap: 15px;
        margin-bottom: -20px;
    }
}

@media (min-width: 768px) {
    .year-summary .summary-row {
        display: grid !important;
        grid-template-columns: repeat(2, minmax(400px, 1fr));
        gap: 40px;
    }
    
    .summary-card {
        max-width: 100%;
        min-width: unset;
        width: 100%;
    }
    
    .story-content {
        padding: 120px 20px 150px;
    }
    
    .year-summary {
        padding: 10rem 20px 80px;
        margin-top: -10rem;
    }
}

@media (min-width: 1200px) {
    .summary-row {
        max-width: 1400px !important;
        gap: 60px !important;
    }
    
    .summary-card {
        padding: 40px !important;
    }
}

@media (max-width: 768px) {
    .welcome-message {
        font-size: 2em;
    }
    
    .welcome-subtitle {
        font-size: 1em;
        margin-bottom: 25px;
    }
    
    .spotify-login-btn {
        padding: 12px 25px;
        font-size: 1.1em;
    }
    
    .welcome-message::after {
        right: -20px;
        top: -5px;
    }
    
    .story-title {
        margin: 30px 0 15px 0;
    }
    
    .story-subtitle {
        margin: 0 0 25px 0;
    }
    
    .story-stat {
        font-size: 2em;
    }
    
    .track-artwork {
        width: 150px;
        height: 150px;
    }
    
    .artist-grid {
        grid-template-columns: 1fr;
        gap: 10px;
        padding: 0 15px;
    }
    
    .artist-item {
        min-height: 200px;
    }
    
    .time-comparison {
        flex-direction: column;
        gap: 30px;
    }
    
    .comparison-artwork {
        width: 150px;
        height: 150px;
    }
    
    .genre-cloud {
        margin: 15px auto;
        gap: 8px;
    }
    
    .genre-pill {
        padding: 6px 12px;
        font-size: calc(0.75em * var(--size));
    }
    
    .playlist-additions {
        gap: 8px;
        margin-top: 10px;
    }
    
    .addition-item {
        padding: 8px;
    }
    
    .addition-image {
        width: 45px;
        height: 45px;
        margin: 0 8px;
    }
    
    .addition-track {
        font-size: 0.9em;
        margin-bottom: 2px;
    }
    
    .addition-artist {
        font-size: 0.8em;
        margin-bottom: 2px;
    }
    
    .addition-playlist,
    .addition-date {
        font-size: 0.7em;
    }
    
    .addition-rank {
        font-size: 1em;
        width: 25px;
    }
    
    .story-navigation {
        bottom: 10px;
    }
    
    .story-progress {
        top: 10px;
    }
    
    .story-content {
        padding-top: 60px;
        padding-bottom: 100px;
        justify-content: flex-start;
        overflow-y: auto;
    }
    
    .summary-card {
        min-width: 100%;
        max-width: 100%;
    }
    
    .summary-row {
        grid-template-columns: 1fr;
        gap: 20px;
        padding: 0 15px;
    }
    
    .genre-cloud,
    .playlist-additions,
    .time-comparison {
        padding: 0 10px;
    }
    
    .artist-item > div {
        padding: 8px;
    }
    
    .artist-item .stat-detail {
        padding: 6px 10px;
        margin-top: 10px;
    }
    
    .artist-item .genre-tag {
        font-size: 0.85em;
    }
    
    .hero-image {
        width: 70px;
        height: 70px;
    }
    
    .hero-name {
        font-size: 1em;
        margin-bottom: 2px;
    }
    
    .hero-meta {
        font-size: 0.8em;
    }
    
    .summary-title {
        font-size: 0.9em;
        margin-bottom: 8px;
        padding-bottom: 8px;
    }
    
    .rank {
        width: 18px;
        margin-right: 8px;
        font-size: 0.9em;
    }

    .year-summary {
        padding: 40px 15px 60px !important;
        margin-top: 0 !important;
    }

    .summary-row {
        grid-template-columns: 1fr;
        gap: 20px;
        padding: 0 15px;
    }

    .top-list {
        grid-template-columns: 1fr;
    }

    .summary-item {
        padding: 8px;
    }

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

@media (max-width: 480px) {
    .welcome-message {
        font-size: 1.8em;
    }
    
    .welcome-subtitle {
        font-size: 0.9em;
        margin-bottom: 20px;
    }
    
    .spotify-login-btn {
        padding: 10px 20px;
        font-size: 1em;
    }
    
    .welcome-message::after {
        right: -15px;
        top: -5px;
        font-size: 0.5em;
    }
    
    .story-title {
        margin: 40px 0 10px 0;
        font-size: 1.8em;
    }
    
    .story-subtitle {
        margin-bottom: 20px;
    }
    
    .track-artwork {
        width: 120px;
        height: 120px;
    }
    
    .artist-item {
        min-height: 180px;
    }
    
    .comparison-artwork {
        width: 120px;
        height: 120px;
    }
    
    .genre-cloud {
        gap: 6px;
        margin: 10px auto;
    }
    
    .genre-pill {
        padding: 5px 10px;
        font-size: calc(0.7em * var(--size));
    }
    
    .playlist-additions {
        gap: 6px;
    }
    
    .addition-image {
        width: 40px;
        height: 40px;
        margin: 0 6px;
    }
    
    .addition-track {
        font-size: 0.85em;
    }
    
    .addition-artist {
        font-size: 0.75em;
    }
    
    .addition-playlist,
    .addition-date {
        font-size: 0.65em;
    }
    
    .story-navigation {
        bottom: 8px;
    }
    
    .story-progress {
        top: 8px;
    }
    
    .story-stat {
        font-size: 1.8em;
    }
    
    .genre-cloud,
    .playlist-additions,
    .time-comparison {
        padding: 0 8px;
    }
    
    .artist-item > div {
        padding: 6px;
    }
    
    .artist-item .stat-detail {
        padding: 4px 8px;
        margin-top: 8px;
    }
    
    .artist-item .genre-tag {
        font-size: 0.8em;
    }
    
    .summary-row {
        padding: 0 10px;
        gap: 15px;
    }
    
    .hero-image {
        width: 150px !important;
        height: 150px !important;
    }
    
    .hero-name {
        font-size: 1.8em;
        margin-bottom: 5px;
    }
    
    .hero-meta {
        font-size: 1.1em;
    }
    
    .summary-title {
        font-size: 0.85em;
        margin-bottom: 6px;
        padding-bottom: 6px;
    }
    
    .summary-item {
        padding: 6px;
    }
    
    .name {
        font-size: 0.85em;
        margin-bottom: 0;
    }
    
    .meta {
        font-size: 0.7em;
    }
    
    .rank {
        width: 16px;
        margin-right: 6px;
        font-size: 0.85em;
    }

    .summary-row {
        gap: 12px;
        padding: 0 10px;
    }

    .hero-image {
        width: 150px !important;
        height: 150px !important;
    }

    .summary-item {
        padding: 6px;
    }

    .year-summary {
        padding: 30px 10px 50px !important;
    }

    .summary-row {
        padding: 0 10px;
        gap: 15px;
    }

    .summary-card {
        padding: 15px;
    }

    .stat-box {
        padding: 6px 12px;
    }

    .summary-hero {
        margin-top: 40px !important;
        margin-bottom: 20px !important;
    }
    
    .hero-image {
        width: 100px !important;
        height: 100px !important;
    }
    
    [data-index="10"] .story-content {
        min-height: unset;
        padding-top: 60px;
        justify-content: flex-start;
    }
}

/* Fix for the rhythm clock on mobile */
@media (max-width: 768px) {
    [data-index="4"] .story-content {
        transform: none;
        margin-top: 0;
        padding: 20px;
    }
}

/* Ensure content is centered and properly scaled */
.story-content {
    max-width: 100%;
    width: 100%;
    padding: 80px 20px 100px;
    box-sizing: border-box;
    margin: 0 auto;
    scrollbar-width: none; /* Firefox */
    -ms-overflow-style: none; /* IE and Edge */
}

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

/* Ensure images don't overflow */
img {
    max-width: 100%;
    height: auto;
}

/* Better touch targets for mobile */
.addition-item,
.genre-pill,
.nav-button {
    min-height: 44px;
}

/* Improve readability on small screens */
.stat-detail {
    max-width: 280px;
    margin-left: auto;
    margin-right: auto;
}

/* Fix for story navigation on mobile */
.story-navigation {
    padding: 0 10px;
    gap: 10px;
}

/* Ensure proper spacing in grid layouts */
.stats-grid {
    display: grid;
    gap: 15px;
    padding: 0 10px;
}

/* Fix for long text overflow */
.track-title,
.track-artist,
.addition-track,
.addition-artist,
.addition-playlist {
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    max-width: 100%;
}

/* PLAYLIST ADDITIONS */
.playlist-additions {
    display: flex;
    flex-direction: column;
    gap: 15px;
    max-width: 600px;
    margin: 0 auto;
    padding: 0 20px;
}

.addition-item {
    display: flex;
    align-items: center;
    background: rgba(255, 255, 255, 0.05);
    padding: 15px;
    border-radius: 10px;
    transition: all 0.3s ease;
    width: 100%;
    max-width: 600px;
    margin-left: auto;
    margin-right: auto;
}

.addition-details {
    flex: 1;
    min-width: 0; /* Critical for text-overflow to work */
    margin-right: 10px;
}

.addition-track,
.addition-artist,
.addition-playlist {
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    width: 100%;
    display: block; /* Ensures the ellipsis works */
}

.addition-rank {
    font-size: 1.2em;
    font-weight: 600;
    color: var(--spotify-green);
    width: 30px;
    text-align: center;
}

.addition-image {
    width: 60px;
    height: 60px;
    border-radius: 8px;
    margin: 0 15px;
    object-fit: cover;
}

.addition-track {
    font-size: 1.1em;
    font-weight: 500;
    margin-bottom: 3px;
}

.addition-artist {
    font-size: 0.9em;
    color: rgba(255, 255, 255, 0.7);
    margin-bottom: 5px;
}

.addition-playlist {
    font-size: 0.8em;
    color: var(--spotify-green);
}

.addition-date {
    font-size: 0.8em;
    color: rgba(255, 255, 255, 0.5);
    margin-top: 3px;
}

@media (max-width: 768px) {
    .addition-item {
        padding: 10px;
        gap: 8px;
    }

    .addition-image {
        width: 45px;
        height: 45px;
        margin: 0 8px;
        flex-shrink: 0; /* Prevent image from shrinking */
    }

    .addition-rank {
        width: 25px;
        flex-shrink: 0; /* Prevent rank from shrinking */
    }

    .addition-details {
        margin-right: 5px;
    }

    /* Ensure text containers don't overflow */
    .addition-track {
        font-size: 0.9em;
        margin-bottom: 2px;
    }

    .addition-artist {
        font-size: 0.8em;
        margin-bottom: 2px;
    }

    .addition-playlist,
    .addition-date {
        font-size: 0.7em;
    }
}

@media (max-width: 480px) {
    .addition-item {
        padding: 8px;
        gap: 6px;
    }

    .addition-image {
        width: 40px;
        height: 40px;
        margin: 0 6px;
    }

    .addition-track {
        font-size: 0.85em;
    }

    .addition-artist {
        font-size: 0.75em;
    }

    .addition-playlist,
    .addition-date {
        font-size: 0.65em;
    }

    .addition-details {
        margin-right: 3px;
    }
}

/* Add fade effect for overflow content */
.story-card::after {
    display: none;
}

.story-card.has-overflow::after {
    opacity: 1;
}

/* Ensure proper centering for all story content */
.story-card {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    display: flex;
    flex-direction: column;
    justify-content: center;
    align-items: center;
    padding: 20px;
    text-align: center;
    opacity: 0;
    transform: scale(0.95);
    transition: all 0.5s ease;
    background: var(--background);
    overflow-y: auto;
}

.story-content {
    max-width: 1200px;
    width: 100%;
    margin: 0 auto;
    padding: 20px;
    box-sizing: border-box;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    min-height: calc(100vh - 120px);
}

/* Center all grid and flex containers */
.artist-grid,
.genre-cloud,
.playlist-additions,
.time-comparison,
.year-summary,
.summary-row {
    width: 100%;
    margin-left: auto;
    margin-right: auto;
}

/* Ensure proper width and centering for summary cards */
.summary-row {
    display: flex;
    justify-content: center;
    gap: 30px;
    flex-wrap: wrap;
    padding: 0 20px 20px;
}

.summary-card {
    flex: 1;
    min-width: 339px;
    max-width: 437px;
}

/* Center the genre cloud items */
.genre-cloud {
    display: flex;
    flex-wrap: wrap;
    gap: 10px;
    justify-content: center;
    padding: 0 20px;
}

/* Center time comparison elements */
.time-comparison {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 50px;
    padding: 0 20px;
}

/* Center playlist additions */
.playlist-additions {
    padding: 0 20px;
}

.addition-item {
    max-width: 600px;
    margin-left: auto;
    margin-right: auto;
}

/* Ensure proper centering for the clock visualization */
[data-index="4"] .story-content {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
}

@media (max-width: 768px) {
    .story-content {
        min-height: calc(100vh - 100px);
        padding: 15px 10px;
    }
    
    .summary-card {
        min-width: 100%;
        max-width: 100%;
    }
    
    .summary-row {
        padding: 0 10px 20px;
    }
    
    .genre-cloud,
    .playlist-additions,
    .time-comparison {
        padding: 0 10px;
    }
}

@media (max-width: 480px) {
    .story-content {
        min-height: calc(100vh - 90px);
        padding: 10px 8px;
    }
    
    .genre-cloud,
    .playlist-additions,
    .time-comparison {
        padding: 0 8px;
    }
}

/* Fix for the stats grid */
.stats-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(250px, 1fr));
    gap: 15px;
    width: 100%;
    max-width: 600px;
    margin: 20px auto;
    padding: 0 20px;
}

/* Ensure proper vertical spacing */
.story-stat,
.stat-detail,
.genre-crown {
    width: 100%;
    text-align: center;
    margin-left: auto;
    margin-right: auto;
}

/* Add horizontal scroll prevention */
.summary-card, .stats-grid, .top-list {
    overflow: hidden;
}

/* Better text truncation */
.name, .meta {
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    max-width: 95%;
}

/* Touch target improvements */
.summary-item {
    min-height: 44px;
}

.clock-container {
    position: relative;
    width: 80vmin;
    height: 80vmin;
    max-width: 400px;
    max-height: 400px;
    margin: 20px auto;
}

.rhythm-clock {
    width: 100%;
    height: 100%;
    filter: drop-shadow(0 0 5px rgba(30, 215, 96, 0.3));
}

.rhythm-line {
    transition: all 0.3s ease;
}

.rhythm-line:hover {
    stroke-width: 3px !important;
    stroke-opacity: 1 !important;
}

.peak-time {
    text-align: center;
    font-size: 1.2em;
    margin-top: 20px;
    animation: pulseGlow 2s infinite;
}

@keyframes pulseGlow {
    0% { text-shadow: 0 0 5px var(--spotify-green); }
    50% { text-shadow: 0 0 15px var(--spotify-green); }
    100% { text-shadow: 0 0 5px var(--spotify-green); }
}

/* Target the main character card specifically */
[data-index="3"] .artist-item > div {
    display: flex;
    flex-direction: column;
    align-items: center;
    text-align: center;
    padding: 20px !important;
    gap: 8px;
}

