/* Typing Speed Test - MVP styles */
:root {
  --color-correct: #22c55e;
  --color-incorrect: #ef4444;
  --color-bg: #f8fafc;
  --color-surface: #ffffff;
  --color-text: #1e293b;
  --color-text-muted: #64748b;
  --color-primary: #3b82f6;
  --color-primary-hover: #2563eb;
  --font-sans: system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
  --font-mono: ui-monospace, "Cascadia Code", "Source Code Pro", Menlo, monospace;
  --radius: 8px;
  --shadow: 0 1px 3px rgba(0, 0, 0, 0.08);
  --shadow-lg: 0 4px 12px rgba(0, 0, 0, 0.1);
}

*,
*::before,
*::after {
  box-sizing: border-box;
}

body {
  margin: 0;
  font-family: var(--font-sans);
  font-size: 16px;
  line-height: 1.5;
  color: var(--color-text);
  background: var(--color-bg);
  min-height: 100vh;
}

.header {
  padding: 1rem 1.5rem;
  background: var(--color-surface);
  box-shadow: var(--shadow);
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
}

.header h1 {
  margin: 0;
  font-size: 1.25rem;
  font-weight: 700;
}

.nav {
  display: flex;
  gap: 1rem;
}

.nav-link {
  color: var(--color-primary);
  text-decoration: none;
  font-weight: 500;
}

.nav-link:hover {
  text-decoration: underline;
}

.nav-icon {
  opacity: 0.85;
}

.main {
  max-width: 800px;
  margin: 0 auto;
  padding: 2rem 1.5rem;
}

.screen {
  animation: fadeIn 0.2s ease-out;
}

.screen.hidden {
  display: none !important;
}

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

/* Config / Landing */
.config-card {
  background: var(--color-surface);
  padding: 2rem;
  border-radius: var(--radius);
  box-shadow: var(--shadow-lg);
}

.config-heading {
  margin-top: 0;
  margin-bottom: 0.25rem;
  font-size: 1.75rem;
  font-weight: 800;
  display: flex;
  align-items: center;
  gap: 0.5rem;
}

.config-heading-icon {
  font-size: 1.5rem;
}

.config-subtitle {
  margin: 0 0 1.5rem;
  font-size: 1rem;
  color: var(--color-text-muted);
}

.duration-label {
  display: block;
  margin-bottom: 0.5rem;
  font-weight: 600;
  color: var(--color-text);
}

.duration-buttons {
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem;
  margin-bottom: 0.25rem;
}

.duration-btn {
  padding: 0.5rem 1rem;
  font-size: 0.95rem;
  font-weight: 600;
  border: 2px solid #cbd5e1;
  border-radius: var(--radius);
  background: var(--color-surface);
  color: var(--color-text);
  cursor: pointer;
  transition: border-color 0.15s ease, background 0.15s ease;
}

.duration-btn:hover {
  border-color: var(--color-primary);
  background: rgba(59, 130, 246, 0.06);
}

.duration-btn.selected {
  border-color: var(--color-primary);
  background: rgba(59, 130, 246, 0.12);
  color: var(--color-primary);
}

.duration-selected {
  margin: 0 0 1.25rem;
  font-size: 0.875rem;
  color: var(--color-text-muted);
}

.btn-start-cta {
  display: inline-flex;
  align-items: center;
  gap: 0.5rem;
  padding: 0.875rem 1.75rem;
  font-size: 1.125rem;
  margin-bottom: 0.5rem;
}

.btn-enter-icon {
  font-size: 1.25rem;
  opacity: 0.9;
}

.hint-pill {
  margin-top: 0;
  margin-bottom: 1.5rem;
}

.pill {
  display: inline-block;
  padding: 0.35rem 0.75rem;
  font-size: 0.8rem;
  font-weight: 500;
  color: var(--color-text-muted);
  background: var(--color-bg);
  border: 1px solid #e2e8f0;
  border-radius: 999px;
}

.empty-state {
  margin-top: 2rem;
  padding-top: 1.5rem;
  border-top: 1px solid #e2e8f0;
  text-align: center;
}

.empty-state-hero {
  font-size: 3rem;
  margin-bottom: 0.75rem;
  opacity: 0.7;
}

.empty-state-stats {
  font-size: 1.1rem;
  font-weight: 600;
  color: var(--color-primary);
  margin: 0 0 0.5rem;
}

.empty-state-tip {
  font-size: 0.9rem;
  color: var(--color-text-muted);
  margin: 0;
}

.btn {
  padding: 0.625rem 1.25rem;
  font-size: 1rem;
  font-weight: 600;
  border: none;
  border-radius: var(--radius);
  cursor: pointer;
  transition: background 0.15s ease;
}

.btn-primary {
  background: var(--color-primary);
  color: white;
}

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

.btn-secondary {
  background: var(--color-text-muted);
  color: white;
}

.btn-secondary:hover {
  background: #475569;
}

.hint {
  margin-top: 1rem;
  font-size: 0.875rem;
  color: var(--color-text-muted);
}

/* Test screen */
.test-header {
  margin-bottom: 1rem;
  text-align: center;
}

.timer {
  font-size: 1.5rem;
  font-weight: 700;
  font-family: var(--font-mono);
}

.passage-wrapper {
  margin-bottom: 1rem;
}

.passage-display {
  font-family: var(--font-mono);
  font-size: 1.125rem;
  line-height: 1.7;
  padding: 0.875rem 1rem;
  background: var(--color-surface);
  border: 1px solid #e2e8f0;
  border-radius: var(--radius);
  margin-bottom: 0.75rem;
  height: 10rem;
  min-height: 8rem;
  overflow: hidden;
  white-space: pre-wrap;
  word-wrap: break-word;
  position: relative;
  touch-action: none;
}

.passage-display .passage-inner {
  will-change: transform;
}

.passage-display .char {
  border-radius: 2px;
}

.passage-display .char.correct {
  color: var(--color-correct);
  background: rgba(34, 197, 94, 0.12);
}

.passage-display .char.incorrect {
  color: var(--color-incorrect);
  background: rgba(239, 68, 68, 0.12);
}

.passage-display .char.current {
  background: #e2e8f0;
  border-bottom: 2px solid var(--color-primary);
}

.passage-display .char.passage-ellipsis {
  color: var(--color-text-muted);
  user-select: none;
}

.test-input-hidden {
  position: absolute;
  left: -9999px;
  width: 1px;
  height: 1px;
  opacity: 0;
  overflow: hidden;
  z-index: -1;
}

.test-hint {
  font-size: 0.875rem;
  color: var(--color-text-muted);
  margin-top: 0.5rem;
}

/* Results */
.results-card {
  background: var(--color-surface);
  padding: 2rem;
  border-radius: var(--radius);
  box-shadow: var(--shadow-lg);
}

.results-card h2 {
  margin-top: 0;
  margin-bottom: 1.5rem;
  font-size: 1.25rem;
}

.results-stats {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(120px, 1fr));
  gap: 1rem;
  margin-bottom: 2rem;
}

.stat {
  text-align: center;
  padding: 0.75rem;
  background: var(--color-bg);
  border-radius: var(--radius);
}

.stat-value {
  display: block;
  font-size: 1.5rem;
  font-weight: 700;
  font-family: var(--font-mono);
}

.stat-label {
  font-size: 0.75rem;
  color: var(--color-text-muted);
  text-transform: uppercase;
  letter-spacing: 0.05em;
}

.chart-container {
  position: relative;
  height: 240px;
  margin-bottom: 1.5rem;
}

.results-actions {
  display: flex;
  gap: 0.75rem;
  flex-wrap: wrap;
}

/* Reports */
.reports-card {
  background: var(--color-surface);
  padding: 2rem;
  border-radius: var(--radius);
  box-shadow: var(--shadow-lg);
}

.reports-card h2 {
  margin-top: 0;
  margin-bottom: 1.5rem;
  font-size: 1.25rem;
}

.personal-bests {
  margin-bottom: 1.5rem;
  padding: 1rem;
  background: var(--color-bg);
  border-radius: var(--radius);
}

.history-table-wrapper {
  overflow-x: auto;
}

.history-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.875rem;
}

.history-table th,
.history-table td {
  padding: 0.5rem 0.75rem;
  text-align: left;
  border-bottom: 1px solid #e2e8f0;
}

.history-table th {
  font-weight: 600;
  color: var(--color-text-muted);
}

.history-table tbody tr:hover {
  background: var(--color-bg);
}

/* Resources */
.resources-card {
  background: var(--color-surface);
  padding: 2rem;
  border-radius: var(--radius);
  box-shadow: var(--shadow-lg);
}

.resources-card h2 {
  margin-top: 0;
  margin-bottom: 1.5rem;
  font-size: 1.25rem;
}

.resource-section {
  margin-bottom: 1.5rem;
}

.resource-section h3 {
  font-size: 1rem;
  margin-bottom: 0.5rem;
}

.resource-section ul {
  margin: 0.5rem 0 0 1.25rem;
  padding: 0;
}

.resource-section a {
  color: var(--color-primary);
}

.resource-section a:hover {
  text-decoration: none;
}

/* Responsive */
@media (max-width: 640px) {
  .main {
    padding: 1rem;
  }

  .config-card,
  .results-card,
  .reports-card,
  .resources-card {
    padding: 1.25rem;
  }

  .results-stats {
    grid-template-columns: repeat(2, 1fr);
  }

  .passage-display {
    font-size: 1rem;
  }
}
