*,
*::before,
*::after {
  box-sizing: border-box;
}

html {
  background: #eeeeee;
  font-family: Arial, Helvetica, sans-serif;
  -webkit-text-size-adjust: 100%;
}

/* Layout a colonna: header, contenuto e footer impilati, footer sempre in fondo */
body {
  margin: 0;
  padding: 0;
  min-height: 100vh;
  display: flex;
  flex-direction: column;
  /* testo fluido: 16px su telefono, fino a 22px su desktop */
  font-size: clamp(16px, 0.9rem + 0.6vw, 22px);
  line-height: 1.45;
  background: #4596bf;
  color: #f0f0f0;
}

.site-header {
  background: #4596bf;
  padding: 20px 16px;
  border-bottom: 1px solid #235c79;
  text-align: center;
}

.site-header h1 {
  margin: 0;
  font-size: clamp(1.35rem, 1rem + 2.5vw, 2.25rem);
  line-height: 1.2;
}

section.vbrotations {
  background: #63b6e0;
  padding-top: 10px;
  padding-bottom: 10px;
  color: #ffffff;
}

section.notes {
  flex: 1 0 auto;
  background: #4596bf;
  border-top: 1px solid #235c79;
  padding-top: 20px;
  padding-bottom: 40px;
}

div.container {
  width: 100%;
  max-width: 900px;
  margin-left: auto;
  margin-right: auto;
  padding-left: 16px;
  padding-right: 16px;
}

/* Diagramma: centrato e ridimensionato alla larghezza disponibile */
.diagram {
  display: flex;
  justify-content: center;
}

.diagram > svg {
  display: block;
  width: 100%;
  max-width: 600px;
  height: auto;
}

/* Barra rotazioni: servizio/ricezione + posizione del palleggiatore (P1-P6) */
.rotation-bar {
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  gap: 10px;
  padding-top: 6px;
  padding-bottom: 12px;
}

.segmented {
  display: flex;
  border: 2px solid #ffffff;
  border-radius: 8px;
  overflow: hidden;
}

.segmented button {
  flex: 1 1 0;
  min-width: 44px;
  min-height: 44px;
  margin: 0;
  padding: 8px 14px;
  border: 0;
  border-left: 1px solid rgba(255, 255, 255, 0.6);
  background: #4596bf;
  color: #ffffff;
  font: inherit;
  font-size: clamp(15px, 0.85rem + 0.3vw, 18px);
  font-weight: bold;
  cursor: pointer;
  touch-action: manipulation;
}

.segmented button:first-child {
  border-left: 0;
}

.segmented button:hover {
  background: #3a86ad;
}

.segmented button[aria-pressed="true"] {
  background: #ffffff;
  color: #235c79;
}

.segmented button:focus-visible {
  outline: 3px solid #235c79;
  outline-offset: -3px;
}

.segmented[hidden] {
  display: none;
}

/* Seconda barra: fasi del gioco (servizio o ricezione), attaccata alla prima */
.phase-bar {
  padding-top: 0;
}

.phase-bar .segmented {
  border-color: rgba(255, 255, 255, 0.8);
}

.phase-bar .segmented button {
  font-weight: normal;
}

.phase-bar .segmented button[aria-pressed="true"] {
  font-weight: bold;
}

/* Legenda dei ruoli sotto il campo */
.legend {
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  gap: 8px 18px;
  margin: 0 auto;
  padding-top: 4px;
  padding-bottom: 10px;
  list-style: none;
  font-size: clamp(14px, 0.8rem + 0.3vw, 17px);
}

.legend li {
  display: flex;
  align-items: center;
  gap: 4px;
  margin: 0;
  white-space: nowrap;
}

.legend li .player-badge:last-of-type {
  margin-right: 4px;
}

.player-badge {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 30px;
  height: 30px;
  padding: 0 4px;
  border: 2px solid #f5f5f5;
  border-radius: 15px;
  background: #efa581;
  color: #ffffff;
  font-size: 13px;
  font-weight: bold;
}

/* Interruttore on/off delle traiettorie, subito sotto il campo */
.trails-row {
  display: flex;
  justify-content: center;
  padding-top: 8px;
  padding-bottom: 4px;
}

.trails-switch {
  display: inline-flex;
  align-items: center;
  gap: 10px;
  min-height: 44px;
  padding: 6px 12px;
  border: 0;
  border-radius: 8px;
  background: transparent;
  color: #ffffff;
  font: inherit;
  font-size: clamp(15px, 0.85rem + 0.3vw, 18px);
  font-weight: bold;
  cursor: pointer;
  touch-action: manipulation;
}

.trails-switch:hover {
  background: rgba(255, 255, 255, 0.12);
}

.trails-switch:focus-visible {
  outline: 3px solid #235c79;
  outline-offset: 2px;
}

.switch-track {
  position: relative;
  flex: none;
  width: 44px;
  height: 24px;
  border: 2px solid #ffffff;
  border-radius: 12px;
  background: #4596bf;
  transition: background 0.15s;
}

.switch-knob {
  position: absolute;
  top: 2px;
  left: 2px;
  width: 16px;
  height: 16px;
  border-radius: 50%;
  background: #ffffff;
  transition: transform 0.15s;
}

.trails-switch[aria-checked="true"] .switch-track {
  background: #7ec485;
}

.trails-switch[aria-checked="true"] .switch-knob {
  transform: translateX(20px);
}

.tutorial-row {
  display: flex;
  justify-content: center;
  padding-top: 4px;
}

.tutorial-button {
  min-height: 44px;
  padding: 8px 28px;
  border: 0;
  border-radius: 8px;
  background: #7ec485;
  color: #ffffff;
  font: inherit;
  font-weight: bold;
  cursor: pointer;
}

.tutorial-button:hover {
  background: #6cb574;
}

/* Selettore lingua */
.lang-picker {
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  align-items: center;
  gap: 12px;
  padding-top: 10px;
}

.lang-picker img {
  display: block;
  width: 26px;
  height: auto;
  cursor: pointer;
}

footer.footer {
  flex-shrink: 0;
  background: #235c79;
  color: #4596bf;
  padding: 15px 16px;
  text-align: right;
  font-size: clamp(13px, 0.75rem + 0.4vw, 18px);
}

footer.footer p {
  margin: 0;
}

/* Riga "Made by P-SOFT" con logo, prima dei crediti */
footer.footer p.made-by {
  margin-bottom: 8px;
}

footer.footer .made-by a {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  color: #ffffff;
  font-weight: bold;
  text-decoration: none;
}

.made-by a:hover span {
  text-decoration: underline;
}

.made-by img {
  display: block;
  width: 22px;
  height: auto;
}

a:link,
a:visited,
a:hover,
a:active {
  color: inherit;
}

li {
  margin-left: 1.12em;
}

@media (max-width: 600px) {
  .site-header {
    padding: 14px 12px;
  }

  div.container {
    padding-left: 12px;
    padding-right: 12px;
  }

  .rotation-bar,
  .segmented {
    width: 100%;
  }

  .segmented button {
    padding: 8px 4px;
  }

  section.vbrotations div.container.diagram {
    padding-left: 0;
    padding-right: 0;
  }

  .lang-picker {
    gap: 14px;
  }

  .lang-picker img {
    width: 32px;
  }

  footer.footer {
    text-align: center;
  }
}
