@import url('https://fonts.googleapis.com/css2?family=Cinzel:wght@700;900&family=Outfit:wght@500;700;900&display=swap');

* {
    user-select: none;
    -webkit-user-select: none;
    -webkit-touch-callout: none;
    box-sizing: border-box;
    -webkit-tap-highlight-color: transparent;
}

body, html {
    margin: 0; padding: 0; width: 100%; height: 100%;
    overflow: hidden; background: #050508;
    font-family: 'Outfit', sans-serif;
    touch-action: manipulation;
}

.font-cinzel { font-family: 'Cinzel', serif; }

#game-app {
    position: relative; width: 100%; height: 100%;
    max-width: 500px; max-height: 920px;
    margin: 0 auto; background: #0f0f14;
    overflow: hidden; display: flex; flex-direction: column;
    box-shadow: 0 0 40px rgba(0,0,0,0.9);
    border-left: 2px solid rgba(180, 130, 50, 0.3);
    border-right: 2px solid rgba(180, 130, 50, 0.3);
    padding-top: env(safe-area-inset-top);
    padding-bottom: env(safe-area-inset-bottom);
}

.wood-panel {
    background: linear-gradient(180deg, #3a2415 0%, #1a0e06 100%);
    border: 2px solid #b8860b;
    box-shadow: inset 0 0 20px rgba(0,0,0,0.9), 0 4px 15px rgba(0,0,0,0.9);
    border-radius: 8px;
}

.btn-gold {
    background: linear-gradient(180deg, #f0c040 0%, #b8860b 100%);
    border: 2px solid #fde68a; color: #1a0e06;
    text-shadow: 0 1px 0 rgba(255,255,255,0.4);
    box-shadow: 0 4px 12px rgba(234, 179, 8, 0.4);
    transition: all 0.1s;
}
.btn-gold:active { transform: scale(0.94); }

.btn-blue {
    background: linear-gradient(180deg, #3b82f6 0%, #1e3a8a 100%);
    border: 2px solid #93c5fd; color: #fff;
    box-shadow: 0 4px 10px rgba(59, 130, 246, 0.3);
}
.btn-blue:active { transform: scale(0.94); }

.btn-red {
    background: linear-gradient(180deg, #ef4444 0%, #991b1b 100%);
    border: 2px solid #fca5a5; color: #fff;
}
.btn-red:active { transform: scale(0.94); }

.btn-green {
    background: linear-gradient(180deg, #22c55e 0%, #15803d 100%);
    border: 2px solid #86efac; color: #fff;
}
.btn-green:active { transform: scale(0.94); }

.dmg-float {
    position: absolute; font-family: 'Outfit', sans-serif;
    font-weight: 900; font-size: 8px;
    -webkit-text-stroke: 0.3px rgba(0,0,0,0.8);
    pointer-events: none; z-index: 60;
    animation: floatUp 0.9s ease-out forwards;
    text-shadow: 0 1px 3px rgba(0,0,0,0.9);
    white-space: nowrap;
}

@keyframes floatUp {
    0% { opacity: 1; transform: translate(-50%, 0) scale(1.3); }
    100% { opacity: 0; transform: translate(-50%, -34px) scale(0.8); }
}

::-webkit-scrollbar { width: 4px; height: 4px; }
::-webkit-scrollbar-thumb { background: #b8860b; border-radius: 4px; }

@keyframes pulseGlow {
    0%, 100% { box-shadow: 0 0 8px rgba(234, 179, 8, 0.4); }
    50% { box-shadow: 0 0 20px rgba(234, 179, 8, 0.8); }
}
.pulse-glow { animation: pulseGlow 1.5s infinite; }

@keyframes dragonFly {
    0% { transform: translateX(-20px) scale(1); }
    50% { transform: translateX(20px) scale(1.1); }
    100% { transform: translateX(-20px) scale(1); }
}
.dragon-flying { animation: dragonFly 0.8s ease-in-out infinite; }

.flex-center { display: flex; align-items: center; justify-content: center; }
.flex-between { display: flex; align-items: center; justify-content: space-between; }

/* ===== Home screen / splash ===== */
#splash {
    position: absolute; inset: 0; z-index: 300;
    background: radial-gradient(ellipse at 50% 38%, #3a1f5c 0%, #150b27 55%, #07040f 100%);
    display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 18px;
    transition: opacity 0.6s ease, visibility 0.6s;
}
#splash.out { opacity: 0; visibility: hidden; pointer-events: none; }
.splash-crown { font-size: 54px; color: #fbbf24; filter: drop-shadow(0 0 18px rgba(251,191,36,.8)); animation: crownPop 1.1s ease-out both, floaty 3s ease-in-out 1.1s infinite; }
@keyframes crownPop { 0% { transform: scale(.2) translateY(30px); opacity: 0; } 70% { transform: scale(1.15); opacity: 1; } 100% { transform: scale(1); } }
@keyframes floaty { 0%,100% { transform: translateY(0); } 50% { transform: translateY(-6px); } }
.logo-text {
    font-family: 'Cinzel', serif; font-weight: 900; letter-spacing: 3px; text-align: center; line-height: 1;
    background: linear-gradient(180deg, #fff6c9 0%, #fbbf24 45%, #b45309 100%);
    -webkit-background-clip: text; background-clip: text; color: transparent;
    filter: drop-shadow(0 3px 0 rgba(60,20,0,.9)) drop-shadow(0 0 18px rgba(251,146,60,.45));
}
.splash-bar { width: 62%; max-width: 260px; height: 8px; border-radius: 6px; background: rgba(255,255,255,.12); overflow: hidden; border: 1px solid rgba(251,191,36,.35); }
.splash-bar > div { height: 100%; width: 0; border-radius: 6px; background: linear-gradient(90deg, #f59e0b, #fde68a); box-shadow: 0 0 10px #f59e0b; animation: loadFill 1.9s cubic-bezier(.4,.1,.3,1) forwards; }
@keyframes loadFill { to { width: 100%; } }
.splash-tip { font-size: 11px; color: #c9b5e8; letter-spacing: 1px; font-weight: 700; min-height: 14px; }

#home-bg { position: absolute; inset: 0; width: 100%; height: 100%; display: block; }
.home-vignette { position: absolute; inset: 0; pointer-events: none; z-index: 1;
    background: linear-gradient(180deg, rgba(8,4,20,.55) 0%, rgba(8,4,20,0) 26%, rgba(8,4,20,0) 52%, rgba(8,4,20,.75) 82%, rgba(8,4,20,.95) 100%); }

.hud-pill { background: rgba(10,6,24,.62); border: 1px solid rgba(251,191,36,.45); backdrop-filter: blur(6px); border-radius: 999px; }
.lvl-badge { width: 34px; height: 34px; border-radius: 50%; display: flex; align-items: center; justify-content: center; font-weight: 900; font-size: 14px; color: #1a0e06;
    background: radial-gradient(circle at 30% 25%, #fff3b0, #f59e0b 70%); border: 2px solid #fde68a; box-shadow: 0 0 12px rgba(251,191,36,.55); flex-shrink: 0; }
.xp-mini { height: 5px; border-radius: 4px; background: rgba(255,255,255,.14); overflow: hidden; }
.xp-mini > div { height: 100%; background: linear-gradient(90deg, #34d399, #a7f3d0); transition: width .4s; }

.title-in { animation: titleIn .9s cubic-bezier(.2,.9,.3,1.2) both; }
@keyframes titleIn { from { opacity: 0; transform: translateY(-22px) scale(.9); } to { opacity: 1; transform: none; } }
.rise-in { animation: riseIn .7s ease-out both; }
@keyframes riseIn { from { opacity: 0; transform: translateY(26px); } to { opacity: 1; transform: none; } }

.play-btn {
    position: relative; overflow: hidden; width: 100%; border-radius: 18px; padding: 14px 10px 12px;
    background: linear-gradient(180deg, #fde68a 0%, #f59e0b 48%, #c2410c 100%);
    border: 2px solid #fff3b0; color: #2a1200;
    box-shadow: 0 6px 0 #7c2d12, 0 10px 26px rgba(245,158,11,.55);
    animation: playPulse 1.8s ease-in-out infinite; transition: transform .08s;
}
.play-btn:active { transform: translateY(4px) scale(.98); box-shadow: 0 2px 0 #7c2d12, 0 4px 14px rgba(245,158,11,.5); }
.play-btn::after { content: ''; position: absolute; top: 0; left: -60%; width: 40%; height: 100%;
    background: linear-gradient(100deg, transparent, rgba(255,255,255,.65), transparent); transform: skewX(-18deg); animation: shine 2.8s ease-in-out infinite; }
@keyframes shine { 0% { left: -60%; } 55%,100% { left: 130%; } }
@keyframes playPulse { 0%,100% { transform: scale(1); } 50% { transform: scale(1.025); } }

.glass-btn { background: rgba(14,9,30,.66); border: 1px solid rgba(255,255,255,.18); backdrop-filter: blur(6px); border-radius: 14px; color: #f3e8ff; font-weight: 800; font-size: 11px; letter-spacing: .6px; text-transform: uppercase; }
.glass-btn:active { transform: scale(.95); }

.nav-bar { background: linear-gradient(180deg, rgba(40,22,10,.96), rgba(18,9,4,.98)); border-top: 2px solid #b8860b; }
.nav-btn { background: transparent; border: 0; flex: 1; display: flex; flex-direction: column; align-items: center; gap: 3px; padding: 8px 2px 7px; color: #c9a86a; font-size: 9px; font-weight: 800; letter-spacing: .6px; text-transform: uppercase; position: relative; transition: transform .1s; }
.nav-btn i { font-size: 19px; }
.nav-btn:active { transform: scale(.9); color: #fde68a; }
.nav-btn.hot { color: #fde68a; }
.nav-btn.hot i { filter: drop-shadow(0 0 6px rgba(251,191,36,.9)); }

#home-more { position: absolute; inset: 0; z-index: 40; background: rgba(5,3,12,.7); backdrop-filter: blur(4px); display: flex; align-items: flex-end; opacity: 1; transition: opacity .2s; }
#home-more.hidden { display: none; }
.more-sheet { width: 100%; background: linear-gradient(180deg, #3a2415, #150a04); border-top: 3px solid #b8860b; border-radius: 22px 22px 0 0; padding: 14px 14px 18px; animation: sheetUp .28s ease-out; }
@keyframes sheetUp { from { transform: translateY(100%); } to { transform: none; } }
.more-item { background: rgba(0,0,0,.35); border: 1px solid rgba(184,134,11,.5); border-radius: 14px; padding: 12px 6px; display: flex; flex-direction: column; align-items: center; gap: 5px; color: #fde68a; font-size: 10px; font-weight: 800; text-transform: uppercase; letter-spacing: .5px; }
.more-item i, .more-item .em { font-size: 22px; }
.more-item:active { transform: scale(.94); }

.chip { flex-shrink: 0; padding: 5px 10px; border-radius: 999px; border: 1px solid rgba(184,134,11,.55); background: rgba(0,0,0,.35); color: #c9a86a; font-size: 10px; font-weight: 800; text-transform: uppercase; letter-spacing: .4px; white-space: nowrap; }
.chip.on { background: linear-gradient(180deg,#f0c040,#b8860b); color: #1a0e06; border-color: #fde68a; }
.row-card { background: rgba(15,23,42,.9); border: 1px solid rgba(180,130,50,.45); border-radius: 12px; padding: 8px; }
.dep-btn { flex-shrink: 0; width: 92px; border-radius: 8px; padding: 3px 5px; text-align: left; display: flex; flex-direction: column; line-height: 1.2; }
.dep-name { font-size: 8px; font-weight: 900; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.dep-sub { font-size: 7px; font-weight: 800; opacity: .85; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
input[type=range].slider { -webkit-appearance: none; appearance: none; height: 8px; border-radius: 6px; background: rgba(255,255,255,.18); outline: none; }
input[type=range].slider::-webkit-slider-thumb { -webkit-appearance: none; width: 22px; height: 22px; border-radius: 50%; background: radial-gradient(circle at 30% 25%, #fff3b0, #f59e0b); border: 2px solid #fde68a; }
input[type=range].slider::-moz-range-thumb { width: 22px; height: 22px; border-radius: 50%; background: #f59e0b; border: 2px solid #fde68a; }

.tab-btn { flex: 1; padding: 6px 4px; text-align: center; font-size: 9px; font-weight: 800; text-transform: uppercase; color: #a08060; border-bottom: 2px solid transparent; cursor: pointer; transition: all 0.2s; }
.tab-btn.active { color: #fde68a; border-bottom-color: #b8860b; }

.toast {
    position: fixed; top: 60px; left: 50%; transform: translateX(-50%);
    background: rgba(0,0,0,0.9); color: #fde68a; padding: 8px 16px;
    border-radius: 20px; border: 1px solid #b8860b;
    font-size: 12px; font-weight: 700; z-index: 999;
    pointer-events: none; transition: opacity 0.3s;
}
.toast.hidden { opacity: 0; }

.progress-bar { width: 100%; height: 6px; background: rgba(0,0,0,0.5); border-radius: 3px; overflow: hidden; }
.progress-bar .fill { height: 100%; background: linear-gradient(90deg, #22c55e, #86efac); transition: width 0.3s; }