body {
    font-family: Arial, sans-serif;
    text-align: center;
    margin: 0;
    padding: 20px;
    background-color: #d6e9f8;
    transition: background-color 0.3s, color 0.3s;
}

body.dark-mode {
    background-color: #121212;
    color: #e0e0e0;
}

body.dark-mode .container {
    background-color: #1e1e1e;
    color: #e0e0e0;
}

.container {
    max-width: 800px;
    margin: auto;
    padding: 20px;
    background-color: white;
    box-shadow: 0 0 10px rgba(0,0,0,0.1);
    transition: background-color 0.3s, color 0.3s;
}

h1 {
    margin-bottom: 20px;
}

button {
    padding: 10px 20px;
    font-size: 16px;
    cursor: pointer;
    border: none;
    background-color: #007bff;
    color: white;
    border-radius: 5px;
    margin: 10px;
    transition: background-color 0.3s;
}

button:disabled {
    background-color: #cccccc;
    cursor: not-allowed;
}

body.dark-mode button {
    background-color: #444;
    color: #e0e0e0;
}

body.dark-mode button:hover {
    background-color: #666;
}

#resetButton {
    background-color: #dc3545;
}

body.dark-mode #resetButton {
    background-color: #a22;
}

#resetButton:hover {
    background-color: #c82333;
}

#downloadButton {
    background-color: #28a745;
}

#downloadButton:hover {
    background-color: #218838;
}

body.dark-mode #downloadButton {
    background-color: #1c7430;
}

.traffic-lights {
    display: flex;
    justify-content: space-around;
    margin: 20px 0;
    flex-wrap: wrap;
}

.traffic-light {
    display: flex;
    flex-direction: column;
    align-items: center;
    border: 4px solid #000;
    border-radius: 10px;
    background-color: #111;
    padding: 10px;
    margin: 5px;
}

.light {
    width: 60px;
    height: 60px;
    margin: 10px 0;
    border-radius: 50%;
    background-color: #333;
    transition: background-color 0.5s;
}

.light.red {
    background-color: red;
}

.light.green {
    background-color: green;
}

#message {
    font-size: 18px;
    margin-top: 20px;
}

#result {
    font-size: 24px;
    font-weight: bold;
    margin-top: 20px;
}

#stats {
    font-size: 16px;
    margin-top: 10px;
    font-style: italic;
}

table {
    margin: 30px auto;
    border-collapse: collapse;
    width: 100%;
    max-width: 500px;
}

th, td {
    padding: 10px;
    border: 1px solid #ccc;
}

body.dark-mode table {
    color: #e0e0e0;
    border-color: #555;
}

.flash-yellow {
    animation: flashYellow 1s infinite ease-in-out;
}

@keyframes flashYellow {
    0%   { background-color: #e6d74f; }
    50%  { background-color: #2c2c2c; }
    100% { background-color: #e6d74f; }
}

/* --- MOBILE: 5 semafori tutti visibili, ridimensionati --- */
@media (max-width: 600px) {
  .container {
    padding: 14px;
    border-radius: 10px;
  }

  h1 { font-size: 1.6rem; }

  button {
    padding: 10px 16px;
    font-size: 14px;
    margin: 6px;
  }

  .traffic-lights {
    display: flex;
    flex-wrap: nowrap;                /* tutti in una sola riga */
    justify-content: space-between;
    gap: 6px;                          /* 4 gap => 24px totali */
    margin: 16px 0;
  }

  .traffic-light {
    flex: 0 0 calc((100% - 24px) / 5); /* 5 colonne perfette */
    padding: 6px;
    border-width: 3px;
    margin: 0;
  }

  /* Luci: diametro = larghezza del blocco; altezza con aspect-ratio */
  .light {
    width: 100%;
    aspect-ratio: 1 / 1;               /* cerchio perfetto */
    margin: 4px 0;
  }

  #message { font-size: 16px; }
  #result  { font-size: 20px; }
  table    { font-size: 14px; }

  /* Grafico responsive */
  #chartContainer canvas { max-width: 100%; height: auto !important; }
}
