html, body {
	height: 100%; 
	margin: 0;   
	padding: 0;  
	overflow: hidden; 
}

body {
	background: #111;
	color: #fff;
	font-family: 'Jua', sans-serif;
	text-align: center;
	display: flex; 
	flex-direction: column; 
}

.hidden {
    display: none !important;
}

/* --- 보스 선택 화면 --- */
#floorSelectionScreen {
    display: flex;
    flex-direction: column;
    height: 100%;
    padding-bottom: 70px;
    box-sizing: border-box;
}
#floorGrid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(140px, 1fr));
    gap: 15px;
    padding: 20px;
    overflow-y: auto;
    flex-grow: 1;
}
.floor-card {
    background: #2a2a3e;
    border: 2px solid #5a5a7d;
    border-radius: 10px;
    padding: 10px;
    cursor: pointer;
    transition: all 0.2s ease-in-out;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: space-around;
}
.floor-card:hover {
    transform: translateY(-5px);
    border-color: #ffcc00;
}
.floor-card-image {
    width: 80px;
    height: 80px;
    background-size: contain;
    background-position: center;
    background-repeat: no-repeat;
}
.floor-card-name {
    font-size: 1.1em;
    font-weight: bold;
    margin-top: 10px;
    color: #fff;
}
.floor-card-status {
    font-size: 0.8em;
    color: #aaa;
    margin-top: 5px;
}
.floor-card.locked {
    filter: grayscale(100%) brightness(0.5);
    cursor: not-allowed;
}
.floor-card.locked:hover {
    transform: none;
    border-color: #5a5a7d;
}
.floor-card.locked .floor-card-status {
    color: #ff5252;
}

/* --- 게임 화면 --- */
#gameScreen {
    height: 100%;
    display: flex;
    flex-direction: column;
}
.header-container {
	display: flex; 
	align-items: center; 
	justify-content: space-between; 
	width: 90%; 
	max-width: 500px; 
	margin: 15px auto 5px auto; 
}

.header-container h1 {
	margin: 0; 
	font-size: 1.5em;
	flex-shrink: 1; 
	min-width: 0; 
	text-align: left;
}

/* 보스 격파 현황 (텍스트 전용) */
#defeatStatusContainer {
    width: 90%;
    max-width: 500px;
    margin: 5px auto;
    text-align: center;
    font-size: 1.1em;
    font-weight: bold;
    color: #ffcc00;
	padding-top: 5px;
}

.boss-info-container {
    width: 90%;
    max-width: 500px;
    margin: 5px auto 10px auto; /* 상단 마진 조정 */
    padding: 10px;
    border: 2px solid #ffcc00;
    border-radius: 10px;
    background: radial-gradient(circle, rgba(63,71,94,1) 0%, rgba(33,37,55,1) 100%);
    box-shadow: 0 0 15px rgba(255, 204, 0, 0.4);
    position: relative;
}

#bossNameDisplay {
    width: 100%;
    margin: 0 auto 0px auto;
    font-size: 1.2em;
    font-weight: bold;
    color: #ffcc00;
    text-shadow: 1px 1px 2px #000;
    text-align: center;
}

#bossStatusWrapper {
    display: flex;
    align-items: flex-start;
    width: 100%;
    position: relative;
    z-index: 10;
    padding-top: 10px;
}

.boss-profile-wrapper {
    position: absolute;
    top: 0;
    left: 0;
    z-index: 12;
    display: flex;
    flex-direction: column;
    align-items: center;
}

#bossProfile {
    width: 80px;
    height: 80px;
    background-size: cover;
    border-radius: 50%;
    border: 3px solid #ffcc00;
}
#bossCharacterName {
    font-size: 0.9em;
    font-weight: bold;
    color: #fff;
    margin-top: 4px;
    background-color: rgba(0,0,0,0.5);
    padding: 2px 6px;
    border-radius: 5px;
}

#statusBarsContainer {
    width: 100%; 
    display: flex;
    flex-direction: column;
    gap: 5px;
    padding-left: 65px;
}

#hpBar, #timeBarContainer {
    width: 100%;
    position: relative;
    box-sizing: border-box;
    background: #444;
	border: 2px solid #fff;
    overflow: hidden;
}
#hpBar { height: 30px; }
#timeBarContainer { height: 22px; }

#hpFill { height: 100%; width: 100%; background: lime; transition: width 0.2s; }
#timeLeftFill { height: 100%; width: 100%; background: #00bfff; transition: width 0.1s linear; }

#hpPercentText, #timeOverlayText {
    position: absolute; top: 50%; left: 50%; transform: translate(-50%, -50%);
    font-weight: bold; color: white; text-shadow: 0 0 3px black; white-space: nowrap;
}
#hpPercentText { font-size: 1em; }
#timeOverlayText { font-size: 0.8em; }

#hpGaugeCounter { 
    position: absolute; top: 50%; transform: translateY(-50%); right: 10px; 
    color: yellow; font-weight: bold; pointer-events: none; text-shadow: 0 0 3px black;
}

#game-content-wrapper {
	position: relative; flex-grow: 1; display: flex; flex-direction: column; align-items: center; 
	justify-content: flex-start; width: 100%; max-width: 600px; margin: 0 auto; z-index: 100; 
}
#effectCanvas {
	position: absolute; top: 0; left: 50%; transform: translateX(-50%);
	width: 100%; height: 100%; 
	z-index: 100000; /* ⭐ 1000에서 극도로 높은 값으로 변경 */
	pointer-events: none; 
}
.damage-text {
  position: absolute; font-size: 32px; font-weight: 900; color: #ffdd57; text-shadow: 2px 2px 6px black;
  pointer-events: none; animation: floatUp 0.8s ease-out forwards; z-index: 100; 
}
@keyframes floatUp { 0% { opacity: 1; transform: translateY(0) scale(1); } 100% { opacity: 0; transform: translateY(-60px) scale(1.8); } }

.time-bonus-indicator {
	position: absolute; right: 10px; top: -35px; font-family: 'Impact', sans-serif; font-size: 28px;
	font-weight: bold; color: #32CD32; text-shadow: 2px 2px 4px black; pointer-events: none;
	opacity: 0; z-index: 10; animation: bonusFloatAndFade 0.8s ease-out forwards; white-space: nowrap; 
}
@keyframes bonusFloatAndFade { 0% { opacity: 1; transform: translateY(0) scale(1.2); } 100% { opacity: 0; transform: translateY(-40px) scale(0.8); } }

#activeBuffsDisplay {
    position: fixed; top: 50%; transform: translateY(-50%); right: 20px; display: flex;
    flex-direction: column; gap: 8px; z-index: 10000; pointer-events: none;
}
.active-buff-icon {
    padding: 6px 10px; border-radius: 20px; font-weight: bold; font-size: 0.8em; color: #fff;
    text-shadow: 1px 1px 2px #000; box-shadow: 0 0 8px rgba(255, 255, 255, 0.4); user-select: none;
    border: 2px solid white; animation: activeGlow 1.5s infinite alternate; white-space: nowrap; text-align: center;
}
.active-buff-icon.hidden { display: none; }
@keyframes activeGlow { 0% { box-shadow: 0 0 8px #fff; } 100% { box-shadow: 0 0 15px #ffd700; } }

#boss {
  width: 200px; height: 200px; margin: 20px auto; background-size: cover; cursor: pointer;
  position: relative; z-index: 5; user-select: none; transition: transform 0.05s;
}

.buff-bubble {
	position: absolute; width: 70px; height: 70px; border: 4px solid #fff; border-radius: 50%;
	display: flex; justify-content: center; align-items: center; color: white; font-size: 1em;
    font-weight: bold; cursor: pointer; z-index: 11; animation: pulse 1s infinite alternate;
	transition: transform 0.1s, opacity 0.3s; opacity: 0; pointer-events: none; text-align: center;
}
.buff-bubble.time-bonus { background: radial-gradient(circle at 70% 30%, #4CAF50, #2E7D32); box-shadow: 0 0 15px rgba(76, 175, 80, 0.8); }
.buff-bubble.critical { background: radial-gradient(circle at 70% 30%, #FFD700, #DAA520); box-shadow: 0 0 15px rgba(255, 215, 0, 0.8); }
.buff-bubble.double { background: radial-gradient(circle at 70% 30%, #FF4500, #CD5C5C); box-shadow: 0 0 15px rgba(255, 69, 0, 0.8); }
.buff-bubble.no-miss { background: radial-gradient(circle at 70% 30%, #8a2be2, #4b0082); box-shadow: 0 0 15px rgba(138, 43, 226, 0.8); }
.buff-bubble:active { transform: scale(0.95); }
@keyframes pulse { 0% { transform: scale(1); } 100% { transform: scale(1.05); } }
.bubble-fade-out { animation: fadeOutUp 0.3s ease-in-out forwards; }
@keyframes fadeOutUp { 100% { opacity: 0; transform: translateY(-50px) scale(1.5); } }
#boss.shake { animation: shake 0.2s; }
@keyframes shake { 0% { transform: translate(0, 0); } 25% { transform: translate(5px, 0); } 50% { transform: translate(-5px, 0); } 75% { transform: translate(5px, 0); } 100% { transform: translate(0, 0); } }

.damage-text.critical { font-family: 'Impact', 'Anton', sans-serif; font-size: 40px; font-weight: bold; color: #ff0000; text-shadow: -2px -2px 0 white, 2px -2px 0 white, -2px 2px 0 white, 2px 2px 0 white; animation: floatUp 0.8s ease-out forwards; }
.damage-text.miss { font-family: 'Impact', 'Anton', sans-serif; font-size: 40px; color: #a347ff; text-shadow: -2px -2px 0 white, 2px -2px 0 white, -2px 2px 0 white, 2px 2px 0 white; animation: floatUpMiss 0.8s ease-out forwards; }
@keyframes floatUpMiss { 0% { transform: scale(1.2); opacity: 1; } 100% { transform: translateY(-80px) scale(2); opacity: 0; } }

#countdownOverlay { position: fixed; top: 0; left: 0; width: 100%; height: 100%; background-color: rgba(0, 0, 0, 0.7); display: flex; justify-content: center; align-items: center; z-index: 9999; pointer-events: none; opacity: 0; transition: opacity 0.3s ease-out; }
#countdownText { font-weight: bold; color: white; text-shadow: 4px 4px 8px #ff0000; height: 120px; display: flex; justify-content: center; align-items: center; }
.stamp { animation: stamp 0.4s ease-out; transform-origin: center; font-size: 100px; }
@keyframes stamp { 0% { transform: scale(0.2); opacity: 0; } 50% { transform: scale(1.5); opacity: 1; } 100% { transform: scale(1); opacity: 1; } }
.start-fade { font-family: 'Jua', sans-serif; font-size: 110px; color: #ffeb3b; animation: startFade 1.5s ease-out forwards; letter-spacing: 10px; }
@keyframes startFade { 0% { transform: scale(0.3); opacity: 0; filter: brightness(2); } 30% { transform: scale(1.3); opacity: 1; filter: brightness(1.2); } 60% { transform: scale(1); opacity: 1; filter: brightness(1); } 100% { transform: scale(1); opacity: 0; filter: brightness(0.5); } }

@keyframes screenShake { 0%, 100% { transform: translate(0px, 0px); } 25% { transform: translate(5px, -5px); } 50% { transform: translate(-5px, 5px); } 75% { transform: translate(5px, 5px); } }
#game-content-wrapper.shake-screen, #game-content-wrapper.shake-countdown { animation: screenShake 0.4s; }

#result {
    /* 모달 기본 스타일 */
    position: fixed; top: 0; left: 0; width: 100%; height: 100%;
    background-color: rgba(0, 0, 0, 0.85); 
    display: flex; flex-direction: column; justify-content: center; align-items: center;
    text-align: center;
    z-index: 1000000; /* 모든 것을 덮는 가장 높은 z-index */
    
    /* 초기에는 숨김 */
    opacity: 0; 
    visibility: hidden;
    transition: opacity 0.3s ease;
}

#result.visible {
    opacity: 1;
    visibility: visible;
}

/* 결과 내용 (기존 스타일 유지) */
#result > strong {
    font-size: 2.5em;
    color: #ffeb3b;
    margin-bottom: 20px;
}

#result .full-damage { font-size: 1.7em; color: #ffcc00; font-family: Impact, sans-serif; }
#result small { font-size: 0.8em; color: #ccc; }

#startBtn.floating-btn-start {
	position: fixed; right: 20px; bottom: 20px; width: 80px; height: 80px; background-color: #e53935;
	color: white; border: 3px solid white; border-radius: 50%; font-size: 1.2em; font-weight: bold;
    line-height: 1.2; cursor: pointer; z-index: 1000; box-shadow: 0 5px 15px rgba(0,0,0,0.4); transition: all 0.2s ease;
}
#startBtn.floating-btn-start::before { content: "시작"; }
#startBtn.floating-btn-start:hover { background-color: #c62828; transform: scale(1.05); }
#startBtn.ingame { animation: burning 1.5s infinite; }
#startBtn.ingame::before { content: "게임\A 진행중"; white-space: pre; }
@keyframes burning { 0% { box-shadow: 0 0 10px #ff5722, 0 0 20px #ff5722, 0 0 30px #e64a19; } 50% { box-shadow: 0 0 20px #ff7043, 0 0 35px #ff7043, 0 0 50px #e64a19; } 100% { box-shadow: 0 0 10px #ff5722, 0 0 20px #ff5722, 0 0 30px #e64a19; } }
#exitBtn.floating-btn-exit {
    position: fixed; left: 20px; bottom: 20px; width: 70px; height: 70px; background-color: #555;
    color: white; border: 3px solid white; border-radius: 50%; cursor: pointer; z-index: 1000;
    font-size: 1.8em; display: flex; align-items: center; justify-content: center;
    box-shadow: 0 5px 15px rgba(0,0,0,0.4); transition: all 0.2s ease;
}
#exitBtn.floating-btn-exit:hover { background-color: #777; transform: scale(1.05); }

.footer { position: fixed; bottom: 20px; left: 0; right: 0; text-align: center; z-index: 10000; }
.back-btn { display: inline-block; min-width: 180px; padding: 12px 24px; background: #28a745; color: white; border: none; font-size: 18px; cursor: pointer; border-radius: 5px; transition: background 0.3s; }
.back-btn:hover { background: #218838; }

.control-btn { padding: 8px 12px; background: #555; color: white; border: none; font-size: 1em; cursor: pointer; border-radius: 5px; transition: background 0.3s; }
.control-btn:hover { background: #777; }
.control-btn.muted { background: #a00; }

#boss.hit-flash { filter: brightness(2) contrast(1.5); transition: filter 0.05s; }

@media (max-width: 600px) {
    #activeBuffsDisplay { right: 5px; }
    #startBtn.floating-btn-start { width: 70px; height: 70px; right: 15px; bottom: 15px; }
    #exitBtn.floating-btn-exit { width: 60px; height: 60px; left: 15px; bottom: 15px; font-size: 1.5em;}
    .floor-card { flex-basis: calc(50% - 10px); }
}