/* ==========================================================================
   SHAREIN RETRO - Mobile Optimized CSS (Fix Layar Memanjang & Anti-Throttling)
   ========================================================================== */

/* --- 1. BASE & VARIABLES --- */
:root {
    --bg-dark: #0f111a;
    --surface: #1e2233;
    --primary: #45a29e;
    --primary-hover: #66fcf1;
    --text-main: #e2e8f0;
    --text-muted: #94a3b8;
    --danger: #ef4444;
    --danger-hover: #dc2626;
    --radius: 12px;
}

* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
    -webkit-tap-highlight-color: transparent; 
}

body {
    font-family: 'Poppins', sans-serif;
    background-color: var(--bg-dark);
    color: var(--text-main);
    line-height: 1.6;
    display: flex;
    flex-direction: column;
    min-height: 100vh;
    text-rendering: optimizeSpeed; 
}

/* --- 2. HEADER & FOOTER --- */
header {
    background: linear-gradient(135deg, #1e2233 0%, #0f111a 100%);
    padding: 20px 15px;
    text-align: center;
    border-bottom: 2px solid var(--primary);
    box-shadow: 0 4px 15px rgba(0, 0, 0, 0.5);
    position: sticky;
    top: 0;
    z-index: 100;
}

header h1 {
    font-size: 1.5rem;
    font-weight: 800;
    letter-spacing: 1px;
    margin-bottom: 4px;
    color: #fff;
}

.subtitle {
    font-size: 0.85rem;
    color: var(--primary);
    font-weight: 600;
}

footer {
    margin-top: auto;
    text-align: center;
    padding: 20px 15px;
    font-size: 0.85rem;
    color: var(--text-muted);
    border-top: 1px solid rgba(255, 255, 255, 0.05);
}

footer strong {
    color: var(--primary);
}

/* --- 3. LAYOUT & CONTAINERS --- */
#menu-area, #emulator-area {
    width: 100%;
    max-width: 1000px;
    margin: 0 auto;
    padding: 20px 15px;
    flex-grow: 1;
}

#emulator-area {
    display: none; 
    flex-direction: column;
    align-items: center;
    gap: 15px;
}

/* --- 4. MENU HEADER & NAVIGATION --- */
.menu-header {
    display: flex;
    flex-direction: column; 
    gap: 15px;
    margin-bottom: 20px;
}

.menu-title {
    font-size: 1.2rem;
    font-weight: 600;
    color: #fff;
    border-left: 4px solid var(--primary);
    padding-left: 10px;
    align-self: flex-start;
}

.back-btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    background-color: var(--surface);
    color: var(--text-main);
    border: 1px solid rgba(255, 255, 255, 0.1);
    padding: 10px 20px;
    border-radius: 8px;
    font-family: 'Poppins', sans-serif;
    font-weight: 600;
    font-size: 0.9rem;
    cursor: pointer;
    transition: all 0.2s ease;
    align-self: flex-start;
}

.back-btn:hover, .back-btn:active {
    background-color: var(--primary);
    color: #000;
    border-color: var(--primary);
}

.stop-btn {
    background-color: rgba(239, 68, 68, 0.1);
    color: var(--danger);
    border-color: var(--danger);
    width: 100%; 
}

.stop-btn:hover, .stop-btn:active {
    background-color: var(--danger);
    color: #fff;
}

/* --- 5. GRID & CARDS --- */
.grid-container {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(110px, 1fr));
    gap: 15px;
}

.card {
    background-color: var(--surface);
    border-radius: var(--radius);
    padding: 15px;
    text-align: center;
    cursor: pointer;
    transition: transform 0.2s ease, box-shadow 0.2s ease, background-color 0.2s;
    border: 1px solid rgba(255, 255, 255, 0.05);
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    box-shadow: 0 4px 6px rgba(0, 0, 0, 0.3);
    will-change: transform;
}

.card:active {
    transform: scale(0.96);
    background-color: #262b3d;
}

.card-icon {
    font-size: 45px;
    margin-bottom: 10px;
}

.card-title {
    font-size: 0.85rem;
    font-weight: 600;
    color: var(--text-main);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    width: 100%;
}

.game-thumbnail {
    width: 100%;
    aspect-ratio: 1 / 1;
    object-fit: cover;
    border-radius: 8px;
    margin-bottom: 10px;
    box-shadow: 0 2px 4px rgba(0,0,0,0.5);
    background-color: #000;
}

/* --- 6. EMULATOR GAME PLAYER --- */

/* OPTIMASI: Animasi gaib untuk mencegah CPU HP "tertidur" saat tidak ada input sentuhan */
@keyframes antiIdleThrottling {
    0% { opacity: 0.99; }
    100% { opacity: 1; }
}

.game-wrapper {
    width: 100%;
    height: 70vh; 
    min-height: 400px;
    background-color: #000;
    border-radius: var(--radius);
    overflow: hidden;
    box-shadow: 0 10px 30px rgba(0, 0, 0, 0.8);
    position: relative;
    border: 2px solid var(--surface);
    transform: translateZ(0);
    -webkit-transform: translateZ(0);
    /* Terapkan animasi gaib ke wrapper game */
    animation: antiIdleThrottling 0.5s infinite alternate;
}

#game-container {
    width: 100%;
    height: 100%;
}

.controls-info {
    font-size: 0.8rem;
    color: var(--text-muted);
    text-align: center;
    padding: 10px;
    background: rgba(255,255,255,0.02);
    border-radius: 8px;
    width: 100%;
}

/* --- 7. RESPONSIVE ADJUSTMENTS --- */
@media (min-width: 600px) {
    .menu-header {
        flex-direction: row;
        align-items: center;
        justify-content: flex-start;
    }
    
    .menu-title {
        border-left: none;
        padding-left: 0;
        align-self: center;
    }
    
    .grid-container {
        grid-template-columns: repeat(auto-fit, minmax(150px, 1fr));
        gap: 20px;
    }

    .stop-btn {
        width: auto;
        align-self: flex-start;
    }
    
    header h1 {
        font-size: 2rem;
    }
    
    .subtitle {
        font-size: 1rem;
    }
    
    .card:hover {
        transform: translateY(-5px);
        box-shadow: 0 8px 15px rgba(69, 162, 158, 0.2);
        border-color: rgba(69, 162, 158, 0.5);
    }

    .game-wrapper {
        height: auto;
        aspect-ratio: 4 / 3; 
        min-height: unset;
    }
}