/* Reset and Base Styles */
* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

body {
    font-family: 'Fredoka', sans-serif;
    background: linear-gradient(135deg, #2c1810 0%, #8b4513 50%, #daa520 100%);
    overflow: hidden;
    user-select: none;
    -webkit-user-select: none;
    -moz-user-select: none;
    -ms-user-select: none;
}

#game-container {
    position: relative;
    width: 100vw;
    height: 100vh;
    z-index: 10;
}

.time-canvas {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    z-index: 1;
    outline: none;
}

/* Loading Screen */
.loading-screen {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: linear-gradient(135deg, #1a1a3a 0%, #4a4a8a 100%);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 1000;
}

.loading-content {
    text-align: center;
    color: white;
    max-width: 400px;
    padding: 40px;
}

.loading-icon {
    font-size: 4rem;
    animation: timeRotate 2s linear infinite;
    margin-bottom: 20px;
}

@keyframes timeRotate {
    from { transform: rotate(0deg) scale(1); }
    50% { transform: rotate(180deg) scale(1.1); }
    to { transform: rotate(360deg) scale(1); }
}

.loading-content h2 {
    font-size: 2rem;
    margin-bottom: 20px;
    font-weight: 600;
}

.loading-bar {
    width: 100%;
    height: 8px;
    background: rgba(255, 255, 255, 0.3);
    border-radius: 4px;
    overflow: hidden;
    margin-bottom: 15px;
}

.loading-progress {
    height: 100%;
    background: linear-gradient(90deg, #daa520, #ffd700);
    border-radius: 4px;
    width: 0%;
    transition: width 0.3s ease;
}

.loading-content p {
    font-size: 1.1rem;
    opacity: 0.9;
}

/* Main Menu */
.main-menu {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.9);
    backdrop-filter: blur(10px);
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    z-index: 100;
    padding: 20px;
    overflow-y: auto;
}

.menu-header {
    text-align: center;
    margin-bottom: 30px;
}

.game-title {
    font-size: 3.5rem;
    color: #ffd700;
    text-shadow: 2px 2px 4px rgba(0, 0, 0, 0.8);
    margin-bottom: 10px;
    font-weight: 700;
    animation: timeGlow 3s ease-in-out infinite alternate;
}

@keyframes timeGlow {
    from { 
        text-shadow: 2px 2px 4px rgba(0, 0, 0, 0.8), 0 0 20px rgba(255, 215, 0, 0.3); 
    }
    to { 
        text-shadow: 2px 2px 4px rgba(0, 0, 0, 0.8), 0 0 30px rgba(255, 215, 0, 0.8); 
    }
}

.game-subtitle {
    font-size: 1.3rem;
    color: #daa520;
    font-weight: 400;
}

.menu-content {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 30px;
    max-width: 900px;
    width: 100%;
}

.professor-guide {
    display: flex;
    align-items: center;
    gap: 20px;
    background: rgba(255, 255, 255, 0.1);
    padding: 20px;
    border-radius: 20px;
    backdrop-filter: blur(10px);
    max-width: 600px;
}

.professor-avatar {
    font-size: 3rem;
    animation: professorBob 2s ease-in-out infinite alternate;
}

@keyframes professorBob {
    from { transform: translateY(0); }
    to { transform: translateY(-10px); }
}

.speech-bubble {
    background: white;
    color: #333;
    padding: 15px;
    border-radius: 15px;
    position: relative;
    flex: 1;
}

.speech-bubble::before {
    content: '';
    position: absolute;
    left: -10px;
    top: 50%;
    transform: translateY(-50%);
    border: 10px solid transparent;
    border-right-color: white;
}

.speech-bubble p {
    margin: 0;
    font-weight: 500;
}

.timeline-progress {
    background: rgba(255, 255, 255, 0.1);
    padding: 25px;
    border-radius: 20px;
    backdrop-filter: blur(10px);
    width: 100%;
    text-align: center;
}

.timeline-progress h3 {
    color: white;
    font-size: 1.5rem;
    margin-bottom: 20px;
    font-weight: 600;
}

.timeline-container {
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 10px;
    margin: 20px 0;
    flex-wrap: wrap;
}

.era-node {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 8px;
    padding: 15px;
    border-radius: 15px;
    background: linear-gradient(135deg, #4a90e2, #357abd);
    color: white;
    cursor: pointer;
    transition: all 0.3s ease;
    min-width: 120px;
    border: 3px solid transparent;
}

.era-node:hover {
    transform: translateY(-5px);
    box-shadow: 0 8px 25px rgba(74, 144, 226, 0.4);
}

.era-node.locked {
    background: linear-gradient(135deg, #666, #444);
    cursor: not-allowed;
    opacity: 0.6;
}

.era-node.locked:hover {
    transform: none;
    box-shadow: none;
}

.era-node.completed {
    background: linear-gradient(135deg, #10b981, #059669);
    border-color: #ffd700;
}

.era-icon {
    font-size: 2rem;
    margin-bottom: 5px;
}

.era-name {
    font-size: 1rem;
    font-weight: 600;
    text-align: center;
}

.era-status {
    font-size: 0.8rem;
    opacity: 0.9;
}

.player-stats {
    display: flex;
    gap: 30px;
    background: rgba(255, 255, 255, 0.1);
    padding: 20px;
    border-radius: 15px;
    backdrop-filter: blur(10px);
}

.stat-item {
    display: flex;
    align-items: center;
    gap: 8px;
    color: white;
}

.stat-icon {
    font-size: 1.5rem;
}

.stat-label {
    font-size: 1rem;
    font-weight: 500;
}

.stat-value {
    font-size: 1.2rem;
    font-weight: 700;
    color: #ffd700;
}

.menu-buttons {
    display: flex;
    gap: 15px;
    flex-wrap: wrap;
    justify-content: center;
}

.menu-button {
    background: linear-gradient(135deg, #daa520, #ffd700);
    color: #333;
    border: none;
    padding: 15px 25px;
    font-size: 1.1rem;
    font-weight: 600;
    border-radius: 25px;
    cursor: pointer;
    transition: all 0.3s ease;
    font-family: 'Fredoka', sans-serif;
    box-shadow: 0 4px 15px rgba(218, 165, 32, 0.4);
}

.menu-button:hover {
    transform: translateY(-2px);
    box-shadow: 0 6px 20px rgba(218, 165, 32, 0.6);
}

.menu-button.start-adventure {
    background: linear-gradient(135deg, #10b981, #059669);
    color: white;
    box-shadow: 0 4px 15px rgba(16, 185, 129, 0.4);
}

/* Game UI */
.game-ui {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    pointer-events: none;
    z-index: 50;
}

.ui-top {
    position: absolute;
    top: 20px;
    left: 20px;
    right: 20px;
    display: flex;
    justify-content: space-between;
    align-items: flex-start;
    pointer-events: auto;
    gap: 20px;
}

.current-era {
    background: rgba(0, 0, 0, 0.8);
    color: white;
    padding: 15px 20px;
    border-radius: 15px;
    display: flex;
    align-items: center;
    gap: 10px;
    backdrop-filter: blur(10px);
}

.era-icon {
    font-size: 1.5rem;
}

.era-name {
    font-size: 1.2rem;
    font-weight: 600;
}

.era-year {
    font-size: 0.9rem;
    opacity: 0.8;
    margin-left: 10px;
}

.mission-objective {
    background: rgba(0, 0, 0, 0.8);
    color: white;
    padding: 15px 20px;
    border-radius: 15px;
    backdrop-filter: blur(10px);
    max-width: 300px;
}

.mission-objective h4 {
    font-size: 1rem;
    margin-bottom: 5px;
    color: #ffd700;
    font-weight: 600;
}

.mission-objective p {
    font-size: 0.9rem;
    opacity: 0.9;
}

.crystal-counter {
    background: rgba(0, 0, 0, 0.8);
    color: white;
    padding: 15px 20px;
    border-radius: 15px;
    display: flex;
    align-items: center;
    gap: 10px;
    backdrop-filter: blur(10px);
    font-size: 1.2rem;
    font-weight: 600;
}

.crystal-icon {
    font-size: 1.5rem;
    animation: crystalPulse 2s ease-in-out infinite;
}

@keyframes crystalPulse {
    0%, 100% { transform: scale(1); }
    50% { transform: scale(1.1); }
}

.ui-controls {
    position: absolute;
    top: 50%;
    right: 20px;
    transform: translateY(-50%);
    background: rgba(0, 0, 0, 0.8);
    padding: 15px;
    border-radius: 15px;
    text-align: center;
    backdrop-filter: blur(10px);
    pointer-events: auto;
    color: white;
}

.movement-guide p {
    font-size: 0.9rem;
    margin-bottom: 5px;
    font-weight: 500;
}

.time-machine-status {
    margin-top: 15px;
    padding-top: 15px;
    border-top: 1px solid rgba(255, 255, 255, 0.3);
}

.status-indicator {
    display: flex;
    align-items: center;
    gap: 8px;
    font-size: 0.9rem;
    font-weight: 500;
}

.status-light {
    width: 12px;
    height: 12px;
    border-radius: 50%;
    background: #10b981;
    animation: statusBlink 2s ease-in-out infinite;
}

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

/* Timeline Modal Styles */
.timeline-content {
    max-width: 800px;
    max-height: 90vh;
    overflow-y: auto;
    padding: 20px;
}

.timeline-title {
    text-align: center;
    color: #ffd700;
    font-size: 2rem;
    margin-bottom: 10px;
    font-weight: 700;
}

.timeline-subtitle {
    text-align: center;
    color: #ccc;
    margin-bottom: 30px;
    font-size: 1.1rem;
}

.detailed-timeline {
    display: flex;
    flex-direction: column;
    gap: 20px;
    margin-bottom: 30px;
}

.timeline-era {
    position: relative;
    display: flex;
    align-items: center;
    gap: 20px;
    padding: 20px;
    border-radius: 15px;
    transition: all 0.3s ease;
}

.timeline-era.unlocked {
    background: rgba(16, 185, 129, 0.1);
    border: 2px solid rgba(16, 185, 129, 0.3);
}

.timeline-era.locked {
    background: rgba(107, 114, 128, 0.1);
    border: 2px solid rgba(107, 114, 128, 0.3);
    opacity: 0.6;
}

.era-connector {
    position: absolute;
    left: 30px;
    top: 100%;
    width: 3px;
    height: 20px;
    background: rgba(107, 114, 128, 0.3);
}

.era-connector.completed {
    background: rgba(16, 185, 129, 0.6);
}

.timeline-era:last-child .era-connector {
    display: none;
}

.era-bubble {
    display: flex;
    align-items: center;
    gap: 20px;
    width: 100%;
}

.era-bubble.completed {
    opacity: 1;
}

.era-bubble.current {
    opacity: 1;
    animation: currentEraPulse 2s ease-in-out infinite;
}

.era-bubble.locked {
    opacity: 0.6;
}

@keyframes currentEraPulse {
    0%, 100% { transform: scale(1); }
    50% { transform: scale(1.02); }
}

.era-icon-large {
    font-size: 3rem;
    width: 80px;
    height: 80px;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: 50%;
    background: rgba(255, 255, 255, 0.1);
    border: 3px solid rgba(255, 255, 255, 0.2);
}

.era-details {
    flex: 1;
}

.era-details h3 {
    font-size: 1.5rem;
    font-weight: 700;
    color: #ffd700;
    margin-bottom: 5px;
}

.era-details .era-year {
    font-size: 1rem;
    color: #10b981;
    font-weight: 600;
    margin-bottom: 8px;
}

.era-details .era-description {
    font-size: 0.95rem;
    color: #ccc;
    margin-bottom: 15px;
    line-height: 1.4;
}

.era-progress {
    font-size: 0.9rem;
    font-weight: 600;
    margin-bottom: 15px;
    padding: 5px 12px;
    border-radius: 20px;
    display: inline-block;
}

.timeline-era.unlocked .era-progress {
    background: rgba(16, 185, 129, 0.2);
    color: #10b981;
}

.timeline-era.locked .era-progress {
    background: rgba(107, 114, 128, 0.2);
    color: #6b7280;
}

.timeline-play-btn {
    background: linear-gradient(135deg, #10b981, #065f46);
    color: white;
    border: none;
    padding: 10px 20px;
    border-radius: 25px;
    font-size: 0.9rem;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.3s ease;
    box-shadow: 0 4px 15px rgba(16, 185, 129, 0.3);
}

.timeline-play-btn:hover {
    transform: translateY(-2px);
    box-shadow: 0 6px 20px rgba(16, 185, 129, 0.4);
}

.timeline-stats {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
    gap: 20px;
    padding: 20px;
    border-top: 2px solid rgba(255, 255, 255, 0.1);
}

.stat-card {
    background: rgba(255, 255, 255, 0.05);
    border: 2px solid rgba(255, 255, 255, 0.1);
    border-radius: 15px;
    padding: 20px;
    text-align: center;
    transition: all 0.3s ease;
}

.stat-card:hover {
    border-color: rgba(255, 215, 0, 0.3);
    transform: translateY(-2px);
}

.stat-card .stat-icon {
    font-size: 2.5rem;
    margin-bottom: 10px;
}

.stat-card .stat-number {
    font-size: 2rem;
    font-weight: 700;
    color: #ffd700;
    margin-bottom: 5px;
}

.stat-card .stat-label {
    font-size: 0.9rem;
    color: #ccc;
    font-weight: 500;
}

.ui-bottom {
    position: absolute;
    bottom: 20px;
    left: 50%;
    transform: translateX(-50%);
    display: flex;
    gap: 15px;
    pointer-events: auto;
}

.ui-button {
    background: rgba(0, 0, 0, 0.8);
    color: white;
    border: none;
    padding: 12px 20px;
    border-radius: 25px;
    cursor: pointer;
    font-size: 1rem;
    font-weight: 500;
    font-family: 'Fredoka', sans-serif;
    transition: all 0.3s ease;
    backdrop-filter: blur(10px);
}

.ui-button:hover {
    background: rgba(0, 0, 0, 0.9);
    transform: translateY(-2px);
}

.ui-button:disabled {
    opacity: 0.5;
    cursor: not-allowed;
}

.ui-button:disabled:hover {
    transform: none;
}

/* Modals */
.modal {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.8);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 200;
    backdrop-filter: blur(5px);
}

.modal-content {
    background: linear-gradient(135deg, #fff, #f8f9fa);
    border-radius: 25px;
    padding: 30px;
    max-width: 600px;
    width: 90%;
    max-height: 80vh;
    overflow-y: auto;
    position: relative;
    box-shadow: 0 20px 60px rgba(0, 0, 0, 0.3);
}

.modal-close {
    position: absolute;
    top: 15px;
    right: 15px;
    background: none;
    border: none;
    font-size: 1.5rem;
    cursor: pointer;
    color: #666;
    width: 30px;
    height: 30px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
}

.modal-close:hover {
    background: #f0f0f0;
}

.interaction-content h3 {
    font-size: 1.8rem;
    color: #333;
    margin-bottom: 15px;
    font-weight: 700;
}

.interaction-image {
    font-size: 4rem;
    text-align: center;
    margin: 20px 0;
}

.interaction-description {
    font-size: 1.1rem;
    color: #555;
    margin-bottom: 20px;
    line-height: 1.6;
}

.interaction-puzzle {
    background: #f8f9fa;
    padding: 20px;
    border-radius: 15px;
    margin: 20px 0;
    text-align: center;
}

.interaction-buttons {
    display: flex;
    gap: 10px;
    flex-wrap: wrap;
    justify-content: center;
}

.interaction-button {
    background: linear-gradient(135deg, #4a90e2, #357abd);
    color: white;
    border: none;
    padding: 12px 20px;
    border-radius: 25px;
    cursor: pointer;
    font-size: 1rem;
    font-weight: 600;
    font-family: 'Fredoka', sans-serif;
    transition: all 0.3s ease;
}

.interaction-button:hover {
    transform: translateY(-2px);
    box-shadow: 0 4px 15px rgba(74, 144, 226, 0.4);
}

.knowledge-content {
    text-align: center;
}

.knowledge-content h3 {
    font-size: 2rem;
    color: #4a90e2;
    margin-bottom: 20px;
    font-weight: 700;
}

.knowledge-icon {
    font-size: 3rem;
    margin: 20px 0;
}

.knowledge-text p {
    font-size: 1.1rem;
    color: #555;
    line-height: 1.6;
    margin-bottom: 20px;
}

.knowledge-quiz {
    background: #f8f9fa;
    padding: 20px;
    border-radius: 15px;
    margin: 20px 0;
}

.knowledge-quiz h4 {
    font-size: 1.3rem;
    color: #333;
    margin-bottom: 15px;
    font-weight: 600;
}

.quiz-question {
    font-size: 1.1rem;
    color: #555;
    margin-bottom: 15px;
}

.quiz-options {
    display: flex;
    flex-direction: column;
    gap: 10px;
    margin-bottom: 15px;
}

.quiz-option {
    background: white;
    border: 2px solid #e9ecef;
    padding: 12px 15px;
    border-radius: 10px;
    cursor: pointer;
    font-size: 1rem;
    font-weight: 500;
    font-family: 'Fredoka', sans-serif;
    transition: all 0.3s ease;
}

.quiz-option:hover {
    background: #e3f2fd;
    border-color: #4a90e2;
}

.quiz-option.correct {
    background: #d4edda;
    border-color: #10b981;
    color: #155724;
}

.quiz-option.incorrect {
    background: #f8d7da;
    border-color: #dc3545;
    color: #721c24;
}

.quiz-result {
    margin-top: 15px;
    padding: 10px;
    border-radius: 8px;
    font-weight: 600;
}

.quiz-result.correct {
    background: #d4edda;
    color: #155724;
}

.quiz-result.incorrect {
    background: #f8d7da;
    color: #721c24;
}

/* Level Complete Modal */
.complete-content {
    text-align: center;
}

.complete-animation {
    font-size: 4rem;
    animation: celebrationBounce 0.8s ease infinite alternate;
    margin-bottom: 20px;
}

@keyframes celebrationBounce {
    from { transform: translateY(0) scale(1); }
    to { transform: translateY(-10px) scale(1.1); }
}

.complete-content h2 {
    font-size: 2.5rem;
    color: #10b981;
    margin-bottom: 20px;
    font-weight: 700;
}

.complete-stats {
    background: #f8f9fa;
    padding: 20px;
    border-radius: 15px;
    margin: 20px 0;
}

.stat-row {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 10px 0;
    border-bottom: 1px solid #e9ecef;
}

.stat-row:last-child {
    border-bottom: none;
}

.era-unlock {
    background: linear-gradient(135deg, #ffd700, #daa520);
    padding: 20px;
    border-radius: 15px;
    margin: 20px 0;
    color: #333;
}

.era-unlock h3 {
    margin-bottom: 15px;
    font-weight: 700;
}

.unlocked-era {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 10px;
    font-size: 1.2rem;
    font-weight: 600;
}

.new-era-icon {
    font-size: 2rem;
}

.modal-button {
    background: linear-gradient(135deg, #4a90e2, #357abd);
    color: white;
    border: none;
    padding: 12px 25px;
    border-radius: 25px;
    cursor: pointer;
    font-size: 1rem;
    font-weight: 600;
    font-family: 'Fredoka', sans-serif;
    margin: 0 5px;
    transition: all 0.3s ease;
}

.modal-button:hover {
    transform: translateY(-2px);
    box-shadow: 0 4px 15px rgba(74, 144, 226, 0.4);
}

.modal-buttons {
    display: flex;
    gap: 10px;
    justify-content: center;
    margin-top: 20px;
    flex-wrap: wrap;
}

/* Inventory */
.inventory-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(80px, 1fr));
    gap: 10px;
    margin: 20px 0;
}

.inventory-slot {
    width: 80px;
    height: 80px;
    border: 2px solid #e9ecef;
    border-radius: 10px;
    display: flex;
    align-items: center;
    justify-content: center;
    background: #f8f9fa;
    font-size: 2rem;
    cursor: pointer;
    transition: all 0.3s ease;
}

.inventory-slot:hover {
    border-color: #4a90e2;
    background: #e3f2fd;
}

.inventory-slot.filled {
    border-color: #10b981;
    background: #d4edda;
}

.inventory-info {
    text-align: center;
    color: #666;
    font-style: italic;
}

/* Utility Classes */
.hidden {
    display: none !important;
}

.fade-in {
    animation: fadeIn 0.5s ease forwards;
}

.fade-out {
    animation: fadeOut 0.5s ease forwards;
}

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

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

/* Responsive Design */
@media (max-width: 768px) {
    .game-title {
        font-size: 2.5rem;
    }
    
    .timeline-container {
        flex-direction: column;
        align-items: center;
    }
    
    .era-node {
        width: 100%;
        max-width: 200px;
    }
    
    .player-stats {
        flex-direction: column;
        gap: 15px;
        text-align: center;
    }
    
    .ui-top {
        flex-direction: column;
        gap: 10px;
        align-items: stretch;
    }
    
    .ui-controls {
        position: static;
        transform: none;
        margin: 10px auto;
        align-self: center;
        font-size: 0.8rem;
    }
    
    .ui-bottom {
        bottom: 10px;
        flex-wrap: wrap;
        max-width: 90%;
    }
    
    .professor-guide {
        flex-direction: column;
        text-align: center;
    }
    
    .speech-bubble::before {
        display: none;
    }
}

@media (max-width: 480px) {
    .modal-content {
        padding: 20px;
        margin: 10px;
    }
    
    .modal-buttons {
        flex-direction: column;
        align-items: center;
    }
    
    .modal-button {
        width: 100%;
        max-width: 250px;
    }
    
    .interaction-buttons {
        flex-direction: column;
        align-items: center;
    }
    
    .interaction-button {
        width: 100%;
        max-width: 200px;
    }
    
    .timeline-container {
        grid-template-columns: repeat(2, 1fr);
    }
}