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

:root {
    --bg-primary: #0a0a0a;
    --bg-secondary: #1a1a1a;
    --bg-tertiary: #2a2a2a;
    --text-primary: #ffffff;
    --text-secondary: #b0b0b0;
    --accent: #4a9eff;
    --accent-hover: #6bb0ff;
    --success: #4ade80;
    --error: #f87171;
    --border: #333333;
}

body {
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Oxygen, Ubuntu, Cantarell, sans-serif;
    background: var(--bg-primary);
    color: var(--text-primary);
    min-height: 100vh;
    overflow-x: hidden;
    position: relative;
}

/* Background Animation Layer */
.background-layer {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    z-index: 0;
    pointer-events: none;
    overflow: hidden;
}

.screen {
    display: none;
    min-height: 100vh;
    position: relative;
    z-index: 1;
}

.screen.active {
    display: flex;
    flex-direction: column;
}

.container {
    max-width: 1200px;
    margin: 0 auto;
    padding: 2rem;
    width: 100%;
}

/* Theme Selection */
#theme-selection {
    align-items: center;
    justify-content: center;
}

#theme-selection h1 {
    font-size: 3rem;
    margin-bottom: 0.5rem;
    text-align: center;
    font-weight: 300;
    letter-spacing: 2px;
}

.subtitle {
    text-align: center;
    color: var(--text-secondary);
    margin-bottom: 3rem;
    font-size: 1.1rem;
}

.theme-list {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(250px, 1fr));
    gap: 1.5rem;
    max-width: 800px;
    margin: 0 auto;
}

.theme-item {
    background: var(--bg-secondary);
    border: 1px solid var(--border);
    border-radius: 12px;
    padding: 2rem;
    text-align: center;
    cursor: pointer;
    transition: all 0.3s ease;
    font-size: 1.2rem;
}

.theme-item:hover {
    background: var(--bg-tertiary);
    border-color: var(--accent);
    transform: translateY(-2px);
}

/* Game Screen */
#game-screen {
    padding: 1rem;
    position: relative;
}

.game-content {
    width: 100%;
    margin: 0 auto;
    display: flex;
    flex-direction: column;
    gap: 3rem;
    padding: 0 1rem;
}

/* Timeline */
.timeline-container {
    position: relative;
    padding: 2rem 0;
    min-height: 300px;
    width: 100%;
    max-width: 100%;
    overflow: hidden;
    box-sizing: border-box;
}

.timeline {
    position: relative;
    display: flex;
    align-items: center;
    justify-content: center;
    min-height: 200px;
    padding: 2rem;
    flex-wrap: nowrap;
    gap: 0;
    overflow: hidden;
    width: 100%;
    cursor: pointer;
}

.timeline::before {
    content: '';
    position: absolute;
    top: 50%;
    left: 2rem;
    right: 2rem;
    height: 2px;
    background: var(--border);
    z-index: 0;
}

.timeline-line {
    position: absolute;
    top: 50%;
    left: 2rem;
    right: 2rem;
    height: 2px;
    background: var(--border);
    z-index: 0;
}

.timeline-slot {
    position: relative;
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 2;
    flex-shrink: 0;
    transition: transform 0.3s ease, margin 0.3s ease;
}

.timeline-slot.insertion-point {
    margin: 0 60px;
}

.timeline-slot.nudge-left {
    transform: translateX(-30px);
}

.timeline-slot.nudge-right {
    transform: translateX(30px);
}

.timeline-event {
    background: var(--bg-secondary);
    border: 2px solid var(--border);
    border-radius: 12px;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    cursor: default;
    position: relative;
    overflow: hidden;
    transition: all 0.3s ease;
    pointer-events: none;
}

.timeline-insertion-indicator {
    position: absolute;
    background: var(--accent);
    z-index: 3;
    border-radius: 2px;
    opacity: 0;
    transition: opacity 0.2s ease;
    pointer-events: none;
}

.timeline-insertion-indicator.visible {
    opacity: 1;
}

.timeline-event:hover {
    transform: scale(1.05);
}

.timeline-event-image {
    width: 100%;
    object-fit: cover;
    border-radius: 10px 10px 0 0;
    flex-shrink: 0;
}

.timeline-event-title {
    padding: 0.4rem 0.3rem;
    text-align: center;
    line-height: 1.3;
    color: var(--text-primary);
    font-weight: 500;
    overflow: visible;
    word-wrap: break-word;
    display: flex;
    align-items: center;
    justify-content: center;
    flex: 1;
}

.timeline-event-year {
    position: absolute;
    bottom: -25px;
    font-size: 0.75rem;
    color: var(--text-secondary);
    white-space: nowrap;
}

/* Current Event Card */
.current-event {
    display: grid;
    grid-template-columns: 1fr 1fr 1fr;
    align-items: center;
    padding: 2rem 1rem;
    max-width: 1400px;
    margin: 0 auto;
    width: 100%;
}

.game-logo-container {
    display: flex;
    align-items: center;
    justify-content: flex-start;
    grid-column: 1;
}

.game-logo {
    height: 80px;
    width: auto;
    cursor: pointer;
    opacity: 0.8;
    transition: opacity 0.3s ease;
}

.game-logo:hover {
    opacity: 1;
}

.event-card-container {
    grid-column: 2;
    margin: 0 auto;
    justify-self: center;
    position: relative;
    width: 200px;
    min-height: 280px;
    max-height: 400px;
}

#event-card {
    width: 100%;
    height: 100%;
}

.event-card-placeholder {
    position: absolute;
    top: 0;
    left: 0;
    width: 200px;
    min-height: 280px;
    max-height: 400px;
    background: var(--bg-secondary);
    border: 2px solid var(--border);
    border-radius: 16px;
    display: none;
    pointer-events: none;
}

.event-card-placeholder.visible {
    display: block;
}

.game-stats {
    display: flex;
    flex-direction: column;
    align-items: flex-end;
    gap: 0.75rem;
    grid-column: 3;
    justify-self: flex-end;
}

.score-display {
    display: flex;
    align-items: center;
}

.score-label {
    font-size: 1.2rem;
    font-weight: 600;
    color: var(--text-primary);
}

.score-label #score {
    color: var(--accent);
    font-size: 1.4rem;
}

.round-progress-container {
    display: flex;
    align-items: center;
    gap: 0.75rem;
}

.round-progress-label {
    font-size: 0.85rem;
    color: var(--text-secondary);
    font-weight: 500;
    min-width: 55px;
}

.round-progress {
    display: flex;
    gap: 3px;
    width: 120px;
}

.round-progress-segment {
    flex: 1;
    height: 6px;
    background: var(--bg-tertiary);
    border-radius: 3px;
    transition: background 0.3s ease;
}

.round-progress-segment.completed {
    background: var(--accent);
}

.round-progress-segment.current {
    background: var(--accent);
    box-shadow: 0 0 6px rgba(74, 158, 255, 0.6);
}

.event-card-container {
    grid-column: 2;
    margin: 0 auto;
    justify-self: center;
    position: relative;
    width: 200px;
    min-height: 280px;
    max-height: 400px;
}

.event-card {
    width: 200px;
    min-height: 280px;
    max-height: 400px;
    background: var(--bg-secondary);
    border: 2px solid var(--accent);
    border-radius: 16px;
    display: flex;
    flex-direction: column;
    cursor: grab;
    transition: all 0.3s ease;
    overflow: hidden;
    box-shadow: 0 4px 20px rgba(74, 158, 255, 0.3);
    position: relative;
}

.event-card-placeholder {
    position: absolute;
    top: 0;
    left: 0;
    width: 200px;
    min-height: 280px;
    max-height: 400px;
    background: var(--bg-secondary);
    border: 2px solid var(--border);
    border-radius: 16px;
    display: none;
    pointer-events: none;
}

.event-card-placeholder.visible {
    display: block;
}

.event-card:active {
    cursor: grabbing;
    transform: scale(0.95);
}

.event-card.dragging {
    opacity: 0.5;
    transform: rotate(5deg);
}

.event-image-container {
    width: 100%;
    height: 120px;
    overflow: hidden;
    display: flex;
    align-items: center;
    justify-content: center;
    background: var(--bg-tertiary);
    border-radius: 14px 14px 0 0;
    flex-shrink: 0;
}

#event-image {
    width: 100%;
    height: 100%;
    object-fit: cover;
}

.event-title {
    padding: 0.5rem 0.5rem 0.25rem;
    text-align: center;
    font-size: 0.9rem;
    font-weight: 500;
    color: var(--text-primary);
    line-height: 1.3;
    flex-shrink: 0;
}

.event-description {
    padding: 0 0.5rem 0.5rem;
    text-align: center;
    font-size: 0.75rem;
    color: var(--text-secondary);
    line-height: 1.4;
    flex: 1;
    overflow-y: auto;
    word-wrap: break-word;
    min-height: 60px;
}

.event-year {
    display: none;
}

/* Game Over Overlay */
.game-over-overlay {
    display: none;
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    z-index: 100;
    pointer-events: none;
    background: rgba(0, 0, 0, 0.3);
}

.game-over-overlay.active {
    display: block;
}

.game-over-content {
    position: absolute;
    bottom: 2rem;
    left: 50%;
    transform: translateX(-50%);
    background: var(--bg-secondary);
    border: 2px solid var(--accent);
    border-radius: 16px;
    padding: 2rem;
    min-width: 300px;
    max-width: 400px;
    text-align: center;
    pointer-events: all;
    box-shadow: 0 8px 32px rgba(0, 0, 0, 0.5);
    z-index: 101;
}

.game-over-content h1 {
    font-size: 2rem;
    margin-bottom: 1rem;
    font-weight: 300;
}

.final-score {
    font-size: 1.2rem;
    margin-bottom: 1.5rem;
    color: var(--text-secondary);
}

#final-score {
    color: var(--accent);
    font-size: 1.8rem;
    font-weight: 600;
}

.game-over-buttons {
    display: flex;
    flex-direction: column;
    gap: 1rem;
}

.btn-primary, .btn-secondary {
    color: var(--text-primary);
    border: none;
    padding: 0.875rem 1.75rem;
    font-size: 1rem;
    border-radius: 8px;
    cursor: pointer;
    transition: all 0.3s ease;
    font-weight: 500;
}

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

.btn-primary:hover {
    background: var(--accent-hover);
    transform: translateY(-2px);
    box-shadow: 0 4px 12px rgba(74, 158, 255, 0.4);
}

.btn-secondary {
    background: var(--bg-tertiary);
    border: 1px solid var(--border);
}

.btn-secondary:hover {
    background: var(--bg-secondary);
    border-color: var(--accent);
    transform: translateY(-2px);
}

/* Incorrect placement styling */
.timeline-event.incorrect-placement {
    filter: hue-rotate(-10deg) saturate(1.5) brightness(0.9);
    border-color: var(--error);
    box-shadow: 0 0 10px rgba(248, 113, 113, 0.5);
}

/* Responsive */
@media (max-width: 768px) {
    .theme-list {
        grid-template-columns: 1fr;
    }

    .timeline {
        padding: 0 1rem;
    }

    .timeline-slot {
        width: 100px;
        height: 100px;
    }

    .timeline-event {
        width: 80px;
        height: 80px;
    }

    .event-card {
        width: 180px;
        height: 180px;
    }

    .current-event {
        grid-template-columns: 1fr;
        gap: 1.5rem;
        padding: 1.5rem 1rem;
    }

    .game-logo-container {
        grid-column: 1;
        justify-content: center;
        order: 2;
    }

    .game-logo {
        height: 50px;
    }

    #event-card {
        grid-column: 1;
        order: 1;
    }

    .game-stats {
        grid-column: 1;
        order: 3;
        align-items: center;
        width: 100%;
    }

    .round-progress {
        width: 100%;
        max-width: 200px;
    }
}

/* Sliding Blocks Background Animation */
@keyframes slideHorizontal {
    0% { transform: translateX(0); }
    100% { transform: translateX(var(--distance)); }
}

@keyframes slideVertical {
    0% { transform: translateY(0); }
    100% { transform: translateY(var(--distance)); }
}
