/* ===== Type Racer ===== */
.tr-page {
  max-width: 700px;
  margin: 0 auto;
  padding: 2rem 1.5rem 4rem;
}

/* Header */
.tr-header {
  text-align: center;
  margin-bottom: 2rem;
}
.tr-back-btn {
  display: inline-flex;
  align-items: center;
  gap: 0.4rem;
  color: var(--text-muted);
  text-decoration: none;
  font-size: 0.85rem;
  margin-bottom: 1.2rem;
  transition: color 0.2s;
}
.tr-back-btn:hover { color: var(--text-main); }
.tr-title {
  font-size: clamp(1.8rem, 4vw, 2.4rem);
  font-weight: 800;
  color: #f9fafb;
  margin-bottom: 0.3rem;
}
.tr-title span {
  background: linear-gradient(120deg, #60a5fa, #3b82f6, #e5e7eb);
  -webkit-background-clip: text;
  background-clip: text;
  color: transparent;
}
.tr-title i { margin-right: 0.4rem; }
.tr-subtitle {
  color: var(--text-muted);
  font-size: 1rem;
  line-height: 1.6;
}

/* HUD */
.tr-hud {
  display: flex;
  justify-content: center;
  gap: 1.4rem;
  flex-wrap: wrap;
  margin-bottom: 1rem;
}
.tr-hud-item {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 0.15rem;
  min-width: 74px;
}
.tr-hud-label {
  font-size: 0.7rem;
  text-transform: uppercase;
  letter-spacing: 0.12em;
  color: var(--text-muted);
}
.tr-hud-value {
  font-size: 1.15rem;
  font-weight: 700;
  color: var(--text-main);
  display: inline-flex;
  align-items: center;
  gap: 0.2rem;
}

/* Arena */
.tr-arena {
  position: relative;
  width: 100%;
  height: 420px;
  background: rgba(15, 23, 42, 0.85);
  border: 1px solid rgba(148, 163, 184, 0.2);
  border-radius: 14px;
  overflow: hidden;
  margin-bottom: 0.8rem;
}
.tr-ground {
  position: absolute;
  bottom: 0;
  left: 0;
  right: 0;
  height: 4px;
  background: linear-gradient(90deg, #ef4444, #f97316, #ef4444);
  opacity: 0.8;
}

/* Falling words */
.tr-word {
  position: absolute;
  font-size: 1.1rem;
  font-weight: 600;
  color: #e5e7eb;
  text-shadow: 0 0 10px rgba(59, 130, 246, 0.5);
  white-space: nowrap;
  transition: color 0.15s;
  user-select: none;
  pointer-events: none;
}
.tr-word.tr-matched {
  color: #10b981;
  text-shadow: 0 0 14px rgba(16, 185, 129, 0.7);
}
.tr-word.tr-danger {
  color: #ef4444;
  text-shadow: 0 0 14px rgba(239, 68, 68, 0.7);
  animation: tr-shake 0.3s;
}

@keyframes tr-shake {
  0%, 100% { transform: translateX(0); }
  25% { transform: translateX(-4px); }
  75% { transform: translateX(4px); }
}

@keyframes tr-pop {
  0% { transform: scale(1); opacity: 1; }
  50% { transform: scale(1.4); opacity: 0.8; }
  100% { transform: scale(0); opacity: 0; }
}
.tr-word.tr-cleared {
  animation: tr-pop 0.35s ease-out forwards;
}

/* Overlay */
.tr-overlay {
  position: absolute;
  inset: 0;
  background: rgba(2, 6, 23, 0.88);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 10;
  backdrop-filter: blur(4px);
}
.tr-overlay.hidden { display: none; }
.tr-overlay-content {
  text-align: center;
  padding: 2rem;
}
.tr-overlay-content h2 {
  font-size: 2rem;
  font-weight: 800;
  color: var(--text-main);
  margin-bottom: 0.6rem;
}
.tr-overlay-content p {
  color: var(--text-muted);
  margin-bottom: 1.4rem;
  line-height: 1.6;
}
.tr-play-btn {
  padding: 0.7rem 2rem;
  border: 1px solid rgba(148, 163, 184, 0.6);
  border-radius: 999px;
  background: transparent;
  color: #e5e7eb;
  font-size: 1rem;
  font-weight: 600;
  cursor: pointer;
  transition: background 0.2s, border-color 0.2s, transform 0.15s;
}
.tr-play-btn:hover {
  background: rgba(148, 163, 184, 0.12);
  border-color: rgba(148, 163, 184, 1);
  transform: translateY(-2px);
}

/* Input */
.tr-input-wrap {
  margin-bottom: 1.8rem;
}
.tr-input {
  width: 100%;
  padding: 0.75rem 1.2rem;
  font-size: 1.1rem;
  font-family: 'Inter', sans-serif;
  font-weight: 600;
  background: rgba(15, 23, 42, 0.9);
  border: 1px solid rgba(148, 163, 184, 0.3);
  border-radius: 10px;
  color: #e5e7eb;
  outline: none;
  transition: border-color 0.2s;
  box-sizing: border-box;
  touch-action: manipulation;
}
.tr-input:focus {
  border-color: #3b82f6;
}

.tr-play-btn:focus-visible,
.tr-input:focus-visible,
.tr-back-btn:focus-visible {
  outline: 2px solid #38bdf8;
  outline-offset: 2px;
}

/* Hearts / Lives */
.tr-heart-full {
  color: #ef4444;
  text-shadow: 0 0 6px rgba(239, 68, 68, 0.5);
  transition: opacity 0.2s, transform 0.2s;
}
.tr-heart-empty {
  color: rgba(148, 163, 184, 0.25);
  transition: opacity 0.2s;
}
.tr-lives-shake {
  animation: tr-lives-shake 0.4s ease;
}
@keyframes tr-lives-shake {
  0%, 100% { transform: translateX(0); }
  20% { transform: translateX(-4px); }
  40% { transform: translateX(4px); }
  60% { transform: translateX(-3px); }
  80% { transform: translateX(3px); }
}

/* Responsive */
@media (max-width: 600px) {
  .tr-page { padding: 0.8rem 0.5rem 2rem !important; }
  .tr-header { margin-bottom: 1rem; }
  .tr-subtitle { font-size: 0.82rem; }
  .tr-arena {
    height: clamp(260px, 55vh, 380px);
    border-radius: 10px;
    margin-bottom: 0.5rem;
  }
  .tr-hud {
    gap: 0.5rem;
    margin-bottom: 0.6rem;
  }
  .tr-hud-label { font-size: 0.6rem; }
  .tr-hud-value { font-size: 0.95rem; }
  .tr-word { font-size: 0.9rem; }
  .tr-input {
    padding: 0.6rem 0.8rem;
    font-size: 1rem;
    border-radius: 8px;
  }
  .tr-input-wrap { margin-bottom: 1rem; }
  .tr-overlay-content { padding: 1.2rem; }
  .tr-overlay-content h2 { font-size: 1.4rem; }
  .tr-overlay-content p { font-size: 0.82rem; }
  .tr-play-btn { font-size: 0.9rem; padding: 0.55rem 1.5rem; }
}
