:root {
    --primary: #ff4757;
    --secondary: #2f3542;
    --text-main: #f1f2f6;
    --gold: #ffa502;
    --kakao: #FEE500;
}

body {
    font-family: 'Noto Sans KR', sans-serif;
    margin: 0;
    padding: 0;
    background-color: #1e272e;
    color: var(--text-main);
    min-height: 100vh;
    display: flex;
    justify-content: center;
    align-items: center;
    overflow-x: hidden;
}

/* 배경 */
.background-overlay {
    position: fixed;
    top: 0; left: 0; width: 100%; height: 100%;
    background: url('https://agmazon.com/background/match.webp') no-repeat center center/cover;
    filter: brightness(0.3) blur(4px);
    z-index: -1;
}

.container {
    width: 100%;
    max-width: 600px;
    padding: 20px;
    padding-top: 80px; 
    padding-bottom: 120px;
    box-sizing: border-box;
    position: relative;
    z-index: 1;
}

/* 상단 고정 광고 스타일 */
.ad-top-fixed {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 60px;
    background: rgba(30, 39, 46, 0.95);
    z-index: 1000;
    display: flex;
    justify-content: center;
    align-items: center;
    border-bottom: 1px solid #57606f;
    box-shadow: 0 2px 10px rgba(0,0,0,0.3);
}

/* 하단 고정 광고 스타일 */
.ad-bottom-fixed {
    position: fixed;
    bottom: 0;
    left: 0;
    width: 100%;
    height: 110px;
    background: rgba(30, 39, 46, 0.95);
    z-index: 1000;
    display: flex;
    justify-content: center;
    align-items: center;
    border-top: 1px solid #57606f;
    box-shadow: 0 -2px 10px rgba(0,0,0,0.3);
}

header { text-align: center; margin-bottom: 30px; }

/* [수정] 폰트 교체 및 애니메이션 추가 */
h1 {
    font-family: 'Jua', sans-serif;
    font-size: 2.8rem;
    color: var(--gold);
    text-shadow: 3px 3px 0 #000;
    margin: 0 0 10px 0;
    letter-spacing: 1px;
    /* 지속적인 애니메이션 효과 적용 */
    animation: battleVibe 2s infinite ease-in-out; 
}

/* [추가] 타이틀 애니메이션 키프레임 */
@keyframes battleVibe {
    0% { transform: scale(1) rotate(0deg); text-shadow: 3px 3px 0 #000; }
    50% { transform: scale(1.05) rotate(-2deg); text-shadow: 3px 3px 15px rgba(255, 165, 2, 0.8), 3px 3px 0 #000; color: #ffda79; }
    70% { transform: scale(1.05) rotate(2deg); }
    100% { transform: scale(1) rotate(0deg); text-shadow: 3px 3px 0 #000; }
}

.subtitle { color: #ccc; font-size: 0.95rem; margin: 0; }

/* 입력창 */
.input-group {
    display: flex;
    gap: 10px;
    margin-bottom: 20px;
    justify-content: center;
    align-items: center;
}

input {
    width: 40%;
    padding: 15px 10px;
    border-radius: 12px;
    border: 3px solid #57606f;
    background: #dfe4ea;
    font-size: 1.1rem;
    font-weight: bold;
    text-align: center;
    outline: none;
    transition: 0.3s;
    font-family: 'Jua', sans-serif;
}

input:focus { border-color: var(--gold); background: #fff; }

.vs-badge {
    font-family: 'Jua', sans-serif;
    font-size: 1.5rem;
    color: var(--primary);
}

/* 시작 버튼 */
.start-btn {
    width: 100%;
    background: linear-gradient(45deg, #ff4757, #ff6b81);
    color: white;
    border: none;
    padding: 18px;
    font-size: 1.5rem;
    font-family: 'Jua', sans-serif;
    border-radius: 15px;
    cursor: pointer;
    box-shadow: 0 6px 0 #b33939, 0 15px 20px rgba(0,0,0,0.4);
    transition: transform 0.1s, box-shadow 0.1s;
    animation: pulse 2s infinite; 
}

@keyframes pulse {
    0% { transform: scale(1); box-shadow: 0 0 0 0 rgba(255, 71, 87, 0.7); }
    70% { transform: scale(1.02); box-shadow: 0 0 0 15px rgba(255, 71, 87, 0); }
    100% { transform: scale(1); box-shadow: 0 0 0 0 rgba(255, 71, 87, 0); }
}

.start-btn:active {
    transform: translateY(6px);
    box-shadow: 0 0 0 #b33939;
    animation: none;
}

/* [추가] 설치하기 버튼 스타일 */
.install-btn {
    width: 100%;
    margin-top: 20px; /* 시작 버튼과 간격 */
    background: transparent;
    color: #dfe4ea;
    border: 2px dashed #747d8c;
    padding: 12px;
    font-size: 1.1rem;
    font-family: 'Jua', sans-serif;
    border-radius: 15px;
    cursor: pointer;
    transition: all 0.3s;
    display: none; /* 기본적으로 숨김 (JS로 제어) */
}

.install-btn:hover {
    background: rgba(255, 255, 255, 0.1);
    border-color: var(--gold);
    color: white;
    transform: translateY(-2px);
}

/* 전투 화면 */
.battle-arena { animation: fadeIn 0.5s ease-out; }
.fighters { display: flex; justify-content: space-between; align-items: center; margin-bottom: 20px; position: relative; }
.fighter { width: 42%; text-align: center; position: relative; }

.avatar-wrapper { position: relative; height: 80px; margin-bottom: 10px; }
.avatar { font-size: 4.5rem; display: block; filter: drop-shadow(0 0 15px rgba(255,255,255,0.4)); }

.name { display: block; font-weight: bold; margin-bottom: 5px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; font-family: 'Jua', sans-serif; letter-spacing: 1px;}

.hp-box {
    background: #57606f;
    height: 22px;
    border-radius: 11px;
    overflow: hidden;
    border: 2px solid #2f3542;
    position: relative;
    box-shadow: 0 3px 5px rgba(0,0,0,0.3);
}

.hp-bar { width: 100%; height: 100%; background: #2ed573; transition: width 0.3s ease-out, background-color 0.3s; }
.hp-text { position: absolute; top: 50%; left: 50%; transform: translate(-50%, -50%); font-size: 0.75rem; font-weight: 900; text-shadow: 1px 1px 2px #000; }

.vs-mark {
    font-family: 'Jua', sans-serif;
    font-size: 2.5rem;
    color: #ff4757;
    position: absolute;
    left: 50%; top: 30px;
    transform: translateX(-50%);
    text-shadow: 2px 2px 0 #000;
}

/* 결과창 */
.result-section {
    background: rgba(255, 255, 255, 0.95);
    color: #333;
    padding: 25px;
    border-radius: 20px;
    text-align: center;
    margin-bottom: 20px;
    border: 4px solid var(--gold);
    animation: slideDown 0.5s cubic-bezier(0.175, 0.885, 0.32, 1.275);
}

.winner-announce { font-family: 'Jua', sans-serif; font-size: 2.2rem; color: var(--primary); margin: 0 0 15px 0; line-height: 1.2; }
.chemistry-box { background: #f1f2f6; padding: 15px; border-radius: 12px; margin-bottom: 20px; border: 1px solid #dcdde1; }
.chem-score { font-family: 'Jua', sans-serif; font-size: 3rem; color: #2f3542; margin: 5px 0; }
.chem-desc { font-weight: bold; color: var(--primary); font-family: 'Jua', sans-serif; font-size: 1.1rem; }

.share-buttons { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.btn-share { border: none; padding: 12px; border-radius: 8px; font-weight: bold; cursor: pointer; font-size: 1rem; display: flex; align-items: center; justify-content: center; gap: 5px; font-family: 'Jua', sans-serif;}
.btn-share.kakao { background: var(--kakao); color: #3C1E1E; grid-column: span 2; }
.btn-share.link { background: #747d8c; color: white; }
.btn-share.retry { background: #2f3542; color: white; }

/* 로그 박스 */
.log-container { background: rgba(0, 0, 0, 0.7); border-radius: 10px; border: 1px solid #57606f; overflow: hidden; margin-bottom: 30px; }
.log-header { background: #2f3542; padding: 8px 15px; font-weight: bold; font-size: 0.9rem; color: #ccc; }
.log-box { height: 250px; overflow-y: auto; padding: 15px; font-family: 'Noto Sans KR', sans-serif; font-size: 0.9rem; color: #00d2d3; line-height: 1.6; }

.log-entry { margin-bottom: 6px; opacity: 0; animation: fadeIn 0.2s forwards; }
.log-entry.crit { color: #ff6b6b; font-weight: bold; }
.log-entry.system { color: #feca57; text-align: center; border-top: 1px dashed #555; padding-top: 5px; margin-top: 10px; }

/* 홍보 섹션 스타일 */
.promo-section { margin-top: 30px; }
.promo-title { text-align: center; color: var(--gold); font-family: 'Jua', sans-serif; margin-bottom: 15px; font-size: 1.2rem; }
.promo-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(130px, 1fr));
    gap: 10px;
}
.promo-card {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    background: rgba(255, 255, 255, 0.1);
    border: 1px solid rgba(255, 255, 255, 0.2);
    border-radius: 10px;
    padding: 15px 5px;
    text-decoration: none;
    color: white;
    transition: 0.2s;
}
.promo-card:hover { background: rgba(255, 255, 255, 0.2); transform: translateY(-3px); border-color: var(--gold); }
.promo-icon { font-size: 1.8rem; margin-bottom: 5px; }
.promo-text { font-size: 0.9rem; font-weight: bold; text-align: center; }

/* 중앙 알림 메시지 (커스텀 Alert) */
.center-msg {
    position: fixed;
    top: 50%; left: 50%;
    transform: translate(-50%, -50%) scale(0.9);
    background: rgba(0, 0, 0, 0.85);
    color: white;
    padding: 20px 40px;
    border-radius: 15px;
    font-size: 1.2rem;
    font-family: 'Jua', sans-serif;
    text-align: center;
    z-index: 9999;
    opacity: 0;
    pointer-events: none;
    transition: all 0.3s cubic-bezier(0.175, 0.885, 0.32, 1.275);
    border: 2px solid var(--primary);
    box-shadow: 0 0 20px rgba(255, 71, 87, 0.4);
}
.center-msg.show { opacity: 1; transform: translate(-50%, -50%) scale(1); }

/* 하단 토스트 */
.toast {
    visibility: hidden; min-width: 250px; background-color: #333; color: #fff; text-align: center; border-radius: 25px; padding: 16px; position: fixed; z-index: 100; left: 50%; bottom: 30px; transform: translateX(-50%); font-size: 1rem; box-shadow: 0 5px 15px rgba(0,0,0,0.5);
}
.toast.show { visibility: visible; animation: fadein 0.5s, fadeout 0.5s 2.5s; }

/* 애니메이션 */
@keyframes fadeIn { from { opacity: 0; } to { opacity: 1; } }
@keyframes slideDown { from { transform: translateY(-20px); opacity: 0; } to { transform: translateY(0); opacity: 1; } }
@keyframes fadein { from {bottom: 0; opacity: 0;} to {bottom: 30px; opacity: 1;} }
@keyframes fadeout { from {bottom: 30px; opacity: 1;} to {bottom: 0; opacity: 0;} }
.attack-right { animation: lungeRight 0.15s; }
.attack-left { animation: lungeLeft 0.15s; }
.hit-shake { animation: shake 0.3s; }
@keyframes lungeRight { 50% { transform: translateX(40px); } }
@keyframes lungeLeft { 50% { transform: translateX(-40px); } }
@keyframes shake { 0%, 100% {transform: translateX(0);} 25% {transform: translateX(-5px) rotate(-5deg);} 75% {transform: translateX(5px) rotate(5deg);} }

/* 데미지 텍스트 */
.damage-float { position: absolute; top: 0; left: 50%; transform: translateX(-50%); font-size: 2rem; font-weight: 900; color: #ff4757; text-shadow: 2px 2px 0 #fff; pointer-events: none; animation: floatUp 0.8s forwards; z-index: 10; font-family: 'Jua', sans-serif;}
@keyframes floatUp { 100% { top: -60px; opacity: 0; transform: translateX(-50%) scale(1.5); } }

/* 언어 전환 버튼 스타일 */
.lang-switch {
    position: absolute;
    top: 15px;
    right: 15px;
    z-index: 1002; /* 광고보다 위에 오도록 */
    display: flex;
    gap: 5px;
}

.lang-btn {
    text-decoration: none;
    font-family: 'Jua', sans-serif;
    font-size: 0.9rem;
    padding: 5px 10px;
    border-radius: 15px;
    background: rgba(0, 0, 0, 0.5);
    color: #bbb;
    border: 1px solid #57606f;
    transition: 0.3s;
}

.lang-btn:hover {
    background: rgba(255, 255, 255, 0.2);
    color: white;
}

.lang-btn.active {
    background: var(--primary);
    color: white;
    border-color: var(--primary);
    font-weight: bold;
    box-shadow: 0 2px 5px rgba(0,0,0,0.3);
}