:root {
    --primary-bg: #1a1a1a;
    --secondary-bg: #2a2a2a;
    --card-bg: #3c3c3c;
    --accent-yellow: #FFC700;
    --accent-green: #4CAF50;
    --accent-red: #F44336;
    --text-primary: #FFFFFF;
    --text-secondary: #BDBDBD;
    --progress-bar: #FFC700;
    --font-family: 'Poppins', sans-serif;
}

body {
    font-family: var(--font-family);
    background-color: var(--primary-bg);
    background-image: linear-gradient(rgba(26, 26, 26, 0.95), rgba(26, 26, 26, 0.95)), url("data:image/svg+xml,%3Csvg width='60' height='60' viewBox='0 0 60 60' xmlns='http://www.w3.org/2000/svg'%3E%3Cg fill='none' fill-rule='evenodd'%3E%3Cg fill='%232a2a2a' fill-opacity='0.4'%3E%3Cpath d='M36 34v-4h-2v4h-4v2h4v4h2v-4h4v-2h-4zm0-30V0h-2v4h-4v2h4v4h2V6h4V4h-4zM6 34v-4H4v4H0v2h4v4h2v-4h4v-2H6zM6 4V0H4v4H0v2h4v4h2V6h4V4H6z'/%3E%3C/g%3E%3C/g%3E%3C/svg%3E");
    color: var(--text-primary);
    margin: 0;
    padding: 0;
    display: flex;
    justify-content: center;
    align-items: flex-start;
    overflow-x: hidden;
    overflow-y: auto;
    height: auto;
    -webkit-tap-highlight-color: transparent;
}

.game-container {
    width: 100%;
    max-width: 480px;
    min-height: 100vh;
    height: auto; /* Allow content to grow */
    background-color: var(--secondary-bg);
    display: flex;
    flex-direction: column;
    box-shadow: 0 0 20px rgba(0,0,0,0.5);
    position: relative;
    margin: 0 auto;
    padding-bottom: 120px; /* Space for nav + ad */
}

/* Add these responsive improvements */

/* Account for ad frame at bottom */
.game-container {
    padding-bottom: 50px; /* Space for ad + nav */
    min-height: 100vh;
    box-sizing: border-box;
}

/* Responsive grid for hustles */
.hustle-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(280px, 1fr));
    gap: 1rem;
    padding: 1rem;
    max-width: 1400px;
    margin: 0 auto;
}

/* Mobile-first breakpoints */
@media (max-width: 768px) {
    .hustle-grid {
        grid-template-columns: 1fr;
        padding: 0.5rem;
    }
    
    .top-bar {
        flex-wrap: wrap;
        gap: 0.5rem;
        padding: 0.5rem;
    }
    
    .stat-box {
        flex: 1 1 45%;
        min-width: 120px;
    }
    
    .bottom-nav {
        padding: 0.5rem;
        gap: 0.25rem;
    }
    
    .nav-button {
        font-size: 0.8rem;
        padding: 0.5rem;
    }
}

@media (max-width: 480px) {
    .welcome-content {
        padding: 1rem;
    }
    
    .features {
        grid-template-columns: 1fr;
    }
}

/* Ensure content doesn't hide behind fixed elements */
main {
    margin-bottom: 88px; /* bottom-nav + ad frame */
}

/* TOP BAR */
.top-bar {
    display: flex;
    justify-content: space-around;
    padding: 8px 10px;
    background-color: var(--primary-bg);
    border-bottom: 2px solid var(--accent-yellow);
    flex-shrink: 0;
    user-select: none;
}

.stat-box {
    text-align: center;
    width: 33.33%;
}

.stat-label {
    display: block;
    font-size: 0.65rem;
    color: var(--text-secondary);
    font-weight: 600;
}

.stat-value {
    font-size: 1.1rem;
    font-weight: 700;
    color: var(--accent-yellow);
}

/* HUSTLE GRID */
.hustle-grid {
    flex-grow: 1;
    overflow-y: auto;
    padding: 15px;
    display: flex;
    flex-direction: column;
    gap: 15px;
    padding-bottom: 20px;
    -webkit-overflow-scrolling: touch;
}

/* HUSTLE CARD */
.hustle-card {
    background-color: var(--card-bg);
    border-radius: 12px;
    padding: 15px;
    display: flex;
    align-items: center;
    gap: 15px;
    border-left: 5px solid var(--accent-yellow);
    transition: transform 0.2s ease, box-shadow 0.2s ease, opacity 0.3s ease;
    user-select: none;
    min-width: 0;
    word-break: break-word;
}
.hustle-card.locked {
    opacity: 0.6;
    filter: grayscale(70%);
    border-left-color: #666;
}
.hustle-card.can-unlock {
    border-left-color: var(--accent-yellow);
    opacity: 1;
    animation: pulse-glow 2s infinite;
    background-color: rgba(255, 199, 0, 0.1);
}

.hustle-icon {
    width: 60px;
    height: 60px;
    background-color: var(--secondary-bg);
    border-radius: 8px;
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
}

.hustle-icon img {
    width: 40px;
    height: 40px;
}

.hustle-details {
    flex-grow: 1;
    display: flex;
    flex-direction: column;
    gap: 5px;
    min-width: 0; /* Prevents flexbox overflow */
}

.hustle-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
}
.hustle-name {
    font-size: 1.1rem;
    font-weight: 600;
}
.hustle-level {
    font-size: 0.9rem;
    padding: 3px 8px;
    background: var(--accent-yellow);
    color: var(--primary-bg);
    border-radius: 5px;
    font-weight: 700;
}
.hustle-income {
    font-size: 0.9rem;
    color: var(--text-secondary);
}

.action-button {
    background-color: var(--accent-green);
    color: white;
    border: none;
    border-radius: 8px;
    padding: 10px 15px;
    font-size: 1rem;
    font-weight: 600;
    cursor: pointer;
    text-align: center;
    transition: background-color 0.2s ease, transform 0.1s ease;
    width: 100%;
    margin-top: 5px;
}

.action-button:active:not(:disabled) {
    transform: scale(0.98);
}
.action-button:disabled {
    background-color: #616161;
    cursor: not-allowed;
    filter: brightness(0.7);
}
.action-button.disabled {
    background-color: #666 !important;
    opacity: 0.5;
    cursor: not-allowed;
}
.action-button:not(.disabled):hover {
    transform: translateY(-1px);
    box-shadow: 0 2px 10px rgba(0,0,0,0.3);
}

.progress-bar-container {
    width: 100%;
    background-color: var(--secondary-bg);
    border-radius: 5px;
    height: 10px;
    margin-top: 5px;
    overflow: hidden;
}
.progress-bar {
    width: 0%;
    height: 100%;
    background-color: var(--progress-bar);
    border-radius: 5px;
    transition: width 0.1s linear;
}
.automation-text {
    font-size: 0.8rem;
    color: var(--accent-yellow);
    text-align: center;
    font-style: italic;
    margin-top: 5px;
}
.automation-available {
    font-size: 0.8rem;
    color: var(--accent-yellow);
    text-align: center;
    font-weight: 600;
    margin-top: 5px;
    animation: pulse 1.5s infinite;
}
.automation-pending {
    font-size: 0.8rem;
    color: #888;
    text-align: center;
    margin-top: 5px;
}

/* BOTTOM NAVIGATION */
.bottom-nav {
    position: fixed;
    left: 0;
    right: 0;
    bottom: 50px; /* Above ad frame */
    z-index: 100;
    background-color: var(--primary-bg);
    border-top: 2px solid var(--accent-yellow);
    display: flex;
    justify-content: space-around;
    align-items: center;
    gap: 8px;
    padding: 10px 8px;
    min-height: 60px;
    width: 100%;
    box-sizing: border-box;
}

.nav-button {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    background: transparent;
    color: var(--text-secondary);
    border: none;
    padding: 8px 6px;
    font-size: 0.8rem;
    font-weight: 600;
    border-radius: 8px;
    cursor: pointer;
    transition: all 0.2s ease;
    min-height: 54px;
    flex: 1;
    max-width: 100px;
}

.nav-button:hover, .nav-button:active {
    transform: translateY(-2px);
    color: var(--text-primary);
}

.nav-icon {
    font-size: 1.4rem;
    margin-bottom: 3px;
    display: block;
}

.nav-label {
    font-size: 0.9rem;
    font-weight: 600;
    margin-top: 2px;
    display: block;
    line-height: 1.1;
    text-align: center;
    white-space: normal;
}

/* Individual button colors */
.advice-btn:hover, .advice-btn:active {
    background: linear-gradient(45deg, rgba(66, 133, 244, 0.2), rgba(52, 168, 83, 0.2), rgba(251, 188, 5, 0.2), rgba(234, 67, 53, 0.2));
    color: #4285f4;
}

.advice-btn .nav-icon {
    background: linear-gradient(45deg, #4285f4, #34a853, #fbbc05, #ea4335);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
}

.reset-btn:hover, .reset-btn:active {
    background-color: rgba(244, 67, 54, 0.2);
    color: var(--accent-red);
}

.reset-btn .nav-icon {
    color: var(--accent-red);
}

.earnings-btn:hover, .earnings-btn:active {
    background-color: rgba(255, 199, 0, 0.2);
    color: var(--accent-yellow);
}

.earnings-btn .nav-icon {
    color: var(--accent-yellow);
}

.exit-btn:hover, .exit-btn:active {
    background-color: rgba(156, 39, 176, 0.2);
    color: #9C27B0;
}

.exit-btn .nav-icon {
    color: #9C27B0;
}

/* Enhanced responsiveness for 4 buttons */
@media (max-width: 360px) {
    .nav-label {
        font-size: 0.6rem;
    }
    
    .nav-icon {
        font-size: 1.3rem;
    }
    
    .nav-button {
        padding: 6px 8px;
        min-height: 50px;
        max-width: 85px;
    }
}

/* Tablet and larger screens */
@media (min-width: 768px) {
    .bottom-nav {
        padding: 12px 15px;
        gap: 12px;
    }
    
    .nav-button {
        padding: 12px 16px;
        min-height: 65px;
        max-width: 120px;
    }
    
    .nav-icon {
        font-size: 1.7rem;
        margin-bottom: 5px;
    }
    
    .nav-label {
        font-size: 0.8rem;
    }
}

/* Desktop hover effects */
@media (min-width: 1024px) {
    .nav-button:hover {
        transform: translateY(-3px);
        box-shadow: 0 4px 12px rgba(0,0,0,0.2);
    }
}

/* Ultra-wide mobile screens */
@media (max-width: 320px) {
    .bottom-nav {
        gap: 2px;
        padding: 6px 8px;
    }
    
    .nav-button {
        max-width: 60px;
        min-height: 48px;
    }
    
    .nav-label {
        font-size: 0.5rem;
    }
    
    .nav-icon {
        font-size: 1.1rem;
    }
}

/* MODALS */
.modal-overlay, .modal-content, .modal-button, .modal-close-button {
    display: none !important;
}

/* Floating Coin Animation */
.coin-animation {
    position: absolute;
    color: var(--accent-yellow);
    font-weight: bold;
    font-size: 1.2rem;
    animation: floatUp 1s ease-out forwards;
    pointer-events: none;
    z-index: 999;
    text-shadow: 0 0 5px black;
}

@keyframes floatUp {
    from {
        opacity: 1;
        transform: translateY(0);
    }
    to {
        opacity: 0;
        transform: translateY(-60px);
    }
}

.event-indicator {
    font-size: 0.75rem;
    font-weight: bold;
    padding: 4px 8px;
    border-radius: 12px;
    margin: 4px 0;
    text-align: center;
    animation: pulse 1.5s infinite;
}

.event-positive {
    background-color: #22c55e;
    color: white;
}

.event-negative {
    background-color: #ef4444;
    color: white;
}

@keyframes pulse {
    0%, 100% { opacity: 1; }
    50% { opacity: 0.7; }
}

@keyframes pulse-glow {
    0%, 100% { 
        box-shadow: 0 0 5px rgba(255, 199, 0, 0.3);
        border-left-color: var(--accent-yellow);
    }
    50% { 
        box-shadow: 0 0 20px rgba(255, 199, 0, 0.6);
        border-left-color: #FFD700;
    }
}

@keyframes gradientShift {
    0% { background-position: 0% 50%; }
    50% { background-position: 100% 50%; }
    100% { background-position: 0% 50%; }
}

.buy-button.disabled {
    opacity: 0.6;
    cursor: not-allowed;
    transform: none !important;
}

.buy-button {
    transition: all 0.2s ease;
}

.buy-button:not(.disabled):hover {
    transform: translateY(-1px);
    box-shadow: 0 4px 12px rgba(0,0,0,0.3);
}

/* WELCOME SCREEN */
.welcome-screen {
    z-index: 10001 !important;
    position: fixed;
    top: 0;
    left: 0;
    width: 100vw;
    min-height: 100vh;
    background: linear-gradient(135deg, #1a1a1a 0%, #2a2a2a 100%);
    display: flex;
    justify-content: center;
    align-items: flex-start;
    z-index: 9999;
    padding: 20px;
    overflow-y: auto;
    overflow-x: auto;
    padding-bottom: 40px;
    -webkit-overflow-scrolling: touch;
    scrollbar-width: none; /* Firefox */
}
.welcome-screen::-webkit-scrollbar {
    display: none; /* Chrome/Safari */
}
body.show-welcome #frame {
    display: none !important;
}
.welcome-content {
    text-align: center;
    max-width: 480px;
    width: 100%;
    background: var(--secondary-bg);
    border-radius: 20px;
    padding: 40px 30px;
    border: 3px solid var(--accent-yellow);
    box-shadow: 0 10px 40px rgba(0,0,0,0.5);
    overflow-x: auto;
    scrollbar-width: none;
    min-width: 0;
    overflow-x: hidden;
}
.welcome-content::-webkit-scrollbar {
    display: none;
}

.logo-section {
    margin-bottom: 30px;
}

.game-title {
    font-size: 3rem;
    font-weight: 700;
    color: var(--accent-yellow);
    margin: 0;
    text-shadow: 2px 2px 4px rgba(0,0,0,0.5);
}

.game-subtitle {
    font-size: 1.2rem;
    color: var(--text-secondary);
    margin: 10px 0 0 0;
    font-weight: 400;
}

.welcome-description {
    margin: 30px 0;
}

.welcome-description p {
    font-size: 1.1rem;
    color: var(--text-primary);
    margin-bottom: 20px;
    line-height: 1.5;
}

.features {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 15px;
    margin: 20px 0;
    flex-wrap: nowrap;
    min-width: 0;
}

.feature {
    background: var(--card-bg);
    padding: 15px;
    border-radius: 10px;
    font-size: 0.9rem;
    font-weight: 600;
    color: var(--text-primary);
    border-left: 3px solid var(--accent-yellow);
    min-width: 120px;
    font-size: 0.85rem;
}

.welcome-actions {
    display: flex;
    flex-direction: column;
    gap: 15px;
    margin-top: 30px;
    margin-bottom: 20px;
}

.start-button, .load-button {
    padding: 15px 30px;
    font-size: 1.2rem;
    font-weight: 600;
    border: none;
    border-radius: 10px;
    cursor: pointer;
    transition: all 0.2s ease;
    width: 100%;
}

.start-button {
    background: var(--accent-yellow);
    color: var(--primary-bg);
}

.start-button:hover {
    background: #e6b400;
    transform: translateY(-2px);
}

.load-button {
    background: var(--accent-green);
    color: white;
}

.load-button:hover {
    background: #45a049;
    transform: translateY(-2px);
}

/* Add emoji styling */
.hustle-emoji {
    font-size: 2rem;
}

/* Info button styling */
.info-button {
    background-color: var(--accent-yellow) !important;
    color: var(--primary-bg) !important;
    font-size: 0.8rem !important;
    padding: 5px 10px !important;
    margin-bottom: 5px !important;
}

/* Responsive design for welcome screen */
@media (max-width: 480px) {
    html, body {
        max-width: 100vw;
        overflow-x: hidden;
        font-size: 15px;
    }
    .game-container, .welcome-content {
        max-width: 100vw;
        width: 100vw;
        box-sizing: border-box;
        margin: 0 !important;
    }
    .welcome-content {
        min-width: 0;
        overflow-x: hidden;
    }
    .features {
        flex-wrap: nowrap;
        min-width: 0;
    }
    .feature {
        min-width: 120px;
        font-size: 0.85rem;
    }
    .bottom-nav {
        min-width: 0;
        width: 100vw;
        left: 0;
        right: 0;
        box-sizing: border-box;
    }
    #frame {
        width: 100vw !important;
        min-width: 0;
        left: 0;
        right: 0;
    }
    .hustle-card {
        min-width: 0;
        word-break: break-word;
    }
    .hustle-details {
        min-width: 0;
    }
    .welcome-content {
        padding: 25px 20px;
        margin: 10px 0;
    }
    
    .game-title {
        font-size: 2.2rem;
    }
    
    .features {
        display: flex;
        flex-direction: row;
        gap: 10px;
        overflow-x: auto;
        padding-bottom: 10px;
        width: 100%;
        min-width: 320px;
        scrollbar-width: none;
    }
    .features::-webkit-scrollbar {
        display: none;
    }
    .feature {
        min-width: 130px;
        padding: 12px;
        font-size: 0.8rem;
    }

    .modal-content {
        width: 95%;
        padding: 20px 15px;
    }
    
    .welcome-content {
        padding: 25px 20px;
    }
    
    .game-title {
        font-size: 2.2rem;
    }
    
    .hustle-grid {
        padding: 12px;
        gap: 12px;
    }
    
    .hustle-card {
        padding: 14px;
    }
}

/* Prevent horizontal scroll on all screens */
body, html {
    overflow-x: hidden !important;
    max-width: 100vw;
}

/* Responsive text sizing */
@media (max-width: 380px) {
    .hustle-name {
        font-size: 1rem;
    }
    
    .stat-value {
        font-size: 1.1rem;
    }
    
    .action-button {
        font-size: 0.9rem;
        padding: 8px 12px;
    }
}

/* Tablet adjustments */
@media (min-width: 481px) and (max-width: 767px) {
    .game-container {
        max-width: 90%;
        height: 95vh;
        border-radius: 15px;
    }
}

/* Improved touch targets for mobile */
@media (max-width: 767px) {
    .action-button {
        min-height: 44px; /* Apple's recommended touch target size */
        font-size: 0.9rem;
        padding: 12px 16px;
    }
    
    .nav-button {
        min-height: 44px;
        padding: 12px 16px;
    }
    
    .hustle-card {
        padding: 16px;
        margin-bottom: 2px;
    }
    
    .hustle-icon {
        width: 55px;
        height: 55px;
    }
    
    .hustle-emoji {
        font-size: 1.8rem;
    }
    
    .game-container {
        padding-bottom: 140px; /* More space for mobile */
    }
    
    .bottom-nav {
        bottom: 45px; /* Adjust for mobile ad height */
        padding: 8px 6px;
        min-height: 56px;
    }
    
    .nav-label {
        font-size: 0.75rem;
    }
    
    .nav-icon {
        font-size: 1.2rem;
    }
    
    .bottom-nav {
        font-size: 0.9rem;
        min-height: 54px;
    }
    
    .nav-label {
        font-size: 0.8rem;
    }
}

/* Desktop responsive adjustments */
@media (min-width: 768px) {
    body {
        align-items: center;
        justify-content: center;
        padding: 20px;
    }
    
    .game-container {
        height: 90vh;
        max-height: 800px;
        border-radius: 20px;
        overflow: hidden;
    }
    
    .welcome-content {
        max-width: 600px;
    }
    
    .hustle-grid {
        padding: 20px;
        gap: 20px;
    }
}

/* Landscape mobile optimization */
@media (max-height: 500px) and (orientation: landscape) {
    .top-bar {
        padding: 8px 15px;
    }
    
    .bottom-nav {
        padding: 6px 15px;
    }
    
    .nav-button {
        min-height: 50px;
    }
    
    .nav-icon {
        font-size: 1.2rem;
        margin-bottom: 2px;
    }
    
    .nav-label {
        font-size: 0.6rem;
    }
}

/* Unlock requirement styling */
.unlock-requirement {
    font-size: 0.8rem;
    margin-top: 2px;
    font-style: italic;
}

/* Better scrolling for mobile */
.hustle-grid::-webkit-scrollbar {
    width: 4px;
}

.hustle-grid::-webkit-scrollbar-track {
    background: transparent;
}

.hustle-grid::-webkit-scrollbar-thumb {
    background: var(--accent-yellow);
    border-radius: 2px;
}

.hustle-grid::-webkit-scrollbar-thumb:hover {
    background: #e6b400;
}

/* --- Responsive adjustments for mobile --- */
@media (max-width: 600px) {
    .game-container {
        padding-bottom: 140px; /* More space for mobile */
    }
    .bottom-nav {
        bottom: 45px; /* Adjust for mobile ad height */
        padding: 8px 6px;
        min-height: 56px;
    }
    .nav-label {
        font-size: 0.75rem;
    }
    .nav-icon {
        font-size: 1.2rem;
    }
}

/* --- Responsive adjustments for very small screens --- */
@media (max-width: 400px) {
    .nav-label {
        font-size: 0.7rem;
    }
    .nav-icon {
        font-size: 1.1rem;
    }
    .nav-button {
        min-height: 48px;
        max-width: 80px;
    }
}

/* Touch targets for mobile */
@media (max-width: 767px) {
    .start-button, .load-button {
        min-height: 48px;
        padding: 15px 20px;
    }
}