* {
  margin: 0;
  padding: 0;
  box-sizing: border-box;
}

body {
  font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;
  background: linear-gradient(135deg, #1a1a2e 0%, #16213e 100%);
  min-height: 100vh;
  color: #fff;
}

.container {
  max-width: 1200px;
  margin: 0 auto;
  padding: 20px;
}

/* 버튼 스타일 */
.btn {
  padding: 12px 24px;
  border: none;
  border-radius: 8px;
  cursor: pointer;
  font-size: 16px;
  font-weight: 600;
  transition: all 0.3s ease;
  background: #4a4a6a;
  color: #fff;
}

.btn:hover {
  transform: translateY(-2px);
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.3);
}

.btn:disabled {
  opacity: 0.5;
  cursor: not-allowed;
  transform: none;
}

.btn.primary {
  background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
}

.btn.danger {
  background: linear-gradient(135deg, #f5576c 0%, #f093fb 100%);
}

.btn.small {
  padding: 8px 16px;
  font-size: 14px;
}

.btn.challenge {
  padding: 6px 12px;
  font-size: 12px;
  background: linear-gradient(135deg, #11998e 0%, #38ef7d 100%);
}

/* 화면 전환 */
.screen {
  display: none;
  min-height: 100vh;
}

.screen.active {
  display: block;
}

/* 언어 선택 화면 */
#language-screen.active {
  display: flex;
  align-items: center;
  justify-content: center;
}

#language-screen .container {
  text-align: center;
}

#language-screen h1 {
  font-size: 36px;
  margin-bottom: 40px;
  background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  background-clip: text;
}

.language-options {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 20px;
  max-width: 400px;
  margin: 0 auto;
}

.language-btn {
  display: flex;
  flex-direction: column;
  align-items: center;
  padding: 25px 20px;
  border-radius: 12px;
  background: rgba(255, 255, 255, 0.1);
  border: 2px solid transparent;
  transition: all 0.3s ease;
}

.language-btn:hover {
  background: rgba(102, 126, 234, 0.2);
  border-color: #667eea;
  transform: translateY(-3px);
}

.lang-flag {
  font-size: 40px;
  margin-bottom: 10px;
}

.lang-name {
  font-size: 18px;
  font-weight: 600;
}

/* 설정 셀렉트 박스 */
.settings-select {
  padding: 8px 16px;
  border-radius: 8px;
  background: #2a2a4e;
  border: 1px solid rgba(255, 255, 255, 0.2);
  color: #fff;
  font-size: 14px;
  cursor: pointer;
  outline: none;
  transition: border-color 0.3s;
}

.settings-select:hover,
.settings-select:focus {
  border-color: #667eea;
}

.settings-select option {
  background: #2a2a4e;
  color: #fff;
}

/* 로그인 화면 */
#login-screen.active {
  display: flex;
  align-items: center;
  justify-content: center;
}

#login-screen .container {
  text-align: center;
}

#login-screen h1 {
  font-size: 48px;
  margin-bottom: 40px;
  background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  background-clip: text;
}

.login-box {
  display: flex;
  flex-direction: column;
  gap: 20px;
  max-width: 400px;
  margin: 0 auto;
}

#username-input {
  padding: 15px 20px;
  border: 2px solid #4a4a6a;
  border-radius: 8px;
  font-size: 18px;
  background: rgba(255, 255, 255, 0.1);
  color: #fff;
  outline: none;
  transition: border-color 0.3s;
}

#username-input:focus {
  border-color: #667eea;
}

#username-input::placeholder {
  color: rgba(255, 255, 255, 0.5);
}

/* 모드 선택 화면 */
#mode-screen.active {
  display: flex;
  align-items: center;
  justify-content: center;
}

#mode-screen .container {
  text-align: center;
}

#mode-screen h1 {
  font-size: 36px;
  margin-bottom: 20px;
  background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  background-clip: text;
}

.welcome-text {
  font-size: 18px;
  color: #aaa;
  margin-bottom: 40px;
}

#welcome-name {
  color: #667eea;
  font-weight: 600;
}

.mode-buttons {
  display: flex;
  gap: 30px;
  justify-content: center;
  margin-bottom: 30px;
}

.mode-btn {
  display: flex;
  flex-direction: column;
  align-items: center;
  padding: 30px 50px;
  border-radius: 16px;
  min-width: 180px;
  transition: all 0.3s ease;
}

.mode-btn.single {
  background: linear-gradient(135deg, #f093fb 0%, #f5576c 100%);
}

.mode-btn.multi {
  background: linear-gradient(135deg, #4facfe 0%, #00f2fe 100%);
}

.mode-btn:hover {
  transform: translateY(-5px);
  box-shadow: 0 10px 30px rgba(0, 0, 0, 0.3);
}

.mode-icon {
  font-size: 48px;
  margin-bottom: 10px;
}

.mode-title {
  font-size: 20px;
  font-weight: 700;
  margin-bottom: 5px;
}

.mode-desc {
  font-size: 14px;
  opacity: 0.9;
}

/* 난이도 선택 모달 */
.difficulty-options {
  display: flex;
  gap: 15px;
  justify-content: center;
  margin: 20px 0;
}

.difficulty-btn {
  display: flex;
  flex-direction: column;
  align-items: center;
  padding: 20px 30px;
  border-radius: 12px;
  min-width: 100px;
  background: rgba(255, 255, 255, 0.1);
  transition: all 0.3s ease;
}

.difficulty-btn:hover {
  background: rgba(102, 126, 234, 0.3);
  transform: translateY(-3px);
}

.difficulty-btn[data-level="easy"] {
  border: 2px solid #38ef7d;
}

.difficulty-btn[data-level="medium"] {
  border: 2px solid #ffd93d;
}

.difficulty-btn[data-level="hard"] {
  border: 2px solid #f5576c;
}

.diff-title {
  font-size: 18px;
  font-weight: 700;
  margin-bottom: 5px;
}

.diff-desc {
  font-size: 12px;
  color: #aaa;
}

/* 대기실 화면 */
.lobby-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 30px;
  padding-bottom: 20px;
  border-bottom: 1px solid rgba(255, 255, 255, 0.1);
}

.lobby-header h2 {
  font-size: 28px;
}

.user-info {
  display: flex;
  align-items: center;
  gap: 15px;
}

#my-name {
  font-size: 18px;
  font-weight: 600;
  color: #667eea;
}

.lobby-content {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 30px;
}

.user-list-section,
.ranking-section {
  background: rgba(255, 255, 255, 0.05);
  border-radius: 12px;
  padding: 20px;
}

.user-list-section h3,
.ranking-section h3 {
  margin-bottom: 20px;
  font-size: 20px;
  color: #667eea;
}

/* 섹션 헤더 (제목 + 버튼) */
.section-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 20px;
}

.section-header h3 {
  margin-bottom: 0;
}

/* 초대 버튼 */
.btn.invite {
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 8px 14px;
  font-size: 13px;
  background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
}

.btn.invite:hover {
  transform: translateY(-2px);
  box-shadow: 0 4px 12px rgba(102, 126, 234, 0.4);
}

.invite-icon {
  font-size: 14px;
}

.user-list {
  display: flex;
  flex-direction: column;
  gap: 10px;
  max-height: 500px;
  overflow-y: auto;
}

.user-item {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 12px 16px;
  background: rgba(255, 255, 255, 0.05);
  border-radius: 8px;
  transition: background 0.3s;
}

.user-item:hover {
  background: rgba(255, 255, 255, 0.1);
}

.user-item .name {
  font-weight: 500;
}

.user-item .status {
  font-size: 12px;
  padding: 4px 8px;
  border-radius: 4px;
}

.user-item .status.lobby {
  background: #38ef7d;
  color: #000;
}

.user-item .status.playing {
  background: #f5576c;
  color: #fff;
}

.user-item .status.challenging {
  background: #ffd93d;
  color: #000;
}

.user-item.me {
  border: 1px solid #667eea;
}

/* 랭킹 리스트 */
.ranking-list {
  max-height: 500px;
  overflow-y: auto;
}

.ranking-table {
  width: 100%;
  border-collapse: collapse;
}

.ranking-table th,
.ranking-table td {
  padding: 12px 8px;
  text-align: center;
  border-bottom: 1px solid rgba(255, 255, 255, 0.1);
}

.ranking-table th {
  background: rgba(102, 126, 234, 0.2);
  font-weight: 600;
}

.ranking-table tr:hover {
  background: rgba(255, 255, 255, 0.05);
}

.rank-1 { color: #ffd700; font-weight: 700; }
.rank-2 { color: #c0c0c0; font-weight: 700; }
.rank-3 { color: #cd7f32; font-weight: 700; }

/* 게임 화면 */
#game-screen .container {
  display: flex;
  flex-direction: column;
  align-items: center;
  padding-top: 20px;
}

.game-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  width: 100%;
  max-width: 600px;
  margin-bottom: 20px;
  padding: 15px 20px;
  background: rgba(255, 255, 255, 0.05);
  border-radius: 12px;
}

.player-info {
  display: flex;
  align-items: center;
  gap: 10px;
  font-size: 18px;
  font-weight: 600;
}

.stone {
  width: 24px;
  height: 24px;
  border-radius: 50%;
  display: inline-block;
}

.stone.black {
  background: radial-gradient(circle at 30% 30%, #555, #000);
  box-shadow: 2px 2px 4px rgba(0, 0, 0, 0.5);
}

.stone.white {
  background: radial-gradient(circle at 30% 30%, #fff, #ccc);
  box-shadow: 2px 2px 4px rgba(0, 0, 0, 0.3);
}

.game-status {
  text-align: center;
}

#turn-indicator {
  font-size: 16px;
  margin-bottom: 5px;
}

.timer {
  font-size: 32px;
  font-weight: 700;
  color: #667eea;
}

.timer.warning {
  color: #ffd93d;
}

.timer.danger {
  color: #f5576c;
  animation: pulse 0.5s infinite;
}

@keyframes pulse {
  0%, 100% { opacity: 1; }
  50% { opacity: 0.5; }
}

.game-board-container {
  position: relative;
  margin-bottom: 20px;
}

#game-board {
  background: #dcb35c;
  border-radius: 8px;
  box-shadow: 0 8px 32px rgba(0, 0, 0, 0.3);
  cursor: pointer;
}

.game-controls {
  display: flex;
  gap: 15px;
}

/* 모달 */
.modal {
  display: none;
  position: fixed;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  background: rgba(0, 0, 0, 0.7);
  justify-content: center;
  align-items: center;
  z-index: 1000;
}

.modal.active {
  display: flex;
}

.modal-content {
  background: #1a1a2e;
  padding: 30px;
  border-radius: 16px;
  text-align: center;
  min-width: 300px;
  box-shadow: 0 8px 32px rgba(0, 0, 0, 0.5);
  border: 1px solid rgba(255, 255, 255, 0.1);
}

.modal-content h3 {
  margin-bottom: 20px;
  color: #667eea;
}

.modal-content p {
  margin-bottom: 15px;
}

.modal-buttons {
  display: flex;
  justify-content: center;
  gap: 15px;
  margin-top: 20px;
}

.time-select {
  margin: 20px 0;
}

.time-select label {
  margin-right: 10px;
}

.time-select select {
  padding: 8px 16px;
  border-radius: 8px;
  background: #2a2a4e;
  border: 1px solid rgba(255, 255, 255, 0.2);
  color: #fff;
  font-size: 16px;
}

.time-select select option {
  background: #2a2a4e;
  color: #fff;
}

.countdown {
  font-size: 24px;
  font-weight: 700;
  color: #ffd93d;
  margin: 15px 0;
}

.countdown.large-countdown {
  font-size: 48px;
  margin: 25px 0;
}

.hint-text {
  font-size: 14px;
  color: #aaa;
  margin-top: 10px;
}

/* 결과 모달 */
#result-title.win {
  color: #38ef7d;
}

#result-title.lose {
  color: #f5576c;
}

#result-title.draw {
  color: #ffd93d;
}

/* 스크롤바 */
::-webkit-scrollbar {
  width: 8px;
}

::-webkit-scrollbar-track {
  background: rgba(255, 255, 255, 0.05);
  border-radius: 4px;
}

::-webkit-scrollbar-thumb {
  background: rgba(102, 126, 234, 0.5);
  border-radius: 4px;
}

::-webkit-scrollbar-thumb:hover {
  background: rgba(102, 126, 234, 0.7);
}

/* 구글 로그인 버튼 */
.google-btn {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 12px;
  padding: 12px 24px;
  background: #fff;
  color: #333;
  border: none;
  border-radius: 8px;
  font-size: 16px;
  font-weight: 500;
  cursor: pointer;
  transition: all 0.3s ease;
}

.google-btn:hover {
  background: #f5f5f5;
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.15);
  transform: translateY(-2px);
}

.google-btn svg {
  flex-shrink: 0;
}

/* 로그인 구분선 */
.login-divider {
  display: flex;
  align-items: center;
  gap: 15px;
  margin: 10px 0;
  color: rgba(255, 255, 255, 0.5);
}

.login-divider::before,
.login-divider::after {
  content: '';
  flex: 1;
  height: 1px;
  background: rgba(255, 255, 255, 0.2);
}

/* 자동 로그인 상태 */
.auto-login-status {
  font-size: 14px;
  color: #667eea;
  min-height: 20px;
}

/* 모드 선택 화면 푸터 버튼 */
.mode-footer-buttons {
  display: flex;
  justify-content: center;
  align-items: center;
  gap: 15px;
  margin-top: 20px;
}

.mode-footer-buttons .btn {
  width: 120px;
  height: 40px;
  text-align: center;
  display: flex;
  align-items: center;
  justify-content: center;
}

/* 설정 모달 */
.settings-content {
  min-width: 400px;
  text-align: left;
}

.settings-section {
  margin-bottom: 25px;
  padding-bottom: 20px;
  border-bottom: 1px solid rgba(255, 255, 255, 0.1);
}

.settings-section:last-of-type {
  border-bottom: none;
  margin-bottom: 0;
  padding-bottom: 0;
}

.settings-section h4 {
  font-size: 16px;
  color: #667eea;
  margin-bottom: 15px;
}

.settings-item {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 10px 0;
}

.settings-label {
  color: rgba(255, 255, 255, 0.7);
}

.settings-value {
  color: #fff;
  font-weight: 500;
}

.uuid-value {
  font-family: monospace;
  font-size: 12px;
  color: rgba(255, 255, 255, 0.5);
  word-break: break-all;
  max-width: 200px;
  text-align: right;
}

.settings-hint {
  font-size: 12px;
  color: rgba(255, 255, 255, 0.5);
  margin-top: 10px;
  line-height: 1.5;
}

/* 구글 연동 상태 */
.google-link-status {
  font-size: 14px;
  margin-bottom: 15px;
}

.google-link-status.linked {
  color: #38ef7d;
}

.google-link-status.not-linked {
  color: rgba(255, 255, 255, 0.5);
}

#google-link-section {
  display: flex;
  flex-direction: column;
  gap: 10px;
}

#google-link-btn {
  width: 100%;
}

#google-unlink-btn {
  align-self: flex-start;
}

/* Danger Zone - 회원탈퇴 */
.danger-zone {
  border-color: rgba(245, 87, 108, 0.3) !important;
  background: rgba(245, 87, 108, 0.05);
  border-radius: 8px;
  padding: 15px !important;
  margin-top: 10px;
}

.danger-zone h4 {
  color: #f5576c !important;
}

.danger-hint {
  color: rgba(245, 87, 108, 0.8) !important;
}

#delete-account-btn {
  margin-top: 10px;
  width: 100%;
}

/* 회원탈퇴 확인 모달 */
#delete-account-modal .modal-content {
  max-width: 400px;
}

.delete-warning {
  color: #f5576c;
  font-weight: 500;
  margin-bottom: 15px;
  font-size: 16px;
}

.delete-info {
  color: rgba(255, 255, 255, 0.7);
  font-size: 14px;
  margin-bottom: 10px;
}

.delete-list {
  list-style: none;
  margin-bottom: 20px;
}

.delete-list li {
  padding: 8px 0;
  padding-left: 20px;
  position: relative;
  color: rgba(255, 255, 255, 0.6);
  font-size: 14px;
}

.delete-list li::before {
  content: "•";
  position: absolute;
  left: 0;
  color: #f5576c;
}

#delete-account-modal .modal-buttons {
  display: flex;
  gap: 10px;
}

#delete-account-modal .btn {
  flex: 1;
}

/* 구글 닉네임 모달 */
#google-nickname-input {
  width: 100%;
  padding: 12px 16px;
  border: 2px solid #4a4a6a;
  border-radius: 8px;
  font-size: 16px;
  background: rgba(255, 255, 255, 0.1);
  color: #fff;
  outline: none;
  transition: border-color 0.3s;
  margin-bottom: 10px;
}

#google-nickname-input:focus {
  border-color: #667eea;
}

#google-nickname-input::placeholder {
  color: rgba(255, 255, 255, 0.5);
}

.google-email-display {
  font-size: 14px;
  color: rgba(255, 255, 255, 0.5);
  margin-bottom: 15px;
}

/* 토스트 알림 */
.toast {
  position: fixed;
  bottom: 30px;
  left: 50%;
  transform: translateX(-50%) translateY(100px);
  background: rgba(0, 0, 0, 0.85);
  color: #fff;
  padding: 14px 28px;
  border-radius: 8px;
  font-size: 14px;
  font-weight: 500;
  box-shadow: 0 4px 20px rgba(0, 0, 0, 0.3);
  opacity: 0;
  visibility: hidden;
  transition: all 0.3s ease;
  z-index: 2000;
}

.toast.show {
  transform: translateX(-50%) translateY(0);
  opacity: 1;
  visibility: visible;
}

/* 반응형 */
@media (max-width: 768px) {
  .lobby-content {
    grid-template-columns: 1fr;
  }

  #game-board {
    width: 100%;
    max-width: 400px;
    height: auto;
  }

  .game-header {
    flex-direction: column;
    gap: 10px;
  }

  .settings-content {
    min-width: auto;
    width: 90vw;
    max-width: 400px;
  }

  .mode-buttons {
    flex-direction: column;
    align-items: center;
  }

  .mode-btn {
    width: 100%;
    max-width: 250px;
  }

  .difficulty-options {
    flex-direction: column;
    align-items: center;
  }

  .difficulty-btn {
    width: 100%;
    max-width: 200px;
  }

  .mode-footer-buttons {
    flex-direction: column;
    align-items: center;
  }

  .language-options {
    grid-template-columns: 1fr;
    max-width: 250px;
  }

  .language-btn {
    padding: 20px 15px;
  }

  .lang-flag {
    font-size: 32px;
  }

  .lang-name {
    font-size: 16px;
  }

  .section-header {
    flex-direction: column;
    gap: 10px;
    align-items: flex-start;
  }

  .btn.invite {
    width: 100%;
    justify-content: center;
  }
}
