:root {
  --theme-transition-duration: 0.3s;
  --background-color: rgb(18 18 18);
  --background-color-secondary: rgb(12, 12, 12);
  --primary-color: rgb(255, 255, 255);
  
  /* Additional game-specific colors */
  --correct-color: #4ade80; /* Soft green */
  --incorrect-color: #f87171; /* Soft red */
  --caret-color: #fbbf24; /* Amber caret */
  --text-dimmed: rgba(255, 255, 255, 0.4);
}

[data-theme="light"] {
  --background-color: rgb(230, 230, 230);
  --background-color-secondary: rgb(216, 216, 216);
  --primary-color: rgb(10, 10, 10);
  
  --correct-color: #16a34a;
  --incorrect-color: #dc2626;
  --caret-color: #d97706;
  --text-dimmed: rgba(10, 10, 10, 0.4);
}

html, body {
  height: 100%;
  margin: 0;
  font-family: 'Lato', sans-serif;
  overflow: hidden;
}

body {
  background-color: var(--background-color);
  color: var(--primary-color);
  transition: background-color var(--theme-transition-duration), color var(--theme-transition-duration);
  display: flex;
  justify-content: center;
  align-items: center;
}

.content {
  width: 100%;
  max-width: 900px;
  height: 100%;
  display: flex;
  flex-direction: column;
  padding: 2rem;
  box-sizing: border-box;
}

header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 3rem;
  margin-top: 2rem;
}

h1 {
  font-size: 2.5em;
  font-weight: 300;
  margin: 0;
}

.header-right {
  display: flex;
  align-items: center;
  gap: 20px;
}

.back-btn {
  color: var(--primary-color);
  opacity: 0.7;
  transition: opacity var(--theme-transition-duration);
  font-weight: 400;
  font-size: 1.1em;
  text-decoration: none;
  position: relative;
  display: inline-block;
}

.back-btn::after {
  content: "";
  position: absolute;
  width: 0%;
  height: 3px;
  bottom: -7px;
  left: 0;
  background-color: var(--primary-color);
  transform-origin: bottom left;
  transition: width 0.25s ease-out;
}

.back-btn:hover {
  opacity: 1;
}

.back-btn:hover::after {
  width: 100%;
}

.dark-toggle {
  width: 37px;
  height: 37px;
  cursor: pointer;
  opacity: 0.7;
  transition: opacity 0.2s;
  user-select: none;
}

.dark-toggle svg {
  width: 100%;
  height: 100%;
  fill: var(--primary-color);
  transition: fill var(--theme-transition-duration);
}

.dark-toggle:hover {
  opacity: 1;
}

.game-container {
  display: flex;
  flex-direction: column;
  flex-grow: 1;
  gap: 2rem;
}

.stats-panel {
  display: flex;
  justify-content: space-between;
  background-color: var(--background-color-secondary);
  padding: 1.5rem 3rem;
  border-radius: 12px;
  transition: background-color var(--theme-transition-duration);
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.2);
}

.stat {
  display: flex;
  flex-direction: column;
  align-items: center;
}

.stat-label {
  font-size: 0.9em;
  text-transform: uppercase;
  letter-spacing: 1.5px;
  opacity: 0.7;
  margin-bottom: 0.5rem;
}

.stat-value {
  font-size: 2em;
  font-weight: 700;
}

.typing-area {
  font-family: 'Roboto Mono', monospace;
  font-size: 2em;
  line-height: 1.8;
  color: var(--text-dimmed);
  position: relative;
  height: 250px;
  overflow: hidden;
  user-select: none;
  cursor: text;
  display: flex;
  flex-wrap: wrap;
  align-content: flex-start;
  scroll-behavior: smooth;
  mask-image: linear-gradient(to bottom, black 50%, transparent 100%);
  -webkit-mask-image: linear-gradient(to bottom, black 50%, transparent 100%);
}

.word {
  margin-right: 0.6em;
  display: inline-block;
  margin-bottom: 0.2em;
}

.letter {
  transition: color 0.1s ease;
}

.letter.correct {
  color: var(--correct-color);
}

.letter.incorrect {
  color: var(--incorrect-color);
  text-decoration: underline;
  text-decoration-color: var(--incorrect-color);
}

.letter.active {
  color: var(--primary-color);
  animation: blink 1s infinite;
  border-bottom: 3px solid var(--caret-color);
}

@keyframes blink {
  0%, 100% { border-bottom-color: var(--caret-color); }
  50% { border-bottom-color: transparent; }
}

.hidden-input {
  position: absolute;
  opacity: 0;
  pointer-events: none;
  top: 0;
  left: 0;
  width: 10px;
  height: 10px;
  z-index: -1;
}

.restart-btn {
  align-self: center;
  background-color: transparent;
  color: var(--primary-color);
  border: 1px solid var(--text-dimmed);
  padding: 0.8rem 2.5rem;
  border-radius: 30px;
  font-family: 'Lato', sans-serif;
  font-size: 1.2em;
  cursor: pointer;
  transition: all 0.2s ease;
  margin-top: 1rem;
  opacity: 0;
  visibility: hidden;
  transform: translateY(10px);
}

.restart-btn.show {
  opacity: 1;
  visibility: visible;
  transform: translateY(0);
}

.restart-btn:hover {
  background-color: var(--primary-color);
  color: var(--background-color);
  border-color: var(--primary-color);
}
