/* CSS 변수 정의 */
:root {
  --primary-color: #3498db;
  --primary-hover: #00bfff;
  --background-dark: #141414;
  --background-darker: #0a0a0a;
  --text-light: #ffffff;
  --border-radius: 15px;
  --transition: all 0.3s ease;
  --shadow: 0 0.5rem 1rem rgba(0, 0, 0, 0.1);
  --shadow-hover: 0 1rem 3rem rgba(0, 0, 0, 0.4);
}

/* 전체 페이지 스타일 */
body,
#page,
.site-content {
  background: linear-gradient(
    135deg,
    var(--background-dark) 0%,
    var(--background-darker) 100%
  ) !important;
  color: var(--text-light) !important;
  min-height: 100vh;
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
}

/* 콘텐츠 영역 스타일 */
.site-content .container,
.entry-content .container,
.post-content .container,
.page-content .container,
.container {
  max-width: 860px !important;
  width: 100% !important;
  background-color: var(--background-dark) !important;
  margin: 0 auto;
}

/* 카드 스타일 */
#bdsm-app .card,
#bdsm-app #start-screen {
  background-color: var(--background-dark) !important;
  border: none !important;
  color: var(--text-light) !important;
  box-shadow: var(--shadow) !important;
  margin-bottom: 1.5rem !important;
  border-radius: var(--border-radius) !important;
  transition: var(--transition);
}

/* 모바일에서 카드 패딩 조정 */
@media (max-width: 768px) {
  #bdsm-app .card,
  #bdsm-app #start-screen {
    margin-bottom: 1rem !important;
  }
}

.bdsm-card-body {
  background: rgba(40, 40, 50, 0.7) !important;
  border-radius: var(--border-radius);
  color: var(--text-light) !important;
}

/* 버튼 스타일 */
.btn-primary,
#start-btn {
  background-color: var(--primary-color) !important;
  border-color: var(--primary-color) !important;
  font-size: 1.2rem;
  padding: 0.75rem 1.5rem;
  transition: var(--transition);
  border-radius: var(--border-radius);
  min-height: 44px; /* 터치 친화적 */
  display: flex;
  align-items: center;
  justify-content: center;
}

.btn-primary:hover,
#start-btn:hover {
  background-color: var(--primary-hover) !important;
  border-color: var(--primary-hover) !important;
  transform: translateY(-2px);
  box-shadow: 0 0.5rem 1rem rgba(0, 191, 255, 0.2);
}

/* 모바일에서 버튼 크기 조정 */
@media (max-width: 768px) {
  .btn-primary,
  #start-btn {
    font-size: 1.1rem;
    padding: 1rem 1.5rem;
    min-height: 48px;
  }
}

/* 프로그레스 바 스타일 */
#bdsm-app .progress-container {
  position: fixed !important;
  top: 0 !important;
  left: 0 !important;
  width: 100% !important;
  z-index: 1000 !important;
  background: rgba(0, 0, 0, 0.1);
  backdrop-filter: blur(10px);
}

#bdsm-app .progress {
  height: 8px;
  border-radius: 0;
  background-color: rgba(255, 255, 255, 0.1);
}

#bdsm-app .progress-bar {
  background: linear-gradient(
    90deg,
    var(--primary-color),
    var(--primary-hover)
  );
  transition: width 0.3s ease;
}

/* 시작 화면 특별 스타일 */
#bdsm-app #start-screen {
  animation: fadeIn 1s ease-out;
}

#bdsm-app #start-screen:hover {
  transform: translateY(-5px);
  box-shadow: var(--shadow-hover);
}

/* 타이포그래피 */
h1,
h2,
h3 {
  color: var(--text-light) !important;
  margin-top: 15px !important;
}

#bdsm-app #start-screen h1 {
  font-size: clamp(2rem, 5vw, 2.5rem);
  margin-bottom: 1.5rem;
  text-shadow: 2px 2px 4px rgba(0, 0, 0, 0.5);
}

#bdsm-app #start-screen .lead {
  font-size: clamp(1rem, 3vw, 1.2rem);
  line-height: 1.6;
}

#bdsm-app #start-screen h2 {
  font-size: clamp(1.5rem, 4vw, 1.8rem);
  margin-top: 2rem;
  margin-bottom: 1rem;
  color: var(--primary-color);
}

/* 리스트 스타일 */
#bdsm-app #start-screen ul {
  list-style-type: none;
  padding-left: 0;
}

#bdsm-app #start-screen ul li {
  margin-bottom: 0.8rem;
  padding-left: 1.5rem;
  position: relative;
  line-height: 1.5;
}

#bdsm-app #start-screen ul li::before {
  content: '•';
  color: var(--primary-color);
  font-size: 1.5em;
  position: absolute;
  left: 0;
  top: -0.2rem;
}

/* 질문 스타일 */
#bdsm-app .question-container {
  background: rgba(40, 40, 50, 0.7);
  border-radius: var(--border-radius);
  margin-bottom: 1.5rem;
  border: 1px solid rgba(120, 120, 140, 0.12);
  transition: var(--transition);
  padding: 1.2rem;
}

#bdsm-app .question-container:hover {
  background: rgba(255, 255, 255, 0.08);
  border-color: rgba(255, 255, 255, 0.2);
}

#bdsm-app .question-text {
  font-size: 1.1rem;
  font-weight: 500;
  line-height: 1.5;
  margin-bottom: 1.5rem;
  color: #e0e0e0;
}

#bdsm-app .question-number {
  display: inline-block;
  background: var(--primary-color);
  color: white;
  width: 28px;
  height: 28px;
  border-radius: 50%;
  text-align: center;
  line-height: 28px;
  font-size: 0.9rem;
  font-weight: bold;
  margin-right: 0.8rem;
}

/* 답변 옵션 스타일 */
#bdsm-app .answer-options {
  display: grid;
  grid-template-columns: repeat(5, minmax(0, 1fr));
  gap: 0.8rem;
  margin-top: 1rem;
}

#bdsm-app .answer-option {
  position: relative;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  min-height: 80px;
  padding: 1rem 0.5rem;
  background: rgba(255, 255, 255, 0.05);
  border: 2px solid rgba(255, 255, 255, 0.1);
  border-radius: var(--border-radius);
  cursor: pointer;
  transition: var(--transition);
  text-align: center;
  overflow: hidden;
}

#bdsm-app .answer-option:hover {
  background: rgba(255, 255, 255, 0.1);
  border-color: var(--primary-color);
  transform: translateY(-2px);
}

#bdsm-app .answer-option input[type='radio'] {
  position: absolute;
  opacity: 0;
  cursor: pointer;
}

/* 선택 전: border, 배경 모두 없음 */
#bdsm-app .answer-option label {
  position: absolute;
  inset: 0;
  z-index: 1;
  width: 100%;
  height: 100%;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  font-weight: 500;
  transition: var(--transition);
  background: transparent;
  border-radius: var(--border-radius);
  border: none;
  box-shadow: none;
  padding: 0;
  min-height: 60px;
  white-space: normal;
  word-break: keep-all;
  text-align: center;
}

/* 마우스 오버 시 살짝 강조 (연보라/연회색) */
#bdsm-app .answer-option label:hover {
  background: rgba(80, 60, 120, 0.1);
  color: #fff;
  box-shadow: 0 0 0 2px #b39ddb33;
}

/* 선택 시: 바나나 이모지로 버튼 전체 꽉 채우기, border 없음, padding 최소화, 텍스트만 노랑 */
#bdsm-app .answer-option input[type='radio']:checked + label {
  background: url('data:image/svg+xml;utf8,<svg xmlns="http://www.w3.org/2000/svg" width="32" height="32"><text y="24" font-size="28">🍌</text></svg>');
  background-size: 32px 32px;
  background-repeat: repeat;
  border: none;
  color: #ffe066;
  font-weight: bold;
  animation: banana-pop 0.4s cubic-bezier(0.68, -0.55, 0.27, 1.55);
  box-shadow: 0 0.5rem 1rem rgba(255, 193, 7, 0.15);
  padding: 0;
}

/* 선택 시 텍스트 숨기기 (바나나만 보이게) */
#bdsm-app .answer-option input[type='radio']:checked + label .answer-number,
#bdsm-app .answer-option input[type='radio']:checked + label .answer-text {
  opacity: 0;
}

/* 선택 전에는 텍스트 보이게 */
#bdsm-app .answer-option label .answer-number,
#bdsm-app .answer-option label .answer-text {
  z-index: 2;
  position: relative;
  opacity: 1;
  transition: opacity 0.2s;
}

#bdsm-app .answer-number {
  font-size: 1.5rem;
  font-weight: bold;
  margin-bottom: 0.3rem;
}

#bdsm-app .answer-text {
  font-size: 0.8rem;
  line-height: 1.2;
  opacity: 0.9;
  white-space: normal;
  word-break: keep-all;
  text-align: center;
  overflow-wrap: break-word;
}

/* 모바일 최적화 */
@media (max-width: 768px) {
  #bdsm-app .question-container {
    padding: 1.2rem;
    margin-bottom: 1rem;
  }

  #bdsm-app .question-text {
    font-size: 1rem;
    margin-bottom: 1.2rem;
  }

  #bdsm-app .answer-options {
    grid-template-columns: repeat(5, minmax(0, 1fr));
    gap: 0.5rem;
  }

  #bdsm-app .answer-option {
    min-height: 70px;
    padding: 0.8rem 0.3rem;
  }

  #bdsm-app .answer-number {
    font-size: 1.3rem;
    margin-bottom: 0.2rem;
  }

  #bdsm-app .answer-text {
    font-size: 0.7rem;
  }
}

/* 매우 작은 화면 */
@media (max-width: 480px) {
  #bdsm-app .answer-options {
    grid-template-columns: repeat(5, minmax(0, 1fr));
    gap: 0.3rem;
  }

  #bdsm-app .answer-option {
    min-height: 60px;
    padding: 0.6rem 0.2rem;
  }

  #bdsm-app .answer-number {
    font-size: 1.2rem;
  }

  #bdsm-app .answer-text {
    font-size: 0.65rem;
  }
}

/* 체크된 버튼 스타일 (기존 호환성) */
.btn-check:checked + .btn-outline-secondary {
  background-color: #320064;
  border-color: var(--primary-hover);
  color: white;
  transform: scale(1.05);
}

/* 결과 차트 스타일 */
#resultChart {
  max-height: 400px;
  margin: 2rem 0;
}

/* 등급 스타일 */
.grade {
  font-weight: bold;
  padding: 4px 8px;
  border-radius: 6px;
  font-size: 0.9rem;
}

.grade-very-low {
  background-color: #f8d7da;
  color: #721c24;
}
.grade-low {
  background-color: #fff3cd;
  color: #856404;
}
.grade-medium {
  background-color: #d4edda;
  color: #155724;
}
.grade-high {
  background-color: #cce5ff;
  color: #004085;
}
.grade-very-high {
  background-color: #d1ecf1;
  color: #0c5460;
}

/* 체크되지 않은 항목 스타일 */
.unchecked {
  border: 2px solid #dc3545 !important;
  border-radius: var(--border-radius);
  animation: shake 0.5s ease-in-out;
  background: rgba(220, 53, 69, 0.1) !important;
}

@keyframes shake {
  0%,
  100% {
    transform: translateX(0);
  }
  25% {
    transform: translateX(-5px);
  }
  75% {
    transform: translateX(5px);
  }
}

/* 워드프레스 관리자 바 조정 */
body.admin-bar #bdsm-app .progress-container {
  top: 32px !important;
}

/* 애니메이션 */
@keyframes fadeIn {
  from {
    opacity: 0;
    transform: translateY(20px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

/* 로딩 상태 */
.loading {
  opacity: 0.7;
  pointer-events: none;
}

/* 포커스 상태 개선 */
.btn:focus,
.btn-check:focus + .btn,
.answer-option:focus-within {
  outline: 2px solid var(--primary-hover);
  outline-offset: 2px;
}

/* 미디어 쿼리 */
@media screen and (max-width: 782px) {
  body.admin-bar #bdsm-app .progress-container {
    top: 46px !important;
  }
}

@media (max-width: 768px) {
  .site-content .container,
  .entry-content .container,
  .post-content .container,
  .page-content .container {
    padding: 0 2px !important;
  }

  /* 모바일에서 더 나은 간격 */
  .mb-4 {
    margin-bottom: 1rem !important;
  }

  .mt-4 {
    margin-top: 1rem !important;
  }

  /* 모바일에서 이미지 최적화 */
  img {
    max-width: 100%;
    height: auto;
  }
}

/* 다크 모드 지원 */
@media (prefers-color-scheme: dark) {
  :root {
    --background-dark: #0a0a0a;
    --background-darker: #000000;
  }
}

/* 고대비 모드 지원 */
@media (prefers-contrast: high) {
  :root {
    --primary-color: #00bfff;
    --primary-hover: #ffffff;
  }
}

/* 결과 리스트 flex-row 개선 */
#bdsm-app .result-row {
  display: flex;
  flex-wrap: nowrap;
  align-items: center;
  justify-content: space-between;
  gap: 0.5rem;
}

#bdsm-app .result-row .grade {
  white-space: nowrap;
  flex-shrink: 0;
  margin-left: 0.3em;
}

#bdsm-app .result-row .result-value {
  display: flex;
  align-items: center;
  gap: 0.2em;
  min-width: 90px;
  flex-shrink: 0;
  overflow: visible;
  font-variant-numeric: tabular-nums;
}

@media (max-width: 480px) {
  #bdsm-app .result-row {
    font-size: 0.95em;
    gap: 0.2rem;
  }
  #bdsm-app .result-row .result-value {
    min-width: 70px;
    font-size: 0.95em;
  }
}
