/* ==========================================================================
   방장.net (Bangjang.net) 메인 스타일시트
   - 확장 가능한 디자인 토큰 (CSS 변수)
   - 다크 & 인디고 골드 글래스모피즘 테마
   - 모바일 우선 반응형 레이아웃
   ========================================================================== */

/* --- 1. 디자인 토큰 및 테마 변수 설정 --- */
:root {
  /* 메인 브랜드 컬러 (인디고 & 골드 톤) */
  --primary: #6366f1;
  --primary-hover: #4f46e5;
  --primary-light: rgba(99, 102, 241, 0.15);
  --accent-gold: #f59e0b;
  --accent-gold-hover: #d97706;
  --accent-emerald: #10b981;
  --accent-rose: #f43f5e;

  /* 다크 배경 및 표면 컬러 */
  --bg-dark: #0f172a;
  --bg-darker: #090d16;
  --card-bg: rgba(30, 41, 59, 0.7);
  --card-border: rgba(255, 255, 255, 0.08);
  --card-hover-border: rgba(99, 102, 241, 0.4);

  /* 텍스트 컬러 */
  --text-main: #f8fafc;
  --text-muted: #94a3b8;
  --text-sub: #64748b;

  /* 글래스모피즘 효과 */
  --glass-blur: blur(12px);
  --glass-shadow: 0 8px 32px 0 rgba(0, 0, 0, 0.37);

  /* 인터랙션 & 둥글기 */
  --radius-sm: 8px;
  --radius-md: 14px;
  --radius-lg: 20px;
  --radius-full: 9999px;
  --transition-fast: 0.2s cubic-bezier(0.4, 0, 0.2, 1);
  --transition-smooth: 0.3s cubic-bezier(0.4, 0, 0.2, 1);
}

/* --- 2. 기본 리셋 및 글로벌 스타일 --- */
* {
  margin: 0;
  padding: 0;
  box-sizing: border-box;
  -webkit-tap-highlight-color: transparent;
}

body {
  font-family: 'Pretendard', -apple-system, BlinkMacSystemFont, system-ui, Roboto, 'Helvetica Neue', 'Segoe UI', 'Apple SD Gothic Neo', 'Noto Sans KR', 'Malgun Gothic', sans-serif;
  background-color: var(--bg-dark);
  color: var(--text-main);
  line-height: 1.6;
  min-height: 100vh;
  display: flex;
  flex-direction: column;
  background-image: 
    radial-gradient(circle at 15% 15%, rgba(99, 102, 241, 0.12) 0%, transparent 40%),
    radial-gradient(circle at 85% 85%, rgba(245, 158, 11, 0.08) 0%, transparent 40%);
  background-attachment: fixed;
}

/* 스크롤바 커스텀 */
::-webkit-scrollbar {
  width: 8px;
  height: 8px;
}
::-webkit-scrollbar-track {
  background: var(--bg-darker);
}
::-webkit-scrollbar-thumb {
  background: #334155;
  border-radius: var(--radius-full);
}
::-webkit-scrollbar-thumb:hover {
  background: var(--primary);
}

/* --- 3. 헤더 및 상단 네비게이션 --- */
.header {
  position: sticky;
  top: 0;
  z-index: 100;
  backdrop-filter: var(--glass-blur);
  -webkit-backdrop-filter: var(--glass-blur);
  background: rgba(15, 23, 42, 0.85);
  border-bottom: 1px solid var(--card-border);
}

.header-container {
  max-width: 1200px;
  margin: 0 auto;
  padding: 0.85rem 1.25rem;
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.brand-logo {
  display: flex;
  align-items: center;
  gap: 0.6rem;
  text-decoration: none;
  color: var(--text-main);
  font-size: 1.35rem;
  font-weight: 800;
  letter-spacing: -0.02em;
}

.brand-badge {
  background: linear-gradient(135deg, var(--accent-gold), #fbbf24);
  color: #1e1b4b;
  font-size: 0.72rem;
  font-weight: 900;
  padding: 0.2rem 0.5rem;
  border-radius: var(--radius-sm);
  text-transform: uppercase;
  box-shadow: 0 0 12px rgba(245, 158, 11, 0.4);
}

.header-tagline {
  font-size: 0.85rem;
  color: var(--text-muted);
  display: none;
}

@media (min-width: 768px) {
  .header-tagline {
    display: inline-block;
  }
}

/* 확장 가능한 탭 네비게이션 바 (가로 스크롤 지원) */
.nav-tab-container {
  background: rgba(15, 23, 42, 0.6);
  border-bottom: 1px solid var(--card-border);
  padding: 0.5rem 1.25rem;
  overflow-x: auto;
  white-space: nowrap;
}

.nav-tabs {
  max-width: 1200px;
  margin: 0 auto;
  display: flex;
  gap: 0.5rem;
  list-style: none;
}

.nav-tab-btn {
  background: transparent;
  border: 1px solid transparent;
  color: var(--text-muted);
  font-size: 0.95rem;
  font-weight: 600;
  padding: 0.55rem 1rem;
  border-radius: var(--radius-md);
  cursor: pointer;
  display: flex;
  align-items: center;
  gap: 0.45rem;
  transition: var(--transition-fast);
}

.nav-tab-btn:hover {
  color: var(--text-main);
  background: rgba(255, 255, 255, 0.05);
}

.nav-tab-btn.active {
  color: #ffffff;
  background: var(--primary);
  border-color: rgba(255, 255, 255, 0.2);
  box-shadow: 0 4px 14px rgba(99, 102, 241, 0.4);
}

.nav-tab-btn .badge-new {
  font-size: 0.65rem;
  background: var(--accent-rose);
  color: white;
  padding: 0.1rem 0.35rem;
  border-radius: var(--radius-full);
}

/* --- 4. 메인 컨테이너 및 탭 콘텐츠 관리 --- */
.main-wrapper {
  max-width: 1200px;
  width: 100%;
  margin: 0 auto;
  padding: 1.5rem 1.25rem 3rem;
  flex: 1;
}

/* 탭 패널 (선택된 탭만 활성화) */
.tab-panel {
  display: none;
  animation: fadeIn 0.35s cubic-bezier(0.16, 1, 0.3, 1);
}

.tab-panel.active {
  display: block;
}

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

/* 섹션 타이틀 공통 */
.section-header {
  margin-bottom: 1.75rem;
}

.section-title {
  font-size: 1.6rem;
  font-weight: 800;
  letter-spacing: -0.02em;
  display: flex;
  align-items: center;
  gap: 0.6rem;
}

.section-desc {
  color: var(--text-muted);
  font-size: 0.95rem;
  margin-top: 0.3rem;
}

/* --- 5. 그리드 및 글래스 카드 레이아웃 --- */
.grid-2col {
  display: grid;
  grid-template-columns: 1fr;
  gap: 1.5rem;
}

@media (min-width: 900px) {
  .grid-2col {
    grid-template-columns: 1fr 1fr;
  }
}

.glass-card {
  background: var(--card-bg);
  border: 1px solid var(--card-border);
  backdrop-filter: var(--glass-blur);
  -webkit-backdrop-filter: var(--glass-blur);
  border-radius: var(--radius-lg);
  padding: 1.5rem;
  box-shadow: var(--glass-shadow);
  transition: var(--transition-smooth);
}

.glass-card:hover {
  border-color: var(--card-hover-border);
}

.card-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 1.25rem;
  padding-bottom: 0.75rem;
  border-bottom: 1px solid rgba(255, 255, 255, 0.06);
}

.card-title {
  font-size: 1.15rem;
  font-weight: 700;
  display: flex;
  align-items: center;
  gap: 0.5rem;
}

/* --- 6. 폼 컨트롤 및 입력 필드 --- */
.form-group {
  margin-bottom: 1.2rem;
}

.form-label {
  display: block;
  font-size: 0.88rem;
  font-weight: 600;
  color: var(--text-muted);
  margin-bottom: 0.45rem;
}

.form-input,
.form-select,
.form-textarea {
  width: 100%;
  background: rgba(15, 23, 42, 0.8);
  border: 1px solid rgba(255, 255, 255, 0.12);
  border-radius: var(--radius-md);
  color: var(--text-main);
  font-size: 0.95rem;
  padding: 0.75rem 0.95rem;
  font-family: inherit;
  transition: var(--transition-fast);
}

.form-input:focus,
.form-select:focus,
.form-textarea:focus {
  outline: none;
  border-color: var(--primary);
  box-shadow: 0 0 0 3px rgba(99, 102, 241, 0.25);
  background: rgba(15, 23, 42, 0.95);
}

.form-textarea {
  resize: vertical;
  min-height: 110px;
}

/* 폼 인라인 헬퍼 */
.form-row {
  display: flex;
  gap: 0.75rem;
  align-items: center;
}

/* --- 7. 버튼 디자인 --- */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 0.5rem;
  font-weight: 700;
  font-size: 0.95rem;
  padding: 0.75rem 1.25rem;
  border-radius: var(--radius-md);
  border: none;
  cursor: pointer;
  transition: var(--transition-fast);
  text-decoration: none;
}

.btn-primary {
  background: linear-gradient(135deg, var(--primary), #4f46e5);
  color: #ffffff;
  box-shadow: 0 4px 14px rgba(99, 102, 241, 0.35);
}

.btn-primary:hover {
  transform: translateY(-2px);
  box-shadow: 0 6px 20px rgba(99, 102, 241, 0.5);
}

.btn-gold {
  background: linear-gradient(135deg, var(--accent-gold), #d97706);
  color: #1e1b4b;
  font-weight: 800;
  box-shadow: 0 4px 14px rgba(245, 158, 11, 0.3);
}

.btn-gold:hover {
  transform: translateY(-2px);
  box-shadow: 0 6px 20px rgba(245, 158, 11, 0.45);
}

.btn-secondary {
  background: rgba(255, 255, 255, 0.08);
  color: var(--text-main);
  border: 1px solid rgba(255, 255, 255, 0.12);
}

.btn-secondary:hover {
  background: rgba(255, 255, 255, 0.15);
}

.btn-danger-outline {
  background: transparent;
  color: var(--accent-rose);
  border: 1px solid rgba(244, 63, 94, 0.3);
}

.btn-danger-outline:hover {
  background: rgba(244, 63, 94, 0.15);
}

.btn-block {
  width: 100%;
}

.btn-sm {
  padding: 0.45rem 0.75rem;
  font-size: 0.85rem;
  border-radius: var(--radius-sm);
}

/* --- 8. 미리보기 및 카카오톡 스타일 박스 --- */
.preview-box {
  background: #182234;
  border: 1px solid rgba(99, 102, 241, 0.2);
  border-radius: var(--radius-md);
  padding: 1.2rem;
  white-space: pre-wrap;
  font-family: 'Consolas', 'Pretendard', monospace;
  font-size: 0.92rem;
  color: #e2e8f0;
  line-height: 1.7;
  max-height: 480px;
  overflow-y: auto;
  position: relative;
}

.kakao-preview-card {
  background: #fee500;
  color: #191919;
  border-radius: 16px;
  padding: 1.25rem;
  font-family: -apple-system, BlinkMacSystemFont, 'Apple SD Gothic Neo', sans-serif;
  box-shadow: 0 8px 24px rgba(0, 0, 0, 0.2);
  position: relative;
}

.kakao-preview-card .kakao-header {
  font-weight: 800;
  font-size: 1.05rem;
  border-bottom: 1px dashed rgba(0, 0, 0, 0.15);
  padding-bottom: 0.5rem;
  margin-bottom: 0.75rem;
}

.kakao-preview-card .kakao-body {
  font-size: 0.95rem;
  white-space: pre-wrap;
  line-height: 1.6;
}

/* --- 9. 미니 게임 (룰렛, 팀나누기, 사다리타기) 스타일 --- */
.game-container {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 1.25rem;
}

.canvas-wrapper {
  position: relative;
  width: 320px;
  height: 320px;
  max-width: 100%;
}

@media (min-width: 480px) {
  .canvas-wrapper {
    width: 360px;
    height: 360px;
  }
}

#rouletteCanvas {
  width: 100%;
  height: 100%;
  border-radius: 50%;
  box-shadow: 0 0 30px rgba(99, 102, 241, 0.3);
}

.roulette-arrow {
  position: absolute;
  top: -12px;
  left: 50%;
  transform: translateX(-50%);
  width: 0;
  height: 0;
  border-left: 15px solid transparent;
  border-right: 15px solid transparent;
  border-top: 26px solid var(--accent-rose);
  z-index: 10;
  filter: drop-shadow(0 2px 4px rgba(0, 0, 0, 0.4));
}

.result-banner {
  background: linear-gradient(135deg, rgba(99, 102, 241, 0.25), rgba(245, 158, 11, 0.25));
  border: 1px solid rgba(255, 255, 255, 0.15);
  border-radius: var(--radius-md);
  padding: 1rem 1.5rem;
  text-align: center;
  width: 100%;
  font-size: 1.25rem;
  font-weight: 800;
  color: var(--accent-gold);
  animation: pulse 2s infinite;
}

@keyframes pulse {
  0%, 100% { transform: scale(1); }
  50% { transform: scale(1.02); }
}

/* 팀 셔플 결과 카드 그리드 */
.team-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
  gap: 1rem;
  width: 100%;
  margin-top: 1rem;
}

.team-card {
  background: rgba(15, 23, 42, 0.85);
  border: 1px solid var(--card-border);
  border-radius: var(--radius-md);
  padding: 1rem;
}

.team-card-header {
  font-weight: 800;
  color: var(--accent-gold);
  border-bottom: 1px solid rgba(255, 255, 255, 0.1);
  padding-bottom: 0.4rem;
  margin-bottom: 0.6rem;
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.team-member-list {
  list-style: none;
  font-size: 0.92rem;
}

.team-member-item {
  padding: 0.3rem 0;
  color: var(--text-main);
  border-bottom: 1px dashed rgba(255, 255, 255, 0.04);
}

/* 정산 목록 테이블/리스트 */
.split-item-list {
  display: flex;
  flex-direction: column;
  gap: 0.75rem;
  margin-bottom: 1rem;
}

.split-item-row {
  display: flex;
  gap: 0.5rem;
  align-items: center;
  background: rgba(15, 23, 42, 0.6);
  padding: 0.5rem 0.75rem;
  border-radius: var(--radius-sm);
  border: 1px solid rgba(255, 255, 255, 0.05);
}

/* --- 10. 토스트 알림 (Toast Notification) --- */
.toast-container {
  position: fixed;
  bottom: 24px;
  right: 24px;
  z-index: 1000;
  display: flex;
  flex-direction: column;
  gap: 10px;
  pointer-events: none;
}

.toast {
  background: rgba(15, 23, 42, 0.95);
  backdrop-filter: var(--glass-blur);
  border: 1px solid var(--primary);
  color: #ffffff;
  padding: 0.85rem 1.4rem;
  border-radius: var(--radius-md);
  box-shadow: 0 10px 30px rgba(0, 0, 0, 0.5);
  display: flex;
  align-items: center;
  gap: 0.75rem;
  font-weight: 600;
  font-size: 0.92rem;
  animation: slideInRight 0.3s ease, fadeOut 0.3s ease 2.7s forwards;
  pointer-events: auto;
}

@keyframes slideInRight {
  from {
    transform: translateX(100%);
    opacity: 0;
  }
  to {
    transform: translateX(0);
    opacity: 1;
  }
}

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

/* --- 11. 확장 슬롯 (Coming Soon 카드 & 전체 허브) --- */
.hub-card-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
  gap: 1.25rem;
}

.hub-card {
  background: var(--card-bg);
  border: 1px solid var(--card-border);
  border-radius: var(--radius-lg);
  padding: 1.5rem;
  cursor: pointer;
  transition: var(--transition-smooth);
  display: flex;
  flex-direction: column;
  justify-content: space-between;
  text-decoration: none;
  color: inherit;
}

.hub-card:hover {
  transform: translateY(-4px);
  border-color: var(--primary);
  box-shadow: 0 12px 24px rgba(99, 102, 241, 0.2);
}

.hub-card-icon {
  font-size: 2.2rem;
  margin-bottom: 0.85rem;
}

.hub-card-title {
  font-size: 1.2rem;
  font-weight: 700;
  margin-bottom: 0.4rem;
}

.hub-card-desc {
  font-size: 0.88rem;
  color: var(--text-muted);
  line-height: 1.5;
  margin-bottom: 1rem;
}

.hub-card-footer {
  display: flex;
  align-items: center;
  justify-content: space-between;
  font-size: 0.85rem;
  font-weight: 700;
  color: var(--primary);
}

.hub-card.locked {
  opacity: 0.65;
  cursor: default;
  border-style: dashed;
}

.hub-card.locked:hover {
  transform: none;
  border-color: var(--card-border);
  box-shadow: none;
}

/* --- 12. 사다리 타기 캔버스 --- */
#ladderCanvas {
  width: 100%;
  max-width: 600px;
  background: rgba(15, 23, 42, 0.9);
  border-radius: var(--radius-md);
  border: 1px solid var(--card-border);
}

/* --- 13. 푸터 --- */
.footer {
  border-top: 1px solid var(--card-border);
  padding: 2rem 1.25rem;
  text-align: center;
  font-size: 0.85rem;
  color: var(--text-sub);
  margin-top: auto;
  background: rgba(9, 13, 22, 0.9);
}

.footer-brand {
  font-weight: 700;
  color: var(--text-muted);
  margin-bottom: 0.3rem;
}

/* --- 14. 모달 오버레이 및 뷰어 팝업 --- */
.modal-overlay {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  background: rgba(0, 0, 0, 0.75);
  backdrop-filter: blur(8px);
  -webkit-backdrop-filter: blur(8px);
  z-index: 1000;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 1.25rem;
  overflow-y: auto;
  animation: fadeIn 0.25s ease;
}

.modal-container {
  width: 100%;
  max-width: 520px;
  max-height: 90vh;
  overflow-y: auto;
  margin: auto;
}

/* --- 15. 구글 애드센스 배너 영역 --- */
.adsense-slot {
  width: 100%;
  margin: 1.5rem auto;
  text-align: center;
  display: flex;
  justify-content: center;
}

.adsense-placeholder {
  width: 100%;
  max-width: 970px;
  min-height: 90px;
  background: rgba(15, 23, 42, 0.5);
  border: 1px dashed rgba(255, 255, 255, 0.1);
  border-radius: var(--radius-md);
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--text-sub);
  font-size: 0.82rem;
  padding: 0.5rem;
}
