* { margin: 0; padding: 0; box-sizing: border-box; }

:root {
    --primary: #f0ad1b;
    --primary-dark: #c17000;
    --bg-dark: #0f0f1a;
    --bg-card: #1a1a2e;
    --bg-card-border: #2a2a4e;
    --text: #ffffff;
    --text-dim: #8888aa;
    --green: #44ff88;
    --red: #ff4444;
    --blue: #4488ff;
    --purple: #8844ff;
}

body {
    font-family: 'Inter', sans-serif;
    background: var(--bg-dark);
    color: var(--text);
    min-height: 100vh;
    overflow: hidden;
    -webkit-tap-highlight-color: transparent;
}

/* Screens */
.screen { display: none; height: 100vh; flex-direction: column; }
.screen.active { display: flex; }

/* Loading */
#loading-screen, #error-screen {
    justify-content: center;
    align-items: center;
    text-align: center;
}
.loading-content { padding: 2rem; }
.logo-float { font-size: 4rem; animation: float 3s ease-in-out infinite; }
.game-title { font-family: 'Cinzel', serif; color: var(--primary); font-size: 1.5rem; margin: 1rem 0; }
.loading-dots { display: flex; gap: 6px; justify-content: center; margin: 1rem 0; }
.loading-dots span { width: 8px; height: 8px; background: var(--primary); border-radius: 50%; animation: pulse 1s infinite; }
.loading-dots span:nth-child(2) { animation-delay: 0.2s; }
.loading-dots span:nth-child(3) { animation-delay: 0.4s; }
.loading-text, .error-text { color: var(--text-dim); font-size: 0.9rem; }

/* Buttons */
.btn-primary {
    background: linear-gradient(135deg, var(--primary), var(--primary-dark));
    color: var(--bg-dark);
    font-weight: 700;
    padding: 12px 24px;
    border: none;
    border-radius: 12px;
    font-size: 1rem;
    cursor: pointer;
    transition: transform 0.2s, box-shadow 0.2s;
}
.btn-primary:active { transform: scale(0.95); }
.btn-secondary {
    background: var(--bg-card);
    border: 1px solid var(--primary);
    color: var(--primary);
    padding: 8px 16px;
    border-radius: 8px;
    font-size: 0.85rem;
    cursor: pointer;
}

/* Top Bar */
.top-bar {
    display: flex; justify-content: space-between; align-items: center;
    padding: 12px 16px; background: rgba(26,26,46,0.95);
    border-bottom: 1px solid var(--bg-card-border);
}
.player-info { display: flex; align-items: center; gap: 8px; }
.player-avatar {
    width: 32px; height: 32px; border-radius: 50%;
    background: linear-gradient(135deg, var(--primary), var(--primary-dark));
    display: flex; align-items: center; justify-content: center;
    font-size: 0.75rem; font-weight: 700; color: var(--bg-dark);
}
.player-name { font-size: 0.85rem; font-weight: 500; }
.player-level-text { font-size: 0.7rem; color: var(--text-dim); display: block; }
.top-resources { display: flex; gap: 8px; }
.streak-badge, .wargold-badge {
    background: rgba(26,26,46,0.8); padding: 4px 8px;
    border-radius: 8px; font-size: 0.75rem;
}

/* Resources Bar */
.resources-bar {
    display: flex; gap: 8px; padding: 8px 16px;
    background: rgba(26,26,46,0.5); overflow-x: auto;
}
.resource {
    background: rgba(26,26,46,0.8); padding: 4px 10px;
    border-radius: 8px; font-size: 0.8rem; white-space: nowrap;
}

/* XP Bar */
.xp-bar-container { height: 4px; background: var(--bg-card); margin: 0 16px; border-radius: 2px; }
.xp-bar { height: 100%; background: linear-gradient(90deg, var(--primary), #f5c446); border-radius: 2px; transition: width 0.5s; }

/* Page Content */
.page-content { flex: 1; overflow-y: auto; padding: 16px; padding-bottom: 80px; }

/* Cards */
.card {
    background: var(--bg-card); border: 1px solid var(--bg-card-border);
    border-radius: 16px; padding: 16px; margin-bottom: 12px;
}
.card-gold {
    background: linear-gradient(135deg, var(--bg-card), #1e1e35);
    border: 1px solid rgba(240,173,27,0.3);
    border-radius: 16px; padding: 16px; margin-bottom: 12px;
    box-shadow: 0 4px 20px rgba(240,173,27,0.05);
}

/* Bottom Nav */
.bottom-nav {
    position: fixed; bottom: 0; left: 0; right: 0;
    display: flex; justify-content: space-around;
    padding: 8px 4px; background: rgba(26,26,46,0.98);
    border-top: 1px solid var(--bg-card-border);
}
.nav-btn {
    display: flex; flex-direction: column; align-items: center;
    gap: 2px; padding: 8px 12px; border: none; background: none;
    border-radius: 12px; cursor: pointer; min-width: 56px;
    transition: background 0.2s;
}
.nav-btn .nav-icon { font-size: 1.3rem; }
.nav-btn .nav-label { font-size: 0.6rem; color: var(--text-dim); }
.nav-btn.active { background: rgba(240,173,27,0.1); }
.nav-btn.active .nav-label { color: var(--primary); }

/* Toast */
.toast {
    position: fixed; top: 16px; left: 16px; right: 16px;
    padding: 12px 16px; border-radius: 12px;
    background: var(--bg-card); border: 1px solid var(--primary);
    font-size: 0.85rem; transform: translateY(-100px);
    transition: transform 0.3s; z-index: 1000;
}
.toast.show { transform: translateY(0); }
.toast.error { border-color: var(--red); }
.toast.success { border-color: var(--green); }

/* Building Grid */
.building-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
.building-card { text-align: center; padding: 12px; }
.building-icon { font-size: 2rem; margin-bottom: 4px; }
.building-name { font-size: 0.8rem; font-weight: 500; }
.building-level { font-size: 0.7rem; color: var(--primary); }

/* Build List */
.build-item {
    display: flex; align-items: center; gap: 12px;
    padding: 12px; cursor: pointer; transition: background 0.2s;
}
.build-item:active { background: rgba(240,173,27,0.05); border-radius: 12px; }

/* Raid */
.raid-center { text-align: center; padding: 2rem 0; }
.raid-target { margin: 1rem 0; }
.mini-game-bar { height: 32px; background: var(--bg-card); border-radius: 16px; position: relative; overflow: hidden; margin: 1rem 0; }
.mini-game-target { position: absolute; top: 0; bottom: 0; width: 10%; background: rgba(68,255,136,0.2); border-left: 2px solid var(--green); border-right: 2px solid var(--green); }
.mini-game-needle { position: absolute; top: 0; bottom: 0; width: 3px; background: var(--primary); transition: left 0.05s linear; }

/* Hero Stats */
.stat-row { display: flex; align-items: center; gap: 8px; margin-bottom: 8px; }
.stat-icon { width: 24px; text-align: center; }
.stat-label { font-size: 0.75rem; color: var(--text-dim); width: 80px; }
.stat-bar { flex: 1; height: 8px; background: var(--bg-card); border-radius: 4px; overflow: hidden; }
.stat-fill { height: 100%; border-radius: 4px; transition: width 0.5s; }
.stat-value { font-size: 0.7rem; color: var(--text-dim); width: 24px; text-align: right; }

/* Progress Bar */
.progress-bar { height: 12px; background: var(--bg-card); border-radius: 6px; overflow: hidden; }
.progress-fill { height: 100%; background: linear-gradient(90deg, var(--primary), #f5c446); border-radius: 6px; }

/* Animations */
@keyframes float { 0%,100% { transform: translateY(0); } 50% { transform: translateY(-10px); } }
@keyframes pulse { 0%,100% { opacity: 1; } 50% { opacity: 0.3; } }
@keyframes slideUp { from { transform: translateY(20px); opacity: 0; } to { transform: translateY(0); opacity: 1; } }
.animate-in { animation: slideUp 0.3s ease-out; }


/* ========== MINI-GAMES ========== */
.mg-game { text-align: center; }
.mg-header { display: flex; justify-content: space-between; align-items: center; margin-bottom: 12px; padding: 8px 12px; background: var(--bg-card); border-radius: 12px; }
.mg-timer { background: var(--red); color: #fff; width: 28px; height: 28px; border-radius: 50%; display: flex; align-items: center; justify-content: center; font-weight: bold; font-size: 0.8rem; }
.mg-title { font-family: 'Cinzel', serif; font-size: 0.9rem; color: var(--primary); }

.mg-power-bar { height: 12px; background: var(--bg-card); border-radius: 6px; margin: 12px 0; overflow: hidden; }
.mg-power-fill { height: 100%; width: 0%; background: linear-gradient(90deg, var(--primary), #f5c446); border-radius: 6px; transition: width 0.05s; }

.mg-fire-btn { width: 100%; margin-top: 12px; padding: 16px; font-size: 1.1rem; }
.mg-fire-btn:active { transform: scale(0.95); }

canvas { display: block; margin: 0 auto; border-radius: 12px; border: 1px solid var(--bg-card-border); }

/* Timing game */
.mg-timing-container { padding: 20px 0; }
.mg-timing-bar { position: relative; height: 40px; background: var(--bg-card); border-radius: 20px; margin: 16px 0; overflow: hidden; }
.mg-timing-zone { position: absolute; top: 0; bottom: 0; background: rgba(68,255,136,0.2); border-left: 3px solid var(--green); border-right: 3px solid var(--green); border-radius: 4px; }
.mg-timing-marker { position: absolute; top: 2px; bottom: 2px; width: 6px; background: var(--primary); border-radius: 3px; box-shadow: 0 0 10px var(--primary); transition: left 0.03s linear; }
.mg-timing-hits { display: flex; justify-content: center; gap: 4px; margin-top: 8px; min-height: 24px; }

/* Score popup */
.mg-score-popup {
    position: fixed; top: 0; left: 0; right: 0; bottom: 0;
    display: flex; align-items: center; justify-content: center;
    background: rgba(15,15,26,0.9); z-index: 100;
    animation: fadeIn 0.3s ease;
}
.mg-score-content { text-align: center; padding: 2rem; }
@keyframes fadeIn { from { opacity: 0; } to { opacity: 1; } }
