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

body {
    font-family: 'Microsoft YaHei', 'SimHei', sans-serif;
    background: linear-gradient(135deg, #e3f2fd 0%, #bbdefb 100%);
    overflow-x: hidden;
    /* Responsive height - 450px in iframe, 90vh in new tab */
    height: 450px;
    min-height: 450px;
}

@media (min-height: 500px) {
    body {
        height: 90vh;
        min-height: 90vh;
    }
}

/* Main container with responsive layout */
.container {
    width: 100%;
    height: 100%;
    display: flex;
    flex-direction: column;
    position: relative;
}

/* Story visualization panel */
.story-panel {
    flex: 1;
    background: linear-gradient(to bottom, #87ceeb 0%, #f0f8ff 50%, #ffd700 100%);
    position: relative;
    overflow: hidden;
    border-radius: 8px 8px 0 0;
    box-shadow: inset 0 2px 8px rgba(0,0,0,0.1);
}

.scene-container {
    width: 100%;
    height: 100%;
    position: relative;
}

.beach-scene {
    width: 100%;
    height: 100%;
    position: relative;
    background: linear-gradient(to bottom, transparent 60%, #c2b280 60%);
}

/* Whale animation */
.whale {
    position: absolute;
    font-size: 3rem;
    bottom: 20%;
    left: 50%;
    transform: translateX(-50%);
    animation: whaleStruggle 3s ease-in-out infinite;
    cursor: pointer;
    transition: all 0.3s ease;
}

.whale:hover {
    transform: translateX(-50%) scale(1.1);
}

@keyframes whaleStruggle {
    0%, 100% { transform: translateX(-50%) rotate(-2deg); }
    50% { transform: translateX(-50%) rotate(2deg); }
}

/* Characters */
.characters {
    position: absolute;
    bottom: 25%;
    left: 20%;
    display: flex;
    gap: 20px;
}

.character {
    font-size: 2rem;
    cursor: pointer;
    transition: all 0.3s ease;
    animation: characterRun 2s ease-in-out infinite;
}

.character:hover {
    transform: scale(1.2);
}

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

/* Villagers */
.villagers {
    position: absolute;
    bottom: 25%;
    right: 20%;
    display: flex;
    gap: 15px;
    flex-wrap: wrap;
}

.villager {
    font-size: 1.5rem;
    animation: villagerHelp 2.5s ease-in-out infinite;
}

@keyframes villagerHelp {
    0%, 100% { transform: translateY(0) rotate(0deg); }
    50% { transform: translateY(-3px) rotate(5deg); }
}

/* Water buckets animation */
.water-buckets {
    position: absolute;
    width: 100%;
    height: 100%;
    pointer-events: none;
}

.water-bucket {
    position: absolute;
    font-size: 1.2rem;
    animation: bucketPour 1s ease-out forwards;
}

@keyframes bucketPour {
    0% { opacity: 1; transform: translateY(0); }
    100% { opacity: 0; transform: translateY(50px); }
}

/* Waves animation */
.waves {
    position: absolute;
    bottom: 0;
    width: 100%;
    height: 30px;
    background: repeating-linear-gradient(
        90deg,
        #4fc3f7 0px,
        #29b6f6 10px,
        #03a9f4 20px
    );
    opacity: 0;
    animation: waveRise 5s ease-in-out;
}

@keyframes waveRise {
    0% { opacity: 0; height: 0; }
    70% { opacity: 0.7; height: 60px; }
    100% { opacity: 1; height: 30px; }
}

/* Progress bar */
.progress-bar {
    position: absolute;
    bottom: 0;
    left: 0;
    width: 100%;
    height: 4px;
    background: rgba(255,255,255,0.3);
}

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

/* Discussion panel */
.discussion-panel {
    flex: 1;
    background: white;
    padding: 15px;
    border-radius: 0 0 8px 8px;
    box-shadow: 0 -2px 8px rgba(0,0,0,0.1);
    overflow-y: auto;
}

/* Activity tabs - NEW ADDITION */
.activity-tabs {
    display: flex;
    gap: 5px;
    margin-bottom: 15px;
    border-bottom: 2px solid #e0e0e0;
    padding-bottom: 10px;
}

.tab-btn {
    background: linear-gradient(135deg, #f5f5f5 0%, #e0e0e0 100%);
    border: 1px solid #bdbdbd;
    border-radius: 6px 6px 0 0;
    padding: 8px 12px;
    font-size: 0.8rem;
    cursor: pointer;
    transition: all 0.3s ease;
    white-space: nowrap;
    flex: 1;
}

.tab-btn:hover {
    background: linear-gradient(135deg, #e0e0e0 0%, #bdbdbd 100%);
}

.tab-btn.active {
    background: linear-gradient(135deg, #2196f3 0%, #1976d2 100%);
    color: white;
    border-color: #1976d2;
    border-bottom: 2px solid #2196f3;
}

/* Activity content containers - NEW ADDITION */
.activity-content {
    display: none;
}

.activity-content.active {
    display: block;
}

.activity-header {
    font-weight: bold;
    font-size: 1rem;
    color: #1976d2;
    margin-bottom: 10px;
    text-align: center;
    padding: 8px;
    background: linear-gradient(135deg, #e3f2fd 0%, #bbdefb 100%);
    border-radius: 6px;
}

/* Action cards */
.action-cards {
    display: flex;
    gap: 10px;
    margin-bottom: 15px;
    flex-wrap: wrap;
}

.action-card {
    flex: 1;
    min-width: 120px;
    background: linear-gradient(135deg, #fff3e0 0%, #ffe0b2 100%);
    border: 2px solid #ffb74d;
    border-radius: 8px;
    padding: 10px;
    cursor: pointer;
    transition: all 0.3s ease;
    box-shadow: 0 2px 4px rgba(0,0,0,0.1);
}

.action-card:hover {
    transform: translateY(-2px);
    box-shadow: 0 4px 12px rgba(255,183,77,0.3);
    border-color: #ff9800;
}

.action-card.active {
    background: linear-gradient(135deg, #e8f5e8 0%, #c8e6c9 100%);
    border-color: #4caf50;
    box-shadow: 0 4px 12px rgba(76,175,80,0.3);
}

.card-header {
    font-weight: bold;
    font-size: 0.9rem;
    color: #d84315;
    margin-bottom: 5px;
}

.card-content {
    font-size: 0.8rem;
    color: #5d4037;
    line-height: 1.3;
}

/* Opinion section */
.opinion-section {
    margin-bottom: 15px;
}

.opinion-prompt {
    font-size: 0.9rem;
    color: #666;
    margin-bottom: 10px;
    text-align: center;
    padding: 8px;
    background: #f5f5f5;
    border-radius: 6px;
}

.sentence-templates {
    display: flex;
    gap: 8px;
    margin-bottom: 10px;
    flex-wrap: wrap;
}

.template-btn {
    background: linear-gradient(135deg, #e1f5fe 0%, #b3e5fc 100%);
    border: 1px solid #29b6f6;
    border-radius: 20px;
    padding: 6px 12px;
    font-size: 0.8rem;
    cursor: pointer;
    transition: all 0.3s ease;
    white-space: nowrap;
}

.template-btn:hover {
    background: linear-gradient(135deg, #b3e5fc 0%, #81d4fa 100%);
    transform: translateY(-1px);
}

.input-area {
    display: flex;
    gap: 10px;
    align-items: flex-end;
}

textarea[id^="opinionInput"] {
    flex: 1;
    min-height: 60px;
    padding: 8px;
    border: 2px solid #e0e0e0;
    border-radius: 6px;
    font-size: 0.9rem;
    font-family: inherit;
    resize: vertical;
    transition: border-color 0.3s ease;
}

textarea[id^="opinionInput"]:focus {
    outline: none;
    border-color: #2196f3;
    box-shadow: 0 0 8px rgba(33,150,243,0.2);
}

.submit-btn {
    background: linear-gradient(135deg, #4caf50 0%, #66bb6a 100%);
    color: white;
    border: none;
    border-radius: 6px;
    padding: 10px 16px;
    font-size: 0.9rem;
    cursor: pointer;
    transition: all 0.3s ease;
    white-space: nowrap;
    height: fit-content;
}

.submit-btn:hover {
    background: linear-gradient(135deg, #66bb6a 0%, #4caf50 100%);
    transform: translateY(-1px);
    box-shadow: 0 4px 12px rgba(76,175,80,0.3);
}

/* Discussion display */
.discussion-display {
    background: #fafafa;
    border-radius: 6px;
    padding: 10px;
    max-height: 120px;
    overflow-y: auto;
}

.discussion-header {
    font-weight: bold;
    font-size: 0.9rem;
    color: #333;
    margin-bottom: 8px;
    border-bottom: 1px solid #e0e0e0;
    padding-bottom: 4px;
}

.discussion-item {
    background: white;
    border-left: 3px solid #2196f3;
    margin-bottom: 8px;
    padding: 8px;
    border-radius: 4px;
    box-shadow: 0 1px 3px rgba(0,0,0,0.1);
}

.discussion-character {
    font-weight: bold;
    color: #1976d2;
    font-size: 0.8rem;
}

.discussion-opinion {
    color: #333;
    font-size: 0.8rem;
    margin-top: 4px;
    line-height: 1.4;
}

/* Animal care examples */
.care-examples {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: white;
    padding: 20px;
    border-radius: 8px;
    z-index: 10;
}

.examples-header {
    font-size: 1.1rem;
    font-weight: bold;
    color: #2e7d32;
    margin-bottom: 15px;
    text-align: center;
}

.examples-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(140px, 1fr));
    gap: 12px;
}

.example-item {
    background: linear-gradient(135deg, #e8f5e8 0%, #c8e6c9 100%);
    border: 2px solid #4caf50;
    border-radius: 8px;
    padding: 12px;
    text-align: center;
    font-size: 0.9rem;
    transition: all 0.3s ease;
    cursor: pointer;
}

.example-item:hover {
    transform: translateY(-2px);
    box-shadow: 0 4px 12px rgba(76,175,80,0.3);
}

/* Controls */
.controls {
    display: flex;
    gap: 8px;
    padding: 10px;
    background: rgba(255,255,255,0.9);
    justify-content: center;
}

.control-btn {
    background: linear-gradient(135deg, #f5f5f5 0%, #e0e0e0 100%);
    border: 1px solid #bdbdbd;
    border-radius: 20px;
    padding: 8px 16px;
    font-size: 0.8rem;
    cursor: pointer;
    transition: all 0.3s ease;
    white-space: nowrap;
}

.control-btn:hover {
    background: linear-gradient(135deg, #e0e0e0 0%, #bdbdbd 100%);
    transform: translateY(-1px);
}

.control-btn.active {
    background: linear-gradient(135deg, #2196f3 0%, #1976d2 100%);
    color: white;
    border-color: #1976d2;
}

/* Tooltip */
.tooltip {
    position: absolute;
    background: rgba(0,0,0,0.8);
    color: white;
    padding: 8px 12px;
    border-radius: 6px;
    font-size: 0.8rem;
    pointer-events: none;
    z-index: 1000;
    opacity: 0;
    transition: opacity 0.3s ease;
    max-width: 200px;
    line-height: 1.3;
}

.tooltip.show {
    opacity: 1;
}

/* Mobile responsiveness */
@media (max-width: 768px) {
    .activity-tabs {
        flex-direction: column;
        gap: 5px;
    }
    
    .tab-btn {
        border-radius: 6px;
        text-align: center;
    }
    
    .action-cards {
        flex-direction: column;
    }
    
    .action-card {
        min-width: auto;
    }
    
    .sentence-templates {
        justify-content: center;
    }
    
    .template-btn {
        font-size: 0.7rem;
        padding: 5px 10px;
    }
    
    .input-area {
        flex-direction: column;
        gap: 8px;
    }
    
    .examples-grid {
        grid-template-columns: repeat(auto-fit, minmax(120px, 1fr));
        gap: 8px;
    }
    
    .controls {
        flex-wrap: wrap;
        gap: 6px;
    }
    
    .control-btn {
        font-size: 0.7rem;
        padding: 6px 12px;
    }
}

/* Touch-friendly sizing for mobile */
@media (pointer: coarse) {
    .action-card, .template-btn, .control-btn, .submit-btn, .tab-btn {
        min-height: 44px;
        display: flex;
        align-items: center;
        justify-content: center;
    }
    
    .example-item {
        min-height: 60px;
        display: flex;
        align-items: center;
        justify-content: center;
    }
}