/* =========================================
   BASE & RESET
========================================= */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

:root {
  --bg:         #0d0f1a;
  --surface:    #141726;
  --surface2:   #1c2035;
  --border:     rgba(255,255,255,0.08);
  --accent:     #6c63ff;
  --accent2:    #a78bfa;
  --gold:       #f5c842;
  --gold2:      #fde68a;
  --red:        #ef4444;
  --green:      #22c55e;
  --text:       #e8eaf6;
  --text-dim:   #8892b0;
  --radius:     16px;
  --shadow:     0 8px 32px rgba(0,0,0,0.5);
}

html { font-size: 16px; }

body {
  font-family: 'Noto Sans KR', sans-serif;
  background: var(--bg);
  color: var(--text);
  min-height: 100vh;
  padding-bottom: 60px;
}

/* =========================================
   CONFETTI CANVAS
========================================= */
#confetti-canvas {
  position: fixed;
  top: 0; left: 0;
  width: 100%; height: 100%;
  pointer-events: none;
  z-index: 9999;
}

/* =========================================
   HEADER
========================================= */
.app-header {
  background: linear-gradient(135deg, #1a1d3a 0%, #141726 100%);
  border-bottom: 1px solid var(--border);
  padding: 20px 24px;
}
.header-inner {
  max-width: 760px;
  margin: 0 auto;
  display: flex;
  align-items: center;
  gap: 16px;
}
.header-icon {
  width: 52px; height: 52px;
  border-radius: 14px;
  background: linear-gradient(135deg, var(--accent), var(--accent2));
  display: flex; align-items: center; justify-content: center;
  font-size: 22px;
  flex-shrink: 0;
  box-shadow: 0 4px 16px rgba(108,99,255,0.4);
  overflow: hidden;
}
.header-icon img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  border-radius: 14px;
}
.header-text h1 {
  font-size: 1.5rem;
  font-weight: 800;
  letter-spacing: -0.02em;
}
.header-text p {
  font-size: 0.8rem;
  color: var(--text-dim);
  margin-top: 2px;
}

/* =========================================
   MAIN LAYOUT
========================================= */
.app-main {
  max-width: 760px;
  margin: 0 auto;
  padding: 28px 16px;
  display: flex;
  flex-direction: column;
  gap: 24px;
}

.card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 24px;
  box-shadow: var(--shadow);
}

/* =========================================
   NAME PANEL
========================================= */
.panel-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 20px;
}
.panel-header h2 {
  font-size: 1rem;
  font-weight: 700;
  display: flex;
  align-items: center;
  gap: 8px;
  color: var(--text-dim);
}
.panel-header h2 i { color: var(--accent2); }

.badge {
  background: var(--accent);
  color: #fff;
  font-size: 0.72rem;
  font-weight: 700;
  padding: 3px 10px;
  border-radius: 99px;
}

.name-list {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  min-height: 48px;
}

.name-chip {
  display: flex;
  align-items: center;
  gap: 7px;
  background: var(--surface2);
  border: 1px solid var(--border);
  border-radius: 99px;
  padding: 5px 12px 5px 6px;
  font-size: 0.88rem;
  font-weight: 500;
  cursor: default;
  transition: border-color 0.2s, box-shadow 0.2s;
  user-select: none;
}
.name-chip:hover { border-color: var(--accent2); box-shadow: 0 0 0 2px rgba(108,99,255,0.2); }

.chip-num {
  width: 20px; height: 20px;
  border-radius: 50%;
  background: var(--accent);
  color: #fff;
  font-size: 0.68rem;
  font-weight: 700;
  display: flex; align-items: center; justify-content: center;
  flex-shrink: 0;
}

/* 쳩 프로필 사진 */
.chip-photo {
  width: 34px; height: 34px;
  border-radius: 50%;
  object-fit: cover;
  flex-shrink: 0;
  border: 2px solid rgba(255,255,255,0.12);
  transition: border-color 0.2s, transform 0.2s;
}
.name-chip:hover .chip-photo {
  border-color: var(--accent2);
  transform: scale(1.08);
}




.chip-del:hover { color: var(--red); }

.name-actions {
  margin-top: 16px;
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
}

/* =========================================
   CTA SECTION
========================================= */
.cta-section {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 16px;
}

.room-info-strip {
  display: flex;
  align-items: center;
  gap: 0;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 99px;
  overflow: hidden;
  width: 100%;
  max-width: 440px;
}
.strip-item {
  flex: 1;
  text-align: center;
  padding: 10px 12px;
  font-size: 0.8rem;
  font-weight: 600;
  color: var(--text-dim);
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
}
.strip-item.gold { color: var(--gold); }
.strip-item i { font-size: 0.9rem; }
.strip-divider {
  width: 1px;
  height: 28px;
  background: var(--border);
  flex-shrink: 0;
}

/* =========================================
   BUTTONS
========================================= */
.btn {
  border: none;
  border-radius: 12px;
  font-family: 'Noto Sans KR', sans-serif;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.2s;
  display: inline-flex;
  align-items: center;
  gap: 8px;
  font-size: 0.9rem;
  padding: 10px 20px;
}

.btn-start {
  background: linear-gradient(135deg, var(--accent) 0%, #8b5cf6 100%);
  color: #fff;
  font-size: 1.1rem;
  font-weight: 800;
  padding: 18px 48px;
  border-radius: 16px;
  letter-spacing: 0.01em;
  box-shadow: 0 6px 24px rgba(108,99,255,0.5);
  animation: pulse-btn 2s ease-in-out infinite;
}
.btn-start:hover {
  transform: translateY(-2px) scale(1.02);
  box-shadow: 0 10px 32px rgba(108,99,255,0.65);
  animation: none;
}
.btn-start:active { transform: scale(0.97); }

.btn-icon { font-size: 1.2rem; }

@keyframes pulse-btn {
  0%, 100% { box-shadow: 0 6px 24px rgba(108,99,255,0.5); }
  50%       { box-shadow: 0 6px 36px rgba(108,99,255,0.75); }
}

.btn-reset {
  background: var(--surface2);
  color: var(--text-dim);
  border: 1px solid var(--border);
  padding: 10px 24px;
  border-radius: 12px;
}
.btn-reset:hover { color: var(--text); border-color: var(--accent2); }

.btn-ghost {
  background: var(--surface2);
  color: var(--text-dim);
  border: 1px solid var(--border);
  font-size: 0.82rem;
  padding: 7px 14px;
  border-radius: 8px;
}
.btn-ghost:hover { color: var(--text); border-color: var(--accent2); }

/* 번호 정하기 버튼 (크게) */
.btn-shuffle-big {
  width: 100%;
  max-width: 480px;
  background: linear-gradient(135deg, #1e1b4b, #312e81);
  color: var(--accent2);
  border: 2px solid rgba(108,99,255,0.5);
  font-size: 1.15rem;
  font-weight: 800;
  padding: 18px 24px;
  border-radius: 14px;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 10px;
  transition: all 0.2s;
  cursor: pointer;
  font-family: 'Noto Sans KR', sans-serif;
  letter-spacing: 0.02em;
  box-shadow: 0 4px 20px rgba(108,99,255,0.25);
}
.btn-shuffle-big:hover {
  background: linear-gradient(135deg, #2e2b6b, #4338ca);
  border-color: var(--accent2);
  box-shadow: 0 6px 28px rgba(108,99,255,0.45);
  transform: translateY(-2px);
}
.btn-shuffle-big:active { transform: scale(0.97); }
.btn-shuffle-big:disabled {
  opacity: 0.6;
  cursor: not-allowed;
  transform: none;
}
.btn-shuffle-big i { font-size: 1.15rem; }

/* 추첨하기 버튼 */
.btn-draw-big {
  width: 100%;
  max-width: 480px;
  background: linear-gradient(135deg, #7c2d00, #c2410c);
  color: #fff;
  border: 2px solid rgba(249,115,22,0.5);
  font-size: 1.15rem;
  font-weight: 800;
  padding: 18px 24px;
  border-radius: 14px;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 10px;
  transition: all 0.2s;
  cursor: pointer;
  font-family: 'Noto Sans KR', sans-serif;
  letter-spacing: 0.02em;
  box-shadow: 0 4px 20px rgba(249,115,22,0.3);
}
.btn-draw-big:hover {
  background: linear-gradient(135deg, #9a3412, #ea580c);
  border-color: #fb923c;
  box-shadow: 0 6px 28px rgba(249,115,22,0.55);
  transform: translateY(-2px);
}
.btn-draw-big:active { transform: scale(0.97); }
.btn-draw-big .btn-icon { font-size: 1.15rem; }

/* 랜덤 정렬 버튼 (구버전 유지) */
.btn-shuffle {
  background: linear-gradient(135deg, #1e1b4b, #312e81);
  color: var(--accent2);
  border: 1px solid rgba(108,99,255,0.4);
  font-size: 0.85rem;
  font-weight: 700;
  padding: 8px 18px;
  border-radius: 10px;
  display: inline-flex;
  align-items: center;
  gap: 7px;
  transition: all 0.2s;
  cursor: pointer;
  font-family: 'Noto Sans KR', sans-serif;
}
.btn-shuffle:hover {
  background: linear-gradient(135deg, #2e2b6b, #4338ca);
  border-color: var(--accent2);
  box-shadow: 0 0 16px rgba(108,99,255,0.35);
  transform: translateY(-1px);
}
.btn-shuffle:active { transform: scale(0.96); }
.btn-shuffle:disabled {
  opacity: 0.65;
  cursor: not-allowed;
  transform: none;
}

/* ── 셔플 애니메이션 상태 ── */
/* 돌아가는 칩 전체 */
.name-chip.shuffling {
  border-color: rgba(108,99,255,0.4);
}
.name-chip.shuffling .chip-name {
  color: var(--accent2);
  animation: nameFlicker 0.09s linear infinite;
}

@keyframes nameFlicker {
  0%   { opacity: 1;    transform: translateY(0); }
  30%  { opacity: 0.3;  transform: translateY(-3px); }
  60%  { opacity: 1;    transform: translateY(2px); }
  100% { opacity: 1;    transform: translateY(0); }
}

/* 확정된 슬롯 이름 */
.chip-name.locked {
  color: var(--green) !important;
  animation: none !important;
  font-weight: 700;
}

/* 완료 후 반짝임 */
@keyframes settleFlash {
  0%   { background: rgba(34,197,94,0.25); border-color: rgba(34,197,94,0.6); transform: scale(1.04); }
  100% { background: var(--surface2); border-color: var(--border); transform: scale(1); }
}
.name-chip.settled {
  animation: settleFlash 0.45s ease forwards;
}

.btn-primary {
  background: var(--accent);
  color: #fff;
  padding: 8px 20px;
  border-radius: 8px;
}
.btn-primary:hover { background: var(--accent2); }

.hidden { display: none !important; }

/* =========================================
   RESULT SECTION
========================================= */
.result-section { animation: fadeUp 0.5s ease; }

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

.result-header {
  text-align: center;
  margin-bottom: 24px;
}
.result-header h2 {
  font-size: 1.4rem;
  font-weight: 800;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 10px;
  color: var(--gold);
}

/* =========================================
   ROOMS GRID
========================================= */
.rooms-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(200px, 1fr));
  gap: 16px;
}

.room-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  overflow: hidden;
  transition: transform 0.2s, box-shadow 0.2s;
  animation: cardIn 0.5s ease both;
}
.room-card:hover {
  transform: translateY(-4px);
  box-shadow: 0 12px 32px rgba(0,0,0,0.4);
}

@keyframes cardIn {
  from { opacity: 0; transform: scale(0.85) translateY(16px); }
  to   { opacity: 1; transform: scale(1) translateY(0); }
}

.room-card:nth-child(1) { animation-delay: 0.05s; }
.room-card:nth-child(2) { animation-delay: 0.1s; }
.room-card:nth-child(3) { animation-delay: 0.15s; }
.room-card:nth-child(4) { animation-delay: 0.2s; }
.room-card:nth-child(5) { animation-delay: 0.25s; }
.room-card:nth-child(6) { animation-delay: 0.3s; }

.room-card-header {
  padding: 14px 16px;
  display: flex;
  align-items: center;
  gap: 10px;
  font-weight: 700;
  font-size: 0.95rem;
  border-bottom: 1px solid var(--border);
}

.room-icon {
  width: 36px; height: 36px;
  border-radius: 10px;
  display: flex; align-items: center; justify-content: center;
  font-size: 1rem;
  flex-shrink: 0;
}

.room-card.twin .room-icon { background: rgba(108,99,255,0.2); color: var(--accent2); }
.room-card.single .room-icon { background: rgba(245,200,66,0.2); color: var(--gold); }

.room-card.twin .room-card-header { background: rgba(108,99,255,0.07); }
.room-card.single .room-card-header { background: rgba(245,200,66,0.07); }

.room-card.single {
  border-color: rgba(245,200,66,0.35);
  box-shadow: 0 0 20px rgba(245,200,66,0.1);
}

.room-label {
  display: flex;
  flex-direction: column;
}
.room-label span:first-child { font-size: 0.95rem; font-weight: 700; }
.room-label .room-type-tag {
  font-size: 0.68rem;
  font-weight: 600;
  letter-spacing: 0.05em;
  margin-top: 1px;
}
.room-card.twin .room-type-tag { color: var(--accent2); }
.room-card.single .room-type-tag { color: var(--gold); }

.room-card-body { padding: 14px 16px; display: flex; flex-direction: column; gap: 8px; }

.occupant-chip {
  display: flex;
  align-items: center;
  gap: 8px;
  background: var(--surface2);
  border-radius: 10px;
  padding: 8px 12px;
  font-size: 0.88rem;
  font-weight: 500;
}
.occupant-avatar {
  width: 36px; height: 36px;
  border-radius: 50%;
  display: flex; align-items: center; justify-content: center;
  font-size: 0.75rem;
  font-weight: 800;
  flex-shrink: 0;
  color: #fff;
}

/* 결과 카드 프로필 사진 */
.occupant-photo {
  width: 40px; height: 40px;
  border-radius: 50%;
  object-fit: cover;
  flex-shrink: 0;
  border: 2px solid rgba(255,255,255,0.15);
  transition: transform 0.2s;
}
.occupant-chip:hover .occupant-photo { transform: scale(1.08); }
.room-card.single .occupant-photo {
  border-color: var(--gold);
  box-shadow: 0 0 10px rgba(245,200,66,0.4);
}



/* single room occupant special style */
.room-card.single .occupant-chip {
  background: rgba(245,200,66,0.1);
  border: 1px solid rgba(245,200,66,0.25);
}
.room-card.single .occupant-avatar { background: var(--gold) !important; color: #1a1200; }
.room-card.single .occupant-chip::after {
  content: '🎉';
  margin-left: auto;
  font-size: 1rem;
}

/* avatar color palette */
.av-0 { background: #6c63ff; }
.av-1 { background: #f5774a; }
.av-2 { background: #22c55e; }
.av-3 { background: #3b82f6; }
.av-4 { background: #ec4899; }
.av-5 { background: #f59e0b; }
.av-6 { background: #8b5cf6; }
.av-7 { background: #06b6d4; }
.av-8 { background: #ef4444; }
.av-9 { background: #84cc16; }
.av-10 { background: #f97316; }

/* =========================================
   MODAL
========================================= */
.modal-overlay {
  position: fixed; inset: 0;
  background: rgba(0,0,0,0.7);
  backdrop-filter: blur(4px);
  z-index: 1000;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 16px;
}
.modal-box {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 20px;
  padding: 28px 24px;
  width: 100%;
  max-width: 340px;
  box-shadow: 0 20px 60px rgba(0,0,0,0.6);
  animation: modalIn 0.25s ease;
}
@keyframes modalIn {
  from { opacity: 0; transform: scale(0.88); }
  to   { opacity: 1; transform: scale(1); }
}
.modal-box h3 {
  font-size: 1rem;
  font-weight: 700;
  margin-bottom: 16px;
  display: flex; align-items: center; gap: 8px;
  color: var(--accent2);
}
.modal-input {
  width: 100%;
  background: var(--surface2);
  border: 1px solid var(--border);
  border-radius: 10px;
  color: var(--text);
  font-family: 'Noto Sans KR', sans-serif;
  font-size: 1rem;
  font-weight: 600;
  padding: 12px 16px;
  outline: none;
  transition: border-color 0.2s;
}
.modal-input:focus { border-color: var(--accent2); }
.modal-actions {
  margin-top: 16px;
  display: flex;
  gap: 8px;
  justify-content: flex-end;
}

/* =========================================
   RESPONSIVE
========================================= */
@media (max-width: 480px) {
  .rooms-grid { grid-template-columns: 1fr 1fr; }
  .btn-start { padding: 16px 36px; font-size: 1rem; }
  .header-text h1 { font-size: 1.2rem; }
}
@media (max-width: 360px) {
  .rooms-grid { grid-template-columns: 1fr; }
}

/* =========================================
   LADDER MODAL
========================================= */
.ladder-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,0.92);
  backdrop-filter: blur(6px);
  z-index: 2000;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 12px;
}

.ladder-modal {
  background: var(--surface);
  border: 1px solid rgba(108,99,255,0.3);
  border-radius: 20px;
  width: 100%;
  max-width: 900px;
  max-height: 95vh;
  display: flex;
  flex-direction: column;
  box-shadow: 0 0 60px rgba(108,99,255,0.25);
  overflow: hidden;
}

.ladder-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 16px 20px;
  border-bottom: 1px solid var(--border);
  background: linear-gradient(135deg, rgba(108,99,255,0.15), rgba(167,139,250,0.08));
}

.ladder-title {
  font-size: 1rem;
  font-weight: 800;
  color: var(--accent2);
  display: flex;
  align-items: center;
  gap: 8px;
  letter-spacing: 0.02em;
}

.ladder-skip {
  font-size: 0.8rem;
  color: var(--text-dim);
  cursor: pointer;
  padding: 4px 12px;
  border-radius: 99px;
  border: 1px solid var(--border);
  transition: all 0.2s;
}
.ladder-skip:hover {
  color: var(--text);
  border-color: var(--accent2);
}

#ladder-canvas {
  display: block;
  width: 100%;
  flex: 1;
  min-height: 0;
}

.ladder-footer {
  padding: 16px 20px;
  display: flex;
  justify-content: center;
  border-top: 1px solid var(--border);
  background: rgba(0,0,0,0.2);
}

.ladder-footer .btn-primary {
  font-size: 1rem;
  font-weight: 800;
  padding: 12px 40px;
  border-radius: 12px;
  background: linear-gradient(135deg, var(--accent), #8b5cf6);
  box-shadow: 0 4px 20px rgba(108,99,255,0.5);
  animation: pulse-btn 1.5s ease-in-out infinite;
}
