/* Base Styles */
:root {
  --primary-color: #3498db;
  --secondary-color: #e74c3c;
  --tertiary-color: #2ecc71;
  --quaternary-color: #f39c12;
  --quinary-color: #9b59b6;
  --senary-color: #1abc9c;
  --background-color: #1a1a2e;
  --text-color: #f0f0f0;
  --border-radius: 12px;
  --transition-speed: 0.3s;
}

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

body {
  font-family: "Segoe UI", Tahoma, Geneva, Verdana, sans-serif;
  background-color: var(--background-color);
  color: var(--text-color);
  line-height: 1.6;
  min-height: 100vh;
  overflow-x: hidden;
  transition: background-color 0.5s ease;
}

.screen {
  display: none;
  min-height: 100vh;
  width: 100%;
  padding: 20px;
}

.screen.active {
  display: flex;
  flex-direction: column;
  justify-content: center;
  align-items: center;
}

.container {
  width: 100%;
  max-width: 500px;
  padding: 20px;
  background-color: rgba(255, 255, 255, 0.1);
  border-radius: var(--border-radius);
  box-shadow: 0 8px 32px rgba(0, 0, 0, 0.3);
  backdrop-filter: blur(10px);
}

h1 {
  text-align: center;
  margin-bottom: 30px;
  font-size: 2rem;
  text-shadow: 0 2px 4px rgba(0, 0, 0, 0.3);
}

/* Settings Screen */
.setting-group {
  margin-bottom: 20px;
}

label {
  display: block;
  margin-bottom: 8px;
  font-weight: 500;
}

.setting-help {
  font-size: 0.85rem;
  margin-top: 5px;
  color: rgba(255, 255, 255, 0.7);
  font-style: italic;
}

input[type="number"],
input[type="text"] {
  width: 100%;
  padding: 12px;
  border: none;
  border-radius: var(--border-radius);
  background-color: rgba(255, 255, 255, 0.15);
  color: var(--text-color);
  font-size: 1rem;
  transition: all var(--transition-speed);
}

input[type="number"]:focus,
input[type="text"]:focus {
  outline: none;
  background-color: rgba(255, 255, 255, 0.25);
  box-shadow: 0 0 0 2px var(--primary-color);
}

.checkbox-label {
  display: flex;
  align-items: center;
  cursor: pointer;
  user-select: none;
}

.checkbox-label input {
  position: absolute;
  opacity: 0;
  cursor: pointer;
  height: 0;
  width: 0;
}

.checkmark {
  position: relative;
  height: 24px;
  width: 24px;
  background-color: rgba(255, 255, 255, 0.15);
  border-radius: 4px;
  margin-right: 10px;
  transition: all var(--transition-speed);
}

.checkbox-label:hover .checkmark {
  background-color: rgba(255, 255, 255, 0.25);
}

.checkbox-label input:checked ~ .checkmark {
  background-color: var(--primary-color);
}

.checkmark:after {
  content: "";
  position: absolute;
  display: none;
}

.checkbox-label input:checked ~ .checkmark:after {
  display: block;
}

.checkbox-label .checkmark:after {
  left: 9px;
  top: 5px;
  width: 6px;
  height: 12px;
  border: solid white;
  border-width: 0 2px 2px 0;
  transform: rotate(45deg);
}

.team-names {
  margin-top: 20px;
}

.team-name-input {
  margin-bottom: 10px;
  display: flex;
  align-items: center;
}

.team-name-input label {
  flex: 0 0 80px;
  margin-bottom: 0;
}

.team-name-input input {
  flex: 1;
}

.team-color {
  width: 24px;
  height: 24px;
  border-radius: 50%;
  margin-left: 10px;
}

.button-group {
  display: flex;
  flex-direction: column;
  gap: 15px;
  margin-top: 30px;
}

.reset-btn {
  display: block;
  width: 100%;
  padding: 12px;
  background-color: var(--secondary-color);
  color: white;
  border: none;
  border-radius: var(--border-radius);
  font-size: 1rem;
  font-weight: 600;
  cursor: pointer;
  transition: all var(--transition-speed);
  box-shadow: 0 4px 12px rgba(231, 76, 60, 0.4);
}

.reset-btn:hover {
  background-color: #c0392b;
  transform: translateY(-2px);
  box-shadow: 0 6px 16px rgba(231, 76, 60, 0.5);
}

.reset-btn:active {
  transform: translateY(1px);
  box-shadow: 0 2px 8px rgba(231, 76, 60, 0.3);
}

.start-btn {
  display: block;
  width: 100%;
  padding: 15px;
  margin-top: 30px;
  background-color: var(--primary-color);
  color: white;
  border: none;
  border-radius: var(--border-radius);
  font-size: 1.2rem;
  font-weight: 600;
  cursor: pointer;
  transition: all var(--transition-speed);
  box-shadow: 0 4px 12px rgba(52, 152, 219, 0.5);
}

.start-btn:hover {
  background-color: #2980b9;
  transform: translateY(-2px);
  box-shadow: 0 6px 16px rgba(52, 152, 219, 0.6);
}

.start-btn:active {
  transform: translateY(1px);
  box-shadow: 0 2px 8px rgba(52, 152, 219, 0.4);
}

/* Game Screen */
.game-container {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  min-height: 100vh;
  width: 100%;
  padding: 20px;
}

.team-indicator {
  font-size: 1.5rem;
  font-weight: 600;
  margin-bottom: 20px;
  padding: 10px 20px;
  border-radius: var(--border-radius);
  background-color: rgba(255, 255, 255, 0.1);
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.2);
  text-align: center;
  min-width: 200px;
}

.timer-container {
  position: relative;
  margin: 20px 0;
}

.progress-ring {
  position: relative;
  width: 300px;
  height: 300px;
}

.progress-ring-svg {
  transform: rotate(-90deg);
}

.progress-ring-circle-bg {
  fill: transparent;
  stroke: rgba(255, 255, 255, 0.1);
  stroke-width: 15;
}

.progress-ring-circle {
  fill: transparent;
  stroke: var(--primary-color);
  stroke-width: 15;
  stroke-dasharray: 879.6;
  stroke-dashoffset: 0;
  transition: stroke-dashoffset 0.5s ease, stroke 0.5s ease;
}

.lights-container {
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  pointer-events: none;
}

.light {
  position: absolute;
  width: 10px;
  height: 10px;
  border-radius: 50%;
  background-color: var(--primary-color);
  box-shadow: 0 0 10px 2px var(--primary-color);
  opacity: 0.8;
  transition: background-color 0.5s ease, box-shadow 0.5s ease;
}

.light-1 {
  top: 5%;
  left: 50%;
}
.light-2 {
  top: 15%;
  left: 85%;
}
.light-3 {
  top: 50%;
  left: 95%;
}
.light-4 {
  top: 85%;
  left: 85%;
}
.light-5 {
  top: 95%;
  left: 50%;
}
.light-6 {
  top: 85%;
  left: 15%;
}
.light-7 {
  top: 50%;
  left: 5%;
}
.light-8 {
  top: 15%;
  left: 15%;
}

.timer-button {
  position: absolute;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  width: 200px;
  height: 200px;
  border-radius: 50%;
  background: radial-gradient(circle, rgba(255, 255, 255, 0.2) 0%, rgba(0, 0, 0, 0.3) 100%);
  border: none;
  color: var(--text-color);
  font-size: 3rem;
  font-weight: 700;
  cursor: pointer;
  transition: all var(--transition-speed);
  box-shadow: 0 0 20px rgba(255, 255, 255, 0.1), inset 0 0 20px rgba(0, 0, 0, 0.2);
  display: flex;
  justify-content: center;
  align-items: center;
  z-index: 10;
}

.timer-button:hover {
  transform: translate(-50%, -50%) scale(1.05);
  box-shadow: 0 0 30px rgba(255, 255, 255, 0.2), inset 0 0 30px rgba(0, 0, 0, 0.3);
}

.timer-button:active {
  transform: translate(-50%, -50%) scale(0.98);
  box-shadow: 0 0 15px rgba(255, 255, 255, 0.1), inset 0 0 15px rgba(0, 0, 0, 0.2);
}

.game-controls {
  display: flex;
  justify-content: center;
  gap: 40px;
  margin-top: 40px;
}

/* Add styles for button tooltips */
.control-btn {
  width: 60px;
  height: 60px;
  border-radius: 50%;
  background-color: rgba(255, 255, 255, 0.1);
  border: none;
  font-size: 1.5rem;
  cursor: pointer;
  transition: all var(--transition-speed);
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.2);
  position: relative;
}

.control-btn:hover {
  background-color: rgba(255, 255, 255, 0.2);
  transform: translateY(-2px);
  box-shadow: 0 6px 16px rgba(0, 0, 0, 0.3);
}

.control-btn:active {
  transform: translateY(1px);
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.2);
}

/* Win Screen */
.win-container {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  min-height: 100vh;
  width: 100%;
  position: relative;
  overflow: hidden;
  padding: 20px;
}

.winner-text {
  font-size: clamp(2rem, 8vw, 4rem);
  font-weight: 700;
  text-align: center;
  margin-bottom: 40px;
  text-shadow: 0 0 20px rgba(0, 0, 0, 0.8), 0 2px 4px rgba(0, 0, 0, 0.6), 0 0 40px rgba(0, 0, 0, 0.5);
  animation: pulse-winning 2s infinite;
  z-index: 100;
  position: relative;
  background-color: rgba(0, 0, 0, 0.4);
  padding: 20px 30px;
  border-radius: var(--border-radius);
  backdrop-filter: blur(15px);
  border: 2px solid rgba(255, 255, 255, 0.1);
  box-shadow: 0 8px 32px rgba(0, 0, 0, 0.3), inset 0 1px 0 rgba(255, 255, 255, 0.1);
  max-width: 90vw;
  word-wrap: break-word;
  hyphens: auto;
  line-height: 1.2;
  white-space: normal;
  overflow-wrap: break-word;
  word-break: break-word;
}

/* Blinking animation for timer display in critical mode */
@keyframes blink {
  0%,
  50% {
    opacity: 1;
  }
  51%,
  100% {
    opacity: 0.3;
  }
}

.timer-display.blink {
  animation: blink 1s infinite;
}

/* Add pulse animation for timer when time is running low */
@keyframes pulse {
  0% {
    transform: translate(-50%, -50%) scale(1);
    box-shadow: 0 0 20px rgba(255, 255, 255, 0.1), inset 0 0 20px rgba(0, 0, 0, 0.2);
  }
  50% {
    transform: translate(-50%, -50%) scale(1.05);
    box-shadow: 0 0 30px var(--primary-color), inset 0 0 30px rgba(0, 0, 0, 0.3);
  }
  100% {
    transform: translate(-50%, -50%) scale(1);
    box-shadow: 0 0 20px rgba(255, 255, 255, 0.1), inset 0 0 20px rgba(0, 0, 0, 0.2);
  }
}

/* Add pulse animation for team flag */
@keyframes pulse-winning {
  0% {
    transform: scale(1);
    box-shadow: 0 0 20px rgba(255, 255, 255, 0.1), inset 0 0 20px rgba(0, 0, 0, 0.2);
  }
  50% {
    transform: scale(1.05);
    box-shadow: 0 0 30px var(--primary-color), inset 0 0 30px rgba(0, 0, 0, 0.3);
  }
  100% {
    transform: scale(1);
    box-shadow: 0 0 20px rgba(255, 255, 255, 0.1), inset 0 0 20px rgba(0, 0, 0, 0.2);
  }
}

.timer-button.pulse {
  animation: pulse 1s infinite;
}

.play-again-btn,
.new-game-btn {
  padding: 15px 30px;
  margin: 10px;
  background-color: var(--primary-color);
  color: white;
  border: none;
  border-radius: var(--border-radius);
  font-size: 1.2rem;
  font-weight: 600;
  cursor: pointer;
  transition: all var(--transition-speed);
  box-shadow: 0 4px 12px rgba(52, 152, 219, 0.5);
}

.play-again-btn:hover,
.new-game-btn:hover {
  background-color: #2980b9;
  transform: translateY(-2px);
  box-shadow: 0 6px 16px rgba(52, 152, 219, 0.6);
}

.play-again-btn:active,
.new-game-btn:active {
  transform: translateY(1px);
  box-shadow: 0 2px 8px rgba(52, 152, 219, 0.4);
}

/* Fireworks Animation */
.fireworks {
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  pointer-events: none;
}

.firework {
  position: absolute;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  width: 0.5rem;
  aspect-ratio: 1;
  background: radial-gradient(circle, var(--primary-color) 0%, transparent 80%);
  border-radius: 50%;
  opacity: 0;
}

.firework:nth-child(1) {
  animation: firework-1 2s ease-out infinite;
  animation-delay: 0s;
}

.firework:nth-child(2) {
  animation: firework-2 2s ease-out infinite;
  animation-delay: 0.5s;
}

.firework:nth-child(3) {
  animation: firework-3 2s ease-out infinite;
  animation-delay: 1s;
}

@keyframes firework-1 {
  0% {
    transform: translate(-50%, -50%) scale(0);
    opacity: 0;
  }
  5% {
    transform: translate(-50%, -50%) scale(0.1);
    opacity: 1;
  }
  30% {
    transform: translate(-50%, -50%) scale(5);
    opacity: 0;
  }
  100% {
    transform: translate(-50%, -50%) scale(5);
    opacity: 0;
  }
}

@keyframes firework-2 {
  0% {
    transform: translate(-30%, -70%) scale(0);
    opacity: 0;
  }
  5% {
    transform: translate(-30%, -70%) scale(0.1);
    opacity: 1;
  }
  30% {
    transform: translate(-30%, -70%) scale(5);
    opacity: 0;
  }
  100% {
    transform: translate(-30%, -70%) scale(5);
    opacity: 0;
  }
}

@keyframes firework-3 {
  0% {
    transform: translate(-70%, -30%) scale(0);
    opacity: 0;
  }
  5% {
    transform: translate(-70%, -30%) scale(0.1);
    opacity: 1;
  }
  30% {
    transform: translate(-70%, -30%) scale(5);
    opacity: 0;
  }
  100% {
    transform: translate(-70%, -30%) scale(5);
    opacity: 0;
  }
}

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

.confetti-piece {
  position: absolute;
  width: 10px;
  height: 20px;
  background-color: var(--primary-color);
  opacity: 0.8;
  animation: confetti-fall 5s linear infinite;
}

.confetti-piece:nth-child(1) {
  left: 10%;
  background-color: var(--secondary-color);
  animation-delay: 0s;
}

.confetti-piece:nth-child(2) {
  left: 30%;
  background-color: var(--tertiary-color);
  animation-delay: 1s;
}

.confetti-piece:nth-child(3) {
  left: 50%;
  background-color: var(--quaternary-color);
  animation-delay: 2s;
}

.confetti-piece:nth-child(4) {
  left: 70%;
  background-color: var(--quinary-color);
  animation-delay: 3s;
}

.confetti-piece:nth-child(5) {
  left: 90%;
  background-color: var(--senary-color);
  animation-delay: 4s;
}

@keyframes confetti-fall {
  0% {
    transform: translateY(-100px) rotate(0deg);
  }
  100% {
    transform: translateY(100vh) rotate(360deg);
  }
}

/* Team Colors */
.team-1 {
  --team-color: var(--primary-color);
}

.team-2 {
  --team-color: var(--secondary-color);
}

.team-3 {
  --team-color: var(--tertiary-color);
}

.team-4 {
  --team-color: var(--quaternary-color);
}

.team-5 {
  --team-color: var(--quinary-color);
}

.team-6 {
  --team-color: var(--senary-color);
}

/* Responsive Design */
@media (max-width: 768px) {
  .progress-ring {
    width: 250px;
    height: 250px;
  }

  .progress-ring-svg {
    width: 250px;
    height: 250px;
  }

  .progress-ring-circle,
  .progress-ring-circle-bg {
    cx: 125px;
    cy: 125px;
    r: 115px;
    stroke-dasharray: 722.5;
  }

  .timer-button {
    width: 170px;
    height: 170px;
    font-size: 2.5rem;
  }

  .winner-text {
    font-size: clamp(1.5rem, 6vw, 2.5rem);
    padding: 15px 20px;
  }
}

@media (max-width: 480px) {
  .progress-ring {
    width: 200px;
    height: 200px;
  }

  .progress-ring-svg {
    width: 200px;
    height: 200px;
  }

  .progress-ring-circle,
  .progress-ring-circle-bg {
    cx: 100px;
    cy: 100px;
    r: 90px;
    stroke-dasharray: 565.5;
  }

  .timer-button {
    width: 140px;
    height: 140px;
    font-size: 2rem;
  }

  .control-btn {
    width: 50px;
    height: 50px;
    font-size: 1.2rem;
  }

  .winner-text {
    font-size: clamp(1.2rem, 5vw, 2rem);
    padding: 10px 15px;
  }

  .win-container {
    padding: 10px;
  }
}

/* PWA Manifest Styles */
@media (display-mode: standalone) {
  body {
    padding-top: env(safe-area-inset-top);
    padding-bottom: env(safe-area-inset-bottom);
    padding-left: env(safe-area-inset-left);
    padding-right: env(safe-area-inset-right);
  }
}
