/* 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 */
    position: relative;
    overflow-y: auto;
    overflow-x: hidden;
    background: linear-gradient(135deg, #f5f7fa 0%, #c3cfe2 100%);
}

/* Detect if not in iframe - use 90vh */
html:not([data-iframe]) #mainContainer {
    height: 90vh;
}

/* Info icon for header tooltip - positioned top left */
.info-icon {
    position: fixed;
    top: 10px;
    left: 10px;
    width: 28px;
    height: 28px;
    background: rgba(255, 255, 255, 0.9);
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    font-size: 16px;
    z-index: 1000;
    box-shadow: 0 2px 8px rgba(0,0,0,0.2);
    transition: all 0.3s ease;
}

.info-icon:hover {
    transform: scale(1.1);
    box-shadow: 0 4px 12px rgba(0,0,0,0.3);
}

/* Header tooltip */
.tooltip {
    position: fixed;
    top: 45px;
    left: 10px;
    max-width: 300px;
    background: rgba(0, 0, 0, 0.9);
    color: white;
    padding: 12px 16px;
    border-radius: 8px;
    font-size: 13px;
    z-index: 1001;
    box-shadow: 0 4px 12px rgba(0,0,0,0.3);
    transition: opacity 0.3s ease;
}

.tooltip.hidden {
    opacity: 0;
    pointer-events: none;
}

/* Score panel - positioned top right */
#scorePanel {
    position: fixed;
    top: 10px;
    right: 10px;
    display: flex;
    gap: 15px;
    z-index: 1000;
}

.score-item {
    background: rgba(255, 255, 255, 0.95);
    padding: 8px 16px;
    border-radius: 20px;
    box-shadow: 0 2px 8px rgba(0,0,0,0.2);
    display: flex;
    align-items: center;
    gap: 8px;
    font-weight: 600;
}

.score-label {
    color: #667eea;
    font-size: 13px;
}

#scoreValue, #stageValue {
    color: #764ba2;
    font-size: 16px;
    font-weight: bold;
}

/* Content area */
#contentArea {
    padding: 50px 20px 20px;
    max-width: 1000px;
    margin: 0 auto;
}

/* Screen management - only one screen visible at a time */
.screen {
    display: none;
    animation: fadeIn 0.5s ease;
}

.screen.active {
    display: block;
}

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

/* Story box - narrative container */
.story-box {
    background: white;
    padding: 20px;
    border-radius: 12px;
    box-shadow: 0 4px 12px rgba(0,0,0,0.1);
    margin-bottom: 20px;
}

.story-box h2 {
    color: #667eea;
    margin-bottom: 12px;
    font-size: 22px;
}

.story-box p {
    color: #333;
    line-height: 1.6;
    margin-bottom: 10px;
    font-size: 14px;
}

.story-text {
    font-size: 15px;
    font-weight: 600;
    color: #764ba2;
}

/* Thinking type badges */
.thinking-types {
    display: flex;
    flex-wrap: wrap;
    gap: 10px;
    margin-top: 15px;
}

.type-badge {
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    color: white;
    padding: 8px 14px;
    border-radius: 20px;
    font-size: 12px;
    font-weight: 600;
    box-shadow: 0 2px 6px rgba(0,0,0,0.2);
}

/* Activity container */
.activity-container {
    background: white;
    padding: 20px;
    border-radius: 12px;
    box-shadow: 0 4px 12px rgba(0,0,0,0.1);
    margin-bottom: 15px;
    min-height: 200px;
}

/* Stage 1: Matching Activity */
.matching-area {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 20px;
}

.column h3 {
    color: #667eea;
    margin-bottom: 12px;
    font-size: 16px;
    text-align: center;
}

.match-item {
    background: #f8f9fa;
    padding: 12px;
    border-radius: 8px;
    margin-bottom: 10px;
    font-size: 13px;
    line-height: 1.4;
    cursor: move;
    transition: all 0.3s ease;
    border: 2px solid transparent;
    min-height: 60px;
    display: flex;
    align-items: center;
}

.match-item.puzzle {
    background: linear-gradient(135deg, #ffecd2 0%, #fcb69f 100%);
    color: #333;
}

.match-item.answer {
    background: linear-gradient(135deg, #a1c4fd 0%, #c2e9fb 100%);
    color: #333;
}

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

.match-item.dragging {
    opacity: 0.5;
}

.match-item.drop-zone.drag-over {
    border: 2px dashed #667eea;
    background: rgba(102, 126, 234, 0.1);
}

.match-item.matched {
    background: linear-gradient(135deg, #84fab0 0%, #8fd3f4 100%);
    border: 2px solid #28a745;
}

/* Stage 2: Sorting Activity */
.sorting-area {
    display: flex;
    flex-direction: column;
    gap: 20px;
}

.sort-source {
    background: #f8f9fa;
    padding: 15px;
    border-radius: 8px;
}

.sort-source h3 {
    color: #667eea;
    margin-bottom: 12px;
    font-size: 15px;
}

.sort-item {
    background: linear-gradient(135deg, #ffecd2 0%, #fcb69f 100%);
    padding: 12px;
    border-radius: 8px;
    margin-bottom: 10px;
    cursor: move;
    font-size: 13px;
    transition: all 0.3s ease;
    border: 2px solid transparent;
}

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

.sort-item.dragging {
    opacity: 0.5;
}

.sort-categories {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 15px;
}

.sort-category {
    background: #f8f9fa;
    padding: 15px;
    border-radius: 8px;
    border: 2px dashed #ccc;
    min-height: 120px;
    transition: all 0.3s ease;
}

.sort-category h4 {
    color: #667eea;
    margin-bottom: 8px;
    font-size: 14px;
}

.category-hint {
    font-size: 11px;
    color: #666;
    font-style: italic;
    margin-bottom: 10px;
}

.sort-category.drag-over {
    border: 2px dashed #667eea;
    background: rgba(102, 126, 234, 0.1);
}

.sort-category.correct {
    background: linear-gradient(135deg, #84fab0 0%, #8fd3f4 100%);
    border: 2px solid #28a745;
}

/* Stage 3: Choice Activity */
.choice-area {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
    gap: 15px;
}

.choice-card {
    background: linear-gradient(135deg, #ffecd2 0%, #fcb69f 100%);
    padding: 15px;
    border-radius: 12px;
    cursor: pointer;
    transition: all 0.3s ease;
    border: 3px solid transparent;
    position: relative;
    min-height: 100px;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
}

.choice-card:hover {
    transform: translateY(-4px);
    box-shadow: 0 6px 16px rgba(0,0,0,0.2);
}

.choice-number {
    width: 35px;
    height: 35px;
    background: #667eea;
    color: white;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-weight: bold;
    font-size: 16px;
    margin-bottom: 10px;
}

.choice-card p {
    font-size: 13px;
    text-align: center;
    color: #333;
    line-height: 1.4;
}

.choice-card.selected {
    border: 3px solid #667eea;
    background: linear-gradient(135deg, #a1c4fd 0%, #c2e9fb 100%);
}

.choice-card.correct {
    border: 3px solid #28a745;
    background: linear-gradient(135deg, #84fab0 0%, #8fd3f4 100%);
}

.choice-card.incorrect {
    border: 3px solid #dc3545;
    background: linear-gradient(135deg, #ffecd2 0%, #fcb69f 100%);
    opacity: 0.6;
}

/* Stage 4: Assumption Activity */
.assumption-area {
    display: flex;
    flex-direction: column;
    gap: 20px;
}

.puzzle-boxes {
    display: flex;
    flex-direction: column;
    gap: 15px;
}

.puzzle-box {
    background: #f8f9fa;
    padding: 15px;
    border-radius: 8px;
    border: 2px solid #ddd;
}

.puzzle-text {
    font-size: 13px;
    color: #333;
    margin-bottom: 10px;
    line-height: 1.4;
}

.assumption-slot {
    min-height: 60px;
    border: 2px dashed #ccc;
    border-radius: 8px;
    display: flex;
    align-items: center;
    justify-content: center;
    color: #999;
    font-size: 12px;
    font-style: italic;
    transition: all 0.3s ease;
}

.assumption-slot.drag-over {
    border: 2px dashed #667eea;
    background: rgba(102, 126, 234, 0.1);
}

.assumption-cards {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 15px;
}

.assumption-card {
    background: linear-gradient(135deg, #ffecd2 0%, #fcb69f 100%);
    padding: 12px;
    border-radius: 8px;
    cursor: move;
    transition: all 0.3s ease;
    border: 2px solid transparent;
}

.assumption-card:hover {
    transform: translateY(-2px);
    box-shadow: 0 4px 8px rgba(0,0,0,0.2);
}

.assumption-card strong {
    display: block;
    color: #667eea;
    margin-bottom: 5px;
    font-size: 13px;
}

.assumption-card p {
    font-size: 11px;
    color: #333;
    line-height: 1.3;
}

.assumption-card.dragging {
    opacity: 0.5;
}

.puzzle-box.correct {
    background: linear-gradient(135deg, #84fab0 0%, #8fd3f4 100%);
    border: 2px solid #28a745;
}

/* Stage 5: Final Challenge */
.final-puzzle {
    display: flex;
    flex-direction: column;
    gap: 20px;
}

.puzzle-scenario {
    background: linear-gradient(135deg, #ffecd2 0%, #fcb69f 100%);
    padding: 15px;
    border-radius: 8px;
}

.puzzle-scenario p {
    font-size: 13px;
    line-height: 1.5;
    color: #333;
    margin-bottom: 8px;
}

.analysis-section, .solution-section {
    background: #f8f9fa;
    padding: 15px;
    border-radius: 8px;
}

.analysis-section h4, .solution-section h4 {
    color: #667eea;
    margin-bottom: 12px;
    font-size: 14px;
}

.checkbox-group {
    display: grid;
    grid-template-columns: repeat(2, 1fr);
    gap: 10px;
}

.checkbox-label {
    display: flex;
    align-items: center;
    gap: 8px;
    cursor: pointer;
    padding: 8px;
    border-radius: 6px;
    transition: background 0.3s ease;
}

.checkbox-label:hover {
    background: rgba(102, 126, 234, 0.1);
}

.thinking-checkbox {
    width: 18px;
    height: 18px;
    cursor: pointer;
}

.checkbox-label span {
    font-size: 13px;
    color: #333;
}

/* Completion Screen */
.completion-box {
    text-align: center;
}

.final-score {
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    color: white;
    padding: 20px;
    border-radius: 12px;
    margin: 20px 0;
}

.final-score h3 {
    font-size: 24px;
    margin-bottom: 10px;
}

#rankDisplay {
    font-size: 18px;
    font-weight: 600;
    margin-top: 10px;
}

.summary-section {
    text-align: left;
    margin-top: 20px;
}

.summary-section h3 {
    color: #667eea;
    margin-bottom: 15px;
    font-size: 18px;
}

.learning-summary {
    display: flex;
    flex-direction: column;
    gap: 15px;
}

.summary-item {
    display: flex;
    gap: 15px;
    align-items: flex-start;
    background: #f8f9fa;
    padding: 12px;
    border-radius: 8px;
}

.summary-icon {
    font-size: 24px;
    flex-shrink: 0;
}

.summary-item strong {
    display: block;
    color: #667eea;
    margin-bottom: 5px;
    font-size: 14px;
}

.summary-item p {
    font-size: 12px;
    color: #666;
    line-height: 1.4;
}

/* Action buttons */
.action-btn {
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    color: white;
    border: none;
    padding: 12px 30px;
    border-radius: 25px;
    font-size: 15px;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.3s ease;
    box-shadow: 0 4px 12px rgba(0,0,0,0.2);
    display: block;
    margin: 15px auto 0;
    min-width: 180px;
}

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

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

/* Feedback area */
.feedback-area {
    background: white;
    padding: 15px;
    border-radius: 8px;
    margin-top: 15px;
    min-height: 50px;
    box-shadow: 0 2px 8px rgba(0,0,0,0.1);
    font-size: 14px;
    line-height: 1.5;
}

.feedback-area.success {
    background: linear-gradient(135deg, #84fab0 0%, #8fd3f4 100%);
    color: #155724;
}

.feedback-area.error {
    background: linear-gradient(135deg, #ffecd2 0%, #fcb69f 100%);
    color: #721c24;
}

.feedback-area.info {
    background: linear-gradient(135deg, #a1c4fd 0%, #c2e9fb 100%);
    color: #004085;
}

/* Central tooltip for detailed information */
.central-tooltip {
    position: fixed;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    max-width: 400px;
    background: rgba(0, 0, 0, 0.95);
    color: white;
    padding: 20px;
    border-radius: 12px;
    font-size: 14px;
    z-index: 2000;
    box-shadow: 0 8px 24px rgba(0,0,0,0.4);
    transition: opacity 0.3s ease;
    line-height: 1.6;
}

.central-tooltip.hidden {
    opacity: 0;
    pointer-events: none;
}

/* Sound toggle button */
.sound-toggle {
    position: fixed;
    bottom: 15px;
    right: 15px;
    width: 45px;
    height: 45px;
    background: rgba(255, 255, 255, 0.9);
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    font-size: 22px;
    z-index: 1000;
    box-shadow: 0 4px 12px rgba(0,0,0,0.2);
    transition: all 0.3s ease;
}

.sound-toggle:hover {
    transform: scale(1.1);
    box-shadow: 0 6px 16px rgba(0,0,0,0.3);
}

/* Responsive design for smaller screens */
@media (max-width: 768px) {
    .matching-area {
        grid-template-columns: 1fr;
    }
    
    .sort-categories {
        grid-template-columns: 1fr;
    }
    
    .assumption-cards {
        grid-template-columns: 1fr;
    }
    
    .checkbox-group {
        grid-template-columns: 1fr;
    }
    
    #scorePanel {
        flex-direction: column;
        gap: 8px;
    }
}

/* Accessibility - focus states */
button:focus, .choice-card:focus, .match-item:focus {
    outline: 3px solid #667eea;
    outline-offset: 2px;
}

/* Smooth scrolling */
html {
    scroll-behavior: smooth;
}

/* Loading animation for transitions */
@keyframes pulse {
    0%, 100% {
        opacity: 1;
    }
    50% {
        opacity: 0.5;
    }
}

.loading {
    animation: pulse 1.5s ease-in-out infinite;
}