/* --- 변수 및 초기화 --- */
:root {
    --bg: #e9d6a7;
    --primary: #2f6fed;
    --success: #27ae60;
    --dark: #333;
    --danger: #e74c3c;
    --impossible: #8e44ad;
}

* { 
    box-sizing: border-box; 
    -webkit-tap-highlight-color: transparent; 
}

body {
    margin: 0; 
    background: var(--bg); 
    font-family: 'Pretendard', -apple-system, sans-serif;
    display: flex; 
    flex-direction: column;
    align-items: center; 
    justify-content: center;
    min-height: 100dvh;
    /* overflow: hidden 제거 → 스크롤 허용 */
    /* touch-action: none 제거 → 스크롤 허용 */
}

/* --- 레이아웃 --- */
.wrapper {
    display: flex; 
    flex-direction: column; 
    align-items: center;
    width: 100%; 
    max-width: 500px; 
    padding: 15px;
    padding-bottom: calc(60px + env(safe-area-inset-bottom, 20px));
    flex: 1 0 auto;
}

/* --- 토스트 팝업 --- */
.toast {
    position: fixed;
    bottom: 30px;
    left: 50%;
    transform: translateX(-50%) translateY(100px);
    background: rgba(0, 0, 0, 0.85);
    color: white;
    padding: 12px 25px;
    border-radius: 50px;
    font-size: 14px;
    font-weight: 500;
    z-index: 12000;
    transition: transform 0.4s cubic-bezier(0.175, 0.885, 0.32, 1.275), opacity 0.4s;
    opacity: 0;
    pointer-events: none;
    box-shadow: 0 5px 15px rgba(0,0,0,0.3);
}

.toast.show {
    transform: translateX(-50%) translateY(0);
    opacity: 1;
}

/* --- 설치 배너 --- */
#install-banner {
    position: fixed;
    bottom: 25px;
    left: 50%;
    transform: translateX(-50%);
    background: #ffffff;
    padding: 10px 15px 10px 20px;
    border-radius: 40px; 
    box-shadow: 0 10px 30px rgba(0,0,0,0.15);
    z-index: 11000;
    display: none; 
    align-items: center;
    width: auto;
    min-width: fit-content;
    max-width: 90%;
    justify-content: center;
    gap: 12px;
    border: 1px solid rgba(0,0,0,0.05);
    animation: floatingPop 0.6s cubic-bezier(0.22, 1, 0.36, 1);
}

.install-text {
    font-size: 13px;
    font-weight: 600;
    color: #444;
    white-space: nowrap;
    flex: 0 1 auto;
}

#install-banner > div:last-child {
    display: flex;
    align-items: center;
    gap: 8px;
    flex-shrink: 0;
}

@keyframes floatingPop {
    from { transform: translateX(-50%) translateY(50px); opacity: 0; }
    to { transform: translateX(-50%) translateY(0); opacity: 1; }
}

#install-confirm-btn {
    background: var(--success);
    color: #ffffff;
    border: none;
    padding: 8px 18px;
    border-radius: 20px;
    cursor: pointer;
    font-weight: 700;
    font-size: 13px;
    box-shadow: 0 2px 8px rgba(39, 174, 96, 0.3);
}

#install-close-btn {
    background: none;
    border: none;
    color: #bbb;
    cursor: pointer;
    font-size: 22px;
}

/* --- 모달 시스템 --- */
#startModal, #historyModal, #finishConfirmModal, #deleteConfirmModal, #actionConfirmModal {
    position: fixed; inset: 0; display: flex; align-items: center; justify-content: center;
    background: rgba(0,0,0,0.7); z-index: 10000; padding: 20px;
}

#historyModal, #finishConfirmModal, #deleteConfirmModal, #actionConfirmModal { display: none; }

.box {
    background: #fff; width: 100%; max-width: 340px; padding: 25px;
    border-radius: 24px; box-shadow: 0 20px 50px rgba(0,0,0,0.3); text-align: center;
}

.title { font-weight: 800; font-size: 1.4rem; margin-bottom: 20px; color: var(--dark); }

/* --- 버튼 스타일 --- */
.btn {
    width: 100%; padding: 14px; margin: 6px 0; border-radius: 12px; border: none;
    background: #f0f0f0; font-weight: 700; cursor: pointer; font-size: 15px; transition: 0.2s;
}

.btn.active { background: var(--primary); color: #fff; }

.btn.active.imp-active { background: var(--impossible) !important; color: #fff; }

.btn:disabled { opacity: 0.3; cursor: not-allowed; }

.btn.danger { background: var(--danger); color: #fff; }

.btn.sub { background: #555; color: #fff; margin-top: 10px; }

/* --- 기보 내역 및 개별 삭제 버튼 --- */
.history-item {
    display: flex; justify-content: space-between; align-items: center;
    padding: 12px; border-bottom: 1px solid #eee; cursor: pointer; text-align: left;
}

.history-item:hover { background: #f9f9f9; }

.history-item strong { display: block; font-size: 14px; color: var(--dark); }

.history-item small { font-size: 11px; color: #999; }

.del-btn {
    background: var(--danger); color: #fff; border: none; padding: 6px 12px;
    border-radius: 8px; font-size: 11px; font-weight: 800; cursor: pointer;
    flex-shrink: 0; margin-left: 10px;
}

/* --- 인게임 UI --- */
.setting-label { 
    font-size: 11px; color: #aaa; text-align: left; display: block;
    width: 100%; margin-bottom: 4px; padding-left: 4px; font-weight: 500;
}

.option-group { display: flex; gap: 4px; margin-bottom: 12px; flex-wrap: wrap; }

.option-group .btn { padding: 10px 2px; font-size: 11px; margin: 0; flex: 1; min-width: 60px; }

canvas {
    background: linear-gradient(135deg,#d8a45d,#c8924a); 
    border: 4px solid #4a3419; border-radius: 12px; 
    width: 100%; aspect-ratio: 1/1;
    /* touch-action은 canvas에만 none 적용 → 캔버스 위에서만 기본 터치 막기 */
    touch-action: none;
}

.info-bar { display: flex; gap: 10px; margin-bottom: 15px; width: 100%; justify-content: space-between; align-items: center; }

.timer-box {
    background: rgba(0,0,0,0.85); color: #fff; padding: 8px 14px; border-radius: 12px;
    font-family: monospace; font-size: 16px; min-width: 75px; text-align: center;
    border: 2px solid transparent; transition: 0.3s;
}

.timer-box.active { border-color: var(--primary); }

.status {
    flex: 1; background: var(--dark); color: #fff; padding: 10px; border-radius: 20px;
    font-size: 13px; font-weight: bold; text-align: center;
}

.control-panel { display: flex; gap: 10px; width: 100%; margin-top: 15px; }

#mainGoBtn { display: none; background: var(--dark); color: white; }

#confirmPlaceBtn { display: none; background: var(--primary); color: white; flex: 1.5; }

/* --- 최종 푸터 디자인 --- */
footer {
    position: fixed;
    bottom: 0;
    left: 0;
    width: 100%;
    background: rgba(233, 214, 167, 0.8); 
    backdrop-filter: blur(10px);
    -webkit-backdrop-filter: blur(10px);
    border-top: 1px solid rgba(74, 52, 25, 0.1);
    padding: 12px 20px calc(12px + env(safe-area-inset-bottom, 0px));
    z-index: 9000;
    text-align: center;
}

.footer-container {
    max-width: 500px;
    margin: 0 auto;
    display: flex;
    flex-direction: column;
    gap: 6px;
}

.footer-nav {
    display: flex;
    justify-content: center;
    align-items: center;
    gap: 12px;
}

.footer-link {
    font-size: 12px;
    font-weight: 600;
    color: var(--primary);
    text-decoration: none;
    transition: opacity 0.2s;
}

.footer-link:hover {
    opacity: 0.7;
    text-decoration: underline;
}

.footer-sep::before {
    content: "•";
    color: #4a3419;
    opacity: 0.3;
    font-size: 10px;
}

.footer-info {
    display: flex;
    flex-direction: column;
    gap: 2px;
    font-size: 10px;
    color: #8a7a60;
    opacity: 0.8;
}

.footer-info strong {
    color: #4a3419;
    font-weight: 600;
}

.no-collect {
    letter-spacing: -0.5px;
}

@media (max-height: 700px) {
    footer {
        padding: 8px 20px calc(8px + env(safe-area-inset-bottom, 0px));
    }
    .footer-container { gap: 3px; }
}

/* AI 생각 중일 때 상태 바 스타일 */
.status.thinking {
    border: 2px solid #007bff;
    border-radius: 8px;
    animation: pulse-blue 1.5s infinite ease-in-out;
}

@keyframes pulse-blue {
    0% { box-shadow: 0 0 0 0 rgba(0, 123, 255, 0.7); opacity: 1; }
    50% { box-shadow: 0 0 10px 5px rgba(0, 123, 255, 0.3); opacity: 0.8; }
    100% { box-shadow: 0 0 0 0 rgba(0, 123, 255, 0); opacity: 1; }
}

/* --- 광고 영역: 크기 제한 추가 --- */
.advertisement {
    width: 75%;
    max-width: 700px;       /* 최대 너비 제한 */
    max-height: 126px;      /* 최대 높이 제한 */
    margin-bottom: 12px;
    overflow: hidden;
    display: flex;
    align-items: center;
    justify-content: center;
}

.advertisement img {
    width: 100%;
    height: 100%;
    object-fit: contain;    /* 비율 유지하며 영역에 맞게 축소 */
    display: block;
}