/* Colori di ogni pagina: la classe va sul <body> (e sui link in sceltaTabellina.html) */
:root {
    --colore: #5000b8;
    --colore-scuro: #30006e;
}

.tema-text             { --colore: #1565c0; --colore-scuro: #0d3c75; }
.tema-number           { --colore: #2e7d32; --colore-scuro: #1b4d1f; }
.tema-range            { --colore: #c62828; --colore-scuro: #7f1919; }
.tema-password         { --colore: #37474f; --colore-scuro: #1c2529; }
.tema-hidden           { --colore: #6d4c41; --colore-scuro: #3e2b25; }
.tema-textarea         { --colore: #00838f; --colore-scuro: #004f56; }
.tema-select           { --colore: #ef6c00; --colore-scuro: #9a4500; }
.tema-select-senza-submit { --colore: #ad1457; --colore-scuro: #6b0c36; }
.tema-radio            { --colore: #283593; --colore-scuro: #171f58; }
.tema-checkbox         { --colore: #558b2f; --colore-scuro: #33541c; }
.tema-image            { --colore: #8e24aa; --colore-scuro: #561666; }

* { box-sizing: border-box; }

body {
    margin: 0;
    padding: 40px 16px;
    background: #f0f4f3;
    font-family: system-ui, sans-serif;
    color: #333;
}

.card {
    max-width: 520px;
    margin: 0 auto;
    padding: 28px;
    background: #fff;
    border-radius: 12px;
    box-shadow: 0 4px 24px rgba(0, 0, 0, 0.08);
}

h1 {
    margin: 0 0 20px;
    font-size: 1.5rem;
    color: var(--colore);
}

h1:has(+ p) { margin-bottom: 8px; }

p { margin: 0 0 20px; }

form {
    display: flex;
    gap: 10px;
}

input[type="number"] {
    flex: 1;
    padding: 10px 12px;
    font-size: 1rem;
    border: 2px solid #ddd;
    border-radius: 8px;
}

input[type="number"]:focus {
    outline: none;
    border-color: var(--colore);
}

button {
    padding: 10px 20px;
    font-size: 1rem;
    font-weight: 600;
    color: #fff;
    background: var(--colore);
    border: none;
    border-radius: 8px;
    cursor: pointer;
    transition: background 0.2s;
}

button:hover { background: var(--colore-scuro); }

.errore {
    margin: 14px 0 0;
    padding: 10px 14px;
    color: #b00020;
    background: #fdecea;
    border-left: 4px solid #b00020;
    border-radius: 4px;
}

table {
    width: 100%;
    margin-top: 24px;
    border-collapse: collapse;
    font-size: 0.95em;
    border-radius: 8px 8px 0 0;
    overflow: hidden;
    box-shadow: 0 0 20px rgba(0, 0, 0, 0.05);
}

table tr:first-child {
    background: var(--colore);
    color: #fff;
    text-align: left;
    font-weight: bold;
}

td { padding: 12px 15px; }

table tr {
    border-bottom: 1px solid #ddd;
    transition: background 0.15s;
}

table tr:nth-of-type(even) { background: #f3f3f3; }
table tr:not(:first-child):hover { background: #e3f4f0; }
table tr:last-of-type { border-bottom: 2px solid var(--colore); }

td:last-child { font-weight: 600; }

.test-form {
    display: grid;
    grid-template-columns: minmax(120px, 1fr) minmax(100px, 140px);
    align-items: center;
    gap: 10px;
}

.test-form input[type="number"],
.scelta-test select {
    min-width: 0;
    padding: 9px 10px;
    border: 2px solid #ddd;
    border-radius: 6px;
    font: inherit;
}

.test-form button {
    grid-column: 1 / -1;
}

.scelta-test {
    display: grid;
    grid-template-columns: 1fr auto;
    align-items: center;
}

.scelta-test > p,
.scelta-tabelline {
    grid-column: 1 / -1;
}

.scelta-test label {
    font-weight: 600;
}

.scelta-test > input[type="number"] {
    width: 100%;
    padding: 9px 10px;
    border: 2px solid #ddd;
    border-radius: 6px;
    font: inherit;
}

.scelta-tabelline {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 8px;
    width: 100%;
    padding: 12px;
    border: 1px solid #ddd;
    border-radius: 8px;
}

.scelta-tabelline label {
    font-weight: 400;
}

.pulsante-secondario {
    color: var(--colore);
    background: #eee;
}

.pulsante-secondario:hover {
    color: #fff;
}

.risultato-test {
    padding: 12px;
    background: #e8f3ec;
    border-left: 4px solid #2e7d32;
}

.tabella-test th {
    padding: 10px 8px;
    text-align: left;
}

.esito-corretto { color: #1b6a32; }
.esito-errato { color: #ad2934; }

@media (max-width: 480px) {
    .test-form {
        grid-template-columns: minmax(0, 1fr) minmax(80px, 110px);
        gap: 8px;
    }

    .tabella-test {
        font-size: 0.8rem;
    }

    .tabella-test th,
    .tabella-test td {
        padding: 8px 5px;
    }
}

.torna-home {
    display: inline-block;
    margin-top: 20px;
    padding: 10px 20px;
    font-size: 1rem;
    font-weight: 600;
    color: var(--colore);
    background: #fff;
    border: 2px solid var(--colore);
    border-radius: 8px;
    text-decoration: none;
    transition: background 0.2s, color 0.2s;
}

.torna-home:hover {
    background: var(--colore);
    color: #fff;
}

/* sceltaTabellina.html */
.metodi {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(140px, 1fr));
    gap: 10px;
}

.metodo {
    display: block;
    padding: 12px;
    font-size: 1rem;
    font-weight: 600;
    text-align: center;
    color: #fff;
    background: var(--colore);
    border-radius: 8px;
    text-decoration: none;
    transition: background 0.2s;
}

.metodo:hover { background: var(--colore-scuro); }

/* image.php: righe e colonne arrivano da PHP come --colonne e --righe */
.griglia {
    position: relative;
    margin: 0 auto;
}

.griglia input[type="image"] {
    display: block;
    image-rendering: pixelated;
    cursor: crosshair;
}

.celle {
    position: absolute;
    inset: 0;
    display: grid;
    grid-template-columns: repeat(var(--colonne), 1fr);
    grid-template-rows: repeat(var(--righe), 1fr);
    pointer-events: none;
}

.celle span {
    display: flex;
    align-items: center;
    justify-content: center;
    font-weight: 700;
    color: #fff;
    text-shadow: 0 0 4px #000;
    outline: 1px solid rgba(255, 255, 255, 0.6);
}
