/* Modern CSS Variables for consistent theming */
:root {
    --primary-color: #015495;
    --secondary-color: #F15E22;
    --accent-color: #029500;
    --text-dark: #1a1a1a;
    --text-light: #666;
    --background-light: #f8f9fa;
    --white: #ffffff;
    --border-radius: 16px;
    --shadow-light: 0 2px 8px rgba(0, 0, 0, 0.1);
    --shadow-medium: 0 4px 20px rgba(0, 0, 0, 0.15);
    --shadow-hover: 0 8px 32px rgba(0, 0, 0, 0.2);
    --transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    --max-width: 1200px;
}

/* Reset and base styles */
* {
    box-sizing: border-box;
}

body {
    margin: 0;
    padding: 0;
    font-family: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
    background: linear-gradient(135deg, #f5f7fa 0%, #c3cfe2 100%);
    min-height: 100vh;
    line-height: 1.6;
    overflow-x: hidden; /* Prevent horizontal scrolling only */
}

/* Main content layout */
.main-content {
    min-height: calc(100vh - 80px); /* Use min-height instead of fixed height */
    display: flex;
    flex-direction: column;
    /* justify-content: center; */
    padding: 1rem;
    padding-top: 1.5rem; /* Add space between navbar and content */
}

.container {
    max-width: var(--max-width);
    margin: 0 auto;
    width: 100%;
    height: 100%;
    display: flex;
    flex-direction: column;
    justify-content: space-between;
}

/* Hero section */
.hero-section {
    text-align: center;
    flex-shrink: 0;
    margin-bottom: 1.5rem; /* Reduced from 2rem */
}

.title {
    font-size: clamp(1.75rem, 4vw, 2.5rem);
    font-weight: 900;
    background: linear-gradient(135deg, var(--secondary-color), #ff7849);
    color: var(--white);
    padding: clamp(0.75rem, 2vw, 1.5rem);
    margin: 0 0 0.75rem 0;
    border-radius: var(--border-radius);
    box-shadow: var(--shadow-medium);
    line-height: 1.2;
    letter-spacing: -0.02em;
}

.subtitle {
    font-size: clamp(1rem, 2.5vw, 1.25rem);
    color: var(--text-light);
    margin: 0;
    font-weight: 400;
}

/* Character selection section */
.character-selection {
    max-width: 100%;
    flex: 1;
    display: flex;
    flex-direction: column;
    justify-content: center;
    min-height: 0; /* Allow flex shrinking */
}

.selection-title {
    text-align: center;
    font-size: clamp(1.5rem, 3vw, 2rem);
    color: var(--primary-color);
    margin-bottom: 2rem; /* Set to consistent 2rem everywhere */
    font-weight: 700;
    position: relative;
    flex-shrink: 0;
}

.selection-title::after {
    content: '';
    position: absolute;
    bottom: -10px;
    left: 50%;
    transform: translateX(-50%);
    width: 60px;
    height: 4px;
    background: var(--secondary-color);
    border-radius: 2px;
}

/* Character grid */
.character-grid {
    display: flex;
    flex-wrap: wrap;
    gap: 1rem;
    padding: 0;
    width: 100%;
    margin: 0 auto;
    justify-content: center;
}

/* Character cards */
.character-card {
    background: var(--white);
    border-radius: clamp(8px, 2vw, 16px);
    box-shadow: var(--shadow-light);
    transition: var(--transition);
    cursor: pointer;
    border: 2px solid transparent;
    position: relative;
    overflow: hidden;
    aspect-ratio: 1;
    flex-shrink: 0;
}

.character-image-wrapper {
    position: absolute;
    inset: 0;
    width: 100%;
    height: 100%;
}

.character-card::before {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    height: 4px;
    background: linear-gradient(90deg, var(--primary-color), var(--secondary-color));
    transform: scaleX(0);
    transition: var(--transition);
}

.character-card:hover {
    transform: translateY(-4px);
    box-shadow: var(--shadow-hover);
    border-color: var(--primary-color);
}

.character-card:hover::before {
    transform: scaleX(1);
}

.character-card:active {
    transform: translateY(-2px);
}

/* Reduce hover effects on touch devices */
@media (hover: none) and (pointer: coarse) {
    .character-card:hover {
        transform: none;
        box-shadow: var(--shadow-light);
    }
    
    .character-card:hover .character-image {
        transform: none;
    }
    
    .character-card:active {
        transform: scale(0.98);
    }
}

/* Character image wrapper */
.character-image-wrapper {
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background-color: #eef3fb;
}

.character-image {
    width: 100%;
    height: 100%;
    object-fit: cover;
    border-radius: clamp(8px, 2vw, 16px);
    display: block;
}

.character-card:hover .character-image {
    border-color: var(--secondary-color);
    transform: scale(1.05);
}

/* Character info */
.character-info {
    flex-shrink: 0;
}

.character-name {
    font-size: clamp(1rem, 2.5vw, 1.25rem);
    color: var(--primary-color);
    margin: 0 0 0.25rem 0;
    font-weight: 600;
}

.character-description {
    color: var(--text-light);
    margin: 0;
    font-size: clamp(0.75rem, 2vw, 0.9rem);
    font-weight: 400;
}

/* Responsive design */

/* Portrait layout */
@media (orientation: portrait) {
    .character-card {
        width: calc((100% - 1rem) / 2);
    }

    .character-grid {
        width: min(90%, 600px);
    }

    .main-content {
        padding: 1rem;
        min-height: calc(100vh - 80px);
    }

    .selection-title {
        margin-bottom: 2rem;
    }
}

/* Landscape layout */
@media (orientation: landscape) {
    .character-card {
        width: calc((100% - 3rem) / 4);
    }

    .character-grid {
        flex-wrap: nowrap;
        width: 95%;
        align-items: center;
    }

    .main-content {
        padding: 1rem;
        min-height: calc(100vh - 80px);
        display: flex;
        align-items: center;
    }


    .selection-title {
        margin-bottom: 1.5rem;
    }
}

/* Mobile portrait */
@media (max-width: 479px) {
    .character-grid {
        grid-template-columns: repeat(2, 1fr);
        gap: 0.75rem;
    }
    
    .main-content {
        padding: 0.75rem;
        min-height: calc(100vh - 70px);
        padding-top: 1.5rem;
    }
    
    .hero-section {
        margin-bottom: 0.75rem;
    }
    
    .title {
        font-size: 1.3rem;
        padding: 0.6rem 1.2rem;
        margin-bottom: 0.5rem;
    }
    
    .subtitle {
        font-size: 0.95rem;
    }
    
    .selection-title {
        font-size: 1.3rem;
        margin-bottom: 2rem;
    }
}

/* Extra small devices */
@media (max-width: 320px) {
    .character-grid {
        gap: 0.5rem;
    }
    
    .main-content {
        min-height: calc(100vh - 65px);
        padding-top: 1.2rem;
    }
    
    .title {
        font-size: 1.1rem;
        padding: 0.5rem 1rem;
    }
    
    .selection-title {
        font-size: 1.1rem;
        margin-bottom: 2rem;
    }
}

/* High-resolution displays */
@media (-webkit-min-device-pixel-ratio: 2), (min-resolution: 192dpi) {
    .character-image {
        image-rendering: -webkit-optimize-contrast;
        image-rendering: crisp-edges;
    }
}

/* Dark mode support (if needed in future) */
@media (prefers-color-scheme: dark) {
    /* Dark mode styles can be added here if needed */
}

/* Reduced motion for accessibility */
@media (prefers-reduced-motion: reduce) {
    * {
        animation-duration: 0.01ms !important;
        animation-iteration-count: 1 !important;
        transition-duration: 0.01ms !important;
    }
    
    .character-card:hover {
        transform: none;
    }
    
    .character-card:hover .character-image {
        transform: none;
    }
}

/* Focus styles for accessibility */
.character-card:focus {
    outline: 3px solid var(--secondary-color);
    outline-offset: 2px;
}

.character-card:focus-visible {
    outline: 3px solid var(--secondary-color);
    outline-offset: 2px;
}

.character-card.keyboard-focused {
    transform: translateY(-4px);
    box-shadow: var(--shadow-hover);
    border-color: var(--secondary-color);
}

/* Loading state animation */
.character-image[src=""] {
    background: linear-gradient(90deg, #f0f0f0 25%, #e0e0e0 50%, #f0f0f0 75%);
    background-size: 200% 100%;
    animation: loading 1.5s infinite;
}

@keyframes loading {
    0% {
        background-position: 200% 0;
    }
    100% {
        background-position: -200% 0;
    }
}

/* Additional mobile optimizations */
html {
    height: 100%;
    overflow-x: hidden; /* Prevent horizontal scroll only */
}

/* Handle different mobile orientations */
@media screen and (orientation: landscape) and (max-height: 500px) {
    .main-content {
        min-height: calc(100vh - 50px);
        padding: 0.5rem;
        padding-top: 0.75rem;
    }
    
    .hero-section {
        margin-bottom: 0.5rem;
    }
    
    .title {
        font-size: 1.1rem;
        padding: 0.3rem 0.8rem;
        margin-bottom: 0.25rem;
    }
    
    .subtitle {
        font-size: 0.8rem;
    }
    
    .selection-title {
        font-size: 1.1rem;
        margin-bottom: 1rem;
    }
    
    .character-grid {
        gap: 0.5rem;
    }
}

/* Handle very wide screens */
@media (min-width: 1400px) {
    .character-grid {
        max-width: 1400px;
    }
}

/* Prevent zoom on input focus (iOS) */
input, select, textarea {
    font-size: 16px !important;
}

