* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

/* Mobile drag/drop optimizations */
@media (pointer: coarse) {
    /* Prevent text selection during touch drag */
    * {
        -webkit-user-select: none;
        -moz-user-select: none;
        -ms-user-select: none;
        user-select: none;
    }
    
    /* Prevent touch callouts */
    * {
        -webkit-touch-callout: none;
        -webkit-tap-highlight-color: transparent;
    }
    
    /* Improve touch targets */
    .card {
        touch-action: none;
        min-height: 44px !important; /* Minimum iOS touch target */
    }
    
    button {
        min-height: 44px !important;
        touch-action: manipulation;
    }
    
    /* Prevent scrolling during drag */
    body.dragging {
        overflow: hidden;
        touch-action: none;
    }
}

body {
    font-family: 'Arial', sans-serif;
    background: linear-gradient(135deg, #1e3c72 0%, #2a5298 100%);
    color: #D3D0CB;
    min-height: 100vh;
}

.screen {
    min-height: 100vh;
    padding: 20px;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
}

.hidden {
    display: none !important;
}

/* Auth Screen */
#auth-screen h1 {
    margin-bottom: 10px;
}

.slogan {
    font-size: 18px;
    text-align: center;
    margin-bottom: 30px;
    color: #e0e7ff;
    font-style: italic;
    max-width: 500px;
}

.auth-container {
    background: rgba(0, 0, 0, 0.3);
    padding: 40px;
    border-radius: 10px;
    min-width: 300px;
}

.auth-discord {
    margin-top: 20px;
}

.auth-form input {
    width: 100%;
    padding: 12px;
    margin: 10px 0;
    border: none;
    border-radius: 5px;
    background: rgba(255, 255, 255, 0.9);
    font-size: 18px;
}

.auth-form button {
    width: 100%;
    padding: 12px;
    margin: 5px 0;
    border: none;
    border-radius: 5px;
    background: #363732;
    color: #D3D0CB;
    font-size: 18px;
    cursor: pointer;
    transition: background 0.3s;
}

.auth-form button:hover {
    background: #D4AD2A;
}

/* Main Menu */
.user-stats {
    background: rgba(0, 0, 0, 0.3);
    padding: 20px;
    border-radius: 10px;
    margin: 20px 0;
    text-align: center;
}

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

.menu-buttons button {
    padding: 15px 30px;
    border: none;
    border-radius: 5px;
    background: #363732;
    color: #D3D0CB;
    font-size: 20px;
    cursor: pointer;
    transition: background 0.3s;
}

.menu-buttons button:hover {
    background: #D4AD2A;
}

/* Golden border for Find Match button when queue has players */
.menu-buttons button.queue-available {
    border: 3px solid #eac435 !important;
    margin: -3px !important;
    box-shadow: 0 0 10px rgba(234, 196, 53, 0.6) !important;
    animation: golden-pulse 2s infinite;
}

@keyframes golden-pulse {
    0% { box-shadow: 0 0 10px rgba(234, 196, 53, 0.6); }
    50% { box-shadow: 0 0 20px rgba(234, 196, 53, 0.8); }
    100% { box-shadow: 0 0 10px rgba(234, 196, 53, 0.6); }
}

.auth-discord button {
    padding: 15px 30px;
    border: none;
    border-radius: 5px;
    background: #3096F3;
    color: #D3D0CB;
    font-size: 20px;
    cursor: pointer;
    transition: background 0.3s;
}

.auth-discord button:hover {
    background: #0b7dda;
}

button.discord-btn {
    background: #5865F2;
}

button.discord-btn:hover {
    background: #4752C4;
}

#queue-status {
    background: rgba(0, 0, 0, 0.8);
    padding: 20px;
    border-radius: 10px;
    margin: 20px 0;
    text-align: center;
}

#queue-status p {
    font-size: 18px;
    margin-bottom: 15px;
}

#queue-status button {
    padding: 15px 30px;
    border: none;
    border-radius: 5px;
    background: #363732;
    color: #D3D0CB;
    font-size: 20px;
    cursor: pointer;
    transition: background 0.3s;
    margin-top: 10px;
}

#queue-status button:hover {
    background: #D4AD2A;
}

#queue-status .or-better {
    color: #BF0603;
    font-weight: bold;
}

/* Deck Builder */
.deck-builder-container {
    display: flex;
    gap: 20px;
    width: 100%;
    max-width: 1200px;
}

.available-cards, .current-deck {
    flex: 1;
    background: rgba(0, 0, 0, 0.3);
    padding: 20px;
    border-radius: 10px;
}

.collection-filters {
    display: flex;
    gap: 15px;
    margin-bottom: 15px;
    padding: 10px;
    background: rgba(0, 0, 0, 0.2);
    border-radius: 5px;
    height: 60px;
}

.filter-group {
    display: flex;
    flex-direction: column;
    gap: 5px;
}

.filter-group label {
    font-size: 0.9em;
    color: #ccc;
    font-weight: bold;
}

.filter-group select {
    padding: 5px;
    border: 1px solid #444;
    border-radius: 3px;
    background: #2a2a2a;
    color: #fff;
    font-size: 0.9em;
}

.deck-actions {
    display: flex;
    gap: 15px;
    margin-bottom: 15px;
    padding: 10px;
    background: rgba(0, 0, 0, 0.2);
    border-radius: 5px;
    height: 60px;
    align-items: center;
}

.action-group {
    display: flex;
    flex-direction: column;
    gap: 5px;
    height: 100%;
    justify-content: center;
}

.action-group button {
    padding: 8px 16px;
    border: 1px solid #444;
    border-radius: 3px;
    background: #363732;
    color: #D3D0CB;
    font-size: 0.9em;
    cursor: pointer;
    transition: background 0.3s;
}

.action-group button:hover:not(:disabled) {
    background: #D4AD2A;
}

.action-group button:disabled {
    background: #666;
    cursor: not-allowed;
    opacity: 0.6;
}

#card-collection, #deck-cards {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(150px, 1fr));
    gap: 10px;
    max-height: 500px;
    overflow-y: auto;
}

.card {
    background: rgba(255, 255, 255, 0.1);
    border: 2px solid #444;
    border-radius: 8px;
    cursor: pointer;
    transition: all 0.3s;
    text-align: center;
    min-height: 160px;
    position: relative;
    overflow: hidden;
    display: flex;
    flex-direction: column;
}

.card:hover {
    background: rgba(255, 255, 255, 0.2);
    border-color: #666;
    transform: translateY(-2px);
}

.card.minion {
    border-color: #8B4513;
}

.card.spell {
    border-color: #4169E1;
}

.card-name {
    font-weight: bold;
    margin-bottom: 5px;
}

.card-cost {
    position: absolute;
    top: 5px;
    left: 5px;
    background: #3096F3;
    color: #D3D0CB;
    border-radius: 50%;
    width: 25px;
    height: 25px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-weight: bold;
    font-size: 14px;
}


.card-stats {
    margin-top: 10px;
    font-size: 14px;
}

.card-text {
    font-size: 12px;
    font-style: italic;
    margin-top: 5px;
    color: #ccc;
}

.card-keywords {
    font-size: 10px;
    color: #FFD700;
    margin-top: 3px;
    font-weight: bold;
}

/* Leaderboard */
#leaderboard-list {
    background: rgba(0, 0, 0, 0.3);
    padding: 20px;
    border-radius: 10px;
    min-width: 400px;
}

.leaderboard-entry {
    display: flex;
    justify-content: space-between;
    padding: 10px 0;
    border-bottom: 1px solid rgba(255, 255, 255, 0.1);
}

/* Game Screen */
#game-screen {
    padding: 10px;
    display: flex;
    flex-direction: row;
    gap: 20px;
    position: relative;
}

#game-screen::after {
    content: '';
    width: 280px;
    flex-shrink: 0;
}

/* Battle History Log */
.battle-history {
    width: 280px;
    background: rgba(0, 0, 0, 0.4);
    border-radius: 10px;
    padding: 15px;
    height: calc(100vh - 40px);
    overflow: hidden;
    display: flex;
    flex-direction: column;
}

.battle-history h3 {
    margin: 0 0 15px 0;
    color: #FFD700;
    text-align: center;
    font-size: 18px;
    border-bottom: 2px solid #444;
    padding-bottom: 8px;
}

#history-log {
    flex: 1;
    overflow-y: auto;
    scrollbar-width: thin;
    scrollbar-color: #666 transparent;
}

#history-log::-webkit-scrollbar {
    width: 6px;
}

#history-log::-webkit-scrollbar-track {
    background: transparent;
}

#history-log::-webkit-scrollbar-thumb {
    background-color: #666;
    border-radius: 3px;
}

.history-entry {
    margin-bottom: 8px;
    padding: 8px;
    border-radius: 6px;
    font-size: 13px;
    line-height: 1.4;
    border-left: 3px solid #666;
}

.history-entry.turn-start {
    background: rgba(100, 149, 237, 0.1);
    border-left-color: #6495ED;
    color: #87CEEB;
    font-weight: bold;
}

.history-entry.play-card {
    background: rgba(255, 305, 0, 0.1);
    border-left-color: #FFD700;
    color: #FFD700;
}

.history-entry.attack {
    background: rgba(255, 69, 0, 0.1);
    border-left-color: #FF4500;
    color: #FF6347;
}

.history-entry.damage {
    background: rgba(220, 20, 60, 0.1);
    border-left-color: #DC143C;
    color: #FFB6C1;
}

.history-entry.heal {
    background: rgba(0, 255, 127, 0.1);
    border-left-color: #00FF7F;
    color: #90EE90;
}

.history-entry.death {
    background: rgba(105, 105, 105, 0.1);
    border-left-color: #696969;
    color: #D3D3D3;
}

.history-entry.spell {
    background: rgba(138, 43, 226, 0.1);
    border-left-color: #8A2BE2;
    color: #DDA0DD;
}

.history-entry.arrival {
    background: rgba(255, 165, 0, 0.1);
    border-left-color: #FFA500;
    color: #FFCC99;
}

.history-entry.timeout {
    background: rgba(255, 68, 68, 0.15);
    border-left-color: #FF4444;
    color: #FF6B6B;
    font-weight: bold;
}

/* Main Game Area */
.game-main {
    flex: 1;
    display: flex;
    flex-direction: column;
    min-width: 0;
    align-items: center;
}

.game-header {
    display: flex;
    justify-content: center;
    align-items: center;
    width: 100%;
    max-width: 1200px;
    margin-bottom: 20px;
    gap: 100px;
}

.player-info {
    background: rgba(0, 0, 0, 0.5);
    padding: 15px;
    border-radius: 10px;
    width: 200px;
    text-align: center;
}

.player-name {
    font-size: 18px;
    font-weight: bold;
    margin-bottom: 10px;
}

.player-stats {
    display: flex;
    gap: 15px;
    margin-bottom: 5px;
    justify-content: center;
}

.health {
    color: #4CAF50;
    font-weight: bold;
}

.armor {
    color: #FFA500;
    font-weight: bold;
}

.gold {
    color: #eac435;
    font-weight: bold;
}

.mana {
    color: #3096F3;
    font-weight: bold;
}

.turn-info {
    text-align: center;
}

#turn-timer {
    color: #FF4444;
    font-weight: bold;
    font-size: 28px;
    margin-top: 8px;
    padding: 8px 12px;
    background: rgba(255, 68, 68, 0.3);
    border-radius: 8px;
    display: inline-block;
    border: 2px solid #FF4444;
    box-shadow: 0 0 10px rgba(255, 68, 68, 0.5);
}

.game-board {
    width: 100%;
    min-width: 500px;
    max-width: 700px;
    margin-bottom: 20px;
}

.board {
    min-height: 120px;
    background: rgba(0, 0, 0, 0.2);
    border: 2px dashed #666;
    border-radius: 10px;
    padding: 10px;
    margin: 10px 0;
    display: flex;
    gap: 10px;
    align-items: center;
    justify-content: center;
    overflow-x: auto;
}

.board.opponent-board {
    border-color: #BF0603;
}

.board.player-board {
    border-color: #4CAF50;
}

/* Targeting styles for game interactions */
.minion.targeting {
    border-color: #ff4444;
    box-shadow: 0 0 40px rgba(255, 68, 68, 0.7);
    cursor: pointer;
}

.targeting {
    border: 4px solid #ff4444 !important;
    box-shadow: 0 0 30px rgba(255, 68, 68, 0.7) !important;
    cursor: pointer !important;
    background: rgba(255, 68, 68, 0.2) !important;
}

.player-area {
    width: 100%;
    max-width: 1200px;
    display: flex;
    flex-direction: column;
    align-items: center;
}

.hand {
    display: flex;
    gap: 10px;
    margin-bottom: 20px;
    justify-content: center;
    overflow-x: auto;
    padding: 10px 0;
    position: relative;
    max-width: 100%;
}

/* Overlapping cards for large hands */
.hand.large-hand {
    gap: 0;
    justify-content: flex-start;
    padding-left: 60px; /* Space for first card */
}

.hand.large-hand .card {
    margin-left: -50px; /* Overlap amount */
    position: relative;
    z-index: 1;
    transition: all 0.2s ease;
}

.hand.large-hand .card:first-child {
    margin-left: 0;
}

.hand.large-hand .card:hover {
    z-index: 10;
    transform: translateY(-10px);
    margin-left: -45px; /* Less overlap on hover */
    margin-right: 5px;
}

.hand .card {
    position: relative;
    min-width: 120px;
}

.hand .card.playable {
    border-color: #4CAF50;
    box-shadow: 0 0 10px rgba(76, 175, 80, 0.5);
}

.game-controls {
    display: flex;
    justify-content: center;
    gap: 20px;
}

.game-controls button {
    padding: 12px 24px;
    border: none;
    border-radius: 5px;
    background: #363732;
    font-size: 18px;
    cursor: pointer;
    transition: background 0.3s;
}

.game-controls button:hover {
    background: #D4AD2A;
}

#end-turn-btn {
    background: #363732;
    color: #D3D0CB;
}

#end-turn-btn:not(:disabled) {
    background: #BF0603;
    color: #D3D0CB;
}

#end-turn-btn:not(:disabled):hover {
    background: #A00502;
}

#end-turn-btn:disabled {
    background: #666;
    cursor: not-allowed;
}

/* Targeting */
#targeting-overlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.5);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 1000;
    pointer-events: none; /* Allow clicks to pass through */
}

#targeting-overlay .targeting-info {
    pointer-events: all; /* But keep the cancel button clickable */
}

.targeting-info {
    background: rgba(0, 0, 0, 0.8);
    padding: 20px;
    border-radius: 10px;
    text-align: center;
}

.targeting-info button {
    padding: 10px 20px;
    margin-top: 10px;
    border: none;
    border-radius: 5px;
    background: #363732;
    color: #D3D0CB;
    cursor: pointer;
}

.targeting-info button:hover {
    background: #D4AD2A;
}

/* Messages */
#message-area {
    position: fixed;
    top: 20px;
    right: 20px;
    z-index: 1001;
}

.message {
    background: rgba(0, 0, 0, 0.8);
    color: #D3D0CB;
    padding: 15px;
    margin: 5px 0;
    border-radius: 5px;
    border-left: 4px solid #3096F3;
    animation: slideIn 0.3s ease-out;
}

.message.error {
    border-left-color: #f44336;
}

.message.success {
    border-left-color: #4CAF50;
}

@keyframes slideIn {
    from {
        transform: translateX(100%);
        opacity: 0;
    }
    to {
        transform: translateX(0);
        opacity: 1;
    }
}

/* Card Tooltips */
.card-tooltip {
    position: absolute;
    background: rgba(0, 0, 0, 0.95);
    color: #D3D0CB;
    padding: 12px;
    border-radius: 8px;
    border: 2px solid #444;
    font-size: 14px;
    z-index: 1002;
    max-width: 250px;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.5);
    pointer-events: none;
    opacity: 0;
    transition: opacity 0.2s;
}

.card-tooltip.visible {
    opacity: 1;
}

.card-tooltip .tooltip-name {
    font-weight: bold;
    font-size: 18px;
    margin-bottom: 8px;
    color: #FFD700;
}

.card-tooltip .tooltip-cost {
    color: #3096F3;
    font-weight: bold;
    margin-bottom: 4px;
}

.card-tooltip .tooltip-stats {
    color: #D3D0CB;
    font-weight: bold;
    margin-bottom: 4px;
}

.card-tooltip .tooltip-text {
    color: #CCC;
    font-style: italic;
    margin-bottom: 4px;
    line-height: 1.4;
}

.card-tooltip .tooltip-keywords {
    color: #FFD700;
    font-weight: bold;
    margin-bottom: 4px;
}


.card-tooltip .tooltip-arrival {
    color: #90EE90;
    font-weight: bold;
    margin-bottom: 4px;
}

.card-tooltip .tooltip-effect {
    color: #87CEEB;
    font-style: italic;
}

/* Responsive */
@media (max-width: 768px) {
    .deck-builder-container {
        flex-direction: column;
    }
    
    #game-screen {
        flex-direction: column;
        gap: 10px;
    }
    
    .battle-history {
        width: 100%;
        height: 200px;
        order: 2;
    }
    
    .game-main {
        order: 1;
    }
    
    #game-screen::after {
        display: none;
    }
    
    .game-header {
        flex-direction: column;
        gap: 10px;
    }
    
    .hand {
        gap: 5px;
    }
    
    .hand.large-hand {
        padding-left: 50px; /* Less space on mobile */
    }
    
    .hand.large-hand .card {
        margin-left: -40px; /* Less overlap on mobile */
    }
    
    .hand.large-hand .card:hover {
        margin-left: -35px;
        transform: translateY(-8px); /* Smaller hover lift */
    }
    
    .hand .card {
        min-width: 100px;
        font-size: 12px;
    }
}

@media (max-width: 1200px) {
    .battle-history {
        width: 240px;
    }
    
    #game-screen::after {
        width: 240px;
    }
    
    .history-entry {
        font-size: 12px;
        padding: 6px;
    }
}

/* Card name highlighting in battle history */
.card-name-highlight {
    color: #FFD700;
    font-weight: bold;
    text-decoration: underline;
    cursor: pointer;
    transition: color 0.2s ease;
}

.card-name-highlight:hover {
    color: #FFF8DC;
    text-shadow: 0 0 4px #FFD700;
}

/* Drag and Drop Styles */
.board.player-board.drag-over {
    border-color: #4CAF50;
    background: rgba(76, 175, 80, 0.1);
    box-shadow: 0 0 15px rgba(76, 175, 80, 0.4);
}

/* Drag-to-attack styles */
.minion.dragging-attacker {
    opacity: 0.7;
    transform: scale(1.05);
    box-shadow: 0 0 20px rgba(255, 215, 0, 0.8);
}

.minion.attack-target-hover {
    border-color: #ff4444;
    background: rgba(255, 68, 68, 0.2);
    box-shadow: 0 0 15px rgba(255, 68, 68, 0.6);
}

#opponent-info.attack-target-hover {
    border-color: #ff4444;
    background: rgba(255, 68, 68, 0.2);
    box-shadow: 0 0 15px rgba(255, 68, 68, 0.6);
}

.minion.spell-target-hover {
    border-color: #4488ff;
    background: rgba(68, 136, 255, 0.2);
    box-shadow: 0 0 15px rgba(68, 136, 255, 0.6);
}

.player-info.spell-target-hover {
    border-color: #4488ff;
    background: rgba(68, 136, 255, 0.2);
    box-shadow: 0 0 15px rgba(68, 136, 255, 0.6);
}

.game-board.spell-drop-area {
    background: rgba(136, 68, 255, 0.1);
    box-shadow: inset 0 0 20px rgba(136, 68, 255, 0.3);
}

/* Tooltip Spacing */
.tooltip-spacer {
    height: 8px;
}

/* Rarity Colors */
.rarity-basic {
    /* Default color - no special styling */
}

.rarity-common {
    color: #BF0603 !important;
}

.rarity-rare {
    color: #3096F3 !important;
}

.rarity-epic {
    color: #9966CC !important;
}

.rarity-legendary {
    color: #eac435 !important;
    font-weight: bold;
}

.rarity-mythical {
    color: #4CAF50 !important;
    font-weight: bold;
}

/* Rarity colors for dropdown options */
#rarity-filter option[value="basic"] {
    /* Default color - no special styling */
}

#rarity-filter option[value="common"] {
    color: #BF0603 !important;
}

#rarity-filter option[value="rare"] {
    color: #3096F3 !important;
}

#rarity-filter option[value="epic"] {
    color: #9966CC !important;
}

#rarity-filter option[value="legendary"] {
    color: #eac435 !important;
    font-weight: bold;
}

#rarity-filter option[value="mythical"] {
    color: #4CAF50 !important;
    font-weight: bold;
}

.card.dragging {
    opacity: 0.5;
    transform: rotate(3deg);
}

.card[draggable="true"]:hover {
    cursor: grab;
}

.card[draggable="true"]:active {
    cursor: grabbing;
}