:root {
  --bg-base: #050505;
  --bg-panel: #141414;
  --bg-card-interface: #0a0a0a;
  --theme-yellow: #FFD700;
  --theme-orange: #FFA500;
  --theme-yellow-dim: #A68C00;
  --theme-yellow-glow: rgba(255, 215, 0, 0.3);
  --text-main: #EFEFEF;
  --text-muted: #888888;
  --board-dark: #1F1F1F;
  --board-light: #333333;
  --enemy-color: #FF4444;
  --enemy-glow: rgba(255, 68, 68, 0.25);
  --clone-color: #4488FF;
  --range-color: rgba(255, 215, 0, 0.15);
  --board-size: 8;
}

* { box-sizing: border-box; margin: 0; padding: 0; font-family: 'Malgun Gothic', sans-serif; -webkit-tap-highlight-color: transparent; }

/* 🚀 앱처럼 화면을 완벽하게 고정시키는 핵심 스타일 */
html, body {
  background-color: var(--bg-base);
  color: var(--text-main);
  display: flex;
  justify-content: center;
  align-items: center;
  width: 100vw;
  height: 100vh;
  height: 100dvh; /* 모바일 동적 주소창 변화 대응 */
  overflow: hidden;
  position: fixed; /* 브라우저 스와이프 및 바운스 차단 */
  top: 0;
  left: 0;
  touch-action: none; /* 핀치 줌, 더블탭 확대 완전 차단 */
  overscroll-behavior: none; /* 당겨서 새로고침 차단 */
}

#appContainer {
  width: 100%;
  max-width: 460px;
  height: 100%;
  position: relative;
  background-color: var(--bg-base);
  border: 1px solid #222;
  display: flex;
  flex-direction: column;
  overflow: hidden;
}

.crown-container { width: 100%; display: flex; justify-content: center; margin-bottom: 30px; animation: floatCrown 3s ease-in-out infinite; }
.crown-icon { width: 90px; height: 90px; filter: drop-shadow(0 10px 15px rgba(255, 215, 0, 0.2)); }
@keyframes floatCrown { 0%, 100% { transform: translateY(0); } 50% { transform: translateY(-8px); } }

.flash-overlay { position: absolute; top: 0; left: 0; width: 100%; height: 100%; background-color: #ffffff; opacity: 0; pointer-events: none; z-index: 2000; transition: opacity 0.05s ease-in; }
.flash-overlay.active { opacity: 1; }

.curtain { position: absolute; top: 0; width: 50%; height: 100%; background: linear-gradient(90deg, #0a0a0a 0%, #1a1a1a 50%, #050505 100%); z-index: 999; transition: transform 1.2s cubic-bezier(0.25, 1, 0.3, 1); box-shadow: 0 0 20px rgba(0,0,0,0.8); pointer-events: none; }
.left-curtain { left: 0; transform: translateX(-100%); border-right: 2px solid var(--theme-yellow-dim); }
.right-curtain { right: 0; transform: translateX(100%); border-left: 2px solid var(--theme-yellow-dim); }
.curtain.closed.left-curtain { transform: translateX(0); }
.curtain.closed.right-curtain { transform: translateX(0); }

.screen { display: none; flex-direction: column; width: 100%; height: 100%; padding: 15px; opacity: 0; transition: opacity 0.3s; }
.screen.active { display: flex; opacity: 1; }

#startScreen, #gameOverScreen { justify-content: center; align-items: center; text-align: center; }
.title, .game-over-title { color: var(--theme-yellow); font-size: 2.8rem; letter-spacing: 3px; margin-bottom: 5px; text-shadow: 0 0 15px var(--theme-yellow-glow); }
.game-over-desc { color: var(--text-muted); font-size: 0.95rem; margin-bottom: 40px; }
.game-over-score { color: var(--theme-yellow); font-size: 1.3rem; font-weight: bold; margin-bottom: 30px; }

.action-btn { background-color: var(--bg-panel); color: var(--theme-yellow); border: 1px solid var(--theme-yellow-dim); padding: 16px 40px; border-radius: 8px; font-weight: bold; font-size: 1rem; cursor: pointer; transition: all 0.2s; }
.action-btn:active { background-color: var(--theme-yellow); color: #000; }

.top-bar { display: flex; justify-content: space-between; margin-bottom: 15px; flex-shrink: 0; }
.info-box { background-color: var(--bg-panel); border: 1px solid #333; padding: 10px; border-radius: 8px; display: flex; flex-direction: column; align-items: center; flex: 1; margin: 0 4px; }
.info-box .label { font-size: 0.7rem; color: var(--text-muted); margin-bottom: 4px; }
.info-box .value { font-size: 0.95rem; font-weight: bold; color: var(--theme-yellow); }

.board-wrapper { width: 100%; aspect-ratio: 1 / 1; background-color: #000; border: 2px solid var(--theme-yellow-dim); border-radius: 8px; padding: 4px; position: relative; margin-bottom: 15px; flex-shrink: 0; }
.board { display: grid; grid-template-columns: repeat(var(--board-size), 1fr); grid-template-rows: repeat(var(--board-size), 1fr); width: 100%; height: 100%; position: relative; }
.cell { width: 100%; height: 100%; cursor: pointer; position: relative; transition: background-color 0.2s; }
.cell.light { background-color: var(--board-light); }
.cell.dark { background-color: var(--board-dark); }

.cell.movable { background-color: var(--theme-yellow-glow) !important; box-shadow: inset 0 0 0 2px var(--theme-yellow); }
.cell.range-preview { background-color: var(--range-color) !important; border: 1px dashed rgba(255, 215, 0, 0.4); }
.cell.targetable { background-color: rgba(255, 68, 68, 0.4) !important; box-shadow: inset 0 0 0 2px var(--enemy-color); }
.cell.special-target { background-color: rgba(68, 136, 255, 0.35) !important; box-shadow: inset 0 0 0 2px var(--clone-color); }
.cell.danger-zone { background-color: var(--enemy-glow) !important; box-shadow: inset 0 0 0 1px var(--enemy-color); }
.cell.danger-zone::after { content: ''; position: absolute; width: 100%; height: 100%; background: repeating-linear-gradient(45deg, transparent, transparent 5px, rgba(255, 68, 68, 0.15) 5px, rgba(255, 68, 68, 0.15) 10px); pointer-events: none; }

.piece { position: absolute; display: flex; justify-content: center; align-items: center; transition: transform 0.35s cubic-bezier(0.34, 1.56, 0.64, 1); pointer-events: none; z-index: 5; }
.player-icon { width: 75%; height: 75%; background-color: var(--theme-yellow); color: #000; border-radius: 50%; display: flex; justify-content: center; align-items: center; font-size: 0.85rem; font-weight: 900; box-shadow: 0 4px 10px rgba(255, 215, 0, 0.4); }
.enemy-icon { width: 80%; height: 80%; background-color: var(--enemy-color); color: #fff; border-radius: 6px; display: flex; justify-content: center; align-items: center; font-size: 0.7rem; font-weight: bold; box-shadow: 0 4px 8px rgba(255, 68, 68, 0.3); }
.clone-icon { width: 65%; height: 65%; background-color: var(--clone-color); color: #fff; border-radius: 50%; display: flex; justify-content: center; align-items: center; font-size: 0.7rem; font-weight: bold; border: 2px dashed #fff; }

.card-interface-wrapper { flex-grow: 1; background-color: var(--bg-card-interface); border: 1px solid #222; border-radius: 8px; display: flex; flex-direction: column; position: relative; overflow: visible; }
.deck-toggle-btn { width: 100%; height: 45px; background: linear-gradient(180deg, #1a1a1a, #0a0a0a); border-bottom: 1px solid #333; border-radius: 8px; display: flex; justify-content: center; align-items: center; cursor: pointer; z-index: 20; }
.deck-stack { color: var(--theme-yellow-dim); font-size: 0.85rem; font-weight: bold; padding: 4px 20px; border: 1px solid #333; border-radius: 4px; background-color: #050505; box-shadow: 2px 2px 0 #111, 4px 4px 0 #222; transition: all 0.2s; }
.deck-toggle-btn:active .deck-stack { transform: translate(2px, 2px); box-shadow: none; }

.hand-area { position: absolute; bottom: 50px; left: 0; width: 100%; height: 180px; display: flex; justify-content: center; align-items: flex-end; transition: transform 0.4s cubic-bezier(0.25, 1, 0.5, 1), opacity 0.3s; z-index: 50; }
.hand-area.hidden { transform: translateY(120px) scale(0.8); opacity: 0; visibility: hidden; pointer-events: none; }

.playing-card { position: absolute; bottom: 0; width: 85px; height: 125px; background: linear-gradient(145deg, #1c1c1c, #0a0a0a); border: 2px solid #444; border-radius: 8px; padding: 10px; display: flex; flex-direction: column; justify-content: space-between; cursor: pointer; transform-origin: bottom center; transition: all 0.25s cubic-bezier(0.25, 1, 0.5, 1); pointer-events: auto; }
.playing-card:hover { border-color: var(--text-muted); bottom: 10px; }

@keyframes cardPulse { 0% { box-shadow: 0 0 15px var(--theme-yellow-glow); } 50% { box-shadow: 0 0 25px var(--theme-yellow); } 100% { box-shadow: 0 0 15px var(--theme-yellow-glow); } }
.playing-card.active { border-color: var(--theme-yellow); bottom: 40px !important; transform: scale(1.15) !important; z-index: 100 !important; animation: cardPulse 1.5s infinite; }

.card-title { font-size: 0.8rem; font-weight: bold; color: var(--theme-yellow); text-align: center; }
.card-desc { font-size: 0.6rem; color: #ccc; text-align: center; flex-grow: 1; margin-top: 5px; line-height: 1.3; }
.card-cost { font-size: 0.7rem; text-align: center; color: var(--text-muted); border-top: 1px solid #333; padding-top: 4px; }

.log-open-btn { margin-top: 10px; background-color: var(--bg-panel); color: var(--text-muted); border: 1px solid #444; padding: 12px; border-radius: 8px; cursor: pointer; width: 100%; flex-shrink: 0; }
.modal-overlay { display: none; position: absolute; top: 0; left: 0; width: 100%; height: 100%; background-color: rgba(0, 0, 0, 0.9); z-index: 100; justify-content: center; align-items: center; padding: 20px; }
.modal-overlay.show { display: flex; }
.modal-content, .draft-content { background-color: var(--bg-panel); border: 1px solid var(--theme-yellow-dim); border-radius: 12px; width: 100%; display: flex; flex-direction: column; }
.modal-content { max-height: 80%; }
.modal-header { display: flex; justify-content: space-between; align-items: center; padding: 15px 20px; border-bottom: 1px solid #333; }
.modal-header h2 { color: var(--theme-yellow); font-size: 1.2rem; }
.close-btn { background: none; border: 1px solid var(--theme-yellow); color: var(--theme-yellow); padding: 6px 15px; border-radius: 6px; cursor: pointer; }

/* 🚀 로그창 예외 처리 (스크롤 허용) */
.logs { 
  padding: 20px; overflow-y: auto; font-size: 0.85rem; color: #ddd; line-height: 1.6; max-height: 350px; 
  touch-action: pan-y; /* 여기만 상하 스크롤 허용 */
  overscroll-behavior: contain; /* 스크롤 끝에서 바운스되는 현상 차단 */
}

.tutorial-content { padding: 25px; }
.tutorial-title { color: var(--theme-yellow); font-size: 1.4rem; margin-bottom: 15px; text-align: center; border-bottom: 1px solid #333; padding-bottom: 10px; }
.tutorial-text { color: #ccc; font-size: 0.9rem; margin-bottom: 25px; line-height: 1.6; }
.tutorial-text ul { padding-left: 20px; }
.tutorial-text li { margin-bottom: 8px; }

.draft-content { padding: 25px; text-align: center; }
.draft-title { color: var(--theme-yellow); font-size: 1.4rem; margin-bottom: 8px; }
.draft-desc { color: #aaa; font-size: 0.85rem; margin-bottom: 25px; line-height: 1.4; }
.draft-cards { display: flex; flex-direction: column; gap: 10px; }

@keyframes draftPopIn { from { opacity: 0; transform: translateY(20px) scale(0.95); } to { opacity: 1; transform: translateY(0) scale(1); } }
.draft-card-btn { background: #1a1a1a; border: 1px solid #444; color: #fff; padding: 15px; border-radius: 8px; cursor: pointer; text-align: left; transition: 0.2s; animation: draftPopIn 0.4s cubic-bezier(0.25, 1, 0.5, 1) backwards; }
.draft-card-btn:hover { border-color: var(--theme-yellow); background: #222; transform: scale(1.02); }
.draft-card-name { font-weight: bold; color: var(--theme-yellow); font-size: 1.05rem; display: block; margin-bottom: 5px; }
.draft-card-detail { font-size: 0.8rem; color: #ccc; }

