/* ===== CSS Variables for Theme Support ===== */
:root {
    /* Dark theme (default) */
    --bg-primary: rgb(19 19 19);
    --bg-secondary: #111;
    --bg-tertiary: #1c1c1e;
    --bg-quaternary: rgb(41 42 44);
    --bg-modal: rgba(0, 0, 0, 0.9);
    --bg-modal-content: rgb(19 19 19);
    --bg-button: #8ab4f8;
    --bg-button-hover: #7aa3e6;
    --bg-button-danger: #b00020;
    --bg-progress-ring: #2a2a2a;
    --bg-progress-ring-fg: #8ab4f8;
    --bg-security-border: rgb(41 42 44);
    --bg-title-arrow: rgb(41 42 44);
    
    --text-primary: #ffffff;
    --text-secondary: #ccc;
    --text-tertiary: #aaa;
    --text-muted: #5f6368;
    --text-button: #ffffff;
    --text-button-dark: #000000;
    --text-link: #90caf9;
    --text-star: #8ab4f8;
    
    --border-primary: #2a2a2a;
    --border-secondary: #333;
    --border-tertiary: #444;
    --border-divider: rgba(255, 255, 255, 0.1);
    
    --nav-active: #90caf9;
    --nav-inactive: #ccc;
}

body.theme-light {
    /* Light theme */
    --bg-primary: #ffffff;
    --bg-secondary: #f5f5f5;
    --bg-tertiary: #fafafa;
    --bg-quaternary: #e8e8e8;
    --bg-modal: rgba(255, 255, 255, 0.95);
    --bg-modal-content: #ffffff;
    --bg-button: #1a73e8;
    --bg-button-hover: #1557b0;
    --bg-button-danger: #d32f2f;
    --bg-progress-ring: #e0e0e0;
    --bg-progress-ring-fg: #1a73e8;
    --bg-security-border: #e0e0e0;
    --bg-title-arrow: #e8e8e8;
    
    --text-primary: #202124;
    --text-secondary: #5f6368;
    --text-tertiary: #80868b;
    --text-muted: #9aa0a6;
    --text-button: #ffffff;
    --text-button-dark: #202124;
    --text-link: #1a73e8;
    --text-star: #1a73e8;
    
    --border-primary: #dadce0;
    --border-secondary: #e8eaed;
    --border-tertiary: #f1f3f4;
    --border-divider: rgba(0, 0, 0, 0.1);
    
    --nav-active: #1a73e8;
    --nav-inactive: #5f6368;
}

#support-content {
    overflow: hidden;
    max-height: 0;
    transition: max-height 0.3s ease;
}

.support-label {
    display: flex;
    align-items: center;
    gap: 8px;
}

.support-value {
    margin-left: 32px;
    color: var(--text-primary);
    font-size: 14px;
    transition: color 0.3s ease;
}

.support-header {
    display: flex;
    align-items: center;
}

.support-icon {
    width: 20px;
    height: 20px;
    flex-shrink: 0;
}

.support-title {
    margin-left: 8px;
}


/* --- Install state tweaks --- */
.icon-wrap.shrink img {
    transform: scale(0.7);
    transform-origin: center;
    transition: transform .25s ease;
}

#appTitle.shrink {
    transition: font-size .25s ease, line-height .25s ease;
}

/* Cancel button (appears during install) */
#cancelInstallBtn {
    display: none;
    padding: 8px 16px;
    border-radius: 20px;
    background: none;
    border: 1px solid var(--border-tertiary);
    color: var(--text-secondary);
    font-size: 14px;
    cursor: pointer;
    transition: border-color 0.3s ease, color 0.3s ease;
}

#cancelInstallBtn:active {
    transform: translateY(1px);
}

/* Delete button (shows after 100%) */
#deleteBtn {
    padding: 8px 16px;
    border-radius: 20px;
    background: var(--bg-button-danger);
    border: none;
    color: var(--text-button);
    font-size: 14px;
    cursor: pointer;
    display: none;
    transition: background-color 0.3s ease;
}

#deleteBtn:active {
    transform: translateY(1px);
}

/* Progress text under title */
#downloadProgressText {
    display: none;
    font-size: 13px;
    color: var(--text-tertiary);
}

body {
    margin: 0;
    font-family: 'Roboto', sans-serif;
    background-color: var(--bg-primary);
    color: var(--text-primary);
    transition: background-color 0.3s ease, color 0.3s ease;
}

span,
h3,
p,
ul,
li,
button {
    border: none;
    background: none;
    padding: 6px;
    border-radius: 6px;
}

.container {
    max-width: 800px;
    margin: auto;
    background: none;
    padding: 16px;
}

.header {
    display: flex;
    align-items: center;
    margin-bottom: 16px;
}

.app-icon {
    width: 96px;
    height: 96px;
    border-radius: 20%;
    background: none;
    margin-right: 16px;
}

.app-details {
    flex-grow: 1;
}

.app-title {
    font-size: 24px;
    font-weight: 500;
}

.app-author {
    color: var(--text-muted);
    font-size: 14px;
}

.app-rating {
    font-size: 14px;
    margin-top: 4px;
}

.install-btn {
    background: none;
    color: var(--text-primary);
    border: none;
    border-radius: 4px;
    padding: 10px 16px;
    font-size: 14px;
    cursor: pointer;
}

.screenshots {
    display: flex;
    overflow-x: auto;
    gap: 8px;
    margin: 16px 0;
}

.screenshots img {
    height: 300px;
    border-radius: 8px;
}

.section {
    margin-bottom: 24px;
}

.section h3 {
    font-size: 18px;
    margin-bottom: 8px;
}

.description,
.reviews,
.extra-info {
    font-size: 14px;
    line-height: 1.5;
}

.stat-block:not(:last-child)::after {
    content: '';
    position: absolute;
    right: -8px;
    top: 20%;
    bottom: 20%;
    width: 1px;
    background-color: var(--bg-primary);
}

/* Разделитель между всеми блоками статистики, кроме последнего */
.stats .stat-block:not(:last-child) {
    border-right: 1px solid var(--border-divider);
    padding-right: 16px;
    margin-right: 16px;
}

.divider-line {
    height: 1px;
    background-color: var(--border-secondary);
    margin: 8px 0;
    opacity: 0.2;
}

.divider {
    width: 1px;
    background-color: var(--border-tertiary);
    height: 60%;
    margin: auto 8px;
}

.modal {
    display: none;
    position: fixed;
    z-index: 10000;
    left: 0;
    top: 0;
    width: 100%;
    height: 100%;
    overflow: hidden;
    background-color: var(--bg-modal);
    justify-content: center;
    align-items: center;
}

.modal-content {
    max-width: 90%;
    max-height: 90%;
    border-radius: 12px;
}

.modal video {
    width: 100%;
    height: auto;
    border-radius: 12px;
}

#descriptionModal {
    padding: 0;
    margin: 0;
}

#descriptionModal .modal-content {
    position: fixed;
    inset: 0;
    border-radius: 0;
    padding: 0;
    background-color: var(--bg-modal-content);
    color: var(--text-primary);
    overflow-y: auto;
    box-sizing: border-box;
    width: 100vw;
    height: 100vh;
    max-width: none;
    max-height: none;
}

.top-bar {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    height: 56px;
    background-color: var(--bg-secondary);
    display: flex;
    align-items: center;
    padding: 0 16px;
    z-index: 9999;
    transition: background-color 0.3s ease;
}

.top-bar svg {
    cursor: pointer;
    fill: var(--text-primary);
    transition: fill 0.3s ease;
}

.bottom-nav {
    position: fixed;
    bottom: 0;
    left: 0;
    right: 0;
    height: 54px;
    background-color: var(--bg-tertiary);
    display: flex;
    justify-content: space-around;
    align-items: center;
    border-top: 1px solid var(--border-primary);
    z-index: 9999;
    transition: background-color 0.3s ease, border-color 0.3s ease;
}

.nav-item {
    display: flex;
    flex-direction: column;
    justify-content: space-between;
    align-items: center;
    height: 100%;
    font-size: 12px;
    color: var(--nav-inactive);
    cursor: pointer;
    transition: color 0.3s ease;
}

.nav-item span {
    font-family: "Google Sans", Roboto, Arial, sans-serif;
    font-size: .875rem;
    letter-spacing: .0178571429em;
    font-weight: 500;
}

.nav-item img {
    width: 24px;
    height: 24px;
    margin-bottom: 4px;
}
.nav-item svg {
    width: 24px;
    height: 24px;
    margin-bottom: 4px;
    color: inherit;
    fill: currentColor;
    transition: color 0.3s ease, fill 0.3s ease;
}

.nav-item.active span {
    color: var(--nav-active);
}

.nav-item.active img {
    filter: brightness(0) saturate(100%) invert(67%) sepia(10%) saturate(1794%) hue-rotate(174deg) brightness(100%) contrast(90%);
}

body {
    padding-bottom: 64px;
}

/* Progress ring defaults: hidden until .visible or .running */
.icon-wrap {
    position: relative;
    width: 64px;
    height: 64px;
}

.progress-ring {
    display: none;
    position: absolute;
    top: -8px;
    left: -8px;
    width: 80px;
    height: 80px;
    pointer-events: none;
}

.progress-ring circle {
    fill: transparent;
}

.progress-ring .ring-bg {
    stroke: var(--bg-progress-ring);
    stroke-width: 4;
}

.progress-ring .ring-fg {
    stroke: var(--bg-progress-ring-fg);
    stroke-width: 4;
    stroke-linecap: round;
    /* initialize to empty ring for r=36 (≈226px) */
    stroke-dasharray: 226;
    stroke-dashoffset: 226;
    transition: stroke-dashoffset .25s ease;
}

.progress-ring.running {
    display: block;
    animation: rotate 1.1s linear infinite;
}

.progress-ring.running .ring-fg {
    animation: dash 1.4s ease-in-out infinite;
}

.progress-ring.visible {
    display: block;
}

@keyframes rotate {
    to {
        transform: rotate(360deg);
    }
}

@keyframes dash {
    0% {
        stroke-dasharray: 1 260;
        stroke-dashoffset: 0;
    }

    50% {
        stroke-dasharray: 120 260;
        stroke-dashoffset: -60;
    }

    100% {
        stroke-dasharray: 1 260;
        stroke-dashoffset: -220;
    }
}


/* === Cross‑browser scrollbar hiding for horizontal scrollers === */
/* Applies to the stats strip and media gallery */
.stats,
#mediaGallery {
  scrollbar-width: none;          /* Firefox */
  -ms-overflow-style: none;        /* IE/Edge legacy */
}
.stats::-webkit-scrollbar,
#mediaGallery::-webkit-scrollbar {
  display: none;                   /* WebKit */
}

/* Ensure intended horizontal layout */
#mediaGallery {
  display: flex;
  gap: 12px;
  white-space: nowrap;
  max-height: 200px;
}

/* === Title arrow styling + rotated state (for sections) === */
.title-arrow {
  width: 28px;
  height: 32px;
  background-color: var(--bg-title-arrow);
  border-radius: 20px;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: background-color 0.3s ease;
}
.title-arrow svg {
  transition: transform .25s ease;
}
.title-arrow.open svg {
  transform: rotate(90deg);
}

/* Modal images should match videos */
.modal img {
  width: 100%;
  height: auto;
  border-radius: 12px;
}

/* Rating bars default look (in case inline widths are removed later) */
.ratings-bar {
  height: 100%;
  background: var(--text-star);
  border-radius: 4px;
  transition: background-color 0.3s ease;
}
/* Layout tweaks moved from inline styles */
body { padding-top: 56px; overscroll-behavior-y: contain; }
.header { gap: 20px; }
.stats { display:flex; gap:16px; text-align:center; font-size:14px; margin-bottom:16px; overflow-x:auto; white-space:nowrap; padding-bottom:15px; padding-top:10px; }
.stat-block { flex:0 0 140px; position:relative; }
#installButton { width:100%; padding:12px; background:var(--bg-button); border:none; border-radius:20px; color:var(--text-button); font-size:16px; margin-bottom:16px; transition: background-color 0.3s ease, color 0.3s ease; }
#mediaGallery { overflow-x:auto; }
#securityContainer { border:1px solid var(--bg-security-border); border-radius:12px; padding:16px; background:none; font-size:14px; color:var(--text-secondary); transition: border-color 0.3s ease, color 0.3s ease; }
/* === Data Safety (Security) section === */
#securityContainer .ds-item {
  display:flex;
  align-items:flex-start;
  gap:12px;
  padding:10px 0;
  border-bottom:1px solid var(--bg-security-border);
  transition: border-color 0.3s ease;
}
#securityContainer .ds-item:last-child { border-bottom:none; }
#securityContainer .ds-icon { width:20px; height:20px; border-radius:4px; flex-shrink:0; }
#securityContainer .ds-title { font-weight:600; }
#securityContainer .ds-text { color:var(--text-secondary); font-size:14px; transition: color 0.3s ease; }

/* === Ratings block polish === */
#ratingsBlock { margin-bottom:16px; }
#ratingsBlock #bigAverageRating { font-size:48px; }
#ratingsBlock #starRating { display:flex; gap:2px; }
#ratingsBlock #totalReviewsText { font-size:12px; color:var(--text-tertiary); transition: color 0.3s ease; }

/* Header with arrow / generic section header */
.ratings-header { display:flex; justify-content:space-between; align-items:center; cursor:pointer; }

/* Tags container */
#tagsContainer { display:flex; flex-wrap:wrap; gap:8px; margin-top:8px; }

/* Security description paragraph */
#securitydesctiption { font-size:14px; color:var(--text-primary); margin-bottom:16px; line-height:20px; transition: color 0.3s ease; }

/* Ratings wrapper columns */
.ratings-wrapper { display:flex; align-items:stretch; gap:16px; margin-bottom:16px; padding:6px; }
.ratings-col-left { flex:1; display:flex; flex-direction:column; align-items:center; justify-content:center; }
.ratings-col-right { flex:3; display:flex; flex-direction:column; justify-content:center; align-items:flex-start; }

/* Modal header text */
.modal-app-title { font-size:15px; font-weight:bold; color: var(--text-primary); transition: color 0.3s ease; }
.modal-description-title { font-size:13px; color:var(--text-tertiary); transition: color 0.3s ease; }
.modal-section-title { margin:0; padding:10px 0; font-size:15px; color: var(--text-primary); transition: color 0.3s ease; }
.modal-description-text { white-space:normal; font-size:14px; color: var(--text-primary); transition: color 0.3s ease; }

/* Support toggle spacing */
.support-toggle { display:flex; align-items:center; justify-content:space-between; cursor:pointer; padding:12px 0; }
.support-detail { margin-left:34px; color:var(--text-primary); font-size:14px; transition: color 0.3s ease; }

/* Developer block */
.developer-info { color:var(--text-secondary); font-size:14px; transition: color 0.3s ease; }

/* Related section */
.related-title { margin-bottom:12px; padding:6px; }
#relatedGamesContainer { display:flex; gap:16px; overflow-x:auto; }

/* Header monetization text */
.monetization { font-size:13px; color:var(--text-tertiary); transition: color 0.3s ease; }

/* Stats small muted text */
.muted { font-size:12px; color:var(--text-tertiary); transition: color 0.3s ease; }
.stat-value { font-size:14px; background:none; color: var(--text-primary); transition: color 0.3s ease; }
.star { font-size:12px; border:none; background:none; color:var(--text-star); transition: color 0.3s ease; }

/* Short description */
#shortDescription { margin:0; font-size:14px; line-height:20px; }

/* Generic section wrapper spacing (as in index_original) */
.section { margin-bottom:24px; }

/* Modal sticky header */
.modal-header-sticky { position:sticky; top:0; background:var(--bg-secondary); padding:12px 0; border-bottom:1px solid var(--border-tertiary); transition: background-color 0.3s ease, border-color 0.3s ease; }

/* Support label tweaks */
.support-label { display:flex; align-items:center; gap:12px; margin-bottom:12px; }
.support-label--lg { margin-bottom:24px; }

/* Related section spacing */
.related-section { margin-top:16px; }