/* Reset */
*,
*::before,
*::after {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
}

body {
  font-family: 'Segoe UI', sans-serif;
  background: linear-gradient(135deg, #000b21, #101532);
  color: #f1f7ff;
  line-height: 1.6;
  overflow-x: hidden;
  transition: background 0.4s, color 0.3s;
}

body.dark-mode {
  background: linear-gradient(135deg, #23262e, #0a0c13);
  color: #eaeaff;
}

/* Background Overlay (GIF from JS) */
#background-overlay {
  position: fixed;
  top: 0; left: 0;
  width: 100vw;
  height: 100vh;
  z-index: -1;
  background-position: center;
  background-size: cover;
  background-repeat: no-repeat;
  opacity: 0.2;
  filter: blur(3px);
}

/* Header */
header {
  text-align: center;
  padding: 2.5rem 1rem 1.3rem;
}
header h1 {
  font-size: 2.5rem;
  color: #56aedc;
  font-weight: 800;
  text-shadow: 0 0 12px #1c2547;
}
header p {
  color: #cccdee;
  font-size: 1.1rem;
  margin-top: 6px;
}

/* Tabs */
#tabs {
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  gap: 0.5rem;
  margin-bottom: 1.2rem;
}
.tab-btn {
  background: rgba(33,49,77,0.85);
  color: #c7d8ff;
  border: none;
  border-radius: 20px;
  padding: 0.6em 1.3em;
  font-weight: bold;
  cursor: pointer;
  transition: 0.25s;
}
.tab-btn:hover,
.tab-btn:focus {
  background: #9cb8fc;
  color: #0d1c3a;
}
.tab-btn.active {
  background: #f1f4ff;
  color: #1a2349;
  box-shadow: 0 2px 15px #6fa3ff80;
}

/* Controls Container */
.controls {
  display: flex;
  justify-content: center;
  align-items: center;
  flex-wrap: wrap;
  gap: 1rem;
  margin-bottom: 1rem;
}

/* Timer Select */
#time-selection {
  font-size: 1rem;
  color: #ddeaff;
}
#practice-time-select {
  margin-left: 0.5em;
  padding: 0.4em 1em;
  border-radius: 8px;
  border: 1px solid #ddeaff;
  font-weight: 600;
  background: #eef4ff;
  color: #27345a;
}

/* Control Buttons */
.control-buttons {
  display: flex;
  gap: 0.6rem;
}
.control-buttons button {
  background: #2a2f4e;
  color: #b0cdf6;
  border: none;
  border-radius: 50%;
  padding: 0.5em 0.7em;
  font-size: 1.1rem;
  cursor: pointer;
  transition: 0.2s;
}
.control-buttons button:hover {
  background: #b1d1ff;
  color: #000b2a;
}

/* Typing Game Area */
main#typing-game {
  max-width: 680px;
  margin: auto;
  background: rgba(12,18,38, 0.9);
  border-radius: 1.5rem;
  box-shadow: 0 8px 48px #2a379a50;
  padding: 2rem 1.5rem;
}

#level-progress {
  display: flex;
  align-items: center;
  gap: 1rem;
  justify-content: center;
  margin-bottom: 1rem;
}
#progress-bar {
  width: 220px;
  height: 1rem;
  border-radius: 100px;
  accent-color: #32d288;
}
#level-info {
  font-size: 1rem;
  color: #79a7f8;
}

#tier-badge {
  background: rgba(109,211,255,0.07);
  color: #ffe700;
  font-weight: bold;
  padding: 0.4em 1.2em;
  border-radius: 20px;
  display: inline-block;
  margin: 0 auto 1rem;
  text-align: center;
}

#challenge-text {
  background: rgba(17,20,44,0.1);
  border-radius: 10px;
  padding: 0.7em;
  font-family: monospace;
  font-size: 1.15rem;
  user-select: none;
  box-shadow: 0 0 4px #5ea7d040;
  min-height: 3em;
  margin-bottom: 0.7em;
  line-height: 1.4;
  white-space: pre-wrap;
}

/* The typing input */
#typing-input {
  width: 100%;
  font-size: 1.1rem;
  padding: 0.8em;
  border-radius: 12px;
  border: 2px solid #343868;
  background: rgba(255,255,255,0.95);
  color: #222c5e;
  font-weight: 520;
  resize: none;
  outline: none;
  transition: border-color 0.3s ease;
  min-height: 6em;
}
#typing-input:focus {
  border-color: #3ab4ff;
  box-shadow: 0 0 18px #5cf6ff60;
}
#typing-input[disabled] {
  background: #eee;
  color: #999;
  cursor: not-allowed;
}

/* Stats Display */
#stats {
  display: flex;
  justify-content: space-around;
  margin-top: 1rem;
  color: #86dcec;
  font-weight: 600;
  user-select: none;
}

/* Timer Line visual */
#timer-line {
  height: 6px;
  background: #4adaaa;
  width: 100%;
  border-radius: 6px;
  margin-top: 1rem;
  transition: width 1s linear;
}

/* Next Button */
#next-btn {
  margin: 1.5rem auto 0;
  display: block;
  background: #4adaaa;
  color: #110e2e;
  font-weight: bold;
  border: none;
  border-radius: 1.2em;
  padding: 0.7em 2.5em;
  font-size: 1rem;
  box-shadow: 0 0 14px #75ffd3a5;
  cursor: pointer;
  transition: 0.2s ease;
}
#next-btn:hover {
  background: #10f0e0;
  color: #18166a;
}

/* User Stats section */
#user-stats {
  margin: 2rem auto 1rem;
  text-align: center;
  background: rgba(42,55,110,0.13);
  padding: 1rem;
  border-radius: 1rem;
  font-size: 1rem;
  color: #a9f5df;
  max-width: 680px;
}

/* Popup */
#popup-container {
  display: none;
  position: fixed;
  top: 0; left: 0;
  width: 100vw; height: 100vh;
  background: rgba(17, 27, 60, 0.8);
  backdrop-filter: blur(3px);
  justify-content: center;
  align-items: center;
  z-index: 999;
}
#popup-container:not(.popup-hide) {
  display: flex;
}
#popup {
  background: #1c2346fa;
  padding: 2rem;
  border-radius: 1rem;
  color: white;
  text-align: center;
  box-shadow: 0 0 40px #529dff6d;
  width: 90%;
  max-width: 420px;
}
#popup h3 {
  color: #ffd13a;
  margin-bottom: 0.7em;
}
#popup-stats p {
  font-size: 1rem;
  margin: 0.5em 0;
}
#close-popup {
  background: #ffd43b;
  border: none;
  padding: 0.6em 2em;
  border-radius: 1em;
  font-weight: bold;
  cursor: pointer;
  transition: 0.2s;
  margin-top: 1rem;
  width: 100%;
}
#close-popup:hover {
  background: #2ddca7;
  color: #183939;
}

/* Responsive */
@media (max-width: 768px) {
  .controls {
    flex-direction: column;
    align-items: flex-start;
    gap: 0.8rem;
    padding: 0 1rem;
  }
  #typing-game {
    padding: 1.5rem 1rem;
  }
  header h1 {
    font-size: 2rem;
  }
  .tab-btn {
    font-size: 0.9rem;
    padding: 0.5em 1em;
  }
}

/* Starry background style if needed */
.stars-bg {
  background: url('https://cdn.pixabay.com/photo/2017/06/20/19/22/stellar-2421109_1280.jpg') repeat top center;
  opacity: 0.23;
}
