:root {
    --ku-crimson: #8B1F41;
    --ku-gold: #8F8F8F;
    --ku-light-gray: #f5f5f5;
    --shadow: 0 4px 6px rgba(0, 0, 0, 0.1);
    --transition: all 0.3s ease;
}

body {
    font-family: 'Noto Sans KR', sans-serif;
    margin: 0;
    padding: 0;
    background: linear-gradient(135deg, #f5f5f5 0%, #e0e0e0 100%);
    min-height: 100vh;
    -webkit-overflow-scrolling: touch;
    overflow-y: scroll;
    position: relative;
}

/* PC 광고 컨테이너 */
.ad-container-pc {
    position: fixed;
    right: 0;
    top: 50%;
    transform: translateY(-50%);
    z-index: 1000;
    display: block; /* 명시적으로 display 속성 설정 */
}

/* 모바일 광고 컨테이너 */
.ad-container-mobile {
    display: none; /* 기본적으로 숨김 */
    width: 100%;
    text-align: center;
    margin: 10px 0;
}

.ad-container-mobile-square {
    display: none;
    text-align: center;
    margin: 20px auto;
}

@media (max-width: 768px) {
    .ad-container-mobile-square {
        display: block;
    }
}

.header {
    background: var(--ku-crimson);
    color: white;
    padding: 20px;
    box-shadow: var(--shadow);
    display: flex;
    align-items: center;
    justify-content: center;
    width: 100%;
    box-sizing: border-box;
    position: relative;
    z-index: 2;
}

.header h1 {
    font-size: 1.8em;
    margin: 0 0 0 20px;
    text-shadow: 2px 2px 4px rgba(0,0,0,0.2);
    text-align: center;
}

.ku-logo {
    width: 100px;
    height: auto;
    margin: 0;
    filter: drop-shadow(2px 2px 4px rgba(0,0,0,0.3));
    transition: var(--transition);
    flex-shrink: 0;
}

.ku-logo:hover {
    transform: scale(1.05);
}

.container {
    max-width: 800px;
    margin: 0 auto;
    padding: 20px;
}

.buttons-wrapper {
    display: flex;
    justify-content: space-between;
    gap: 10px;
    margin: 40px 0;
    width: 100%;
}

.view-all-button, .menu-button, .contact-button {
    flex: 1;
    display: flex;
    justify-content: center;
    align-items: center;
    padding: 15px;
    background: var(--ku-crimson);
    color: white;
    border: none;
    border-radius: 25px;
    cursor: pointer;
    text-decoration: none;
    font-weight: 500;
    transition: var(--transition);
    box-shadow: var(--shadow);
    min-height: 45px;
    line-height: 1.2;
    word-break: keep-all;
}

.view-all-button:hover, .menu-button:hover, .contact-button:hover {
    transform: translateY(-2px);
    box-shadow: 0 6px 12px rgba(0,0,0,0.2);
    background: #6b1731;
}

.current-time {
    margin: 25px 0;
    background: white;
    border-radius: 15px;
    box-shadow: var(--shadow);
    overflow: hidden;
}

.current-time-header {
    background: var(--ku-crimson);
    color: white;
    padding: 10px;
    text-align: center;
    font-weight: bold;
    font-size: 1.2em;
}

.current-time-content {
    padding: 20px;
    text-align: center;
    font-size: 1.8em;
    color: var(--ku-crimson);
    font-weight: bold;
}

.next-buses {
    display: grid;
    gap: 20px;
    margin: 20px 0;
}

.bus-section {
    background: white;
    border-radius: 15px;
    padding: 25px;
    box-shadow: var(--shadow);
    transition: var(--transition);
    border: 1px solid rgba(139, 31, 65, 0.1);
}

.bus-section h2 {
    color: var(--ku-crimson);
    font-size: 1.4em;
    margin: 0 0 20px 0;
    padding-bottom: 12px;
    border-bottom: 2px solid var(--ku-crimson);
    display: flex;
    align-items: center;
    gap: 10px;
}

.next-bus-time {
    padding: 15px;
    margin: 10px 0;
    background: var(--ku-light-gray);
    border-radius: 12px;
    font-size: 1.1em;
    transition: var(--transition);
}

@media (hover: hover) {
    .next-bus-time:hover {
        background: #eaeaea;
        transform: translateX(5px);
    }

    .bus-section:hover {
        transform: translateY(-3px);
        box-shadow: 0 8px 15px rgba(0,0,0,0.15);
    }
}

.time-info {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 8px 0;
}

.time-info.imminent {
    animation: blink 1s infinite;
    color: var(--ku-crimson);
    font-weight: bold;
}

.time-info.friday-no-service {
    opacity: 0.7;
    background-color: #fff5f5;
}

.time-info.friday-no-service .note {
    color: #dc3545;
    font-weight: 500;
    font-size: 0.9em;
    padding: 2px 6px;
    border-radius: 4px;
    background-color: #ffe5e5;
    display: inline-block;
}

@keyframes blink {
    0% { opacity: 1; }
    50% { opacity: 0.5; }
    100% { opacity: 1; }
}

.time-label {
    color: var(--ku-crimson);
    font-weight: 600;
    min-width: 60px;
}

.countdown-display {
    color: var(--ku-crimson);
    font-weight: bold;
    background: white;
    padding: 4px 8px;
    border-radius: 4px;
    margin-left: 10px;
    font-size: 0.9em;
}

.note {
    color: var(--ku-gold);
    font-size: 0.9em;
    margin-left: auto;
}

.no-buses {
    color: #666;
    text-align: center;
    padding: 15px;
    background: var(--ku-light-gray);
    border-radius: 12px;
    font-weight: 500;
}

/* 모바일 화면에서의 설정 */
@media screen and (max-width: 768px) {
    body {
        overflow-y: scroll;
        -webkit-overflow-scrolling: touch;
    }

    .container {
        padding: 10px;
        margin: 10px auto;
        position: relative;
        z-index: 1;
        touch-action: pan-y pinch-zoom;
    }
    
    .header {
        padding: 10px;
        flex-direction: row;
        gap: 10px;
        justify-content: center;
    }
    
    .header h1 {
        font-size: 1.2rem;
        margin: 0 0 0 10px;
        word-break: keep-all;
    }
    
    .ku-logo {
        width: 40px;
        margin: 0;
    }
    
    .current-time {
        margin: 15px 0;
    }
    
    .current-time-header {
        font-size: 1rem;
        padding: 8px;
    }
    
    .current-time-content {
        font-size: 1.4em;
        padding: 15px;
    }
    
    .bus-section {
        padding: 15px;
        margin-bottom: 15px;
    }
    
    .bus-section h2 {
        font-size: 1.1em;
        margin-bottom: 15px;
        padding-bottom: 8px;
    }
    
    .next-bus-time {
        padding: 12px;
        font-size: 0.95em;
        margin: 8px 0;
    }
    
    .time-info {
        flex-wrap: wrap;
        gap: 5px;
        pointer-events: none;
    }
    
    .time-label {
        min-width: 50px;
        font-size: 0.9em;
    }
    
    .countdown-display {
        font-size: 0.85em;
        padding: 3px 6px;
    }
    
    .note {
        font-size: 0.8em;
        width: 100%;
        text-align: right;
        margin-top: 5px;
    }
    
    .buttons-wrapper {
        margin: 20px 0;
        gap: 8px;
        pointer-events: auto;
        position: relative;
        z-index: 2;
    }
    
    .view-all-button, .menu-button, .contact-button {
        font-size: 0.9em;
        padding: 12px;
        min-height: 40px;
    }
    
    .next-buses {
        gap: 15px;
        margin: 15px 0;
        pointer-events: none;
    }
    
    .no-buses {
        font-size: 0.9em;
        padding: 12px;
    }

    .next-bus-time {
        transform: none !important;
        transition: none;
    }
    
    .bus-section {
        transform: none !important;
        transition: none;
    }
    
    .next-bus-time, 
    .bus-section {
        -webkit-tap-highlight-color: transparent;
        touch-action: none;
    }

    .ad-container-pc {
        display: none !important; /* !important로 우선순위 높임 */
    }
    
    .ad-container-mobile {
        display: block !important; /* !important로 우선순위 높임 */
    }
}

@media (max-width: 360px) {
    .header h1 {
        font-size: 1rem;
    }
    
    .ku-logo {
        width: 35px;
    }
    
    .bus-section h2 {
        font-size: 1em;
    }
    
    .next-bus-time {
        font-size: 0.9em;
    }

    .view-all-button, .menu-button, .contact-button {
        font-size: 0.8em;
        padding: 10px;
        min-height: 35px;
    }
}

/* 푸터 스타일 */
.footer {
    background-color: #8B1F41;
    color: #ffffff;
    padding: 30px 20px;
    margin-top: 50px;
    text-align: center;
    box-shadow: 0 -2px 10px rgba(0, 0, 0, 0.1);
}

.footer-content {
    max-width: 1200px;
    margin: 0 auto;
}

.footer-text {
    margin: 0 0 8px 0;
    font-size: 14px;
    font-weight: 400;
    opacity: 0.9;
}

.footer-creator {
    margin: 0;
    font-size: 13px;
    font-weight: 400;
    opacity: 0.85;
}

.creator-name {
    font-weight: 700;
    letter-spacing: 0.5px;
}

/* 반응형 디자인 */
@media (max-width: 768px) {
    .footer {
        padding: 25px 15px;
        margin-top: 40px;
    }
    
    .footer-text {
        font-size: 13px;
    }
    
    .footer-creator {
        font-size: 12px;
    }
}

/* General Style Reset & Font */
:root {
    --ku-crimson: #862633;
    --border-color: #f0f0f0;
    --text-primary: #333;
    --text-secondary: #888;
    --bg-light-gray: #f9f9f9;
}

/* Floating Action Button */
.calendar-fab {
    position: fixed;
    bottom: 30px;
    right: 30px;
    width: 60px;
    height: 60px;
    background-color: var(--ku-crimson);
    color: white;
    border-radius: 50%;
    display: flex;
    justify-content: center;
    align-items: center;
    font-size: 28px;
    cursor: pointer;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.15);
    z-index: 1000;
    transition: transform 0.2s ease-in-out, box-shadow 0.2s;
}

.calendar-fab:hover {
    transform: scale(1.08);
    box-shadow: 0 6px 16px rgba(0, 0, 0, 0.2);
}

/* Modal Overlay & Container */
.modal-overlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background-color: rgba(0, 0, 0, 0.4);
    display: none;
    justify-content: center;
    align-items: center;
    z-index: 1001;
    backdrop-filter: blur(4px);
    opacity: 0;
    transition: opacity 0.3s ease;
    padding: 20px; /* 모바일에서 마진 효과를 위한 패딩 추가 */
    box-sizing: border-box;
}

.modal-overlay.visible {
    opacity: 1;
}

.calendar-container {
    background-color: white;
    padding: 20px;
    border-radius: 16px;
    box-shadow: 0 10px 40px rgba(0, 0, 0, 0.1);
    width: 100%;
    max-width: 380px;
    transform: scale(0.95);
    opacity: 0;
    transition: transform 0.3s ease, opacity 0.3s ease;
    display: flex;
    flex-direction: column;
    max-height: calc(100vh - 40px); /* 상하 마진 고려한 최대 높이 */
    box-sizing: border-box;
}

.modal-overlay.visible .calendar-container {
    transform: scale(1);
    opacity: 1;
}

/* ==== [캘린더 모달 제목 추가] ==== */
.calendar-modal-title {
    text-align: center;
    padding-bottom: 15px;
    border-bottom: 2px solid var(--ku-crimson);
    margin-bottom: 20px;
}

.calendar-modal-title h1 {
    margin: 0;
    font-size: 1.5em;
    font-weight: 700;
    color: var(--ku-crimson);
    letter-spacing: -0.5px;
}
/* ==== [캘린더 모달 제목 끝] ==== */

/* Calendar Header */
.calendar-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 20px;
    flex-shrink: 0;
}

.calendar-title-container {
    display: flex;
    align-items: center;
    cursor: pointer;
    padding: 5px;
    border-radius: 8px;
    transition: background-color 0.2s;
}
.calendar-title-container:hover {
    background-color: var(--bg-light-gray);
}
.calendar-header h2 {
    margin: 0;
    font-size: 1.4em;
    font-weight: 700;
    color: var(--text-primary);
}
.arrow-down {
    font-size: 0.7em;
    margin-left: 8px;
    color: var(--text-secondary);
    transition: transform 0.3s ease;
}
.arrow-down.up {
    transform: rotate(180deg);
}

.header-buttons {
    display: flex;
    align-items: center;
}
.header-buttons button {
    background: none;
    border: none;
    cursor: pointer;
    color: #999;
    padding: 8px;
    transition: color 0.2s, background-color 0.2s;
    border-radius: 50%;
    display: flex;
    justify-content: center;
    align-items: center;
}
.header-buttons button:hover {
    color: var(--text-primary);
    background-color: var(--bg-light-gray);
}
#prev-month, #next-month { font-size: 1em; }
#close-modal { font-size: 1.8em; font-weight: 300; }
#go-to-today svg { color: #555; }


/* Calendar Main Area */
.calendar-main {
    position: relative;
    overflow: hidden;
    flex-shrink: 0;
}
.calendar-view, .date-picker {
    transition: opacity 0.3s ease, transform 0.3s ease;
}
.date-picker {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: white;
    opacity: 0;
    transform: translateY(10px);
    pointer-events: none;
}
.date-picker.visible {
    opacity: 1;
    transform: translateY(0);
    pointer-events: auto;
}

/* Calendar Grid */
.calendar-grid {
    display: grid;
    grid-template-columns: repeat(7, 1fr);
    gap: 4px; /* 셀 사이 간격 추가로 클리핑 방지 */
    text-align: center;
}
.day-name {
    font-weight: 500;
    color: var(--text-secondary);
    padding-bottom: 15px;
    font-size: 0.85em;
}

/* ==== [모바일 최적화: 날짜 셀 잘림 방지] ==== */
.calendar-body-wrapper {
    padding: 5px; /* 외곽 패딩 추가 */
}

.date-cell {
    position: relative;
    display: flex;
    justify-content: center;
    align-items: center;
    padding: 8px;
    border-radius: 50%;
    aspect-ratio: 1 / 1;
    font-size: 0.9em;
    cursor: pointer;
    box-sizing: border-box;
}

.other-month { 
    color: #dcdcdc; 
    cursor: default; 
}

.date-cell:not(.other-month):hover { 
    background-color: var(--bg-light-gray);
    transition: background-color 0.2s;
}

/* Date States */
.today {
    background-color: #fbebee;
    color: var(--ku-crimson);
    font-weight: 700;
}

.date-cell.active-date {
    background-color: var(--ku-crimson) !important;
    color: white !important;
    font-weight: 700;
}

.date-cell.today.active-date {
    background-color: var(--ku-crimson) !important;
    color: white !important;
}
/* ==== [날짜 셀 잘림 방지 끝] ==== */


.saturday { color: #3b82f6; }
.sunday, .holiday { color: #ef4444; }

.has-schedule::after {
    content: '';
    position: absolute;
    bottom: 8%;
    left: 50%;
    transform: translateX(-50%);
    width: 4px;
    height: 4px;
    border-radius: 50%;
    background-color: var(--ku-crimson);
}

.active-date.has-schedule::after { background-color: white; }

/* Date Picker */
.picker-header { padding: 10px 0; }
#year-select {
    font-size: 1.2em;
    font-weight: bold;
    border: none;
    background: transparent;
    padding: 5px;
    cursor: pointer;
    -webkit-appearance: none;
    -moz-appearance: none;
    appearance: none;
}
.month-select {
    display: grid;
    grid-template-columns: repeat(4, 1fr);
    gap: 10px;
    padding: 10px;
}
.month-button {
    padding: 12px 5px;
    border-radius: 8px;
    cursor: pointer;
    transition: background-color 0.2s;
    font-weight: 500;
}
.month-button:hover { background-color: var(--bg-light-gray); }
.month-button.active {
    background-color: var(--ku-crimson);
    color: white;
}

/* ==== [모바일 최적화: 스크롤 인디케이터 추가] ==== */
.schedule-display {
    position: relative;
    margin-top: 20px;
    padding-top: 20px;
    border-top: 1px solid var(--border-color);
    text-align: left;
    max-height: 100px;
    overflow-y: auto;
    padding-right: 12px; /* 스크롤 인디케이터 공간 확보 */
}

.schedule-display::-webkit-scrollbar { 
    width: 5px; 
}
.schedule-display::-webkit-scrollbar-track { 
    background: transparent; 
}
.schedule-display::-webkit-scrollbar-thumb { 
    background-color: #ccc; 
    border-radius: 10px; 
}

/* 커스텀 스크롤 인디케이터 (모바일용) */
.scroll-indicator {
    position: absolute;
    right: 2px;
    top: 22px;
    width: 4px;
    height: calc(100% - 24px);
    background-color: rgba(0, 0, 0, 0.05);
    border-radius: 2px;
    opacity: 0;
    transition: opacity 0.3s ease;
    pointer-events: none;
}

.scroll-indicator.visible {
    opacity: 1;
}

.scroll-indicator-thumb {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    background-color: var(--ku-crimson);
    border-radius: 2px;
    transition: background-color 0.2s;
}

.scroll-indicator-thumb.scrolling {
    background-color: #6b1f29;
}
/* ==== [스크롤 인디케이터 끝] ==== */

.scroll-guide {
    display: none;
    position: absolute;
    bottom: 10px;
    left: 50%;
    transform: translateX(-50%);
    background-color: rgba(0, 0, 0, 0.7);
    color: white;
    padding: 5px 15px;
    border-radius: 20px;
    font-size: 0.8em;
    z-index: 10;
    opacity: 0;
    transition: opacity 0.3s ease;
    pointer-events: none;
}
.scroll-guide.visible {
    display: block;
    opacity: 1;
}
.scroll-guide .scroll-icon {
    display: inline-block;
    animation: scrollAnimation 1.5s infinite;
}
@keyframes scrollAnimation {
    0%, 100% { transform: translateY(-2px); }
    50% { transform: translateY(2px); }
}

.schedule-display .schedule-date {
    font-weight: 700;
    font-size: 1.0em;
    color: var(--text-primary);
    margin-bottom: 10px;
}
.schedule-display .schedule-item {
    font-size: 0.95em;
    color: #555;
    padding: 4px 0 4px 15px;
    position: relative;
}
.schedule-display .schedule-item::before {
    content: '•';
    position: absolute;
    left: 0;
    color: var(--ku-crimson);
}
.schedule-display .no-schedule {
    color: var(--text-secondary);
    text-align: center;
    padding: 10px 0;
}

/* 모바일 환경 추가 최적화 */
@media (max-width: 480px) {
    .modal-overlay {
        padding: 10px;
    }

    .calendar-container {
        width: 100%;
        padding: 15px;
        max-height: calc(100vh - 20px);
    }
    
    .calendar-modal-title h1 {
        font-size: 1.3em;
    }
    
    .calendar-header h2 {
        font-size: 1.2em;
    }
    
    .day-name {
        font-size: 0.75em;
        padding-bottom: 10px;
    }
    
    .calendar-grid {
        gap: 2px;
    }
    
    .calendar-body-wrapper {
        padding: 3px;
    }
    
    .date-cell {
        font-size: 0.8em;
        padding: 6px;
    }
    
    .schedule-display {
        max-height: 120px; /* 모바일에서 조금 더 높게 */
    }

    .schedule-display .schedule-date {
        font-size: 0.9em;
    }

    .schedule-display .schedule-item {
        font-size: 0.85em;
    }
}

@media (max-width: 360px) {
    .calendar-container {
        padding: 10px;
    }
    
    .calendar-modal-title h1 {
        font-size: 1.1em;
    }
    
    .calendar-header h2 {
        font-size: 1.1em;
    }
    
    .day-name {
        font-size: 0.7em;
    }
    
    .date-cell {
        font-size: 0.75em;
        padding: 4px;
    }
    
    .month-button {
        padding: 8px 3px;
        font-size: 0.85em;
    }
}