/* typing_rain game.css */

.tr-stage {
  position: relative;
  width: 100%;
  height: min(60vh, 520px);
  background: linear-gradient(180deg, #e0f2fe 0%, #f0f9ff 100%);
  border-radius: 14px;
  overflow: hidden;
  border: 1px solid #bae6fd;
  box-shadow: inset 0 0 40px rgba(56, 189, 248, 0.08);
}

/* 빗방울 느낌의 얇은 선들 (데코) */
.tr-stage::before {
  content: '';
  position: absolute;
  inset: 0;
  background-image:
    linear-gradient(180deg, transparent 0%, rgba(14, 165, 233, 0.04) 100%);
  pointer-events: none;
}

.tr-words {
  position: absolute;
  inset: 0;
  pointer-events: none;
  font-family: ui-monospace, SFMono-Regular, 'Menlo', 'Consolas', monospace;
}

.tr-word {
  position: absolute;
  will-change: transform;
  padding: 4px 10px;
  border-radius: 8px;
  background: rgba(255, 255, 255, 0.85);
  border: 1px solid rgba(14, 165, 233, 0.2);
  box-shadow: 0 4px 14px rgba(14, 165, 233, 0.08);
  font-size: 18px;
  font-weight: 600;
  color: #1f2937;
  white-space: nowrap;
  letter-spacing: 0.02em;
  transition: box-shadow 120ms ease;
}

.tr-word.tr-word--active {
  background: #fff;
  border-color: #38bdf8;
  box-shadow: 0 6px 18px rgba(14, 165, 233, 0.25), 0 0 0 2px rgba(56, 189, 248, 0.25);
}

.tr-word .tr-typed {
  color: #0ea5e9;
}

.tr-word .tr-rest {
  color: #1f2937;
}

/* 완성된 단어 사라지는 애니메이션 */
.tr-word.tr-word--dying {
  animation: tr-word-die 220ms cubic-bezier(0.34, 1.56, 0.64, 1) forwards;
  pointer-events: none;
}
@keyframes tr-word-die {
  0%   { transform: translateY(0) scale(1); opacity: 1; }
  50%  { transform: translateY(-6px) scale(1.12); opacity: 1; }
  100% { transform: translateY(-12px) scale(1.2); opacity: 0; }
}

/* 단어가 바닥에 닿는 순간 (life lost) */
.tr-stage.tr-stage--hit {
  animation: tr-stage-hit 240ms ease-out;
}
@keyframes tr-stage-hit {
  0%, 100% { box-shadow: inset 0 0 40px rgba(56, 189, 248, 0.08); }
  40%      { box-shadow: inset 0 0 80px rgba(244, 63, 94, 0.45); }
}

/* 바닥 표시선 */
.tr-stage::after {
  content: '';
  position: absolute;
  left: 0; right: 0; bottom: 0;
  height: 2px;
  background: linear-gradient(90deg, transparent, rgba(244, 63, 94, 0.4), transparent);
}

/* 오버레이 */
.tr-overlay {
  position: absolute;
  inset: 0;
  background: rgba(255, 255, 255, 0.82);
  backdrop-filter: blur(3px);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 10;
}
.tr-overlay.hidden { display: none; }

.tr-overlay-inner {
  text-align: center;
  padding: 24px;
}
.tr-overlay-title {
  font-size: 26px;
  font-weight: 800;
  color: #0c4a6e;
  margin-bottom: 8px;
}
.tr-overlay-sub {
  font-size: 14px;
  color: #475569;
  margin-bottom: 18px;
}
.tr-overlay-actions {
  display: flex;
  gap: 8px;
  justify-content: center;
  flex-wrap: wrap;
}
.tr-overlay-btn {
  display: inline-block;
  padding: 10px 18px;
  border-radius: 8px;
  background: #e2e8f0;
  color: #0c4a6e;
  font-weight: 600;
  font-size: 14px;
  border: 0;
  cursor: pointer;
  text-decoration: none;
}
.tr-overlay-btn--primary { background: #0284c7; color: #fff; }
.tr-overlay-btn--primary:hover { background: #0369a1; }

/* 모션 민감 사용자 */
@media (prefers-reduced-motion: reduce) {
  .tr-word.tr-word--dying { animation: none; opacity: 0; }
  .tr-stage.tr-stage--hit { animation: none; }
}
