/* =========================================================================
   1. 커스텀 웹폰트 (@font-face) 정의
   ========================================================================= */
@font-face {
  font-family: 'Jalnan';
  src:
    url('./assets/fonts/Jalnan.woff2') format('woff2'),
    url('./assets/fonts/Jalnan.woff') format('woff');
  font-weight: normal;
  font-style: normal;
}

/* =========================================================================
   2. 전역 문서 및 바디 레이아웃 기본 스타일
   ========================================================================= */
html {
  width: 100%;
  height: 100%;
  height: var(--app-height, 100vh);
  margin: 0;
  padding: 0;
  overflow: hidden;
  background-color: #000000;
}

body {
  width: 100%;
  height: 100%;
  height: var(--app-height, 100vh);
  margin: 0;
  padding: 0;
  overflow: hidden; /* 스크롤바 강제 숨김 */
  position: fixed; /* 모바일 바운스 스크롤 방지 */
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  background-color: #000000; /* 여백 검은색 처리 */
  overscroll-behavior: none;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  text-rendering: optimizeLegibility;
  font-smooth: always;
  box-sizing: border-box;
  padding-top: env(safe-area-inset-top, 0px);
  padding-bottom: env(safe-area-inset-bottom, 0px);
}

body {
  background: transparent !important; /* 웹앱 임베딩 대비 */
}

/* =========================================================================
   3. Phaser 게임 캔버스 컨테이너 (카카오톡 등 모바일 인앱 웹뷰 상단 잘림 방지)
   ========================================================================= */
#game-container {
  width: 100%;
  height: 100%;
  height: var(--app-height, 100%);
  position: relative;
  overflow: hidden;
  background-color: #000000;
  display: flex;
  justify-content: center;
  align-items: center;
}

/* Phaser 스케일 매니저와의 충돌 방지: Canvas 크기를 강제 고정하지 않고 Phaser가 계산한 크기를 따름 */
#game-container canvas {
  display: block;
  image-rendering: -webkit-optimize-contrast;
  image-rendering: crisp-edges;
  margin: auto;
}

/* =========================================================================
   4. 앱 초기 로딩 오버레이 레이어
   ========================================================================= */
#app-loading-screen {
  position: fixed;
  inset: 0;
  width: 100%;
  height: 100%;
  background-color: #000000;
  display: flex;
  justify-content: center;
  align-items: center;
  z-index: 9998;
  pointer-events: none;
  transition: opacity 0.3s ease;
}

#app-loading-screen img {
  width: 100%;
  height: 100%;
  object-fit: contain;
}

/* =========================================================================
   5. 모바일 세로 모드 회전 유도 경고창 (미디어 쿼리)
   ========================================================================= */
@media screen and (orientation: portrait) {
  #landscape-warning {
    display: flex !important;
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    width: 100vw;
    height: 100dvh; /* 모바일 브라우저 주소창 포함 유동 높이 대응 */
    background: radial-gradient(circle at center, #1a1a2e 0%, #0f0c1b 100%);
    color: #ffffff;
    z-index: 9999;
    justify-content: center;
    align-items: center;
    box-sizing: border-box;
    padding: 20px;
  }

  .warning-content {
    background: rgba(255, 255, 255, 0.05);
    border: 1px solid rgba(255, 255, 255, 0.1);
    border-radius: 24px;
    padding: 40px 30px;
    backdrop-filter: blur(16px);
    -webkit-backdrop-filter: blur(16px);
    box-shadow: 0 20px 50px rgba(0, 0, 0, 0.4);
    max-width: 320px;
    width: 90%;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    text-align: center;
  }

  .phone-icon-wrapper {
    position: relative;
    width: 80px;
    height: 80px;
    margin: 0 auto 24px auto;
  }

  .phone-icon {
    width: 40px;
    height: 70px;
    border: 3px solid #00f2fe;
    border-radius: 6px;
    position: absolute;
    top: 5px;
    left: 20px;
    box-shadow: 0 0 15px rgba(0, 242, 254, 0.5);
    animation: rotatePhone 2.5s cubic-bezier(0.68, -0.55, 0.27, 1.55) infinite;
  }

  .warning-title {
    font-size: 22px;
    font-weight: 900;
    margin: 0 0 12px 0;
    color: #ffffff;
    letter-spacing: -0.5px;
    background: linear-gradient(45deg, #00f2fe, #4facfe);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
  }

  .warning-subtitle {
    font-size: 14px;
    font-weight: 400;
    line-height: 1.6;
    color: #a0aec0;
    margin: 0;
    font-family: 'SpoqaHanSansNeo-Regular', sans-serif;
  }
}

/* 가로 모드 진입 시 숨김 처리 */
@media screen and (orientation: landscape) {
  #landscape-warning {
    display: none !important;
  }
}

/* =========================================================================
   6. 핸드폰 회전 애니메이션 키프레임
   ========================================================================= */
@keyframes rotatePhone {
  0%,
  10% {
    transform: rotate(0deg);
  }
  40%,
  60% {
    transform: rotate(-90deg);
  }
  90%,
  100% {
    transform: rotate(0deg);
  }
}
