* {
    box-sizing: border-box;
    margin: 0;
    padding: 0;
    font-family: 'Apple SD Gothic Neo', 'Noto Sans KR', sans-serif;
    /* 모바일에서 꾹 눌렀을 때 텍스트 선택 방지 */
    user-select: none;
    -webkit-user-select: none;
}

body {
    background-color: #1e293b; /* slate-800 */
    color: white;
    display: flex;
    justify-content: center;
    align-items: center;
    min-height: 100vh;
    /* 모바일 스크롤 튕김 방지 */
    overscroll-behavior: none;
}

.game-container {
    width: 100%;
    max-width: 480px;
    background-color: #0f172a; /* slate-900 */
    border-radius: 16px;
    padding: 20px;
    box-shadow: 0 10px 25px rgba(0,0,0,0.5);
    position: relative; /* 플로팅 버튼의 좌표 기준점 설정 (필수) */
    /* 모바일 하단 안전 영역(Safe Area) 확보 */
    padding-bottom: calc(20px + env(safe-area-inset-bottom));
}

header {
    text-align: center;
    margin-bottom: 20px;
    border-bottom: 1px solid #334155;
    padding-bottom: 15px;
}

h1 {
    color: #38bdf8; /* sky-400 */
    margin-bottom: 10px;
}

.stats-bar {
    display: flex;
    justify-content: space-around;
    font-weight: bold;
    color: #fbbf24; /* amber-400 */
}

.save-status {
    font-size: 0.9rem;
    color: #4ade80; /* green-400 */
    animation: pulse 1.5s infinite;
}
@keyframes pulse {
    0% { opacity: 1; }
    50% { opacity: 0.5; }
    100% { opacity: 1; }
}

.scene {
    background: linear-gradient(to bottom, #38bdf8 0%, #60a5fa 50%, #1e3a8a 50%, #1e293b 100%);
    border-radius: 12px;
    margin-bottom: 20px;
    height: 300px;
    position: relative;
    overflow: hidden;
    display: flex;
    flex-direction: column;
    border: 2px solid #334155;
}

.weather {
    position: absolute;
    top: 10px;
    left: 15px;
    z-index: 10;
    background: rgba(0,0,0,0.3);
    padding: 5px 10px;
    border-radius: 15px;
    font-size: 0.9rem;
    color: white;
}

.message-box {
    position: absolute;
    top: 50px;
    width: 100%;
    text-align: center;
    z-index: 10;
    text-shadow: 0 2px 4px rgba(0,0,0,0.8);
}

#main-message {
    font-size: 1.2rem;
    font-weight: bold;
    margin-bottom: 5px;
}

.sub-text {
    font-size: 0.9rem;
    color: #cbd5e1;
}

/* Visual Area Styles */
.visual-area {
    position: absolute;
    bottom: 0;
    width: 100%;
    height: 100%;
}

.boat-container {
    position: absolute;
    bottom: 40px;
    left: 50%;
    transform: translateX(-50%);
    font-size: 4rem;
    z-index: 5;
    animation: boat-bob 3s ease-in-out infinite;
}

.fisherman {
    position: absolute;
    top: -30px;
    left: 10px;
    font-size: 3rem;
    z-index: 6;
}

.bobber {
    position: absolute;
    font-size: 1.5rem;
    z-index: 4;
    transition: top 0.5s, left 0.5s;
    animation: bobber-float 1s ease-in-out infinite;
}

.fishing-line-svg {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    z-index: 3;
    pointer-events: none;
}

@keyframes boat-bob {
    0%, 100% { transform: translateX(-50%) rotate(0deg) translateY(0); }
    50% { transform: translateX(-50%) rotate(2deg) translateY(5px); }
}

@keyframes bobber-float {
    0%, 100% { transform: translateY(0); }
    50% { transform: translateY(5px); }
}

@keyframes bobber-bite {
    0% { transform: translateY(0); }
    25% { transform: translateY(15px); }
    50% { transform: translateY(-5px); }
    75% { transform: translateY(10px); }
    100% { transform: translateY(0); }
}

.controls {
    display: grid;
    grid-template-columns: repeat(5, 1fr); /* 5개 버튼 균등 배치 */
    gap: 6px;
    width: 100%;
}

.btn {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    padding: 8px 4px;
    height: auto;
    min-height: 70px;
    border: none;
    border-radius: 8px;
    font-weight: bold;
    cursor: pointer;
    transition: background-color 0.2s;
    touch-action: manipulation; /* 더블 탭 줌 방지 */
}

.btn-icon {
    font-size: 1.8rem;
    margin-bottom: 4px;
    line-height: 1;
}

.btn-label {
    font-size: 0.75rem;
    font-weight: normal;
    white-space: nowrap;
    letter-spacing: -0.5px; /* 좁은 공간에 글자 맞춤 */
}

.primary-btn {
    background-color: #2563eb; /* blue-600 */
    color: white;
}

.primary-btn:hover { background-color: #1d4ed8; }
.primary-btn:disabled { background-color: #475569; cursor: not-allowed; }

.danger-btn {
    background-color: #ef4444; /* red-500 */
    color: white;
}
.danger-btn:active { background-color: #dc2626; transform: scale(0.98); } /* 모바일 터치감 개선 */

.floating-reel-btn {
    position: absolute;
    bottom: calc(100px + env(safe-area-inset-bottom)); /* 컨트롤 패널 위로 배치 */
    right: 15px;
    width: 70px;
    height: 70px;
    background-color: white;
    color: #1e293b;
    border: 2px solid #cbd5e1;
    border-radius: 50%;
    font-size: 2.5rem;
    z-index: 21; /* reeling-ui는 20 */
    display: flex;
    justify-content: center;
    align-items: center;
    padding: 0;
    flex: none; /* .btn의 flex: 1 오버라이드 */
    box-shadow: 0 4px 12px rgba(0,0,0,0.4);
    cursor: grab;
    touch-action: none; /* 드래그 시 스크롤 등 브라우저 동작 방지 */
}
.floating-reel-btn:active { cursor: grabbing; }

.floating-reel-btn.hit {
    background-color: #ef4444; /* red-500 */
    color: white;
    border-color: #ef4444;
    animation: pulse-red 0.5s infinite;
}

@keyframes pulse-red {
    0% { transform: scale(1); box-shadow: 0 0 0 0 rgba(239, 68, 68, 0.7); }
    70% { transform: scale(1.1); box-shadow: 0 0 0 10px rgba(239, 68, 68, 0); }
    100% { transform: scale(1); box-shadow: 0 0 0 0 rgba(239, 68, 68, 0); }
}

.secondary-btn {
    background-color: #475569; /* slate-600 */
    color: white;
}
.secondary-btn:hover { background-color: #334155; }

/* Modal Styles */
.modal {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background-color: rgba(0, 0, 0, 0.8);
    display: flex;
    justify-content: center;
    align-items: center;
    z-index: 100;
}

.hidden { display: none; }

.modal-content {
    background-color: #1e293b;
    padding: 25px;
    border-radius: 16px;
    width: 90%;
    max-width: 400px;
    border: 1px solid #334155;
}

.modal-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 20px;
    color: #fbbf24;
}

.close-btn {
    font-size: 1.5rem;
    cursor: pointer;
}

.shop-item {
    background-color: #0f172a;
    padding: 15px;
    border-radius: 10px;
    margin-bottom: 15px;
}

.shop-item h3 { font-size: 1rem; margin-bottom: 5px; }
.shop-item p { font-size: 0.9rem; color: #94a3b8; margin-bottom: 10px; }

.upgrade-btn {
    width: 100%;
    background-color: #059669; /* emerald-600 */
    color: white;
}
.upgrade-btn:hover { background-color: #047857; }
.upgrade-btn:disabled { background-color: #334155; color: #64748b; cursor: not-allowed; }

/* Inventory Styles */
.inventory-grid {
    display: flex;
    flex-direction: column;
    gap: 10px;
    max-height: 300px;
    overflow-y: auto;
    margin-bottom: 15px;
    padding-right: 5px;
}

.inventory-item {
    background-color: #0f172a;
    padding: 10px;
    border-radius: 8px;
    display: flex;
    align-items: center;
    gap: 10px;
    border: 1px solid #334155;
}

.inv-emoji { font-size: 1.5rem; }
.inv-info { flex: 1; }
.inv-name { font-size: 0.9rem; font-weight: bold; }
.inv-count { color: #94a3b8; font-size: 0.8rem; }
.inv-price { color: #fbbf24; font-size: 0.8rem; }

.empty-msg {
    text-align: center;
    color: #64748b;
    padding: 20px;
}

/* Rarity Colors */
.rarity-common { border-color: #94a3b8; }
.rarity-uncommon { border-color: #22c55e; }
.rarity-rare { border-color: #3b82f6; }
.rarity-epic { border-color: #a855f7; }
.rarity-legendary { border-color: #eab308; }
.rarity-mythical { border-color: #ef4444; box-shadow: 0 0 10px #ef4444; }

/* Reeling UI */
.reeling-ui {
    position: absolute;
    bottom: 10px;
    left: 50%;
    transform: translateX(-50%);
    width: 90%;
    background: rgba(15, 23, 42, 0.9);
    padding: 10px;
    border-radius: 10px;
    border: 1px solid #fbbf24;
    z-index: 20;
}

.reeling-info {
    text-align: center;
    font-size: 0.9rem;
    margin-bottom: 5px;
    color: #fbbf24;
}

.progress-container {
    width: 100%;
    height: 20px;
    background-color: #334155;
    border-radius: 10px;
    overflow: hidden;
}

.progress-bar {
    height: 100%;
    background: linear-gradient(90deg, #22c55e, #eab308, #ef4444);
    width: 0%;
    transition: width 0.1s linear;
}

.reeling-status {
    text-align: right;
    font-size: 0.8rem;
    margin-top: 5px;
    color: #cbd5e1;
}

/* Catch Modal Styles */
.catch-content {
    text-align: center;
    background: linear-gradient(to bottom, #1e293b, #0f172a);
    border: 2px solid #fbbf24;
}

.catch-emoji {
    font-size: 6rem;
    margin: 20px 0;
    animation: pop-in 0.5s cubic-bezier(0.175, 0.885, 0.32, 1.275);
}

@keyframes pop-in {
    0% { transform: scale(0); opacity: 0; }
    100% { transform: scale(1); opacity: 1; }
}

.catch-details {
    margin-bottom: 20px;
}

.catch-content .btn {
    width: 100%;
    min-height: auto;
    padding: 15px;
    flex-direction: row;
    font-size: 1.1rem;
}

.catch-content .btn:disabled {
    background-color: #475569;
    cursor: not-allowed;
}

.rarity-badge {
    display: inline-block;
    padding: 5px 15px;
    border-radius: 20px;
    font-size: 0.9rem;
    font-weight: bold;
    margin: 10px 0;
    background-color: #334155;
    color: white;
    border: 1px solid #94a3b8;
}

/* Auth Modal & User Profile Styles */
.user-profile {
    display: flex;
    align-items: center;
    gap: 10px;
}

.logout-btn {
    background: #ef4444;
    color: white;
    border: none;
    border-radius: 5px;
    padding: 3px 8px;
    font-size: 0.7rem;
    cursor: pointer;
}

.auth-content {
    background: #0f172a;
    border: 1px solid #334155;
}

.auth-content h2 {
    text-align: center;
    color: #38bdf8;
    margin-bottom: 20px;
}

.auth-form {
    display: flex;
    flex-direction: column;
    gap: 15px;
}

.auth-form input {
    padding: 10px;
    border-radius: 5px;
    border: 1px solid #334155;
    background-color: #1e293b;
    color: white;
    font-size: 1rem;
}

.auth-form button {
    padding: 12px;
    border-radius: 8px;
    border: none;
    background-color: #2563eb;
    color: white;
    font-weight: bold;
    cursor: pointer;
}

.auth-switch {
    text-align: center;
    margin-top: 15px;
    font-size: 0.9rem;
    color: #94a3b8;
}

.auth-switch span {
    color: #38bdf8;
    cursor: pointer;
    text-decoration: underline;
}

.auth-error {
    color: #ef4444;
    text-align: center;
    margin-top: 10px;
    font-size: 0.9rem;
}

/* Ranking Styles */
.ranking-list {
    display: flex;
    flex-direction: column;
    gap: 10px;
    max-height: 400px;
    overflow-y: auto;
}

.ranking-item {
    display: flex;
    align-items: center;
    background-color: #0f172a;
    padding: 10px 15px;
    border-radius: 8px;
    border: 1px solid #334155;
}

.ranking-item.rank-1 { border-color: #eab308; box-shadow: 0 0 5px #eab308; }
.ranking-item.rank-2 { border-color: #c0c0c0; }
.ranking-item.rank-3 { border-color: #cd7f32; }

.ranking-rank {
    font-size: 1.2rem;
    font-weight: bold;
    width: 40px;
    color: #fbbf24;
}

.ranking-info {
    flex: 1;
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.ranking-username {
    font-size: 1rem;
    font-weight: bold;
}

.ranking-stats {
    text-align: right;
    font-size: 0.9rem;
    color: #94a3b8;
}

.ranking-loading {
    text-align: center;
    padding: 20px;
    color: #94a3b8;
}

/* Guide Modal Styles */
.guide-content-wrapper {
    max-width: 500px; /* 도감은 좀 더 넓게 */
    height: 80vh; /* 높이 고정 */
    display: flex;
    flex-direction: column;
}

.guide-tabs {
    display: flex;
    gap: 10px;
    margin-bottom: 15px;
    border-bottom: 1px solid #334155;
    padding-bottom: 10px;
}

.tab-btn {
    flex: 1;
    padding: 10px;
    background: transparent;
    border: none;
    color: #94a3b8;
    font-weight: bold;
    cursor: pointer;
    border-bottom: 2px solid transparent;
}

.tab-btn.active {
    color: #38bdf8;
    border-bottom-color: #38bdf8;
}

.guide-body {
    flex: 1;
    overflow-y: auto;
    padding-right: 5px;
}

.guide-section-title {
    color: #fbbf24;
    margin: 15px 0 10px 0;
    font-size: 1rem;
    border-left: 3px solid #fbbf24;
    padding-left: 10px;
}

.guide-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(130px, 1fr));
    gap: 10px;
}

.guide-card {
    background-color: #0f172a;
    border: 1px solid #334155;
    border-radius: 8px;
    padding: 10px;
    text-align: center;
    font-size: 0.85rem;
}

.guide-emoji { font-size: 2rem; margin-bottom: 5px; }
.guide-name { font-weight: bold; margin-bottom: 5px; color: white; }
.guide-stats { color: #94a3b8; font-size: 0.8rem; line-height: 1.4; }
.guide-req { color: #ef4444; font-size: 0.75rem; margin-top: 5px; }

.equip-list {
    display: flex;
    flex-direction: column;
    gap: 10px;
}

.equip-card { display: flex; align-items: center; gap: 15px; text-align: left; }

/* --- 모바일/태블릿 반응형 스타일 --- */
@media (max-width: 480px) {
    body {
        align-items: flex-start; /* 위쪽부터 채우기 */
        background-color: #0f172a; /* 배경색 통일 */
    }

    .game-container {
        min-height: 100vh; /* 전체 높이 사용 */
        border-radius: 0; /* 둥근 모서리 제거 */
        box-shadow: none;
        padding: 10px;
        padding-bottom: calc(10px + env(safe-area-inset-bottom));
        display: flex;
        flex-direction: column;
    }

    header {
        margin-bottom: 10px;
        padding-bottom: 10px;
    }

    h1 {
        font-size: 1.5rem;
        margin-bottom: 5px;
    }

    main {
        flex: 1;
        display: flex;
        flex-direction: column;
    }

    .scene {
        flex: 1; /* 남은 공간 모두 차지 */
        height: auto;
        min-height: 200px; /* 최소 높이 줄임 */
        margin-bottom: 10px;
    }

    .controls {
        gap: 4px; /* 버튼 간격 좁힘 */
    }

    .btn {
        min-height: 60px; /* 버튼 높이 최적화 */
        padding: 6px 2px;
    }

    .btn-icon {
        font-size: 1.5rem;
    }

    .btn-label {
        font-size: 0.7rem; /* 글자 크기 조정 */
    }

    /* 모달을 전체 화면으로 */
    .modal-content {
        width: 100%;
        height: 100%;
        max-width: none;
        border-radius: 0;
        border: none;
        padding: 20px;
        padding-bottom: calc(20px + env(safe-area-inset-bottom));
        display: flex;
        flex-direction: column;
    }

    .inventory-grid, .ranking-list, .shop-items, .guide-body {
        flex: 1; /* 내용 영역이 남은 공간 차지 */
        max-height: none; /* 높이 제한 해제 */
    }

    .close-btn {
        padding: 10px; /* 닫기 버튼 터치 영역 확대 */
        font-size: 2rem;
    }
}