/* ═══════════════════════════════════════════════════════════════════
   MAIN CSS - Variables, Reset, Global Styles
   Token Clash Mobile-First SPA
   ═══════════════════════════════════════════════════════════════════ */

/* ─────────────────────────────────────────────────────────────────────
   CSS VARIABLES
   ───────────────────────────────────────────────────────────────────── */
:root {
    /* Colors */
    --color-bg-primary: #1a1a2e;
    --color-bg-secondary: #16213e;
    --color-bg-panel: rgba(255, 255, 255, 0.1);
    --color-bg-dark: rgba(0, 0, 0, 0.3);
    --color-bg-darker: rgba(0, 0, 0, 0.5);

    --color-gold: #ffd700;
    --color-gold-dark: #ff8c00;
    --color-success: #44ff44;
    --color-success-dark: #00cc00;
    --color-danger: #ff4444;
    --color-danger-dark: #cc0000;
    --color-purple: #9c27b0;
    --color-purple-dark: #673ab7;
    --color-blue: #2196f3;
    --color-blue-dark: #1976d2;
    --color-cyan: #74c0fc;

    --color-text-primary: #fff;
    --color-text-secondary: #aaa;
    --color-text-muted: #888;
    --color-text-dim: #666;

    /* Rarity colors */
    --color-common: #888;
    --color-rare: #4a9eff;
    --color-epic: #a855f7;
    --color-legendary: #ffd700;

    /* Role colors */
    --color-attacker: #ff6b6b;
    --color-defender: #74c0fc;
    --color-hybrid: #da77f2;

    /* Typography */
    --font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;
    --font-mono: 'Courier New', monospace;

    /* Spacing */
    --spacing-xs: 5px;
    --spacing-sm: 10px;
    --spacing-md: 15px;
    --spacing-lg: 20px;
    --spacing-xl: 30px;

    /* Border radius */
    --radius-sm: 6px;
    --radius-md: 8px;
    --radius-lg: 10px;
    --radius-xl: 15px;
    --radius-round: 50%;

    /* Shadows */
    --shadow-sm: 0 2px 8px rgba(0, 0, 0, 0.2);
    --shadow-md: 0 5px 20px rgba(0, 0, 0, 0.3);
    --shadow-lg: 0 10px 40px rgba(0, 0, 0, 0.4);
    --shadow-gold: 0 5px 20px rgba(255, 215, 0, 0.4);
    --shadow-success: 0 0 10px rgba(68, 255, 68, 0.5);

    /* Transitions */
    --transition-fast: 0.2s ease;
    --transition-normal: 0.3s ease;

    /* Mobile dimensions */
    --phone-width: 390px;
    --phone-height: 844px;
    --nav-height: 60px;
    --header-height: 50px;
    --min-touch-target: 44px;
}

/* ─────────────────────────────────────────────────────────────────────
   CSS RESET
   ───────────────────────────────────────────────────────────────────── */
*, *::before, *::after {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

html {
    font-size: 16px;
    -webkit-tap-highlight-color: transparent;
}

body {
    font-family: var(--font-family);
    background: linear-gradient(135deg, var(--color-bg-primary) 0%, var(--color-bg-secondary) 100%);
    color: var(--color-text-primary);
    min-height: 100vh;
    min-height: 100dvh; /* Dynamic viewport height for mobile */
    overflow-x: hidden;
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
}

a {
    color: inherit;
    text-decoration: none;
}

button {
    font-family: inherit;
}

img {
    max-width: 100%;
    display: block;
}

/* ─────────────────────────────────────────────────────────────────────
   APP CONTAINER
   ───────────────────────────────────────────────────────────────────── */
.app-container {
    display: flex;
    flex-direction: column;
    min-height: 100vh;
    min-height: 100dvh;
}

/* ─────────────────────────────────────────────────────────────────────
   APP HEADER
   ───────────────────────────────────────────────────────────────────── */
.app-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: var(--spacing-sm) var(--spacing-md);
    background: var(--color-bg-darker);
    border-bottom: 1px solid rgba(255, 255, 255, 0.1);
    height: var(--header-height);
    position: sticky;
    top: 0;
    z-index: 100;
}

.header-left {
    display: flex;
    align-items: center;
    gap: var(--spacing-sm);
}

.header-logo {
    font-size: 1.5rem;
}

.header-title {
    font-size: 1rem;
    font-weight: bold;
    color: var(--color-gold);
    display: none;
}

@media (min-width: 480px) {
    .header-title {
        display: inline;
    }
}

.header-right {
    display: flex;
    align-items: center;
    gap: var(--spacing-sm);
}

.header-balance {
    display: flex;
    align-items: center;
    gap: var(--spacing-md);
}

.balance-item {
    display: flex;
    align-items: center;
    gap: 4px;
    background: var(--color-bg-panel);
    padding: 6px 10px;
    border-radius: var(--radius-md);
    font-size: 0.85rem;
}

.balance-icon {
    font-size: 0.9rem;
}

.balance-value {
    color: var(--color-gold);
    font-weight: bold;
    font-family: var(--font-mono);
}

.wallet-display {
    cursor: pointer;
    transition: background var(--transition-fast);
    position: relative;
    display: flex;
    align-items: center;
    gap: 4px;
}

.wallet-display:hover {
    background: rgba(255, 255, 255, 0.15);
}

.wallet-short {
    color: var(--color-text-secondary);
    font-family: var(--font-mono);
    font-size: 0.8rem;
}

.wallet-dropdown-arrow {
    font-size: 0.6rem;
    color: var(--color-text-muted);
    transition: transform var(--transition-fast);
}

.wallet-display.open .wallet-dropdown-arrow {
    transform: rotate(180deg);
}

/* Wallet Dropdown Menu */
.wallet-dropdown {
    position: absolute;
    top: calc(100% + 5px);
    right: 0;
    background: var(--color-bg-primary);
    border: 1px solid rgba(255, 255, 255, 0.2);
    border-radius: var(--radius-md);
    min-width: 150px;
    box-shadow: var(--shadow-md);
    z-index: 1000;
    display: none;
    overflow: hidden;
}

.wallet-display.open .wallet-dropdown {
    display: block;
    animation: dropdownFadeIn 0.15s ease-out;
}

@keyframes dropdownFadeIn {
    from { opacity: 0; transform: translateY(-5px); }
    to { opacity: 1; transform: translateY(0); }
}

.wallet-dropdown-item {
    padding: var(--spacing-sm) var(--spacing-md);
    cursor: pointer;
    transition: background var(--transition-fast);
    font-size: 0.85rem;
    display: flex;
    align-items: center;
    gap: var(--spacing-sm);
}

.wallet-dropdown-item:hover {
    background: rgba(255, 255, 255, 0.1);
}

.wallet-dropdown-item:active {
    background: rgba(255, 255, 255, 0.15);
}

#walletDropdownDisconnect {
    color: var(--color-danger);
    border-top: 1px solid rgba(255, 255, 255, 0.1);
}

#walletDropdownDisconnect:hover {
    background: rgba(255, 68, 68, 0.2);
}

.header-connect-btn {
    padding: 8px 16px;
    font-size: 0.85rem;
    min-height: 36px;
}

/* Hide header on very small screens during battle */
.battle-active .app-header {
    display: none;
}

.battle-active #app {
    padding-bottom: 0;
    overflow: hidden;
}

/* Main content area */
#app {
    flex: 1;
    padding-bottom: var(--nav-height);
    padding-top: 0;
    overflow-y: auto;
    -webkit-overflow-scrolling: touch;
}

/* Mobile screen wrapper */
.screen {
    max-width: var(--phone-width);
    margin: 0 auto;
    padding: var(--spacing-md);
    min-height: calc(100vh - var(--nav-height));
    min-height: calc(100dvh - var(--nav-height));
}

/* Desktop: wider content area */
@media (min-width: 1200px) {
    .screen {
        max-width: 1400px;
    }

    #app {
        padding-bottom: 0;
    }
}

@media (min-width: 1600px) {
    .screen {
        max-width: 1600px;
    }
}

/* ─────────────────────────────────────────────────────────────────────
   SCREEN HEADER
   ───────────────────────────────────────────────────────────────────── */
.screen-header {
    display: flex;
    align-items: center;
    gap: var(--spacing-md);
    padding: var(--spacing-sm) 0;
    margin-bottom: var(--spacing-md);
    border-bottom: 1px solid rgba(255, 215, 0, 0.2);
}

.screen-title {
    font-size: 1.5rem;
    font-weight: bold;
    color: var(--color-gold);
    text-shadow: 0 0 10px rgba(255, 215, 0, 0.5);
}

.screen-subtitle {
    font-size: 0.875rem;
    color: var(--color-text-muted);
    margin-top: var(--spacing-xs);
}

/* ─────────────────────────────────────────────────────────────────────
   UTILITY CLASSES
   ───────────────────────────────────────────────────────────────────── */
.text-gold { color: var(--color-gold); }
.text-success { color: var(--color-success); }
.text-danger { color: var(--color-danger); }
.text-muted { color: var(--color-text-muted); }
.text-center { text-align: center; }
.text-right { text-align: right; }
.text-bold { font-weight: bold; }
.text-small { font-size: 0.75rem; }
.text-xs { font-size: 0.625rem; }

.mt-sm { margin-top: var(--spacing-sm); }
.mt-md { margin-top: var(--spacing-md); }
.mt-lg { margin-top: var(--spacing-lg); }
.mb-sm { margin-bottom: var(--spacing-sm); }
.mb-md { margin-bottom: var(--spacing-md); }
.mb-lg { margin-bottom: var(--spacing-lg); }

.p-sm { padding: var(--spacing-sm); }
.p-md { padding: var(--spacing-md); }
.p-lg { padding: var(--spacing-lg); }

.flex { display: flex; }
.flex-col { flex-direction: column; }
.flex-1 { flex: 1; }
.items-center { align-items: center; }
.justify-center { justify-content: center; }
.justify-between { justify-content: space-between; }
.gap-sm { gap: var(--spacing-sm); }
.gap-md { gap: var(--spacing-md); }

.hidden { display: none !important; }
.visible { display: block; }

/* ─────────────────────────────────────────────────────────────────────
   SCROLLBAR STYLING
   ───────────────────────────────────────────────────────────────────── */
::-webkit-scrollbar {
    width: 6px;
    height: 6px;
}

::-webkit-scrollbar-track {
    background: rgba(255, 255, 255, 0.05);
    border-radius: 3px;
}

::-webkit-scrollbar-thumb {
    background: rgba(255, 255, 255, 0.2);
    border-radius: 3px;
}

::-webkit-scrollbar-thumb:hover {
    background: rgba(255, 255, 255, 0.3);
}

/* ─────────────────────────────────────────────────────────────────────
   ANIMATIONS
   ───────────────────────────────────────────────────────────────────── */
@keyframes pulse {
    0%, 100% { opacity: 1; }
    50% { opacity: 0.5; }
}

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

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

@keyframes fadeIn {
    from { opacity: 0; }
    to { opacity: 1; }
}

@keyframes scaleIn {
    from { transform: scale(0.9); opacity: 0; }
    to { transform: scale(1); opacity: 1; }
}

@keyframes legendaryGlow {
    0%, 100% { box-shadow: 0 0 15px rgba(255, 215, 0, 0.4); }
    50% { box-shadow: 0 0 25px rgba(255, 215, 0, 0.7); }
}

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

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

.animate-pulse { animation: pulse 1s infinite; }
.animate-slide-in { animation: slideIn 0.3s ease-out; }
.animate-slide-up { animation: slideUp 0.3s ease-out; }
.animate-fade-in { animation: fadeIn 0.2s ease-out; }
.animate-scale-in { animation: scaleIn 0.2s ease-out; }
