/* css/game.css
 * Sky Defender 미니 게임 모달 스타일.
 * 시계 모드 좌측 메뉴 '게임' 아이콘을 통해 열리는 모달 전용.
 * 다른 .modal 공통 스타일은 css/style.css의 .overlay > div / .modal 규칙을 그대로 활용한다.
 */

/* 모달 기본 박스: 캔버스 가로 480 + 좌우 패딩을 안전하게 확보 */
.game-modal {
  width: 540px;
  max-width: 95vw;
  max-height: 95dvh;
  padding: 22px 26px 18px 26px !important;
  display: flex;
  flex-direction: column;
  align-items: center;
  overflow: hidden;
  background: linear-gradient(180deg, #0e1726 0%, #04070f 100%) !important;
  color: #e6edf6;
  user-select: none;
  -webkit-user-select: none;
}

.game-modal h3 {
  margin: 0 0 10px 0;
  font-size: 22px;
  font-weight: 700;
  letter-spacing: 0.08em;
  color: #cbe2ff;
  text-shadow: 0 0 12px rgba(120, 180, 255, 0.35);
}

/* HUD: 점수/생명/웨이브/베스트 */
.game-hud {
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  gap: 14px;
  width: 100%;
  margin-bottom: 10px;
  font-size: 14px;
  color: #b9c8de;
}

.game-hud-item {
  background: rgba(255, 255, 255, 0.06);
  border: 1px solid rgba(255, 255, 255, 0.08);
  padding: 4px 10px;
  border-radius: 8px;
  white-space: nowrap;
}

.game-hud-item b {
  color: #ffd24a;
  margin-left: 4px;
  font-variant-numeric: tabular-nums;
}

/* World HUD: 글로벌 최고 점수 (이름 + 점수) */
.game-hud-item.game-hud-world {
  background: linear-gradient(180deg, rgba(255, 200, 80, 0.18), rgba(120, 80, 40, 0.18));
  border-color: rgba(255, 200, 80, 0.35);
  color: #ffe9b0;
  display: inline-flex;
  align-items: center;
  gap: 5px;
}

.game-hud-item.game-hud-world i {
  color: #ffd24a;
  font-size: 12px;
}

.game-hud-item.game-hud-world #gameWorldName {
  color: #ffe9b0;
  max-width: 120px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  display: inline-block;
  vertical-align: bottom;
}

.game-hud-item.game-hud-world #gameWorldScore {
  color: #ffd24a;
  margin-left: 0;
}

/* 캔버스 래퍼: 게임오버/일시정지 오버레이 텍스트 띄우기 위한 컨테이너 */
.game-canvas-wrap {
  position: relative;
  width: 480px;
  max-width: 100%;
  margin: 0 auto;
  border-radius: 10px;
  overflow: hidden;
  background: #02050b;
  box-shadow:
    inset 0 0 0 1px rgba(120, 180, 255, 0.18),
    0 8px 24px rgba(0, 0, 0, 0.5),
    0 0 24px rgba(80, 160, 255, 0.12);
}

#gameCanvas {
  display: block;
  width: 100%;
  height: auto;
  aspect-ratio: 3 / 4;
  outline: none;
  cursor: crosshair;
  image-rendering: auto;
}

.game-overlay-msg {
  position: absolute;
  inset: 0;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  text-align: center;
  background: rgba(0, 0, 0, 0.55);
  color: #fff;
  padding: 20px;
  pointer-events: none;
}

.game-overlay-msg .big {
  font-size: 32px;
  font-weight: 800;
  letter-spacing: 0.06em;
  color: #ffd24a;
  text-shadow: 0 0 18px rgba(255, 200, 80, 0.55);
  margin-bottom: 6px;
}

.game-overlay-msg .small {
  font-size: 14px;
  opacity: 0.9;
  color: #cfe1ff;
}

/* ─── READY 타이틀 신: 캔버스에 그려지는 영웅기를 가리지 않도록 ─── */
.game-overlay-msg.ready {
  /* 상하단만 살짝 어둡게 두어 텍스트 가독성을 확보, 가운데는 투명 → hero 노출 */
  background: linear-gradient(180deg,
    rgba(0, 0, 0, 0.25) 0%,
    rgba(0, 0, 0, 0.00) 22%,
    rgba(0, 0, 0, 0.00) 75%,
    rgba(0, 0, 0, 0.45) 100%);
  justify-content: space-between;
  padding: 36px 20px 28px;
}

.game-overlay-msg.ready .big {
  font-size: 58px;
  font-weight: 900;
  letter-spacing: 0.18em;
  color: #fff6cc;
  text-shadow:
    0 0 24px rgba(255, 200, 80, 0.85),
    0 0 10px rgba(255, 255, 255, 0.7),
    0 2px 0 rgba(0, 0, 0, 0.55);
  margin: 0;
  animation: ready-pulse 2.4s ease-in-out infinite;
}

.game-overlay-msg.ready .small {
  font-size: 14px;
  color: #e6f0ff;
  text-shadow: 0 0 8px rgba(0, 0, 0, 0.85), 0 0 16px rgba(0, 0, 0, 0.6);
  letter-spacing: 0.04em;
  margin: 0;
}

@keyframes ready-pulse {
  0%, 100% { transform: scale(1);    opacity: 1;   }
  50%      { transform: scale(1.04); opacity: 0.92;}
}

/* 모션 감소 선호 시 깜빡임 비활성화 */
@media (prefers-reduced-motion: reduce) {
  .game-overlay-msg.ready .big { animation: none; }
}

/* PAUSE / GAME OVER 는 기존 어두운 풀스크린 배경 유지 (가독성 우선) */
.game-overlay-msg.pause,
.game-overlay-msg.gameover {
  background: rgba(0, 0, 0, 0.55);
}

/* 세계 신기록 입력 폼 (게임오버 시 점수가 세계 기록을 넘었을 때만 표시) */
.game-record-form {
  position: absolute;
  inset: 0;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  text-align: center;
  background: linear-gradient(180deg, rgba(20, 30, 60, 0.88), rgba(0, 0, 0, 0.92));
  color: #fff;
  padding: 24px 18px;
  gap: 10px;
  z-index: 5;
}

.game-record-form .game-record-title {
  font-size: 22px;
  font-weight: 800;
  letter-spacing: 0.08em;
  color: #ffd24a;
  text-shadow: 0 0 18px rgba(255, 200, 80, 0.55);
  margin-bottom: 6px;
}

.game-record-form .game-record-label {
  font-size: 13px;
  color: #cfe1ff;
  opacity: 0.95;
}

.game-record-form .game-record-input {
  width: min(280px, 80%);
  padding: 10px 12px;
  background: rgba(255, 255, 255, 0.08);
  border: 1px solid rgba(140, 190, 255, 0.4);
  border-radius: 8px;
  color: #fff;
  font-size: 15px;
  text-align: center;
  outline: none;
  transition: border-color 0.15s ease, box-shadow 0.15s ease;
}

.game-record-form .game-record-input:focus {
  border-color: rgba(255, 200, 80, 0.7);
  box-shadow: 0 0 0 2px rgba(255, 200, 80, 0.25);
}

.game-record-form .game-record-buttons {
  display: flex;
  gap: 10px;
  margin-top: 6px;
}

.game-record-form .modal-btn {
  min-width: 86px;
  padding: 8px 14px;
  border-radius: 8px;
  cursor: pointer;
  font-weight: 600;
  color: #eaf2ff;
  background: linear-gradient(180deg, rgba(60, 120, 200, 0.45), rgba(20, 60, 120, 0.6));
  border: 1px solid rgba(140, 190, 255, 0.4);
  transition: transform 0.12s ease, background 0.2s ease, box-shadow 0.2s ease;
}

.game-record-form #gameRecordSubmitBtn {
  background: linear-gradient(180deg, rgba(255, 200, 80, 0.6), rgba(180, 120, 30, 0.7));
  border-color: rgba(255, 220, 120, 0.6);
  color: #1a1206;
}

.game-record-form .modal-btn:hover {
  transform: translateY(-1px);
  box-shadow: 0 4px 14px rgba(80, 160, 255, 0.25);
}

.game-record-form .game-record-status {
  font-size: 12px;
  min-height: 16px;
  color: #cfe1ff;
  opacity: 0.9;
}

.game-record-form .game-record-status.error {
  color: #ffb3b3;
}

.game-record-form .game-record-status.success {
  color: #b3ffb8;
}

/* 컨트롤 힌트 */
.game-controls-hint {
  margin-top: 10px;
  font-size: 12px;
  color: #8aa1c0;
  letter-spacing: 0.02em;
  text-align: center;
}

/* 버튼 행 */
.game-buttons {
  margin-top: 10px;
  display: flex;
  gap: 10px;
  justify-content: center;
  flex-wrap: wrap;
}

.game-buttons .modal-btn {
  min-width: 86px;
  padding: 8px 14px;
  background: linear-gradient(180deg, rgba(60, 120, 200, 0.35), rgba(20, 60, 120, 0.5));
  border: 1px solid rgba(140, 190, 255, 0.35);
  color: #eaf2ff;
  border-radius: 8px;
  cursor: pointer;
  font-weight: 600;
  transition: transform 0.12s ease, background 0.2s ease, box-shadow 0.2s ease;
}

.game-buttons .modal-btn:hover {
  transform: translateY(-1px);
  background: linear-gradient(180deg, rgba(80, 150, 230, 0.45), rgba(30, 80, 150, 0.6));
  box-shadow: 0 4px 14px rgba(80, 160, 255, 0.25);
}

.game-buttons .modal-btn:active {
  transform: translateY(0);
}

.game-buttons #gameSoundBtn[aria-pressed="true"] {
  background: linear-gradient(180deg, rgba(80, 200, 120, 0.4), rgba(20, 100, 60, 0.55));
  border-color: rgba(120, 230, 160, 0.5);
}

/* 좁은 화면에서 모달이 너무 커지지 않도록 */
@media (max-width: 560px) {
  .game-modal {
    width: 95vw;
    padding: 16px 14px 14px 14px !important;
  }
  .game-hud {
    font-size: 12px;
    gap: 8px;
  }
  .game-controls-hint {
    font-size: 11px;
  }
}
