:root {
  --purple: #46178f;
  --teal: #20c59b;
  --red: #e21b3c;
  --blue: #1368ce;
  --yellow: #d89e00;
  --green: #26890c;
  --dark: #2b1a4a;
  --gold: #ffd23f;
  --silver: #cfd8dc;
  --bronze: #d98246;
}

* {
  box-sizing: border-box;
}

html, body {
  margin: 0;
  min-height: 100vh;
}

body {
  font-family: "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
  background: linear-gradient(160deg, var(--purple), var(--teal));
  color: #fff;
  display: flex;
  flex-direction: column;
  align-items: center;
}

.screen {
  width: 100%;
  max-width: 520px;
  padding: 24px 20px;
  display: flex;
  flex-direction: column;
  align-items: center;
  text-align: center;
  gap: 18px;
}

.hidden {
  display: none !important;
}

h1 {
  font-size: 2rem;
  margin: 8px 0;
  letter-spacing: 1px;
}

h1 .accent {
  color: var(--yellow);
}

p {
  line-height: 1.4;
}

.card {
  background: rgba(255, 255, 255, 0.1);
  border-radius: 16px;
  padding: 20px;
  width: 100%;
  backdrop-filter: blur(4px);
}

input[type="text"],
input[type="password"] {
  width: 100%;
  padding: 14px 16px;
  border-radius: 10px;
  border: none;
  font-size: 1.1rem;
  margin-bottom: 12px;
}

button {
  cursor: pointer;
  border: none;
  border-radius: 12px;
  font-weight: 700;
  font-size: 1.1rem;
  padding: 14px 22px;
  background: var(--yellow);
  color: var(--dark);
  transition: transform 0.1s ease;
  width: 100%;
}

button:active {
  transform: scale(0.97);
}

button:disabled {
  opacity: 0.5;
  cursor: default;
}

.error {
  color: #ffb4c0;
  font-weight: 600;
}

.small {
  font-size: 0.85rem;
  opacity: 0.85;
}

/* ---------- Timer circolare (host) ---------- */
.circle-timer {
  position: relative;
  width: 96px;
  height: 96px;
}

.circle-timer svg {
  transform: rotate(-90deg);
  width: 100%;
  height: 100%;
}

.circle-timer circle {
  fill: none;
  stroke-width: 8;
}

.circle-timer .track {
  stroke: rgba(255, 255, 255, 0.25);
}

.circle-timer .progress {
  stroke: var(--yellow);
  stroke-linecap: round;
  transition: stroke-dashoffset 0.2s linear;
}

.circle-timer .value {
  position: absolute;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 1.6rem;
  font-weight: 800;
}

/* ---------- Barra timer sottile (player, in alto) ---------- */
.timer-bar-track {
  width: 100%;
  height: 8px;
  background: rgba(0, 0, 0, 0.25);
  flex-shrink: 0;
}

.timer-bar-fill {
  height: 100%;
  background: var(--yellow);
  width: 100%;
  transition: width 0.2s linear;
}

/* ---------- Schermata domanda host: card bianca + tile con testo ---------- */
.host-question-wrap {
  width: 100%;
  max-width: 900px;
  padding: 20px;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 18px;
}

.question-card {
  background: #fff;
  color: var(--dark);
  border-radius: 18px;
  padding: 22px 28px;
  width: 100%;
  font-size: 1.5rem;
  font-weight: 800;
  text-align: center;
  box-shadow: 0 8px 0 rgba(0, 0, 0, 0.15);
}

.host-tile-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 14px;
  width: 100%;
}

.host-tile {
  min-height: 110px;
  border-radius: 14px;
  color: #fff;
  font-size: 1.15rem;
  font-weight: 700;
  display: flex;
  align-items: center;
  gap: 14px;
  padding: 16px 20px;
  box-shadow: 0 6px 0 rgba(0, 0, 0, 0.18);
}

.host-tile .shape {
  font-size: 1.6rem;
  flex-shrink: 0;
}

.tile-0 { background: var(--red); }
.tile-1 { background: var(--blue); }
.tile-2 { background: #e8b400; }
.tile-3 { background: var(--green); }

/* ---------- Schermata domanda player: tile edge-to-edge, solo forme ---------- */
.player-question-shell {
  width: 100%;
  min-height: 100vh;
  padding: 0;
  gap: 0;
  max-width: none;
}

.player-tile-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  grid-template-rows: 1fr 1fr;
  width: 100%;
  flex: 1;
  min-height: calc(100vh - 8px);
}

.player-tile {
  border: none;
  border-radius: 0;
  width: 100%;
  height: 100%;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 4rem;
  color: #fff;
}

.player-tile:active {
  filter: brightness(0.82);
}

.player-tile:disabled {
  opacity: 0.5;
}

.locked-note {
  position: fixed;
  bottom: 18px;
  left: 0;
  right: 0;
  text-align: center;
  font-weight: 700;
  text-shadow: 0 2px 6px rgba(0, 0, 0, 0.5);
}

/* ---------- Feedback risposta (player), a piena pagina ---------- */
.feedback-full {
  width: 100%;
  min-height: 100vh;
  max-width: none;
  justify-content: center;
  gap: 10px;
}

.feedback-full.ok { background: var(--green); }
.feedback-full.ko { background: var(--red); }

.feedback-icon {
  font-size: 5rem;
}

.feedback-points {
  font-size: 1.8rem;
  font-weight: 800;
}

/* ---------- Grafico a barre delle risposte (host, dopo ogni domanda) ---------- */
.answer-chart {
  width: 100%;
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.answer-chart-row {
  display: flex;
  align-items: center;
  gap: 10px;
}

.answer-chart-shape {
  width: 28px;
  flex-shrink: 0;
  text-align: center;
  font-size: 1.2rem;
}

.answer-chart-bar-track {
  flex: 1;
  background: rgba(255, 255, 255, 0.15);
  border-radius: 8px;
  overflow: hidden;
  height: 30px;
}

.answer-chart-bar {
  height: 100%;
  min-width: 2px;
  display: flex;
  align-items: center;
  justify-content: flex-end;
  padding-right: 8px;
  font-weight: 800;
  font-size: 0.9rem;
  transition: width 0.6s ease;
}

.answer-chart-row.correct .answer-chart-shape {
  color: var(--yellow);
}

/* ---------- Classifica con barre proporzionali ---------- */
.leaderboard-bars {
  width: 100%;
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.lb-row {
  display: flex;
  align-items: center;
  gap: 10px;
  background: rgba(255, 255, 255, 0.08);
  border-radius: 10px;
  padding: 8px 12px;
}

.lb-rank {
  width: 26px;
  font-weight: 800;
  flex-shrink: 0;
}

.lb-name {
  flex-shrink: 0;
  width: 34%;
  text-align: left;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.lb-bar-track {
  flex: 1;
  height: 18px;
  background: rgba(255, 255, 255, 0.12);
  border-radius: 9px;
  overflow: hidden;
}

.lb-bar {
  height: 100%;
  background: var(--yellow);
  transition: width 0.6s ease;
}

.lb-score {
  width: 60px;
  text-align: right;
  font-weight: 700;
  flex-shrink: 0;
}

.lb-row.rank-1 .lb-bar { background: var(--gold); }
.lb-row.rank-2 .lb-bar { background: var(--silver); }
.lb-row.rank-3 .lb-bar { background: var(--bronze); }

/* ---------- Podio finale ---------- */
.podium {
  display: flex;
  align-items: flex-end;
  justify-content: center;
  gap: 10px;
  width: 100%;
  margin-top: 20px;
}

.podium-col {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 6px;
  width: 30%;
}

.podium-name {
  font-weight: 700;
  font-size: 0.95rem;
  max-width: 100%;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.podium-score {
  font-size: 0.85rem;
  opacity: 0.9;
}

.podium-pillar {
  width: 100%;
  border-radius: 10px 10px 0 0;
  display: flex;
  align-items: flex-start;
  justify-content: center;
  padding-top: 10px;
  font-size: 1.8rem;
  font-weight: 800;
  color: var(--dark);
}

.podium-col.first .podium-pillar { height: 150px; background: var(--gold); order: -1; }
.podium-col.second .podium-pillar { height: 105px; background: var(--silver); }
.podium-col.third .podium-pillar { height: 75px; background: var(--bronze); }

.podium-col.first { order: 2; }
.podium-col.second { order: 1; }
.podium-col.third { order: 3; }

.badge {
  display: inline-block;
  padding: 4px 12px;
  border-radius: 20px;
  font-weight: 700;
  font-size: 0.9rem;
}

.badge.ok { background: var(--green); }
.badge.ko { background: var(--red); }

.alert-card {
  background: #7a0f1f;
  border: 3px solid var(--red);
  border-radius: 16px;
  padding: 32px 20px;
  animation: alert-pulse 1.2s ease-in-out infinite;
}

.alert-card h1 {
  color: #fff;
  font-size: 2.1rem;
  margin: 6px 0 14px;
}

.alert-icon {
  font-size: 3rem;
}

.alert-main {
  font-size: 1.15rem;
  font-weight: 800;
  margin-bottom: 10px;
}

@keyframes alert-pulse {
  0%, 100% { box-shadow: 0 0 0 0 rgba(226, 27, 60, 0.6); }
  50% { box-shadow: 0 0 0 16px rgba(226, 27, 60, 0); }
}
