/* 기본 스타일 */
body {
  font-family: 'Noto Sans KR', sans-serif;
  margin: 0;
  padding: 0;
  background-color: #FFF6E9;
  color: #333;
  position: relative;
  overflow-x: hidden;
  min-height: 100vh;
}

/* 배경 원형 요소 */
body::before {
  content: '';
  position: fixed;
  top: -120px;
  right: -120px;
  width: 350px;
  height: 350px;
  background-color: rgba(199, 176, 227, 0.3);
  border-radius: 50%;
  z-index: 0;
  animation: float 8s ease-in-out infinite;
}

body::after {
  content: '';
  position: fixed;
  bottom: -100px;
  left: -100px;
  width: 280px;
  height: 280px;
  background-color: rgba(247, 205, 100, 0.2);
  border-radius: 50%;
  z-index: 0;
  animation: float 10s ease-in-out infinite reverse;
}

@keyframes float {
  0%, 100% { transform: translateY(0); }
  50% { transform: translateY(-20px); }
}

/* 로비 컨테이너 */
.lobby-container {
  max-width: 1200px;
  margin: 0 auto;
  padding: 20px;
  position: relative;
  z-index: 1;
  min-height: 100vh;
}

/* 헤더 */
.lobby-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 40px;
  padding: 20px 0;
}

.lobby-header h1 {
  font-size: 2.5rem;
  font-weight: 700;
  color: #37306B;
  margin: 0;
  flex: 1;
  text-align: center;
}

.back-button,
.refresh-button {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 12px 20px;
  background-color: white;
  border: 2px solid #6c63ff;
  border-radius: 12px;
  cursor: pointer;
  font-size: 1rem;
  font-weight: 600;
  color: #6c63ff;
  transition: all 0.3s ease;
  box-shadow: 0 4px 15px rgba(108, 99, 255, 0.1);
}

.back-button:hover,
.refresh-button:hover {
  background-color: #6c63ff;
  color: white;
  transform: translateY(-2px);
  box-shadow: 0 6px 20px rgba(108, 99, 255, 0.2);
}

.back-button:hover svg path,
.refresh-button:hover svg path {
  fill: white;
}

.refresh-button {
  padding: 12px;
}

/* 로딩 */
.loading-container {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: 60px 20px;
}

.spinner {
  width: 50px;
  height: 50px;
  border: 4px solid #f3f3f3;
  border-top: 4px solid #6c63ff;
  border-radius: 50%;
  animation: spin 1s linear infinite;
}

@keyframes spin {
  0% { transform: rotate(0deg); }
  100% { transform: rotate(360deg); }
}

.loading-container p {
  margin-top: 20px;
  font-size: 1.2rem;
  color: #666;
}

/* 빈 상태 */
.empty-state {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: 80px 20px;
  text-align: center;
}

.empty-state svg {
  margin-bottom: 20px;
  opacity: 0.6;
}

.empty-state h2 {
  font-size: 1.8rem;
  color: #37306B;
  margin: 20px 0 10px;
}

.empty-state p {
  font-size: 1.1rem;
  color: #666;
  margin-bottom: 30px;
}

.create-room-button {
  padding: 15px 40px;
  background: linear-gradient(135deg, #6c63ff 0%, #5a52d5 100%);
  color: white;
  border: none;
  border-radius: 12px;
  font-size: 1.1rem;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.3s ease;
  box-shadow: 0 4px 15px rgba(108, 99, 255, 0.3);
}

.create-room-button:hover {
  transform: translateY(-2px);
  box-shadow: 0 6px 20px rgba(108, 99, 255, 0.4);
}

/* 방 리스트 */
.room-list {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(320px, 1fr));
  gap: 20px;
  padding: 20px 0;
}

/* 방 카드 */
.room-card {
  background: white;
  border-radius: 16px;
  padding: 24px;
  box-shadow: 0 4px 15px rgba(0, 0, 0, 0.08);
  transition: all 0.3s ease;
  cursor: pointer;
  position: relative;
  overflow: hidden;
}

.room-card::before {
  content: '';
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 4px;
  background: linear-gradient(90deg, #6c63ff, #c7b0e3);
}

.room-card:hover {
  transform: translateY(-5px);
  box-shadow: 0 8px 25px rgba(108, 99, 255, 0.15);
}

.room-card-header {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  margin-bottom: 16px;
}

.room-name {
  font-size: 1.3rem;
  font-weight: 700;
  color: #6c63ff;
  margin: 0;
  word-break: break-word;
  flex: 1;
}

.room-status {
  padding: 6px 12px;
  background-color: #e8f5e9;
  color: #2e7d32;
  border-radius: 20px;
  font-size: 0.85rem;
  font-weight: 600;
  white-space: nowrap;
}

/* 게임 중 상태 */
.room-status.playing {
  background-color: #ffebee;
  color: #c62828;
}

/* 게임 진행 중 텍스트 */
.game-in-progress {
  color: #999;
  font-size: 0.95rem;
  font-weight: 500;
  font-style: italic;
}

.room-card-body {
  margin: 16px 0;
}

.room-info {
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.room-info-item {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 0.95rem;
  color: #666;
}

.room-info-item svg {
  flex-shrink: 0;
}

.room-info-label {
  font-weight: 600;
  color: #37306B;
}

.quiz-title {
  color: #37306B;
  font-weight: 600;
}

.room-card-footer {
  display: flex;
  justify-content: flex-end;
  align-items: center;
  margin-top: 20px;
  padding-top: 16px;
  border-top: 1px solid #f0f0f0;
}

.join-room-button {
  padding: 10px 24px;
  background: linear-gradient(135deg, #6c63ff 0%, #5a52d5 100%);
  color: white;
  border: none;
  border-radius: 10px;
  font-size: 1rem;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.3s ease;
  box-shadow: 0 2px 10px rgba(108, 99, 255, 0.2);
}

.join-room-button:hover {
  transform: scale(1.05);
  box-shadow: 0 4px 15px rgba(108, 99, 255, 0.3);
}

.join-room-button:disabled {
  background: #ccc;
  cursor: not-allowed;
  transform: none;
}

/* 모달 */
.modal {
  position: fixed;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  background-color: rgba(0, 0, 0, 0.5);
  display: flex;
  justify-content: center;
  align-items: center;
  z-index: 1000;
  animation: fadeIn 0.3s ease;
}

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

.modal-content {
  background: white;
  border-radius: 20px;
  padding: 0;
  width: 90%;
  max-width: 450px;
  box-shadow: 0 10px 40px rgba(0, 0, 0, 0.2);
  animation: slideUp 0.3s ease;
}

@keyframes slideUp {
  from {
    opacity: 0;
    transform: translateY(30px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

.modal-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 24px 28px;
  border-bottom: 1px solid #f0f0f0;
}

.modal-header h2 {
  margin: 0;
  font-size: 1.5rem;
  color: #37306B;
}

.close-button {
  background: none;
  border: none;
  cursor: pointer;
  padding: 8px;
  border-radius: 8px;
  transition: background-color 0.2s;
}

.close-button:hover {
  background-color: #f0f0f0;
}

.modal-body {
  padding: 28px;
}

.modal-body p {
  margin: 0 0 20px;
  color: #666;
  font-size: 1rem;
}

.modal-body input {
  width: 100%;
  padding: 14px 16px;
  border: 2px solid #e0e0e0;
  border-radius: 10px;
  font-size: 1rem;
  box-sizing: border-box;
  transition: border-color 0.3s;
}

.modal-body input:focus {
  outline: none;
  border-color: #6c63ff;
}

.error-message {
  color: #d32f2f;
  font-size: 0.9rem;
  margin-top: 10px;
}

.modal-footer {
  display: flex;
  gap: 12px;
  padding: 20px 28px;
  border-top: 1px solid #f0f0f0;
}

.cancel-button,
.join-button {
  flex: 1;
  padding: 14px;
  border: none;
  border-radius: 10px;
  font-size: 1rem;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.3s ease;
}

.cancel-button {
  background-color: #f5f5f5;
  color: #666;
}

.cancel-button:hover {
  background-color: #e0e0e0;
}

.join-button {
  background: linear-gradient(135deg, #6c63ff 0%, #5a52d5 100%);
  color: white;
  box-shadow: 0 2px 10px rgba(108, 99, 255, 0.2);
}

.join-button:hover {
  transform: translateY(-2px);
  box-shadow: 0 4px 15px rgba(108, 99, 255, 0.3);
}

/* 반응형 */
@media (max-width: 768px) {
  .lobby-header h1 {
    font-size: 1.8rem;
  }

  .back-button span {
    display: none;
  }

  .room-list {
    grid-template-columns: 1fr;
    gap: 16px;
  }

  .room-card {
    padding: 20px;
  }

  .room-name {
    font-size: 1.2rem;
  }

  .empty-state {
    padding: 60px 20px;
  }

  .empty-state h2 {
    font-size: 1.5rem;
  }

  .modal-content {
    width: 95%;
    max-width: none;
  }
}

@media (max-width: 480px) {
  .lobby-container {
    padding: 12px;
  }

  .lobby-header {
    margin-bottom: 24px;
  }

  .lobby-header h1 {
    font-size: 1.5rem;
  }

  .back-button,
  .refresh-button {
    padding: 10px 14px;
  }

  .refresh-button {
    padding: 10px;
  }

  .room-card-footer {
    flex-direction: column;
    gap: 12px;
    align-items: stretch;
  }

  .join-room-button {
    width: 100%;
  }
}
