* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

:root {
    --primary-color: #4285F4;
    --secondary-color: #34A853;
    --accent-color: #FBBC04;
    --error-color: #EA4335;
    --text-primary: #202124;
    --text-secondary: #5F6368;
    --background: #FFFFFF;
    --surface: #F8F9FA;
    --border: #DADCE0;
    --shadow: rgba(0, 0, 0, 0.1);
}

body {
    font-family: 'Roboto', -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
    background-color: var(--background);
    color: var(--text-primary);
    line-height: 1.5;
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
    max-width: 100%;
    overflow-x: hidden;
}

/* Header */
.header {
    position: sticky;
    top: 0;
    background: var(--background);
    z-index: 100;
    border-bottom: 1px solid var(--border);
}

.header-top {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 12px 16px;
    max-width: 100%;
}

.back-btn,
.more-btn {
    background: none;
    border: none;
    padding: 8px;
    cursor: pointer;
    color: var(--text-primary);
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: 50%;
    transition: background-color 0.2s;
}

.back-btn:hover,
.more-btn:hover {
    background-color: var(--surface);
}

/* Main Content */
.main-content {
    padding-bottom: 80px;
}

/* App Header Section */
.app-header {
    padding: 20px 16px;
    display: flex;
    gap: 16px;
    background: var(--background);
}

.app-icon-container {
    flex-shrink: 0;
}

.app-icon {
    width: 96px;
    height: 96px;
    border-radius: 24px;
    box-shadow: 0 2px 12px rgba(0, 0, 0, 0.15);
    object-fit: cover;
    background: var(--surface);
}

.app-info {
    flex: 1;
    min-width: 0;
}

.app-name-row {
    display: flex;
    align-items: center;
    gap: 6px;
    margin-bottom: 4px;
}

.app-name {
    font-size: 22px;
    font-weight: 600;
    color: var(--text-primary);
    line-height: 1.3;
}

.verified-badge {
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
    width: 20px;
    height: 20px;
    margin-top: 2px;
}

.verified-icon {
    width: 100%;
    height: 100%;
    object-fit: contain;
}

.app-developer {
    font-size: 14px;
    color: var(--primary-color);
    margin-bottom: 4px;
}

.app-features {
    font-size: 13px;
    color: var(--text-secondary);
    margin-bottom: 16px;
    line-height: 1.4;
}

.app-meta-row {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 16px;
    margin-top: 12px;
    row-gap: 8px;
}

.app-rating {
    display: flex;
    align-items: center;
    gap: 4px;
    flex-wrap: wrap;
}

.app-rating svg {
    flex-shrink: 0;
}

.rating-value {
    font-size: 14px;
    font-weight: 500;
    color: var(--text-primary);
}

.rating-count {
    font-size: 14px;
    color: var(--text-secondary);
}

.badge {
    display: inline-flex;
    align-items: center;
    gap: 4px;
    padding: 4px 8px;
    border-radius: 4px;
    font-size: 12px;
    font-weight: 500;
}

.badge.editor-choice {
    background-color: var(--accent-color);
    color: var(--text-primary);
}

.app-size {
    display: flex;
    align-items: center;
    gap: 4px;
    font-size: 13px;
    color: var(--text-secondary);
    white-space: nowrap;
}

.app-size svg {
    flex-shrink: 0;
}

.content-rating {
    display: flex;
    align-items: center;
    gap: 6px;
    font-size: 13px;
    color: var(--text-secondary);
    flex-wrap: wrap;
}

.content-rating span {
    white-space: nowrap;
}

.rating-icon {
    width: 24px;
    height: 24px;
    border-radius: 50%;
    background-color: var(--text-secondary);
    color: white;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 11px;
    font-weight: 600;
    flex-shrink: 0;
}

/* Install Button */
.install-section {
    padding: 0 16px 20px;
}

.install-btn {
    width: 100%;
    background-color: var(--primary-color);
    color: white;
    border: none;
    padding: 14px 24px;
    border-radius: 8px;
    font-size: 16px;
    font-weight: 600;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: background-color 0.2s, transform 0.1s;
    box-shadow: 0 2px 4px rgba(66, 133, 244, 0.3);
    position: relative;
    min-height: 50px;
}

.install-btn:active:not(:disabled) {
    transform: scale(0.98);
    background-color: #3367D6;
}

.install-btn:disabled {
    opacity: 0.8;
    cursor: not-allowed;
}

.btn-text {
    display: block;
}

.download-progress {
    display: flex;
    align-items: center;
    gap: 12px;
    width: 100%;
}

.progress-bar {
    flex: 1;
    height: 6px;
    background-color: rgba(255, 255, 255, 0.3);
    border-radius: 3px;
    overflow: hidden;
}

.progress-fill {
    height: 100%;
    background-color: white;
    border-radius: 3px;
    transition: width 0.3s ease;
    width: 0%;
}

.progress-text {
    font-size: 14px;
    font-weight: 600;
    color: white;
    min-width: 40px;
    text-align: right;
}

/* Screenshots Section */
.screenshots-section {
    margin: 20px 0;
    padding: 0 16px;
}

.screenshots-container {
    display: flex;
    gap: 12px;
    overflow-x: auto;
    padding-bottom: 8px;
    scroll-snap-type: x mandatory;
    -webkit-overflow-scrolling: touch;
    scrollbar-width: none;
}

.screenshots-container::-webkit-scrollbar {
    display: none;
}

.screenshot-item {
    flex-shrink: 0;
    width: 150px;
    scroll-snap-align: start;
}

.screenshot-item img {
    width: 100%;
    height: auto;
    max-height: 30vh;
    border-radius: 12px;
    box-shadow: 0 2px 12px rgba(0, 0, 0, 0.15);
    object-fit: contain;
    background: var(--surface);
    transition: transform 0.2s;
}

.screenshot-item:active img {
    transform: scale(0.98);
}

/* About Section */
.about-section,
.data-safety-section {
    padding: 24px 16px;
    border-top: 1px solid var(--border);
    margin-bottom: 0;
}

.section-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 16px;
    cursor: pointer;
    padding: 4px 0;
    transition: opacity 0.2s;
}

.section-header:active {
    opacity: 0.7;
}

.section-header svg {
    color: var(--text-secondary);
    transition: transform 0.2s;
}

.section-title {
    font-size: 18px;
    font-weight: 500;
    color: var(--text-primary);
}

.about-content {
    display: flex;
    flex-direction: column;
    gap: 16px;
}

.app-description {
    font-size: 14px;
    color: var(--text-primary);
    line-height: 1.7;
    margin-bottom: 16px;
}

.app-tags {
    display: flex;
    gap: 8px;
    flex-wrap: wrap;
}

.tag {
    display: inline-block;
    padding: 6px 12px;
    border-radius: 16px;
    font-size: 13px;
    background-color: var(--surface);
    color: var(--text-secondary);
    border: 1px solid var(--border);
    transition: background-color 0.2s;
}

.app-details {
    display: flex;
    flex-direction: column;
    gap: 12px;
}

.detail-item {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 12px 0;
    border-bottom: 1px solid var(--border);
}

.detail-item:last-child {
    border-bottom: none;
}

.detail-label {
    font-size: 14px;
    color: var(--text-secondary);
}

.detail-value {
    font-size: 14px;
    color: var(--text-primary);
    font-weight: 500;
}

/* Reviews Section */
.reviews-section {
    padding: 24px 16px;
    border-top: 1px solid var(--border);
    margin-bottom: 20px;
}

.reviews-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 16px;
}

.sort-btn {
    background: none;
    border: none;
    color: var(--primary-color);
    font-size: 14px;
    font-weight: 500;
    cursor: pointer;
    padding: 4px 8px;
    border-radius: 4px;
    transition: background-color 0.2s;
}

.sort-btn:active {
    background-color: var(--surface);
}

.reviews-list {
    display: flex;
    flex-direction: column;
    gap: 20px;
    margin-bottom: 16px;
}

.review-item {
    padding-bottom: 20px;
    border-bottom: 1px solid var(--border);
}

.review-item:last-child {
    border-bottom: none;
    padding-bottom: 0;
}

.review-header {
    display: flex;
    justify-content: space-between;
    align-items: flex-start;
    margin-bottom: 8px;
}

.reviewer-info {
    display: flex;
    gap: 12px;
    flex: 1;
}

.reviewer-avatar {
    width: 40px;
    height: 40px;
    border-radius: 50%;
    background: linear-gradient(135deg, var(--primary-color), var(--secondary-color));
    color: white;
    display: flex;
    align-items: center;
    justify-content: center;
    font-weight: 500;
    font-size: 16px;
    flex-shrink: 0;
}

.reviewer-name {
    font-size: 14px;
    font-weight: 500;
    color: var(--text-primary);
    margin-bottom: 4px;
}

.review-rating {
    display: flex;
    gap: 2px;
    align-items: center;
}

.review-date {
    font-size: 12px;
    color: var(--text-secondary);
}

.review-text {
    font-size: 14px;
    color: var(--text-primary);
    line-height: 1.6;
    margin-top: 8px;
}

.view-all-reviews-btn {
    width: 100%;
    background: var(--surface);
    border: 1px solid var(--border);
    color: var(--text-primary);
    padding: 14px 24px;
    border-radius: 24px;
    font-size: 14px;
    font-weight: 500;
    cursor: pointer;
    transition: background-color 0.2s, transform 0.1s;
    margin-top: 8px;
}

.view-all-reviews-btn:active {
    background-color: var(--border);
    transform: scale(0.98);
}

/* Similar Apps Section */
.similar-apps-section {
    padding: 24px 16px;
    border-top: 1px solid var(--border);
}

.similar-apps-list {
    display: flex;
    flex-direction: column;
    gap: 16px;
}

.similar-app-item {
    display: flex;
    gap: 16px;
    align-items: center;
    padding: 12px;
    border-radius: 12px;
    transition: background-color 0.2s;
    cursor: pointer;
}

.similar-app-item:active {
    background-color: var(--surface);
}

.similar-app-icon {
    width: 64px;
    height: 64px;
    border-radius: 16px;
    object-fit: cover;
    flex-shrink: 0;
    box-shadow: 0 2px 4px var(--shadow);
}

.similar-app-info {
    flex: 1;
    min-width: 0;
}

.similar-app-name {
    font-size: 16px;
    font-weight: 500;
    color: var(--text-primary);
    margin-bottom: 4px;
}

.similar-app-rating {
    display: flex;
    align-items: center;
    gap: 4px;
    font-size: 14px;
    color: var(--text-secondary);
}

/* Responsive adjustments */
@media (max-width: 360px) {
    .app-icon {
        width: 80px;
        height: 80px;
    }
    
    .app-name {
        font-size: 20px;
    }
    
    .screenshot-item {
        width: 200px;
    }
    
    .app-meta-row {
        gap: 12px;
    }
}

/* Smooth scrolling */
html {
    scroll-behavior: smooth;
    -webkit-tap-highlight-color: transparent;
}

/* Touch optimizations */
button,
.similar-app-item,
.section-header,
.nav-item {
    -webkit-tap-highlight-color: transparent;
    touch-action: manipulation;
    user-select: none;
}

/* Loading states */
img {
    background: var(--surface);
    transition: opacity 0.3s;
    display: block;
}

img[src=""],
img:not([src]) {
    opacity: 0;
}

/* Focus states for accessibility */
button:focus-visible,
.nav-item:focus-visible {
    outline: 2px solid var(--primary-color);
    outline-offset: 2px;
}

/* Selection */
::selection {
    background-color: var(--primary-color);
    color: white;
}

/* Scrollbar styling for webkit browsers */
::-webkit-scrollbar {
    width: 4px;
    height: 4px;
}

::-webkit-scrollbar-track {
    background: transparent;
}

::-webkit-scrollbar-thumb {
    background: var(--border);
    border-radius: 2px;
}

::-webkit-scrollbar-thumb:hover {
    background: var(--text-secondary);
}

/* Loading Screen */
.loading-screen {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background-color: var(--background);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 10000;
    transition: opacity 0.3s ease;
}

.loading-content {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 24px;
}

.loading-logo {
    width: 120px;
    height: 120px;
    border-radius: 28px;
    box-shadow: 0 4px 20px rgba(0, 0, 0, 0.15);
    animation: pulse 2s ease-in-out infinite;
}

.loading-spinner {
    width: 40px;
    height: 40px;
    border: 4px solid var(--surface);
    border-top-color: var(--primary-color);
    border-radius: 50%;
    animation: spin 1s linear infinite;
}

.loading-text {
    font-size: 16px;
    color: var(--text-secondary);
    font-weight: 500;
}

@keyframes spin {
    to {
        transform: rotate(360deg);
    }
}

@keyframes pulse {
    0%, 100% {
        transform: scale(1);
        opacity: 1;
    }
    50% {
        transform: scale(1.05);
        opacity: 0.9;
    }
}

/* Bottom Navigation */
.bottom-nav {
    position: fixed;
    bottom: 0;
    left: 0;
    right: 0;
    background: var(--background);
    border-top: 1px solid var(--border);
    display: flex;
    justify-content: space-around;
    align-items: center;
    padding: 10px 0 calc(10px + env(safe-area-inset-bottom));
    z-index: 100;
    box-shadow: 0 -2px 12px rgba(0, 0, 0, 0.08);
    backdrop-filter: blur(10px);
}

.nav-item {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 4px;
    padding: 8px 12px;
    color: var(--text-secondary);
    text-decoration: none;
    transition: color 0.2s, transform 0.1s;
    min-width: 60px;
    border-radius: 8px;
}

.nav-item svg {
    stroke: currentColor;
    transition: transform 0.2s;
}

.nav-item span {
    font-size: 11px;
    font-weight: 500;
    line-height: 1.2;
}

.nav-item:active {
    color: var(--primary-color);
    transform: scale(0.95);
}

.nav-item:active svg {
    transform: scale(1.1);
}
