{#if error}
{error}
{/if} {#each openChallenges as ch} {@const chPlays = JSON.parse(ch.plays || '[]')} {@const chObstacleIds = JSON.parse(ch.obstacle_ids || '[]')}

{#if ch.challenge_type === 'pvp'} ⚔️ Duel: {playerName(ch.challenger_player_id)} vs {playerName(ch.target_player_id)} {:else} ⚔️ The Deep challenges {playerName(ch.target_player_id)}! {/if}

{#if state.player.role === 'deep' && ch.challenge_type === 'deep'}
{/if}
{#if ch.stakes_success}

✅ On success: {ch.stakes_success}

{/if} {#if ch.stakes_failure}

❌ On failure: {ch.stakes_failure}

{/if} {#if ch.stakes && !ch.stakes_success && !ch.stakes_failure}

Stakes: {ch.stakes}

{/if} {#if ch.challenge_type === 'pvp'}

Temporary Obstacle: {getCardDisplay(ch.temp_card)} — {playerName(ch.acting_player_id)} must answer it!

{:else}

Applied Obstacles: {chObstacleIds.map(oid => state.obstacles.find(o => o.id === oid)?.title || '(discarded)').join(', ') || 'None left'} — attempted by {playerName(ch.acting_player_id)}{ch.acting_player_id !== ch.target_player_id ? ` (took it over via ${ch.tax_type === 'gat' ? 'Gat' : 'Name'} Tax)` : ''}. Other Pi-Rats may assist (assistants don't draw back).

{/if} {#if chPlays.length > 0}

Plays: {chPlays.map(p => `${p.player_name}: ${getCardDisplay(p.card)} ${p.success ? '✔' : '✘'}`).join(' · ')}

{/if} {#if ch.tax_state === 'requested'} {#if myTaxRequest && myTaxRequest.id === ch.id}

{playerName(ch.target_player_id)} calls a {ch.tax_type === 'gat' ? 'Gat' : 'Name'} Tax on you: take this Challenge for them!

Accept: you get one random card from their hand and attempt the Challenge. Refuse: you hand over your {ch.tax_type === 'gat' ? 'Gat' : 'Name'} — they keep it if they succeed!

{:else}

⏳ Waiting for {playerName(ch.tax_target_id)} to answer the {ch.tax_type === 'gat' ? 'Gat' : 'Name'} Tax...

{/if} {/if} {#if ch.challenge_type === 'deep' && ch.acting_player_id === state.player.id && !ch.tax_state && !state.player.tax_banned && taxType(state.player) && eligibleTaxTargets().length > 0}
No {taxType(state.player)}? Make it someone else's problem:
{/if} {#if myPvpDefense && myPvpDefense.id === ch.id}

Defend yourself! Pick a card:

{#each hand.filter(c => !isJoker(c)) as card} {/each}
{/if}
{/each}