:root {
    --bg1: #0f2027; /* dark teal */
    --bg2: #203a43; /* slightly lighter */
    --accent1: #ff7eb3; /* pink */
    --accent2: #65f0d6; /* mint */
    --card: rgba(255, 255, 255, 0.06);
    --glass: rgba(255, 255, 255, 0.06);
    --glass-2: rgba(255, 255, 255, 0.03);
    --muted: rgba(255, 255, 255, 0.7);
    color-scheme: dark;
    font-family: Inter, ui-sans-serif, system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", Arial;
}

html,
body {
    height: 100%;
    margin: 0;
}
body {
    background: radial-gradient(1200px 700px at 10% 10%, rgba(255, 126, 179, 0.06), transparent 6%),
        radial-gradient(1000px 600px at 90% 90%, rgba(101, 240, 214, 0.04), transparent 6%),
        linear-gradient(135deg, var(--bg1) 0%, var(--bg2) 100%);
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
    color: #eaeef2;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 48px;
    box-sizing: border-box;
}

.wrap {
    max-width: 1100px;
    width: 100%;
}
header {
    display: flex;
    align-items: center;
    gap: 16px;
    margin-bottom: 24px;
}
.logo {
    width: 64px;
    height: 64px;
    border-radius: 12px;
    background: linear-gradient(135deg, var(--accent1), var(--accent2));
    display: flex;
    align-items: center;
    justify-content: center;
    box-shadow: 0 6px 28px rgba(0, 0, 0, 0.5), inset 0 -4px 12px rgba(255, 255, 255, 0.05);
    transform: translateZ(0);
}
.logo svg {
    filter: drop-shadow(0 6px 18px rgba(0, 0, 0, 0.45));
}
h1 {
    font-size: 20px;
    margin: 0;
}
p.lead {
    margin: 0;
    color: var(--muted);
    font-size: 14px;
}
main {
    display: grid;
    grid-template-columns: 1fr 360px;
    gap: 24px;
}
.card {
    background: linear-gradient(180deg, var(--glass), var(--glass-2));
    border-radius: 12px;
    padding: 20px;
    box-shadow: 0 8px 30px rgba(0, 0, 0, 0.5);
    backdrop-filter: blur(8px);
}
.script-list {
    display: flex;
    flex-direction: column;
    gap: 12px;
}
.script {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 12px;
    border-radius: 10px;
    transition: transform 0.18s ease, box-shadow 0.18s ease, background 0.18s ease;
    background: linear-gradient(180deg, rgba(255, 255, 255, 0.02), rgba(255, 255, 255, 0.01));
}

.script:hover {
    transform: translateY(-6px);
    box-shadow: 0 18px 40px rgba(0, 0, 0, 0.6);
}

.script .meta {
    flex: 1;
}

.script h3 {
    margin: 0;
    font-size: 15px;
}

.script p {
    margin: 6px 0 0 0;
    color: var(--muted);
    font-size: 13px;
}

/* action buttons inside script items */
.actions {
    display: flex;
    gap: 8px;
}

.btn {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    padding: 8px 12px;
    border-radius: 8px;
    background: linear-gradient(90deg, rgba(255, 255, 255, 0.03), rgba(255, 255, 255, 0.02));
    border: 1px solid rgba(255, 255, 255, 0.04);
    color: inherit;
    text-decoration: none;
    font-weight: 600;
    font-size: 13px;
    cursor: pointer;
    transition: transform 0.12s ease, box-shadow 0.12s ease;
}

/* smoothly fade out clones when they're removed */
.phy-clone {
    transition: opacity 420ms ease, transform 420ms ease;
}
.btn:hover {
    transform: translateY(-4px);
    box-shadow: 0 8px 24px rgba(0, 0, 0, 0.5);
}
.btn.install {
    background: linear-gradient(90deg, var(--accent1), var(--accent2));
    color: #082023;
    border: none;
}
.btn.repo {
    background: transparent;
}
aside .card h4 {
    margin: 0 0 8px 0;
}
.muted {
    color: var(--muted);
    font-size: 13px;
}
footer {
    margin-top: 20px;
    color: var(--muted);
    font-size: 13px;
}
.ribbon {
    display: inline-block;
    padding: 6px 10px;
    border-radius: 999px;
    background: linear-gradient(90deg, #ffd6eb, #c6fff5);
    color: #042;
    font-weight: 700;
    font-size: 12px;
}
canvas#fw {
    position: fixed;
    left: 0;
    top: 0;
    width: 100%;
    height: 100%;
    pointer-events: none;
    mix-blend-mode: screen;
    z-index: 0;
}
.wrap {
    position: relative;
    z-index: 2;
}
.spark {
    width: 10px;
    height: 10px;
    border-radius: 50%;
    background: linear-gradient(90deg, #fff, #ffd6eb);
    box-shadow: 0 8px 24px rgba(255, 126, 179, 0.2);
    display: inline-block;
    animation: pop 1.4s infinite;
}
@keyframes pop {
    0% {
        transform: translateY(0) scale(1);
    }
    50% {
        transform: translateY(-8px) scale(1.12);
    }
    100% {
        transform: translateY(0) scale(1);
    }
}
@media (max-width: 920px) {
    main {
        grid-template-columns: 1fr;
    }
    aside {
        order: 2;
    }
}

/* bottom-left panel styles */
.fw-panel {
    /* inside #controls-wrap; positioning is handled by that wrapper */
    z-index: 10001; /* above cloned pieces */
    display: flex;
    align-items: center;
    gap: 8px;
}
.fw-toggle {
    width: 44px;
    height: 44px;
    border-radius: 10px;
    border: none;
    background: linear-gradient(90deg, var(--accent1), var(--accent2));
    cursor: pointer;
    box-shadow: 0 8px 24px rgba(0, 0, 0, 0.4);
    font-size: 18px;
}
.fw-controls {
    background: linear-gradient(180deg, rgba(255, 255, 255, 0.04), rgba(255, 255, 255, 0.02));
    padding: 10px;
    border-radius: 10px;
    border: 1px solid rgba(255, 255, 255, 0.04);
    box-shadow: 0 8px 24px rgba(0, 0, 0, 0.45);
    display: flex;
    flex-direction: column;
    align-items: flex-start;
}
.fw-panel.collapsed .fw-controls {
    display: none;
}
.fw-controls .btn {
    padding: 6px 10px;
    border-radius: 8px;
}
@media (max-width: 600px) {
    .fw-panel {
        left: 10px;
        bottom: 10px;
    }
}

/* self-destruct button */
.nuke-btn {
    background: linear-gradient(180deg, #ff4b4b, #b80000);
    color: white;
    border: none;
    padding: 8px 12px;
    border-radius: 8px;
    font-weight: 800;
    letter-spacing: 0.04em;
    box-shadow: 0 10px 32px rgba(184, 0, 0, 0.35);
    cursor: pointer;
}
.nuke-btn:active {
    transform: translateY(1px) scale(0.995);
}

/* clones used for physics explosion */
.phy-clone {
    position: fixed;
    left: 0;
    top: 0;
    /* allow pointer events so clones can be dragged */
    pointer-events: auto;
    will-change: transform, opacity;
    z-index: 9999;
}

.phy-clone:active {
    cursor: grabbing;
}
.phy-clone {
    touch-action: none;
}

/* repairable physics elements: pulsing green border */
.phy-clone.repairable {
    position: relative;
    /* use a visible box-shadow border so it isn't clipped by overflow:hidden */
    box-shadow: 0 0 0 0 rgba(86, 209, 110, 0);
    border-radius: 6px; /* gentle rounding to match clones */
    animation: repairableBorderPulse 1.8s ease-in-out infinite;
}

@keyframes repairableBorderPulse {
    0% {
        box-shadow: 0 0 0 0 rgba(86, 209, 110, 0);
    }
    50% {
        /* reduced size: ~40% of previous values (60% smaller) */
        box-shadow: 0 0 5px 1px rgba(86, 209, 110, 0.17);
    }
    100% {
        box-shadow: 0 0 0 0 rgba(86, 209, 110, 0);
    }
}

/* repair hint: faint outline at original position while dragging */
.repair-hint {
    position: fixed;
    pointer-events: none;
    border: 2px dashed rgba(255, 255, 255, 0.18);
    background: rgba(255, 255, 255, 0.04);
    border-radius: 6px;
    z-index: 9998; /* behind clones but above content */
    opacity: 0.9;
}

/* repair ripple: briefly glow then fade when a piece is repaired */
.repair-ripple {
    transition: box-shadow 420ms cubic-bezier(0.2, 0.9, 0.2, 1), opacity 420ms ease, transform 420ms ease;
    box-shadow: 0 0 0 0 rgba(255, 255, 255, 0);
    will-change: box-shadow, opacity, transform;
}
.repair-ripple.repaired {
    box-shadow: 0 12px 36px rgba(101, 240, 214, 0.18), 0 0 12px rgba(255, 126, 179, 0.12) inset;
    opacity: 0;
    transform: scale(0.98);
}

/* repair ripple: briefly glow and fade out when a piece is repaired */
.repair-ripple {
    box-shadow: 0 0 0 4px rgba(101, 240, 214, 0.25), 0 0 18px rgba(101, 240, 214, 0.18);
    transition: box-shadow 360ms ease, opacity 360ms ease, transform 360ms ease;
    opacity: 1;
    /* ensure it appears above the hint but still near clones */
    z-index: 10000;
    animation: repairFade 560ms ease forwards;
}
@keyframes repairFade {
    0% {
        box-shadow: 0 0 0 2px rgba(101, 240, 214, 0.3), 0 0 14px rgba(101, 240, 214, 0.22);
        transform: scale(1);
        opacity: 1;
    }
    60% {
        box-shadow: 0 0 0 10px rgba(101, 240, 214, 0.12), 0 0 28px rgba(101, 240, 214, 0.08);
        transform: scale(1.02);
        opacity: 0.9;
    }
    100% {
        box-shadow: 0 0 0 18px rgba(101, 240, 214, 0), 0 0 36px rgba(101, 240, 214, 0);
        transform: scale(1.04);
        opacity: 0;
    }
}

/* smoothly fade out clones when they're removed */
.phy-clone {
    transition: opacity 420ms ease, transform 420ms ease;
}

/* faint shadow and subtle lift while dragging a clone */
.phy-clone.dragging {
    box-shadow: 0 16px 28px rgba(11, 22, 40, 0.1), 0 4px 8px rgba(11, 22, 40, 0.06);
    transition: box-shadow 180ms ease, transform 180ms ease;
    /* keep pointer cursor unchanged while dragging */
    cursor: grabbing !important;
}

/* reset button */
.reset-btn {
    background: transparent;
    border: 1px solid rgba(255, 255, 255, 0.04);
    color: inherit;
    padding: 6px 10px;
    border-radius: 8px;
}

/* controls wrapper placed bottom-left; contains fw-panel and dnp-panel */
#controls-wrap {
    position: fixed;
    left: 12px;
    bottom: 12px;
    z-index: 10000;
    display: flex;
    gap: 12px;
    align-items: flex-end;
}

@media (max-width: 600px) {
    #controls-wrap {
        left: 8px;
        bottom: 8px;
        gap: 8px;
    }
}

/* utility spacing */
.mt-0 {
    margin-top: 0;
}
.m8-0 {
    margin: 8px 0;
}
.ml-6 {
    margin-left: 6px;
}

/* decorative hr used in side cards */
.fancy-hr {
    border: none;
    height: 1px;
    background: linear-gradient(90deg, rgba(255, 255, 255, 0.02), rgba(255, 255, 255, 0.06));
    margin: 16px 0;
}

/* fireworks controls moved from inline styles */
.fw-controls-title {
    font-weight: 700;
    margin-bottom: 6px;
}
.fw-controls-row {
    display: flex;
    align-items: center;
    gap: 8px;
}
.fw-controls-row-center {
    margin-top: 10px;
    width: 100%;
    display: flex;
    justify-content: center;
    gap: 8px;
}
#fw-count {
    min-width: 44px;
    text-align: center;
    font-weight: 700;
}
.small-muted {
    margin-top: 8px;
    font-size: 12px;
    color: rgba(255, 255, 255, 0.7);
}
.small-active {
    margin-top: 8px;
    font-size: 13px;
    color: rgba(255, 255, 255, 0.9);
}

/* fw quick nuke small margin helper */
.fw-quick-nuke.ml-6 {
    margin-left: 6px;
}

/* DNP controls moved from inline styles */
.dnp-toggle {
    background: rgba(255, 255, 255, 0.06);
    border-radius: 8px;
    padding: 6px;
    margin-bottom: 6px;
    border: none;
    cursor: pointer;
}
.dnp-controls {
    background: rgba(0, 0, 0, 0.25);
    padding: 10px;
    border-radius: 12px;
    display: flex;
    align-items: center;
    justify-content: center;
}
.dnp-btn {
    width: 84px;
    height: 84px;
    border-radius: 999px;
    background: linear-gradient(180deg, #ff7b7b, #ff5252);
    color: white;
    font-weight: 800;
    font-size: 13px;
    border: none;
    cursor: pointer;
    box-shadow: 0 10px 28px rgba(0, 0, 0, 0.45);
}
