* {
    box-sizing: border-box;
}

body {
    font-family: 'Kalam', 'Segoe Script', 'Comic Sans MS', 'Bradley Hand', cursive;
    line-height: 1.8;
    margin: 0;
    padding: 0;
    background: #f0f0f0;
    height: 100vh;
    overflow: hidden;
    /* Fix for mobile browsers */
    min-height: -webkit-fill-available;
}

/* Site Header Strip */
.site-header {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    background: #1a1a1a;
    color: white;
    padding: 10px 20px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1.1em;
    z-index: 10000;
    box-shadow: 0 2px 5px rgba(0,0,0,0.2);
}

.site-name {
    font-weight: bold;
    letter-spacing: 1px;
}

/* Help icon in header */
.site-header .help-icon {
    position: absolute;
    right: 15px;
    top: 50%;
    transform: translateY(-50%);
    width: 30px;
    height: 30px;
    border-radius: 50%;
    background: #007bff;
    color: white;
    border: none;
    font-size: 18px;
    font-weight: bold;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 0;
    box-shadow: 0 2px 5px rgba(0,0,0,0.3);
    transition: all 0.2s;
    font-family: Arial, sans-serif;
}

.site-header .help-icon:hover {
    background: #0056b3;
    transform: translateY(-50%) scale(1.1);
}

.site-header .help-icon:active {
    transform: translateY(-50%) scale(0.95);
}

/* Help dropdown */
.help-text {
    position: fixed;
    top: 50px;
    right: 15px;
    background: white;
    border: 2px solid #007bff;
    border-radius: 8px;
    padding: 15px;
    box-shadow: 0 4px 12px rgba(0,0,0,0.2);
    z-index: 9999;
    max-width: 350px;
    font-size: 0.9em;
}

/* Goal checklist styling */
.goal-checklist {
    list-style: none;
    padding: 0;
    margin: 10px 0 0 0;
    text-align: left;
}

.goal-checklist li {
    padding: 8px 0;
    color: #333;
    font-size: 1em;
    display: flex;
    align-items: flex-start;
}

.goal-checklist li .checkmark {
    font-size: 1.2em;
    margin-right: 8px;
    font-weight: bold;
    color: #666;
    flex-shrink: 0;
}

.goal-checklist li.completed {
    color: #28a745;
    text-decoration: line-through;
    opacity: 0.7;
}

.goal-checklist li.completed .checkmark {
    color: #28a745;
}

.goal-checklist li.subgoal {
    color: #ff6b6b;
    font-weight: bold;
    border-top: 1px solid #eee;
    margin-top: 8px;
    padding-top: 12px;
}

.goal-checklist li.subgoal .checkmark {
    color: #ff6b6b;
}

/* Intro Screen */
#intro-screen {
    width: 100%;
    height: 100vh;
    background: white;
    display: flex;
    align-items: flex-start;
    justify-content: center;
    padding-top: 80px; /* Space for header + reduced gap */
    overflow-y: auto;
}

.intro-content {
    text-align: center;
    padding: 40px;
    max-width: 600px;
    background: #f9f9f9;
    border-radius: 8px;
    border: 1px solid #e0e0e0;
    box-shadow: 0 2px 8px rgba(0,0,0,0.1);
    margin: 20px;
}

#intro-title {
    font-size: 3em;
    margin-bottom: 20px;
    color: #333;
}

#intro-goal {
    font-size: 1.5em;
    margin-bottom: 40px;
    line-height: 1.6;
    color: #555;
}

#start-button {
    font-size: 1.3em;
    padding: 15px 40px;
    background: #0056b3;
    color: white;
    border: none;
    border-radius: 4px;
    cursor: pointer;
    font-family: inherit;
    font-weight: bold;
    box-shadow: 0 2px 8px rgba(0,0,0,0.2);
    transition: transform 0.2s, box-shadow 0.2s, background 0.2s;
}

#start-button:hover {
    background: #004494;
    transform: translateY(-2px);
    box-shadow: 0 4px 12px rgba(0,0,0,0.3);
}

#start-button:active {
    transform: translateY(0);
    box-shadow: 0 2px 8px rgba(0,0,0,0.2);
}

/* Victory Screen */
#victory-screen {
    width: 100%;
    height: 100vh;
    background: white;
    display: flex;
    align-items: center;
    justify-content: center;
    padding-top: 50px; /* Space for header */
    padding-bottom: 20px;
    box-sizing: border-box;
    overflow-y: auto;
}

.victory-content {
    text-align: center;
    padding: 40px;
    max-width: 90%;
    width: 600px;
    box-sizing: border-box;
    background: #f0f8f0;
    border-radius: 8px;
    border: 2px solid #4caf50;
    box-shadow: 0 4px 16px rgba(76, 175, 80, 0.2);
    margin: 20px;
}

.victory-title {
    font-size: 3.5em;
    margin-bottom: 20px;
    color: #2e7d32;
    animation: victoryPulse 2s ease-in-out infinite;
}

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

#victory-message {
    font-size: 1.5em;
    margin-bottom: 40px;
    line-height: 1.6;
    color: #555;
}

#restart-button {
    font-size: 1.3em;
    padding: 15px 40px;
    background: #4caf50;
    color: white;
    border: none;
    border-radius: 4px;
    cursor: pointer;
    font-family: inherit;
    font-weight: bold;
    box-shadow: 0 2px 8px rgba(0,0,0,0.2);
    transition: transform 0.2s, box-shadow 0.2s, background 0.2s;
}

#restart-button:hover {
    background: #45a049;
    transform: translateY(-2px);
    box-shadow: 0 4px 12px rgba(0,0,0,0.3);
}

/* Game Over Screen */
#gameover-screen {
    width: 100%;
    height: 100vh;
    background: linear-gradient(135deg, #d32f2f 0%, #c62828 100%);
    display: flex;
    align-items: center;
    justify-content: center;
    padding-top: 50px;
    box-sizing: border-box;
}

.gameover-content {
    text-align: center;
    color: white;
    padding: 40px;
    max-width: 90%;
    width: 600px;
    box-sizing: border-box;
}

.gameover-title {
    font-size: 3.5em;
    margin-bottom: 20px;
    text-shadow: 2px 2px 4px rgba(0,0,0,0.3);
}

#gameover-message {
    font-size: 1.5em;
    margin-bottom: 40px;
    line-height: 1.6;
    text-shadow: 1px 1px 2px rgba(0,0,0,0.2);
}

#gameover-restart-button {
    font-size: 1.3em;
    padding: 15px 40px;
    background: white;
    color: #d32f2f;
    border: none;
    border-radius: 50px;
    cursor: pointer;
    font-family: inherit;
    font-weight: bold;
    box-shadow: 0 4px 15px rgba(0,0,0,0.2);
    transition: transform 0.2s, box-shadow 0.2s;
}

#gameover-restart-button:hover {
    transform: translateY(-2px);
    box-shadow: 0 6px 20px rgba(0,0,0,0.3);
}

/* Time limit info display in game */
#time-limit-display {
    position: fixed;
    top: 50px;
    right: 10px;
    background: rgba(255, 255, 255, 0.95);
    padding: 10px 15px;
    border-radius: 8px;
    box-shadow: 0 2px 10px rgba(0,0,0,0.1);
    font-size: 0.9em;
    z-index: 9000;
}

#time-limit-display .time-info {
    margin: 5px 0;
    color: #333;
}

#time-limit-display .time-warning {
    color: #d32f2f;
    font-weight: bold;
}

#restart-button:active {
    transform: translateY(0);
    box-shadow: 0 2px 10px rgba(0,0,0,0.2);
}

#app {
    max-width: 800px;
    margin: 0 auto;
    background: white;
    height: 100vh;
    min-height: -webkit-fill-available;
    display: flex;
    flex-direction: column;
    box-shadow: 0 2px 4px rgba(0,0,0,0.1);
}

/* Fixed header section */
.game-header {
    flex-shrink: 0;
    padding: 20px;
    padding-top: 50px;
    border-bottom: 1px solid #e0e0e0;
    background: white;
    position: relative;
    overflow: visible;
}

#problem {
    font-size: 1.2em;
    margin-bottom: 20px;
    color: #333;
}

.controls {
    margin-bottom: 15px;
    display: flex;
    align-items: center;
    gap: 10px;
}

.controls button {
    padding: 8px 16px;
    background: #007bff;
    color: white;
    border: none;
    border-radius: 4px;
    cursor: pointer;
    font-size: 14px;
}

.controls button:hover {
    background: #0056b3;
}

.controls label {
    margin-left: auto;
}

#message {
    padding: 12px;
    margin: 0 0 10px 0;
    color: #2c3e50;
    font-weight: bold;
    font-size: 24px;
    text-align: center;
    transition: all 0.3s ease;
    min-height: 20px;
    letter-spacing: 0.5px;
}

/* Event messages - no longer used but keeping for compatibility */
#events-container {
    margin: 10px 0 0 0;
}

.event-message {
    padding: 12px;
    margin: 5px 0;
    border-radius: 4px;
    font-weight: 500;
    animation: fadeIn 0.5s ease-in;
}

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

.event-start {
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    color: white;
    border-left: 4px solid #4c51bf;
    box-shadow: 0 2px 8px rgba(102, 126, 234, 0.3);
}

.event-ongoing {
    background: linear-gradient(135deg, #f093fb 0%, #f5576c 100%);
    color: white;
    border-left: 4px solid #ed64a6;
    box-shadow: 0 2px 8px rgba(240, 147, 251, 0.3);
}

.event-end {
    background: linear-gradient(135deg, #4facfe 0%, #00f2fe 100%);
    color: white;
    border-left: 4px solid #0ea5e9;
    box-shadow: 0 2px 8px rgba(79, 172, 254, 0.3);
}

.help-text {
    padding: 10px;
    margin: 10px 0 0 0;
    background: #e8f4ff;
    border-left: 4px solid #0056b3;
    border-radius: 4px;
}

.help-text p {
    margin: 0 0 8px 0;
    font-weight: bold;
    color: #0056b3;
}

.help-text ul {
    margin: 0;
    padding-left: 20px;
    color: #444;
}

.help-text li {
    margin: 4px 0;
}

/* Scrollable content section */
.game-content {
    flex: 1;
    overflow-y: auto;
    padding: 20px;
    background: white;
}

.view {
    margin-bottom: 20px;
    padding: 15px;
    background: #f9f9f9;
    border-radius: 4px;
    border: 1px solid #e0e0e0;
    transition: all 0.2s ease;
}

.view:hover {
    border-color: #ccc;
}

.view-header {
    margin: 0 0 10px 0;
    color: #333;
    cursor: pointer;
    transition: color 0.2s ease;
}

.view-header:hover {
    color: #0056b3;
}

.view h2 {
    font-size: 1.4em;
}

.view h3 {
    font-size: 1.2em;
}

.view p {
    margin: 0 0 15px 0;
    line-height: 1.6;
}

.objects {
    display: flex;
    flex-wrap: wrap;
    gap: 10px;
    margin-top: 10px;
}

.object-link {
    color: #0056b3;
    text-decoration: underline;
    cursor: pointer;
    user-select: none;
    transition: all 0.2s ease;
}

.object-link:hover {
    color: #003d80;
}

.object-link:active {
    color: #004c99;
}

.room-link {
    color: #0056b3;
    text-decoration: underline;
    cursor: pointer;
    user-select: none;
    transition: all 0.2s ease;
}

.room-link:hover {
    color: #003d80;
}

.room-link:active {
    color: #004c99;
}

.object.selected {
    background: #007bff;
    color: white;
    border-color: #0056b3;
}

/* Fixed inventory section */
#inventory {
    flex-shrink: 0;
    padding: 15px 20px;
    background: #f8f8f8;
    border-top: 1px solid #e0e0e0;
    max-height: 40vh;
    overflow-y: auto;
}

#inventory h3 {
    margin: 0 0 15px 0;
    color: #333;
}

#inventory-list {
    list-style: none;
    padding: 0;
    margin: 0;
}

.inventory-item {
    padding: 10px;
    margin-bottom: 8px;
    background: white;
    border: 2px solid #dee2e6;
    border-radius: 4px;
    transition: all 0.2s ease;
}

.inventory-item:hover {
    background: #f0f0f0;
    border-color: #007bff;
}

.inventory-item.selected {
    background: #e3f2fd;
    border-color: #007bff;
    box-shadow: 0 0 0 2px rgba(0, 123, 255, 0.2);
}

.inventory-item .object-link {
    font-weight: bold;
    color: #0056b3;
    text-decoration: underline;
    cursor: pointer;
}

.inventory-item .object-link:hover {
    color: #003d80;
}

.inventory-item.selected .object-link {
    color: #0056b3;
}

.inventory-item-desc {
    color: #666;
    font-size: 0.9em;
}

.inventory-item.selected .inventory-item-desc {
    color: #444;
}

/* Mobile-friendly adjustments */
@media (max-width: 600px) {
    body {
        padding: 0;
        /* Better handling of mobile viewport */
        height: 100vh;
        height: -webkit-fill-available;
    }
    
    #app {
        height: 100vh;
        height: -webkit-fill-available;
    }
    
    .game-header {
        padding: 12px;
        padding-top: 60px; /* Space for site header */
        overflow: visible;
    }
    
    /* Help icon stays in site header on mobile */
    .site-header .help-icon {
        width: 35px;
        height: 35px;
        font-size: 20px;
        right: 10px;
    }
    
    /* Help dropdown on mobile */
    .help-text {
        top: 55px;
        right: 10px;
        left: 10px;
        max-width: none;
        font-size: 0.85em;
    }
    
    #message {
        font-size: 18px;
        padding: 10px 8px;
        margin: 0 0 10px 0;
        min-height: 20px;
        display: block;
        width: 100%;
        box-sizing: border-box;
        letter-spacing: 0.3px;
    }
    
    .game-content {
        padding: 15px;
    }
    
    #inventory {
        padding: 15px;
    }
    
    .object {
        padding: 12px 20px; /* Larger touch targets */
        font-size: 1.1em;
    }
    
    .objects {
        gap: 12px;
    }
}