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

body {
    font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    overflow: hidden;
}

/* Main Container - Adapts to iframe or standalone */
#mainContainer {
    width: 100%;
    height: 450px; /* Default for iframe */
    background: linear-gradient(to bottom, #87CEEB 0%, #98D8C8 100%);
    position: relative;
    overflow-y: auto;
    overflow-x: hidden;
}

/* Standalone mode - uses 90vh */
body.standalone #mainContainer {
    height: 90vh;
}

/* Header Tooltip - Saves vertical space */
#headerTooltip {
    position: absolute;
    top: 8px;
    right: 8px;
    z-index: 1000;
}

.info-icon {
    font-size: 20px;
    cursor: help;
    background: rgba(255, 255, 255, 0.9);
    border-radius: 50%;
    width: 28px;
    height: 28px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    box-shadow: 0 2px 8px rgba(0,0,0,0.2);
    transition: transform 0.2s;
}

.info-icon:hover {
    transform: scale(1.1);
}

.tooltiptext {
    visibility: hidden;
    width: 280px;
    background-color: #333;
    color: #fff;
    text-align: center;
    border-radius: 6px;
    padding: 10px;
    position: absolute;
    z-index: 1001;
    top: 35px;
    right: 0;
    opacity: 0;
    transition: opacity 0.3s;
    font-size: 13px;
    line-height: 1.4;
    box-shadow: 0 4px 12px rgba(0,0,0,0.3);
}

#headerTooltip:hover .tooltiptext {
    visibility: visible;
    opacity: 1;
}

/* Panel Styles */
.panel {
    width: 100%;
    height: 100%;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    padding: 15px;
    transition: opacity 0.3s;
}

.hidden {
    display: none !important;
}

/* Story Panel */
.story-content {
    background: rgba(255, 255, 255, 0.95);
    border-radius: 12px;
    padding: 25px;
    max-width: 600px;
    box-shadow: 0 8px 24px rgba(0,0,0,0.2);
    text-align: center;
}

.story-content h2 {
    color: #2c3e50;
    margin-bottom: 15px;
    font-size: 24px;
}

.story-content p {
    color: #34495e;
    margin-bottom: 12px;
    line-height: 1.6;
    font-size: 15px;
}

/* Action Buttons */
.action-btn {
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    color: white;
    border: none;
    padding: 12px 28px;
    border-radius: 25px;
    font-size: 15px;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.3s;
    box-shadow: 0 4px 12px rgba(0,0,0,0.2);
    margin: 8px 5px;
    white-space: nowrap;
    min-height: 44px; /* Touch-friendly */
}

.action-btn:hover:not(:disabled) {
    transform: translateY(-2px);
    box-shadow: 0 6px 16px rgba(0,0,0,0.3);
}

.action-btn:active:not(:disabled) {
    transform: translateY(0);
}

.action-btn:disabled {
    opacity: 0.5;
    cursor: not-allowed;
}

.secondary-btn {
    background: linear-gradient(135deg, #f093fb 0%, #f5576c 100%);
}

.hint-btn {
    background: linear-gradient(135deg, #4facfe 0%, #00f2fe 100%);
}

/* Game Area */
#gameArea {
    justify-content: flex-start;
    padding: 10px;
}

/* Status Bar */
.status-bar {
    display: flex;
    justify-content: space-between;
    align-items: center;
    width: 100%;
    max-width: 900px;
    background: rgba(255, 255, 255, 0.9);
    padding: 8px 15px;
    border-radius: 8px;
    margin-bottom: 10px;
    box-shadow: 0 2px 8px rgba(0,0,0,0.1);
}

.progress-container {
    display: flex;
    align-items: center;
    flex: 1;
    margin-right: 15px;
}

.progress-label {
    font-weight: 600;
    margin-right: 8px;
    font-size: 13px;
    color: #2c3e50;
}

.progress-bar {
    flex: 1;
    height: 20px;
    background: #e0e0e0;
    border-radius: 10px;
    overflow: hidden;
    max-width: 200px;
}

.progress-fill {
    height: 100%;
    background: linear-gradient(90deg, #4CAF50, #8BC34A);
    width: 0%;
    transition: width 0.5s ease;
}

.timer-container {
    display: flex;
    align-items: center;
    font-weight: 600;
    color: #2c3e50;
    font-size: 14px;
}

.timer-icon {
    margin-right: 5px;
}

.weather-indicator {
    font-size: 24px;
    margin-left: 10px;
    transition: all 0.5s;
}

/* Instruction Box */
.instruction-box {
    background: rgba(255, 255, 255, 0.9);
    padding: 8px 15px;
    border-radius: 8px;
    margin-bottom: 10px;
    display: flex;
    align-items: center;
    font-size: 14px;
    font-weight: 500;
    color: #2c3e50;
    box-shadow: 0 2px 8px rgba(0,0,0,0.1);
    max-width: 900px;
    width: 100%;
}

.instruction-icon {
    margin-right: 8px;
    font-size: 18px;
}

/* Drop Zones Container */
.drop-zones-container {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
    justify-content: center;
    margin-bottom: 12px;
    max-width: 900px;
    width: 100%;
}

.drop-zone {
    background: rgba(255, 255, 255, 0.7);
    border: 3px dashed #999;
    border-radius: 8px;
    padding: 10px;
    min-height: 70px;
    width: calc(33.333% - 8px);
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    transition: all 0.3s;
    position: relative;
}

.drop-zone.drag-over {
    background: rgba(103, 126, 234, 0.2);
    border-color: #667eea;
    transform: scale(1.02);
}

.drop-zone.filled {
    border-style: solid;
    border-color: #4CAF50;
    background: rgba(76, 175, 80, 0.1);
}

.drop-zone.incorrect {
    border-color: #f44336;
    background: rgba(244, 67, 54, 0.1);
    animation: shake 0.5s;
}

.drop-zone.correct {
    border-color: #4CAF50;
    background: rgba(76, 175, 80, 0.2);
}

.zone-number {
    position: absolute;
    top: 5px;
    left: 8px;
    background: #667eea;
    color: white;
    width: 22px;
    height: 22px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-weight: 700;
    font-size: 12px;
}

/* Items Pool */
.items-pool {
    background: rgba(255, 255, 255, 0.9);
    border-radius: 8px;
    padding: 10px;
    margin-bottom: 10px;
    max-width: 900px;
    width: 100%;
    box-shadow: 0 2px 8px rgba(0,0,0,0.1);
}

.pool-label {
    font-weight: 600;
    margin-bottom: 8px;
    color: #2c3e50;
    font-size: 13px;
}

.draggable-items {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
    justify-content: center;
}

/* Draggable Item */
.draggable-item {
    background: linear-gradient(135deg, #ffffff 0%, #f0f0f0 100%);
    border: 2px solid #667eea;
    border-radius: 8px;
    padding: 10px 15px;
    cursor: move;
    transition: all 0.3s;
    box-shadow: 0 2px 6px rgba(0,0,0,0.1);
    font-size: 13px;
    text-align: center;
    min-height: 44px; /* Touch-friendly */
    display: flex;
    align-items: center;
    justify-content: center;
    user-select: none;
    touch-action: none;
}

.draggable-item:hover {
    transform: translateY(-2px);
    box-shadow: 0 4px 12px rgba(0,0,0,0.2);
}

.draggable-item.dragging {
    opacity: 0.5;
    cursor: grabbing;
}

.draggable-item.placed {
    opacity: 0.3;
    cursor: not-allowed;
}

/* Feedback Panel */
.feedback-panel {
    background: rgba(255, 255, 255, 0.95);
    border-radius: 8px;
    padding: 12px;
    margin-bottom: 10px;
    max-width: 900px;
    width: 100%;
    box-shadow: 0 2px 8px rgba(0,0,0,0.1);
    text-align: center;
}

.feedback-content {
    font-size: 14px;
    font-weight: 600;
}

.feedback-success {
    color: #4CAF50;
}

.feedback-error {
    color: #f44336;
}

.feedback-hint {
    color: #2196F3;
}

/* Action Buttons Container */
.action-buttons {
    display: flex;
    justify-content: center;
    flex-wrap: wrap;
    gap: 8px;
    max-width: 900px;
    width: 100%;
}

/* Success Panel */
.success-content {
    background: rgba(255, 255, 255, 0.95);
    border-radius: 12px;
    padding: 25px;
    max-width: 600px;
    box-shadow: 0 8px 24px rgba(0,0,0,0.2);
    text-align: center;
}

.success-icon {
    font-size: 60px;
    margin-bottom: 15px;
    animation: bounce 1s;
}

.success-content h2 {
    color: #4CAF50;
    margin-bottom: 15px;
    font-size: 24px;
}

.success-content p {
    color: #34495e;
    margin-bottom: 12px;
    line-height: 1.6;
    font-size: 15px;
}

.final-stats {
    background: #f5f5f5;
    padding: 15px;
    border-radius: 8px;
    margin: 15px 0;
    font-size: 14px;
}

.success-message ul {
    text-align: left;
    margin: 15px auto;
    max-width: 450px;
}

.success-message li {
    margin: 8px 0;
    color: #34495e;
    font-size: 14px;
    line-height: 1.5;
}

/* Animations */
@keyframes shake {
    0%, 100% { transform: translateX(0); }
    25% { transform: translateX(-5px); }
    75% { transform: translateX(5px); }
}

@keyframes bounce {
    0%, 100% { transform: translateY(0); }
    50% { transform: translateY(-20px); }
}

/* Responsive Design for smaller screens */
@media (max-width: 768px) {
    .drop-zone {
        width: calc(50% - 8px);
        min-height: 65px;
    }
    
    .story-content, .success-content {
        padding: 20px;
    }
    
    .action-btn {
        padding: 10px 20px;
        font-size: 14px;
    }
}

@media (max-width: 480px) {
    .drop-zone {
        width: 100%;
    }
    
    .status-bar {
        flex-direction: column;
        gap: 8px;
    }
    
    .progress-container {
        width: 100%;
        margin-right: 0;
    }
    
    .progress-bar {
        max-width: 100%;
    }
}