* {
  margin: 0;
  padding: 0;
  box-sizing: border-box;
}

:root {
  --primary: #6c5ce7;
  --primary-dark: #5a4bd1;
  --success: #00b894;
  --warning: #fdcb6e;
  --danger: #d63031;
  --bg: #f8f9fa;
  --card-bg: #ffffff;
  --text: #2d3436;
  --text-light: #636e72;
  --radius: 12px;
  --shadow: 0 4px 20px rgba(0, 0, 0, 0.08);
}

body {
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
  background: var(--bg);
  color: var(--text);
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 20px;
}

.app {
  width: 100%;
  max-width: 600px;
}

.screen {
  display: none;
  animation: fadeIn 0.3s ease;
}

.screen.active {
  display: block;
}

@keyframes fadeIn {
  from { opacity: 0; transform: translateY(10px); }
  to { opacity: 1; transform: translateY(0); }
}

/* Setup Screen */
#setup-screen h1 {
  font-size: 3rem;
  text-align: center;
  color: var(--primary);
  margin-bottom: 0;
}

.subtitle {
  text-align: center;
  font-size: 1.2rem;
  color: var(--text-light);
  margin-bottom: 2rem;
}

.setup-section {
  background: var(--card-bg);
  border-radius: var(--radius);
  padding: 1.5rem;
  margin-bottom: 1rem;
  box-shadow: var(--shadow);
}

.setup-section h2 {
  font-size: 1rem;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: var(--text-light);
  margin-bottom: 1rem;
}

/* Team name inputs */
.teams-config {
  display: flex;
  flex-direction: column;
  gap: 0.75rem;
}

.team-input {
  display: flex;
  align-items: center;
  gap: 0.5rem;
}

.team-input label {
  display: flex;
  align-items: center;
}

.team-color-dot {
  display: inline-block;
  width: 14px;
  height: 14px;
  border-radius: 50%;
  flex-shrink: 0;
}

.team-input input {
  flex: 1;
  padding: 0.6rem 1rem;
  border: 2px solid #e0e0e0;
  border-radius: 8px;
  font-size: 1rem;
  transition: border-color 0.2s;
}

.team-input input:focus {
  outline: none;
  border-color: var(--primary);
}

.delete-team-btn {
  width: 36px;
  height: 36px;
  border: none;
  background: none;
  font-size: 1.2rem;
  cursor: pointer;
  border-radius: 8px;
  transition: background 0.2s;
  flex-shrink: 0;
  opacity: 0.5;
}

.delete-team-btn:hover {
  background: #fee2e2;
  opacity: 1;
}

.add-team-btn {
  display: block;
  width: 100%;
  margin-top: 0.75rem;
  padding: 0.6rem;
  border: 2px dashed #ccc;
  border-radius: 8px;
  background: none;
  color: var(--text-light);
  font-size: 0.95rem;
  cursor: pointer;
  transition: all 0.2s;
}

.add-team-btn:hover {
  border-color: var(--primary);
  color: var(--primary);
}

/* Category and time option buttons */
.categories,
.time-options {
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem;
}

.category-btn,
.time-btn {
  padding: 0.5rem 1rem;
  border: 2px solid #e0e0e0;
  border-radius: 20px;
  background: white;
  font-size: 0.9rem;
  cursor: pointer;
  transition: all 0.2s;
}

.category-btn:hover,
.time-btn:hover {
  border-color: var(--primary);
  color: var(--primary);
}

.category-btn.selected,
.time-btn.selected {
  background: var(--primary);
  border-color: var(--primary);
  color: white;
}

/* Buttons */
.primary-btn {
  display: block;
  width: 100%;
  padding: 1rem;
  margin-top: 1.5rem;
  background: var(--primary);
  color: white;
  border: none;
  border-radius: var(--radius);
  font-size: 1.2rem;
  font-weight: 600;
  cursor: pointer;
  transition: background 0.2s, transform 0.1s;
}

.primary-btn:hover {
  background: var(--primary-dark);
}

.primary-btn:active {
  transform: scale(0.98);
}

.secondary-btn {
  display: block;
  width: 100%;
  padding: 0.75rem;
  margin-top: 1rem;
  background: transparent;
  color: var(--text-light);
  border: 2px solid #e0e0e0;
  border-radius: var(--radius);
  font-size: 1rem;
  cursor: pointer;
  transition: all 0.2s;
}

.secondary-btn:hover {
  border-color: var(--text-light);
  color: var(--text);
}

/* Game Screen - Scoreboard */
.scoreboard {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 0.75rem;
  margin-bottom: 1rem;
  flex-wrap: wrap;
}

.team-score {
  display: flex;
  flex-direction: column;
  align-items: center;
  background: var(--card-bg);
  padding: 0.75rem 1rem;
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  min-width: 90px;
  border-top: 4px solid;
  transition: transform 0.2s, box-shadow 0.2s;
}

.team-score.active-team {
  transform: scale(1.05);
  box-shadow: 0 4px 25px rgba(108, 92, 231, 0.2);
}

.team-name {
  font-size: 0.75rem;
  margin-bottom: 0.25rem;
  font-weight: 600;
  text-align: center;
}

.score {
  font-size: 2rem;
  font-weight: 700;
}

.vs {
  font-weight: 700;
  color: var(--text-light);
  font-size: 0.85rem;
}

/* Turn indicator */
.turn-indicator {
  text-align: center;
  padding: 0.75rem;
  background: var(--card-bg);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  margin-bottom: 1rem;
  font-size: 1.1rem;
}

.turn-indicator strong {
  color: var(--primary);
}

/* Round config (per-round category & time selection) */
.round-config {
  background: var(--card-bg);
  border-radius: var(--radius);
  padding: 1rem 1.25rem;
  box-shadow: var(--shadow);
  margin-bottom: 1rem;
}

.round-config-row {
  margin-bottom: 0.75rem;
}

.round-config-row:last-child {
  margin-bottom: 0;
}

.round-config-label {
  display: block;
  font-size: 0.75rem;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: var(--text-light);
  margin-bottom: 0.4rem;
}

.categories-inline,
.time-options-inline {
  display: flex;
  flex-wrap: wrap;
  gap: 0.4rem;
}

.categories-inline .category-btn,
.time-options-inline .time-btn {
  padding: 0.35rem 0.75rem;
  font-size: 0.8rem;
}

/* Word area */
.word-area {
  background: var(--card-bg);
  border-radius: var(--radius);
  padding: 2rem;
  text-align: center;
  box-shadow: var(--shadow);
  margin-bottom: 1.5rem;
}

.word-label {
  display: block;
  font-size: 0.85rem;
  color: var(--text-light);
  margin-bottom: 0.5rem;
  text-transform: uppercase;
  letter-spacing: 0.05em;
}

.the-word {
  display: block;
  font-size: 2.2rem;
  font-weight: 700;
  color: var(--primary);
  min-height: 3rem;
}

.word-hidden .the-word {
  color: transparent;
  background: #e0e0e0;
  border-radius: 8px;
  user-select: none;
}

/* Timer */
.timer-area {
  display: flex;
  justify-content: center;
  margin-bottom: 1.5rem;
}

.timer-circle {
  width: 100px;
  height: 100px;
  border-radius: 50%;
  border: 6px solid #e0e0e0;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: border-color 0.3s;
}

.timer-circle.running {
  border-color: var(--success);
}

.timer-circle.warning {
  border-color: var(--warning);
  animation: pulse 0.5s infinite alternate;
}

.timer-circle.danger {
  border-color: var(--danger);
  animation: pulse 0.3s infinite alternate;
}

@keyframes pulse {
  from { transform: scale(1); }
  to { transform: scale(1.05); }
}

#timer-value {
  font-size: 2rem;
  font-weight: 700;
}

/* Game action buttons */
.game-controls {
  display: flex;
  gap: 1rem;
  margin-bottom: 2.5rem;
}

.action-btn {
  flex: 1;
  padding: 1rem;
  border: none;
  border-radius: var(--radius);
  font-size: 1.1rem;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.2s;
}

.action-btn.correct-btn,
.action-btn.skip-btn {
  padding: 1.5rem 1rem;
  font-size: 1.3rem;
}

.action-btn:disabled {
  opacity: 0.4;
  cursor: not-allowed;
}

.timer-btn {
  background: #00cec9;
  color: white;
}

.timer-btn:hover:not(:disabled) {
  background: #00b5b0;
}

.correct-btn {
  background: var(--success);
  color: white;
}

.correct-btn:hover:not(:disabled) {
  background: #00a382;
}

.skip-btn {
  background: #636e72;
  color: white;
}

.skip-btn:hover:not(:disabled) {
  background: #4a5459;
}

/* Round summary */
.round-summary {
  background: var(--card-bg);
  border-radius: var(--radius);
  padding: 1.5rem;
  text-align: center;
  box-shadow: var(--shadow);
  margin-bottom: 1rem;
}

.round-summary p {
  font-size: 1.2rem;
  margin-bottom: 1rem;
}

.round-summary strong {
  color: var(--primary);
  font-size: 1.5rem;
}

.bottom-controls {
  display: flex;
  gap: 0.75rem;
  margin-top: 2rem;
  padding-top: 1.5rem;
  border-top: 1px solid #e0e0e0;
}

.bottom-controls .secondary-btn {
  flex: 1;
  margin-top: 0;
  padding: 0.6rem;
  font-size: 0.85rem;
}

/* Results Screen */
#results-screen {
  text-align: center;
}

.results-content {
  background: var(--card-bg);
  border-radius: var(--radius);
  padding: 2rem 1.5rem;
  box-shadow: var(--shadow);
  position: relative;
  overflow: hidden;
}

.results-title {
  font-size: 2rem;
  color: var(--text);
  margin-bottom: 0.5rem;
}

.results-winner {
  font-size: 1.5rem;
  font-weight: 700;
  margin-bottom: 1.5rem;
  padding: 0.5rem 1rem;
  border-radius: 8px;
  display: inline-block;
}

.results-totals {
  display: flex;
  justify-content: center;
  flex-wrap: wrap;
  gap: 1rem;
  margin-bottom: 1.5rem;
}

.result-total {
  display: flex;
  flex-direction: column;
  align-items: center;
  padding: 1rem 1.25rem;
  border-radius: var(--radius);
  border: 2px solid #e0e0e0;
  border-left: 4px solid;
  min-width: 100px;
}

.result-team-name {
  font-size: 0.8rem;
  font-weight: 600;
  margin-bottom: 0.25rem;
}

.result-team-score {
  font-size: 2.2rem;
  font-weight: 700;
  color: var(--text);
}

.results-rounds {
  text-align: left;
  margin-top: 1.5rem;
  padding-top: 1.5rem;
  border-top: 2px solid #f0f0f0;
}

.results-rounds h3 {
  font-size: 0.9rem;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: var(--text-light);
  margin-bottom: 0.75rem;
}

.rounds-table {
  width: 100%;
}

.rounds-header,
.rounds-row {
  display: grid;
  text-align: center;
  padding: 0.5rem 0;
}

.rounds-header {
  font-weight: 700;
  font-size: 0.8rem;
  color: var(--text-light);
  border-bottom: 2px solid #f0f0f0;
  margin-bottom: 0.25rem;
}

.rounds-row {
  font-size: 1rem;
  border-bottom: 1px solid #f8f8f8;
}

.rounds-row:last-child {
  border-bottom: none;
}

/* Confetti */
.confetti-container {
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  pointer-events: none;
  overflow: hidden;
}

.confetti-piece {
  position: absolute;
  width: 10px;
  height: 10px;
  top: -10px;
  animation: confettiFall 3s ease-in forwards;
}

@keyframes confettiFall {
  0% { transform: translateY(0) rotate(0deg); opacity: 1; }
  100% { transform: translateY(400px) rotate(720deg); opacity: 0; }
}

/* Help Screen */
#help-screen h1 {
  font-size: 2rem;
  text-align: center;
  color: var(--primary);
  margin-bottom: 1.5rem;
}

.help-content {
  background: var(--card-bg);
  border-radius: var(--radius);
  padding: 1.5rem;
  box-shadow: var(--shadow);
  margin-bottom: 1rem;
}

.help-step {
  display: flex;
  align-items: flex-start;
  gap: 1rem;
  margin-bottom: 1.25rem;
}

.help-step:last-of-type {
  margin-bottom: 0;
}

.step-number {
  display: flex;
  align-items: center;
  justify-content: center;
  min-width: 32px;
  height: 32px;
  background: var(--primary);
  color: white;
  border-radius: 50%;
  font-weight: 700;
  font-size: 0.9rem;
}

.help-step p {
  font-size: 1rem;
  line-height: 1.5;
  color: var(--text);
  padding-top: 4px;
}

.help-rules {
  margin-top: 1.5rem;
  padding-top: 1.25rem;
  border-top: 2px solid #f0f0f0;
}

.help-rules h3 {
  font-size: 1rem;
  color: var(--danger);
  margin-bottom: 0.75rem;
}

.help-rules ul {
  list-style: none;
  padding: 0;
}

.help-rules li {
  position: relative;
  padding-left: 1.5rem;
  margin-bottom: 0.5rem;
  font-size: 0.95rem;
  color: var(--text);
}

.help-rules li::before {
  content: '\2715';
  position: absolute;
  left: 0;
  color: var(--danger);
  font-weight: 700;
}

/* Responsive */
@media (max-width: 480px) {
  #setup-screen h1 {
    font-size: 2.2rem;
  }

  .scoreboard {
    gap: 0.5rem;
  }

  .team-score {
    padding: 0.5rem 0.75rem;
    min-width: 70px;
  }

  .team-name {
    font-size: 0.65rem;
  }

  .score {
    font-size: 1.6rem;
  }

  .vs {
    font-size: 0.7rem;
  }

  .the-word {
    font-size: 1.8rem;
  }

  .game-controls {
    flex-direction: column;
  }

  .results-totals {
    gap: 0.75rem;
  }

  .result-total {
    padding: 0.75rem 1rem;
    min-width: 80px;
  }
}

/* Dialog modal */
.game-dialog {
  border: none;
  border-radius: var(--radius);
  padding: 0;
  max-width: 360px;
  width: 90%;
  box-shadow: 0 8px 40px rgba(0, 0, 0, 0.2);
  position: fixed;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  margin: 0;
  animation: dialogFadeIn 0.2s ease;
}

@keyframes dialogFadeIn {
  from { opacity: 0; transform: translate(-50%, -50%) scale(0.95); }
  to { opacity: 1; transform: translate(-50%, -50%) scale(1); }
}

.game-dialog::backdrop {
  background: rgba(0, 0, 0, 0.5);
  animation: fadeIn 0.2s ease;
}

.dialog-content {
  padding: 2rem 1.5rem 1.5rem;
  text-align: center;
}

.dialog-content p {
  font-size: 1.05rem;
  line-height: 1.5;
  color: var(--text);
  margin-bottom: 1.5rem;
}

.dialog-buttons {
  display: flex;
  gap: 0.75rem;
}

.dialog-btn {
  flex: 1;
  padding: 0.75rem 1rem;
  border: none;
  border-radius: 8px;
  font-size: 1rem;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.2s;
}

.dialog-btn-confirm {
  background: var(--primary);
  color: white;
}

.dialog-btn-confirm:hover {
  background: var(--primary-dark);
}

.dialog-btn-cancel {
  background: #f0f0f0;
  color: var(--text);
}

.dialog-btn-cancel:hover {
  background: #e0e0e0;
}
