:root {
    --primary-color: #50C878; /*#4A90E2*/
    --secondary-color: #50B3E8; /*#50C878*/
    --danger-color: #E74C3C;
    --warning-color: #F39C12;
    --text-primary: #2C3E50;
    --text-secondary: #7F8C8D;
    --bg-color: #F8F9FA;
    --card-bg: #FFFFFF;
    --border-color: #E1E8ED;
    --shadow: 0 2px 8px rgba(0, 0, 0, 0.1);
    --shadow-hover: 0 4px 12px rgba(0, 0, 0, 0.15);
}

* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
    -webkit-tap-highlight-color: transparent;
}

html {
    overflow-x: hidden;
    width: 100%;
}

body {
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', 'Hiragino Sans', 'Hiragino Kaku Gothic ProN', Meiryo, sans-serif;
    background: var(--bg-color);
    color: var(--text-primary);
    line-height: 1.6;
    overflow-x: hidden;
    width: 100%;
    max-width: 100vw;
}

.calendar-container {
    max-width: 600px;
    width: 100%;
    margin: 0 auto 10px auto;
    padding: 0;
    overflow-x: hidden;
}

/* グリッド部分を親幅ちょうどに */
.calendar-weekdays,
.calendar-body,
.calendar-week {
    width: 100%;
}

.calendar-header {
    background: linear-gradient(135deg, var(--primary-color) 0%, var(--secondary-color) 100%);
    color: white;
    padding: 20px 16px;
    position: sticky;
    top: 0;
    z-index: 100;
    box-shadow: var(--shadow);
    width: 100%;
}

.calendar-nav {
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 16px;
    width: 100%;
}

.calendar-title {
    font-size: clamp(20px, 5vw, 24px);
    font-weight: 700;
    flex: 1;
    text-align: center;
    letter-spacing: 0.5px;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.nav-button {
    background: rgba(255, 255, 255, 0.2);
    border: none;
    color: white;
    width: 44px;
    height: 44px;
    min-width: 44px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    transition: all 0.3s ease;
    font-size: 20px;
    flex-shrink: 0;
}

.nav-button:active {
    background: rgba(255, 255, 255, 0.3);
    transform: scale(0.95);
}

/* 前月ボタンを非表示にする */
.nav-button.hidden {
    visibility: hidden;
    pointer-events: none;
}

.instruction {
	background: white;
	padding: 16px;
	margin: 16px;
	border-radius: 12px;
	box-shadow: var(--shadow);
	text-align: center;
	font-size: 14px;
	color: var(--text-secondary);
	line-height: 1.6;
}

.calendar-weekdays {
    display: grid;
    grid-template-columns: repeat(7, 1fr);
    background: var(--card-bg);
    padding: 8px 4px;
    gap: 2px;
    border-bottom: 1px solid var(--border-color);
    width: 100%;
}

.weekday {
    text-align: center;
    font-size: clamp(10px, 2.5vw, 12px);
    font-weight: 600;
    color: var(--text-secondary);
    padding: 8px 0;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.weekday.sunday {
    color: var(--danger-color);
}

.weekday.saturday {
    color: var(--secomdary-color) !important;
}

.calendar-body {
    background: var(--card-bg);
    padding: 4px 4px 30px 4px;
    touch-action: pan-y;
    transition: transform 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    position: relative;
    width: 100%;
}

.calendar-body.slide-left {
    animation: slideOutLeft 0.3s cubic-bezier(0.4, 0, 0.2, 1);
}

.calendar-body.slide-right {
    animation: slideOutRight 0.3s cubic-bezier(0.4, 0, 0.2, 1);
}

.calendar-week {
    display: grid;
    grid-template-columns: repeat(7, minmax(0, 1fr));
    gap: clamp(4px, 1.5vw, 8px);
    margin-bottom: clamp(4px, 1.5vw, 8px);
    width: 100%;
}


.calendar-day {
    aspect-ratio: 1;
    border-radius: 12px;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    position: relative;
    transition: all 0.3s ease;
    cursor: pointer;
    user-select: none;
    background: var(--bg-color);
    border: 2px solid transparent;
    min-width: 0;
    /* 長押しメニューを無効化 */
    -webkit-touch-callout: none;
    -webkit-user-select: none;
}

.calendar-day.empty {
    background: transparent;
    cursor: default;
}

a.calendar-day {
    text-decoration: none;
    color: inherit;
}

a.calendar-day:active {
    transform: scale(0.95);
}

.calendar-day:not(.empty):not(.holiday):not(.past):hover {
    border-color: var(--primary-color);
    box-shadow: var(--shadow-hover);
}

.calendar-day.today {
    background: linear-gradient(135deg, #ebcc9b, #F39C12) !important;
    color: #FFFFFF !important;
    font-weight: 700;
    box-shadow: var(--shadow);
}

.calendar-day.sunday:not(.today):not(.past) {
    color: var(--danger-color);
}

.calendar-day.saturday:not(.today):not(.past) {
    color: var(--secondary-color) !important;
}

.calendar-day.holiday {
    background: #FFE5E5;    /*F5F5F5*/
    color: var(--text-secondary);
    cursor: default;
}

.calendar-day.full {
    background: #f4f0f0;
}

/* 過去の日付スタイル */
.calendar-day.past {
    background: #F0F0F0;
    color: #BCBCBC;
    cursor: not-allowed;
    pointer-events: none;
    opacity: 0.6;
}

.calendar-day.past .day-number {
    color: #BCBCBC;
}

.calendar-day.past .status-badge {
    background: #D3D3D3;
    color: #999999;
}

.day-number {
    font-size: clamp(14px, 3.5vw, 16px);
    font-weight: 600;
    margin-bottom: 4px;
}

.status-badge {
    font-size: clamp(9px, 2.5vw, 11px);
    font-weight: 700;
    padding: 2px 8px;
    border-radius: 10px;
    background: var(--primary-color);
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
    max-width: 100%;
    color:#FFFFFF
}

.calendar-day.today .status-badge {
    background: rgba(255, 255, 255, 0.3);
    color: white;
}

.calendar-day.holiday .status-badge {
    background: #bdb7b7;
    color: white;
}

.calendar-day.full .status-badge {
    background: #bdb7b7;
    color: white;
}

/* タッチフィードバック */
.calendar-day.pressing {
    transform: scale(0.95);
    box-shadow: inset 0 0 10px rgba(0, 0, 0, 0.1);
}


/* 残りわずか（△）のスタイル - オレンジ系 */
.calendar-day.limited {
    background: linear-gradient(135deg, #FFF5E6 0%, #FFE8CC 100%);
}

.calendar-day.limited:hover {
    background: linear-gradient(135deg, #FFE8CC 0%, #FFD9A8 100%);
    transform: translateY(-2px);
    box-shadow: 0 4px 12px rgba(255, 152, 0, 0.2);
}

.calendar-day.limited .status-badge {
    background: linear-gradient(135deg, #FF9800 0%, #F57C00 100%);
    color: white;
    font-weight: 700;
}

/* アクセシビリティ対応 */
.calendar-day.limited[data-status="△"]::after {
    content: "残りわずか";
    position: absolute;
    left: -9999px;
}

/* 凡例スタイル */
.calendar-legend {
    display: flex;
    justify-content: center;
    align-items: center;
    gap: 1.5rem;
    padding: 1.5rem 1rem;
    margin-top: 1rem;
    background: rgba(255, 255, 255, 0.5);
    border-radius: 12px;
    flex-wrap: wrap;
}

.legend-item {
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

.legend-icon {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 32px;
    height: 32px;
    border-radius: 6px;
    font-weight: 700;
    font-size: 16px;
    border: 2px solid;
}

.legend-icon.available {
    background: linear-gradient(135deg, #E8F5E9 0%, #C8E6C9 100%);
    border-color: #4CAF50;
    color: #2E7D32;
}

.legend-icon.limited {
    background: linear-gradient(135deg, #FFF5E6 0%, #FFE8CC 100%);
    border-color: #FF9800;
    color: #E65100;
}

.legend-icon.holiday {
    background: linear-gradient(135deg, #e88686 0%, #e498a0 100%);
    border-color: #ed594e;
    color: #fff;
}

.legend-icon.full {
    background: linear-gradient(135deg, #929090 0%, #bab5b5 100%);
    border-color: #b2b2b2;
    color: #ffffff;
}

.legend-text {
    font-size: 14px;
    font-weight: 500;
    color: var(--text-primary);
    white-space: nowrap;
}

/* モバイル対応 */
@media (max-width: 480px) {
    .calendar-legend {
        gap: 1rem;
        padding: 1rem 0.5rem;
    }

    .legend-item {
        gap: 0.4rem;
    }

    .legend-icon {
        width: 28px;
        height: 28px;
        font-size: 14px;
    }

    .legend-text {
        font-size: 13px;
    }
}

/* スワイプインジケーター */
.swipe-indicator {
	position: fixed;
	top: 50%;
	transform: translateY(-50%);
	width: 60px;
	height: 60px;
	background: rgba(255, 255, 255, 0.95);
	border-radius: 50%;
	display: flex;
	align-items: center;
	justify-content: center;
	font-size: 28px;
	opacity: 0;
	pointer-events: none;
	transition: opacity 0.2s ease;
	box-shadow: 0 4px 20px rgba(0, 0, 0, 0.2);
	z-index: 1000;
}

.swipe-indicator.left {
	left: 20px;
}

.swipe-indicator.right {
	right: 20px;
}

.swipe-indicator.show {
	opacity: 1;
}

/* コンテンツのスワイプアニメーション */
.content-wrapper {
	transition: transform 0.3s cubic-bezier(0.4, 0, 0.2, 1), opacity 0.3s ease;
}

.content-wrapper.swipe-left-out {
	transform: translateX(-100%);
	opacity: 0;
}

.content-wrapper.swipe-right-out {
	transform: translateX(100%);
	opacity: 0;
}

/* スワイプナビゲーション */
.swipe-nav {
	position: fixed;
	bottom: 0;
	left: 0;
	right: 0;
	background: white;
	padding: 12px 50px 12px 8px;
	box-shadow: 0 -2px 10px rgba(0, 0, 0, 0.1);
	display: flex;
	justify-content: space-between;
	align-items: center;
	gap: 8px;
	z-index: 90;
}

.swipe-indicator-footer {
	display: flex;
	align-items: center;
	gap: 8px;
	color: var(--text-secondary);
	font-size: 11px;
	flex: 1;
	justify-content: center;
}

.swipe-arrow {
	font-size: 18px;
	animation: swipeHint 2s ease-in-out infinite;
}

@keyframes swipeHint {
	0%,
	100% {
		transform: translateX(0);
	}

	50% {
		transform: translateX(8px);
	}
}

.nav-month-button {
	background: var(--primary-color);
	color: white;
	border: none;
	padding: 10px 20px;
	border-radius: 8px;
	font-weight: 600;
	cursor: pointer;
	transition: all 0.3s ease;
	font-size: 14px;
	min-width: 80px;
}

.nav-month-button:active {
	transform: scale(0.95);
	background: var(--secondary-color);
}

.nav-month-button.prev {
	background: var(--secondary-color);
}

.nav-month-button.prev:active {
	background: var(--primary-color);
}

.nav-month-button.hidden {
	display: none;
}

/* ========================================
   年月選択ピッカー
   ======================================== */
.month-picker-btn {
    font-size: 18px;
}

.month-picker-modal {
    max-width: 90%;
    width: 360px;
}

.month-picker-container {
    margin-bottom: 20px;
}

.year-selector {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 16px;
    margin-bottom: 20px;
    padding: 12px;
    background: var(--bg-color);
    border-radius: 12px;
}

.year-nav-btn {
    background: var(--primary-color);
    border: none;
    color: white;
    width: 40px;
    height: 40px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    transition: all 0.3s ease;
    font-size: 24px;
    font-weight: bold;
    flex-shrink: 0;
}

.year-nav-btn:active {
    transform: scale(0.9);
    background: var(--secondary-color);
}

.year-display {
    font-size: 20px;
    font-weight: 700;
    color: var(--text-primary);
    min-width: 100px;
    text-align: center;
}

.month-grid {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 12px;
}

.month-item {
    background: var(--bg-color);
    border: 2px solid var(--border-color);
    border-radius: 12px;
    padding: 16px 12px;
    font-size: 15px;
    font-weight: 600;
    color: var(--text-primary);
    cursor: pointer;
    transition: all 0.3s ease;
    min-height: 56px;
    display: flex;
    align-items: center;
    justify-content: center;
}

.month-item:active {
    transform: scale(0.95);
}

.month-item:hover {
    border-color: var(--primary-color);
    background: rgba(80, 200, 120, 0.1);
}

.month-item.current {
    background: var(--primary-color);
    color: white;
    border-color: var(--primary-color);
    font-weight: 700;
}

.month-item:disabled {
    opacity: 0.4;
    cursor: not-allowed;
    pointer-events: none;
}

/* タブレット以上での調整 */
@media (min-width: 768px) {
    .month-picker-modal {
        width: 400px;
    }
    
    .month-grid {
        gap: 16px;
    }
    
    .month-item {
        padding: 20px 16px;
        min-height: 64px;
        font-size: 16px;
    }
}

/* モーダル */
.modal-overlay {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(0, 0, 0, 0.5);
    display: none;
    align-items: center;
    justify-content: center;
    z-index: 1000;
    animation: fadeIn 0.3s ease;
    padding: 16px;
}

.modal-overlay.active {
    display: flex;
}

.modal-content {
    background: white;
    border-radius: 16px;
    padding: 24px;
    max-width: 90%;
    width: 320px;
    box-shadow: 0 10px 40px rgba(0, 0, 0, 0.3);
    animation: slideUp 0.3s ease;
}

.modal-title {
    font-size: 18px;
    font-weight: 700;
    margin-bottom: 12px;
    color: var(--text-primary);
}

.modal-message {
    font-size: 15px;
    color: var(--text-secondary);
    margin-bottom: 24px;
    line-height: 1.5;
    word-wrap: break-word;
}

.modal-buttons {
    display: flex;
    gap: 12px;
    flex-wrap: wrap;
}

.modal-button {
    flex: 1;
    min-width: 100px;
    padding: 12px 20px;
    border: none;
    border-radius: 8px;
    font-size: 15px;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.3s ease;
}

.modal-button.cancel {
    background: var(--bg-color);
    color: var(--text-primary);
}

.modal-button.confirm {
    background: var(--primary-color);
    color: white;
}

.modal-button:active {
    transform: scale(0.95);
}

/* ローディング */
.loading-overlay {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(255, 255, 255, 0.95);
    display: none;
    align-items: center;
    justify-content: center;
    z-index: 2000;
    transition: opacity 0.3s ease;
}

.loading-overlay.active {
    display: flex;
    opacity: 1;
}

.spinner {
    width: 50px;
    height: 50px;
    border: 4px solid var(--border-color);
    border-top-color: var(--primary-color);
    border-radius: 50%;
    animation: spin 1s linear infinite;
}

/* トースト通知 */
.toast {
    position: fixed;
    bottom: 80px;
    left: 50%;
    transform: translateX(-50%) translateY(100px);
    background: var(--text-primary);
    color: white;
    padding: 16px 24px;
    border-radius: 8px;
    box-shadow: var(--shadow-hover);
    z-index: 3000;
    opacity: 0;
    transition: all 0.3s ease;
    max-width: 90%;
    text-align: center;
    word-wrap: break-word;
}

.toast.active {
    opacity: 1;
    transform: translateX(-50%) translateY(0);
}

@keyframes fadeIn {
    from {
opacity: 0;
    }

    to {
opacity: 1;
    }
}

@keyframes slideUp {
    from {
opacity: 0;
transform: translateY(20px);
    }

    to {
opacity: 1;
transform: translateY(0);
    }
}

@keyframes spin {
    to {
transform: rotate(360deg);
    }
}

@keyframes slideOutLeft {
    from {
opacity: 1;
transform: translateX(0);
    }

    to {
opacity: 0;
transform: translateX(-100%);
    }
}

@keyframes slideOutRight {
    from {
opacity: 1;
transform: translateX(0);
    }

    to {
opacity: 0;
transform: translateX(100%);
    }
}

/* レスポンシブ調整 */
@media (min-width: 768px) {
    .calendar-title {
font-size: 28px;
    }

    .day-number {
font-size: 18px;
    }

    .status-badge {
font-size: 12px;
    }
}

/* 小さい画面での調整 */
@media (max-width: 375px) {
    .calendar-header {
padding: 16px 12px;
    }

    .calendar-body {
padding: 6px;
    }

    .calendar-weekdays {
padding: 10px 6px;
    }
}