/* ============================================================
   MOBILE.CSS - KORRIGERAD & KOMPLETT
   ============================================================ */

@media (max-width: 768px) {

    /* --- 1. HERO & LANDING (TOTALT KORRIGERAD) --- */
    
    /* Huvudbehållaren - Relativ för att agera ankare åt video och nav */
    .landing-header {
        height: auto !important;
        min-height: 78dvh !important; /* Anpassad för iPhone/Safari */
        display: flex !important;
        flex-direction: column !important;
        position: relative !important;
        overflow: hidden !important;
    }

    /* Videon - Låst i bakgrunden */
    .bg-video-carousel {
        position: absolute !important;
        inset: 0 !important;
        width: 100% !important;
        height: 100% !important;
        z-index: 0 !important; 
        display: block !important;
        object-fit: cover !important;
    }

    /* Mörk toning över videon */
    .hero-overlay {
        position: absolute !important;
        inset: 0 !important;
        z-index: -1 !important;
        background: rgba(0,0,0,0.6) !important;
    }

    /* Hero Sektionen - Centrerar texten mitt på skärmen */
    .hero {
        position: relative !important;
        display: flex !important;
        flex-direction: column !important;
        justify-content: center !important;
        align-items: center !important;
        padding: 80px 20px 100px 20px !important; /* Extra padding i botten för nav-knappar */
        margin: 0 !important;
        z-index: 10 !important;
        top: 0 !important;
        flex: 1 !important;
        width: 100% !important;
    }

   .discord-link {
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 0.5rem;
    color: var(--text-secondary);
    transition: color 0.2s ease;
    margin-right: 0.5rem;
    display: none;
}
    .carousel-nav, .carousel-dot {
        min-width: 24px;
        min-height: 24px;
    }
    /* Innehålls-återställning - Dödar alla desktop-positioner */
    .hero-content {
        position: relative !important;
        top: auto !important;
        left: auto !important;
        transform: none !important;
        margin: 0 !important;
        width: 100% !important;
        max-width: 100% !important;
        text-align: center !important;
        display: flex !important;
        flex-direction: column !important; /* Staplar elementen vertikalt */
        align-items: center !important;
    }

    /* TVINGANDE ORDNING PÅ ELEMENTEN */
    /* Detta fixar felet där knapparna hamnade överst */
    
    .hero-title {
        display: contents !important; /* Låter barnen (main/sub) sorteras fritt */
    }

    .hero-title-main {
            font-size: 1.9rem !important;
            line-height: 1.2 !important;
            font-weight: 900;
            font-family: Cinzel;
            color: #fff !important;
            margin-bottom: 5px !important;
            order: 1 !important;
            position: relative !important;
            top: auto !important;
            left: auto !important;
    }
    
    .hero-title-sub {
        font-size: 1.2rem !important;
        color: var(--gold-color) !important;
        margin-bottom: 20px !important;
        order: 2 !important; /* Alltid tvåa */
        position: relative !important; top: auto !important; left: auto !important;
    }

    .hero-description {
            font-size: 1rem !important;
            margin-bottom: 30px !important;
            order: 3 !important;
            position: relative !important;
            top: auto !important;
            border-radius: 3px;
            box-shadow: none;
            border: none;
            background: none;
            left: auto !important;
    }

    .hero-cta {
            gap: 15px !important;
            margin-top: 0 !important;
            order: 4 !important;
            position: relative !important;
            top: auto !important;
            left: auto !important;
            display: flex !important;
            flex-direction: column !important;
            align-items: center !important;
            width: 100% !important;
            background: none;
            box-shadow: none;
            border: none;
    }
    
    .hero-cta .btn {
            width: 100% !important;
            max-width: 280px !important;
            margin: 0 !important;
    }

   .feature-card {
    background: #1a1a1a;
    padding: 3rem 2.5rem;
    position: relative;
    overflow: hidden;
    transition: background 0.5s;
    border: none;
    border-radius: 0;
    text-align: left;
    border-left: 1px solid var(--border-default);
    padding: 5px;
}

    /* Navigeringen (Pilar/Prickar) - Placeras under CTA */
    .carousel-controls, 
    .hero-nav, 
    .carousel-indicators {
        position: static !important;
        z-index: 20 !important;
        display: flex !important;
        justify-content: center !important;
        gap: 15px !important;
        margin: 0 !important;
        transform: none !important;
    }

    .carousel-controls-host {
        margin-top: 12px !important;
    }

    /* --- 2. HEADER & NAVIGATION (BEVARAD KOD) --- */
    .unified-header {
        /* position: sticky; */
        top: 0;
        z-index: 1100;
        padding-top: env(safe-area-inset-top);
    }
    .hamburger-menu {
        border: 1px solid var(--border-default);
        border-radius: var(--radius-md);
    }
    .hamburger-menu:hover {
        background: var(--bg-hover);
        border-color: var(--accent-gold);
    }
    .app-nav.mobile-nav-open {
        display: block;
    }
    .nav-tab.active {
        background: var(--bg-elevated);
    }

    /* --- 3. GOLD FRAME & FEATURES (BEVARAD KOD) --- */
    .gold-frame-section {
        padding: 0 1rem 2rem;
        margin-top: 0 !important;
        position: relative;
        z-index: 20;
    }
    .gold-frame-box .corner {
        width: 30px;
        height: 30px;
    }
    .gold-frame-box .corner::before { width: 20px !important; }
    .gold-frame-box .corner::after { height: 20px !important; }
    
    .features { padding: 2rem 1rem; }
    .section-heading { font-size: 1.5rem; }
    .feature-icon { font-size: 2.5rem; top: 2px; right: 2px; }

    /* --- 4. APP MAIN & CARDS (BEVARAD KOD) --- */
    .app-main { padding: 1rem; }
    .section-header-bar {
        flex-direction: column;
        align-items: flex-start;
        gap: 0.5rem;
    }
    .section-header-bar h1 { font-size: 1.25rem; }
    .characters-grid { justify-content: center; }
    .character-card, .character-card-full {
        width: 100%;
        max-width: 100%;
    }
    .card-stats-grid {
        grid-template-columns: repeat(3, 1fr);
        gap: 0.25rem;
    }
    .card-stats-grid .stat-box:nth-child(4),
    .card-stats-grid .stat-box:nth-child(5) {
        grid-column: span 1;
    }

    /* --- 5. SHEETS & MODALS (BEVARAD KOD) --- */
    .sheet-header-full { align-items: center; text-align: center; }
    .sheet-hp-vp-bar { flex-direction: column; width: 100%; }
    .sheet-tabs { scrollbar-width: none; -ms-overflow-style: none; }
    .sheet-tabs::-webkit-scrollbar { display: none; }
    .sheet-tab { padding: 0.75rem 1rem; font-size: 0.8rem; }
    .attrs-grid { grid-template-columns: repeat(3, 1fr); }
    
    .modal { padding: 0.5rem; align-items: flex-start; padding-top: 2rem; }
    .modal-content {
        max-width: 100%;
        max-height: calc(100vh - 4rem);
        padding: 1.5rem 1rem;
    }
    .modal-header h2 { font-size: 1.25rem; }
    .modal-fullscreen .modal-content { max-height: 100vh; }
    
    .kin-grid, .profession-grid, .age-grid { grid-template-columns: repeat(2, 1fr); }
    .attrs-roll-grid { grid-template-columns: repeat(3, 1fr); gap: 0.5rem; }

    /* --- 6. UTILS & FOOTER (BEVARAD KOD) --- */
    .session-card { padding: 1rem; }
    .auth-form input { padding: 1rem; }
    .btn-sm { min-height: 36px; padding: 0.5rem 1rem; }
    
    .inv-row { flex-direction: column; align-items: flex-start; gap: 0.25rem; }
    .currency-grid { grid-template-columns: repeat(3, 1fr); gap: 0.5rem; }
    
    .landing-footer {
        padding: 1.5rem 1rem;
        padding-bottom: calc(1.5rem + env(safe-area-inset-bottom));
    }
    .footer-links .footer-link {
        display: inline-block;
        padding: 14px 10px;
    }
    .footer-disclaimer { font-size: 0.7rem; padding: 0 0.5rem; }
    .community-feed { grid-template-columns: 1fr; }
    .toast { left: 1rem; right: 1rem; max-width: calc(100% - 2rem); }
    
    /* Homebrew & Adventure Grid (BEVARAD KOD) */
    .homebrew-grid,
    .adventure-grid,
    .adventures-grid {
        grid-template-columns: 1fr;
    }


/* ============================================================
   KARAKTÄRSSIDA V2 - SLUTGILTIG ÅTGÄRD FÖR ALLA ALIGNMENT-FEL
   ============================================================ */

@media (max-width: 768px) {

    /* 1. ATTRIBUT: Tvinga 3 kolumner (skriver över tidigare fel) */
    .attributes-grid-v2 {
        display: grid !important;
        grid-template-columns: repeat(3, 1fr) !important; 
        gap: 8px !important;
        width: 100% !important;
        padding: 0 !important;
        justify-content: center !important;
    }

    .attr-box-v2 {
        width: 100% !important;
        max-width: 100% !important;
    }
    .sheet-main-v2 {
        width: 100% !important;
        padding: 0rem;
    }

    /* 2. NAMN-INPUT: Fixa overflow till vänster */
    .char-name-input-v2 {
        width: 100% !important;
        margin: 0 auto !important;
        text-align: center !important;
        left: 0 !important;
        position: relative !important;
        box-sizing: border-box !important;
    }

    /* 3. META-RAD: Fixa bredden på Dvärg/Krigare-raden */
    .char-details-row-v2 {
        width: 100% !important;
        display: flex !important;
        flex-wrap: wrap !important;
        justify-content: center !important;
        gap: 0.5rem !important;
        margin: 0 auto !important;
    }

    /* 4. SEKUNDÄRA ATTRIBUT: Fixa overflow till höger */
    .secondary-attrs-v2 {
        display: grid !important;
        grid-template-columns: repeat(2, 1fr) !important; /* 2 st på rad istället för 4 */
        width: 100% !important;
        box-sizing: border-box !important;
        padding: 1rem !important;
        gap: 10px !important;
        margin: 0 !important;
    }

    /* 5. ARMOR-GRID: Fixa overflow till höger */
    .armor-grid-v2 {
        display: grid !important;
        grid-template-columns: 1fr !important; /* Stapla armor vertikalt */
        width: 100% !important;
        box-sizing: border-box !important;
        padding: 0 !important;
        margin: 0 !important;
    }

    /* 6. HEADER & PORTRÄTT: Centrera allt */
    .char-header-v2 {
        display: flex !important;
        flex-direction: column !important;
        align-items: center !important;
        width: 100% !important;
        text-align: center !important;
        padding: 1rem !important;
    }

    .char-portrait-v2 {
        margin: 0 auto 0rem auto !important;
        flex-shrink: 0 !important;
    }

    .char-actions-v2 {
        width: 100% !important;
        justify-content: center !important;
        display: flex !important;
        gap: 10px !important;
    }
   
    .sheet-tabs-v2 {
        margin-bottom: 10px;
    }
   
    .skill-row-v2 {
        padding: 0.4rem;
    }

    .skills-grid-v2 {
        gap: 0.3rem;
    }
   
    .header-brand {
        padding-top: 0px;
        padding-right: 4px;
    }

    .fantasy-group-card {
        width: 100%;
    }

    .fantasy-create-card {
        width: 100%; !important;
    }

    /* 7. ALLMÄN SÄKERHET: Förhindra sidscroll */
    .character-sheet-wrapper, 
    #characterSheetContainer {
        overflow-x: hidden !important;
        width: 100% !important;
        margin-bottom: 10px;
    }

    /* ============================================================
       CHARACTER CREATOR MOBILE IMPROVEMENTS
       ============================================================ */
    
    /* Creator input fields - make full width and touch-friendly */
    .creator-input {
        width: 100% !important;
        font-size: 16px !important; /* Prevents zoom on iOS */
        padding: 0.75rem !important;
        box-sizing: border-box !important;
    }
    
    /* Attribute rolling grid - better mobile layout */
    .attrs-roll-grid {
        grid-template-columns: repeat(2, 1fr) !important;
        gap: 0.75rem !important;
    }
    
    .attr-roll-item {
        display: flex !important;
        flex-direction: column !important;
        align-items: center !important;
        padding: 0.75rem !important;
        gap: 0.5rem !important;
    }
    
    .attr-roll-item .attr-label {
        font-size: 0.9rem !important;
        font-weight: bold !important;
    }
    
    .attr-roll-item .attr-value {
        font-size: 1.5rem !important;
    }
    
    .attr-roll-item .btn {
        width: 100% !important;
        min-height: 44px !important; /* Touch-friendly */
    }
    
    /* Portrait selector - stack vertically on mobile */
    .portrait-selector {
        display: flex !important;
        flex-direction: column !important;
        align-items: center !important;
        gap: 1.5rem !important;
    }
    
    .portrait-selector .current-portrait {
        margin-bottom: 1rem !important;
    }
    
    .portrait-selector .portrait-options {
        width: 100% !important;
    }
    
    /* Icon grid - better mobile layout */
    .icon-grid {
        grid-template-columns: repeat(3, 1fr) !important;
        gap: 0.75rem !important;
    }
    
    .icon-option,
    .creation-icon-option {
        min-height: 60px !important;
        padding: 0.5rem !important;
    }
    
    .icon-option img,
    .creation-icon-option img {
        max-width: 48px !important;
        max-height: 48px !important;
    }
    
    /* Creator navigation - stack buttons vertically if needed */
    .creator-nav {
        display: flex !important;
        flex-wrap: wrap !important;
        gap: 0.75rem !important;
        margin-top: 1.5rem !important;
    }
    
    .creator-nav .btn {
        flex: 1 1 45% !important;
        min-height: 48px !important; /* Touch-friendly */
        font-size: 1rem !important;
    }
    
    /* Summary card - better mobile padding */
    .summary-card {
        padding: 1rem !important;
        margin: 1rem 0 !important;
    }
    
    .summary-card p {
        margin: 0.5rem 0 !important;
        font-size: 0.95rem !important;
    }
    
    /* Creator progress dots - ensure visibility */
    .creator-progress {
        display: flex !important;
        justify-content: center !important;
        gap: 0.5rem !important;
        padding: 1rem 0 !important;
    }
    
    .progress-dot {
        width: 12px !important;
        height: 12px !important;
        min-width: 12px !important;
        border-radius: 50% !important;
    }
    
    /* Modal fullscreen - ensure proper scrolling */
    .modal-fullscreen .modal-content {
        max-height: 100vh !important;
        overflow-y: auto !important;
        -webkit-overflow-scrolling: touch !important;
    }
    
    /* Creator step content */
    .creator-step {
        padding: 1rem !important;
    }
    
    .creator-step h2 {
        font-size: 1.5rem !important;
        margin-bottom: 1rem !important;
    }

    /* ============================================================
       CHARACTER SHEET MOBILE IMPROVEMENTS
       ============================================================ */
    
    /* Character info section - make inputs responsive */
    .char-info-v2 {
        width: 100% !important;
    }
    
    .char-meta-v2 {
        display: flex !important;
        flex-wrap: wrap !important;
        justify-content: center !important;
        gap: 0.5rem !important;
    }
    
    .char-select-v2 {
        font-size: 16px !important; /* Prevents zoom on iOS */
        min-height: 44px !important; /* Touch-friendly */
    }
    
    /* Details row - make inline inputs responsive */
    .char-details-row-v2 input[type="text"] {
        width: 100% !important;
        max-width: 150px !important;
        font-size: 16px !important; /* Prevents zoom on iOS */
        min-height: 36px !important;
    }
    
    /* Sheet layout - stack main and sidebar on mobile */
    .sheet-layout-v2 {
        display: flex !important;
        flex-direction: column !important;
        gap: 1rem !important;
    }
    
    .sheet-main-v2,
    .sheet-sidebar-v2 {
        width: 100% !important;
    }
    
    /* Sheet tabs - enable horizontal scrolling */
    .sheet-tabs-v2 {
        display: flex !important;
        overflow-x: auto !important;
        -webkit-overflow-scrolling: touch !important;
        scrollbar-width: none !important;
        gap: 0.5rem !important;
    }
    
    .sheet-tabs-v2::-webkit-scrollbar {
        display: none !important;
    }
    
    .sheet-tab-v2 {
        flex-shrink: 0 !important;
        padding: 0.75rem 1rem !important;
        font-size: 0.9rem !important;
        min-height: 44px !important; /* Touch-friendly */
        white-space: nowrap !important;
    }
    
    /* Settings tab background grid - smaller minimums */
    .bg-grid {
        grid-template-columns: repeat(auto-fill, minmax(80px, 1fr)) !important;
        gap: 0.5rem !important;
    }
    
    /* Number inputs and selects - touch-friendly sizing */
    input[type="number"],
    input[type="text"],
    select,
    textarea {
        font-size: 16px !important; /* Prevents zoom on iOS */
        min-height: 36px !important;
    }
    
    /* Attribute inputs */
    .attr-value-input-v2 {
        font-size: 1.25rem !important;
        min-height: 44px !important;
        width: 60px !important;
    }
    
    /* Secondary attributes - better mobile grid */
    .secondary-attr-v2 label {
        font-size: 0.85rem !important;
    }
    
    /* Weapon table - make responsive */
    .weapons-table-v2 {
        font-size: 0.85rem !important;
    }
    
    .weapons-table-v2 input {
        font-size: 0.85rem !important;
        padding: 0.4rem !important;
    }
    
    /* Skills grid - better mobile layout */
    .skills-grid-v2 {
        grid-template-columns: 1fr !important;
    }
    
    /* Portrait edit button - touch-friendly */
    .portrait-edit-btn {
        min-width: 32px !important;
        min-height: 32px !important;
        font-size: 1rem !important;
    }
}
/* VIKTIGT: Skriv över 480px-regeln explicit ifall den ligger kvar */
@media (max-width: 480px) {
    .attrs-grid {
        grid-template-columns: repeat(3, 1fr) !important;
    }
}
