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

:root {
    --bg-primary: #0a0a0f;
    --bg-secondary: #151520;
    --bg-tertiary: #1f1f2e;
    --text-primary: #e0e0ff;
    --text-secondary: #a0a0c0;
    --accent-primary: #00d4ff;
    --accent-secondary: #ff00ff;
    --accent-success: #00ff88;
    --accent-warning: #ffaa00;
    --accent-danger: #ff4444;
    --border-color: #2a2a3e;
}

body {
    font-family: 'Segoe UI', system-ui, -apple-system, sans-serif;
    background: var(--bg-primary);
    color: var(--text-primary);
    overflow-x: hidden;
    min-height: 100vh;
    position: relative;
}

/* Animated background */
body::before {
    content: '';
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background:
        radial-gradient(circle at 20% 50%, rgba(0, 212, 255, 0.12), transparent 55%),
        radial-gradient(circle at 75% 35%, rgba(255, 0, 255, 0.12), transparent 55%),
        radial-gradient(circle at 40% 80%, rgba(0, 255, 136, 0.08), transparent 60%),
        linear-gradient(120deg, rgba(0, 212, 255, 0.05), rgba(255, 0, 255, 0.08));
    background-size: 200% 200%;
    background-position: 0% 0%;
    z-index: -1;
    animation: nebulaShift 60s ease-in-out infinite;
}

@keyframes nebulaShift {
    0% {
        background-position: 0% 0%;
    }

    50% {
        background-position: 100% 50%;
    }

    100% {
        background-position: 0% 0%;
    }
}

/* Header */
.header {
    background: var(--bg-secondary);
    padding: 1rem 2rem;
    border-bottom: 2px solid var(--border-color);
    display: flex;
    justify-content: space-between;
    align-items: center;
    flex-wrap: wrap;
    gap: 1rem;
}

.game-title {
    font-size: 2rem;
    font-weight: bold;
    background: linear-gradient(135deg, var(--accent-primary), var(--accent-secondary));
    -webkit-background-clip: text;
    background-clip: text;
    /* Standard property for compatibility */
    -webkit-text-fill-color: transparent;
    text-shadow: 0 0 30px rgba(0, 212, 255, 0.5);
}

.resources {
    display: flex;
    gap: 2rem;
    flex-wrap: wrap;
}

.resource {
    background: var(--bg-tertiary);
    padding: 0.75rem 1.5rem;
    border-radius: 10px;
    border: 1px solid var(--border-color);
    transition: all 0.3s ease;
    position: relative;
    overflow: hidden;
}

.resource:hover {
    transform: translateY(-2px);
    box-shadow: 0 5px 20px rgba(0, 212, 255, 0.3);
}

.resource-name {
    font-size: clamp(0.7rem, 2vw, 1rem);
    color: var(--text-secondary);
    margin-bottom: 0.25rem;
}

.resource-value {
    font-size: clamp(1.1rem, 4vw, 2.2rem);
    font-weight: bold;
    color: var(--accent-primary);
    text-shadow: 0 0 10px rgba(0, 212, 255, 0.5);
    word-break: break-all;
}

.resource-per-second {
    font-size: clamp(0.65rem, 1.5vw, 1rem);
    color: var(--accent-success);
    margin-top: 0.25rem;
    word-break: break-all;
}

.offline-summary {
    width: 100%;
    background: rgba(0, 212, 255, 0.08);
    border: 1px solid rgba(0, 212, 255, 0.3);
    border-radius: 10px;
    padding: 0.75rem 1rem;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 0.75rem;
}

.offline-summary-title {
    text-transform: uppercase;
    font-size: 0.8rem;
    letter-spacing: 0.08em;
    color: var(--accent-primary);
    margin-bottom: 0.25rem;
}

.offline-summary-body {
    font-size: 0.95rem;
    color: var(--text-primary);
}

.offline-summary-content {
    display: flex;
    flex-direction: column;
    gap: 0.15rem;
}

.offline-summary-close {
    background: transparent;
    border: none;
    color: var(--text-secondary);
    font-size: 1.5rem;
    cursor: pointer;
    transition: color 0.2s ease;
    line-height: 1;
}

.offline-summary-close:hover {
    color: var(--accent-danger);
}

/* Navigation Tabs */
.nav-tabs {
    background: var(--bg-secondary);
    padding: 0 2rem;
    display: flex;
    gap: 0.5rem;
    border-bottom: 2px solid var(--border-color);
    overflow-x: auto;
}

.nav-tab {
    padding: 1rem 1.5rem;
    background: transparent;
    border: none;
    color: var(--text-secondary);
    cursor: pointer;
    transition: color 0.2s ease, background 0.2s ease;
    position: relative;
    font-size: clamp(0.8rem, 2.5vw, 1.1rem);
    white-space: nowrap;
}

.nav-tab:hover {
    color: var(--text-primary);
    background: rgba(0, 212, 255, 0.1);
}

.nav-tab.active {
    color: var(--accent-primary);
}

.nav-tab.active::after {
    content: '';
    position: absolute;
    bottom: -2px;
    left: 0;
    right: 0;
    height: 2px;
    background: var(--accent-primary);
    box-shadow: 0 0 6px rgba(0, 212, 255, 0.35);
}

.nav-tab.prestige-ready:not(.active) {
    color: var(--accent-primary);
    text-shadow: 0 0 12px rgba(0, 212, 255, 0.5);
}

/* Main Content */
.main-content {
    padding: 2rem;
    max-width: 1400px;
    margin: 0 auto;
}

.tab-content {
    display: none;
    animation: fadeIn 0.5s ease;
}

.tab-content.active {
    display: block;
}

@keyframes fadeIn {
    from {
        opacity: 0;
        transform: translateY(10px);
    }

    to {
        opacity: 1;
        transform: translateY(0);
    }
}

/* Grid Layout */
.grid-container {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(300px, 1fr));
    gap: 1.5rem;
    margin-top: 2rem;
}

/* Cards */
.card {
    background: var(--bg-secondary);
    border: 1px solid var(--border-color);
    border-radius: 15px;
    padding: 1.5rem;
    transition: box-shadow 0.3s ease, border-color 0.3s ease;
    position: relative;
    overflow: hidden;
}

.card::before {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    height: 3px;
    background: linear-gradient(90deg, var(--accent-primary), var(--accent-secondary));
    transform: scaleX(0);
    transition: transform 0.3s ease;
}

.card:hover {
    box-shadow: 0 10px 30px rgba(0, 212, 255, 0.2);
    border-color: var(--accent-primary);
}

.card:hover::before {
    transform: scaleX(1);
}

.card-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 1rem;
}

.card-title {
    font-size: clamp(1rem, 3vw, 1.5rem);
    font-weight: bold;
    color: var(--text-primary);
}

.card-count {
    background: var(--bg-tertiary);
    padding: 0.25rem 0.75rem;
    border-radius: 20px;
    font-size: 0.875rem;
    color: var(--accent-primary);
}

.card-description {
    color: var(--text-secondary);
    font-size: clamp(0.8rem, 2vw, 1rem);
    margin-bottom: 1rem;
    line-height: 1.5;
}

.card-cost {
    background: var(--bg-tertiary);
    padding: 0.75rem;
    border-radius: 8px;
    margin-bottom: 1rem;
    font-size: clamp(0.75rem, 1.7vw, 1rem);
}

.cost-item {
    display: flex;
    justify-content: space-between;
    margin-bottom: 0.25rem;
}

.cost-item:last-child {
    margin-bottom: 0;
}

.btn {
    background: linear-gradient(135deg, var(--accent-primary), var(--accent-secondary));
    color: white;
    border: none;
    padding: 0.75rem 1.5rem;
    border-radius: 8px;
    font-size: clamp(0.9rem, 2.5vw, 1.1rem);
    font-weight: bold;
    cursor: pointer;
    transition: all 0.3s ease;
    width: 100%;
    position: relative;
    overflow: hidden;
}

.btn::before {
    content: '';
    position: absolute;
    top: 50%;
    left: 50%;
    width: 0;
    height: 0;
    background: rgba(255, 255, 255, 0.3);
    border-radius: 50%;
    transform: translate(-50%, -50%);
    transition: width 0.6s, height 0.6s;
}

.btn:hover::before {
    width: 300px;
    height: 300px;
}

.btn:hover {
    transform: translateY(-2px);
    box-shadow: 0 5px 20px rgba(0, 212, 255, 0.4);
}

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

.btn:disabled {
    background: var(--bg-tertiary);
    color: var(--text-secondary);
    cursor: not-allowed;
    opacity: 0.5;
}

.btn:disabled:hover {
    transform: none;
    box-shadow: none;
}

/* Progress Bars */
.progress-bar {
    background: var(--bg-tertiary);
    height: 8px;
    border-radius: 4px;
    overflow: hidden;
    margin-top: 0.5rem;
}

.progress-fill {
    height: 100%;
    background: linear-gradient(90deg, var(--accent-primary), var(--accent-secondary));
    border-radius: 4px;
    transition: width 0.3s ease;
    position: relative;
    overflow: hidden;
}

.progress-fill::after {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: linear-gradient(90deg, transparent, rgba(255, 255, 255, 0.3), transparent);
    animation: shimmer 2s infinite;
}

@keyframes shimmer {
    0% {
        transform: translateX(-100%);
    }

    100% {
        transform: translateX(100%);
    }
}

/* Achievement System */
.achievement {
    background: var(--bg-tertiary);
    border: 1px solid var(--border-color);
    border-radius: 10px;
    padding: 1rem;
    margin-bottom: 1rem;
    transition: all 0.3s ease;
    position: relative;
    overflow: hidden;
}

.achievement.unlocked {
    border-color: var(--accent-success);
    background: rgba(0, 255, 136, 0.1);
}

.achievement-icon {
    font-size: 2rem;
    margin-bottom: 0.5rem;
}

.achievement-name {
    font-weight: bold;
    margin-bottom: 0.25rem;
}

.achievement-description {
    font-size: 0.875rem;
    color: var(--text-secondary);
}

.achievement-reward {
    font-size: 0.85rem;
    color: var(--accent-primary);
    margin-top: 0.5rem;
}

.achievement.unlocked .achievement-reward {
    color: var(--accent-success);
}

/* Prestige Section */
.prestige-section {
    background: linear-gradient(135deg, rgba(255, 0, 255, 0.1), rgba(0, 212, 255, 0.1));
    border: 2px solid var(--accent-secondary);
    border-radius: 15px;
    padding: 2rem;
    margin-top: 2rem;
    text-align: center;
    position: relative;
    overflow: hidden;
}

.prestige-title {
    font-size: clamp(1.2rem, 5vw, 2rem);
    margin-bottom: 1rem;
    color: var(--accent-secondary);
}

.dark-matter-display {
    font-size: clamp(1.5rem, 7vw, 3rem);
    font-weight: bold;
    color: var(--accent-secondary);
    text-shadow: 0 0 20px rgba(255, 0, 255, 0.5);
    margin-bottom: 1rem;
}

.prestige-subtitle {
    color: var(--text-secondary);
    margin-bottom: 1.5rem;
}

.prestige-progress {
    display: grid;
    grid-template-columns: minmax(180px, 240px) 1fr;
    gap: 1rem;
    align-items: center;
    margin-bottom: 1.5rem;
}

.prestige-progress-ring {
    position: relative;
    width: 180px;
    height: 180px;
    margin: 0 auto;
}

.prestige-progress-ring svg {
    width: 100%;
    height: 100%;
    transform: rotate(-90deg);
}

.ring-bg {
    fill: none;
    stroke: rgba(255, 255, 255, 0.08);
    stroke-width: 12;
}

.ring-progress {
    fill: none;
    stroke: var(--accent-primary);
    stroke-width: 12;
    stroke-linecap: round;
    stroke-dasharray: 327;
    stroke-dashoffset: 327;
    transition: stroke-dashoffset 0.3s ease;
    filter: drop-shadow(0 0 8px rgba(0, 212, 255, 0.5));
}

.prestige-progress-value {
    position: absolute;
    inset: 0;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1.4rem;
    font-weight: 700;
    color: var(--accent-primary);
    text-shadow: 0 0 12px rgba(0, 212, 255, 0.5);
}

.prestige-progress-info {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(120px, 1fr));
    gap: 0.75rem;
}

.prestige-metric {
    padding: 0.75rem 1rem;
    background: rgba(0, 0, 0, 0.2);
    border: 1px solid var(--border-color);
    border-radius: 10px;
    text-align: left;
}

.prestige-metric .label {
    color: var(--text-secondary);
    font-size: 0.85rem;
}

.prestige-metric .value {
    font-size: 1.1rem;
    font-weight: 700;
    color: var(--text-primary);
}

/* Stats Section */
.stat-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
    gap: 1rem;
    margin-top: 1rem;
}

.stat-item {
    background: var(--bg-tertiary);
    padding: 1rem;
    border-radius: 8px;
    text-align: center;
    border: 1px solid transparent;
    transition: box-shadow 0.2s ease, border-color 0.2s ease;
}

.stat-label {
    font-size: clamp(0.7rem, 2vw, 1rem);
    color: var(--text-secondary);
    margin-bottom: 0.25rem;
}

.stat-value {
    font-size: clamp(1rem, 3vw, 1.25rem);
    font-weight: bold;
    color: var(--accent-primary);
}

.stat-section {
    background: var(--bg-secondary);
    border: 1px solid var(--border-color);
    border-radius: 12px;
    margin-bottom: 1rem;
    overflow: hidden;
    box-shadow: 0 6px 24px rgba(0, 0, 0, 0.25);
    transition: box-shadow 0.2s ease, border-color 0.2s ease;
}

.stat-section-header {
    width: 100%;
    background: linear-gradient(90deg, rgba(0, 212, 255, 0.08), rgba(255, 0, 255, 0.08));
    border: none;
    color: var(--text-primary);
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 0.9rem 1.1rem;
    font-size: 1rem;
    font-weight: 700;
    cursor: pointer;
}

.stat-section-header:focus-visible {
    outline: 2px solid var(--accent-primary);
    outline-offset: 2px;
}

.stat-caret {
    font-size: 1.1rem;
    transition: transform 0.2s ease;
}

.stat-section.collapsed .stat-caret {
    transform: rotate(-90deg);
}

.stat-section-body {
    overflow: hidden;
    transition: max-height 0.3s ease;
    padding: 0 1rem 1rem;
}

.stat-section.collapsed .stat-section-body {
    padding-bottom: 0;
}

.stat-section-body .stat-grid {
    margin-top: 0.75rem;
}

.stat-item:hover {
    box-shadow: 0 6px 16px rgba(0, 212, 255, 0.12);
    border-color: var(--accent-primary);
}

/* Notification System */
.notification {
    position: fixed;
    bottom: 2rem;
    right: 2rem;
    background: var(--bg-secondary);
    border: 1px solid var(--border-color);
    border-radius: 10px;
    padding: 1rem 1.5rem;
    box-shadow: 0 5px 20px rgba(0, 0, 0, 0.5);
    transform: translateX(400px);
    transition: transform 0.3s ease;
    z-index: 6000;
    /* FIX: Superiore a Prestige Overlay (4000) e Live Chart (5000) */
    max-width: 300px;
}

.notification.show {
    transform: translateX(0);
}

.notification-title {
    font-weight: bold;
    margin-bottom: 0.25rem;
    color: var(--accent-success);
}

.notification-message {
    font-size: 0.875rem;
    color: var(--text-secondary);
}

/* Attributions Section */
.attributions-card {
    max-width: 700px;
    margin: 2rem auto;
    background: linear-gradient(135deg, rgba(10, 10, 15, 0.8), rgba(21, 21, 32, 0.95));
    border: 1px solid rgba(0, 212, 255, 0.2);
}

.attributions-list {
    list-style: none;
    padding: 0;
    margin: 1.5rem 0;
    display: flex;
    flex-direction: column;
    gap: 1rem;
}

.attributions-list li {
    display: flex;
    justify-content: space-between;
    flex-wrap: wrap;
    gap: 0.5rem;
    padding-bottom: 0.75rem;
    border-bottom: 1px solid rgba(255, 255, 255, 0.05);
}

.attributions-list li:last-child {
    border-bottom: none;
    padding-bottom: 0;
}

.attributions-role {
    font-weight: 600;
    color: var(--accent-primary);
}

.attributions-name {
    color: var(--text-primary);
}

.attributions-divider {
    height: 1px;
    width: 100%;
    background: linear-gradient(90deg, transparent, rgba(0, 212, 255, 0.5), transparent);
    margin: 1.5rem 0;
    opacity: 0.6;
}

.attributions-line {
    font-size: 0.95rem;
    line-height: 1.6;
    color: var(--text-secondary);
    border-left: 3px solid var(--accent-warning);
    padding-left: 1rem;
}

/* Particle Effects */
.particle {
    position: fixed;
    pointer-events: none;
    opacity: 0;
    z-index: 999;
    font-weight: bold;
    color: #00ff88;
    animation: particleFloat 1s ease-out forwards;
}

@keyframes particleFloat {
    0% {
        opacity: 1;
        transform: translateY(0) scale(1);
    }

    100% {
        opacity: 0;
        transform: translateY(-100px) scale(0.5);
    }
}

/* Clicker Area */
.clicker-area {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    margin: 2rem auto;
    max-width: 500px;
}

.clicker-button {
    width: 250px;
    height: 250px;
    border-radius: 50%;
    background: linear-gradient(135deg, var(--bg-tertiary), var(--bg-secondary));
    border: 3px solid var(--accent-primary);
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    transition: all 0.2s ease;
    box-shadow: 0 0 30px rgba(0, 212, 255, 0.3);
    position: relative;
    overflow: hidden;
}

.clicker-button:hover {
    transform: scale(1.05);
    box-shadow: 0 0 40px rgba(0, 212, 255, 0.5);
}

.clicker-button:active {
    transform: scale(0.95);
}

.clicker-button::before {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: radial-gradient(circle, rgba(0, 212, 255, 0.2), transparent 70%);
    opacity: 0;
    transition: opacity 0.3s ease;
}

.clicker-button:active::before {
    opacity: 1;
}

.clicker-icon {
    font-size: clamp(2.2rem, 7vw, 4rem);
    margin-bottom: 0.5rem;
}

.clicker-text {
    font-size: clamp(1rem, 4vw, 1.5rem);
    font-weight: bold;
    color: var(--text-primary);
}

.clicker-value {
    font-size: clamp(0.9rem, 2.5vw, 1.2rem);
    color: var(--accent-success);
    margin-top: 0.5rem;
}

.clicker-upgrade {
    margin-top: 2rem;
    text-align: center;
    width: 100%;
}

/* Responsive Design */
@media (max-width: 768px) {
    .header {
        padding: 1rem;
    }

    .game-title {
        font-size: 1.5rem;
    }

    .resources {
        gap: 1rem;
    }

    .resource {
        padding: 0.5rem 1rem;
    }

    .nav-tabs {
        padding: 0 1rem;
    }

    .nav-tab {
        padding: 0.75rem 1rem;
        font-size: 0.875rem;
    }

    .main-content {
        padding: 1rem;
    }

    .grid-container {
        grid-template-columns: 1fr;
    }

    .clicker-button {
        width: 200px;
        height: 200px;
    }

    .clicker-icon {
        font-size: 3rem;
    }
}

/* Prestige Overlay */
.prestige-overlay {
    position: fixed;
    inset: 0;
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 4000;
}

.prestige-overlay-backdrop {
    position: absolute;
    inset: 0;
    background: radial-gradient(circle at 20% 20%, rgba(0, 212, 255, 0.2), transparent 40%), radial-gradient(circle at 80% 80%, rgba(255, 0, 255, 0.2), transparent 40%), rgba(10, 10, 15, 0.9);
    backdrop-filter: blur(4px);
}

.prestige-overlay-content {
    position: relative;
    background: var(--bg-secondary);
    border: 1px solid var(--border-color);
    border-radius: 16px;
    padding: 1.5rem;
    width: min(1100px, 95vw);
    max-height: 90vh;
    overflow: auto;
    box-shadow: 0 20px 50px rgba(0, 0, 0, 0.5);
}

.prestige-overlay-grid {
    display: grid;
    grid-template-columns: 1fr;
    gap: 1.5rem;
    position: relative;
    z-index: 1;
}

.prestige-overlay-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 1rem;
}

.overlay-eyebrow {
    text-transform: uppercase;
    letter-spacing: 0.12em;
    font-size: 0.7rem;
    color: var(--accent-secondary);
    margin-bottom: 0.35rem;
}

.prestige-overlay-header h2 {
    margin: 0;
    font-size: clamp(1.4rem, 3vw, 2.2rem);
    color: var(--text-primary);
}

.prestige-overlay-header p {
    color: var(--text-secondary);
    margin-top: 0.3rem;
}

.prestige-overlay-main {
    display: flex;
    flex-direction: column;
    gap: 1rem;
    position: relative;
    z-index: 1;
}

.prestige-stats {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
    gap: 1rem;
}

.stat-block {
    padding: 1rem;
    border: 1px solid var(--border-color);
    border-radius: 12px;
    background: var(--bg-tertiary);
}

.stat-block .label {
    color: var(--text-secondary);
    font-size: 0.9rem;
}

.stat-block .value {
    font-size: 1.4rem;
    font-weight: 700;
    color: var(--accent-primary);
    margin: 0.25rem 0;
}

.stat-block .note {
    color: var(--text-secondary);
    font-size: 0.85rem;
}

.prestige-deltas {
    padding: 1rem;
    border: 1px solid var(--border-color);
    border-radius: 12px;
    background: var(--bg-tertiary);
}

.delta-header {
    display: flex;
    align-items: baseline;
    justify-content: space-between;
    margin-bottom: 0.5rem;
}

.delta-header .label {
    font-weight: 700;
}

.delta-header .note {
    color: var(--text-secondary);
    font-size: 0.85rem;
}

.delta-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(120px, 1fr));
    gap: 0.75rem;
    margin-bottom: 0.75rem;
}

.delta-item {
    background: rgba(0, 0, 0, 0.15);
    border: 1px solid var(--border-color);
    border-radius: 10px;
    padding: 0.75rem;
    display: flex;
    align-items: center;
    justify-content: space-between;
    color: var(--text-secondary);
}

.delta-item strong {
    color: var(--accent-success);
    font-size: 1.2rem;
}

.plan-panel {
    padding: 0.75rem 1rem;
    border-radius: 10px;
    background: rgba(0, 212, 255, 0.08);
    border: 1px solid rgba(0, 212, 255, 0.25);
    color: var(--text-primary);
    font-size: 0.95rem;
    position: relative;
}

.plan-panel.pulse {
    box-shadow: 0 0 18px rgba(0, 212, 255, 0.35);
    border-color: rgba(0, 212, 255, 0.6);
}

.plan-status-inline {
    margin-top: 0.5rem;
    font-size: 0.85rem;
    color: var(--text-secondary);
}

.plan-settings {
    margin-top: 0.75rem;
    padding: 1rem;
    border-radius: 10px;
    background: rgba(0, 0, 0, 0.2);
    border: 1px solid var(--border-color);
    display: flex;
    flex-direction: column;
    gap: 0.6rem;
}

.plan-settings-header {
    font-weight: 600;
    font-size: 1.05rem;
}

.plan-settings-description {
    font-size: 0.9rem;
    color: var(--text-secondary);
    margin: 0;
}

.plan-delay-label {
    display: flex;
    justify-content: space-between;
    align-items: center;
    font-size: 0.9rem;
    color: var(--text-secondary);
}

.plan-delay-label span {
    color: var(--text-primary);
    font-weight: 600;
}

#planDelaySlider {
    width: 100%;
}

.plan-settings-actions {
    display: flex;
    flex-wrap: wrap;
    gap: 0.5rem;
}

.plan-settings-actions .btn {
    flex: 1 1 150px;
}

.plan-status {
    font-size: 0.9rem;
    color: var(--text-secondary);
}

.prestige-actions {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(150px, 1fr));
    gap: 0.75rem;
}

.prestige-controls {
    display: flex;
    align-items: center;
    justify-content: flex-start;
    gap: 0.5rem;
    color: var(--text-secondary);
    font-size: 0.9rem;
}

.prestige-overlay-visual {
    position: absolute;
    inset: 0;
    background: radial-gradient(circle at 50% 40%, rgba(0, 212, 255, 0.22), transparent 55%), var(--bg-tertiary);
    border-radius: 14px;
    overflow: hidden;
    pointer-events: none;
    opacity: 0.55;
    z-index: 0;
}

.canvas-shell {
    position: absolute;
    inset: 0;
}

#prestigeCanvas {
    position: absolute;
    inset: 0;
    width: 100%;
    height: 100%;
    display: block;
    filter: drop-shadow(0 0 10px rgba(0, 212, 255, 0.5));
}

.canvas-glow {
    position: absolute;
    inset: 0;
    background: radial-gradient(circle at 30% 30%, rgba(0, 212, 255, 0.12), transparent 45%), radial-gradient(circle at 70% 60%, rgba(255, 0, 255, 0.12), transparent 45%);
    mix-blend-mode: screen;
    pointer-events: none;
    animation: pulseGlow 6s ease-in-out infinite;
}

@keyframes pulseGlow {

    0%,
    100% {
        opacity: 0.6;
    }

    50% {
        opacity: 1;
    }
}

.btn.ghost {
    background: transparent;
    border: 1px solid var(--border-color);
    color: var(--text-primary);
    width: auto;
}

.btn.primary {
    background: linear-gradient(135deg, var(--accent-primary), var(--accent-secondary));
}

.btn.secondary {
    background: linear-gradient(135deg, var(--accent-warning), var(--accent-primary));
}

.btn.tertiary {
    background: var(--bg-tertiary);
    color: var(--text-primary);
    border: 1px solid var(--border-color);
}

/* Live Chart Overlay */
.live-chart-overlay {
    position: fixed;
    inset: 0;
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 5000;
}

.live-chart-backdrop {
    position: absolute;
    inset: 0;
    background: rgba(10, 10, 15, 0.9);
    backdrop-filter: blur(4px);
}

.live-chart-dialog {
    position: relative;
    background: var(--bg-secondary);
    border: 1px solid var(--border-color);
    border-radius: 16px;
    padding: 1.25rem;
    width: min(960px, 95vw);
    max-height: 90vh;
    height: min(90vh, 720px);
    display: flex;
    flex-direction: column;
    overflow: hidden;
    box-shadow: 0 18px 42px rgba(0, 0, 0, 0.55);
    z-index: 1;
}

.live-chart-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 1rem;
    margin-bottom: 0.75rem;
}

.live-chart-subtitle {
    color: var(--text-secondary);
    margin-top: 0.25rem;
}

.live-chart-legend {
    display: flex;
    gap: 1rem;
    flex-wrap: wrap;
    color: var(--text-secondary);
    font-size: 0.95rem;
    margin-bottom: 0.5rem;
}

.live-chart-legend span {
    display: inline-flex;
    align-items: center;
    gap: 0.4rem;
    padding: 0.25rem 0.6rem;
    border-radius: 999px;
    background: var(--bg-tertiary);
    border: 1px solid var(--border-color);
}

.live-chart-legend span::before {
    content: '';
    width: 12px;
    height: 12px;
    border-radius: 50%;
    display: inline-block;
}

.live-chart-legend span[data-series="minerals"]::before {
    background: #00d4ff;
}

.live-chart-legend span[data-series="energy"]::before {
    background: #ffaa00;
}

.live-chart-legend span[data-series="credits"]::before {
    background: #ff4d88;
}

.live-chart-controls {
    display: flex;
    align-items: center;
    gap: 1rem;
    margin-bottom: 0.8rem;
    flex-wrap: wrap;
}

.live-chart-control-label {
    font-size: 0.9rem;
    color: var(--text-secondary);
    display: flex;
    flex-direction: column;
    gap: 0.2rem;
}

.live-chart-control-label span {
    color: var(--text-primary);
    font-weight: 600;
    font-size: 1rem;
}

#liveChartWindow {
    flex: 1;
    min-width: 200px;
}

.live-chart-canvas-wrap {
    position: relative;
    background: var(--bg-tertiary);
    border: 1px solid var(--border-color);
    border-radius: 12px;
    overflow: hidden;
    flex: 1 1 320px;
    min-height: 0;
}

#liveChartCanvas {
    width: 100%;
    height: 100%;
    display: block;
}

.live-chart-tooltip {
    position: absolute;
    padding: 0.4rem 0.6rem;
    background: rgba(10, 10, 15, 0.95);
    border: 1px solid var(--border-color);
    border-radius: 8px;
    font-size: 0.85rem;
    color: var(--text-primary);
    pointer-events: none;
    transform: translate(-50%, -120%);
    white-space: nowrap;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.4);
}

.live-chart-tooltip strong {
    color: var(--accent-primary);
}

.live-chart-hint {
    color: var(--text-secondary);
    font-size: 0.9rem;
    margin-top: 0.75rem;
}

.toggle {
    display: inline-flex;
    align-items: center;
    gap: 0.5rem;
}

/* Colony Visualizer (v0.6.0) */
.colony-visualizer-card {
    background: var(--bg-secondary);
    border: 1px solid var(--accent-primary);
    border-radius: 15px;
    overflow: hidden;
    margin-bottom: 2rem;
    box-shadow: 0 0 20px rgba(0, 212, 255, 0.1);
    transition: all 0.3s ease;
}

/* Fullscreen Mode */
.colony-visualizer-card.fullscreen {
    position: fixed;
    top: 0;
    left: 0;
    width: 100vw;
    height: 100vh;
    z-index: 5000;
    border-radius: 0;
    border: none;
}

.colony-visualizer-card.fullscreen .colony-canvas-wrapper {
    height: calc(100vh - 60px);
    /* Subtract header height */
}

.colony-header {
    padding: 0.75rem 1.5rem;
    background: rgba(0, 212, 255, 0.05);
    border-bottom: 1px solid var(--border-color);
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.colony-controls {
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

.btn.small {
    padding: 0.25rem 0.6rem;
    font-size: 0.9rem;
    line-height: 1;
}

.colony-status {
    font-size: 0.7rem;
    text-transform: uppercase;
    letter-spacing: 1px;
    color: var(--accent-success);
    animation: pulseText 2s infinite;
    background: rgba(0, 255, 136, 0.1);
    padding: 0.2rem 0.5rem;
    border-radius: 4px;
}

@keyframes pulseText {

    0%,
    100% {
        opacity: 1;
    }

    50% {
        opacity: 0.5;
    }
}

.colony-canvas-wrapper {
    position: relative;
    width: 100%;
    height: 300px;
    /* Taller default height */
    background: radial-gradient(circle at 50% 120%, #1a1a2e 0%, #050508 80%);
    overflow: hidden;
    cursor: grab;
}

.colony-canvas-wrapper:active {
    cursor: grabbing;
}

#colonyCanvas {
    width: 100%;
    height: 100%;
    display: block;
}

.scan-line {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 2px;
    background: rgba(0, 212, 255, 0.3);
    box-shadow: 0 0 10px rgba(0, 212, 255, 0.5);
    animation: scanDown 8s linear infinite;
    pointer-events: none;
}

.colony-overlay-hint {
    position: absolute;
    bottom: 10px;
    right: 15px;
    font-size: 0.75rem;
    color: rgba(255, 255, 255, 0.3);
    pointer-events: none;
    user-select: none;
}

@keyframes scanDown {
    0% {
        top: -5%;
        opacity: 0;
    }

    10% {
        opacity: 1;
    }

    90% {
        opacity: 1;
    }

    100% {
        top: 105%;
        opacity: 0;
    }
}

/* Database / Codex Styles */
.database-container {
    display: flex;
    flex-direction: column;
    gap: 2rem;
    margin-top: 1.5rem;
}

.db-section {
    display: flex;
    flex-direction: column;
    gap: 1rem;
}

.db-section-title {
    font-size: 1.2rem;
    font-weight: bold;
    color: var(--text-primary);
    border-bottom: 1px solid var(--border-color);
    padding-bottom: 0.5rem;
    text-transform: uppercase;
    letter-spacing: 2px;
}

.db-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(300px, 1fr));
    gap: 1rem;
}

.db-entry {
    background: rgba(255, 255, 255, 0.03);
    border-left: 4px solid var(--border-color);
    /* Thicker border */
    padding: 1.2rem;
    border-radius: 0 8px 8px 0;
    transition: all 0.2s ease;
    height: 100%;
    /* Uniform height */
}

.db-entry:hover {
    background: rgba(255, 255, 255, 0.06);
    transform: translateX(5px);
}

/* Type-specific accents */
.db-entry.type-building {
    border-left-color: var(--accent-primary);
}

/* Cyan */
.db-entry.type-research {
    border-left-color: var(--accent-secondary);
}

/* Purple/Pink */
.db-entry.type-upgrade {
    border-left-color: var(--accent-warning);
}

/* Orange/Gold */

.db-header {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    margin-bottom: 0.75rem;
}

.db-icon {
    font-size: 1.8rem;
    background: rgba(0, 0, 0, 0.3);
    width: 40px;
    height: 40px;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: 8px;
}

.db-title {
    font-weight: bold;
    color: var(--text-primary);
    font-size: 1.1rem;
}

.db-lore {
    font-style: italic;
    color: var(--text-secondary);
    font-size: 0.9rem;
    margin-bottom: 0.75rem;
    line-height: 1.5;
    border-left: 2px solid rgba(255, 255, 255, 0.1);
    padding-left: 0.75rem;
}

.db-stats {
    font-size: 0.85rem;
    color: var(--accent-success);
    font-family: 'Segoe UI', monospace;
    background: rgba(0, 0, 0, 0.2);
    padding: 0.5rem;
    border-radius: 4px;
}

/* --- LANDING SCREEN STYLES (v0.7.1) --- */
.landing-overlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: radial-gradient(circle at 50% 30%, #1a1a2e 0%, #050508 80%);
    z-index: 9999;
    display: flex;
    align-items: center;
    justify-content: center;
    text-align: center;
    transition: opacity 0.8s ease, visibility 0.8s;
    padding: 1rem;
}

.landing-overlay.hidden {
    opacity: 0;
    visibility: hidden;
    pointer-events: none;
}

.landing-content {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 1.5rem;
    animation: floatIn 1s ease-out;
    width: 100%;
    max-width: 400px;
}

.landing-title {
    font-size: clamp(2.5rem, 8vw, 4rem);
    font-weight: 800;
    background: linear-gradient(135deg, #00d4ff, #ff00ff);
    -webkit-background-clip: text;
    background-clip: text;
    -webkit-text-fill-color: transparent;
    text-shadow: 0 0 50px rgba(0, 212, 255, 0.4);
    margin: 0;
    letter-spacing: 2px;
    line-height: 1.1;
}

.landing-subtitle {
    font-size: 1rem;
    color: var(--text-secondary);
    letter-spacing: 4px;
    text-transform: uppercase;
    margin-bottom: 1rem;
}

.landing-input-group {
    width: 100%;
    text-align: left;
    margin-bottom: 0.5rem;
}

.landing-input {
    width: 100%;
    background: rgba(255, 255, 255, 0.05);
    border: 1px solid var(--border-color);
    border-radius: 8px;
    padding: 1rem;
    color: var(--text-primary);
    font-size: 1.1rem;
    font-family: inherit;
    text-align: center;
    transition: all 0.3s ease;
    outline: none;
}

.landing-input:focus {
    border-color: var(--accent-primary);
    box-shadow: 0 0 15px rgba(0, 212, 255, 0.2);
    background: rgba(255, 255, 255, 0.1);
}

.language-select {
    width: 100%;
    background: rgba(255, 255, 255, 0.05);
    border: 1px solid var(--border-color);
    border-radius: 8px;
    padding: 0.65rem 0.9rem;
    color: var(--text-primary);
    font-size: 0.95rem;
    font-family: inherit;
    outline: none;
    transition: all 0.2s ease;
}

.language-select:focus {
    border-color: var(--accent-primary);
    box-shadow: 0 0 12px rgba(0, 212, 255, 0.2);
    background: rgba(255, 255, 255, 0.1);
}

.language-select option {
    background: var(--bg-secondary);
    color: var(--text-primary);
}

html[dir="rtl"] .language-select {
    text-align: right;
}

.landing-btn {
    padding: 1rem 2rem;
    font-size: 1.1rem;
    letter-spacing: 1px;
    width: 100%;
    background: linear-gradient(135deg, var(--accent-primary), var(--accent-secondary));
    border: none;
    color: #fff;
    font-weight: bold;
    box-shadow: 0 0 20px rgba(0, 212, 255, 0.2);
    transition: all 0.3s ease;
}

.landing-btn:hover {
    transform: translateY(-2px);
    box-shadow: 0 0 30px rgba(0, 212, 255, 0.5);
}

@keyframes floatIn {
    from {
        opacity: 0;
        transform: translateY(20px);
    }

    to {
        opacity: 1;
        transform: translateY(0);
    }
}

/* --- NUOVO SISTEMA RISORSE CENTRALIZZATO --- */

.header {
    display: flex;
    flex-direction: column;
    align-items: center;
    /* Centra tutto il contenuto dell'header */
    padding: 1.5rem;
    background: linear-gradient(to b, rgba(10, 10, 15, 0.95), rgba(20, 20, 30, 0.8));
    border-bottom: 1px solid var(--border-color);
}

.resource-center-container {
    width: 100%;
    max-width: 900px;
    display: flex;
    flex-direction: column;
    gap: 1rem;
    margin-top: 1rem;
}

.resource-main-row {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    /* Tre colonne uguali */
    gap: 1.5rem;
}

/* Stile card risorse */
.resource-card {
    background: rgba(255, 255, 255, 0.03);
    padding: 1rem;
    border-radius: 12px;
    text-align: center;
    border-top: 2px solid transparent;
    transition: transform 0.2s, background 0.2s;
    box-shadow: 0 4px 15px rgba(0, 0, 0, 0.2);
}

.resource-card:hover {
    background: rgba(255, 255, 255, 0.06);
    transform: translateY(-2px);
}

/* Colori specifici richiesti */
.resource-card.minerals {
    border-top-color: #00d4ff;
    /* Azzurro */
    box-shadow: inset 0 0 10px rgba(0, 212, 255, 0.1);
}

.resource-card.minerals .res-value {
    color: #00d4ff;
    text-shadow: 0 0 10px rgba(0, 212, 255, 0.5);
}

.resource-card.energy {
    border-top-color: #ffaa00;
    /* Giallo/Ambra */
    box-shadow: inset 0 0 10px rgba(255, 170, 0, 0.1);
}

.resource-card.energy .res-value {
    color: #ffaa00;
    text-shadow: 0 0 10px rgba(255, 170, 0, 0.5);
}

.resource-card.credits {
    border-top-color: #ff4d4d;
    /* Rosso */
    box-shadow: inset 0 0 10px rgba(255, 77, 77, 0.1);
}

.resource-card.credits .res-value {
    color: #ff4d4d;
    text-shadow: 0 0 10px rgba(255, 77, 77, 0.5);
}

/* Testi interni alle card */
.res-label {
    font-size: 0.75rem;
    text-transform: uppercase;
    letter-spacing: 2px;
    color: var(--text-secondary);
    margin-bottom: 0.25rem;
}

.res-value {
    font-size: 1.8rem;
    font-weight: 800;
    font-family: 'Segoe UI', Roboto, sans-serif;
}

.res-ps {
    font-size: 0.85rem;
    opacity: 0.8;
    margin-top: 0.2rem;
}

/* Stile Dark Matter (Sotto le risorse) */
.resource-dark-matter-row {
    display: flex;
    justify-content: center;
    margin-top: 0.5rem;
}

.dark-matter-display {
    background: linear-gradient(90deg, rgba(147, 51, 234, 0.1), rgba(79, 70, 229, 0.1));
    padding: 0.5rem 2rem;
    border-radius: 50px;
    border: 1px solid rgba(147, 51, 234, 0.3);
    display: flex;
    align-items: center;
    gap: 0.75rem;
    box-shadow: 0 0 15px rgba(147, 51, 234, 0.2);
}

.dm-icon {
    font-size: 1.2rem;
}

.dm-label {
    color: #c084fc;
    font-weight: 600;
    font-size: 0.9rem;
    text-transform: uppercase;
}

.dm-value {
    color: #e9d5ff;
    font-weight: 800;
    font-size: 1.1rem;
}

/* Responsive per mobile */
@media (max-width: 600px) {
    .resource-main-row {
        grid-template-columns: 1fr;
        /* Una colonna su mobile */
        gap: 0.75rem;
    }

    .res-value {
        font-size: 1.5rem;
    }
}

/* --- TECH TREE SYSTEM - IMMERSIVE & SEAMLESS --- */

.tab-content.active.full-height {
    display: flex !important;
    flex-direction: column;

    /* Forza l'espansione totale */
    width: 100vw;
    position: relative;
    left: 50%;
    right: 50%;
    margin-left: -50vw;
    margin-right: -50vw;

    /* ELIMINA LA FASCIA VUOTA: offset del padding di .main-content */
    margin-top: -2rem;

    /* Calcolo altezza precisa per tappare il buco in fondo */
    height: calc(100vh - 180px);
    /* Regola i pixel se l'header è diverso */
    min-height: 500px;

    background: var(--bg-primary);
    overflow: hidden;
}

.tech-tree-container {
    position: relative;
    flex: 1;
    width: 100%;
    height: 100%;
    background: radial-gradient(circle at center, #0f2a4a 0%, #0a1a2a 100%);
    cursor: grab;
}

/* --- STILE ORIGINALE DM SHOP (RIPRISTINATO) --- */

.dm-float-group {
    position: absolute;
    top: 25px;
    right: 25px;
    display: flex;
    flex-direction: column;
    align-items: flex-end;
    gap: 0.6rem;
    pointer-events: none;
    z-index: 20;
}

.dm-float-balance {
    background: rgba(10, 10, 20, 0.85);
    border: 1px solid #9d4edd;
    /* Viola originale */
    padding: 0.6rem 1.4rem;
    border-radius: 30px;
    font-weight: 800;
    font-size: 1.15rem;
    color: #c77dff;
    box-shadow: 0 0 20px rgba(157, 78, 221, 0.3), inset 0 0 10px rgba(157, 78, 221, 0.2);
    pointer-events: auto;
    backdrop-filter: blur(5px);
    letter-spacing: 1px;
}

.dm-float-notice {
    font-size: 0.8rem;
    color: var(--text-secondary);
    background: rgba(0, 0, 0, 0.6);
    padding: 0.4rem 0.9rem;
    border-radius: 8px;
    border: 1px solid rgba(255, 255, 255, 0.1);
    font-style: italic;
    backdrop-filter: blur(3px);
}

/* Overlay stile */
.tech-tree-overlay {
    position: absolute;
    bottom: 25px;
    left: 25px;
    width: 330px;
    max-width: calc(100% - 50px);
    background: rgba(10, 15, 25, 0.97);
    border: 1px solid var(--accent-primary);
    border-radius: 12px;
    padding: 1.3rem;
    pointer-events: auto;
    box-shadow: 0 15px 50px rgba(0, 0, 0, 0.9);
    backdrop-filter: blur(15px);
    z-index: 20;
}

/* --- MINING VISUALIZER STYLES (Immersive) --- */

#clicker.tab-content.full-height {
    min-height: 500px;
}

#miningContainer {
    width: 100%;
    height: 100%;
    min-height: clamp(320px, 55vh, 900px);
}

#clicker.tab-content.active.full-height #miningContainer {
    width: 100%;
    height: 100%;
    min-height: clamp(320px, 55vh, 900px);
}

.mining-scene-container {
    position: relative;
    display: block;
    flex: 1 1 auto;
    min-height: 320px;
    width: 100%;
    height: 100%;
    background: #0a0a0f;
    overflow: hidden;
    isolation: isolate;
    contain: layout paint size;
    cursor: url('data:image/svg+xml;utf8,<svg xmlns="http://www.w3.org/2000/svg" width="24" height="24" viewBox="0 0 24 24" fill="none" stroke="%2300d4ff" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"><circle cx="12" cy="12" r="10"></circle><line x1="12" y1="8" x2="12" y2="16"></line><line x1="8" y1="12" x2="16" y2="12"></line></svg>') 12 12, crosshair;
    touch-action: none;
}

.mining-scene-container.active-focus {
    cursor: none;
}

/* FIXED: Explicit positioning context and overflow handling */
#miningContainer {
    position: relative;
    width: 100%;
    height: 100%;
    min-height: 400px; /* Crucial: Prevents 0-height collapse */
    overflow: hidden;
    background: #05070c; /* Fallback color matching 3D bg */
    z-index: 1;
}

#miningCanvas {
    display: block;
    width: 100%;
    height: 100%;
    position: absolute;
    top: 0;
    left: 0;
    outline: none;
    z-index: 0;
}

.mining-overlay {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    z-index: 10;
    pointer-events: none; /* Let clicks pass through to canvas */
}

/* Allow interaction with specific UI elements inside overlay */
.mining-status, .mining-controls {
    pointer-events: auto;
}

/* Fix per i Canvas dei Tech Tree su mobile */
#upgradesCanvas,
#researchCanvas,
#dmCanvas {
    touch-action: none;
}

.mining-overlay {
    position: absolute;
    inset: 0;
    pointer-events: none;
    z-index: 10;
}

.mining-reticle {
    position: absolute;
    top: 50%;
    left: 50%;
    width: 20px;
    height: 20px;
    transform: translate(-50%, -50%);
    pointer-events: none;
    z-index: 20;
    opacity: 0.95;
    transition: opacity 0.15s ease, transform 0.15s ease, filter 0.15s ease;
}

.mining-reticle.is-hidden {
    opacity: 0.28;
}

.mining-reticle.is-locked {
    filter: drop-shadow(0 0 12px rgba(0, 212, 255, 0.7));
    transform: translate(-50%, -50%) scale(1.02);
}

.mining-reticle::before,
.mining-reticle::after {
    content: '';
    position: absolute;
    background: rgba(255, 255, 255, 0.8);
    left: 50%;
    top: 50%;
    transform: translate(-50%, -50%);
}

.mining-reticle::before {
    width: 2px;
    height: 100%;
}

.mining-reticle::after {
    width: 100%;
    height: 2px;
}

.mining-status {
    position: absolute;
    top: 20px;
    left: 20px;
    z-index: 25;
    pointer-events: auto;

    background: rgba(10, 15, 25, 0.85);
    backdrop-filter: blur(8px);
    padding: 0.6rem 1.2rem;
    border-radius: 30px;
    border: 1px solid var(--accent-success);
    box-shadow: 0 4px 20px rgba(0, 255, 136, 0.15);
}

.mining-value-display {
    font-size: 1.1rem;
    font-weight: 700;
    color: var(--accent-success);
    display: flex;
    align-items: center;
    gap: 0.6rem;
    letter-spacing: 0.5px;
    pointer-events: auto;
}

.mining-controls {
    position: absolute;
    bottom: 30px;
    left: 50%;
    transform: translateX(-50%);
    z-index: 25;
    pointer-events: auto;

    width: 100%;
    max-width: 400px;
    animation: slideUp 0.5s ease-out;
}

.mining-upgrade-panel {
    background: rgba(10, 15, 25, 0.9);
    backdrop-filter: blur(10px);
    border: 1px solid var(--border-color);
    border-radius: 16px;
    padding: 1rem;
    text-align: center;
    box-shadow: 0 10px 40px rgba(0, 0, 0, 0.6);
    transition: transform 0.2s;
}

.mining-upgrade-panel:hover {
    transform: translateY(-2px);
    border-color: var(--accent-primary);
}

.upgrade-info {
    margin-bottom: 0.8rem;
    color: var(--text-secondary);
    font-size: 0.95rem;
    font-weight: 600;
}

.upgrade-info .separator {
    margin: 0 0.5rem;
    opacity: 0.4;
}

.mining-instructions {
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    text-align: center;
    color: rgba(255, 255, 255, 0.7);
    pointer-events: none;
    z-index: 15;
    transition: opacity 0.3s;
    background: rgba(0, 0, 0, 0.6);
    padding: 20px;
    border-radius: 10px;
    border: 1px solid rgba(255, 255, 255, 0.1);
}

.mining-instructions--corner {
    top: 20px;
    left: auto;
    right: 20px;
    transform: none;
    text-align: right;
    max-width: min(480px, 60vw);
    padding: 0.7rem 0.9rem;
    border-radius: 12px;
    font-size: 0.82rem;
    line-height: 1.45;
    opacity: 0.9;
}

.mining-instructions.is-faded {
    opacity: 0.18;
}

.pointer-locked .mining-instructions {
    opacity: 0;
}

@media (max-width: 768px) {
    .mining-instructions--corner {
        right: 12px;
        left: 12px;
        bottom: 120px;
        top: auto;
        max-width: none;
        text-align: center;
    }
}

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

    to {
        opacity: 1;
        transform: translateY(0);
    }
}

/* Scossa schermo al colpo */
@keyframes shakeScreen {
    0% {
        transform: translate(0, 0);
    }

    20% {
        transform: translate(-3px, 3px);
    }

    40% {
        transform: translate(3px, -3px);
    }

    60% {
        transform: translate(-2px, 2px);
    }

    80% {
        transform: translate(1px, -1px);
    }

    100% {
        transform: translate(0, 0);
    }
}

.mining-scene-container.shake canvas {
    animation: shakeScreen 0.15s ease-out;
}

/* Floating Text */
.floating-text {
    position: absolute;
    pointer-events: none;
    color: #00d4ff;
    font-weight: bold;
    font-size: 1.5rem;
    text-shadow: 0 0 10px rgba(0, 212, 255, 0.8);
    white-space: nowrap;
    z-index: 100;
    transition: opacity 0.2s;
    will-change: transform, opacity;
}

/* 3D Mining Overlay Text */
.mining-damage-text {
    position: absolute;
    pointer-events: none;
    color: #fff;
    font-size: 1.5rem;
    font-weight: 800;
    text-shadow: 0 0 5px #00d4ff, 0 0 10px #000;
    animation: driftFade 0.8s cubic-bezier(0.2, 1, 0.3, 1) forwards;
    transform: translate(-50%, -50%);
    z-index: 1000;
    user-select: none;
}

.mining-float-text {
    position: absolute;
    pointer-events: none;
    color: #d8f9ff;
    font-size: 1rem;
    font-weight: 700;
    text-shadow: 0 0 6px rgba(0, 212, 255, 0.7), 0 0 12px rgba(0, 0, 0, 0.8);
    white-space: nowrap;
    z-index: 1000;
    transform: translate(-50%, -50%);
    will-change: transform, opacity, left, top;
    /* FIX: animation was defined but never applied */
    animation: driftFade 1s ease-out forwards;
    --drift-x: 0px;
    --drift-y: 0px;
}

@keyframes driftFade {
    0% {
        opacity: 0;
        transform: translate(-50%, -50%) scale(0.5);
    }

    15% {
        opacity: 1;
        transform: translate(-50%, -50%) scale(1.2);
    }

    100% {
        opacity: 0;
        transform: translate(calc(-50% + var(--drift-x)), calc(-50% - 80px + var(--drift-y))) scale(0.9);
    }
}

/* Mining Fallback Overlay ⚠️ shown when 3D engine fails */
.mining-fallback {
    position: absolute;
    inset: 0;
    z-index: 100;
    display: flex;
    align-items: center;
    justify-content: center;
    background: rgba(5, 7, 12, 0.92);
    backdrop-filter: blur(6px);
}

.mining-fallback-content {
    text-align: center;
    padding: 2rem;
    max-width: 320px;
}

.mining-fallback-icon {
    font-size: 3rem;
    margin-bottom: 1rem;
    opacity: 0.7;
}

.mining-fallback-title {
    font-size: 1.15rem;
    font-weight: 700;
    color: var(--text-primary, #e8e8f0);
    margin-bottom: 0.5rem;
}

.mining-fallback-msg {
    font-size: 0.9rem;
    color: var(--text-secondary, #9898b0);
    line-height: 1.5;
    margin-bottom: 1.25rem;
}

.mining-fallback-retry {
    min-width: 120px;
}

/* Mining D-Pad (mobile touch controls) */
.mining-dpad {
    position: absolute;
    bottom: 18px;
    right: 18px;
    width: 130px;
    height: 130px;
    z-index: 900;
    pointer-events: none;
    user-select: none;
    -webkit-user-select: none;
    opacity: 0.72;
}
.dpad-btn {
    position: absolute;
    width: 42px;
    height: 42px;
    border: none;
    border-radius: 8px;
    background: rgba(255,255,255,0.12);
    color: rgba(255,255,255,0.8);
    font-size: 18px;
    display: flex;
    align-items: center;
    justify-content: center;
    pointer-events: auto;
    touch-action: manipulation;
    -webkit-tap-highlight-color: transparent;
    backdrop-filter: blur(4px);
    -webkit-backdrop-filter: blur(4px);
    transition: background 0.1s, transform 0.08s;
}
.dpad-btn.active {
    background: rgba(0,212,255,0.35);
    transform: scale(0.92);
}
.dpad-up    { left: 50%; top: 0;   transform: translateX(-50%); }
.dpad-down  { left: 50%; bottom:0; transform: translateX(-50%); }
.dpad-left  { left: 0;   top: 50%; transform: translateY(-50%); }
.dpad-right { right: 0;  top: 50%; transform: translateY(-50%); }
.dpad-up.active    { transform: translateX(-50%) scale(0.92); }
.dpad-down.active  { transform: translateX(-50%) scale(0.92); }
.dpad-left.active  { transform: translateY(-50%) scale(0.92); }
.dpad-right.active { transform: translateY(-50%) scale(0.92); }

/* Pointer lock: hide system cursor when locked */
.pointer-locked #miningCanvas {
    cursor: none;
}
#miningCanvas {
    cursor: crosshair;
}

/* ========== CLICKER MODE TOGGLE ========== */
.clicker-mode-toggle {
    position: absolute;
    top: 12px;
    left: 50%;
    transform: translateX(-50%);
    z-index: 25;
    display: flex;
    gap: 0;
    background: rgba(10, 14, 20, 0.85);
    border: 1px solid rgba(0, 212, 255, 0.15);
    border-radius: 8px;
    padding: 3px;
    backdrop-filter: blur(8px);
    -webkit-backdrop-filter: blur(8px);
}
.mode-btn {
    padding: 6px 16px;
    border: none;
    border-radius: 6px;
    background: transparent;
    color: rgba(200, 210, 230, 0.6);
    font-size: 0.78rem;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.25s ease;
    letter-spacing: 0.02em;
    white-space: nowrap;
}
.mode-btn:hover {
    color: rgba(200, 210, 230, 0.9);
    background: rgba(0, 212, 255, 0.06);
}
.mode-btn.active {
    background: rgba(0, 212, 255, 0.15);
    color: #00d4ff;
    box-shadow: 0 0 10px rgba(0, 212, 255, 0.12);
}

/* ========== CLICKER MODE PANELS ========== */
.clicker-mode-panel {
    display: none;
}
.clicker-mode-panel.is-active {
    display: block;
}
/* 3D panel keeps existing mining-scene-container styles */

/* ========== 2D ROCK BREAKER ========== */
.rock-clicker-container {
    position: relative;
    flex: 1 1 auto;
    width: 100%;
    height: 100%;
    min-height: 320px;
    background: #05070c;
    overflow: hidden;
    touch-action: none;
}
.rock-clicker-container.is-active {
    display: block;
}
#rockClickerCanvas {
    display: block;
    width: 100%;
    height: 100%;
    position: absolute;
    top: 0;
    left: 0;
    cursor: pointer;
    -webkit-tap-highlight-color: transparent;
    user-select: none;
    -webkit-user-select: none;
}
#rockClickerCanvas:active {
    cursor: grabbing;
}
.rock-clicker-instructions {
    position: absolute;
    bottom: 90px;
    left: 50%;
    transform: translateX(-50%);
    color: rgba(180, 200, 220, 0.5);
    font-size: 0.75rem;
    text-align: center;
    pointer-events: none;
    transition: opacity 0.5s ease;
    white-space: nowrap;
    z-index: 5;
}

/* ========== SHARED CLICKER HUD ========== */
.clicker-hud {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    pointer-events: none;
    z-index: 20;
}
.clicker-hud .mining-status,
.clicker-hud .mining-controls {
    pointer-events: auto;
}

/* ========== CLOUD SAVE (Firebase) ========== */
.cloud-google-btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 100%;
    padding: 0.65rem 1.2rem;
    background: #ffffff;
    color: #3c4043;
    font-weight: 600;
    font-size: 0.95rem;
    border: 1px solid #dadce0;
    border-radius: 8px;
    cursor: pointer;
    transition: background 0.2s, box-shadow 0.2s;
}
.cloud-google-btn:hover {
    background: #f7f8f8;
    box-shadow: 0 1px 3px rgba(0,0,0,0.15);
}
.cloud-google-btn:active {
    background: #eee;
}
#cloudSyncStatus.syncing {
    color: var(--accent-primary);
}
#cloudSyncStatus.success {
    color: var(--accent-success);
}
#cloudSyncStatus.error {
    color: var(--accent-danger);
}

/* ========== LEADERBOARD TAB ========== */
.lb-sort-bar {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    margin: 1rem 0;
    flex-wrap: wrap;
}
.lb-sort-label {
    font-size: 0.85rem;
    color: var(--text-secondary);
}
.lb-sort-btn {
    padding: 0.35rem 0.75rem;
    border-radius: 6px;
    border: 1px solid rgba(255,255,255,0.08);
    background: var(--bg-tertiary);
    color: var(--text-secondary);
    font-size: 0.82rem;
    cursor: pointer;
    transition: all 0.2s;
}
.lb-sort-btn:hover {
    border-color: var(--accent-primary);
    color: var(--text-primary);
}
.lb-sort-btn.active {
    background: linear-gradient(135deg, var(--accent-primary), var(--accent-secondary));
    color: #fff;
    border-color: transparent;
    font-weight: 600;
}
.lb-table-wrap {
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
    margin: 0.5rem 0;
}
.lb-table {
    width: 100%;
    border-collapse: collapse;
    font-size: 0.9rem;
}
.lb-table thead th {
    text-align: left;
    padding: 0.6rem 0.5rem;
    color: var(--text-secondary);
    font-size: 0.78rem;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    border-bottom: 1px solid rgba(255,255,255,0.06);
    white-space: nowrap;
}
.lb-table tbody td {
    padding: 0.55rem 0.5rem;
    border-bottom: 1px solid rgba(255,255,255,0.03);
    vertical-align: middle;
}
.lb-table tbody tr:hover {
    background: rgba(255,255,255,0.02);
}
.lb-col-rank {
    width: 40px;
    text-align: center;
}
.lb-col-name {
    min-width: 120px;
}
.lb-col-stat {
    text-align: right;
    white-space: nowrap;
}
.lb-table tbody td.lb-col-stat {
    text-align: right;
    font-variant-numeric: tabular-nums;
}
.lb-table tbody td.lb-col-rank {
    text-align: center;
    font-weight: 700;
}
/* Rank medals */
.lb-rank-1 { color: #ffd700; }
.lb-rank-2 { color: #c0c0c0; }
.lb-rank-3 { color: #cd7f32; }
/* Highlight current user row */
.lb-row-self {
    background: rgba(0, 212, 255, 0.07) !important;
    border-left: 3px solid var(--accent-primary);
}
.lb-row-self td:first-child {
    padding-left: calc(0.5rem - 3px);
}
.lb-self-row {
    text-align: center;
}
.lb-self-divider {
    color: var(--text-secondary);
    font-size: 1.2rem;
    letter-spacing: 2px;
    padding: 0.25rem 0;
}
.lb-table-self {
    border-top: 1px solid rgba(0, 212, 255, 0.15);
}
.lb-status {
    text-align: center;
    padding: 2rem 1rem;
    color: var(--text-secondary);
    font-size: 0.9rem;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 0.75rem;
}
.lb-spinner {
    width: 24px;
    height: 24px;
    border: 3px solid rgba(255,255,255,0.1);
    border-top-color: var(--accent-primary);
    border-radius: 50%;
    animation: lb-spin 0.8s linear infinite;
}
@keyframes lb-spin {
    to { transform: rotate(360deg); }
}
.lb-auth-prompt {
    text-align: center;
    padding: 1.25rem;
    margin-top: 1rem;
    background: rgba(255,255,255,0.02);
    border-radius: 10px;
    border: 1px dashed rgba(255,255,255,0.08);
}
.lb-auth-text {
    font-size: 0.9rem;
    color: var(--text-secondary);
    margin-bottom: 0.5rem;
}
.lb-optin-prompt {
    margin-top: 1rem;
}
.lb-footer {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-top: 1rem;
    padding-top: 0.75rem;
    border-top: 1px solid rgba(255,255,255,0.04);
}
.lb-refresh-btn {
    padding: 0.3rem 0.7rem;
    font-size: 0.8rem;
    background: var(--bg-tertiary);
    border: 1px solid rgba(255,255,255,0.08);
}
.lb-refresh-btn:hover {
    border-color: var(--accent-primary);
}
/* Mobile responsive: stack stats on small screens */
@media (max-width: 480px) {
    .lb-table { font-size: 0.82rem; }
    .lb-table thead th,
    .lb-table tbody td { padding: 0.45rem 0.35rem; }
    .lb-col-name { min-width: 80px; }
}
