/* public/style.css */
* {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
  -webkit-tap-highlight-color: transparent;
  user-select: none;
  -webkit-user-select: none;
  -webkit-touch-callout: none;
}

html, body {
  width: 100%;
  height: 100%;
  position: fixed;
  inset: 0;
  overflow: hidden;
  background: #fdf3e7;
  font-family: -apple-system, BlinkMacSystemFont, "Pretendard", "Apple SD Gothic Neo", "Malgun Gothic", sans-serif;
  touch-action: none;
}

#canvas-container,
#label-container {
  position: fixed;
  inset: 0;
  width: 100%;
  height: 100%;
}

#label-container {
  pointer-events: none;
  z-index: 5;
}

/* ==========================================
   상단 HUD 네비게이션
   ========================================== */
#top-hud {
  position: fixed;
  top: max(10px, env(safe-area-inset-top));
  left: 10px;
  right: 10px;
  display: flex;
  justify-content: space-between;
  align-items: center;
  z-index: 25;
  pointer-events: none;
  gap: 8px;
}

.hud-left,
.hud-right {
  display: flex;
  align-items: center;
  gap: 6px;
  pointer-events: auto;
}

.hud-pill {
  background: rgba(255, 255, 255, 0.88);
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
  border: 1.5px solid rgba(255, 190, 152, 0.75);
  border-radius: 999px;
  padding: 6px 12px;
  display: flex;
  align-items: center;
  gap: 6px;
  box-shadow: 0 4px 14px rgba(100, 50, 20, 0.08);
  font-size: 12px;
  font-weight: 700;
  color: #5c4033;
  cursor: pointer;
  transition: transform 0.1s, background 0.15s;
}

.hud-pill.hud-icon-btn {
  padding: 6px 10px;
  font-size: 13.5px;
  min-width: 36px;
  justify-content: center;
}

.hud-pill.hud-icon-btn.is-muted {
  background: rgba(240, 240, 240, 0.85);
  border-color: #cfd8dc;
  color: #90a4ae;
  opacity: 0.8;
}

.hud-pill:active {
  transform: scale(0.95);
}

#my-nick-badge {
  background: #fff5ec;
  border-color: #ffb7b2;
}

#my-nick-badge .edit-icon {
  font-size: 11px;
  opacity: 0.7;
}

#room-info-btn .dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: #2ecc71;
  box-shadow: 0 0 6px rgba(46, 204, 113, 0.8);
  animation: pulseDot 1.6s infinite;
}

/* 동적 시간대 배지 */
.time-pill {
  background: rgba(255, 248, 225, 0.92);
  border-color: #ffe082;
  color: #e65100;
  padding: 5px 10px;
  transition: all 0.5s ease;
}

.time-pill.time-sunset {
  background: rgba(254, 237, 222, 0.92);
  border-color: #fb923c;
  color: #c2410c;
}

.time-pill.time-night {
  background: rgba(30, 27, 75, 0.92);
  border-color: #818cf8;
  color: #e0e7ff;
}

#user-count {
  background: #ffe4c4;
  padding: 1px 7px;
  border-radius: 99px;
  color: #d2691e;
  font-size: 11px;
}

.dropdown-arrow {
  font-size: 9px;
  opacity: 0.6;
}

.hud-action {
  font-weight: 800;
}

#random-join-btn {
  background: linear-gradient(135deg, #e8f5e9, #c8e6c9);
  color: #2e7d32;
  border-color: #a5d6a7;
}

#open-chat-btn.chat-highlight {
  background: linear-gradient(135deg, #fff9c4, #fff59d);
  color: #795548;
  border-color: #ffe082;
}

@keyframes pulseDot {
  0%, 100% { opacity: 1; transform: scale(1); }
  50% { opacity: 0.35; transform: scale(0.85); }
}

/* ==========================================
   모달 팝업 공통 스타일 (방 목록, 닉네임)
   ========================================== */
.modal-overlay {
  position: fixed;
  inset: 0;
  background: rgba(20, 10, 5, 0.45);
  backdrop-filter: blur(6px);
  -webkit-backdrop-filter: blur(6px);
  z-index: 50;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 16px;
  animation: fadeIn 0.18s ease-out;
}

.modal-card {
  background: rgba(255, 255, 255, 0.96);
  border: 2px solid #ffccbc;
  border-radius: 24px;
  width: min(92vw, 440px);
  max-height: 82vh;
  display: flex;
  flex-direction: column;
  box-shadow: 0 16px 36px rgba(50, 20, 10, 0.22);
  overflow: hidden;
  animation: scaleUp 0.2s cubic-bezier(0.175, 0.885, 0.32, 1.275);
}

.modal-card.mini-card {
  width: min(88vw, 360px);
}

.modal-header {
  padding: 14px 18px;
  border-bottom: 1px solid #ffe0b2;
  display: flex;
  justify-content: space-between;
  align-items: center;
  background: #fff8f0;
}

.modal-header h3 {
  font-size: 15px;
  font-weight: 800;
  color: #5c4033;
}

.modal-close-btn {
  background: none;
  border: none;
  font-size: 16px;
  color: #8d6e63;
  cursor: pointer;
  padding: 4px;
}

.modal-body {
  padding: 16px;
  overflow-y: auto;
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.modal-subtext {
  font-size: 12px;
  color: #795548;
  line-height: 1.4;
}

.section-title {
  font-size: 12px;
  font-weight: 800;
  color: #8d6e63;
  margin-top: 4px;
}

/* 빠른 입장 배너 */
.quick-join-banner {
  background: linear-gradient(135deg, #fff3e0, #ffe0b2);
  border-radius: 16px;
  padding: 12px;
  display: flex;
  flex-direction: column;
  gap: 8px;
  text-align: center;
  font-size: 12px;
  font-weight: 700;
  color: #e65100;
}

/* 방 목록 리스트 */
.room-list-box {
  display: flex;
  flex-direction: column;
  gap: 8px;
  max-height: 220px;
  overflow-y: auto;
  padding-right: 2px;
}

.room-item {
  background: #fffaf5;
  border: 1.5px solid #ffe0b2;
  border-radius: 14px;
  padding: 10px 14px;
  display: flex;
  justify-content: space-between;
  align-items: center;
  transition: background 0.15s, border-color 0.15s;
}

.room-item.active-room {
  border-color: #ff9aa2;
  background: #fff0f2;
}

.room-item-info {
  display: flex;
  flex-direction: column;
  gap: 2px;
}

.room-item-name {
  font-size: 13px;
  font-weight: 800;
  color: #4a3525;
}

.room-item-badge {
  font-size: 11px;
  font-weight: 700;
  color: #ff7043;
}

.room-join-btn {
  background: linear-gradient(135deg, #ff9aa2, #ff758c);
  border: none;
  border-radius: 99px;
  color: #fff;
  font-size: 11.5px;
  font-weight: 800;
  padding: 6px 14px;
  cursor: pointer;
  box-shadow: 0 2px 6px rgba(255, 117, 140, 0.25);
}

.room-join-btn:disabled {
  background: #ccc;
  cursor: not-allowed;
  box-shadow: none;
}

.room-loading {
  text-align: center;
  font-size: 12px;
  color: #999;
  padding: 20px 0;
}

/* 비밀방 입력 바 */
.custom-room-bar {
  display: flex;
  gap: 6px;
}

.custom-room-bar input,
.nick-input-group input {
  flex: 1;
  border: 1.5px solid #ffd1dc;
  border-radius: 14px;
  padding: 9px 12px;
  font-size: 13.5px;
  outline: none;
  background: #fff;
  user-select: text;
  -webkit-user-select: text;
}

.custom-room-bar input:focus,
.nick-input-group input:focus {
  border-color: #ff9aa2;
}

/* 모달 버튼 스타일 */
.btn-primary {
  background: linear-gradient(135deg, #ff9aa2, #ff758c);
  border: none;
  border-radius: 12px;
  color: white;
  font-weight: 800;
  font-size: 13px;
  padding: 10px 16px;
  cursor: pointer;
}

.btn-secondary {
  background: #ffe0b2;
  border: none;
  border-radius: 12px;
  color: #d84315;
  font-weight: 800;
  font-size: 12px;
  padding: 9px 14px;
  cursor: pointer;
}

.btn-ghost {
  background: #f0f0f0;
  border: none;
  border-radius: 12px;
  color: #666;
  font-weight: 700;
  font-size: 12px;
  padding: 9px 14px;
  cursor: pointer;
}

.nick-input-group {
  display: flex;
  gap: 6px;
}

.modal-actions {
  display: flex;
  justify-content: flex-end;
  gap: 8px;
  margin-top: 6px;
}

/* ==========================================
   플로팅 채팅 모달
   ========================================== */
#chat-modal {
  position: fixed;
  top: max(58px, calc(env(safe-area-inset-top) + 48px));
  left: 50%;
  transform: translateX(-50%);
  width: min(92vw, 420px);
  z-index: 40;
  background: rgba(255, 255, 255, 0.96);
  border: 2px solid #ffb7b2;
  border-radius: 20px;
  padding: 8px;
  box-shadow: 0 10px 30px rgba(0, 0, 0, 0.15);
  animation: slideDown 0.2s ease-out;
}

#chat-form {
  display: flex;
  gap: 6px;
}

#chat-input {
  flex: 1;
  border: 1.5px solid #ffd1dc;
  border-radius: 14px;
  padding: 9px 12px;
  font-size: 14px;
  outline: none;
  background: #fff;
  user-select: text;
  -webkit-user-select: text;
}

#chat-form button {
  border: none;
  border-radius: 14px;
  padding: 0 14px;
  font-weight: 700;
  font-size: 13px;
  cursor: pointer;
}

#submit-chat-btn {
  background: linear-gradient(135deg, #ff9aa2, #ff758c);
  color: white;
}

#close-chat-btn {
  background: #f0f0f0;
  color: #666;
}

/* ==========================================
   천본앵 중앙 컷인 배너
   ========================================== */
#senbon-banner {
  position: fixed;
  top: 26%;
  left: 50%;
  transform: translate(-50%, -50%);
  z-index: 30;
  text-align: center;
  pointer-events: none;
  background: linear-gradient(90deg, rgba(255,183,197,0) 0%, rgba(45,15,35,0.88) 18%, rgba(45,15,35,0.88) 82%, rgba(255,183,197,0) 100%);
  padding: 16px 40px;
  width: 100%;
  box-shadow: 0 0 30px rgba(255, 105, 180, 0.4);
  animation: bannerPop 0.35s cubic-bezier(0.175, 0.885, 0.32, 1.275);
}

.senbon-title {
  font-size: clamp(20px, 5.2vw, 32px);
  font-weight: 900;
  color: #fff0f5;
  text-shadow: 0 0 10px #ff69b4, 0 0 24px #ff1493;
}

.senbon-sub {
  margin-top: 5px;
  font-size: clamp(12px, 3.2vw, 15px);
  color: #ffc0cb;
  font-weight: 600;
}

/* ==========================================
   하단 컨트롤 & 2단 인터랙션 도크
   ========================================== */
#bottom-controls {
  position: fixed;
  bottom: max(12px, env(safe-area-inset-bottom));
  left: 12px;
  right: 12px;
  display: flex;
  justify-content: space-between;
  align-items: flex-end;
  z-index: 20;
  pointer-events: none;
}

/* 좌측 조이스틱 */
#joystick-zone {
  width: 124px;
  height: 124px;
  position: relative;
  pointer-events: auto;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
}

#joystick-base {
  width: 100px;
  height: 100px;
  border-radius: 50%;
  background: rgba(255, 255, 255, 0.5);
  border: 3px solid rgba(255, 183, 178, 0.85);
  backdrop-filter: blur(8px);
  -webkit-backdrop-filter: blur(8px);
  position: relative;
  display: flex;
  align-items: center;
  justify-content: center;
  box-shadow: 0 6px 18px rgba(0, 0, 0, 0.08);
}

#joystick-stick {
  width: 42px;
  height: 42px;
  border-radius: 50%;
  background: radial-gradient(circle at 30% 30%, #ffdac1, #ff9aa2);
  box-shadow: 0 4px 12px rgba(255, 105, 135, 0.45);
  transform: translate(0px, 0px);
}

.control-hint {
  margin-top: 4px;
  font-size: 10.5px;
  color: rgba(92, 64, 51, 0.85);
  font-weight: 700;
  white-space: nowrap;
  text-shadow: 0 1px 3px rgba(255, 255, 255, 0.85);
}

/* 우측 인터랙션 도크 */
#interaction-dock {
  display: flex;
  flex-direction: column;
  align-items: flex-end;
  gap: 8px;
  pointer-events: auto;
}

/* 1층: 감정표현 바 (기도, 박수, 인사, 댄스, 눕기) */
.emote-bar {
  display: flex;
  gap: 5px;
  background: rgba(255, 255, 255, 0.8);
  backdrop-filter: blur(8px);
  -webkit-backdrop-filter: blur(8px);
  padding: 4px 6px;
  border-radius: 999px;
  border: 1.5px solid rgba(255, 204, 188, 0.7);
  box-shadow: 0 4px 14px rgba(0, 0, 0, 0.06);
}

.emote-btn {
  background: rgba(255, 255, 255, 0.9);
  border: 1.5px solid #ffe0b2;
  border-radius: 999px;
  padding: 4px 8px;
  display: flex;
  align-items: center;
  gap: 3px;
  cursor: pointer;
  transition: transform 0.1s, background 0.15s;
  box-shadow: 0 2px 6px rgba(0,0,0,0.04);
}

.emote-btn:active {
  transform: scale(0.88);
  background: #ffe0b2;
}

.emote-btn .emoji {
  font-size: 14px;
  line-height: 1;
}

.emote-btn .label {
  font-size: 10.5px;
  font-weight: 800;
  color: #5d4037;
}

/* 2층: 4대 핵심 액션 버튼 */
#action-wheel {
  display: grid;
  grid-template-columns: repeat(4, 56px);
  grid-gap: 6px;
}

.action-btn {
  width: 56px;
  height: 56px;
  border-radius: 50%;
  border: 2px solid rgba(255, 255, 255, 0.95);
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  box-shadow: 0 4px 14px rgba(0, 0, 0, 0.12);
  transition: transform 0.1s;
  position: relative;
  overflow: hidden;
}

.cooldown-badge {
  position: absolute;
  inset: 0;
  border-radius: 50%;
  background: rgba(40, 20, 10, 0.72);
  backdrop-filter: blur(2px);
  color: #fff;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 11px;
  font-weight: 800;
  letter-spacing: 0.5px;
}

/* 근처 상호작용 (칼군무 합류 / NPC 대화) 플로팅 팝업 */
#proximity-prompt {
  position: fixed;
  bottom: 135px;
  left: 50%;
  transform: translateX(-50%);
  z-index: 35;
  pointer-events: auto;
  animation: bounceIn 0.3s cubic-bezier(0.175, 0.885, 0.32, 1.275);
}

#proximity-btn {
  border: 2.5px solid #ffffff;
  background: linear-gradient(135deg, #ff4081, #7c4dff);
  color: #fff;
  font-weight: 900;
  font-size: 13.5px;
  padding: 10px 22px;
  border-radius: 999px;
  display: flex;
  align-items: center;
  gap: 8px;
  cursor: pointer;
  box-shadow: 0 8px 25px rgba(124, 77, 255, 0.45);
  transition: transform 0.1s;
}

#proximity-btn:active {
  transform: scale(0.92);
}

/* 차량 탑승 중 하차 플로팅 버튼 */
#car-controls {
  position: fixed;
  bottom: 135px;
  left: 50%;
  transform: translateX(-50%);
  z-index: 36;
  pointer-events: auto;
  animation: bounceIn 0.3s cubic-bezier(0.175, 0.885, 0.32, 1.275);
}

.car-exit-btn {
  border: 2px solid #ffffff;
  background: linear-gradient(135deg, #ef4444, #b91c1c);
  color: #fff;
  font-weight: 800;
  font-size: 13.5px;
  padding: 10px 22px;
  border-radius: 999px;
  display: flex;
  align-items: center;
  gap: 8px;
  cursor: pointer;
  box-shadow: 0 8px 24px rgba(239, 68, 68, 0.45);
  transition: transform 0.1s;
}

.car-exit-btn:active {
  transform: scale(0.92);
}

@keyframes bounceIn {
  0% { transform: translate(-50%, 15px) scale(0.7); opacity: 0; }
  100% { transform: translate(-50%, 0) scale(1); opacity: 1; }
}

.action-btn:active {
  transform: scale(0.88);
}

.action-btn .emoji {
  font-size: 19px;
  line-height: 1;
}

.action-btn .label {
  font-size: 9.5px;
  font-weight: 800;
  margin-top: 2px;
  color: #4a3525;
}

.action-btn.senbon { background: linear-gradient(135deg, #ffc3d0, #ff8da1); }
.action-btn.pepero { background: linear-gradient(135deg, #f5cba7, #d38b5d); }
.action-btn.flute  { background: linear-gradient(135deg, #c7ceea, #9fa8da); }
.action-btn.hide   { background: linear-gradient(135deg, #ffeaa7, #fdcb6e); }

/* ==========================================
   3D 라벨 및 말풍선
   ========================================== */
.avatar-label {
  display: flex;
  flex-direction: column;
  align-items: center;
  transform: translateY(-8px);
}

.nickname-tag {
  background: rgba(45, 30, 20, 0.72);
  color: #fff;
  font-size: 11px;
  font-weight: 700;
  padding: 2px 8px;
  border-radius: 99px;
  white-space: nowrap;
  box-shadow: 0 2px 6px rgba(0,0,0,0.15);
}

.speech-bubble {
  margin-bottom: 5px;
  background: #ffffff;
  color: #333;
  border: 2px solid #ffb7b2;
  padding: 6px 12px;
  border-radius: 16px;
  font-size: 12.5px;
  font-weight: 800;
  max-width: 190px;
  word-break: keep-all;
  text-align: center;
  box-shadow: 0 4px 14px rgba(0, 0, 0, 0.12);
  animation: bubblePop 0.25s cubic-bezier(0.175, 0.885, 0.32, 1.275);
}

.speech-bubble.senbon-shout {
  background: #2b091f;
  color: #ff9ebb;
  border-color: #ff1493;
  box-shadow: 0 0 14px rgba(255, 20, 147, 0.65);
}

/* 감정표현 상태 말풍선 */
.speech-bubble.emote-bubble {
  background: #fff8e1;
  border-color: #ffca28;
  color: #795548;
}

/* NPC 전용 라벨 & 말풍선 */
.nickname-tag.npc-tag {
  background: rgba(230, 81, 0, 0.88);
  border: 1px solid #ffe082;
  color: #fffde7;
  font-weight: 800;
}

.speech-bubble.npc-bubble {
  background: #fffde7;
  border-color: #ffd54f;
  color: #5d4037;
  box-shadow: 0 4px 14px rgba(255, 179, 0, 0.25);
}

@keyframes bubblePop {
  0% { transform: scale(0.3); opacity: 0; }
  100% { transform: scale(1); opacity: 1; }
}

@keyframes bannerPop {
  0% { transform: translate(-50%, -50%) scale(0.65); opacity: 0; }
  100% { transform: translate(-50%, -50%) scale(1); opacity: 1; }
}

@keyframes fadeIn {
  from { opacity: 0; }
  to { opacity: 1; }
}

@keyframes scaleUp {
  from { opacity: 0; transform: scale(0.9); }
  to { opacity: 1; transform: scale(1); }
}

@keyframes slideDown {
  from { opacity: 0; transform: translate(-50%, -10px); }
  to { opacity: 1; transform: translate(-50%, 0); }
}

#toast {
  position: fixed;
  bottom: 175px;
  left: 50%;
  transform: translateX(-50%);
  background: rgba(45, 30, 20, 0.88);
  backdrop-filter: blur(8px);
  -webkit-backdrop-filter: blur(8px);
  color: #fff;
  padding: 9px 18px;
  border-radius: 99px;
  font-size: 12.5px;
  font-weight: 700;
  z-index: 60;
  box-shadow: 0 6px 20px rgba(0, 0, 0, 0.2);
}

.hidden {
  display: none !important;
}

/* 화면이 작은 기기 (너비 360px 이하) 대응 */
@media (max-width: 360px) {
  #action-wheel {
    grid-template-columns: repeat(4, 48px);
    grid-gap: 4px;
  }
  .action-btn {
    width: 48px;
    height: 48px;
  }
  .action-btn .emoji {
    font-size: 16px;
  }
  .emote-bar {
    gap: 3px;
    padding: 3px 4px;
  }
  .emote-btn {
    padding: 3px 6px;
  }
}

/* ==========================================
   추가: 캐릭터 스킨 모달 & 포춘쿠키 & 낚시 HUD
   ========================================== */
.skin-grid {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 10px;
  margin-top: 10px;
}

.skin-option {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: 14px 10px;
  background: #fffdf9;
  border: 2px solid #e2e8f0;
  border-radius: 14px;
  cursor: pointer;
  transition: all 0.2s ease;
}

.skin-option:hover {
  border-color: #ffb7b2;
  transform: translateY(-2px);
}

.skin-option.active {
  border-color: #ff7043;
  background: #fff3e0;
  box-shadow: 0 4px 12px rgba(255, 112, 67, 0.2);
}

.skin-preview {
  font-size: 32px;
  margin-bottom: 6px;
}

.skin-title {
  font-size: 13px;
  font-weight: 700;
  color: #4a5568;
}

/* 포춘쿠키 모달 */
.fortune-card {
  max-width: 380px;
  text-align: center;
  background: #fffcf5;
  border: 3px solid #ffb300;
  box-shadow: 0 10px 30px rgba(255, 179, 0, 0.25);
  animation: scaleUp 0.3s cubic-bezier(0.175, 0.885, 0.32, 1.275);
}

.fortune-header {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 6px;
  margin-bottom: 14px;
}

.fortune-icon {
  font-size: 44px;
  animation: bounce 1.2s infinite;
}

.fortune-header h3 {
  font-size: 17px;
  font-weight: 800;
  color: #b78103;
}

.fortune-quote {
  font-size: 15px;
  font-weight: 700;
  color: #4e342e;
  line-height: 1.6;
  padding: 16px;
  background: #fff8e1;
  border-radius: 12px;
  border: 1px dashed #ffd54f;
  margin-bottom: 10px;
  word-break: keep-all;
}

.fortune-author {
  font-size: 12px;
  color: #8d6e63;
  margin-bottom: 16px;
}

/* 낚시 HUD */
#fishing-hud {
  position: fixed;
  top: 75px;
  left: 50%;
  transform: translateX(-50%);
  z-index: 55;
  pointer-events: none;
}

.fishing-status-box {
  background: rgba(15, 23, 42, 0.88);
  backdrop-filter: blur(8px);
  border: 2px solid #38bdf8;
  color: #ffffff;
  padding: 10px 20px;
  border-radius: 30px;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 6px;
  font-size: 13.5px;
  font-weight: 700;
  box-shadow: 0 6px 20px rgba(56, 189, 248, 0.3);
  animation: slideDown 0.3s ease;
}

#fishing-bite-alert {
  background: #ef4444;
  color: #ffffff;
  padding: 6px 14px;
  border-radius: 99px;
  font-size: 14px;
  font-weight: 900;
  animation: pulseBite 0.4s infinite alternate;
  box-shadow: 0 0 16px rgba(239, 68, 68, 0.8);
}

@keyframes pulseBite {
  from { transform: scale(0.95); opacity: 0.85; }
  to { transform: scale(1.1); opacity: 1; }
}

@keyframes bounce {
  0%, 100% { transform: translateY(0); }
  50% { transform: translateY(-8px); }
}

/* 낚시 액션 버튼 컬러 */
.action-btn.fish {
  background: linear-gradient(135deg, #0284c7, #38bdf8);
  color: #ffffff;
  border: 2px solid #7dd3fc;
}

.action-btn.fish:active {
  background: #0369a1;
}
