/* MegaQUIZ! - Styles */

:root {
  --bg: #0f1724;
  --card: #0b1220;
  --accent: #ffcc00;
  --muted: #9ca3af;
  --glass: rgba(255,255,255,0.04);
}

html, body {
  height: 100%;
  margin: 0;
  font-family: Inter, 'Segoe UI', Helvetica, Arial, sans-serif;
  background: linear-gradient(180deg, #071028 0%, #071a2a 100%);
  color: #e6eef8;
}

/* Common Elements */
button, .btn {
  background: var(--accent);
  color: #07203a;
  border: none;
  padding: 8px 12px;
  border-radius: 8px;
  font-weight: 600;
  cursor: pointer;
  font-size: 14px;
  transition: transform 0.15s ease;
}

button:hover, .btn:hover {
  transform: scale(1.05);
}

.btn-secondary {
  background: var(--glass);
  color: #e6eef8;
  border: 1px solid rgba(255,255,255,0.2);
}

.small {
  padding: 6px 10px;
  font-size: 14px;
}

/* Index Page */
.index-container {
  display: flex;
  align-items: center;
  justify-content: center;
  height: 100%;
  padding: 20px;
}

.logo-wrapper {
  width: 80%;
  max-width: 800px;
  cursor: pointer;
  transition: transform 0.3s ease, filter 0.3s ease;
}

.logo-wrapper:hover {
  transform: scale(1.05);
  filter: drop-shadow(0 0 20px rgba(255, 204, 0, 0.3));
}

.logo-wrapper img {
  width: 100%;
  height: auto;
  display: block;
}

/* Accesso Page */
.container {
  display: flex;
  align-items: center;
  justify-content: center;
  min-height: 100vh;
  padding: 20px;
}

.access-box {
  background: linear-gradient(180deg, #06233a, #07324a);
  padding: 32px;
  border-radius: 16px;
  max-width: 500px;
  width: 100%;
  box-shadow: 0 10px 40px rgba(2, 6, 23, 0.8);
}

.logo-mini {
  width: 120px;
  margin-bottom: 24px;
}

h2 {
  margin: 0 0 20px 0;
  font-size: 20px;
  color: var(--muted);
}

.player-selector {
  display: flex;
  gap: 10px;
  margin-bottom: 24px;
}

.player-btn {
  flex: 1;
  background: var(--glass);
  color: #e6eef8;
  border: 2px solid transparent;
  padding: 12px;
  border-radius: 8px;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.2s ease;
  font-size: 18px;
}

.player-btn:hover {
  background: rgba(255,255,255,0.08);
}

.player-btn.active {
  background: var(--accent);
  color: #07203a;
  border-color: var(--accent);
}

.teams-container {
  margin-bottom: 24px;
  max-height: 0;
  overflow: hidden;
  transition: max-height 0.3s ease;
}

.teams-container.show {
  max-height: 400px;
}

.team-input {
  display: flex;
  align-items: center;
  gap: 12px;
  margin-bottom: 12px;
}

.color-box {
  width: 32px;
  height: 32px;
  border-radius: 6px;
  flex-shrink: 0;
}

.team-input input {
  flex: 1;
  background: var(--glass);
  border: 1px solid rgba(255,255,255,0.1);
  padding: 10px 12px;
  border-radius: 8px;
  color: #e6eef8;
  font-size: 16px;
}

.team-input input:focus {
  outline: none;
  border-color: var(--accent);
  background: rgba(255,255,255,0.06);
}

.action-buttons {
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.action-buttons button {
  padding: 14px 20px;
  font-size: 16px;
}

/* Gestione Domande */
.app {
  max-width: 1200px;
  margin: 0 auto;
  padding: 24px;
}

header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 32px;
}

h1 {
  margin: 0;
  font-size: 28px;
  color: var(--accent);
}

.level-selector {
  display: flex;
  gap: 12px;
  margin-bottom: 24px;
}

.level-btn {
  flex: 1;
  background: var(--glass);
  color: #e6eef8;
  border: 2px solid transparent;
  padding: 14px;
  border-radius: 8px;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.2s ease;
}

.level-btn.active {
  background: var(--accent);
  color: #07203a;
  border-color: var(--accent);
}

.questions-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(320px, 1fr));
  gap: 16px;
  margin-bottom: 24px;
}

.question-card {
  background: linear-gradient(180deg, #06233a, #07324a);
  padding: 20px;
  border-radius: 12px;
  box-shadow: 0 6px 18px rgba(2, 6, 23, 0.6);
}

.question-card h3 {
  margin: 0 0 12px 0;
  font-size: 14px;
  color: var(--accent);
  display: flex;
  justify-content: space-between;
  align-items: center;
}

.value-badge {
  background: var(--accent);
  color: #07203a;
  padding: 4px 10px;
  border-radius: 6px;
  font-weight: 700;
  font-size: 16px;
}

label {
  display: block;
  margin-bottom: 6px;
  color: var(--muted);
  font-size: 13px;
  font-weight: 500;
}

input, textarea {
  width: 100%;
  background: var(--glass);
  border: 1px solid rgba(255,255,255,0.1);
  padding: 10px;
  border-radius: 6px;
  color: #e6eef8;
  font-size: 14px;
  margin-bottom: 12px;
  box-sizing: border-box;
  font-family: inherit;
}

textarea {
  min-height: 80px;
  resize: vertical;
}

input:focus, textarea:focus {
  outline: none;
  border-color: var(--accent);
  background: rgba(255,255,255,0.06);
}

.save-section {
  position: sticky;
  bottom: 0;
  background: linear-gradient(180deg, #031a2b, #051e33);
  padding: 20px;
  border-radius: 12px;
  display: flex;
  gap: 12px;
  justify-content: center;
  flex-wrap: wrap;
  box-shadow: 0 -4px 20px rgba(2, 6, 23, 0.8);
}

.save-section button {
  padding: 14px 32px;
  font-size: 16px;
}

.status-message {
  margin-top: 16px;
  padding: 12px;
  border-radius: 8px;
  text-align: center;
  display: none;
}

.status-message.success {
  background: rgba(82, 190, 128, 0.2);
  border: 1px solid #52be80;
  color: #52be80;
}

.status-message.error {
  background: rgba(236, 112, 99, 0.2);
  border: 1px solid #ec7063;
  color: #ec7063;
}

.file-input-wrapper {
  position: relative;
  overflow: hidden;
  display: inline-block;
}

.file-input-wrapper input[type=file] {
  position: absolute;
  left: -9999px;
}

/* Quiz Page */
.quiz-app {
  max-width: 1100px;
  margin: 24px auto;
  padding: 20px 20px 140px 20px;
}

.controls {
  display: flex;
  gap: 8px;
  align-items: center;
}

.board {
  display: grid;
  grid-template-columns: repeat(6, 1fr);
  gap: 8px;
  margin-top: 18px;
}

.category {
  background: var(--card);
  padding: 12px;
  border-radius: 10px;
  text-align: center;
  box-shadow: 0 6px 18px rgba(2, 6, 23, 0.6);
}

.category h2 {
  margin: 0;
  font-size: 14px;
  color: var(--accent);
}

.cat-icon {
  width: 120px;
  height: 60px;
  object-fit: contain;
  display: block;
  margin: 0 auto 8px;
  border-radius: 6px;
}

.cat-icon-fa {
  font-size: 40px;
  display: block;
  margin: 0 auto 12px;
  color: #e6eef8;
}

.cell {
  background: linear-gradient(180deg, #072033, #03304a);
  padding: 12px;
  border-radius: 10px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 18px;
  font-weight: 700;
  cursor: pointer;
  min-height: 60px;
}

.cell.used {
  opacity: 0.10;
  pointer-events: none;
}

.grid-column {
  display: grid;
  grid-auto-rows: minmax(72px, auto);
  gap: 8px;
}

/* Modal */
.modal-backdrop {
  position: fixed;
  inset: 0;
  background: rgba(2, 6, 23, 0.9);
  display: none;
  align-items: center;
  justify-content: center;
  padding: 20px;
  z-index: 1000;
}

.modal {
  background: linear-gradient(180deg, #06233a, #07324a);
  padding: 24px;
  border-radius: 12px;
  max-width: 820px;
  width: 100%;
  box-shadow: 0 10px 40px rgba(2, 6, 23, 0.8);
}

.modal h3 {
  margin: 0 0 8px 0;
}

.current-team {
  background: var(--glass);
  padding: 12px;
  border-radius: 8px;
  margin-bottom: 16px;
  text-align: center;
  font-size: 18px;
  font-weight: 600;
}

.team-indicator {
  display: inline-block;
  width: 16px;
  height: 16px;
  border-radius: 4px;
  margin-right: 8px;
}

#modalMedia img {
  max-width: 100%;
  height: auto;
  border-radius: 8px;
  box-shadow: 0 6px 18px rgba(0, 0, 0, 0.45);
}

#modalMedia audio {
  width: 100%;
  outline: none;
  border-radius: 6px;
}

.clue {
  font-size: 20px;
  line-height: 1.4;
  margin-bottom: 15px;
}

.answer {
  margin-top: 12px;
  padding: 15px;
  border-radius: 8px;
  background: var(--glass);
  display: none;
}

/* Scoreboard */
#scoreboard {
  position: fixed;
  bottom: 0;
  left: 0;
  width: 100%;
  background: linear-gradient(180deg, #031a2b, #051e33);
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 16px 20px;
  gap: 20px;
  z-index: 999;
  flex-wrap: wrap;
}

.team-score {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 4px;
  padding: 10px 16px;
  background: var(--glass);
  border-radius: 10px;
  min-width: 140px;
}

.team-score.active {
  background: rgba(255, 204, 0, 0.15);
  border: 2px solid var(--accent);
}

.team-name {
  font-size: 14px;
  font-weight: 600;
  display: flex;
  align-items: center;
  gap: 6px;
}

.team-points {
  font-size: 28px;
  font-weight: 800;
  color: var(--accent);
}

.level-tag {
  color: var(--muted);
  font-weight: 700;
  font-size: 16px;
}

/* Final Results */
.final-results {
  position: fixed;
  inset: 0;
  background: rgba(2, 6, 23, 0.95);
  display: none;
  align-items: center;
  justify-content: center;
  z-index: 2000;
}

.results-box {
  background: linear-gradient(180deg, #06233a, #07324a);
  padding: 48px;
  border-radius: 16px;
  max-width: 600px;
  width: 90%;
  box-shadow: 0 20px 60px rgba(2, 6, 23, 0.9);
  text-align: center;
}

.winner-section {
  margin-bottom: 32px;
  padding-bottom: 32px;
  border-bottom: 2px solid rgba(255, 204, 0, 0.3);
}

.winner-title {
  font-size: 32px;
  color: var(--accent);
  margin-bottom: 16px;
  font-weight: 800;
  text-shadow: 0 0 20px rgba(255, 204, 0, 0.5);
}

.winner-name {
  font-size: 48px;
  font-weight: 800;
  margin-bottom: 8px;
}

.winner-score {
  font-size: 64px;
  color: var(--accent);
  font-weight: 800;
}

.other-teams {
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.other-team {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 12px 20px;
  background: var(--glass);
  border-radius: 8px;
  font-size: 18px;
}

.other-team-name {
  font-weight: 600;
  display: flex;
  align-items: center;
  gap: 10px;
}

.other-team-score {
  font-size: 24px;
  font-weight: 700;
  color: var(--accent);
}

/* Responsive */
@media (max-width: 900px) {
  .board {
    grid-template-columns: repeat(2, 1fr);
  }
}