:root {
    --csl-primary: #FF6600; /* csl Orange */
    --csl-secondary: #000000;
    --bg-color: #F4F6F8;
    --text-main: #333333;
    --text-light: #777777;
    --card-bg: #FFFFFF;
    --danger: #E74C3C;
    --success: #2ECC71;
    --warning: #F1C40F;
}

* {
    box-sizing: border-box;
    margin: 0;
    padding: 0;
    font-family: 'PingFang HK', 'Helvetica Neue', Helvetica, Arial, sans-serif;
    -webkit-tap-highlight-color: transparent;
}

body {
    background-color: var(--bg-color);
    color: var(--text-main);
    display: flex;
    justify-content: center;
    height: 100vh;
    overflow: hidden;
}

/* Mobile App Container */
#app-container {
    width: 100%;
    max-width: 900px;
    height: 100%;
    background: var(--bg-color);
    position: relative;
    box-shadow: 0 0 20px rgba(0,0,0,0.1);
    display: flex;
    flex-direction: column;
    overflow: hidden;
}

/* Top Header */
.header {
    background: var(--csl-secondary);
    color: white;
    padding: 15px 20px;
    display: flex;
    justify-content: space-between;
    align-items: center;
    z-index: 10;
}

.header-title {
    font-weight: bold;
    font-size: 1.1rem;
    display: flex;
    align-items: center;
    gap: 8px;
}

.header-coins {
    background: rgba(255,255,255,0.2);
    padding: 4px 10px;
    border-radius: 15px;
    font-size: 0.85rem;
    display: flex;
    align-items: center;
    gap: 5px;
}

/* Page Container */
.page {
    display: none;
    flex: 1;
    flex-direction: column;
    overflow-y: auto;
    background: var(--bg-color);
    animation: fadeIn 0.3s ease;
}
.page.active { display: flex; }

/* ======== Page 1: Level Selection ======== */
.level-header {
    padding: 20px;
    text-align: center;
    background: linear-gradient(135deg, var(--csl-primary), #FF8C33);
    color: white;
}

.level-header h2 { font-size: 1.4rem; margin-bottom: 5px; }
.level-header p { font-size: 0.9rem; opacity: 0.9; }

.card-list { padding: 15px; display: flex; flex-direction: column; gap: 15px; }

.product-card {
    background: var(--card-bg);
    border-radius: 12px;
    padding: 15px;
    box-shadow: 0 4px 6px rgba(0,0,0,0.05);
    cursor: pointer;
    transition: transform 0.1s;
    position: relative;
    overflow: hidden;
}
.product-card:active { transform: scale(0.98); }
.product-card.locked { opacity: 0.6; pointer-events: none; }

.card-title { font-weight: bold; font-size: 1.1rem; margin-bottom: 8px; display: flex; align-items: center; justify-content: space-between; }
.progress-bar-bg { background: #EEEEEE; height: 8px; border-radius: 4px; margin-bottom: 10px; overflow: hidden; }
.progress-bar-fill { background: var(--csl-primary); height: 100%; border-radius: 4px; }
.badge { font-size: 0.8rem; background: #FFF0E6; color: var(--csl-primary); padding: 4px 8px; border-radius: 4px; display: inline-block; }

/* ======== Page 2: Difficulty ======== */
.back-btn { padding: 10px 15px; color: var(--csl-primary); font-weight: bold; cursor: pointer; background: white; border-bottom: 1px solid #EEE;}

.diff-card {
    background: var(--card-bg);
    border-radius: 12px;
    padding: 15px;
    margin: 0 15px 15px 15px;
    box-shadow: 0 2px 5px rgba(0,0,0,0.05);
    cursor: pointer;
    border-left: 5px solid #CCC;
}
.diff-card.easy { border-left-color: var(--success); }
.diff-card.normal { border-left-color: var(--warning); }
.diff-card.hard { border-left-color: var(--csl-primary); }
.diff-card.hell { border-left-color: var(--danger); }

.diff-header { display: flex; justify-content: space-between; margin-bottom: 5px; }
.diff-stars { font-size: 0.9rem; }
.diff-name { font-weight: bold; font-size: 1.1rem; }
.diff-desc { font-size: 0.85rem; color: var(--text-light); }

/* ======== Page 3: Game UI ======== */
.game-header {
    background: white;
    padding: 10px 15px;
    display: flex;
    flex-direction: column;
    gap: 10px;
    box-shadow: 0 2px 5px rgba(0,0,0,0.05);
    z-index: 5;
}

.health-bar-container { display: flex; align-items: center; gap: 10px; }
.health-title { font-size: 0.85rem; font-weight: bold; }
.health-bar-bg { flex: 1; height: 12px; background: #EEEEEE; border-radius: 6px; overflow: hidden; }
.health-bar-fill { height: 100%; background: var(--success); transition: width 0.3s ease, background-color 0.3s ease; }
.health-score { font-size: 0.85rem; font-weight: bold; min-width: 35px; text-align: right; }

.scene-area {
    height: 180px;
    background: #E0E0E0;
    position: relative;
    display: flex;
    justify-content: center;
    align-items: flex-end;
    overflow: hidden;
}
/* Fake Shop Background */
.scene-bg {
    position: absolute;
    top: 0; left: 0; width: 100%; height: 100%;
    background: linear-gradient(to bottom, #FFE8D6, #FFF), repeating-linear-gradient(90deg, transparent, transparent 40px, rgba(0,0,0,0.03) 40px, rgba(0,0,0,0.03) 80px);
    z-index: 1;
}
/* Fake Chibi Character */
.chibi-char {
    width: 120px;
    height: 150px;
    background: #CCC;
    border-radius: 60px 60px 10px 10px;
    z-index: 2;
    position: relative;
    box-shadow: inset -10px -10px 20px rgba(0,0,0,0.2);
    transition: all 0.3s;
}
/* Faces */
.chibi-face {
    position: absolute; top: 40px; width: 100%; text-align: center; font-size: 2rem;
}

.system-tip { background: #FFF0E6; color: var(--csl-primary); padding: 8px 15px; font-size: 0.8rem; text-align: center; border-bottom: 1px solid #FFE0CC; }

.chat-area {
    flex: 1;
    padding: 15px;
    overflow-y: auto;
    display: flex;
    flex-direction: column;
    gap: 15px;
    background: #F9F9F9;
}

.bubble { max-width: 80%; padding: 10px 15px; border-radius: 15px; font-size: 0.95rem; line-height: 1.4; position: relative; }
.bubble.ai { background: white; align-self: flex-start; border-bottom-left-radius: 2px; box-shadow: 0 1px 2px rgba(0,0,0,0.1); }
.bubble.user { background: var(--csl-primary); color: white; align-self: flex-end; border-bottom-right-radius: 2px; box-shadow: 0 1px 2px rgba(0,0,0,0.2); }
.bubble-name { font-size: 0.75rem; color: var(--text-light); margin-bottom: 4px; display: block; }
.bubble.user .bubble-name { color: #FFE0CC; text-align: right; }

.input-area {
    background: white;
    padding: 10px 15px;
    display: flex;
    gap: 10px;
    box-shadow: 0 -2px 10px rgba(0,0,0,0.05);
    align-items: center;
}
.skills-bar {
    display: flex; gap: 10px; padding: 5px 15px 10px 15px; background: white;
}
.skill-btn { background: var(--bg-color); border: none; padding: 5px 10px; border-radius: 15px; font-size: 0.75rem; color: var(--text-main); cursor: pointer; display: flex; align-items: center; gap: 4px;}

.chat-input { flex: 1; border: 1px solid #DDD; border-radius: 20px; padding: 10px 15px; font-size: 0.95rem; outline: none; }
.send-btn { background: var(--csl-primary); color: white; border: none; width: 40px; height: 40px; border-radius: 20px; font-size: 1.2rem; display: flex; justify-content: center; align-items: center; cursor: pointer; }

/* ======== Animations ======== */
@keyframes fadeIn { from { opacity: 0; } to { opacity: 1; } }
@keyframes damage { 0% { background-color: var(--danger); } 100% { background-color: white; } }
.damage-flash { animation: damage 0.3s ease; }

/* ======== Alert Modal ======== */
.modal-overlay {
    position: absolute; top: 0; left: 0; width: 100%; height: 100%;
    background: rgba(0,0,0,0.5); z-index: 100;
    display: none; justify-content: center; align-items: center;
    backdrop-filter: blur(2px);
}
.modal-card {
    background: white; width: 80%; border-radius: 16px; padding: 25px 20px;
    text-align: center; box-shadow: 0 10px 25px rgba(0,0,0,0.2);
    transform: scale(0.9); transition: transform 0.2s;
}
.modal-overlay.active { display: flex; }
.modal-overlay.active .modal-card { transform: scale(1); }
.modal-icon { font-size: 2.5rem; margin-bottom: 10px; }
.modal-title { font-weight: bold; font-size: 1.2rem; margin-bottom: 10px; }
.modal-desc { font-size: 0.9rem; color: var(--text-light); margin-bottom: 20px; line-height: 1.5; }
.btn-primary { background: var(--csl-primary); color: white; border: none; padding: 12px; width: 100%; border-radius: 8px; font-size: 1rem; font-weight: bold; margin-bottom: 10px; cursor: pointer; }
.btn-secondary { background: #EEE; color: var(--text-main); border: none; padding: 12px; width: 100%; border-radius: 8px; font-size: 1rem; font-weight: bold; cursor: pointer; }