/* AD Plays — public leaderboard (mobile-first) */
:root {
    --apl-bg: #f0f4f8;
    --apl-surface: #ffffff;
    --apl-text: #1a2b3c;
    --apl-muted: #6b7c8f;
    --apl-teal: #0d9488;
    --apl-teal-dark: #0f766e;
    --apl-shadow: 0 4px 20px rgba(15, 45, 60, 0.08);
    --apl-shadow-hover: 0 12px 32px rgba(15, 45, 60, 0.14);
    --apl-radius: 16px;
    --apl-header-h: 56px;
    --apl-font: "DM Sans", system-ui, sans-serif;
    --apl-font-display: "Montserrat", system-ui, sans-serif;
    --apl-theme-red: #e53935;
    --apl-theme-sky: #29b6f6;
    --apl-theme-green: #43a047;
    --apl-theme-purple: #8e24aa;
    --apl-theme-orange: #fb8c00;
    --apl-theme-teal: #00897b;
    --apl-theme-pink: #ec407a;
    --apl-theme-navy: #3949ab;
}

*,
*::before,
*::after {
    box-sizing: border-box;
}

html {
    -webkit-text-size-adjust: 100%;
}

.apl-page-wrap {
    min-height: 100vh;
    display: flex;
    flex-direction: column;
}

body.apl-app {
    margin: 0;
    min-height: 100vh;
    font-family: var(--apl-font);
    font-size: 15px;
    color: var(--apl-text);
    background: var(--apl-bg);
    line-height: 1.45;
}

.apl-hidden {
    display: none !important;
}

/* Header */
.apl-header {
    background: var(--apl-surface);
    border-bottom: 1px solid rgba(0, 0, 0, 0.06);
    z-index: 100;
}

.apl-header-sticky {
    position: sticky;
    top: 0;
}

.apl-header-inner {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    max-width: 720px;
    margin: 0 auto;
    padding: 0.65rem 1rem;
    min-height: var(--apl-header-h);
}

.apl-header-title {
    flex: 1;
    margin: 0;
    font-family: var(--apl-font-display);
    font-size: 1.1rem;
    font-weight: 700;
    text-align: center;
}

.apl-header-spacer {
    width: 40px;
}

.apl-back,
.apl-share-btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 40px;
    height: 40px;
    border-radius: 50%;
    color: var(--apl-text);
    text-decoration: none;
    border: none;
    background: transparent;
    cursor: pointer;
    transition: background 0.15s ease;
}

.apl-back:hover,
.apl-share-btn:hover {
    background: rgba(13, 148, 136, 0.1);
    color: var(--apl-teal-dark);
}

/* Main */
.apl-main {
    max-width: 720px;
    margin: 0 auto;
    padding: 1rem 1rem 2rem;
    width: 100%;
}

.apl-hero {
    margin-bottom: 1.25rem;
}

.apl-hero-kicker {
    margin: 0 0 0.25rem;
    font-size: 0.75rem;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.06em;
    color: var(--apl-teal);
}

.apl-hero-title {
    margin: 0 0 0.35rem;
    font-family: var(--apl-font-display);
    font-size: 1.5rem;
    font-weight: 800;
}

.apl-hero-lead {
    margin: 0;
    color: var(--apl-muted);
    font-size: 0.95rem;
}

/* Toolbar */
.apl-toolbar {
    margin-bottom: 1.25rem;
}

.apl-toolbar-compact {
    margin-bottom: 0.75rem;
}

.apl-search-wrap {
    position: relative;
    margin-bottom: 0.75rem;
}

.apl-search-icon {
    position: absolute;
    left: 14px;
    top: 50%;
    transform: translateY(-50%);
    color: var(--apl-muted);
    pointer-events: none;
}

.apl-search-input {
    width: 100%;
    padding: 0.75rem 1rem 0.75rem 2.5rem;
    border: 1px solid rgba(0, 0, 0, 0.08);
    border-radius: 12px;
    font-size: 1rem;
    font-family: inherit;
    background: var(--apl-surface);
    box-shadow: var(--apl-shadow);
}

.apl-search-input:focus {
    outline: 2px solid var(--apl-teal);
    outline-offset: 1px;
}

.apl-filter-chips {
    display: flex;
    flex-wrap: wrap;
    gap: 0.5rem;
}

.apl-chip {
    padding: 0.4rem 0.85rem;
    border-radius: 999px;
    border: 1px solid rgba(0, 0, 0, 0.1);
    background: var(--apl-surface);
    font-size: 0.85rem;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.15s ease;
}

.apl-chip.is-active,
.apl-chip:hover {
    background: var(--apl-teal);
    border-color: var(--apl-teal);
    color: #fff;
}

/* Game cards (dashboard) */
.apl-game-list {
    display: flex;
    flex-direction: column;
    gap: 0.85rem;
}

.apl-game-card {
    display: flex;
    align-items: center;
    gap: 0.85rem;
    padding: 0.9rem 1rem;
    background: var(--apl-surface);
    border-radius: var(--apl-radius);
    box-shadow: var(--apl-shadow);
    text-decoration: none;
    color: inherit;
    position: relative;
    overflow: hidden;
    transition: transform 0.2s ease, box-shadow 0.2s ease;
    animation: aplFadeUp 0.4s ease backwards;
}

.apl-game-card::before {
    content: "";
    position: absolute;
    left: 0;
    top: 0;
    bottom: 0;
    width: 5px;
    background: var(--apl-card-accent, var(--apl-teal));
}

.apl-game-card:hover,
.apl-game-card:focus {
    transform: translateY(-2px);
    box-shadow: var(--apl-shadow-hover);
}

.apl-game-icon {
    flex-shrink: 0;
    width: 52px;
    height: 52px;
    border-radius: 14px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1.35rem;
    background: var(--apl-icon-bg, rgba(13, 148, 136, 0.12));
    color: var(--apl-card-accent, var(--apl-teal));
}

.apl-game-body {
    flex: 1;
    min-width: 0;
}

.apl-game-name {
    margin: 0 0 0.2rem;
    font-family: var(--apl-font-display);
    font-size: 1.05rem;
    font-weight: 700;
}

.apl-game-meta {
    margin: 0;
    font-size: 0.8rem;
    color: var(--apl-muted);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.apl-game-badge {
    flex-shrink: 0;
    width: 48px;
    height: 48px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-family: var(--apl-font-display);
    font-weight: 800;
    font-size: 1.1rem;
    color: #fff;
    background: var(--apl-card-accent, var(--apl-teal));
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.15);
}

/* Theme accents */
.apl-theme-red { --apl-card-accent: var(--apl-theme-red); --apl-icon-bg: rgba(229, 57, 53, 0.12); }
.apl-theme-sky { --apl-card-accent: var(--apl-theme-sky); --apl-icon-bg: rgba(41, 182, 246, 0.12); }
.apl-theme-green { --apl-card-accent: var(--apl-theme-green); --apl-icon-bg: rgba(67, 160, 71, 0.12); }
.apl-theme-purple { --apl-card-accent: var(--apl-theme-purple); --apl-icon-bg: rgba(142, 36, 170, 0.12); }
.apl-theme-orange { --apl-card-accent: var(--apl-theme-orange); --apl-icon-bg: rgba(251, 140, 0, 0.12); }
.apl-theme-teal { --apl-card-accent: var(--apl-theme-teal); --apl-icon-bg: rgba(0, 137, 123, 0.12); }
.apl-theme-pink { --apl-card-accent: var(--apl-theme-pink); --apl-icon-bg: rgba(236, 64, 122, 0.12); }
.apl-theme-navy { --apl-card-accent: var(--apl-theme-navy); --apl-icon-bg: rgba(57, 73, 171, 0.12); }

/* Game banner (detail page) */
.apl-game-banner {
    display: flex;
    align-items: center;
    gap: 1rem;
    padding: 1rem 1.1rem;
    margin-bottom: 1rem;
    border-radius: var(--apl-radius);
    background: linear-gradient(135deg, rgba(41, 182, 246, 0.15), rgba(13, 148, 136, 0.08));
    box-shadow: var(--apl-shadow);
}

.apl-game-banner .apl-game-icon {
    width: 56px;
    height: 56px;
    font-size: 1.5rem;
}

.apl-game-banner h2 {
    margin: 0 0 0.2rem;
    font-family: var(--apl-font-display);
    font-size: 1.2rem;
    font-weight: 800;
}

.apl-game-banner p {
    margin: 0;
    font-size: 0.85rem;
    color: var(--apl-muted);
}

/* Podium top 3 */
.apl-podium {
    display: grid;
    grid-template-columns: 1fr 1.15fr 1fr;
    gap: 0.5rem;
    align-items: end;
    margin-bottom: 1.25rem;
    padding-top: 0.5rem;
}

.apl-podium-card {
    display: flex;
    flex-direction: column;
    align-items: center;
    padding: 1rem 0.5rem 0.85rem;
    border-radius: var(--apl-radius);
    text-align: center;
    box-shadow: var(--apl-shadow);
    animation: aplFadeUp 0.5s ease backwards;
}

.apl-podium-card.rank-1 {
    order: 2;
    background: linear-gradient(180deg, #1976d2 0%, #1565c0 100%);
    color: #fff;
    min-height: 200px;
    padding-top: 1.5rem;
}

.apl-podium-card.rank-2 {
    order: 1;
    background: linear-gradient(180deg, #e3f2fd 0%, #bbdefb 100%);
    color: #1565c0;
}

.apl-podium-card.rank-3 {
    order: 3;
    background: linear-gradient(180deg, #fff3e0 0%, #ffe0b2 100%);
    color: #e65100;
}

.apl-podium-crown {
    font-size: 1.1rem;
    margin-bottom: 0.35rem;
    opacity: 0.9;
}

.apl-podium-card.rank-1 .apl-podium-crown { color: #ffd54f; }

.apl-podium-avatar {
    width: 64px;
    height: 64px;
    border-radius: 50%;
    object-fit: cover;
    border: 3px solid rgba(255, 255, 255, 0.9);
    background: rgba(255, 255, 255, 0.3);
    margin-bottom: 0.5rem;
}

.apl-podium-card.rank-2 .apl-podium-avatar,
.apl-podium-card.rank-3 .apl-podium-avatar {
    width: 56px;
    height: 56px;
    border-color: rgba(255, 255, 255, 0.8);
}

.apl-podium-rank-badge {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 26px;
    height: 26px;
    border-radius: 50%;
    font-weight: 800;
    font-size: 0.8rem;
    margin-bottom: 0.35rem;
    background: rgba(255, 255, 255, 0.35);
}

.apl-podium-name {
    margin: 0 0 0.35rem;
    font-weight: 700;
    font-size: 0.85rem;
    line-height: 1.2;
    max-width: 100%;
    overflow: hidden;
    text-overflow: ellipsis;
}

.apl-podium-points {
    margin: 0;
    font-family: var(--apl-font-display);
    font-weight: 800;
    font-size: 1.35rem;
}

.apl-podium-card.rank-2 .apl-podium-points,
.apl-podium-card.rank-3 .apl-podium-points {
    font-size: 1.1rem;
}

/* Rank list */
.apl-rank-list {
    display: flex;
    flex-direction: column;
    gap: 0.65rem;
}

.apl-rank-row {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    padding: 0.75rem 1rem;
    background: var(--apl-surface);
    border-radius: 14px;
    box-shadow: var(--apl-shadow);
    animation: aplFadeUp 0.35s ease backwards;
}

.apl-rank-row.is-highlight {
    border: 2px solid var(--apl-teal);
    box-shadow: 0 0 0 3px rgba(13, 148, 136, 0.15);
}

.apl-rank-num {
    flex-shrink: 0;
    width: 28px;
    font-family: var(--apl-font-display);
    font-weight: 800;
    font-size: 1rem;
    color: var(--apl-rank-color, var(--apl-muted));
}

.apl-rank-avatar,
.apl-avatar-initials {
    width: 44px;
    height: 44px;
    border-radius: 50%;
    object-fit: cover;
    background: #e8eef2;
    flex-shrink: 0;
}

.apl-avatar-initials {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    font-weight: 700;
    font-size: 0.85rem;
    color: var(--apl-teal-dark);
}

.apl-rank-info {
    flex: 1;
    min-width: 0;
}

.apl-rank-name {
    margin: 0;
    font-weight: 700;
    font-size: 0.95rem;
}

.apl-rank-motivation {
    margin: 0.15rem 0 0;
    font-size: 0.75rem;
    color: var(--apl-teal-dark);
    font-weight: 600;
}

.apl-rank-score {
    display: flex;
    align-items: center;
    gap: 0.25rem;
    font-family: var(--apl-font-display);
    font-weight: 800;
    font-size: 1rem;
    color: var(--apl-rank-color, var(--apl-text));
}

.apl-rank-score i {
    font-size: 0.85rem;
    opacity: 0.85;
}

/* Global search dropdown */
.apl-global-search {
    margin-top: 0.5rem;
    background: var(--apl-surface);
    border-radius: 12px;
    box-shadow: var(--apl-shadow);
    overflow: hidden;
}

.apl-search-hit {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    padding: 0.65rem 1rem;
    text-decoration: none;
    color: inherit;
    border-bottom: 1px solid rgba(0, 0, 0, 0.05);
}

.apl-search-hit:hover {
    background: rgba(13, 148, 136, 0.06);
}

.apl-search-hit:last-child {
    border-bottom: none;
}

/* Misc */
.apl-loading {
    text-align: center;
    padding: 2rem;
    color: var(--apl-muted);
}

.apl-spinner {
    display: inline-block;
    width: 22px;
    height: 22px;
    border: 3px solid rgba(13, 148, 136, 0.2);
    border-top-color: var(--apl-teal);
    border-radius: 50%;
    animation: aplSpin 0.7s linear infinite;
    vertical-align: middle;
    margin-right: 0.5rem;
}

.apl-alert-error {
    padding: 0.85rem 1rem;
    border-radius: 10px;
    background: #ffebee;
    color: #c62828;
    margin-bottom: 1rem;
}

.apl-empty {
    text-align: center;
    padding: 2rem 1rem;
    color: var(--apl-muted);
}

.apl-footer {
    text-align: center;
    padding: 1rem;
    font-size: 0.75rem;
    color: var(--apl-muted);
}

.apl-load-more-wrap {
    text-align: center;
    margin-top: 1rem;
}

.apl-btn {
    padding: 0.65rem 1.25rem;
    border-radius: 10px;
    font-weight: 600;
    font-family: inherit;
    cursor: pointer;
    border: none;
}

.apl-btn-outline {
    background: var(--apl-surface);
    border: 2px solid var(--apl-teal);
    color: var(--apl-teal-dark);
}

.apl-btn-outline:hover {
    background: var(--apl-teal);
    color: #fff;
}

@keyframes aplSpin {
    to { transform: rotate(360deg); }
}

@keyframes aplFadeUp {
    from {
        opacity: 0;
        transform: translateY(10px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

/* Tablet+ */
@media (min-width: 600px) {
    .apl-main {
        padding: 1.5rem 1.5rem 2.5rem;
    }

    .apl-hero-title {
        font-size: 1.75rem;
    }

    .apl-podium {
        gap: 0.75rem;
        max-width: 520px;
        margin-left: auto;
        margin-right: auto;
    }

    .apl-game-list {
        display: grid;
        grid-template-columns: 1fr;
        gap: 1rem;
    }
}

@media (min-width: 900px) {
    .apl-main {
        max-width: 960px;
    }

    .apl-header-inner {
        max-width: 960px;
    }

    .apl-game-list {
        grid-template-columns: repeat(2, 1fr);
    }
}

@media (max-width: 380px) {
    .apl-podium-name {
        font-size: 0.75rem;
    }

    .apl-podium-points {
        font-size: 1.1rem;
    }
}
