:root {
    --bg: #07070c;
    --bg-elev: #101018;
    --surface: rgba(255, 255, 255, 0.05);
    --surface-strong: rgba(255, 255, 255, 0.08);
    --border: rgba(255, 255, 255, 0.1);
    --text: #f4f4f7;
    --muted: #9b9bb0;
    --accent: #8b7cff;
    --accent-2: #4de2c8;
    --accent-soft: rgba(139, 124, 255, 0.18);
    --danger: #ff6b7a;
    --ok: #3ee0a0;
    --shadow: 0 20px 50px rgba(0, 0, 0, 0.35);
    --radius: 22px;
    --radius-sm: 14px;
    --font: "IBM Plex Sans Arabic", "Inter", "Segoe UI", sans-serif;
    --nav-h: 72px;
}

html.light {
    --bg: #f3f1f8;
    --bg-elev: #ffffff;
    --surface: rgba(255, 255, 255, 0.72);
    --surface-strong: #ffffff;
    --border: rgba(28, 25, 48, 0.08);
    --text: #16141f;
    --muted: #6b6780;
    --accent: #6d5efc;
    --accent-2: #0f9d8a;
    --accent-soft: rgba(109, 94, 252, 0.12);
    --shadow: 0 18px 40px rgba(40, 30, 80, 0.08);
}

* { box-sizing: border-box; margin: 0; padding: 0; }

html, body { min-height: 100%; }

body {
    font-family: var(--font);
    background: var(--bg);
    color: var(--text);
    line-height: 1.55;
    overflow-x: hidden;
}

button, input, select, textarea { font-family: inherit; }

a { color: inherit; }

.bg-orbs {
    position: fixed;
    inset: 0;
    pointer-events: none;
    z-index: 0;
    overflow: hidden;
}
.bg-orbs::before,
.bg-orbs::after {
    content: "";
    position: absolute;
    width: 42vw;
    height: 42vw;
    border-radius: 50%;
    filter: blur(80px);
    opacity: 0.35;
}
.bg-orbs::before {
    background: #5b3dff;
    top: -12vw;
    inset-inline-start: -8vw;
}
.bg-orbs::after {
    background: #21c8b2;
    bottom: -16vw;
    inset-inline-end: -10vw;
}
html.light .bg-orbs::before,
html.light .bg-orbs::after { opacity: 0.18; }

.app-shell {
    position: relative;
    z-index: 1;
    min-height: 100vh;
    display: flex;
    flex-direction: column;
}

.nav {
    position: sticky;
    top: 0;
    z-index: 40;
    height: var(--nav-h);
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 16px;
    padding: 0 28px;
    backdrop-filter: blur(22px);
    background: color-mix(in srgb, var(--bg) 72%, transparent);
    border-bottom: 1px solid var(--border);
}

.brand {
    display: flex;
    align-items: center;
    gap: 10px;
    font-weight: 700;
    letter-spacing: -0.03em;
    font-size: 18px;
}
.brand-mark {
    width: 34px;
    height: 34px;
    border-radius: 11px;
    display: grid;
    place-items: center;
    background: linear-gradient(135deg, var(--accent), var(--accent-2));
    color: #0b0b12;
    box-shadow: 0 8px 20px rgba(109, 94, 252, 0.35);
}
.brand-mark svg { width: 18px; height: 18px; }

.nav-tabs {
    display: flex;
    gap: 6px;
    background: var(--surface);
    border: 1px solid var(--border);
    padding: 5px;
    border-radius: 999px;
}
.nav-tabs button {
    border: 0;
    background: transparent;
    color: var(--muted);
    padding: 8px 16px;
    border-radius: 999px;
    cursor: pointer;
    font-size: 14px;
    font-weight: 600;
    transition: 0.2s ease;
}
.nav-tabs button.active,
.nav-tabs button:hover {
    color: var(--text);
    background: var(--surface-strong);
}
.nav-tabs button.active {
    box-shadow: inset 0 0 0 1px var(--border);
}

.nav-actions { display: flex; align-items: center; gap: 8px; }

.icon-btn {
    width: 40px;
    height: 40px;
    border-radius: 12px;
    border: 1px solid var(--border);
    background: var(--surface);
    color: var(--text);
    cursor: pointer;
    display: grid;
    place-items: center;
    transition: 0.2s ease;
}
.icon-btn:hover { transform: translateY(-1px); border-color: color-mix(in srgb, var(--accent) 50%, var(--border)); }
.icon-btn svg { width: 18px; height: 18px; }

.lang-switch {
    display: flex;
    border: 1px solid var(--border);
    border-radius: 12px;
    overflow: hidden;
    background: var(--surface);
}
.lang-switch button {
    border: 0;
    background: transparent;
    color: var(--muted);
    padding: 8px 11px;
    cursor: pointer;
    font-weight: 700;
    font-size: 12px;
}
.lang-switch button.active { background: var(--accent-soft); color: var(--text); }

main {
    width: min(1180px, calc(100% - 40px));
    margin: 0 auto;
    flex: 1;
    padding: 28px 0 80px;
}

.hero {
    text-align: center;
    padding: 28px 0 22px;
}
.hero h1 {
    font-size: clamp(28px, 5vw, 48px);
    letter-spacing: -0.04em;
    line-height: 1.15;
    margin-bottom: 10px;
}
.hero p {
    color: var(--muted);
    font-size: 16px;
}

.search-wrap { position: relative; margin: 28px auto 0; max-width: 820px; }

.search-box {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 10px;
    border-radius: 22px;
    background: var(--surface);
    border: 1px solid var(--border);
    box-shadow: var(--shadow);
    backdrop-filter: blur(18px);
}
.search-box:focus-within {
    border-color: color-mix(in srgb, var(--accent) 55%, var(--border));
    box-shadow: 0 0 0 6px var(--accent-soft), var(--shadow);
}
.search-box input {
    flex: 1;
    border: 0;
    outline: none;
    background: transparent;
    color: var(--text);
    font-size: 16px;
    padding: 10px 8px;
    min-width: 0;
}
.search-box input::placeholder { color: var(--muted); }

.primary-btn,
.ghost-btn,
.chip,
.pill {
    border: 0;
    cursor: pointer;
    border-radius: 999px;
    font-weight: 700;
}

.primary-btn {
    background: linear-gradient(135deg, var(--accent), #6ad7c8);
    color: #0c0c14;
    padding: 12px 20px;
    font-size: 14px;
    white-space: nowrap;
}
.primary-btn:hover { filter: brightness(1.05); }

.ghost-btn {
    background: var(--surface);
    color: var(--text);
    border: 1px solid var(--border);
    padding: 10px 14px;
    font-size: 13px;
}
.ghost-btn:hover { background: var(--surface-strong); }

.mode-row, .history-row, .toolbar, .filters {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
    justify-content: center;
    margin-top: 14px;
}

.chip {
    background: var(--surface);
    color: var(--muted);
    border: 1px solid var(--border);
    padding: 7px 12px;
    font-size: 13px;
}
.chip.active, .chip:hover { color: var(--text); background: var(--accent-soft); }
.country-field {
    flex: 0 0 190px;
    min-width: 160px;
    margin: 0;
    text-align: start;
}
.country-field span {
    font-size: 12px;
    color: var(--muted);
    font-weight: 700;
}
.chip.history { font-weight: 500; }

.suggestions {
    position: absolute;
    inset-inline: 0;
    top: calc(100% + 8px);
    background: var(--bg-elev);
    border: 1px solid var(--border);
    border-radius: 18px;
    overflow: hidden;
    box-shadow: var(--shadow);
    display: none;
    z-index: 20;
}
.suggestions.open { display: block; }
.suggestion {
    width: 100%;
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 10px 14px;
    background: transparent;
    border: 0;
    color: var(--text);
    cursor: pointer;
    text-align: start;
}
.suggestion:hover { background: var(--surface); }
.suggestion img {
    width: 36px;
    height: 36px;
    border-radius: 10px;
}
.suggestion small { color: var(--muted); display: block; }

.filters {
    align-items: end;
    margin-top: 18px;
    padding: 16px;
    border-radius: var(--radius);
    background: var(--surface);
    border: 1px solid var(--border);
}
.filters.hidden { display: none; }
.field { display: flex; flex-direction: column; gap: 6px; min-width: 140px; flex: 1; }
.field label { font-size: 12px; color: var(--muted); font-weight: 700; }
.field select {
    appearance: none;
    background: var(--bg-elev) url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' viewBox='0 0 24 24' fill='none' stroke='%239b9bb0' stroke-width='2'%3E%3Cpath d='M6 9l6 6 6-6'/%3E%3C/svg%3E") no-repeat;
    background-position: center left 12px;
    padding: 10px 14px;
    border-radius: 12px;
    border: 1px solid var(--border);
    color: var(--text);
}
[dir="rtl"] .field select { background-position: center right 12px; padding-inline: 14px 28px; }
[dir="ltr"] .field select { padding-inline: 14px 28px; }
.field select:focus { outline: none; border-color: var(--accent); }

.toolbar {
    justify-content: space-between;
    margin: 22px 0 8px;
}
.toolbar-left, .toolbar-right { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; }
.count { color: var(--muted); font-size: 13px; font-weight: 600; }

.grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(250px, 1fr));
    gap: 16px;
}

.card {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 18px;
    box-shadow: var(--shadow);
    display: flex;
    flex-direction: column;
    gap: 12px;
    transition: transform 0.2s ease, border-color 0.2s ease;
    min-height: 100%;
}
.card:hover {
    transform: translateY(-4px);
    border-color: color-mix(in srgb, var(--accent) 40%, var(--border));
}
.card-top {
    display: flex;
    gap: 12px;
    align-items: flex-start;
}
.card-top img {
    width: 68px;
    height: 68px;
    border-radius: 18px;
    box-shadow: 0 10px 24px rgba(0,0,0,0.25);
    object-fit: cover;
}
.card-title { font-size: 16px; font-weight: 800; letter-spacing: -0.02em; }
.card-sub { color: var(--muted); font-size: 13px; margin-top: 2px; }
.rank {
    min-width: 28px;
    height: 28px;
    border-radius: 8px;
    display: grid;
    place-items: center;
    font-size: 12px;
    font-weight: 800;
    background: var(--accent-soft);
}
.rank.gold { background: #f5c451; color: #2a2108; }
.rank.silver { background: #c8cdd6; color: #2a2e36; }
.rank.bronze { background: #d08a5a; color: #2a160c; }

.meta-row { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; }
.pill {
    background: var(--surface-strong);
    border: 1px solid var(--border);
    color: var(--text);
    padding: 4px 9px;
    font-size: 12px;
    font-weight: 700;
}
.pill.free { color: #0b3d2c; background: #3ee0a0; border-color: transparent; }
html.light .pill.free { color: #0b3d2c; }
.stars { color: #f5c451; font-size: 13px; letter-spacing: 1px; }
.muted { color: var(--muted); }

.card-actions { display: flex; flex-wrap: wrap; gap: 6px; margin-top: auto; }
.card-actions button, .card-actions a {
    text-decoration: none;
    font-size: 12px;
    padding: 8px 10px;
}

.empty, .status {
    text-align: center;
    padding: 48px 16px;
    color: var(--muted);
}
.empty h3 { color: var(--text); margin-bottom: 6px; }

.skeleton {
    background: linear-gradient(90deg, var(--surface), var(--surface-strong), var(--surface));
    background-size: 200% 100%;
    animation: shimmer 1.2s infinite;
    border-radius: 16px;
    min-height: 210px;
}
@keyframes shimmer {
    0% { background-position: 100% 0; }
    100% { background-position: -100% 0; }
}

.overlay {
    position: fixed;
    inset: 0;
    background: rgba(5, 5, 10, 0.62);
    backdrop-filter: blur(10px);
    z-index: 60;
    display: none;
    align-items: center;
    justify-content: center;
    padding: 24px;
}
.overlay.open { display: flex; }

.drawer {
    width: min(980px, 100%);
    max-height: min(90vh, 920px);
    overflow: auto;
    background: var(--bg-elev);
    border: 1px solid var(--border);
    border-radius: 28px;
    box-shadow: var(--shadow);
    padding: 24px;
}

.drawer-head {
    display: flex;
    gap: 16px;
    align-items: flex-start;
}
.drawer-head img {
    width: 92px;
    height: 92px;
    border-radius: 24px;
    object-fit: cover;
}
.drawer-head h2 { font-size: 26px; letter-spacing: -0.03em; }
.drawer-close { margin-inline-start: auto; }

.stats {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(120px, 1fr));
    gap: 10px;
    margin: 18px 0;
}
.stat {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: 16px;
    padding: 12px;
}
.stat b { display: block; font-size: 15px; }
.stat span { color: var(--muted); font-size: 12px; }

.shots {
    display: flex;
    gap: 10px;
    overflow-x: auto;
    padding-bottom: 8px;
    scroll-snap-type: x mandatory;
}
.shots img {
    height: 280px;
    border-radius: 18px;
    scroll-snap-align: start;
    border: 1px solid var(--border);
}

.desc {
    white-space: pre-wrap;
    color: color-mix(in srgb, var(--text) 88%, var(--muted));
    margin: 14px 0;
}
.lang-chips { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 8px; }

.compare-box { margin-top: 18px; }
.compare-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(148px, 1fr));
    gap: 10px;
}
.compare-card {
    display: flex;
    flex-direction: column;
    gap: 8px;
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: 18px;
    padding: 14px;
    text-decoration: none;
    color: inherit;
    min-height: 112px;
    transition: border-color 0.18s ease, transform 0.18s ease, background 0.18s ease;
}
.compare-card strong { color: var(--muted); font-size: 12px; font-weight: 700; }
.compare-card b { font-size: 18px; letter-spacing: -0.03em; }
.compare-card:hover { border-color: color-mix(in srgb, var(--accent) 55%, var(--border)); transform: translateY(-2px); }
.compare-card.missing { opacity: 0.5; }
.compare-card.is-cheap,
.iap-price.is-cheap {
    border-color: color-mix(in srgb, var(--ok) 55%, var(--border));
}
.compare-card.is-current,
.iap-price.is-current {
    border-color: color-mix(in srgb, var(--accent) 70%, var(--border));
    background: var(--accent-soft);
}

.iap-board {
    display: grid;
    gap: 16px;
}
.iap-board-head {
    display: flex;
    justify-content: space-between;
    gap: 16px;
    align-items: flex-end;
    padding: 4px 2px 2px;
}
.iap-kicker {
    color: var(--accent-2);
    font-size: 12px;
    font-weight: 700;
    letter-spacing: 0.04em;
}
.iap-board-head h3 {
    font-size: 22px;
    letter-spacing: -0.04em;
    margin-top: 2px;
}
.iap-board-head p:last-child {
    color: var(--muted);
    font-size: 12px;
    max-width: 280px;
    line-height: 1.5;
}
.iap-plans { display: grid; gap: 14px; }
.iap-plan {
    background: linear-gradient(180deg, var(--surface-strong), var(--surface));
    border: 1px solid var(--border);
    border-radius: 22px;
    padding: 16px;
    box-shadow: 0 10px 30px rgba(0, 0, 0, 0.12);
}
.iap-plan-head {
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 12px;
    margin-bottom: 14px;
}
.iap-plan-head h4 {
    font-size: 17px;
    letter-spacing: -0.03em;
}
.iap-plan-head p {
    color: var(--muted);
    font-size: 12px;
    margin-top: 2px;
}
.iap-plan-count {
    background: var(--accent-soft);
    color: var(--text);
    border: 1px solid var(--border);
    border-radius: 999px;
    padding: 6px 10px;
    font-size: 12px;
    font-weight: 700;
}
.iap-price-grid {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 8px;
}
@media (min-width: 720px) {
    .iap-price-grid {
        grid-template-columns: repeat(auto-fill, minmax(140px, 1fr));
    }
}
.iap-price {
    display: flex;
    flex-direction: column;
    gap: 8px;
    min-height: 86px;
    padding: 11px 12px;
    border-radius: 16px;
    background: color-mix(in srgb, var(--bg) 55%, transparent);
    border: 1px solid var(--border);
    text-decoration: none;
    color: inherit;
    transition: border-color 0.18s ease, transform 0.18s ease;
}
.iap-price > a {
    display: flex;
    flex-direction: column;
    gap: 6px;
    color: inherit;
    text-decoration: none;
    flex: 1;
}
.iap-price:hover { transform: translateY(-1px); border-color: color-mix(in srgb, var(--accent-2) 50%, var(--border)); }
.iap-price-top {
    display: flex;
    align-items: center;
    gap: 6px;
}
.iap-flag { font-size: 14px; line-height: 1; }
.iap-country { color: var(--muted); font-size: 11px; font-weight: 700; }
.iap-price strong {
    font-size: 15px;
    letter-spacing: -0.03em;
    line-height: 1.25;
}
.iap-price small { color: var(--muted); font-size: 10px; line-height: 1.3; }
.iap-price.missing { opacity: 0.42; }
.iap-empty {
    margin-top: 8px;
    padding: 22px;
    border-radius: 20px;
    border: 1px dashed var(--border);
    background: var(--surface);
}
.iap-empty p + p { margin-top: 6px; }
.iap-progress {
    position: relative;
    overflow: hidden;
    padding: 14px 16px 16px;
    border-radius: 18px;
    background: var(--surface);
    border: 1px solid var(--border);
}
.iap-progress p {
    color: var(--muted);
    font-size: 13px;
    font-weight: 600;
}
.iap-progress > span {
    display: block;
    height: 4px;
    margin-bottom: 10px;
    border-radius: 999px;
    background: linear-gradient(90deg, var(--accent), var(--accent-2));
    width: 24%;
    transition: width 0.3s ease;
}

.iap-toolbar {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
    align-items: center;
}
.iap-toolbar .chip { cursor: pointer; }
.iap-fx, .iap-period, .badge-cheap, .badge-miss {
    display: inline-flex;
    align-items: center;
    border-radius: 999px;
    padding: 3px 8px;
    font-size: 11px;
    font-weight: 700;
}
.iap-fx { color: var(--accent-2); background: color-mix(in srgb, var(--accent-2) 12%, transparent); }
.iap-period { background: var(--surface-strong); color: var(--muted); border: 1px solid var(--border); }
.badge-cheap { background: color-mix(in srgb, var(--ok) 18%, transparent); color: var(--ok); }
.badge-miss { background: color-mix(in srgb, var(--danger) 16%, transparent); color: var(--danger); }
.iap-vs { color: var(--muted); font-size: 11px; line-height: 1.35; }
.iap-price.is-cheap { border-color: color-mix(in srgb, var(--ok) 55%, var(--border)); }
.iap-board-actions { display: flex; flex-wrap: wrap; gap: 8px; }

.duel-bar {
    display: flex;
    flex-wrap: wrap;
    gap: 10px;
    align-items: center;
    justify-content: space-between;
    margin-top: 14px;
    padding: 12px 14px;
    border-radius: 18px;
    background: var(--accent-soft);
    border: 1px solid var(--border);
}
.duel-bar-apps { display: flex; flex-wrap: wrap; gap: 10px; align-items: center; }
.duel-mini { display: flex; gap: 8px; align-items: center; font-weight: 700; }
.duel-mini img { width: 32px; height: 32px; border-radius: 9px; }
.duel-grid {
    display: grid;
    grid-template-columns: 140px 1fr 1fr;
    gap: 10px;
    margin-top: 18px;
}
.duel-grid div {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: 16px;
    padding: 12px;
}
.duel-grid .label { color: var(--muted); font-size: 12px; font-weight: 700; }
.duel-app { text-align: center; }
.duel-app img { width: 72px; height: 72px; border-radius: 20px; }
#duelOverlay { z-index: 70; }
.duel-iap { margin-top: 22px; }
.duel-iap h3 { margin-bottom: 10px; }
.duel-iap-grid strong { display: block; font-size: 18px; }
.iap-price-top { display: flex; flex-wrap: wrap; gap: 6px; align-items: center; }
.alerts-box { margin-top: 22px; display: grid; gap: 10px; }
.alert-card {
    display: flex;
    justify-content: space-between;
    gap: 12px;
    align-items: center;
    padding: 12px 14px;
    border-radius: 16px;
    background: var(--surface);
    border: 1px solid var(--border);
}
@media (max-width: 800px) {
    .duel-grid { grid-template-columns: 1fr; }
}

.toast-wrap {
    position: fixed;
    inset-inline-end: 18px;
    bottom: 18px;
    z-index: 80;
    display: flex;
    flex-direction: column;
    gap: 8px;
}
.toast {
    background: var(--bg-elev);
    color: var(--text);
    border: 1px solid var(--border);
    border-radius: 14px;
    padding: 10px 14px;
    box-shadow: var(--shadow);
    min-width: 180px;
}

.footer {
    text-align: center;
    color: var(--muted);
    padding: 20px;
    font-size: 13px;
}

.hidden { display: none !important; }
.developer-banner {
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 12px;
    padding: 14px 16px;
    border-radius: 16px;
    background: var(--accent-soft);
    border: 1px solid var(--border);
    margin-bottom: 16px;
}

@media (max-width: 800px) {
    .nav { padding: 0 14px; }
    .nav-tabs { display: none; }
    .mobile-tabs { display: flex !important; }
    main { width: min(100% - 24px, 1180px); }
    .search-box { flex-direction: column; align-items: stretch; }
    .drawer-head { flex-direction: column; }
    .shots img { height: 220px; }
    .iap-board-head { flex-direction: column; align-items: flex-start; }
    .iap-board-head p:last-child { max-width: none; }
}

.mobile-tabs {
    display: none;
    position: sticky;
    bottom: 12px;
    z-index: 30;
    margin: 0 auto;
    width: min(420px, 100%);
    background: var(--bg-elev);
    border: 1px solid var(--border);
    border-radius: 999px;
    padding: 6px;
    box-shadow: var(--shadow);
}
.mobile-tabs button {
    flex: 1;
    border: 0;
    background: transparent;
    color: var(--muted);
    padding: 10px 8px;
    border-radius: 999px;
    font-weight: 700;
    cursor: pointer;
}
.mobile-tabs button.active { background: var(--accent-soft); color: var(--text); }
