/* ─── CSS Variables & Modern Design System ────────────────────────────── */
:root {
    --bg-dark: #070913;
    --card-bg: rgba(15, 23, 42, 0.75);
    --card-border: rgba(0, 243, 255, 0.2);
    --card-border-glow: rgba(0, 243, 255, 0.5);
    
    --primary: #00f3ff;
    --primary-glow: rgba(0, 243, 255, 0.4);
    --secondary: #bc13fe;
    --secondary-glow: rgba(188, 19, 254, 0.4);
    --accent: #ff0055;
    --accent-glow: rgba(255, 0, 85, 0.4);
    --gold: #ffd700;
    
    --text-main: #f1f5f9;
    --text-muted: #94a3b8;
    
    --font-heading: 'Orbitron', sans-serif;
    --font-body: 'Rajdhani', sans-serif;
    
    --radius-lg: 16px;
    --radius-md: 10px;
    --radius-pill: 999px;
    
    --transition: all 0.25s cubic-bezier(0.4, 0, 0.2, 1);
}

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

body {
    background-color: var(--bg-dark);
    color: var(--text-main);
    font-family: var(--font-body);
    font-size: 16px;
    line-height: 1.5;
    min-height: 100vh;
    overflow-x: hidden;
    position: relative;
}

/* Background Canvas */
#space-canvas {
    position: fixed;
    top: 0;
    left: 0;
    width: 100vw;
    height: 100vh;
    z-index: -1;
    pointer-events: none;
}

/* Container */
.app-container {
    max-width: 1200px;
    margin: 0 auto;
    padding: 20px;
    display: flex;
    flex-direction: column;
    gap: 20px;
}

/* ─── Glassmorphism Card Style ────────────────────────────────────────── */
.glass-card {
    background: var(--card-bg);
    backdrop-filter: blur(16px);
    -webkit-backdrop-filter: blur(16px);
    border: 1px solid var(--card-border);
    border-radius: var(--radius-lg);
    padding: 24px;
    box-shadow: 0 8px 32px 0 rgba(0, 0, 0, 0.5), inset 0 0 0 1px rgba(255, 255, 255, 0.05);
    transition: var(--transition);
}

.glass-card:hover {
    border-color: var(--card-border-glow);
    box-shadow: 0 12px 40px 0 rgba(0, 243, 255, 0.15);
}

.glass-pill {
    background: rgba(255, 255, 255, 0.08);
    backdrop-filter: blur(8px);
    border: 1px solid rgba(255, 255, 255, 0.15);
    border-radius: var(--radius-pill);
    padding: 6px 16px;
}

/* ─── Typography & Utilities ───────────────────────────────────────────── */
h1, h2, h3, h4 {
    font-family: var(--font-heading);
    letter-spacing: 1px;
}

.highlight {
    color: var(--primary);
    text-shadow: 0 0 10px var(--primary-glow);
}

.hidden {
    display: none !important;
}

.card-desc {
    color: var(--text-muted);
    font-size: 15px;
    margin-bottom: 20px;
}

/* ─── Top Header ───────────────────────────────────────────────────────── */
.top-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 16px 24px;
}

.brand {
    display: flex;
    align-items: center;
    gap: 12px;
}

.logo-icon {
    font-size: 2rem;
    animation: float 4s ease-in-out infinite;
}

.logo-text {
    font-size: 1.8rem;
    font-weight: 900;
}

.subtitle {
    font-size: 12px;
    color: var(--text-muted);
    text-transform: uppercase;
    letter-spacing: 2px;
    display: block;
}

.user-bar {
    display: flex;
    align-items: center;
    gap: 12px;
}

.user-badge {
    display: flex;
    align-items: center;
    gap: 8px;
    font-weight: 600;
}

.icon-btn {
    background: rgba(255, 255, 255, 0.1);
    border: 1px solid rgba(255, 255, 255, 0.2);
    border-radius: var(--radius-md);
    color: var(--text-main);
    font-size: 18px;
    padding: 8px;
    cursor: pointer;
    transition: var(--transition);
}

.icon-btn:hover {
    background: var(--primary-glow);
    border-color: var(--primary);
}

/* ─── Buttons ──────────────────────────────────────────────────────────── */
.btn {
    font-family: var(--font-heading);
    font-size: 15px;
    font-weight: 700;
    padding: 12px 24px;
    border-radius: var(--radius-md);
    border: none;
    cursor: pointer;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    transition: var(--transition);
    text-transform: uppercase;
    letter-spacing: 1px;
}

.btn-primary {
    background: linear-gradient(135deg, var(--primary), #0088ff);
    color: #070913;
    box-shadow: 0 0 15px var(--primary-glow);
}

.btn-primary:hover {
    transform: translateY(-2px);
    box-shadow: 0 0 25px var(--primary-glow);
}

.btn-accent {
    background: linear-gradient(135deg, var(--accent), var(--secondary));
    color: #fff;
    box-shadow: 0 0 15px var(--accent-glow);
}

.btn-accent:hover {
    transform: translateY(-2px);
    box-shadow: 0 0 25px var(--accent-glow);
}

.btn-upgrade {
    width: 100%;
    background: rgba(0, 243, 255, 0.1);
    border: 1px solid var(--primary);
    color: var(--primary);
    padding: 10px;
    border-radius: var(--radius-md);
    margin-top: 12px;
}

.btn-upgrade:hover:not(:disabled) {
    background: var(--primary);
    color: #070913;
    box-shadow: 0 0 15px var(--primary-glow);
}

.btn-upgrade:disabled {
    opacity: 0.4;
    cursor: not-allowed;
    border-color: var(--text-muted);
    color: var(--text-muted);
}

.btn-large {
    width: 100%;
    padding: 16px;
    font-size: 16px;
}

/* ─── Screen 1: Login ─────────────────────────────────────────────────── */
.login-screen {
    display: flex;
    justify-content: center;
    align-items: center;
    min-height: 70vh;
}

.login-card {
    max-width: 550px;
    margin: 40px auto;
    text-align: center;
}

.login-card h2 {
    margin-bottom: 12px;
    color: var(--primary);
}

.login-form {
    display: flex;
    flex-direction: column;
    gap: 20px;
    margin-top: 24px;
}

.input-group {
    text-align: left;
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.input-group label {
    font-family: var(--font-heading);
    font-size: 13px;
    color: var(--text-muted);
    letter-spacing: 1px;
}

.input-group input {
    background: rgba(0, 0, 0, 0.4);
    border: 1px solid var(--card-border);
    border-radius: var(--radius-md);
    padding: 14px;
    color: #fff;
    font-family: var(--font-body);
    font-size: 18px;
    outline: none;
    transition: var(--transition);
}

.input-group input:focus {
    border-color: var(--primary);
    box-shadow: 0 0 15px var(--primary-glow);
}

.seed-preview-box {
    background: rgba(0, 0, 0, 0.3);
    border: 1px dashed var(--card-border);
    border-radius: var(--radius-md);
    padding: 16px;
    text-align: left;
}

.seed-preview-box h3 {
    font-size: 13px;
    color: var(--secondary);
    margin-bottom: 12px;
}

.params-preview-grid {
    display: grid;
    grid-template-columns: repeat(2, 1fr);
    gap: 8px;
    font-size: 14px;
}

.preview-param strong {
    color: var(--primary);
}

/* ─── Navigation Tabs ─────────────────────────────────────────────────── */
.nav-tabs {
    display: flex;
    gap: 8px;
    padding: 10px;
    overflow-x: auto;
}

.tab-btn {
    background: transparent;
    border: none;
    color: var(--text-muted);
    font-family: var(--font-heading);
    font-size: 14px;
    padding: 12px 20px;
    border-radius: var(--radius-md);
    cursor: pointer;
    transition: var(--transition);
    white-space: nowrap;
}

.tab-btn:hover {
    color: var(--text-main);
    background: rgba(255, 255, 255, 0.05);
}

.tab-btn.active {
    color: #070913;
    background: var(--primary);
    box-shadow: 0 0 15px var(--primary-glow);
    font-weight: 800;
}

/* ─── Grids ───────────────────────────────────────────────────────────── */
.grid-2col {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 20px;
}

@media (max-width: 850px) {
    .grid-2col {
        grid-template-columns: 1fr;
    }
}

/* ─── Tab 1: Clicker ──────────────────────────────────────────────────── */
.clicker-card {
    display: flex;
    flex-direction: column;
    align-items: center;
    text-align: center;
}

.clicker-area {
    margin: 30px 0;
    position: relative;
}

.clicker-node {
    width: 170px;
    height: 170px;
    border-radius: 50%;
    background: radial-gradient(circle, var(--primary) 0%, #0044ff 100%);
    border: 4px solid #fff;
    cursor: pointer;
    position: relative;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    color: #fff;
    box-shadow: 0 0 30px var(--primary-glow);
    transition: transform 0.1s cubic-bezier(0.175, 0.885, 0.32, 1.275);
    outline: none;
}

.clicker-node:active {
    transform: scale(0.92);
}

.pulse-ring {
    position: absolute;
    top: -15px;
    left: -15px;
    right: -15px;
    bottom: -15px;
    border-radius: 50%;
    border: 2px solid var(--primary);
    animation: pulse 2s cubic-bezier(0.4, 0, 0.6, 1) infinite;
}

.click-icon {
    font-size: 3.5rem;
}

.click-label {
    font-family: var(--font-heading);
    font-size: 13px;
    font-weight: 800;
    letter-spacing: 1px;
}

/* Floating click text animation */
.floating-click-text {
    position: absolute;
    color: var(--primary);
    font-family: var(--font-heading);
    font-weight: 900;
    font-size: 22px;
    pointer-events: none;
    animation: floatUp 0.8s ease-out forwards;
    text-shadow: 0 0 10px var(--primary-glow);
}

@keyframes floatUp {
    0% { opacity: 1; transform: translateY(0) scale(1); }
    100% { opacity: 0; transform: translateY(-60px) scale(1.3); }
}

@keyframes pulse {
    0%, 100% { opacity: 1; transform: scale(1); }
    50% { opacity: 0.3; transform: scale(1.1); }
}

@keyframes float {
    0%, 100% { transform: translateY(0); }
    50% { transform: translateY(-8px); }
}

.stats-mini-bar {
    display: flex;
    gap: 20px;
    width: 100%;
    justify-content: space-around;
    padding-top: 16px;
    border-top: 1px solid rgba(255, 255, 255, 0.1);
}

.mini-stat {
    display: flex;
    flex-direction: column;
    font-size: 14px;
    color: var(--text-muted);
}

.mini-stat strong {
    color: var(--text-main);
    font-size: 16px;
}

/* Resources List */
.resources-list {
    display: flex;
    flex-direction: column;
    gap: 12px;
}

.res-item {
    display: flex;
    justify-content: space-between;
    align-items: center;
    background: rgba(0, 0, 0, 0.3);
    padding: 12px 16px;
    border-radius: var(--radius-md);
    border: 1px solid rgba(255, 255, 255, 0.05);
}

.res-info {
    display: flex;
    align-items: center;
    gap: 12px;
}

.res-icon {
    font-size: 1.6rem;
}

.res-name {
    font-weight: 700;
}

.res-rate {
    font-size: 13px;
    color: var(--primary);
}

.res-amount {
    font-family: var(--font-heading);
    font-size: 18px;
    font-weight: 800;
    color: var(--gold);
}

/* Upgrades Section */
.upgrades-section {
    margin-top: 20px;
}

.upgrades-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(220px, 1fr));
    gap: 16px;
    margin-top: 16px;
}

.upgrade-card {
    background: rgba(0, 0, 0, 0.3);
    border: 1px solid rgba(255, 255, 255, 0.08);
    border-radius: var(--radius-md);
    padding: 16px;
    display: flex;
    flex-direction: column;
    justify-content: space-between;
}

.upg-header {
    display: flex;
    align-items: center;
    gap: 12px;
    margin-bottom: 10px;
}

.upg-icon {
    font-size: 2rem;
}

.upg-title {
    font-weight: 700;
    font-size: 15px;
}

.upg-level {
    font-size: 12px;
    color: var(--text-muted);
}

.upg-desc {
    font-size: 13px;
    color: var(--text-muted);
    line-height: 1.4;
    margin-bottom: 12px;
}

/* ─── Tab 2: Physics Laboratory ───────────────────────────────────────── */
.physics-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(320px, 1fr));
    gap: 20px;
    margin-top: 20px;
}

.phys-card {
    background: rgba(0, 0, 0, 0.4);
    border: 1px solid rgba(255, 255, 255, 0.1);
    border-radius: var(--radius-md);
    padding: 20px;
    position: relative;
    overflow: hidden;
}

.phys-card.discovered {
    border-color: var(--primary);
    box-shadow: inset 0 0 20px var(--primary-glow);
}

.phys-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 12px;
}

.phys-title {
    font-family: var(--font-heading);
    font-size: 16px;
    color: var(--primary);
}

.phys-val {
    font-family: var(--font-heading);
    font-size: 22px;
    font-weight: 900;
    color: var(--gold);
}

.phys-progress-bg {
    background: rgba(255, 255, 255, 0.1);
    height: 8px;
    border-radius: var(--radius-pill);
    overflow: hidden;
    margin-bottom: 12px;
}

.phys-progress-fill {
    height: 100%;
    background: linear-gradient(90deg, var(--primary), var(--secondary));
    border-radius: var(--radius-pill);
    transition: width 0.4s ease;
}

.phys-explanation {
    font-size: 13px;
    color: var(--text-muted);
    line-height: 1.4;
}

/* ─── Tab 3: Robot Hangar ─────────────────────────────────────────────── */
.robot-card {
    display: flex;
    flex-direction: column;
    align-items: center;
    text-align: center;
}

.robot-visual {
    margin: 20px 0;
}

.robot-avatar {
    font-size: 5rem;
    filter: drop-shadow(0 0 20px var(--primary-glow));
    animation: float 3s ease-in-out infinite;
}

.robot-stats-grid {
    display: grid;
    grid-template-columns: repeat(2, 1fr);
    gap: 12px;
    width: 100%;
    margin-top: 16px;
}

.stat-box {
    background: rgba(0, 0, 0, 0.3);
    border: 1px solid rgba(255, 255, 255, 0.08);
    border-radius: var(--radius-md);
    padding: 12px;
    display: flex;
    align-items: center;
    gap: 12px;
}

.stat-icon {
    font-size: 1.5rem;
}

.stat-name {
    font-size: 12px;
    color: var(--text-muted);
}

.stat-val {
    font-family: var(--font-heading);
    font-size: 18px;
    color: var(--text-main);
}

.build-card {
    display: flex;
    flex-direction: column;
    justify-content: space-between;
}

.build-info-box {
    background: rgba(0, 0, 0, 0.4);
    border-radius: var(--radius-md);
    padding: 20px;
    margin: 20px 0;
}

.cost-highlight {
    font-size: 20px;
    color: var(--gold);
}

.build-note {
    margin-top: 12px;
    font-size: 13px;
    color: var(--text-muted);
    line-height: 1.4;
}

/* ─── Tab 4: Arena ────────────────────────────────────────────────────── */
.arena-layout {
    display: flex;
    flex-direction: column;
    gap: 20px;
}

.arena-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    flex-wrap: wrap;
    gap: 16px;
}

.queue-status-bar {
    display: flex;
    justify-content: space-between;
    align-items: center;
    background: rgba(0, 0, 0, 0.3);
    padding: 10px 16px;
    border-radius: var(--radius-md);
    margin-top: 16px;
    font-size: 14px;
}

.status-tag {
    background: rgba(0, 243, 255, 0.15);
    color: var(--primary);
    border: 1px solid var(--primary);
    padding: 4px 12px;
    border-radius: var(--radius-pill);
    font-size: 12px;
    font-weight: 700;
}

.fighters-container {
    display: grid;
    grid-template-columns: 1fr auto 1fr;
    gap: 16px;
    align-items: center;
    margin: 20px 0;
}

.fighter-box {
    background: rgba(0, 0, 0, 0.4);
    border: 1px solid rgba(255, 255, 255, 0.1);
    border-radius: var(--radius-md);
    padding: 16px;
    text-align: center;
}

.f-name {
    font-family: var(--font-heading);
    font-weight: 800;
    font-size: 16px;
    color: var(--primary);
}

.f-owner {
    font-size: 13px;
    color: var(--text-muted);
    margin-bottom: 10px;
}

.hp-bar-container {
    background: rgba(255, 255, 255, 0.1);
    height: 14px;
    border-radius: var(--radius-pill);
    overflow: hidden;
    position: relative;
    border: 1px solid rgba(255, 255, 255, 0.2);
}

.hp-bar-fill {
    height: 100%;
    background: linear-gradient(90deg, #ff0055, #ff5500, #00ff66);
    border-radius: var(--radius-pill);
    transition: width 0.3s ease;
}

.hp-text {
    font-size: 12px;
    margin-top: 6px;
    font-weight: 600;
}

.vs-badge {
    font-family: var(--font-heading);
    font-size: 24px;
    font-weight: 900;
    color: var(--accent);
    text-shadow: 0 0 15px var(--accent-glow);
}

.arena-physics-tag {
    text-align: center;
    background: rgba(188, 19, 254, 0.15);
    border: 1px dashed var(--secondary);
    color: var(--secondary);
    padding: 8px;
    border-radius: var(--radius-md);
    font-size: 13px;
    font-weight: 600;
    margin-bottom: 16px;
}

.battle-log-feed {
    background: rgba(0, 0, 0, 0.6);
    border: 1px solid rgba(255, 255, 255, 0.1);
    border-radius: var(--radius-md);
    height: 220px;
    overflow-y: auto;
    padding: 14px;
    font-family: monospace;
    font-size: 13px;
    display: flex;
    flex-direction: column;
    gap: 6px;
}

.log-line {
    padding: 4px 8px;
    border-radius: 4px;
}

.log-line.header { color: var(--gold); font-weight: bold; }
.log-line.info { color: var(--primary); }
.log-line.round { color: var(--secondary); font-weight: bold; border-bottom: 1px dashed rgba(255,255,255,0.1); }
.log-line.atk1 { color: #60a5fa; }
.log-line.atk2 { color: #f87171; }
.log-line.victory { color: #4ade80; font-weight: bold; font-size: 15px; }

/* History List */
.history-list {
    display: flex;
    flex-direction: column;
    gap: 8px;
    margin-top: 14px;
    max-height: 180px;
    overflow-y: auto;
}

.history-item {
    display: flex;
    justify-content: space-between;
    align-items: center;
    background: rgba(0, 0, 0, 0.3);
    padding: 8px 14px;
    border-radius: var(--radius-md);
    font-size: 13px;
}

/* ─── Tab 5: Leaderboard ──────────────────────────────────────────────── */
.table-responsive {
    overflow-x: auto;
    margin-top: 16px;
}

.leaderboard-table {
    width: 100%;
    border-collapse: collapse;
    text-align: left;
}

.leaderboard-table th, .leaderboard-table td {
    padding: 14px 16px;
    border-bottom: 1px solid rgba(255, 255, 255, 0.08);
}

.leaderboard-table th {
    font-family: var(--font-heading);
    font-size: 13px;
    color: var(--primary);
    text-transform: uppercase;
}

.leaderboard-table tbody tr:hover {
    background: rgba(255, 255, 255, 0.03);
}

/* ─── Toast Notifications ─────────────────────────────────────────────── */
#toast-container {
    position: fixed;
    bottom: 20px;
    right: 20px;
    z-index: 9999;
    display: flex;
    flex-direction: column;
    gap: 10px;
    pointer-events: none;
}

.toast {
    background: var(--card-bg);
    backdrop-filter: blur(16px);
    border: 1px solid var(--primary);
    color: #fff;
    padding: 12px 20px;
    border-radius: var(--radius-md);
    box-shadow: 0 5px 20px rgba(0,0,0,0.5);
    font-family: var(--font-body);
    font-size: 14px;
    font-weight: 600;
    animation: toastIn 0.3s ease-out forwards;
    pointer-events: auto;
}

.toast.error { border-color: var(--accent); color: #ff88a8; }
.toast.success { border-color: #00ff66; color: #88ffaa; }

@keyframes toastIn {
    from { opacity: 0; transform: translateX(50px); }
    to { opacity: 1; transform: translateX(0); }
}
