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

body {
  font-family: 'Segoe UI', system-ui, sans-serif;
  background: #0d1117;
  color: #e6edf3;
  min-height: 100vh;
  padding: 2rem 1rem;
}

.page {
  max-width: 720px;
  margin: 0 auto;
}

nav {
  margin-bottom: 2.5rem;
}

.nav-back {
  font-size: 13px;
  color: #8b949e;
  text-decoration: none;
  font-family: monospace;
}

.nav-back:hover {
  color: #e6edf3;
}

.header {
  margin-bottom: 2rem;
}

.header h1 {
  font-size: 26px;
  font-weight: 500;
  color: #e6edf3;
}

.header p {
  font-size: 13px;
  color: #484f58;
  font-family: monospace;
  margin-top: 4px;
}

.controls {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
  margin-bottom: 1.5rem;
}

.pill {
  font-size: 12px;
  padding: 5px 16px;
  border: 0.5px solid rgba(255,255,255,0.15);
  border-radius: 999px;
  background: transparent;
  color: #8b949e;
  cursor: pointer;
  font-family: monospace;
  transition: all .15s;
}

.pill.active {
  background: #21262d;
  color: #e6edf3;
}

.sep {
  width: 1px;
  height: 18px;
  background: rgba(255,255,255,0.1);
}

.stats {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 10px;
  margin-bottom: 1.25rem;
}

.stat {
  background: #161b22;
  border-radius: 8px;
  padding: 12px 14px;
}

.stat-label {
  font-size: 11px;
  color: #484f58;
  font-family: monospace;
  margin-bottom: 5px;
}

.stat-val {
  font-size: 20px;
  font-weight: 500;
  color: #e6edf3;
}

.stat-unit {
  font-size: 11px;
  color: #8b949e;
  margin-left: 2px;
}

.timerbar-row {
  display: flex;
  align-items: center;
  gap: 10px;
  margin-bottom: 1rem;
}

.timerbar-label {
  font-size: 12px;
  font-family: monospace;
  color: #484f58;
  min-width: 28px;
  text-align: right;
}

.bar-bg {
  flex: 1;
  height: 3px;
  background: #21262d;
  border-radius: 999px;
  overflow: hidden;
}

.bar-fill {
  height: 100%;
  background: #e6edf3;
  opacity: .25;
  border-radius: 999px;
  transition: width .9s linear;
  width: 0%;
}

.text-box {
  background: #0d1117;
  border: 0.5px solid rgba(255,255,255,0.1);
  border-radius: 12px;
  padding: 1.25rem 1.5rem;
  font-size: 16px;
  font-family: monospace;
  letter-spacing: .03em;
  line-height: 2.2;
  min-height: 96px;
  max-height: 140px;
  overflow: hidden;
  margin-bottom: 1rem;
  word-break: break-all;
}

.w {
  color: #484f58;
  margin-right: 6px;
  display: inline-block;
}

.w.ok {
  color: #3fb950;
}

.w.ko {
  color: #f85149;
  text-decoration: underline wavy;
}

.w.cur {
  color: #e6edf3;
  border-bottom: 2px solid #e6edf3;
}

.input-row {
  display: flex;
  gap: 10px;
  margin-bottom: .75rem;
}

#ti {
  flex: 1;
  font-family: monospace;
  font-size: 15px;
  padding: 10px 14px;
  border: 0.5px solid rgba(255,255,255,0.15);
  border-radius: 8px;
  background: #0d1117;
  color: #e6edf3;
  outline: none;
  transition: border-color .15s;
}

#ti:focus {
  border-color: rgba(255,255,255,0.3);
}

#ti:disabled {
  opacity: .4;
  cursor: not-allowed;
}

.btn {
  font-size: 13px;
  padding: 10px 18px;
  border: 0.5px solid rgba(255,255,255,0.15);
  border-radius: 8px;
  background: transparent;
  color: #8b949e;
  cursor: pointer;
  font-family: inherit;
  display: inline-flex;
  align-items: center;
  gap: 6px;
  white-space: nowrap;
  transition: background .15s;
}

.btn:hover {
  background: #161b22;
}

.btn:active {
  transform: scale(.98);
}

.wprog-bg {
  height: 2px;
  background: #21262d;
  border-radius: 999px;
  margin-bottom: 1.5rem;
  overflow: hidden;
}

.wprog-fill {
  height: 100%;
  background: #e6edf3;
  opacity: .15;
  border-radius: 999px;
  transition: width .3s;
}

.hint {
  text-align: center;
  font-size: 11px;
  color: #484f58;
  font-family: monospace;
  transition: opacity .3s;
}

.result {
  background: #0d1117;
  border: 0.5px solid rgba(255,255,255,0.1);
  border-radius: 12px;
  padding: 2.5rem 1.5rem;
  text-align: center;
  display: none;
}

.r-wpm {
  font-size: 56px;
  font-weight: 500;
  color: #e6edf3;
  line-height: 1;
}

.r-sub {
  font-size: 12px;
  color: #484f58;
  font-family: monospace;
  margin-top: 8px;
  margin-bottom: .75rem;
}

.best-row {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  font-size: 12px;
  color: #484f58;
  font-family: monospace;
  margin-bottom: 1.5rem;
}

.best-val {
  color: #8b949e;
}

.r-grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 10px;
  margin-bottom: 1.75rem;
}

.r-stat {
  background: #161b22;
  border-radius: 8px;
  padding: 12px;
}

.r-stat-label {
  font-size: 11px;
  color: #484f58;
  font-family: monospace;
  margin-bottom: 4px;
}

.r-stat-val {
  font-size: 20px;
  font-weight: 500;
  color: #e6edf3;
}

@media (max-width: 520px) {
  .stats {
    grid-template-columns: repeat(2, 1fr);
  }
}


#loading-screen {
  position: fixed;
  inset: 0;
  background: #222f3e;
  display: flex;
  justify-content: center;
  align-items: center;
  z-index: 9999;
  transition: all 0.6s ease-in-out;
}

.loading-content {
  text-align: center;
  transform: scale(1);
  opacity: 1;
  transition: all 0.6s ease-in-out;
}

.loading-text {
  font-size: 2rem;
  color: #82ccdd;
  margin-bottom: 20px;
  animation: fadeIn 1s forwards;
  font-family: 'Montserrat', sans-serif;
  font-weight: 600px;
}

.dot.flash {
  animation: blink 1s infinite;
}

.dot.flash:nth-of-type(2) { animation-delay: 0.2s; }
.dot.flash:nth-of-type(3) { animation-delay: 0.6s; }

.spinner {
  width: 50px;
  height: 50px;
  border: 6px solid #333;
  border-top: 6px solid #82ccdd;
  border-radius: 50%;
  margin: 0 auto;
  animation: spin 1s linear infinite;
}

@keyframes fadeIn {
  to { opacity: 1; }
}

@keyframes blink {
  0%, 100% { opacity: 1; }
  50% { opacity: 0; }
}

@keyframes spin {
  0% { transform: rotate(0deg); }
  100% { transform: rotate(360deg); }
}

#main-content {
  display: none;
  padding: 2rem;
  background: white;
}
