/* Base Variables */
:root {
    --bg-color: #050a14;
    --text-primary: #e2e8f0;
    --text-secondary: #94a3b8;

    --primary-color: #3b82f6;
    /* Holo Blue */
    --primary-hover: #60a5fa;
    --neon-accent: #00f0ff;
    --danger-color: #ef4444;
    /* Imperial Red */

    --glass-bg: rgba(15, 23, 42, 0.6);
    --glass-border: rgba(255, 255, 255, 0.08);
    --glass-shadow: 0 8px 32px 0 rgba(0, 0, 0, 0.37);

    --font-heading: 'Outfit', sans-serif;
    --font-body: 'Inter', sans-serif;
}

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

body {
    background-color: var(--bg-color);
    background-image: radial-gradient(circle at 50% 0%, #111827 0%, #050a14 100%);
    color: var(--text-primary);
    font-family: var(--font-body);
    min-height: 100vh;
    overflow-x: hidden;
}

/* Background Stars Effect */
.stars-bg {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background-image: url('/imgs/hyperspace_bg.png');
    /* From Android app */
    background-size: cover;
    background-position: center;
    opacity: 0.15;
    z-index: -1;
    pointer-events: none;
}

/* Glassmorphism Classes */
.glass-header {
    background: var(--glass-bg);
    backdrop-filter: blur(12px);
    -webkit-backdrop-filter: blur(12px);
    border-bottom: 1px solid var(--glass-border);
    padding: 1rem 2rem;
    display: flex;
    justify-content: space-between;
    align-items: center;
    position: sticky;
    top: 0;
    z-index: 100;
}

.logo-container {
    display: flex;
    align-items: center;
    gap: 1rem;
}

.logo {
    height: 48px;
    width: auto;
    filter: drop-shadow(0 0 8px rgba(0, 240, 255, 0.3));
}

h1,
h2,
h3 {
    font-family: var(--font-heading);
}

h1 {
    font-size: 1.75rem;
    font-weight: 700;
    background: linear-gradient(135deg, #fff, #94a3b8);
    background-clip: text;
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    letter-spacing: 1px;
}

.header-status {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    font-size: 0.875rem;
    color: var(--neon-accent);
    font-family: var(--font-heading);
    text-transform: uppercase;
    letter-spacing: 1px;
}

.status-dot {
    width: 8px;
    height: 8px;
    background-color: var(--neon-accent);
    border-radius: 50%;
    box-shadow: 0 0 10px var(--neon-accent);
    animation: pulse-dot 2s infinite ease-in-out;
}

@keyframes pulse-dot {

    0%,
    100% {
        opacity: 1;
        box-shadow: 0 0 10px var(--neon-accent);
    }

    50% {
        opacity: 0.4;
        box-shadow: 0 0 2px var(--neon-accent);
    }
}

/* Main Layout */
.container {
    max-width: 1400px;
    margin: 0 auto;
    padding: 2rem;
}

.glass-panel {
    background: var(--glass-bg);
    backdrop-filter: blur(16px);
    -webkit-backdrop-filter: blur(16px);
    border: 1px solid var(--glass-border);
    border-radius: 16px;
    box-shadow: var(--glass-shadow);
    padding: 2rem;
}

.panel-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 2rem;
    padding-bottom: 1rem;
    border-bottom: 1px solid rgba(255, 255, 255, 0.05);
}

.panel-header h2 {
    font-size: 1.5rem;
    font-weight: 600;
}

/* Buttons */
.controls {
    display: flex;
    gap: 1rem;
}

.btn {
    padding: 0.6rem 1.25rem;
    border-radius: 8px;
    font-family: var(--font-heading);
    font-weight: 600;
    cursor: pointer;
    transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    border: none;
    display: inline-flex;
    align-items: center;
    gap: 0.5rem;
    font-size: 0.9rem;
}

.btn-primary {
    background: linear-gradient(135deg, var(--primary-color), #2563eb);
    color: white;
    box-shadow: 0 4px 14px rgba(59, 130, 246, 0.4);
}

.btn-primary:hover {
    transform: translateY(-2px);
    box-shadow: 0 6px 20px rgba(59, 130, 246, 0.6);
}

.btn-primary:active {
    transform: translateY(0);
}

.btn-secondary {
    background: rgba(255, 255, 255, 0.05);
    color: var(--text-primary);
    border: 1px solid var(--glass-border);
}

.btn-secondary:hover {
    background: rgba(255, 255, 255, 0.1);
}

/* Grid & Loading */
.games-grid {
    min-height: 400px;
    display: flex;
    justify-content: center;
    align-items: center;
}

.loading-state {
    text-align: center;
    color: var(--text-secondary);
}

.spinner {
    width: 48px;
    height: 48px;
    margin: 0 auto 1rem;
    border: 3px solid rgba(0, 240, 255, 0.1);
    border-radius: 50%;
    border-top-color: var(--neon-accent);
    animation: spin 1s ease-in-out infinite;
}

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

/* 
 * Game Cards 
 */
.games-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(400px, 1fr));
    gap: 1.5rem;
    align-items: start;
}

.game-card {
    background: rgba(15, 23, 42, 0.4);
    border: 1px solid var(--glass-border);
    border-radius: 12px;
    overflow: hidden;
    transition: transform 0.2s;
}

.game-card:hover {
    border-color: rgba(255, 255, 255, 0.15);
}

.game-header {
    background: rgba(0, 0, 0, 0.3);
    padding: 1rem;
    display: flex;
    justify-content: space-between;
    align-items: center;
    border-bottom: 1px solid var(--glass-border);
    font-family: var(--font-heading);
}

.game-info {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    font-size: 0.9rem;
}

.game-id {
    color: var(--text-secondary);
    font-family: monospace;
}

.game-type {
    padding: 2px 8px;
    border-radius: 4px;
    font-size: 0.75rem;
    font-weight: 700;
    text-transform: uppercase;
}

.game-type.premier {
    background: rgba(59, 130, 246, 0.2);
    color: #60a5fa;
}

.game-type.twinsuns {
    background: rgba(245, 158, 11, 0.2);
    color: #fbbf24;
}

.store-badge {
    background: rgba(255, 255, 255, 0.1);
    padding: 2px 8px;
    border-radius: 4px;
    font-size: 0.75rem;
}

.game-time {
    color: var(--text-secondary);
    font-size: 0.85rem;
}

/* Players Area */
.players-container {
    padding: 1rem;
    display: flex;
    flex-direction: column; /* This guarantees Player 1 is above Player 2 */
    gap: 1rem;
    width: 100%;
}

.player-row {
    position: relative;
    background: rgba(255, 255, 255, 0.02);
    border-radius: 8px;
    padding: 0.75rem;
    display: flex;
    flex-direction: row;        
    justify-content: space-between;
    align-items: stretch;       
    gap: 1rem;
    width: 100%;
    box-sizing: border-box; 
    flex-wrap: nowrap; /* Do not let the internal items wrap to a new line */
}

.player-cards {
    display: flex;
    gap: 1.5rem; /* Increased from 0.5rem to give more space between leaders and base */
    align-items: center;
    flex-wrap: nowrap; /* Do not wrap cards so they stay in a horizontal line */
}

.leaders-col {
    display: flex;
    flex-direction: column;
    justify-content: center;
    align-items: center;
    height: 114px; /* Match base-slot height */
}

.leaders-col .leader-circle + .leader-circle {
    margin-top: -6px; /* slight overlap so two 60px circles fit nicely in 114px */
}

.card-slot {
    position: relative;
    width: 60px;
    height: 84px;
    border-radius: 4px;
    /* removed overflow: hidden to let epic tokens peek outside */
    box-shadow: 0 4px 6px rgba(0, 0, 0, 0.5);
    background: #111;
}

/* Base specific larger scale */
.base-slot {
    width: 160px;
    height: 114px;
}

.base-slot .card-img {
    filter: brightness(0.5);
    object-fit: cover;
}

.card-img {
    width: 100%;
    height: 100%;
    object-fit: contain;
    display: block;
    border-radius: 4px;
}

/* Leader Circular Style */
.leader-circle {
    width: 60px;
    height: 60px;
    border-radius: 50%;
    border: 2px solid white;
    box-shadow: 0 4px 6px rgba(0, 0, 0, 0.3);
}

.leader-crop {
    width: 100%;
    height: 100%;
    border-radius: 50%;
    overflow: hidden;
    position: relative;
}

.leader-circle .card-img {
    width: 260%;
    height: 260%;
    object-fit: cover;
    transform: translate(1%, -12%);
    transform-origin: top left;
    position: absolute;
    top: 0;
    left: 0;
}

.life-overlay {
    position: absolute;
    bottom: 0;
    left: 0;
    width: 100%;
    background: rgba(0, 0, 0, 0.7);
    color: #fff;
    text-align: center;
    font-weight: bold;
    font-size: 1.2rem;
    padding: 2px 0;
    backdrop-filter: blur(2px);
    border-top: 1px solid var(--danger-color);
    border-bottom-left-radius: 4px;
    border-bottom-right-radius: 4px;
}

.base-slot .life-overlay {
    font-size: 3.5rem;
    height: 100%;
    display: flex;
    align-items: center;
    justify-content: center;
    background: transparent;
    border: none;
    backdrop-filter: none;
    text-shadow: 2px 2px 8px #000, -2px -2px 8px #000, 2px -2px 8px #000, -2px 2px 8px #000, 0 0 20px var(--danger-color);
}

.stat.points-stat {
    display: none; /* Removed as requested */
}

/* Epic Token Images */
.epic-star {
    position: absolute;
    width: 24px;
    height: 24px;
    z-index: 10;
    filter: drop-shadow(0 2px 4px rgba(0, 0, 0, 0.8));
}

.leader-epic-pos {
    bottom: -6px;
    right: -6px;
}

.base-epic-pos {
    bottom: -6px;
    right: -6px;
    width: 28px;
    height: 28px;
}

.player-stats {
    flex: 1;
    display: flex;
    flex-direction: column;
    justify-content: space-between;
    height: 114px; /* Match base-slot height */
    padding: 4px 0;
}

.player-name {
    font-weight: 600;
    font-family: var(--font-heading);
    font-size: 1.1rem;
    line-height: 1.2;
}

.stats-row {
    display: flex;
    align-items: center;
    gap: 1rem;
}

.stat {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    background: rgba(0, 0, 0, 0.4);
    padding: 4px 8px;
    border-radius: 6px;
    font-weight: bold;
}

.credits-stat {
    color: #ffd700;
}

.credit-icon {
    width: 16px;
    height: 16px;
}

.tokens-stat {
    gap: 0.25rem;
}

.token-icon {
    width: 20px;
    height: 20px;
    filter: drop-shadow(0 2px 2px rgba(0, 0, 0, 0.5));
}

/* Force CSS Token Canvas Replacement */
.force-css-token {
    width: 26px;
    height: 26px;
    border-radius: 50%;
    background: radial-gradient(circle, rgba(33, 150, 243, 0.4) 0%, rgba(0, 0, 0, 0.4) 100%);
    border: 2px solid #2196F3;
    display: flex;
    align-items: center;
    justify-content: center;
    position: relative;
    box-shadow: 0 0 8px rgba(33, 150, 243, 0.5);
    /* Space removed since it is now in a vertical column */
}

.force-css-token .force-pulse {
    position: absolute;
    width: 8px;
    height: 8px;
    background: #fff;
    border-radius: 50%;
    box-shadow: 0 0 10px rgba(255, 255, 255, 1);
    animation: force-pulse 2s cubic-bezier(0.4, 0, 0.2, 1) infinite;
}

.force-css-token span {
    position: absolute;
    bottom: -18px;
    font-size: 0.65rem;
    font-weight: 800;
    color: #fff;
    text-shadow: 0 1px 2px #000, 0 0 4px #2196f3;
    letter-spacing: 0.5px;
}

@keyframes force-pulse {
    0% {
        transform: scale(1);
        opacity: 0.8;
    }

    100% {
        transform: scale(3.5);
        opacity: 0;
    }
}

/* 
 * App Promo Box 
 */
.app-promo-box {
    position: fixed;
    bottom: 2rem;
    left: 2rem;
    background: rgba(15, 23, 42, 0.6);
    border: 1px solid var(--glass-border);
    border-radius: 12px;
    padding: 1rem;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 0.75rem;
    backdrop-filter: blur(10px);
    z-index: 100;
    box-shadow: 0 10px 25px rgba(0, 0, 0, 0.5);
    transition: transform 0.2s;
}

.app-promo-box:hover {
    transform: translateY(-2px);
    border-color: rgba(255, 255, 255, 0.15);
}

.promo-title {
    font-size: 0.85rem;
    font-weight: 600;
    color: var(--text-primary);
    text-align: center;
    line-height: 1.3;
}

.qr-container {
    background: white;
    padding: 4px;
    border-radius: 8px;
    display: flex;
}

.qr-code {
    width: 100px;
    height: 100px;
    display: block;
}

.promo-link {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    color: #60a5fa;
    text-decoration: none;
    font-size: 0.8rem;
    font-weight: bold;
    background: rgba(59, 130, 246, 0.1);
    padding: 0.5rem 0.75rem;
    border-radius: 8px;
    border: 1px solid rgba(59, 130, 246, 0.2);
    transition: background 0.2s;
}

.promo-link:hover {
    background: rgba(59, 130, 246, 0.2);
}

.promo-link img {
    filter: grayscale(1) brightness(2);
}

.promo-divider {
    width: 100%;
    height: 1px;
    background: rgba(255, 255, 255, 0.05);
    margin: 4px 0;
}

.promo-extra-links {
    display: flex;
    gap: 0.5rem;
    width: 100%;
}

.glass-link-small {
    flex: 1;
    text-align: center;
    background: rgba(255, 255, 255, 0.05);
    border: 1px solid var(--glass-border);
    padding: 6px;
    border-radius: 6px;
    font-size: 0.75rem;
    font-weight: 600;
    color: var(--text-secondary);
    text-decoration: none;
    transition: all 0.2;
}

.glass-link-small:hover {
    background: rgba(255, 255, 255, 0.1);
    color: var(--text-primary);
    border-color: rgba(255, 255, 255, 0.2);
}

/* 
 * Scoreboard Highlight Animations
 */
.highlight-green {
    color: #00ff88 !important;
    text-shadow: 0 0 15px rgba(0, 255, 136, 0.8);
    animation: highlight-pulse 0.8s ease-in-out infinite;
}

.highlight-red {
    color: #ff4444 !important;
    text-shadow: 0 0 15px rgba(255, 68, 68, 0.8);
    animation: highlight-pulse 0.8s ease-in-out infinite;
}

@keyframes highlight-pulse {
    0%, 100% { transform: scale(1); }
    50% { transform: scale(1.05); }
}

.player-points-floating {
    position: absolute;
    bottom: 0.6rem;
    right: 1.1rem;
    font-size: 2.8rem;
    font-weight: 800;
    color: #F57C00;
    font-family: var(--font-heading);
    line-height: 1;
    text-shadow: 0 0 15px rgba(245, 124, 0, 0.4), 2px 2px 4px #000;
    pointer-events: none;
    z-index: 10;
}

/* Ensure smooth transition back to normal */
.life-overlay, .credits-stat span {
    display: inline-block;
    transition: color 0.5s ease, text-shadow 0.5s ease, transform 0.3s ease;
}

.life-overlay {
    /* Ensure transform works on the absolute positioned overlay */
    transform-origin: center;
}