/**
 * ═══════════════════════════════════════════════════════════════════════════════
 * TSI MOBILE RESPONSIVE CSS v2.0
 * Cross-AI Synthesis: Claude × Grok × Gemini
 * ═══════════════════════════════════════════════════════════════════════════════
 * 
 * Import AFTER tsi-design-system.css:
 *   <link rel="stylesheet" href="/assets/css/tsi-design-system.css">
 *   <link rel="stylesheet" href="/assets/css/tsi-mobile-responsive.css">
 * 
 * ═══════════════════════════════════════════════════════════════════════════════
 */

/* ═══════════════════════════════════════════════════════════════════════════════
   SECTION 1: CSS CUSTOM PROPERTIES (Mobile Extensions)
   ═══════════════════════════════════════════════════════════════════════════════ */

:root {
    /* Dynamic Viewport (set by JS, fallback to CSS) */
    --tsi-vh: 1vh;
    --tsi-vw: 1vw;
    --tsi-dvh: 1dvh;
    
    /* Safe Areas (populated by browser) */
    --safe-top: env(safe-area-inset-top, 0px);
    --safe-bottom: env(safe-area-inset-bottom, 0px);
    --safe-left: env(safe-area-inset-left, 0px);
    --safe-right: env(safe-area-inset-right, 0px);
    
    /* Touch Targets */
    --tsi-touch-min: 44px;
    --tsi-touch-comfortable: 48px;
    
    /* Mobile Spacing */
    --tsi-mobile-padding: 16px;
    --tsi-mobile-gap: 12px;
}

/* ═══════════════════════════════════════════════════════════════════════════════
   SECTION 2: GLOBAL RESETS & FOUNDATIONS
   ═══════════════════════════════════════════════════════════════════════════════ */

*,
*::before,
*::after {
    box-sizing: border-box;
    -webkit-tap-highlight-color: transparent;
    -webkit-touch-callout: none;
}

html {
    -webkit-text-size-adjust: 100%;
    -moz-text-size-adjust: 100%;
    text-size-adjust: 100%;
    height: 100%;
    scroll-behavior: smooth;
}

body {
    /* Hybrid Viewport Height - Multiple fallbacks */
    min-height: 100vh;
    min-height: calc(var(--tsi-vh, 1vh) * 100);
    min-height: 100dvh;
    
    /* Safe Area Padding */
    padding-top: var(--safe-top);
    padding-bottom: var(--safe-bottom);
    padding-left: var(--safe-left);
    padding-right: var(--safe-right);
    
    /* Prevent Overscroll Bounce */
    overflow-x: hidden;
    overscroll-behavior: none;
    overscroll-behavior-y: contain;
    
    /* Smooth Scrolling */
    -webkit-overflow-scrolling: touch;
}

/* ═══════════════════════════════════════════════════════════════════════════════
   SECTION 3: GLASSMORPHISM ENGINE (Cross-Browser)
   ═══════════════════════════════════════════════════════════════════════════════ */

.glass-panel,
.tsi-glass-card,
.tsi-card {
    background: var(--tsi-glass-medium, rgba(18, 24, 32, 0.75));
    border: 1px solid rgba(255, 102, 0, 0.15);
    border-radius: var(--tsi-radius-lg, 12px);
    
    /* Safari requires -webkit- prefix */
    -webkit-backdrop-filter: blur(20px) saturate(180%);
    backdrop-filter: blur(20px) saturate(180%);
    
    /* Performance optimizations */
    will-change: transform, backdrop-filter;
    transform: translateZ(0);
    contain: paint;
}

/* Fallback for browsers without backdrop-filter (Android WebView <76) */
@supports not (backdrop-filter: blur(20px)) {
    .glass-panel,
    .tsi-glass-card,
    .tsi-card {
        background: rgba(18, 24, 32, 0.95);
    }
}

/* ═══════════════════════════════════════════════════════════════════════════════
   SECTION 4: TOUCH TARGETS & INTERACTIONS
   ═══════════════════════════════════════════════════════════════════════════════ */

button,
.tsi-btn,
.tsi-nav-item,
.tsi-tab,
[role="button"],
input[type="button"],
input[type="submit"],
a.btn {
    min-height: var(--tsi-touch-min);
    min-width: var(--tsi-touch-min);
    padding: 12px 16px;
    touch-action: manipulation;
    cursor: pointer;
    
    /* Prevent double-tap zoom */
    -ms-touch-action: manipulation;
}

/* Active state for touch feedback */
button:active,
.tsi-btn:active,
[role="button"]:active {
    transform: scale(0.98);
    opacity: 0.9;
}

/* ═══════════════════════════════════════════════════════════════════════════════
   SECTION 5: TRAINING PAGE LAYOUT
   ═══════════════════════════════════════════════════════════════════════════════ */

.training-viewport {
    display: flex;
    flex-direction: column;
    height: 100vh;
    height: calc(var(--tsi-vh, 1vh) * 100);
    height: 100dvh;
    overflow: hidden;
    position: relative;
    
    /* Account for fixed control dock */
    padding-bottom: calc(80px + var(--safe-bottom));
}

/* Graph Container Stack */
.graph-stack {
    flex: 1;
    min-height: 0;
    display: flex;
    flex-direction: column;
    justify-content: flex-start;
    padding: var(--tsi-mobile-padding);
    gap: var(--tsi-mobile-gap);
    
    /* Performance isolation */
    contain: paint;
}

/* Individual Chart Container */
.chart-container {
    position: relative;
    width: 100%;
    flex: 1;
    min-height: 80px;
    max-height: 150px;
}

.chart-container canvas {
    width: 100% !important;
    height: 100% !important;
}

/* Gauge Display Strip */
.gauge-strip {
    flex: 0 0 auto;
    display: flex;
    overflow-x: auto;
    gap: 15px;
    padding: 10px var(--tsi-mobile-padding);
    background: rgba(0, 0, 0, 0.3);
    
    /* Smooth scrolling */
    -webkit-overflow-scrolling: touch;
    scroll-snap-type: x mandatory;
    scrollbar-width: none;
}

.gauge-strip::-webkit-scrollbar {
    display: none;
}

.gauge-item {
    flex: 0 0 auto;
    display: flex;
    flex-direction: column;
    align-items: center;
    min-width: 70px;
    scroll-snap-align: start;
}

.gauge-item canvas,
.gauge-item svg {
    width: 60px;
    height: 60px;
    max-width: 100%;
}

.gauge-label {
    font-size: 0.7rem;
    color: var(--tsi-text-muted, #6B7280);
    text-transform: uppercase;
    letter-spacing: 0.05em;
    margin-top: 4px;
    white-space: nowrap;
}

/* Fixed Control Dock */
.control-dock {
    position: fixed;
    bottom: 0;
    left: 0;
    right: 0;
    z-index: 1000;
    
    display: flex;
    justify-content: center;
    align-items: center;
    gap: 16px;
    
    height: calc(70px + var(--safe-bottom));
    padding: 10px var(--tsi-mobile-padding);
    padding-bottom: calc(10px + var(--safe-bottom));
    
    background: linear-gradient(
        to top,
        rgba(13, 17, 23, 0.98) 0%,
        rgba(13, 17, 23, 0.95) 50%,
        rgba(13, 17, 23, 0.85) 100%
    );
    border-top: 1px solid rgba(255, 102, 0, 0.2);
}

/* Control Buttons */
.control-dock .tsi-btn {
    flex: 0 0 auto;
    min-width: 70px;
    padding: 12px 20px;
}

/* ═══════════════════════════════════════════════════════════════════════════════
   SECTION 6: HEADER BAR (Level/Stage/XP/Score)
   ═══════════════════════════════════════════════════════════════════════════════ */

.training-header {
    flex: 0 0 auto;
    display: flex;
    justify-content: space-between;
    align-items: center;
    flex-wrap: wrap;
    gap: 8px;
    padding: 10px var(--tsi-mobile-padding);
    padding-top: calc(10px + var(--safe-top));
    background: rgba(13, 17, 23, 0.9);
    border-bottom: 1px solid rgba(255, 102, 0, 0.15);
}

.training-title {
    font-family: var(--tsi-font-heading, 'Oswald', sans-serif);
    font-size: clamp(1rem, 4vw, 1.25rem);
    color: var(--tsi-orange, #FF6600);
    margin: 0;
}

.training-stats {
    display: flex;
    gap: 12px;
    font-family: var(--tsi-font-mono, monospace);
    font-size: clamp(0.7rem, 2.5vw, 0.85rem);
    color: var(--tsi-text-secondary, #B0B8C4);
}

.training-stats span {
    white-space: nowrap;
}

/* ═══════════════════════════════════════════════════════════════════════════════
   SECTION 7: SIDEBAR (Species Navigation)
   ═══════════════════════════════════════════════════════════════════════════════ */

/* Desktop: Vertical sidebar */
.species-sidebar {
    position: fixed;
    left: 0;
    top: 50%;
    transform: translateY(-50%);
    z-index: 100;
    
    display: flex;
    flex-direction: column;
    gap: 8px;
    padding: 10px 8px;
    
    background: rgba(13, 17, 23, 0.8);
    border-radius: 0 12px 12px 0;
    border: 1px solid rgba(255, 102, 0, 0.15);
    border-left: none;
}

.species-sidebar-item {
    width: 40px;
    height: 40px;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: 8px;
    background: rgba(255, 255, 255, 0.05);
    transition: all 0.2s ease;
}

.species-sidebar-item:hover,
.species-sidebar-item.active {
    background: rgba(255, 102, 0, 0.2);
    border-color: var(--tsi-orange);
}

.species-sidebar-item img {
    width: 28px;
    height: 28px;
    object-fit: contain;
}

/* ═══════════════════════════════════════════════════════════════════════════════
   SECTION 8: RESPONSIVE BREAKPOINTS
   ═══════════════════════════════════════════════════════════════════════════════ */

/* Tablet Portrait */
@media (max-width: 768px) {
    :root {
        --tsi-mobile-padding: 12px;
        --tsi-mobile-gap: 10px;
    }
    
    .training-viewport {
        padding-left: 0;
    }
    
    /* Hide sidebar on mobile, use bottom nav instead */
    .species-sidebar {
        display: none;
    }
    
    .chart-container {
        max-height: 120px;
    }
    
    .gauge-item canvas,
    .gauge-item svg {
        width: 50px;
        height: 50px;
    }
}

/* Phone Portrait */
@media (max-width: 480px) {
    :root {
        --tsi-mobile-padding: 10px;
        --tsi-mobile-gap: 8px;
    }
    
    .training-header {
        flex-direction: column;
        align-items: flex-start;
    }
    
    .training-stats {
        width: 100%;
        justify-content: space-between;
    }
    
    .chart-container {
        max-height: 100px;
    }
    
    .control-dock {
        gap: 10px;
    }
    
    .control-dock .tsi-btn {
        min-width: 60px;
        padding: 10px 14px;
        font-size: 0.85rem;
    }
}

/* Small Phone */
@media (max-width: 360px) {
    .training-stats {
        font-size: 0.65rem;
        gap: 8px;
    }
    
    .gauge-strip {
        gap: 10px;
    }
    
    .gauge-item {
        min-width: 55px;
    }
    
    .gauge-item canvas,
    .gauge-item svg {
        width: 40px;
        height: 40px;
    }
}

/* Landscape Phone */
@media (max-height: 500px) and (orientation: landscape) {
    .training-viewport {
        flex-direction: row;
        padding-bottom: 0;
        padding-right: calc(80px + var(--safe-right));
    }
    
    .graph-stack {
        flex-direction: row;
        flex: 1;
    }
    
    .chart-container {
        flex: 1;
        max-height: none;
        min-height: 0;
    }
    
    .gauge-strip {
        position: absolute;
        bottom: var(--safe-bottom);
        left: 0;
        right: calc(80px + var(--safe-right));
        flex-direction: row;
        overflow-x: auto;
    }
    
    .control-dock {
        position: fixed;
        bottom: 0;
        right: 0;
        left: auto;
        top: 0;
        width: calc(70px + var(--safe-right));
        height: 100%;
        flex-direction: column;
        padding: var(--safe-top) 10px var(--safe-bottom) 10px;
        padding-right: calc(10px + var(--safe-right));
        border-top: none;
        border-left: 1px solid rgba(255, 102, 0, 0.2);
    }
    
    .training-header {
        position: absolute;
        top: 0;
        left: 0;
        right: calc(70px + var(--safe-right));
        padding-top: var(--safe-top);
    }
}

/* Large Tablets */
@media (min-width: 769px) and (max-width: 1024px) {
    .training-viewport {
        padding-left: 60px;
    }
    
    .species-sidebar {
        width: 50px;
    }
}

/* ═══════════════════════════════════════════════════════════════════════════════
   SECTION 9: CAMP PAGE STYLES
   ═══════════════════════════════════════════════════════════════════════════════ */

.camp-viewport {
    min-height: 100vh;
    min-height: calc(var(--tsi-vh, 1vh) * 100);
    min-height: 100dvh;
    padding: var(--safe-top) var(--safe-right) var(--safe-bottom) var(--safe-left);
}

.camp-compass-nav {
    position: relative;
    width: min(300px, 80vw);
    height: min(300px, 80vw);
    margin: 0 auto;
}

/* ═══════════════════════════════════════════════════════════════════════════════
   SECTION 10: ADVENTURE PAGE STYLES
   ═══════════════════════════════════════════════════════════════════════════════ */

.adventure-viewport {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    height: calc(var(--tsi-vh, 1vh) * 100);
    height: 100dvh;
    overflow: hidden;
}

.adventure-hud {
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    pointer-events: none;
    z-index: 100;
    
    padding: var(--safe-top) var(--safe-right) var(--safe-bottom) var(--safe-left);
}

.adventure-hud > * {
    pointer-events: auto;
}

/* ═══════════════════════════════════════════════════════════════════════════════
   SECTION 11: UTILITY CLASSES
   ═══════════════════════════════════════════════════════════════════════════════ */

/* Full viewport height with iOS fix */
.full-height {
    height: 100vh;
    height: calc(var(--tsi-vh, 1vh) * 100);
    height: 100dvh;
}

/* Safe area padding utilities */
.safe-padding {
    padding: var(--safe-top) var(--safe-right) var(--safe-bottom) var(--safe-left);
}

.safe-padding-top {
    padding-top: var(--safe-top);
}

.safe-padding-bottom {
    padding-bottom: var(--safe-bottom);
}

/* Hide on mobile */
@media (max-width: 768px) {
    .hide-mobile {
        display: none !important;
    }
}

/* Hide on desktop */
@media (min-width: 769px) {
    .hide-desktop {
        display: none !important;
    }
}

/* Show only in landscape */
@media (orientation: portrait) {
    .landscape-only {
        display: none !important;
    }
}

/* Show only in portrait */
@media (orientation: landscape) {
    .portrait-only {
        display: none !important;
    }
}

/* ═══════════════════════════════════════════════════════════════════════════════
   SECTION 12: ANIMATION PERFORMANCE
   ═══════════════════════════════════════════════════════════════════════════════ */

/* Reduce motion for users who prefer it */
@media (prefers-reduced-motion: reduce) {
    *,
    *::before,
    *::after {
        animation-duration: 0.01ms !important;
        animation-iteration-count: 1 !important;
        transition-duration: 0.01ms !important;
    }
}

/* GPU-accelerated transforms */
.gpu-accelerated {
    transform: translateZ(0);
    will-change: transform;
}

/* ═══════════════════════════════════════════════════════════════════════════════
   SECTION 13: MOBILE OVERFLOW FIX
   Adventure pages set body { overflow: hidden } which blocks scrolling on mobile.
   Override on small screens so users can scroll when content overflows.
   ═══════════════════════════════════════════════════════════════════════════════ */

@media (max-width: 768px) {
    body {
        overflow-y: auto !important;
        overflow-x: hidden !important;
    }
}

/* ═══════════════════════════════════════════════════════════════════════════════
   SECTION 14: iOS FORM ZOOM PREVENTION
   iOS Safari auto-zooms when input font-size < 16px. Force 16px minimum
   on all interactive elements to prevent unwanted zoom on focus.
   ═══════════════════════════════════════════════════════════════════════════════ */

@media screen and (max-width: 768px) {
    input,
    select,
    textarea,
    button {
        font-size: 16px !important;
    }
}

/* ═══════════════════════════════════════════════════════════════════════════════
   SECTION: ASCE TRAINING PAGES — Mobile Fixes
   Targets: training-duck-ASCE, training-turkey-ASCE, training-elk-ASCE,
            training-deer-ASCE, training-goose-ASCE, training-songbird-ASCE
   ═══════════════════════════════════════════════════════════════════════════════ */

@media screen and (max-width: 768px) {
    /* Stack main layout vertically */
    main {
        flex-direction: column !important;
        margin-left: 0 !important;
        margin-top: 55px !important;
        padding: 8px !important;
        gap: 8px !important;
    }

    /* ASCE Header — compact on mobile */
    header {
        padding: 8px 12px !important;
        flex-wrap: wrap !important;
    }

    .tsi-icon {
        width: 32px !important;
        height: 32px !important;
        margin-right: 8px !important;
    }

    .title-text {
        font-size: 0.9em !important;
        letter-spacing: 0.5px !important;
    }

    .progress-info {
        font-size: 0.7em !important;
    }

    .medal-display {
        gap: 4px !important;
        margin: 0 6px !important;
    }

    .medal {
        width: 20px !important;
        height: 20px !important;
    }

    /* Level/Score bar compact */
    .level-score-bar,
    .status-bar {
        flex-wrap: wrap !important;
        gap: 6px !important;
        padding: 6px 8px !important;
        font-size: 0.75rem !important;
    }

    /* Unfix right-section sidebar, stack below graphs */
    .right-section {
        position: relative !important;
        width: 100% !important;
        right: auto !important;
        top: auto !important;
        max-height: none !important;
        overflow-y: visible !important;
    }

    /* Unfix bottom-section, stack naturally */
    .bottom-section {
        position: relative !important;
        left: 0 !important;
        right: 0 !important;
        bottom: auto !important;
        flex-direction: column !important;
        gap: 8px !important;
        z-index: auto !important;
    }

    /* Controls — fixed bottom, full width, compact */
    .controls {
        position: fixed !important;
        bottom: 0 !important;
        left: 0 !important;
        right: 0 !important;
        width: 100% !important;
        transform: none !important;
        padding: 10px 15px !important;
        gap: 8px !important;
        border-radius: 0 !important;
        border-left: none !important;
        border-right: none !important;
        border-bottom: none !important;
        z-index: 1000 !important;
        justify-content: center !important;
        padding-bottom: calc(10px + env(safe-area-inset-bottom, 0px)) !important;
    }

    .control-btn {
        min-height: 44px !important;
        min-width: 44px !important;
        padding: 10px 20px !important;
        font-size: 0.9rem !important;
        letter-spacing: 1px !important;
        border-radius: 20px !important;
        touch-action: manipulation !important;
        flex: 1 !important;
        max-width: 140px !important;
    }

    .control-btn:active:not(:disabled) {
        transform: scale(0.95) !important;
        filter: brightness(0.85) !important;
    }

    /* Countdown — smaller on mobile */
    .countdown-number {
        font-size: 8em !important;
    }

    .countdown-overlay,
    .listening-overlay {
        font-size: 1.2em !important;
        padding: 15px 25px !important;
    }

    /* Graphs section full width */
    .graphs-section {
        max-width: 100% !important;
        margin-right: 0 !important;
    }

    .graph-box {
        min-height: 160px !important;
        padding: 35px 10px 10px 10px !important;
    }

    .graph-box canvas {
        width: 100% !important;
        max-height: 130px !important;
    }

    .graph-label {
        font-size: 0.75em !important;
        padding: 4px 8px !important;
        top: 6px !important;
        left: 10px !important;
    }

    /* Loader bar overflow fix */
    .loader-bar {
        max-width: 85vw !important;
    }

    /* Score popup mobile sizing */
    .score-popup {
        padding: 15px !important;
        width: 92vw !important;
        max-width: 92vw !important;
        border-radius: 15px !important;
    }

    .score-main {
        font-size: 2em !important;
    }

    .score-label {
        font-size: 0.8em !important;
    }

    /* Env indicators full width, compact */
    .env-indicators {
        max-width: 100% !important;
        width: 100% !important;
        padding: 12px !important;
    }

    .env-title {
        font-size: 0.9em !important;
        margin-bottom: 8px !important;
    }

    /* Wind compass sizing */
    .wind-compass {
        width: 90px !important;
        height: 90px !important;
    }

    /* Hunt context readable */
    .hunt-context {
        font-size: 0.7rem !important;
        padding: 8px !important;
    }

    .hunt-context span {
        display: block !important;
        margin-bottom: 2px !important;
    }

    /* Distance/status indicators */
    .distance-indicator,
    .status-section {
        padding: 8px !important;
    }

    /* Frequency display compact */
    .freq-display {
        font-size: 1.5em !important;
    }

    .match-display,
    .match-percentage {
        font-size: 1.8em !important;
    }

    /* Target status compact */
    .target-status {
        padding: 4px 10px !important;
        font-size: 0.75em !important;
    }

    /* Subsonic/ultrasonic gauges */
    .gauge-bar {
        height: 8px !important;
    }

    .gauge-label {
        font-size: 0.65em !important;
    }

    /* Recording controls compact */
    .recording-controls {
        flex-wrap: wrap !important;
        gap: 6px !important;
    }

    .recording-controls button {
        padding: 6px 12px !important;
        font-size: 0.75rem !important;
    }

    /* Live weather panel compact */
    .live-weather-detail {
        grid-template-columns: 1fr 1fr !important;
        gap: 6px !important;
        font-size: 0.75rem !important;
    }

    /* Difficulty badge */
    .difficulty-badge,
    #difficultyBadge {
        font-size: 0.7rem !important;
        padding: 2px 8px !important;
    }

    /* Left nav hidden on mobile */
    .left-nav {
        display: none !important;
    }

    /* Add bottom padding to main so content isn't hidden behind fixed controls */
    main {
        padding-bottom: 80px !important;
    }
}

@media screen and (max-width: 480px) {
    main {
        margin-top: 48px !important;
        padding: 4px !important;
        padding-bottom: 75px !important;
    }

    header {
        padding: 6px 8px !important;
    }

    .title-text {
        font-size: 0.75em !important;
    }

    .progress-info {
        font-size: 0.6em !important;
    }

    .medal-display {
        display: none !important;
    }

    .graph-box {
        min-height: 130px !important;
    }

    .graph-box canvas {
        max-height: 100px !important;
    }

    .controls {
        padding: 8px 10px !important;
        gap: 6px !important;
    }

    .control-btn {
        padding: 8px 14px !important;
        font-size: 0.75rem !important;
        letter-spacing: 0.5px !important;
        max-width: 120px !important;
    }

    .score-popup {
        padding: 12px !important;
    }

    .score-main {
        font-size: 1.6em !important;
    }

    .countdown-number {
        font-size: 6em !important;
    }

    .env-indicators {
        flex-direction: column !important;
        padding: 8px !important;
    }

    .wind-compass {
        width: 70px !important;
        height: 70px !important;
    }

    .freq-display {
        font-size: 1.2em !important;
    }

    .match-display,
    .match-percentage {
        font-size: 1.4em !important;
    }
}

/* ═══════════════════════════════════════════════════════════════════════════════
   SECTION: ROUND TABLE HUB — Mobile Fixes
   ═══════════════════════════════════════════════════════════════════════════════ */

@media screen and (max-width: 480px) {
    .quick-links {
        grid-template-columns: repeat(2, 1fr) !important;
    }

    .panel-card {
        padding: 0.75rem !important;
    }

    .holiday-countdown {
        gap: 0.3rem !important;
    }

    .countdown-unit {
        min-width: 40px !important;
        padding: 0.3rem 0.4rem !important;
    }

    .countdown-num {
        font-size: 1.1rem !important;
    }
}

/* ═══════════════════════════════════════════════════════════════════════════════
   SECTION: PROFILE PAGE — Mobile Fixes
   ═══════════════════════════════════════════════════════════════════════════════ */

@media screen and (max-width: 768px) {
    .tabs {
        overflow-x: auto !important;
        -webkit-overflow-scrolling: touch !important;
        scrollbar-width: thin !important;
        flex-wrap: nowrap !important;
        gap: 4px !important;
    }

    .tabs button,
    .tab-btn {
        min-height: 44px !important;
        white-space: nowrap !important;
        padding: 8px 12px !important;
        font-size: 0.8rem !important;
        flex-shrink: 0 !important;
    }
}

/* ═══════════════════════════════════════════════════════════════════════════════
   SECTION: MANUFACTURERS PAGE — Mobile Fixes
   ═══════════════════════════════════════════════════════════════════════════════ */

@media screen and (max-width: 768px) {
    .manufacturers-grid {
        grid-template-columns: 1fr !important;
    }

    .filter-grid {
        grid-template-columns: 1fr !important;
    }

    .stat-value {
        font-size: 1.8em !important;
    }
}

/* ═══════════════════════════════════════════════════════════════════════════════
   SECTION: LEADERBOARD PAGE — Mobile Fixes
   ═══════════════════════════════════════════════════════════════════════════════ */

@media screen and (max-width: 768px) {
    .lb-table {
        min-width: unset !important;
        font-size: 0.8rem !important;
    }

    .lb-table th,
    .lb-table td {
        padding: 8px 6px !important;
    }

    .lb-stats-bar {
        grid-template-columns: repeat(2, 1fr) !important;
    }

    .lb-header {
        flex-direction: column !important;
        gap: 0.5rem !important;
    }
}

/* ═══════════════════════════════════════════════════════════════════════════════
   SECTION: CONSERVATION HUB — Mobile Fixes
   ═══════════════════════════════════════════════════════════════════════════════ */

@media screen and (max-width: 768px) {
    .conservation-hub .nav-links a {
        min-height: 44px !important;
        display: flex !important;
        align-items: center !important;
        justify-content: center !important;
    }

    .donation-grid {
        grid-template-columns: 1fr !important;
    }
}

/* ═══════════════════════════════════════════════════════════════════════════════
   SECTION: ADVENTURE MAP — Mobile Fixes
   ═══════════════════════════════════════════════════════════════════════════════ */

@media screen and (max-width: 768px) {
    .animal-btn {
        min-height: 44px !important;
        padding: 10px 14px !important;
    }

    .map-title {
        font-size: clamp(1rem, 4vw, 1.75rem) !important;
    }

    .animal-selector {
        flex-wrap: wrap !important;
        gap: 4px !important;
    }
}

@media screen and (max-width: 480px) {
    .map-header {
        padding: 10px !important;
    }

    .progress-bar-container {
        min-width: unset !important;
    }

    .map-legend {
        display: none !important;
    }
}

/* ═══════════════════════════════════════════════════════════════════════════════
   SECTION: DAILY CHALLENGES — Mobile Fixes
   ═══════════════════════════════════════════════════════════════════════════════ */

@media screen and (max-width: 480px) {
    .timer-value {
        font-size: clamp(1.5rem, 6vw, 2.5rem) !important;
    }

    .back-btn {
        min-height: 44px !important;
    }

    .summary-cards {
        grid-template-columns: 1fr !important;
    }

    .page-header {
        padding: 0.75rem 1rem !important;
    }
}

/* ═══════════════════════════════════════════════════════════════════════════════
   SECTION: CAMP PAGES — Grid Overflow Fixes
   ═══════════════════════════════════════════════════════════════════════════════ */

@media screen and (max-width: 480px) {
    .explore-grid,
    .feature-grid,
    .features-grid,
    .species-grid {
        grid-template-columns: 1fr !important;
    }

    .modal-content {
        padding: 15px !important;
        width: 95vw !important;
        max-width: 95vw !important;
    }
}

/* ═══════════════════════════════════════════════════════════════════════════════
   SECTION: CALL LIBRARY — Nav Fix
   ═══════════════════════════════════════════════════════════════════════════════ */

@media screen and (max-width: 640px) {
    nav .flex.items-center.gap-6,
    nav .flex.gap-6 {
        flex-wrap: wrap !important;
        gap: 8px !important;
    }

    nav a {
        min-height: 44px !important;
        display: flex !important;
        align-items: center !important;
    }
}

/* ═══════════════════════════════════════════════════════════════════════════════
   SECTION: GLOBAL — Safe Grid Pattern
   Prevents any auto-fit grid from overflowing on small screens
   ═══════════════════════════════════════════════════════════════════════════════ */

@media screen and (max-width: 400px) {
    [style*="grid-template-columns"] {
        grid-template-columns: 1fr !important;
    }
}

/* ═══════════════════════════════════════════════════════════════════════════════
   SECTION: INDEX / LANDING PAGE — Mobile Fixes
   ═══════════════════════════════════════════════════════════════════════════════ */

@media screen and (max-width: 480px) {
    .hero {
        min-height: min(600px, 85vh) !important;
    }

    .hero-title {
        letter-spacing: 1px !important;
    }
}

/* ═══════════════════════════════════════════════════════════════════════════════
   SECTION: COMPETITION ASCE PAGES — Mobile Fixes
   Targets: competition-duck-ASCE, competition-deer-ASCE, competition-elk-ASCE,
            competition-goose-ASCE, competition-turkey-ASCE, competition-songbird-ASCE,
            competition-elk-ASCE-integrated
   ═══════════════════════════════════════════════════════════════════════════════ */

@media screen and (max-width: 768px) {
    /* HUD top bar: prevent overflow, allow wrapping */
    .hud-top-bar {
        flex-wrap: wrap !important;
        gap: 6px !important;
        padding: 10px !important;
    }

    .hud-stat {
        padding: 6px 10px !important;
        font-size: 0.85rem !important;
    }

    /* Call meter: shrink on mobile */
    .call-meter {
        width: 30px !important;
        height: 180px !important;
        left: 10px !important;
    }

    /* Radar: shrink on mobile */
    .duck-radar,
    .elk-radar,
    .deer-radar,
    .goose-radar,
    .turkey-radar,
    .bird-radar {
        width: 70px !important;
        height: 70px !important;
        right: 10px !important;
    }

    /* Call button: ensure touch-friendly size */
    .call-button {
        width: 80px !important;
        height: 80px !important;
        bottom: 20px !important;
        font-size: 2rem !important;
    }

    /* Game timer: scale down */
    .game-timer {
        font-size: 1.5rem !important;
        top: 55px !important;
    }

    /* Game screen overlays: ensure padding on small screens */
    .game-screen p {
        max-width: 90vw !important;
        padding: 0 15px !important;
    }

    .game-btn {
        padding: 12px 30px !important;
        font-size: 1rem !important;
        min-height: 44px !important;
    }

    /* Results grid: stack on mobile */
    .results-grid {
        grid-template-columns: 1fr !important;
        gap: 10px !important;
    }

    /* Trophy alert: fit on screen */
    .trophy-alert {
        padding: 20px 25px !important;
        width: 90vw !important;
        max-width: 90vw !important;
    }

    /* Response indicator: scale */
    .response-indicator {
        font-size: 2.5rem !important;
    }

    /* Loading icons: scale */
    .loading-duck,
    .loading-deer,
    .loading-elk,
    .loading-goose,
    .loading-turkey,
    .loading-bird {
        font-size: 3rem !important;
    }
}

@media screen and (max-width: 480px) {
    .hud-stat {
        padding: 4px 8px !important;
        font-size: 0.75rem !important;
    }

    .call-meter {
        width: 25px !important;
        height: 140px !important;
    }

    .duck-radar,
    .elk-radar,
    .deer-radar,
    .goose-radar,
    .turkey-radar,
    .bird-radar {
        width: 55px !important;
        height: 55px !important;
    }

    .call-button {
        width: 70px !important;
        height: 70px !important;
        font-size: 1.8rem !important;
    }

    .game-timer {
        font-size: 1.2rem !important;
    }

    /* Scope crosshair: scale for small screens */
    .scope-crosshair {
        width: 140px !important;
        height: 140px !important;
    }
}

/* ═══════════════════════════════════════════════════════════════════════════════
   SECTION: COMPETITION HUB — Mobile Fixes
   ═══════════════════════════════════════════════════════════════════════════════ */

@media screen and (max-width: 768px) {
    .competition-page .nav-bar {
        padding: 0.75rem 1rem !important;
    }

    .competition-page .nav-links {
        gap: 0.75rem !important;
    }

    .competition-page .nav-link {
        font-size: 0.8rem !important;
        min-height: 44px !important;
        display: flex !important;
        align-items: center !important;
    }

    .competition-page .page-title {
        font-size: clamp(1.5rem, 6vw, 3rem) !important;
    }

    .competition-page .page-header {
        padding: 5rem 1rem 1.5rem !important;
    }

    .competition-page .quick-stats {
        gap: 1rem !important;
        flex-wrap: wrap !important;
        padding: 1rem !important;
    }

    .competition-page .quick-stat-value {
        font-size: 1.5rem !important;
    }

    .comp-card-grid {
        grid-template-columns: 1fr !important;
    }

    .two-column {
        grid-template-columns: 1fr !important;
    }

    .leaderboard-tab {
        min-height: 44px !important;
        padding: 8px 12px !important;
    }
}

@media screen and (max-width: 480px) {
    .competition-page .nav-links {
        flex-wrap: wrap !important;
        gap: 0.5rem !important;
    }

    .competition-page .quick-stats {
        flex-direction: column !important;
        gap: 0.5rem !important;
    }

    .competition-page .featured-section {
        padding: 1rem !important;
    }
}

/* ═══════════════════════════════════════════════════════════════════════════════
   SECTION: PROGUIDE STUDIO PAGES — Mobile Fixes
   Targets: proguide-studio-record, proguide-studio-analysis,
            proguide-studio-equipment
   ═══════════════════════════════════════════════════════════════════════════════ */

@media screen and (max-width: 768px) {
    /* Analysis page: recording cards grid overflow fix */
    .recordings-grid {
        grid-template-columns: 1fr !important;
    }

    .summary-grid {
        grid-template-columns: 1fr !important;
    }

    /* Record page: shrink record button */
    .record-button {
        width: 150px !important;
        height: 150px !important;
        font-size: 1.2em !important;
    }

    /* Nav buttons: stack vertically */
    .nav-buttons {
        flex-direction: column !important;
    }

    .nav-btn {
        min-width: unset !important;
        width: 100% !important;
    }

    /* Modal inline max-width override */
    .modal-content[style*="max-width: 900px"] {
        max-width: 95vw !important;
    }

    /* Equipment page: form grid single column */
    .form-grid {
        grid-template-columns: 1fr !important;
    }

    /* Action buttons stack */
    .action-buttons {
        flex-direction: column-reverse !important;
    }

    .action-buttons .btn {
        width: 100% !important;
        justify-content: center !important;
    }

    /* Autosave indicator: reposition for mobile */
    .autosave-indicator {
        bottom: 10px !important;
        right: 10px !important;
        left: 10px !important;
        justify-content: center !important;
    }
}

@media screen and (max-width: 480px) {
    /* Record button even smaller on phones */
    .record-button {
        width: 120px !important;
        height: 120px !important;
        font-size: 1em !important;
    }

    /* Metrics grid single column */
    .metrics-grid {
        grid-template-columns: 1fr !important;
    }

    /* Iteration list: 2 columns max on small phones */
    .iteration-list {
        grid-template-columns: repeat(2, 1fr) !important;
    }

    /* Analysis: chart container height */
    .chart-container {
        height: 200px !important;
    }

    .thredam-container {
        height: 250px !important;
    }

    /* Section card padding */
    .section-card {
        padding: 15px !important;
    }

    /* Stats table horizontal scroll */
    .stats-table {
        display: block !important;
        overflow-x: auto !important;
        -webkit-overflow-scrolling: touch !important;
    }
}

/* ═══════════════════════════════════════════════════════════════════════════════
   SECTION: EDUCATION PAGE — Mobile Fixes
   ═══════════════════════════════════════════════════════════════════════════════ */

@media screen and (max-width: 768px) {
    .age-groups {
        grid-template-columns: 1fr !important;
    }

    .stats {
        grid-template-columns: 1fr !important;
    }

    .enroll-btn {
        min-height: 44px !important;
    }

    .back-btn {
        min-height: 44px !important;
    }
}

/* ═══════════════════════════════════════════════════════════════════════════════
   SECTION: ACCESSIBILITY — Focus Visible & Reduced Motion
   ═══════════════════════════════════════════════════════════════════════════════ */

/* Focus-visible outlines for all interactive elements */
a:focus-visible,
button:focus-visible,
input:focus-visible,
select:focus-visible,
textarea:focus-visible,
[role="button"]:focus-visible,
[tabindex]:focus-visible,
.tsi-btn:focus-visible,
.tsi-nav-item:focus-visible,
.tsi-tab:focus-visible,
.nav-btn:focus-visible,
.control-btn:focus-visible,
.species-btn:focus-visible,
.nav-card:focus-visible {
    outline: 2px solid #FF6600;
    outline-offset: 2px;
    box-shadow: 0 0 0 4px rgba(255, 102, 0, 0.25);
}

/* Remove default outline only when :focus-visible is supported */
a:focus:not(:focus-visible),
button:focus:not(:focus-visible),
input:focus:not(:focus-visible),
select:focus:not(:focus-visible),
textarea:focus:not(:focus-visible),
[role="button"]:focus:not(:focus-visible) {
    outline: none;
    box-shadow: none;
}

/* Reduced motion — disable animations for users who prefer it */
@media (prefers-reduced-motion: reduce) {
    *,
    *::before,
    *::after {
        animation-duration: 0.01ms !important;
        animation-iteration-count: 1 !important;
        transition-duration: 0.01ms !important;
        scroll-behavior: auto !important;
    }

    .compass-ring,
    .pointer-arrow,
    .wind-arrow,
    .fish-emoji,
    .fish-float-btn,
    .loader-progress,
    .countdown-number,
    .pulse-dot,
    .neon-title,
    .error-illustration {
        animation: none !important;
    }
}

/* ═══════════════════════════════════════════════════════════════════════════════
   SECTION: PRINT STYLES
   ═══════════════════════════════════════════════════════════════════════════════ */

@media print {
    /* Hide navigation, fixed UI elements, decorative backgrounds, animations */
    nav,
    .nav-bar,
    .top-nav,
    .bottom-nav,
    .quick-actions,
    .theme-toggle-btn,
    .night-mode-btn,
    .tsi-guide-chat-btn,
    .tsi-guide-chat-container,
    .fish-float-btn,
    .feedback-widget-btn,
    .feedback-widget-container,
    .cookie-consent-banner,
    .bug-reporter-btn,
    .global-search-overlay,
    .onboarding-overlay,
    .streak-popup,
    [class*="fixed-btn"],
    [class*="float-btn"],
    .species-background,
    .particle-canvas,
    .bg-animation {
        display: none !important;
    }

    /* White background, black text for readability */
    body {
        background: #fff !important;
        color: #000 !important;
        font-family: 'Arial', sans-serif !important;
    }

    * {
        color: #000 !important;
        text-shadow: none !important;
        box-shadow: none !important;
        animation: none !important;
        transition: none !important;
    }

    a {
        text-decoration: underline !important;
    }

    /* Keep images, scale to fit */
    img, svg {
        max-width: 100% !important;
        height: auto !important;
    }

    /* Prevent page breaks inside cards and content blocks */
    .card,
    .forecast-card,
    .stamp-slot,
    .skill-node,
    .branch,
    .quick-btn,
    [class*="-card"],
    [class*="-tile"],
    article,
    section {
        page-break-inside: avoid;
        break-inside: avoid;
    }

    /* Remove dark backgrounds from cards */
    .card,
    .forecast-card,
    .stamp-slot,
    .branch,
    [class*="-card"] {
        background: #fff !important;
        border-color: #ccc !important;
    }
}

/* ═══════════════════════════════════════════════════════════════════════════════
   SECTION: HUNT SETUP SYSTEM — Mobile Overrides
   Strengthens hunt-setup.css rules for overlay, ProGuide, compass,
   binocular scanner, env-icon strip, and wind particles.
   ═══════════════════════════════════════════════════════════════════════════════ */

@media screen and (max-width: 768px) {
    /* Overlay must not conflict with compact header or cause overflow */
    #hunt-setup-overlay {
        overflow: hidden !important;
        -webkit-overflow-scrolling: touch !important;
    }

    /* ProGuide popup: full-width bottom sheet with safe-area padding */
    .proguide-popup {
        bottom: 70px !important;
        left: 8px !important;
        right: 8px !important;
        width: auto !important;
        max-width: 100% !important;
        transform: none !important;
        padding-bottom: calc(14px + env(safe-area-inset-bottom, 0px)) !important;
    }

    /* TTS toggle must be tappable */
    .proguide-tts-toggle {
        min-width: 44px !important;
        min-height: 44px !important;
        padding: 8px !important;
    }

    /* ProGuide action button touch target */
    .proguide-action-btn {
        min-height: 44px !important;
    }

    /* Env-icon strip must not overlap compact header (typically 50px) */
    .env-icon-strip {
        top: 50px !important;
        max-width: calc(100vw - 16px) !important;
    }

    /* All env-icons must meet 44px touch target */
    .env-icon {
        min-width: 44px !important;
        min-height: 44px !important;
    }

    /* Binocular scanner minimum touch area */
    .binocular-container {
        min-height: 250px !important;
        touch-action: none !important;
    }

    /* Wind particles must not cause scroll */
    .wind-particle {
        pointer-events: none !important;
    }

    /* Phase content scrollable if it overflows */
    .phase-content {
        max-height: calc(100dvh - 180px) !important;
        overflow-y: auto !important;
        -webkit-overflow-scrolling: touch !important;
    }

    /* Skip button touch target */
    .skip-setup-btn {
        min-width: 44px !important;
        min-height: 44px !important;
    }
}

@media screen and (max-width: 480px) {
    /* ProGuide column layout for small phones */
    .proguide-popup {
        flex-direction: column !important;
        align-items: center !important;
        text-align: center !important;
        bottom: 60px !important;
        padding-bottom: calc(10px + env(safe-area-inset-bottom, 0px)) !important;
    }

    .proguide-action-btn {
        width: 100% !important;
        min-height: 48px !important;
    }

    /* Env-icon labels hidden on small screens to save space */
    .env-icon-label {
        display: none !important;
    }

    /* Env strip tighter fit */
    .env-icon-strip {
        top: 45px !important;
        gap: 6px !important;
        padding: 4px 8px !important;
    }

    /* Compass scaled down */
    .setup-compass {
        width: 100px !important;
        height: 100px !important;
    }

    /* Binocular container */
    .binocular-container {
        height: 250px !important;
        min-height: 250px !important;
    }

    /* Phase content tighter padding */
    .phase-content {
        padding: 15px !important;
    }

    /* Segue title smaller */
    .phase-segue-title {
        font-size: 1.1rem !important;
        letter-spacing: 1px !important;
    }

    /* Distance legend wraps */
    .distance-legend {
        flex-wrap: wrap !important;
    }
}

/* iPhone safe area bottom for ProGuide popup (all sizes) */
@supports (padding-bottom: env(safe-area-inset-bottom)) {
    .proguide-popup {
        padding-bottom: calc(18px + env(safe-area-inset-bottom, 0px));
    }
}

/* ═══════════════════════════════════════════════════════════════════════════════
   END OF TSI MOBILE RESPONSIVE CSS v2.3
   ═══════════════════════════════════════════════════════════════════════════════ */
