/* ==========================================================================
   화려한 프리미엄 마작 솔리테어 (Mahjong Solitaire) 스타일시트
   ========================================================================== */

:root {
  --tile-width: 44px;
  --tile-height: 58px;
  --tile-depth: 7px;
  --layer-step-x: 3px;
  --layer-step-y: 3px;
}

@media (min-width: 640px) {
  :root {
    --tile-width: 50px;
    --tile-height: 66px;
    --tile-depth: 8px;
    --layer-step-x: 4px;
    --layer-step-y: 4px;
  }
}

@media (min-width: 1024px) {
  :root {
    --tile-width: 54px;
    --tile-height: 72px;
    --tile-depth: 9px;
    --layer-step-x: 5px;
    --layer-step-y: 5px;
  }
}

/* 메인 배경 - 럭셔리 다크 에메랄드 & 골드 오리엔탈 벨벳 */
.mahjong-bg {
  background-color: #041412;
  background-image: 
    radial-gradient(circle at 50% 20%, rgba(20, 83, 68, 0.5) 0%, rgba(6, 32, 27, 0.8) 50%, #030e0c 100%),
    radial-gradient(rgba(245, 158, 11, 0.08) 1px, transparent 1px);
  background-size: 100% 100%, 32px 32px;
  background-position: 0 0, 16px 16px;
  position: relative;
  overflow-x: hidden;
}

/* 앰비언트 글로우 오브 */
.ambient-glow {
  position: absolute;
  width: 500px;
  height: 500px;
  border-radius: 50%;
  filter: blur(120px);
  pointer-events: none;
  opacity: 0.15;
  z-index: 0;
}
.glow-gold {
  top: -100px;
  right: -100px;
  background: radial-gradient(circle, #f59e0b, transparent 70%);
}
.glow-emerald {
  bottom: -100px;
  left: -100px;
  background: radial-gradient(circle, #10b981, transparent 70%);
}

/* 게임 보드 래퍼 및 3D 원근법 */
.board-viewport {
  position: relative;
  width: 100%;
  min-height: 560px;
  display: flex;
  justify-content: center;
  align-items: center;
  perspective: 1200px;
  overflow: auto;
  padding: 24px 12px;
  user-select: none;
  -webkit-user-select: none;
}

.board-container {
  position: relative;
  transition: transform 0.6s cubic-bezier(0.16, 1, 0.3, 1);
  transform-style: preserve-3d;
  margin: 0 auto;
}

/* 3D 뷰 활성화 시 */
.board-container.is-3d {
  transform: rotateX(24deg) rotateZ(-2deg) scale(0.96);
}

/* 파티클 캔버스 */
#fx-canvas {
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  pointer-events: none;
  z-index: 500;
}

/* ==========================================================================
   마작 타일 (Mahjong Tile) 3D 입체 디자인
   ========================================================================== */
.mahjong-tile {
  position: absolute;
  width: var(--tile-width);
  height: var(--tile-height);
  box-sizing: border-box;
  cursor: pointer;
  transform-style: preserve-3d;
  transform: translate(var(--tx), var(--ty));
  transition: transform 0.18s cubic-bezier(0.2, 0.8, 0.4, 1), 
              box-shadow 0.18s ease, 
              filter 0.2s ease,
              opacity 0.25s ease;
  border-radius: 6px;
}

/* 타일 베이스 구조 (녹색 옥/비취 뒷면 + 상아빛 전면) */
.tile-inner {
  position: relative;
  width: 100%;
  height: 100%;
  border-radius: 6px;
  background: linear-gradient(135deg, #ffffff 0%, #faf6eb 50%, #f1e8d4 100%);
  display: flex;
  flex-direction: column;
  justify-content: center;
  align-items: center;
  box-sizing: border-box;
  border: 1px solid rgba(220, 205, 175, 0.8);
  /* 3D 비취 두께 레이어 시각화 */
  box-shadow: 
    inset 0 1px 1px rgba(255, 255, 255, 0.9),
    inset 0 -1px 2px rgba(160, 130, 85, 0.25),
    2px 2px 0px #0b4535,
    3px 3px 0px #083428,
    4px 4px 0px #06261d,
    5px 5px 6px rgba(0, 0, 0, 0.45);
}

/* 상단 은은한 유리/본차이나 광택 리플렉션 */
.tile-inner::before {
  content: '';
  position: absolute;
  top: 1px;
  left: 2px;
  right: 2px;
  height: 38%;
  background: linear-gradient(180deg, rgba(255, 255, 255, 0.65) 0%, rgba(255, 255, 255, 0) 100%);
  border-radius: 4px 4px 0 0;
  pointer-events: none;
}

/* 타일 인덱스 라벨 (왼쪽 상단 보조 숫자) */
.tile-index-badge {
  position: absolute;
  top: 2px;
  left: 3px;
  font-size: 9px;
  font-weight: 800;
  color: #786b59;
  font-family: ui-sans-serif, system-ui, sans-serif;
  line-height: 1;
  pointer-events: none;
  opacity: 0.75;
}

/* 타일 페이스 그래픽 래퍼 */
.tile-face {
  width: 100%;
  height: 100%;
  display: flex;
  justify-content: center;
  align-items: center;
  position: relative;
  z-index: 2;
  padding: 4px;
}

/* 레이어 깊이에 따른 추가 그림자 (Z-Level Shadows) */
.mahjong-tile[data-z="0"] .tile-inner {
  box-shadow: 
    inset 0 1px 1px rgba(255, 255, 255, 0.9),
    2px 2px 0px #0b4535,
    3px 3px 0px #06261d,
    3px 5px 6px rgba(0, 0, 0, 0.4);
}
.mahjong-tile[data-z="1"] .tile-inner {
  box-shadow: 
    inset 0 1px 1px rgba(255, 255, 255, 0.9),
    2px 2px 0px #0b4535,
    3px 3px 0px #083428,
    4px 4px 0px #06261d,
    5px 8px 10px rgba(0, 0, 0, 0.5);
}
.mahjong-tile[data-z="2"] .tile-inner {
  box-shadow: 
    inset 0 1px 1px rgba(255, 255, 255, 0.9),
    2px 2px 0px #0b4535,
    3px 3px 0px #083428,
    4px 4px 0px #06261d,
    5px 5px 0px #041a14,
    7px 11px 14px rgba(0, 0, 0, 0.55);
}
.mahjong-tile[data-z="3"] .tile-inner {
  box-shadow: 
    inset 0 1px 1px rgba(255, 255, 255, 0.9),
    3px 3px 0px #0b4535,
    4px 4px 0px #083428,
    5px 5px 0px #06261d,
    6px 6px 0px #041a14,
    9px 14px 18px rgba(0, 0, 0, 0.6);
}
.mahjong-tile[data-z="4"] .tile-inner {
  box-shadow: 
    inset 0 1px 1px rgba(255, 255, 255, 0.9),
    3px 3px 0px #0b4535,
    5px 5px 0px #083428,
    6px 6px 0px #06261d,
    7px 7px 0px #041a14,
    11px 17px 22px rgba(0, 0, 0, 0.65);
}

/* ==========================================================================
   타일 인터랙션 상태 (자유 / 잠김 / 선택 / 힌트)
   ========================================================================== */

/* 자유 타일 호버 시 3D 살짝 부유 리프트 */
.mahjong-tile.is-free:hover {
  transform: translate(calc(var(--tx) - 2px), calc(var(--ty) - 5px)) scale(1.03);
  z-index: 100 !important;
}
.mahjong-tile.is-free:hover .tile-inner {
  border-color: #f59e0b;
  box-shadow: 
    inset 0 1px 2px rgba(255, 255, 255, 1),
    0 0 15px rgba(245, 158, 11, 0.55),
    3px 3px 0px #0b4535,
    4px 4px 0px #083428,
    6px 12px 16px rgba(0, 0, 0, 0.6);
}

/* 선택된 타일 - 황금빛 아우라 & 펄스 애니메이션 */
.mahjong-tile.is-selected {
  transform: translate(calc(var(--tx) - 3px), calc(var(--ty) - 8px)) scale(1.06) !important;
  z-index: 120 !important;
}
.mahjong-tile.is-selected .tile-inner {
  background: linear-gradient(135deg, #ffffff 0%, #fef3c7 60%, #fde68a 100%);
  border: 2px solid #f59e0b;
  animation: tileSelectedPulse 1.4s ease-in-out infinite alternate;
  box-shadow: 
    0 0 20px #f59e0b, 
    0 0 35px rgba(245, 158, 11, 0.65),
    3px 3px 0px #b45309,
    5px 5px 0px #78350f,
    8px 15px 22px rgba(0, 0, 0, 0.65);
}
@keyframes tileSelectedPulse {
  0% { box-shadow: 0 0 12px #f59e0b, 0 0 24px rgba(245, 158, 11, 0.5); }
  100% { box-shadow: 0 0 22px #fbbf24, 0 0 45px rgba(251, 191, 36, 0.85); }
}

/* 잠긴 타일 (Dimmed) - 시각적 어시스트 활성화 시 */
.highlight-free .mahjong-tile:not(.is-free) {
  filter: brightness(0.68) saturate(0.65);
  cursor: not-allowed;
}

/* 힌트 타일 하이라이트 */
.mahjong-tile.is-hint {
  z-index: 110 !important;
  animation: hintBlink 0.7s ease-in-out infinite alternate;
}
.mahjong-tile.is-hint .tile-inner {
  border: 2px solid #38bdf8 !important;
}
@keyframes hintBlink {
  0% { 
    transform: translate(var(--tx), var(--ty)) scale(1);
    filter: drop-shadow(0 0 4px #38bdf8);
  }
  100% { 
    transform: translate(calc(var(--tx) - 2px), calc(var(--ty) - 6px)) scale(1.06);
    filter: drop-shadow(0 0 16px #0284c7) drop-shadow(0 0 28px #38bdf8);
  }
}

/* 타일 매칭 제거 애니메이션 */
.mahjong-tile.is-matched {
  pointer-events: none;
  animation: tileVanish 0.45s cubic-bezier(0.2, 0.8, 0.2, 1) forwards;
  z-index: 200 !important;
}
@keyframes tileVanish {
  0% {
    transform: translate(var(--tx), var(--ty)) scale(1.06);
    opacity: 1;
    filter: brightness(1.5);
  }
  50% {
    transform: translate(var(--tx), calc(var(--ty) - 22px)) scale(1.2) rotateZ(8deg);
    opacity: 0.85;
    filter: brightness(2.2) drop-shadow(0 0 25px #f59e0b);
  }
  100% {
    transform: translate(var(--tx), calc(var(--ty) - 45px)) scale(0.3) rotateZ(-15deg);
    opacity: 0;
    filter: brightness(3);
  }
}

/* ==========================================================================
   화려한 콤보 플로팅 배너 & 점수 효과
   ========================================================================== */
.floating-combo-box {
  position: absolute;
  pointer-events: none;
  z-index: 600;
  display: flex;
  flex-direction: column;
  align-items: center;
  transform: translate(-50%, -50%);
  animation: comboFloat 0.95s cubic-bezier(0.16, 1, 0.3, 1) forwards;
}
.combo-banner-title {
  font-family: 'Pretendard', system-ui, sans-serif;
  font-weight: 900;
  font-size: 26px;
  letter-spacing: -0.5px;
  background: linear-gradient(180deg, #fffbeb 0%, #fbbf24 40%, #ea580c 100%);
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  filter: drop-shadow(0 2px 8px rgba(0, 0, 0, 0.8)) drop-shadow(0 0 15px rgba(245, 158, 11, 0.8));
  text-transform: uppercase;
}
.combo-banner-sub {
  font-size: 13px;
  font-weight: 800;
  color: #fef08a;
  text-shadow: 0 1px 4px rgba(0, 0, 0, 0.9);
  margin-top: -3px;
}
@keyframes comboFloat {
  0% {
    opacity: 0;
    transform: translate(-50%, -20%) scale(0.5);
  }
  20% {
    opacity: 1;
    transform: translate(-50%, -50%) scale(1.18);
  }
  40% {
    transform: translate(-50%, -60%) scale(1);
  }
  80% {
    opacity: 1;
    transform: translate(-50%, -85%) scale(1);
  }
  100% {
    opacity: 0;
    transform: translate(-50%, -110%) scale(0.85);
  }
}

/* ==========================================================================
   조작 패널 & 글래스모피즘 HUD UI
   ========================================================================== */
.glass-panel {
  background: rgba(10, 35, 30, 0.75);
  backdrop-filter: blur(14px);
  -webkit-backdrop-filter: blur(14px);
  border: 1px solid rgba(245, 158, 11, 0.25);
  box-shadow: 0 8px 32px rgba(0, 0, 0, 0.5), inset 0 1px 0 rgba(255, 255, 255, 0.1);
}

.hud-btn {
  transition: all 0.15s cubic-bezier(0.2, 0.8, 0.2, 1);
  box-shadow: 0 3px 8px rgba(0, 0, 0, 0.4), inset 0 1px 0 rgba(255, 255, 255, 0.2);
}
.hud-btn:hover {
  transform: translateY(-2px);
  box-shadow: 0 6px 16px rgba(0, 0, 0, 0.5), 0 0 12px rgba(245, 158, 11, 0.4);
}
.hud-btn:active {
  transform: translateY(1px);
  box-shadow: 0 1px 4px rgba(0, 0, 0, 0.4);
}

/* 승리 모달 애니메이션 */
.modal-overlay {
  background: rgba(2, 12, 10, 0.85);
  backdrop-filter: blur(10px);
}
.victory-card {
  background: radial-gradient(circle at 50% 20%, #134237 0%, #08211b 70%, #03100d 100%);
  border: 2px solid #f59e0b;
  box-shadow: 0 0 50px rgba(245, 158, 11, 0.4), 0 25px 50px rgba(0, 0, 0, 0.8);
}
