3024 lines
83 KiB
Vue
3024 lines
83 KiB
Vue
<script setup lang="ts">
|
||
import { deckValidation, loadDecks, type SavedDeck } from '~/utils/decks'
|
||
import { loadPlaymatChoice, savePlaymatChoice, type PlaymatSelection } from '~/utils/playmat'
|
||
import { cardBackVars } from '~/utils/cardBack'
|
||
import { diffGameState, type GameAnimations } from '~/utils/gameAnimations'
|
||
|
||
interface AbilityView {
|
||
index: number
|
||
kind: string
|
||
text?: string
|
||
}
|
||
|
||
interface CardView {
|
||
id: string
|
||
oracleId: string
|
||
name: string
|
||
typeLine: string
|
||
manaCost?: string
|
||
manaValue?: number
|
||
colors: string[]
|
||
colorIdentity: string[]
|
||
oracleText?: string
|
||
power?: number
|
||
toughness?: number
|
||
tapped: boolean
|
||
damage: number
|
||
counters: Record<string, number>
|
||
isToken: boolean
|
||
isCommander: boolean
|
||
zone: string
|
||
controller: string
|
||
owner: string
|
||
position?: { x: number; y: number }
|
||
attacking?: string
|
||
blockedBy: string[]
|
||
blocking?: string
|
||
chosenType?: string
|
||
abilities: AbilityView[]
|
||
playable?: boolean
|
||
}
|
||
|
||
interface PlayerView {
|
||
id: string
|
||
name: string
|
||
commander?: { oracleId: string; name: string }
|
||
playmat?: PlaymatView
|
||
life?: number
|
||
lost?: boolean
|
||
handCount?: number
|
||
libraryCount?: number
|
||
battlefield?: CardView[]
|
||
graveyard?: CardView[]
|
||
exile?: CardView[]
|
||
command?: CardView[]
|
||
commanderId?: string
|
||
commanderDamage?: { commanderId: string; commanderName: string; amount: number }[]
|
||
commanderCasts?: Record<string, number>
|
||
landPlayedThisTurn?: boolean
|
||
}
|
||
|
||
interface MatchView {
|
||
id: string
|
||
status: 'lobby' | 'active' | 'finished'
|
||
version: number
|
||
viewerId: string
|
||
hostId: string
|
||
maxPlayers: number
|
||
players: PlayerView[]
|
||
game?: {
|
||
turn: number
|
||
activePlayer: string
|
||
phase: string
|
||
step: string
|
||
priority: string
|
||
status: string
|
||
winner?: string
|
||
stack: { id: string; kind: string; label: string; controller: string }[]
|
||
log: string[]
|
||
hand: CardView[]
|
||
manaPool: Record<string, number>
|
||
pendingChoice?: {
|
||
player: string
|
||
what: string
|
||
sourceId: string
|
||
sourceName: string
|
||
options: string[]
|
||
}
|
||
pendingSearch?: {
|
||
player: string
|
||
remaining: number
|
||
destination: string
|
||
cards: CardView[]
|
||
library?: CardView[]
|
||
}
|
||
}
|
||
}
|
||
|
||
interface MatchSummary {
|
||
id: string
|
||
hostName: string
|
||
status: 'lobby' | 'active' | 'finished'
|
||
playerCount: number
|
||
maxPlayers: number
|
||
players: string[]
|
||
}
|
||
|
||
interface FloatingLabel {
|
||
id: number
|
||
targetId: string
|
||
text: string
|
||
tone: 'damage' | 'heal'
|
||
}
|
||
|
||
interface ManaBurst {
|
||
id: number
|
||
color: string
|
||
amount: number
|
||
}
|
||
|
||
type PlaymatView = { kind: 'card'; oracleId: string } | { kind: 'upload'; id: string }
|
||
|
||
definePageMeta({ middleware: 'auth' })
|
||
|
||
const { public: { apiBase } } = useRuntimeConfig()
|
||
const route = useRoute()
|
||
const gameId = computed(() => String(route.params.id))
|
||
const SESSION_PREFIX = 'commander-session-'
|
||
|
||
const state = ref<MatchView | null>(null)
|
||
const token = ref('')
|
||
const error = ref('')
|
||
const notice = ref('')
|
||
const busy = ref(false)
|
||
const connection = ref<'connecting' | 'live' | 'reconnecting' | 'offline'>('connecting')
|
||
const castCardId = ref('')
|
||
const selectedTarget = ref('')
|
||
const castX = ref(0)
|
||
const castOverload = ref(false)
|
||
const selectedAttackers = ref<string[]>([])
|
||
const attackTargets = reactive<Record<string, string>>({})
|
||
const attackDropId = ref('')
|
||
const blockSelection = reactive<Record<string, string>>({})
|
||
const selectedCardId = ref('')
|
||
const menu = ref<{ cardId: string; x: number; y: number } | null>(null)
|
||
const menuEl = ref<HTMLElement | null>(null)
|
||
let menuTrigger: HTMLElement | null = null
|
||
const browsingZone = ref<{ playerId: string; zone: 'graveyard' | 'exile' } | null>(null)
|
||
const playmatOpen = ref(false)
|
||
const playmatBusy = ref(false)
|
||
let events: EventSource | undefined
|
||
|
||
const cardEnterAnimations = reactive<Record<string, number>>({})
|
||
const cardDamageAnimations = reactive<Record<string, number>>({})
|
||
const cardAttackAnimations = reactive<Record<string, number>>({})
|
||
const playerHitAnimations = reactive<Record<string, number>>({})
|
||
const playerHealAnimations = reactive<Record<string, number>>({})
|
||
const floatingLabels = ref<FloatingLabel[]>([])
|
||
const manaBursts = ref<ManaBurst[]>([])
|
||
const animationTimers = new Set<ReturnType<typeof setTimeout>>()
|
||
let previousState: MatchView | null = null
|
||
let animationCounter = 0
|
||
|
||
const tableEl = ref<HTMLElement | null>(null)
|
||
const sidebarEl = ref<HTMLElement | null>(null)
|
||
const panning = ref(false)
|
||
const showLog = ref(true)
|
||
const menuOpen = ref(false)
|
||
const view = reactive({ x: 0, y: 0, scale: 1 })
|
||
const MIN_ZOOM = 0.5
|
||
const MAX_ZOOM = 2.5
|
||
const PILE_SIZE = 6
|
||
let panOrigin = { x: 0, y: 0, viewX: 0, viewY: 0 }
|
||
const dragPreview = ref<{ cardId: string; x: number; y: number } | null>(null)
|
||
let cardDrag: {
|
||
cardId: string
|
||
pointerId: number
|
||
board: HTMLElement
|
||
startX: number
|
||
startY: number
|
||
grabX: number
|
||
grabY: number
|
||
halfWidth: number
|
||
halfHeight: number
|
||
moved: boolean
|
||
} | null = null
|
||
let suppressCardClick = ''
|
||
|
||
const canvasStyle = computed(() => ({
|
||
transform: `translate(${view.x}px, ${view.y}px) scale(${view.scale})`,
|
||
}))
|
||
|
||
const decks = ref<SavedDeck[]>([])
|
||
const joinName = ref('')
|
||
const deckId = ref('')
|
||
const joining = ref(false)
|
||
const joinError = ref('')
|
||
const summary = ref<MatchSummary | null>(null)
|
||
|
||
const game = computed(() => state.value?.game)
|
||
const me = computed(() => state.value?.players.find(player => player.id === state.value?.viewerId))
|
||
const myPlaymat = computed(() => {
|
||
const playmat = me.value?.playmat
|
||
if (!playmat) return null
|
||
return playmat.kind === 'card'
|
||
? { kind: 'card' as const, oracleId: playmat.oracleId }
|
||
: { kind: 'upload' as const, url: `${apiBase}/playmats/${encodeURIComponent(playmat.id)}` }
|
||
})
|
||
const viewerId = computed(() => state.value?.viewerId ?? '')
|
||
const isHost = computed(() => state.value?.hostId === viewerId.value)
|
||
const emptySeats = computed(() => state.value ? state.value.maxPlayers - state.value.players.length : 0)
|
||
const opponents = computed(() => (state.value?.players ?? []).filter(player => player.id !== viewerId.value && !player.lost))
|
||
const canAct = computed(() => Boolean(state.value?.status === 'active'
|
||
&& game.value
|
||
&& !game.value.pendingSearch
|
||
&& !game.value.pendingChoice
|
||
&& game.value.priority === viewerId.value))
|
||
const isActive = computed(() => game.value?.activePlayer === viewerId.value)
|
||
const priorityName = computed(() => playerName(game.value?.priority))
|
||
const phaseLabel = computed(() => game.value
|
||
? `${game.value.phase.replaceAll('_', ' ')} · ${game.value.step.replaceAll('_', ' ')}`
|
||
: '')
|
||
const winnerName = computed(() => playerName(game.value?.winner))
|
||
const myBattlefield = computed(() => me.value?.battlefield ?? [])
|
||
const myUntappedCreatures = computed(() => myBattlefield.value.filter(card => /creature/i.test(card.typeLine) && !card.tapped))
|
||
const menuCard = computed(() => myBattlefield.value.find(card => card.id === menu.value?.cardId))
|
||
const incomingAttackers = computed(() => (state.value?.players ?? []).flatMap(player => (player.battlefield ?? [])
|
||
.filter(card => card.attacking === viewerId.value)
|
||
.map(card => ({ card, player }))))
|
||
const attackWindow = computed(() => Boolean(state.value?.status === 'active'
|
||
&& game.value
|
||
&& isActive.value
|
||
&& canAct.value
|
||
&& !game.value.stack.length
|
||
&& (game.value.phase === 'precombat_main'
|
||
|| (game.value.phase === 'combat' && game.value.step === 'declare_attackers'))))
|
||
const draggingAttackerId = computed(() => {
|
||
const cardId = dragPreview.value?.cardId
|
||
if (!attackWindow.value || !cardId) return ''
|
||
return myUntappedCreatures.value.some(card => card.id === cardId) ? cardId : ''
|
||
})
|
||
const blockWindow = computed(() => Boolean(state.value?.status === 'active'
|
||
&& game.value
|
||
&& !game.value.pendingSearch
|
||
&& !game.value.pendingChoice
|
||
&& game.value.step === 'declare_blockers'
|
||
&& game.value.priority === viewerId.value))
|
||
const castCard = computed(() => {
|
||
if (!state.value || !castCardId.value) return undefined
|
||
return state.value.game?.hand.find(card => card.id === castCardId.value)
|
||
?? me.value?.command?.find(card => card.id === castCardId.value)
|
||
})
|
||
const overloadAbility = computed(() => castCard.value?.abilities.find(ability => ability.kind === 'overload'))
|
||
const pendingSearch = computed(() => game.value?.pendingSearch)
|
||
const searchFilter = ref('')
|
||
const searchInput = ref<HTMLInputElement | null>(null)
|
||
const searchLegalIds = computed(() => new Set(pendingSearch.value?.cards.map(card => card.id) ?? []))
|
||
const searchLibrary = computed(() => pendingSearch.value?.library ?? pendingSearch.value?.cards ?? [])
|
||
const filteredSearchLibrary = computed(() => {
|
||
const query = searchFilter.value.trim().toLowerCase()
|
||
return query
|
||
? searchLibrary.value.filter(card => card.name.toLowerCase().includes(query))
|
||
: searchLibrary.value
|
||
})
|
||
const pendingChoice = computed(() => game.value?.pendingChoice)
|
||
const choiceFilter = ref('')
|
||
const choiceInput = ref<HTMLInputElement | null>(null)
|
||
const filteredChoiceOptions = computed(() => {
|
||
const query = choiceFilter.value.trim().toLowerCase()
|
||
return query
|
||
? (pendingChoice.value?.options ?? []).filter(option => option.toLowerCase().includes(query))
|
||
: (pendingChoice.value?.options ?? [])
|
||
})
|
||
const browseView = computed(() => {
|
||
const zone = browsingZone.value
|
||
const player = state.value?.players.find(entry => entry.id === zone?.playerId)
|
||
if (!zone || !player) return null
|
||
return {
|
||
zone: zone.zone,
|
||
title: `${player.name}'s ${zone.zone}`,
|
||
cards: (zone.zone === 'graveyard' ? player.graveyard : player.exile) ?? [],
|
||
}
|
||
})
|
||
const sidebarOpen = computed(() => Boolean((pendingSearch.value && pendingSearch.value.player !== viewerId.value)
|
||
|| (pendingChoice.value && pendingChoice.value.player !== viewerId.value)
|
||
|| castCard.value
|
||
|| browseView.value
|
||
|| playmatOpen.value
|
||
|| attackWindow.value
|
||
|| blockWindow.value
|
||
|| showLog.value))
|
||
const searchDestination = computed(() => {
|
||
switch (pendingSearch.value?.destination) {
|
||
case 'hand': return 'into your hand'
|
||
case 'graveyard': return 'into your graveyard'
|
||
case 'top': return 'on top of your library'
|
||
case 'bottom': return 'on the bottom of your library'
|
||
default: return 'onto the battlefield'
|
||
}
|
||
})
|
||
const targetOptions = computed(() => {
|
||
const options = [{ value: '', label: 'Auto (first legal target)' }]
|
||
for (const player of state.value?.players ?? []) {
|
||
options.push({ value: `player:${player.id}`, label: player.name })
|
||
}
|
||
for (const player of state.value?.players ?? []) {
|
||
for (const card of player.battlefield ?? []) {
|
||
options.push({ value: `object:${card.id}`, label: `${card.name} (${player.name})` })
|
||
}
|
||
}
|
||
for (const item of game.value?.stack ?? []) {
|
||
options.push({ value: `spell:${item.id}`, label: `Spell: ${item.label}` })
|
||
}
|
||
return options
|
||
})
|
||
const connectionClass = computed(() => connection.value === 'live' ? 'good' : connection.value === 'offline' ? 'bad' : '')
|
||
|
||
function playerName(id?: string): string {
|
||
if (!id) return 'nobody'
|
||
return state.value?.players.find(player => player.id === id)?.name ?? id
|
||
}
|
||
|
||
function isLand(card: CardView): boolean {
|
||
return /\bland\b/i.test(card.typeLine)
|
||
}
|
||
|
||
function activatedAbilities(card: CardView): AbilityView[] {
|
||
return card.abilities.filter(ability => ability.kind === 'activated')
|
||
}
|
||
|
||
function toggleCard(card: CardView, event?: MouseEvent | KeyboardEvent) {
|
||
if (suppressCardClick === card.id) {
|
||
suppressCardClick = ''
|
||
return
|
||
}
|
||
const open = selectedCardId.value !== card.id
|
||
selectedCardId.value = open ? card.id : ''
|
||
if (!open || card.controller !== viewerId.value || !activatedAbilities(card).length) {
|
||
menu.value = null
|
||
return
|
||
}
|
||
const rect = (event?.currentTarget as HTMLElement | null)?.getBoundingClientRect()
|
||
const x = event instanceof MouseEvent ? event.clientX : (rect?.left ?? 0) + (rect?.width ?? 0) / 2
|
||
const y = event instanceof MouseEvent ? event.clientY : rect?.bottom ?? 0
|
||
menuTrigger = event?.currentTarget as HTMLElement ?? null
|
||
menu.value = {
|
||
cardId: card.id,
|
||
x: Math.max(8, Math.min(x, window.innerWidth - 280)),
|
||
y: Math.max(8, Math.min(y, window.innerHeight - 56 - activatedAbilities(card).length * 34)),
|
||
}
|
||
nextTick(() => menuEl.value?.querySelector('button:not(:disabled)')?.focus())
|
||
}
|
||
|
||
function closeMenu() {
|
||
const trigger = menuTrigger
|
||
menuTrigger = null
|
||
menu.value = null
|
||
selectedCardId.value = ''
|
||
trigger?.focus()
|
||
}
|
||
|
||
function onKeydown(event: KeyboardEvent) {
|
||
if (event.key === 'Escape' && menu.value) closeMenu()
|
||
}
|
||
|
||
function toggleZone(player: PlayerView, zone: 'graveyard' | 'exile') {
|
||
const current = browsingZone.value
|
||
const same = current?.playerId === player.id && current.zone === zone
|
||
browsingZone.value = same ? null : { playerId: player.id, zone }
|
||
if (!same) nextTick(() => sidebarEl.value?.scrollTo({ top: 0 }))
|
||
}
|
||
|
||
function playmatUrl(player: PlayerView): string | undefined {
|
||
const playmat = player.playmat
|
||
if (!playmat) return undefined
|
||
return playmat.kind === 'card'
|
||
? `${apiBase}/cards/${encodeURIComponent(playmat.oracleId)}/art`
|
||
: `${apiBase}/playmats/${encodeURIComponent(playmat.id)}`
|
||
}
|
||
|
||
function playmatStyle(player: PlayerView) {
|
||
const url = playmatUrl(player)
|
||
return url ? { '--playmat': `url("${url}")` } : undefined
|
||
}
|
||
|
||
const cardBackStyle = computed(() =>
|
||
cardBackVars(decks.value.find(deck => deck.id === deckId.value)?.cardBack),
|
||
)
|
||
|
||
function togglePlaymat() {
|
||
playmatOpen.value = !playmatOpen.value
|
||
if (playmatOpen.value) nextTick(() => sidebarEl.value?.scrollTo({ top: 0 }))
|
||
}
|
||
|
||
async function savePlaymat(playmat: PlaymatSelection): Promise<boolean> {
|
||
playmatBusy.value = true
|
||
error.value = ''
|
||
try {
|
||
await $fetch(`${apiBase}/games/${gameId.value}/playmat`, {
|
||
method: 'POST',
|
||
body: { token: token.value, playmat },
|
||
})
|
||
if (playmat.kind === 'card') await savePlaymatChoice(apiBase, { kind: 'card', oracleId: playmat.oracleId })
|
||
else if (playmat.kind === 'upload') await savePlaymatChoice(apiBase, { kind: 'upload', data: playmat.data })
|
||
else await savePlaymatChoice(apiBase, undefined)
|
||
playmatOpen.value = false
|
||
return true
|
||
} catch (caught) {
|
||
error.value = errorMessage(caught)
|
||
return false
|
||
} finally {
|
||
playmatBusy.value = false
|
||
}
|
||
}
|
||
|
||
function commanderTax(player: PlayerView, card: CardView): number {
|
||
return (player.commanderCasts?.[card.id] ?? 0) * 2
|
||
}
|
||
|
||
function blockersFor(attackerId: string): CardView[] {
|
||
const used = new Set(Object.entries(blockSelection)
|
||
.filter(([id, blocker]) => id !== attackerId && blocker)
|
||
.map(([, blocker]) => blocker))
|
||
return myUntappedCreatures.value.filter(card => !used.has(card.id))
|
||
}
|
||
|
||
function parseTarget(value: string): { kind: 'player' | 'object' | 'spell'; id: string } | null {
|
||
const separator = value.indexOf(':')
|
||
if (separator < 0) return null
|
||
const kind = value.slice(0, separator)
|
||
const id = value.slice(separator + 1)
|
||
if (!id || (kind !== 'player' && kind !== 'object' && kind !== 'spell')) return null
|
||
return { kind, id }
|
||
}
|
||
|
||
async function act(action: Record<string, unknown>): Promise<boolean> {
|
||
if (!token.value) return false
|
||
busy.value = true
|
||
error.value = ''
|
||
try {
|
||
await $fetch(`${apiBase}/games/${gameId.value}/actions`, {
|
||
method: 'POST',
|
||
body: { token: token.value, action },
|
||
})
|
||
return true
|
||
} catch (caught) {
|
||
error.value = errorMessage(caught)
|
||
return false
|
||
} finally {
|
||
busy.value = false
|
||
}
|
||
}
|
||
|
||
async function loadSummary() {
|
||
try {
|
||
const data = await $fetch<{ games: MatchSummary[] }>(`${apiBase}/games`)
|
||
summary.value = data.games.find(entry => entry.id === gameId.value) ?? null
|
||
} catch {
|
||
summary.value = null
|
||
}
|
||
}
|
||
|
||
async function connect() {
|
||
if (!token.value) return
|
||
connection.value = 'connecting'
|
||
try {
|
||
const next = await $fetch<MatchView>(`${apiBase}/games/${gameId.value}/state`, {
|
||
query: { token: token.value },
|
||
})
|
||
applyState(next, false)
|
||
} catch (caught) {
|
||
error.value = errorMessage(caught)
|
||
token.value = ''
|
||
connection.value = 'offline'
|
||
return
|
||
}
|
||
const seated = state.value?.players.find(player => player.id === state.value?.viewerId)
|
||
const seatedDeck = decks.value.find(deck => deck.commander.oracleId === seated?.commander?.oracleId)
|
||
if (seatedDeck) deckId.value = seatedDeck.id
|
||
|
||
events?.close()
|
||
events = new EventSource(`${apiBase}/games/${gameId.value}/events?token=${encodeURIComponent(token.value)}`)
|
||
events.onopen = () => { connection.value = 'live' }
|
||
events.onmessage = (event) => {
|
||
try {
|
||
const next = JSON.parse(event.data) as MatchView
|
||
applyState(next)
|
||
connection.value = 'live'
|
||
} catch {
|
||
// Ignore malformed keepalive frames.
|
||
}
|
||
}
|
||
events.onerror = () => { connection.value = 'reconnecting' }
|
||
}
|
||
|
||
function deckPayload(deck: SavedDeck) {
|
||
return {
|
||
commander: deck.commander.oracleId,
|
||
cards: deck.cards.map(card => card.oracleId),
|
||
}
|
||
}
|
||
|
||
async function joinGame() {
|
||
const deck = decks.value.find(entry => entry.id === deckId.value)
|
||
if (!deck) {
|
||
joinError.value = 'Choose a deck.'
|
||
return
|
||
}
|
||
joining.value = true
|
||
joinError.value = ''
|
||
try {
|
||
const data = await $fetch<{ matchId: string; playerId: string; token: string }>(
|
||
`${apiBase}/games/${gameId.value}/join`,
|
||
{
|
||
method: 'POST',
|
||
body: {
|
||
name: joinName.value,
|
||
deck: deckPayload(deck),
|
||
playmat: await loadPlaymatChoice(apiBase),
|
||
},
|
||
},
|
||
)
|
||
sessionStorage.setItem(`${SESSION_PREFIX}${gameId.value}`, JSON.stringify(data))
|
||
token.value = data.token
|
||
await connect()
|
||
} catch (caught) {
|
||
joinError.value = errorMessage(caught)
|
||
} finally {
|
||
joining.value = false
|
||
}
|
||
}
|
||
|
||
async function changeDeck() {
|
||
const deck = decks.value.find(entry => entry.id === deckId.value)
|
||
if (!deck) return
|
||
busy.value = true
|
||
error.value = ''
|
||
notice.value = ''
|
||
try {
|
||
await $fetch(`${apiBase}/games/${gameId.value}/deck`, {
|
||
method: 'POST',
|
||
body: { token: token.value, deck: deckPayload(deck) },
|
||
})
|
||
notice.value = `Deck changed to ${deck.name}.`
|
||
} catch (caught) {
|
||
error.value = errorMessage(caught)
|
||
} finally {
|
||
busy.value = false
|
||
}
|
||
}
|
||
|
||
async function startGame() {
|
||
busy.value = true
|
||
error.value = ''
|
||
try {
|
||
await $fetch(`${apiBase}/games/${gameId.value}/start`, {
|
||
method: 'POST',
|
||
body: { token: token.value },
|
||
})
|
||
} catch (caught) {
|
||
error.value = errorMessage(caught)
|
||
} finally {
|
||
busy.value = false
|
||
}
|
||
}
|
||
|
||
function menuAction(action: () => void) {
|
||
menuOpen.value = false
|
||
action()
|
||
}
|
||
|
||
async function leaveGame() {
|
||
busy.value = true
|
||
error.value = ''
|
||
const forfeited = state.value?.status === 'active'
|
||
try {
|
||
await $fetch(`${apiBase}/games/${gameId.value}/leave`, {
|
||
method: 'POST',
|
||
body: { token: token.value },
|
||
})
|
||
sessionStorage.removeItem(`${SESSION_PREFIX}${gameId.value}`)
|
||
events?.close()
|
||
events = undefined
|
||
resetAnimations()
|
||
state.value = null
|
||
token.value = ''
|
||
connection.value = 'offline'
|
||
if (forfeited) {
|
||
await navigateTo('/')
|
||
return
|
||
}
|
||
notice.value = 'You left the game.'
|
||
await loadSummary()
|
||
} catch (caught) {
|
||
error.value = errorMessage(caught)
|
||
} finally {
|
||
busy.value = false
|
||
}
|
||
}
|
||
|
||
async function playLand(card: CardView) {
|
||
await act({ type: 'play_land', cardId: card.id })
|
||
}
|
||
|
||
/** Cards with choices need the cast panel; everything else plays on click. */
|
||
function needsCastOptions(card: CardView): boolean {
|
||
return Boolean(card.manaCost?.includes('X') || /\btarget|choose (one|two|three)/i.test(card.oracleText ?? ''))
|
||
}
|
||
|
||
async function playCard(card: CardView) {
|
||
if (busy.value || !card.playable) return
|
||
cancelCast()
|
||
if (isLand(card)) {
|
||
await playLand(card)
|
||
return
|
||
}
|
||
await act({ type: 'cast', cardId: card.id, targets: [], x: 0 })
|
||
}
|
||
|
||
/** Place a hand card on the fan: spread, tilt and arc drop around the middle card. */
|
||
function fanStyle(index: number, total: number) {
|
||
const offset = index - (total - 1) / 2
|
||
const step = Math.min(3.4, 30 / Math.max(total, 1))
|
||
const angle = offset * Math.min(5, 36 / Math.max(total, 1))
|
||
const drop = Math.min(2.5, Math.abs(offset) ** 1.7 * 0.18)
|
||
return {
|
||
'--angle': `${angle.toFixed(2)}deg`,
|
||
transform: `translateX(calc(-50% + ${(offset * step).toFixed(3)}em)) translateY(${drop.toFixed(3)}em) rotate(${angle.toFixed(2)}deg)`,
|
||
}
|
||
}
|
||
|
||
function startPan(event: PointerEvent) {
|
||
// Touch keeps native scrolling; drag-to-pan is for mice and pens.
|
||
if (event.pointerType === 'touch' || event.button !== 0) return
|
||
if ((event.target as HTMLElement).closest('button, a, input, select, textarea, [role="button"]')) return
|
||
panOrigin = { x: event.clientX, y: event.clientY, viewX: view.x, viewY: view.y }
|
||
panning.value = true
|
||
tableEl.value?.setPointerCapture(event.pointerId)
|
||
}
|
||
|
||
function movePan(event: PointerEvent) {
|
||
if (!panning.value) return
|
||
view.x = panOrigin.viewX + event.clientX - panOrigin.x
|
||
view.y = panOrigin.viewY + event.clientY - panOrigin.y
|
||
}
|
||
|
||
function endPan(event: PointerEvent) {
|
||
if (!panning.value) return
|
||
panning.value = false
|
||
const el = tableEl.value
|
||
if (el?.hasPointerCapture(event.pointerId)) el.releasePointerCapture(event.pointerId)
|
||
}
|
||
|
||
/** Zoom toward the cursor, so the card under the pointer stays put. */
|
||
function zoomTable(event: WheelEvent) {
|
||
const el = tableEl.value
|
||
if (!el) return
|
||
const delta = event.deltaY * (event.deltaMode === 1 ? 16 : event.deltaMode === 2 ? 100 : 1)
|
||
const scale = Math.min(MAX_ZOOM, Math.max(MIN_ZOOM, view.scale * Math.exp(-delta * 0.0015)))
|
||
if (scale === view.scale) return
|
||
const rect = el.getBoundingClientRect()
|
||
const x = event.clientX - rect.left
|
||
const y = event.clientY - rect.top
|
||
view.x = x - (x - view.x) * (scale / view.scale)
|
||
view.y = y - (y - view.y) * (scale / view.scale)
|
||
view.scale = scale
|
||
}
|
||
|
||
function resetView() {
|
||
view.x = 0
|
||
view.y = 0
|
||
view.scale = 1
|
||
}
|
||
|
||
function isPositioned(card: CardView): boolean {
|
||
return dragPreview.value?.cardId === card.id || Boolean(card.position)
|
||
}
|
||
|
||
function permStyle(card: CardView) {
|
||
const position = dragPreview.value?.cardId === card.id ? dragPreview.value : card.position
|
||
if (!position) return undefined
|
||
return { left: `${position.x * 100}%`, top: `${position.y * 100}%` }
|
||
}
|
||
|
||
/** Drag a permanent you control; positions are stored as a normalized board center. */
|
||
function startCardMove(card: CardView, event: PointerEvent) {
|
||
if (event.button !== 0 || card.controller !== viewerId.value || state.value?.status !== 'active') return
|
||
const perm = event.currentTarget as HTMLElement
|
||
const board = perm.closest('.battlefield') as HTMLElement | null
|
||
if (!board) return
|
||
event.stopPropagation()
|
||
perm.setPointerCapture(event.pointerId)
|
||
const rect = perm.getBoundingClientRect()
|
||
cardDrag = {
|
||
cardId: card.id,
|
||
pointerId: event.pointerId,
|
||
board,
|
||
startX: event.clientX,
|
||
startY: event.clientY,
|
||
grabX: event.clientX - (rect.left + rect.width / 2),
|
||
grabY: event.clientY - (rect.top + rect.height / 2),
|
||
halfWidth: rect.width / 2,
|
||
halfHeight: rect.height / 2,
|
||
moved: false,
|
||
}
|
||
}
|
||
|
||
function moveCardPreview(event: PointerEvent) {
|
||
const drag = cardDrag
|
||
if (!drag || drag.pointerId !== event.pointerId) return
|
||
if (!drag.moved && Math.hypot(event.clientX - drag.startX, event.clientY - drag.startY) < 4) return
|
||
drag.moved = true
|
||
const rect = drag.board.getBoundingClientRect()
|
||
const marginX = Math.min(0.49, drag.halfWidth / rect.width)
|
||
const marginY = Math.min(0.49, drag.halfHeight / rect.height)
|
||
const clamp = (value: number, margin: number) => Math.min(1 - margin, Math.max(margin, value))
|
||
const x = (event.clientX - drag.grabX - rect.left) / rect.width
|
||
const y = (event.clientY - drag.grabY - rect.top) / rect.height
|
||
const attackDrag = Boolean(attackWindow.value && myUntappedCreatures.value.some(card => card.id === drag.cardId))
|
||
dragPreview.value = {
|
||
cardId: drag.cardId,
|
||
x: attackDrag ? x : clamp(x, marginX),
|
||
y: attackDrag ? y : clamp(y, marginY),
|
||
}
|
||
attackDropId.value = attackDropTargetAt(drag.cardId, event.clientX, event.clientY)
|
||
}
|
||
|
||
/** Topmost opponent panel under the pointer, ignoring the card being dragged. */
|
||
function attackDropTargetAt(cardId: string, x: number, y: number): string {
|
||
if (!attackWindow.value || !myUntappedCreatures.value.some(card => card.id === cardId)) return ''
|
||
for (const element of document.elementsFromPoint(x, y)) {
|
||
const panel = element.closest<HTMLElement>('.player')
|
||
const id = panel?.dataset.playerId
|
||
if (id && opponents.value.some(player => player.id === id)) return id
|
||
}
|
||
return ''
|
||
}
|
||
|
||
async function endCardMove(event: PointerEvent) {
|
||
const drag = cardDrag
|
||
if (!drag || drag.pointerId !== event.pointerId) return
|
||
cardDrag = null
|
||
const preview = dragPreview.value
|
||
dragPreview.value = null
|
||
const attackTarget = attackDropTargetAt(drag.cardId, event.clientX, event.clientY)
|
||
attackDropId.value = ''
|
||
if (!drag.moved || !preview) return
|
||
|
||
// The click that follows a drag must not open the ability menu.
|
||
suppressCardClick = drag.cardId
|
||
setTimeout(() => { suppressCardClick = '' }, 0)
|
||
|
||
if (attackTarget) {
|
||
if (!selectedAttackers.value.includes(drag.cardId)) selectedAttackers.value.push(drag.cardId)
|
||
attackTargets[drag.cardId] = attackTarget
|
||
return
|
||
}
|
||
|
||
const target = myBattlefield.value.find(card => card.id === drag.cardId)
|
||
if (!target) return
|
||
const rect = drag.board.getBoundingClientRect()
|
||
const marginX = Math.min(0.49, drag.halfWidth / rect.width)
|
||
const marginY = Math.min(0.49, drag.halfHeight / rect.height)
|
||
const previous = target.position
|
||
target.position = {
|
||
x: Math.min(1 - marginX, Math.max(marginX, preview.x)),
|
||
y: Math.min(1 - marginY, Math.max(marginY, preview.y)),
|
||
}
|
||
const ok = await act({
|
||
type: 'move_permanent',
|
||
cardId: drag.cardId,
|
||
position: target.position,
|
||
})
|
||
if (!ok) target.position = previous
|
||
}
|
||
|
||
function cancelCardMove(event: PointerEvent) {
|
||
if (cardDrag?.pointerId !== event.pointerId) return
|
||
cardDrag = null
|
||
dragPreview.value = null
|
||
attackDropId.value = ''
|
||
}
|
||
|
||
function openCast(card: CardView) {
|
||
castCardId.value = card.id
|
||
selectedTarget.value = ''
|
||
castX.value = 0
|
||
castOverload.value = false
|
||
error.value = ''
|
||
}
|
||
|
||
function cancelCast() {
|
||
castCardId.value = ''
|
||
selectedTarget.value = ''
|
||
castOverload.value = false
|
||
}
|
||
|
||
async function confirmCast() {
|
||
if (!castCard.value) return
|
||
const target = parseTarget(selectedTarget.value)
|
||
const ok = await act({
|
||
type: 'cast',
|
||
cardId: castCard.value.id,
|
||
targets: target ? [target] : [],
|
||
x: castX.value,
|
||
overload: castOverload.value,
|
||
})
|
||
if (ok) cancelCast()
|
||
}
|
||
|
||
async function activate(card: CardView, ability: AbilityView) {
|
||
await act({ type: 'activate', sourceId: card.id, abilityIndex: ability.index })
|
||
}
|
||
|
||
async function activateFromMenu(card: CardView, ability: AbilityView) {
|
||
closeMenu()
|
||
await activate(card, ability)
|
||
}
|
||
|
||
async function chooseSearchCard(card: CardView) {
|
||
if (busy.value || !searchLegalIds.value.has(card.id)) return
|
||
await act({ type: 'choose_search', cardId: card.id })
|
||
}
|
||
|
||
async function chooseCreatureType(type: string) {
|
||
if (busy.value) return
|
||
await act({ type: 'choose_type', choice: type })
|
||
}
|
||
|
||
async function attack() {
|
||
const attackers = selectedAttackers.value
|
||
.filter(attackerId => attackTargets[attackerId])
|
||
.map(attackerId => ({ attackerId, defenderId: attackTargets[attackerId] }))
|
||
if (!attackers.length) return
|
||
const ok = await act({ type: 'attack', attackers })
|
||
if (ok) {
|
||
selectedAttackers.value = []
|
||
for (const key of Object.keys(attackTargets)) delete attackTargets[key]
|
||
}
|
||
}
|
||
|
||
function removeAttacker(cardId: string) {
|
||
selectedAttackers.value = selectedAttackers.value.filter(id => id !== cardId)
|
||
delete attackTargets[cardId]
|
||
}
|
||
|
||
function attackerName(cardId: string): string {
|
||
return myUntappedCreatures.value.find(card => card.id === cardId)?.name ?? 'Creature'
|
||
}
|
||
|
||
async function declareBlocks() {
|
||
const blocks = Object.entries(blockSelection)
|
||
.filter(([, blockerId]) => blockerId)
|
||
.map(([attackerId, blockerId]) => ({ blockerId, attackerId }))
|
||
if (!blocks.length) {
|
||
await act({ type: 'pass' })
|
||
return
|
||
}
|
||
const ok = await act({ type: 'block', blocks })
|
||
if (ok) {
|
||
for (const key of Object.keys(blockSelection)) delete blockSelection[key]
|
||
}
|
||
}
|
||
|
||
async function copyLink() {
|
||
try {
|
||
await navigator.clipboard.writeText(window.location.href)
|
||
notice.value = 'Game link copied. Anyone opening it can take an open seat.'
|
||
} catch {
|
||
notice.value = 'Copy failed.'
|
||
}
|
||
}
|
||
|
||
function errorMessage(caught: unknown): string {
|
||
const data = (caught as { data?: { error?: string } })?.data
|
||
return data?.error ?? (caught instanceof Error ? caught.message : String(caught))
|
||
}
|
||
|
||
const MANA_COLORS: Record<string, string> = {
|
||
W: '#f5f2d6',
|
||
U: '#7aa2f7',
|
||
B: '#b6a2d8',
|
||
R: '#e07a7a',
|
||
G: '#7dd3a0',
|
||
C: '#c4c8d4',
|
||
}
|
||
|
||
function manaColor(color: string): string {
|
||
return MANA_COLORS[color] ?? 'var(--accent)'
|
||
}
|
||
|
||
function scheduleAnimation(callback: () => void, delay: number) {
|
||
const timer = setTimeout(() => {
|
||
animationTimers.delete(timer)
|
||
callback()
|
||
}, delay)
|
||
animationTimers.add(timer)
|
||
}
|
||
|
||
/** Flash a keyed CSS animation, then let it be applied again next time. */
|
||
function pulse(map: Record<string, number>, id: string, duration: number) {
|
||
const token = ++animationCounter
|
||
map[id] = token
|
||
scheduleAnimation(() => {
|
||
if (map[id] === token) delete map[id]
|
||
}, duration)
|
||
}
|
||
|
||
function addFloatingLabel(targetId: string, text: string, tone: FloatingLabel['tone']) {
|
||
const id = ++animationCounter
|
||
floatingLabels.value.push({ id, targetId, text, tone })
|
||
scheduleAnimation(() => {
|
||
floatingLabels.value = floatingLabels.value.filter(label => label.id !== id)
|
||
}, 1100)
|
||
}
|
||
|
||
function addManaBurst(color: string, amount: number) {
|
||
const id = ++animationCounter
|
||
manaBursts.value.push({ id, color, amount })
|
||
scheduleAnimation(() => {
|
||
manaBursts.value = manaBursts.value.filter(burst => burst.id !== id)
|
||
}, 1100)
|
||
}
|
||
|
||
function labelsFor(targetId: string): FloatingLabel[] {
|
||
return floatingLabels.value.filter(label => label.targetId === targetId)
|
||
}
|
||
|
||
function playAnimations(animations: GameAnimations) {
|
||
for (const id of animations.enteringCardIds) pulse(cardEnterAnimations, id, 520)
|
||
for (const id of animations.attackingCardIds) pulse(cardAttackAnimations, id, 540)
|
||
for (const damage of animations.damagedCards) {
|
||
pulse(cardDamageAnimations, damage.cardId, 500)
|
||
addFloatingLabel(damage.cardId, `−${damage.amount}`, 'damage')
|
||
}
|
||
for (const change of animations.lifeChanges) {
|
||
if (change.amount < 0) {
|
||
pulse(playerHitAnimations, change.playerId, 700)
|
||
addFloatingLabel(change.playerId, `−${Math.abs(change.amount)}`, 'damage')
|
||
} else {
|
||
pulse(playerHealAnimations, change.playerId, 700)
|
||
addFloatingLabel(change.playerId, `+${change.amount}`, 'heal')
|
||
}
|
||
}
|
||
for (const gain of animations.manaGains) addManaBurst(gain.color, gain.amount)
|
||
}
|
||
|
||
function applyState(next: MatchView, animate = true) {
|
||
if (animate) playAnimations(diffGameState(previousState, next))
|
||
previousState = next
|
||
state.value = next
|
||
}
|
||
|
||
function resetAnimations() {
|
||
previousState = null
|
||
for (const timer of animationTimers) clearTimeout(timer)
|
||
animationTimers.clear()
|
||
for (const map of [
|
||
cardEnterAnimations,
|
||
cardDamageAnimations,
|
||
cardAttackAnimations,
|
||
playerHitAnimations,
|
||
playerHealAnimations,
|
||
]) {
|
||
for (const key of Object.keys(map)) delete map[key]
|
||
}
|
||
floatingLabels.value = []
|
||
manaBursts.value = []
|
||
}
|
||
|
||
watch(() => game.value?.step, () => {
|
||
selectedAttackers.value = []
|
||
attackDropId.value = ''
|
||
for (const key of Object.keys(attackTargets)) delete attackTargets[key]
|
||
for (const key of Object.keys(blockSelection)) delete blockSelection[key]
|
||
})
|
||
|
||
watch(() => Boolean(pendingSearch.value), async active => {
|
||
if (!active) return
|
||
searchFilter.value = ''
|
||
await nextTick()
|
||
searchInput.value?.focus()
|
||
})
|
||
|
||
watch(() => pendingChoice.value?.sourceId, async sourceId => {
|
||
if (!sourceId) return
|
||
choiceFilter.value = ''
|
||
await nextTick()
|
||
choiceInput.value?.focus()
|
||
})
|
||
|
||
onMounted(async () => {
|
||
window.addEventListener('keydown', onKeydown)
|
||
decks.value = (await loadDecks(apiBase)).sort((a, b) => b.updatedAt - a.updatedAt)
|
||
joinName.value = localStorage.getItem('commander-player-name') ?? ''
|
||
deckId.value = decks.value.find(deck => !deckValidation(deck).length)?.id
|
||
?? decks.value[0]?.id
|
||
?? ''
|
||
|
||
const raw = sessionStorage.getItem(`${SESSION_PREFIX}${gameId.value}`)
|
||
if (raw) {
|
||
try {
|
||
token.value = (JSON.parse(raw) as { token?: string }).token ?? ''
|
||
} catch {
|
||
token.value = ''
|
||
}
|
||
}
|
||
|
||
await loadSummary()
|
||
if (token.value) {
|
||
await connect()
|
||
} else {
|
||
connection.value = 'offline'
|
||
}
|
||
})
|
||
|
||
onUnmounted(() => {
|
||
window.removeEventListener('keydown', onKeydown)
|
||
events?.close()
|
||
for (const timer of animationTimers) clearTimeout(timer)
|
||
animationTimers.clear()
|
||
})
|
||
</script>
|
||
|
||
<template>
|
||
<main class="fill-page" :class="{ 'game-page': game }">
|
||
<header class="game-head">
|
||
<div>
|
||
<h1>{{ summary ? `${summary.hostName}'s game` : 'Commander game' }}</h1>
|
||
<p v-if="game" class="muted">
|
||
Turn {{ game.turn }} · {{ phaseLabel }} · priority: {{ priorityName }}
|
||
</p>
|
||
<p v-else class="muted">{{ state?.status ?? summary?.status ?? 'Loading…' }}</p>
|
||
</div>
|
||
<div class="row wrap">
|
||
<button
|
||
type="button"
|
||
class="mini hamburger"
|
||
:aria-expanded="menuOpen"
|
||
aria-label="Game menu"
|
||
@click="menuOpen = !menuOpen"
|
||
>☰</button>
|
||
</div>
|
||
</header>
|
||
|
||
<p v-if="error" class="error">{{ error }}</p>
|
||
<p v-else-if="notice" class="ok">{{ notice }}</p>
|
||
|
||
<section v-if="!token" class="panel join-panel">
|
||
<h2>Join this game</h2>
|
||
<p v-if="summary" class="muted">
|
||
Host: {{ summary.hostName }} · {{ summary.playerCount }}/{{ summary.maxPlayers }}
|
||
· {{ summary.status }}
|
||
</p>
|
||
<p v-if="summary?.status === 'active'" class="warn">
|
||
This game has already started. You can only join games in the lobby.
|
||
</p>
|
||
<p v-if="!decks.length" class="warn">
|
||
No saved decks. <NuxtLink to="/decks">Create or import one first</NuxtLink>.
|
||
</p>
|
||
<label class="field">
|
||
<span class="muted">Your name</span>
|
||
<input v-model="joinName" maxlength="30" placeholder="Player">
|
||
</label>
|
||
<label class="field">
|
||
<span class="muted">Deck</span>
|
||
<select v-model="deckId">
|
||
<option v-for="deck in decks" :key="deck.id" :value="deck.id">
|
||
{{ deck.name }} ({{ deck.cards.length + 1 }})
|
||
</option>
|
||
</select>
|
||
</label>
|
||
<p v-if="joinError" class="error">{{ joinError }}</p>
|
||
<button
|
||
type="button"
|
||
class="primary"
|
||
:disabled="joining || !joinName.trim() || !deckId || summary?.status === 'active'"
|
||
@click="joinGame"
|
||
>{{ joining ? 'Joining…' : 'Join game' }}</button>
|
||
</section>
|
||
|
||
<template v-else-if="state">
|
||
<section v-if="state.status === 'lobby'" class="panel lobby-panel">
|
||
<header class="lobby-head">
|
||
<h2>Lobby</h2>
|
||
<p class="muted">
|
||
{{ state.players.length }}/{{ state.maxPlayers }} players · Waiting for players.
|
||
Share the link or use the Play page.
|
||
</p>
|
||
</header>
|
||
|
||
<div class="lobby-seats">
|
||
<article
|
||
v-for="player in state.players"
|
||
:key="player.id"
|
||
class="lobby-seat"
|
||
:class="{ self: player.id === viewerId }"
|
||
>
|
||
<div class="lobby-commander">
|
||
<GameCard
|
||
v-if="player.commander"
|
||
:oracle-id="player.commander.oracleId"
|
||
:name="player.commander.name"
|
||
/>
|
||
<div v-else class="lobby-commander-empty">{{ player.name.charAt(0) }}</div>
|
||
</div>
|
||
<strong>{{ player.name }}</strong>
|
||
<span v-if="player.commander" class="lobby-commander-name">{{ player.commander.name }}</span>
|
||
<div class="lobby-badges">
|
||
<span v-if="player.id === state.hostId" class="tag">host</span>
|
||
<span v-if="player.id === viewerId" class="tag good">you</span>
|
||
</div>
|
||
</article>
|
||
|
||
<article v-for="seat in emptySeats" :key="`empty-${seat}`" class="lobby-seat empty">
|
||
<div class="lobby-commander">
|
||
<div class="lobby-commander-empty">?</div>
|
||
</div>
|
||
<span class="muted">Waiting for a player…</span>
|
||
</article>
|
||
</div>
|
||
|
||
<div class="lobby-actions">
|
||
<label v-if="decks.length" class="field lobby-deck">
|
||
<span class="muted">Your deck</span>
|
||
<select v-model="deckId" :disabled="busy" @change="changeDeck">
|
||
<option v-for="deck in decks" :key="deck.id" :value="deck.id">
|
||
{{ deck.name }} ({{ deck.cards.length + 1 }})
|
||
</option>
|
||
</select>
|
||
</label>
|
||
<button
|
||
v-if="isHost"
|
||
type="button"
|
||
class="primary"
|
||
:disabled="busy || state.players.length < 2"
|
||
@click="startGame"
|
||
>{{ state.players.length < 2 ? 'Need at least two players' : 'Start game' }}</button>
|
||
<p v-else class="muted">Waiting for the host to start.</p>
|
||
<button type="button" :disabled="busy" @click="leaveGame">Leave game</button>
|
||
</div>
|
||
</section>
|
||
|
||
<template v-else-if="game">
|
||
<p v-if="game.status === 'finished'" class="winner">
|
||
{{ winnerName }} wins!
|
||
<NuxtLink to="/">Back to games</NuxtLink>
|
||
</p>
|
||
|
||
<div class="game-layout">
|
||
<section
|
||
ref="tableEl"
|
||
class="players"
|
||
:class="{ panning }"
|
||
@pointerdown="startPan"
|
||
@pointermove="movePan"
|
||
@pointerup="endPan"
|
||
@pointercancel="endPan"
|
||
@wheel.prevent="zoomTable"
|
||
>
|
||
<div class="table-canvas" :style="canvasStyle">
|
||
<article
|
||
v-for="(player, playerIndex) in state.players"
|
||
:key="player.id"
|
||
class="panel player"
|
||
:data-player-id="player.id"
|
||
:class="{
|
||
current: game.activePlayer === player.id,
|
||
dead: player.lost,
|
||
'anim-hit': playerHitAnimations[player.id],
|
||
'anim-heal': playerHealAnimations[player.id],
|
||
'attack-ready': draggingAttackerId && player.id !== viewerId && !player.lost,
|
||
'drop-hover': attackDropId === player.id,
|
||
}"
|
||
>
|
||
<header class="player-head">
|
||
<strong class="grow">{{ player.name }}</strong>
|
||
<span v-if="player.id === viewerId" class="tag">you</span>
|
||
<span
|
||
class="life"
|
||
:class="{
|
||
'life-hit': playerHitAnimations[player.id],
|
||
'life-heal': playerHealAnimations[player.id],
|
||
}"
|
||
>{{ player.life }}</span>
|
||
<span class="tag">hand {{ player.handCount ?? 0 }}</span>
|
||
<span class="tag">library {{ player.libraryCount ?? 0 }}</span>
|
||
<span v-if="game.priority === player.id" class="tag good">priority</span>
|
||
<span v-if="player.lost" class="tag bad">lost</span>
|
||
<button
|
||
v-if="player.id === viewerId"
|
||
type="button"
|
||
class="mini"
|
||
:class="{ active: playmatOpen }"
|
||
title="Change your playmat"
|
||
@click="togglePlaymat"
|
||
>Playmat</button>
|
||
<span
|
||
v-for="label in labelsFor(player.id)"
|
||
:key="label.id"
|
||
class="float-text player-float"
|
||
:class="label.tone"
|
||
aria-hidden="true"
|
||
>{{ label.text }}</span>
|
||
</header>
|
||
|
||
<p v-if="player.commanderDamage?.length" class="damage">
|
||
<span v-for="damage in player.commanderDamage" :key="damage.commanderId" class="tag bad">
|
||
☠ {{ damage.commanderName }} {{ damage.amount }}/21
|
||
</span>
|
||
</p>
|
||
|
||
<div class="play-area" :class="{ 'command-right': playerIndex % 2 === 1 }">
|
||
<div v-if="player.command?.length || player.graveyard?.length || player.libraryCount" class="side-zones">
|
||
<div v-if="player.libraryCount" class="zone">
|
||
<span class="zone-label">Library {{ player.libraryCount }}</span>
|
||
<div class="library-stack" :style="cardBackStyle">
|
||
<span
|
||
v-for="layer in Math.min(3, player.libraryCount ?? 1)"
|
||
:key="layer"
|
||
class="library-back"
|
||
/>
|
||
</div>
|
||
</div>
|
||
|
||
<div v-if="player.command?.length" class="zone">
|
||
<span class="zone-label">Command</span>
|
||
<div v-for="card in player.command" :key="card.id" class="command-card" :title="card.oracleText">
|
||
<CardHover :oracle-id="card.oracleId" :name="card.name">
|
||
<GameCard :oracle-id="card.oracleId" :name="card.name">
|
||
<span v-if="card.isCommander" class="overlay-tag commander" title="Commander">♛</span>
|
||
</GameCard>
|
||
</CardHover>
|
||
<span v-if="commanderTax(player, card)" class="tag">tax {{ commanderTax(player, card) }}</span>
|
||
<button
|
||
v-if="player.id === viewerId && canAct"
|
||
type="button"
|
||
class="mini"
|
||
:disabled="busy"
|
||
@click="openCast(card)"
|
||
>Cast</button>
|
||
</div>
|
||
</div>
|
||
|
||
<div v-if="player.graveyard?.length" class="zone graveyard-zone">
|
||
<span class="zone-label">Graveyard {{ player.graveyard.length }}</span>
|
||
<div class="graveyard-stack">
|
||
<CardHover
|
||
v-for="card in player.graveyard.slice(-PILE_SIZE)"
|
||
:key="card.id"
|
||
:oracle-id="card.oracleId"
|
||
:name="card.name"
|
||
>
|
||
<GameCard :oracle-id="card.oracleId" :name="card.name" />
|
||
</CardHover>
|
||
</div>
|
||
</div>
|
||
</div>
|
||
|
||
<div class="battlefield" :class="{ 'has-playmat': player.playmat }" :style="playmatStyle(player)">
|
||
<div
|
||
v-for="card in player.battlefield"
|
||
:key="card.id"
|
||
class="perm"
|
||
:class="{
|
||
selected: selectedCardId === card.id,
|
||
positioned: isPositioned(card),
|
||
dragging: dragPreview?.cardId === card.id,
|
||
movable: card.controller === viewerId,
|
||
'pending-attack': attackTargets[card.id],
|
||
'anim-enter': cardEnterAnimations[card.id],
|
||
'anim-damage': cardDamageAnimations[card.id],
|
||
'anim-attack': cardAttackAnimations[card.id],
|
||
}"
|
||
:style="permStyle(card)"
|
||
:title="card.oracleText"
|
||
role="button"
|
||
tabindex="0"
|
||
@pointerdown="startCardMove(card, $event)"
|
||
@pointermove="moveCardPreview"
|
||
@pointerup="endCardMove"
|
||
@pointercancel="cancelCardMove"
|
||
@click="toggleCard(card, $event)"
|
||
@keydown.enter.prevent="toggleCard(card, $event)"
|
||
@keydown.space.prevent="toggleCard(card, $event)"
|
||
>
|
||
<CardHover :oracle-id="card.oracleId" :name="card.name">
|
||
<GameCard :oracle-id="card.oracleId" :name="card.name" :tapped="card.tapped">
|
||
<span v-if="card.isCommander" class="overlay-tag commander" title="Commander">♛</span>
|
||
<span
|
||
v-if="card.chosenType"
|
||
class="overlay-tag chosen"
|
||
:title="`Chosen creature type: ${card.chosenType}`"
|
||
>{{ card.chosenType }}</span>
|
||
<span
|
||
v-if="card.attacking || attackTargets[card.id]"
|
||
class="overlay-tag attacking"
|
||
:title="`Attacking ${playerName(card.attacking || attackTargets[card.id])}`"
|
||
>⚔</span>
|
||
<span v-if="card.damage" class="overlay-tag card-damage" title="Damage">−{{ card.damage }}</span>
|
||
<span v-if="card.power !== undefined" class="stats">{{ card.power }}/{{ card.toughness }}</span>
|
||
<div v-if="Object.keys(card.counters).length" class="overlay-counters">
|
||
<span
|
||
v-for="(amount, counter) in card.counters"
|
||
:key="counter"
|
||
class="overlay-tag counter"
|
||
>{{ amount }} {{ counter }}</span>
|
||
</div>
|
||
</GameCard>
|
||
</CardHover>
|
||
<span
|
||
v-for="label in labelsFor(card.id)"
|
||
:key="label.id"
|
||
class="float-text card-float"
|
||
:class="label.tone"
|
||
aria-hidden="true"
|
||
>{{ label.text }}</span>
|
||
</div>
|
||
<p v-if="!player.battlefield?.length" class="muted">No permanents.</p>
|
||
</div>
|
||
</div>
|
||
|
||
<p class="muted small zone-bar">
|
||
<button
|
||
type="button"
|
||
class="zone-link"
|
||
:class="{ active: browsingZone?.playerId === player.id && browsingZone.zone === 'graveyard' }"
|
||
@click="toggleZone(player, 'graveyard')"
|
||
>Graveyard {{ player.graveyard?.length ?? 0 }}</button>
|
||
<span aria-hidden="true">·</span>
|
||
<button
|
||
type="button"
|
||
class="zone-link"
|
||
:class="{ active: browsingZone?.playerId === player.id && browsingZone.zone === 'exile' }"
|
||
@click="toggleZone(player, 'exile')"
|
||
>Exile {{ player.exile?.length ?? 0 }}</button>
|
||
</p>
|
||
</article>
|
||
</div>
|
||
</section>
|
||
|
||
<section class="stack-pile" :class="{ empty: !game.stack.length }" aria-live="polite" aria-label="Stack">
|
||
<h2 v-if="game.stack.length" class="stack-heading">
|
||
Stack <span class="muted">{{ game.stack.length }}</span>
|
||
</h2>
|
||
<TransitionGroup name="stack" tag="ol" class="stack-pile-list">
|
||
<li
|
||
v-for="(item, index) in [...game.stack].reverse()"
|
||
:key="item.id"
|
||
class="stack-card"
|
||
:class="[`kind-${item.kind}`, { 'is-top': index === 0 }]"
|
||
:style="{ zIndex: game.stack.length - index }"
|
||
:title="item.label"
|
||
>
|
||
<span class="stack-glyph" aria-hidden="true">{{ item.kind === 'spell' ? '✦' : '⟳' }}</span>
|
||
<span class="stack-copy">
|
||
<strong><SymbolText :text="item.label" /></strong>
|
||
<span class="muted">{{ playerName(item.controller) }}</span>
|
||
</span>
|
||
</li>
|
||
</TransitionGroup>
|
||
</section>
|
||
|
||
<section class="hand-panel">
|
||
<div class="row wrap hand-head">
|
||
<h2>Your hand</h2>
|
||
<span class="tag">{{ game.hand.length }}</span>
|
||
<div class="mana-row">
|
||
<span v-for="(amount, color) in game.manaPool" :key="color" class="tag">
|
||
<ManaCost :cost="`{${color}}`" /> {{ amount }}
|
||
</span>
|
||
<span
|
||
v-for="burst in manaBursts"
|
||
:key="burst.id"
|
||
class="mana-burst"
|
||
:style="{ color: manaColor(burst.color) }"
|
||
aria-hidden="true"
|
||
>
|
||
<ManaCost :cost="`{${burst.color}}`" /> +{{ burst.amount }}
|
||
</span>
|
||
</div>
|
||
</div>
|
||
<p v-if="!game.hand.length" class="muted">No cards in hand.</p>
|
||
<TransitionGroup v-else name="hand" tag="div" class="hand-fan">
|
||
<div
|
||
v-for="(card, index) in game.hand"
|
||
:key="card.id"
|
||
class="hand-card"
|
||
:class="{ playable: card.playable, unplayable: !card.playable }"
|
||
:style="fanStyle(index, game.hand.length)"
|
||
:title="card.playable
|
||
? `Click to ${isLand(card) ? 'play' : 'cast'} ${card.name}`
|
||
: card.oracleText"
|
||
role="button"
|
||
:tabindex="card.playable ? 0 : -1"
|
||
:aria-disabled="!card.playable"
|
||
@click="playCard(card)"
|
||
@keydown.enter.prevent="playCard(card)"
|
||
@keydown.space.prevent="playCard(card)"
|
||
>
|
||
<div class="hand-lift">
|
||
<CardHover :oracle-id="card.oracleId" :name="card.name">
|
||
<GameCard :oracle-id="card.oracleId" :name="card.name">
|
||
<span v-if="card.isCommander" class="overlay-tag commander" title="Commander">♛</span>
|
||
</GameCard>
|
||
</CardHover>
|
||
<button
|
||
v-if="!isLand(card) && needsCastOptions(card)"
|
||
type="button"
|
||
class="mini hand-options"
|
||
:disabled="!card.playable || busy"
|
||
@click.stop="openCast(card)"
|
||
@keydown.stop
|
||
>Options</button>
|
||
</div>
|
||
</div>
|
||
</TransitionGroup>
|
||
</section>
|
||
|
||
<aside v-if="sidebarOpen" ref="sidebarEl" class="sidebar">
|
||
<section v-if="playmatOpen" class="panel side">
|
||
<div class="row">
|
||
<h2 class="grow">Playmat</h2>
|
||
<button type="button" class="mini" @click="playmatOpen = false">Close</button>
|
||
</div>
|
||
<p class="muted">Only you can change your mat.</p>
|
||
<PlaymatPicker :current="myPlaymat" :busy="playmatBusy" @select="savePlaymat" />
|
||
</section>
|
||
|
||
<section v-if="browseView" class="panel side browse-panel">
|
||
<div class="row">
|
||
<h2 class="grow">{{ browseView.title }}</h2>
|
||
<button type="button" class="mini" @click="browsingZone = null">Close</button>
|
||
</div>
|
||
<p v-if="!browseView.cards.length" class="muted">Empty.</p>
|
||
<div v-else class="zone-cards">
|
||
<CardHover
|
||
v-for="card in browseView.cards"
|
||
:key="card.id"
|
||
:oracle-id="card.oracleId"
|
||
:name="card.name"
|
||
>
|
||
<GameCard :oracle-id="card.oracleId" :name="card.name" :title="card.oracleText" />
|
||
</CardHover>
|
||
</div>
|
||
</section>
|
||
|
||
<section v-if="pendingSearch && pendingSearch.player !== viewerId" class="panel side search-panel">
|
||
<h2>Search</h2>
|
||
<p class="muted">{{ playerName(pendingSearch.player) }} is searching their library.</p>
|
||
</section>
|
||
|
||
<section v-if="pendingChoice && pendingChoice.player !== viewerId" class="panel side search-panel">
|
||
<h2>Choose a type</h2>
|
||
<p class="muted">
|
||
{{ playerName(pendingChoice.player) }} is choosing a creature type for {{ pendingChoice.sourceName }}.
|
||
</p>
|
||
</section>
|
||
|
||
<section v-if="castCard" class="panel side cast-panel">
|
||
<div class="row">
|
||
<h2 class="grow">Cast {{ castCard.name }}</h2>
|
||
<button type="button" class="mini" @click="cancelCast">Cancel</button>
|
||
</div>
|
||
<p class="muted">
|
||
{{ castCard.typeLine }}
|
||
<ManaCost v-if="castCard.manaCost" :cost="castCard.manaCost" />
|
||
</p>
|
||
<p v-if="castCard.oracleText" class="oracle small"><SymbolText :text="castCard.oracleText" /></p>
|
||
<label v-if="overloadAbility" class="row">
|
||
<input v-model="castOverload" type="checkbox">
|
||
<span>{{ overloadAbility.text ?? 'Overload' }}</span>
|
||
</label>
|
||
<label class="field">
|
||
<span class="muted">Target</span>
|
||
<select v-model="selectedTarget">
|
||
<option v-for="option in targetOptions" :key="option.value" :value="option.value">
|
||
{{ option.label }}
|
||
</option>
|
||
</select>
|
||
</label>
|
||
<label v-if="castCard.manaCost?.includes('X')" class="field">
|
||
<span class="muted">X</span>
|
||
<input v-model.number="castX" type="number" min="0">
|
||
</label>
|
||
<button type="button" class="primary" :disabled="busy || Boolean(pendingSearch)" @click="confirmCast">Cast</button>
|
||
</section>
|
||
|
||
<section v-if="attackWindow" class="panel side">
|
||
<h2>Attack</h2>
|
||
<p class="muted">Drag an untapped creature onto a player to attack them.</p>
|
||
<div v-if="selectedAttackers.length" class="attack-list">
|
||
<button
|
||
v-for="attackerId in selectedAttackers"
|
||
:key="attackerId"
|
||
type="button"
|
||
class="attack-pick"
|
||
:title="`Remove ${attackerName(attackerId)} from the attack`"
|
||
@click="removeAttacker(attackerId)"
|
||
>
|
||
<span>{{ attackerName(attackerId) }}</span>
|
||
<span class="muted">⚔ {{ playerName(attackTargets[attackerId]) }} ✕</span>
|
||
</button>
|
||
</div>
|
||
<p v-else class="muted">No attackers chosen yet.</p>
|
||
<button type="button" :disabled="busy || !selectedAttackers.length" @click="attack">
|
||
Attack with {{ selectedAttackers.length }}
|
||
</button>
|
||
</section>
|
||
|
||
<section v-if="blockWindow" class="panel side">
|
||
<h2>Block</h2>
|
||
<p v-if="!incomingAttackers.length" class="muted">No creatures are attacking you.</p>
|
||
<div v-for="entry in incomingAttackers" :key="entry.card.id" class="block-row">
|
||
<span>{{ entry.card.name }} ({{ entry.card.power }}/{{ entry.card.toughness }})</span>
|
||
<select v-model="blockSelection[entry.card.id]">
|
||
<option value="">No block</option>
|
||
<option v-for="blocker in blockersFor(entry.card.id)" :key="blocker.id" :value="blocker.id">
|
||
{{ blocker.name }}
|
||
</option>
|
||
</select>
|
||
</div>
|
||
<button type="button" :disabled="busy" @click="declareBlocks">
|
||
{{ Object.values(blockSelection).some(Boolean) ? 'Declare blockers' : 'Pass (no blocks)' }}
|
||
</button>
|
||
</section>
|
||
|
||
<section v-if="showLog" class="panel side log-panel">
|
||
<h2>Log</h2>
|
||
<ul class="log-list">
|
||
<li v-for="(line, index) in [...game.log].reverse()" :key="index">{{ line }}</li>
|
||
</ul>
|
||
</section>
|
||
</aside>
|
||
</div>
|
||
</template>
|
||
</template>
|
||
|
||
<div v-if="state?.status === 'active' && game" class="turn-actions">
|
||
<button
|
||
type="button"
|
||
class="turn-button"
|
||
:disabled="!canAct || busy"
|
||
@click="act({ type: 'pass' })"
|
||
>Pass</button>
|
||
<button
|
||
type="button"
|
||
class="turn-button end"
|
||
:disabled="!canAct || !isActive || busy || Boolean(game.stack.length)"
|
||
@click="act({ type: 'end_turn' })"
|
||
>End turn</button>
|
||
</div>
|
||
|
||
<Teleport to="body">
|
||
<div v-if="pendingChoice?.player === viewerId" class="search-backdrop">
|
||
<section class="search-modal" role="dialog" aria-modal="true" aria-labelledby="choice-title">
|
||
<header class="search-head">
|
||
<div class="grow">
|
||
<h2 id="choice-title">Choose a creature type</h2>
|
||
<p class="muted">{{ pendingChoice.sourceName }} enters.</p>
|
||
</div>
|
||
<span class="tag">{{ filteredChoiceOptions.length }} types</span>
|
||
</header>
|
||
<input
|
||
ref="choiceInput"
|
||
v-model="choiceFilter"
|
||
class="search-filter"
|
||
type="search"
|
||
placeholder="Search creature types"
|
||
autocomplete="off"
|
||
>
|
||
<p v-if="!filteredChoiceOptions.length" class="muted">No creature types match “{{ choiceFilter }}”.</p>
|
||
<div v-else class="choice-grid">
|
||
<button
|
||
v-for="type in filteredChoiceOptions"
|
||
:key="type"
|
||
type="button"
|
||
class="choice-option"
|
||
:disabled="busy"
|
||
@click="chooseCreatureType(type)"
|
||
>{{ type }}</button>
|
||
</div>
|
||
</section>
|
||
</div>
|
||
</Teleport>
|
||
|
||
<Teleport to="body">
|
||
<div v-if="pendingSearch?.player === viewerId" class="search-backdrop">
|
||
<section class="search-modal" role="dialog" aria-modal="true" aria-labelledby="search-title">
|
||
<header class="search-head">
|
||
<div class="grow">
|
||
<h2 id="search-title">Search your library</h2>
|
||
<p class="muted">
|
||
Choose a card to put {{ searchDestination }}.
|
||
<template v-if="pendingSearch.remaining > 1">({{ pendingSearch.remaining }} picks left)</template>
|
||
</p>
|
||
</div>
|
||
<span class="tag">{{ searchLegalIds.size }} can be chosen</span>
|
||
</header>
|
||
<input
|
||
ref="searchInput"
|
||
v-model="searchFilter"
|
||
class="search-filter"
|
||
type="search"
|
||
placeholder="Search by card name"
|
||
autocomplete="off"
|
||
>
|
||
<p v-if="!filteredSearchLibrary.length" class="muted">No cards match “{{ searchFilter }}”.</p>
|
||
<div v-else class="search-library">
|
||
<button
|
||
v-for="card in filteredSearchLibrary"
|
||
:key="card.id"
|
||
type="button"
|
||
class="search-card"
|
||
:class="{ legal: searchLegalIds.has(card.id) }"
|
||
:disabled="!searchLegalIds.has(card.id) || busy"
|
||
:title="searchLegalIds.has(card.id) ? `Choose ${card.name}` : `${card.name} does not match this search`"
|
||
@click="chooseSearchCard(card)"
|
||
>
|
||
<CardHover :oracle-id="card.oracleId" :name="card.name">
|
||
<GameCard :oracle-id="card.oracleId" :name="card.name" />
|
||
</CardHover>
|
||
<span class="search-name">{{ card.name }}</span>
|
||
</button>
|
||
</div>
|
||
<p class="muted small">Cards that do not match this search are dimmed.</p>
|
||
</section>
|
||
</div>
|
||
</Teleport>
|
||
|
||
<Teleport to="body">
|
||
<template v-if="menuOpen">
|
||
<div class="menu-backdrop" @pointerdown="menuOpen = false" />
|
||
<div class="game-menu" role="menu" aria-label="Game menu">
|
||
<div class="game-menu-head">
|
||
<span class="tag" :class="connectionClass">{{ connection }}</span>
|
||
<span class="muted small">Connection</span>
|
||
</div>
|
||
<button type="button" role="menuitem" class="menu-item" @click="menuAction(copyLink)">
|
||
Copy link
|
||
</button>
|
||
<button
|
||
v-if="game"
|
||
type="button"
|
||
role="menuitem"
|
||
class="menu-item"
|
||
@click="menuAction(() => { showLog = !showLog })"
|
||
>{{ showLog ? 'Hide log' : 'Show log' }}</button>
|
||
<button
|
||
v-if="game"
|
||
type="button"
|
||
role="menuitem"
|
||
class="menu-item"
|
||
@click="menuAction(resetView)"
|
||
>Reset view</button>
|
||
<template v-if="token">
|
||
<div class="game-menu-divider" />
|
||
<button
|
||
type="button"
|
||
role="menuitem"
|
||
class="menu-item leave"
|
||
:disabled="busy"
|
||
@click="menuAction(leaveGame)"
|
||
>Forfeit</button>
|
||
</template>
|
||
</div>
|
||
</template>
|
||
</Teleport>
|
||
|
||
<Teleport to="body">
|
||
<template v-if="menuCard">
|
||
<div class="menu-backdrop" @pointerdown="closeMenu" />
|
||
<div
|
||
ref="menuEl"
|
||
class="context-menu"
|
||
role="menu"
|
||
:aria-label="`${menuCard.name} actions`"
|
||
:style="{ left: `${menu?.x ?? 0}px`, top: `${menu?.y ?? 0}px` }"
|
||
>
|
||
<button
|
||
v-for="ability in activatedAbilities(menuCard)"
|
||
:key="ability.index"
|
||
type="button"
|
||
role="menuitem"
|
||
class="menu-item"
|
||
:disabled="!canAct || busy"
|
||
@click="activateFromMenu(menuCard, ability)"
|
||
>
|
||
<SymbolText :text="ability.text || 'Activate'" />
|
||
</button>
|
||
</div>
|
||
</template>
|
||
</Teleport>
|
||
</main>
|
||
</template>
|
||
|
||
<style scoped>
|
||
.game-head {
|
||
display: flex;
|
||
align-items: start;
|
||
justify-content: space-between;
|
||
gap: 1rem;
|
||
}
|
||
|
||
.game-page {
|
||
position: relative;
|
||
padding: 0;
|
||
gap: 0;
|
||
overflow: hidden;
|
||
}
|
||
|
||
.game-page > .game-head {
|
||
position: absolute;
|
||
inset: 0 0 auto;
|
||
z-index: 40;
|
||
padding: 0.85rem 1rem 1.5rem;
|
||
background: linear-gradient(to bottom, rgb(15 17 23 / 94%), rgb(15 17 23 / 0%));
|
||
pointer-events: none;
|
||
}
|
||
|
||
.game-page > .game-head .row {
|
||
pointer-events: auto;
|
||
}
|
||
|
||
.game-page > .error,
|
||
.game-page > .ok,
|
||
.game-page > .winner {
|
||
position: absolute;
|
||
top: 4.6rem;
|
||
left: 1rem;
|
||
z-index: 41;
|
||
max-width: min(42rem, calc(100% - 2rem));
|
||
padding: 0.4rem 0.65rem;
|
||
border: 1px solid var(--line);
|
||
border-radius: 6px;
|
||
background: rgb(15 17 23 / 94%);
|
||
}
|
||
|
||
.turn-actions {
|
||
position: fixed;
|
||
right: 1.25rem;
|
||
bottom: 1rem;
|
||
z-index: 40;
|
||
display: flex;
|
||
align-items: center;
|
||
gap: 0.6rem;
|
||
}
|
||
|
||
.turn-button {
|
||
font-size: 1rem;
|
||
padding: 0.75rem 1.4rem;
|
||
border-radius: 10px;
|
||
background: var(--panel);
|
||
box-shadow: 0 8px 24px rgb(0 0 0 / 45%);
|
||
}
|
||
|
||
.turn-button.end {
|
||
font-size: 1.1rem;
|
||
font-weight: 700;
|
||
padding: 0.85rem 1.6rem;
|
||
border-color: var(--accent);
|
||
background: var(--accent);
|
||
color: #0b1020;
|
||
}
|
||
|
||
.turn-button.end:not(:disabled):hover {
|
||
filter: brightness(1.1);
|
||
}
|
||
|
||
.mini {
|
||
font-size: 0.75rem;
|
||
padding: 0.2rem 0.45rem;
|
||
}
|
||
|
||
.field {
|
||
display: flex;
|
||
flex-direction: column;
|
||
gap: 0.25rem;
|
||
}
|
||
|
||
.field select,
|
||
.field input {
|
||
width: 100%;
|
||
}
|
||
|
||
.join-panel {
|
||
max-width: 30rem;
|
||
}
|
||
|
||
.lobby-panel {
|
||
flex: 1;
|
||
align-items: center;
|
||
justify-content: center;
|
||
gap: 1.75rem;
|
||
padding: 2rem 1rem;
|
||
text-align: center;
|
||
background:
|
||
radial-gradient(ellipse at 50% 0%, rgb(122 162 247 / 10%), transparent 60%),
|
||
var(--panel);
|
||
}
|
||
|
||
.lobby-head {
|
||
display: flex;
|
||
flex-direction: column;
|
||
gap: 0.3rem;
|
||
}
|
||
|
||
.lobby-actions {
|
||
display: flex;
|
||
flex-wrap: wrap;
|
||
align-items: center;
|
||
justify-content: center;
|
||
gap: 0.75rem;
|
||
}
|
||
|
||
.lobby-deck select {
|
||
min-width: 14rem;
|
||
}
|
||
|
||
.lobby-seats {
|
||
display: flex;
|
||
flex-wrap: wrap;
|
||
justify-content: center;
|
||
gap: clamp(1rem, 3vw, 2rem);
|
||
width: 100%;
|
||
}
|
||
|
||
.lobby-seat {
|
||
width: clamp(9.5rem, 20vw, 14rem);
|
||
display: flex;
|
||
flex-direction: column;
|
||
align-items: center;
|
||
gap: 0.45rem;
|
||
}
|
||
|
||
.lobby-commander {
|
||
width: 100%;
|
||
transition: transform 160ms ease;
|
||
}
|
||
|
||
.lobby-seat:not(.empty):hover .lobby-commander {
|
||
transform: translateY(-4px);
|
||
}
|
||
|
||
.lobby-seat.self .lobby-commander {
|
||
border-radius: 6px;
|
||
outline: 2px solid var(--accent);
|
||
outline-offset: 3px;
|
||
}
|
||
|
||
.lobby-commander-empty {
|
||
display: grid;
|
||
place-items: center;
|
||
width: 100%;
|
||
aspect-ratio: 488 / 680;
|
||
border: 1px dashed var(--line);
|
||
border-radius: 6px;
|
||
background: rgb(17 21 29 / 45%);
|
||
color: var(--muted);
|
||
font-size: 2rem;
|
||
}
|
||
|
||
.lobby-commander-name {
|
||
font-size: 0.8rem;
|
||
color: var(--muted);
|
||
line-height: 1.2;
|
||
}
|
||
|
||
.lobby-badges {
|
||
display: flex;
|
||
gap: 0.3rem;
|
||
min-height: 1.3rem;
|
||
}
|
||
|
||
.game-layout {
|
||
position: absolute;
|
||
inset: 0;
|
||
min-height: 0;
|
||
overflow: hidden;
|
||
}
|
||
|
||
.players {
|
||
position: absolute;
|
||
inset: 0;
|
||
overflow: hidden;
|
||
cursor: grab;
|
||
user-select: none;
|
||
touch-action: none;
|
||
background:
|
||
radial-gradient(ellipse at 50% 0%, rgb(60 110 82 / 22%), transparent 65%),
|
||
#121c17;
|
||
}
|
||
|
||
.players.panning {
|
||
cursor: grabbing;
|
||
}
|
||
|
||
.table-canvas {
|
||
min-width: 180rem;
|
||
display: grid;
|
||
grid-template-columns: repeat(2, minmax(0, 1fr));
|
||
align-content: start;
|
||
gap: 1.5rem;
|
||
/* Always reserve the sidebar column so toggling panels never reflows the board. */
|
||
padding: 5rem 24rem 15rem 1rem;
|
||
transform-origin: 0 0;
|
||
will-change: transform;
|
||
}
|
||
|
||
.player {
|
||
gap: 0.5rem;
|
||
min-height: 50rem;
|
||
background: rgb(17 21 29 / 76%);
|
||
border-color: #2e4437;
|
||
}
|
||
|
||
.player.current {
|
||
border-color: var(--accent);
|
||
}
|
||
|
||
.player.attack-ready {
|
||
border-style: dashed;
|
||
border-color: var(--bad);
|
||
}
|
||
|
||
.player.drop-hover {
|
||
border-color: var(--bad);
|
||
box-shadow: inset 0 0 0 3px var(--bad), 0 0 24px rgb(224 122 122 / 35%);
|
||
}
|
||
|
||
.player.dead {
|
||
opacity: 0.6;
|
||
}
|
||
|
||
.player-head {
|
||
position: relative;
|
||
display: flex;
|
||
align-items: center;
|
||
flex-wrap: wrap;
|
||
gap: 0.4rem;
|
||
}
|
||
|
||
.player-head .mini.active {
|
||
border-color: var(--accent);
|
||
color: var(--accent);
|
||
}
|
||
|
||
.life {
|
||
display: inline-block;
|
||
font-size: 1.2rem;
|
||
font-weight: 700;
|
||
}
|
||
|
||
.player.anim-hit {
|
||
animation: player-hit 700ms ease-out;
|
||
}
|
||
|
||
.player.anim-heal {
|
||
animation: player-heal 700ms ease-out;
|
||
}
|
||
|
||
.life.life-hit {
|
||
animation: life-hit 700ms ease-out;
|
||
}
|
||
|
||
.life.life-heal {
|
||
animation: life-heal 700ms ease-out;
|
||
}
|
||
|
||
.float-text {
|
||
position: absolute;
|
||
top: -0.2rem;
|
||
left: 50%;
|
||
z-index: 35;
|
||
font-size: 1rem;
|
||
font-weight: 800;
|
||
line-height: 1;
|
||
pointer-events: none;
|
||
text-shadow: 0 1px 3px #000, 0 0 8px currentColor;
|
||
animation: float-up 1.05s ease-out forwards;
|
||
}
|
||
|
||
.float-text.damage {
|
||
color: var(--bad);
|
||
}
|
||
|
||
.float-text.heal {
|
||
color: var(--ok);
|
||
}
|
||
|
||
.player-float {
|
||
top: 0.15rem;
|
||
}
|
||
|
||
.card-float {
|
||
top: 22%;
|
||
font-size: 1.15rem;
|
||
transform: translateX(-50%);
|
||
}
|
||
|
||
@keyframes player-hit {
|
||
0%, 100% {
|
||
box-shadow: none;
|
||
}
|
||
18% {
|
||
box-shadow: inset 0 0 0 2px var(--bad), 0 0 26px rgb(224 122 122 / 55%);
|
||
}
|
||
55% {
|
||
box-shadow: inset 0 0 0 1px var(--bad), 0 0 12px rgb(224 122 122 / 30%);
|
||
}
|
||
}
|
||
|
||
@keyframes player-heal {
|
||
0%, 100% {
|
||
box-shadow: none;
|
||
}
|
||
18% {
|
||
box-shadow: inset 0 0 0 2px var(--ok), 0 0 26px rgb(125 211 160 / 45%);
|
||
}
|
||
55% {
|
||
box-shadow: inset 0 0 0 1px var(--ok), 0 0 12px rgb(125 211 160 / 25%);
|
||
}
|
||
}
|
||
|
||
@keyframes life-hit {
|
||
0%, 100% {
|
||
color: var(--text);
|
||
transform: scale(1);
|
||
}
|
||
28% {
|
||
color: var(--bad);
|
||
transform: scale(1.35);
|
||
}
|
||
}
|
||
|
||
@keyframes life-heal {
|
||
0%, 100% {
|
||
color: var(--text);
|
||
transform: scale(1);
|
||
}
|
||
28% {
|
||
color: var(--ok);
|
||
transform: scale(1.3);
|
||
}
|
||
}
|
||
|
||
@keyframes float-up {
|
||
0% {
|
||
opacity: 0;
|
||
transform: translate(-50%, 0.45rem) scale(0.75);
|
||
}
|
||
18% {
|
||
opacity: 1;
|
||
transform: translate(-50%, 0) scale(1.15);
|
||
}
|
||
72% {
|
||
opacity: 1;
|
||
}
|
||
100% {
|
||
opacity: 0;
|
||
transform: translate(-50%, -1.5rem) scale(0.95);
|
||
}
|
||
}
|
||
|
||
.damage {
|
||
display: flex;
|
||
flex-wrap: wrap;
|
||
gap: 0.3rem;
|
||
}
|
||
|
||
.play-area {
|
||
flex: 1;
|
||
display: flex;
|
||
align-items: stretch;
|
||
gap: 0.6rem;
|
||
min-height: 0;
|
||
}
|
||
|
||
.play-area.command-right {
|
||
flex-direction: row-reverse;
|
||
}
|
||
|
||
.zone {
|
||
display: flex;
|
||
flex-direction: column;
|
||
align-items: stretch;
|
||
gap: 0.25rem;
|
||
border: 1px dashed var(--line);
|
||
border-radius: 6px;
|
||
padding: 0.3rem;
|
||
}
|
||
|
||
.side-zones {
|
||
display: flex;
|
||
flex-direction: column;
|
||
gap: 0.4rem;
|
||
flex: 0 0 7rem;
|
||
}
|
||
|
||
.graveyard-stack {
|
||
display: flex;
|
||
flex-direction: column;
|
||
align-items: stretch;
|
||
}
|
||
|
||
/* overlap card faces into a pile; the last (newest) card sits on top */
|
||
.graveyard-stack > * {
|
||
margin-top: -122%;
|
||
}
|
||
|
||
.graveyard-stack > :first-child {
|
||
margin-top: 0;
|
||
}
|
||
|
||
.library-stack {
|
||
position: relative;
|
||
width: 100%;
|
||
aspect-ratio: 488 / 680;
|
||
}
|
||
|
||
.library-back {
|
||
position: absolute;
|
||
inset: 0;
|
||
border: 1px solid #3a4660;
|
||
border-radius: 6px;
|
||
background-color: var(--card-back-color, #26304a);
|
||
background-image: var(--card-back-image, none);
|
||
background-position: center;
|
||
background-size: cover;
|
||
box-shadow: 0 3px 10px rgb(0 0 0 / 45%);
|
||
}
|
||
|
||
/* Offset the back layers down-right to read as a pile. */
|
||
.library-back:nth-child(1) { z-index: 3; }
|
||
.library-back:nth-child(2) { z-index: 2; translate: 3px 3px; }
|
||
.library-back:nth-child(3) { z-index: 1; translate: 6px 6px; }
|
||
|
||
.zone-label {
|
||
font-size: 0.7rem;
|
||
text-align: center;
|
||
text-transform: uppercase;
|
||
letter-spacing: 0.04em;
|
||
color: var(--muted);
|
||
}
|
||
|
||
.command-card {
|
||
width: 100%;
|
||
display: flex;
|
||
flex-direction: column;
|
||
align-items: stretch;
|
||
gap: 0.25rem;
|
||
font-size: 0.7rem;
|
||
}
|
||
|
||
.battlefield {
|
||
--perm-width: 7rem;
|
||
position: relative;
|
||
flex: 1;
|
||
display: grid;
|
||
grid-template-columns: repeat(auto-fill, minmax(var(--perm-width), 1fr));
|
||
align-content: start;
|
||
gap: 0.5rem;
|
||
min-height: 40rem;
|
||
padding: 0.4rem;
|
||
border: 1px solid transparent;
|
||
border-radius: 8px;
|
||
background-position: center;
|
||
background-size: cover;
|
||
}
|
||
|
||
.battlefield.has-playmat {
|
||
border-color: #2e4437;
|
||
background-image:
|
||
linear-gradient(rgb(8 10 14 / 48%), rgb(8 10 14 / 48%)),
|
||
var(--playmat);
|
||
}
|
||
|
||
.perm {
|
||
position: relative;
|
||
display: flex;
|
||
flex-direction: column;
|
||
gap: 0.25rem;
|
||
min-width: 0;
|
||
cursor: pointer;
|
||
}
|
||
|
||
.perm.anim-enter .game-card {
|
||
animation: perm-enter 520ms cubic-bezier(0.2, 0.8, 0.2, 1);
|
||
}
|
||
|
||
.perm.anim-damage .game-card {
|
||
animation: perm-damage 500ms ease-in-out;
|
||
}
|
||
|
||
.perm.anim-attack .game-card {
|
||
animation: perm-attack 540ms cubic-bezier(0.2, 0.8, 0.2, 1);
|
||
}
|
||
|
||
@keyframes perm-enter {
|
||
0% {
|
||
opacity: 0;
|
||
filter: brightness(1.8);
|
||
transform: translateY(-1.6rem) scale(0.65) rotate(-5deg);
|
||
}
|
||
65% {
|
||
opacity: 1;
|
||
filter: brightness(1.15);
|
||
transform: translateY(0.15rem) scale(1.04) rotate(1deg);
|
||
}
|
||
100% {
|
||
opacity: 1;
|
||
filter: none;
|
||
transform: none;
|
||
}
|
||
}
|
||
|
||
@keyframes perm-damage {
|
||
0%, 100% {
|
||
filter: none;
|
||
transform: translateX(0);
|
||
}
|
||
16% {
|
||
filter: brightness(1.5) drop-shadow(0 0 0.5rem var(--bad));
|
||
transform: translateX(-0.32rem) rotate(-1deg);
|
||
}
|
||
38% {
|
||
transform: translateX(0.3rem) rotate(1deg);
|
||
}
|
||
60% {
|
||
transform: translateX(-0.2rem);
|
||
}
|
||
80% {
|
||
transform: translateX(0.12rem);
|
||
}
|
||
}
|
||
|
||
@keyframes perm-attack {
|
||
0%, 100% {
|
||
filter: none;
|
||
transform: translateY(0) scale(1);
|
||
}
|
||
42% {
|
||
filter: brightness(1.25) drop-shadow(0 0 0.5rem var(--bad));
|
||
transform: translateY(-0.45rem) scale(1.06);
|
||
}
|
||
}
|
||
|
||
.perm.movable {
|
||
cursor: grab;
|
||
}
|
||
|
||
.perm.positioned {
|
||
position: absolute;
|
||
width: var(--perm-width);
|
||
z-index: 3;
|
||
transform: translate(-50%, -50%);
|
||
transition: left 120ms ease, top 120ms ease;
|
||
}
|
||
|
||
.perm.dragging {
|
||
z-index: 20;
|
||
cursor: grabbing;
|
||
transition: none;
|
||
}
|
||
|
||
.perm.selected .game-card,
|
||
.perm:focus-visible .game-card {
|
||
border-radius: 6px;
|
||
outline: 2px solid var(--accent);
|
||
outline-offset: 2px;
|
||
}
|
||
|
||
.perm.pending-attack .game-card {
|
||
border-radius: 6px;
|
||
outline: 2px solid var(--bad);
|
||
outline-offset: 2px;
|
||
}
|
||
|
||
.perm:focus-visible {
|
||
outline: none;
|
||
}
|
||
|
||
.stats {
|
||
position: absolute;
|
||
right: 0.2rem;
|
||
bottom: 0.2rem;
|
||
z-index: 2;
|
||
padding: 0 0.25rem;
|
||
border: 1px solid var(--line);
|
||
border-radius: 4px;
|
||
background: rgb(8 10 14 / 84%);
|
||
font-size: 0.72rem;
|
||
font-weight: 700;
|
||
color: var(--warn);
|
||
white-space: nowrap;
|
||
}
|
||
|
||
.overlay-tag {
|
||
position: absolute;
|
||
z-index: 2;
|
||
padding: 0 0.3rem;
|
||
border: 1px solid var(--line);
|
||
border-radius: 4px;
|
||
background: rgb(8 10 14 / 84%);
|
||
font-size: 0.6rem;
|
||
line-height: 1.4;
|
||
white-space: nowrap;
|
||
}
|
||
|
||
.overlay-tag.commander {
|
||
top: 0.2rem;
|
||
left: 0.2rem;
|
||
color: var(--warn);
|
||
}
|
||
|
||
.overlay-tag.chosen {
|
||
bottom: 0.2rem;
|
||
left: 50%;
|
||
transform: translateX(-50%);
|
||
max-width: 80%;
|
||
overflow: hidden;
|
||
text-overflow: ellipsis;
|
||
color: var(--accent);
|
||
}
|
||
|
||
.overlay-tag.attacking {
|
||
top: 0.2rem;
|
||
right: 0.2rem;
|
||
color: var(--bad);
|
||
}
|
||
|
||
.overlay-tag.card-damage {
|
||
top: 0.2rem;
|
||
left: 50%;
|
||
transform: translateX(-50%);
|
||
color: var(--bad);
|
||
}
|
||
|
||
.overlay-counters {
|
||
position: absolute;
|
||
left: 0.2rem;
|
||
bottom: 0.2rem;
|
||
z-index: 2;
|
||
display: flex;
|
||
flex-direction: column;
|
||
align-items: flex-start;
|
||
gap: 0.15rem;
|
||
}
|
||
|
||
.overlay-counters .overlay-tag {
|
||
position: static;
|
||
}
|
||
|
||
.menu-backdrop {
|
||
position: fixed;
|
||
inset: 0;
|
||
z-index: 60;
|
||
}
|
||
|
||
.hamburger {
|
||
font-size: 1rem;
|
||
line-height: 1;
|
||
padding: 0.3rem 0.55rem;
|
||
}
|
||
|
||
.game-menu {
|
||
position: fixed;
|
||
top: 3.5rem;
|
||
right: 1rem;
|
||
z-index: 61;
|
||
display: flex;
|
||
flex-direction: column;
|
||
gap: 0.1rem;
|
||
min-width: 12rem;
|
||
padding: 0.3rem;
|
||
border: 1px solid var(--line);
|
||
border-radius: 8px;
|
||
background: var(--panel);
|
||
box-shadow: 0 12px 28px rgb(0 0 0 / 55%);
|
||
}
|
||
|
||
.game-menu-head {
|
||
display: flex;
|
||
align-items: center;
|
||
gap: 0.4rem;
|
||
padding: 0.3rem 0.5rem 0.45rem;
|
||
}
|
||
|
||
.game-menu-divider {
|
||
height: 1px;
|
||
margin: 0.3rem 0.2rem;
|
||
background: var(--line);
|
||
}
|
||
|
||
.menu-item.leave {
|
||
color: var(--bad);
|
||
}
|
||
|
||
.context-menu {
|
||
position: fixed;
|
||
z-index: 61;
|
||
display: flex;
|
||
flex-direction: column;
|
||
gap: 0.1rem;
|
||
width: 16rem;
|
||
max-width: calc(100vw - 1rem);
|
||
padding: 0.3rem;
|
||
border: 1px solid var(--line);
|
||
border-radius: 8px;
|
||
background: var(--panel);
|
||
box-shadow: 0 12px 28px rgb(0 0 0 / 55%);
|
||
}
|
||
|
||
.menu-item {
|
||
padding: 0.4rem 0.5rem;
|
||
border: 0;
|
||
border-radius: 5px;
|
||
background: transparent;
|
||
text-align: left;
|
||
font-size: 0.8rem;
|
||
line-height: 1.35;
|
||
}
|
||
|
||
.menu-item:not(:disabled):hover {
|
||
border-color: transparent;
|
||
background: var(--panel-2);
|
||
}
|
||
|
||
.small {
|
||
font-size: 0.72rem;
|
||
}
|
||
|
||
.zone-bar {
|
||
display: flex;
|
||
align-items: center;
|
||
gap: 0.3rem;
|
||
}
|
||
|
||
.zone-link {
|
||
padding: 0;
|
||
border: 0;
|
||
background: none;
|
||
color: inherit;
|
||
text-decoration: underline dotted;
|
||
text-underline-offset: 0.2em;
|
||
}
|
||
|
||
.zone-link.active {
|
||
color: var(--accent);
|
||
}
|
||
|
||
.zone-cards {
|
||
display: grid;
|
||
grid-template-columns: repeat(auto-fill, minmax(6.5rem, 1fr));
|
||
gap: 0.5rem;
|
||
}
|
||
|
||
.sidebar {
|
||
position: absolute;
|
||
top: 4.6rem;
|
||
right: 0.75rem;
|
||
z-index: 20;
|
||
display: flex;
|
||
flex-direction: column;
|
||
gap: 0.75rem;
|
||
width: min(22rem, calc(100% - 1.5rem));
|
||
max-height: calc(100% - 5.35rem);
|
||
overflow-y: auto;
|
||
}
|
||
|
||
.side {
|
||
flex-shrink: 0;
|
||
}
|
||
|
||
.cast-panel .oracle {
|
||
max-height: 8rem;
|
||
overflow-y: auto;
|
||
}
|
||
|
||
.search-backdrop {
|
||
position: fixed;
|
||
inset: 0;
|
||
z-index: 70;
|
||
display: grid;
|
||
place-items: center;
|
||
padding: 1rem;
|
||
background: rgb(0 0 0 / 65%);
|
||
}
|
||
|
||
.search-modal {
|
||
display: flex;
|
||
flex-direction: column;
|
||
gap: 0.75rem;
|
||
width: min(60rem, 100%);
|
||
max-height: calc(100vh - 2rem);
|
||
padding: 1rem;
|
||
background: var(--panel);
|
||
border: 1px solid var(--line);
|
||
border-radius: 12px;
|
||
}
|
||
|
||
.search-head {
|
||
display: flex;
|
||
align-items: flex-start;
|
||
gap: 0.75rem;
|
||
}
|
||
|
||
.search-head h2,
|
||
.search-head p {
|
||
margin: 0;
|
||
}
|
||
|
||
.search-filter {
|
||
width: 100%;
|
||
flex: 0 0 auto;
|
||
}
|
||
|
||
.search-library {
|
||
display: grid;
|
||
grid-template-columns: repeat(auto-fill, minmax(6.2rem, 1fr));
|
||
gap: 0.5rem;
|
||
min-height: 0;
|
||
flex: 1 1 auto;
|
||
overflow-y: auto;
|
||
}
|
||
|
||
.search-card {
|
||
display: flex;
|
||
flex-direction: column;
|
||
gap: 0.25rem;
|
||
padding: 0.25rem;
|
||
border-color: transparent;
|
||
opacity: 0.35;
|
||
text-align: center;
|
||
}
|
||
|
||
.search-card.legal {
|
||
border-color: var(--line);
|
||
opacity: 1;
|
||
}
|
||
|
||
.search-card.legal:hover:not(:disabled) {
|
||
border-color: var(--accent);
|
||
}
|
||
|
||
.search-card:disabled {
|
||
cursor: not-allowed;
|
||
}
|
||
|
||
.search-name {
|
||
overflow: hidden;
|
||
font-size: 0.72rem;
|
||
text-overflow: ellipsis;
|
||
white-space: nowrap;
|
||
}
|
||
|
||
.choice-grid {
|
||
display: grid;
|
||
grid-template-columns: repeat(auto-fill, minmax(7rem, 1fr));
|
||
gap: 0.35rem;
|
||
min-height: 0;
|
||
flex: 1 1 auto;
|
||
overflow-y: auto;
|
||
}
|
||
|
||
.choice-option {
|
||
font-size: 0.78rem;
|
||
}
|
||
|
||
.attack-list {
|
||
display: flex;
|
||
flex-direction: column;
|
||
gap: 0.3rem;
|
||
}
|
||
|
||
.attack-pick {
|
||
display: flex;
|
||
align-items: center;
|
||
justify-content: space-between;
|
||
gap: 0.5rem;
|
||
width: 100%;
|
||
font-size: 0.8rem;
|
||
text-align: left;
|
||
}
|
||
|
||
.attack-pick:hover {
|
||
border-color: var(--bad);
|
||
}
|
||
|
||
.block-row {
|
||
display: flex;
|
||
flex-direction: column;
|
||
gap: 0.2rem;
|
||
font-size: 0.85rem;
|
||
}
|
||
|
||
.hand-panel {
|
||
position: absolute;
|
||
bottom: 0;
|
||
left: 50%;
|
||
z-index: 25;
|
||
display: flex;
|
||
flex-direction: column;
|
||
gap: 0.25rem;
|
||
width: min(100%, 60rem);
|
||
padding: 0 0.5rem;
|
||
font-size: 1rem;
|
||
pointer-events: none;
|
||
transform: translateX(-50%);
|
||
}
|
||
|
||
.hand-head {
|
||
justify-content: center;
|
||
padding: 0 0.25rem;
|
||
pointer-events: auto;
|
||
}
|
||
|
||
.hand-head h2 {
|
||
font-size: 0.95rem;
|
||
white-space: nowrap;
|
||
}
|
||
|
||
.mana-row {
|
||
display: flex;
|
||
flex-wrap: wrap;
|
||
gap: 0.25rem;
|
||
}
|
||
|
||
.mana-burst {
|
||
display: inline-flex;
|
||
align-items: center;
|
||
gap: 0.1rem;
|
||
font-size: 0.85rem;
|
||
font-weight: 700;
|
||
text-shadow: 0 0 8px currentColor;
|
||
animation: mana-burst 1.05s ease-out forwards;
|
||
}
|
||
|
||
@keyframes mana-burst {
|
||
0% {
|
||
opacity: 0;
|
||
transform: translateY(0.45rem) scale(0.7);
|
||
}
|
||
20% {
|
||
opacity: 1;
|
||
transform: translateY(0) scale(1.12);
|
||
}
|
||
70% {
|
||
opacity: 1;
|
||
transform: translateY(-0.2rem) scale(1);
|
||
}
|
||
100% {
|
||
opacity: 0;
|
||
transform: translateY(-0.8rem) scale(0.95);
|
||
}
|
||
}
|
||
|
||
.hand-fan {
|
||
position: relative;
|
||
height: 12em;
|
||
pointer-events: none;
|
||
}
|
||
|
||
.hand-card {
|
||
position: absolute;
|
||
bottom: 3em;
|
||
left: 50%;
|
||
width: 6.5em;
|
||
user-select: none;
|
||
pointer-events: auto;
|
||
transition: transform 260ms cubic-bezier(0.2, 0.8, 0.2, 1);
|
||
will-change: transform;
|
||
}
|
||
|
||
.hand-card.playable {
|
||
cursor: pointer;
|
||
}
|
||
|
||
.hand-card:hover,
|
||
.hand-card:focus-within {
|
||
z-index: 30;
|
||
}
|
||
|
||
.hand-lift {
|
||
position: relative;
|
||
display: flex;
|
||
flex-direction: column;
|
||
transform-origin: 50% 100%;
|
||
transition: transform 180ms cubic-bezier(0.2, 0.9, 0.3, 1.15), filter 180ms ease;
|
||
}
|
||
|
||
.hand-card:hover .hand-lift,
|
||
.hand-card:focus-within .hand-lift {
|
||
transform: translateY(-3.25em) rotate(calc(var(--angle, 0deg) * -1)) scale(1.08);
|
||
filter: drop-shadow(0 14px 22px rgb(0 0 0 / 55%));
|
||
}
|
||
|
||
.hand-card.playable:hover .hand-lift,
|
||
.hand-card.playable:focus-within .hand-lift {
|
||
outline: 2px solid var(--accent);
|
||
outline-offset: 2px;
|
||
border-radius: 8px;
|
||
}
|
||
|
||
.hand-card.unplayable {
|
||
filter: grayscale(1);
|
||
opacity: 0.45;
|
||
}
|
||
|
||
.hand-options {
|
||
position: absolute;
|
||
bottom: 0.4em;
|
||
left: 50%;
|
||
z-index: 3;
|
||
transform: translateX(-50%);
|
||
white-space: nowrap;
|
||
}
|
||
|
||
@media (hover: hover) {
|
||
.hand-options {
|
||
opacity: 0;
|
||
pointer-events: none;
|
||
transition: opacity 120ms ease;
|
||
}
|
||
|
||
.hand-card:hover .hand-options,
|
||
.hand-card:focus-within .hand-options {
|
||
opacity: 1;
|
||
pointer-events: auto;
|
||
}
|
||
}
|
||
|
||
.hand-leave-active {
|
||
pointer-events: none;
|
||
}
|
||
|
||
.hand-enter-active .hand-lift,
|
||
.hand-leave-active .hand-lift {
|
||
transition: transform 220ms cubic-bezier(0.2, 0.8, 0.2, 1), opacity 180ms ease;
|
||
}
|
||
|
||
.hand-enter-from .hand-lift,
|
||
.hand-leave-to .hand-lift {
|
||
opacity: 0;
|
||
transform: translateY(2.5em) scale(0.7);
|
||
}
|
||
|
||
.stack-pile {
|
||
position: absolute;
|
||
top: 5rem;
|
||
right: 24rem;
|
||
z-index: 22;
|
||
display: flex;
|
||
flex-direction: column;
|
||
gap: 0.35rem;
|
||
width: min(15rem, calc(100% - 2rem));
|
||
pointer-events: none;
|
||
transition: opacity 160ms ease;
|
||
}
|
||
|
||
.stack-pile.empty {
|
||
opacity: 0;
|
||
}
|
||
|
||
.stack-heading {
|
||
display: flex;
|
||
gap: 0.4rem;
|
||
align-items: baseline;
|
||
margin: 0;
|
||
font-size: 0.72rem;
|
||
letter-spacing: 0.08em;
|
||
text-transform: uppercase;
|
||
color: var(--muted);
|
||
}
|
||
|
||
.stack-pile-list {
|
||
list-style: none;
|
||
margin: 0;
|
||
padding: 0;
|
||
display: flex;
|
||
flex-direction: column;
|
||
}
|
||
|
||
.stack-pile-list > li + li {
|
||
margin-top: -2.9rem;
|
||
}
|
||
|
||
.stack-card {
|
||
display: flex;
|
||
align-items: center;
|
||
gap: 0.5rem;
|
||
min-height: 4.4rem;
|
||
padding: 0.5rem 0.65rem;
|
||
border: 1px solid #3c4d64;
|
||
border-left: 3px solid var(--accent);
|
||
border-radius: 8px;
|
||
background: #141a24;
|
||
box-shadow: 0 8px 18px rgb(0 0 0 / 50%);
|
||
transition: transform 260ms cubic-bezier(0.2, 0.8, 0.2, 1), box-shadow 220ms ease;
|
||
}
|
||
|
||
.stack-card.kind-ability {
|
||
border-left-color: #c9a86a;
|
||
}
|
||
|
||
.stack-card.is-top {
|
||
border-color: rgb(122 162 247 / 65%);
|
||
box-shadow:
|
||
0 0 0 1px rgb(122 162 247 / 25%),
|
||
0 0 20px rgb(122 162 247 / 25%),
|
||
0 10px 24px rgb(0 0 0 / 55%);
|
||
}
|
||
|
||
.stack-card.kind-ability.is-top {
|
||
border-color: rgb(201 168 106 / 60%);
|
||
box-shadow:
|
||
0 0 0 1px rgb(201 168 106 / 22%),
|
||
0 0 20px rgb(201 168 106 / 20%),
|
||
0 10px 24px rgb(0 0 0 / 55%);
|
||
}
|
||
|
||
.stack-glyph {
|
||
flex: 0 0 auto;
|
||
font-size: 1.05rem;
|
||
color: var(--accent);
|
||
}
|
||
|
||
.kind-ability .stack-glyph {
|
||
color: #c9a86a;
|
||
}
|
||
|
||
.stack-copy {
|
||
display: flex;
|
||
flex-direction: column;
|
||
gap: 0.1rem;
|
||
min-width: 0;
|
||
line-height: 1.2;
|
||
}
|
||
|
||
.stack-copy strong {
|
||
display: -webkit-box;
|
||
overflow: hidden;
|
||
font-size: 0.8rem;
|
||
-webkit-box-orient: vertical;
|
||
-webkit-line-clamp: 2;
|
||
}
|
||
|
||
.stack-copy .muted {
|
||
overflow: hidden;
|
||
font-size: 0.68rem;
|
||
text-overflow: ellipsis;
|
||
white-space: nowrap;
|
||
}
|
||
|
||
.stack-enter-active {
|
||
transition: transform 300ms cubic-bezier(0.2, 0.9, 0.25, 1.15), opacity 200ms ease, filter 300ms ease;
|
||
}
|
||
|
||
.stack-leave-active {
|
||
transition: transform 200ms ease-in, opacity 180ms ease-in;
|
||
}
|
||
|
||
.stack-enter-from {
|
||
opacity: 0;
|
||
filter: brightness(1.9);
|
||
transform: translate(4rem, -1.2rem) rotate(6deg) scale(0.82);
|
||
}
|
||
|
||
.stack-leave-to {
|
||
opacity: 0;
|
||
transform: translate(3rem, -0.8rem) rotate(3deg) scale(0.9);
|
||
}
|
||
|
||
.stack-move {
|
||
transition: transform 280ms cubic-bezier(0.2, 0.8, 0.2, 1);
|
||
}
|
||
|
||
.log-panel {
|
||
max-height: 16rem;
|
||
}
|
||
|
||
.log-list {
|
||
list-style: none;
|
||
margin: 0;
|
||
padding: 0;
|
||
display: flex;
|
||
flex-direction: column;
|
||
gap: 0.2rem;
|
||
font-size: 0.78rem;
|
||
color: var(--muted);
|
||
overflow-y: auto;
|
||
}
|
||
|
||
.winner {
|
||
font-size: 1.1rem;
|
||
color: var(--ok);
|
||
display: flex;
|
||
gap: 0.75rem;
|
||
align-items: center;
|
||
}
|
||
|
||
@media (prefers-reduced-motion: reduce) {
|
||
.perm.anim-enter .game-card,
|
||
.perm.anim-damage .game-card,
|
||
.perm.anim-attack .game-card,
|
||
.player.anim-hit,
|
||
.player.anim-heal,
|
||
.life.life-hit,
|
||
.life.life-heal,
|
||
.float-text,
|
||
.mana-burst {
|
||
animation: none;
|
||
}
|
||
|
||
.stack-enter-active,
|
||
.stack-leave-active,
|
||
.stack-move {
|
||
transition: none;
|
||
}
|
||
}
|
||
|
||
@media (max-width: 1000px) {
|
||
.game-page {
|
||
height: auto;
|
||
min-height: calc(100vh - 3rem);
|
||
padding: 1rem 1.25rem 5.5rem;
|
||
gap: 1rem;
|
||
overflow: visible;
|
||
}
|
||
|
||
.game-page > .game-head {
|
||
position: static;
|
||
padding: 0;
|
||
background: none;
|
||
pointer-events: auto;
|
||
}
|
||
|
||
.game-page > .error,
|
||
.game-page > .ok,
|
||
.game-page > .winner {
|
||
position: static;
|
||
max-width: none;
|
||
padding: 0;
|
||
border: 0;
|
||
background: none;
|
||
}
|
||
|
||
.game-layout {
|
||
position: relative;
|
||
inset: auto;
|
||
display: flex;
|
||
flex-direction: column;
|
||
gap: 0.75rem;
|
||
overflow: visible;
|
||
}
|
||
|
||
.players {
|
||
position: relative;
|
||
inset: auto;
|
||
min-height: 24rem;
|
||
overflow: visible;
|
||
border: 1px solid #24372c;
|
||
border-radius: 12px;
|
||
cursor: auto;
|
||
touch-action: auto;
|
||
}
|
||
|
||
.table-canvas {
|
||
min-width: 0;
|
||
grid-template-columns: 1fr;
|
||
padding: 0.6rem;
|
||
transform: none !important;
|
||
}
|
||
|
||
.player {
|
||
min-height: 32rem;
|
||
}
|
||
|
||
.battlefield {
|
||
--perm-width: 6rem;
|
||
min-height: 24rem;
|
||
}
|
||
|
||
.side-zones {
|
||
flex-basis: 6rem;
|
||
}
|
||
|
||
.sidebar {
|
||
position: static;
|
||
width: auto;
|
||
max-height: none;
|
||
overflow: visible;
|
||
}
|
||
|
||
.stack-pile {
|
||
position: static;
|
||
width: auto;
|
||
}
|
||
|
||
.stack-pile.empty {
|
||
display: none;
|
||
}
|
||
|
||
.hand-panel {
|
||
position: static;
|
||
width: auto;
|
||
padding: 0;
|
||
pointer-events: auto;
|
||
transform: none;
|
||
}
|
||
}
|
||
|
||
@media (max-width: 700px) {
|
||
.hand-panel {
|
||
font-size: 0.78rem;
|
||
}
|
||
}
|
||
|
||
@media (max-width: 480px) {
|
||
.hand-panel {
|
||
font-size: 0.62rem;
|
||
}
|
||
}
|
||
</style>
|