/* Reset and base styles */
* {
    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%);
    color: #333;
    overflow-x: hidden;
}

/* Main container - adapts to iframe or full screen */
#main-container {
    width: 100%;
    height: 100vh;
    min-height: 450px;
    position: relative;
    display: flex;
    align-items: center;
    justify-content: center;
}

/* Check if in iframe and adjust height */
@media (max-height: 500px) {
    #main-container {
        height: 450px;
    }
}

/* Screen management */
.screen {
    display: none;
    width: 100%;
    height: 100%;
    padding: 10px;
    position: absolute;
    top: 0;
    left: 0;
}

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

/* Welcome Screen Styles */
#welcome-screen {
    align-items: center;
    justify-content: center;
    text-align: center;
    background: rgba(255, 255, 255, 0.95);
    backdrop-filter: blur(10px);
}

.welcome-content {
    max-width: 500px;
    padding: 20px;
}

.icon-container {
    font-size: 4rem;
    margin-bottom: 20px;
    cursor: help;
}

.welcome-content h2 {
    color: #4a5568;
    margin-bottom: 15px;
    font-size: 1.8rem;
}

.welcome-content p {
    color: #718096;
    margin-bottom: 25px;
    font-size: 1.1rem;
}

.objectives {
    text-align: left;
    margin-bottom: 30px;
    background: rgba(102, 126, 234, 0.1);
    padding: 20px;
    border-radius: 10px;
}

.objectives h3 {
    color: #4a5568;
    margin-bottom: 10px;
}

.objectives ul {
    list-style: none;
    padding-left: 0;
}

.objectives li {
    padding: 5px 0;
    position: relative;
    padding-left: 25px;
}

.objectives li:before {
    content: "✓";
    position: absolute;
    left: 0;
    color: #48bb78;
    font-weight: bold;
}

/* Button Styles */
.primary-btn, .secondary-btn {
    padding: 12px 30px;
    border: none;
    border-radius: 25px;
    font-size: 1rem;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.3s ease;
    margin: 5px;
    min-height: 44px; /* Touch-friendly size */
    white-space: nowrap;
}

.primary-btn {
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    color: white;
    box-shadow: 0 4px 15px rgba(102, 126, 234, 0.4);
}

.primary-btn:hover {
    transform: translateY(-2px);
    box-shadow: 0 6px 20px rgba(102, 126, 234, 0.6);
}

.secondary-btn {
    background: rgba(255, 255, 255, 0.9);
    color: #4a5568;
    border: 2px solid #e2e8f0;
}

.secondary-btn:hover {
    background: white;
    border-color: #cbd5e0;
    transform: translateY(-1px);
}

/* Game Screen Styles */
#game-screen {
    background: rgba(255, 255, 255, 0.95);
    backdrop-filter: blur(10px);
    padding: 15px;
}

.game-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 20px;
    flex-wrap: wrap;
    gap: 10px;
}

.progress-container {
    display: flex;
    align-items: center;
    gap: 10px;
    flex: 1;
    min-width: 150px;
}

.progress-bar {
    flex: 1;
    height: 8px;
    background: #e2e8f0;
    border-radius: 4px;
    overflow: hidden;
}

#progress-fill {
    height: 100%;
    background: linear-gradient(90deg, #48bb78, #38a169);
    width: 0%;
    transition: width 0.5s ease;
}

.score-container {
    display: flex;
    gap: 15px;
    font-weight: 600;
    color: #4a5568;
}

/* Game Board */
.game-board {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 20px;
    height: calc(100% - 120px);
    min-height: 300px;
}

.column {
    background: rgba(255, 255, 255, 0.8);
    border-radius: 15px;
    padding: 15px;
    box-shadow: 0 4px 20px rgba(0, 0, 0, 0.1);
}

.column-title {
    text-align: center;
    color: #4a5568;
    margin-bottom: 15px;
    font-size: 1.1rem;
    padding-bottom: 10px;
    border-bottom: 2px solid #e2e8f0;
}

.cards-container {
    display: flex;
    flex-direction: column;
    gap: 10px;
    height: calc(100% - 60px);
    overflow-y: auto;
}

/* Card Styles */
.card {
    background: white;
    border-radius: 10px;
    padding: 15px;
    box-shadow: 0 2px 10px rgba(0, 0, 0, 0.1);
    cursor: pointer;
    transition: all 0.3s ease;
    border: 2px solid transparent;
    min-height: 60px;
    display: flex;
    align-items: center;
    justify-content: center;
    text-align: center;
    font-size: 0.9rem;
    line-height: 1.4;
}

.card:hover {
    transform: translateY(-2px);
    box-shadow: 0 4px 15px rgba(0, 0, 0, 0.15);
    border-color: #667eea;
}

.card.selected {
    border-color: #667eea;
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    color: white;
}

.card.matched {
    background: linear-gradient(135deg, #48bb78 0%, #38a169 100%);
    color: white;
    cursor: default;
    opacity: 0.8;
}

.card.incorrect {
    background: linear-gradient(135deg, #f56565 0%, #e53e3e 100%);
    color: white;
    animation: shake 0.5s ease-in-out;
}

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

/* Feedback Section */
.feedback {
    position: fixed;
    bottom: 20px;
    left: 50%;
    transform: translateX(-50%);
    background: white;
    padding: 15px 25px;
    border-radius: 25px;
    box-shadow: 0 4px 20px rgba(0, 0, 0, 0.2);
    z-index: 1000;
    transition: all 0.3s ease;
}

.feedback.hidden {
    opacity: 0;
    transform: translateX(-50%) translateY(100px);
    pointer-events: none;
}

.feedback-content {
    display: flex;
    align-items: center;
    gap: 15px;
}

/* Hint Button */
.hint-btn {
    position: fixed;
    top: 20px;
    right: 20px;
    width: 50px;
    height: 50px;
    border-radius: 50%;
    border: none;
    background: linear-gradient(135deg, #ffd89b 0%, #19547b 100%);
    color: white;
    font-size: 1.5rem;
    cursor: pointer;
    box-shadow: 0 4px 15px rgba(0, 0, 0, 0.2);
    transition: all 0.3s ease;
    z-index: 1000;
}

.hint-btn:hover {
    transform: scale(1.1);
}

/* Results Screen */
#results-screen {
    align-items: center;
    justify-content: center;
    text-align: center;
    background: rgba(255, 255, 255, 0.95);
    backdrop-filter: blur(10px);
}

.results-content {
    max-width: 500px;
    padding: 20px;
}

.trophy-icon {
    font-size: 4rem;
    margin-bottom: 20px;
}

.results-stats {
    display: flex;
    justify-content: space-around;
    margin: 30px 0;
    gap: 20px;
}

.stat {
    text-align: center;
}

.stat-value {
    display: block;
    font-size: 2rem;
    font-weight: bold;
    color: #667eea;
}

.stat-label {
    color: #718096;
    font-size: 0.9rem;
}

.reflection-section {
    margin: 30px 0;
    text-align: left;
    background: rgba(102, 126, 234, 0.1);
    padding: 20px;
    border-radius: 10px;
}

.reflection-section h3 {
    margin-bottom: 10px;
    color: #4a5568;
}

.reflection-section p {
    margin-bottom: 15px;
    color: #718096;
}

#reflection-text {
    width: 100%;
    min-height: 80px;
    padding: 10px;
    border: 2px solid #e2e8f0;
    border-radius: 8px;
    font-family: inherit;
    resize: vertical;
}

.results-actions {
    display: flex;
    gap: 15px;
    justify-content: center;
    flex-wrap: wrap;
}

/* Tooltip */
.tooltip {
    position: fixed;
    background: rgba(0, 0, 0, 0.9);
    color: white;
    padding: 10px 15px;
    border-radius: 8px;
    font-size: 0.9rem;
    max-width: 250px;
    z-index: 2000;
    pointer-events: none;
    transition: opacity 0.3s ease;
}

.tooltip.hidden {
    opacity: 0;
}

/* Modal */
.modal {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.5);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 2000;
}

.modal.hidden {
    display: none;
}

.modal-content {
    background: white;
    padding: 30px;
    border-radius: 15px;
    max-width: 400px;
    margin: 20px;
    position: relative;
    text-align: center;
}

.close-modal {
    position: absolute;
    top: 10px;
    right: 15px;
    font-size: 1.5rem;
    cursor: pointer;
    color: #718096;
}

/* Mobile Responsive */
@media (max-width: 768px) {
    .game-board {
        grid-template-columns: 1fr;
        gap: 15px;
    }
    
    .game-header {
        flex-direction: column;
        align-items: stretch;
        gap: 10px;
    }
    
    .score-container {
        justify-content: center;
    }
    
    .card {
        font-size: 0.85rem;
        padding: 12px;
        min-height: 50px;
    }
    
    .results-stats {
        flex-direction: column;
        gap: 15px;
    }
    
    .results-actions {
        flex-direction: column;
    }
    
    .primary-btn, .secondary-btn {
        width: 100%;
    }
}

/* Very small screens (iframe height constraint) */
@media (max-height: 500px) {
    .welcome-content {
        padding: 15px;
    }
    
    .objectives {
        padding: 15px;
        margin-bottom: 20px;
    }
    
    .game-header {
        margin-bottom: 10px;
    }
    
    .card {
        padding: 10px;
        min-height: 45px;
        font-size: 0.8rem;
    }
    
    .column {
        padding: 10px;
    }
    
    .results-content {
        padding: 15px;
    }
    
    .reflection-section {
        padding: 15px;
        margin: 20px 0;
    }
    
    #reflection-text {
        min-height: 60px;
    }
}