/* ============================================
   AutoGuessr — Design System
   Dark premium theme with automotive accents
   ============================================ */

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

/* ---- CSS Variables ---- */
:root {
    --bg-primary: #08080d;
    --bg-secondary: #0e0e15;
    --bg-card: #13131d;
    --bg-card-hover: #1a1a28;
    --bg-glass: rgba(255, 255, 255, 0.03);
    --bg-glass-hover: rgba(255, 255, 255, 0.06);

    --accent: #f59e0b;
    --accent-hover: #d97706;
    --accent-glow: rgba(245, 158, 11, 0.15);
    --accent-secondary: #ef4444;
    --accent-green: #22c55e;
    --accent-blue: #3b82f6;

    --text-primary: #f1f1f5;
    --text-secondary: #9ca3af;
    --text-muted: #5b5b6b;

    --border: rgba(255, 255, 255, 0.06);
    --border-hover: rgba(255, 255, 255, 0.12);

    --radius-sm: 8px;
    --radius-md: 12px;
    --radius-lg: 16px;
    --radius-xl: 24px;
    --radius-full: 9999px;

    --shadow-sm: 0 1px 2px rgba(0,0,0,0.3);
    --shadow-md: 0 4px 12px rgba(0,0,0,0.4);
    --shadow-lg: 0 8px 32px rgba(0,0,0,0.5);
    --shadow-glow: 0 0 40px var(--accent-glow);

    --transition-fast: 0.15s ease;
    --transition-normal: 0.3s ease;
    --transition-slow: 0.5s ease;
}

/* ---- Reset & Base ---- */
*, *::before, *::after {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

html {
    font-size: 16px;
    scroll-behavior: smooth;
}

body {
    font-family: 'Inter', -apple-system, BlinkMacSystemFont, sans-serif;
    background: var(--bg-primary);
    color: var(--text-primary);
    line-height: 1.6;
    min-height: 100vh;
    overflow-x: hidden;
    -webkit-font-smoothing: antialiased;
}

/* ---- Animated Background ---- */
.bg-grid {
    position: fixed;
    inset: 0;
    z-index: 0;
    pointer-events: none;
    background-image:
        linear-gradient(rgba(255,255,255,0.015) 1px, transparent 1px),
        linear-gradient(90deg, rgba(255,255,255,0.015) 1px, transparent 1px);
    background-size: 60px 60px;
}

.bg-gradient-orb {
    position: fixed;
    width: 600px;
    height: 600px;
    border-radius: 50%;
    filter: blur(120px);
    opacity: 0.15;
    pointer-events: none;
    z-index: 0;
}

.bg-gradient-orb.orb-1 {
    background: var(--accent);
    top: -200px;
    right: -200px;
    animation: orbFloat 15s ease-in-out infinite;
}

.bg-gradient-orb.orb-2 {
    background: var(--accent-secondary);
    bottom: -300px;
    left: -200px;
    animation: orbFloat 20s ease-in-out infinite reverse;
}

@keyframes orbFloat {
    0%, 100% { transform: translate(0, 0); }
    33% { transform: translate(30px, -50px); }
    66% { transform: translate(-20px, 30px); }
}

/* ---- Layout ---- */
.app-container {
    position: relative;
    z-index: 1;
    width: 100%;
    max-width: 1400px;
    margin: 0 auto;
    padding: 2rem;
    min-height: 100vh;
}

/* ---- Logo / Header ---- */
.header {
    text-align: center;
    padding: 3rem 0 2rem;
}

.logo {
    font-size: 3.5rem;
    font-weight: 900;
    letter-spacing: -0.03em;
    background: linear-gradient(135deg, var(--accent) 0%, #fbbf24 50%, var(--accent-secondary) 100%);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
    display: inline-block;
    position: relative;
}

.logo::after {
    content: '';
    position: absolute;
    bottom: -8px;
    left: 50%;
    transform: translateX(-50%);
    width: 60px;
    height: 3px;
    background: linear-gradient(90deg, var(--accent), var(--accent-secondary));
    border-radius: var(--radius-full);
}

.logo-subtitle {
    margin-top: 1.2rem;
    font-size: 1.1rem;
    color: var(--text-secondary);
    font-weight: 400;
    letter-spacing: 0.05em;
}

/* ---- Cards ---- */
.card {
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: var(--radius-lg);
    padding: 1.5rem;
    transition: all var(--transition-normal);
    position: relative;
    overflow: hidden;
}

.card::before {
    content: '';
    position: absolute;
    inset: 0;
    background: linear-gradient(135deg, rgba(245,158,11,0.03) 0%, transparent 60%);
    opacity: 0;
    transition: opacity var(--transition-normal);
}

.card:hover {
    border-color: var(--border-hover);
    transform: translateY(-2px);
    box-shadow: var(--shadow-lg);
}

.card:hover::before {
    opacity: 1;
}

/* ---- Mode Selection Cards ---- */
.mode-grid {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 1.5rem;
    margin-top: 2rem;
}

.mode-card {
    cursor: pointer;
    text-align: center;
    padding: 2.5rem 1.5rem;
    position: relative;
}

.mode-card .mode-icon {
    font-size: 3rem;
    margin-bottom: 1rem;
    display: block;
}

.mode-card .mode-title {
    font-size: 1.3rem;
    font-weight: 700;
    margin-bottom: 0.5rem;
}

.mode-card .mode-desc {
    font-size: 0.9rem;
    color: var(--text-secondary);
    line-height: 1.5;
}

.mode-card:hover {
    border-color: var(--accent);
    box-shadow: var(--shadow-glow);
}

.mode-card.active {
    border-color: var(--accent);
    background: rgba(245, 158, 11, 0.05);
}

/* ---- Stats Bar ---- */
.stats-bar {
    display: flex;
    gap: 1.5rem;
    justify-content: center;
    margin: 2rem 0;
    flex-wrap: wrap;
}

.stat-item {
    text-align: center;
    padding: 1rem 1.5rem;
    background: var(--bg-glass);
    border: 1px solid var(--border);
    border-radius: var(--radius-md);
    min-width: 130px;
}

.stat-value {
    font-size: 1.8rem;
    font-weight: 800;
    color: var(--accent);
}

.stat-label {
    font-size: 0.75rem;
    color: var(--text-muted);
    text-transform: uppercase;
    letter-spacing: 0.1em;
    margin-top: 0.25rem;
}

/* ---- Play Button ---- */
.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 0.5rem;
    padding: 0.85rem 2rem;
    font-family: inherit;
    font-size: 1rem;
    font-weight: 600;
    color: #000;
    background: var(--accent);
    border: none;
    border-radius: var(--radius-sm);
    cursor: pointer;
    transition: all var(--transition-normal);
    text-decoration: none;
    position: relative;
    overflow: hidden;
}

.btn:hover {
    background: var(--accent-hover);
    transform: translateY(-1px);
    box-shadow: 0 4px 20px rgba(245, 158, 11, 0.3);
}

.btn:active {
    transform: translateY(0);
}

.btn-large {
    padding: 1.1rem 3rem;
    font-size: 1.15rem;
    border-radius: var(--radius-md);
}

.btn-ghost {
    background: transparent;
    color: var(--text-primary);
    border: 1px solid var(--border);
}

.btn-ghost:hover {
    background: var(--bg-glass-hover);
    border-color: var(--border-hover);
    box-shadow: none;
}

.btn-success {
    background: var(--accent-green);
}

.btn-success:hover {
    background: #16a34a;
    box-shadow: 0 4px 20px rgba(34,197,94,0.3);
}

.btn-danger {
    background: var(--accent-secondary);
    color: #fff;
}

/* ---- Ads ---- */
.ad-container {
    width: 100%;
    max-width: 100%;
    margin-inline: auto;
    overflow: hidden;
}

.ad-container .adsbygoogle {
    width: 100%;
    min-height: 90px;
}

/* ---- Game Layout ---- */
.game-container {
    display: none;
    gap: 2rem;
}

.game-container.active {
    display: grid;
    grid-template-columns: 1.2fr 1fr;
    animation: fadeIn 0.5s ease;
}

@keyframes fadeIn {
    from { opacity: 0; transform: translateY(20px); }
    to { opacity: 1; transform: translateY(0); }
}

/* ---- Car Image Area ---- */
.car-image-container {
    position: relative;
    border-radius: var(--radius-lg);
    overflow: hidden;
    aspect-ratio: 16/10;
    background: var(--bg-secondary);
}

.car-image {
    width: 100%;
    height: 100%;
    object-fit: cover;
    transition: transform var(--transition-slow);
}

.car-image-container:hover .car-image {
    transform: scale(1.03);
}

.car-image-overlay {
    position: absolute;
    bottom: 0;
    left: 0;
    right: 0;
    padding: 2rem 1.5rem 1.5rem;
    background: linear-gradient(transparent, rgba(0,0,0,0.8));
}

.car-badge {
    display: inline-flex;
    align-items: center;
    gap: 0.4rem;
    padding: 0.35rem 0.8rem;
    background: rgba(255,255,255,0.15);
    backdrop-filter: blur(10px);
    border-radius: var(--radius-full);
    font-size: 0.8rem;
    font-weight: 600;
    color: #fff;
}

.car-badge.source-badge {
    background: rgba(245, 158, 11, 0.2);
    color: var(--accent);
    border: 1px solid rgba(245, 158, 11, 0.3);
}

/* ---- Car Info Panel ---- */
.car-info-panel {
    display: flex;
    flex-direction: column;
    gap: 1.5rem;
}

.car-title {
    font-size: 1.6rem;
    font-weight: 800;
    letter-spacing: -0.02em;
}

.car-version {
    font-size: 0.95rem;
    color: var(--text-secondary);
    margin-top: 0.25rem;
}

/* ---- Specs Grid ---- */
.specs-grid {
    display: grid;
    grid-template-columns: repeat(2, 1fr);
    gap: 0.75rem;
}

.spec-item {
    display: flex;
    align-items: center;
    gap: 0.65rem;
    padding: 0.7rem 0.9rem;
    background: var(--bg-glass);
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    transition: all var(--transition-fast);
}

.spec-item:hover {
    border-color: var(--border-hover);
    background: var(--bg-glass-hover);
}

.spec-icon {
    font-size: 1.1rem;
    width: 24px;
    text-align: center;
    flex-shrink: 0;
}

.spec-text {
    display: flex;
    flex-direction: column;
}

.spec-label {
    font-size: 0.65rem;
    color: var(--text-muted);
    text-transform: uppercase;
    letter-spacing: 0.08em;
}

.spec-value {
    font-size: 0.9rem;
    font-weight: 600;
    color: var(--text-primary);
}

/* ---- Description ---- */
.car-description {
    padding: 1rem;
    background: var(--bg-glass);
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    font-size: 0.9rem;
    color: var(--text-secondary);
    line-height: 1.6;
    font-style: italic;
}

.car-description::before {
    content: '"';
    font-size: 1.5rem;
    color: var(--accent);
    margin-right: 0.25rem;
    font-weight: 700;
}

/* ---- Price Input ---- */
.price-input-container {
    position: relative;
    margin-top: auto;
}

.price-input-label {
    font-size: 0.85rem;
    font-weight: 600;
    color: var(--text-secondary);
    margin-bottom: 0.5rem;
    display: block;
}

.price-input-wrapper {
    position: relative;
    display: flex;
    align-items: center;
}

.price-input {
    width: 100%;
    padding: 1rem 1.2rem;
    padding-right: 3rem;
    font-family: inherit;
    font-size: 1.8rem;
    font-weight: 800;
    color: var(--accent);
    background: var(--bg-secondary);
    border: 2px solid var(--border);
    border-radius: var(--radius-md);
    outline: none;
    transition: all var(--transition-normal);
    text-align: center;
}

.price-input:focus {
    border-color: var(--accent);
    box-shadow: 0 0 0 4px var(--accent-glow);
}

.price-input::placeholder {
    color: var(--text-muted);
    font-weight: 400;
    font-size: 1.2rem;
}

.price-currency {
    position: absolute;
    right: 1.2rem;
    font-size: 1.4rem;
    font-weight: 700;
    color: var(--text-muted);
}

.price-hint {
    margin-top: 0.5rem;
    font-size: 0.75rem;
    color: var(--text-muted);
    text-align: center;
}

/* ---- Progress Bar ---- */
.progress-bar-container {
    display: flex;
    align-items: center;
    gap: 1rem;
    padding: 1rem 0;
}

.progress-dots {
    display: flex;
    gap: 0.5rem;
    flex: 1;
}

.progress-dot {
    width: 100%;
    height: 4px;
    border-radius: var(--radius-full);
    background: var(--bg-card);
    transition: all var(--transition-normal);
    position: relative;
}

.progress-dot.completed {
    background: var(--accent-green);
}

.progress-dot.current {
    background: var(--accent);
    box-shadow: 0 0 10px var(--accent-glow);
}

.progress-dot.upcoming {
    background: var(--bg-card);
}

.progress-text {
    font-size: 0.85rem;
    font-weight: 600;
    color: var(--text-secondary);
    white-space: nowrap;
}

/* ---- Timer ---- */
.timer-display {
    font-size: 2.5rem;
    font-weight: 900;
    color: var(--accent);
    text-align: center;
    font-variant-numeric: tabular-nums;
    display: none;
}

.timer-display.warning {
    color: var(--accent-secondary);
    animation: pulse 0.5s ease infinite;
}

@keyframes pulse {
    0%, 100% { opacity: 1; }
    50% { opacity: 0.5; }
}

/* ---- Result Screen ---- */
.result-overlay {
    position: fixed;
    inset: 0;
    background: rgba(8, 8, 13, 0.9);
    backdrop-filter: blur(20px);
    z-index: 100;
    display: none;
    align-items: center;
    justify-content: center;
    animation: fadeIn 0.3s ease;
}

.result-overlay.active {
    display: flex;
}

.result-card {
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: var(--radius-xl);
    padding: 3rem;
    max-width: 500px;
    width: 90%;
    text-align: center;
    animation: slideUp 0.5s ease;
}

@keyframes slideUp {
    from { opacity: 0; transform: translateY(40px) scale(0.95); }
    to { opacity: 1; transform: translateY(0) scale(1); }
}

.result-emoji {
    font-size: 4rem;
    margin-bottom: 1rem;
    animation: bounceIn 0.6s ease 0.2s both;
}

@keyframes bounceIn {
    0% { transform: scale(0); }
    50% { transform: scale(1.2); }
    100% { transform: scale(1); }
}

.result-label {
    font-size: 1.5rem;
    font-weight: 700;
    margin-bottom: 0.5rem;
}

.result-prices {
    display: flex;
    justify-content: center;
    gap: 2rem;
    margin: 1.5rem 0;
}

.result-price-col {
    text-align: center;
}

.result-price-title {
    font-size: 0.75rem;
    color: var(--text-muted);
    text-transform: uppercase;
    letter-spacing: 0.1em;
    margin-bottom: 0.3rem;
}

.result-price-value {
    font-size: 1.6rem;
    font-weight: 800;
}

.result-price-value.guess {
    color: var(--accent-blue);
}

.result-price-value.actual {
    color: var(--accent-green);
}

.result-direction {
    font-size: 0.9rem;
    color: var(--text-secondary);
    margin-bottom: 1rem;
}

.result-direction .arrow-up {
    color: var(--accent-secondary);
}

.result-direction .arrow-down {
    color: var(--accent-blue);
}

/* ---- Score Display ---- */
.score-display {
    margin: 1.5rem 0;
}

.score-points {
    font-size: 3rem;
    font-weight: 900;
    color: var(--accent);
    display: block;
    line-height: 1;
}

.score-max {
    font-size: 1rem;
    color: var(--text-muted);
}

.accuracy-bar {
    height: 8px;
    background: var(--bg-secondary);
    border-radius: var(--radius-full);
    margin: 1rem auto;
    max-width: 300px;
    overflow: hidden;
}

.accuracy-fill {
    height: 100%;
    border-radius: var(--radius-full);
    transition: width 1s ease;
    background: linear-gradient(90deg, var(--accent-secondary), var(--accent), var(--accent-green));
}

/* ---- Final Score Screen ---- */
.final-score-container {
    display: none;
}

.final-score-container.active {
    display: block;
    animation: fadeIn 0.5s ease;
}

.final-score-card {
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: var(--radius-xl);
    padding: 3rem;
    max-width: 700px;
    margin: 2rem auto;
    text-align: center;
}

.final-stars {
    font-size: 2.5rem;
    margin: 1rem 0;
    letter-spacing: 0.3em;
}

.final-total-score {
    font-size: 4rem;
    font-weight: 900;
    background: linear-gradient(135deg, var(--accent), #fbbf24);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
    line-height: 1.2;
}

.final-max-score {
    font-size: 1.2rem;
    color: var(--text-muted);
}

/* ---- Rounds Summary ---- */
.rounds-summary {
    margin-top: 2rem;
    text-align: left;
}

.round-summary-item {
    display: flex;
    align-items: center;
    gap: 1rem;
    padding: 0.8rem 1rem;
    border-bottom: 1px solid var(--border);
}

.round-summary-item:last-child {
    border-bottom: none;
}

.round-num {
    font-size: 0.8rem;
    font-weight: 700;
    color: var(--text-muted);
    min-width: 30px;
}

.round-car-name {
    flex: 1;
    font-weight: 600;
    font-size: 0.9rem;
}

.round-accuracy {
    font-size: 0.8rem;
    color: var(--text-secondary);
    min-width: 60px;
    text-align: right;
}

.round-score {
    font-weight: 700;
    color: var(--accent);
    min-width: 50px;
    text-align: right;
}

/* ---- Share Button ---- */
.share-text {
    background: var(--bg-secondary);
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    padding: 1rem;
    font-family: monospace;
    font-size: 0.85rem;
    color: var(--text-secondary);
    margin: 1rem 0;
    white-space: pre-line;
    text-align: left;
    cursor: pointer;
    transition: all var(--transition-fast);
}

.share-text:hover {
    border-color: var(--accent);
}

/* ---- Leaderboard ---- */
.leaderboard {
    margin-top: 2rem;
}

.leaderboard-title {
    font-size: 1.2rem;
    font-weight: 700;
    margin-bottom: 1rem;
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

.leaderboard-item {
    display: flex;
    align-items: center;
    gap: 1rem;
    padding: 0.75rem 1rem;
    border-bottom: 1px solid var(--border);
    transition: background var(--transition-fast);
}

.leaderboard-item:hover {
    background: var(--bg-glass-hover);
}

.leaderboard-rank {
    font-size: 1rem;
    font-weight: 800;
    min-width: 30px;
    color: var(--text-muted);
}

.leaderboard-rank.gold { color: #fbbf24; }
.leaderboard-rank.silver { color: #94a3b8; }
.leaderboard-rank.bronze { color: #d97706; }

.leaderboard-name {
    flex: 1;
    font-weight: 600;
}

.leaderboard-score {
    font-weight: 700;
    color: var(--accent);
}

/* ---- Loading Spinner ---- */
.spinner {
    width: 40px;
    height: 40px;
    border: 3px solid var(--border);
    border-top-color: var(--accent);
    border-radius: 50%;
    animation: spin 0.8s linear infinite;
    margin: 2rem auto;
}

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

/* ---- Toast / Notification ---- */
.toast {
    position: fixed;
    bottom: 2rem;
    right: 2rem;
    padding: 1rem 1.5rem;
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: var(--radius-md);
    box-shadow: var(--shadow-lg);
    z-index: 200;
    animation: slideIn 0.3s ease;
    max-width: 350px;
}

@keyframes slideIn {
    from { transform: translateX(100%); opacity: 0; }
    to { transform: translateX(0); opacity: 1; }
}

/* ---- Confetti ---- */
.confetti-piece {
    position: fixed;
    width: 8px;
    height: 8px;
    border-radius: 2px;
    z-index: 300;
    pointer-events: none;
    animation: confettiFall 2s ease forwards;
}

@keyframes confettiFall {
    0% { transform: translateY(-100vh) rotate(0deg); opacity: 1; }
    100% { transform: translateY(100vh) rotate(720deg); opacity: 0; }
}

/* ---- Responsive ---- */
@media (max-width: 900px) {
    .mode-grid {
        grid-template-columns: 1fr;
        gap: 1rem;
    }

    .game-container.active {
        grid-template-columns: 1fr;
    }

    .logo {
        font-size: 2.5rem;
    }

    .app-container {
        padding: 1rem;
    }

    .result-card {
        padding: 2rem 1.5rem;
    }

    .final-score-card {
        padding: 2rem 1.5rem;
    }

    .specs-grid {
        grid-template-columns: repeat(2, 1fr);
    }

    .result-prices {
        gap: 1rem;
    }

    .stats-bar {
        gap: 0.75rem;
    }

    .stat-item {
        min-width: 100px;
        padding: 0.75rem 1rem;
    }
}

@media (max-width: 480px) {
    .specs-grid {
        grid-template-columns: 1fr;
    }

    .price-input {
        font-size: 1.4rem;
    }

    .final-total-score {
        font-size: 3rem;
    }
}

/* ---- Utility Classes ---- */
.hidden { display: none !important; }
.text-center { text-align: center; }
.mt-1 { margin-top: 0.5rem; }
.mt-2 { margin-top: 1rem; }
.mt-3 { margin-top: 1.5rem; }
.mt-4 { margin-top: 2rem; }
.mb-2 { margin-bottom: 1rem; }
.gap-1 { gap: 0.5rem; }
.flex { display: flex; }
.flex-col { flex-direction: column; }
.items-center { align-items: center; }
.justify-center { justify-content: center; }
.w-full { width: 100%; }
