@import url('https://fonts.googleapis.com/css2?family=Inter:wght@300;500;600;700&display=swap');

/* Reset and Base Styles */
* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
    -webkit-tap-highlight-color: transparent;
    -webkit-touch-callout: none;
    -webkit-user-select: none;
    user-select: none;
}

/* Enhanced mobile viewport handling */
html {
    height: 100%;
    width: 100%;
    overflow-x: hidden;
    /* Prevent zoom on input focus (iOS) */
    -webkit-text-size-adjust: 100%;
    -ms-text-size-adjust: 100%;
}

/* Ensure proper viewport on mobile */
@supports (height: 100dvh) {
    html, body {
        height: 100dvh;
    }
}

body {
    background: #000;
    font-family: 'Inter', -apple-system, BlinkMacSystemFont, sans-serif;
    height: 100vh;
    height: 100dvh;
    color: #fff;
    overflow: hidden;
    -webkit-text-size-adjust: 100%;
    -ms-text-size-adjust: 100%;
    position: relative;
    display: flex;
    flex-direction: column;
}

/* Grid Background */
body::before {
    content: '';
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background-image: 
        linear-gradient(rgba(0, 212, 255, 0.03) 1px, transparent 1px),
        linear-gradient(90deg, rgba(0, 212, 255, 0.03) 1px, transparent 1px);
    background-size: 50px 50px;
    background-position: -1px -1px;
    pointer-events: none;
    z-index: 1;
}

/* Animated spotlight effect */
@keyframes spotlight {
    0% {
        background: radial-gradient(
            circle at 20% 30%,
            rgba(0, 212, 255, 0.08) 0%,
            transparent 40%
        );
    }
    33% {
        background: radial-gradient(
            circle at 80% 60%,
            rgba(0, 212, 255, 0.08) 0%,
            transparent 40%
        );
    }
    66% {
        background: radial-gradient(
            circle at 50% 80%,
            rgba(0, 212, 255, 0.08) 0%,
            transparent 40%
        );
    }
    100% {
        background: radial-gradient(
            circle at 20% 30%,
            rgba(0, 212, 255, 0.08) 0%,
            transparent 40%
        );
    }
}

/* Gradient overlay with animated spotlight */
body::after {
    content: '';
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: radial-gradient(
        circle at 20% 30%,
        rgba(0, 212, 255, 0.08) 0%,
        transparent 40%
    );
    pointer-events: none;
    z-index: 2;
    animation: spotlight 20s ease-in-out infinite;
}

/* Ensure all content is above the grid */
.header, .tab-container, .tab-content, .footer, .philosophy-modal, .checkout-modal {
    position: relative;
    z-index: 10;
}

/* Header - Compact height for no-scroll design */
.header {
    padding: 6px 12px;
    text-align: center;
    background: linear-gradient(180deg, rgba(0,0,0,0.8) 0%, rgba(10,10,10,0.6) 100%);
    position: relative;
    backdrop-filter: blur(10px);
    z-index: 10;
    flex-shrink: 0;
    height: 50px;
    display: flex;
    flex-direction: column;
    justify-content: center;
    align-items: center;
    order: 1;
}

/* Header title container with Philosophy icon - Safari optimized */
.header-title-container {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 12px;
    margin-bottom: 6px;
    flex-wrap: nowrap;
    width: 100%;
    max-width: 100%;
    overflow: hidden;
}

.header h1 {
    font-size: 20px;
    font-weight: 700;
    color: #fff;
    margin: 0;
    letter-spacing: -0.5px;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

/* Header Philosophy Icon removed - philosophy accessible via modal only */

.header p {
    font-size: 11px;
    color: #888;
    line-height: 1.4;
    padding: 0 16px;
}

/* Arsenal Section - Compact for viewport fit */
.arsenal-section {
    display: flex;
    justify-content: center;
    padding: 15px 20px;
    flex-shrink: 0;
    height: 60px;
    align-items: center;
}

.arsenal-btn {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 12px 24px;
    background: rgba(255, 255, 255, 0.08);
    border: 1px solid rgba(255, 255, 255, 0.15);
    border-radius: 8px;
    color: #ffffff;
    font-size: 16px;
    font-weight: 500;
    text-decoration: none;
    cursor: pointer;
    transition: all 0.2s ease;
    min-height: 48px;
    touch-action: manipulation;
}

.arsenal-btn:hover {
    background: rgba(255, 255, 255, 0.12);
    border-color: rgba(255, 255, 255, 0.25);
    transform: translateY(-1px);
}

.arsenal-btn:active {
    transform: translateY(0);
    background: rgba(255, 255, 255, 0.06);
}


/* Pagination Controls */
.pagination {
    display: flex;
    justify-content: center;
    align-items: center;
    gap: 15px;
    padding: 10px;
    margin: 0;
    position: absolute;
    bottom: 70px; /* Above arsenal section */
    left: 50%;
    transform: translateX(-50%);
    z-index: 100;
}

.pagination-btn {
    width: 40px;
    height: 40px;
    border-radius: 50%;
    background: rgba(255, 255, 255, 0.05);
    border: 1px solid rgba(255, 255, 255, 0.1);
    color: rgba(255, 255, 255, 0.7);
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    transition: all 0.3s ease;
}

.pagination-btn:hover:not(:disabled) {
    background: rgba(255, 255, 255, 0.1);
    border-color: rgba(255, 255, 255, 0.2);
    transform: scale(1.1);
}

.pagination-btn:disabled {
    opacity: 0.3;
    cursor: not-allowed;
}

.pagination-btn svg {
    width: 18px;
    height: 18px;
}

.pagination-info {
    display: flex;
    align-items: center;
    gap: 8px;
    color: rgba(255, 255, 255, 0.6);
    font-size: 14px;
    font-weight: 500;
}

.page-current {
    color: rgba(255, 255, 255, 0.9);
    font-size: 16px;
}

.page-separator {
    color: rgba(255, 255, 255, 0.4);
}

.page-total {
    color: rgba(255, 255, 255, 0.6);
}




/* Philosophy Modal */
.philosophy-modal {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.95);
    backdrop-filter: blur(20px);
    z-index: 1000;
    display: none;
    animation: fadeIn 0.4s ease;
}

.philosophy-modal.active {
    display: flex;
    flex-direction: column;
    justify-content: center;
    align-items: center;
}

.philosophy-content {
    max-width: 800px;
    padding: 40px 20px;
    text-align: center;
    animation: slideUp 0.5s ease;
}

@keyframes slideUp {
    from { transform: translateY(30px); opacity: 0; }
    to { transform: translateY(0); opacity: 1; }
}

.philosophy-close {
    position: absolute;
    top: 30px;
    right: 30px;
    width: 40px;
    height: 40px;
    background: rgba(255, 255, 255, 0.1);
    border: 1px solid rgba(255, 255, 255, 0.2);
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    transition: all 0.3s ease;
}

.philosophy-close:hover {
    background: rgba(255, 255, 255, 0.2);
    transform: rotate(90deg);
}

.philosophy-close svg {
    width: 20px;
    height: 20px;
    color: #fff;
}

.philosophy-translate {
    position: absolute;
    top: 30px;
    left: 30px;
    width: 60px;
    height: 40px;
    background: rgba(255, 255, 255, 0.1);
    border: 1px solid rgba(255, 255, 255, 0.2);
    border-radius: 20px;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 4px;
    cursor: pointer;
    transition: all 0.3s ease;
    font-size: 11px;
    font-weight: 600;
    color: #fff;
}

.philosophy-translate:hover {
    background: rgba(255, 255, 255, 0.2);
    transform: scale(1.05);
}

.philosophy-translate svg {
    width: 16px;
    height: 16px;
    color: #fff;
}

.entrance-replay-btn {
    position: absolute;
    top: calc(20px + env(safe-area-inset-top));
    left: calc(100px + env(safe-area-inset-left));
    width: 44px;
    height: 44px;
    background: rgba(255, 255, 255, 0.1);
    border: 1px solid rgba(255, 255, 255, 0.2);
    border-radius: 22px;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    transition: all 0.3s ease;
    font-size: 11px;
    font-weight: 600;
    color: #fff;
    z-index: 1001;
}

.entrance-replay-btn:hover {
    background: rgba(255, 255, 255, 0.2);
    transform: scale(1.05);
}

.entrance-replay-btn svg {
    width: 18px;
    height: 18px;
    color: #fff;
    transition: transform 0.3s ease;
}

.entrance-replay-btn:active svg {
    transform: rotate(180deg);
}

.philosophy-title {
    font-size: 36px;
    font-weight: 700;
    color: #ffffff;
    margin-bottom: 30px;
    letter-spacing: -1px;
}

.philosophy-text {
    font-size: 16px;
    line-height: 1.8;
    color: #ccc;
    margin-bottom: 20px;
}

.philosophy-highlight {
    color: #00d4ff;
    font-weight: 600;
}

/* Tab Navigation - Hidden (removed from design) */
.tab-container {
    display: none;
}

/* Philosophy Book Icon removed - philosophy accessible via modal only */

.tabs {
    display: flex;
    justify-content: center;
    overflow-x: auto;
    padding: 6px 10px;
    gap: 6px;
    scrollbar-width: none;
    -ms-overflow-style: none;
    scroll-behavior: smooth;
}

.tabs::-webkit-scrollbar {
    display: none;
}

.tab {
    flex-shrink: 0;
    padding: 8px 16px;
    background: #111;
    border: 1px solid #333;
    border-radius: 20px;
    color: #888;
    font-size: 12px;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.3s ease;
    user-select: none;
}

.tab.active {
    background: linear-gradient(135deg, #00d4ff 0%, #0099cc 100%);
    color: #000;
    border-color: transparent;
    transform: scale(1.05);
}

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

/* Apps Container - No tabs, fills remaining viewport space */
.apps-container {
    flex: 1;
    display: flex;
    flex-direction: column;
    overflow: hidden;
    position: relative;
    min-height: 0;
    order: 3;
}

@keyframes fadeIn {
    from { opacity: 0; transform: translateY(10px); }
    to { opacity: 1; transform: translateY(0); }
}

/* Grid Layout - Fixed 3x3 grid filling available viewport (no tabs) */
.grid {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    grid-template-rows: repeat(3, 1fr);
    gap: 10px;
    padding: 15px;
    width: 100%;
    max-width: min(90vw, 600px);
    height: calc(100vh - 150px); /* header(50) + arsenal(60) + footer(40) */
    max-height: calc(100vh - 150px);
    margin: 0 auto;
    align-content: center;
    justify-content: center;
    justify-items: center;
    align-items: center;
    box-sizing: border-box;
}

.app-link {
    text-decoration: none;
    color: inherit;
    display: block;
    cursor: pointer;
}

.icon-container {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 12px;
    width: 100%;
    height: 100%;
    padding: 5px;
    box-sizing: border-box;
}

.icon-wrapper {
    width: min(22vw, 90px);
    height: min(22vw, 90px);
    max-width: 90px;
    max-height: 90px;
    aspect-ratio: 1;
    background: rgba(0, 0, 0, 0.6);
    backdrop-filter: blur(10px);
    border: 1px solid rgba(0, 212, 255, 0.05);
    border-radius: 20px;
    display: flex;
    flex-direction: column;
    justify-content: center;
    align-items: center;
    gap: 3px;
    transition: all 0.3s ease;
    position: relative;
    overflow: hidden;
}

.icon-wrapper::before {
    content: '';
    position: absolute;
    top: 50%;
    left: 50%;
    width: 120%;
    height: 120%;
    background: radial-gradient(circle, currentColor, transparent);
    opacity: 0;
    transform: translate(-50%, -50%);
    transition: opacity 0.3s ease;
    pointer-events: none;
}

.app-link:active .icon-wrapper {
    transform: scale(0.95);
}

@media (hover: hover) {
    .app-link:hover .icon-wrapper {
        transform: translateY(-4px) scale(1.02);
    }
    
    .app-link:hover .icon-wrapper::before {
        opacity: 0.1;
    }
}

.v-letter {
    font-size: 16px;
    font-weight: 700;
    line-height: 1;
}

.ledger-text {
    font-size: 5px;
    font-weight: 600;
    letter-spacing: 1px;
    text-transform: uppercase;
}

.app-name {
    font-size: 10px;
    font-weight: 600;
    color: #fff;
}

/* Pagination Controls - Close to icons */
.pagination {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 16px;
    padding: 4px 20px;
    flex-shrink: 0;
    height: 35px;
    margin-top: -5px;
}

.pagination-btn {
    width: 44px;
    height: 44px;
    background: rgba(255, 255, 255, 0.1);
    border: 1px solid rgba(255, 255, 255, 0.2);
    border-radius: 50%;
    color: #fff;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.3s ease;
    touch-action: manipulation;
}

.pagination-btn:hover:not(:disabled) {
    background: rgba(255, 255, 255, 0.2);
    transform: scale(1.05);
}

.pagination-btn:active:not(:disabled) {
    transform: scale(0.95);
}

.pagination-btn:disabled {
    opacity: 0.3;
    cursor: not-allowed;
    transform: none;
}

.pagination-btn svg {
    width: 20px;
    height: 20px;
}

.pagination-info {
    display: flex;
    align-items: center;
    gap: 8px;
    font-size: 14px;
    font-weight: 600;
    color: #fff;
    min-width: 80px;
    justify-content: center;
}

.page-current {
    color: #00d4ff;
    font-size: 16px;
}

.page-separator {
    color: rgba(255, 255, 255, 0.6);
    font-size: 12px;
}

.page-total {
    color: rgba(255, 255, 255, 0.8);
}

/* Pagination animations */
@keyframes slideOutLeft {
    from {
        opacity: 1;
        transform: translateX(0) scale(1);
    }
    to {
        opacity: 0;
        transform: translateX(-100px) scale(0.9);
    }
}

@keyframes slideOutRight {
    from {
        opacity: 1;
        transform: translateX(0) scale(1);
    }
    to {
        opacity: 0;
        transform: translateX(100px) scale(0.9);
    }
}

@keyframes slideInLeft {
    from {
        opacity: 0;
        transform: translateX(-100px) scale(0.9);
    }
    to {
        opacity: 1;
        transform: translateX(0) scale(1);
    }
}

@keyframes slideInRight {
    from {
        opacity: 0;
        transform: translateX(100px) scale(0.9);
    }
    to {
        opacity: 1;
        transform: translateX(0) scale(1);
    }
}

/* Footer - Compact height, always at bottom */
.footer {
    padding: 6px 12px;
    border-top: 1px solid #222;
    flex-shrink: 0;
    height: 40px;
    display: flex;
    flex-direction: column;
    justify-content: center;
    align-items: center;
    position: relative;
    z-index: 10;
    margin-top: auto;
}

.footer-items {
    display: flex;
    flex-wrap: wrap;
    justify-content: center;
    gap: 10px;
    font-size: 9px;
    color: #666;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    margin-bottom: 12px;
}

.footer-item {
    padding: 5px 10px;
    background: #111;
    border-radius: 10px;
}

.footer-pricing {
    text-align: center;
    font-size: 12px;
    color: #aaa;
    font-weight: 500;
}

.footer-pricing span {
    color: #00d4ff;
    font-weight: 700;
    font-size: 14px;
}

.footer-pricing .price-detail {
    font-size: 10px;
    color: #666;
    display: block;
    margin-top: 2px;
}

/* Color Schemes for Apps */
.vunotes .v-letter, .vunotes .ledger-text, .vunotes .checkout-icon { color: #00d4ff; }
.vunotes .icon-wrapper { box-shadow: 0 6px 20px rgba(0, 212, 255, 0.2); }
.vunotes .icon-wrapper::before { color: #00d4ff; }

.vuvault .v-letter, .vuvault .ledger-text, .vuvault .checkout-icon { color: #f5f5f0; }
.vuvault .icon-wrapper { background: rgba(26, 26, 26, 0.8); box-shadow: 0 6px 20px rgba(0, 0, 0, 0.4); }
.vuvault .icon-wrapper::before { color: #f5f5f0; }

.vuwallet .v-letter, .vuwallet .ledger-text, .vuwallet .checkout-icon { color: #9333ea; }
.vuwallet .icon-wrapper { box-shadow: 0 6px 20px rgba(147, 51, 234, 0.2); }
.vuwallet .icon-wrapper::before { color: #9333ea; }

.vutext .v-letter, .vutext .ledger-text, .vutext .checkout-icon { color: #f97316; }
.vutext .icon-wrapper { box-shadow: 0 6px 20px rgba(249, 115, 22, 0.2); }
.vutext .icon-wrapper::before { color: #f97316; }

.vumail .v-letter, .vumail .ledger-text, .vumail .checkout-icon { color: #3b82f6; }
.vumail .icon-wrapper { box-shadow: 0 6px 20px rgba(59, 130, 246, 0.2); }
.vumail .icon-wrapper::before { color: #3b82f6; }

.vucal .v-letter, .vucal .ledger-text, .vucal .checkout-icon { color: #ef4444; }
.vucal .icon-wrapper { box-shadow: 0 6px 20px rgba(239, 68, 68, 0.2); }
.vucal .icon-wrapper::before { color: #ef4444; }

.vudrive .v-letter, .vudrive .ledger-text, .vudrive .checkout-icon { color: #22c55e; }
.vudrive .icon-wrapper { box-shadow: 0 6px 20px rgba(34, 197, 94, 0.2); }
.vudrive .icon-wrapper::before { color: #22c55e; }

.vuvoice .v-letter, .vuvoice .ledger-text, .vuvoice .checkout-icon { color: #3b82f6; }
.vuvoice .icon-wrapper { box-shadow: 0 6px 20px rgba(59, 130, 246, 0.2); }
.vuvoice .icon-wrapper::before { color: #3b82f6; }

.vuchat .v-letter, .vuchat .ledger-text, .vuchat .checkout-icon { color: #ec4899; }
.vuchat .icon-wrapper { box-shadow: 0 6px 20px rgba(236, 72, 153, 0.2); }
.vuchat .icon-wrapper::before { color: #ec4899; }

.vuphotos .v-letter, .vuphotos .ledger-text, .vuphotos .checkout-icon { color: #eab308; }
.vuphotos .icon-wrapper { box-shadow: 0 6px 20px rgba(234, 179, 8, 0.2); }
.vuphotos .icon-wrapper::before { color: #eab308; }

.vutask .v-letter, .vutask .ledger-text, .vutask .checkout-icon { color: #a78bfa; }
.vutask .icon-wrapper { box-shadow: 0 6px 20px rgba(167, 139, 250, 0.2); }
.vutask .icon-wrapper::before { color: #a78bfa; }

.vumeet .v-letter, .vumeet .ledger-text, .vumeet .checkout-icon { color: #8b5cf6; }
.vumeet .icon-wrapper { box-shadow: 0 6px 20px rgba(139, 92, 246, 0.2); }
.vumeet .icon-wrapper::before { color: #8b5cf6; }

.vudocs .v-letter, .vudocs .ledger-text, .vudocs .checkout-icon { color: #0ea5e9; }
.vudocs .icon-wrapper { box-shadow: 0 6px 20px rgba(14, 165, 233, 0.2); }
.vudocs .icon-wrapper::before { color: #0ea5e9; }

.vuconvert .v-letter, .vuconvert .ledger-text, .vuconvert .checkout-icon { color: #fb923c; }
.vuconvert .icon-wrapper { box-shadow: 0 6px 20px rgba(251, 146, 60, 0.2); }
.vuconvert .icon-wrapper::before { color: #fb923c; }

.vucode .v-letter, .vucode .ledger-text, .vucode .checkout-icon { color: #84cc16; }
.vucode .icon-wrapper { box-shadow: 0 6px 20px rgba(132, 204, 22, 0.2); }
.vucode .icon-wrapper::before { color: #84cc16; }

.vuvideo .v-letter, .vuvideo .ledger-text, .vuvideo .checkout-icon { color: #d946ef; }
.vuvideo .icon-wrapper { box-shadow: 0 6px 20px rgba(217, 70, 239, 0.2); }
.vuvideo .icon-wrapper::before { color: #d946ef; }

.vubooks .v-letter, .vubooks .ledger-text, .vubooks .checkout-icon { color: #b45309; }
.vubooks .icon-wrapper { box-shadow: 0 6px 20px rgba(180, 83, 9, 0.2); }
.vubooks .icon-wrapper::before { color: #b45309; }

.vucontacts .v-letter, .vucontacts .ledger-text, .vucontacts .checkout-icon { color: #14b8a6; }
.vucontacts .icon-wrapper { box-shadow: 0 6px 20px rgba(20, 184, 166, 0.2); }
.vucontacts .icon-wrapper::before { color: #14b8a6; }

.vubrowser .v-letter, .vubrowser .ledger-text, .vubrowser .checkout-icon { color: #6366f1; }
.vubrowser .icon-wrapper { box-shadow: 0 6px 20px rgba(99, 102, 241, 0.2); }
.vubrowser .icon-wrapper::before { color: #6366f1; }

.vupass .v-letter, .vupass .ledger-text, .vupass .checkout-icon { color: #64748b; }
.vupass .icon-wrapper { box-shadow: 0 6px 20px rgba(100, 116, 139, 0.2); }
.vupass .icon-wrapper::before { color: #64748b; }

.vuscan .v-letter, .vuscan .ledger-text, .vuscan .checkout-icon { color: #10b981; }
.vuscan .icon-wrapper { box-shadow: 0 6px 20px rgba(16, 185, 129, 0.2); }
.vuscan .icon-wrapper::before { color: #10b981; }

.vuhealth .v-letter, .vuhealth .ledger-text, .vuhealth .checkout-icon { color: #e11d48; }
.vuhealth .icon-wrapper { box-shadow: 0 6px 20px rgba(225, 29, 72, 0.2); }
.vuhealth .icon-wrapper::before { color: #e11d48; }

.vufit .v-letter, .vufit .ledger-text, .vufit .checkout-icon { color: #f97316; }
.vufit .icon-wrapper { box-shadow: 0 6px 20px rgba(249, 115, 22, 0.2); }
.vufit .icon-wrapper::before { color: #f97316; }

.vunews .v-letter, .vunews .ledger-text, .vunews .checkout-icon { color: #94a3b8; }
.vunews .icon-wrapper { box-shadow: 0 6px 20px rgba(148, 163, 184, 0.2); }
.vunews .icon-wrapper::before { color: #94a3b8; }

/* MOBILE VIEWPORT (up to 480px) - No-scroll viewport fit */
@media (max-width: 480px) {
    /* Viewport structure: Header(50px) + Grid(flex) + Arsenal(55px) + Footer(35px) = 100vh */
    
    body {
        height: 100vh !important;
        height: 100dvh !important;
        overflow: hidden !important;
        width: 100% !important;
        max-width: 100vw !important;
    }

    .header {
        height: 50px !important;
        padding: 6px 12px !important;
        /* Safe area support for iPhone */
        padding-top: max(6px, env(safe-area-inset-top, 6px)) !important;
        padding-left: max(12px, env(safe-area-inset-left, 12px)) !important;
        padding-right: max(12px, env(safe-area-inset-right, 12px)) !important;
    }

    .header h1 {
        font-size: 16px !important;
        margin: 0 !important;
        font-weight: 700 !important;
        line-height: 1.2 !important;
    }

    .header p {
        font-size: 9px !important;
        line-height: 1.3 !important;
        margin-top: 2px !important;
        padding: 0 10px !important;
    }

    /* Tabs removed */
    .tab-container {
        display: none !important;
        /* Safe area support */
        padding-left: max(8px, env(safe-area-inset-left, 8px)) !important;
        padding-right: max(8px, env(safe-area-inset-right, 8px)) !important;
    }

    .tabs {
        padding: 4px 8px !important;
        gap: 6px !important;
        justify-content: center !important;
        /* Ensure tabs fit within viewport */
        max-width: 100% !important;
        overflow-x: auto !important;
        -webkit-overflow-scrolling: touch !important;
        scrollbar-width: none !important;
        -ms-overflow-style: none !important;
    }

    .tabs::-webkit-scrollbar {
        display: none !important;
    }

    .tab {
        padding: 8px 14px !important;
        font-size: 12px !important;
        min-height: 32px !important;
        border-radius: 16px !important;
        /* Ensure minimum touch target */
        min-width: 44px !important;
        display: flex !important;
        align-items: center !important;
        justify-content: center !important;
        white-space: nowrap !important;
        flex-shrink: 0 !important;
    }

    .grid {
        grid-template-columns: repeat(3, 1fr) !important;
        grid-template-rows: repeat(3, 1fr) !important;
        gap: 8px !important;
        padding: 10px !important;
        /* Safe area support */
        padding-left: max(10px, env(safe-area-inset-left, 10px)) !important;
        padding-right: max(10px, env(safe-area-inset-right, 10px)) !important;
        align-content: center !important;
        justify-content: center !important;
        width: 100% !important;
        height: calc(100vh - 140px) !important; /* header(50) + arsenal(55) + footer(35) - no tabs */
        max-height: calc(100dvh - 140px) !important;
        box-sizing: border-box !important;
    }

    .icon-wrapper {
        width: 75px !important;
        height: 75px !important;
        max-width: 75px !important;
        min-width: 75px !important;
        border-radius: 18px !important;
        /* Ensure minimum touch target */
        min-height: 44px !important;
        display: flex !important;
        flex-direction: column !important;
        justify-content: center !important;
        align-items: center !important;
    }

    .v-letter {
        font-size: 16px !important;
        font-weight: 700 !important;
    }

    .ledger-text {
        font-size: 5px !important;
        letter-spacing: 1px !important;
        margin-top: 2px !important;
    }

    .app-name {
        font-size: 10px !important;
        margin-top: 6px !important;
        font-weight: 600 !important;
        text-align: center !important;
        line-height: 1.2 !important;
    }

    .pagination {
        height: 36px !important;
        padding: 0 12px !important;
        gap: 12px !important;
        margin-top: -6px !important;
        /* Safe area support */
        padding-left: max(12px, env(safe-area-inset-left, 12px)) !important;
        padding-right: max(12px, env(safe-area-inset-right, 12px)) !important;
    }

    .pagination {
        bottom: 65px !important; /* Above arsenal section on mobile */
    }
    
    .pagination-btn {
        width: 38px !important;
        height: 38px !important;
        /* Ensure minimum touch target */
        min-width: 38px !important;
        min-height: 38px !important;
    }

    .pagination-info {
        font-size: 12px !important;
        min-width: 60px !important;
    }

    .arsenal-section {
        height: 55px !important;
        padding: 12px !important;
        /* Safe area support */
        padding-left: max(12px, env(safe-area-inset-left, 12px)) !important;
        padding-right: max(12px, env(safe-area-inset-right, 12px)) !important;
    }

    .arsenal-btn {
        font-size: 15px !important;
        padding: 12px 24px !important;
        min-height: 48px !important;
        border-radius: 24px !important;
        gap: 8px !important;
        /* Ensure minimum touch target */
        min-width: 44px !important;
        font-weight: 600 !important;
    }

    .footer {
        height: 35px !important;
        padding: 6px 12px !important;
        /* Safe area support */
        padding-bottom: max(6px, env(safe-area-inset-bottom, 6px)) !important;
        padding-left: max(12px, env(safe-area-inset-left, 12px)) !important;
        padding-right: max(12px, env(safe-area-inset-right, 12px)) !important;
    }

    .footer-items {
        font-size: 9px !important;
        gap: 8px !important;
        margin-bottom: 4px !important;
    }

    .footer-item {
        padding: 4px 8px !important;
        border-radius: 8px !important;
        /* Ensure minimum touch target */
        min-height: 20px !important;
        display: flex !important;
        align-items: center !important;
    }

    .footer-pricing {
        font-size: 10px !important;
        line-height: 1.3 !important;
    }

    .footer-pricing span {
        font-size: 11px !important;
    }
}

/* LARGE MOBILE VIEWPORT (481px to 639px) - Enhanced responsive implementation */
@media (min-width: 481px) and (max-width: 639px) {
    /* Viewport structure: Header(70px) + Tabs(40px) + Grid(flex) + Arsenal(60px) + Footer(45px) = 100vh */
    
    body {
        height: 100vh !important;
        height: 100dvh !important;
        overflow: hidden !important;
        /* Prevent horizontal scroll */
        overflow-x: hidden !important;
        width: 100% !important;
        max-width: 100vw !important;
    }

    .header {
        height: 70px !important;
        padding: 8px 16px !important;
        /* Safe area support for iPhone */
        padding-top: max(8px, env(safe-area-inset-top, 8px)) !important;
        padding-left: max(16px, env(safe-area-inset-left, 16px)) !important;
        padding-right: max(16px, env(safe-area-inset-right, 16px)) !important;
    }

    .header h1 {
        font-size: 20px !important;
        margin: 0 !important;
        font-weight: 700 !important;
    }

    .header p {
        font-size: 12px !important;
        line-height: 1.3 !important;
        margin-top: 4px !important;
    }

    /* Philosophy icons removed - philosophy accessible via modal only */

    .tab-container {
        height: 45px !important;
        /* Safe area support */
        padding-left: max(12px, env(safe-area-inset-left, 12px)) !important;
        padding-right: max(12px, env(safe-area-inset-right, 12px)) !important;
    }

    .tab {
        font-size: 13px !important;
        padding: 10px 18px !important;
        min-height: 36px !important;
        /* Ensure minimum touch target */
        min-width: 44px !important;
        border-radius: 18px !important;
        font-weight: 600 !important;
    }

    /* Tabs removed */
    .tab-container {
        display: none !important;
    }
    
    .grid {
        grid-template-columns: repeat(3, 1fr) !important;
        grid-template-rows: repeat(3, 1fr) !important;
        gap: 10px !important;
        padding: 12px !important;
        /* Safe area support */
        padding-left: max(12px, env(safe-area-inset-left, 12px)) !important;
        padding-right: max(12px, env(safe-area-inset-right, 12px)) !important;
        align-content: center !important;
        justify-content: center !important;
        width: 100% !important;
        height: calc(100vh - 155px) !important; /* header(50) + arsenal(60) + footer(40) + margins */
        max-height: calc(100dvh - 155px) !important;
        box-sizing: border-box !important;
    }

    .icon-wrapper {
        width: 115px !important;
        height: 115px !important;
        max-width: 115px !important;
        min-width: 115px !important;
        border-radius: 24px !important;
        /* Ensure minimum touch target */
        min-height: 44px !important;
        display: flex !important;
        flex-direction: column !important;
        justify-content: center !important;
        align-items: center !important;
    }

    .v-letter {
        font-size: 18px !important;
        font-weight: 700 !important;
    }

    .ledger-text {
        font-size: 6px !important;
        letter-spacing: 1.2px !important;
        margin-top: 3px !important;
    }

    .app-name {
        font-size: 11px !important;
        margin-top: 8px !important;
        font-weight: 600 !important;
        text-align: center !important;
        line-height: 1.2 !important;
    }

    .pagination {
        height: 40px !important;
        margin-top: -6px !important;
        /* Safe area support */
        padding-left: max(14px, env(safe-area-inset-left, 14px)) !important;
        padding-right: max(14px, env(safe-area-inset-right, 14px)) !important;
    }

    .pagination-btn {
        width: 44px !important;
        height: 44px !important;
        /* Ensure minimum touch target */
        min-width: 44px !important;
        min-height: 44px !important;
    }

    .arsenal-section {
        height: 65px !important;
        padding: 16px !important;
        /* Safe area support */
        padding-left: max(16px, env(safe-area-inset-left, 16px)) !important;
        padding-right: max(16px, env(safe-area-inset-right, 16px)) !important;
    }

    .arsenal-btn {
        font-size: 16px !important;
        min-height: 50px !important;
        /* Ensure minimum touch target */
        min-width: 44px !important;
        font-weight: 600 !important;
        padding: 14px 28px !important;
    }

    .footer {
        height: 50px !important;
        padding: 8px 16px !important;
        /* Safe area support */
        padding-bottom: max(8px, env(safe-area-inset-bottom, 8px)) !important;
        padding-left: max(16px, env(safe-area-inset-left, 16px)) !important;
        padding-right: max(16px, env(safe-area-inset-right, 16px)) !important;
    }

    .footer-items {
        font-size: 10px !important;
        gap: 10px !important;
    }

    .footer-item {
        padding: 5px 10px !important;
        /* Ensure minimum touch target */
        min-height: 24px !important;
        display: flex !important;
        align-items: center !important;
    }

    .footer-pricing {
        font-size: 11px !important;
    }

    .footer-pricing span {
        font-size: 12px !important;
    }
}

/* TABLET VIEWPORT (640px to 1023px) - Independent no-scroll implementation */
@media (min-width: 640px) and (max-width: 1023px) {
    /* Viewport structure: Header(90px) + Philosophy(60px) + Tabs(50px) + Grid(flex) + Arsenal(70px) + Footer(55px) = 100vh */
    
    body {
        height: 100vh !important;
        overflow: hidden !important;
    }
    .header {
        padding: 20px 16px;
    }

    .header h1 {
        font-size: 24px;
        margin: 0;
    }

    .header p {
        font-size: 13px;
        padding: 0 100px;
    }

    /* Philosophy icons removed - philosophy accessible via modal only */

    .jump-btn, .philosophy-btn {
        font-size: 12px;
        padding: 10px 16px;
    }

    .jump-btn {
        left: 20px;
    }

    .philosophy-btn {
        right: 20px;
    }

    .tabs {
        padding: 8px 12px;
    }

    .tab {
        padding: 10px 20px;
        font-size: 13px;
    }

    .grid {
        grid-template-columns: repeat(3, minmax(140px, 180px));
        grid-template-rows: repeat(3, minmax(140px, 180px));
        gap: 15px;
        padding: 20px;
        max-width: 650px;
    }

    .icon-wrapper {
        width: 100px !important;
        height: 100px !important;
        max-width: 100px !important;
        min-width: 100px !important;
    }

    .v-letter {
        font-size: 26px;
    }

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

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

    .tab-content {
        min-height: calc(100vh - 220px);
    }
}

/* Desktop screens - MUCH LARGER ICONS to fill viewport */
@media (min-width: 1024px) {
    body {
        overflow: hidden;
        height: 100vh;
    }

    /* Philosophy icons removed - philosophy accessible via modal only */

    .header {
        padding: 8px 20px 6px;
        position: relative;
    }

    .header h1 {
        font-size: 20px;
    }

    .header p {
        font-size: 9px;
        padding: 0 100px;
    }

    .jump-btn, .philosophy-btn {
        font-size: 10px;
        padding: 6px 12px;
    }

    .jump-btn {
        left: 30px;
    }

    .arsenal-btn {
        font-size: 16px;
        padding: 12px 24px;
        min-height: 48px;
        border-radius: 8px;
        gap: 8px;
    }


    .jump-btn svg, .philosophy-btn svg {
        width: 14px;
        height: 14px;
    }

    /* Tabs removed */
    .tab-container {
        display: none !important;
    }

    .grid {
        grid-template-columns: repeat(3, minmax(150px, 200px));
        grid-template-rows: repeat(3, minmax(150px, 200px));
        gap: 20px;
        padding: 24px 48px;
        max-width: 750px;
        margin: 0 auto;
        flex-grow: 1;
        align-content: center;
        justify-content: center;
    }

    .icon-wrapper {
        width: 100px !important;
        height: 100px !important;
        max-width: 100px !important;
        min-width: 100px !important;
    }

    .v-letter {
        font-size: 44px;
    }

    .ledger-text {
        font-size: 9px;
        letter-spacing: 2.5px;
    }

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

    .footer {
        margin-top: auto;
        padding: 8px 20px 10px;
        border-top: 1px solid #222;
    }

    .footer-items {
        font-size: 7px;
        gap: 6px;
        margin-bottom: 4px;
    }

    .footer-item {
        padding: 2px 6px;
    }

    .footer-pricing {
        font-size: 9px;
    }

    .footer-pricing span {
        font-size: 11px;
    }

    .footer-pricing .price-detail {
        font-size: 8px;
    }
}

/* Large desktop - Even BIGGER icons */
@media (min-width: 1440px) {
    .grid {
        grid-template-columns: repeat(3, minmax(160px, 220px));
        grid-template-rows: repeat(3, minmax(160px, 220px));
        max-width: 800px;
        gap: 25px;
        padding: 32px 60px;
        margin: 0 auto;
        justify-content: center;
    }

    .icon-wrapper {
        width: 100px !important;
        height: 100px !important;
        max-width: 100px !important;
        min-width: 100px !important;
    }

    .v-letter {
        font-size: 47px;
    }

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

    .app-name {
        font-size: 19px;
    }
}

/* Ultra-wide screens - MAXIMUM size icons */
@media (min-width: 1920px) {
    .grid {
        grid-template-columns: repeat(3, minmax(180px, 240px));
        grid-template-rows: repeat(3, minmax(180px, 240px));
        max-width: 900px;
        gap: 30px;
        padding: 36px 72px;
        margin: 0 auto;
        justify-content: center;
    }

    .icon-wrapper {
        width: 100px !important;
        height: 100px !important;
        max-width: 100px !important;
        min-width: 100px !important;
    }

    .v-letter {
        font-size: 55px;
    }

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

    .app-name {
        font-size: 22px;
    }
}

/* ============================================
   iPhone 13 Pro and Newer - Complete Native Optimization
   ============================================ */

/* iPhone 13 Pro (390x844) and iPhone 14 Pro (393x852) */
@media only screen 
    and (min-device-width: 390px) 
    and (max-device-width: 430px)
    and (-webkit-device-pixel-ratio: 3) {
    
    /* Root-level safe area implementation */
    :root {
        --safe-top: env(safe-area-inset-top, 44px);
        --safe-bottom: env(safe-area-inset-bottom, 34px);
        --safe-left: env(safe-area-inset-left, 0px);
        --safe-right: env(safe-area-inset-right, 0px);
        --content-padding: 20px;
        --border-spacing: 16px;
    }

    /* Full viewport with safe areas */
    html, body {
        height: 100vh;
        height: 100dvh; /* Dynamic viewport height for iOS */
        overflow-x: hidden;
        -webkit-text-size-adjust: 100%;
        -webkit-font-smoothing: antialiased;
        -moz-osx-font-smoothing: grayscale;
    }

    body {
        padding: 0;
        margin: 0;
        position: relative;
    }

    /* Native iOS scrolling behavior */
    * {
        -webkit-overflow-scrolling: touch;
        scroll-behavior: smooth;
    }

    /* Header with native spacing */
    .header {
        padding-top: calc(var(--safe-top) + var(--content-padding));
        padding-left: calc(var(--safe-left) + var(--border-spacing));
        padding-right: calc(var(--safe-right) + var(--border-spacing));
        padding-bottom: var(--content-padding);
        background: linear-gradient(180deg, rgba(0,0,0,0.98) 0%, rgba(0,0,0,0.85) 100%);
        backdrop-filter: blur(30px);
        -webkit-backdrop-filter: blur(30px);
        position: relative;
        z-index: 100;
    }

    .header h1 {
        font-size: 22px;
        font-weight: 700;
        letter-spacing: -0.5px;
    }

    .header p {
        font-size: 13px;
        line-height: 1.4;
        padding: 0 20px;
        opacity: 0.9;
    }

    /* Optimized buttons for touch */
    .jump-btn, .philosophy-btn {
        min-height: 44px;
        min-width: 44px;
        padding: 12px 20px;
        font-size: 14px;
        font-weight: 600;
        border-radius: 22px;
        touch-action: manipulation;
    }

    .jump-btn {
        left: 16px;
        background: linear-gradient(135deg, #00d4ff 0%, #0099cc 100%);
    }

    .philosophy-btn {
        right: 16px;
    }

    /* Philosophy book icon removed - philosophy accessible via modal only */

    /* Tab container with native spacing */
    .tab-container {
        padding-left: calc(var(--safe-left) + var(--border-spacing));
        padding-right: calc(var(--safe-right) + var(--border-spacing));
    }

    .tabs {
        padding: 8px 0;
        gap: 8px;
        overflow-x: auto;
        -webkit-overflow-scrolling: touch;
        scrollbar-width: none;
        scroll-snap-type: x mandatory;
        justify-content: center;
    }

    .tabs::-webkit-scrollbar {
        display: none;
    }

    .tab {
        min-height: 44px;
        padding: 10px 20px;
        font-size: 15px;
        font-weight: 600;
        white-space: nowrap;
        flex-shrink: 0;
        border-radius: 22px;
        scroll-snap-align: center;
        backdrop-filter: blur(20px);
        -webkit-backdrop-filter: blur(20px);
    }

    /* Grid with native iPhone spacing */
    .grid {
        grid-template-columns: repeat(3, minmax(70px, 1fr));
        grid-template-rows: repeat(3, minmax(70px, 1fr));
        gap: var(--border-spacing);
        padding: var(--border-spacing);
        padding-left: calc(var(--safe-left) + var(--border-spacing));
        padding-right: calc(var(--safe-right) + var(--border-spacing));
        padding-bottom: calc(var(--border-spacing) + var(--safe-bottom));
        max-width: none;
        margin: 0;
    }

    /* Icon optimization for iPhone */
    .icon-wrapper {
        width: 100px !important;
        height: 100px !important;
        max-width: 100px !important;
        min-width: 100px !important;
        border-radius: 20px;
        padding: 16px;
        background: rgba(0, 0, 0, 0.7);
        backdrop-filter: blur(20px);
        -webkit-backdrop-filter: blur(20px);
        border: 1px solid rgba(255, 255, 255, 0.1);
        transition: transform 0.2s ease, box-shadow 0.2s ease;
    }

    /* Touch feedback */
    .icon-wrapper:active {
        transform: scale(0.96);
        box-shadow: 0 2px 8px rgba(0, 0, 0, 0.3);
    }

    .v-letter {
        font-size: 20px;
        font-weight: 700;
    }

    .ledger-text {
        font-size: 6px;
        letter-spacing: 1.2px;
        margin-top: 2px;
    }

    .app-name {
        font-size: 12px;
        margin-top: 8px;
        font-weight: 600;
    }

    /* Pagination with native spacing - closer to icons */
    .pagination {
        padding-left: calc(var(--safe-left) + var(--border-spacing));
        padding-right: calc(var(--safe-right) + var(--border-spacing));
        margin: -8px 0 8px 0;
        height: 40px;
    }

    .pagination-btn {
        width: 50px;
        height: 50px;
        backdrop-filter: blur(20px);
        -webkit-backdrop-filter: blur(20px);
    }

    /* Arsenal section with native spacing and top padding */
    .arsenal-section {
        padding: 20px calc(var(--safe-left) + var(--border-spacing)) 8px calc(var(--safe-right) + var(--border-spacing));
    }

    .arsenal-btn {
        font-size: 16px;
        padding: 12px 24px;
        gap: 8px;
        min-height: 48px;
        border-radius: 8px;
    }

    /* Footer with native bottom spacing */
    .footer {
        padding: var(--border-spacing);
        padding-left: calc(var(--safe-left) + var(--border-spacing));
        padding-right: calc(var(--safe-right) + var(--border-spacing));
        padding-bottom: calc(var(--safe-bottom) + var(--border-spacing));
        background: linear-gradient(180deg, rgba(0,0,0,0.85) 0%, rgba(0,0,0,0.98) 100%);
        backdrop-filter: blur(25px);
        -webkit-backdrop-filter: blur(25px);
    }

    .footer-items {
        font-size: 10px;
        gap: 8px;
        flex-wrap: wrap;
    }

    .footer-item {
        padding: 6px 12px;
        border-radius: 16px;
        min-height: 32px;
        display: flex;
        align-items: center;
    }

    .footer-pricing {
        font-size: 12px;
        line-height: 1.6;
    }

    /* Modal optimizations with native iPhone spacing */
    .philosophy-modal, .checkout-modal, .trial-modal {
        padding: 0;
        background: rgba(0, 0, 0, 0.97);
        backdrop-filter: blur(40px);
        -webkit-backdrop-filter: blur(40px);
    }

    .philosophy-content, .checkout-content, .trial-content {
        max-width: none;
        width: 100%;
        padding: calc(var(--safe-top) + 80px) calc(var(--safe-right) + var(--content-padding)) calc(var(--safe-bottom) + var(--content-padding)) calc(var(--safe-left) + var(--content-padding));
        max-height: 100vh;
        max-height: 100dvh;
        overflow-y: auto;
        -webkit-overflow-scrolling: touch;
        box-sizing: border-box;
    }

    .philosophy-title {
        font-size: 32px;
        margin-bottom: 24px;
        font-weight: 700;
        letter-spacing: -0.5px;
    }

    .philosophy-text {
        font-size: 17px;
        line-height: 1.6;
        margin-bottom: 20px;
        font-weight: 400;
    }

    .philosophy-close, .checkout-close, .trial-close {
        width: 50px;
        height: 50px;
        top: calc(var(--safe-top) + var(--content-padding));
        right: calc(var(--safe-right) + var(--border-spacing));
        backdrop-filter: blur(20px);
        -webkit-backdrop-filter: blur(20px);
        border-radius: 25px;
    }

    .philosophy-translate {
        width: 80px;
        height: 50px;
        top: calc(var(--safe-top) + var(--content-padding));
        left: calc(var(--safe-left) + var(--border-spacing));
        font-size: 14px;
        border-radius: 25px;
        backdrop-filter: blur(20px);
        -webkit-backdrop-filter: blur(20px);
    }

    .entrance-replay-btn {
        top: calc(var(--safe-top) + var(--content-padding));
        left: calc(var(--safe-left) + 90px);
        width: 50px;
        height: 50px;
        border-radius: 25px;
        backdrop-filter: blur(20px);
        -webkit-backdrop-filter: blur(20px);
    }

    /* Smooth scrolling */
    * {
        scroll-behavior: smooth;
    }

    /* Prevent horizontal scroll */
    html, body {
        overflow-x: hidden;
        width: 100%;
    }

    /* Tab content with native spacing */
    .tab-content {
        min-height: calc(100vh - 200px - var(--safe-top) - var(--safe-bottom));
        min-height: calc(100dvh - 200px - var(--safe-top) - var(--safe-bottom));
    }

    /* Checkout modal native optimization */
    .checkout-apps {
        padding: 0 !important;
        gap: 12px;
    }

    .checkout-app {
        margin: 0 0 12px 0;
        padding: 16px;
        border-radius: 16px;
        backdrop-filter: blur(20px);
        -webkit-backdrop-filter: blur(20px);
        border: 1px solid rgba(255, 255, 255, 0.1);
        min-height: 70px;
    }

    .checkout-header {
        padding-bottom: 20px;
        margin-bottom: 20px;
        border-bottom: 1px solid rgba(255, 255, 255, 0.1);
    }

    .checkout-title {
        font-size: 28px;
        font-weight: 700;
        letter-spacing: -0.5px;
        margin-bottom: 8px;
    }

    .checkout-subtitle {
        font-size: 16px;
        line-height: 1.5;
        opacity: 0.8;
    }

    .checkout-summary {
        margin-top: 24px;
        padding: 20px;
        background: rgba(255, 255, 255, 0.05);
        border-radius: 16px;
        backdrop-filter: blur(20px);
        -webkit-backdrop-filter: blur(20px);
    }

    .checkout-button {
        width: 100%;
        min-height: 56px;
        font-size: 17px;
        font-weight: 600;
        border-radius: 28px;
        margin-top: 20px;
        backdrop-filter: blur(20px);
        -webkit-backdrop-filter: blur(20px);
    }
}

/* iPhone 14 Pro Max, 15 Pro Max (430x932) */
@media only screen 
    and (min-device-width: 428px) 
    and (max-device-width: 430px)
    and (-webkit-device-pixel-ratio: 3) {
    
    .grid {
        grid-template-columns: repeat(3, minmax(90px, 120px));
        grid-template-rows: repeat(3, minmax(90px, 120px));
        gap: 15px;
        padding: 18px;
        max-width: 450px;
        margin: 0 auto;
        justify-content: center;
    }

    .icon-wrapper {
        width: 100px !important;
        height: 100px !important;
        max-width: 100px !important;
        min-width: 100px !important;
    }

    .v-letter {
        font-size: 22px;
    }
}

/* Landscape orientation for iPhone */
@media only screen 
    and (min-device-width: 390px) 
    and (max-device-width: 430px)
    and (orientation: landscape) {
    
    .header {
        padding: 12px 16px 10px;
        padding-left: calc(16px + env(safe-area-inset-left));
        padding-right: calc(16px + env(safe-area-inset-right));
    }

    .header h1 {
        font-size: 20px;
    }

    .header p {
        font-size: 10px;
    }

    .grid {
        grid-template-columns: repeat(3, minmax(120px, 150px));
        grid-template-rows: repeat(3, minmax(120px, 150px));
        gap: 16px;
        padding: 14px;
        padding-left: calc(14px + env(safe-area-inset-left));
        padding-right: calc(14px + env(safe-area-inset-right));
        max-width: 550px;
        margin: 0 auto;
        justify-content: center;
    }

    .icon-wrapper {
        width: 100px !important;
        height: 100px !important;
        max-width: 100px !important;
        min-width: 100px !important;
    }

    .v-letter {
        font-size: 19px;
    }

    .tabs {
        padding: 8px 16px;
        padding-left: calc(16px + env(safe-area-inset-left));
        padding-right: calc(16px + env(safe-area-inset-right));
    }

    .tab {
        min-height: 36px;
        padding: 8px 20px;
        font-size: 13px;
    }

    .footer {
        padding: 12px 16px;
        padding-left: calc(16px + env(safe-area-inset-left));
        padding-right: calc(16px + env(safe-area-inset-right));
        padding-bottom: calc(12px + env(safe-area-inset-bottom));
    }
}

/* Dynamic Island support for iPhone 14 Pro and newer */
@supports (padding: max(0px)) {
    @media only screen 
        and (min-device-width: 393px) 
        and (-webkit-device-pixel-ratio: 3) {
        
        .header {
            padding-top: max(20px, env(safe-area-inset-top));
        }
    }
}

/* Improved touch targets and gestures */
@media (hover: none) and (pointer: coarse) {
    /* All clickable elements get minimum touch target */
    button, a, .app-link, .tab, .footer-item, 
    .philosophy-btn, .jump-btn, .philosophy-close, 
    .checkout-close, .trial-close, .philosophy-translate {
        min-height: 44px;
        min-width: 44px;
    }

    /* Improved hover states for touch */
    .app-link:active .icon-wrapper {
        transform: scale(0.95);
        opacity: 0.9;
    }

    /* Disable hover effects on touch devices */
    @media (hover: hover) {
        .app-link:hover .icon-wrapper {
            transform: translateY(-4px);
        }
    }
}

/* High contrast mode for accessibility */
@media (prefers-contrast: high) {
    .icon-wrapper {
        border: 2px solid rgba(255, 255, 255, 0.3);
    }

    .tab.active {
        background: rgba(255, 255, 255, 0.2);
    }
}

/* Reduced motion for accessibility */
@media (prefers-reduced-motion: reduce) {
    * {
        animation: none !important;
        transition: none !important;
    }
}

/* Dark mode optimizations */
@media (prefers-color-scheme: dark) {
    :root {
        color-scheme: dark;
    }
}

/* Enhanced Mobile Touch Optimizations */
@media (hover: none) and (pointer: coarse) {
    /* All clickable elements get minimum touch target */
    button, a, .app-link, .tab, .footer-item, 
    .philosophy-btn, .jump-btn, .philosophy-close, 
    .checkout-close, .trial-close, .philosophy-translate,
    .pagination-btn, .arsenal-btn {
        min-height: 44px;
        min-width: 44px;
    }

    /* Improved hover states for touch */
    .app-link:active .icon-wrapper {
        transform: scale(0.95);
        opacity: 0.9;
    }

    .tab:active {
        transform: scale(0.95);
        opacity: 0.9;
    }

    .pagination-btn:active {
        transform: scale(0.95);
    }

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

    /* Disable hover effects on touch devices */
    @media (hover: hover) {
        .app-link:hover .icon-wrapper {
            transform: translateY(-4px);
        }
    }
}

/* Safari-specific fixes */
@supports (-webkit-appearance: none) {
    /* Philosophy icons removed - philosophy accessible via modal only */
    
    .header-title-container {
        align-items: center !important;
        justify-content: center !important;
        gap: 12px !important;
        flex-wrap: nowrap !important;
    }
}

/* PWA Standalone Mode Fixes - Critical for iOS */
@media all and (display-mode: standalone) {
    body {
        height: 100vh;
        height: 100dvh;
        overflow: hidden;
        display: flex !important;
        flex-direction: column !important;
    }
    
    .header {
        order: 1 !important;
        flex-shrink: 0 !important;
    }
    
    .trial-banner {
        order: 2 !important;
        position: relative !important;
        top: 0 !important;
    }
    
    .apps-container {
        order: 3 !important;
        flex: 1 !important;
        min-height: 0 !important;
        overflow: hidden !important;
        display: flex !important;
        flex-direction: column !important;
    }
    
    .footer {
        order: 4 !important;
        flex-shrink: 0 !important;
        margin-top: 0 !important;
        position: relative !important;
    }
}

/* iOS PWA Standalone Mode - Safe Area Support */
@media all and (display-mode: standalone) {
    .header {
        padding-top: max(6px, env(safe-area-inset-top, 6px)) !important;
    }
    
    .footer {
        padding-bottom: max(6px, env(safe-area-inset-bottom, 6px)) !important;
    }
    
    .apps-container {
        padding-left: max(0px, env(safe-area-inset-left, 0px)) !important;
        padding-right: max(0px, env(safe-area-inset-right, 0px)) !important;
    }
}
