* {
  margin: 0;
  padding: 0;
  box-sizing: border-box;
}

:root {
  --primary-bg: #ffffff;
  --primary-text: #000000;
  --border-color: #000000;
  --accent-bg: #f0f0f0;
  --secondary-bg: #d0d0d0;
  --success-color: #00cc00;
  --error-color: #ff3333;
  --warning-color: #ff9900;
  --focus-color: #00cc00;
  --shadow: 0 4px 12px rgba(0, 0, 0, 0.15);
}

body {
  font-family: "Courier New", monospace;
  background: var(--primary-bg);
  color: var(--primary-text);
  line-height: 1.4;
  overflow-x: hidden;
  min-height: 100vh;
  display: flex;
  flex-direction: column;
}
.app-container {
  max-width: 1200px;
  width: 100%;
  margin: 0 auto;
  padding: 15px;
  height: 100vh;
  display: flex;
  flex-direction: column;
  gap: 12px;
  position: relative;
  overflow: hidden;
}

.header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  background: var(--accent-bg);
  border: 3px solid var(--border-color);
  padding: 15px 20px;
  border-radius: 0;
  height: 70px;
  flex-shrink: 0;
  width: 100%;
  overflow: hidden;
}

.logo {
  font-size: clamp(1.4rem, 3vw, 1.8rem);
  font-weight: bold;
  letter-spacing: -0.5px;
  white-space: nowrap;
}

.best-scores-mini {
  background: var(--border-color);
  color: var(--primary-bg);
  padding: 8px 12px;
  font-size: clamp(0.8rem, 1.8vw, 0.9rem);
  font-weight: bold;
  text-transform: uppercase;
  cursor: pointer;
  transition: all 0.15s ease;
  white-space: nowrap;
  flex-shrink: 0;
}

.best-scores-mini:hover {
  background: var(--secondary-bg);
  color: var(--border-color);
}

.control-panel {
  display: grid;
  grid-template-columns: 1fr 1fr 1fr auto;
  gap: 15px;
  background: var(--accent-bg);
  border: 3px solid var(--border-color);
  padding: 15px 20px;
  align-items: center;
  height: 90px;
  flex-shrink: 0;
  width: 100%;
  overflow: hidden;
}

.dropdown-group {
  display: flex;
  flex-direction: column;
  gap: 6px;
  min-height: 60px;
  width: 100%;
  overflow: hidden;
}

.dropdown-label {
  font-weight: bold;
  font-size: clamp(0.8rem, 1.8vw, 0.9rem);
  text-transform: uppercase;
  height: 20px;
  line-height: 20px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.dropdown {
  background: var(--primary-bg);
  border: 3px solid var(--border-color);
  padding: 8px 12px;
  font-family: inherit;
  font-weight: bold;
  font-size: clamp(0.9rem, 2vw, 1rem);
  cursor: pointer;
  width: 100%;
  text-transform: uppercase;
  height: 42px;
  flex-shrink: 0;
  overflow: hidden;
}

.dropdown:focus {
  outline: none;
  border-color: var(--focus-color);
}

.control-buttons {
  display: flex;
  gap: 8px;
  align-items: center;
  justify-self: end;
  flex-shrink: 0;
}

.control-btn {
  background: var(--primary-bg);
  border: 3px solid var(--border-color);
  padding: 10px 15px;
  font-family: inherit;
  font-size: clamp(0.8rem, 1.8vw, 0.9rem);
  cursor: pointer;
  font-weight: bold;
  transition: all 0.15s ease;
  text-transform: uppercase;
  height: 42px;
  white-space: nowrap;
  flex-shrink: 0;
}

.control-btn:hover {
  background: var(--secondary-bg);
}

.control-btn.restart {
  background: var(--warning-color);
  color: var(--primary-bg);
}

.control-btn.restart:hover {
  background: #cc7700;
}

.stats-row {
  display: grid;
  grid-template-columns: repeat(5, 1fr);
  gap: 15px;
  background: var(--accent-bg);
  border: 3px solid var(--border-color);
  padding: 15px 20px;
  height: 80px;
  flex-shrink: 0;
  width: 100%;
  overflow: hidden;
}

.stat-box {
  text-align: center;
  padding: 8px;
  display: flex;
  flex-direction: column;
  justify-content: center;
  min-height: 60px;
  overflow: hidden;
}

.stat-value {
  font-size: clamp(1.2rem, 3vw, 1.8rem);
  font-weight: bold;
  display: block;
  margin-bottom: 4px;
  line-height: 1;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.stat-label {
  font-size: clamp(0.8rem, 1.8vw, 0.9rem);
  text-transform: uppercase;
  font-weight: bold;
  line-height: 1;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.game-area {
  flex: 1;
  background: var(--primary-bg);
  border: 3px solid var(--border-color);
  padding: 30px;
  display: flex;
  flex-direction: column;
  justify-content: center;
  position: relative;
  min-height: 300px;
  max-height: 450px;
  width: 100%;
  overflow: hidden;
}

.difficulty-badge {
  position: absolute;
  top: 15px;
  right: 15px;
  background: var(--border-color);
  color: var(--primary-bg);
  padding: 6px 12px;
  font-size: clamp(0.8rem, 1.8vw, 0.9rem);
  font-weight: bold;
  text-transform: uppercase;
  z-index: 2;
  white-space: nowrap;
}

.content-display {
  margin-bottom: 30px;
  height: 120px;
  width: 100%;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-wrap: wrap;
  line-height: 1.4;
  overflow-y: auto;
  overflow-x: hidden;
  position: relative;
  padding: 15px;
  border-left: 6px solid var(--secondary-bg);
  background: rgba(240, 240, 240, 0.3);
  word-wrap: break-word;
  word-break: break-word;
  hyphens: auto;
  min-width: 0;
  max-width: 100%;
  box-sizing: border-box;
}

.content-display.word-mode {
  text-align: center;
  justify-content: center;
  align-items: center;
  font-weight: bold;
  font-size: clamp(2.5rem, 6vw, 4rem);
}

.content-display.sentence-mode {
  text-align: left;
  justify-content: flex-start;
  align-items: flex-start;
  font-weight: normal;
  font-size: clamp(1.1rem, 2.5vw, 1.5rem); /* Smaller text for sentences */
}

.char {
  position: relative;
  transition: all 0.2s ease;
  margin: 0 1px;
  display: inline-block;
  max-width: 100%;
  word-break: break-all;
}

.char.correct {
  background: var(--success-color);
  color: var(--primary-bg);
  border-radius: 3px;
  animation: flash-correct 0.3s ease;
}

.char.incorrect {
  background: var(--error-color);
  color: var(--primary-bg);
  border-radius: 3px;
  animation: flash-incorrect 0.3s ease;
}

.char.current {
  background: var(--border-color);
  color: var(--primary-bg);
  animation: blink 1s infinite;
  border-radius: 3px;
  box-shadow: 0 0 8px rgba(0, 0, 0, 0.5);
}

@keyframes flash-correct {
  0%,
  100% {
    transform: scale(1);
  }
  50% {
    transform: scale(1.1);
  }
}

@keyframes flash-incorrect {
  0%,
  100% {
    transform: scale(1);
  }
  50% {
    transform: scale(1.1);
    background: #ff6666;
  }
}

@keyframes blink {
  0%,
  50% {
    opacity: 1;
  }
  51%,
  100% {
    opacity: 0.5;
  }
}

.typing-input {
  font-family: inherit;
  font-size: clamp(1.2rem, 3vw, 1.6rem);
  padding: 15px 20px;
  border: 3px solid var(--border-color);
  background: var(--primary-bg);
  width: 100%;
  text-align: center;
  outline: none;
  transition: all 0.2s ease;
  height: 60px;
  flex-shrink: 0;
  overflow: hidden;
  white-space: nowrap;
  text-overflow: ellipsis;
}

.typing-input:focus {
  border-color: var(--focus-color);
  box-shadow: 0 0 10px rgba(0, 204, 0, 0.3);
}

.progress-section {
  background: var(--accent-bg);
  border: 3px solid var(--border-color);
  padding: 15px 20px;
  display: flex;
  justify-content: space-between;
  align-items: center;
  font-size: clamp(0.9rem, 2vw, 1rem);
  font-weight: bold;
  height: 60px;
  flex-shrink: 0;
  width: 100%;
  overflow: hidden;
}

.progress-bar {
  flex: 1;
  height: 12px;
  background: var(--secondary-bg);
  border: 2px solid var(--border-color);
  margin: 0 20px;
  position: relative;
  min-width: 0;
}

.progress-fill {
  height: 100%;
  background: linear-gradient(90deg, var(--success-color), #00ff00);
  width: 0%;
  transition: width 0.4s ease;
}

.modal-overlay {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  background: rgba(0, 0, 0, 0.85);
  display: none;
  align-items: center;
  justify-content: center;
  z-index: 1000;
  padding: 20px;
}

.modal {
  background: var(--primary-bg);
  border: 3px solid var(--border-color);
  padding: 24px;
  max-width: 500px;
  width: 100%;
  text-align: center;
  max-height: 80vh;
  overflow-y: auto;
}

.modal h2 {
  margin-bottom: 16px;
  font-size: clamp(1.3rem, 3vw, 1.6rem);
}

.modal-stats {
  margin: 16px 0;
  text-align: left;
}

.modal-stat {
  display: flex;
  justify-content: space-between;
  margin: 8px 0;
  padding: 6px 0;
  border-bottom: 1px solid var(--secondary-bg);
  font-size: clamp(0.8rem, 2vw, 0.9rem);
}

.tips-section {
  background: var(--accent-bg);
  border: 2px solid var(--border-color);
  padding: 12px;
  margin: 16px 0;
  text-align: left;
  font-size: clamp(0.8rem, 2vw, 0.9rem);
}

.score-list {
  text-align: left;
  margin: 16px 0;
}

.score-item {
  display: flex;
  justify-content: space-between;
  padding: 8px 0;
  border-bottom: 1px solid var(--secondary-bg);
  font-size: clamp(0.8rem, 2vw, 0.9rem);
}

.score-item:last-child {
  border-bottom: none;
}

@media (max-width: 1024px) {
  .app-container {
    max-width: 100%;
    padding: 12px;
  }
}

@media (max-width: 768px) {
  .app-container {
    padding: 10px;
    gap: 8px;
  }

  .header {
    flex-direction: column;
    gap: 8px;
    padding: 12px;
    height: auto;
    min-height: 80px;
  }

  .control-panel {
    grid-template-columns: 1fr 1fr;
    gap: 12px;
    padding: 15px;
    height: auto;
    min-height: 140px;
  }

  .control-buttons {
    justify-self: center;
    justify-content: center;
    grid-column: 1 / -1;
  }

  .stats-row {
    grid-template-columns: repeat(3, 1fr);
    gap: 10px;
    padding: 12px;
    height: auto;
    min-height: 100px;
  }

  .game-area {
    padding: 20px;
    min-height: 280px;
    max-height: 400px;
  }

  .content-display {
    height: 100px;
    padding: 12px;
  }

  .content-display.word-mode {
    font-size: clamp(2rem, 8vw, 3rem);
  }

  .content-display.sentence-mode {
    font-size: clamp(0.95rem, 3vw, 1.3rem);
  }

  .progress-section {
    flex-direction: column;
    gap: 10px;
    text-align: center;
    height: auto;
    min-height: 80px;
  }

  .progress-bar {
    margin: 0;
    width: 100%;
  }
}

@media (max-width: 480px) {
  .app-container {
    padding: 8px;
    gap: 6px;
  }

  .header {
    padding: 10px;
    min-height: 70px;
  }

  .control-panel {
    grid-template-columns: 1fr;
    padding: 12px;
    min-height: 140px;
  }

  .control-buttons {
    grid-column: 1;
  }

  .stats-row {
    grid-template-columns: repeat(2, 1fr);
    text-align: center;
    min-height: 120px;
  }

  .game-area {
    padding: 15px;
    min-height: 250px;
    max-height: 350px;
  }

  .content-display {
    height: 80px;
    padding: 10px;
  }

  .content-display.word-mode {
    font-size: clamp(1.5rem, 10vw, 2.5rem);
  }

  .content-display.sentence-mode {
    font-size: clamp(0.85rem, 4vw, 1.1rem);
  }

  .dropdown-group {
    text-align: center;
    min-height: 50px;
  }

  .dropdown-label {
    font-size: 0.8rem;
  }

  .dropdown {
    font-size: 0.9rem;
    height: 38px;
  }

  .control-btn {
    font-size: 0.8rem;
    padding: 8px 12px;
    height: 38px;
  }
}

@media (max-width: 360px) {
  .stats-row {
    grid-template-columns: 1fr;
    min-height: 200px;
  }

  .content-display {
    height: 70px;
    padding: 8px;
  }

  .content-display.word-mode {
    font-size: clamp(1.2rem, 12vw, 2rem);
  }

  .content-display.sentence-mode {
    font-size: clamp(0.8rem, 5vw, 1rem);
  }
}

/* Utility Classes */
.hidden {
  display: none !important;
}
.loading {
  opacity: 0.6;
  font-style: italic;
}
.streak-bonus {
  animation: streak-glow 0.6s ease;
}
.achievement {
  animation: achievement-pop 0.8s ease;
}

@keyframes streak-glow {
  0%,
  100% {
    transform: scale(1);
  }
  50% {
    transform: scale(1.05);
    background: var(--warning-color);
  }
}

@keyframes achievement-pop {
  0% {
    transform: scale(1) rotate(0deg);
  }
  25% {
    transform: scale(1.1) rotate(2deg);
  }
  75% {
    transform: scale(1.1) rotate(-2deg);
  }
  100% {
    transform: scale(1) rotate(0deg);
  }
}

* {
  max-width: 100%;
  box-sizing: border-box;
}

.content-display span,
.content-display * {
  word-wrap: break-word !important;
  word-break: break-word !important;
  hyphens: auto !important;
  max-width: 100% !important;
}
/* Universal Home Button Styling */
.home-button {
  position: fixed;
  top: 20px;
  left: 20px;
  background: #ffffff;
  color: #000000;
  text-decoration: none;
  padding: 12px 18px;
  border: 4px solid #000000;
  box-shadow: 6px 6px 0 #808080;
  font-family: "Arial Black", Arial, sans-serif;
  font-size: 0.9rem;
  font-weight: bold;
  text-transform: uppercase;
  letter-spacing: 0.02em;
  z-index: 1000;
  transition: all 0.3s cubic-bezier(0.25, 0.46, 0.45, 0.94);
  cursor: pointer;
  user-select: none;
}

.home-button:hover {
  background: #000000;
  color: #ffffff;
  transform: translate(-2px, -2px);
  box-shadow: 8px 8px 0 #808080;
}

.home-button:active {
  transform: translate(2px, 2px);
  box-shadow: 2px 2px 0 #808080;
}
