/* ===== UNIVERSAL ROLEPLAYING PLATFORM - ADVANCED MOBILE FRAMEWORK ===== */
/* Enhanced Responsive System with Device Detection & Dynamic Scaling */
/* Optimized for Android Moto G Play 2023 and similar devices */

/* ===== CSS CUSTOM PROPERTIES FOR DYNAMIC SCALING ===== */
:root {
    /* Base sizing variables that adapt to device */
    --base-font-size: clamp(14px, 4vw, 18px);
    --heading-scale: clamp(1.2, 1.5vw, 1.8);
    --spacing-unit: clamp(0.5rem, 2vw, 1rem);
    --touch-target: clamp(44px, 12vw, 48px);
    
    /* Dynamic viewport units */
    --vh: 1vh;
    --vw: 1vw;
    --vmin: 1vmin;
    --vmax: 1vmax;
    
    /* Container sizes that adapt to device */
    --container-xs: 100%;
    --container-sm: min(95%, 540px);
    --container-md: min(90%, 720px);
    --container-lg: min(85%, 960px);
    --container-xl: min(80%, 1140px);
    
    /* Fluid spacing system */
    --space-xs: clamp(0.25rem, 1vw, 0.5rem);
    --space-sm: clamp(0.5rem, 2vw, 1rem);
    --space-md: clamp(1rem, 3vw, 1.5rem);
    --space-lg: clamp(1.5rem, 4vw, 2rem);
    --space-xl: clamp(2rem, 5vw, 3rem);
    
    /* Fluid typography */
    --text-xs: clamp(0.75rem, 2.5vw, 0.875rem);
    --text-sm: clamp(0.875rem, 3vw, 1rem);
    --text-base: clamp(1rem, 3.5vw, 1.125rem);
    --text-lg: clamp(1.125rem, 4vw, 1.25rem);
    --text-xl: clamp(1.25rem, 4.5vw, 1.5rem);
    --text-2xl: clamp(1.5rem, 5vw, 2rem);
    --text-3xl: clamp(2rem, 6vw, 2.5rem);
    
    /* Color system with dark theme optimization */
    --primary: #FFD700;
    --primary-dark: #FFA500;
    --secondary: #333;
    --secondary-light: #444;
    --background: #000;
    --surface: rgba(255, 255, 255, 0.05);
    --surface-elevated: rgba(255, 255, 255, 0.1);
    --text-primary: #fff;
    --text-secondary: rgba(255, 255, 255, 0.7);
    --text-accent: #FFD700;
    --border: rgba(255, 255, 255, 0.1);
    --border-active: rgba(255, 215, 0, 0.5);
    
    /* Animation durations */
    --transition-fast: 0.15s;
    --transition-normal: 0.25s;
    --transition-slow: 0.4s;
    
    /* Z-index scale */
    --z-dropdown: 1000;
    --z-sticky: 1020;
    --z-fixed: 1030;
    --z-modal-backdrop: 1040;
    --z-modal: 1050;
    --z-popover: 1060;
    --z-tooltip: 1070;
    --z-toast: 1080;
}

/* ===== DEVICE-SPECIFIC OPTIMIZATIONS ===== */
/* Android Moto G Play 2023: 720x1600, 6.5" screen */
@media screen and (device-width: 720px) and (device-height: 1600px) {
    :root {
        --base-font-size: 16px;
        --touch-target: 48px;
        --spacing-unit: 0.75rem;
    }
}

/* Common Android device optimizations */
@media screen and (-webkit-device-pixel-ratio: 2) and (max-width: 768px) {
    :root {
        --base-font-size: clamp(15px, 4.2vw, 17px);
        --touch-target: 46px;
    }
}

/* High DPI Android devices */
@media screen and (-webkit-device-pixel-ratio: 3) and (max-width: 768px) {
    :root {
        --base-font-size: clamp(14px, 4vw, 16px);
        --touch-target: 44px;
    }
}

/* ===== DYNAMIC VIEWPORT HANDLING ===== */
/* Fix viewport height issues on mobile browsers */
.full-height {
    height: 100vh;
    height: calc(var(--vh, 1vh) * 100);
}

.min-full-height {
    min-height: 100vh;
    min-height: calc(var(--vh, 1vh) * 100);
}

/* ===== RESET & FOUNDATION ===== */
*, *::before, *::after {
    box-sizing: border-box;
    -webkit-tap-highlight-color: transparent;
}

html {
    font-size: var(--base-font-size);
    -webkit-text-size-adjust: 100%;
    -ms-text-size-adjust: 100%;
    scroll-behavior: smooth;
}

@media (prefers-reduced-motion: reduce) {
    html {
        scroll-behavior: auto;
    }
}

body {
    margin: 0;
    padding: 0;
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', system-ui, sans-serif;
    font-size: var(--text-base);
    line-height: 1.6;
    color: var(--text-primary);
    background: url('/overlay.webp') center/cover fixed no-repeat !important;
    overflow-x: hidden;
    position: relative;
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
}

/* Overlay for readability */
body::before {
    content: '';
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.85);
    z-index: -1;
    pointer-events: none;
}

/* ===== ADVANCED CONTAINER SYSTEM ===== */
.container {
    width: 100%;
    margin: 0 auto;
    padding: 0 var(--space-md);
    max-width: var(--container-xl);
}

.container-fluid {
    width: 100%;
    padding: 0 var(--space-sm);
}

.container-xs { max-width: var(--container-xs); }
.container-sm { max-width: var(--container-sm); }
.container-md { max-width: var(--container-md); }
.container-lg { max-width: var(--container-lg); }
.container-xl { max-width: var(--container-xl); }

/* Responsive container padding */
@media (max-width: 480px) {
    .container {
        padding: 0 var(--space-sm);
    }
    .container-fluid {
        padding: 0 var(--space-xs);
    }
}

/* ===== ADVANCED GRID SYSTEM ===== */
.grid {
    display: grid;
    gap: var(--space-md);
    width: 100%;
}

.grid-auto { grid-template-columns: repeat(auto-fit, minmax(250px, 1fr)); }
.grid-1 { grid-template-columns: 1fr; }
.grid-2 { grid-template-columns: 1fr; }
.grid-3 { grid-template-columns: 1fr; }
.grid-4 { grid-template-columns: 1fr; }
.grid-5 { grid-template-columns: 1fr; }
.grid-6 { grid-template-columns: 1fr; }

/* Responsive grid breakpoints */
@media (min-width: 480px) {
    .grid-2 { grid-template-columns: repeat(2, 1fr); }
    .grid-4 { grid-template-columns: repeat(2, 1fr); }
    .grid-6 { grid-template-columns: repeat(2, 1fr); }
}

@media (min-width: 768px) {
    .grid-3 { grid-template-columns: repeat(3, 1fr); }
    .grid-6 { grid-template-columns: repeat(3, 1fr); }
}

@media (min-width: 1024px) {
    .grid-4 { grid-template-columns: repeat(4, 1fr); }
    .grid-5 { grid-template-columns: repeat(5, 1fr); }
    .grid-6 { grid-template-columns: repeat(6, 1fr); }
}

/* Flexible grid gaps */
.grid-gap-xs { gap: var(--space-xs); }
.grid-gap-sm { gap: var(--space-sm); }
.grid-gap-md { gap: var(--space-md); }
.grid-gap-lg { gap: var(--space-lg); }
.grid-gap-xl { gap: var(--space-xl); }

/* ===== FLUID TYPOGRAPHY SYSTEM ===== */
.text-xs { font-size: var(--text-xs); }
.text-sm { font-size: var(--text-sm); }
.text-base { font-size: var(--text-base); }
.text-lg { font-size: var(--text-lg); }
.text-xl { font-size: var(--text-xl); }
.text-2xl { font-size: var(--text-2xl); }
.text-3xl { font-size: var(--text-3xl); }

.heading-1 {
    font-size: var(--text-3xl);
    font-weight: 700;
    line-height: 1.2;
    color: var(--text-accent);
    margin-bottom: var(--space-md);
}

.heading-2 {
    font-size: var(--text-2xl);
    font-weight: 600;
    line-height: 1.3;
    color: var(--text-accent);
    margin-bottom: var(--space-sm);
}

.heading-3 {
    font-size: var(--text-xl);
    font-weight: 600;
    line-height: 1.4;
    color: var(--text-primary);
    margin-bottom: var(--space-sm);
}

.text-responsive {
    font-size: clamp(0.9rem, 2.5vw, 1.1rem);
    line-height: 1.6;
}

/* ===== ADVANCED BUTTON SYSTEM ===== */
.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    min-height: var(--touch-target);
    min-width: var(--touch-target);
    padding: var(--space-sm) var(--space-md);
    border: none;
    border-radius: 8px;
    font-size: var(--text-base);
    font-weight: 500;
    text-decoration: none;
    cursor: pointer;
    transition: all var(--transition-normal) ease;
    touch-action: manipulation;
    user-select: none;
    position: relative;
    overflow: hidden;
}

.btn::before {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(255, 255, 255, 0.1);
    opacity: 0;
    transition: opacity var(--transition-fast) ease;
}

.btn:hover::before,
.btn:focus::before {
    opacity: 1;
}

.btn:active {
    transform: scale(0.98);
}

/* Button variants */
.btn-primary {
    background: linear-gradient(135deg, var(--primary), var(--primary-dark));
    color: var(--background);
    box-shadow: 0 2px 8px rgba(255, 215, 0, 0.3);
}

.btn-secondary {
    background: var(--surface);
    color: var(--text-primary);
    border: 1px solid var(--border);
}

.btn-outline {
    background: transparent;
    color: var(--primary);
    border: 2px solid var(--primary);
}

.btn-ghost {
    background: transparent;
    color: var(--text-primary);
    border: 1px solid transparent;
}

.btn-danger {
    background: linear-gradient(135deg, #ff4444, #cc0000);
    color: white;
}

/* Button sizes */
.btn-xs {
    min-height: calc(var(--touch-target) * 0.75);
    min-width: calc(var(--touch-target) * 0.75);
    padding: var(--space-xs) var(--space-sm);
    font-size: var(--text-xs);
}

.btn-sm {
    min-height: calc(var(--touch-target) * 0.85);
    min-width: calc(var(--touch-target) * 0.85);
    padding: var(--space-xs) var(--space-sm);
    font-size: var(--text-sm);
}

.btn-lg {
    min-height: calc(var(--touch-target) * 1.2);
    padding: var(--space-md) var(--space-lg);
    font-size: var(--text-lg);
}

.btn-block {
    width: 100%;
    justify-content: center;
}

/* ===== ENHANCED MOBILE NAVIGATION ===== */
.nav-toggle {
    display: none;
    background: var(--surface-elevated);
    border: 1px solid var(--border-active);
    color: var(--primary);
    font-size: var(--text-lg);
    cursor: pointer;
    min-height: var(--touch-target);
    min-width: var(--touch-target);
    padding: var(--space-sm);
    position: fixed;
    top: var(--space-md);
    right: var(--space-md);
    z-index: var(--z-fixed);
    border-radius: 12px;
    backdrop-filter: blur(16px);
    transition: all var(--transition-normal) ease;
}

.nav-menu {
    display: flex;
    list-style: none;
    margin: 0;
    padding: 0;
    gap: var(--space-md);
    align-items: center;
}

@media (max-width: 768px) {
    .nav-toggle {
        display: flex !important;
        align-items: center;
        justify-content: center;
    }
    
    .nav-toggle:hover,
    .nav-toggle:focus {
        background: var(--surface-elevated);
        border-color: var(--primary);
        transform: scale(1.05);
    }
    
    .nav-menu {
        position: fixed;
        top: 0;
        left: -100%;
        width: min(85vw, 320px);
        height: calc(var(--vh, 1vh) * 100);
        background: rgba(0, 0, 0, 0.95);
        backdrop-filter: blur(20px);
        flex-direction: column;
        padding: calc(var(--touch-target) + var(--space-lg)) var(--space-md) var(--space-md);
        transition: left var(--transition-slow) cubic-bezier(0.4, 0, 0.2, 1);
        z-index: var(--z-modal);
        overflow-y: auto;
        overflow-x: hidden;
        overscroll-behavior: contain;
        gap: 0;
        border-right: 1px solid var(--border);
    }
    
    .nav-menu.active {
        left: 0;
    }
    
    .nav-menu li {
        width: 100%;
        margin: var(--space-xs) 0;
    }
    
    .nav-menu a {
        width: 100%;
        padding: var(--space-md);
        border-radius: 8px;
        display: flex;
        align-items: center;
        color: var(--text-primary);
        text-decoration: none;
        transition: all var(--transition-normal) ease;
        border: 1px solid transparent;
    }
    
    .nav-menu a:hover,
    .nav-menu a:focus {
        background: var(--surface);
        border-color: var(--border-active);
        color: var(--primary);
    }
    
    .nav-overlay {
        display: none;
        position: fixed;
        top: 0;
        left: 0;
        width: 100%;
        height: 100%;
        background: rgba(0, 0, 0, 0.6);
        z-index: calc(var(--z-modal) - 1);
        backdrop-filter: blur(4px);
    }
    
    .nav-overlay.active {
        display: block;
    }
}

/* ===== ENHANCED FORM SYSTEM ===== */
.form-group {
    margin-bottom: var(--space-md);
}

.form-label {
    display: block;
    margin-bottom: var(--space-xs);
    font-weight: 500;
    color: var(--text-accent);
    font-size: var(--text-sm);
}

.form-input,
.form-select,
.form-textarea {
    width: 100%;
    min-height: var(--touch-target);
    padding: var(--space-sm);
    border: 2px solid var(--border);
    border-radius: 8px;
    background: var(--surface);
    color: var(--text-primary);
    font-size: var(--text-base);
    transition: all var(--transition-normal) ease;
    resize: none;
}

.form-input:focus,
.form-select:focus,
.form-textarea:focus {
    outline: none;
    border-color: var(--border-active);
    box-shadow: 0 0 0 3px rgba(255, 215, 0, 0.1);
    background: var(--surface-elevated);
}

.form-textarea {
    min-height: calc(var(--touch-target) * 2.5);
    resize: vertical;
}

.form-input[disabled],
.form-select[disabled],
.form-textarea[disabled] {
    opacity: 0.6;
    cursor: not-allowed;
}

/* Input groups */
.input-group {
    display: flex;
    width: 100%;
}

.input-group .form-input {
    border-radius: 8px 0 0 8px;
    border-right: none;
}

.input-group .btn {
    border-radius: 0 8px 8px 0;
    border-left: none;
}

/* ===== ADVANCED TABLE SYSTEM ===== */
.table-responsive {
    width: 100%;
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
    border-radius: 8px;
    background: var(--surface);
}

.table {
    width: 100%;
    border-collapse: collapse;
    font-size: var(--text-sm);
}

.table th,
.table td {
    padding: var(--space-sm);
    text-align: left;
    border-bottom: 1px solid var(--border);
    vertical-align: middle;
}

.table th {
    background: var(--surface-elevated);
    color: var(--text-accent);
    font-weight: 600;
    font-size: var(--text-xs);
    text-transform: uppercase;
    letter-spacing: 0.05em;
}

.table tbody tr:hover {
    background: var(--surface);
}

/* Mobile table transformation */
@media (max-width: 767px) {
    .table-mobile {
        font-size: var(--text-sm);
    }
    
    .table-mobile thead {
        display: none;
    }
    
    .table-mobile tbody,
    .table-mobile tr,
    .table-mobile td {
        display: block;
        width: 100%;
    }
    
    .table-mobile tr {
        margin-bottom: var(--space-md);
        padding: var(--space-md);
        background: var(--surface);
        border-radius: 12px;
        border: 1px solid var(--border);
        box-shadow: 0 2px 8px rgba(0, 0, 0, 0.1);
    }
    
    .table-mobile td {
        padding: var(--space-xs) 0;
        border: none;
        position: relative;
        padding-left: 40%;
        min-height: calc(var(--touch-target) * 0.8);
        display: flex;
        align-items: center;
        word-wrap: break-word;
    }
    
    .table-mobile td:before {
        content: attr(data-label);
        position: absolute;
        left: 0;
        width: 35%;
        padding-right: var(--space-xs);
        font-weight: 600;
        color: var(--text-accent);
        font-size: var(--text-xs);
        text-transform: uppercase;
        letter-spacing: 0.05em;
        display: flex;
        align-items: center;
    }
    
    .table-mobile td .btn {
        max-width: 100%;
        margin: var(--space-xs) 0;
        font-size: var(--text-xs);
    }
}

/* ===== MODAL SYSTEM ===== */
.modal-overlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.8);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: var(--z-modal);
    padding: var(--space-md);
    backdrop-filter: blur(8px);
}

.modal-content {
    background: var(--background);
    border-radius: 16px;
    width: 100%;
    max-width: 500px;
    max-height: 90vh;
    overflow-y: auto;
    position: relative;
    border: 1px solid var(--border);
    box-shadow: 0 20px 40px rgba(0, 0, 0, 0.3);
}

.modal-header {
    padding: var(--space-lg);
    border-bottom: 1px solid var(--border);
    display: flex;
    align-items: center;
    justify-content: space-between;
    position: sticky;
    top: 0;
    background: var(--background);
    z-index: 1;
}

.modal-title {
    font-size: var(--text-xl);
    font-weight: 600;
    color: var(--text-accent);
    margin: 0;
}

.modal-body {
    padding: var(--space-lg);
}

.modal-footer {
    padding: var(--space-lg);
    border-top: 1px solid var(--border);
    display: flex;
    gap: var(--space-sm);
    justify-content: flex-end;
    position: sticky;
    bottom: 0;
    background: var(--background);
}

.modal-close {
    background: none;
    border: none;
    color: var(--text-secondary);
    font-size: var(--text-xl);
    cursor: pointer;
    min-height: var(--touch-target);
    min-width: var(--touch-target);
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: 8px;
    transition: all var(--transition-normal) ease;
}

.modal-close:hover,
.modal-close:focus {
    background: var(--surface);
    color: var(--text-primary);
}

@media (max-width: 480px) {
    .modal-content {
        margin: 0;
        border-radius: 16px 16px 0 0;
        max-height: 95vh;
        position: fixed;
        bottom: 0;
        left: 0;
        right: 0;
        width: 100%;
    }
    
    .modal-footer {
        flex-direction: column;
    }
    
    .modal-footer .btn {
        width: 100%;
    }
}

/* ===== CARD COMPONENTS ===== */
.card {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: 12px;
    padding: var(--space-lg);
    margin-bottom: var(--space-md);
    transition: all var(--transition-normal) ease;
}

.card:hover {
    background: var(--surface-elevated);
    border-color: var(--border-active);
    transform: translateY(-2px);
    box-shadow: 0 8px 16px rgba(0, 0, 0, 0.2);
}

.card-header {
    border-bottom: 1px solid var(--border);
    padding-bottom: var(--space-md);
    margin-bottom: var(--space-md);
}

.card-title {
    color: var(--text-accent);
    font-size: var(--text-lg);
    font-weight: 600;
    margin: 0 0 var(--space-xs) 0;
}

.card-subtitle {
    color: var(--text-secondary);
    font-size: var(--text-sm);
    margin: 0;
}

.card-body {
    color: var(--text-primary);
}

.card-footer {
    border-top: 1px solid var(--border);
    padding-top: var(--space-md);
    margin-top: var(--space-md);
    display: flex;
    gap: var(--space-sm);
    justify-content: flex-end;
}

/* ===== ALERT SYSTEM ===== */
.alert {
    padding: var(--space-md);
    border-radius: 8px;
    margin-bottom: var(--space-md);
    border-left: 4px solid;
    display: flex;
    align-items: flex-start;
    gap: var(--space-sm);
}

.alert-success {
    background: rgba(34, 197, 94, 0.1);
    border-color: #22c55e;
    color: #86efac;
}

.alert-error {
    background: rgba(239, 68, 68, 0.1);
    border-color: #ef4444;
    color: #fca5a5;
}

.alert-warning {
    background: rgba(245, 158, 11, 0.1);
    border-color: #f59e0b;
    color: #fcd34d;
}

.alert-info {
    background: rgba(59, 130, 246, 0.1);
    border-color: #3b82f6;
    color: #93c5fd;
}

.alert-icon {
    flex-shrink: 0;
    width: 20px;
    height: 20px;
    margin-top: 2px;
}

.alert-content {
    flex: 1;
    min-width: 0;
}

.alert-title {
    font-weight: 600;
    margin-bottom: var(--space-xs);
}

.alert-message {
    font-size: var(--text-sm);
    line-height: 1.5;
}

/* ===== UTILITY CLASSES ===== */
/* Spacing utilities */
.p-0 { padding: 0; }
.p-1 { padding: var(--space-xs); }
.p-2 { padding: var(--space-sm); }
.p-3 { padding: var(--space-md); }
.p-4 { padding: var(--space-lg); }
.p-5 { padding: var(--space-xl); }

.m-0 { margin: 0; }
.m-1 { margin: var(--space-xs); }
.m-2 { margin: var(--space-sm); }
.m-3 { margin: var(--space-md); }
.m-4 { margin: var(--space-lg); }
.m-5 { margin: var(--space-xl); }

.mt-auto { margin-top: auto; }
.mr-auto { margin-right: auto; }
.mb-auto { margin-bottom: auto; }
.ml-auto { margin-left: auto; }

/* Text utilities */
.text-center { text-align: center; }
.text-left { text-align: left; }
.text-right { text-align: right; }

.text-primary { color: var(--text-primary); }
.text-secondary { color: var(--text-secondary); }
.text-accent { color: var(--text-accent); }

.font-normal { font-weight: 400; }
.font-medium { font-weight: 500; }
.font-semibold { font-weight: 600; }
.font-bold { font-weight: 700; }

/* Display utilities */
.d-none { display: none; }
.d-block { display: block; }
.d-flex { display: flex; }
.d-grid { display: grid; }

.flex-column { flex-direction: column; }
.flex-row { flex-direction: row; }
.flex-wrap { flex-wrap: wrap; }
.flex-nowrap { flex-wrap: nowrap; }

.justify-start { justify-content: flex-start; }
.justify-center { justify-content: center; }
.justify-end { justify-content: flex-end; }
.justify-between { justify-content: space-between; }

.items-start { align-items: flex-start; }
.items-center { align-items: center; }
.items-end { align-items: flex-end; }

/* Responsive utilities */
.hide-mobile { display: block; }
.show-mobile { display: none; }

@media (max-width: 768px) {
    .hide-mobile { display: none !important; }
    .show-mobile { display: block !important; }
    .show-mobile-flex { display: flex !important; }
    .show-mobile-grid { display: grid !important; }
}

@media (min-width: 769px) {
    .hide-desktop { display: none !important; }
    .show-desktop { display: block !important; }
    .show-desktop-flex { display: flex !important; }
    .show-desktop-grid { display: grid !important; }
}

/* Width and height utilities */
.w-full { width: 100%; }
.w-auto { width: auto; }
.h-full { height: 100%; }
.h-auto { height: auto; }

.max-w-full { max-width: 100%; }
.max-h-full { max-height: 100%; }

/* Overflow utilities */
.overflow-hidden { overflow: hidden; }
.overflow-auto { overflow: auto; }
.overflow-x-hidden { overflow-x: hidden; }
.overflow-y-auto { overflow-y: auto; }

/* Position utilities */
.relative { position: relative; }
.absolute { position: absolute; }
.fixed { position: fixed; }
.sticky { position: sticky; }

/* ===== TOUCH & INTERACTION OPTIMIZATIONS ===== */
.touch-action-manipulation { touch-action: manipulation; }
.touch-action-pan-y { touch-action: pan-y; }
.touch-action-none { touch-action: none; }

.select-none { user-select: none; }
.select-text { user-select: text; }
.select-all { user-select: all; }

/* Smooth scrolling for touch devices */
.smooth-scroll {
    -webkit-overflow-scrolling: touch;
    scroll-behavior: smooth;
}

/* ===== PERFORMANCE OPTIMIZATIONS ===== */
.will-change-transform { will-change: transform; }
.will-change-scroll { will-change: scroll-position; }

.backface-hidden { backface-visibility: hidden; }
.perspective-1000 { perspective: 1000px; }

/* ===== ACCESSIBILITY ENHANCEMENTS ===== */
.sr-only {
    position: absolute;
    width: 1px;
    height: 1px;
    padding: 0;
    margin: -1px;
    overflow: hidden;
    clip: rect(0, 0, 0, 0);
    white-space: nowrap;
    border: 0;
}

.focus-visible:focus {
    outline: 2px solid var(--primary);
    outline-offset: 2px;
}

/* Skip links completely hidden per user request */
.skip-link {
    display: none !important;
    visibility: hidden !important;
}

/* ===== PRINT OPTIMIZATIONS ===== */
@media print {
    .no-print { display: none !important; }
    
    .btn,
    .nav-toggle,
    .nav-menu {
        display: none !important;
    }
    
    .card {
        border: 1px solid #ccc !important;
        box-shadow: none !important;
    }
}

/* ===== HIGH CONTRAST MODE ===== */
@media (prefers-contrast: high) {
    :root {
        --border: #fff;
        --border-active: #fff;
        --surface: rgba(255, 255, 255, 0.1);
        --surface-elevated: rgba(255, 255, 255, 0.2);
    }
    
    .btn {
        border: 2px solid currentColor !important;
    }
    
    .form-input,
    .form-select,
    .form-textarea {
        border: 2px solid currentColor !important;
    }
}

/* ===== REDUCED MOTION ===== */
@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;
    }
}

/* ===== DARK MODE OPTIMIZATIONS ===== */
@media (prefers-color-scheme: dark) {
    :root {
        --text-primary: #fff;
        --text-secondary: rgba(255, 255, 255, 0.7);
        --background: #000;
        --surface: rgba(255, 255, 255, 0.05);
        --surface-elevated: rgba(255, 255, 255, 0.1);
    }
}

/* ===== ORIENTATION HANDLING ===== */
@media (orientation: landscape) and (max-height: 500px) {
    :root {
        --space-md: var(--space-sm);
        --space-lg: var(--space-md);
    }
    
    .nav-menu {
        padding-top: calc(var(--touch-target) + var(--space-sm));
    }
    
    .modal-content {
        max-height: 95vh;
    }
}

/* ===== DEVICE-SPECIFIC FIXES ===== */
/* Fix iOS zoom on input focus */
@supports (-webkit-touch-callout: none) {
    .form-input,
    .form-select,
    .form-textarea {
        font-size: max(16px, var(--text-base));
    }
}

/* Android-specific optimizations */
@media screen and (-webkit-device-pixel-ratio: 2) {
    .btn,
    .form-input,
    .form-select,
    .form-textarea {
        -webkit-appearance: none;
        appearance: none;
    }
}