/* ==========================================================================
   PlayMetrics — refined dark aurora/glass design system
   ========================================================================== */

:root {
    --bg: #07070c;
    --bg-elev: #0d0d15;
    --surface: rgba(255, 255, 255, 0.035);
    --surface-strong: rgba(255, 255, 255, 0.06);
    --border: rgba(255, 255, 255, 0.09);
    --border-strong: rgba(255, 255, 255, 0.16);

    --text: #f5f5fa;
    --text-dim: #9c9cb4;
    --text-faint: #6b6b82;

    --brand-1: #6366f1;
    --brand-2: #8b5cf6;
    --brand-3: #ec4899;
    --accent-grad: linear-gradient(135deg, var(--brand-1) 0%, var(--brand-2) 48%, var(--brand-3) 100%);

    --up: #34d399;
    --down: #fb7185;
    --star: #fbbf24;

    --radius-lg: 22px;
    --radius-md: 15px;
    --radius-sm: 10px;

    --shadow-card: 0 1px 2px rgba(0, 0, 0, 0.4), 0 12px 40px -12px rgba(0, 0, 0, 0.5);
    --shadow-glow: 0 0 0 1px rgba(139, 92, 246, 0.25), 0 20px 60px -15px rgba(99, 102, 241, 0.35);

    --font: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
    --maxw: 1140px;
}

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

html { scroll-behavior: smooth; }

body {
    font-family: var(--font);
    background: var(--bg);
    color: var(--text);
    line-height: 1.6;
    min-height: 100vh;
    overflow-x: hidden;
    -webkit-font-smoothing: antialiased;
}

/* Aurora backdrop ---------------------------------------------------------- */
.aurora {
    position: fixed;
    inset: 0;
    z-index: 0;
    pointer-events: none;
    overflow: hidden;
}
.aurora::before,
.aurora::after {
    content: '';
    position: absolute;
    width: 60vw;
    height: 60vw;
    border-radius: 50%;
    filter: blur(120px);
    opacity: 0.45;
}
.aurora::before {
    top: -20vw;
    left: -10vw;
    background: radial-gradient(circle, rgba(99, 102, 241, 0.55), transparent 65%);
    animation: drift1 26s ease-in-out infinite alternate;
}
.aurora::after {
    bottom: -25vw;
    right: -15vw;
    background: radial-gradient(circle, rgba(236, 72, 153, 0.4), transparent 65%);
    animation: drift2 32s ease-in-out infinite alternate;
}
@keyframes drift1 { to { transform: translate(8vw, 10vh) scale(1.15); } }
@keyframes drift2 { to { transform: translate(-6vw, -8vh) scale(1.1); } }

/* Layout ----------------------------------------------------------------- */
.wrap {
    position: relative;
    z-index: 1;
    max-width: var(--maxw);
    margin: 0 auto;
    padding: 0 22px;
}

.site-header {
    position: sticky;
    top: 0;
    z-index: 50;
    backdrop-filter: blur(18px) saturate(160%);
    background: rgba(7, 7, 12, 0.72);
    border-bottom: 1px solid var(--border);
}
.site-header .wrap {
    display: flex;
    align-items: center;
    gap: 20px;
    height: 66px;
}
.brand {
    display: flex;
    align-items: center;
    gap: 10px;
    font-weight: 800;
    font-size: 19px;
    letter-spacing: -0.02em;
    color: var(--text);
    text-decoration: none;
    flex-shrink: 0;
}
.brand .dot {
    width: 26px;
    height: 26px;
    border-radius: 8px;
    background: var(--accent-grad);
    box-shadow: 0 4px 14px rgba(139, 92, 246, 0.5);
}
.brand span { background: var(--accent-grad); -webkit-background-clip: text; background-clip: text; color: transparent; }

.header-search {
    flex: 1;
    max-width: 460px;
    margin-left: auto;
    display: none;
}
.header-search.visible { display: block; }
.header-search input {
    width: 100%;
    padding: 10px 16px;
    background: var(--surface-strong);
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    color: var(--text);
    font: inherit;
    font-size: 14px;
    transition: border-color 0.2s, box-shadow 0.2s;
}
.header-search input:focus {
    outline: none;
    border-color: var(--brand-2);
    box-shadow: 0 0 0 3px rgba(139, 92, 246, 0.2);
}

/* Hero ----------------------------------------------------------------- */
.hero {
    text-align: center;
    padding: clamp(60px, 12vh, 130px) 0 70px;
}
.hero h1 {
    font-size: clamp(2.4rem, 6vw, 4rem);
    font-weight: 900;
    letter-spacing: -0.035em;
    line-height: 1.05;
    margin-bottom: 18px;
}
.hero h1 em {
    font-style: normal;
    background: var(--accent-grad);
    -webkit-background-clip: text;
    background-clip: text;
    color: transparent;
}
.hero p {
    color: var(--text-dim);
    font-size: clamp(1rem, 2vw, 1.2rem);
    max-width: 560px;
    margin: 0 auto 40px;
}

.search-box {
    display: flex;
    gap: 12px;
    max-width: 640px;
    margin: 0 auto;
}
@media (max-width: 560px) { .search-box { flex-direction: column; } }

.search-box input {
    flex: 1;
    padding: 18px 22px;
    background: var(--surface-strong);
    border: 1px solid var(--border-strong);
    border-radius: var(--radius-md);
    color: var(--text);
    font: inherit;
    font-size: 16px;
    transition: border-color 0.25s, box-shadow 0.25s, transform 0.25s;
}
.search-box input::placeholder { color: var(--text-faint); }
.search-box input:focus {
    outline: none;
    border-color: var(--brand-2);
    box-shadow: var(--shadow-glow);
    transform: translateY(-1px);
}

.btn {
    padding: 18px 30px;
    border: none;
    border-radius: var(--radius-md);
    background: var(--accent-grad);
    color: #fff;
    font: inherit;
    font-weight: 700;
    font-size: 15px;
    cursor: pointer;
    white-space: nowrap;
    transition: transform 0.2s, box-shadow 0.2s, filter 0.2s;
    box-shadow: 0 10px 30px -8px rgba(99, 102, 241, 0.6);
}
.btn:hover { transform: translateY(-2px); filter: brightness(1.08); box-shadow: 0 16px 40px -8px rgba(99, 102, 241, 0.7); }
.btn:active { transform: translateY(0); }
.btn[disabled] { opacity: 0.6; cursor: progress; transform: none; }

.examples {
    margin-top: 26px;
    display: flex;
    flex-wrap: wrap;
    gap: 9px;
    justify-content: center;
}
.examples span { color: var(--text-faint); font-size: 13px; align-self: center; }
.chip {
    padding: 7px 14px;
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: 999px;
    color: var(--text-dim);
    font-size: 13px;
    cursor: pointer;
    transition: all 0.2s;
}
.chip:hover { border-color: var(--brand-2); color: var(--text); background: var(--surface-strong); }

/* Generic card --------------------------------------------------------- */
.card {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius-lg);
    padding: 30px;
    backdrop-filter: blur(12px);
    box-shadow: var(--shadow-card);
}

.section { margin-bottom: 26px; animation: rise 0.6s cubic-bezier(0.2, 0.7, 0.2, 1) both; }
@keyframes rise { from { opacity: 0; transform: translateY(18px); } to { opacity: 1; transform: none; } }

.section-head {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 16px;
    margin-bottom: 20px;
    flex-wrap: wrap;
}
.section-head h2 {
    font-size: 1.2rem;
    font-weight: 750;
    letter-spacing: -0.01em;
    display: flex;
    align-items: center;
    gap: 11px;
}
.section-head h2::before {
    content: '';
    width: 4px;
    height: 20px;
    border-radius: 2px;
    background: var(--accent-grad);
}

/* App overview -------------------------------------------------------- */
#results { padding: 34px 0 80px; display: none; }
#results.visible { display: block; }

.app-hero {
    position: relative;
    overflow: hidden;
    display: flex;
    gap: 28px;
    align-items: center;
}
.app-hero__bg {
    position: absolute;
    inset: 0;
    background-size: cover;
    background-position: center;
    opacity: 0.16;
    filter: blur(6px) saturate(140%);
    transform: scale(1.1);
    z-index: 0;
}
.app-hero > * { position: relative; z-index: 1; }
.app-hero__icon {
    width: 118px;
    height: 118px;
    border-radius: 26px;
    object-fit: cover;
    flex-shrink: 0;
    border: 1px solid var(--border-strong);
    box-shadow: 0 14px 40px -10px rgba(0, 0, 0, 0.7);
}
.app-hero__meta { flex: 1; min-width: 0; }
.app-hero__meta h1 {
    font-size: clamp(1.4rem, 3.5vw, 2rem);
    font-weight: 850;
    letter-spacing: -0.02em;
    line-height: 1.15;
    margin-bottom: 4px;
}
.app-hero__dev { color: var(--brand-2); font-weight: 600; font-size: 0.95rem; margin-bottom: 14px; }
.app-hero__dev a { color: inherit; text-decoration: none; }
.app-hero__dev a:hover { text-decoration: underline; }

.badges { display: flex; flex-wrap: wrap; gap: 9px; }
.badge {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 7px 13px;
    background: var(--surface-strong);
    border: 1px solid var(--border);
    border-radius: 999px;
    font-size: 13px;
    font-weight: 600;
    color: var(--text-dim);
}
.badge strong { color: var(--text); font-weight: 700; }
.badge--free { color: var(--up); border-color: rgba(52, 211, 153, 0.3); background: rgba(52, 211, 153, 0.1); }
.badge--star strong { color: var(--star); }

/* KPI grid ----------------------------------------------------------- */
.kpis {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(150px, 1fr));
    gap: 14px;
}
.kpi {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius-md);
    padding: 20px 18px;
    text-align: center;
    transition: transform 0.25s, border-color 0.25s, background 0.25s;
}
.kpi:hover { transform: translateY(-4px); border-color: var(--border-strong); background: var(--surface-strong); }
.kpi__icon { font-size: 1.3rem; display: block; margin-bottom: 8px; }
.kpi__value {
    font-size: clamp(1.35rem, 3vw, 1.8rem);
    font-weight: 850;
    letter-spacing: -0.02em;
    background: var(--accent-grad);
    -webkit-background-clip: text;
    background-clip: text;
    color: transparent;
}
.kpi__label { color: var(--text-faint); font-size: 11.5px; text-transform: uppercase; letter-spacing: 0.08em; margin-top: 4px; }

/* Tabs / switchers -------------------------------------------------- */
.switch { display: inline-flex; background: var(--surface-strong); border: 1px solid var(--border); border-radius: 999px; padding: 4px; gap: 2px; }
.switch button {
    padding: 7px 15px;
    border: none;
    background: transparent;
    color: var(--text-dim);
    font: inherit;
    font-size: 13px;
    font-weight: 600;
    border-radius: 999px;
    cursor: pointer;
    transition: all 0.2s;
}
.switch button:hover { color: var(--text); }
.switch button.active { background: var(--accent-grad); color: #fff; box-shadow: 0 4px 14px -4px rgba(99, 102, 241, 0.6); }

.date-input {
    padding: 9px 14px;
    background: var(--surface-strong);
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    color: var(--text);
    font: inherit;
    font-size: 13px;
    color-scheme: dark;
}
.date-input:focus { outline: none; border-color: var(--brand-2); }

/* Charts ----------------------------------------------------------- */
.chart-wrap {
    position: relative;
    height: 340px;
    padding: 8px;
}
@media (max-width: 560px) { .chart-wrap { height: 260px; } }

/* Rankings table ------------------------------------------------- */
.table-scroll { overflow: auto; max-height: 540px; border-radius: var(--radius-sm); }
.table-scroll::-webkit-scrollbar { width: 10px; height: 10px; }
.table-scroll::-webkit-scrollbar-thumb { background: var(--border-strong); border-radius: 6px; }
.rank-table { width: 100%; border-collapse: collapse; font-size: 14px; min-width: 520px; }
.rank-table th {
    position: sticky;
    top: 0;
    background: var(--bg-elev);
    z-index: 1;
    text-align: left;
    padding: 12px 14px;
    font-size: 11px;
    text-transform: uppercase;
    letter-spacing: 0.07em;
    color: var(--text-faint);
    border-bottom: 1px solid var(--border);
}
.rank-table td { padding: 13px 14px; border-bottom: 1px solid var(--border); color: var(--text-dim); }
.rank-table tr:last-child td { border-bottom: none; }
.rank-table tbody tr { transition: background 0.15s; }
.rank-table tbody tr:hover { background: var(--surface); }
.flag { font-size: 1.25rem; margin-right: 9px; vertical-align: -2px; }
.rank-pill {
    display: inline-block;
    min-width: 42px;
    text-align: center;
    padding: 4px 10px;
    border-radius: 7px;
    font-weight: 700;
    font-size: 13px;
    background: rgba(99, 102, 241, 0.16);
    color: #a5b4fc;
}
.rank-pill--prev { background: var(--surface-strong); color: var(--text-faint); }
.delta { font-weight: 700; font-size: 13px; display: inline-flex; align-items: center; gap: 3px; }
.delta--up { color: var(--up); }
.delta--down { color: var(--down); }
.delta--flat { color: var(--text-faint); }
.delta--new { color: var(--star); }

.chart-type-label { font-size: 12px; color: var(--text-faint); font-weight: 600; }

/* Screenshots -------------------------------------------------- */
.shots {
    display: flex;
    gap: 14px;
    overflow-x: auto;
    padding-bottom: 8px;
    scroll-snap-type: x mandatory;
}
.shots img {
    height: 300px;
    width: auto;
    border-radius: var(--radius-md);
    border: 1px solid var(--border);
    cursor: zoom-in;
    scroll-snap-align: start;
    transition: transform 0.25s, border-color 0.25s;
    flex-shrink: 0;
}
.shots img:hover { transform: translateY(-4px); border-color: var(--brand-2); }
.shots img.landscape { height: 220px; }

/* Description ------------------------------------------------- */
.description { color: var(--text-dim); font-size: 0.97rem; line-height: 1.8; }
.description.clamped { display: -webkit-box; -webkit-line-clamp: 6; -webkit-box-orient: vertical; overflow: hidden; }
.read-more {
    margin-top: 12px;
    background: none;
    border: none;
    color: var(--brand-2);
    font: inherit;
    font-weight: 600;
    font-size: 13px;
    cursor: pointer;
}

/* States --------------------------------------------------- */
.skeleton {
    background: linear-gradient(100deg, var(--surface) 30%, var(--surface-strong) 50%, var(--surface) 70%);
    background-size: 200% 100%;
    animation: shimmer 1.4s ease-in-out infinite;
    border-radius: var(--radius-sm);
}
@keyframes shimmer { to { background-position: -200% 0; } }
.sk-line { height: 13px; margin-bottom: 10px; }
.sk-block { height: 100%; width: 100%; border-radius: var(--radius-md); }

.inline-msg {
    text-align: center;
    padding: 40px 20px;
    color: var(--text-faint);
    font-size: 14px;
}
.inline-msg--error { color: var(--down); }

.toast {
    position: fixed;
    left: 50%;
    bottom: 28px;
    transform: translateX(-50%) translateY(30px);
    opacity: 0;
    visibility: hidden;
    background: var(--bg-elev);
    border: 1px solid var(--down);
    color: var(--text);
    padding: 13px 22px;
    border-radius: var(--radius-md);
    font-size: 14px;
    font-weight: 500;
    box-shadow: var(--shadow-card);
    transition: transform 0.35s cubic-bezier(0.2, 0.8, 0.2, 1), opacity 0.3s, visibility 0.3s;
    z-index: 200;
    max-width: 90vw;
}
.toast.show { transform: translateX(-50%) translateY(0); opacity: 1; visibility: visible; }

/* Cache pill */
.cache-note { font-size: 11px; color: var(--text-faint); }
.cache-note b { color: var(--text-dim); }

/* Lightbox ------------------------------------------------ */
.lightbox {
    position: fixed;
    inset: 0;
    z-index: 300;
    background: rgba(4, 4, 8, 0.94);
    display: none;
    align-items: center;
    justify-content: center;
    padding: 40px;
    cursor: zoom-out;
    animation: fade 0.2s ease;
}
.lightbox.open { display: flex; }
.lightbox img { max-width: 92vw; max-height: 88vh; border-radius: 14px; box-shadow: 0 30px 80px rgba(0, 0, 0, 0.6); }
.lightbox__close {
    position: absolute;
    top: 22px;
    right: 30px;
    font-size: 40px;
    color: #fff;
    background: none;
    border: none;
    cursor: pointer;
    line-height: 1;
    opacity: 0.7;
    transition: opacity 0.2s, transform 0.2s;
}
.lightbox__close:hover { opacity: 1; transform: rotate(90deg); }
@keyframes fade { from { opacity: 0; } to { opacity: 1; } }

/* Footer ------------------------------------------------- */
.site-footer {
    position: relative;
    z-index: 1;
    border-top: 1px solid var(--border);
    padding: 30px 0;
    text-align: center;
    color: var(--text-faint);
    font-size: 13px;
}
.site-footer a { color: var(--text-dim); text-decoration: none; }
.site-footer a:hover { color: var(--text); }

/* Responsive -------------------------------------------- */
@media (max-width: 640px) {
    .card { padding: 22px; }
    .app-hero { flex-direction: column; text-align: center; gap: 18px; }
    .badges { justify-content: center; }
    .shots img { height: 240px; }
}

@media (prefers-reduced-motion: reduce) {
    *, *::before, *::after { animation-duration: 0.001ms !important; animation-iteration-count: 1 !important; transition-duration: 0.001ms !important; }
    html { scroll-behavior: auto; }
}
