/* ============================
   Global Styles & Variables
   ============================ */
:root {
    /* Color Palette */
    --sky-blue: #87CEEB;
    --light-green: #90EE90;
    --gold: #FFD700;
    --pink: #FFB6C1;
    --white: #FFFFFF;
    --light-gray: #F5F5F5;
    --dark-gray: #333333;
    
    /* Spacing */
    --spacing-xs: 4px;
    --spacing-sm: 8px;
    --spacing-md: 16px;
    --spacing-lg: 24px;
    --spacing-xl: 32px;
    
    /* Border Radius */
    --radius-sm: 8px;
    --radius-md: 12px;
    --radius-lg: 20px;
    
    /* Shadows */
    --shadow-sm: 0 2px 4px rgba(0,0,0,0.1);
    --shadow-md: 0 4px 8px rgba(0,0,0,0.15);
    --shadow-lg: 0 8px 16px rgba(0,0,0,0.2);
    
    /* Transitions */
    --transition-fast: 0.2s ease;
    --transition-normal: 0.3s ease;
}

* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

body {
    font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;
    background: linear-gradient(to bottom, var(--sky-blue), #B0E0E6);
    min-height: 100vh;
    overflow-x: hidden;
    /* Better font rendering on iPad */
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
}

/* Optimize for iPad touch interactions */
@media (min-width: 768px) {
    * {
        -webkit-tap-highlight-color: transparent;
    }
}

.container {
    max-width: 1200px;
    margin: 0 auto;
    padding: 0 var(--spacing-md);
}

/* ============================
   Top Bar
   ============================ */
.top-bar {
    background: linear-gradient(135deg, var(--sky-blue), #6BB6D6);
    color: var(--white);
    padding: var(--spacing-md) 0;
    box-shadow: var(--shadow-md);
    position: sticky;
    top: 0;
    z-index: 100;
}

.top-bar .container {
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: var(--spacing-lg);
}

.title {
    font-size: 1.8rem;
    font-weight: bold;
    text-shadow: 2px 2px 4px rgba(0,0,0,0.2);
}

.stats-container {
    display: flex;
    align-items: center;
    gap: var(--spacing-lg);
}

/* Level Info */
.level-info {
    display: flex;
    align-items: center;
    gap: var(--spacing-sm);
}

.level-text {
    font-weight: bold;
    font-size: 1.1rem;
    white-space: nowrap;
}

.exp-bar {
    position: relative;
    width: 150px;
    height: 20px;
    background: rgba(255,255,255,0.3);
    border-radius: 10px;
    overflow: hidden;
}

.exp-fill {
    position: absolute;
    left: 0;
    top: 0;
    height: 100%;
    background: linear-gradient(90deg, var(--gold), #FFA500);
    transition: width var(--transition-normal);
}

.exp-text {
    position: absolute;
    width: 100%;
    text-align: center;
    line-height: 20px;
    font-size: 0.8rem;
    font-weight: bold;
    color: var(--white);
    text-shadow: 1px 1px 2px rgba(0,0,0,0.5);
}

/* Coin Info */
.coin-info {
    display: flex;
    align-items: center;
    gap: var(--spacing-xs);
    background: rgba(255,255,255,0.3);
    padding: var(--spacing-xs) var(--spacing-md);
    border-radius: var(--radius-lg);
    font-size: 1.2rem;
    font-weight: bold;
}

.coin-icon {
    font-size: 1.5rem;
}

/* ============================
   Main Content
   ============================ */
.main-content {
    display: grid;
    grid-template-columns: 1fr;
    gap: var(--spacing-lg);
    padding: var(--spacing-lg);
    max-width: 1400px;
    margin: 0 auto;
}

/* iPad and larger screens: Side by side layout */
@media (min-width: 768px) {
    .main-content {
        grid-template-columns: 1.5fr 1fr;
        gap: var(--spacing-xl);
        padding: var(--spacing-xl);
    }
}

/* ============================
   World View
   ============================ */
.world-view {
    position: relative;
    background-image: url('../assets/images/backgrounds/bg.png');
    background-size: cover;
    background-position: center bottom;
    background-repeat: no-repeat;
    border-radius: var(--radius-lg);
    min-height: 500px;
    overflow: hidden;
    box-shadow: var(--shadow-lg);
}

/* iPad: Taller world view */
@media (min-width: 768px) {
    .world-view {
        min-height: 600px;
    }
}

/* Large iPad Pro */
@media (min-width: 1024px) {
    .world-view {
        min-height: 700px;
    }
}

.sky-background {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    z-index: 0;
    pointer-events: none;
}

/* World Tree */
.world-tree-container {
    position: absolute;
    bottom: 100px;
    left: 50%;
    transform: translateX(-50%);
    z-index: 10;
}

.world-tree {
    position: relative;
    display: flex;
    flex-direction: column;
    align-items: center;
    transition: all 1s ease;
}

/* iPad: Larger tree */
@media (min-width: 768px) {
    .world-tree-container {
        bottom: 120px;
    }
    
    .world-tree > div {
        transform: scale(1.3);
    }
}

/* Grass Field - Hidden since bg.png has grass */
.grass-field {
    position: absolute;
    bottom: 0;
    left: 0;
    width: 100%;
    height: 80px;
    z-index: 5;
    pointer-events: none;
}

/* NPC Container */
.npc-container {
    position: absolute;
    bottom: 80px;
    left: 0;
    width: 100%;
    height: calc(100% - 80px);
    z-index: 15;
    pointer-events: none;
}

.npc {
    position: absolute;
    width: 100px;
    height: 100px;
    font-size: 3rem;
    cursor: pointer;
    pointer-events: all;
    transition: transform var(--transition-fast);
    animation: npc-idle 3s ease-in-out infinite;
    display: flex;
    align-items: center;
    justify-content: center;
}

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

.npc-image {
    max-width: 100%;
    max-height: 100%;
    object-fit: contain;
    image-rendering: crisp-edges;
}

/* iPad: Larger NPCs */
@media (min-width: 768px) {
    .npc {
        width: 120px;
        height: 120px;
        font-size: 3.5rem;
    }
}

@media (min-width: 1024px) {
    .npc {
        width: 140px;
        height: 140px;
        font-size: 4rem;
    }
}

.npc-speech-bubble {
    position: absolute;
    bottom: 100%;
    left: 50%;
    transform: translateX(-50%);
    background: var(--white);
    color: var(--dark-gray);
    padding: var(--spacing-sm) var(--spacing-md);
    border-radius: var(--radius-md);
    white-space: nowrap;
    box-shadow: var(--shadow-sm);
    margin-bottom: var(--spacing-sm);
    opacity: 0;
    pointer-events: none;
    transition: opacity var(--transition-fast);
}

.npc.speaking .npc-speech-bubble {
    opacity: 1;
}

@keyframes npc-idle {
    0%, 100% { transform: translateY(0); }
    50% { transform: translateY(-10px); }
}

/* ============================
   Task Panel
   ============================ */
.task-panel {
    background: var(--white);
    border-radius: var(--radius-lg);
    padding: var(--spacing-lg);
    box-shadow: var(--shadow-md);
}

.panel-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: var(--spacing-lg);
}

.panel-header h2 {
    color: var(--dark-gray);
    font-size: 1.5rem;
}

.streak-info {
    display: flex;
    align-items: center;
    gap: var(--spacing-xs);
    background: linear-gradient(135deg, #FF6B6B, #FF8E53);
    color: var(--white);
    padding: var(--spacing-xs) var(--spacing-md);
    border-radius: var(--radius-lg);
    font-weight: bold;
}

.streak-icon {
    font-size: 1.2rem;
}

/* Task List */
.task-list {
    display: flex;
    flex-direction: column;
    gap: var(--spacing-md);
    margin-bottom: var(--spacing-lg);
}

.task-item {
    display: flex;
    align-items: center;
    gap: var(--spacing-md);
    padding: var(--spacing-md);
    background: var(--light-gray);
    border-radius: var(--radius-md);
    transition: all var(--transition-normal);
    border: 2px solid transparent;
}

.task-item:hover {
    border-color: var(--sky-blue);
    transform: translateX(4px);
}

.task-item.completed {
    opacity: 0.6;
    background: #E8F5E9;
}

.task-checkbox {
    width: 40px;
    height: 40px;
    min-width: 40px;
    cursor: pointer;
    accent-color: var(--light-green);
}

/* iPad: Larger touch targets */
@media (min-width: 768px) {
    .task-checkbox {
        width: 50px;
        height: 50px;
        min-width: 50px;
    }
}

.task-info {
    flex: 1;
}

.task-name {
    font-size: 1.1rem;
    font-weight: 600;
    color: var(--dark-gray);
    margin-bottom: var(--spacing-xs);
}

/* iPad: Larger text */
@media (min-width: 768px) {
    .task-name {
        font-size: 1.3rem;
    }
    
    .task-category {
        font-size: 1rem;
    }
}

.task-category {
    font-size: 0.9rem;
    color: #666;
}

.task-rewards {
    display: flex;
    gap: var(--spacing-md);
    align-items: center;
}

.reward-badge {
    display: flex;
    align-items: center;
    gap: var(--spacing-xs);
    padding: var(--spacing-xs) var(--spacing-sm);
    border-radius: var(--radius-sm);
    font-weight: bold;
    font-size: 0.9rem;
}

.reward-exp {
    background: #FFF9C4;
    color: #F57F17;
}

.reward-coin {
    background: #FFE082;
    color: #E65100;
}


/* ============================
   Modals
   ============================ */
.modal {
    display: none;
    position: fixed;
    z-index: 1000;
    left: 0;
    top: 0;
    width: 100%;
    height: 100%;
    background: rgba(0,0,0,0.5);
    backdrop-filter: blur(5px);
}

.modal.show {
    display: flex;
    justify-content: center;
    align-items: center;
}

.modal-content {
    background: var(--white);
    padding: var(--spacing-xl);
    border-radius: var(--radius-lg);
    box-shadow: var(--shadow-lg);
    max-width: 600px;
    max-height: 80vh;
    overflow-y: auto;
    position: relative;
}

/* iPad: Larger modals */
@media (min-width: 768px) {
    .modal-content {
        max-width: 700px;
        padding: 40px;
    }
}

@media (min-width: 1024px) {
    .modal-content {
        max-width: 800px;
        padding: 50px;
    }
}

.close-btn {
    position: absolute;
    top: var(--spacing-md);
    right: var(--spacing-md);
    font-size: 2rem;
    cursor: pointer;
    color: #999;
    transition: color var(--transition-fast);
}

.close-btn:hover {
    color: var(--dark-gray);
}

/* iPad: Larger close button for easier touch */
@media (min-width: 768px) {
    .close-btn {
        font-size: 2.5rem;
        top: 20px;
        right: 20px;
        padding: 10px;
    }
}

/* Celebration Modal */
.celebration-modal .celebration-content {
    text-align: center;
    animation: celebration-bounce 0.6s ease;
}

.celebration-modal h2 {
    font-size: 2.5rem;
    margin-bottom: var(--spacing-lg);
    color: var(--gold);
}

.level-up-text {
    font-size: 1.5rem;
    margin-bottom: var(--spacing-md);
}

.reward-text {
    font-size: 1.2rem;
    color: #666;
    margin-bottom: var(--spacing-lg);
}

/* iPad: Larger celebration text */
@media (min-width: 768px) {
    .celebration-modal h2 {
        font-size: 3rem;
    }
    
    .level-up-text {
        font-size: 1.8rem;
    }
    
    .reward-text {
        font-size: 1.4rem;
    }
}

.celebration-btn {
    padding: var(--spacing-md) var(--spacing-xl);
    background: linear-gradient(135deg, var(--gold), #FFA500);
    color: var(--white);
    border: none;
    border-radius: var(--radius-lg);
    font-size: 1.2rem;
    font-weight: bold;
    cursor: pointer;
    transition: all var(--transition-normal);
}

.celebration-btn:hover {
    transform: scale(1.05);
}

/* iPad: Larger celebration button */
@media (min-width: 768px) {
    .celebration-btn {
        padding: 18px 40px;
        font-size: 1.5rem;
    }
}

@keyframes celebration-bounce {
    0%, 100% { transform: scale(1); }
    50% { transform: scale(1.1); }
}

/* ============================
   Floating Buttons
   ============================ */
.floating-buttons {
    position: fixed;
    bottom: var(--spacing-lg);
    right: var(--spacing-lg);
    display: flex;
    flex-direction: column;
    gap: var(--spacing-md);
    z-index: 900;
}

.floating-btn {
    width: 60px;
    height: 60px;
    border-radius: 50%;
    border: none;
    background: linear-gradient(135deg, var(--sky-blue), var(--light-green));
    color: var(--white);
    font-size: 1.8rem;
    cursor: pointer;
    box-shadow: var(--shadow-md);
    transition: all var(--transition-normal);
}

.floating-btn:hover {
    transform: scale(1.1) rotate(10deg);
    box-shadow: var(--shadow-lg);
}

/* ============================
   Responsive Design
   ============================ */

/* iPad Portrait and Landscape */
@media (min-width: 768px) and (max-width: 1024px) {
    .title {
        font-size: 2rem;
    }
    
    .exp-bar {
        width: 200px;
        height: 24px;
    }
    
    .exp-text {
        line-height: 24px;
        font-size: 0.9rem;
    }
    
    .coin-info {
        font-size: 1.4rem;
        padding: var(--spacing-sm) var(--spacing-lg);
    }
    
    .panel-header h2 {
        font-size: 1.8rem;
    }
    
    .floating-btn {
        width: 70px;
        height: 70px;
        font-size: 2rem;
    }
}

/* Large iPad Pro */
@media (min-width: 1024px) {
    .title {
        font-size: 2.2rem;
    }
    
    .exp-bar {
        width: 250px;
        height: 28px;
    }
    
    .exp-text {
        line-height: 28px;
        font-size: 1rem;
    }
    
    .coin-info {
        font-size: 1.6rem;
    }
    
    .panel-header h2 {
        font-size: 2rem;
    }
    
    .task-item {
        padding: var(--spacing-lg);
    }
    
    .floating-btn {
        width: 80px;
        height: 80px;
        font-size: 2.2rem;
    }
}

/* Mobile phones */
@media (max-width: 767px) {
    .title {
        font-size: 1.3rem;
    }
    
    .top-bar .container {
        flex-direction: column;
        gap: var(--spacing-md);
    }
    
    .stats-container {
        width: 100%;
        justify-content: space-between;
    }
    
    .exp-bar {
        width: 120px;
    }
    
    .world-view {
        min-height: 350px;
    }
    
    .npc {
        font-size: 2.5rem;
    }
    
    .floating-btn {
        width: 50px;
        height: 50px;
        font-size: 1.5rem;
    }
    
    .task-checkbox {
        width: 35px;
        height: 35px;
        min-width: 35px;
    }
}

/* ============================
   Utility Classes
   ============================ */
.hidden {
    display: none !important;
}

.fade-in {
    animation: fadeIn 0.5s ease;
}

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

.shake {
    animation: shake 0.5s ease;
}

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

.pulse {
    animation: pulse 1s ease infinite;
}

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

