/**
 * loading.css — 시작 화면, 로그인 팝업, 디버그 패널 스타일
 *
 * index.html에서 <link rel="stylesheet"> 로 참조됩니다.
 * Phaser 게임 로드 전 표시되는 UI만 담당합니다.
 */

/* ─── 기본 레이아웃 ─── */
html,
body {
  width: 100%;
  height: 100%;
}

body {
  margin: 0;
  padding: 0;
  overflow: hidden;
  background-color: #000;
  font-family: 'Outfit', sans-serif;
}

#game-container {
  position: fixed;
  inset: 0;
  width: 100%;
  height: 100%;
}

#game-container canvas {
  display: block;
}

/* ─── 시작 화면 ─── */
#load-msg {
  position: fixed;
  inset: 0;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  color: #fff;
  font-size: 18px;
  text-align: center;
  z-index: 1;
  background:
    radial-gradient(ellipse at 50% 35%, rgba(40,30,0,0.6) 0%, transparent 50%),
    radial-gradient(ellipse at 20% 80%, rgba(30,15,0,0.3) 0%, transparent 40%),
    radial-gradient(ellipse at 80% 20%, rgba(20,10,0,0.25) 0%, transparent 40%),
    linear-gradient(180deg, #0c0a04 0%, #080604 40%, #040302 100%);
  overflow: hidden;
}
#load-msg::before {
  content: '';
  position: absolute;
  inset: 0;
  background: radial-gradient(ellipse at center, transparent 50%, rgba(0,0,0,0.7) 100%);
  pointer-events: none;
  z-index: 0;
}
#load-msg.hidden { display: none; }

/* ─── CSS 파티클 (떠다니는 빛 입자) ─── */
.particle {
  position: absolute;
  border-radius: 50%;
  pointer-events: none;
  opacity: 0;
  filter: blur(1px);
  animation: particleFloat linear infinite;
}
.particle.p1 {
  width: 6px; height: 6px;
  background: rgba(255,204,0,0.5);
  left: 15%; top: 80%;
  animation-duration: 8s; animation-delay: 0s;
}
.particle.p2 {
  width: 4px; height: 4px;
  background: rgba(255,180,0,0.4);
  left: 30%; top: 85%;
  animation-duration: 10s; animation-delay: 1.5s;
}
.particle.p3 {
  width: 8px; height: 8px;
  background: rgba(255,220,50,0.35);
  left: 50%; top: 90%;
  filter: blur(2px);
  animation-duration: 12s; animation-delay: 0.5s;
}
.particle.p4 {
  width: 5px; height: 5px;
  background: rgba(255,170,0,0.45);
  left: 70%; top: 82%;
  animation-duration: 9s; animation-delay: 3s;
}
.particle.p5 {
  width: 3px; height: 3px;
  background: rgba(255,220,100,0.5);
  left: 85%; top: 88%;
  animation-duration: 7s; animation-delay: 2s;
}
.particle.p6 {
  width: 7px; height: 7px;
  background: rgba(255,200,0,0.3);
  left: 40%; top: 75%;
  filter: blur(3px);
  animation-duration: 14s; animation-delay: 4s;
}
.particle.p7 {
  width: 4px; height: 4px;
  background: rgba(255,230,80,0.4);
  left: 60%; top: 92%;
  animation-duration: 11s; animation-delay: 2.5s;
}
.particle.p8 {
  width: 5px; height: 5px;
  background: rgba(255,190,30,0.35);
  left: 22%; top: 78%;
  filter: blur(2px);
  animation-duration: 13s; animation-delay: 5s;
}
@keyframes particleFloat {
  0% {
    opacity: 0;
    transform: translateY(0) translateX(0) scale(0.5);
  }
  10% {
    opacity: 1;
  }
  50% {
    transform: translateY(-45vh) translateX(20px) scale(1);
  }
  90% {
    opacity: 0.6;
  }
  100% {
    opacity: 0;
    transform: translateY(-90vh) translateX(-10px) scale(0.3);
  }
}

/* ─── 스플래시: Phase 1 회사 로고 ─── */
.splash {
  position: absolute;
  inset: 0;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  z-index: 3;
  opacity: 0;
  transition: opacity 0.6s ease;
  pointer-events: none;
}
.splash.active { opacity: 1; }

.splash-company-img {
  width: min(480px, 55vw);
  height: auto;
  filter: drop-shadow(0 0 50px rgba(255,200,0,0.2)) drop-shadow(0 8px 30px rgba(0,0,0,0.6));
  animation: logoBreath 3s ease-in-out infinite;
}
@keyframes logoBreath {
  0%, 100% { filter: drop-shadow(0 0 50px rgba(255,200,0,0.2)) drop-shadow(0 8px 30px rgba(0,0,0,0.6)); }
  50% { filter: drop-shadow(0 0 70px rgba(255,200,0,0.3)) drop-shadow(0 8px 30px rgba(0,0,0,0.6)); }
}

/* ─── Phase 2+3: 메인 스테이지 (로고 + Touch + 로그인) ─── */
.main-stage {
  position: absolute;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 3;
  opacity: 0;
  transition: opacity 0.6s ease;
  pointer-events: none;
  padding: 5vh 8vw;
  box-sizing: border-box;
}
.main-stage.visible {
  opacity: 1;
  pointer-events: auto;
}

.logo-side {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  transition: transform 0.6s cubic-bezier(0.4, 0, 0.2, 1);
  flex-shrink: 0;
  position: relative;
}
.logo-side::before {
  content: '';
  position: absolute;
  width: min(700px, 70vw);
  height: min(700px, 70vw);
  border-radius: 50%;
  background: radial-gradient(circle, rgba(255,180,0,0.08) 0%, transparent 70%);
  pointer-events: none;
  animation: logoAura 4s ease-in-out infinite;
}
@keyframes logoAura {
  0%, 100% { opacity: 0.6; transform: scale(1); }
  50% { opacity: 1; transform: scale(1.1); }
}
.stage-dragon-img {
  width: min(240px, 24vw, 26vh);
  height: auto;
  margin-bottom: min(18px, 2vh);
  filter: drop-shadow(0 0 40px rgba(255,180,0,0.35)) drop-shadow(0 6px 26px rgba(0,0,0,0.5));
  position: relative;
  z-index: 1;
}
.stage-title-img {
  width: min(480px, 50vw, 55vh);
  height: auto;
  filter: drop-shadow(0 0 28px rgba(255,200,0,0.25)) drop-shadow(0 3px 14px rgba(0,0,0,0.5));
  position: relative;
  z-index: 1;
}

.login-side {
  display: flex;
  align-items: center;
  justify-content: center;
  opacity: 0;
  width: 0;
  overflow: hidden;
  transition: opacity 0.5s ease 0.3s, width 0.6s cubic-bezier(0.4, 0, 0.2, 1);
}

/* split: 가로 (로고 좌측, 로그인 우측) */
.main-stage.split .logo-side {
  transform: translateX(min(-80px, -5vw)) scale(0.7);
}
.main-stage.split .login-side {
  width: min(540px, 45vw);
  opacity: 1;
  margin-left: min(64px, 6vw);
}

/* 모바일 세로: split 시 세로 배치 */
@media (max-width: 768px), (max-aspect-ratio: 1/1) {
  .main-stage { flex-direction: column; }
  .main-stage.split .logo-side {
    transform: translateX(0) translateY(-6vh) scale(0.6);
  }
  .main-stage.split .login-side {
    width: min(460px, 92vw);
    margin-left: 0;
    margin-top: 12px;
  }
}

/* ─── Touch to Start ─── */
.touch-to-start {
  margin-top: min(40px, 4.5vh);
  font-size: min(24px, 3.8vw);
  font-weight: 600;
  font-family: 'Outfit', sans-serif;
  color: rgba(255,204,0,0.3);
  letter-spacing: min(12px, 1.8vw);
  text-transform: uppercase;
  cursor: default;
  user-select: none;
  -webkit-tap-highlight-color: transparent;
  position: relative;
  z-index: 1;
}
.touch-to-start.pulse {
  color: rgba(255,204,0,0.6);
  cursor: pointer;
  text-shadow: 0 0 28px rgba(255,180,0,0.35);
  animation: touchPulse 2.5s ease-in-out infinite;
}
@keyframes touchPulse {
  0%, 100% { opacity: 0.4; text-shadow: 0 0 28px rgba(255,180,0,0.25); }
  50% { opacity: 1; text-shadow: 0 0 40px rgba(255,180,0,0.55); }
}

/* ─── 로그인 박스 ─── */
.login-box {
  background: linear-gradient(180deg, rgba(30,25,48,0.95) 0%, rgba(15,12,30,0.98) 100%);
  border: 1px solid rgba(255,204,0,0.2);
  border-radius: 20px;
  padding: min(44px, 4.5vh) min(48px, 5vw) min(32px, 3vh);
  width: min(480px, 85vw);
  max-height: 80vh;
  overflow-y: auto;
  box-sizing: border-box;
  box-shadow:
    0 24px 70px rgba(0,0,0,0.75),
    0 0 50px rgba(255,180,0,0.06),
    inset 0 1px 0 rgba(255,255,255,0.05);
  backdrop-filter: blur(14px);
  -webkit-backdrop-filter: blur(14px);
}
.login-box h2 {
  margin: 0 0 min(32px, 3.5vh);
  font-size: min(32px, 5vw);
  font-weight: 700;
  color: #ffcc00;
  text-align: center;
  letter-spacing: 2px;
}
.server-select {
  display: block;
  width: 100%;
  padding: min(16px, 2vh) 18px;
  margin-bottom: min(18px, 2vh);
  font-size: 20px;
  font-family: inherit;
  color: #eee;
  background: rgba(255,255,255,0.04);
  border: 1px solid rgba(255,255,255,0.1);
  border-radius: 13px;
  outline: none;
  box-sizing: border-box;
  transition: border-color 0.2s, box-shadow 0.2s;
  cursor: pointer;
}
.server-select:focus {
  border-color: rgba(255,204,0,0.4);
  box-shadow: 0 0 16px rgba(255,180,0,0.12);
}
.server-select option {
  background: #1a1530;
  color: #eee;
}
.login-box input {
  display: block;
  width: 100%;
  padding: min(16px, 2vh) 18px;
  margin-bottom: min(18px, 2vh);
  font-size: 20px;
  font-family: inherit;
  color: #eee;
  background: rgba(255,255,255,0.04);
  border: 1px solid rgba(255,255,255,0.1);
  border-radius: 13px;
  outline: none;
  box-sizing: border-box;
  transition: border-color 0.2s, box-shadow 0.2s;
}
.login-box input:focus {
  border-color: rgba(255,204,0,0.4);
  box-shadow: 0 0 16px rgba(255,180,0,0.12);
}
.login-box input::placeholder { color: #666; }
.login-btn {
  display: block;
  width: 100%;
  padding: min(18px, 2vh) 0;
  margin-top: 12px;
  font-size: 24px;
  font-weight: 700;
  font-family: inherit;
  color: #1a1200;
  background: linear-gradient(180deg, #ffe066 0%, #ffcc00 50%, #e6b800 100%);
  border: none;
  border-radius: 13px;
  cursor: pointer;
  box-shadow: 0 5px 20px rgba(255,204,0,0.35), 0 0 26px rgba(255,180,0,0.12);
  transition: transform 0.12s, box-shadow 0.12s;
  letter-spacing: 1px;
}
.login-btn:hover {
  background: linear-gradient(180deg, #ffe880 0%, #ffdd22 50%, #f0c200 100%);
  box-shadow: 0 7px 28px rgba(255,204,0,0.5), 0 0 36px rgba(255,180,0,0.18);
  transform: translateY(-2px);
}
.login-btn:active { transform: scale(0.97); }
.login-btn:disabled { opacity: 0.5; cursor: not-allowed; transform: none; }
.login-error {
  display: none;
  margin-top: 16px;
  padding: 13px 16px;
  font-size: 17px;
  color: #ff8888;
  background: rgba(255,80,80,0.12);
  border: 1px solid rgba(255,80,80,0.35);
  border-radius: 8px;
  text-align: center;
}

/* ─── 디버그 토글 버튼 ─── */
.debug-toggle-btn {
  position: fixed;
  bottom: 12px;
  right: 12px;
  z-index: 10;
  padding: 6px 14px;
  font-size: 12px;
  font-family: 'Outfit', sans-serif;
  font-weight: 600;
  color: #888;
  background: rgba(255,255,255,0.08);
  border: 1px solid rgba(255,255,255,0.12);
  border-radius: 6px;
  cursor: pointer;
  transition: background 0.2s, color 0.2s;
  -webkit-tap-highlight-color: transparent;
}
.debug-toggle-btn:hover {
  background: rgba(255,255,255,0.15);
  color: #bbb;
}
#load-msg.hidden ~ .debug-toggle-btn { display: none; }

/* ─── 디버그 슬라이드 패널 ─── */
.debug-panel {
  position: fixed;
  bottom: 0;
  left: 0;
  right: 0;
  z-index: 9;
  max-height: 50vh;
  background: rgba(10,10,10,0.95);
  border-top: 1px solid rgba(255,255,255,0.1);
  backdrop-filter: blur(8px);
  -webkit-backdrop-filter: blur(8px);
  transform: translateY(100%);
  transition: transform 0.35s cubic-bezier(0.4, 0, 0.2, 1);
  overflow-y: auto;
  -webkit-overflow-scrolling: touch;
  padding: 16px 16px 24px;
  box-sizing: border-box;
}
.debug-panel.open {
  transform: translateY(0);
}
#load-msg.hidden ~ .debug-panel { display: none; }

/* 디버그 패널 내부 스타일 */
.debug-panel .debug-section {
  margin-bottom: 12px;
}
.debug-panel .debug-section-title {
  font-size: 11px;
  font-weight: 600;
  color: #666;
  text-transform: uppercase;
  letter-spacing: 1px;
  margin-bottom: 6px;
}
.debug-panel .syntax-check {
  font-size: 12px;
  line-height: 1.6;
  text-align: left;
  color: #ccc;
}
.debug-panel .syntax-check .syntax-ok { color: #8f8; }
.debug-panel .syntax-check .syntax-fail { color: #fa8; }
.debug-panel .syntax-check .syntax-note { color: #8af; font-size: 11px; }
.debug-panel .device-info {
  padding: 8px 10px;
  font-size: 12px;
  line-height: 1.6;
  color: #aaa;
  text-align: left;
  background: rgba(255,255,255,0.04);
  border-radius: 4px;
  font-family: monospace;
  word-break: break-all;
}
.debug-panel .localhost-warning {
  display: none;
  margin-top: 8px;
  padding: 10px 12px;
  font-size: 13px;
  color: #fa8;
  background: rgba(200,80,0,0.15);
  border-radius: 6px;
  border: 1px solid rgba(255,170,0,0.4);
}
.debug-panel .start-log {
  padding: 8px 10px;
  font-size: 11px;
  line-height: 1.5;
  color: #8af;
  text-align: left;
  background: rgba(0,0,0,0.4);
  border-radius: 4px;
  max-height: 140px;
  overflow-y: auto;
  font-family: monospace;
}
.debug-panel .start-log .err { color: #f88; }
