:root {
    --bg: #020617;
    --accent: #38bdf8;
    --accent-rgb: 56, 189, 248;
    --money: #4ade80;
    --science: #a855f7;
    --gold: #facc15;
    --iron-c: #cbd5e1;
    --copper-c: #fb923c;
    --neon-shadow: 0 0 10px rgba(var(--accent-rgb), 0.5), 0 0 20px rgba(var(--accent-rgb), 0.3);
}

* {
    user-select: none;
    box-sizing: border-box;
    font-family: 'Segoe UI', Tahoma, sans-serif;
}

body,
html {
    margin: 0;
    padding: 0;
    background: var(--bg);
    color: white;
    overflow: hidden;
}

/* Animation Néon */
@keyframes neonPulse {
    0% {
        text-shadow: 0 0 5px var(--accent), 0 0 10px var(--accent);
    }

    50% {
        text-shadow: 0 0 10px var(--accent), 0 0 20px var(--accent), 0 0 30px var(--accent);
    }

    100% {
        text-shadow: 0 0 5px var(--accent), 0 0 10px var(--accent);
    }
}

.neon-text {
    animation: neonPulse 2s infinite;
    font-weight: bold;
}

/* Barre du haut */
.top-bar {
    width: 100%;
    height: 50px;
    background: #0f172a;
    border-bottom: 2px solid var(--accent);
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 0 20px;
    box-shadow: 0 5px 15px rgba(0, 0, 0, 0.5), 0 0 10px rgba(var(--accent-rgb), 0.3);
}

.val {
    font-size: 1.1rem;
    font-weight: bold;
    font-family: monospace;
    text-shadow: 0 0 10px currentColor;
}

/* Layout Principal */
#game-layout {
    display: none;
    grid-template-columns: 180px 1fr 180px;
    gap: 10px;
    padding: 10px;
    height: calc(100vh - 50px);
}

/* Panneaux */
.side-panel {
    background: rgba(15, 23, 42, 0.8);
    border: 1px solid var(--accent);
    box-shadow: inset 0 0 10px rgba(var(--accent-rgb), 0.2), 0 0 15px rgba(0, 0, 0, 0.5);
    border-radius: 12px;
    padding: 10px;
    overflow-y: auto;
    display: flex;
    flex-direction: column;
    gap: 10px;
    backdrop-filter: blur(8px);
}

h3 {
    font-size: 0.8rem;
    margin: 0;
    text-align: center;
    border-bottom: 1px solid var(--accent);
    padding-bottom: 8px;
    text-transform: uppercase;
    letter-spacing: 2px;
    color: var(--accent);
    text-shadow: 0 0 8px var(--accent);
}

.card {
    background: #020617;
    border: 1px solid #334155;
    padding: 6px;
    border-radius: 4px;
    font-size: 0.65rem;
    transition: border 0.3s;
}

.card:hover {
    border-color: var(--accent);
}

.buy-btn {
    width: 100%;
    background: transparent;
    border: 1px solid var(--accent);
    color: var(--accent);
    cursor: pointer;
    border-radius: 44px;
    padding: 4px;
    margin-top: 5px;
    font-weight: bold;
    transition: all 0.2s;
}

.buy-btn:not(:disabled):hover {
    background: var(--accent);
    color: white;
    box-shadow: 0 0 10px var(--accent);
}

.buy-btn:disabled {
    opacity: 0.3;
    border-color: #444;
    color: #444;
}

/* Zone Centrale */
.main-view {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 10px;
}

.controls {
    display: grid;
    grid-template-columns: repeat(5, 1fr);
    gap: 4px;
    background: #1e293b;
    padding: 8px;
    border-radius: 10px;
    width: 100%;
    max-width: 450px;
}

.btn {
    background: rgba(15, 23, 42, 0.7);
    border: 1px solid rgba(var(--accent-rgb), 0.3);
    color: #94a3b8;
    padding: 8px;
    border-radius: 6px;
    cursor: pointer;
    font-size: 0.6rem;
    text-align: center;
    transition: all 0.2s;
}

.btn:hover {
    border-color: var(--accent);
    color: white;
    box-shadow: 0 0 10px rgba(var(--accent-rgb), 0.4);
}

.btn.active {
    border-color: var(--accent);
    background: rgba(var(--accent-rgb), 0.2);
    box-shadow: 0 0 15px var(--accent), inset 0 0 5px rgba(var(--accent-rgb), 0.5);
    color: white;
    font-weight: bold;
}

/* SVG machines dans les cellules */
.cell svg { width: 60%; height: 60%; }

/* SVG machines dans les boutons de contrôle */
.btn svg { width: 22px; height: 22px; }

/* Grille */
.grid {
    display: grid;
    grid-template-columns: repeat(12, 1fr);
    grid-template-rows: repeat(12, 1fr);
    gap: 2px;
    background: #000;
    border: 2px solid var(--accent);
    box-shadow: 0 0 20px rgba(var(--accent-rgb), 0.3);
    padding: 5px;
    border-radius: 8px;
    width: min(100%, calc(100vh - 200px));
    aspect-ratio: 1 / 1;
    flex-shrink: 0;
}

.cell {
    background: #020617;
    border: 1px solid rgba(var(--accent-rgb), 0.1);
    display: flex;
    align-items: center;
    justify-content: center;
    position: relative;
    cursor: crosshair;
    transition: all 0.2s;
}

.cell:hover:not(.cell-locked) {
    background: #0f172a;
    border-color: var(--accent);
    box-shadow: inset 0 0 8px rgba(var(--accent-rgb), 0.3);
}

.cell-locked {
    background: #020617;
    color: #334155;
    font-size: 7px;
    border: 1px dashed #1e293b;
    cursor: pointer;
}

/* Minerais différenciés */
.cell-iron {
    background: #0a0f1e;
    border-color: rgba(148, 163, 184, 0.15);
}

.cell-iron::before {
    content: '';
    position: absolute;
    bottom: 2px;
    right: 2px;
    width: 5px;
    height: 5px;
    background: rgba(148, 163, 184, 0.25);
    border-radius: 1px;
}

.cell-copper {
    background: #120a05;
    border-color: rgba(251, 146, 60, 0.15);
}

.cell-copper::before {
    content: '';
    position: absolute;
    bottom: 2px;
    right: 2px;
    width: 5px;
    height: 5px;
    background: rgba(251, 146, 60, 0.25);
    border-radius: 1px;
}

.cell-titanium {
    background: #0d1117;
    border-color: rgba(200, 200, 220, 0.2);
}

.cell-titanium::before {
    content: '';
    position: absolute;
    bottom: 2px;
    right: 2px;
    width: 5px;
    height: 5px;
    background: rgba(200, 200, 220, 0.35);
    border-radius: 1px;
}

.cell-crystal {
    background: #05101a;
    border-color: rgba(96, 165, 250, 0.2);
}

.cell-crystal::before {
    content: '';
    position: absolute;
    bottom: 2px;
    right: 2px;
    width: 6px;
    height: 6px;
    background: rgba(96, 165, 250, 0.3);
    border-radius: 50%;
}

.cell-plasma {
    background: #150520;
    border-color: rgba(192, 132, 252, 0.25);
}

.cell-plasma::before {
    content: '';
    position: absolute;
    bottom: 2px;
    right: 2px;
    width: 6px;
    height: 6px;
    background: rgba(192, 132, 252, 0.4);
    border-radius: 50%;
}

.cell-aether {
    background: #082f49;
    border-color: rgba(14, 165, 233, 0.3);
}

.cell-aether::before {
    content: '';
    position: absolute;
    bottom: 3px;
    right: 3px;
    width: 4px;
    height: 8px;
    background: #0ea5e9;
    border-radius: 2px;
    box-shadow: 0 0 10px #0ea5e9;
}

.cell-obsidian {
    background: #0f172a;
    border-color: rgba(30, 41, 59, 0.5);
}

.cell-obsidian::before {
    content: '';
    position: absolute;
    bottom: 2px;
    right: 2px;
    width: 7px;
    height: 7px;
    background: #020617;
    border: 1px solid #1e293b;
    transform: rotate(45deg);
}

.cell-adamantium {
    background: #040d1a;
    border-color: rgba(125, 211, 252, 0.2);
}

.cell-adamantium::before {
    content: '';
    position: absolute;
    bottom: 2px;
    right: 2px;
    width: 5px;
    height: 5px;
    background: rgba(125, 211, 252, 0.35);
    border-radius: 1px;
    box-shadow: 0 0 4px rgba(125, 211, 252, 0.4);
}

.cell-dark_matter {
    background: #020617;
    border-color: rgba(76, 29, 149, 0.2);
}

.cell-dark_matter::before {
    content: '';
    position: absolute;
    bottom: 50%;
    right: 50%;
    transform: translate(50%, 50%);
    width: 10px;
    height: 10px;
    background: radial-gradient(circle, #4c1d95, transparent);
    border-radius: 50%;
    filter: blur(2px);
    animation: pulse 2s infinite alternate;
}

@keyframes pulse {
    from {
        opacity: 0.4;
    }

    to {
        opacity: 1;
    }
}

.cell-void {
    background: #000;
    border-color: rgba(30, 10, 40, 0.6);
    cursor: not-allowed;
    overflow: hidden;
}

.cell-void::before {
    content: '';
    position: absolute;
    inset: 0;
    background: radial-gradient(circle at 50% 50%, #0d0015 0%, #000 60%);
    animation: void-depth 4s ease-in-out infinite alternate;
}

.cell-void::after {
    content: '▼';
    position: absolute;
    font-size: 8px;
    color: rgba(80, 0, 120, 0.5);
    animation: void-fall 2s ease-in infinite;
}

@keyframes void-depth {
    from { opacity: 0.6; transform: scale(1); }
    to   { opacity: 1;   transform: scale(1.15); }
}

@keyframes void-fall {
    0%   { opacity: 0;   transform: translateY(-4px); }
    50%  { opacity: 0.7; }
    100% { opacity: 0;   transform: translateY(6px); }
}

.cell-void:hover {
    background: #000;
    border-color: rgba(80, 0, 120, 0.4);
    box-shadow: inset 0 0 8px rgba(80, 0, 120, 0.3);
}

.item {
    position: absolute;
    width: 12px;
    height: 12px;
    border-radius: 2px;
    border: 1px solid white;
    z-index: 5;
    box-shadow: 0 0 8px currentColor;
}

/* Splash */
#splash {
    position: fixed;
    inset: 0;
    background: #000;
    z-index: 1000;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 20px;
}

.go-btn {
    padding: 18px 45px;
    border: 2px solid var(--accent);
    background: rgba(var(--accent-rgb), 0.05);
    color: var(--accent);
    cursor: pointer;
    font-weight: 800;
    border-radius: 8px;
    transition: all 0.4s cubic-bezier(0.175, 0.885, 0.32, 1.275);
    text-transform: uppercase;
    letter-spacing: 2px;
    font-size: 0.9rem;
    box-shadow: 0 0 10px rgba(var(--accent-rgb), 0.2);
}

.go-btn:hover {
    background: var(--accent);
    color: black;
    box-shadow: 0 0 30px var(--accent), inset 0 0 10px rgba(255, 255, 255, 0.5);
    transform: translateY(-3px) scale(1.05);
}

.menu-btn {
    background: rgba(15, 23, 42, 0.5);
    border: 1px solid var(--accent);
    color: var(--accent);
    padding: 4px 12px;
    border-radius: 4px;
    cursor: pointer;
    font-size: 0.7rem;
    font-weight: bold;
    transition: all 0.3s;
    text-shadow: 0 0 5px rgba(var(--accent-rgb), 0.5);
}

.menu-btn:hover {
    background: var(--accent);
    color: black;
    box-shadow: 0 0 15px var(--accent);
}

.planet-nav-btn {
    background: rgba(var(--accent-rgb), 0.1);
    border: 1px solid var(--accent);
    color: var(--accent);
    padding: 4px 12px;
    border-radius: 4px;
    cursor: pointer;
    font-size: 0.7rem;
    font-weight: bold;
    transition: all 0.3s;
    box-shadow: inset 0 0 5px rgba(var(--accent-rgb), 0.3);
}

.planet-nav-btn:hover {
    box-shadow: 0 0 15px var(--accent), inset 0 0 10px rgba(var(--accent-rgb), 0.5);
}

/* Audio Controls */
.audio-ctrl {
    position: fixed;
    bottom: 20px;
    right: 20px;
    background: rgba(15, 23, 42, 0.8);
    border: 1px solid var(--accent);
    color: var(--accent);
    padding: 10px;
    border-radius: 50%;
    width: 45px;
    height: 45px;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    z-index: 2000;
    box-shadow: 0 0 15px rgba(56, 189, 248, 0.3);
    transition: all 0.3s;
}

.audio-ctrl:hover {
    transform: scale(1.1);
    box-shadow: 0 0 20px var(--accent);
}

/* Panel planètes (overlay fixe sous la top-bar) */
.planet-panel {
    display: none;
    position: fixed;
    top: 50px;
    left: 0;
    right: 0;
    z-index: 500;
    background: rgba(15, 23, 42, 0.97);
    border-bottom: 2px solid var(--accent);
    padding: 10px 20px;
    max-height: calc(100vh - 50px);
    overflow-y: auto;
    backdrop-filter: blur(8px);
    box-shadow: 0 8px 20px rgba(0, 0, 0, 0.6);
}

.planet-cards {
    display: flex;
    flex-wrap: wrap;
    gap: 10px;
    justify-content: center;
    padding: 8px 0;
}

.planet-card {
    background: #020617;
    border: 1px solid #334155;
    border-radius: 8px;
    padding: 10px 14px;
    cursor: pointer;
    text-align: center;
    min-width: 110px;
    transition: all 0.2s;
}

.planet-card:hover {
    border-color: var(--accent);
    box-shadow: 0 0 10px rgba(var(--accent-rgb), 0.3);
}

.planet-card.active {
    border-color: var(--accent);
    background: rgba(var(--accent-rgb), 0.08);
}

.planet-card.locked {
    opacity: 0.5;
}

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

.planet-name {
    font-size: 0.75rem;
    font-weight: bold;
    margin-top: 4px;
}

.planet-res {
    font-size: 0.6rem;
    color: #94a3b8;
    margin-top: 2px;
}

.planet-cost {
    font-size: 0.6rem;
    color: var(--science);
    margin-top: 3px;
}

/* Planètes décoratives */
.space-bg {
    position: fixed;
    inset: 0;
    pointer-events: none;
    z-index: 0;
    overflow: hidden;
}

.planet {
    position: absolute;
    border-radius: 50%;
    pointer-events: none;
}

.planet-1 {
    width: 120px;
    height: 120px;
    top: 10%;
    right: 5%;
    background: radial-gradient(circle at 35% 35%, #facc15, #b45309, #451a03);
    box-shadow: 0 0 40px rgba(250, 204, 21, 0.3), inset -15px -10px 20px rgba(0, 0, 0, 0.6);
    animation: orbit1 30s linear infinite;
}

.planet-2 {
    width: 60px;
    height: 60px;
    bottom: 15%;
    left: 3%;
    background: radial-gradient(circle at 40% 30%, #a855f7, #581c87, #1e0539);
    box-shadow: 0 0 25px rgba(168, 85, 247, 0.3), inset -8px -6px 15px rgba(0, 0, 0, 0.5);
    animation: orbit2 22s linear infinite;
}

.planet-3 {
    width: 40px;
    height: 40px;
    top: 60%;
    right: 12%;
    background: radial-gradient(circle at 30% 35%, #38bdf8, #0369a1, #082f49);
    box-shadow: 0 0 20px rgba(56, 189, 248, 0.3), inset -6px -5px 12px rgba(0, 0, 0, 0.5);
    animation: orbit3 18s linear infinite;
}

/* Anneau de planète */
.planet-1::after {
    content: '';
    position: absolute;
    top: 50%;
    left: 50%;
    width: 170px;
    height: 30px;
    margin-top: -15px;
    margin-left: -85px;
    border: 2px solid rgba(250, 204, 21, 0.3);
    border-radius: 50%;
    transform: rotateX(70deg) rotateZ(-20deg);
}

@keyframes orbit1 {
    0% {
        transform: translate(0, 0);
    }

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

    50% {
        transform: translate(0, 30px);
    }

    75% {
        transform: translate(20px, 15px);
    }

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

@keyframes orbit2 {
    0% {
        transform: translate(0, 0);
    }

    25% {
        transform: translate(15px, -10px);
    }

    50% {
        transform: translate(30px, 0);
    }

    75% {
        transform: translate(15px, 10px);
    }

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

@keyframes orbit3 {
    0% {
        transform: translate(0, 0);
    }

    25% {
        transform: translate(-10px, -15px);
    }

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

    75% {
        transform: translate(-10px, 15px);
    }

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

/* Étoiles */
.star {
    position: absolute;
    width: 2px;
    height: 2px;
    background: white;
    border-radius: 50%;
    opacity: 0;
    animation: twinkle 3s infinite;
}

@keyframes twinkle {

    0%,
    100% {
        opacity: 0.1;
    }

    50% {
        opacity: 1;
    }
}

/* Tutorial & Toast */
.modal-overlay {
    display: none;
    position: fixed;
    inset: 0;
    background: rgba(0, 0, 0, 0.8);
    z-index: 3000;
    justify-content: center;
    align-items: center;
    backdrop-filter: blur(5px);
}

.modal {
    background: #0f172a;
    border: 2px solid var(--accent);
    padding: 25px;
    width: 350px;
    max-height: 85vh;
    border-radius: 12px;
    overflow-y: auto;
    color: white;
    box-shadow: 0 0 30px rgba(var(--accent-rgb), 0.4);
}

.save-slot {
    background: #1e293b;
    padding: 12px;
    border-radius: 8px;
    border: 1px solid #334155;
    display: flex;
    justify-content: space-between;
    align-items: center;
    transition: all 0.2s;
}

.save-slot:hover {
    border-color: var(--accent);
    transform: scale(1.02);
}

.save-slot .slot-info {
    display: flex;
    flex-direction: column;
    gap: 2px;
}

.slot-name {
    font-weight: bold;
    color: var(--accent);
    font-size: 0.8rem;
}

.slot-date {
    font-size: 0.6rem;
    color: #94a3b8;
}

.slot-money {
    font-size: 0.7rem;
    color: var(--money);
    font-weight: bold;
}

.modal h2 {
    color: var(--accent);
    margin-top: 0;
    text-align: center;
}

.modal p,
.modal li {
    font-size: 0.9rem;
    line-height: 1.5;
    margin-bottom: 10px;
    color: #cbd5e1;
}

.modal ul {
    margin-left: 20px;
    margin-bottom: 15px;
}

.modal-btn {
    display: block;
    width: 100%;
    padding: 12px;
    margin-top: 20px;
    background: transparent;
    color: var(--accent);
    border: 1px solid var(--accent);
    border-radius: 6px;
    font-weight: bold;
    cursor: pointer;
    text-transform: uppercase;
    letter-spacing: 1px;
    transition: all 0.3s;
    box-shadow: 0 0 10px rgba(var(--accent-rgb), 0.2);
}

.modal-btn:hover {
    background: var(--accent);
    color: black;
    box-shadow: 0 0 20px var(--accent);
}

.toast {
    position: fixed;
    top: 70px;
    left: 50%;
    transform: translateX(-50%);
    background: rgba(34, 197, 94, 0.9);
    color: white;
    padding: 10px 20px;
    border-radius: 8px;
    font-weight: bold;
    z-index: 4000;
    opacity: 0;
    transition: opacity 0.3s;
    pointer-events: none;
}

.story-overlay {
    position: fixed;
    bottom: 30px;
    left: 50%;
    transform: translateX(-50%);
    width: 90%;
    max-width: 500px;
    background: rgba(15, 23, 42, 0.95);
    border: 2px solid var(--accent);
    border-radius: 12px;
    padding: 20px;
    z-index: 5000;
    box-shadow: 0 0 40px rgba(var(--accent-rgb), 0.4);
    animation: storySlide 0.5s cubic-bezier(0.175, 0.885, 0.32, 1.275);
}

@keyframes storySlide {
    from {
        transform: translate(-50%, 150%);
        opacity: 0;
    }

    to {
        transform: translate(-50%, 0);
        opacity: 1;
    }
}

.story-char {
    color: var(--accent);
    font-weight: 900;
    font-size: 0.8rem;
    margin-bottom: 8px;
    text-transform: uppercase;
    letter-spacing: 2px;
    text-shadow: 0 0 10px var(--accent);
    display: flex;
    align-items: center;
    gap: 10px;
}

.story-char::after {
    content: "";
    flex: 1;
    height: 1px;
    background: linear-gradient(90deg, var(--accent), transparent);
}

.story-text {
    color: #e2e8f0;
    font-size: 0.9rem;
    line-height: 1.5;
    margin-bottom: 15px;
    font-family: 'Courier New', Courier, monospace;
}

/* === Animations & Floaters === */
@keyframes pulse-btn {
    0% { transform: scale(1); box-shadow: 0 0 5px #4ade80; }
    100% { transform: scale(1.05); box-shadow: 0 0 15px #4ade80, inset 0 0 5px #4ade80; }
}
@keyframes pulse-guide {
    0% { box-shadow: 0 0 10px #4ade80 inset, 0 0 5px #4ade80; background-color: rgba(74, 222, 128, 0.1); }
    100% { box-shadow: 0 0 30px #4ade80 inset, 0 0 15px #4ade80; background-color: rgba(74, 222, 128, 0.3); }
}
@keyframes floatUp {
    0% {
        transform: translateY(0);
        opacity: 1;
    }

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

.floater {
    position: absolute;
    animation: floatUp 1s ease-out forwards;
    font-weight: bold;
    font-size: 0.8rem;
    pointer-events: none;
    z-index: 100;
    text-shadow: 0 0 4px #000;
}
