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

html, body {
  width: 100%;
  height: 100%;
  font-family: -apple-system, BlinkMacSystemFont, 'Noto Sans KR', 'Segoe UI', sans-serif;
  background: #f2f2f2;
  color: #2A2A2A;
  overflow: hidden;
  -webkit-font-smoothing: antialiased;
}

.screen { width: 100vw; height: 100vh; position: absolute; inset: 0; }
.hidden { display: none !important; }

/* ═══════════════════════════════════════════
   커스터마이징 화면
═══════════════════════════════════════════ */
#customize-screen {
  display: flex;
  flex-direction: column;
  background: #f2f2f2;
}

/* ── 상단 헤더 ── */
.customize-header {
  height: 48px;
  display: flex;
  align-items: center;
  padding: 0 28px;
  border-bottom: 1px solid rgba(0,0,0,0.07);
  flex-shrink: 0;
}
.game-title {
  font-size: 13px;
  font-weight: 500;
  color: rgba(0,0,0,0.55);
  letter-spacing: 0.5px;
}

/* ── 메인 레이아웃 ── */
.customize-layout {
  flex: 1;
  display: flex;
  overflow: hidden;
  min-height: 0;
  padding: 24px 32px;
  gap: 28px;
}

/* ── 왼쪽: 미리보기 ── */
/* preview-panel: 45%로 확대 */
.preview-panel {
  flex: 0 0 45%;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 20px 14px 20px 20px;
  border-right: 1px solid rgba(0,0,0,0.12);
}

/* preview-aspect: padding-top 비율 고정 방식으로 교체 */
.preview-aspect {
  width: 100%;
  max-width: 360px;
  position: relative;
}
.preview-aspect::before {
  content: '';
  display: block;
  padding-top: 138.9%;   /* 500/360 × 100% */
}
#preview-canvas {
  position: absolute;
  top: 0; left: 0;
  width: 100%;
  height: 100%;
  display: block;
}

/* ── 오른쪽: 옵션 ── */
.options-panel {
  flex: 1;
  display: flex;
  flex-direction: column;
  overflow: hidden;
  min-height: 0;
  min-width: 0;
}

/* ── 메인 탭 ── */
.category-tabs {
  display: flex;
  justify-content: center;
  gap: 4px;
  border-bottom: 1.5px solid rgba(0,0,0,0.09);
  padding-top: 4px;
  margin-bottom: 22px;
  flex-shrink: 0;
}
.cat-tab {
  position: relative;
  padding: 11px 24px;
  border: none;
  background: transparent;
  font-size: 14px;
  color: rgba(0,0,0,0.42);
  cursor: pointer;
  font-family: inherit;
  font-weight: 500;
  letter-spacing: 0.3px;
  margin-bottom: -1.5px;
  transition: color 0.15s;
}
.cat-tab:hover { color: rgba(0,0,0,0.7); }
.cat-tab.active { color: #3E6AA3; }
.cat-tab.active::after {
  content: '';
  position: absolute;
  bottom: -1.5px;
  left: 24%;
  right: 24%;
  height: 2.5px;
  background: #3E6AA3;
  border-radius: 2px;
}

/* ── 카테고리 패널 (스크롤) ── */
.category-panel {
  flex: 1;
  overflow-y: auto;
  padding-right: 6px;
  min-height: 0;
}

/* ── 서브 탭 (pill) ── */
.sub-tabs {
  display: flex;
  gap: 6px;
  margin-bottom: 18px;
  flex-wrap: wrap;
}
.sub-tab {
  padding: 6px 16px;
  border: 1.5px solid rgba(0,0,0,0.14);
  border-radius: 999px;
  background: rgba(255,255,255,0.6);
  font-size: 12px;
  color: rgba(0,0,0,0.55);
  cursor: pointer;
  font-family: inherit;
  font-weight: 500;
  transition: all 0.15s;
}
.sub-tab:hover {
  background: white;
  color: rgba(0,0,0,0.8);
  border-color: rgba(0,0,0,0.2);
}
.sub-tab.active {
  background: #3E6AA3;
  border-color: #3E6AA3;
  color: white;
}
.sub-panel.hidden { display: none; }

/* ── 섹션 타이틀 ── */
.section-title {
  font-size: 13px;
  font-weight: 500;
  color: rgba(0,0,0,0.55);
  margin-bottom: 12px;
}
.section-title + .section-title { margin-top: 4px; }

/* ── 파츠 그리드 (원형 아이템) ── */
.parts-grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 12px;
  margin-bottom: 22px;
}
.part-item {
  aspect-ratio: 1;
  border: 1.5px solid rgba(0,0,0,0.1);
  border-radius: 16%;
  background: white;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: border-color 0.15s, transform 0.15s, box-shadow 0.15s;
  overflow: hidden;
}
.part-item:hover {
  border-color: rgba(0,0,0,0.22);
  transform: translateY(-1px);
}
.part-item.selected {
  border: 2.5px solid #3E6AA3;
  box-shadow: 0 0 0 2px rgba(62,106,163,0.18);
}
.part-item canvas {
  display: block;
  pointer-events: none;
  width: 86%;
  height: 86%;
}

/* ── 색상 섹션 ── */
.color-section {
  margin-top: 22px;
  margin-bottom: 8px;
}
.color-label {
  font-size: 13px;
  font-weight: 500;
  color: rgba(0,0,0,0.55);
  margin-bottom: 12px;
}
.color-grid {
  display: flex;
  gap: 12px;
  flex-wrap: wrap;
}
.color-dot {
  width: 30px;
  height: 30px;
  border-radius: 50%;
  cursor: pointer;
  border: 2.5px solid white;
  box-shadow: 0 0 0 1.2px rgba(0,0,0,0.12);
  transition: transform 0.15s, box-shadow 0.15s;
}
.color-dot:hover { transform: scale(1.12); }
.color-dot.selected {
  box-shadow: 0 0 0 2.5px #3E6AA3;
}

/* ── 의상 그리드 ── */
.clothing-grid {
  display: grid;
  grid-template-columns: repeat(5, 1fr);
  gap: 16px 14px;
}
.clothing-item {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 7px;
  cursor: pointer;
}
.clothing-circle {
  width: 44px;
  height: 44px;
  border-radius: 50%;
  border: 3px solid white;
  box-shadow: 0 0 0 1.2px rgba(0,0,0,0.1);
  transition: box-shadow 0.15s, transform 0.15s;
}
.clothing-item:hover .clothing-circle {
  transform: scale(1.06);
}
.clothing-item.selected .clothing-circle {
  box-shadow: 0 0 0 2.5px #3E6AA3, 0 3px 10px rgba(62,106,163,0.25);
}
.clothing-label {
  font-size: 11px;
  color: rgba(0,0,0,0.55);
  font-weight: 500;
}
.clothing-item.selected .clothing-label {
  color: #3E6AA3;
}

/* ── 섹션 인트로 텍스트 ── */
.intro-text,
.pers-intro {
  font-size: 12.5px;
  color: rgba(0,0,0,0.48);
  margin-bottom: 18px;
  line-height: 1.5;
}

/* ── 성격 질문 ── */
.question-item {
  padding: 14px 0 20px;
  border-bottom: 1px solid rgba(0,0,0,0.08);
}
.question-item:last-child { border-bottom: none; }
.question-text {
  font-size: 13px;
  font-weight: 500;
  color: #333;
  margin-bottom: 12px;
}
.scale-row {
  display: flex;
  align-items: center;
  gap: 12px;
}
.scale-label {
  font-size: 11px;
  color: rgba(0,0,0,0.55);
  line-height: 1.45;
  flex: 1;
}
.scale-label.right { text-align: right; }
.scale-boxes {
  display: flex;
  gap: 5px;
}
.scale-box {
  width: 22px;
  height: 22px;
  border: 1.5px solid rgba(0,0,0,0.2);
  border-radius: 5px;
  background: white;
  cursor: pointer;
  transition: all 0.12s;
  flex-shrink: 0;
}
.scale-box:hover { border-color: #3E6AA3; }
.scale-box.selected {
  background: #3E6AA3;
  border-color: #3E6AA3;
}

/* ── 하단 바 (Nintendo Switch 느낌) ── */
.bottom-bar {
  background: #2E343C;
  padding: 0 28px;
  display: flex;
  align-items: center;
  justify-content: flex-end;
  flex-shrink: 0;
  height: 54px;
}
.complete-btn {
  padding: 9px 34px;
  border-radius: 22px;
  border: none;
  font-size: 13px;
  font-weight: 600;
  font-family: inherit;
  background: rgba(255,255,255,0.08);
  color: rgba(255,255,255,0.4);
  cursor: not-allowed;
  letter-spacing: 3px;
  transition: all 0.4s;
}
.complete-btn.active {
  background: #FFD54F;
  color: #5C3A00;
  cursor: pointer;
  box-shadow: 0 0 20px rgba(255,215,80,0.35);
}
.complete-btn.active:hover {
  background: #FFC940;
}

/* ═══════════════════════════════════════════
   결과 화면
═══════════════════════════════════════════ */
#result-screen {
  background: #f2f2f2;
  display: flex;
  align-items: center;
  justify-content: center;
}
.result-container { text-align: center; max-width: 480px; width: 90%; padding: 40px 24px; }
.result-tada {
  font-size: 52px;
  font-weight: 800;
  color: #2A2A2A;
  margin-bottom: 28px;
  animation: tada-pop 0.55s cubic-bezier(0.36,0.07,0.19,0.97);
}
@keyframes tada-pop {
  0%   { transform: scale(0.3) rotate(-6deg); opacity:0; }
  60%  { transform: scale(1.12) rotate(2deg); opacity:1; }
  100% { transform: scale(1) rotate(0); }
}
.result-card {
  background: white;
  border-radius: 20px;
  padding: 32px 36px;
  box-shadow: 0 8px 28px rgba(0,0,0,0.08);
  margin-bottom: 24px;
  animation: slide-up 0.45s 0.15s both ease-out;
}
@keyframes slide-up {
  from { opacity:0; transform: translateY(20px); }
  to   { opacity:1; transform: translateY(0); }
}
.mbti-type {
  font-size: 48px;
  font-weight: 800;
  color: #3E6AA3;
  letter-spacing: 5px;
  margin-bottom: 6px;
}
.mbti-name {
  font-size: 18px;
  font-weight: 600;
  color: #333;
  margin-bottom: 14px;
}
.mbti-desc {
  font-size: 13px;
  color: #666;
  line-height: 1.75;
  text-align: left;
}
.result-bottom {
  display: flex;
  justify-content: flex-end;
  animation: slide-up 0.4s 0.4s both ease-out;
}
.next-btn {
  padding: 11px 40px;
  border-radius: 22px;
  border: none;
  font-size: 14px;
  font-weight: 600;
  font-family: inherit;
  background: #FFD54F;
  color: #5C3A00;
  cursor: pointer;
  box-shadow: 0 0 24px rgba(255,215,80,0.4);
  letter-spacing: 1.5px;
  transition: all 0.2s;
}
.next-btn:hover { background: #FFC940; transform: translateY(-1px); }

/* ═══════════════════════════════════════════
   게임 화면
═══════════════════════════════════════════ */
#game-screen { background: #111; }
#game-canvas {
  width: 100%;
  height: 100%;
  display: block;
  cursor: grab;
  outline: none;
}
.game-ui {
  position: absolute;
  top: 16px;
  left: 50%;
  transform: translateX(-50%);
  background: rgba(0,0,0,0.35);
  backdrop-filter: blur(10px);
  border-radius: 999px;
  padding: 7px 20px;
  font-size: 12px;
  color: rgba(255,255,255,0.8);
  pointer-events: none;
  letter-spacing: 0.3px;
}
.char-info {
  position: absolute;
  bottom: 20px;
  left: 24px;
  background: rgba(0,0,0,0.45);
  backdrop-filter: blur(10px);
  border-radius: 14px;
  padding: 14px 20px;
  color: #fff;
  min-width: 150px;
}
.char-info .mbti-badge {
  font-size: 20px;
  font-weight: 800;
  color: #FFD54F;
  letter-spacing: 2px;
}
.char-info .mbti-name-sm {
  font-size: 12px;
  color: rgba(255,255,255,0.7);
  margin-top: 3px;
}

/* ── 스크롤바 ── */
::-webkit-scrollbar { width: 6px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb {
  background: rgba(0,0,0,0.15);
  border-radius: 3px;
}
::-webkit-scrollbar-thumb:hover { background: rgba(0,0,0,0.28); }
