/* ==========================================================================
   The Binding of Isaac - Web Edition Theme CSS
   ========================================================================== */

:root {
  --bg-dark: #0f0b08;
  --dungeon-wall: #261912;
  --dungeon-floor: #3d281c;
  --border-gold: #c9933b;
  --blood-red: #b31e1e;
  --blood-glow: rgba(179, 30, 30, 0.4);
  --soul-blue: #4aa3df;
  --text-parchment: #eedbb6;
  --text-muted: #9e8975;
  --will-bg: #e4d1b5;
  --will-text: #2c1b12;
}

* {
  margin: 0;
  padding: 0;
  box-sizing: border-box;
  -webkit-tap-highlight-color: transparent;
  user-select: none;
  -webkit-user-select: none;
}

html, body {
  width: 100%;
  height: 100%;
  overflow: hidden;
  background-color: var(--bg-dark);
  font-family: 'Cinzel', 'Pretendard', sans-serif;
  color: var(--text-parchment);
  touch-action: none;
}

/* 게임 메인 컨테이너 */
#gameContainer {
  position: relative;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: space-between;
  width: 100vw;
  height: 100vh;
  height: 100dvh;
  padding: 6px 10px;
  background: radial-gradient(circle at 50% 40%, #2a1810 0%, #0d0805 85%);
}

/* 상단 아이작 HUD */
#gameHUD {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  width: 100%;
  max-width: 960px;
  height: 64px;
  z-index: 10;
  pointer-events: none;
}

#gameHUD button {
  pointer-events: auto;
}

.hud-left-panel {
  display: flex;
  flex-direction: column;
  gap: 4px;
}

/* 하트 컨테이너 */
.hearts-row {
  display: flex;
  align-items: center;
  gap: 3px;
  min-height: 24px;
  filter: drop-shadow(0 2px 4px rgba(0, 0, 0, 0.8));
}

.hud-heart {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  font-size: 20px;
  animation: heartPulse 2.4s infinite ease-in-out;
}

.hud-heart.soul {
  color: var(--soul-blue);
  filter: drop-shadow(0 0 6px rgba(74, 163, 223, 0.6));
}

/* 자원 행 (동전, 폭탄, 열쇠) */
.resources-row {
  display: flex;
  align-items: center;
  gap: 12px;
  font-family: 'Press Start 2P', monospace;
  font-size: 11px;
  color: #fff;
  text-shadow: 1px 1px 0 #000, -1px -1px 0 #000, 1px -1px 0 #000, -1px 1px 0 #000;
}

.resource-item {
  display: flex;
  align-items: center;
  gap: 4px;
}

.res-icon {
  font-size: 14px;
}

.floor-badge {
  font-size: 11px;
  font-weight: 700;
  color: var(--border-gold);
  letter-spacing: 1px;
  text-shadow: 0 0 6px rgba(201, 147, 59, 0.5);
}

/* 보스 체력바 */
.boss-bar-panel {
  display: flex;
  flex-direction: column;
  align-items: center;
  width: 320px;
  max-width: 40%;
  animation: fadeInDown 0.3s ease-out;
}

.boss-info-row {
  display: flex;
  align-items: center;
  gap: 6px;
  margin-bottom: 3px;
}

.boss-skull {
  font-size: 14px;
  animation: skullPulse 1.2s infinite alternate;
}

.boss-name {
  font-size: 12px;
  font-weight: 900;
  letter-spacing: 2px;
  color: #ff3333;
  text-shadow: 0 0 8px var(--blood-glow);
}

.boss-bar-track {
  width: 100%;
  height: 12px;
  background: #1a0a0a;
  border: 2px solid #5a1a1a;
  border-radius: 4px;
  overflow: hidden;
  box-shadow: 0 0 10px rgba(0, 0, 0, 0.8), inset 0 0 5px #000;
}

.boss-bar-fill {
  height: 100%;
  background: linear-gradient(90deg, #ff1a1a 0%, #b30000 100%);
  box-shadow: 0 0 8px #ff3333;
  transition: width 0.15s ease-out;
}

/* 우측 패널 (버튼 & 미니맵) */
.hud-right-panel {
  display: flex;
  flex-direction: column;
  align-items: flex-end;
  gap: 6px;
}

.hud-buttons {
  display: flex;
  gap: 6px;
}

.hud-btn {
  background: rgba(38, 25, 18, 0.85);
  border: 1px solid var(--border-gold);
  border-radius: 4px;
  color: var(--text-parchment);
  font-size: 14px;
  padding: 4px 8px;
  cursor: pointer;
  box-shadow: 0 2px 6px rgba(0, 0, 0, 0.5);
  transition: all 0.15s ease;
}

.hud-btn:hover {
  background: #4d3324;
  border-color: #ffd700;
  transform: translateY(-1px);
}

.minimap-wrapper {
  background: rgba(15, 11, 8, 0.8);
  border: 2px solid #543c2c;
  border-radius: 6px;
  padding: 2px;
  box-shadow: 0 4px 10px rgba(0, 0, 0, 0.7);
}

#minimapCanvas {
  display: block;
}

/* 메인 캔버스 래퍼 */
#canvasWrapper {
  position: relative;
  display: flex;
  align-items: center;
  justify-content: center;
  flex: 1;
  width: 100%;
  max-width: 960px;
  margin: 4px 0;
  border-radius: 10px;
  overflow: hidden;
  border: 3px solid #3d281c;
  box-shadow: 0 10px 30px rgba(0, 0, 0, 0.9), inset 0 0 20px #000;
  background: #180f0a;
}

#gameCanvas {
  display: block;
  width: 100%;
  height: 100%;
  max-height: 100%;
  aspect-ratio: 960 / 640;
  object-fit: contain;
}

/* 아이템 획득 시그니처 팝업 배너 */
.item-banner {
  position: absolute;
  top: 30px;
  left: 50%;
  transform: translateX(-50%);
  display: flex;
  align-items: center;
  gap: 14px;
  background: rgba(20, 10, 8, 0.94);
  border: 2px solid var(--border-gold);
  border-radius: 8px;
  padding: 10px 22px;
  box-shadow: 0 8px 30px rgba(0, 0, 0, 0.9), 0 0 20px rgba(201, 147, 59, 0.3);
  z-index: 20;
  animation: bannerPop 0.4s cubic-bezier(0.34, 1.56, 0.64, 1);
  pointer-events: none;
}

.banner-icon {
  font-size: 32px;
  filter: drop-shadow(0 0 8px #ffd700);
}

.banner-text-group {
  display: flex;
  flex-direction: column;
}

.banner-name {
  font-family: 'Cinzel', serif;
  font-size: 16px;
  font-weight: 900;
  color: #ffd700;
  letter-spacing: 1px;
}

.banner-desc {
  font-family: 'Pretendard', sans-serif;
  font-size: 12px;
  color: var(--text-parchment);
}

/* 방 진입 안내 토스트 */
.room-prompt-toast {
  position: absolute;
  bottom: 20px;
  left: 50%;
  transform: translateX(-50%);
  font-family: 'Cinzel', serif;
  font-size: 14px;
  font-weight: 700;
  letter-spacing: 2px;
  color: var(--text-parchment);
  background: rgba(10, 6, 4, 0.8);
  border: 1px solid #543c2c;
  padding: 4px 14px;
  border-radius: 20px;
  opacity: 0;
  transition: opacity 0.5s ease;
  pointer-events: none;
}

/* 모바일 전용 가상 컨트롤러 */
.mobile-ui {
  display: none;
  width: 100%;
  max-width: 960px;
  height: 120px;
  align-items: center;
  justify-content: space-between;
  padding: 0 10px 6px 10px;
  z-index: 15;
}

@media (max-width: 900px), (pointer: coarse) {
  .mobile-ui {
    display: flex;
  }
  #desktopGuide {
    display: none;
  }
}

/* 가상 이동 스틱 */
.joystick-zone {
  position: relative;
  width: 100px;
  height: 100px;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
}

.joystick-base {
  width: 80px;
  height: 80px;
  border-radius: 50%;
  background: rgba(61, 40, 28, 0.5);
  border: 2px solid rgba(201, 147, 59, 0.4);
  display: flex;
  align-items: center;
  justify-content: center;
  touch-action: none;
}

.joystick-thumb {
  width: 36px;
  height: 36px;
  border-radius: 50%;
  background: rgba(201, 147, 59, 0.7);
  box-shadow: 0 0 10px rgba(0, 0, 0, 0.6);
  pointer-events: none;
  transform: translate(0, 0);
  transition: transform 0.05s ease-out;
}

/* 폭탄 버튼 */
.mobile-mid-actions {
  display: flex;
  align-items: center;
  justify-content: center;
}

.mobile-bomb-btn {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  width: 54px;
  height: 54px;
  border-radius: 50%;
  background: #3d281c;
  border: 2px solid var(--border-gold);
  color: #fff;
  font-size: 18px;
  cursor: pointer;
  box-shadow: 0 4px 10px rgba(0, 0, 0, 0.6);
}

.mobile-bomb-btn:active {
  transform: scale(0.92);
  background: #5a1a1a;
}

.bomb-label {
  font-size: 9px;
  font-weight: 700;
  color: var(--border-gold);
}

/* 4방향 눈물 사격 패드 */
.fire-pad-zone {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  width: 110px;
  height: 110px;
}

.fire-mid-row {
  display: flex;
  align-items: center;
  gap: 8px;
}

.fire-btn {
  width: 34px;
  height: 34px;
  border-radius: 8px;
  background: rgba(61, 40, 28, 0.7);
  border: 1.5px solid var(--border-gold);
  color: var(--soul-blue);
  font-size: 14px;
  font-weight: bold;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  touch-action: none;
}

.fire-btn.active, .fire-btn:active {
  background: #2b4c66;
  color: #fff;
  box-shadow: 0 0 10px var(--soul-blue);
}

.fire-center-icon {
  font-size: 14px;
  opacity: 0.6;
}

.ctrl-label {
  font-size: 10px;
  color: var(--text-muted);
  margin-top: 2px;
}

/* 하단 데스크톱 가이드 */
#desktopGuide {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  font-size: 12px;
  color: var(--text-muted);
  padding: 4px 0;
  flex-wrap: wrap;
}

.guide-sep {
  opacity: 0.4;
}

kbd {
  display: inline-block;
  padding: 2px 5px;
  background: #2a1b14;
  border: 1px solid #4a3022;
  border-radius: 4px;
  box-shadow: 0 2px 0 #000;
  font-family: inherit;
  font-size: 11px;
  color: var(--text-parchment);
  font-weight: 700;
}

/* ==========================================================================
   모달 공통 스타일
   ========================================================================== */

.modal-backdrop {
  position: fixed;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  background: rgba(8, 5, 4, 0.85);
  backdrop-filter: blur(6px);
  -webkit-backdrop-filter: blur(6px);
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 16px;
  z-index: 100;
  opacity: 1;
  visibility: visible;
  transition: opacity 0.25s ease, visibility 0.25s ease;
}

.modal-backdrop.hidden {
  opacity: 0;
  visibility: hidden;
  pointer-events: none;
}

/* 사망 유서 (Death Note / Will) 카드 */
.death-will-card {
  background: var(--will-bg);
  border: 4px solid #5a3825;
  border-radius: 6px;
  padding: 24px 20px;
  width: 100%;
  max-width: 440px;
  color: var(--will-text);
  box-shadow: 0 20px 50px rgba(0, 0, 0, 0.9), inset 0 0 30px rgba(139, 90, 43, 0.3);
  font-family: 'Cinzel', serif;
  transform: rotate(-1deg);
}

.will-header {
  border-bottom: 2px dashed #8b5a2b;
  padding-bottom: 10px;
  margin-bottom: 14px;
  text-align: center;
}

.will-title {
  font-size: 22px;
  font-weight: 900;
  color: #5c1818;
  letter-spacing: 1px;
}

.will-sub {
  font-size: 12px;
  font-style: italic;
  color: #694a32;
  margin-top: 2px;
}

.will-character-tomb {
  display: flex;
  flex-direction: column;
  align-items: center;
  margin-bottom: 14px;
}

.isaac-ghost-anim {
  font-size: 42px;
  animation: ghostFloat 2s infinite ease-in-out;
}

.killed-by-row {
  font-size: 13px;
  font-weight: 700;
  color: #4a2f1c;
}

.killer-highlight {
  color: var(--blood-red);
  font-weight: 900;
}

.will-stats {
  background: rgba(139, 90, 43, 0.1);
  border-radius: 4px;
  padding: 10px 14px;
  margin-bottom: 14px;
  font-size: 13px;
}

.stat-line {
  display: flex;
  justify-content: space-between;
  margin-bottom: 4px;
}

.will-items-section {
  margin-bottom: 18px;
}

.section-title {
  font-size: 12px;
  font-weight: 700;
  color: #5c3c26;
  margin-bottom: 6px;
}

.items-thumb-grid {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  min-height: 36px;
}

.item-thumb {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 36px;
  height: 36px;
  background: #3d281c;
  border: 1px solid var(--border-gold);
  border-radius: 4px;
  font-size: 20px;
  box-shadow: inset 0 0 6px #000;
}

.btn-isaac-restart {
  width: 100%;
  padding: 12px;
  background: #7a1c1c;
  color: #fff;
  border: 2px solid #4a1010;
  border-radius: 6px;
  font-family: 'Cinzel', serif;
  font-size: 15px;
  font-weight: 900;
  cursor: pointer;
  box-shadow: 0 4px 12px rgba(122, 28, 28, 0.5);
  transition: all 0.15s ease;
}

.btn-isaac-restart:hover {
  background: #992222;
  transform: translateY(-2px);
}

/* 승리 및 일시정지 모달 */
.victory-card, .pause-card {
  background: #241710;
  border: 2px solid var(--border-gold);
  border-radius: 8px;
  padding: 24px;
  width: 100%;
  max-width: 400px;
  text-align: center;
  box-shadow: 0 16px 40px rgba(0, 0, 0, 0.9);
}

.trophy-glow {
  font-size: 48px;
  margin-bottom: 8px;
  filter: drop-shadow(0 0 12px #ffd700);
}

.modal-title {
  font-size: 24px;
  font-weight: 900;
  color: #ffd700;
  margin-bottom: 6px;
}

.modal-subtitle {
  font-size: 13px;
  color: var(--text-parchment);
  margin-bottom: 18px;
}

.stats-summary {
  display: flex;
  justify-content: space-around;
  background: rgba(0, 0, 0, 0.4);
  border: 1px solid #4d3324;
  border-radius: 6px;
  padding: 10px;
  margin-bottom: 20px;
}

.stat-box {
  display: flex;
  flex-direction: column;
  gap: 2px;
}

.stat-name {
  font-size: 11px;
  color: var(--text-muted);
}

.stat-value {
  font-size: 16px;
  font-weight: 700;
  color: var(--text-parchment);
}

.modal-actions {
  display: flex;
  gap: 10px;
}

.btn {
  flex: 1;
  padding: 10px 14px;
  border-radius: 6px;
  font-family: inherit;
  font-size: 14px;
  font-weight: 700;
  cursor: pointer;
  border: none;
  transition: all 0.15s ease;
}

.btn-primary {
  background: #b31e1e;
  color: #fff;
  border: 1px solid #ff4d4d;
}

.btn-primary:hover {
  background: #cc2929;
  box-shadow: 0 0 10px rgba(255, 77, 77, 0.4);
}

.btn-secondary {
  background: #3d281c;
  color: var(--text-parchment);
  border: 1px solid var(--border-gold);
}

.btn-secondary:hover {
  background: #543c2c;
}

.hidden {
  display: none !important;
}

/* 애니메이션 */
@keyframes heartPulse {
  0%, 100% { transform: scale(1); }
  15% { transform: scale(1.15); }
  30% { transform: scale(1); }
  45% { transform: scale(1.12); }
  60% { transform: scale(1); }
}

@keyframes skullPulse {
  from { transform: scale(1); }
  to { transform: scale(1.2); }
}

@keyframes bannerPop {
  0% { transform: translate(-50%, -20px) scale(0.8); opacity: 0; }
  100% { transform: translate(-50%, 0) scale(1); opacity: 1; }
}

@keyframes ghostFloat {
  0%, 100% { transform: translateY(0); }
  50% { transform: translateY(-8px); }
}

@keyframes fadeInDown {
  from { opacity: 0; transform: translateY(-10px); }
  to { opacity: 1; transform: translateY(0); }
}