:root {
    --primary-color: #6366f1;
    /* Indigo */
    --primary-hover: #4f46e5;
    --bg-gradient: linear-gradient(135deg, #0f172a 0%, #1e293b 100%);
    --card-bg: rgba(255, 255, 255, 0.1);
    --text-color: #f8fafc;
    --text-muted: #94a3b8;
    --border-radius: 16px;
    --font-family: 'Outfit', sans-serif;
}

* {
    box-sizing: border-box;
    margin: 0;
    padding: 0;
    -webkit-tap-highlight-color: transparent;
}

/* IOS SAFARI BACKGROUND FIX */
html {
    background-color: #0f172a;
    /* Fallback color */
    height: 100%;
}

body {
    font-family: var(--font-family);
    color: var(--text-color);

    /* Full height, including address bar area */
    min-height: 100vh;
    min-height: 100dvh;

    display: flex;
    justify-content: center;

    /* Safe Area Padding for notch devices */
    padding: 20px;
    padding-top: max(20px, env(safe-area-inset-top));
    padding-bottom: max(20px, env(safe-area-inset-bottom));

    overflow-x: hidden;
    position: relative;
    z-index: 0;
}

/* FIXED Background Gradient - Stays put during scroll/bounce */
body::before {
    content: "";
    position: fixed;
    top: 0;
    left: 0;
    width: 100vw;
    height: 100vh;
    height: 100dvh;
    background: var(--bg-gradient);
    z-index: -1;
    pointer-events: none;
}

.app-container {
    width: 100%;
    max-width: 600px;
    /* Tablet/Desktop constraint */
    display: flex;
    flex-direction: column;
    gap: 2rem;
}

/* Header */
header {
    text-align: center;
    padding: 1rem 0;
}

header h1 {
    font-size: 2.5rem;
    font-weight: 700;
    background: linear-gradient(to right, #818cf8, #c084fc);
    -webkit-background-clip: text;
    background-clip: text;
    -webkit-text-fill-color: transparent;
    margin-bottom: 0.5rem;
}

header p {
    color: var(--text-muted);
    font-size: 1rem;
}

/* Views Management */
.view {
    display: none;
    animation: fadeIn 0.5s ease-out;
}

.view.active {
    display: block;
}

@keyframes fadeIn {
    from {
        opacity: 0;
        transform: translateY(10px);
    }

    to {
        opacity: 1;
        transform: translateY(0);
    }
}

/* Input Card */
.input-card {
    background: transparent;
    border: none;
    box-shadow: none;
    padding: 2rem 0;

    display: flex;
    flex-direction: column;
    gap: 1.5rem;
}

label {
    font-size: 1.1rem;
    font-weight: 500;
    text-align: center;
    /* Center labels */
    width: 100%;
}

input[type="text"] {
    width: 100%;
    padding: 1rem;
    border-radius: 12px;
    border: 2px solid rgba(255, 255, 255, 0.2);
    background: rgba(0, 0, 0, 0.2);
    color: white;
    font-size: 1.1rem;
    font-family: inherit;
    transition: all 0.3s;
}

input[type="text"]:focus {
    outline: none;
    border-color: var(--primary-color);
    background: rgba(0, 0, 0, 0.4);
}

/* Divider */
.divider {
    display: flex;
    align-items: center;
    text-align: center;
    margin: 1rem 0;
    color: var(--text-muted);
}

.divider::before,
.divider::after {
    content: '';
    flex: 1;
    border-bottom: 1px solid rgba(255, 255, 255, 0.1);
}

.divider span {
    padding: 0 10px;
    font-size: 0.9rem;
    font-weight: 500;
}

/* Dropdown */
select {
    width: 100%;
    padding: 1rem;
    border-radius: 12px;
    border: 2px solid rgba(255, 255, 255, 0.2);
    background: rgba(0, 0, 0, 0.2);
    color: white;
    font-size: 1.1rem;
    font-family: inherit;
    cursor: pointer;
    appearance: none;
    /* Remove default arrow */
    background-image: url("data:image/svg+xml;charset=US-ASCII,%3Csvg%20xmlns%3D%22http%3A%2F%2Fwww.w3.org%2F2000%2Fsvg%22%20width%3D%22292.4%22%20height%3D%22292.4%22%3E%3Cpath%20fill%3D%22%23FFFFFF%22%20d%3D%22M287%2069.4a17.6%2017.6%200%200%200-13-5.4H18.4c-5%200-9.3%201.8-12.9%205.4A17.6%2017.6%200%200%200%200%2082.2c0%205%201.8%209.3%205.4%2012.9l128%20127.9c3.6%203.6%207.8%205.4%2012.8%205.4s9.2-1.8%2012.8-5.4L287%2095c3.5-3.5%205.4-7.8%205.4-12.8%200-5-1.9-9.2-5.5-12.8z%22%2F%3E%3C%2Fsvg%3E");
    background-repeat: no-repeat;
    background-position: right 1rem top 50%;
    background-size: 0.65rem auto;
    transition: all 0.3s;
}

select:focus {
    outline: none;
    border-color: var(--primary-color);
    background-color: rgba(0, 0, 0, 0.4);
}

select option {
    background: #1e293b;
    /* Dark background for dropdown options */
    color: white;
}

/* Secondary Action Button (Load) */
.secondary-action {
    background: transparent;
    border: 1px solid var(--primary-color);
    color: var(--primary-color);
    box-shadow: none;
}

.secondary-action:hover {
    background: rgba(99, 102, 241, 0.1);
}

.hidden {
    display: none !important;
}

/* Accordion Styles */
.hidden-accordion {
    max-height: 0;
    overflow: hidden;
    opacity: 0;
    transition: max-height 0.3s ease-out, opacity 0.3s ease-out;
    display: flex;
    flex-direction: column;
    gap: 1rem;
}

.hidden-accordion.open {
    max-height: 200px;
    /* Approximate height needed */
    opacity: 1;
    margin-top: 0.5rem;
}

/* Buttons */
button {
    cursor: pointer;
    font-family: inherit;
    border: none;
    transition: transform 0.2s, opacity 0.2s;
}

button:active {
    transform: scale(0.98);
}

.primary-btn {
    background: var(--primary-color);
    color: white;
    padding: 1rem;
    border-radius: 12px;
    font-size: 1.1rem;
    font-weight: 600;
    width: 100%;
    box-shadow: 0 4px 15px rgba(99, 102, 241, 0.4);
}

.primary-btn:hover {
    background: var(--primary-hover);
}

.secondary-btn {
    background: rgba(255, 255, 255, 0.1);
    color: white;
    padding: 0.5rem 1rem;
    border-radius: 8px;
    font-size: 0.9rem;
}

.secondary-btn:hover {
    background: rgba(255, 255, 255, 0.2);
}

/* Loading State & Dino Animation */
#loading-indicator {
    text-align: center;
    padding: 2rem 0;
    overflow: hidden;
    /* Ensure animation doesn't overflow */
}

#loading-indicator.hidden {
    display: none;
}

.dino-wrapper {
    position: relative;
    width: 300px;
    height: 100px;
    margin: 0 auto 1.5rem;
    border-bottom: 2px solid rgba(255, 255, 255, 0.2);
    overflow: hidden;
}

.dino {
    font-size: 40px;
    line-height: 40px;
    position: absolute;
    bottom: 0;
    left: 20px;
    /* Remove block styles */
    width: auto;
    height: auto;
    background: transparent;
    box-shadow: none;
}

/* Remove CSS shape adjustments */
.dino::before {
    display: none;
}

.dino {
    /* Flip dino to face right */
    transform: scaleX(-1);
    animation: jump 1.5s infinite ease-in-out;
    animation-delay: 0.9s;
    z-index: 2;
}

.fart {
    font-size: 24px;
    position: absolute;
    /* Start position aligned with where dino is at peak approx */
    left: 10px;
    bottom: 60px;
    /* Peak height */
    opacity: 0;
    z-index: 1;
    animation: farting 1.5s infinite linear;
    animation-delay: 0.9s;
    /* Sync with dino */
}

.cactus {
    font-size: 30px;
    line-height: 30px;
    position: absolute;
    bottom: 0;

    /* Start outside to the right */
    right: -40px;

    /* Remove block styles */
    width: auto;
    height: auto;
    background: transparent;
    border-radius: 0;

    animation: moveCactus 1.5s infinite linear;
}

@keyframes jump {

    0%,
    100% {
        transform: translateY(0) scaleX(-1);
    }

    15% {
        transform: translateY(-60px) rotate(-10deg) scaleX(-1);
    }

    30% {
        transform: translateY(0) rotate(0) scaleX(-1);
    }
}

@keyframes farting {

    0%,
    10% {
        opacity: 0;
        transform: translateX(0) scale(0.5) scaleX(-1);
    }

    15% {
        opacity: 1;
        transform: translateX(-10px) scale(1.2) scaleX(-1);
    }

    /* Peak visibility */
    30%,
    100% {
        opacity: 0;
        transform: translateX(-30px) scale(1.5) scaleX(-1);
    }
}

@keyframes moveCactus {
    0% {
        transform: translateX(0);
    }

    100% {
        transform: translateX(-350px);
    }
}

/* Game Grid & Controls */
.game-controls {
    display: flex;
    justify-content: space-between;
    align-items: center;
    background: var(--card-bg);
    padding: 0.5rem 1rem;
    border-radius: 12px;
    backdrop-filter: blur(5px);
    margin-bottom: 0.5rem;
    position: sticky;
    /* Keep header visible */
    top: 10px;
    z-index: 10;
    border: 1px solid rgba(255, 255, 255, 0.1);
}

.header-info h2 {
    font-size: 1rem;
    font-weight: 500;
}

.header-info p {
    font-size: 0.8rem;
    color: var(--text-muted);
}

.secret-char {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 2px;
}

.secret-char span {
    font-size: 0.6rem;
    text-transform: uppercase;
    letter-spacing: 1px;
    color: var(--primary-color);
}

.secret-char img {
    width: 40px;
    height: 40px;
    border-radius: 8px;
    border: 2px solid var(--primary-color);
    object-fit: cover;
}

.actions-bar {
    display: flex;
    justify-content: flex-end;
    margin-bottom: 1rem;
}

.actions-bar.centered-bottom {
    justify-content: center;
    margin-top: 2rem;
    margin-bottom: 2rem;
}

.grid-container {
    display: grid;
    /* 3 columns on mobile default */
    grid-template-columns: repeat(3, 1fr);
    gap: 10px;
    padding-bottom: 2rem;
}

@media (min-width: 480px) {
    .grid-container {
        grid-template-columns: repeat(4, 1fr);
        /* 4 columns on larger phones/tablets */
    }
}

.card {
    position: relative;
    aspect-ratio: 1;
    /* Square cards */
    border-radius: 12px;
    overflow: hidden;
    cursor: pointer;
    box-shadow: 0 4px 6px rgba(0, 0, 0, 0.2);
    transition: transform 0.2s, filter 0.3s;
    background-color: #334155;
}

.card img {
    width: 100%;
    height: 100%;
    object-fit: cover;
    transition: transform 0.4s;
}

/* Hover effect for active cards */
.card:not(.eliminated):hover img {
    transform: scale(1.25);
}

/* Eliminated State */
.card.eliminated {
    filter: grayscale(100%) brightness(0.4);
    transform: scale(0.95);
}

.card.eliminated::after {
    content: '✖';
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    font-size: 2rem;
    color: rgba(255, 255, 255, 0.5);
    pointer-events: none;
    z-index: 2;
}

.char-name {
    position: absolute;
    bottom: 0;
    left: 0;
    width: 100%;
    background: rgba(0, 0, 0, 0.6);
    color: white;
    font-size: 0.8rem;
    padding: 4px;
    text-align: center;
    backdrop-filter: blur(2px);
}

/* Toast Notification */
.toast {
    position: fixed;
    bottom: 20px;
    left: 50%;
    transform: translateX(-50%);
    background: #10b981;
    /* Green */
    color: white;
    padding: 0.8rem 1.5rem;
    border-radius: 50px;
    font-weight: 500;
    box-shadow: 0 10px 15px -3px rgba(0, 0, 0, 0.1);
    z-index: 100;
    transition: opacity 0.3s, transform 0.3s;
}

.toast.hidden {
    opacity: 0;
    transform: translate(-50%, 20px);
    pointer-events: none;
}