@props(['game' => []])

@php
$name = $game['name'] ?? 'Game';
$cover = $game['cover'] ?? null;
$coverUrl = $cover
    ? (str_starts_with($cover, 'http') || str_starts_with($cover, '/') ? (str_starts_with($cover, 'http') ? $cover : asset(ltrim($cover, '/'))) : asset(ltrim($cover, '/')))
    : asset('assets/images/generated/games/game-valorstrike.webp');
$url = $game['url'] ?? '#';
$count = (int) ($game['players_count'] ?? 0);
@endphp

<a href="{{ $url }}" class="game-card" role="listitem">
    <img class="game-card__img" src="{{ $coverUrl }}" alt="{{ $name }}" width="160" height="228" loading="lazy" onerror="this.src='{{ asset('assets/images/generated/games/game-valorstrike.webp') }}'">
    <div class="game-card__overlay" aria-hidden="true"></div>
    <div class="game-card__sweep" aria-hidden="true"></div>
    <div class="game-card__body">
        <h3 class="game-card__name">{{ $name }}</h3>
        <div class="game-card__meta">{{ number_format($count) }} players</div>
    </div>
</a>
