@import url('https://fonts.googleapis.com/css2?family=Inter:wght@400;500;600;700;800;900&family=JetBrains+Mono:wght@400;700;900&display=swap');

/* ===== Reset & Base ===== */
*, *::before, *::after {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
}

body {
  font-family: 'Inter', ui-sans-serif, system-ui, -apple-system, sans-serif;
  background-color: #0a0a0a;
  color: #ffffff;
  overflow: hidden;
  user-select: none;
  -webkit-user-select: none;
  -webkit-tap-highlight-color: transparent;
}

/* ===== Game Container ===== */
.game-container {
  position: fixed;
  inset: 0;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  transition: background-color 0.2s ease;
}

.game-container.state-idle { background-color: #0a0a0a; }
.game-container.state-waiting { background-color: rgba(239, 68, 68, 0.2); }
.game-container.state-ready { background-color: #10b981; }
.game-container.state-too-soon { background-color: rgba(245, 158, 11, 0.4); }
.game-container.state-result { background-color: #0a0a0a; }
.game-container.state-finished { background-color: #1e1b4b; }

/* ===== Screen Panels ===== */
.screen {
  text-align: center;
  padding: 0 1.5rem;
  animation: fadeInUp 0.3s ease-out;
}

@keyframes fadeInUp {
  from {
    opacity: 0;
    transform: translateY(20px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

@keyframes fadeIn {
  from { opacity: 0; }
  to { opacity: 1; }
}

@keyframes scaleIn {
  from {
    opacity: 0;
    transform: scale(0.8);
  }
  to {
    opacity: 1;
    transform: scale(1);
  }
}

/* ===== IDLE Screen ===== */
.icon-wrapper {
  margin-bottom: 2rem;
  display: flex;
  justify-content: center;
}

.icon-circle {
  padding: 1rem;
  border-radius: 9999px;
  background-color: rgba(255, 255, 255, 0.05);
  border: 1px solid rgba(255, 255, 255, 0.1);
  display: flex;
  align-items: center;
  justify-content: center;
}

.icon-circle svg {
  width: 48px;
  height: 48px;
  color: #34d399;
}

.game-title {
  font-size: clamp(2.2rem, 7vw, 3.25rem);
  font-weight: 900;
  letter-spacing: -0.05em;
  margin-bottom: 1rem;
  font-style: italic;
  line-height: 1.1;
}

.game-subtitle {
  color: #a1a1aa;
  font-size: 1.125rem;
  max-width: 28rem;
  margin: 0 auto 3rem;
  font-weight: 500;
  line-height: 1.6;
}

.green-text {
  color: #34d399;
}

.start-btn {
  display: inline-flex;
  align-items: center;
  gap: 0.5rem;
  padding: 1rem 2rem;
  background-color: #ffffff;
  color: #000000;
  font-weight: 700;
  border-radius: 9999px;
  border: none;
  font-size: 0.875rem;
  letter-spacing: 0.05em;
  cursor: pointer;
  transition: transform 0.15s ease;
  font-family: inherit;
}

.start-btn:hover {
  transform: scale(1.05);
}

.start-btn svg {
  width: 20px;
  height: 20px;
}

/* ===== WAITING Screen ===== */
.waiting-text {
  font-size: clamp(1.5rem, 6vw, 2.25rem);
  font-weight: 700;
  letter-spacing: 0.15em;
  color: #f87171;
  animation: pulseSlow 2s cubic-bezier(0.4, 0, 0.6, 1) infinite;
}

@keyframes pulseSlow {
  0%, 100% { opacity: 0.3; }
  50% { opacity: 0.6; }
}

/* ===== READY Screen ===== */
.screen-ready {
  animation: scaleIn 0.15s ease-out;
}

.timer-display {
  font-family: 'JetBrains Mono', ui-monospace, monospace;
  font-size: clamp(4rem, 15vw, 8rem);
  font-weight: 900;
  color: #ffffff;
  text-shadow: 0 10px 30px rgba(0, 0, 0, 0.3);
  line-height: 1;
}

.timer-unit {
  font-size: clamp(1.25rem, 4vw, 2rem);
  opacity: 0.5;
  margin-left: 0.5rem;
}

.tap-now {
  margin-top: 2rem;
  font-size: 1.5rem;
  font-weight: 900;
  letter-spacing: -0.025em;
  color: rgba(255, 255, 255, 0.8);
  text-transform: uppercase;
}

/* ===== TOO SOON Screen ===== */
.too-soon-icon {
  width: 80px;
  height: 80px;
  color: #fbbf24;
  margin: 0 auto 1.5rem;
}

.too-soon-title {
  font-size: clamp(2rem, 7vw, 3rem);
  font-weight: 900;
  letter-spacing: -0.05em;
  margin-bottom: 1rem;
}

.too-soon-subtitle {
  color: #a1a1aa;
  font-size: 1.25rem;
  margin-bottom: 3rem;
}

.hint-text {
  color: #71717a;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.15em;
  font-size: 0.875rem;
}

/* ===== RESULT Screen ===== */
.round-label {
  color: #71717a;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.15em;
  margin-bottom: 0.5rem;
  font-size: 0.875rem;
}

.result-time {
  font-family: 'JetBrains Mono', ui-monospace, monospace;
  font-size: clamp(4rem, 15vw, 8rem);
  font-weight: 900;
  color: #34d399;
  margin-bottom: 3rem;
  line-height: 1;
}

.dots-container {
  display: flex;
  justify-content: center;
  gap: 1rem;
  margin-bottom: 3rem;
}

.dot {
  width: 12px;
  height: 12px;
  border-radius: 9999px;
  background-color: rgba(255, 255, 255, 0.1);
  transition: background-color 0.2s;
}

.dot.active {
  background-color: #10b981;
}

.next-text {
  color: #ffffff;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.15em;
  font-size: 0.875rem;
}

/* ===== FINISHED Screen ===== */
.screen-finished {
  max-width: 28rem;
  width: 100%;
}

.trophy-icon {
  width: 48px;
  height: 64px;
  color: #facc15;
  margin: 0 auto 1.5rem;
}

.session-title {
  font-size: clamp(1.25rem, 4vw, 1.75rem);
  font-weight: 900;
  letter-spacing: -0.05em;
  margin-bottom: 0.5rem;
}

.results-card {
  background-color: rgba(255, 255, 255, 0.05);
  border: 1px solid rgba(255, 255, 255, 0.1);
  border-radius: 1.5rem;
  padding: 1.5rem;
  margin-bottom: 1.5rem;
  backdrop-filter: blur(20px);
  -webkit-backdrop-filter: blur(20px);
}

.avg-label {
  color: #a1a1aa;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.15em;
  margin-bottom: 0.5rem;
  font-size: 0.75rem;
}

.avg-time {
  font-family: 'JetBrains Mono', ui-monospace, monospace;
  font-size: clamp(2.5rem, 10vw, 4rem);
  font-weight: 900;
  color: #ffffff;
  margin-bottom: 2rem;
  line-height: 1;
}

.avg-unit {
  font-size: clamp(1rem, 3vw, 1.5rem);
  opacity: 0.5;
  margin-left: 0.5rem;
}

.rounds-grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 0.75rem;
  border-top: 1px solid rgba(255, 255, 255, 0.1);
  padding-top: 1.5rem;
}

.round-item {
  text-align: center;
}

.round-item-label {
  font-size: 10px;
  color: #71717a;
  font-weight: 700;
  text-transform: uppercase;
  margin-bottom: 0.25rem;
}

.round-item-time {
  font-family: 'JetBrains Mono', ui-monospace, monospace;
  font-size: 1.25rem;
  font-weight: 700;
}

.play-again-btn {
  width: 100%;
  padding: 1.25rem;
  background-color: #ffffff;
  color: #000000;
  font-weight: 900;
  border-radius: 1rem;
  border: none;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 0.75rem;
  font-size: 1rem;
  font-family: inherit;
  letter-spacing: 0.05em;
  transition: background-color 0.15s ease;
}

.play-again-btn:hover {
  background-color: #e4e4e7;
}

.play-again-btn svg {
  width: 24px;
  height: 24px;
}

/* ===== Footer ===== */
.footer {
  position: fixed;
  bottom: 2rem;
  left: 0;
  right: 0;
  display: flex;
  justify-content: center;
  pointer-events: none;
}

.footer-inner {
  display: flex;
  align-items: center;
  gap: 1.5rem;
  padding: 0.75rem 1.5rem;
  border-radius: 9999px;
  background-color: rgba(0, 0, 0, 0.2);
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
  border: 1px solid rgba(255, 255, 255, 0.05);
  font-size: 10px;
  font-weight: 700;
  letter-spacing: 0.2em;
  color: #71717a;
  text-transform: uppercase;
}

.footer-item {
  display: flex;
  align-items: center;
  gap: 0.5rem;
}

.footer-item svg {
  width: 12px;
  height: 12px;
}

.footer-dot {
  width: 4px;
  height: 4px;
  border-radius: 9999px;
  background-color: #27272a;
}

/* ===== Hidden class ===== */
.hidden {
  display: none !important;
}

#nickname-section {
  margin-bottom: 2rem;
  display: flex;
  flex-direction: column;
  gap: 0.75rem;
}

#nickname-input {
  background: rgba(255, 255, 255, 0.05);
  border: 1px solid rgba(255, 255, 255, 0.2);
  padding: 1rem;
  border-radius: 0.75rem;
  color: white;
  text-align: center;
  font-size: 1.1rem;
  font-weight: 700;
  outline: none;
}

#nickname-input:focus {
  border-color: #34d399;
}

#submit-score-btn {
  background-color: #34d399;
  color: #000;
  border: none;
  padding: 0.75rem;
  border-radius: 0.75rem;
  font-weight: 800;
  cursor: pointer;
  transition: 0.2s;
}

#submit-score-btn:hover {
  background-color: #10b981;
}

/* 리더보드 테이블 */
.leaderboard-section {
  margin-bottom: 2rem;
  animation: fadeIn 0.5s;
}

.leaderboard-header {
  font-size: 0.75rem;
  font-weight: 800;
  color: #fbbf24;
  margin-bottom: 1rem;
  letter-spacing: 0.1em;
}

.leaderboard-table {
  width: 100%;
  border-collapse: collapse;
  margin-bottom: 1.5rem;
  font-size: 0.9rem;
}

.leaderboard-table td {
  padding: 0.5rem 0;
  border-bottom: 1px solid rgba(255, 255, 255, 0.05);
}

.leaderboard-table .rank {
  color: #71717a;
  width: 20%;
  text-align: left;
}

.leaderboard-table .name {
  text-align: left;
  font-weight: 600;
}

.leaderboard-table .score {
  text-align: right;
  font-family: 'JetBrains Mono', monospace;
  color: #34d399;
}

/* 모바일 전용 (화면 높이가 낮거나 폭이 좁은 기기) */
@media (max-width: 480px) {
  .results-card {
    padding: 1rem;
    margin-bottom: 1rem;
  }
  
  .avg-time {
    font-size: 2.5rem;
    margin-bottom: 1rem;
  }

  .trophy-icon {
    width: 40px;
    height: 40px;
    margin-bottom: 2.2rem;
  }

  .rounds-grid {
    padding-top: 1rem;
    gap: 0.5rem;
  }

  .round-item-time {
    font-size: 1rem;
  }
  
  .play-again-btn {
    padding: 1rem;
    font-size: 0.9rem;
  }
}
