/* ═══════════════════════════════════════════════════════════════
   ZEYTİN İMPARATORLUĞU 2D — Mobil Odaklı UI v6.1 (Click Fix)
   ═══════════════════════════════════════════════════════════════ */

:root {
    --bg-dark: #0f172a;
    --bg-card: #1e293b;
    --bg-deep: #0a0f1a;
    --primary: #84cc16;
    --primary-dark: #4d7c0f;
    --secondary: #eab308;
    --danger: #ef4444;
    --info: #3b82f6;
    --purple: #9333ea;
    --text-main: #f8fafc;
    --text-muted: #94a3b8;
    --border: #334155;
    --brown: #78350f;
    --wood: #92400e;
    --panel-bg: #111827;
}

* { box-sizing: border-box; margin: 0; padding: 0; font-family: 'Nunito', sans-serif; user-select: none; -webkit-tap-highlight-color: transparent; }
body { background: var(--bg-deep); color: var(--text-main); width: 100vw; height: 100vh; overflow: hidden; }

/* KARAKTER OLUŞTURMA */
#char-creation-screen {
    position: fixed; inset: 0; z-index: 99999;
    background: linear-gradient(180deg, #1a3a0a 0%, #0f2408 40%, #0a1a06 100%);
    display: flex; justify-content: center; align-items: center;
}
.char-creation-card {
    position: relative; background: rgba(15,23,42,0.95); border: 3px solid var(--brown);
    border-radius: 16px; padding: 24px; width: 90%; max-width: 380px; text-align: center;
    box-shadow: 0 0 40px rgba(0,0,0,0.8);
}
.char-creation-card h1 { font-family: 'Press Start 2P', monospace; font-size: 13px; color: var(--secondary); margin-bottom: 4px; }
.char-creation-card .subtitle { font-size: 11px; color: var(--text-muted); margin-bottom: 16px; }
.char-form-group { margin-bottom: 14px; text-align: left; }
.char-form-group label { display: block; font-size: 10px; font-weight: 800; color: var(--primary); text-transform: uppercase; margin-bottom: 4px; }
.char-name-input {
    width: 100%; padding: 10px 12px; background: rgba(0,0,0,0.5); border: 2px solid var(--border);
    border-radius: 8px; color: #fff; font-size: 15px; font-weight: 700; outline: none;
}
.gender-selector { display: flex; gap: 10px; }
.gender-option {
    flex: 1; background: rgba(0,0,0,0.4); border: 2px solid var(--border); border-radius: 10px;
    padding: 10px; cursor: pointer; display: flex; flex-direction: column; align-items: center; gap: 4px;
}
.gender-option.selected { border-color: var(--primary); background: rgba(132,204,22,0.15); }
.gender-option canvas { image-rendering: pixelated; }
.gender-label { font-size: 11px; font-weight: 800; color: var(--text-muted); }
.btn-start-game {
    width: 100%; padding: 12px; background: linear-gradient(180deg, #65a30d, #4d7c0f); border: none; border-radius: 10px;
    color: #fff; font-size: 13px; font-weight: 900; cursor: pointer; text-transform: uppercase;
    box-shadow: 0 4px 0 #3f6212; margin-top: 6px;
}

/* ANA LAYOUT */
#app-layout {
    display: flex; width: 100vw; height: 100vh; overflow: hidden; display: none; position: relative;
}

#game-area {
    flex: 1; position: relative; display: flex; flex-direction: column; min-width: 0; background: #2d5016;
}

/* ÜST HUD */
#top-hud {
    display: flex; justify-content: space-between; align-items: center;
    padding: 6px 10px; background: rgba(15,23,42,0.92); backdrop-filter: blur(8px);
    border-bottom: 2px solid var(--brown); z-index: 500; position: relative; pointer-events: auto;
}
.hud-left, .hud-right { display: flex; align-items: center; gap: 8px; }
.hud-money { font-family: 'Press Start 2P', monospace; font-size: 10px; color: var(--secondary); text-shadow: 0 1px 3px #000; }
.hud-day, .hud-weather, .hud-level {
    background: rgba(0,0,0,0.4); padding: 3px 6px; border-radius: 6px; border: 1px solid var(--border);
    font-size: 10px; font-weight: 800; white-space: nowrap;
}
.hud-weather { color: #fff; }
.hud-level { color: var(--secondary); background: rgba(234,179,8,0.1); }
.hud-btn { background: rgba(255,255,255,0.1); border: 1px solid rgba(255,255,255,0.15); width: 28px; height: 28px; border-radius: 6px; color: #fff; font-size: 12px; cursor: pointer; display: flex; justify-content: center; align-items: center; }

#day-progress { width: 100%; height: 3px; background: #000; z-index: 500; }
#day-bar { height: 100%; width: 0%; background: linear-gradient(90deg, var(--primary), var(--secondary)); transition: width 0.1s linear; }

/* MİNİ BORSA WIDGET'I */
#mini-borsa-widget {
    position: absolute; top: 46px; right: 10px; z-index: 500;
    background: rgba(15, 23, 42, 0.85); backdrop-filter: blur(6px);
    border: 2px solid var(--brown); border-radius: 8px;
    padding: 3px 8px; display: flex; gap: 8px; align-items: center;
    box-shadow: 0 4px 12px rgba(0,0,0,0.5); pointer-events: none;
}
.mini-borsa-item { display: flex; align-items: center; gap: 3px; font-size: 9px; font-weight: 900; }
.mini-borsa-label { font-size: 10px; }
.mini-borsa-val { color: #fff; font-family: 'Press Start 2P', monospace; font-size: 8px; }
.mini-borsa-arrow { font-size: 10px; }
.mini-borsa-arrow.up { color: #4ade80; }
.mini-borsa-arrow.down { color: #f87171; }
.mini-borsa-arrow.neutral { color: var(--text-muted); }

/* MOBİL ÇEKMECE TOGGLE BUTONU (Z-Index Yükseltildi) */
#btn-toggle-side {
    display: none; position: absolute; top: 46px; left: 10px; z-index: 550;
    background: rgba(30, 41, 59, 0.95); border: 2px solid var(--primary); border-radius: 8px;
    color: #fff; font-size: 11px; font-weight: 900; padding: 6px 12px; cursor: pointer;
    box-shadow: 0 4px 16px rgba(0,0,0,0.6); pointer-events: auto;
}

/* CANVAS */
#game-container {
    flex: 1; position: relative; overflow: hidden; background: #3a6a1e; cursor: pointer;
}
#game-container canvas {
    display: block; width: 100% !important; height: 100% !important;
    image-rendering: pixelated; image-rendering: crisp-edges;
}

/* SANAL DOKUNMATİK JOYSTİCK ZONU */
#virtual-joystick-zone {
    position: absolute; top: 90px; left: 0; width: 50%; bottom: 60px;
    z-index: 40; touch-action: none;
}

.joy-base {
    position: fixed; width: 90px; height: 90px;
    border-radius: 50%; background: rgba(255, 255, 255, 0.12);
    border: 2px solid rgba(255, 255, 255, 0.35);
    backdrop-filter: blur(4px); box-shadow: 0 0 15px rgba(0,0,0,0.3);
    pointer-events: none; z-index: 99; display: none;
}

.joy-stick {
    position: fixed; width: 44px; height: 44px;
    border-radius: 50%; background: radial-gradient(circle at 30% 30%, #84cc16, #4d7c0f);
    border: 2px solid #fef08a; box-shadow: 0 2px 8px rgba(0,0,0,0.5);
    pointer-events: none; z-index: 100;
}

/* AKILLI DOKUNMATİK AKSİYON BUTONU */
.smart-action-btn {
    position: absolute; bottom: 65px; right: 16px; z-index: 450;
    background: linear-gradient(180deg, #65a30d, #4d7c0f);
    border: 3px solid #fef08a; border-radius: 25px;
    padding: 10px 20px; display: none; align-items: center; gap: 8px;
    color: #fff; font-weight: 900; font-size: 13px; text-transform: uppercase;
    box-shadow: 0 6px 20px rgba(0,0,0,0.6); cursor: pointer; pointer-events: auto;
    animation: smartPulse 1.2s infinite alternate ease-in-out;
}
.smart-action-btn:active { transform: scale(0.95); background: #4d7c0f; }
@keyframes smartPulse { from { transform: scale(1); } to { transform: scale(1.06); } }

/* ENVANTER ÇUBUĞU */
#inventory-bar {
    position: absolute; bottom: 44px; left: 50%; transform: translateX(-50%);
    display: flex; gap: 2px; z-index: 350;
    background: rgba(15,23,42,0.9); border: 2px solid var(--brown); border-radius: 8px;
    padding: 3px 5px; box-shadow: 0 4px 12px rgba(0,0,0,0.6); pointer-events: none;
}
.inv-slot {
    width: 42px; height: 42px; background: rgba(0,0,0,0.5); border: 1px solid var(--border);
    border-radius: 5px; display: flex; flex-direction: column; align-items: center; justify-content: center;
    position: relative;
}
.inv-slot:first-child { border-color: var(--primary); background: rgba(132,204,22,0.15); }
.inv-icon canvas { width: 20px; height: 20px; image-rendering: pixelated; }
.inv-count {
    position: absolute; bottom: 1px; right: 2px; font-size: 8px; font-weight: 900; color: #fff;
    font-family: 'Press Start 2P', monospace; text-shadow: 0 1px 2px #000, 1px 0 2px #000;
}
.inv-label { position: absolute; top: 1px; left: 2px; font-size: 6px; font-weight: 800; color: var(--text-muted); text-transform: uppercase; }

/* ALT NAVİGASYON */
#bottom-nav {
    display: flex; justify-content: space-around; padding: 2px 0; padding-bottom: env(safe-area-inset-bottom);
    background: rgba(15,23,42,0.98); border-top: 2px solid var(--brown); z-index: 500; pointer-events: auto;
}
.nav-item {
    flex: 1; display: flex; flex-direction: column; align-items: center; gap: 1px;
    color: var(--text-muted); cursor: pointer; background: none; border: none; padding: 2px 0;
}
.nav-item .icon { font-size: 16px; }
.nav-item span:not(.icon) { font-size: 8px; font-weight: 800; text-transform: uppercase; color: var(--text-muted); }

/* YAN PANEL & PERSONEL KARTLARI (Tıklanabilir Z-Index Fix) */
#side-panel {
    width: 250px; min-width: 250px; background: var(--panel-bg); border-left: 3px solid var(--brown);
    display: flex; flex-direction: column; overflow-y: auto; z-index: 600; transition: transform 0.3s ease;
    pointer-events: auto;
}

#borsa-section { padding: 10px; border-bottom: 2px solid var(--border); }
.borsa-header { font-family: 'Press Start 2P', monospace; font-size: 9px; color: var(--secondary); text-align: center; margin-bottom: 2px; }
.borsa-subheader { font-size: 8px; color: var(--text-muted); text-align: center; margin-bottom: 8px; }
.borsa-item-row {
    display: flex; align-items: center; gap: 6px; padding: 5px 8px;
    background: rgba(0,0,0,0.3); border-radius: 6px; margin-bottom: 4px; border: 1px solid var(--border);
}
.borsa-icon-wrap { width: 20px; height: 20px; flex-shrink: 0; }
.borsa-name { flex: 1; font-size: 10px; font-weight: 800; color: var(--text-main); }
.borsa-val { font-family: 'Press Start 2P', monospace; font-size: 8px; color: #fff; }
.borsa-arrow { font-size: 12px; width: 16px; text-align: center; font-weight: 900; }
.borsa-arrow.up { color: #4ade80; }
.borsa-arrow.down { color: #f87171; }
.borsa-arrow.neutral { color: var(--text-muted); }

#npc-section { padding: 8px; flex: 1; }
.npc-section-title { font-size: 9px; font-weight: 900; color: var(--primary); text-transform: uppercase; text-align: center; margin-bottom: 6px; }
.npc-card {
    display: flex; align-items: center; gap: 6px; padding: 6px;
    background: rgba(0,0,0,0.3); border: 2px solid var(--border); border-radius: 8px; margin-bottom: 4px;
}
.npc-card.hired { border-color: var(--primary); background: rgba(132,204,22,0.08); }
.npc-portrait { width: 40px; height: 40px; border-radius: 6px; border: 1px solid var(--border); background: rgba(0,0,0,0.4); image-rendering: pixelated; }
.npc-info { flex: 1; min-width: 0; }
.npc-name { font-size: 11px; font-weight: 900; color: #fff; }
.npc-role { font-size: 8px; color: var(--text-muted); font-weight: 700; }
.npc-cost { font-size: 7px; color: var(--secondary); font-weight: 800; }
.npc-hire-btn {
    background: linear-gradient(180deg, #3b82f6, #2563eb); border: none; border-radius: 5px;
    color: #fff; font-size: 9px; font-weight: 900; padding: 6px 8px; cursor: pointer; white-space: nowrap;
    box-shadow: 0 2px 0 #1d4ed8; pointer-events: auto;
}
.npc-hire-btn.hired-btn { background: linear-gradient(180deg, #16a34a, #15803d); box-shadow: 0 2px 0 #166534; }

/* FLAŞ BANNER & HAVA DURUMU */
.flash-banner { position: fixed; top: 0; left: 0; width: 100%; z-index: 9000; background: var(--danger); color: #fff; text-align: center; padding: 6px; font-size: 11px; font-weight: 900; display: none; }
#weather-splash { position: fixed; inset: 0; z-index: 8000; background: rgba(0,0,0,0.7); backdrop-filter: blur(5px); display: none; justify-content: center; align-items: center; }
.splash-card { background: var(--bg-card); border: 3px solid var(--brown); border-radius: 14px; padding: 20px 24px; text-align: center; max-width: 320px; width: 90%; }
.splash-card h2 { font-family: 'Press Start 2P', monospace; font-size: 11px; color: var(--secondary); margin-bottom: 8px; }
.splash-weather { font-size: 18px; margin-bottom: 14px; }
.ws-close-btn { background: linear-gradient(180deg, #65a30d, #4d7c0f); border: none; border-radius: 8px; color: #fff; font-size: 11px; font-weight: 900; padding: 8px 16px; cursor: pointer; }

/* MODALLER */
.modal-overlay { position: fixed; inset: 0; background: rgba(0,0,0,0.75); display: none; justify-content: center; align-items: center; z-index: 7000; backdrop-filter: blur(4px); }
.modal-content { background: var(--bg-card); width: 92%; max-width: 380px; max-height: 85vh; border-radius: 12px; border: 2px solid var(--brown); display: flex; flex-direction: column; overflow: hidden; }
.modal-header { padding: 8px 12px; border-bottom: 1px solid var(--border); display: flex; justify-content: space-between; align-items: center; }
.modal-title { font-size: 12px; font-weight: 900; text-transform: uppercase; }
.modal-close { background: rgba(255,255,255,0.1); border: none; color: #fff; width: 24px; height: 24px; border-radius: 5px; font-size: 12px; cursor: pointer; }
.modal-body { padding: 10px; overflow-y: auto; font-size: 11px; line-height: 1.4; color: var(--text-muted); }
.card-inner { background: rgba(0,0,0,0.3); border: 1px solid var(--border); border-radius: 6px; padding: 8px; margin-bottom: 8px; }
.card-inner h4 { font-size: 11px; color: var(--primary); margin-bottom: 4px; }
.desc { font-size: 9px; color: var(--text-muted); margin-bottom: 4px; }
.info-row { display: flex; justify-content: space-between; font-size: 10px; font-weight: 800; margin-bottom: 3px; }
.hl { color: var(--primary); }
.prog-bar { width: 100%; height: 5px; background: #000; border-radius: 2px; margin-bottom: 6px; overflow: hidden; }
.prog-fill { height: 100%; width: 0%; background: var(--primary); }
.btn-act { width: 100%; padding: 7px; border: none; border-radius: 6px; color: #fff; font-size: 11px; font-weight: 900; cursor: pointer; margin-bottom: 4px; text-transform: uppercase; }
.btn-act.green { background: linear-gradient(180deg, #65a30d, #4d7c0f); }
.btn-act.blue { background: linear-gradient(180deg, #3b82f6, #2563eb); }
.btn-act.gold { background: linear-gradient(180deg, #eab308, #ca8a04); color: #000; }
.btn-act.purple { background: linear-gradient(180deg, #9333ea, #7e22ce); }
.btn-act.red { background: linear-gradient(180deg, #ef4444, #dc2626); }
.btn-row { display: flex; gap: 4px; } .btn-row .btn-act { flex: 1; }
.trade-row { display: flex; align-items: center; gap: 6px; padding: 6px; background: rgba(0,0,0,0.3); border: 1px solid var(--border); border-radius: 6px; margin-bottom: 4px; }
.trade-info { flex: 1; } .trade-name { font-size: 11px; font-weight: 900; color: #fff; } .trade-stock { font-size: 9px; color: var(--text-muted); }
.trade-price { font-family: 'Press Start 2P', monospace; font-size: 9px; color: var(--secondary); }
.btn-sm { background: linear-gradient(180deg, #3b82f6, #2563eb); border: none; border-radius: 5px; color: #fff; font-size: 9px; font-weight: 900; padding: 5px 8px; cursor: pointer; }
.btn-sm.sell { background: linear-gradient(180deg, #16a34a, #15803d); }
.btn-sm.gold { background: linear-gradient(180deg, #eab308, #ca8a04); color: #000; }
.btn-sm.red { background: linear-gradient(180deg, #ef4444, #dc2626); }
.section-label { font-size: 9px; font-weight: 900; color: var(--secondary); text-transform: uppercase; margin: 6px 0 3px; }
.manage-row { display: flex; align-items: center; gap: 6px; padding: 5px; background: rgba(0,0,0,0.2); border-radius: 5px; margin-bottom: 3px; font-size: 10px; font-weight: 800; }
.manage-row span { flex: 1; }
.reward-box { text-align: center; padding: 16px; }
.reward-icon { font-size: 36px; margin-bottom: 6px; }
.reward-title { font-family: 'Press Start 2P', monospace; font-size: 12px; color: var(--secondary); margin-bottom: 6px; }
.reward-desc { font-size: 12px; color: #fff; font-weight: 900; margin-bottom: 12px; }
.center-text { text-align: center; }
.gold-text { color: var(--secondary); }
#wheel-spinner { font-size: 48px; transition: transform 2s cubic-bezier(0.17,0.67,0.12,0.99); margin: 12px auto; }
.floating-text { position: fixed; pointer-events: none; font-weight: 900; font-size: 14px; z-index: 99999; animation: floatUp 1.2s forwards; text-shadow: 0 2px 4px #000; }
@keyframes floatUp { 0% { transform: translateY(0) scale(1); opacity: 1; } 100% { transform: translateY(-35px) scale(1.2); opacity: 0; } }

/* MOBİL RESPONSIVE */
@media (max-width: 768px) {
    #btn-toggle-side { display: block; }

    #side-panel {
        position: fixed; top: 0; right: 0; bottom: 0; width: 280px; z-index: 999;
        transform: translateX(100%); box-shadow: -10px 0 30px rgba(0,0,0,0.8);
    }
    #side-panel.open { transform: translateX(0); }

    #inventory-bar { bottom: 35px; transform: translateX(-50%) scale(0.9); }
    .inv-slot { width: 36px; height: 36px; }
    .smart-action-btn { bottom: 80px; right: 10px; padding: 8px 14px; font-size: 11px; }
}

@media (max-width: 480px) {
    .hud-money { font-size: 8px; }
    .hud-day, .hud-weather, .hud-level { font-size: 8px; padding: 2px 4px; }
    #mini-borsa-widget { top: 42px; right: 6px; padding: 2px 5px; gap: 5px; }
    .mini-borsa-val { font-size: 7px; }
    .inv-slot { width: 32px; height: 32px; }
    .inv-count { font-size: 7px; }
}
