/* Import fonts */
@import url('https://fonts.googleapis.com/css2?family=Press+Start+2P&display=swap');
@import url('https://fonts.googleapis.com/css2?family=Inter:wght@400;500;600;700&family=Outfit:wght@400;600;700&display=swap');

/* --- IMPOSTAZIONI GLOBALI E FONT --- */
:root {
    --font-pixel: 'Press Start 2P', system-ui;
    --font-modern: 'Inter', system-ui, -apple-system, sans-serif;
    --font-title: 'Outfit', sans-serif;
    --bg-dark: #0f0f12;
    --bg-panel: #1a1a1f;
    --bg-input: #0a0a0c;
    --bg-hover: #2a2a32;
    --accent-purple: #c499f3;
    --accent-green: #03dac6;
    --accent-blue: #4dabf7;
    --border-color: #2a2a30;
    --border-light: #3a3a42;
    --text-main: #e0e0e6;
    --text-dim: #9090a0;
    --glass-bg: rgba(26, 26, 31, 0.85);
    --radius-lg: 10px;
    --radius-md: 6px;
    --radius-sm: 4px;
}

/* Custom Scrollbars */
::-webkit-scrollbar {
    width: 6px;
    height: 6px;
}

::-webkit-scrollbar-track {
    background: #111;
}

::-webkit-scrollbar-thumb {
    background: #444;
    border-radius: 3px;
}

::-webkit-scrollbar-thumb:hover {
    background: var(--accent-purple);
}

html,
body {
    margin: 0;
    padding: 0;
    width: 100%;
    height: 100%;
    overflow: hidden;
}

body {
    font-family: var(--font-pixel);
    background-color: var(--bg-dark);
    color: #fff;
    font-size: 12px;
    scrollbar-width: thin;
}

body::-webkit-scrollbar {
    width: 8px;
}

.hidden {
    display: none !important;
}

/* --- LAYOUT DEL CONTENITORE PRINCIPALE (FLEXBOX) --- */
.editor-container {
    display: flex;
    width: 100%;
    height: 100%;
    background-color: black;
}

/* --- STILI DELLA BARRA LATERALE A SINISTRA --- */
.tool-button {
    font-family: var(--font-title) !important;
    font-weight: 600 !important;
    font-size: 1.0em !important;
    /* FORCE SIZE */
    padding: 12px 16px;
    background-color: var(--bg-panel);
    border: 1px solid var(--border-color);
    color: var(--text-main);
    cursor: pointer;
    text-align: center;
    width: auto;
    min-width: 40px;
    box-sizing: border-box;
    margin-bottom: 8px;
    display: inline-block;
    text-decoration: none;
    transition: all 0.25s cubic-bezier(0.4, 0, 0.2, 1);
    border-radius: var(--radius-md);
    text-transform: uppercase;
    letter-spacing: 0.04em;
    line-height: 1.4;
}

.tool-button:hover {
    background-color: #383838;
    border-color: #666;
    transform: translateY(-1px);
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.2);
}

.tool-button.scene-button.export {
    background-color: #333;
    border-color: #555;
    color: #fff;
    font-weight: bold;
}

.tool-button.scene-button.export:hover {
    background-color: #fff;
    border-color: #333;
}

.tool-button.purple {
    background-color: #802080 !important;
    border-color: #a040a0 !important;
    color: white !important;
    font-weight: bold;
    margin-bottom: 15px;
    text-shadow: 1px 1px 2px rgba(0, 0, 0, 0.5);
    border-radius: 4px;
}

.tool-button.purple:hover {
    background-color: #a040a0 !important;
    border-color: #d060d0 !important;
    box-shadow: 0 0 10px rgba(160, 64, 160, 0.5);
}

.sidebar {
    width: 400px;
    flex: 0 0 400px;
    /* Don't shrink, don't grow, fixed basis */
    min-width: 400px;
    flex-shrink: 0;
    font-family: var(--font-modern);
    /* Enforce modern font for everything in sidebar */
    background-color: var(--bg-dark);
    padding: 20px;
    box-shadow: 10px 0 30px rgba(0, 0, 0, 0.6);
    display: flex;
    flex-direction: column;
    overflow-y: auto;
    z-index: 20;
    border-right: 1px solid var(--border-color);
    justify-content: flex-start;
}

.sidebar input[type="checkbox"]+label {
    font-family: var(--font-title);
    font-size: 1.1em;
    /* Match headers */
    font-weight: 700;
    text-transform: uppercase;
    color: #eee;
    margin-left: 5px;
    cursor: pointer;
}

/* Force specific fix for the toggle-labels in the screenshot */
label[for="toggle-items"],
label[for="toggle-walkable"],
label[for="toggle-sensors"] {
    font-family: var(--font-title) !important;
    font-size: 1.1em !important;
    font-weight: 700 !important;
    text-transform: uppercase !important;
}

.sidebar h1 {
    font-family: var(--font-title);
    font-size: 1.8em;
    font-weight: 700;
    margin-top: 0;
    margin-bottom: 20px;
    color: var(--accent-purple);
    letter-spacing: -0.02em;
}

/* --- MODERN BUTTONS (TOP BAR) --- */
.top-bar-btn {
    flex: 1;
    /* Default to filling space */
    font-family: var(--font-modern);
    font-weight: 600;
    text-transform: uppercase;
    font-size: 0.75rem;
    padding: 10px;
    border-radius: 6px;
    border: 1px solid var(--border-light);
    background: #252525;
    color: #eee;
    cursor: pointer;
    transition: all 0.2s cubic-bezier(0.4, 0, 0.2, 1);
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    text-decoration: none;
}

.top-bar-btn:hover {
    background: #333;
    border-color: #666;
    transform: translateY(-1px);
}

.top-bar-btn#open-logic-editor-btn {
    background: #4a00b0;
    border-color: #6200ea;
}

.top-bar-btn#open-logic-editor-btn:hover {
    background: #5a00d0;
    box-shadow: 0 0 15px rgba(98, 0, 234, 0.3);
}

.top-bar-btn#toggle-mode-btn {
    background: #1a1a1a;
    color: var(--accent-green);
}

.top-bar-btn#export-scene-btn {
    background: #1a1a1a;
    color: #4CAF50;
}

.top-bar-btn#dashboard-btn {
    flex: 0 0 50px;
    /* Wider for accessibility */
    font-size: 1.5rem !important;
    padding: 0;
    /* Center arrow */
}

/* --- MODERN DETAILS / SUMMARY --- */

/* FORCE TOP BAR BUTTONS TO BE MODERN */
#dashboard-btn,
#export-scene-btn,
#toggle-mode-btn,
#open-logic-editor-btn {
    font-family: var(--font-title) !important;
    font-weight: 700 !important;
    text-transform: uppercase !important;
    font-size: 1.0em !important;
    /* Slightly smaller top bar */
    letter-spacing: 0.05em !important;
    padding: 8px 10px !important;
    /* Strettio */
}

details {
    margin-bottom: 12px;
    border: 1px solid var(--border-color);
    border-radius: 8px;
    background: var(--bg-panel);
    transition: border-color 0.2s;
}

details:hover {
    border-color: var(--border-light);
}

summary {
    padding: 14px 18px;
    background-color: var(--bg-hover);
    color: var(--text-main);
    font-family: var(--font-title);
    font-weight: 600;
    font-size: 0.95em;
    cursor: pointer;
    border-bottom: 1px solid transparent;
    display: flex;
    align-items: center;
    user-select: none;
    transition: all 0.2s ease;
}

summary:hover {
    background-color: #32323f;
    color: var(--accent-purple);
}

details[open] summary {
    border-bottom: 1px solid var(--border-color);
    color: var(--accent-purple);
    background-color: #22222a;
}

.details-content {
    padding: 20px;
    background-color: var(--bg-panel);
}

summary::before {
    content: "▸";
    margin-right: 12px;
    transition: transform 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    font-size: 1.2em;
    font-weight: 400;
    color: var(--accent-purple);
}

details[open] summary::before {
    transform: rotate(90deg);
}

summary::-webkit-details-marker {
    display: none;
}

/* --- ACCORDIONS (Details/Summary) --- */
details {
    background: #1a1a1a;
    border: 1px solid #333;
    border-radius: 4px;
    margin-bottom: 8px;
}

summary {
    background: #2d2d2d;
    padding: 12px 15px;
    color: #e594ff;
    font-weight: bold;
    cursor: pointer;
    list-style: none;
    border-bottom: 1px solid #333;
    font-size: 1.2em;
    text-transform: uppercase;
    display: flex;
    align-items: center;
}

summary::-webkit-details-marker {
    display: none;
}

summary::before {
    content: "▸";
    margin-right: 8px;
    transition: transform 0.2s;
    font-size: 1.2em;
}

details[open] summary::before {
    transform: rotate(90deg);
}

.details-content {
    padding: 10px;
}



/* --- CONTENITORE PRINCIPALE (A DESTRA) --- */
.content-wrapper {
    flex-grow: 1;
    display: flex;
    flex-direction: column;
    height: 100%;
    overflow: hidden;
    position: relative;
}

.main-content {
    flex-grow: 1;
    display: flex;
    position: relative;
    overflow: hidden;
    justify-content: center;
    align-items: center;
    background-color: black;
}

/* --- Area di Gioco con tutti gli elementi del gioco --- */
#game-area {
    position: relative;
    width: 100%;
    height: 100%;
    display: flex;
    flex-direction: column;
    justify-content: center;
    align-items: center;
}

/* --- Layut Canvas --- */
#scene-canvas {
    max-width: 100%;
    max-height: 100%;
    width: auto;
    height: auto;
    object-fit: contain;
    background: transparent;
    display: block;
    z-index: 10;
}

/* Aggiungi questo alla fine del file editor.css */

.content-wrapper {
    flex: 1 1 auto;
    min-width: 0;
    /* Important for flex item shrinking */
    display: flex;
    flex-direction: column;
    overflow: hidden;
    position: relative;
    height: 100%;
}

.main-content {
    position: relative;
    /* Necessario per posizionare i figli in modo assoluto */
    display: flex;
    justify-content: center;
    align-items: center;
    flex: 1;
    width: 100%;
    height: 100%;
    overflow: hidden;
}

#background-canvas,
#scene-canvas {
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
}

.start-prompt,
#play-container {
    text-align: center;
}

.start-prompt h2 {
    font-family: 'Press Start 2P', system-ui;
    font-size: 2em;
    margin-bottom: 30px;
    color: #e594ff;
    text-shadow: 2px 2px #3c1c4a;
}

#confirm-start-btn,
#big-play-button {
    font-family: 'Press Start 2P', system-ui;
    font-size: 1.5em;
    padding: 15px 30px;
    cursor: pointer;
    background-color: #1a0d21;
    color: #e594ff;
    border: 2px solid #945cb4;
    text-shadow: 2px 2px #3c1c4a;
}

.hidden {
    display: none !important;
}

#background-canvas {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    z-index: 5;
    transform: none;
    pointer-events: none;
}

/* --- FORM ELEMENTS --- */
.form-group {
    margin-bottom: 18px;
    display: flex;
    flex-direction: column;
    gap: 6px;
}

.form-group label {
    font-family: var(--font-modern);
    font-weight: 600;
    font-size: 0.8rem;
    color: #888;
    text-transform: uppercase;
    letter-spacing: 0.05em;
}

.form-group input[type="text"],
.form-group input[type="number"],
.form-group textarea,
.form-group select {
    width: 100%;
    background-color: var(--bg-input);
    border: 1px solid var(--border-color);
    color: #f0f0f0;
    padding: 10px 12px;
    border-radius: 6px;
    font-family: var(--font-modern);
    font-size: 0.9rem;
    transition: all 0.2s;
}

.form-group input:focus,
.form-group textarea:focus,
.form-group select:focus {
    outline: none;
    border-color: var(--accent-purple);
    box-shadow: 0 0 0 2px rgba(187, 134, 252, 0.1);
}

.form-group input[readonly] {
    background-color: #111;
    color: #666;
    border-style: dashed;
}

.form-group.row {
    flex-direction: row;
    gap: 15px;
}

.form-group.row .col {
    flex: 1;
}

.inspector-divider {
    font-family: var(--font-title);
    font-size: 1rem;
    font-weight: 700;
    margin: 25px 0 15px 0;
    padding-top: 15px;
    border-top: 1px solid var(--border-color);
    color: #eee;
}

#sensor-custom-value-container label {
    display: block;
    margin-top: 10px;
    color: #ccc;
}

#scene-canvas {
    z-index: 2;
    /* Mette questo canvas davanti */
}

/* --- Layut Frasi sopra il Canvas --- */
#sentence-display {
    position: absolute;
    top: 40px;
    width: 80%;
    text-align: center;
    word-wrap: break-word;
    z-index: 10;
    color: #fff;
    padding: 10px;
    text-shadow: 2px 2px 4px rgba(0, 0, 0, 0.8);
    font-size: 1.4em;
}

.pixel-gradient {
    pointer-events: none;
    /* Ignora il mouse e permette di cliccare il canvas sotto */
}

#game-container {
    /* Sostituisci con l'ID del contenitore del tuo canvas */
    height: 100%;
}

canvas {
    display: block;
    width: 100vw;
    /* Larghezza del viewport */
    height: 100vh;
    /* Altezza del viewport */
}

/* --- Stili per il Dialogo sopra il Canvas --- */
#dialogue-container {
    position: absolute;
    bottom: 0;
    left: 0;
    transform: none;
    width: 100%;
    max-height: 30%;
    background-color: rgba(0, 0, 0, 0.8);
    color: #eee;
    padding: 15px 20px;
    display: none;
    font-size: 1.1em;
    z-index: 20;
    overflow-y: auto;
}

/* Regole per mostrare/nascondere il dialogo */
.dialogue-active #dialogue-container {
    display: block;
}

.dialogue-active #dialogue-grid {
    display: flex;
    flex-direction: column;
}

.dialogue-active #dialogue-grid button {
    background-color: transparent;
    color: white;
    padding: 10px 15px;
    border: none;
    cursor: pointer;
    font-family: var(--font-pixel);
    font-size: 1.1em;
}

.dialogue-active #dialogue-grid button:hover {
    background-color: transparent;
}

/* --- CONTENITORE UI DI GIOCO (OVERLAY SUL CANVAS) --- */
#game-ui-container {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    z-index: 50;
    display: flex;
    align-items: center;
    pointer-events: none;
}

#game-ui-container.hidden {
    display: none !important;
}


/* --- PULSANTE PER MOSTRARE/NASCONDERE LA UI --- */
#toggle-ingame-ui-btn {
    position: absolute;
    top: 20px;
    left: 20px;
    width: 40px;
    height: 40px;
    background-color: rgba(26, 13, 33, 0.8);
    border: 2px solid #3c1c4a;
    cursor: pointer;
    z-index: 51;
    pointer-events: auto;
    transition: left 0.3s ease-in-out;
}

#toggle-ingame-ui-btn:hover {
    background-color: #3c1c4a;
}

/* --- Layout barra UI (Verbi e inventario) --- */
#ui-bar {
    width: 150px;
    height: auto;
    max-height: 90vh;
    border-left: none;
    border-radius: 0 10px 10px 0;
    display: flex;
    flex-direction: column;
    justify-content: center;
    padding: 9px;
    z-index: 50;
    margin-bottom: 0;
    pointer-events: auto;
    transform: translateX(0);
    transition: transform 0.3s ease-in-out;
    background-color: rgba(0, 0, 0, 0.75);
    border: 2px solid #3c1c4a;
}

/* Stato nascosto per la UI di gioco */
#ui-bar.hidden {
    transform: translateX(-100%);
}

@media (min-width: 900px) {
    #ui-bar.hidden {
        transform: translateX(0) !important;
        display: flex !important;
    }
}

#main-ui-area {
    display: flex;
    flex-direction: column;
    width: 100%;
    gap: 10px;
}

/* --- VERBI --- */
#verb-grid {
    display: grid;
    grid-template-columns: repeat(2, 1fr);
    gap: 0;
    width: 100%;
}

#verb-grid button {
    font-family: var(--font-pixel);
    background-color: #1a0d21;
    color: #945cb4;
    padding: 8px 5px;
    border: 2px solid #3c1c4a;
    cursor: pointer;
    font-size: 1.2em;
    text-align: center;
    text-decoration: none;
    text-transform: uppercase;
    text-shadow: 1px 1px #3c1c4a;
    box-shadow: inset 0 0 5px rgba(0, 0, 0, 0.5);
    transition: background-color 0.3s, border-color 0.3s;
}

#verb-grid button:hover {
    border-color: #e594ff;
}

#verb-grid button.disabled {
    opacity: 0.4;
    pointer-events: none;
}

#verb-grid button.selected {
    background-color: #1a0d21;
    color: #e594ff;
    border-color: #e594ff;
}

#help-btn {
    grid-column: 1 / -1;
}

/* --- INVENTARIO --- */
#inventory-grid {
    width: 100%;
    display: grid;
    grid-template-columns: repeat(2, 1fr);
    /* 2 colonne di base (Desktop) */

}

.inventory-slot {
    aspect-ratio: 1 / 1;
    background-color: #1A0D20;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    overflow: hidden;
    border: 2px solid #3c1c4a;
    box-shadow: inset 0 0 5px rgba(0, 0, 0, 0.5);
    transition: box-shadow 0.2s;
}

.inventory-slot img {
    width: 100%;
    height: 100%;
    object-fit: contain;
}

.inventory-slot:hover {
    box-shadow: inset 0 0 10px #e594ff;
}

.inventory-placeholder {
    opacity: 0.5;
}

/* --- STRUMENTI --- */
.tool-section {
    margin-bottom: 20px;
}

.button-row {
    display: flex;
    gap: 10px;
}

.controls-row {
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.toggle-group {
    display: flex;
    flex-direction: column;
    gap: 5px;
}

.play-button {
    background-color: #28a745;
    color: white;
    text-align: center !important;
    font-size: 1em;
    padding: 12px !important;
    margin-bottom: 20px !important;
    border: 2px solid #1a5e2a !important;
    box-shadow: 0 4px #1a5e2a;
}

.play-button:hover {
    background-color: #218838;
    transform: translateY(2px);
    box-shadow: 0 2px #1a5e2a;
}

.play-button.pause {
    background-color: #ffc107;
    color: #212529;
    border-color: #c69500 !important;
    box-shadow: 0 4px #c69500;
}

.play-button.pause:hover {
    background-color: #e0a800;
}

/* --- ASSET E SFONDI --- */

/* --- HIDE UI DURING DIALOGUE --- */
body.dialogue-active #ui-bar,
body.dialogue-active #toggle-ingame-ui-btn {
    display: none !important;
}

.preview-grid,
.asset-category-content {

    display: flex;
    flex-wrap: wrap;
    gap: 10px;
}

.preview-item,
.asset-item {
    width: 72px;
    height: 72px;
    background-color: var(--bg-hover);
    border: 1px solid var(--border-color);
    cursor: pointer;
    overflow: hidden;
    position: relative;
    display: flex;
    justify-content: center;
    align-items: center;
    flex-direction: column;
    text-align: center;
    border-radius: var(--radius-md);
    transition: all 0.25s cubic-bezier(0.4, 0, 0.2, 1);
}

.asset-item:hover,
.preview-item:hover {
    border-color: var(--accent-purple);
    background-color: #32323f;
    transform: translateY(-2px);
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.3);
}

.asset-item.selected,
.preview-item.selected {
    border-color: var(--accent-purple);
    box-shadow: 0 0 0 2px rgba(196, 153, 243, 0.4);
}

.preview-item img,
.asset-item img {
    max-width: 100%;
    max-height: 100%;
    object-fit: contain;
}

#asset-library {
    display: flex;
    flex-direction: column;
    gap: 5px;
}

.asset-category-content {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
    padding: 10px 5px;
    justify-content: flex-start;
}

.asset-item-name {
    font-size: 0.7em;
    word-wrap: break-word;
    padding: 2px;
    display: none;
}

.asset-item:hover .asset-item-name {
    display: block;
    position: absolute;
    bottom: 0;
    background-color: rgba(0, 0, 0, 0.7);
    width: 100%;
}

/* Specific override for action buttons to ensure they match labels */
#add-sensor-btn,
#draw-polygon-btn,
.sidebar .tool-button,
#trash-can {
    font-family: var(--font-title) !important;
    font-size: 0.85em !important;
    font-weight: 600 !important;
    text-transform: uppercase !important;
    letter-spacing: 0.05em !important;
    display: inline-flex !important;
    flex-direction: row !important;
    align-items: center !important;
    justify-content: center !important;
    padding: 10px 12px !important;
    width: auto !important;
    gap: 8px !important;
    white-space: nowrap !important;
    border-radius: var(--radius-md);
    transition: all 0.2s ease;
}

#add-sensor-btn {
    background-color: #00695c !important;
    border-color: #00897b !important;
}

#draw-polygon-btn {
    background-color: #2e7d32 !important;
    border-color: #388e3c !important;
}

#trash-can {
    background-color: #333 !important;
    border-color: #444 !important;
}

#add-sensor-btn:hover {
    background-color: #00796b !important;
    transform: translateY(-1px);
}

#draw-polygon-btn:hover {
    background-color: #388e3c !important;
    transform: translateY(-1px);
}

#trash-can:hover {
    background-color: #c62828 !important;
    border-color: #e53935 !important;
    transform: translateY(-1px);
}

/* Make Delete button visually smaller */
#trash-can {
    font-size: 0.85em !important;
    padding: 8px 4px !important;
    opacity: 0.8;
}

/* Ensure images/emojis inside buttons have margin */
.tool-button img,
.tool-button i,
#trash-can i,
#trash-can img,
.tool-button span:first-child,
#trash-can span:first-child {
    margin-right: 5px !important;
    /* Reduce icon spacing */
    margin-bottom: 0 !important;
}

/* Fix Trash Label specifically if inside */
#trash-can span,
#trash-can div {
    font-family: var(--font-title) !important;
    font-size: 1.0em !important;
    font-weight: 700 !important;
}

/* --- CESTINO --- */
#trash-can {
    font-size: 2.5em;
    padding: 10px;
    text-align: center;
    border: 2px dashed #555;
    border-radius: 8px;
    transition: background-color 0.2s, border-color 0.2s;
}

#trash-can.droppable {
    background-color: #ff6b6b;
    border-color: white;
}

/* --- REGOLE RESPONSIVE --- */
@media (min-width: 900px) {
    .sidebar {
        width: 450px;
    }

    #verb-grid button {
        font-size: 1.2em;
    }

    #toggle-ingame-ui-btn {
        display: none !important;
    }
}

@media (max-width: 899px), (pointer: coarse) {
    #game-ui-container {
        left: 0 !important;
        right: 0 !important;
        width: 100% !important;
        align-items: flex-start !important;
    }

    /* Hamburger: in alto a DESTRA */
    #toggle-ingame-ui-btn {
        width: 44px;
        height: 44px;
        top: 10px;
        right: 10px;
        left: auto !important;
    }

    /* Barra verbi e inventario: a SINISTRA */
    #ui-bar {
        margin-top: 10px;
        max-height: calc(100dvh - 20px);
        overflow-y: auto;
        -webkit-overflow-scrolling: touch;
        touch-action: pan-y;
        overscroll-behavior: contain;
        justify-content: flex-start !important;
        border-left: none;
        border-right: 2px solid #3c1c4a;
        border-radius: 0 10px 10px 0;
        transform: translateX(0);
    }

    #ui-bar.hidden {
        transform: translateX(-100%) !important;
    }

    #verb-grid button {
        font-size: 0.9em;
        padding: 10px 4px;
        min-height: 40px;
    }

    .inventory-slot {
        min-width: 44px;
        min-height: 44px;
    }

    /* --- DIALOGUE UI ON MOBILE --- */
    .dialogue-active #dialogue-grid button {
        padding: 15px 20px;
        font-size: 1.2em;
        border-bottom: 1px solid rgba(255, 255, 255, 0.1);
    }

    /* --- MODIFICA PER L'INVENTARIO SU MOBILE --- */
    #inventory-grid {
        grid-template-columns: repeat(2, 1fr); /* 2 columns is better for larger touch targets than 3 */
    }
}

/* --- STILE SPECIALE PULSANTE FEEDBACK (CORRETTO) --- */
#donate-btn,
#donate-btn:hover,
#donate-btn.selected {
    /* Aggiungiamo .selected per assicurarci che non cambi colore se cliccato */
    background-color: #004d40 !important;
    /* Verde scuro/petrolio */
    color: #4db6ac !important;
    /* Verde acqua */
    border-color: #4db6ac !important;
    /* Verde acqua */
}

/* --- STILI PER LA FINESTRA DI FEEDBACK --- */
#feedback-overlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background-color: rgba(0, 0, 0, 0.85);
    z-index: 1000;
    display: flex;
    justify-content: center;
    align-items: center;
}

#feedback-modal {
    background-color: #2c2c2c;
    padding: 25px;
    border-radius: 8px;
    border: 1px solid #555;
    width: 100%;

}

#feedback-modal h2 {
    font-family: var(--font-pixel);
    color: #e594ff;
    margin-top: 0;
    font-size: 1.5em;
}

#language-container {
    margin-bottom: 40px;
    /* spazio extra sopra il pulsante PLAY */
}

#feedback-modal p {
    /* --- TESTO PIÙ GRANDE --- */
    font-size: 1.1em;

}

.feedback-field {
    text-align: left;
    /* Allinea a sinistra per i checkbox */
}

.feedback-field label {
    display: block;
    margin-bottom: 5px;
    font-size: 1em;
    /* <-- CORRETTO */
    color: #ccc;
}

/* Stile per i checkbox */
.feedback-field input[type="checkbox"] {
    margin-right: 10px;
}

#feedback-modal input,
#feedback-modal textarea {
    width: 100%;
    padding: 10px;
    background-color: #1a1a1a;
    border: 1px solid #555;
    color: #f0f0f0;
    border-radius: 4px;
    box-sizing: border-box;
    font-family: Arial, sans-serif;
    font-size: 1em;
}

.feedback-actions {
    display: flex;
    justify-content: flex-end;
    gap: 10px;
}

.feedback-actions button {
    font-family: var(--font-pixel);
    padding: 10px 20px;
    border: none;
    border-radius: 4px;
    cursor: pointer;
}

#feedback-send-btn {
    background-color: #007bff;
    color: white;
}

#feedback-cancel-btn {
    background-color: #6c757d;
    color: white;
}


/* Riduciamo lo spazio TRA i pulsanti nella griglia */
#verb-grid {
    gap: 4px;
}

/* Questa è la regola chiave: agisce sui singoli pulsanti dei verbi */
#verb-grid button {
    /* Riduciamo drasticamente lo spazio a destra e sinistra (padding orizzontale) */


    /* Riduciamo leggermente la dimensione del testo per aiutare */
    font-size: 0.8em;

    /* Rimuoviamo eventuali larghezze minime che potrebbero forzare il pulsante ad essere largo */
    min-width: 0;
}



/* ========================================================== */
/* ======== REGOLE PER FEEDBACK SU MOBILE ORIZZONTALE ======== */
/* ========================================================== */

/* Applica queste regole solo quando lo schermo è in orizzontale E non è molto alto (tipico di un telefono) */
@media (orientation: landscape) and (max-height: 500px) {
    #feedback-modal {
        /* Riduciamo la larghezza massima e il padding generale del box */
        width: 90vw;
        /* Occupa il 90% della larghezza dello schermo */
        max-width: 550px;
        /* Ma non più di 550px */
        padding: 15px;

        /* Permettiamo lo scorrimento se il contenuto è troppo */
        max-height: 95vh;
        overflow-y: auto;
    }

    /* Riduciamo la dimensione e lo spazio dei testi principali */
    #feedback-modal h2 {
        font-size: 1.1em;
        margin-bottom: 5px;
    }

    #feedback-modal p {
        font-size: 0.8em;
        margin-bottom: 10px;
    }

    /* Riduciamo lo spazio tra i campi del form */
    #feedback-modal .feedback-field {
        margin-bottom: 8px;
    }

    /* Riduciamo la dimensione delle etichette e dei campi di testo */
    #feedback-modal label {
        font-size: 0.75em;
    }

    #feedback-modal textarea,
    #feedback-modal input[type="email"] {
        padding: 6px;
        font-size: 0.9em;
    }

    /* Facciamo in modo che il testo dei checkbox non vada a capo */
    #feedback-modal .feedback-field label[for="feedback-newsletter"],
    #feedback-modal .feedback-field label[for="feedback-next-chapter"] {
        display: inline-block;
        margin-left: 5px;
    }

    /* Riduciamo lo spazio sopra i pulsanti e la loro grandezza */
    #feedback-modal .feedback-actions {
        margin-top: 10px;
    }

    #feedback-modal .feedback-actions button {
        padding: 8px 12px;
        font-size: 0.8em;
    }
}

/* ========================================================== */
/* ========= STILE PER IL MESSAGGIO "PLEASE ROTATE" ========= */
/* ========================================================== */

/* Per impostazione predefinita, il messaggio è nascosto */
#please-rotate-overlay {
    display: none;
}

/* 
  Questa regola si attiva SOLO se il dispositivo è in verticale (portrait)
  e ha una larghezza massima di 850px (per colpire telefoni e piccoli tablet).
*/
@media screen and (orientation: portrait) and (max-width: 850px) {

    /* Quando le condizioni sono vere, mostriamo il nostro messaggio */
    #please-rotate-overlay {
        display: flex;
        position: fixed;
        top: 0;
        left: 0;
        width: 100%;
        height: 100%;
        background-color: rgba(0, 0, 0, 0.98);
        z-index: 20000;
        /* Lo mettiamo sopra a tutto */
        justify-content: center;
        align-items: center;
        text-align: center;
        color: #ffffff;
    }

    .rotate-prompt-content .main-message {
        font-family: 'Press Start 2P', system-ui;
        font-size: 1.1em;
        line-height: 1.5;
        margin-bottom: 15px;
        text-shadow: 2px 2px #3c1c4a;
    }

    .rotate-prompt-content .sub-message {
        font-family: Arial, sans-serif;
        font-size: 1em;
        color: #cccccc;
    }

    .rotate-prompt-content .rotate-icon {
        width: 70px;
        height: 70px;
        margin-bottom: 30px;
        animation: rotate-hint 2.5s ease-in-out infinite;
    }
}

/* --- MISSING GLOBAL RULES (RECONSTRUCTED) --- */

#donate-btn,
#donate-btn:hover,
#donate-btn.selected {
    background-color: #004d40 !important;
    color: #4db6ac !important;
    border-color: #4db6ac !important;
}

#feedback-cancel-btn {
    background-color: #6c757d;
    color: white;
}

#verb-grid button {
    font-size: 0.8em;
    min-width: 0;
}


/* --- INSPECTOR SIDEBAR (INTEGRATED) --- */
#inspector-panel {
    display: flex;
    flex-direction: column;
    padding: 10px 0;
}

/* IMAGE SELECTOR (MIRROR WIZARD) */
.selected-image-display {
    border: 1px solid #444;
    background: #111;
    padding: 5px;
    border-radius: 6px;
    cursor: pointer;
    display: flex;
    justify-content: center;
    align-items: center;
    height: 60px;
    box-sizing: border-box;
}

.selected-image-display img {
    max-height: 100%;
    max-width: 100%;
    object-fit: contain;
}

.image-select-grid {
    position: absolute;
    bottom: 55px;
    /* Stay above the parent row */
    left: 0;
    width: 320px;
    /* FIXED WIDTH to avoid narrow parent constraint */
    max-height: 400px;
    overflow-y: auto;
    background: #1a1a1a;
    border: 1px solid #444;
    z-index: 1000;
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(70px, 1fr));
    gap: 8px;
    padding: 12px;
    box-shadow: 0 10px 30px rgba(0, 0, 0, 0.8), 0 0 0 1px rgba(255, 255, 255, 0.05);
    border-radius: 8px;
}

.image-option {
    cursor: pointer;
    border: 1px solid transparent;
    padding: 2px;
    text-align: center;
}

.image-option:hover {
    border-color: #e594ff;
    background: #333;
}

.image-option img {
    width: 100%;
    height: 40px;
    /* Smaller height to fit more */
    object-fit: contain;
    transition: transform 0.1s;
}

.image-option:hover img {
    transform: scale(1.1);
}

.image-option.selected {
    border-color: var(--accent-purple);
    background: rgba(187, 134, 252, 0.1);
}

#inspector-toggle-btn {
    position: fixed;
    top: 50%;
    right: 0;
    transform: translateY(-50%);
    width: 30px;
    height: 60px;
    background-color: #333;
    border: 2px solid #555;
    border-right: none;
    border-radius: 8px 0 0 8px;
    cursor: pointer;
    z-index: 10000;
    color: #bb86fc;
    font-size: 1.2em;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: right 0.3s ease-in-out;
}

#inspector-toggle-btn.open {
    right: 300px;
}

.inspector-content {
    display: flex;
    flex-direction: column;
    gap: 15px;
}

.inspector-divider {
    border-top: 1px solid #444;
    margin: 10px 0;
    padding-top: 10px;
    color: #888;
    font-size: 0.7em;
    text-transform: uppercase;
    letter-spacing: 1px;
}

.form-group {
    display: flex;
    flex-direction: column;
    gap: 5px;
    margin-bottom: 10px;
}

.form-group.row {
    flex-direction: row;
    gap: 10px;
}

#floating-is-sensor-wrapper {
    color: #FFA500; /* Orange color to match Trigger color */
    font-weight: bold;
    margin-left: 10px;
}

#floating-is-sensor-wrapper input {
    accent-color: #FFA500;
}

.form-group.row>.col {
    flex: 1;
}

.form-group label {
    color: #ccc;
    font-size: 1.1em;
    text-transform: uppercase;
    display: block;
    font-weight: bold;
}

.form-group input,
.form-group select {
    background-color: #111;
    border: 1px solid #555;
    color: white;
    padding: 8px;
    border-radius: 4px;
    font-family: inherit;
    width: 100%;
    box-sizing: border-box;
    font-size: 0.9em;
}

.form-group input:focus,
.form-group select:focus {
    border-color: #bb86fc;
    outline: none;
}

.form-group input[readonly] {
    background-color: #222;
    color: #888;
    cursor: not-allowed;
}

/* --- TRANSLATION POPOVER (Wizard Inline UI) --- */
/* --- TRANSLATION POPOVER (Wizard Inline UI) --- */
.translation-popover {
    font-family: var(--font-title);
    font-size: 0.95rem;
    /* Larger, readable */
    line-height: 1.5;
    animation: popoverFadeIn 0.2s ease-out;
    border-radius: 8px;
    /* Softer corners */
    box-shadow: 0 10px 40px rgba(0, 0, 0, 0.6);
    border: 1px solid var(--border-light);
}

@keyframes popoverFadeIn {
    from {
        opacity: 0;
        transform: translateY(-10px);
    }

    to {
        opacity: 1;
        transform: translateY(0);
    }
}

.translation-popover h3 {
    font-family: var(--font-title);
    font-weight: 700;
    font-size: 1.1em;
    text-transform: uppercase;
    color: var(--accent-purple);
    margin-bottom: 15px;
    letter-spacing: 0.05em;
}

.translation-popover label {
    font-family: var(--font-modern);
    font-weight: 600;
    font-size: 0.85em;
    text-transform: uppercase;
    color: #aaa;
    margin-bottom: 4px;
    display: block;
}

.translation-popover input,
.translation-popover textarea {
    font-family: var(--font-modern);
    font-size: 1em;
    padding: 8px 10px;
    border-radius: 6px;
    background: #111;
    border: 1px solid #444;
    color: #eee;
    transition: all 0.2s;
}

.translation-popover input:focus,
.translation-popover textarea:focus {
    border-color: var(--accent-purple) !important;
    box-shadow: 0 0 0 2px rgba(187, 134, 252, 0.15);
    outline: none;
}

.translation-popover .close-btn {
    font-family: var(--font-modern);
    font-size: 1.5em;
    color: #888;
    transition: color 0.2s;
}

.translation-popover .close-btn:hover {
    color: #fff !important;
}

.translation-popover button {
    font-family: var(--font-title);
    font-weight: 700;
    text-transform: uppercase;
    font-size: 1.0em;
    padding: 10px 20px;
    border-radius: 6px;
    letter-spacing: 0.05em;
}

/* --- VISUAL LOGIC EDITOR --- */
.visual-editor-modal {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: #000;
    /* Full black background as requested */
    z-index: 2000;
    display: flex;
    font-family: 'Segoe UI', sans-serif;
    pointer-events: auto;
    /* Ensure events are captured */
}

.visual-editor-modal.hidden {
    display: none !important;
    pointer-events: none !important;
}

body.logic-mode-active .sidebar {
    display: none !important;
}

.logic-sidebar {
    width: 250px;
    background: #1e1e1e;
    border-right: 1px solid #444;
    padding: 10px;
    display: flex;
    flex-direction: column;
    z-index: 2001;
    /* Ensure sidebar is above background */
    position: relative;
    background: #1e1e1e !important;
    display: flex !important;
    /* Force display */
    width: 250px !important;
}

.logic-sidebar.right-sidebar {
    border-right: none;
    border-left: 1px solid #444;
}

.palette-section {
    margin-bottom: 20px;
}

.palette-section h4 {
    color: #aaa;
    font-size: 0.9em;
    text-transform: uppercase;
    margin-bottom: 10px;
    border-bottom: 1px solid #333;
}

.draggable-node-tool,
.draggable-node-asset {
    padding: 8px;
    margin-bottom: 5px;
    background: #333;
    border: 1px solid #555;
    border-radius: 4px;
    cursor: grab;
    user-select: none;
    transition: background 0.2s;
}

.draggable-node-tool:hover,
.draggable-node-asset:hover {
    background: #444;
    border-color: #888;
}

.logic-canvas-wrapper {
    flex: 1;
    display: flex;
    flex-direction: column;
    background: transparent;
    /* Make wrapper transparent */
    position: relative;
    overflow: hidden;
}

#logic-toolbar {
    height: 40px;
    background: #222;
    border-bottom: 1px solid #444;
    display: flex;
    align-items: center;
    padding: 0 10px;
    gap: 10px;
}

.logic-canvas {
    flex: 1;
    background-color: #000 !important;
    /* Force black background */
    /* Semi-transparent canvas background removed, only grid */
    background-image:
        linear-gradient(rgba(255, 255, 255, 0.15) 1px, transparent 1px),
        linear-gradient(90deg, rgba(255, 255, 255, 0.15) 1px, transparent 1px);
    background-size: 20px 20px;
    background-position: center;
    position: relative;
    overflow: hidden;
    pointer-events: auto;
    /* Ensure canvas captures events */
}

#logic-sidebar {
    overflow-y: auto;
    /* ENABLE SCROLLING */
    scrollbar-width: thin;
    scrollbar-color: #555 #222;
    max-height: 100%;
}

/* NODE STYLES - Professional Re-skin */
.logic-node {
    position: absolute;
    min-width: 180px;
    background: var(--bg-panel);
    border: 1px solid var(--border-color);
    border-radius: 6px;
    box-shadow: 0 10px 40px rgba(0, 0, 0, 0.6);
    color: var(--text-main);
    z-index: 10;
    transition: box-shadow 0.2s, border-color 0.2s, transform 0.1s;
    pointer-events: auto;
    overflow: hidden;
    font-family: var(--font-modern);
}

.logic-node.selected {
    border-color: var(--accent-purple) !important;
    box-shadow: 0 0 20px rgba(187, 134, 252, 0.3), 0 10px 30px rgba(0, 0, 0, 0.5);
    z-index: 100 !important;
}

.logic-node input,
.logic-node select,
.logic-node textarea {
    background: var(--bg-input);
    border: 1px solid var(--border-color);
    color: var(--text-main);
    border-radius: var(--radius-sm);
    padding: 6px 8px;
    font-size: 0.85em;
    width: 100%;
    box-sizing: border-box;
    font-family: var(--font-modern);
}

.logic-node input:focus,
.logic-node select:focus {
    border-color: var(--accent-purple);
    outline: none;
}

/* Connection Path States */
path.selected {
    stroke: var(--accent-purple) !important;
    stroke-width: 4 !important;
    filter: drop-shadow(0 0 8px rgba(187, 134, 252, 0.6));
}

.node-body .field-wrap {
    display: flex;
    flex-direction: column;
    gap: 4px;
}

.node-body .node-label {
    font-size: 0.75em;
    color: var(--text-dim);
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.02em;
}

.node-body .node-input {
    background: var(--bg-input);
    border: 1px solid var(--border-color);
    color: var(--text-main);
    border-radius: var(--radius-sm);
    padding: 6px 8px;
    font-size: 0.85em;
    font-family: var(--font-modern);
    transition: border-color 0.2s;
}

.node-body .node-input:focus {
    border-color: var(--accent-purple);
    outline: none;
    box-shadow: 0 0 0 2px rgba(196, 153, 243, 0.1);
}

.node-header {
    background: rgba(255, 255, 255, 0.05);
    padding: 10px 14px;
    font-weight: 700;
    cursor: grab;
    border-bottom: 1px solid var(--border-color);
    user-select: none;
    font-family: var(--font-title);
    text-transform: uppercase;
    font-size: 0.8em;
    letter-spacing: 0.05em;
    display: flex;
    align-items: center;
    gap: 8px;
    background-image: linear-gradient(to right, rgba(255, 255, 255, 0.05), transparent);
}

.node-header:active {
    cursor: grabbing;
}

.node-body {
    padding: 8px 10px;
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.node-port {
    width: 20px;
    height: 20px;
    border-radius: 50%;
    background: #444;
    position: absolute;
    cursor: crosshair;
    border: 2px solid var(--bg-panel);
    z-index: 100;
    transition: all 0.2s ease;
    box-shadow: 0 0 0 1px rgba(255, 255, 255, 0.1);
}

.node-port.port-in {
    left: -11px;
    top: 20px;
    background: #4CAF50;
}

.node-port.port-in-target {
    left: -11px;
    top: 45px;
    background: #888;
}

.node-port.port-out {
    right: -11px;
    top: 20px;
    background: #2196F3;
}

/* Branching Logic Ports (IF Node) */
.logic-node.node-is-if .node-port[data-handle="source_true"] {
    top: 15px;
}
.logic-node.node-is-if .node-port[data-handle="source_false"] {
    top: 45px;
}

.node-port.port-hover {
    transform: scale(1.4);
    box-shadow: 0 0 10px var(--accent-purple);
    background: var(--accent-purple) !important;
}

/* Node Type Specifics - Professional Color Coding */
.node-type-object {
    border-left: 4px solid #f9a825;
}

.node-type-object .node-header {
    color: #f9a825;
}

.node-type-trigger {
    border-left: 4px solid #ff5252;
}

.node-type-trigger .node-header {
    color: #ff5252;
}

.node-type-action {
    border-left: 4px solid #64ffda;
}

.node-type-action .node-header {
    color: #64ffda;
}

.node-type-sound {
    border-left: 4px solid #40c4ff;
}

.node-type-sound .node-header {
    color: #40c4ff;
}

.node-type-timer {
    border-left: 4px solid #e040fb;
}

.node-type-timer .node-header {
    color: #e040fb;
}

.node-type-transition {
    border-left: 4px solid #ffd740;
}

.node-type-transition .node-header {
    color: #ffd740;
}

.node-type-property {
    border-left: 4px solid #b0bec5;
}

.node-type-property .node-header {
    color: #b0bec5;
}

.node-type-animation {
    border-left: 4px solid #ff80ab;
}

.node-type-animation .node-header {
    color: #ff80ab;
}

/* Sidebar Logic Items - Compact Modern Style */
.logic-item {
    padding: 10px 14px;
    background: var(--bg-hover);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-md);
    margin-bottom: 6px;
    cursor: grab;
    font-size: 0.9em;
    font-weight: 500;
    transition: all 0.2s ease;
    display: flex;
    align-items: center;
    gap: 10px;
    color: var(--text-main);
    font-family: var(--font-modern);
}

.logic-item:hover {
    background: #32323f;
    border-color: var(--accent-purple);
}

.logic-item.selected {
    background: rgba(196, 153, 243, 0.1);
    border-color: var(--accent-purple);
    color: var(--accent-purple);
}

.logic-item span {
    font-size: 1.2em;
}

/* --- AI CHARACTER GENERATOR STYLES --- */
.editor-modal {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.85);
    display: flex;
    justify-content: center;
    align-items: center;
    z-index: 2000;
}

.modal-content.large-modal {
    width: 900px;
    max-width: 95%;
    max-height: 90%;
}

.gen-layout {
    display: flex;
    gap: 30px;
}

.gen-controls {
    flex: 1;
    display: flex;
    flex-direction: column;
    gap: 15px;
}

.gen-controls textarea {
    height: 150px;
    background: #000;
    color: #fff;
    border: 1px solid #444;
    padding: 10px;
    font-family: var(--font-modern);
}

.gen-preview {
    flex: 1;
    display: flex;
    flex-direction: column;
    gap: 15px;
    align-items: center;
}

.preview-box {
    width: 100%;
    height: 350px;
    background: #000;
    border: 2px dashed #444;
    display: flex;
    justify-content: center;
    align-items: center;
    overflow: auto;
    position: relative;
}

.preview-box canvas {
    max-width: 100%;
    max-height: 100%;
    image-rendering: pixelated;
    /* Essential for pixel art */
}

.gen-actions {
    display: flex;
    gap: 10px;
    width: 100%;
}

.gen-actions button {
    flex: 1;
}

.hint {
    font-size: 0.8em;
    color: #888;
    font-style: italic;
}

.success-btn {
    background: #2e7d32;
    color: white;
    padding: 12px;
    border: none;
    border-radius: 4px;
    cursor: pointer;
    font-family: var(--font-title);
    font-weight: bold;
    text-transform: uppercase;
}

.success-btn:hover {
    background: #388e3c;
}

/* Glass effect refinement */
.glass-effect {
    background: rgba(30, 30, 30, 0.8);
    backdrop-filter: blur(10px);
    border: 1px solid rgba(255, 255, 255, 0.1);
    border-radius: 12px;
    box-shadow: 0 8px 32px rgba(0, 0, 0, 0.5);
}

/* --- AI CHARACTER GENERATOR STYLES --- */
.editor-modal {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.85);
    display: flex;
    justify-content: center;
    align-items: center;
    z-index: 2000;
}

.modal-content.large-modal {
    width: 900px;
    max-width: 95%;
    max-height: 90%;
}

.gen-layout {
    display: flex;
    gap: 30px;
}

.gen-controls {
    flex: 1;
    display: flex;
    flex-direction: column;
    gap: 15px;
}

.gen-controls textarea {
    height: 150px;
    background: #000;
    color: #fff;
    border: 1px solid #444;
    padding: 10px;
    font-family: var(--font-modern);
}

.gen-preview {
    flex: 1;
    display: flex;
    flex-direction: column;
    gap: 15px;
    align-items: center;
}

.preview-box {
    width: 100%;
    height: 350px;
    background: #000;
    border: 2px dashed #444;
    display: flex;
    justify-content: center;
    align-items: center;
    overflow: auto;
    position: relative;
}

.preview-box canvas {
    max-width: 100%;
    max-height: 100%;
    image-rendering: pixelated;
    /* Essential for pixel art */
}

.gen-actions {
    display: flex;
    gap: 10px;
    width: 100%;
}

.gen-actions button {
    flex: 1;
}

.hint {
    font-size: 0.8em;
    color: #888;
    font-style: italic;
}

.success-btn {
    background: #2e7d32;
    color: white;
    padding: 12px;
    border: none;
    border-radius: 4px;
    cursor: pointer;
    font-family: var(--font-title);
    font-weight: bold;
    text-transform: uppercase;
}

.success-btn:hover {
    background: #388e3c;
}

/* Glass effect refinement */
.glass-effect {
    background: rgba(30, 30, 30, 0.8);
    backdrop-filter: blur(10px);
    border: 1px solid rgba(255, 255, 255, 0.1);
    border-radius: 12px;
    box-shadow: 0 8px 32px rgba(0, 0, 0, 0.5);
}

/* Spinner Animation */
.spinner {
    width: 40px;
    height: 40px;
    border: 4px solid rgba(255, 255, 255, 0.1);
    border-left-color: #9c27b0;
    border-radius: 50%;
    animation: spin 1s linear infinite;
}

@keyframes spin {
    to {
        transform: rotate(360deg);
    }
}

.loading-spinner {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    height: 100%;
    width: 100%;
}

/* --- INVENTORY NODE STYLE --- */
.node-conf_inventory {
    border: 2px solid #bb86fc;
    /* Purple accent */
    background: rgba(30, 30, 30, 0.95);
    min-width: 200px;
    box-shadow: 0 0 15px rgba(187, 134, 252, 0.2);
    border-radius: 8px;
}

.node-conf_inventory .node-header {
    background: linear-gradient(90deg, #3700b3, #6200ea);
    color: white;
    font-weight: bold;
    text-transform: uppercase;
    padding: 8px;
    border-bottom: 1px solid #bb86fc;
}

.node-conf_inventory .node-body {
    padding: 10px;
    color: #eee;
}

/* --- FLOATING INSPECTOR OVERLAY --- */
.floating-inspector {
    position: fixed;
    width: 280px;
    background: var(--glass-bg);
    border: 1px solid var(--border-light);
    border-radius: var(--radius-lg);
    box-shadow: 0 10px 40px rgba(0, 0, 0, 0.7);
    z-index: 5000;
    backdrop-filter: blur(12px);
    -webkit-backdrop-filter: blur(12px);
    display: flex;
    flex-direction: column;
    overflow: visible;
    font-family: var(--font-modern);
    transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
}

.floating-inspector.hidden {
    display: none !important;
    pointer-events: none;
    opacity: 0;
    transform: scale(0.95);
}

.floating-header {
    background: linear-gradient(90deg, #333, #222);
    padding: 8px 12px;
    border-bottom: 1px solid #444;
    display: flex;
    justify-content: space-between;
    align-items: center;
    cursor: move;
}

.floating-header span {
    font-weight: bold;
    color: #eee;
    font-size: 0.9em;
    text-transform: uppercase;
}

.floating-header button {
    background: none;
    border: none;
    color: #888;
    cursor: pointer;
    font-size: 1.2em;
    padding: 0 4px;
}

.floating-header button:hover {
    color: #fff;
}

.floating-body {
    padding: 12px;
    display: flex;
    flex-direction: column;
    gap: 10px;
}

.floating-form-group {
    display: flex;
    flex-direction: column;
    gap: 4px;
}

.floating-form-group label {
    font-size: 0.75em;
    color: #aaa;
    text-transform: uppercase;
    font-weight: 600;
}

.floating-form-group input,
.floating-form-group textarea {
    background: #111;
    border: 1px solid #333;
    color: white;
    padding: 6px;
    border-radius: 4px;
    font-family: inherit;
    font-size: 0.9em;
    box-sizing: border-box;
}

.floating-form-group input[type="number"] {
    width: 60px;
    text-align: center;
}

.floating-form-group input:focus,
.floating-form-group textarea:focus {
    border-color: var(--accent-purple);
    outline: none;
}

.floating-row {
    display: flex;
    gap: 15px;
    align-items: center;
}

.floating-row label {
    display: flex;
    align-items: center;
    gap: 6px;
    font-size: 0.85em;
    color: #ccc;
    cursor: pointer;
}

.floating-footer {
    padding-top: 5px;
    border-top: 1px solid #333;
    margin-top: 5px;
    display: flex;
    justify-content: flex-end;
}

.floating-footer button {
    background: #2e7d32;
    color: white;
    border: none;
    border-radius: 4px;
    padding: 6px 12px;
    font-size: 0.8em;
    font-weight: bold;
    text-transform: uppercase;
    cursor: pointer;
}

.floating-footer button:hover {
    background: #388e3c;
}

/* --- CONTEXT MENU --- */
.context-menu {
    position: fixed;
    z-index: 10001;
    background: var(--bg-panel);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-md);
    padding: 5px 0;
    min-width: 160px;
    box-shadow: 0 10px 30px rgba(0, 0, 0, 0.5);
    font-family: var(--font-title);
    font-size: 0.9em;
}

.context-menu .menu-item {
    padding: 8px 15px;
    cursor: pointer;
    display: flex;
    justify-content: space-between;
    align-items: center;
    color: var(--text-main);
    position: relative;
    transition: background 0.2s;
}

.context-menu .menu-item:hover {
    background: var(--bg-hover);
    color: var(--accent-purple);
}

.context-menu .menu-divider {
    height: 1px;
    background: var(--border-color);
    margin: 4px 0;
}

.context-menu .has-submenu::after {
    content: '▶';
    font-size: 0.7em;
    margin-left: 10px;
    opacity: 0.5;
}

.context-menu .submenu {
    position: absolute;
    left: 100%;
    top: -5px;
    background: var(--bg-panel);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-md);
    padding: 5px 0;
    min-width: 150px;
    display: none;
    box-shadow: 10px 10px 30px rgba(0, 0, 0, 0.5);
}

.context-menu .has-submenu:hover>.submenu {
    display: block;
}

.context-menu .menu-item input[type="checkbox"] {
    margin-right: 10px;
    width: 14px;
    height: 14px;
}

.hidden {
    display: none !important;
}

/* --- STILI DONAZIONI --- */
#donate-overlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background-color: rgba(0, 0, 0, 0.85);
    backdrop-filter: blur(5px);
    z-index: 99999; /* Superiore a tutti i pannelli dell'editor */
    display: flex;
    justify-content: center;
    align-items: center;
}

#donate-modal {
    background-color: #2c2c2c;
    padding: 30px;
    border-radius: 12px;
    border: 1px solid #555;
    width: 90%;
    max-width: 600px;
    text-align: center;
    box-shadow: 0 10px 30px rgba(0,0,0,0.5);
}

#donate-title {
    font-family: 'Press Start 2P', system-ui;
    color: #e594ff;
    margin-top: 0;
    font-size: 1.5em;
    margin-bottom: 10px;
}

#donate-subtitle {
    font-size: 1.1em;
    color: #ccc;
    margin-bottom: 30px;
}

.donate-grid {
    display: grid;
    grid-template-columns: repeat(2, 1fr);
    gap: 20px;
    margin-bottom: 30px;
}

.donate-card {
    background-color: #1a1a1a;
    border: 2px solid #444;
    border-radius: 10px;
    padding: 20px;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    text-decoration: none;
    color: white;
    transition: all 0.2s ease-in-out;
    cursor: pointer;
}

.donate-card:hover {
    border-color: #e594ff;
    background-color: #333;
    transform: translateY(-5px);
    box-shadow: 0 5px 15px rgba(229, 148, 255, 0.3);
}

.donate-icon {
    font-size: 3em;
    margin-bottom: 10px;
}

.donate-label {
    font-family: 'Press Start 2P', system-ui;
    font-size: 0.8em;
    line-height: 1.4;
}

#donate-close-btn {
    font-family: 'Press Start 2P', system-ui;
    padding: 15px 30px;
    background-color: #444;
    color: white;
    border: none;
    border-radius: 8px;
    cursor: pointer;
    font-size: 1em;
    transition: background-color 0.2s;
}

#donate-close-btn:hover {
    background-color: #666;
}

@media (max-width: 600px) {
    .donate-grid {
        grid-template-columns: 1fr;
    }
}

/* ============================================================ */
/* === ACTION MENU — LANDSCAPE MOBILE (telefono in orizzontale) */
/* ============================================================ */
/* Targeting: altezza ridotta = telefono in landscape (funziona su touch e browser) */
@media (max-height: 520px) and (max-width: 960px) {

    /* Contenitore a schermo intero */
    #game-ui-container {
        left: 0 !important;
        right: 0 !important;
        width: 100% !important;
        align-items: flex-start !important;
    }

    /* Hamburger: in alto a DESTRA */
    #toggle-ingame-ui-btn {
        position: absolute !important;
        top: 6px !important;
        right: 6px !important;
        left: auto !important;
        width: 40px !important;
        height: 40px !important;
        z-index: 100 !important;
    }

    /* Barra verbi e inventario: a SINISTRA, sfrutta tutta l'altezza verticale */
    #ui-bar {
        margin-top: 6px !important;
        max-height: calc(100dvh - 12px) !important;
        overflow-y: auto !important;
        -webkit-overflow-scrolling: touch !important;
        touch-action: pan-y !important;
        overscroll-behavior: contain !important;
        justify-content: flex-start !important;
        padding: 4px !important;
        width: 130px !important;
        border-left: none !important;
        border-right: 2px solid #3c1c4a !important;
        border-radius: 0 10px 10px 0 !important;
        transform: translateX(0);
    }

    #ui-bar.hidden {
        transform: translateX(-100%) !important;
    }

    /* Bottoni verbi: compatti, partono da CIMA (GIVE, PICK UP, USE, OPEN ecc.) */
    #verb-grid button {
        font-size: 0.58em !important;
        padding: 5px 2px !important;
        min-height: 30px !important;
        line-height: 1.15;
        word-break: break-word;
        overflow: visible;
        white-space: normal;
    }

    /* Slot inventario più compatti */
    .inventory-slot {
        min-width: 34px !important;
        min-height: 34px !important;
    }
}
