/* Reset and base styles for cross-browser compatibility */
* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

body {
    font-family: 'Comic Sans MS', cursive, sans-serif;
    background: linear-gradient(135deg, #2c1810 0%, #8b4513 50%, #daa520 100%);
    color: #2c1810;
    overflow: hidden;
    height: 100vh;
    width: 100vw;
}

/* Main game container - responsive height for iframe vs full screen */
.game-container {
    width: 100%;
    height: 450px; /* Default iframe height */
    max-height: 90vh; /* Full screen height */
    background: linear-gradient(135deg, #f4e4bc 0%, #e6d3a3 50%, #d4af37 100%);
    position: relative;
    overflow: hidden;
    border-radius: 10px;
    box-shadow: 0 8px 32px rgba(0, 0, 0, 0.3);
}

/* Detect if running in full screen and adjust height */
@media (min-height: 500px) {
    .game-container {
        height: 90vh;
    }
}

/* Game header with progress indicators */
.game-header {
    background: rgba(139, 69, 19, 0.9);
    color: white;
    padding: 8px 15px;
    display: flex;
    justify-content: center;
    border-bottom: 3px solid #8b4513;
}

.progress-section {
    display: flex;
    gap: 20px;
    align-items: center;
    font-weight: bold;
    font-size: 14px;
}

.crystals-collected, .timer, .typing-stats {
    display: flex;
    align-items: center;
    gap: 5px;
    background: rgba(255, 255, 255, 0.2);
    padding: 5px 10px;
    border-radius: 15px;
    transition: all 0.3s ease;
}

.crystals-collected:hover, .timer:hover, .typing-stats:hover {
    background: rgba(255, 255, 255, 0.3);
    transform: scale(1.05);
}

/* Main game area */
.game-area {
    height: calc(100% - 50px);
    padding: 15px;
    display: flex;
    flex-direction: column;
    justify-content: center;
    align-items: center;
    position: relative;
    background-image: 
        radial-gradient(circle at 20% 20%, rgba(218, 165, 32, 0.3) 0%, transparent 50%),
        radial-gradient(circle at 80% 80%, rgba(139, 69, 19, 0.2) 0%, transparent 50%);
}

/* Word section styling */
.word-section {
    text-align: center;
    margin-bottom: 20px;
    animation: fadeInUp 0.6s ease-out;
}

.magical-book {
    background: linear-gradient(145deg, #fff8dc, #f5deb3);
    border: 3px solid #8b4513;
    border-radius: 15px;
    padding: 20px;
    box-shadow: 0 8px 25px rgba(0, 0, 0, 0.2);
    position: relative;
    transform: perspective(1000px) rotateX(5deg);
}

.magical-book::before {
    content: "📖";
    position: absolute;
    top: -15px;
    left: 50%;
    transform: translateX(-50%);
    font-size: 24px;
    background: #f5deb3;
    padding: 5px 10px;
    border-radius: 50%;
}

.current-word {
    font-size: 2.5em;
    color: #8b4513;
    text-shadow: 2px 2px 4px rgba(0, 0, 0, 0.3);
    margin-bottom: 10px;
    font-weight: bold;
}

.word-hint {
    color: #654321;
    font-style: italic;
    font-size: 1.1em;
}

/* Definitions section */
.definitions-section {
    width: 100%;
    max-width: 600px;
    margin-bottom: 20px;
}

.definitions-section h3 {
    text-align: center;
    color: #8b4513;
    margin-bottom: 15px;
    font-size: 1.3em;
}

.definitions-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 10px;
}

.definition-btn {
    background: linear-gradient(145deg, #fff8dc, #f0e68c);
    border: 2px solid #daa520;
    border-radius: 10px;
    padding: 12px;
    font-size: 14px;
    font-family: inherit;
    color: #654321;
    cursor: pointer;
    transition: all 0.3s ease;
    text-align: left;
    min-height: 60px;
    display: flex;
    align-items: center;
    justify-content: center;
    word-wrap: break-word;
    hyphens: auto;
}

.definition-btn:hover {
    background: linear-gradient(145deg, #f0e68c, #daa520);
    transform: translateY(-2px);
    box-shadow: 0 6px 20px rgba(0, 0, 0, 0.2);
}

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

.definition-btn.correct {
    background: linear-gradient(145deg, #90ee90, #32cd32);
    border-color: #228b22;
    animation: correctAnswer 0.6s ease-out;
}

.definition-btn.incorrect {
    background: linear-gradient(145deg, #ffb6c1, #ff69b4);
    border-color: #dc143c;
    animation: incorrectAnswer 0.6s ease-out;
}

/* Typing section */
.typing-section {
    width: 100%;
    max-width: 600px;
    text-align: center;
}

.sentence-display {
    background: rgba(255, 255, 255, 0.9);
    border-radius: 10px;
    padding: 15px;
    margin-bottom: 15px;
    border: 2px solid #daa520;
}

.instruction {
    color: #8b4513;
    font-weight: bold;
    margin-bottom: 10px;
}

.target-sentence {
    font-size: 1.2em;
    color: #2c1810;
    font-weight: bold;
    line-height: 1.4;
}

.typing-area {
    position: relative;
    margin-bottom: 15px;
}

#typingInput {
    width: 100%;
    min-height: 80px;
    padding: 12px;
    border: 2px solid #daa520;
    border-radius: 10px;
    font-size: 16px;
    font-family: inherit;
    resize: vertical;
    background: rgba(255, 255, 255, 0.95);
}

#typingInput:focus {
    outline: none;
    border-color: #8b4513;
    box-shadow: 0 0 10px rgba(139, 69, 19, 0.3);
}

.typing-feedback {
    margin-top: 10px;
    font-weight: bold;
    min-height: 20px;
}

.submit-btn, .next-btn, .start-btn, .restart-btn {
    background: linear-gradient(145deg, #daa520, #b8860b);
    border: none;
    border-radius: 25px;
    padding: 12px 24px;
    font-size: 16px;
    font-weight: bold;
    color: white;
    cursor: pointer;
    transition: all 0.3s ease;
    text-shadow: 1px 1px 2px rgba(0, 0, 0, 0.3);
    box-shadow: 0 4px 15px rgba(0, 0, 0, 0.2);
}

.submit-btn:hover, .next-btn:hover, .start-btn:hover, .restart-btn:hover {
    background: linear-gradient(145deg, #b8860b, #daa520);
    transform: translateY(-2px);
    box-shadow: 0 6px 20px rgba(0, 0, 0, 0.3);
}

/* Results section */
.results-section {
    text-align: center;
    width: 100%;
    max-width: 500px;
}

.result-card {
    background: rgba(255, 255, 255, 0.95);
    border-radius: 15px;
    padding: 20px;
    border: 3px solid #daa520;
    box-shadow: 0 8px 25px rgba(0, 0, 0, 0.2);
}

.result-card h3 {
    color: #8b4513;
    margin-bottom: 15px;
    font-size: 1.5em;
}

.accuracy-display {
    margin: 15px 0;
    font-size: 1.2em;
    color: #654321;
}

.accuracy-label {
    font-weight: bold;
}

/* Start screen and game over */
.start-screen, .game-over {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(139, 69, 19, 0.95);
    display: flex;
    justify-content: center;
    align-items: center;
    z-index: 1000;
}

.welcome-card, .final-score {
    background: linear-gradient(145deg, #fff8dc, #f5deb3);
    border-radius: 20px;
    padding: 30px;
    text-align: center;
    max-width: 90%;
    box-shadow: 0 10px 30px rgba(0, 0, 0, 0.3);
    border: 3px solid #daa520;
}

.welcome-card h1 {
    color: #8b4513;
    margin-bottom: 20px;
    font-size: 2em;
    text-shadow: 2px 2px 4px rgba(0, 0, 0, 0.2);
}

.game-instructions {
    margin: 20px 0;
    text-align: left;
}

.game-instructions p {
    margin: 8px 0;
    color: #654321;
    font-size: 1.1em;
}

.final-stats p {
    margin: 10px 0;
    font-size: 1.2em;
    color: #654321;
}

/* Tooltip styling */
.tooltip {
    position: absolute;
    background: rgba(0, 0, 0, 0.9);
    color: white;
    padding: 8px 12px;
    border-radius: 6px;
    font-size: 12px;
    pointer-events: none;
    z-index: 1001;
    opacity: 0;
    transition: opacity 0.3s ease;
    max-width: 200px;
    text-align: center;
}

/* Animations */
@keyframes fadeInUp {
    from {
        opacity: 0;
        transform: translateY(30px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

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

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

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

/* Mobile responsiveness */
@media (max-width: 768px) {
    .game-container {
        border-radius: 0;
    }
    
    .progress-section {
        gap: 10px;
        font-size: 12px;
    }
    
    .current-word {
        font-size: 2em;
    }
    
    .definitions-grid {
        grid-template-columns: 1fr;
        gap: 8px;
    }
    
    .definition-btn {
        min-height: 50px;
        font-size: 13px;
        padding: 10px;
    }
    
    .welcome-card, .final-score {
        padding: 20px;
        margin: 10px;
    }
    
    .welcome-card h1 {
        font-size: 1.5em;
    }
}

/* Touch device optimizations */
@media (hover: none) and (pointer: coarse) {
    .definition-btn, .submit-btn, .next-btn, .start-btn, .restart-btn {
        min-height: 44px; /* iOS recommended touch target size */
    }
    
    .definition-btn:active {
        background: linear-gradient(145deg, #f0e68c, #daa520);
    }
}