/* ============================================================================
   Physics Games — Hub + Player Stylesheet
   RTL, mobile-first
   ============================================================================ */

/* ─── Hub Hero ─── */
.games-hero {
    background: linear-gradient(135deg, #7c3aed 0%, #ec4899 50%, #f97316 100%);
    color: #fff;
    padding: 50px 0 38px;
    margin-bottom: 28px;
    position: relative;
    overflow: hidden;
}
.games-hero::before {
    content: '';
    position: absolute;
    top: -50%;
    left: -10%;
    width: 500px;
    height: 500px;
    background: radial-gradient(circle, rgba(255,255,255,0.12) 0%, transparent 70%);
    pointer-events: none;
}
.games-hero h1 {
    font-size: clamp(1.4rem, 4vw, 2.1rem);
    margin: 0 0 10px;
    display: flex;
    align-items: center;
    gap: 14px;
    color: #fff;
    font-weight: 800;
}
.games-hero h1 .ico {
    background: rgba(255,255,255,0.2);
    backdrop-filter: blur(10px);
    width: 56px; height: 56px;
    border-radius: 14px;
    display: inline-flex; align-items: center; justify-content: center;
    font-size: 1.7rem;
    border: 1px solid rgba(255,255,255,0.18);
}
.games-hero p { opacity: 0.95; font-size: 1rem; margin: 0 0 18px; max-width: 640px; }
.games-hero .stats { display: flex; gap: 14px; flex-wrap: wrap; }
.games-hero .stat {
    background: rgba(255,255,255,0.18);
    backdrop-filter: blur(8px);
    padding: 10px 18px;
    border-radius: 12px;
    border: 1px solid rgba(255,255,255,0.2);
    text-align: center;
    min-width: 110px;
}
.games-hero .stat strong { display: block; font-size: 1.4rem; line-height: 1; }
.games-hero .stat span { font-size: 0.82rem; opacity: 0.88; }

/* ─── Filter Chips ─── */
.games-filters {
    background: #fff;
    border-radius: 16px;
    padding: 18px 22px;
    box-shadow: 0 4px 20px rgba(0,0,0,0.04);
    margin-bottom: 24px;
}
.games-filters .row {
    display: flex; gap: 8px; flex-wrap: wrap;
    align-items: center; margin-bottom: 10px;
}
.games-filters .row:last-child { margin-bottom: 0; }
.games-filters .label {
    font-weight: 700; color: #6b7280; font-size: 0.85rem;
    min-width: 72px;
}
.games-filters .chip {
    background: #f3f4f6;
    border: 1px solid #e5e7eb;
    padding: 7px 16px;
    border-radius: 999px;
    font-size: 0.85rem;
    color: #374151;
    cursor: pointer;
    text-decoration: none;
    transition: all 0.18s;
    font-family: inherit;
    font-weight: 600;
}
.games-filters .chip:hover { background: #f3e8ff; color: #7c3aed; border-color: #c4b5fd; }
.games-filters .chip.active {
    background: linear-gradient(135deg, #7c3aed, #6d28d9);
    color: #fff; border-color: #6d28d9;
}

/* ─── Games Grid ─── */
.games-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(260px, 1fr));
    gap: 16px;
}
@media (max-width: 480px) {
    .games-grid { grid-template-columns: 1fr; }
}

/* ─── Game Card ─── */
.game-card {
    background: #fff;
    border-radius: 16px;
    border: 1px solid #f0f0f5;
    overflow: hidden;
    transition: all 0.25s;
    text-decoration: none;
    color: inherit;
    display: flex;
    flex-direction: column;
    position: relative;
}
.game-card:hover {
    transform: translateY(-4px);
    box-shadow: 0 12px 28px rgba(124, 58, 237, 0.15);
    border-color: #c4b5fd;
}
.game-card .cover {
    position: relative;
    aspect-ratio: 16/9;
    background: linear-gradient(135deg, #ede9fe, #fce7f3);
    display: flex; align-items: center; justify-content: center;
    font-size: 3.4rem;
    color: #7c3aed;
    overflow: hidden;
}
.game-card .cover img { width: 100%; height: 100%; object-fit: cover; }

.game-card .badges {
    position: absolute;
    top: 10px;
    right: 10px;
    display: flex;
    gap: 6px;
    flex-wrap: wrap;
    z-index: 2;
}
.game-card .badge {
    background: #fff;
    color: #6d28d9;
    padding: 4px 10px;
    border-radius: 999px;
    font-size: 0.72rem;
    font-weight: 800;
    box-shadow: 0 2px 8px rgba(0,0,0,0.1);
    display: inline-flex; align-items: center; gap: 4px;
}
.game-card .badge.free { background: #10b981; color: #fff; }
.game-card .badge.premium { background: linear-gradient(135deg, #f59e0b, #d97706); color: #fff; }

.game-card .body { padding: 16px 18px; flex: 1; display: flex; flex-direction: column; }
.game-card h3 {
    font-size: 1.02rem;
    margin: 0 0 6px;
    line-height: 1.4;
    color: #1f2937;
    font-weight: 800;
}
.game-card .subtitle {
    color: #6b7280;
    font-size: 0.82rem;
    line-height: 1.5;
    margin: 0 0 12px;
    flex: 1;
}
.game-card .meta {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding-top: 10px;
    border-top: 1px dashed #f0f0f5;
}
.game-card .meta .difficulty {
    display: inline-flex;
    gap: 2px;
}
.game-card .meta .difficulty .star { color: #fbbf24; }
.game-card .meta .difficulty .star.empty { color: #e5e7eb; }
.game-card .play-icon {
    color: #7c3aed;
    font-weight: 700;
    font-size: 0.85rem;
}

/* ─── Lesson/Chapter Strip (embedded) ─── */
.lesson-games-strip {
    margin: 28px 0;
    padding: 20px 22px;
    background: linear-gradient(135deg, #faf5ff 0%, #fff7ed 100%);
    border: 1px solid #ddd6fe;
    border-radius: 16px;
}
.lesson-games-strip .strip-head {
    display: flex; align-items: center; justify-content: space-between;
    margin-bottom: 14px; flex-wrap: wrap; gap: 10px;
}
.lesson-games-strip .strip-head h3 {
    font-size: 1.1rem; margin: 0; color: #6d28d9; font-weight: 800;
}
.lesson-games-strip .view-all {
    color: #7c3aed; text-decoration: none; font-weight: 700; font-size: 0.85rem;
}
.lesson-games-strip .strip-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(200px, 1fr));
    gap: 12px;
}

/* ─── Game Player ─── */
.game-player {
    background: #fff;
    border-radius: 18px;
    overflow: hidden;
    box-shadow: 0 4px 28px rgba(0,0,0,0.06);
    margin-bottom: 24px;
}
.game-player .header {
    background: linear-gradient(135deg, #1e3a8a, #7c3aed);
    color: #fff;
    padding: 16px 22px;
    display: flex; align-items: center; gap: 14px;
}
.game-player .header h1 { margin: 0; font-size: 1.2rem; color: #fff; font-weight: 800; }
.game-player .header .meta { font-size: 0.82rem; opacity: 0.92; }
.game-player .header .actions {
    margin-inline-start: auto;
    display: flex; gap: 8px;
}
.game-player .btn-fullscreen,
.game-player .btn-restart {
    background: rgba(255,255,255,0.15);
    border: 1px solid rgba(255,255,255,0.25);
    color: #fff;
    padding: 8px 14px;
    border-radius: 10px;
    cursor: pointer;
    font-family: inherit;
    font-size: 0.82rem;
    font-weight: 700;
}
.game-player .btn-fullscreen:hover,
.game-player .btn-restart:hover {
    background: rgba(255,255,255,0.25);
}

.game-stage {
    position: relative;
    width: 100%;
    background: #0b1020;
    aspect-ratio: 16/10;
    max-height: 70vh;
    overflow: hidden;
}
.game-stage iframe {
    width: 100%; height: 100%;
    border: 0;
    display: block;
}
.game-stage canvas {
    width: 100%; height: 100%;
    display: block;
    touch-action: manipulation;
}

/* ─── Player Footer (score + leaderboard prompt) ─── */
.game-footer {
    padding: 18px 22px;
    display: flex;
    flex-wrap: wrap;
    gap: 16px;
    align-items: center;
    justify-content: space-between;
    border-top: 1px solid #f0f0f5;
    background: #fafafa;
}
.game-footer .score-info { font-size: 0.9rem; color: #374151; }
.game-footer .score-info strong { color: #7c3aed; font-size: 1.05rem; }
.game-footer .quota-info {
    background: #fef3c7;
    color: #92400e;
    padding: 6px 12px;
    border-radius: 10px;
    font-size: 0.82rem;
    font-weight: 700;
}

/* ─── Leaderboard ─── */
.leaderboard-card {
    background: #fff;
    border-radius: 16px;
    padding: 20px;
    border: 1px solid #f0f0f5;
    margin-bottom: 20px;
}
.leaderboard-card .head {
    display: flex; align-items: center; justify-content: space-between;
    margin-bottom: 14px;
}
.leaderboard-card h3 {
    margin: 0; font-size: 1rem; color: #1f2937; font-weight: 800;
    display: flex; align-items: center; gap: 8px;
}
.leaderboard-card .scope-tabs { display: flex; gap: 4px; background: #f3f4f6; padding: 3px; border-radius: 10px; }
.leaderboard-card .scope-tab {
    background: transparent; border: 0; padding: 6px 12px; border-radius: 8px;
    cursor: pointer; font-family: inherit; font-size: 0.78rem; font-weight: 700; color: #6b7280;
}
.leaderboard-card .scope-tab.active { background: #fff; color: #7c3aed; box-shadow: 0 2px 6px rgba(0,0,0,0.05); }

.leaderboard-list { list-style: none; padding: 0; margin: 0; }
.leaderboard-list li {
    padding: 10px 0;
    border-bottom: 1px dashed #f0f0f5;
    display: flex; align-items: center; gap: 12px;
}
.leaderboard-list li:last-child { border-bottom: 0; }
.leaderboard-list .rank {
    width: 30px; height: 30px;
    background: #f3e8ff; color: #7c3aed;
    border-radius: 50%;
    display: inline-flex; align-items: center; justify-content: center;
    font-weight: 800; font-size: 0.85rem; flex-shrink: 0;
}
.leaderboard-list .rank.gold   { background: linear-gradient(135deg, #fbbf24, #f59e0b); color: #fff; }
.leaderboard-list .rank.silver { background: linear-gradient(135deg, #94a3b8, #64748b); color: #fff; }
.leaderboard-list .rank.bronze { background: linear-gradient(135deg, #d97706, #b45309); color: #fff; }
.leaderboard-list .name { flex: 1; font-weight: 700; color: #374151; font-size: 0.9rem; }
.leaderboard-list .score {
    background: #ecfdf5; color: #065f46; padding: 4px 10px; border-radius: 8px;
    font-weight: 800; font-size: 0.82rem;
}

/* ─── Empty & Loading States ─── */
.games-empty, .leaderboard-empty {
    text-align: center;
    padding: 40px 20px;
    color: #94a3b8;
}
.games-empty i, .leaderboard-empty i { font-size: 2.5rem; margin-bottom: 12px; color: #d1d5db; }

.game-loading {
    display: flex; align-items: center; justify-content: center;
    padding: 60px 20px; color: #6b7280;
    flex-direction: column; gap: 12px;
}

/* ─── Mobile Tweaks ─── */
@media (max-width: 600px) {
    .games-hero { padding: 32px 0 26px; }
    .game-player .header { flex-wrap: wrap; }
    .game-player .header .actions { width: 100%; }
    .game-stage { aspect-ratio: 9/16; max-height: 80vh; }
    .games-filters { padding: 14px 16px; }
    .games-filters .chip { padding: 6px 12px; font-size: 0.78rem; }
}
