* {
  box-sizing: border-box;
}

body {
  margin: 0;
  padding: 25px;
  min-height: 100vh;
  font-family: Arial, Helvetica, sans-serif;
  color: white;
  overflow-x: hidden;

  background:
    radial-gradient(circle at 10% 10%, rgba(0, 212, 255, 0.45), transparent 28%),
    radial-gradient(circle at 85% 20%, rgba(255, 0, 200, 0.35), transparent 26%),
    radial-gradient(circle at 50% 90%, rgba(255, 215, 0, 0.25), transparent 30%),
    linear-gradient(135deg, #030416, #07136b 50%, #160033);
}

.background-stars {
  position: fixed;
  inset: 0;
  pointer-events: none;
  z-index: -1;

  background-image:
    radial-gradient(circle, rgba(255,255,255,0.8) 1px, transparent 1px),
    radial-gradient(circle, rgba(255,255,255,0.45) 1px, transparent 1px);

  background-size: 70px 70px, 120px 120px;
  background-position: 0 0, 35px 55px;

  animation: starDrift 18s linear infinite;
  opacity: 0.55;
}

@keyframes starDrift {
  from {
    transform: translateY(0);
  }

  to {
    transform: translateY(80px);
  }
}

.app-header {
  position: relative;

  display: flex;
  align-items: center;
  justify-content: space-between;

  margin-bottom: 25px;
}

.title-row {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 14px;
}

h1 {
  margin: 0;

  font-size: clamp(2rem, 5vw, 3.6rem);

  letter-spacing: 2px;

  color: white;

  text-shadow:
    0 0 12px rgba(255,255,255,0.35),
    0 0 28px rgba(0,212,255,0.35),
    0 5px 18px rgba(0,0,0,0.65);
}

.mode-badge,
.autosave-badge {
  padding: 10px 16px;

  border-radius: 999px;

  font-weight: 900;

  letter-spacing: 1px;

  text-transform: uppercase;

  box-shadow: 0 0 18px rgba(0,0,0,0.4);
}

.edit-badge {
  background: linear-gradient(135deg, #00d4ff, #0066ff);
  color: white;
}

.play-badge {
  background: linear-gradient(135deg, #00ff88, #00a35c);
  color: #001f12;
}

.autosave-badge {
  background: rgba(255,255,255,0.12);
  border: 1px solid rgba(255,255,255,0.25);
  color: #ffd700;
  font-size: 0.8rem;
}

.autosave-badge.saving {
  color: white;
  background: linear-gradient(135deg, #ff9f1c, #ff4d00);
}

button {
  padding: 12px 16px;

  border: none;
  border-radius: 12px;

  background: linear-gradient(135deg, #ffd700, #ff9f1c);

  color: #111;

  font-weight: bold;

  cursor: pointer;

  transition: 0.2s ease;

  box-shadow:
    0 5px 15px rgba(0,0,0,0.35),
    inset 0 1px 0 rgba(255,255,255,0.45);
}

button:hover {
  transform: translateY(-2px) scale(1.02);
  filter: brightness(1.08);
}

button:active {
  transform: translateY(1px) scale(0.98);
}

.secondary-btn {
  background: linear-gradient(135deg, #cccccc, #888888);
}

.danger-btn {
  background: linear-gradient(135deg, #ff4d4d, #b30000);
  color: white;
}

.menu-toggle {
  font-size: 1rem;
}

.dropdown-menu {
  position: absolute;

  top: 70px;
  right: 0;

  width: 280px;

  padding: 18px;

  border-radius: 18px;

  background: rgba(8,10,35,0.98);

  border: 2px solid rgba(255,255,255,0.15);

  box-shadow: 0 15px 40px rgba(0,0,0,0.5);

  z-index: 1000;

  animation: menuDrop 0.2s ease;
}

@keyframes menuDrop {
  from {
    opacity: 0;
    transform: translateY(-10px) scale(0.97);
  }

  to {
    opacity: 1;
    transform: translateY(0) scale(1);
  }
}

.dropdown-menu h3 {
  margin-top: 15px;
  margin-bottom: 10px;

  color: #ffd700;

  border-bottom: 1px solid rgba(255,255,255,0.15);

  padding-bottom: 5px;
}

.dropdown-menu label {
  display: block;
  margin-bottom: 6px;
  font-weight: bold;
}

.dropdown-menu button,
.dropdown-menu select {
  width: 100%;

  margin-bottom: 10px;
}

.dropdown-menu select {
  padding: 12px;

  border: none;
  border-radius: 10px;

  font-weight: bold;
}

.hidden,
.modal.hidden,
.dropdown-menu.hidden {
  display: none;
}

.game-layout {
  display: grid;
  grid-template-columns: 260px 1fr;
  gap: 25px;
  align-items: start;
}

.scoreboard {
  padding: 18px;

  border-radius: 22px;

  background:
    linear-gradient(160deg, rgba(255,255,255,0.16), rgba(255,255,255,0.05));

  border: 2px solid rgba(255,255,255,0.15);

  box-shadow:
    0 10px 30px rgba(0,0,0,0.4),
    inset 0 1px 0 rgba(255,255,255,0.2);
}

.scoreboard h2 {
  margin-top: 0;

  color: #ffd700;

  text-align: center;

  text-shadow: 0 0 12px rgba(255,215,0,0.45);
}

.team-card {
  padding: 12px;

  margin-bottom: 12px;

  border-radius: 16px;

  background: rgba(0,0,0,0.35);

  border: 2px solid transparent;

  transition: 0.2s ease;
}

.active-team {
  border-color: #ffd700;

  box-shadow:
    0 0 18px rgba(255,215,0,0.5),
    inset 0 0 20px rgba(255,215,0,0.1);
}

.team-card input {
  width: 100%;

  padding: 8px;

  border-radius: 8px;

  border: none;

  text-align: center;

  font-weight: bold;
}

.score {
  margin: 10px 0;

  font-size: 2rem;

  font-weight: 900;

  color: #ffd700;

  text-align: center;

  text-shadow: 0 0 12px rgba(255,215,0,0.45);
}

.game-board {
  display: grid;

  gap: 14px;

  border-radius: 22px;

  padding: 10px;

  perspective: 1200px;

  transition: 0.25s ease;
}

body.edit-mode .game-board {
  outline: 4px solid rgba(0, 212, 255, 0.6);

  box-shadow: 0 0 35px rgba(0, 212, 255, 0.25);
}

body.play-mode .game-board {
  outline: 4px solid rgba(0, 255, 136, 0.65);

  box-shadow: 0 0 35px rgba(0, 255, 136, 0.25);
}

.category-tile {
  min-height: 90px;

  padding: 10px;

  border-radius: 18px;

  background:
    linear-gradient(160deg, #151b66, #080b2b);

  border: 2px solid rgba(255,255,255,0.35);

  display: flex;
  align-items: center;
  justify-content: center;

  text-align: center;

  font-size: 1.15rem;

  font-weight: 900;

  color: white;

  text-transform: uppercase;

  cursor: pointer;

  transition: 0.2s ease;

  box-shadow:
    inset 0 0 25px rgba(255,255,255,0.08),
    0 10px 25px rgba(0,0,0,0.35);
}

.category-tile:hover {
  transform: scale(1.03);

  background: linear-gradient(160deg, #252d9e, #0b0f3e);
}

.tile {
  height: 125px;

  border-radius: 18px;

  background: transparent;

  border: none;

  cursor: pointer;

  perspective: 1000px;

  transition: 0.2s ease;
}

.tile:hover {
  transform: translateY(-4px) scale(1.02);
}

.tile-inner {
  position: relative;

  width: 100%;
  height: 100%;

  transition: transform 0.55s ease;

  transform-style: preserve-3d;
}

.tile.flipped .tile-inner {
  transform: rotateY(180deg);
}

.tile-front,
.tile-back {
  position: absolute;

  inset: 0;

  border-radius: 18px;

  display: flex;
  align-items: center;
  justify-content: center;

  backface-visibility: hidden;

  border: 2px solid rgba(255,255,255,0.35);

  box-shadow:
    inset 0 0 25px rgba(255,255,255,0.08),
    0 10px 25px rgba(0,0,0,0.4);
}

.tile-front {
  background:
    radial-gradient(circle at 30% 20%, rgba(255,255,255,0.22), transparent 22%),
    linear-gradient(160deg, #0b2bff, #020a8a);

  font-size: 2.5rem;

  font-weight: 900;

  color: #ffd700;

  text-shadow:
    0 0 12px rgba(255,215,0,0.45),
    0 4px 8px rgba(0,0,0,0.75);
}

.tile-back {
  transform: rotateY(180deg);

  background:
    radial-gradient(circle at 30% 20%, rgba(255,255,255,0.18), transparent 22%),
    linear-gradient(160deg, #1b1b1b, #050505);

  color: #777;

  font-size: 1.2rem;

  font-weight: 900;

  text-transform: uppercase;
}

.used {
  pointer-events: none;
  opacity: 0.75;
}

.modal {
  position: fixed;

  inset: 0;

  display: flex;
  align-items: center;
  justify-content: center;

  padding: 20px;

  background: rgba(0,0,0,0.78);

  z-index: 2000;

  animation: modalFade 0.2s ease;
}

@keyframes modalFade {
  from {
    opacity: 0;
  }

  to {
    opacity: 1;
  }
}

.modal-box {
  width: min(700px, 95vw);

  padding: 25px;

  border-radius: 24px;

  background:
    linear-gradient(160deg, #10153d, #050725);

  border: 2px solid rgba(255,255,255,0.2);

  box-shadow:
    0 20px 60px rgba(0,0,0,0.6),
    0 0 35px rgba(0,212,255,0.18);

  animation: modalPop 0.22s ease;
}

@keyframes modalPop {
  from {
    transform: scale(0.92);
  }

  to {
    transform: scale(1);
  }
}

.modal-box h2 {
  margin-top: 0;

  text-align: center;

  color: #ffd700;

  text-shadow: 0 0 14px rgba(255,215,0,0.4);
}

.modal-box label {
  display: block;

  margin: 15px 0 6px;

  font-weight: bold;
}

.modal-box textarea,
.modal-box input {
  width: 100%;

  padding: 12px;

  border-radius: 12px;

  border: none;

  font-size: 1rem;
}

.modal-box textarea {
  min-height: 110px;

  resize: vertical;
}

.modal-buttons {
  margin-top: 20px;

  text-align: center;
}

.play-box {
  text-align: center;
}

#playQuestion {
  margin: 25px 0;

  font-size: clamp(1.4rem, 4vw, 2.1rem);

  line-height: 1.4;
}

.answer-text {
  margin-top: 20px;

  padding: 16px;

  border-radius: 14px;

  background: rgba(255,255,255,0.1);

  color: #ffd700;

  font-size: 1.35rem;

  font-weight: bold;

  box-shadow: inset 0 0 20px rgba(255,215,0,0.08);
}

.confetti-pop {
  animation: confettiPop 0.45s ease;
}

@keyframes confettiPop {
  0% {
    transform: scale(1);
  }

  45% {
    transform: scale(1.08) rotate(-1deg);
  }

  100% {
    transform: scale(1);
  }
}

.active-button {
  outline: 3px solid white;
  box-shadow: 0 0 20px rgba(255,255,255,0.75);
}

@media (max-width: 900px) {
  .game-layout {
    grid-template-columns: 1fr;
  }

  .scoreboard {
    order: 2;
  }

  .app-header {
    align-items: flex-start;
    gap: 15px;
  }
}