/* Mobile-Specific Styles - Cozy Garden Game */
/* This file contains mobile-only overrides via media queries */
/* Desktop styles remain completely untouched */

/* ===========================================
   MOBILE BREAKPOINTS
   - Small phones: max-width 480px
   - Large phones: max-width 768px
   - Tablets: max-width 1024px
   =========================================== */

/* ===========================================
   BASE MOBILE STYLES (max-width: 768px)
   =========================================== */

@media screen and (max-width: 768px) {

    /* ----- GLOBAL MOBILE RESETS ----- */

    body {
        /* Prevent zoom on input focus */
        -webkit-text-size-adjust: 100%;
        /* Enable smooth scrolling on iOS */
        -webkit-overflow-scrolling: touch;
        /* Prevent pull-to-refresh on game screens */
        overscroll-behavior-y: contain;
    }

    /* Hide scrollbars on mobile for cleaner look */
    ::-webkit-scrollbar {
        width: 4px;
        height: 4px;
    }

    ::-webkit-scrollbar-thumb {
        background: rgba(139, 111, 71, 0.4);
    }

    /* ----- HEADER MOBILE LAYOUT - COMPACT ----- */

    .header {
        flex-direction: row;
        flex-wrap: wrap;
        gap: 4px;
        padding: 6px 10px;
        min-height: auto;
        background: linear-gradient(180deg, rgba(255, 255, 255, 0.95) 0%, rgba(255, 255, 255, 0.9) 100%);
        backdrop-filter: blur(10px);
        align-items: center;
        justify-content: space-between;
    }

    .header>div:first-child {
        flex-direction: row;
        gap: 6px;
        align-items: center;
    }

    .title {
        font-size: 14px;
        text-align: left;
    }

    .resources {
        justify-content: center;
        gap: 4px;
        flex-wrap: nowrap;
    }

    .resource {
        padding: 2px 6px;
        font-size: 11px;
        border-radius: 10px;
        border-width: 2px;
    }

    .coin-icon {
        width: 14px;
        height: 14px;
        border-width: 2px;
    }

    .coin-icon::after {
        font-size: 8px;
    }

    .season-icon {
        font-size: 14px;
    }

    /* Level display compact on mobile */
    .level-display {
        padding: 2px 6px;
        gap: 4px;
    }

    .level-badge {
        padding-right: 4px;
    }

    .level-icon {
        font-size: 14px;
    }

    .level-number {
        font-size: 12px;
    }

    .xp-bar-container {
        width: 60px;
        height: 12px;
    }

    .xp-text {
        font-size: 7px;
    }

    /* Header buttons - hide reset on mobile header */
    .header>div:last-child {
        display: none;
    }

    .nav-button {
        padding: 4px 8px;
        font-size: 10px;
        border-radius: 6px;
    }

    .reset-btn {
        display: none !important;
    }

    /* ----- GAME CONTAINER MOBILE - SWIPEABLE GARDENS ----- */

    .game-container {
        padding: 0;
        width: 100%;
        flex: 1;
        display: flex;
        flex-direction: column;
        overflow: hidden;
        position: relative;
    }

    /* Gardens slider - horizontal swipe */
    .gardens-slider {
        display: flex;
        flex-direction: row;
        width: 100%;
        height: 100%;
        transition: transform 0.3s cubic-bezier(0.4, 0, 0.2, 1);
        touch-action: pan-x;
        transform: translateX(0);
    }

    .gardens-slider.show-fruits {
        transform: translateX(-100%);
    }

    /* Each garden view takes full container width */
    .garden-view {
        min-width: 100%;
        width: 100%;
        flex-shrink: 0;
        height: 100%;
        display: flex;
        flex-direction: column;
        align-items: center;
        justify-content: center;
        padding: 15px;
        position: relative;
        box-sizing: border-box;
    }

    /* Hide arrow buttons on mobile - use swipe instead */
    .garden-nav-arrow {
        display: none !important;
    }

    /* Garden wrapper - smaller on mobile */
    .garden-wrapper,
    .fruit-wrapper {
        padding: 10px;
        border-radius: 12px;
        border-width: 3px;
        width: 95%;
        max-width: 350px;
        background: rgba(139, 111, 71, 0.5);
        overflow: hidden;
    }

    .garden-panel {
        padding: 10px;
        width: 95%;
        max-width: 350px;
    }

    .garden-card-title {
        font-size: 15px;
    }

    .garden-card-subtitle {
        font-size: 10px;
    }

    .garden-card-header .garden-switch {
        display: none; /* mobile uses the garden-dot indicators instead */
    }

    /* Mobile garden grid - 6x4 with horizontal scroll */
    .garden-grid {
        grid-template-columns: repeat(6, 55px) !important;
        grid-template-rows: repeat(4, 55px) !important;
        gap: 4px;
        padding: 8px;
        overflow-x: auto;
        overflow-y: hidden;
        -webkit-overflow-scrolling: touch;
        scroll-behavior: smooth;
        /* Scroll snap for better UX */
        scroll-snap-type: x proximity;
    }

    /* Subtle horizontal scrollbar */
    .garden-grid::-webkit-scrollbar {
        height: 6px;
    }

    .garden-grid::-webkit-scrollbar-track {
        background: rgba(255, 255, 255, 0.2);
        border-radius: 3px;
    }

    .garden-grid::-webkit-scrollbar-thumb {
        background: rgba(139, 111, 71, 0.5);
        border-radius: 3px;
    }

    .tile {
        width: 55px;
        height: 55px;
        flex-shrink: 0;
        font-size: 24px;
        border-width: 2px;
        border-radius: 8px;
        scroll-snap-align: start;
    }

    /* Fruit grid */
    .fruit-grid {
        gap: 10px;
    }

    .fruit-cell {
        width: 65px;
        height: 65px;
        border-width: 2px;
        border-radius: 12px;
        font-size: 30px;
    }

    /* Garden indicator dots - compact */
    .garden-indicators {
        display: flex !important;
        justify-content: center;
        gap: 8px;
        padding: 6px 0;
        background: rgba(255, 255, 255, 0.1);
    }

    .garden-dot {
        width: 10px;
        height: 10px;
        border-radius: 50%;
        background: rgba(255, 255, 255, 0.4);
        border: 2px solid rgba(255, 255, 255, 0.6);
        cursor: pointer;
        transition: all 0.3s;
    }

    .garden-dot.active {
        background: var(--season-primary, #7CB342);
        border-color: white;
        transform: scale(1.15);
        box-shadow: 0 0 8px var(--season-primary, #7CB342);
    }

    .garden-dot-label {
        display: none;
    }

    /* Swipe hint on first load */
    .swipe-hint {
        position: absolute;
        bottom: 20px;
        left: 50%;
        transform: translateX(-50%);
        display: flex;
        align-items: center;
        gap: 8px;
        background: rgba(0, 0, 0, 0.7);
        color: white;
        padding: 8px 16px;
        border-radius: 20px;
        font-size: 12px;
        animation: swipeHintPulse 2s ease-in-out infinite;
    }

    .swipe-hint.hidden {
        display: none;
    }

    @keyframes swipeHintPulse {
        0%, 100% { opacity: 0.8; transform: translateX(-50%) scale(1); }
        50% { opacity: 1; transform: translateX(-50%) scale(1.05); }
    }

    /* ----- BOTTOM BAR MOBILE ----- */
    /* Desktop bottom bar is completely hidden in mobile mode - see body.mobile-mode rules below */

    .tools-bar {
        width: 100%;
        flex-direction: column;
        gap: 8px;
    }

    .tool-section {
        display: flex;
        justify-content: center;
        gap: 8px;
        width: 100%;
    }

    .tool-button {
        padding: 12px 14px;
        /* Increased padding */
        min-width: 64px;
        /* Increased min-width */
        border-radius: 12px;
        /* Touch-friendly size - min 44px height */
        min-height: 60px;
        justify-content: center;
    }

    .tool-icon {
        font-size: 24px;
    }

    .tool-name {
        font-size: 9px;
    }

    /* Seed selector - horizontal scroll on mobile */
    .seed-selector-container {
        width: 100%;
        height: 70px;
        padding: 0 40px;
        border-left: none;
        border-top: 2px solid var(--dark-brown);
        margin-top: 5px;
        padding-top: 5px;
    }

    .seeds-slider {
        flex-direction: row;
        gap: 0;
        overflow-x: auto;
        overflow-y: hidden;
        scroll-snap-type: x mandatory;
        -webkit-overflow-scrolling: touch;
    }

    .seeds-slider.show-fruits {
        transform: translateY(0);
    }

    .seed-section {
        flex-direction: row;
        height: 60px;
        min-height: auto;
        min-width: 100%;
        scroll-snap-align: start;
        justify-content: center;
        padding: 0 10px;
    }

    .seed-button {
        min-width: 54px;
        /* Increased width */
        min-height: 64px;
        /* Increased height */
        padding: 6px;
        gap: 4px;
        border-radius: 10px;
        justify-content: center;
    }

    .seed-packet {
        width: 24px;
        height: 28px;
    }

    .seed-count {
        font-size: 10px;
    }

    .seed-name {
        font-size: 8px;
    }

    /* Seed nav arrows - reposition for horizontal scroll */
    .seed-nav-arrow {
        width: 36px;
        height: 36px;
        font-size: 14px;
        top: 50%;
    }

    .seed-nav-arrow.down-arrow {
        right: 5px;
        transform: translateY(-50%) rotate(-90deg);
    }

    .seed-nav-arrow.up-arrow {
        left: 5px;
        transform: translateY(-50%) rotate(-90deg);
    }

    /* Navigation buttons - horizontal row */
    .nav-buttons {
        display: flex;
        width: 100%;
        gap: 8px;
        justify-content: center;
        margin-top: 5px;
    }

    .shop-btn,
    .upgrade-btn,
    .market-btn {
        flex: 1;
        max-width: none;
        /* Allow full width */
        padding: 12px 16px !important;
        /* Larger touch target */
        font-size: 13px !important;
        justify-content: center;
        height: 48px;
        /* Min touch height */
        align-items: center;
    }

    .shop-btn .btn-icon,
    .upgrade-btn .btn-icon,
    .market-btn .btn-icon {
        gap: 8px;
    }

    .shop-tab {
        padding: 10px 15px;
        font-size: 14px;
    }

    .shop-tab .tab-icon {
        font-size: 16px;
    }

    /* ----- SHOP CONTENT MOBILE ----- */

    .shop-content,
    .upgrades-content {
        padding: 15px;
    }

    .shop-tab-content {
        padding: 15px;
    }

    .player-money {
        padding: 12px;
        font-size: 24px;
        margin-bottom: 15px;
    }

    .player-money .coin-icon {
        width: 22px;
        height: 22px;
    }

    /* Shop items grid - single column on mobile */
    .shop-items {
        grid-template-columns: 1fr;
        gap: 16px;
        /* Increased gap */
        padding-bottom: 80px;
        /* Space for bottom nav */
    }

    .shop-item {
        padding: 12px;
        gap: 8px;
        border-width: 3px;
        border-radius: 12px;
    }

    .shop-item::before {
        font-size: 50px;
    }

    .shop-item-icon {
        height: 70px;
        font-size: 48px;
    }

    .shop-item-header h3 {
        font-size: 16px;
    }

    .shop-item-details {
        padding: 8px;
    }

    .shop-item-details p {
        font-size: 12px;
        margin-bottom: 6px;
    }

    .stats {
        gap: 6px;
    }

    .stat {
        padding: 4px 6px;
        font-size: 11px;
        gap: 3px;
    }

    .shop-item-footer {
        gap: 8px;
        flex-direction: column;
    }

    .price {
        padding: 6px 12px;
        font-size: 16px;
        width: 100%;
        justify-content: center;
    }

    .buy-button {
        padding: 10px 16px;
        font-size: 14px;
        width: 100%;
    }

    .level-requirement {
        top: 8px;
        left: 8px;
        padding: 4px 8px;
        font-size: 12px;
    }

    /* ----- MARKET CONTENT MOBILE ----- */

    .new-market-content {
        gap: 15px;
        padding: 8px;
    }

    .product-selection-area,
    .sell-cart-area {
        padding: 15px;
        border-radius: 12px;
    }

    .product-selection-area h3,
    .sell-cart-area h3 {
        font-size: 18px;
        margin-bottom: 12px;
    }

    .selection-hint {
        font-size: 12px;
    }

    /* Product grid - 2 columns on mobile */
    .product-grid {
        grid-template-columns: repeat(2, 1fr);
        gap: 10px;
    }

    .product-card {
        padding: 12px;
        border-radius: 10px;
        gap: 6px;
    }

    .product-card::before {
        font-size: 30px;
    }

    .product-icon {
        font-size: 36px;
    }

    .product-name {
        font-size: 14px;
    }

    .product-stock {
        font-size: 11px;
    }

    .product-price {
        font-size: 12px;
    }

    .product-select-overlay {
        width: 28px;
        height: 28px;
    }

    .product-select-overlay .checkmark {
        font-size: 16px;
    }

    /* Cart items mobile */
    .sell-cart {
        min-height: 120px;
    }

    .cart-item {
        grid-template-columns: 50px 1fr;
        gap: 10px;
        padding: 12px;
    }

    .cart-item-icon {
        font-size: 36px;
    }

    .cart-item-name {
        font-size: 15px;
    }

    .cart-item-price {
        font-size: 11px;
    }

    .cart-item-quantity {
        grid-column: 1 / -1;
        justify-content: center;
    }

    .qty-btn {
        width: 36px;
        height: 36px;
        font-size: 20px;
    }

    .qty-input {
        width: 50px;
        height: 36px;
        font-size: 14px;
    }

    .cart-item-total {
        grid-column: 1 / -1;
        justify-content: center;
        font-size: 16px;
    }

    .cart-remove-btn {
        width: 32px;
        height: 32px;
        font-size: 18px;
    }

    /* Sell summary mobile */
    .sell-summary {
        flex-direction: column;
        gap: 12px;
        padding-top: 15px;
    }

    .total-display {
        font-size: 24px;
        justify-content: center;
    }

    .sell-all-button {
        width: 100%;
        padding: 14px 20px;
        font-size: 16px;
    }

    /* ----- UPGRADES SCREEN MOBILE ----- */

    .upgrades-list {
        grid-template-columns: 1fr;
        gap: 12px;
    }

    .upgrade-item {
        padding: 15px;
        gap: 10px;
    }

    .upgrade-item::before {
        font-size: 50px;
    }

    .upgrade-icon-large {
        font-size: 50px;
    }

    .upgrade-info h3 {
        font-size: 16px;
        margin-bottom: 6px;
    }

    .upgrade-info p {
        font-size: 12px;
    }

    .upgrade-footer {
        flex-direction: column;
        gap: 10px;
    }

    .upgrade-button {
        width: 100%;
        padding: 10px 16px;
        font-size: 14px;
    }

    .owned-badge {
        width: 100%;
        padding: 10px;
        font-size: 14px;
    }

    /* ----- MODALS MOBILE ----- */

    .modal-content {
        width: 95%;
        max-width: none;
        margin: 10px;
        max-height: 90vh;
    }

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

    .modal-header h2 {
        font-size: 20px;
    }

    .modal-close {
        width: 32px;
        height: 32px;
        font-size: 18px;
    }

    .modal-body {
        padding: 15px;
    }

    .modal-footer {
        padding: 12px 16px;
        flex-direction: column;
        gap: 8px;
    }

    .modal-button {
        width: 100%;
        padding: 12px 16px;
        font-size: 14px;
    }

    /* Harvest modal mobile */
    .harvest-list {
        gap: 10px;
    }

    .harvest-item {
        padding: 10px 12px;
        gap: 10px;
        flex-wrap: wrap;
    }

    .harvest-item-icon {
        font-size: 32px;
        width: 50px;
        height: 50px;
    }

    .harvest-item-info {
        flex: 1;
        min-width: 120px;
    }

    .harvest-item-name {
        font-size: 15px;
    }

    .harvest-item-details {
        font-size: 12px;
        gap: 10px;
    }

    .harvest-item-total {
        font-size: 16px;
        width: 100%;
        justify-content: flex-end;
    }

    .harvest-total {
        padding: 12px 15px;
    }

    .total-label {
        font-size: 16px;
    }

    .total-value {
        font-size: 22px;
    }

    /* ----- TOAST NOTIFICATIONS MOBILE ----- */

    #toast-container {
        top: 10px;
        width: calc(100% - 20px);
        max-width: 360px;
    }

    .toast {
        min-width: auto;
        max-width: none;
        width: 100%;
        padding: 12px 16px;
    }

    .toast-icon {
        font-size: 24px;
    }

    .toast-title {
        font-size: 14px;
    }

    .toast-message {
        font-size: 12px;
    }

    /* Season change toast mobile */
    .season-change-toast {
        min-width: auto;
        padding: 15px;
    }

    .season-change-toast .toast-icon.season-transition {
        gap: 8px;
        font-size: 32px;
        margin-right: 12px;
    }

    .season-change-toast .season-arrow {
        font-size: 20px;
    }

    .season-change-toast .toast-title {
        font-size: 16px;
    }

    .season-change-toast .toast-message {
        font-size: 13px;
    }

    /* ----- WELCOME SCREEN MOBILE ----- */

    .welcome-content {
        padding: 20px 15px;
    }

    .welcome-title {
        font-size: 28px;
        margin-bottom: 8px;
    }

    .welcome-subtitle {
        font-size: 16px;
        margin-bottom: 25px;
    }

    .welcome-features {
        grid-template-columns: repeat(2, 1fr);
        gap: 10px;
        margin-bottom: 25px;
    }

    .feature-item {
        padding: 12px 8px;
        border-radius: 12px;
    }

    .feature-icon {
        font-size: 32px;
    }

    .feature-text {
        font-size: 11px;
    }

    .welcome-button {
        padding: 16px 30px;
        font-size: 20px;
        gap: 12px;
        margin-bottom: 15px;
        border-radius: 16px;
    }

    .button-icon {
        font-size: 24px;
    }

    .welcome-hint {
        font-size: 12px;
    }

    /* ----- PLANT INFO POPUP MOBILE ----- */

    .plant-info-popup {
        min-width: 240px;
        max-width: 280px;
    }

    .plant-info-header {
        padding: 10px 14px;
        gap: 8px;
    }

    .plant-info-header .plant-icon {
        font-size: 28px;
    }

    .plant-info-header .plant-name {
        font-size: 16px;
    }

    .plant-info-close {
        width: 28px;
        height: 28px;
        font-size: 16px;
    }

    .plant-info-body {
        padding: 12px;
        gap: 10px;
    }

    .info-row {
        padding: 8px;
    }

    .info-label {
        font-size: 10px;
    }

    .info-value {
        font-size: 14px;
    }

    .info-value.live-timer {
        font-size: 16px;
    }

    /* ----- SEASON ANNOUNCEMENT MOBILE ----- */

    .season-transition {
        padding: 25px 30px;
        gap: 20px;
        border-radius: 20px;
    }

    .season-icon-large {
        font-size: 50px;
    }

    .season-name {
        font-size: 18px;
    }

    .season-arrow {
        font-size: 36px;
    }

    /* ----- FRUIT GRID MOBILE ----- */

    .fruit-grid {
        gap: 10px;
    }

    .fruit-cell {
        border-width: 2px;
        border-radius: 8px;
    }
}

/* ===========================================
   SMALL PHONES (max-width: 480px)
   =========================================== */

@media screen and (max-width: 480px) {

    /* Even more compact header */
    .header {
        padding: 8px 10px;
    }

    .title {
        font-size: 18px;
    }

    .resources {
        gap: 6px;
    }

    .resource {
        padding: 3px 6px;
        font-size: 11px;
    }

    /* Smaller garden grid for small screens */
    .garden-grid {
        gap: 3px;
        padding: 6px;
    }

    .tile {
        font-size: 20px;
        border-radius: 6px;
    }

    /* Smaller tools */
    .tool-button {
        padding: 6px 10px;
        min-width: 50px;
    }

    .tool-icon {
        font-size: 20px;
    }

    .tool-name {
        font-size: 8px;
    }

    /* Even smaller seeds */
    .seed-button {
        min-width: 42px;
        padding: 3px;
    }

    .seed-packet {
        width: 20px;
        height: 24px;
    }

    .seed-count {
        font-size: 9px;
    }

    .seed-name {
        font-size: 7px;
    }

    /* Smaller shop items */
    .shop-item {
        padding: 10px;
    }

    .shop-item-icon {
        height: 60px;
        font-size: 40px;
    }

    .shop-item-header h3 {
        font-size: 14px;
    }

    .price {
        font-size: 14px;
        padding: 5px 10px;
    }

    .buy-button {
        padding: 8px 12px;
        font-size: 13px;
    }

    /* Smaller product cards */
    .product-grid {
        gap: 8px;
    }

    .product-card {
        padding: 10px;
    }

    .product-icon {
        font-size: 30px;
    }

    .product-name {
        font-size: 12px;
    }

    /* Smaller upgrades */
    .upgrade-item {
        padding: 12px;
    }

    .upgrade-icon-large {
        font-size: 40px;
    }

    .upgrade-info h3 {
        font-size: 14px;
    }

    .upgrade-info p {
        font-size: 11px;
    }

    /* Smaller welcome screen */
    .welcome-title {
        font-size: 24px;
    }

    .welcome-subtitle {
        font-size: 14px;
    }

    .welcome-features {
        grid-template-columns: repeat(2, 1fr);
        gap: 8px;
    }

    .feature-item {
        padding: 10px 6px;
    }

    .feature-icon {
        font-size: 28px;
    }

    .feature-text {
        font-size: 10px;
    }

    .welcome-button {
        padding: 14px 24px;
        font-size: 18px;
    }

    /* Smaller modals */
    .modal-content {
        margin: 5px;
    }

    .modal-header h2 {
        font-size: 18px;
    }

    .modal-button {
        padding: 10px 14px;
        font-size: 13px;
    }
}

/* ===========================================
   LANDSCAPE MOBILE OPTIMIZATION
   =========================================== */

@media screen and (max-height: 500px) and (orientation: landscape) {

    /* Ultra-compact header in landscape */
    .header {
        padding: 5px 10px;
        flex-direction: row;
        flex-wrap: wrap;
    }

    .header>div:first-child {
        flex-direction: row;
        gap: 15px;
    }

    .title {
        font-size: 16px;
    }

    .resources {
        flex-wrap: nowrap;
    }

    /* Smaller garden for landscape */
    .game-container {
        padding: 4px;
    }

    .garden-wrapper,
    .fruit-wrapper {
        padding: 6px;
    }

    .garden-grid {
        gap: 2px;
        padding: 4px;
    }

    .tile {
        font-size: 18px;
    }

    /* Compact bottom bar in landscape */
    .bottom-bar {
        flex-direction: row;
        padding: 6px 10px;
        min-height: auto;
    }

    .tools-bar {
        flex-direction: row;
        width: auto;
    }

    .seed-selector-container {
        height: 50px;
        border-top: none;
        border-left: 2px solid var(--dark-brown);
        margin-top: 0;
        padding-top: 0;
    }

    .seed-section {
        height: 50px;
    }

    .nav-buttons {
        width: auto;
        margin-top: 0;
    }

    /* Hide welcome features in landscape */
    .welcome-features {
        display: none;
    }

    .welcome-content {
        padding: 10px;
    }

    .welcome-title {
        font-size: 22px;
        margin-bottom: 5px;
    }

    .welcome-subtitle {
        margin-bottom: 15px;
    }

    .welcome-button {
        padding: 10px 20px;
        font-size: 16px;
    }
}

/* ===========================================
   TOUCH-FRIENDLY ENHANCEMENTS
   =========================================== */

@media (hover: none) and (pointer: coarse) {

    /* Increase touch targets to minimum 44px */
    .tool-button,
    .seed-button,
    .nav-button,
    .back-button,
    .buy-button,
    .upgrade-button,
    .sell-all-button,
    .modal-button,
    .modal-close,
    .plant-info-close,
    .qty-btn,
    .cart-remove-btn,
    .garden-nav-arrow,
    .seed-nav-arrow,
    .shop-tab {
        min-height: 44px;
        min-width: 44px;
    }

    /* Larger hit areas for tiles */
    .tile {
        /* Already responsive, but ensure minimum touch size */
        min-width: 44px;
        min-height: 44px;
    }

    /* Disable hover effects on touch devices */
    .tile:hover,
    .shop-item:hover,
    .upgrade-item:hover,
    .product-card:hover,
    .cart-item:hover,
    .harvest-item:hover,
    .nav-button:hover,
    .tool-button:hover,
    .seed-button:hover,
    .buy-button:hover,
    .upgrade-button:hover,
    .sell-all-button:hover,
    .modal-button:hover {
        transform: none;
    }

    /* Active state for touch feedback */
    .tile:active,
    .shop-item:active,
    .product-card:active,
    .nav-button:active,
    .tool-button:active,
    .seed-button:active,
    .buy-button:active,
    .upgrade-button:active,
    .sell-all-button:active,
    .modal-button:active {
        transform: scale(0.95);
        transition: transform 0.1s;
    }

    /* Larger product cards for touch */
    .product-card {
        padding: 15px;
    }

    /* Prevent text selection on interactive elements */
    button,
    .tile,
    .product-card,
    .shop-item,
    .upgrade-item,
    .cart-item {
        -webkit-user-select: none;
        user-select: none;
        -webkit-tap-highlight-color: transparent;
    }
}

/* ===========================================
   SAFE AREA INSETS (for notched phones)
   =========================================== */

@supports (padding: env(safe-area-inset-top)) {

    .header {
        padding-top: max(15px, env(safe-area-inset-top));
        padding-left: max(15px, env(safe-area-inset-left));
        padding-right: max(15px, env(safe-area-inset-right));
    }

    .bottom-bar {
        padding-bottom: max(12px, env(safe-area-inset-bottom));
        padding-left: max(10px, env(safe-area-inset-left));
        padding-right: max(10px, env(safe-area-inset-right));
    }

    .screen-header {
        padding-left: max(15px, env(safe-area-inset-left));
        padding-right: max(15px, env(safe-area-inset-right));
    }

    .shop-content,
    .upgrades-content,
    .shop-tab-content {
        padding-left: max(15px, env(safe-area-inset-left));
        padding-right: max(15px, env(safe-area-inset-right));
    }

    .modal-content {
        margin-left: max(10px, env(safe-area-inset-left));
        margin-right: max(10px, env(safe-area-inset-right));
    }

    /* This @supports block isn't actually mobile-only (a feature query, not a screen-size
       query, so it applies on desktop too) - matches main.css's top-center positioning. */
    #toast-container {
        top: max(10px, env(safe-area-inset-top));
    }
}

/* ===========================================
   DARK MODE SUPPORT (future enhancement)
   =========================================== */

@media (prefers-color-scheme: dark) {
    /* Dark mode styles can be added here */
    /* Currently the game has its own theming via seasons */
}

/* ===========================================
   MOBILE UI SYSTEM - Object-First Interaction
   =========================================== */

/* Mobile mode class - applied by JavaScript */
body.mobile-mode {
    /* Ensure proper sizing */
    overflow: hidden;
}

/* Hide desktop bottom bar ONLY in garden screen when in mobile mode */
body.mobile-mode #garden-screen .bottom-bar {
    display: none !important;
}

/* Hide desktop elements in mobile mode */
body.mobile-mode #garden-screen .tools-bar .tool-section,
body.mobile-mode #garden-screen .seed-selector-container,
body.mobile-mode #garden-screen .seed-nav-arrow,
body.mobile-mode #garden-screen .nav-buttons {
    display: none !important;
}

/* Mobile Header */
.mobile-header-title {
    width: 100%;
    text-align: center;
    margin-bottom: 8px;
}

.mobile-header-title h1 {
    font-size: 22px;
    font-weight: 700;
    color: var(--dark-brown);
    margin: 0;
    text-shadow: 2px 2px 4px rgba(0, 0, 0, 0.1);
}

body.mobile-mode .mobile-header-row {
    display: flex;
    justify-content: center;
    align-items: center;
    width: 100%;
    gap: 12px;
}

.mobile-level-display {
    display: flex;
    align-items: center;
    gap: 6px;
    background: rgba(255, 255, 255, 0.9);
    padding: 4px 10px;
    border-radius: 15px;
    border: 2px solid var(--season-border);
}

.mobile-level-display .level-icon {
    font-size: 16px;
}

.mobile-level-display .level-number {
    font-size: 14px;
    font-weight: 700;
}

.mobile-xp-bar {
    width: 50px;
    height: 8px;
    background: #e0e0e0;
    border-radius: 4px;
    overflow: hidden;
}

.mobile-xp-bar .xp-fill {
    height: 100%;
    background: #5DADE2;
    border-radius: 4px;
    transition: width 0.3s ease;
}

.mobile-resources {
    display: flex;
    gap: 8px;
}

.mobile-resource {
    display: flex;
    align-items: center;
    gap: 4px;
    background: rgba(255, 255, 255, 0.9);
    padding: 4px 8px;
    border-radius: 12px;
    border: 2px solid var(--season-border);
    font-size: 13px;
    font-weight: 600;
}

.mobile-header-actions {
    display: flex;
    align-items: center;
    gap: 8px;
}

.mobile-header-actions .season-icon {
    font-size: 20px;
}

.mobile-header-actions .settings-btn {
    background: rgba(255, 255, 255, 0.9);
    border: 2px solid var(--season-border);
    border-radius: 50%;
    width: 36px;
    height: 36px;
    font-size: 18px;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
}

/* Context Menu - Object-First Interaction */
.mobile-context-menu {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    z-index: 5000;
    pointer-events: auto;
}

.mobile-context-menu.hidden {
    display: none;
}

.mobile-context-menu .context-menu-content {
    position: absolute;
    background: rgba(255, 255, 255, 0.98);
    border: 3px solid var(--season-border);
    border-radius: 16px;
    padding: 8px;
    box-shadow: 0 8px 24px rgba(0, 0, 0, 0.3);
    min-width: 120px;
}

.context-actions {
    display: flex;
    gap: 8px;
}

.context-action-btn {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 4px;
    padding: 12px 16px;
    background: linear-gradient(135deg, #f8f8f8 0%, #e8e8e8 100%);
    border: 2px solid var(--season-border);
    border-radius: 12px;
    cursor: pointer;
    transition: all 0.2s;
    min-width: 60px;
}

.context-action-btn:active {
    transform: scale(0.95);
    background: var(--season-accent);
}

.context-action-btn .action-icon {
    font-size: 24px;
}

.context-action-btn .action-label {
    font-size: 11px;
    font-weight: 600;
    color: var(--dark-brown);
}

/* Bottom Sheet */
.mobile-bottom-sheet {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    z-index: 6000;
}

.mobile-bottom-sheet.hidden {
    display: none;
}

.bottom-sheet-backdrop {
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(0, 0, 0, 0.5);
    backdrop-filter: blur(3px);
}

.bottom-sheet-content {
    position: absolute;
    bottom: 0;
    left: 0;
    right: 0;
    background: white;
    border-radius: 20px 20px 0 0;
    max-height: 70vh;
    overflow-y: auto;
    transform: translateY(100%);
    transition: transform 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    -webkit-overflow-scrolling: touch;
}

.bottom-sheet-handle {
    width: 40px;
    height: 4px;
    background: #ccc;
    border-radius: 2px;
    margin: 10px auto;
}

.bottom-sheet-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 15px 20px;
    border-bottom: 2px solid #eee;
}

.bottom-sheet-header h3 {
    font-size: 20px;
    font-weight: 700;
    color: var(--dark-brown);
    margin: 0;
}

.close-sheet-btn {
    background: none;
    border: none;
    font-size: 24px;
    color: #666;
    cursor: pointer;
    padding: 5px;
}

.bottom-sheet-body {
    padding: 20px;
}

/* Seed Grid in Bottom Sheet */
.seed-grid {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 12px;
}

.seed-card {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 8px;
    padding: 15px 10px;
    background: linear-gradient(135deg, rgba(255, 255, 255, 0.98) 0%, var(--season-accent) 100%);
    border: 3px solid var(--season-border);
    border-radius: 12px;
    cursor: pointer;
    transition: all 0.2s;
}

.seed-card:active {
    transform: scale(0.95);
}

.seed-card[disabled] {
    opacity: 0.4;
    cursor: not-allowed;
}

.seed-card-icon {
    font-size: 36px;
}

.seed-card-name {
    font-size: 12px;
    font-weight: 600;
    color: var(--dark-brown);
}

.seed-card-count {
    font-size: 11px;
    font-weight: 700;
    color: var(--season-text);
    background: rgba(255, 255, 255, 0.8);
    padding: 2px 8px;
    border-radius: 8px;
}

/* Floating Action Buttons */
.mobile-floating-buttons {
    position: fixed;
    bottom: 80px;
    /* Above tab bar */
    right: 15px;
    z-index: 4000;
    display: flex;
    flex-direction: column;
    gap: 10px;
}

.fab {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 12px 16px;
    border-radius: 25px;
    border: none;
    cursor: pointer;
    font-family: 'Fredoka', sans-serif;
    font-weight: 600;
    font-size: 14px;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.3);
    transition: all 0.3s;
}

.fab.hidden {
    display: none;
}

.fab:active {
    transform: scale(0.95);
}

.fab span:first-child {
    font-size: 20px;
}

.water-all-fab {
    background: linear-gradient(135deg, #81D4FA 0%, #29B6F6 100%);
    color: white;
}

.harvest-all-fab {
    background: linear-gradient(135deg, #FFD54F 0%, #FFA000 100%);
    color: var(--dark-brown);
}

/* Mobile Tab Bar - Cozy Garden Style - COMPACT */
.mobile-tab-bar {
    position: fixed;
    bottom: 0;
    left: 0;
    right: 0;
    height: 52px;
    background: linear-gradient(180deg, rgba(139, 111, 71, 0.95) 0%, rgba(101, 67, 33, 0.98) 100%);
    border-top: 2px solid var(--season-border);
    display: flex;
    justify-content: space-around;
    align-items: center;
    z-index: 5000;
    padding: 4px 8px;
    padding-bottom: calc(4px + env(safe-area-inset-bottom));
    box-shadow: 0 -2px 10px rgba(0, 0, 0, 0.3);
}

/* Wood grain effect on tab bar */
.mobile-tab-bar::before {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: linear-gradient(90deg,
            transparent 0%,
            rgba(0, 0, 0, 0.05) 25%,
            transparent 50%,
            rgba(0, 0, 0, 0.05) 75%,
            transparent 100%);
    pointer-events: none;
}

.tab-item {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 2px;
    padding: 6px 10px;
    background: none;
    border: none;
    cursor: pointer;
    color: rgba(255, 255, 255, 0.6);
    transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    border-radius: 10px;
    position: relative;
    z-index: 1;
    min-width: 50px;
}

.tab-item:active {
    transform: scale(0.9);
}

.tab-item.active {
    color: var(--season-text);
    background: var(--season-background);
    border: 2px solid var(--season-border);
    box-shadow: 0 2px 8px var(--season-shadow), inset 0 1px 4px rgba(255, 255, 255, 0.3);
    transform: translateY(-2px);
}

/* Active tab indicator glow */
.tab-item.active::before {
    content: '';
    position: absolute;
    top: -2px;
    left: 50%;
    transform: translateX(-50%);
    width: 30px;
    height: 3px;
    background: var(--season-primary);
    border-radius: 0 0 3px 3px;
    box-shadow: 0 2px 8px var(--season-primary);
}

.tab-item .tab-icon {
    font-size: 20px;
    filter: drop-shadow(0 1px 2px rgba(0, 0, 0, 0.2));
    transition: transform 0.3s;
}

.tab-item.active .tab-icon {
    transform: scale(1.05);
    filter: drop-shadow(0 2px 4px var(--season-shadow));
}

.tab-item .tab-label {
    font-size: 9px;
    font-weight: 700;
    text-shadow: 0 1px 2px rgba(0, 0, 0, 0.3);
    font-family: 'Fredoka', sans-serif;
}

/* Inventory in Bottom Sheet */
.inventory-sections {
    display: flex;
    flex-direction: column;
    gap: 20px;
}

.inventory-section h4 {
    font-size: 16px;
    color: var(--dark-brown);
    margin-bottom: 10px;
}

.inventory-grid {
    display: grid;
    grid-template-columns: repeat(4, 1fr);
    gap: 10px;
}

.inventory-item {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 4px;
    padding: 10px 8px;
    background: rgba(255, 255, 255, 0.9);
    border: 2px solid var(--season-border);
    border-radius: 10px;
}

.inventory-item .item-icon {
    font-size: 28px;
}

.inventory-item .item-count {
    font-size: 12px;
    font-weight: 700;
}

.inventory-item .item-price {
    font-size: 10px;
    color: #228B22;
    font-weight: 600;
}

.inventory-actions {
    margin-top: 20px;
    padding-top: 15px;
    border-top: 2px solid #eee;
}

.inventory-actions .sell-all-btn {
    width: 100%;
    padding: 14px;
    background: linear-gradient(135deg, #FFD700 0%, #FFA500 100%);
    border: 3px solid #FF8C00;
    border-radius: 12px;
    font-family: 'Fredoka', sans-serif;
    font-size: 16px;
    font-weight: 700;
    color: var(--dark-brown);
    cursor: pointer;
}

/* Settings in Bottom Sheet */
.settings-list {
    display: flex;
    flex-direction: column;
    gap: 10px;
}

.settings-item {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 15px;
    background: rgba(255, 255, 255, 0.9);
    border: 2px solid #eee;
    border-radius: 12px;
    font-size: 16px;
    font-weight: 600;
    color: var(--dark-brown);
    cursor: pointer;
    text-align: left;
}

.settings-item:active {
    background: #f0f0f0;
}

/* Plant Info in Bottom Sheet */
.plant-info-mobile {
    display: flex;
    align-items: center;
    gap: 20px;
    padding: 10px;
}

.plant-info-mobile .plant-info-icon {
    font-size: 64px;
}

.plant-info-mobile .plant-info-stats {
    flex: 1;
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.plant-info-mobile .stat-row {
    display: flex;
    justify-content: space-between;
    font-size: 14px;
}

.plant-info-mobile .stat-row span:first-child {
    color: #666;
}

.plant-info-mobile .stat-row span:last-child {
    font-weight: 700;
    color: var(--dark-brown);
}

/* Ensure all screens work properly in mobile mode */
body.mobile-mode .screen {
    padding-bottom: 55px;
    /* Space for compact mobile tab bar */
}

body.mobile-mode .screen.active {
    display: flex !important;
}

/* Garden screen specific adjustments */
body.mobile-mode #garden-screen .game-container {
    flex: 1;
    overflow-y: auto;
}

/* ===========================================
   REDUCED MOTION SUPPORT
   =========================================== */

@media (prefers-reduced-motion: reduce) {

    *,
    *::before,
    *::after {
        animation-duration: 0.01ms !important;
        animation-iteration-count: 1 !important;
        transition-duration: 0.01ms !important;
    }

    .tile.needs-water,
    .tile.harvestable,
    .harvest-ready-indicator,
    .water-droplet-indicator,
    .level-icon,
    .season-icon-large,
    .button-icon,
    .live-timer {
        animation: none !important;
    }
}