/**
 * TaniGo - Game Web Styling & Glassmorphism UI
 */

:root {
    --primary: #2d6a4f;
    --primary-light: #52b788;
    --primary-hover: #40916c;
    --primary-dark: #1b4332;
    --gold: #facc15;
    --gold-dark: #ca8a04;
    --emerald: #10b981;
    --danger: #ef4444;
    --sky: #38bdf8;
    --bg-overlay: rgba(11, 29, 20, 0.85);
    --glass-bg: rgba(22, 48, 35, 0.75);
    --glass-border: rgba(255, 255, 255, 0.15);
    --card-bg: rgba(0, 0, 0, 0.25);
    --text-light: #f8fafc;
    --text-muted: #94a3b8;
}

* {
    box-sizing: border-box;
    margin: 0;
    padding: 0;
    font-family: 'Plus Jakarta Sans', system-ui, -apple-system, sans-serif;
    user-select: none;
    -webkit-user-select: none;
}

html, body {
    width: 100%;
    height: 100%;
    overflow: hidden;
    background-color: #0d2818;
    color: var(--text-light);
}

#game-wrapper {
    position: relative;
    width: 100vw;
    height: 100vh;
    overflow: hidden;
}

#phaser-game {
    width: 100%;
    height: 100%;
    display: flex;
    justify-content: center;
    align-items: center;
}

/* ==============================================================
   TOP HUD
   ============================================================== */
.top-hud {
    position: absolute;
    top: 14px;
    left: 14px;
    right: 14px;
    display: flex;
    justify-content: space-between;
    align-items: center;
    pointer-events: none;
    z-index: 50;
    gap: 12px;
}

.hud-group {
    display: flex;
    align-items: center;
    gap: 10px;
    pointer-events: auto;
}

.hud-pill {
    background: var(--glass-bg);
    backdrop-filter: blur(12px);
    border: 1px solid var(--glass-border);
    border-radius: 99px;
    padding: 6px 14px;
    display: flex;
    align-items: center;
    gap: 8px;
    box-shadow: 0 8px 20px rgba(0,0,0,0.3);
    font-size: 13px;
    font-weight: 700;
}

.user-pill {
    padding-left: 6px;
    cursor: pointer;
    transition: transform 0.2s;
}
.user-pill:hover {
    transform: scale(1.02);
    border-color: var(--primary-light);
}

.user-avatar {
    width: 32px;
    height: 32px;
    border-radius: 50%;
    background: linear-gradient(135deg, #10b981 0%, #059669 100%);
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 15px;
    font-weight: 800;
    color: #fff;
    border: 2px solid #52b788;
}

.user-level-badge {
    background: #ca8a04;
    color: #fff;
    padding: 2px 7px;
    border-radius: 99px;
    font-size: 10px;
    font-weight: 800;
    letter-spacing: 0.5px;
}

.coin-icon { font-size: 17px; }
.coin-value { color: #fef08a; font-weight: 800; }

.pulsa-pill {
    background: rgba(16, 185, 129, 0.2);
    border-color: rgba(16, 185, 129, 0.4);
}
.pulsa-value { color: #6ee7b7; font-weight: 800; }

.debt-alert-pill {
    background: rgba(239, 68, 68, 0.25);
    border-color: rgba(239, 68, 68, 0.6);
    color: #fca5a5;
    cursor: pointer;
    animation: pulseGlow 2s infinite;
}
@keyframes pulseGlow {
    0%, 100% { box-shadow: 0 0 10px rgba(239, 68, 68, 0.3); }
    50% { box-shadow: 0 0 20px rgba(239, 68, 68, 0.6); }
}

.hud-btn {
    width: 38px;
    height: 38px;
    border-radius: 50%;
    background: var(--glass-bg);
    border: 1px solid var(--glass-border);
    color: #fff;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    font-size: 15px;
    transition: all 0.2s;
    backdrop-filter: blur(8px);
}
.hud-btn:hover {
    background: rgba(255, 255, 255, 0.15);
    transform: scale(1.08);
}

/* ==============================================================
   BOTTOM DOCK (NAVIGATION / ACTIONS)
   ============================================================== */
.bottom-dock {
    position: absolute;
    bottom: 16px;
    left: 50%;
    transform: translateX(-50%);
    display: flex;
    align-items: center;
    gap: 8px;
    background: var(--glass-bg);
    backdrop-filter: blur(16px);
    border: 1px solid var(--glass-border);
    padding: 8px 12px;
    border-radius: 20px;
    box-shadow: 0 15px 35px rgba(0,0,0,0.5);
    z-index: 50;
    max-width: 95vw;
    overflow-x: auto;
}

.dock-btn {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 4px;
    background: transparent;
    border: none;
    color: #d1fae5;
    padding: 8px 14px;
    border-radius: 14px;
    cursor: pointer;
    transition: all 0.2s cubic-bezier(0.4, 0, 0.2, 1);
    position: relative;
    white-space: nowrap;
}

.dock-btn:hover {
    background: rgba(255, 255, 255, 0.1);
    transform: translateY(-3px);
    color: #fff;
}

.dock-btn:active {
    transform: translateY(0);
}

.dock-icon {
    font-size: 22px;
}

.dock-label {
    font-size: 11px;
    font-weight: 700;
    letter-spacing: -0.2px;
}

.dock-badge {
    position: absolute;
    top: 4px;
    right: 8px;
    background: #ef4444;
    color: #fff;
    font-size: 9px;
    font-weight: 800;
    padding: 2px 5px;
    border-radius: 99px;
    box-shadow: 0 2px 6px rgba(0,0,0,0.3);
}

.dock-btn-special {
    background: linear-gradient(135deg, #059669 0%, #10b981 100%);
    color: #fff;
    box-shadow: 0 4px 15px rgba(16, 185, 129, 0.4);
}
.dock-btn-special:hover {
    background: linear-gradient(135deg, #10b981 0%, #34d399 100%);
}

/* ==============================================================
   MODAL WINDOWS
   ============================================================== */
.modal-backdrop {
    position: fixed;
    inset: 0;
    background: rgba(0, 0, 0, 0.65);
    backdrop-filter: blur(8px);
    display: none;
    align-items: center;
    justify-content: center;
    z-index: 100;
    padding: 16px;
    opacity: 0;
    transition: opacity 0.2s ease;
}

.modal-backdrop.active {
    display: flex;
    opacity: 1;
}

.modal-window {
    background: linear-gradient(180deg, #183d2b 0%, #0f271b 100%);
    border: 1px solid var(--glass-border);
    border-radius: 24px;
    width: 100%;
    max-width: 640px;
    max-height: 88vh;
    display: flex;
    flex-direction: column;
    box-shadow: 0 25px 60px rgba(0,0,0,0.6);
    overflow: hidden;
    transform: scale(0.95);
    transition: transform 0.2s ease;
}

.modal-backdrop.active .modal-window {
    transform: scale(1);
}

.modal-header {
    padding: 18px 24px;
    display: flex;
    justify-content: space-between;
    align-items: center;
    border-bottom: 1px solid rgba(255, 255, 255, 0.08);
}

.modal-title {
    font-size: 18px;
    font-weight: 800;
    color: #fff;
    display: flex;
    align-items: center;
    gap: 8px;
}

.btn-close {
    width: 32px;
    height: 32px;
    border-radius: 50%;
    background: rgba(255, 255, 255, 0.06);
    border: none;
    color: #94a3b8;
    cursor: pointer;
    font-size: 16px;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: 0.2s;
}
.btn-close:hover {
    background: rgba(239, 68, 68, 0.3);
    color: #fff;
}

.modal-body {
    padding: 20px 24px;
    overflow-y: auto;
    flex: 1;
}

/* Tabs */
.tab-row {
    display: flex;
    gap: 8px;
    border-bottom: 1px solid rgba(255, 255, 255, 0.08);
    padding-bottom: 12px;
    margin-bottom: 18px;
    overflow-x: auto;
}

.tab-btn {
    background: rgba(255, 255, 255, 0.04);
    border: 1px solid rgba(255, 255, 255, 0.08);
    color: #cbd5e1;
    padding: 8px 16px;
    border-radius: 10px;
    font-size: 13px;
    font-weight: 700;
    cursor: pointer;
    transition: 0.2s;
    white-space: nowrap;
}

.tab-btn:hover, .tab-btn.active {
    background: #2d6a4f;
    border-color: #52b788;
    color: #fff;
}

/* Item Grids */
.item-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(180px, 1fr));
    gap: 14px;
}

.item-card {
    background: rgba(0, 0, 0, 0.25);
    border: 1px solid rgba(255, 255, 255, 0.08);
    border-radius: 16px;
    padding: 14px;
    display: flex;
    flex-direction: column;
    justify-content: space-between;
    transition: 0.2s;
    position: relative;
}

.item-card:hover {
    border-color: #52b788;
    transform: translateY(-2px);
    background: rgba(0, 0, 0, 0.35);
}

.item-card-icon {
    font-size: 34px;
    text-align: center;
    margin-bottom: 8px;
}

.item-card-title {
    font-size: 14px;
    font-weight: 700;
    color: #f1f5f9;
    margin-bottom: 4px;
}

.item-card-desc {
    font-size: 11px;
    color: #94a3b8;
    line-height: 1.4;
    margin-bottom: 10px;
    flex: 1;
}

.item-card-footer {
    display: flex;
    justify-content: space-between;
    align-items: center;
    border-top: 1px solid rgba(255, 255, 255, 0.06);
    padding-top: 10px;
}

.item-price {
    font-size: 13px;
    font-weight: 800;
    color: #facc15;
}

.btn-buy, .btn-sell, .btn-primary {
    background: #059669;
    border: none;
    color: #fff;
    padding: 7px 12px;
    border-radius: 8px;
    font-size: 12px;
    font-weight: 700;
    cursor: pointer;
    transition: 0.2s;
}
.btn-buy:hover, .btn-sell:hover, .btn-primary:hover {
    background: #10b981;
}

.btn-secondary {
    background: rgba(255, 255, 255, 0.08);
    border: 1px solid rgba(255, 255, 255, 0.15);
    color: #fff;
    padding: 7px 12px;
    border-radius: 8px;
    font-size: 12px;
    font-weight: 700;
    cursor: pointer;
    transition: 0.2s;
}
.btn-secondary:hover {
    background: rgba(255, 255, 255, 0.15);
}

/* ==============================================================
   AD SIMULATION OVERLAY
   ============================================================== */
.ad-overlay {
    position: fixed;
    inset: 0;
    background: #000;
    z-index: 1000;
    display: none;
    flex-direction: column;
    justify-content: space-between;
    align-items: center;
    padding: 24px;
}

.ad-overlay.active {
    display: flex;
}

.ad-header {
    width: 100%;
    max-width: 720px;
    display: flex;
    justify-content: space-between;
    align-items: center;
    color: #fff;
}

.ad-countdown-pill {
    background: rgba(255, 255, 255, 0.2);
    padding: 6px 14px;
    border-radius: 99px;
    font-size: 13px;
    font-weight: 700;
    color: #facc15;
}

.ad-player-box {
    width: 100%;
    max-width: 720px;
    flex: 1;
    margin: 20px 0;
    background: linear-gradient(135deg, #1e293b 0%, #0f172a 100%);
    border: 2px solid rgba(255, 255, 255, 0.1);
    border-radius: 20px;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    padding: 30px;
    text-align: center;
    position: relative;
    overflow: hidden;
}

.ad-progress-bar {
    position: absolute;
    bottom: 0;
    left: 0;
    height: 6px;
    background: #10b981;
    width: 0%;
    transition: width 0.5s linear;
}

/* Toasts */
.game-toast {
    position: fixed;
    bottom: 84px;
    left: 50%;
    transform: translateX(-50%);
    background: rgba(6, 78, 59, 0.95);
    backdrop-filter: blur(12px);
    color: #ecfdf5;
    border: 1px solid #10b981;
    padding: 12px 24px;
    border-radius: 99px;
    font-size: 13px;
    font-weight: 700;
    box-shadow: 0 10px 30px rgba(0,0,0,0.5);
    z-index: 200;
    display: none;
    animation: toastPop 0.3s ease;
    text-align: center;
    max-width: 90vw;
}
@keyframes toastPop {
    from { opacity: 0; transform: translate(-50%, 15px); }
    to { opacity: 1; transform: translate(-50%, 0); }
}

/* Floating Click Feedback */
.floating-text {
    position: absolute;
    font-size: 14px;
    font-weight: 800;
    color: #facc15;
    text-shadow: 0 2px 4px rgba(0,0,0,0.8);
    pointer-events: none;
    z-index: 90;
    animation: floatUp 1.2s forwards;
}
@keyframes floatUp {
    0% { opacity: 1; transform: translateY(0); }
    100% { opacity: 0; transform: translateY(-45px); }
}

/* ==============================================================
   MOBILE LANDSCAPE ENFORCEMENT & RESPONSIVE LAYOUT
   ============================================================== */

/* Rotate Device Overlay (Shown only in portrait mode on mobile) */
.rotate-overlay {
    position: fixed;
    inset: 0;
    background: radial-gradient(circle at center, #14532d 0%, #052e16 100%);
    backdrop-filter: blur(16px);
    z-index: 9999;
    display: none;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    padding: 24px;
    text-align: center;
    color: #fff;
}

/* Triggered on portrait orientation on mobile devices */
@media screen and (orientation: portrait) and (max-width: 900px) {
    .rotate-overlay {
        display: flex !important;
    }
}

.rotate-box {
    max-width: 360px;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 16px;
}

.rotate-phone-anim {
    position: relative;
    width: 80px;
    height: 80px;
    display: flex;
    align-items: center;
    justify-content: center;
    animation: phoneRotate 2.5s infinite ease-in-out;
}

.rotate-arrow {
    position: absolute;
    top: -8px;
    right: -8px;
    font-size: 28px;
    color: #facc15;
}

@keyframes phoneRotate {
    0%, 25% { transform: rotate(0deg); }
    55%, 80% { transform: rotate(-90deg); }
    100% { transform: rotate(0deg); }
}

.rotate-box h2 {
    font-size: 19px;
    font-weight: 800;
    color: #a7f3d0;
    line-height: 1.3;
}

.rotate-box p {
    font-size: 13px;
    color: #cbd5e1;
    line-height: 1.5;
}

.btn-lock-landscape {
    background: linear-gradient(135deg, #10b981 0%, #059669 100%);
    color: #fff;
    border: none;
    padding: 12px 20px;
    border-radius: 12px;
    font-size: 14px;
    font-weight: 700;
    cursor: pointer;
    box-shadow: 0 8px 20px rgba(16, 185, 129, 0.4);
    transition: transform 0.2s;
    margin-top: 6px;
}
.btn-lock-landscape:active {
    transform: scale(0.96);
}

/* Mobile Landscape Compact Optimization (height <= 520px) */
@media screen and (orientation: landscape) and (max-height: 520px) {
    .top-hud {
        top: 6px;
        left: 8px;
        right: 8px;
        gap: 6px;
    }

    .hud-pill {
        padding: 4px 10px;
        font-size: 11px;
        gap: 6px;
    }

    .user-avatar {
        width: 26px;
        height: 26px;
        font-size: 12px;
    }

    .hud-btn {
        width: 30px;
        height: 30px;
        font-size: 12px;
    }

    #map-hint-pill {
        display: none !important;
    }

    .bottom-dock {
        bottom: 6px;
        padding: 4px 8px;
        gap: 4px;
        border-radius: 14px;
    }

    .dock-btn {
        padding: 4px 8px;
        gap: 2px;
        border-radius: 10px;
    }

    .dock-icon {
        font-size: 17px;
    }

    .dock-label {
        font-size: 9.5px;
    }

    .modal-window {
        max-height: 95vh;
        border-radius: 18px;
    }

    .modal-header {
        padding: 10px 16px;
    }

    .modal-title {
        font-size: 15px;
    }

    .modal-body {
        padding: 12px 16px;
    }

    .tab-row {
        padding-bottom: 6px;
        margin-bottom: 10px;
        gap: 6px;
    }

    .tab-btn {
        padding: 5px 12px;
        font-size: 11px;
    }

    .item-card {
        padding: 10px;
    }

    .item-card-icon {
        font-size: 26px;
        margin-bottom: 4px;
    }

    .item-card-title {
        font-size: 12.5px;
    }

    .item-card-desc {
        font-size: 10px;
        margin-bottom: 6px;
    }

    .btn-buy, .btn-sell, .btn-primary, .btn-secondary {
        padding: 5px 10px;
        font-size: 11px;
    }

    .game-toast {
        bottom: 60px;
        padding: 8px 18px;
        font-size: 11.5px;
    }
}

