/* 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, #2d5a27, #4a7c59);
    color: #333;
    overflow: hidden;
}

/* Main container - responsive height */
.main-container {
    width: 100%;
    height: 450px; /* Default iframe height */
    position: relative;
    overflow: hidden;
}

/* Detect if opened in new tab */
@media (min-height: 600px) {
    .main-container {
        height: 90vh;
    }
}

/* Forest background */
.forest-background {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: linear-gradient(to bottom, 
        #87CEEB 0%, 
        #98FB98 30%, 
        #228B22 70%, 
        #006400 100%);
    z-index: 1;
}

.trees {
    position: absolute;
    bottom: 0;
    width: 100%;
    height: 60%;
    background: url('data:image/svg+xml,<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 100 60"><polygon points="10,60 15,30 20,60" fill="%23228B22"/><polygon points="30,60 35,25 40,60" fill="%2332CD32"/><polygon points="60,60 65,35 70,60" fill="%23228B22"/><polygon points="80,60 85,20 90,60" fill="%2332CD32"/></svg>') repeat-x;
    background-size: 200px 100%;
}

.pond {
    position: absolute;
    bottom: 10%;
    left: 20%;
    width: 60%;
    height: 20%;
    background: radial-gradient(ellipse, #4169E1, #1E90FF);
    border-radius: 50%;
    opacity: 0.8;
}

/* Character hub styles */
.character-hub {
    position: absolute;
    top: 10px;
    left: 10px;
    right: 10px;
    bottom: 80px;
    background: rgba(255, 255, 255, 0.95);
    border-radius: 15px;
    padding: 15px;
    box-shadow: 0 8px 32px rgba(0, 0, 0, 0.3);
    backdrop-filter: blur(10px);
    z-index: 10;
}

.character-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(120px, 1fr));
    gap: 10px;
    height: 100%;
    align-content: start;
}

.character-card {
    background: linear-gradient(145deg, #f0f8ff, #e6f3ff);
    border-radius: 12px;
    padding: 12px;
    text-align: center;
    cursor: pointer;
    transition: all 0.3s ease;
    border: 2px solid transparent;
    box-shadow: 0 4px 15px rgba(0, 0, 0, 0.1);
    min-height: 100px;
}

.character-card:hover {
    transform: translateY(-5px);
    box-shadow: 0 8px 25px rgba(0, 0, 0, 0.2);
    border-color: #4CAF50;
}

.character-avatar {
    font-size: 2.5em;
    margin-bottom: 8px;
    animation: bounce 2s infinite;
}

.character-name {
    font-weight: bold;
    font-size: 0.9em;
    color: #2c5530;
    margin-bottom: 4px;
}

.character-desc {
    font-size: 0.75em;
    color: #666;
    line-height: 1.2;
}

/* Dialog panel styles */
.dialog-panel {
    position: absolute;
    top: 10px;
    left: 10px;
    right: 10px;
    bottom: 80px;
    background: rgba(255, 255, 255, 0.95);
    border-radius: 15px;
    padding: 15px;
    box-shadow: 0 8px 32px rgba(0, 0, 0, 0.3);
    backdrop-filter: blur(10px);
    z-index: 10;
}

.current-character {
    display: flex;
    align-items: center;
    margin-bottom: 15px;
    padding: 10px;
    background: linear-gradient(145deg, #e8f5e8, #f0fff0);
    border-radius: 10px;
}

.character-display {
    font-size: 3em;
    margin-right: 15px;
}

.thought-bubble {
    flex: 1;
    background: white;
    padding: 10px;
    border-radius: 20px;
    position: relative;
    box-shadow: 0 2px 10px rgba(0, 0, 0, 0.1);
    font-style: italic;
    color: #555;
}

.thought-bubble::before {
    content: '';
    position: absolute;
    left: -10px;
    top: 50%;
    transform: translateY(-50%);
    border: 10px solid transparent;
    border-right-color: white;
}

.dialog-content {
    flex: 1;
}

.dialog-text {
    background: #f8f9fa;
    padding: 15px;
    border-radius: 10px;
    margin-bottom: 15px;
    line-height: 1.6;
    border-left: 4px solid #4CAF50;
}

.dialog-options {
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.dialog-option {
    background: linear-gradient(145deg, #ffffff, #f0f0f0);
    border: 2px solid #ddd;
    padding: 12px 15px;
    border-radius: 8px;
    cursor: pointer;
    transition: all 0.3s ease;
    text-align: left;
    font-size: 0.9em;
    line-height: 1.4;
}

.dialog-option:hover {
    background: linear-gradient(145deg, #e8f5e8, #f0fff0);
    border-color: #4CAF50;
    transform: translateX(5px);
}

/* Relationship panel styles */
.relationship-panel {
    position: absolute;
    top: 10px;
    left: 10px;
    right: 10px;
    bottom: 80px;
    background: rgba(255, 255, 255, 0.95);
    border-radius: 15px;
    padding: 15px;
    box-shadow: 0 8px 32px rgba(0, 0, 0, 0.3);
    backdrop-filter: blur(10px);
    z-index: 10;
}

.relationship-canvas {
    height: calc(100% - 60px);
    background: #f8f9fa;
    border: 2px dashed #ccc;
    border-radius: 10px;
    position: relative;
    overflow: hidden;
}

.canvas-instructions {
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    color: #888;
    font-style: italic;
}

.relationship-tools {
    display: flex;
    gap: 10px;
    margin-top: 10px;
}

/* Notebook panel styles */
.notebook-panel {
    position: absolute;
    top: 10px;
    left: 10px;
    right: 10px;
    bottom: 80px;
    background: rgba(255, 255, 255, 0.95);
    border-radius: 15px;
    padding: 15px;
    box-shadow: 0 8px 32px rgba(0, 0, 0, 0.3);
    backdrop-filter: blur(10px);
    z-index: 10;
    overflow-y: auto;
}

.notebook-section {
    margin-bottom: 20px;
}

.notebook-section h3 {
    color: #2c5530;
    margin-bottom: 10px;
    font-size: 1.1em;
}

.advice-list {
    background: #f8f9fa;
    border-radius: 8px;
    padding: 10px;
    min-height: 100px;
}

.advice-item {
    background: white;
    padding: 8px;
    margin-bottom: 8px;
    border-radius: 6px;
    border-left: 3px solid #4CAF50;
    font-size: 0.9em;
}

#personalReflection {
    width: 100%;
    height: 100px;
    padding: 10px;
    border: 2px solid #ddd;
    border-radius: 8px;
    resize: vertical;
    font-family: inherit;
}

/* Decision panel styles */
.decision-panel {
    position: absolute;
    top: 10px;
    left: 10px;
    right: 10px;
    bottom: 80px;
    background: rgba(255, 255, 255, 0.95);
    border-radius: 15px;
    padding: 15px;
    box-shadow: 0 8px 32px rgba(0, 0, 0, 0.3);
    backdrop-filter: blur(10px);
    z-index: 10;
}

.decision-question {
    font-size: 1.1em;
    font-weight: bold;
    color: #2c5530;
    margin-bottom: 15px;
    text-align: center;
}

.decision-options {
    display: flex;
    flex-direction: column;
    gap: 10px;
    margin-bottom: 20px;
}

.decision-option {
    background: linear-gradient(145deg, #ffffff, #f0f0f0);
    border: 2px solid #ddd;
    padding: 15px;
    border-radius: 10px;
    cursor: pointer;
    transition: all 0.3s ease;
    text-align: center;
}

.decision-option:hover {
    background: linear-gradient(145deg, #e8f5e8, #f0fff0);
    border-color: #4CAF50;
    transform: scale(1.02);
}

.decision-result {
    background: #e8f5e8;
    padding: 15px;
    border-radius: 10px;
    border-left: 4px solid #4CAF50;
    display: none;
}

/* Navigation panel */
.navigation-panel {
    position: absolute;
    bottom: 10px;
    left: 50%;
    transform: translateX(-50%);
    display: flex;
    gap: 5px;
    background: rgba(255, 255, 255, 0.9);
    padding: 8px;
    border-radius: 25px;
    box-shadow: 0 4px 20px rgba(0, 0, 0, 0.2);
    z-index: 20;
}

.nav-btn {
    background: transparent;
    border: none;
    padding: 8px 12px;
    border-radius: 20px;
    cursor: pointer;
    transition: all 0.3s ease;
    font-size: 1.2em;
    min-width: 44px;
    min-height: 44px;
}

.nav-btn:hover {
    background: rgba(76, 175, 80, 0.2);
    transform: scale(1.1);
}

.nav-btn.active {
    background: #4CAF50;
    color: white;
}

/* Progress tracker */
.progress-tracker {
    position: absolute;
    top: 10px;
    right: 10px;
    width: 150px;
    z-index: 15;
}

.progress-bar {
    height: 6px;
    background: rgba(255, 255, 255, 0.3);
    border-radius: 3px;
    overflow: hidden;
    margin-bottom: 5px;
}

.progress-fill {
    height: 100%;
    background: #4CAF50;
    width: 0%;
    transition: width 0.5s ease;
}

.progress-text {
    font-size: 0.8em;
    color: white;
    text-align: center;
    text-shadow: 1px 1px 2px rgba(0, 0, 0, 0.5);
}

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

/* Utility classes */
.tool-btn {
    background: #4CAF50;
    color: white;
    border: none;
    padding: 8px 15px;
    border-radius: 6px;
    cursor: pointer;
    font-size: 0.9em;
    transition: all 0.3s ease;
}

.tool-btn:hover {
    background: #45a049;
    transform: translateY(-2px);
}

/* Animations */
@keyframes bounce {
    0%, 20%, 50%, 80%, 100% {
        transform: translateY(0);
    }
    40% {
        transform: translateY(-10px);
    }
    60% {
        transform: translateY(-5px);
    }
}

/* Mobile optimizations */
@media (max-width: 768px) {
    .character-grid {
        grid-template-columns: repeat(2, 1fr);
        gap: 8px;
    }
    
    .character-card {
        padding: 8px;
        min-height: 80px;
    }
    
    .character-avatar {
        font-size: 2em;
    }
    
    .character-name {
        font-size: 0.8em;
    }
    
    .character-desc {
        font-size: 0.7em;
    }
    
    .nav-btn {
        padding: 6px 10px;
        min-width: 40px;
        min-height: 40px;
    }
    
    .dialog-option {
        padding: 10px 12px;
        font-size: 0.85em;
    }
}

/* Touch-friendly interactions */
@media (pointer: coarse) {
    .character-card,
    .dialog-option,
    .decision-option,
    .nav-btn,
    .tool-btn {
        min-height: 44px;
    }
}