* {
  box-sizing: border-box;
}

body {
  background: #F3F3F3;
  font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;
  margin: 0;
  min-height: 100vh;
  color: #302F2C;
}

.header {
  background: #1D85E9;
  padding: 1rem 0;
  box-shadow: 0 2px 12px rgba(29, 133, 233, 0.25);
  position: sticky;
  top: 0;
  z-index: 100;
  color: #F3F3F3;
}

.header-content {
  max-width: 1200px;
  margin: 0 auto;
  padding: 0 2rem;
  display: flex;
  justify-content: space-between;
  align-items: center;
}

.logo {
  font-size: 1.5rem;
  font-weight: bold;
  color: #F3F3F3;
}

.controls {
  display: flex;
  gap: 1rem;
  align-items: center;
}

.control-group {
  display: flex;
  flex-direction: column;
  gap: 0.25rem;
}

.control-group label {
  font-size: 0.8rem;
  color: rgba(243, 243, 243, 0.85);
  font-weight: 500;
}

select,
input {
  padding: 0.5rem;
  border: 2px solid rgba(255, 255, 255, 0.4);
  border-radius: 8px;
  font-size: 0.9rem;
  background: rgba(255, 255, 255, 0.2);
  color: #F3F3F3;
  transition: border-color 0.3s, background 0.3s;
}

.hidden-input {
  position: fixed;
  top: 0;
  left: 0;
  width: 1px;
  height: 1px;
  opacity: 0;
  pointer-events: none;
  padding: 0;
  border: 0;
  background: transparent;
  color: transparent;
  caret-color: transparent;
  font-size: 16px;
}

select option {
  color: #302F2C;
  background: #F3F3F3;
}

select:focus,
input:focus {
  outline: none;
  border-color: #F3F3F3;
  background: rgba(255, 255, 255, 0.35);
}

.center {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  min-height: calc(100vh - 80px);
  padding: 2rem 0;
}

.typer-container {
  background: rgba(255, 255, 255, 0.95);
  backdrop-filter: blur(12px);
  border-radius: 24px;
  box-shadow: 0 20px 60px rgba(0, 0, 0, 0.1);
  padding: 3rem;
  max-width: 900px;
  width: 96%;
  border: 1px solid rgba(255, 255, 255, 0.2);
}

.typer {
  font-size: 1.8rem;
  line-height: 2.2rem;
  margin-bottom: 2rem;
  height: calc(4 * 2.2rem);
  padding: 1.5rem;
  background: #f8fafc;
  border-radius: 16px;
  border: 2px solid #e2e8f0;
  overflow: hidden;
  white-space: normal;
  word-break: normal;
  overflow-wrap: normal;
  position: relative;
}

.typer span {
  transition: all 0.15s ease;
  white-space: pre-wrap;
  border-radius: 4px;
  padding: 2px 1px;
}

.typer-content {
  position: relative;
  min-height: calc(4 * 2.2rem);
  width: 100%;
  padding-right: 0.5rem;
  transform: translateY(0);
  transition: transform 0.2s ease;
}

.typed {
  color: #10b981;
  background: #d1fae5;
  font-weight: 500;
}

.current {
  background: #dbeafe;
  color: #1d4ed8;
  border-left: 4px solid #3b82f6;
  padding-left: 4px;
  animation: blink 1s infinite;
}

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

.flash-error {
  background: #fee2e2 !important;
  color: #dc2626 !important;
}

.error {
  background: #fee2e2;
  color: #dc2626;
  font-weight: 500;
}

.notyet {
  color: #64748b;
  opacity: 0.6;
}

.timer {
  font-size: 2rem;
  margin-bottom: 2rem;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 1rem;
  font-weight: bold;
  color: #1e293b;
}

.timer-icon {
  font-size: 1.5rem;
}

.progress-bar {
  width: 100%;
  height: 8px;
  background: #e2e8f0;
  border-radius: 4px;
  margin: 1rem 0;
  overflow: hidden;
}

.progress-fill {
  height: 100%;
  background: #1D85E0;
  border-radius: 4px;
  transition: width 0.3s ease;
  width: 0%;
}

.instructions {
  background: linear-gradient(135deg, rgba(29, 133, 233, 0.12) 0%, rgba(48, 47, 44, 0.12) 100%);
  border: 2px solid rgba(29, 133, 233, 0.3);
  border-radius: 12px;
  padding: 1rem;
  margin: 1rem 0;
  text-align: center;
}

.instructions p {
  margin: 0;
  color: #1D85E9;
  font-size: 0.9rem;
  line-height: 1.4;
}

.stats {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
  gap: 1.5rem;
  margin: 2rem 0;
}

.statbox {
  border-radius: 16px;
  padding: 1.5rem;
  display: flex;
  flex-direction: column;
  align-items: center;
  box-shadow: 0 8px 32px rgba(0, 0, 0, 0.1);
  background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
  color: white;
  transition: transform 0.3s ease;
}

.statbox:hover {
  transform: translateY(-5px);
}

.statbox.wpm {
  background: linear-gradient(135deg, #4facfe 0%, #00f2fe 100%);
}

.statbox.accuracy {
  background: linear-gradient(135deg, #f093fb 0%, #f5576c 100%);
}

.statbox-title {
  font-size: 0.9rem;
  opacity: 0.9;
  margin-bottom: 0.5rem;
}

.statbox-value {
  font-size: 2.5rem;
  font-weight: bold;
  margin: 0.5rem 0;
}

.statbox-unit {
  font-size: 0.8rem;
  opacity: 0.8;
}

.certificate {
  text-align: center;
  margin: 2rem 0;
  padding: 2rem;
  border-radius: 16px;
  background: linear-gradient(135deg, #ffeaa7 0%, #fab1a0 100%);
  border: 3px solid #fdcb6e;
}

.certificate-icon {
  font-size: 4rem;
  margin-bottom: 1rem;
}

.certificate-title {
  font-size: 1.5rem;
  font-weight: bold;
  margin-bottom: 0.5rem;
  color: #2d3436;
}

.certificate-level {
  font-size: 1.2rem;
  color: #636e72;
}

.buttons {
  display: flex;
  gap: 1rem;
  justify-content: center;
  margin-top: 2rem;
  flex-wrap: wrap;
}

button {
  padding: 1rem 2rem;
  border-radius: 12px;
  font-size: 1.1rem;
  font-family: inherit;
  font-weight: 600;
  border: none;
  cursor: pointer;
  transition: all 0.3s ease;
  box-shadow: 0 4px 15px rgba(0, 0, 0, 0.1);
}

.btn-primary {
  background: #1D85E9;
  color: #F3F3F3;
  box-shadow: 0 8px 18px rgba(29, 133, 233, 0.25);
}

.btn-primary:hover {
  transform: translateY(-2px);
  box-shadow: 0 10px 24px rgba(29, 133, 233, 0.35);
  background: #166FC0;
}

.btn-secondary {
  background: #FFFFFF;
  color: #1D85E9;
  border: 2px solid rgba(29, 133, 233, 0.2);
}

.btn-secondary:hover {
  background: rgba(29, 133, 233, 0.08);
}

.share-status {
  font-size: 0.85rem;
  color: #1D85E9;
  text-align: center;
  margin-top: 0.75rem;
}

.hidden {
  display: none !important;
}

@media (max-width: 768px) {
  .header-content {
    flex-direction: column;
    gap: 1rem;
    padding: 0 1rem;
  }

  .controls {
    flex-wrap: wrap;
    justify-content: center;
  }

  .typer {
    font-size: 1.2rem;
    line-height: 1.8rem;
    padding: 1rem;
  }

  .typer-container {
    padding: 1.5rem;
    margin: 1rem;
  }

  .stats {
    grid-template-columns: 1fr;
    gap: 1rem;
  }

  .statbox-value {
    font-size: 2rem;
  }

  button {
    width: 100%;
    max-width: 320px;
  }
}
