* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

/* 昼テーマ（デフォルト） */
body.day-theme {
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Oxygen, Ubuntu, Cantarell, sans-serif;
    background: linear-gradient(135deg, #87CEEB 0%, #B0E0E6 50%, #ADD8E6 100%);
    min-height: 100vh;
    color: #333;
    transition: background 0.5s ease;
}

/* 夜テーマ */
body.night-theme {
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Oxygen, Ubuntu, Cantarell, sans-serif;
    background: linear-gradient(135deg, #2C3E50 0%, #34495E 50%, #4A5F7F 100%);
    min-height: 100vh;
    color: #E0E0E0;
    transition: background 0.5s ease;
}

/* 昼テーマのカード */
body.day-theme .cities-section,
body.day-theme .detail-section,
body.day-theme .date-navigation {
    background: rgba(255, 255, 255, 0.95);
    color: #333;
}

/* 夜テーマのカード */
body.night-theme .cities-section,
body.night-theme .detail-section,
body.night-theme .date-navigation {
    background: rgba(52, 73, 94, 0.95);
    color: #E0E0E0;
}

/* 昼テーマのテキスト */
body.day-theme h2,
body.day-theme h3,
body.day-theme h4 {
    color: #2196F3;
}

/* 夜テーマのテキスト */
body.night-theme h2,
body.night-theme h3,
body.night-theme h4 {
    color: #64B5F6;
}

/* 昼テーマのカード */
body.day-theme .city-card {
    background: white;
    border: 1px solid #E3F2FD;
    color: #333;
}

body.day-theme .city-card:hover {
    box-shadow: 0 8px 24px rgba(33, 150, 243, 0.3);
}

/* 夜テーマのカード */
body.night-theme .city-card {
    background: rgba(44, 62, 80, 0.8);
    border: 1px solid #4A5F7F;
}

body.night-theme .city-card:hover {
    box-shadow: 0 8px 24px rgba(100, 181, 246, 0.3);
}

/* 夜テーマの地域ヘッダー */
body.night-theme .region-header {
    background: linear-gradient(135deg, #546E7A 0%, #455A64 100%);
}

/* 昼テーマの地域ヘッダー */
body.day-theme .region-header {
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
}

body.day-theme .region-header h3 {
    color: white;
}

/* 昼テーマのボタン */
body.day-theme .date-nav-btn {
    background: #2196F3;
    color: white;
}

body.day-theme .date-nav-btn:hover {
    background: #1976D2;
}

body.day-theme .date-nav-btn.today-btn {
    background: #4CAF50;
}

body.day-theme .date-nav-btn.today-btn:hover {
    background: #45a049;
}

/* 夜テーマのボタン */
body.night-theme .date-nav-btn {
    background: #546E7A;
    color: white;
}

body.night-theme .date-nav-btn:hover {
    background: #455A64;
}

body.night-theme .date-nav-btn.today-btn {
    background: #66BB6A;
}

body.night-theme .date-nav-btn.today-btn:hover {
    background: #4CAF50;
}

/* 昼テーマのタブ */
body.day-theme .tab-btn {
    background: #E3F2FD;
    color: #1976D2;
}

body.day-theme .tab-btn.active {
    background: #2196F3;
    color: white;
}

/* 夜テーマのタブ */
body.night-theme .tab-btn {
    background: rgba(69, 90, 100, 0.8);
    color: #B0BEC5;
}

body.night-theme .tab-btn.active {
    background: #546E7A;
    color: white;
}

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

header {
    text-align: center;
    color: white;
    margin-bottom: 40px;
}

header h1 {
    font-size: 2.5rem;
    margin-bottom: 10px;
}

header p {
    font-size: 1.1rem;
    opacity: 0.9;
}

/* 日付ナビゲーション */
.date-navigation {
    background: white;
    border-radius: 12px;
    padding: 20px;
    box-shadow: 0 10px 30px rgba(0, 0, 0, 0.2);
    margin-bottom: 20px;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 20px;
}

/* PC版はフルテキスト、スマホ版は短縮テキスト */
.btn-text-short {
    display: none;
}

.btn-text-full {
    display: inline;
}

.date-nav-btn {
    background: #667eea;
    color: white;
    border: none;
    padding: 12px 24px;
    border-radius: 8px;
    font-size: 1rem;
    cursor: pointer;
    transition: all 0.3s ease;
    font-weight: 500;
}

.date-nav-btn:hover {
    background: #5568d3;
    transform: translateY(-2px);
    box-shadow: 0 4px 12px rgba(102, 126, 234, 0.4);
}

.date-nav-btn:active {
    transform: translateY(0);
}

.date-nav-btn.today-btn {
    background: #4CAF50;
}

.date-nav-btn.today-btn:hover {
    background: #45a049;
}

.date-display {
    text-align: center;
    min-width: 200px;
}

.current-date {
    font-size: 1.5rem;
    font-weight: bold;
    color: #333;
    margin-bottom: 5px;
}

.date-type {
    font-size: 0.9rem;
    color: #666;
    font-weight: 500;
}

.date-type.past {
    color: #9E9E9E;
}

.date-type.future {
    color: #2196F3;
}

.date-type.today {
    color: #4CAF50;
}

/* 都市グリッド */
.cities-section {
    background: white;
    border-radius: 12px;
    padding: 30px;
    box-shadow: 0 10px 30px rgba(0, 0, 0, 0.2);
    margin-bottom: 30px;
}

.cities-section h2 {
    margin-bottom: 20px;
    color: #667eea;
}

.cities-grid {
    display: flex;
    flex-direction: column;
    gap: 30px;
}

.region-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 15px 20px;
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    border-radius: 10px;
    color: white;
    margin-top: 10px;
}

.region-header h3 {
    margin: 0;
    font-size: 1.5rem;
    color: white;
}

.region-count {
    font-size: 0.9rem;
    opacity: 0.9;
    background: rgba(255, 255, 255, 0.2);
    padding: 5px 15px;
    border-radius: 20px;
}

.region-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
    gap: 20px;
}

.city-card {
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    color: white;
    padding: 20px;
    border-radius: 10px;
    cursor: pointer;
    transition: transform 0.2s, box-shadow 0.2s;
}

.city-card:hover {
    transform: translateY(-5px);
    box-shadow: 0 10px 25px rgba(0, 0, 0, 0.3);
}

.city-card h3 {
    font-size: 1.5rem;
    margin-bottom: 5px;
}

.city-card .country {
    font-size: 0.9rem;
    opacity: 0.8;
    margin-bottom: 15px;
}

.city-card .weather-info {
    display: flex;
    align-items: center;
    gap: 15px;
    margin-top: 10px;
}

.city-card .weather-icon {
    font-size: 3rem;
    line-height: 1;
}

.city-card .weather-details {
    flex: 1;
}

.city-card .temp {
    font-size: 2rem;
    font-weight: bold;
    line-height: 1.2;
}

.city-card .weather-desc {
    font-size: 0.9rem;
    opacity: 0.9;
    margin-top: 2px;
}

.loading {
    text-align: center;
    padding: 40px;
    color: #999;
}

/* 詳細セクション */
.detail-section {
    background: white;
    border-radius: 12px;
    padding: 30px;
    box-shadow: 0 10px 30px rgba(0, 0, 0, 0.2);
}

.detail-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 30px;
}

.detail-header h2 {
    color: #667eea;
}

.close-btn {
    background: #f44336;
    color: white;
    border: none;
    width: 40px;
    height: 40px;
    border-radius: 50%;
    font-size: 1.5rem;
    cursor: pointer;
    transition: background 0.2s;
}

.close-btn:hover {
    background: #d32f2f;
}

/* 現在の天気 */
.current-weather {
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    color: white;
    padding: 30px;
    border-radius: 10px;
    margin-bottom: 30px;
}

.weather-main {
    text-align: center;
    margin-bottom: 20px;
}

.temperature {
    font-size: 4rem;
    font-weight: bold;
}

.weather-desc {
    font-size: 1.5rem;
    opacity: 0.9;
}

.weather-details {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(150px, 1fr));
    gap: 15px;
}

.detail-item {
    display: flex;
    flex-direction: column;
    align-items: center;
}

.detail-item .label {
    font-size: 0.9rem;
    opacity: 0.8;
    margin-bottom: 5px;
}

.detail-item .value {
    font-size: 1.3rem;
    font-weight: bold;
}

/* 日の出・日の入り */
.sun-times {
    display: flex;
    justify-content: center;
    gap: 40px;
    margin-top: 25px;
    padding-top: 20px;
    border-top: 1px solid rgba(255, 255, 255, 0.2);
}

.sun-time-item {
    display: flex;
    align-items: center;
    gap: 12px;
}

.sun-icon {
    font-size: 2.5rem;
}

.sun-time-info {
    display: flex;
    flex-direction: column;
}

.sun-time-label {
    font-size: 0.85rem;
    opacity: 0.8;
}

.sun-time-value {
    font-size: 1.4rem;
    font-weight: bold;
}

/* 統計 */
.stats-section {
    margin-bottom: 30px;
}

.stats-section h3 {
    color: #667eea;
    margin-bottom: 15px;
}

.stats-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(150px, 1fr));
    gap: 15px;
}

.stat-card {
    background: #f5f5f5;
    padding: 20px;
    border-radius: 8px;
    text-align: center;
}

.stat-label {
    font-size: 0.9rem;
    color: #666;
    margin-bottom: 10px;
}

.stat-value {
    font-size: 1.8rem;
    font-weight: bold;
    color: #667eea;
}

/* グラフ */
.chart-section {
    margin-top: 30px;
}

.chart-section h3 {
    color: #667eea;
    margin-bottom: 15px;
}

#weather-chart {
    max-height: 400px;
}

/* フッター */
footer {
    text-align: center;
    color: white;
    margin-top: 40px;
    opacity: 0.8;
}

/* レスポンシブ */
/* 表示切り替えタブ */
.view-tabs {
    display: flex;
    gap: 10px;
    margin-bottom: 20px;
    justify-content: center;
}

.tab-btn {
    background: white;
    color: #667eea;
    border: 2px solid #667eea;
    padding: 12px 30px;
    border-radius: 25px;
    font-size: 1rem;
    font-weight: bold;
    cursor: pointer;
    transition: all 0.3s;
}

.tab-btn:hover {
    background: #667eea;
    color: white;
    transform: translateY(-2px);
    box-shadow: 0 5px 15px rgba(102, 126, 234, 0.3);
}

.tab-btn.active {
    background: #667eea;
    color: white;
}

/* 地図表示 */
.map-section {
    background: white;
    border-radius: 12px;
    padding: 30px;
    box-shadow: 0 10px 30px rgba(0, 0, 0, 0.2);
    margin-bottom: 30px;
}

.map-section h2 {
    margin-bottom: 20px;
    color: #667eea;
}

.map-container {
    position: relative;
    width: 100%;
    background: #B3E5FC;
    border-radius: 10px;
    overflow: hidden;
    box-shadow: inset 0 2px 10px rgba(0, 0, 0, 0.1);
}

#world-map {
    width: 100%;
    height: auto;
    display: block;
    min-height: 400px;
}

/* 都市ピン */
.city-pin {
    cursor: pointer;
    transition: all 0.2s;
}

.city-pin:hover {
    r: 8;
    filter: drop-shadow(0 0 8px rgba(0, 0, 0, 0.5));
}

.city-pin-label {
    font-size: 12px;
    font-weight: bold;
    fill: #333;
    pointer-events: none;
    text-shadow: 1px 1px 2px white, -1px -1px 2px white, 1px -1px 2px white, -1px 1px 2px white;
}

/* 地図凡例 */
.map-legend {
    display: flex;
    justify-content: center;
    gap: 20px;
    padding: 15px;
    background: white;
    border-top: 1px solid #e0e0e0;
}

.legend-item {
    display: flex;
    align-items: center;
    gap: 8px;
    font-size: 0.9rem;
}

.legend-color {
    width: 20px;
    height: 20px;
    border-radius: 50%;
    border: 2px solid #333;
}

@media (max-width: 768px) {
    header h1 {
        font-size: 2rem;
    }

    .cities-grid {
        grid-template-columns: 1fr;
    }

    .temperature {
        font-size: 3rem;
    }
    
    .view-tabs {
        flex-direction: column;
    }
    
    .tab-btn {
        width: 100%;
    }
    
    .map-legend {
        flex-direction: column;
        align-items: flex-start;
    }
    
    /* スマホでの地図表示を大きく */
    .map-section {
        padding: 15px;
    }
    
    #world-map {
        min-height: 70vh;
        max-height: 80vh;
    }
    
    /* スマホでピンとラベルを大きく */
    .city-pin {
        r: 8;
    }
    
    .city-pin:hover {
        r: 10;
    }
    
    .city-pin-label {
        font-size: 14px;
        font-weight: bold;
    }
    
    /* 日付ナビゲーションをスマホ用にコンパクト化 */
    .date-navigation {
        flex-wrap: wrap;
        gap: 8px;
        padding: 12px;
    }
    
    .date-nav-btn {
        padding: 8px 12px;
        font-size: 0.85rem;
        flex: 0 0 auto;
    }
    
    /* 前後ボタンを横並び */
    #prev-day-btn,
    #next-day-btn {
        flex: 1 1 calc(50% - 4px);
        min-width: 0;
    }
    
    /* 日付表示を全幅 */
    .date-display {
        flex: 1 1 100%;
        order: -1;
        min-width: 0;
        padding: 8px 0;
    }
    
    .current-date {
        font-size: 1.1rem;
    }
    
    .date-type {
        font-size: 0.85rem;
    }
    
    /* 現在時刻ボタンを全幅 */
    #today-btn {
        flex: 1 1 100%;
        font-size: 0.85rem;
        padding: 8px 12px;
    }
    
    /* スマホでは短縮テキストを表示 */
    .btn-text-full {
        display: none;
    }
    
    .btn-text-short {
        display: inline;
    }
}


/* 星空観測セクション */
.stargazing-section {
    background: linear-gradient(135deg, #1a1a2e 0%, #16213e 100%);
    color: white;
    padding: 30px;
    border-radius: 10px;
    margin-bottom: 30px;
}

.stargazing-section h3 {
    color: #ffd700;
    margin-bottom: 20px;
}

.stargazing-score {
    display: flex;
    align-items: center;
    gap: 30px;
    margin-bottom: 20px;
}

.score-circle {
    background: rgba(255, 255, 255, 0.1);
    border-radius: 50%;
    width: 120px;
    height: 120px;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    border: 3px solid rgba(255, 255, 255, 0.3);
}

.score-value {
    font-size: 2.5rem;
    font-weight: bold;
}

.score-label {
    font-size: 0.8rem;
    opacity: 0.8;
    margin-top: 5px;
}

.moon-info {
    display: flex;
    align-items: center;
    gap: 15px;
}

.moon-visual {
    position: relative;
}

.moon-icon {
    position: relative;
    width: 100px;
    height: 100px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.3s ease;
}

/* 月の満ち欠けに応じた背景 */
.moon-icon.new-moon {
    background: linear-gradient(135deg, #1a1a2e 0%, #0f0f1e 100%);
    box-shadow: 0 0 20px rgba(255, 255, 255, 0.1);
}

.moon-icon.waxing-crescent {
    background: linear-gradient(90deg, #1a1a2e 0%, #1a1a2e 40%, #f5f5dc 40%, #f5f5dc 100%);
    box-shadow: 0 0 25px rgba(245, 245, 220, 0.3);
}

.moon-icon.first-quarter {
    background: linear-gradient(90deg, #1a1a2e 0%, #1a1a2e 50%, #f5f5dc 50%, #f5f5dc 100%);
    box-shadow: 0 0 30px rgba(245, 245, 220, 0.4);
}

.moon-icon.waxing-gibbous {
    background: linear-gradient(90deg, #1a1a2e 0%, #1a1a2e 20%, #f5f5dc 20%, #f5f5dc 100%);
    box-shadow: 0 0 35px rgba(245, 245, 220, 0.5);
}

.moon-icon.full-moon {
    background: linear-gradient(135deg, #f5f5dc 0%, #fffacd 100%);
    box-shadow: 0 0 40px rgba(255, 250, 205, 0.6);
}

.moon-emoji {
    font-size: 3.5rem;
    filter: drop-shadow(0 0 10px rgba(255, 255, 255, 0.3));
}

.moon-details {
    display: flex;
    flex-direction: column;
    gap: 5px;
}

.moon-phase-name {
    font-size: 1.3rem;
    font-weight: bold;
    color: #ffd700;
}

.moon-illumination-text,
.moon-age {
    font-size: 1rem;
    opacity: 0.9;
}

.stargazing-tips {
    margin-top: 20px;
}

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

.tip {
    padding: 10px 15px;
    border-radius: 5px;
    font-size: 0.95rem;
}

.tip.good {
    background: rgba(76, 175, 80, 0.2);
    border-left: 4px solid #4CAF50;
}

.tip.ok {
    background: rgba(255, 193, 7, 0.2);
    border-left: 4px solid #FFC107;
}

.tip.poor {
    background: rgba(255, 152, 0, 0.2);
    border-left: 4px solid #FF9800;
}

.tip.bad {
    background: rgba(244, 67, 54, 0.2);
    border-left: 4px solid #F44336;
}

@media (max-width: 768px) {
    .stargazing-score {
        flex-direction: column;
        align-items: flex-start;
    }
    
    .moon-icon {
        width: 80px;
        height: 80px;
    }
    
    .moon-emoji {
        font-size: 2.5rem;
    }
    
    .moon-phase-name {
        font-size: 1.1rem;
    }
}


/* 星座セクション */
.constellations-section {
    margin: 20px 0;
    padding: 20px;
    background: rgba(255, 255, 255, 0.05);
    border-radius: 8px;
}

.constellations-section h4 {
    color: #ffd700;
    margin-bottom: 15px;
    font-size: 1.1rem;
}

.constellations-display {
    font-size: 1.1rem;
    line-height: 1.8;
}

.constellation-text {
    margin-bottom: 10px;
    font-size: 1.2rem;
}

.constellation-count {
    font-size: 0.9rem;
    opacity: 0.8;
    margin-top: 10px;
}

/* ランキング表示 */
.ranking-section {
    padding: 2rem 0;
}

.ranking-container {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(300px, 1fr));
    gap: 2rem;
    margin-top: 2rem;
}

.ranking-card {
    background: rgba(255, 255, 255, 0.05);
    border-radius: 12px;
    padding: 1.5rem;
    backdrop-filter: blur(10px);
}

.ranking-card h3 {
    margin: 0 0 1rem 0;
    font-size: 1.2rem;
    color: #fff;
}

.ranking-list {
    display: flex;
    flex-direction: column;
    gap: 0.75rem;
}

.ranking-item {
    display: flex;
    align-items: center;
    gap: 1rem;
    padding: 0.75rem;
    background: rgba(255, 255, 255, 0.05);
    border-radius: 8px;
    transition: all 0.3s ease;
    cursor: pointer;
}

.ranking-item:hover {
    background: rgba(255, 255, 255, 0.1);
    transform: translateX(5px);
}

.ranking-rank {
    font-size: 1.5rem;
    font-weight: bold;
    min-width: 2rem;
    text-align: center;
}

.ranking-rank.rank-1 { color: #FFD700; }
.ranking-rank.rank-2 { color: #C0C0C0; }
.ranking-rank.rank-3 { color: #CD7F32; }
.ranking-rank.rank-4,
.ranking-rank.rank-5 { color: #888; }

.ranking-info {
    flex: 1;
}

.ranking-city-name {
    font-weight: bold;
    font-size: 1rem;
    margin-bottom: 0.25rem;
}

.ranking-country {
    font-size: 0.85rem;
    color: #aaa;
}

.ranking-value {
    font-size: 1.2rem;
    font-weight: bold;
    color: #4CAF50;
    min-width: 80px;
    text-align: right;
}
