/* ============================
   Custom Fonts
   ============================ */
@font-face {
    font-family: 'Belwe';
    src: url('../assets/fonts/belwestd-bold.otf') format('opentype');
    font-weight: bold;
    font-style: normal;
}

/* ============================
   CSS Variables / Theme
   ============================ */
:root {
    --bg-dark: #1a1a2e;
    --bg-darker: #0f0f1a;
    --bg-card: #2d2d44;
    --bg-hover: #3d3d5c;

    --gold: #ffd700;
    --gold-dark: #b8860b;
    --blue: #4a9eff;
    --blue-dark: #2d7dd2;
    --green: #4caf50;
    --red: #f44336;
    --purple: #9c27b0;

    --text-primary: #ffffff;
    --text-secondary: #b0b0c0;
    --text-muted: #707080;

    --border-color: #404060;
    --border-gold: #b8860b;

    --card-width: 80px;
    --card-height: 110px;
    --minion-size: 90px;
    --hero-size: 100px;

    --font-title: 'Cinzel', serif;
    --font-body: 'Open Sans', sans-serif;

    --transition-fast: 0.15s ease;
    --transition-normal: 0.3s ease;
}

/* ============================
   Reset & Base
   ============================ */
* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

html, body {
    height: 100%;
    overflow: hidden;
}

body {
    font-family: var(--font-body);
    background: linear-gradient(135deg, var(--bg-darker) 0%, var(--bg-dark) 100%);
    color: var(--text-primary);
}

#app {
    width: 100%;
    height: 100%;
    position: relative;
}

/* ============================
   Screens
   ============================ */
.screen {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    display: none;
    justify-content: center;
    align-items: center;
}

.screen.active {
    display: flex;
}

/* ============================
   Buttons
   ============================ */
.btn {
    padding: 12px 32px;
    font-family: var(--font-title);
    font-size: 16px;
    font-weight: 600;
    border: none;
    border-radius: 8px;
    cursor: pointer;
    transition: all var(--transition-fast);
    text-transform: uppercase;
    letter-spacing: 1px;
}

.btn:disabled {
    opacity: 0.5;
    cursor: not-allowed;
}

.btn-primary {
    background: linear-gradient(180deg, var(--gold) 0%, var(--gold-dark) 100%);
    color: var(--bg-darker);
    box-shadow: 0 4px 15px rgba(255, 215, 0, 0.3);
}

.btn-primary:hover:not(:disabled) {
    transform: translateY(-2px);
    box-shadow: 0 6px 20px rgba(255, 215, 0, 0.4);
}

.btn-secondary {
    background: linear-gradient(180deg, var(--blue) 0%, var(--blue-dark) 100%);
    color: white;
    box-shadow: 0 4px 15px rgba(74, 158, 255, 0.3);
}

.btn-secondary:hover:not(:disabled) {
    transform: translateY(-2px);
    box-shadow: 0 6px 20px rgba(74, 158, 255, 0.4);
}

.btn-text {
    background: transparent;
    color: var(--text-secondary);
    padding: 8px 16px;
}

.btn-text:hover {
    color: var(--text-primary);
}

.btn-small {
    padding: 6px 12px;
    font-size: 12px;
}

/* ============================
   Menu Screen
   ============================ */
.menu-container {
    text-align: center;
}

.game-title {
    font-family: var(--font-title);
    font-size: 64px;
    color: var(--gold);
    text-shadow: 0 4px 20px rgba(255, 215, 0, 0.5);
    margin-bottom: 60px;
}

.menu-buttons {
    display: flex;
    flex-direction: column;
    gap: 20px;
}

/* ============================
   Form Screens
   ============================ */
.form-container {
    background: var(--bg-card);
    padding: 40px;
    border-radius: 16px;
    border: 2px solid var(--border-color);
    width: 100%;
    max-width: 500px;
}

.form-container h2 {
    font-family: var(--font-title);
    color: var(--gold);
    margin-bottom: 30px;
    text-align: center;
}

.form-group {
    margin-bottom: 24px;
}

.form-group label {
    display: block;
    margin-bottom: 8px;
    color: var(--text-secondary);
    font-size: 14px;
}

.form-group input {
    width: 100%;
    padding: 12px 16px;
    background: var(--bg-darker);
    border: 2px solid var(--border-color);
    border-radius: 8px;
    color: var(--text-primary);
    font-size: 16px;
    font-family: var(--font-body);
    transition: border-color var(--transition-fast);
}

.form-group input:focus {
    outline: none;
    border-color: var(--gold);
}

.form-group input::placeholder {
    color: var(--text-muted);
}

.form-actions {
    display: flex;
    flex-direction: column;
    gap: 12px;
    align-items: center;
    margin-top: 30px;
}

/* ============================
   Class Selector
   ============================ */
.class-selector {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 10px;
}

.class-btn {
    padding: 12px 8px;
    background: var(--bg-darker);
    border: 2px solid var(--border-color);
    border-radius: 8px;
    color: var(--text-secondary);
    font-size: 12px;
    font-weight: 600;
    cursor: pointer;
    transition: all var(--transition-fast);
    text-transform: uppercase;
}

.class-btn:hover {
    border-color: var(--gold);
    color: var(--text-primary);
}

.class-btn.selected {
    border-color: var(--gold);
    background: rgba(255, 215, 0, 0.1);
    color: var(--gold);
}

/* Class-specific colors */
.class-btn[data-class="DRUID"] { --class-color: #ff7d0a; }
.class-btn[data-class="HUNTER"] { --class-color: #abd473; }
.class-btn[data-class="MAGE"] { --class-color: #69ccf0; }
.class-btn[data-class="PALADIN"] { --class-color: #f58cba; }
.class-btn[data-class="PRIEST"] { --class-color: #ffffff; }
.class-btn[data-class="ROGUE"] { --class-color: #fff569; }
.class-btn[data-class="SHAMAN"] { --class-color: #0070de; }
.class-btn[data-class="WARLOCK"] { --class-color: #9482c9; }
.class-btn[data-class="WARRIOR"] { --class-color: #c79c6e; }

.class-btn.selected {
    border-color: var(--class-color, var(--gold));
    color: var(--class-color, var(--gold));
}

/* ============================
   Lobby Screen
   ============================ */
.lobby-container {
    background: var(--bg-card);
    padding: 40px;
    border-radius: 16px;
    border: 2px solid var(--border-color);
    width: 100%;
    max-width: 500px;
    text-align: center;
}

.lobby-container h2 {
    font-family: var(--font-title);
    color: var(--gold);
    margin-bottom: 30px;
}

.game-code-display {
    background: var(--bg-darker);
    padding: 20px;
    border-radius: 8px;
    margin-bottom: 30px;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 15px;
}

.game-code-display .code {
    font-family: monospace;
    font-size: 32px;
    font-weight: bold;
    color: var(--gold);
    letter-spacing: 4px;
}

.players-list {
    margin-bottom: 30px;
}

.player-slot {
    background: var(--bg-darker);
    padding: 20px;
    border-radius: 8px;
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.player-slot .player-name {
    font-weight: 600;
    font-size: 18px;
}

.player-slot .player-class {
    color: var(--text-secondary);
    font-size: 14px;
}

.player-slot.ready .player-name {
    color: var(--green);
}

.host-badge {
    background: var(--gold);
    color: var(--bg-darker);
    padding: 4px 8px;
    border-radius: 4px;
    font-size: 10px;
    font-weight: bold;
}

.vs-divider {
    font-family: var(--font-title);
    font-size: 24px;
    color: var(--text-muted);
    margin: 20px 0;
}

.lobby-actions {
    display: flex;
    flex-direction: column;
    gap: 12px;
    align-items: center;
}

.status-message {
    margin-top: 20px;
    color: var(--text-secondary);
    font-size: 14px;
}

/* ============================
   Game Board - Pygame Replica
   ============================ */

/* Game screen container - centers the 16:9 game board */
#game-screen.active {
    background: #000;  /* Black letterbox/pillarbox bars */
    display: flex;
    justify-content: center;
    align-items: center;
}

/* Force 16:9 aspect ratio - will letterbox/pillarbox as needed */
.game-board {
    position: relative;
    overflow: hidden;
    aspect-ratio: 16 / 9;

    /* Fill available space while maintaining aspect ratio */
    width: min(100vw, calc(100vh * 16 / 9));
    height: min(100vh, calc(100vw * 9 / 16));
}

/* Board background - fills entire game board */
.board-bg {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    object-fit: cover;
    z-index: 0;
}

/* Hero Container - Pygame positions */
.hero-container {
    position: absolute;
    z-index: 10;
}

/* Player hero: centered bottom */
.hero-container.player {
    left: 45.05%;
    bottom: 15.5%;
    width: 8.5%;
    aspect-ratio: 111 / 123;
}

/* Opponent hero: centered top */
.hero-container.opponent {
    left: 45.7%;
    top: 9.5%;
    width: 8.5%;
    aspect-ratio: 111 / 123;
}

.hero-portrait-img {
    width: 100%;
    height: 100%;
    object-fit: contain;
}

/* Health container - bottom right of hero portrait */
/* Pygame: ix = rect.right - icon.width + 12, iy = rect.bottom - icon.height + 6 */
.hero-health-container {
    position: absolute;
    right: -10%;
    bottom: -4%;
    width: 36%;  /* 40/111 */
    height: 32%; /* 40/123 */
}

.health-icon {
    width: 100%;
    height: 100%;
    object-fit: contain;
}

.health-text {
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -40%);
    font-family: 'Belwe', 'Arial Black', sans-serif;
    font-weight: bold;
    /* Scale with game board: proportional to both width and height */
    font-size: min(2vw, 3.56vh);
    color: white;
    text-shadow:
        -1px -1px 0 #000,
        1px -1px 0 #000,
        -1px 1px 0 #000,
        1px 1px 0 #000,
        0 2px 4px rgba(0,0,0,0.5);
}

.health-text.damaged {
    color: #ff4444;
}

/* Armor container - above health */
.hero-armor-container {
    position: absolute;
    right: -6.5%;
    bottom: 18%;
    width: 29%;  /* 32/111 */
    height: 30%; /* 37/123 */
}

.armor-icon {
    width: 100%;
    height: 100%;
    object-fit: contain;
}

.armor-text {
    position: absolute;
    top: 45%;
    left: 48%;
    transform: translate(-50%, -45%);
    font-family: 'Belwe', 'Arial Black', sans-serif;
    font-weight: bold;
    /* Scale with game board: proportional to both width and height */
    font-size: min(2vw, 3.56vh);
    color: white;
    text-shadow:
        -1px -1px 0 #000,
        1px -1px 0 #000,
        -1px 1px 0 #000,
        1px 1px 0 #000;
}

/* Attack container - bottom left of hero */
.hero-attack-container {
    position: absolute;
    left: -15%;
    bottom: -8%;
    width: 36%;
    height: 32%;
}

.attack-icon {
    width: 100%;
    height: 100%;
    object-fit: contain;
}

.attack-text {
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -40%);
    font-family: 'Belwe', 'Arial Black', sans-serif;
    font-weight: bold;
    font-size: min(2vw, 3.56vh);
    color: white;
    text-shadow:
        -1px -1px 0 #000,
        1px -1px 0 #000,
        -1px 1px 0 #000,
        1px 1px 0 #000;
}

/* Hero Power Container */
.hero-power-container {
    position: absolute;
    z-index: 10;
    width: 7.8%;
    aspect-ratio: 1 / 1;
}

.hero-power-container.player {
    left: 55%;
    bottom: 14%;
}

.hero-power-container.opponent {
    left: 55%;
    top: 12%;
}

.hero-power-img {
    width: 100%;
    height: 100%;
    object-fit: contain;
    cursor: pointer;
    transition: transform 0.15s ease;
}

.hero-power-img:hover {
    transform: scale(1.05);
}

.hero-power-container.used .hero-power-img {
    opacity: 0.5;
    filter: grayscale(50%);
}

/* End Turn Button */
.end-turn-container {
    position: absolute;
    right: 16%;
    top: 42%;
    width: 8%;
    aspect-ratio: 102 / 54;
    z-index: 20;
    cursor: pointer;
}

.end-turn-img {
    width: 100%;
    height: 100%;
    object-fit: contain;
    transition: transform 0.15s ease;
}

.end-turn-container:hover .end-turn-img {
    transform: scale(1.05);
}

.end-turn-container.enemy-turn .end-turn-img {
    opacity: 0.7;
}

/* Mana Bar */
.mana-bar-container {
    position: absolute;
    right: 1.5%;
    bottom: 3%;
    width: 19.5%;
    aspect-ratio: 250 / 50;
    z-index: 20;
}

.mana-bar-img {
    width: 100%;
    height: 100%;
    object-fit: contain;
}

.mana-crystals {
    position: absolute;
    left: 15%;
    top: 50%;
    transform: translateY(-50%);
    display: flex;
    gap: 2px;
}

.mana-crystal {
    width: clamp(10px, 1.5vw, 18px);
    height: clamp(10px, 1.5vw, 18px);
}

.mana-text {
    position: absolute;
    left: 5%;
    top: 50%;
    transform: translateY(-50%);
    font-family: 'Belwe', 'Arial Black', sans-serif;
    font-weight: bold;
    font-size: clamp(10px, 1.4vw, 16px);
    color: white;
    text-shadow:
        -1px -1px 0 #000,
        1px -1px 0 #000,
        -1px 1px 0 #000,
        1px 1px 0 #000;
}

/* Hand containers - positioned to match pygame layout */
.hand-container {
    position: absolute;
    z-index: 15;
}

/* Player hand - covers full board area for absolute positioning
 * Pygame: player_hand_rect at (280, H-120) with fan extending from bottom
 * Fan center is at (640-30, 720+300+30) = (610, 1050) below screen
 * Cards are positioned with game-board-relative coordinates
 */
.hand-container.player {
    left: 0;
    top: 0;
    width: 100%;
    height: 100%;
    pointer-events: none;  /* Allow clicks to pass through empty areas */
    overflow: visible;
}

.hand-container.player .card {
    pointer-events: auto;  /* Cards themselves are clickable */
}

/* Opponent hand - top area */
.hand-container.opponent {
    left: 30%;
    top: -5.5%;
    width: 40%;
    height: 25%;
    overflow: visible;
}

/* Board rows for minions */
.board-row {
    position: absolute;
    left: 12%;
    width: 78%;
    height: 25%;
    display: flex;
    justify-content: center;
    align-items: center;
    gap: 0.8%;
    z-index: 10;
}

/* Minion size - pygame uses 80x100 at 1280x720 base (6.25% of board width) */
.board-row .minion {
    width: 6.25%;
    height: auto;
    aspect-ratio: 80 / 100;
    flex-shrink: 0;
}

/* Player board - bottom center */
.board-row.player {
    bottom: 33%;
}

/* Opponent board - top center */
.board-row.opponent {
    top: 25%;
}

/* ============================
   Hero Section
   ============================ */
.hero-section {
    display: flex;
    align-items: center;
    gap: 10px;
}

.hero-portrait {
    width: var(--hero-size);
    height: var(--hero-size);
    background: var(--bg-card);
    border: 3px solid var(--border-color);
    border-radius: 50%;
    position: relative;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    transition: all var(--transition-fast);
}

.hero-portrait:hover {
    border-color: var(--gold);
}

.hero-portrait.targetable {
    border-color: var(--green);
    box-shadow: 0 0 15px rgba(76, 175, 80, 0.5);
}

.hero-portrait.can-attack {
    border-color: var(--green);
    animation: pulse 1.5s infinite;
}

.hero-health {
    position: absolute;
    bottom: -5px;
    right: -5px;
    width: 30px;
    height: 30px;
    background: var(--red);
    border: 2px solid #fff;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-weight: bold;
    font-size: 14px;
}

.hero-armor {
    position: absolute;
    bottom: -5px;
    left: -5px;
    width: 30px;
    height: 30px;
    background: #607d8b;
    border: 2px solid #fff;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-weight: bold;
    font-size: 14px;
}

.hero-attack {
    position: absolute;
    top: -5px;
    left: -5px;
    width: 30px;
    height: 30px;
    background: var(--gold);
    color: var(--bg-darker);
    border: 2px solid #fff;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-weight: bold;
    font-size: 14px;
}

/* Hero Power */
.hero-power {
    width: 60px;
    height: 60px;
    background: var(--bg-card);
    border: 2px solid var(--border-color);
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    transition: all var(--transition-fast);
    position: relative;
}

.hero-power:hover:not(.used) {
    border-color: var(--gold);
}

.hero-power.usable {
    border-color: var(--green);
    box-shadow: 0 0 10px rgba(76, 175, 80, 0.4);
}

.hero-power.used {
    opacity: 0.5;
    cursor: not-allowed;
}

.hero-power-cost {
    position: absolute;
    top: -8px;
    right: -8px;
    width: 24px;
    height: 24px;
    background: var(--blue);
    border: 2px solid #fff;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-weight: bold;
    font-size: 12px;
}

/* Weapon Slot */
.weapon-slot {
    width: 50px;
    height: 50px;
    background: var(--bg-darker);
    border: 2px dashed var(--border-color);
    border-radius: 8px;
    position: relative;
}

.weapon-slot.has-weapon {
    border-style: solid;
    border-color: var(--gold);
}

.weapon-attack, .weapon-durability {
    position: absolute;
    width: 22px;
    height: 22px;
    border: 2px solid #fff;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-weight: bold;
    font-size: 11px;
}

.weapon-attack {
    bottom: -8px;
    left: -8px;
    background: var(--gold);
    color: var(--bg-darker);
}

.weapon-durability {
    bottom: -8px;
    right: -8px;
    background: #607d8b;
}

/* ============================
   Mana Display
   ============================ */
.mana-display {
    background: var(--bg-card);
    padding: 8px 16px;
    border-radius: 20px;
    font-weight: bold;
    color: var(--blue);
    font-size: 18px;
}

.mana-crystals {
    display: flex;
    gap: 4px;
    margin-top: 4px;
    justify-content: center;
}

.mana-crystal {
    width: 16px;
    height: 16px;
    border-radius: 50%;
    background: var(--blue);
    border: 1px solid #fff;
}

.mana-crystal.empty {
    background: var(--bg-darker);
}

.mana-crystal.locked {
    background: #9c27b0;
}

/* ============================
   Deck Display
   ============================ */
.deck-display {
    background: var(--bg-card);
    width: 60px;
    height: 80px;
    border-radius: 8px;
    display: flex;
    align-items: center;
    justify-content: center;
    border: 2px solid var(--border-color);
}

.deck-count {
    font-weight: bold;
    font-size: 20px;
    color: var(--gold);
}

/* ============================
   Cards - Pygame Replica
   ============================ */
/* Pygame card size: 108x153 at 1280x720 base */
.card {
    /* Size relative to game board at 1280 base */
    width: calc(108 / 1280 * 100%);
    aspect-ratio: 108 / 153;
    position: absolute;
    cursor: pointer;
    transition: transform 0.15s ease, filter 0.15s ease;
    transform-origin: center bottom;
    z-index: 1;
}

/* Card image fills the card */
.card .card-img {
    width: 100%;
    height: 100%;
    object-fit: contain;
    border-radius: 6px;
}

/* Playable glow effect (pygame green glow) */
.card.playable {
    filter: drop-shadow(0 0 8px rgba(76, 255, 80, 0.8))
            drop-shadow(0 0 15px rgba(76, 255, 80, 0.5));
}

.card.playable:hover {
    transform: translateY(-15px) scale(1.1);
    z-index: 20;
    filter: drop-shadow(0 0 12px rgba(76, 255, 80, 1))
            drop-shadow(0 0 25px rgba(76, 255, 80, 0.7));
}

.card.selected {
    transform: translateY(-25px) scale(1.15);
    z-index: 25;
    filter: drop-shadow(0 0 15px rgba(255, 215, 0, 1))
            drop-shadow(0 0 30px rgba(255, 215, 0, 0.8));
}

/* Card back for opponent hand - inherits position: absolute from .card */
.card.card-back .card-back-img {
    width: 100%;
    height: 100%;
    object-fit: contain;
}

/* ============================
   Card Dragging
   ============================ */
.card.dragging {
    filter: drop-shadow(0 8px 20px rgba(0, 0, 0, 0.5))
            drop-shadow(0 0 15px rgba(76, 255, 80, 0.6));
    cursor: grabbing;
}

.card.dragging .card-img {
    width: 100%;
    height: 100%;
    object-fit: contain;
}

/* Card is past the play line (subtle scale only, no glow) */
.card.dragging.over-play-zone {
    transform: rotate(0deg) scale(1.15) !important;
}

/* ============================
   Attack Arrow Overlay
   ============================ */
.attack-arrow-overlay {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    pointer-events: none;
    z-index: 50;
    display: none;
}

.attack-arrow-overlay.visible {
    display: block;
}

/* Minion that can attack */
.minion.can-attack {
    cursor: grab;
    filter: drop-shadow(0 0 8px rgba(76, 255, 80, 0.8))
            drop-shadow(0 0 15px rgba(76, 255, 80, 0.5));
}

.minion.can-attack:hover {
    filter: drop-shadow(0 0 12px rgba(76, 255, 80, 1))
            drop-shadow(0 0 20px rgba(76, 255, 80, 0.7));
}

/* Hero that can attack (has weapon) */
.hero-container.can-attack {
    cursor: grab;
    filter: drop-shadow(0 0 8px rgba(76, 255, 80, 0.8))
            drop-shadow(0 0 15px rgba(76, 255, 80, 0.5));
}

.hero-container.can-attack:hover {
    filter: drop-shadow(0 0 12px rgba(76, 255, 80, 1))
            drop-shadow(0 0 20px rgba(76, 255, 80, 0.7));
}

/* Minion being dragged for attack */
.minion.attacking,
.hero-container.attacking {
    cursor: grabbing;
    filter: drop-shadow(0 0 15px rgba(220, 0, 0, 1))
            drop-shadow(0 0 25px rgba(220, 0, 0, 0.8));
}

/* Valid attack target highlighting */
.minion.attack-target,
.hero-container.attack-target {
    filter: drop-shadow(0 0 10px rgba(220, 0, 0, 0.8))
            drop-shadow(0 0 20px rgba(220, 0, 0, 0.5));
}

/* Valid spell target highlighting (blue/purple glow for spells) */
.minion.spell-target,
.hero-container.spell-target {
    filter: drop-shadow(0 0 10px rgba(100, 149, 237, 0.9))
            drop-shadow(0 0 20px rgba(138, 43, 226, 0.6));
    cursor: crosshair;
}

/* ============================
   Card with fallback content (when no image)
   ============================ */
.card-fallback {
    width: 100%;
    height: 100%;
    background: linear-gradient(135deg, #2d4a6d 0%, #1a2d3d 100%);
    border: 2px solid #4a7099;
    border-radius: 6px;
    position: relative;
    display: flex;
    flex-direction: column;
    padding: 4px;
}

.card-fallback .card-cost {
    position: absolute;
    top: -6px;
    left: -6px;
    width: 24px;
    height: 24px;
    background: #4a9eff;
    border: 2px solid #fff;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-weight: bold;
    font-size: 12px;
    color: white;
    text-shadow: 1px 1px 1px #000;
}

.card-fallback .card-name {
    position: absolute;
    top: 50%;
    left: 4px;
    right: 4px;
    transform: translateY(-50%);
    text-align: center;
    font-size: 8px;
    font-weight: 600;
    color: white;
    background: rgba(0,0,0,0.6);
    padding: 2px;
    border-radius: 2px;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.card-fallback .card-stats {
    position: absolute;
    bottom: 4px;
    left: 4px;
    right: 4px;
    display: flex;
    justify-content: space-between;
}

.card-fallback .card-attack,
.card-fallback .card-health {
    width: 20px;
    height: 20px;
    border: 2px solid #fff;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-weight: bold;
    font-size: 10px;
    color: white;
    text-shadow: 1px 1px 1px #000;
}

.card-fallback .card-attack {
    background: #ffd700;
    color: #1a1a2e;
    text-shadow: none;
}

.card-fallback .card-health {
    background: #f44336;
}

/* ============================
   Minions - Pygame Style with Portraits
   ============================ */
.minion {
    position: relative;
    cursor: pointer;
    transition: transform var(--transition-fast), filter var(--transition-fast);
    user-select: none;
    -webkit-user-drag: none;
}

.minion img {
    user-select: none;
    -webkit-user-drag: none;
    pointer-events: none;
}

.minion:hover {
    transform: scale(1.15);
    z-index: 10;
}

/* Portrait wrapper contains portrait, border, and divine shield */
.minion-portrait-wrapper {
    position: relative;
    width: 100%;
    height: 100%;
}

/* The actual minion portrait image */
.minion-portrait {
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    width: 97%;
    height: 97%;
    object-fit: cover;
    border-radius: 5px;
}

/* Border frame overlays the portrait */
.minion-border {
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    width: 125%;
    height: 125%;
    object-fit: contain;
    pointer-events: none;
}

/* Taunt border is larger */
.minion.taunt .minion-border {
    width: 150%;
    height: 150%;
}

/* Divine shield overlay */
.minion-divine-shield {
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -46%);
    width: 200%;
    height: 200%;
    object-fit: contain;
    pointer-events: none;
    z-index: 5;
}

/* Attack stat - bottom left */
.minion-attack-stat {
    position: absolute;
    bottom: 5%;
    left: 10%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-family: 'Belwe', 'Arial Black', sans-serif;
    font-weight: bold;
    /* Scale with game board: 20px at 1280px = 1.5625vw, capped for 16:9 */
    font-size: min(1.5vw, 2.67vh);
    color: white;
    text-shadow:
        -1px -1px 0 #000,
        1px -1px 0 #000,
        -1px 1px 0 #000,
        1px 1px 0 #000,
        0 2px 3px rgba(0,0,0,0.5);
    z-index: 10;
}

/* Health stat - bottom right */
.minion-health-stat {
    position: absolute;
    bottom: 5%;
    right: 10%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-family: 'Belwe', 'Arial Black', sans-serif;
    font-weight: bold;
    /* Scale with game board: 20px at 1280px = 1.5625vw, capped for 16:9 */
    font-size: min(1.5vw, 2.67vh);
    color: white;
    text-shadow:
        -1px -1px 0 #000,
        1px -1px 0 #000,
        -1px 1px 0 #000,
        1px 1px 0 #000,
        0 2px 3px rgba(0,0,0,0.5);
    z-index: 10;
}

/* Damaged health shows in red */
.minion-health-stat.damaged {
    color: #ff4444;
}

/* Can attack glow */
.minion.can-attack {
    filter: drop-shadow(0 0 8px rgba(76, 255, 80, 0.8))
            drop-shadow(0 0 15px rgba(76, 255, 80, 0.5));
}

.minion.can-attack:hover {
    filter: drop-shadow(0 0 12px rgba(76, 255, 80, 1))
            drop-shadow(0 0 20px rgba(76, 255, 80, 0.7));
}

/* Selected attacker */
.minion.selected {
    filter: drop-shadow(0 0 15px rgba(255, 215, 0, 1))
            drop-shadow(0 0 25px rgba(255, 215, 0, 0.8));
}

/* Targetable glow */
.minion.targetable {
    filter: drop-shadow(0 0 10px rgba(76, 175, 80, 0.8));
}

/* Stealth effect */
.minion.stealth {
    opacity: 0.5;
}

.minion.stealth .minion-portrait {
    filter: brightness(0.7) saturate(0.5);
}

/* Frozen effect */
.minion.frozen {
    filter: hue-rotate(180deg) brightness(1.1) saturate(1.5);
}

/* ============================
   Turn Indicator & End Turn
   ============================ */
.turn-indicator {
    background: var(--bg-card);
    padding: 10px 30px;
    border-radius: 20px;
    border: 2px solid var(--border-color);
}

.turn-indicator.your-turn {
    border-color: var(--green);
    background: rgba(76, 175, 80, 0.2);
}

.btn-end-turn {
    padding: 15px 40px;
    font-family: var(--font-title);
    font-size: 16px;
    font-weight: bold;
    background: linear-gradient(180deg, var(--green) 0%, #388e3c 100%);
    color: white;
    border: none;
    border-radius: 8px;
    cursor: pointer;
    transition: all var(--transition-fast);
    text-transform: uppercase;
}

.btn-end-turn:hover {
    transform: scale(1.05);
}

.btn-end-turn.disabled {
    background: var(--bg-card);
    color: var(--text-muted);
    cursor: not-allowed;
}

/* ============================
   Overlays
   ============================ */
.overlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.8);
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    z-index: 100;
}

.overlay.hidden {
    display: none;
}

.overlay-message {
    font-family: var(--font-title);
    font-size: 24px;
    color: var(--gold);
    margin-bottom: 20px;
}

.game-over-content {
    background: var(--bg-card);
    padding: 40px 60px;
    border-radius: 16px;
    border: 2px solid var(--gold);
    text-align: center;
}

.game-over-content h2 {
    font-family: var(--font-title);
    font-size: 48px;
    color: var(--gold);
    margin-bottom: 20px;
}

.game-over-content p {
    color: var(--text-secondary);
    margin-bottom: 30px;
}

/* ============================
   Game Menu
   ============================ */
.btn-game-menu {
    position: fixed;
    top: 10px;
    left: 10px;
    padding: 8px 16px;
    background: var(--bg-card);
    border: 2px solid var(--border-color);
    border-radius: 8px;
    color: var(--text-secondary);
    font-size: 14px;
    cursor: pointer;
    z-index: 50;
}

.btn-game-menu:hover {
    border-color: var(--gold);
    color: var(--text-primary);
}

.dropdown {
    position: fixed;
    top: 50px;
    left: 10px;
    background: var(--bg-card);
    border: 2px solid var(--border-color);
    border-radius: 8px;
    overflow: hidden;
    z-index: 51;
}

.dropdown.hidden {
    display: none;
}

.dropdown-item {
    display: block;
    width: 100%;
    padding: 12px 24px;
    background: none;
    border: none;
    color: var(--text-primary);
    font-size: 14px;
    text-align: left;
    cursor: pointer;
}

.dropdown-item:hover {
    background: var(--bg-hover);
}

/* ============================
   Loading Spinner
   ============================ */
.spinner {
    width: 50px;
    height: 50px;
    border: 4px solid var(--bg-card);
    border-top-color: var(--gold);
    border-radius: 50%;
    animation: spin 1s linear infinite;
    margin-bottom: 20px;
}

@keyframes spin {
    to { transform: rotate(360deg); }
}

/* ============================
   Toast Notifications
   ============================ */
.toast {
    position: fixed;
    bottom: 20px;
    left: 50%;
    transform: translateX(-50%);
    background: var(--red);
    color: white;
    padding: 12px 24px;
    border-radius: 8px;
    display: flex;
    align-items: center;
    gap: 16px;
    z-index: 200;
    animation: slideUp 0.3s ease;
}

.toast.hidden {
    display: none;
}

.btn-close {
    background: none;
    border: none;
    color: white;
    font-size: 20px;
    cursor: pointer;
    padding: 0;
    line-height: 1;
}

@keyframes slideUp {
    from {
        opacity: 0;
        transform: translateX(-50%) translateY(20px);
    }
    to {
        opacity: 1;
        transform: translateX(-50%) translateY(0);
    }
}

/* ============================
   Animations
   ============================ */
@keyframes pulse {
    0%, 100% {
        box-shadow: 0 0 0 0 rgba(76, 175, 80, 0.4);
    }
    50% {
        box-shadow: 0 0 0 10px rgba(76, 175, 80, 0);
    }
}

/* ============================
   Utilities
   ============================ */
.hidden {
    display: none !important;
}

/* ============================
   Responsive
   ============================ */
@media (max-width: 768px) {
    :root {
        --card-width: 60px;
        --card-height: 85px;
        --minion-size: 70px;
        --hero-size: 80px;
    }

    .game-title {
        font-size: 36px;
    }

    .form-container {
        padding: 20px;
        margin: 10px;
    }

    .class-selector {
        grid-template-columns: repeat(3, 1fr);
    }
}
