/**
 * demo2 — 게임 실행 중 / 종료(로딩) 오버레이
 * 메인(보라·블루 네온) 톤에 맞춤
 * PC: backUrl 페이지를 iframe으로 깔고 그 위에 반투명 딤
 */

/* 게임 부모창 — 셸 없이 배경 iframe + 딤만 */
body.page-demo2-game-parent {
  margin: 0;
  min-height: 100vh;
  overflow: hidden;
  background: #070716;
}

.mg-game-parent-preview {
  position: fixed;
  inset: 0;
  z-index: 1;
  width: 100%;
  height: 100%;
  border: 0;
  pointer-events: none;
  background: #0a0a16;
}

.mg-game-block {
  position: fixed;
  inset: 0;
  z-index: 10000;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 24px;
  /* 반투명 딤 — 아래 iframe(이전 페이지)이 비쳐 보임 */
  background:
    radial-gradient(ellipse 70% 50% at 50% 30%, rgba(122, 61, 255, 0.14), transparent 60%),
    radial-gradient(ellipse 50% 40% at 70% 80%, rgba(77, 125, 255, 0.08), transparent 55%),
    rgba(7, 7, 22, 0.42);
}

.mg-game-block-panel {
  position: relative;
  width: min(520px, 100%);
  padding: 36px 28px 28px;
  border-radius: 18px;
  border: 1px solid rgba(181, 107, 255, 0.45);
  background:
    linear-gradient(180deg, rgba(36, 22, 62, 0.95) 0%, rgba(14, 10, 28, 0.98) 100%);
  box-shadow:
    0 0 0 1px rgba(122, 61, 255, 0.15),
    0 24px 64px rgba(0, 0, 0, 0.55),
    0 0 40px rgba(122, 61, 255, 0.18);
  text-align: center;
  overflow: hidden;
}

.mg-game-block-panel::before {
  content: "";
  position: absolute;
  inset: 0 0 auto;
  height: 2px;
  background: linear-gradient(90deg, transparent, #b56bff 20%, #7a3dff 50%, #4d7dff 80%, transparent);
  opacity: 0.9;
}

.mg-game-block-icon {
  position: relative;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 64px;
  height: 64px;
  margin: 0 auto 18px;
  border-radius: 50%;
  background:
    radial-gradient(circle at 35% 30%, rgba(181, 107, 255, 0.35), transparent 55%),
    rgba(122, 61, 255, 0.2);
  border: 1px solid rgba(181, 107, 255, 0.45);
  box-shadow: 0 0 24px rgba(122, 61, 255, 0.35);
  color: #e9d5ff;
}

.mg-game-block-icon svg {
  width: 28px;
  height: 28px;
  display: block;
}

.mg-game-block-icon .mg-ico-play {
  display: block;
}

.mg-game-block-icon .mg-ico-hourglass {
  display: none;
}

/* 로딩/종료 중 — 모래시계 */
.mg-game-block-icon.is-hourglass .mg-ico-play,
.mg-game-block.is-ending .mg-game-block-icon .mg-ico-play {
  display: none;
}

.mg-game-block-icon.is-hourglass .mg-ico-hourglass,
.mg-game-block.is-ending .mg-game-block-icon .mg-ico-hourglass {
  display: block;
  animation: demo2-hourglass-flip 1.45s ease-in-out infinite;
  transform-origin: 50% 50%;
}

.mg-game-block-icon.is-hourglass,
.mg-game-block.is-ending .mg-game-block-icon {
  border-color: rgba(77, 125, 255, 0.55);
  box-shadow: 0 0 28px rgba(77, 125, 255, 0.35);
  background:
    radial-gradient(circle at 35% 30%, rgba(77, 125, 255, 0.35), transparent 55%),
    rgba(77, 125, 255, 0.18);
  color: #c7d7ff;
}

@keyframes demo2-hourglass-flip {
  0%,
  38% {
    transform: rotate(0deg);
  }
  50%,
  88% {
    transform: rotate(180deg);
  }
  100% {
    transform: rotate(360deg);
  }
}

.mg-game-block-title {
  margin: 0 0 10px;
  color: #f4f6ff;
  font-size: 1.2rem;
  font-weight: 800;
  letter-spacing: -0.02em;
  line-height: 1.4;
}

.mg-game-block.is-ending .mg-game-block-title {
  font-size: 1.05rem;
  line-height: 1.45;
}

.mg-game-block-desc {
  margin: 0 0 26px;
  padding: 0;
  list-style: none;
  color: rgba(201, 198, 216, 0.88);
  font-size: 0.92rem;
  line-height: 1.65;
  text-align: left;
}

.mg-game-block.is-ending .mg-game-block-desc {
  text-align: center;
  list-style: none;
}

.mg-game-block.is-ending .mg-game-block-desc li::before {
  content: none;
}

.mg-game-block-desc li {
  position: relative;
  padding-left: 14px;
}

.mg-game-block.is-ending .mg-game-block-desc li {
  padding-left: 0;
}

.mg-game-block-desc li + li {
  margin-top: 6px;
}

.mg-game-block-desc li::before {
  content: "-";
  position: absolute;
  left: 0;
  top: 0;
  color: rgba(201, 198, 216, 0.75);
}

.mg-game-block-end {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 180px;
  height: 48px;
  padding: 0 28px;
  border: 0;
  border-radius: 12px;
  background: linear-gradient(90deg, #b56bff, #7a3dff 48%, #4d7dff);
  color: #fff;
  font-size: 0.98rem;
  font-weight: 800;
  letter-spacing: -0.01em;
  cursor: pointer;
  box-shadow: 0 10px 28px rgba(122, 61, 255, 0.35);
  transition: filter 0.15s ease, transform 0.15s ease, opacity 0.15s ease;
}

.mg-game-block-end:hover:not(:disabled) {
  filter: brightness(1.08);
  transform: translateY(-1px);
  color: #fff;
}

.mg-game-block-end:disabled,
.mg-game-block.is-ending .mg-game-block-end {
  opacity: 0.48;
  cursor: not-allowed;
  filter: none;
  pointer-events: none;
  transform: none;
  box-shadow: none;
}

body.mg-game-blocked {
  overflow: hidden;
}

/* demo2: 부모창 딤(block)만 유지 — 안내 메시지 박스 숨김
 * 모바일 iframe DIV는 상단 닫기만 사용(하단 패널 없음) */
body.mg-game-blocked:not(.mg-game-same-window) .mg-game-block-panel {
  display: none !important;
}

/* demo2 모바일 — 하단 「게임 실행 중」 패널 완전 제거 */
body.page-demo2-game-parent.mg-game-same-window .mg-game-block,
body.page-demo2-game-parent.mg-game-iframe-popup .mg-game-block {
  display: none !important;
}

body.page-demo2-home .game-launch-block-panel,
body.page-demo2 .game-launch-block-panel {
  display: none !important;
}

/* —— 클릭 직후 로딩 블록(game-launch-guard) —— */
body.page-demo2-home .game-launch-block,
body.page-demo2 .game-launch-block {
  background:
    radial-gradient(ellipse 70% 50% at 50% 35%, rgba(122, 61, 255, 0.16), transparent 60%),
    rgba(7, 7, 22, 0.55);
  backdrop-filter: blur(2px);
  -webkit-backdrop-filter: blur(2px);
}

body.page-demo2-home .game-launch-block-panel,
body.page-demo2 .game-launch-block-panel {
  border: 1px solid rgba(181, 107, 255, 0.45);
  border-radius: 18px;
  background: linear-gradient(180deg, rgba(36, 22, 62, 0.95) 0%, rgba(14, 10, 28, 0.98) 100%);
  box-shadow:
    0 0 0 1px rgba(122, 61, 255, 0.12),
    0 24px 64px rgba(0, 0, 0, 0.55),
    0 0 36px rgba(122, 61, 255, 0.16);
}

body.page-demo2-home .game-launch-block-spinner,
body.page-demo2 .game-launch-block-spinner {
  width: 52px;
  height: 52px;
  margin: 0 auto 16px;
  border: 0;
  border-radius: 50%;
  background:
    radial-gradient(circle at 35% 30%, rgba(181, 107, 255, 0.35), transparent 55%),
    rgba(122, 61, 255, 0.2);
  box-shadow: 0 0 22px rgba(122, 61, 255, 0.35);
  animation: none;
  display: flex;
  align-items: center;
  justify-content: center;
  color: #e9d5ff;
}

body.page-demo2-home .game-launch-block-spinner svg,
body.page-demo2 .game-launch-block-spinner svg {
  width: 26px;
  height: 26px;
  animation: demo2-hourglass-flip 1.45s ease-in-out infinite;
  transform-origin: 50% 50%;
}

body.page-demo2-home .game-launch-block-title,
body.page-demo2 .game-launch-block-title {
  color: #f4f6ff;
}

body.page-demo2-home .game-launch-block-text,
body.page-demo2 .game-launch-block-text {
  color: rgba(201, 198, 216, 0.88);
}

@media (max-width: 560px) {
  .mg-game-block-panel {
    padding: 28px 18px 22px;
    border-radius: 14px;
  }

  .mg-game-block-title {
    font-size: 1.05rem;
  }

  .mg-game-block-end {
    width: 100%;
    min-width: 0;
  }
}

/* 모바일 같은 창 실행 — 팝업 없이 iframe + 하단 종료 패널 */
.mg-game-same-frame {
  position: fixed;
  inset: 0;
  z-index: 9990;
  width: 100%;
  height: 100%;
  border: 0;
  background: #070716;
}

/* 같은 창 게임 iframe 사용 시 배경 미리보기는 숨김 */
body.mg-game-same-window .mg-game-parent-preview {
  display: none;
}

/* demo2 모바일 same-window 레거시 — 하단 패널 미사용(상단 닫기 iframe shell) */
body.page-demo2-game-parent.mg-game-same-window .mg-game-block-panel {
  display: none !important;
}

body:not(.page-demo2-game-parent).mg-game-same-window .mg-game-block {
  background: transparent;
  pointer-events: none;
}

body:not(.page-demo2-game-parent).mg-game-same-window .mg-game-block-panel {
  position: fixed;
  left: 50%;
  bottom: max(12px, env(safe-area-inset-bottom));
  transform: translateX(-50%);
  z-index: 10001;
  width: min(440px, calc(100% - 20px));
  padding: 14px 16px 16px;
  pointer-events: auto;
}

body:not(.page-demo2-game-parent).mg-game-same-window .mg-game-block-icon,
body:not(.page-demo2-game-parent).mg-game-same-window .mg-game-block-desc {
  display: none;
}

body:not(.page-demo2-game-parent).mg-game-same-window .mg-game-block-title {
  margin: 0 0 12px;
  font-size: 0.95rem;
}

body:not(.page-demo2-game-parent).mg-game-same-window .mg-game-block-end {
  width: 100%;
  min-width: 0;
  height: 44px;
}

/* 모바일 iframe DIV — 상단 닫기, 실행중 안내 패널 숨김 (유자망과 동일 동작) */
body.mg-game-iframe-popup .mg-game-block,
body.mg-game-iframe-popup .mg-game-block.is-iframe-popup {
  display: none !important;
}

.mg-game-iframe-shell {
  position: fixed;
  inset: 0;
  z-index: 10020;
  display: flex;
  flex-direction: column;
  background: #070716;
}

.mg-game-iframe-bar {
  flex: 0 0 auto;
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: 8px;
  min-height: 48px;
  padding: max(8px, env(safe-area-inset-top)) 12px 8px;
  background: linear-gradient(180deg, rgba(20, 14, 38, 0.98) 0%, rgba(10, 8, 22, 0.98) 100%);
  border-bottom: 1px solid rgba(181, 107, 255, 0.25);
}

.mg-game-iframe-close {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 72px;
  height: 36px;
  padding: 0 14px;
  border: 0;
  border-radius: 10px;
  background: linear-gradient(135deg, #7a3dff 0%, #4d7dff 100%);
  color: #fff;
  font-size: 14px;
  font-weight: 700;
  cursor: pointer;
  box-shadow: 0 4px 14px rgba(122, 61, 255, 0.35);
}

.mg-game-iframe-close:active {
  filter: brightness(1.08);
}

/* demo2 모바일 iframe — 상단 닫기 없이 전체 화면 */
body.page-demo2-game-parent.mg-game-iframe-no-bar .mg-game-iframe-bar,
body.page-demo2-game-parent .mg-game-iframe-shell--no-bar .mg-game-iframe-bar {
  display: none !important;
}

body.page-demo2-game-parent.mg-game-iframe-no-bar .mg-game-iframe-shell .mg-game-same-frame,
body.page-demo2-game-parent .mg-game-iframe-shell--no-bar .mg-game-same-frame {
  position: fixed;
  inset: 0;
  flex: none;
  width: 100%;
  height: 100%;
  min-height: 100%;
  padding-top: env(safe-area-inset-top);
  padding-bottom: env(safe-area-inset-bottom);
  box-sizing: border-box;
}

.mg-game-iframe-shell .mg-game-same-frame {
  position: relative;
  inset: auto;
  flex: 1 1 auto;
  width: 100%;
  height: auto;
  min-height: 0;
  z-index: 1;
  border: 0;
  background: #000;
}
