@import url('https://cdn.jsdelivr.net/npm/galmuri/dist/galmuri.css');

body {
    font-family: 'Galmuri11', sans-serif;
    background-color: #f4f4f9;
    color: #333;
    margin: 0;
    padding: 20px;
    display: flex;
    justify-content: center;
    line-height: 1.6;
}

.container {
    width: 100%;
    max-width: 900px;
    background-color: #fff;
    padding: 20px;
    border-radius: 12px;
    box-shadow: 0 4px 12px rgba(0,0,0,0.08);
}

.header-nav {
    display: flex;
    justify-content: center;
    gap: 10px;
    background-color: #2c3e50;
    padding: 10px;
    border-radius: 8px;
    margin-bottom: 25px;
    flex-wrap: wrap;
}

.header-nav a {
    color: white;
    text-decoration: none;
    padding: 8px 15px;
    border-radius: 5px;
    font-weight: bold;
    transition: background-color 0.3s;
    font-size: 0.9em;
}

.header-nav a:hover {
    background-color: #34495e;
}

.header-nav a.active {
    background-color: #e74c3c;
}

h1, h2, h3 {
    color: #2c3e50;
    border-bottom: 2px solid #eaeaea;
    padding-bottom: 10px;
    margin-top: 30px;
}

h1 {
    font-size: 1.8em;
    text-align: center;
}
h2 {
    font-size: 1.4em;
}
h3.chart-title {
    font-size: 1.2em;
    margin-top: 40px;
}

.upload-section {
    display: flex;
    gap: 20px;
    margin: 20px 0;
    flex-wrap: wrap;
}

.upload-box {
    flex: 1;
    min-width: 250px;
    border: 2px dashed #ddd;
    padding: 20px;
    border-radius: 8px;
    text-align: center;
    background-color: #f9f9f9;
}

.upload-box label {
    display: block;
    margin-bottom: 10px;
}

input[type="file"] {
    width: 100%;
    max-width: 100%;
}

.file-status {
    display: block;
    margin-top: 10px;
    font-size: 0.85em;
    color: #27ae60;
    font-weight: bold;
}

#resetButton {
    display: block;
    width: 100%;
    padding: 12px;
    margin: 10px 0 30px 0;
    background-color: #e74c3c;
    color: white;
    border: none;
    border-radius: 8px;
    font-size: 1em;
    font-weight: bold;
    cursor: pointer;
    transition: background-color 0.3s;
}

#resetButton:hover {
    background-color: #c0392b;
}


.summary-box {
    background-color: #e8f0fe;
    border-left: 5px solid #3498db;
    border-radius: 8px;
    padding: 20px;
    margin: 20px 0;
    font-size: 1.1em;
    font-weight: bold;
}
.summary-box.secondary {
    background-color: #e8f5e9;
    border-color: #2ecc71;
}
.summary-box.tertiary {
    background-color: #fff8e1;
    border-color: #f1c40f;
}
.summary-box.quaternary {
    background-color: #f3e5f5;
    border-color: #9b59b6;
}

#game-selector-section select {
    width: 100%;
    padding: 12px;
    font-size: 1em;
    border-radius: 8px;
    border: 1px solid #ccc;
    background-color: #fff;
}

#currency-section select {
    width: 100%;
    padding: 12px;
    font-size: 1em;
    border-radius: 8px;
    border: 1px solid #ccc;
    background-color: #fff;
}


#filter-section {
    margin: 20px 0;
    display: flex;
    flex-direction: column;
    gap: 15px;
}
#search-container input {
    width: 100%;
    padding: 10px 15px;
    border: 1px solid #ccc;
    border-radius: 20px;
    box-sizing: border-box;
}

#button-container, #trickcal-filter-buttons {
    display: flex;
    flex-wrap: wrap;
    gap: 10px;
}

.filter-btn {
    padding: 8px 15px;
    border: 1px solid #ccc;
    background-color: #f7f7f7;
    border-radius: 20px;
    cursor: pointer;
    transition: background-color 0.2s, color 0.2s;
}

.filter-btn:hover { background-color: #e0e0e0; }
.filter-btn.active { background-color: #2c3e50; color: #fff; border-color: #2c3e50; }

table {
    width: 100%;
    border-collapse: collapse;
    margin-top: 10px;
}

th, td {
    padding: 12px 15px;
    text-align: left;
    border-bottom: 1px solid #ddd;
}
th {
    background-color: #f8f8f8;
    font-weight: bold;
    white-space: nowrap;
}
tbody tr:nth-child(even) { background-color: #fdfdfd; }
td:last-child { text-align: right; font-weight: 500; }

/* Monthly Accordion */
#monthly-accordion .month-item {
    border: 1px solid #ddd;
    border-radius: 5px;
    margin-bottom: 5px;
    overflow: hidden;
}
#monthly-accordion .month-summary {
    display: flex;
    justify-content: space-between;
    padding: 15px;
    background-color: #f9f9f9;
    cursor: pointer;
    font-weight: bold;
}
#monthly-accordion .month-summary:hover { background-color: #f1f1f1; }
#monthly-accordion .month-summary::before { content: '▶'; margin-right: 10px; transition: transform 0.3s ease; }
#monthly-accordion .month-item.active .month-summary::before { transform: rotate(90deg); }
#monthly-accordion .month-details {
    max-height: 0;
    overflow: hidden;
    transition: max-height 0.3s ease-out;
    background-color: #fff;
}
#monthly-accordion .month-item.active .month-details { max-height: 500px; overflow-y: auto; }
#monthly-accordion .month-details table { margin-top: 0; border-top: 1px solid #ddd; }


/* Charts */
.chart-container {
    position: relative;
    height: 400px;
    width: 100%;
}

#monthly-chart-container {
    display: flex;
    align-items: flex-end;
    height: 250px;
    padding: 20px;
    border: 1px solid #ddd;
    border-radius: 5px;
    margin-top: 10px;
    overflow-x: auto;
    justify-content: flex-start;
    -webkit-overflow-scrolling: touch;
}
#monthly-chart-container::-webkit-scrollbar { height: 8px; }
#monthly-chart-container::-webkit-scrollbar-track { background: #f1f1f1; border-radius: 10px; }
#monthly-chart-container::-webkit-scrollbar-thumb { background: #ccc; border-radius: 10px; }
#monthly-chart-container::-webkit-scrollbar-thumb:hover { background: #aaa; }

.chart-bar-wrapper {
    display: flex;
    flex-direction: column;
    align-items: center;
    text-align: center;
    height: 100%;
    justify-content: flex-end;
    min-width: 70px;
    flex-shrink: 0;
}
.chart-amount { font-size: 0.8em; font-weight: bold; margin-bottom: 5px; }
.chart-bar {
    width: 40px;
    background-color: #3498db;
    border-radius: 5px 5px 0 0;
    transition: height 0.5s ease-out;
}
.chart-label {
    margin-top: 5px;
    font-size: 0.75em;
    white-space: pre;
    height: 2.5em;
    display: flex;
    justify-content: center;
    align-items: center;
}

.hidden {
    display: none !important;
}

/* Mobile Responsive Styles */
@media (max-width: 768px) {
    body {
        padding: 10px;
    }
    .container {
        padding: 15px;
    }
    h1 { font-size: 1.5em; }
    h2 { font-size: 1.2em; }

    .upload-section {
        flex-direction: column;
    }
    
    .header-nav {
        gap: 5px;
    }
    .header-nav a {
        padding: 8px 10px;
        font-size: 0.8em;
    }

    #details-table,
    .month-details table {
        border: 0;
    }
    #details-table thead,
    .month-details table thead {
        display: none;
    }
    #details-table tr,
    .month-details table tr {
        display: block;
        margin-bottom: 15px;
        border: 1px solid #ddd;
        border-radius: 8px;
        box-shadow: 0 2px 4px rgba(0,0,0,0.05);
        padding: 10px;
        background-color: #fff !important;
    }
    #details-table td,
    .month-details table td {
        display: block;
        text-align: right !important;
        font-size: 0.95em;
        border-bottom: 1px dotted #ccc;
        position: relative;
        padding-left: 50%;
        min-height: 24px; /* 높이 확보 */
    }
    #details-table td:last-child,
    .month-details table td:last-child {
        border-bottom: 0;
    }
    #details-table td::before,
    .month-details table td::before {
        content: attr(data-label);
        position: absolute;
        left: 10px;
        width: 45%;
        padding-right: 10px;
        white-space: nowrap;
        text-align: left;
        font-weight: bold;
        color: #34495e;
    }
    
    .chart-bar-wrapper { min-width: 55px; }
    .chart-bar { width: 30px; }
}

/* --- Keyword Manager --- */
#keyword-manager {
    background-color: #fff;
    margin: 20px 0;
}
#keyword-manager summary {
    cursor: pointer;
    padding: 15px 20px;
    font-weight: bold;
    list-style: none; /* 기본 화살표 제거 */
}
#keyword-manager summary::-webkit-details-marker {
    display: none; /* Safari에서 화살표 제거 */
}
#keyword-manager summary h2 {
    display: inline;
    border: none;
    padding: 0;
    margin: 0;
    font-size: 1.2em;
}
#keyword-manager summary::before {
    content: '▶';
    margin-right: 10px;
    display: inline-block;
    transition: transform 0.2s;
}
#keyword-manager details[open] > summary::before {
    transform: rotate(90deg);
}
.keyword-content {
    padding: 0 20px 20px 20px;
    border-top: 1px solid #eee;
}
.keyword-form {
    display: flex;
    flex-direction: column;
    gap: 10px;
    margin-bottom: 15px;
}
.keyword-form input, .keyword-search-container input {
    padding: 10px;
    border: 1px solid #ccc;
    border-radius: 4px;
    width: 100%;
    box-sizing: border-box;
}
.keyword-search-container {
    margin-bottom: 15px;
}
.keyword-form button {
    padding: 10px;
    background-color: #3498db;
    color: white;
    border: none;
    border-radius: 4px;
    cursor: pointer;
    font-weight: bold;
    transition: background-color 0.3s;
}
#keywords-list {
    list-style-type: none;
    padding: 0;
    max-height: 500px;
    overflow-y: auto;
    border: 1px solid #eee;
    border-radius: 4px;
    padding: 10px;
    background-color: #fff;
}
#keywords-list li {
    padding: 5px;
    border-bottom: 1px solid #f0f0f0;
}
#keywords-list li:last-child {
    border-bottom: none;
}
.keyword-tag {
    display: inline-flex;
    align-items: center;
    background-color: #ecf0f1;
    border-radius: 12px;
    padding: 3px 8px;
    margin: 3px;
    font-size: 0.9em;
}

.delete-keyword-btn {
    background-color: #e74c3c;
    color: white;
    border: none;
    border-radius: 4px;
    padding: 2px 6px;
    font-size: 0.8em;
    cursor: pointer;
    margin-left: 10px;
}
.delete-keyword-btn.app-delete {
    background-color: #c0392b;
}
.delete-keyword-btn:hover {
    opacity: 0.8;
}

.keyword-tag .delete-keyword-btn {
    padding: 0;
    background: none;
    color: #95a5a6;
    font-size: 1.2em;
    line-height: 1;
    margin-left: 5px;
    font-weight: bold;
}
.keyword-tag .delete-keyword-btn:hover {
    color: #e74c3c;
}

/* --- Recap Page Specific Styles --- */
.recap-intro {
    text-align: center;
    padding: 40px 20px;
}
.recap-intro h1 { font-size: 2.2em; color: #6c5ce7; border-bottom: none; }
.intro-text { font-size: 1.1em; margin-bottom: 30px; color: #555; }

.year-select-wrapper { margin: 20px 0; font-size: 1.2em; }
.year-select-wrapper select {
    padding: 8px 15px; font-size: 1em; border-radius: 8px; border: 2px solid #6c5ce7;
}

.start-btn {
    background-color: #b2bec3;
    color: white;
    font-size: 1.2em;
    padding: 15px 40px;
    border: none;
    border-radius: 50px;
    cursor: not-allowed;
    margin-top: 30px;
    transition: all 0.3s ease;
}
.start-btn.ready {
    background-color: #6c5ce7;
    cursor: pointer;
    box-shadow: 0 5px 15px rgba(108, 92, 231, 0.4);
    animation: pulse-btn 2s infinite;
}
@keyframes pulse-btn {
    0% { transform: scale(1); }
    50% { transform: scale(1.05); }
    100% { transform: scale(1); }
}

/* --- Recap Overlay & Animation --- */
#recap-overlay {
    position: fixed;
    top: 0; left: 0; width: 100%; height: 100%;
    background: radial-gradient(circle at center, #2d3436 0%, #000000 100%);
    z-index: 9999;
    color: white;
    display: flex;
    justify-content: center;
    align-items: center;
    flex-direction: column;
}

#close-recap-btn {
    position: absolute; top: 20px; right: 20px;
    background: rgba(255,255,255,0.2);
    border: 1px solid white; color: white;
    padding: 5px 15px; border-radius: 20px; cursor: pointer;
}

.slide-content { text-align: center; width: 100%; max-width: 500px; padding: 20px; }
.highlight-text { font-size: 3em; color: #a29bfe; text-shadow: 0 0 20px rgba(162, 155, 254, 0.5); margin: 20px 0; }
.big-number { font-size: 3.5em; font-weight: bold; color: #ffeaa7; margin: 20px 0; }

/* 영수증 스타일 */
.receipt-paper {
    background: #fff; color: #333;
    padding: 30px; margin: 0 auto;
    width: 80%; max-width: 350px;
    font-family: 'Courier New', Courier, monospace;
    box-shadow: 0 0 20px rgba(255,255,255,0.1);
    transform: rotate(-2deg);
}
.receipt-line { letter-spacing: 3px; color: #aaa; margin: 10px 0; overflow: hidden; white-space: nowrap; }
.receipt-row { display: flex; justify-content: space-between; margin-bottom: 8px; font-size: 0.9em; }
.receipt-row .name { flex: 1; text-align: left; }
.receipt-row .count { width: 40px; text-align: right; color: #666; }
.receipt-row .price { width: 80px; text-align: right; font-weight: bold; }
.receipt-total { display: flex; justify-content: space-between; font-size: 1.2em; font-weight: bold; margin-top: 10px; }
.barcode { font-family: 'Libre Barcode 39', sans-serif; font-size: 2em; margin-top: 20px; opacity: 0.7; }

/* 월별 원형 스타일 */
.month-circle {
    width: 150px; height: 150px;
    background-color: #ff7675;
    border-radius: 50%;
    display: flex; justify-content: center; align-items: center;
    font-size: 3em; font-weight: bold;
    margin: 30px auto;
    box-shadow: 0 0 30px rgba(255, 118, 117, 0.6);
}

.next-btn {
    margin-top: 40px;
    padding: 12px 40px;
    background-color: #6c5ce7;
    color: white; border: none; border-radius: 30px;
    font-size: 1.2em; cursor: pointer;
    transition: transform 0.2s;
}
.next-btn:hover { transform: scale(1.1); background-color: #5f27cd; }
.restart-btn {
    margin-top: 20px; padding: 10px 30px;
    background: transparent; border: 2px solid white; color: white;
    border-radius: 20px; cursor: pointer;
}

/* 애니메이션 */
.fade-in-up { animation: fadeInUp 0.8s cubic-bezier(0.2, 0.8, 0.2, 1) forwards; opacity: 0; transform: translateY(30px); }
@keyframes fadeInUp { to { opacity: 1; transform: translateY(0); } }

/* 월별 상세 영수증 (Long Receipt) 스타일 */
.receipt-paper.long-receipt {
    max-height: 70vh; /* 화면 높이의 70%까지만 차지 */
    display: flex;
    flex-direction: column;
}

.receipt-body.scrollable-body {
    overflow-y: auto; /* 내용이 넘치면 스크롤 */
    flex: 1;
    padding-right: 5px;
    margin: 10px 0;
    max-height: 400px; /* PC화면 기준 최대 높이 */
}

/* 스크롤바 커스텀 (크롬, 사파리 등) */
.receipt-body.scrollable-body::-webkit-scrollbar {
    width: 6px;
}
.receipt-body.scrollable-body::-webkit-scrollbar-track {
    background: #f1f1f1; 
}
.receipt-body.scrollable-body::-webkit-scrollbar-thumb {
    background: #ccc; 
    border-radius: 3px;
}
.receipt-body.scrollable-body::-webkit-scrollbar-thumb:hover {
    background: #aaa; 
}

.receipt-month-header {
    text-align: center;
    font-weight: bold;
    margin: 15px 0 5px 0;
    color: #6c5ce7;
    border-bottom: 1px dashed #ddd;
    padding-bottom: 2px;
}
.receipt-row.sub-total {
    font-size: 0.8em;
    font-style: italic;
    border-bottom: 1px solid #eee;
    padding-bottom: 5px;
}

/* --- 고급 패스 (Premium Pass) 스타일 --- */
.pass-row {
    align-items: center;
    padding: 5px 0;
}

.pass-info-left {
    display: flex;
    align-items: center;
    gap: 10px;
}

.month-label {
    font-weight: bold;
    min-width: 40px;
}

.normal-badge {
    font-size: 0.8em;
    color: #888;
    background: #f0f0f0;
    padding: 2px 6px;
    border-radius: 10px;
}

.premium-badge {
    display: flex;
    align-items: center;
    gap: 5px;
    background-color: #ffeaa7;
    color: #d35400;
    font-size: 0.85em;
    font-weight: bold;
    padding: 2px 8px;
    border-radius: 15px;
    box-shadow: 0 2px 5px rgba(0,0,0,0.1);
    animation: bounce 1s infinite alternate;
}

/* GIF 이미지 스타일 */
.premium-badge img {
    width: 24px;
    height: 24px;
    border-radius: 50%;
    object-fit: cover;
    border: 1px solid #fff;
    background-color: #fff;
}

/* [NEW] MP4 비디오 스타일 */
.premium-badge video {
    width: 24px;
    height: 24px;
    border-radius: 50%;
    object-fit: cover;
    border: 1px solid #fff;
    background-color: #fff;
    vertical-align: middle;
}

.premium-row {
    background-color: rgba(255, 234, 167, 0.2);
    border-radius: 5px;
    margin: 2px 0;
    padding: 5px;
}

@keyframes bounce {
    from { transform: translateY(0); }
    to { transform: translateY(-2px); }
}

/* --- 사복 패스 이미지 스타일 --- */
.sashik-row {
    align-items: center;
    padding: 8px 0;
    border-bottom: 1px dotted #eee;
}

.sashik-info {
    display: flex;
    align-items: center;
    gap: 10px;
    flex: 1;
}

.sashik-img-wrapper {
    width: 40px;
    height: 40px;
    border-radius: 50%;
    overflow: hidden;
    border: 2px solid #e17055;
    background-color: #fff;
    flex-shrink: 0; /* 이미지 찌그러짐 방지 */
}

.sashik-char-img {
    width: 100%;
    height: 100%;
    object-fit: cover;
}

/* --- 사복 패스 갤러리 (카드 그리드) 스타일 --- */
.sashik-gallery-grid {
    display: grid;
    grid-template-columns: repeat(2, 1fr); /* 2열 배치 */
    gap: 15px;
    padding: 10px;
    max-height: 60vh;
    overflow-y: auto;
}

.sashik-card {
    background-color: #fff;
    border-radius: 12px;
    padding: 10px;
    box-shadow: 0 4px 10px rgba(0,0,0,0.2);
    text-align: center;
    transition: transform 0.2s;
    color: #333;
}
.sashik-card:hover {
    transform: translateY(-5px);
}

.sashik-card-wrapper {
    width: 100%;
    aspect-ratio: 1; /* 정사각형 비율 유지 */
    overflow: hidden;
    border-radius: 8px;
    background-color: #f9f9f9;
    border: 2px solid #fdcb6e;
    margin-bottom: 8px;
    display: flex;
    align-items: center;
    justify-content: center;
}

.sashik-card-img {
    width: 100%;
    height: 100%;
    object-fit: cover; /* 꽉 차게 */
    display: block;
}

.sashik-card-info {
    display: flex;
    flex-direction: column;
    gap: 2px;
}

.sashik-month {
    font-size: 0.8em;
    color: #e17055;
    font-weight: bold;
    background: #ffeaa7;
    border-radius: 10px;
    display: inline-block;
    padding: 2px 6px;
    align-self: center;
}

.sashik-name {
    font-size: 0.9em;
    font-weight: bold;
    word-break: keep-all;
    line-height: 1.2;
}


/* --- 사복 패스 영수증 (리스트) 스타일 --- */
.sashik-row {
    align-items: center;
    padding: 8px 0;
    border-bottom: 1px dotted #eee;
}

.sashik-info {
    display: flex;
    align-items: center;
    gap: 10px;
    flex: 1;
}

/* 영수증용 작은 동그라미 이미지 */
.sashik-img-wrapper {
    width: 40px;
    height: 40px;
    border-radius: 50%;
    overflow: hidden;
    border: 2px solid #e17055;
    background-color: #fff;
    flex-shrink: 0;
}

.sashik-char-img {
    width: 100%;
    height: 100%;
    object-fit: cover;
}


/* 카드 순차적 등장 애니메이션 */
.fade-in-up-stagger {
    animation: fadeInUp 0.5s ease-out forwards;
    opacity: 0;
    transform: translateY(20px);
}
/* nth-child로 딜레이 주기 (최대 20개까지만 설정) */
.sashik-card:nth-child(1) { animation-delay: 0.1s; }
.sashik-card:nth-child(2) { animation-delay: 0.2s; }
.sashik-card:nth-child(3) { animation-delay: 0.3s; }
.sashik-card:nth-child(4) { animation-delay: 0.4s; }
.sashik-card:nth-child(5) { animation-delay: 0.5s; }
.sashik-card:nth-child(6) { animation-delay: 0.6s; }
.sashik-card:nth-child(n+7) { animation-delay: 0.7s; }

/* --- 버튼 스타일 --- */
.save-img-btn {
    padding: 10px 20px;
    background-color: #fab1a0;
    color: #2d3436;
    border: none;
    border-radius: 20px;
    font-size: 1em;
    font-weight: bold;
    cursor: pointer;
    transition: transform 0.2s, background-color 0.2s;
    box-shadow: 0 4px 6px rgba(0,0,0,0.2);
}
.save-img-btn:hover {
    transform: scale(1.05);
    background-color: #ff7675;
    color: white;
}
.button-group {
    display: flex;
    flex-direction: column;
    gap: 15px;
    align-items: center;
    margin-top: 20px;
}

/* --- Footer 스타일 --- */
.site-footer {
    text-align: center;
    padding: 40px 20px;
    margin-top: 50px;
    border-top: 1px solid #ddd;
    background-color: #fff;
    color: #666;
    font-size: 0.9em;
}

.site-footer strong {
    font-weight: bold;
}

.site-footer .copyright {
    margin-top: 10px;
    font-size: 0.8em;
    color: #999;
}

#recap-content-area {
    max-height: 80vh;       /* 화면 높이의 80%까지만 차지 */
    overflow-y: auto;       /* 내용이 넘치면 세로 스크롤 생성 */
    width: 100%;
    display: flex;
    flex-direction: column;
    align-items: center;
    padding: 10px;          /* 여백 추가 */
    box-sizing: border-box; /* 패딩 포함 크기 계산 */
}

/* 스크롤바 꾸미기 (선택사항) */
#recap-content-area::-webkit-scrollbar {
    width: 8px;
}
#recap-content-area::-webkit-scrollbar-thumb {
    background-color: rgba(255, 255, 255, 0.3);
    border-radius: 4px;
}