html, body {
    /* バウンド（弾性スクロール）と、それに伴うナビゲーションを無効化 */
    overscroll-behavior: none;
    overscroll-behavior-y: none; /* 縦方向のバウンドも禁止 */
    
    /* アプリ全体がスクロールしないように固定 */
    overflow: hidden;
    
    /* 高さの固定 */
    width: 100%;
    height: 100%;
    position: fixed;
}

/* スクロールさせたいエリアには明示的にスクロール許可を与える */
.popup-content, 
.course-list-container,
.message-scrollable-content,
.popup-scroll-body,
.scrollable-help-content {
    overflow-y: auto;
    overscroll-behavior-y: contain; /* 親へのスクロール連鎖を防ぐ（バウンド防止） */
    touch-action: pan-y; /* 縦スクロール操作を明示的に許可 */
    -webkit-overflow-scrolling: touch; /* iOSでの慣性スクロールを有効化 */
}

:root {
    /* ▼▼▼ アプリ標準カラー設定 ▼▼▼ */
    --primary-color: #009999;       /* 標準（背景用） */
    --text-on-primary: #ffffff;     /* 文字色 */
    --primary-darkened: #006666;    /* 白背景上の文字色（濃いティール） */
    
    /* ▼▼▼ 修正：ホバー色を標準カラーの少し濃い色に変更 ▼▼▼ */
    --primary-hover-color: #007373; /* #009999 を20%ほど暗くした色 */
    
    --success-color: #28a745;
    --success-hover-color: #218838;
    --danger-color: #dc3545;
    --danger-hover-color: #c82333;
    --warning-color: #ffc107;
    --warning-hover-color: #e0a800;
    
    --text-primary: #1d1d1f;
    --text-secondary: #6e6e73;
    --white-color: #ffffff;
    --body-bg: #f5f5f7;
    --component-bg: #ffffff;
    --border-color: #d1d1d6;
    
    --shadow-sm: 0 1px 2px rgba(0, 0, 0, 0.05);
    --shadow-md: 0 4px 12px rgba(0, 0, 0, 0.1);
    
    --border-radius-sm: 8px;
    --border-radius-md: 12px;
    
    --stamp-rally-color: #42A5F5;
    --stamp-rally-hover-color: #1E88E5;
    --gold-color: #FFD700;
    
    --dark-purple-bg: #4A148C;
    --light-purple-bg: #6A1B9A;
    --stats-panel-height: 0px; 
}

body, html {
    margin: 0; padding: 0; height: 100%;
    display: flex; flex-direction: column;
    font-family: 'Noto Sans JP', sans-serif;
    color: var(--text-primary);
    overscroll-behavior: none; -webkit-font-smoothing: antialiased;
    box-sizing: border-box;
}

html {
    background-color: var(--primary-color);
}

body {
    background-color: var(--primary-color);
    padding-bottom: calc(24px + env(safe-area-inset-bottom));
}

h1 {
    height: 56px;
    flex-shrink: 0;
    padding: 0 16px;
    padding-top: env(safe-area-inset-top);
    box-sizing: content-box;
    margin: 0;
    background: var(--primary-color);
    color: var(--text-on-primary) !important; /* ★自動計算された文字色を使用 */
    font-size: 1.2em;
    display: flex;
    align-items: center;
    box-shadow: var(--shadow-md);
    z-index: 100;
    gap: 16px;
}

h1 img {
    height: 85%;
}

.title-wrapper {
    display: flex;
    flex-direction: column;
    justify-content: center;
    align-items: flex-start;
    gap: 0;
    margin-right: auto;
    line-height: 1.2;
    min-width: 0;
}

.main-title {
    font-size: 1em;
    font-weight: 700;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    max-width: 100%;
}
.subtitle {
    font-size: 0.6em;
    font-weight: 400;
    color: var(--text-on-primary); /* ★テーマカラー上の文字色 */
    opacity: 0.9;
    display: flex;
    align-items: center;
    gap: 0.6em;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    max-width: 100%;
}

.manual-link-header {
    color: var(--text-on-primary); /* ★テーマカラー上の文字色 */
    opacity: 0.8;
    text-decoration: underline;
    font-size: 0.7em;
    font-weight: normal;
    margin-left: 8px;
    transition: opacity 0.2s;
}
.manual-link-header:hover {
    opacity: 1;
}

.header-help-btn {
    background: transparent;
    border: none;
    color: var(--text-on-primary); /* ★テーマカラー上の文字色 */
    cursor: pointer;
    padding: 8px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: background-color 0.2s ease;
}

.header-button-group {
    display: flex;
    align-items: center;
    gap: 4px;
}

.header-help-btn:hover {
    background-color: rgba(255, 255, 255, 0.15);
}

.header-help-btn svg {
    width: 28px;
    height: 28px;
}

#top-left-info-cluster {
    position: fixed;
    left: 16px;
    z-index: 1000;
    display: none;
    flex-direction: column;
    align-items: flex-start;
    gap: 10px;
    transition: top 0.4s cubic-bezier(0.4, 0, 0.2, 1);
}

body[data-app-state="tour"] #top-left-info-cluster,
body[data-app-state="paused"] #top-left-info-cluster {
    display: flex;
    top: calc(56px + env(safe-area-inset-top) + 2px);
}

body.stats-panel-shown[data-app-state="tour"] #top-left-info-cluster,
body.stats-panel-shown[data-app-state="paused"] #top-left-info-cluster {
    top: calc(56px + env(safe-area-inset-top) + 99px);
}

.header-hidden[data-app-state="tour"] #top-left-info-cluster,
.header-hidden[data-app-state="paused"] #top-left-info-cluster {
    top: calc(env(safe-area-inset-top) + 16px);
}

.stats-panel-shown.header-hidden[data-app-state="tour"] #top-left-info-cluster,
.stats-panel-shown.header-hidden[data-app-state="paused"] #top-left-info-cluster {
    top: calc(env(safe-area-inset-top) + 95px);
}

body.stats-panel-shown:not(.header-hidden)[data-app-state="tour"] #top-left-info-cluster,
body.stats-panel-shown:not(.header-hidden)[data-app-state="paused"] #top-left-info-cluster {
    top: 155px;
}

/* GPSインジケータのコンテナスタイル */
#map-controls-container {
  position: fixed;
  top: calc(env(safe-area-inset-top) + 4px);
  left: 50%;
  transform: translateX(-50%);
  z-index: 1001;
  pointer-events: none;
  padding: 10px 0;
  box-sizing: border-box;
  width: 100%;
  display: flex;
  justify-content: center;
  align-items: center;
  transition: top 0.3s ease-in-out;
}

/* GPSインジケータ自体のスタイル */
#gps-status-indicator {
    font-size: 0.75em;
    font-weight: 400;
    padding: 4px 10px;
    border-radius: 20px;
    display: inline-flex;
    align-items: center;
    transition: background-color 0.3s, color 0.3s;
    white-space: nowrap;
    pointer-events: auto;
}

/* 情報パネル表示時の位置 */
body.stats-panel-shown #map-controls-container {
    top: calc(env(safe-area-inset-top) + var(--stats-panel-height) + 4px);
}

#gps-status-indicator.idle { background-color: rgba(0, 0, 0, 0.5); color: #f0f0f0; }
#gps-status-indicator.idle::before { background-color: #f0f0f0; }
#gps-status-indicator.searching { background-color: #ffc107; color: #333; }
#gps-status-indicator.searching::before { background-color: #333; animation: pulse 1.5s infinite; }
#gps-status-indicator.good { background-color: #28a745; color: white; }
#gps-status-indicator.good::before { background-color: white; }
#gps-status-indicator.poor { background-color: #ffc107; color: #333; }
#gps-status-indicator.poor::before { background-color: #333; }
#gps-status-indicator.error { background-color: #dc3545; color: white; }
#gps-status-indicator.error::before { background-color: white; }
@keyframes pulse { 0% { opacity: 1; } 50% { opacity: 0.3; } 100% { opacity: 1; } }

#wrap_map {
    position: relative;
    flex: 1;
    min-height: 0;
    display: flex;
    flex-direction: column;
    background-color: #f0f0f0;
}
#map { width: 100%; height: 100%; flex-grow: 1; }

footer {
    display: none !important;
}

#button-container {
    display: none;
    justify-content: center;
    padding: 8px 16px; 
    background-color: #ffffff;
    border-top: 1px solid var(--border-color);
    z-index: 20;
    transition: gap 0.3s, padding 0.3s;
}

#button-container[data-state="finished"] {
    /* 背景のグラデーション */
    background: linear-gradient(135deg, #007777 0%, #00b3b3 100%);
    padding: 16px 12px;
    gap: 12px;
    border-top: none;
    
    display: flex;
    flex-wrap: wrap;
    justify-content: center;
    align-items: stretch;
}

#button-container > .button-wrapper,
#button-container > .speed-controls {
    display: none;
}
#button-container[data-state~="finished"] > .button-wrapper[data-state~="finished"],
#button-container[data-state~="finished"] > .speed-controls[data-state~="finished"] {
    display: flex;
}

.button-wrapper {
    flex: 1 1 0;
    min-width: 0;
    display: flex;
    flex-direction: column;
    align-items: center;
}
.button-wrapper button {
    width: 52px; height: 52px; border-radius: 16px;
    border: 1px solid var(--border-color);
    background-color: var(--component-bg); cursor: pointer; display: flex;
    justify-content: center; align-items: center; padding: 0;
    transition: all 0.2s ease;
}
.button-wrapper button:hover {
    transform: translateY(-2px);
    box-shadow: var(--shadow-md);
    border-color: var(--primary-color);
}
.button-wrapper button:active {
    transform: translateY(-2px) scale(0.95);
}
.button-wrapper button svg {
    width: 28px; height: 28px;
    color: var(--primary-color);
}
.button-wrapper .button-label {
    font-size: 11px; margin-top: 6px;
    color: var(--text-secondary);
    white-space: normal;
    text-align: center;
}

.speed-controls {
    flex-shrink: 0;
    display: flex;
    align-items: center;
    gap: 5px;
    padding: 4px;
    border-radius: 12px;
    background-color: var(--body-bg);
    border: 1px solid var(--border-color);
}
.speed-controls button {
    width: 40px;
    height: 40px;
    border: none;
    border-radius: 8px;
    background-color: transparent;
    font-weight: bold;
    color: var(--text-secondary);
    cursor: pointer;
    transition: background-color 0.2s, color 0.2s;
}
.speed-controls button.active {
    background-color: var(--primary-color);
    color: var(--text-on-primary); /* ★黒文字対応 */
}

/* 情報パネルのスタイル */
#stats-panel {
    position: fixed;
    top: calc(56px + env(safe-area-inset-top));
    left: 0;
    width: 100%;
    display: flex;
    justify-content: space-evenly;
    padding: 12px 4px;
    background-color: var(--component-bg);
    border-bottom: 1px solid var(--border-color);
    z-index: 99;
    transform: translateY(-100%);
    transition: transform 0.4s cubic-bezier(0.4, 0, 0.2, 1);
    box-sizing: border-box;
    flex-wrap: nowrap;
    gap: 4px;
    overflow: hidden;
}

.stat-item {
    display: flex;
    align-items: center;
    gap: 8px;
    text-align: left;
    flex: 1;
    min-width: 0;
    justify-content: center;
}

#stats-panel.stats-visible {
    transform: translateY(0);
}
body.header-hidden #stats-panel {
    top: 0;
}

body[data-app-state="finished"] #stats-panel {
    position: static;
    transform: none;
    top: auto;
}

.stat-icon {
    color: var(--primary-color);
}
.stat-icon svg {
    width: 28px;
    height: 28px;
    opacity: 0.8;
}
.stat-text {
    display: flex;
    flex-direction: column;
    align-items: flex-start;
}
.stat-label {
    font-size: 11px;
    color: var(--text-secondary);
    white-space: nowrap;
}
.stat-value {
    font-size: clamp(16px, 4.5vw, 20px);
    font-weight: 700;
    color: var(--text-primary);
    white-space: nowrap;
}

.hidden { display: none !important; }

#fab-container, #fab-container-animation-stop {
    position: fixed; right: 16px;
    bottom: calc(40px + env(safe-area-inset-bottom));
    z-index: 1100;
    display: flex; flex-direction: column-reverse; align-items: flex-end; gap: 12px;
    transition: bottom 0.3s ease-in-out, top 0.3s ease-in-out, opacity 0.3s, visibility 0.3s;
}
#fab-container-left {
    position: fixed; left: 16px;
    bottom: calc(40px + env(safe-area-inset-bottom));
    z-index: 1100;
    display: flex; flex-direction: column-reverse; align-items: flex-start; gap: 12px;
    transition: bottom 0.3s ease-in-out, opacity 0.3s, visibility 0.3s;
}
#fab-container-top-right {
    display: flex;
    flex-direction: column;
    align-items: flex-end;
    gap: 12px;
    position: fixed;
    top: calc(56px + env(safe-area-inset-top) + 14px);
    right: 10px;
    z-index: 1100;
    transition: top 0.3s ease-in-out, visibility 0.3s;
}

.fab {
    width: 56px; height: 56px; border-radius: 50%; border: none;
    color: var(--white-color); cursor: pointer; display: flex;
    align-items: center; justify-content: center; box-shadow: var(--shadow-md);
    transition: transform 0.2s ease, background-color 0.2s ease, color 0.2s ease, opacity 0.3s, width 0.3s, height 0.3s;
}
.fab:hover { transform: scale(1.05); }
.fab:active {
    transform: scale(0.95);
}
.fab:disabled {
    opacity: 0.5;
    cursor: not-allowed;
    background-color: var(--text-secondary);
}
.fab svg {
    width: 24px;
    height: 24px;
    transition: width 0.3s, height 0.3s;
}

/* 縦並びFABレイアウト */
#fab-start,
#fab-pause,
#fab-resume,
#fab-stop,
#fab-reset,
#fab-lock-screen,
#fab-track-reload {
    width: 64px;
    height: 64px;
    flex-direction: column;
    justify-content: center;
    padding: 8px 4px;
    gap: 3px;
    box-sizing: border-box;
}

/* アイコンサイズ調整 */
#fab-start svg,
#fab-pause svg,
#fab-resume svg,
#fab-stop svg,
#fab-reset svg,
#fab-lock-screen svg {
    width: 28px;
    height: 28px;
}

#fab-lock-screen .fab-label {
    font-size: 9px;
}

#fab-start { background-color: var(--success-color); }
#fab-start:hover:not(:disabled) { background-color: var(--success-hover-color); }
#fab-pause { background-color: var(--warning-color); }
#fab-pause:hover { background-color: var(--warning-hover-color); }
#fab-resume { background-color: var(--success-color); }
#fab-resume:hover { background-color: var(--success-hover-color); }
#fab-stop, #fab-stop-animation { background-color: var(--danger-color); }
#fab-stop:hover, #fab-stop-animation:hover { background-color: var(--danger-hover-color); }
#fab-reset { 
    background-color: var(--primary-color);
    color: var(--text-on-primary) !important; /* ★黒文字対応 */
}
#fab-reset:hover { background-color: var(--primary-hover-color); }
#fab-reset svg { stroke: currentColor; fill: none; } /* 色を文字色に追従 */

#fab-lock-screen { background-color: #343a40; }
#fab-lock-screen:hover { background-color: #23272b; }
#fab-lock-screen svg { stroke: var(--white-color); }
#fab-track-reload { background-color: #007aff; }
#fab-track-reload:hover { background-color: #0062cc; }
#fab-track-reload svg { stroke: var(--white-color); }

.fab.secondary {
    width: 48px; height: 48px; background-color: var(--component-bg);
    color: var(--text-primary); border: 1px solid var(--border-color);
}
.fab.secondary:hover { border-color: var(--primary-color); color: var(--primary-color); }
.fab.secondary.active {
    background-color: var(--primary-color);
    color: var(--text-on-primary);
    border-color: var(--primary-color);
}
.fab.secondary svg { width: 22px; height: 22px; stroke: currentColor; fill: currentColor; }
#navi-mode-btn svg, #pitch-toggle-btn svg, #recenter-map-btn svg, #orientation-btn svg, #fab-help svg, #fab-center-guide svg, #fab-opacity-toggle svg, #fab-settings svg { fill: none; }

#fab-stamp-rally {
    width: 64px;
    height: 64px;
    background-color: var(--stamp-rally-color);
    color: var(--white-color);
    border: 2px solid var(--white-color);
    box-shadow: 0 4px 12px rgba(0,0,0,0.3);
    flex-direction: column;
    justify-content: center;
    align-items: center;
    padding: 8px;
    box-sizing: border-box;
    height: auto;
}

#fab-stamp-rally:hover {
    background-color: var(--stamp-rally-hover-color);
    border-color: var(--white-color);
    color: var(--white-color);
    transform: scale(1.05);
}

#fab-stamp-rally svg {
    width: 28px;
    height: 28px;
    stroke: var(--white-color);
    fill: none;
}

#stamp-rally-count-display {
    font-size: 16px;
    font-weight: bold;
    color: var(--white-color);
    margin-top: 2px;
    line-height: 1;
    text-shadow: 1px 1px 2px rgba(0,0,0,0.4);
}

#fab-container-plotting, #fab-container-delete-guide, #fab-container-spot-creation {
    position: fixed;
    bottom: calc(40px + env(safe-area-inset-bottom));
    left: 50%;
    transform: translateX(-50%);
    z-index: 1011;
    display: flex;
    gap: 16px;
    background-color: rgba(255, 255, 255, 0.8);
    padding: 12px 16px;
    border-radius: 34px;
    box-shadow: var(--shadow-md);
    -webkit-backdrop-filter: none;
    backdrop-filter: none;
    transition: opacity 0.3s, bottom 0.3s;
}

#fab-container-plotting .fab, #fab-container-delete-guide .fab, #fab-container-spot-creation .fab {
    width: 52px;
    height: 52px;
}
#fab-plotting-confirm { background-color: var(--success-color); }
#fab-plotting-confirm:hover { background-color: var(--success-hover-color); }
#fab-plotting-undo { background-color: var(--warning-color); }
#fab-plotting-undo:hover { background-color: var(--warning-hover-color); }
#fab-plotting-cancel { background-color: var(--danger-color); }
#fab-plotting-cancel:hover { background-color: var(--danger-hover-color); }

#fab-delete-guide-confirm { background-color: var(--primary-color); }
#fab-delete-guide-confirm:hover { background-color: var(--primary-hover-color); }
#fab-delete-guide-cancel { background-color: var(--danger-color); }
#fab-delete-guide-cancel:hover { background-color: var(--danger-hover-color); }

#fab-spot-creation-exit {
    background-color: var(--danger-color);
}
#fab-spot-creation-exit:hover {
    background-color: var(--danger-hover-color);
}

#countdown-overlay {
    position: fixed; top: 0; left: 0; width: 100%; height: 100%;
    background-color: rgba(0, 0, 0, 0.7);
    z-index: 2000;
    display: flex; justify-content: center; align-items: center;
    opacity: 0; visibility: hidden;
    transition: opacity 0.3s, visibility 0.3s;
}
#countdown-overlay.visible { opacity: 1; visibility: visible; }
#countdown-number {
    font-size: 25vw;
    font-weight: 700;
    color: white;
    text-shadow: 0 0 20px rgba(0,0,0,0.5);
    transform: scale(1.5);
    opacity: 0;
}
#countdown-overlay.visible #countdown-number {
    animation: countdown-tick 1s forwards;
}
@keyframes countdown-tick {
    0% { transform: scale(1.5); opacity: 0; }
    20% { transform: scale(1); opacity: 1; }
    80% { transform: scale(1); opacity: 1; }
    100% { transform: scale(0.8); opacity: 0; }
}

#image-message-container {
    position: absolute; top: 0; left: 0; width: 100%; height: 100%;
    background-color: rgba(0, 0, 0, 0.6); z-index: 2001;
    display: flex; justify-content: center; align-items: center;
    padding: 15px;
    box-sizing: border-box;
    opacity: 0; visibility: hidden;
    transition: opacity 0.3s, visibility 0.3s;
}
#image-message-container.visible { opacity: 1; visibility: visible; }

.message-content-wrapper {
    position: relative;
    background-color: var(--component-bg);
    color: var(--text-primary);
    padding: 0;
    border-radius: 16px;
    width: 100%;
    max-width: 450px;
    height: 85vh;
    max-height: 650px;
    display: flex;
    flex-direction: column;
    overflow: hidden;
    text-align: center;
    border: none;
    box-shadow: 0 8px 32px rgba(0, 0, 0, 0.2);
    transform: translateY(20px) scale(0.95);
    opacity: 0;
    transition: transform 0.4s cubic-bezier(0.25, 0.8, 0.25, 1), opacity 0.3s ease-out;
}

#image-message-container.visible .message-content-wrapper {
    transform: translateY(0) scale(1);
    opacity: 1;
}

.message-scrollable-content {
    padding: 50px 24px 24px 24px;
    overflow-y: auto;
    flex-grow: 1;
    min-height: 0;
}

#image-message-container .close-message-btn {
    position: absolute;
    top: 10px;
    right: 10px;
    width: 54px;
    height: 54px;
    background-color: rgba(0, 0, 0, 0.08);
    border: none;
    border-radius: 50%;
    cursor: pointer;
    color: var(--text-secondary);
    display: flex;
    align-items: center;
    justify-content: center;
    transition: background-color 0.2s, transform 0.1s;
    z-index: 1000; 
    touch-action: manipulation; 
}

#image-message-container .close-message-btn:active {
    background-color: rgba(0, 0, 0, 0.2);
    transform: scale(0.9);
}

#stamp-get-title {
    color: var(--primary-darkened) !important; /* ★白背景用の濃い色 */
    font-size: 1.6em;
    font-weight: 700;
    text-align: center;
    margin: 0 0 15px 0;
    padding-bottom: 12px;
    border-bottom: 2px solid var(--border-color);
}

#myImage {
    max-width: 100%;
    height: auto;
    max-height: 30vh;
    border-radius: 8px;
    margin-bottom: 15px;
    display: block;
    margin-left: auto;
    margin-right: auto;
    object-fit: contain;
}

#mess { margin-top: 0; margin-bottom: 24px; font-size: 1.1em; line-height: 1.6; }

#spot-description {
    text-align: left;
    font-size: 0.95em;
    line-height: 1.7;
    color: var(--text-secondary);
    margin-top: 16px;
    padding-top: 16px;
    border-top: 1px solid var(--border-color);
    white-space: pre-wrap; /* Keep pre-wrap for general text formatting */
}

/* ルビ（ふりがな）のスタイル - スポット説明文用 */
#spot-description ruby {
    display: inline-flex; /* Use inline-flex for better alignment control */
    flex-direction: column; /* Stack base text and ruby text vertically */
    align-items: center; /* Center ruby text above base text */
    white-space: normal !important; /* Override pre-wrap for ruby content */
    ruby-position: over; /* Standard for Japanese ruby */
}

#spot-description rt {
    display: block; /* Ensure ruby text is on its own line within the ruby element */
    font-size: 0.6em; /* Smaller font size for ruby text */
    line-height: 1; /* Compact line height */
    text-align: center; /* Center align ruby text */
    white-space: nowrap; /* Prevent ruby text from wrapping */
    font-feature-settings: "liga" 0; /* Disable ligatures if any */
    /* For better browser compatibility */
    -webkit-text-emphasis-style: none; /* For Safari/iOS */
    text-emphasis-style: none;
}

/* ルビ（ふりがな）のスタイル - クイズ解説文用 */
#quiz-explanation {
    white-space: pre-wrap; /* Keep pre-wrap for general text formatting */
}

#quiz-explanation ruby {
    display: inline-flex; /* Use inline-flex for better alignment control */
    flex-direction: column; /* Stack base text and ruby text vertically */
    align-items: center; /* Center ruby text above base text */
    white-space: normal !important; /* Override pre-wrap for ruby content */
    ruby-position: over; /* Standard for Japanese ruby */
}

#quiz-explanation rt {
    display: block; /* Ensure ruby text is on its own line within the ruby element */
    font-size: 0.6em; /* Smaller font size for ruby text */
    line-height: 1; /* Compact line height */
    text-align: center; /* Center align ruby text */
    white-space: nowrap; /* Prevent ruby text from wrapping */
    font-feature-settings: "liga" 0; /* Disable ligatures if any */
    /* For better browser compatibility */
    -webkit-text-emphasis-style: none; /* For Safari/iOS */
    text-emphasis-style: none;
}

.message-footer {
    padding: 16px 24px;
    border-top: 1px solid var(--border-color);
    background-color: var(--component-bg);
    flex-shrink: 0;
    display: flex;
    justify-content: center;
    align-items: center;
    gap: 24px;
}

#guideline { position: absolute; top: 50%; left: 50%; transform: translate(-50%, -50%); border: 2px dashed rgba(255, 0, 0, 0.8); box-shadow: 0 0 10px rgba(0, 0, 0, 0.5); pointer-events: none; display: none; z-index: 10; }

/* トースト通知 */
#toast-notification {
    visibility: hidden;
    min-width: 250px;
    background-color: #333;
    color: #fff;
    text-align: center;
    border-radius: 25px;
    padding: 14px 22px;
    position: fixed;
    z-index: 3500;
    left: 50%;
    bottom: calc(160px + env(safe-area-inset-bottom));
    transform: translate(-50%, 20px);
    font-size: 1em;
    opacity: 0;
    transition: all 0.4s cubic-bezier(0.25, 0.8, 0.25, 1);
}

#toast-notification.show {
    visibility: visible;
    opacity: 1;
    bottom: calc(180px + env(safe-area-inset-bottom));
    transform: translateX(-50%);
}

/* トーストを上部に表示するためのスタイル */
#toast-notification.toast-top {
    bottom: auto !important;
    top: calc(env(safe-area-inset-top) + 100px) !important;
    transform: translate(-50%, -20px) !important;
}

#toast-notification.toast-top.show {
    transform: translate(-50%, 0) !important;
}

#export-confirm-popup {
    position: fixed;
    bottom: calc(34px + env(safe-area-inset-bottom));
    left: 10px;
    right: 10px;
    transform: translateX(0);
    max-width: 500px;
    margin: 0 auto;
    background-color: rgba(0, 0, 0, 0.7);
    -webkit-backdrop-filter: blur(10px);
    backdrop-filter: blur(10px);
    color: white;
    padding: 16px;
    border-radius: 16px;
    border: 1px solid rgba(255, 255, 255, 0.2);
    box-shadow: 0 4px 20px rgba(0, 0, 0, 0.4);
    z-index: 1100;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 12px;
    transition: opacity 0.3s, bottom 0.3s;
}

#export-confirm-popup p {
    margin: 0;
    font-size: 0.95em;
    font-weight: bold;
    text-align: center;
    line-height: 1.5;
    text-shadow: 1px 1px 2px rgba(0,0,0,0.5);
}
.export-buttons { display: flex; gap: 8px; flex-shrink: 0; }
#export-confirm-popup button { padding: 8px 16px; border: none; border-radius: 8px; cursor: pointer; font-weight: bold; transition: background-color 0.2s; }
#export-confirm-popup #execute-export-btn { background-color: #007aff; color: white; }
#export-confirm-popup #cancel-export-btn { background-color: #555; color: white; }

body[data-app-state="finished"] .maplibregl-user-location-dot,
body[data-app-state="finished"] .maplibregl-user-location-accuracy-circle {
    display: none !important;
}

.popup-overlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background-color: rgba(30, 30, 30, 0.85);
    -webkit-backdrop-filter: none;
    backdrop-filter: none;
    display: flex;
    justify-content: center;
    align-items: center;
    z-index: 9000;
    opacity: 0;
    visibility: hidden;
    transition: opacity 0.3s ease, visibility 0s 0.3s;
}

.popup-overlay:not(.hidden) {
    opacity: 1;
    visibility: visible;
    transition: opacity 0.3s ease;
}

.popup-content {
    position: relative;
    background-color: var(--component-bg);
    padding: 24px;
    border-radius: 12px;
    box-shadow: var(--shadow-md);
    text-align: center;
    max-width: 90%;
    width: 300px;
    opacity: 0;
    transform: scale(0.95) translateY(10px);
    transition: transform 0.3s cubic-bezier(0.25, 0.8, 0.25, 1), opacity 0.3s ease-out;
}

.popup-overlay:not(.hidden) .popup-content {
    opacity: 1;
    transform: scale(1) translateY(0);
}

.popup-content p, .popup-section label {
    margin: 0 0 12px 0;
    font-size: 1.1em;
    color: var(--text-primary);
    font-weight: bold;
    display: block;
}

/* ★ポップアップの見出しは白背景用の濃い色を使う */
.popup-content h3 {
    margin: 0 0 12px 0;
    font-size: 1.1em;
    font-weight: bold;
    display: block;
    color: var(--primary-darkened) !important; /* ★変更 */
}

.popup-content p small {
    font-size: 0.8em;
    color: var(--text-secondary);
    font-weight: normal;
}
.popup-section {
    margin-bottom: 24px;
}
.popup-buttons {
    display: flex;
    flex-direction: column;
    gap: 12px;
    margin-bottom: 0;
}
.popup-buttons button {
    padding: 12px;
    border-radius: 8px;
    border: 1px solid var(--border-color);
    font-size: 1em;
    font-weight: bold;
    cursor: pointer;
    transition: background-color 0.2s, color 0.2s, transform 0.1s;
}
.popup-buttons button:active {
    transform: scale(0.96);
}

.popup-buttons button.popup-btn-primary {
    background-color: var(--primary-color);
    color: var(--text-on-primary);
    border-color: var(--primary-color);
}
.popup-buttons button.popup-btn-primary:hover {
    background-color: var(--primary-hover-color);
}
.popup-buttons button.popup-btn-secondary {
    background-color: var(--component-bg);
    color: var(--primary-color);
}
.popup-buttons button.popup-btn-secondary:hover {
    background-color: #f0f0f0;
}
.popup-buttons button.popup-btn-cancel:hover {
     background-color: #f0f0f0;
}

.popup-buttons button.popup-btn-danger {
    background-color: var(--danger-color);
    color: var(--white-color);
    border-color: var(--danger-color);
}
.popup-buttons button.popup-btn-danger:hover {
    background-color: var(--danger-hover-color);
}
.speed-controls-popup {
    display: flex;
    justify-content: center;
    gap: 5px;
}
.speed-controls-popup button {
    flex: 1;
    padding: 10px 0;
    border: 1px solid var(--border-color);
    background-color: transparent;
    font-weight: bold;
    color: var(--text-secondary);
    cursor: pointer;
    transition: background-color 0.2s, color 0.2s;
}
.speed-controls-popup button.active {
    background-color: var(--primary-color);
    color: var(--text-on-primary);
    border-color: var(--primary-color);
}

body[data-app-state="finished"] #fab-container,
body[data-app-state="finished"] #fab-container-left {
    bottom: calc(115px + env(safe-area-inset-bottom));
}
/* ツアー完了後のトースト通知の位置 */
body[data-app-state="finished"] #toast-notification {
    bottom: calc(195px + env(safe-area-inset-bottom));
}
body[data-app-state="finished"] #toast-notification.show {
    bottom: calc(215px + env(safe-area-inset-bottom));
}
body[data-app-state="finished"] #export-confirm-popup {
    bottom: calc(100px + env(safe-area-inset-bottom));
}
.maplibregl-ctrl-logo {
    display: none !important;
}
.maplibregl-ctrl-top-left .maplibregl-ctrl {
    margin-top: 10px;
    transition: margin-top 0.3s ease-in-out;
}

body[data-app-state="finished"] #fab-container-top-right {
    top: 70px;
}

#qr-scanner-overlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0,0,0,0.9);
    z-index: 4000;
    display: flex;
    flex-direction: column;
    justify-content: center;
    align-items: center;
}
#qr-reader {
    width: 80vw;
    max-width: 400px;
    border: 2px solid var(--primary-color);
    border-radius: var(--border-radius-md);
    overflow: hidden;
}
#close-qr-scanner {
    margin-top: 20px;
    padding: 10px 20px;
    background: var(--danger-color);
    color: white;
    border: none;
    border-radius: var(--border-radius-sm);
    font-weight: bold;
    cursor: pointer;
}

/* お絵かき中・終了後の両方でヘッダーを非表示にする */
body[data-app-state="tour"] h1,
body[data-app-state="paused"] h1,
body[data-app-state="finished"] h1 {
    display: none !important;
}

.header-hidden h1 {
    display: none !important;
}

body.stats-panel-shown.header-hidden .maplibregl-ctrl-top-left .maplibregl-ctrl {
    margin-top: 69px;
}
body.stats-panel-shown:not(.header-hidden) .maplibregl-ctrl-top-left .maplibregl-ctrl {
    margin-top: 65px;
}

#initial-panel {
    position: fixed;
    bottom: 0;
    left: 0;
    right: 0;
    background-color: var(--component-bg);
    z-index: 3100;
    padding: 16px 16px calc(16px + env(safe-area-inset-bottom));
    border-top-left-radius: var(--border-radius-md);
    border-top-right-radius: var(--border-radius-md);
    box-shadow: 0 -4px 12px rgba(0,0,0,0.15);
    transform: translateY(100%);
    transition: transform 0.4s cubic-bezier(0.4, 0, 0.2, 1);
}

#initial-panel.visible {
    transform: translateY(0);
}
#initial-panel-content p {
    text-align: center;
    margin-top: 0;
    margin-bottom: 24px;
    font-size: 1.1em;
    line-height: 1.6;
}

#loading-overlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background-color: var(--body-bg);
    z-index: 9000;
    display: flex;
    justify-content: center;
    align-items: center;
    flex-direction: column;
    gap: 20px;
    transition: opacity 0.5s ease, visibility 0.5s ease;
    opacity: 1;
    visibility: visible;
}

#loading-overlay.hidden {
    opacity: 0;
    visibility: hidden;
    pointer-events: none;
}

#loading-overlay .spinner {
    width: 50px;
    height: 50px;
    border: 5px solid rgba(0, 0, 0, 0.1);
    border-top-color: var(--primary-color);
    border-radius: 50%;
    animation: spin 1s linear infinite;
}

#loading-overlay p {
    font-size: 1em;
    color: var(--text-secondary);
    font-weight: bold;
}

@keyframes spin {
    to {
        transform: rotate(360deg);
    }
}

#help-modal.popup-overlay {
    align-items: flex-start;
    padding: 20px 0;
}

.popup-content.help-content {
    width: 360px;
    max-width: 95vw;
    text-align: left;
    max-height: calc(100% - 60px);
    overflow-y: auto;
    display: flex;
    flex-direction: column;
}

.popup-content.help-content .help-section {
    flex-shrink: 0;
}

#help-modal .close-message-btn {
    position: absolute;
    top: 12px;
    right: 12px;
    left: auto;
    width: 36px;
    height: 36px;
    background-color: rgba(0, 0, 0, 0.08);
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: background-color 0.2s;
    cursor: pointer;
    z-index: 10;
}
#help-modal .close-message-btn:hover {
    background-color: rgba(0, 0, 0, 0.15);
}

.popup-content.help-content h2 {
    text-align: center;
    margin-top: 0;
    margin-right: 40px;
}

.help-section {
    margin-bottom: 20px;
}

.help-section + .help-section {
    margin-top: 20px;
    padding-top: 20px;
    border-top: 1px solid var(--border-color);
}

.help-section h3 {
    font-size: 1em;
    color: var(--primary-darkened) !important; /* ★白背景対策 */
    border-bottom: 2px solid var(--primary-darkened) !important; /* ★白背景対策 */
    padding-bottom: 4px;
    margin-bottom: 12px;
}
.help-section p {
    font-size: 0.9em;
    line-height: 1.6;
    margin: 0;
    font-weight: normal;
}
.help-item {
    display: flex;
    align-items: center;
    gap: 15px;
    margin-bottom: 12px;
}
.help-item .icon-placeholder {
    flex-shrink: 0;
    width: 40px;
    height: 40px;
    display: flex;
    justify-content: center;
    align-items: center;
    background-color: var(--body-bg);
    border-radius: 8px;
    color: var(--text-primary);
}
.help-item .icon-placeholder svg {
    width: 24px;
    height: 24px;
    stroke-width: 2;
    stroke: currentColor;
    color: currentColor;
}
.help-item p {
    flex-grow: 1;
    font-size: 0.85em;
    line-height: 1.5;
}
.help-item p b {
    font-weight: bold;
    color: var(--text-primary);
    display: block;
}

.user-manual-link {
    display: block;
    text-align: center;
    margin-top: 16px;
    margin-bottom: 16px;
    font-size: 0.9em;
    color: var(--primary-darkened) !important; /* ★白背景対策 */
    text-decoration: underline;
}

#confirm-help-btn {
    width: 100%;
    padding: 14px;
    font-size: 1.1em;
    margin-top: 10px;
}

#gpx-download-modal .popup-content p {
    font-weight: normal;
    text-align: center;
    line-height: 1.6;
}
#gpx-download-modal .popup-content p a {
    color: var(--primary-darkened) !important; /* ★白背景対策 */
    font-weight: bold;
}

#paused-overlay {
    position: absolute;
    bottom: 0;
    left: 0;
    width: 100%;
    padding: 10px;
    background-color: rgba(0, 0, 0, 0.6);
    color: white;
    text-align: center;
    font-weight: bold;
    font-size: 1.1em;
    z-index: 1000;
    pointer-events: none;
    transition: opacity 0.3s, visibility 0.3s;
}

.loading-intro-image {
    width: 80%;
    max-width: 280px;
    height: auto;
    border-radius: var(--border-radius-md);
    box-shadow: var(--shadow-sm);
}

.popup-input {
    width: 100%;
    padding: 10px;
    border: 1px solid var(--border-color);
    border-radius: var(--border-radius-sm);
    box-sizing: border-box;
    font-size: 1em;
}

#trash-stat-item.hidden {
    display: none;
}

#plogging-collect-button-container {
    position: fixed;
    bottom: calc(40px + env(safe-area-inset-bottom));
    left: 50%;
    transform: translateX(-50%);
    z-index: 1011;
    transition: opacity 0.3s, transform 0.3s;
}

#plogging-collect-btn {
    width: 64px;
    height: 64px;
    background-color: var(--primary-color);
    border: 2px solid white;
    border-radius: 50%;
    box-shadow: 0 4px 12px rgba(0,0,0,0.3);
    cursor: pointer;
    transition: transform 0.2s cubic-bezier(0.34, 1.56, 0.64, 1);
    display: flex;
    flex-direction: column;
    justify-content: center;
    align-items: center;
    color: white;
    padding: 8px;
    box-sizing: border-box;
}

#plogging-collect-btn:active {
    transform: scale(0.92);
}

#plogging-collect-btn svg {
    width: 28px;
    height: 28px;
}

#plogging-count-display {
    font-size: 16px;
    font-weight: bold;
    margin-top: 2px;
    text-shadow: 1px 1px 2px rgba(0,0,0,0.4);
}

#camera-overlay {
    z-index: 4500;
    background-color: rgba(0,0,0,0.95);
    backdrop-filter: none;
    -webkit-backdrop-filter: none;
}
.camera-container {
    position: relative;
    width: 100%;
    height: 100%;
    display: flex;
    flex-direction: column;
    justify-content: center;
    align-items: center;
    overflow: hidden;
}
#camera-video, #camera-canvas {
    width: 100%;
    max-height: 100%;
    object-fit: contain;
}
#camera-canvas {
    display: none;
}
#camera-shutter-button {
    position: absolute;
    bottom: 10%;
    left: 50%;
    transform: translateX(-50%);
    width: 70px;
    height: 70px;
    border-radius: 50%;
    background-color: #fff;
    border: 5px solid rgba(0,0,0,0.3);
    cursor: pointer;
    z-index: 10;
}
#camera-shutter-button:active {
    background-color: #ccc;
}
#camera-cancel-btn {
    position: absolute;
    top: 40px;
    right: 20px;
    background: rgba(0,0,0,0.5);
    color: white;
    border: none;
    border-radius: 8px;
    padding: 10px 15px;
    font-weight: bold;
    cursor: pointer;
    z-index: 10;
}
#camera-controls {
    position: absolute;
    bottom: 10%;
    width: 100%;
    display: flex;
    justify-content: space-around;
    align-items: center;
    z-index: 10;
}
#camera-controls button {
    padding: 12px 24px;
    border-radius: 8px;
    border: none;
    font-size: 1em;
    font-weight: bold;
    cursor: pointer;
    background-color: rgba(255, 255, 255, 0.9);
    color: var(--text-primary);
}
#camera-controls button#camera-save-btn {
    background-color: var(--primary-color);
    color: white;
}

#permission-help-modal .popup-content {
    max-width: 360px;
}

#permission-modal-instructions {
    text-align: left;
    font-size: 0.9em;
    line-height: 1.6;
    background-color: var(--body-bg);
    padding: 12px 16px;
    border-radius: var(--border-radius-sm);
    margin: 16px 0;
    border: 1px solid var(--border-color);
}

#permission-modal-instructions ol {
    padding-left: 20px;
    margin: 0;
}

#permission-modal-instructions li {
    margin-bottom: 12px;
}
#permission-modal-instructions li:last-child {
    margin-bottom: 0;
}

#permission-modal-instructions strong {
    color: var(--primary-darkened) !important; /* ★白背景対策 */
    font-weight: 700;
}

#permission-modal-instructions .os-instructions {
    margin-top: 15px;
    padding-top: 15px;
    border-top: 1px solid var(--border-color);
}

#permission-modal-instructions .os-instructions h4 {
    margin: 0 0 8px 0;
    font-size: 1.1em;
    color: var(--text-primary);
}

.mode-selection-options {
    margin: 24px 0;
    display: flex;
    flex-direction: column;
    gap: 12px;
}
.mode-selection-option {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 12px;
    background-color: var(--body-bg);
    border-radius: var(--border-radius-sm);
    border: 1px solid var(--border-color);
}
.mode-selection-option input[type="checkbox"] {
    width: 20px;
    height: 20px;
    accent-color: var(--primary-color);
    flex-shrink: 0;
}
.mode-selection-option label {
    font-weight: bold;
    font-size: 1em;
    margin: 0;
    line-height: 1.4;
    flex-grow: 1;
}
.mode-selection-option input[type="color"] {
    width: 44px;
    height: 44px;
    border: none;
    background: none;
    padding: 0;
    border-radius: 8px;
    cursor: pointer;
}


#stamp-rally-popup .popup-content.stamp-rally-content {
    background: var(--component-bg);
    border: 2px solid var(--primary-color);
    box-shadow: var(--shadow-md);
    color: var(--text-primary);
    width: 90vw;
    max-width: 500px;
    max-height: 85vh;
    overflow-y: auto;
    display: flex;
    flex-direction: column;
}

#stamp-rally-popup #close-stamp-rally-popup {
    position: absolute;
    top: 15px;
    right: 15px;
    width: 36px;
    height: 36px;
    background-color: rgba(0, 0, 0, 0.08);
    border-radius: 50%;
    border: none;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    z-index: 10;
    transition: background-color 0.2s;
}

#stamp-rally-popup #close-stamp-rally-popup:hover {
    background-color: rgba(0, 0, 0, 0.15);
}

#stamp-rally-popup .popup-content h3 {
    font-family: 'Noto Sans JP', sans-serif;
    font-size: 1.6em;
    color: var(--primary-darkened) !important; /* ★白背景対策 */
    text-shadow: none;
    border-bottom: 2px solid var(--primary-darkened) !important; /* ★白背景対策 */
    padding-bottom: 10px;
    margin-bottom: 20px;
    margin-right: 40px;
}
.stamp-sheet-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(100px, 1fr));
    gap: 15px;
    padding: 15px;
    background-color: var(--body-bg);
    border-radius: var(--border-radius-sm);
    border: 1px solid var(--border-color);
    min-height: 120px;
    flex-grow: 1;
}
.stamp-card {
    border: 2px dashed var(--border-color);
    border-radius: var(--border-radius-sm);
    aspect-ratio: 1 / 1;
    display: flex;
    flex-direction: column;
    justify-content: center;
    align-items: center;
    text-align: center;
    transition: all 0.4s ease-in-out;
    padding: 8px;
    box-sizing: border-box;
    background-color: transparent;
    box-shadow: none;
}
.stamp-card.stamped {
    border-style: solid;
    border-color: var(--primary-darkened) !important; /* ★白背景対策 */
    border-width: 3px;
    background-color: var(--component-bg);
    transform: scale(1.05);
    box-shadow: 0 4px 12px rgba(0, 153, 153, 0.25);
}
.stamp-card .stamp-image {
    width: 60%;
    height: 60%;
    object-fit: contain;
    border-radius: 4px;
}
.stamp-card .stamp-name {
    font-size: 0.75em;
    font-weight: bold;
    color: var(--text-secondary);
    margin: 4px 0 0 0;
    line-height: 1.3;
}
.stamp-card.stamped .stamp-name {
    font-family: 'Noto Sans JP', sans-serif;
    color: var(--primary-darkened) !important; /* ★白背景対策 */
    font-weight: 700;
}
.stamp-card.empty {
    background-color: rgba(0,0,0, 0.02);
}

#stamp-get-animation {
    position: absolute;
    top: 15px;
    left: 50%;
    width: 60%;
    max-width: 200px;
    transform: translateX(-50%);
    pointer-events: none;
    z-index: 15;
    opacity: 0;
}
#stamp-get-animation.animate {
    animation: stamp-animation 1.2s cubic-bezier(0.34, 1.56, 0.64, 1) forwards;
}
@keyframes stamp-animation {
    0% {
        transform: translateX(-50%) scale(2.5) rotate(-15deg);
        opacity: 0;
    }
    40% {
        transform: translateX(-50%) scale(1) rotate(5deg);
        opacity: 1;
    }
    70% {
        transform: translateX(-50%) scale(1.1) rotate(0deg);
        opacity: 1;
    }
    100% {
        transform: translateX(-50%) scale(1.1) translateY(-10px);
        opacity: 0;
    }
}

.popup-content.course-select-content {
    width: 90vw;
    max-width: 800px;
    height: 80vh;
    padding-top: 20px;
    display: flex;
    flex-direction: column;
}

.course-select-content h2 {
    text-align: center;
    margin-top: 0;
    margin-bottom: 16px;
    padding-bottom: 8px;
    border-bottom: 1px solid var(--border-color);
}

.course-filters {
    display: flex;
    gap: 15px;
    margin-bottom: 15px;
    flex-shrink: 0;
}

.course-filters select {
    flex-grow: 1;
    padding: 10px;
    font-size: 1em;
    border: 1px solid var(--border-color);
    border-radius: var(--border-radius-sm);
    background-color: var(--component-bg);
}

.course-list-container {
    flex-grow: 1;
    overflow-y: auto;
    border: 1px solid var(--border-color);
    border-radius: var(--border-radius-sm);
}

#course-list-table {
    width: 100%;
    border-collapse: collapse;
}

#course-list-table th,
#course-list-table td {
    padding: 12px 15px;
    text-align: left;
    border-bottom: 1px solid var(--border-color);
}

#course-list-table th {
    background-color: var(--body-bg);
    position: sticky;
    top: 0;
    font-size: 0.9em;
}

#course-list-table tbody tr:hover {
    background-color: #f0f8ff;
}

#course-list-table .course-name {
    font-weight: bold;
}

#course-list-table .course-meta {
    font-size: 0.8em;
    color: var(--text-secondary);
}

#course-list-table .load-course-btn {
    padding: 8px 16px;
    font-size: 0.9em;
    font-weight: bold;
    color: var(--white-color);
    background-color: var(--primary-color);
    border: none;
    border-radius: var(--border-radius-sm);
    cursor: pointer;
    transition: background-color 0.2s;
}

#course-list-table .load-course-btn:hover {
    background-color: var(--primary-hover-color);
}

.footer-btn-wrapper {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 6px; 
    flex-shrink: 0;
}

.footer-btn-wrapper button,
.footer-btn-wrapper a {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 60px;
    height: 60px;
    border-radius: 50%; 
    background-color: var(--primary-color);
    color: var(--text-on-primary) !important; /* ★黒文字対応 */
    border: none;
    cursor: pointer;
    box-shadow: var(--shadow-sm);
    transition: all 0.2s ease;
    text-decoration: none;
    padding: 0;
}

.footer-btn-wrapper button:hover,
.footer-btn-wrapper a:hover {
    background-color: var(--primary-hover-color);
    transform: translateY(-2px);
    box-shadow: var(--shadow-md);
}

.footer-btn-wrapper svg {
    width: 28px;
    height: 28px;
    stroke: currentColor !important; /* ★黒文字対応 */
    fill: none; 
}

/* カメラボタンのSVGはfillを使用 */
.footer-btn-wrapper #camera-btn svg {
    fill: currentColor !important; /* ★黒文字対応 */
    stroke: none !important;
}

.footer-btn-caption {
    font-size: 12px;
    color: var(--text-secondary);
    font-weight: 500;
}

#fab-container-creation-tools {
    position: fixed;
    top: calc(56px + env(safe-area-inset-top) + 16px);
    left: 16px;
    z-index: 1011;
    display: flex;
    flex-direction: column;
    align-items: flex-start;
    gap: 12px;
}

#fab-container-creation-tools.open #fab-create-toggle {
    transform: rotate(45deg);
}

#fab-creation-options {
    display: flex;
    flex-direction: column;
    gap: 12px;
    transition: opacity 0.2s ease-out, transform 0.2s ease-out;
}

#fab-creation-options.hidden {
    opacity: 0;
    transform: translateY(-10px);
    pointer-events: none;
}

.fab-creation {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 8px 14px;
    background-color: var(--component-bg);
    border: 1px solid var(--border-color);
    border-radius: 20px;
    box-shadow: var(--shadow-md);
    cursor: pointer;
    font-size: 0.9em;
    font-weight: bold;
    color: var(--text-primary);
    transition: all 0.2s ease;
    white-space: nowrap;
}

.fab-creation:hover {
    transform: scale(1.05);
    border-color: var(--primary-color);
    color: var(--primary-color);
}

.fab-creation svg {
    width: 20px;
    height: 20px;
    flex-shrink: 0;
}

/* 左上ボタンの配置 */
#top-left-fab-container {
    position: fixed;
    top: calc(env(safe-area-inset-top) + 4px);
    left: 16px;
    z-index: 1010;
    display: flex;
    flex-direction: column;
    align-items: flex-start;
    gap: 12px;
    transition: top 0.4s cubic-bezier(0.4, 0, 0.2, 1);
}

body.stats-panel-shown #top-left-fab-container {
    top: calc(env(safe-area-inset-top) + var(--stats-panel-height) + 4px);
}

/* 透過度ボタンの位置調整 */
#opacity-toggle-container {
    position: absolute;
    left: 50%;
    bottom: calc(10px + 54px + 12px + env(safe-area-inset-bottom));
    transform: translateX(-50%);
    z-index: 400;
    transition: opacity 0.3s, bottom 0.3s;
}

#opacity-toggle-container.hidden {
    opacity: 0;
    pointer-events: none;
}

/* 古地図切替ボタンの位置調整 */
#historical-map-switcher {
    position: absolute;
    bottom: calc(18px + env(safe-area-inset-bottom));
    left: 50%;
    transform: translateX(-50%);
    background-color: rgba(255, 255, 255, 0.85);
    backdrop-filter: blur(5px);
    -webkit-backdrop-filter: blur(5px);
    padding: 8px 12px;
    border-radius: 25px;
    box-shadow: var(--shadow-md);
    z-index: 1050;
    display: flex;
    align-items: center;
    gap: 12px;
    color: var(--text-primary);
    font-weight: bold;
    transition: opacity 0.3s, bottom 0.3s;
    min-height: 52px;
    box-sizing: border-box;
}

#historical-map-switcher.hidden {
    opacity: 0;
    pointer-events: none;
}

#historical-map-label {
    white-space: normal;
    font-size: 0.85em;
    line-height: 1.3;
    max-width: 120px;
    min-width: 100px;
    text-align: center;
}

.hist-nav-btn {
    background-color: var(--component-bg);
    border: 1px solid var(--border-color);
    color: var(--text-primary);
    width: 36px;
    height: 36px;
    border-radius: 50%;
    font-size: 1.1em;
    font-weight: bold;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 0;
    transition: background-color 0.2s, color 0.2s, transform 0.1s;
}

.hist-nav-btn:hover:not(:disabled) {
    background-color: var(--primary-color);
    color: white;
    border-color: var(--primary-color);
}

.hist-nav-btn:active:not(:disabled) {
    transform: scale(0.9);
}

.hist-nav-btn:disabled {
    opacity: 0.4;
    cursor: not-allowed;
    background-color: rgba(200, 200, 200, 0.5);
}

/* セーフエリア対応スタイル */
#safe-area-top-bar {
    display: none;
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: env(safe-area-inset-top);
    background-color: var(--primary-color);
    z-index: 1100;
}

body.native-app #safe-area-top-bar {
    display: block !important;
}

.header-hidden #fab-container-top-right {
    top: calc(env(safe-area-inset-top) + 4px);
}
.stats-panel-shown.header-hidden #fab-container-top-right {
    top: calc(env(safe-area-inset-top) + var(--stats-panel-height) + 4px);
}

#safe-area-bottom-bar {
    display: flex;
    position: fixed;
    bottom: 0;
    left: 0;
    width: 100%;
    height: calc(24px + env(safe-area-inset-bottom));
    background-color: var(--primary-color);
    z-index: 1100;
    justify-content: center;
    align-items: flex-start;
    box-sizing: border-box;
    padding-top: 5px;
}

#safe-area-bottom-bar p {
    margin: 0;
    color: var(--text-on-primary) !important; /* ★黒文字対応 */
    font-size: 0.8em;
}
#safe-area-bottom-bar a {
    color: var(--text-on-primary) !important; /* ★黒文字対応 */
    text-decoration: underline;
}

.mode-selection-option.disabled {
    opacity: 0.6;
    cursor: not-allowed;
    background-color: var(--body-bg);
}

.mode-selection-option.disabled label {
    color: var(--text-secondary);
}

@keyframes pulse-lock {
    0% { transform: scale(1); opacity: 0.8; }
    50% { transform: scale(1.1); opacity: 1; }
    100% { transform: scale(1); opacity: 0.8; }
}

.swipe-arrow {
    position: absolute;
    bottom: 20%;
    opacity: 0.7;
    animation: swipe-up-animation 1.5s infinite;
}

@keyframes swipe-up-animation {
    0% { transform: translateY(10px); opacity: 0; }
    50% { opacity: 0.8; }
    100% { transform: translateY(-10px); opacity: 0; }
}

#tutorial-overlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background-color: rgba(0, 0, 0, 0.6);
    z-index: 9990;
    transition: opacity 0.3s;
}

#tutorial-step {
    position: absolute;
    background-color: var(--component-bg);
    padding: 16px;
    border-radius: var(--border-radius-md);
    box-shadow: var(--shadow-md);
    width: 280px;
    max-width: 80vw;
    z-index: 9999;
    border: 2px solid var(--primary-color);
}

#tutorial-step h3 {
    margin-top: 0;
    font-size: 1.2em;
    color: var(--primary-darkened) !important; /* ★白背景対策 */
}

#tutorial-step p {
    font-size: 0.95em;
    line-height: 1.6;
    margin-bottom: 20px;
}

#tutorial-navigation {
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.tutorial-btn {
    padding: 8px 16px;
    border-radius: var(--border-radius-sm);
    border: none;
    font-weight: bold;
    cursor: pointer;
}
.tutorial-btn.primary {
    background-color: var(--primary-color);
    color: white;
}
.tutorial-btn.secondary {
    background-color: #e0e0e0;
    color: var(--text-primary);
}
.tutorial-btn.close {
    background-color: transparent;
    color: var(--text-secondary);
    font-weight: normal;
    padding: 8px;
}

.tutorial-icon-inline {
    width: 1.2em;
    height: 1.2em;
    vertical-align: middle;
    margin: 0 0.1em -0.2em 0.1em;
    fill: currentColor;
    stroke: currentColor;
    stroke-width: 2;
}

.tutorial-icon-inline path {
    stroke-width: 0;
    fill: var(--primary-color);
}

.tutorial-icon-inline line,
.tutorial-icon-inline rect,
.tutorial-icon-inline circle,
.tutorial-icon-inline path[d*='m21 15-5-5L5 21'] {
    stroke: var(--primary-color);
    fill: none;
}

/* FAB共通ラベル */
.fab-label {
    font-size: 10px;
    font-weight: bold;
    color: var(--text-on-primary) !important; /* ★黒文字対応 */
    line-height: 1;
    text-align: center;
    white-space: nowrap;
    letter-spacing: -0.5px;
}

/* FAB共通レイアウト */
#fab-create-toggle,
#fab-load-course,
#fab-spot-create-toggle, 
#fab-start,
#fab-pause,
#fab-resume,
#fab-stop,
#fab-reset,
#fab-lock-screen {
    width: 64px;
    height: 64px;
    border-radius: 20px;
    flex-direction: column;
    justify-content: center;
    padding: 8px 4px;
    gap: 3px;
    box-sizing: border-box;
    transition: transform 0.3s cubic-bezier(0.4, 0, 0.2, 1);
}

/* 作成系ボタンの背景色と文字色 */
#fab-create-toggle,
#fab-load-course,
#fab-spot-create-toggle {
    background-color: var(--primary-color);
    color: var(--text-on-primary) !important; /* ★黒文字対応 */
}

#fab-create-toggle:hover,
#fab-load-course:hover,
#fab-spot-create-toggle:hover {
    background-color: var(--primary-hover-color);
}

/* アイコンとラベル付きFABの共通アイコンサイズと色 */
#fab-create-toggle svg,
#fab-load-course svg,
#fab-spot-create-toggle svg {
    width: 28px;
    height: 28px;
    stroke: currentColor !important; /* ★黒文字対応 */
    fill: none;
}

/* その他のFABアイコンサイズ */
#fab-start svg,
#fab-pause svg,
#fab-resume svg,
#fab-stop svg,
#fab-reset svg,
#fab-lock-screen svg {
    width: 28px;
    height: 28px;
}

#fab-container-plotting .button-wrapper button svg,
#fab-container-spot-creation .button-wrapper button svg {
    color: var(--white-color);
}

.os-prompt-instructions {
    text-align: left;
    margin: 20px 0;
    padding: 15px;
    border: 1px solid var(--border-color);
    border-radius: var(--border-radius-sm);
    background-color: var(--body-bg);
}

.os-prompt-instructions p {
    font-size: 1em;
    line-height: 1.5;
    margin: 10px 0;
    font-weight: normal;
}

.os-prompt-instructions b {
    color: var(--primary-darkened) !important; /* ★白背景対策 */
}

.inline-icon {
    width: 20px;
    height: 20px;
    vertical-align: middle;
    margin: 0 4px;
}

.finish-tutorial-section {
    margin: 20px 0;
    text-align: left;
}

.tutorial-item {
    display: flex;
    align-items: center;
    gap: 15px;
    margin-bottom: 20px;
}
.tutorial-item:last-child {
    margin-bottom: 0;
}

.tutorial-icon {
    flex-shrink: 0;
    width: 48px;
    height: 48px;
    display: flex;
    justify-content: center;
    align-items: center;
    background-color: var(--body-bg);
    border-radius: 12px;
    color: var(--primary-darkened) !important; /* ★白背景対策 */
    border: 1px solid var(--border-color);
}

.tutorial-icon svg {
    width: 28px;
    height: 28px;
}

.tutorial-description h4 {
    margin: 0 0 4px 0;
    font-size: 1.1em;
    color: var(--text-primary);
}

.tutorial-description p {
    margin: 0;
    font-size: 0.9em;
    line-height: 1.5;
    color: var(--text-secondary);
    font-weight: normal;
}

.popup-buttons.choice-buttons {
    flex-direction: column;
    gap: 10px;
}
.popup-buttons.choice-buttons button {
    flex: none;
    width: 100%;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: var(--spacing-sm, 8px);
}
.popup-buttons.choice-buttons button svg {
    width: 20px;
    height: 20px;
    fill: none;
    stroke: currentColor;
    stroke-width: 2;
    stroke-linecap: round;
    stroke-linejoin: round;
}

.maplibregl-ctrl-geolocate {
    display: none !important;
}

.target-marker {
    width: 24px;
    height: 24px;
    background-color: #ff4e4e;
    border: 2px solid white;
    border-radius: 50%;
    box-shadow: 0 0 10px rgba(255, 78, 78, 0.8);
    animation: pulse-marker 2s infinite;
}

@keyframes pulse-marker {
    0% { transform: scale(0.9); opacity: 1; }
    50% { transform: scale(1.2); opacity: 0.7; }
    100% { transform: scale(0.9); opacity: 1; }
}

.target-marker-icon {
    transform-origin: center; 
    transition: transform 0.5s ease-out; 
}

#course-loaded-info p {
    text-align: center;
    margin-top: 0;
    margin-bottom: 0;
    font-size: 1.1em;
    line-height: 1.6;
}

#course-loaded-info p small {
    font-size: 0.9em;
    color: var(--text-secondary);
}

#delete-point-confirm-popup .popup-buttons {
    flex-direction: row;
    gap: 10px;
}
#delete-point-confirm-popup .popup-buttons button {
    flex: 1;
}

.toggle-switch-container {
    position: relative;
    width: 52px;
    height: 30px;
    margin-bottom: 2px;
}

.toggle-switch-container input[type="checkbox"] {
    opacity: 0;
    width: 0;
    height: 0;
}

.toggle-switch-label {
    position: absolute;
    cursor: pointer;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background-color: #ccc;
    transition: .4s;
    border-radius: 34px;
}

.toggle-switch-label:before {
    position: absolute;
    content: "";
    height: 22px;
    width: 22px;
    left: 4px;
    bottom: 4px;
    background-color: white;
    transition: .4s;
    border-radius: 50%;
}

input:checked + .toggle-switch-label {
    background-color: var(--success-color);
}

input:checked + .toggle-switch-label:before {
    transform: translateX(22px);
}

#plotting-distance-display {
    display: flex;
    align-items: center;
    padding: 0 16px;
    font-size: 14px;
    font-weight: bold;
    color: var(--text-primary);
    background-color: rgba(245, 245, 247, 0.7);
    border-radius: 16px;
    height: 32px;
    white-space: nowrap;
    border: 1px solid var(--border-color);
}

#fab-container-plotting {
    align-items: center;
}

#plotting-info-controls {
    display: flex;
    flex-direction: column;
    align-items: center;  
    gap: 4px;              
}

#plotting-info-controls .button-wrapper .button-label {
    margin-top: 2px;
}

.popup-buttons button.with-icon {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
}

#fab-container-plotting-help {
    position: fixed;
    top: calc(env(safe-area-inset-top) + 16px);
    right: 16px;
    left: auto;
    z-index: 1011;
    transition: opacity 0.3s;
}

/* 記念画像ポップアップ */
#button-container[data-state="finished"] {
    background: linear-gradient(135deg, #007777 0%, #00b3b3 100%);
    padding-top: 16px;
    padding-bottom: 16px;
    gap: 8px;
    border-top: none;
}

.popup-content {
    position: relative;
    background-color: var(--white-color);
    padding: 20px;
    border-radius: 10px;
    box-shadow: 0 2px 10px rgba(0, 0, 0, 0.2);
    text-align: center;
    max-width: 90%;
    margin: 20px auto;
    overflow-y: auto;
    max-height: 80vh;
}

#layout-choice-popup .popup-content {
    width: 320px;
}

#layout-choice-popup .popup-section {
    margin-bottom: 12px;
    text-align: left;
}

#layout-choice-popup .popup-section:first-of-type {
    margin-top: 0;
}

#layout-choice-popup .popup-section:last-of-type {
    margin-bottom: 0;
}

#layout-choice-popup .popup-section label {
    font-weight: bold;
    font-size: 0.9em;
    color: var(--text-secondary);
    margin-bottom: 8px;
    display: block;
}

.layout-icon-buttons {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(60px, 1fr));
    gap: 10px;
}

.layout-icon-btn {
    width: 100%;
    aspect-ratio: 1 / 1;
    padding: 8px;
    border: 2px solid var(--border-color);
    border-radius: var(--border-radius-sm);
    background-color: var(--component-bg);
    cursor: pointer;
    transition: all 0.2s ease;
}

.layout-icon-btn:hover {
    border-color: var(--primary-hover-color);
    background-color: #f5f5f5;
}

.layout-icon-btn.active {
    border-color: var(--primary-color);
    background-color: var(--primary-color);
}

.layout-icon-btn svg {
    width: 100%;
    height: 100%;
}

.layout-icon-btn svg rect {
    fill: var(--text-secondary);
    transition: fill 0.2s ease;
}

.layout-icon-btn.active svg rect {
    fill: var(--white-color);
}

#layout-preview-container {
    position: relative;
    width: 100%;
    aspect-ratio: 1.25 / 1;
    background-color: var(--body-bg);
    border-radius: var(--border-radius-sm);
    overflow: hidden;
    border: 1px solid var(--border-color);
}

#layout-preview-thumbnail {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    object-fit: cover;
}

#track-preview-image {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    object-fit: contain;
    padding: 12px;
    box-sizing: border-box;
    transition: all 0.3s ease-in-out;
}

/* レイアウト配置 */
#track-preview-image.layout-center { }
#track-preview-image.layout-top-left {
    top: 0; left: 0; transform: none; width: 50%; height: 50%; padding: 6px;
}
#track-preview-image.layout-top-center {
    top: 0; left: 50%; transform: translateX(-50%); width: 50%; height: 50%; padding: 6px;
}
#track-preview-image.layout-top-right {
    top: 0; right: 0; left: auto; transform: none; width: 50%; height: 50%; padding: 6px;
}

.background-change-buttons {
    display: flex;
    gap: 12px;
    justify-content: center;
    margin: 8px 0;
}

.background-change-buttons button,
.background-change-buttons button.popup-btn-secondary {
    flex: 1;
    padding: 14px 16px !important;
    font-size: 0.95em !important;
    font-weight: 600 !important;
    border: 2px solid var(--primary-color) !important;
    border-radius: 8px !important;
    background-color: var(--white-color) !important;
    color: var(--primary-color) !important;
    cursor: pointer;
    transition: all 0.2s ease;
    box-shadow: 0 2px 4px rgba(0, 0, 0, 0.1) !important;
    min-height: 48px;
    display: flex;
    align-items: center;
    justify-content: center;
    -webkit-tap-highlight-color: transparent;
}

.background-change-buttons button:hover,
.background-change-buttons button.popup-btn-secondary:hover {
    background-color: var(--primary-color) !important;
    color: var(--white-color) !important;
    box-shadow: 0 4px 8px rgba(0, 153, 153, 0.3) !important;
    transform: translateY(-1px);
}

.background-change-buttons button:active,
.background-change-buttons button.popup-btn-secondary:active {
    background-color: var(--primary-hover-color) !important;
    box-shadow: 0 2px 4px rgba(0, 153, 153, 0.2) !important;
    transform: translateY(0);
}

#export-color-picker {
    width: 100%;
    height: 44px;
    border: 1px solid var(--border-color);
    border-radius: var(--border-radius-sm);
    cursor: pointer;
    padding: 0;
}

#fab-edit-profile {
    display: none !important;
}

.top-control-button {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 48px;
    height: 48px;
    border-radius: 50%;
    border: none;
    cursor: pointer;
    box-shadow: var(--shadow-md);
    transition: background-color 0.2s ease, transform 0.2s ease;
    background-color: lightskyblue;
    color: white;
    font-size: 24px;
    font-weight: bold;
    line-height: 1;
}

.top-control-button:hover {
    background-color: #64B5F6;
    transform: scale(1.05);
}

.top-control-button:active {
    transform: scale(0.95);
}

.button-row-secondary {
    display: flex;
    flex-direction: row;
    gap: 12px;
}

.button-row-secondary > button {
    flex: 1;
}

#update-notification {
    position: fixed;
    bottom: calc(16px + env(safe-area-inset-bottom));
    left: 50%;
    transform: translateX(-50%) translateY(100px);
    background-color: #4A148C;
    color: white;
    padding: 16px 20px;
    border-radius: 28px;
    box-shadow: var(--shadow-md);
    z-index: 5000;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 12px;
    min-width: 280px;
    max-width: 90%;
    opacity: 0;
    visibility: hidden;
    transition: all 0.4s cubic-bezier(0.4, 0, 0.2, 1);
}

#update-notification:not(.hidden) {
    opacity: 1;
    visibility: visible;
    transform: translateX(-50%) translateY(0);
}

#update-notification p {
    margin: 0;
    font-weight: bold;
    font-size: 0.95em;
    text-align: center;
}

#update-notification .update-buttons {
    display: flex;
    gap: 10px;
    width: 100%;
    justify-content: center;
}

#update-notification button {
    padding: 10px 20px;
    border-radius: 20px;
    border: none;
    color: white;
    font-weight: bold;
    cursor: pointer;
    white-space: nowrap;
    transition: background-color 0.2s, transform 0.1s;
    flex: 1;
    min-width: 100px;
}

#update-notification #update-now-btn {
    background-color: #6A1B9A;
}

#update-notification #update-now-btn:hover {
    background-color: #7B1FA2;
    transform: scale(1.05);
}

#update-notification #update-now-btn:active {
    transform: scale(0.95);
}

#update-notification #update-later-btn {
    background-color: rgba(255, 255, 255, 0.2);
}

#update-notification #update-later-btn:hover {
    background-color: rgba(255, 255, 255, 0.3);
    transform: scale(1.05);
}

#update-notification #update-later-btn:active {
    transform: scale(0.95);
}

.fab-with-label {
    width: 72px;
    height: 72px;
    border-radius: 20px;
    flex-direction: column;
    justify-content: center;
    padding: 8px 4px;
    gap: 3px;
    box-sizing: border-box;
}

.fab-with-label svg {
    width: 30px;
    height: 30px;
}

.fab-with-label.secondary .fab-label {
    color: var(--text-primary);
}

.large-action-button.hidden {
    display: none;
}

#track-preview-compact-container {
    display: none !important;
}

#fab-container-rerouting-controls {
    background-color: rgba(0, 0, 0, 0.7);
    backdrop-filter: blur(8px);
    -webkit-backdrop-filter: blur(8px);
    width: 95%;
    max-width: 400px;
    padding: 0 10px;
    gap: 0;
}

#fab-container-rerouting-controls .button-group {
    display: flex;
    justify-content: space-around;
    align-items: flex-end;
    width: 100%;
    padding: 10px 0;
}

#fab-container-rerouting-controls .button-label {
    color: var(--white-color);
    text-shadow: 1px 1px 2px rgba(0,0,0,0.7);
}

#rerouting-confirm-btn { background-color: var(--success-color); }
#rerouting-confirm-btn:hover { background-color: var(--success-hover-color); }
#rerouting-next-btn { background-color: var(--primary-color); }
#rerouting-next-btn:hover { background-color: var(--primary-hover-color); }
#rerouting-cancel-btn { background-color: var(--danger-color); }
#rerouting-cancel-btn:hover { background-color: var(--danger-hover-color); }
#fab-container-rerouting-controls .button-wrapper button svg { color: var(--white-color); }

#my-courses-table {
    width: 100%;
    border-collapse: collapse;
}

#my-courses-table th,
#my-courses-table td {
    padding: 12px 15px;
    text-align: left;
    border-bottom: 1px solid var(--border-color);
}

#my-courses-table th {
    background-color: var(--body-bg);
    position: sticky;
    top: 0;
    font-size: 0.9em;
}

#my-courses-table tbody tr:hover {
    background-color: #f0f8ff;
}

#my-courses-table .my-course-name {
    font-weight: bold;
}

#my-courses-table .my-course-meta {
    font-size: 0.8em;
    color: var(--text-secondary);
}

.my-course-actions {
    display: grid;
    grid-template-columns: repeat(2, auto);
    gap: 6px;
    width: max-content;
    margin-left: auto;
}

.my-course-action-btn {
    padding: 6px 10px;
    font-size: 0.85em;
    font-weight: bold;
    border: none;
    border-radius: var(--border-radius-sm);
    cursor: pointer;
    transition: all 0.2s;
}

.my-course-action-btn.primary { background-color: var(--primary-color); color: white; }
.my-course-action-btn.primary:hover { background-color: var(--primary-hover-color); }
.my-course-action-btn.secondary { background-color: #e9ecef; color: var(--text-primary); }
.my-course-action-btn.secondary:hover { background-color: #dee2e6; }
.my-course-action-btn.danger { background-color: var(--danger-color); color: white; }
.my-course-action-btn.danger:hover { background-color: var(--danger-hover-color); }

body[data-app-state="plotting"] #fab-container-left {
    bottom: calc(180px + env(safe-area-inset-bottom));
}

body[data-app-state="plotting"] #fab-container-left > .fab:not(#changeMapStyleButton) {
    display: none;
}

.story-link-button {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 10px;
    padding: 14px 20px;
    margin-bottom: 20px;
    width: 100%;
    box-sizing: border-box;
    background: linear-gradient(135deg, var(--gold-color), #FFC107);
    color: var(--dark-purple-bg);
    border-radius: var(--border-radius-md);
    text-decoration: none;
    font-size: 1.1em;
    font-weight: 700;
    box-shadow: 0 4px 15px rgba(0, 0, 0, 0.2);
    transition: all 0.2s ease-in-out;
}

.story-link-button:hover {
    transform: translateY(-2px) scale(1.02);
    box-shadow: 0 6px 20px rgba(0, 0, 0, 0.25);
}

.story-link-button svg {
    width: 24px;
    height: 24px;
    stroke-width: 2.5;
    flex-shrink: 0;
}

.popup-section-divider {
    height: 1px;
    background-color: var(--border-color);
    margin: 0 -24px 20px -24px;
}

#create-course-choice-popup .popup-content h3 {
    margin-top: 0;
}

/* 完了後ボタンレイアウト (最終ブラッシュアップ) */
#button-container[data-state="finished"] {
    display: flex;
    flex-direction: row;
    flex-wrap: nowrap;
    justify-content: center;
    align-items: stretch;
    padding: 10px 12px;
    gap: 10px;
    background: linear-gradient(160deg, rgba(0, 30, 30, 0.6) 0%, rgba(0, 10, 10, 0.6) 100%);
    border-top: 1px solid rgba(255, 255, 255, 0.1);
    box-shadow: inset 0 1px 3px rgba(0, 0, 0, 0.3);
}

#exportCombinedButton {
    order: -1;
    flex: 1.8;
    min-width: 90px;
    background: linear-gradient(135deg, #00c9c9 0%, #00f2f2 100%);
    border: 1px solid rgba(255, 255, 255, 0.2);
    box-shadow: 0 4px 15px rgba(0, 242, 242, 0.6), 0 8px 20px rgba(0, 0, 0, 0.3);
    transition: all 0.3s ease-out;
}
#exportCombinedButton svg,
#exportCombinedButton span {
    color: #003333;
    text-shadow: 1px 1px 2px rgba(255, 255, 255, 0.2);
}
#exportCombinedButton:hover {
    transform: translateY(-5px) scale(1.02);
    box-shadow: 0 8px 25px rgba(0, 242, 242, 0.8), 0 12px 30px rgba(0, 0, 0, 0.4);
    background: linear-gradient(135deg, #00f2f2 0%, #00c9c9 100%);
}

#button-container[data-state="finished"] .large-action-button {
    flex: 1;
    min-width: 0;
    height: 55px;
    padding: 6px 2px;
    font-size: 10px;
    background: rgba(255, 255, 255, 0.05);
    border: 1px solid rgba(255, 255, 255, 0.1);
    box-shadow: 0 2px 5px rgba(0, 0, 0, 0.3);
    transition: all 0.2s ease-in-out;
    border-radius: var(--border-radius-md);
    display: flex;
    flex-direction: column;
    justify-content: center;
    align-items: center;
    gap: 4px;
    cursor: pointer;
}

#button-container[data-state="finished"] .large-action-button:not(#exportCombinedButton):hover {
    background-color: rgba(255, 255, 255, 0.12);
    transform: translateY(-2px);
    box-shadow: 0 4px 10px rgba(0, 0, 0, 0.4);
}

#button-container[data-state="finished"] .large-action-button svg {
    width: 26px;
    height: 26px;
    margin-bottom: 3px;
    color: #e0f7fa;
    text-shadow: 1px 1px 2px rgba(0, 0, 0, 0.5);
}
#button-container[data-state="finished"] .large-action-button span {
    color: #e0f7fa;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    width: 100%;
    text-align: center;
    font-weight: bold;
    line-height: 1.2;
    text-shadow: 1px 1px 2px rgba(0, 0, 0, 0.5);
}

#layout-preview-container.loading::after {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background-color: rgba(0, 0, 0, 0.5);
    z-index: 5;
    opacity: 1;
    visibility: visible;
    transition: opacity 0.2s, visibility 0.2s;
}

.spinner-local {
    position: absolute;
    top: 50%;
    left: 50%;
    width: 40px;
    height: 40px;
    margin-top: -20px;
    margin-left: -20px;
    border: 4px solid rgba(255, 255, 255, 0.3);
    border-top-color: #ffffff;
    border-radius: 50%;
    animation: spin 1s linear infinite;
    z-index: 10;
}

/* マイコース画面テーブル調整 */
#my-courses-table th,
#my-courses-table td {
    padding: 12px 15px;
    border-bottom: 1px solid var(--border-color);
    vertical-align: middle;
}

#my-courses-table th:first-child,
#my-courses-table td:first-child {
    text-align: left;
}

#my-courses-table .my-course-col-numeric {
    text-align: right;
    width: 1%;
    white-space: nowrap;
}

#my-courses-table th.my-course-col-actions {
    text-align: right;
}

#my-courses-table td.my-course-col-actions {
    display: flex;
    justify-content: flex-end;
}

.my-course-actions {
    display: grid;
    grid-template-columns: repeat(2, auto);
    gap: 6px;
}

/* 汎用確認ポップアップ */
#custom-confirm-popup .popup-content {
    width: 300px;
    max-width: 90%;
}

#custom-confirm-popup #custom-confirm-message {
    font-weight: normal;
    font-size: 1em;
    line-height: 1.6;
    margin-bottom: 24px;
    white-space: pre-wrap;
}

#custom-confirm-popup .popup-buttons {
    flex-direction: row;
    gap: 10px;
}

#custom-confirm-popup .popup-buttons button {
    flex: 1;
}

#custom-confirm-popup {
    z-index: 3001;
}

/* 軌跡修正UI 説明パネル */
#fab-container-rerouting-controls {
    flex-direction: column;
    align-items: center;   
    gap: 12px;
    /* 地図の許諾表示より上に表示するため、z-indexを設定 */
    z-index: 10 !important;
    position: relative;
}

.rerouting-explanation-box {
    background-color: rgba(255, 255, 255, 0.9);
    backdrop-filter: blur(5px);
    -webkit-backdrop-filter: blur(5px);
    color: var(--text-primary);
    padding: 12px 16px;
    border-radius: 12px;
    box-shadow: 0 2px 8px rgba(0,0,0,0.2);
    width: 100%;
    max-width: 380px;
    box-sizing: border-box;
    text-align: center;
    /* 地図の許諾表示より上に表示するため、z-indexを設定 */
    z-index: 10 !important;
    position: relative;
}

.rerouting-explanation-box h4 {
    margin: 0 0 8px 0;
    font-size: 1.1em;
    color: var(--primary-darkened) !important; /* ★白背景対策 */
}

.rerouting-explanation-box p {
    margin: 0;
    font-size: 0.85em;
    line-height: 1.6;
    color: var(--text-secondary);
}

.popup-actions {
    display: flex;
    justify-content: flex-end;
    gap: 10px;
    margin-top: 20px;
}

.popup-btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    padding: 10px 20px;
    border: none;
    border-radius: 8px;
    font-size: 16px;
    font-weight: bold;
    cursor: pointer;
    transition: background-color 0.2s, box-shadow 0.2s;
    -webkit-tap-highlight-color: transparent;
}

.popup-btn-icon {
    margin-right: 8px;
}

.popup-btn.primary {
    background-color: var(--primary-color, #007AFF);
    color: white;
}
.popup-btn.primary:hover {
    background-color: var(--primary-hover-color);
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.2); /* 影の色もニュートラルに */
}

.popup-btn.secondary {
    background-color: #f0f0f0;
    color: #333;
}
.popup-btn.secondary:hover {
    background-color: #e0e0e0;
}

.popup-content.help-content {
    display: flex;
    flex-direction: column;
    max-height: 85vh;
}

.scrollable-help-content {
    flex: 1;
    overflow-y: auto;
    padding: 0 15px;
    margin: 0 -15px;
}

.popup-footer {
    padding-top: 15px;
    text-align: center;
}

.user-manual-link {
    display: block;
    margin-bottom: 15px;
}

.mode-selection-group {
    margin: 12px 0;
}

.mode-selection-group-label {
    font-weight: bold;
    font-size: 0.9em;
    color: var(--text-secondary);
    margin-bottom: 8px;
    display: block;
    text-align: left;
}

.mode-selection-option input[type="radio"] {
    width: 20px;
    height: 20px;
    accent-color: var(--primary-color);
    flex-shrink: 0;
}

#add-to-home-popup {
    background-color: transparent;
    backdrop-filter: none;
    -webkit-backdrop-filter: none;
}

#web-ar-link-wrapper #web-ar-link {
    background-color: #6A1B9A;
}
#web-ar-link-wrapper #web-ar-link:hover {
    background-color: #4A148C;
}

#fab-load-course {
    background-color: var(--primary-color);
}

#fab-load-course:hover {
    background-color: var(--primary-hover-color);
}

#fab-course-list {
    display: none !important;
}

#layout-choice-popup .popup-content {
    display: flex;
    flex-direction: column;
    padding: 0;
    max-height: 90vh;
    overflow: hidden;
    width: 340px;
}

#layout-choice-popup .popup-content > p {
    margin: 0;
    padding: 16px;
    border-bottom: 1px solid var(--border-color);
    background-color: var(--white-color);
    flex-shrink: 0;
    font-size: 1.1em;
}

.popup-scroll-body {
    flex: 1;
    overflow-y: auto;
    padding: 20px;
    -webkit-overflow-scrolling: touch;
}

#layout-choice-popup .popup-buttons {
    margin: 0;
    padding: 12px 16px;
    border-top: 1px solid var(--border-color);
    background-color: var(--white-color);
    flex-shrink: 0;
    box-shadow: 0 -2px 10px rgba(0,0,0,0.05);
    gap: 10px;
}

@media (max-height: 600px) {
    #layout-choice-popup .popup-content {
        height: 95vh;
    }
    #layout-preview-container {
        max-height: 180px; 
        object-fit: contain;
    }
}

#lock-screen-overlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background-color: transparent;
    -webkit-backdrop-filter: none;
    backdrop-filter: none;
    z-index: 2147483647 !important;
    display: flex;
    flex-direction: column;
    justify-content: flex-end;
    align-items: center;
    color: white;
    padding-bottom: calc(30px + env(safe-area-inset-bottom)); 
    box-sizing: border-box;
    touch-action: none;
    transition: background-color 0.5s ease, backdrop-filter 0.5s ease;
}

#lock-screen-overlay p {
    order: 1; 
    font-size: 1.1em;
    font-weight: bold;
    text-shadow: 0 2px 4px rgba(0,0,0,0.7);
    margin: 0;
    margin-bottom: 5px; 
    padding: 8px 16px;
    background-color: rgba(0, 0, 0, 0.5);
    border-radius: 20px;
}

#lock-screen-overlay .lock-icon {
    order: 2; 
    margin-bottom: 0; 
    animation: pulse-lock 2s infinite;
    color: #FFD700; 
}

#lock-screen-overlay.low-power-blackout {
    background-color: #000000 !important;
    backdrop-filter: none !important;
    cursor: pointer;
}

#lock-screen-overlay.low-power-blackout > * {
    display: none !important;
}

#fab-tutorial {
    display: flex !important;
    align-items: center;
    justify-content: center;
    width: 40px;
    height: 40px;
    background: transparent;
    border: none;
    color: white;
    cursor: pointer;
    border-radius: 50%;
    transition: background-color 0.2s ease;
}

#fab-tutorial:hover {
    background-color: rgba(255, 255, 255, 0.15);
}

#fab-tutorial svg {
    width: 24px;
    height: 24px;
    stroke: currentColor;
    fill: none;
}

body.header-hidden #fab-tutorial {
    display: none !important;
}

body[data-app-state="initial"] #fab-tutorial {
    display: flex !important;
    visibility: visible !important;
    opacity: 1 !important;
    z-index: 9999;
}

.maplibregl-ctrl-bottom-right {
    right: 90px !important; 
    bottom: 2px !important;
    margin: 0 !important;
    z-index: 1000 !important;
    max-width: calc(100vw - 160px) !important;
}

.maplibregl-ctrl-attrib.maplibregl-compact {
    min-height: 24px !important;
    margin: 0 !important;
    background-color: rgba(255, 255, 255, 0.9) !important;
}

.maplibregl-ctrl-attrib-inner {
    white-space: normal !important;
    line-height: 1.2 !important;
    display: inline-block;
}

.custom-marker {
    width: 32px;
    height: 32px;
    background-color: #f78b27 !important; 
    border: 2px solid white;
    border-radius: 50% 50% 50% 0;
    transform: rotate(-45deg);
    display: flex;
    justify-content: center;
    align-items: center;
    cursor: pointer;
    box-shadow: 0 2px 4px rgba(0,0,0,0.3);
}

.marker-number {
    transform: rotate(45deg);
    color: white;
    font-weight: bold;
    font-size: 14px;
    pointer-events: none;
}

.custom-marker.collected {
    background-color: #888888 !important;
}

.popup-no {
    display: inline-block;
    background: #333;
    color: white;
    padding: 2px 6px;
    border-radius: 4px;
    font-size: 10px;
    font-weight: bold;
    margin-bottom: 4px;
}

/* ▼▼▼ テーマカラー変更時の文字色修正（追加分） ▼▼▼ */

/* 1. フッターメニューのボタン */
.footer-btn-wrapper button,
.footer-btn-wrapper a {
    color: var(--text-on-primary) !important; /* ★黒文字対応 */
}

/* 2. メインの操作ボタン（コース読込、作成など） */
#fab-create-toggle,
#fab-load-course,
#fab-spot-create-toggle,
#fab-reset {
    color: var(--text-on-primary) !important; /* ★黒文字対応 */
}

/* 3. ボタン内のアイコン（SVG）の色を文字色に合わせる */
/* これで文字が黒ならアイコンも黒になります */
.footer-btn-wrapper svg,
#fab-create-toggle svg,
#fab-load-course svg,
#fab-spot-create-toggle svg,
#fab-reset svg {
    stroke: currentColor !important; /* ★黒文字対応 */
    color: currentColor !important; /* ★黒文字対応 */
    fill: none; 
}

/* カメラボタンの例外処理（塗りつぶしタイプの場合） */
.footer-btn-wrapper #camera-btn svg {
    fill: currentColor !important; /* ★黒文字対応 */
    stroke: none !important;
}

/* ==========================================================================
   ▼▼▼ 最終調整・不具合修正まとめ（決定版 v2） ▼▼▼
   ========================================================================== */

/* --------------------------------------------------
   1. スポットポップアップのレイアウト修正
      (丸型・テキスト付き・中央寄せ・データ無し非表示)
   -------------------------------------------------- */

/* 不要な写真ボタンを完全に隠す */
#camera-btn-wrapper {
    display: none !important;
}

/* ボタンの親エリア（フッター）の設定 */
.message-footer {
    display: flex !important;
    justify-content: center !important; /* 中央寄せ */
    align-items: flex-start !important; /* 上揃え */
    gap: 15px !important; /* ボタン同士の間隔 */
    padding: 10px 0 !important;
    flex-wrap: wrap !important;
}

/* 各ボタンの入れ物（ラッパー）の設定 */
/* ★重要：display: flex を書かないことで、JSによる表示制御(display: none)を有効にします */
.footer-btn-wrapper,
#spot-url-link-wrapper,
#web-ar-link-wrapper,
#quiz-btn-wrapper,
#audio-replay-btn-wrapper {
    /* display: flex;  <-- 削除済み */
    flex-direction: column !important; /* 縦並び */
    justify-content: center !important;
    align-items: center !important;
    width: 60px !important; /* 幅を固定 */
    margin: 0 !important;
    padding: 0 !important;
}

/* 丸型ボタンの共通デザイン */
#spot-url-link,
#web-ar-link,
#quiz-btn,
#audio-replay-btn {
    width: 50px !important;
    height: 50px !important;
    border-radius: 50% !important;
    padding: 0 !important;
    margin: 0 0 4px 0 !important; /* 下にテキスト用の隙間 */
    font-size: 0 !important;
    display: flex !important;
    align-items: center;
    justify-content: center;
    border: none !important;
    color: #ffffff !important;
    box-shadow: 0 4px 8px rgba(0, 0, 0, 0.2) !important;
    text-decoration: none !important;
    transition: transform 0.2s, box-shadow 0.2s;
}

/* ホバーアクション */
#spot-url-link:hover,
#web-ar-link:hover,
#quiz-btn:hover,
#audio-replay-btn:hover {
    transform: translateY(-3px);
    box-shadow: 0 6px 12px rgba(0, 0, 0, 0.3) !important;
    filter: brightness(1.1);
}

/* アイコンのサイズ調整 */
#spot-url-link svg,
#web-ar-link svg,
#quiz-btn svg,
#audio-replay-btn svg {
    width: 24px !important;
    height: 24px !important;
    stroke: #ffffff !important;
    fill: none;
    margin: 0 !important;
}

/* ボタン下のテキスト（キャプション）設定 */
.footer-btn-caption {
    display: block !important;
    font-size: 10px !important;
    color: #333333 !important;
    text-align: center !important;
    font-weight: bold !important;
    line-height: 1.2 !important;
    white-space: nowrap !important;
}

/* 各ボタンのテキスト内容指定 */
#spot-url-link-wrapper .footer-btn-caption { font-size: 0 !important; }
#spot-url-link-wrapper .footer-btn-caption::after { content: "URL"; font-size: 10px !important; }

#web-ar-link-wrapper .footer-btn-caption { font-size: 0 !important; }
#web-ar-link-wrapper .footer-btn-caption::after { content: "AR"; font-size: 10px !important; }

#audio-replay-btn-wrapper .footer-btn-caption { font-size: 0 !important; }
#audio-replay-btn-wrapper .footer-btn-caption::after { content: "ガイド"; font-size: 10px !important; }

#quiz-btn-wrapper .footer-btn-caption { font-size: 0 !important; }
#quiz-btn-wrapper .footer-btn-caption::after { content: "クイズ"; font-size: 10px !important; }

/* 各ボタンの背景色 */
#spot-url-link { background-color: #1565C0 !important; } /* 青 */
#web-ar-link { background-color: #6A1B9A !important; }   /* 紫 */
#quiz-btn { background-color: #00695C !important; }      /* 緑 */
#audio-replay-btn { background-color: #C2185B !important; } /* ピンク */


/* --------------------------------------------------
   2. 重なり順（Z-Index）の整理
   -------------------------------------------------- */

/* (1) ★最前面：クイズポップアップ (スポット詳細より手前に表示) */
#quiz-modal {
    z-index: 9500 !important;
}

/* (2) 通常のポップアップ・オーバーレイ */
.popup-overlay,
#image-message-popup,     /* 古いIDも念のため残存 */
#image-message-container, /* ★正しいIDを追加 */
#completion-popup,
#goal-popup,
#export-choice-popup {
    z-index: 9000 !important;
}

/* (2-1) 完走証の情報パネルはその場限りなので、思い切りz-indexを上げる */
#finish-tutorial-popup {
    z-index: 10000 !important;
}

/* (3) 中間：地図の右下「i」マーク（Attribution） */
/* 軌跡修正の情報ボックスより下に配置するため、z-indexを0に変更 */
.maplibregl-ctrl-bottom-right,
.maplibregl-ctrl-attrib {
    z-index: 0 !important;
}

/* (4) その下：透過・年代切替スライダー（情報パネルより下に配置） */
#opacity-toggle-container,
#historical-map-switcher {
    z-index: 100 !important; /* 情報パネル(10000)より下に配置 */
}

/* (5) 最奥：画面上の操作ボタン群（FAB） */
#fab-container-left,
#fab-container-top-right,
.fab-container {
    z-index: 1100 !important;
}


/* --------------------------------------------------
   3. ボタン配色の強制設定（テーマカラー対策）
   -------------------------------------------------- */

/* --- A. 背景色が濃い「アクションボタン」 (文字・アイコンは常に白) --- */
/* 対象：開始、停止、AR、リセット、コース制作・読込、省エネ、軌跡修正など */
#fab-start, #fab-pause, #fab-resume, #fab-stop, #fab-stop-animation,
#fab-ar-camera, #fab-stamp-rally,
#fab-plotting-confirm, #fab-plotting-undo, #fab-plotting-cancel,
#fab-reset,
#fab-create-toggle, #fab-load-course, #fab-spot-create-toggle,
#fab-lock-screen, #fab-track-reload {
    color: #ffffff !important;
}

/* ボタン内のテキスト（ラベル）も白に強制 */
#fab-start .fab-label, #fab-pause .fab-label, #fab-resume .fab-label, #fab-stop .fab-label,
#fab-reset .fab-label, #fab-stamp-rally .fab-label,
#fab-create-toggle .fab-label, #fab-load-course .fab-label, #fab-spot-create-toggle .fab-label,
#fab-lock-screen .fab-label, #fab-track-reload .fab-label {
    color: #ffffff !important;
}

/* アイコンの線（stroke）も白に固定 */
#fab-start svg, #fab-pause svg, #fab-resume svg, #fab-stop svg, #fab-stop-animation svg,
#fab-ar-camera svg, #fab-stamp-rally svg,
#fab-plotting-confirm svg, #fab-plotting-undo svg, #fab-plotting-cancel svg,
#fab-reset svg,
#fab-create-toggle svg, #fab-load-course svg, #fab-spot-create-toggle svg,
#fab-lock-screen svg, #fab-track-reload svg {
    stroke: #ffffff !important;
    color: #ffffff !important;
	stroke-width: 3 !important;
    fill: none;
}
/* 塗りつぶしアイコンの例外 */
#camera-btn svg {
    fill: #ffffff !important;
    stroke: none !important;
}


/* --- B. 背景色が白/薄い「ユーティリティボタン」 (文字・アイコンは常に黒) --- */
/* 対象：左下の地図切替、右上の設定・ヘルプなど */
#fab-container-left button,
#fab-container-left .fab,
#fab-container-left .fab-label,
#fab-container-top-right button,
#fab-container-top-right .fab,
#fab-container-top-right .fab-label,
.fab.secondary:not(.active) {
    color: #333333 !important;
}

#fab-container-left svg,
#fab-container-top-right svg,
.fab.secondary:not(.active) svg {
    stroke: #333333 !important;
    color: #333333 !important;
}


/* --------------------------------------------------
   4. 個別のボタンデザイン調整
   -------------------------------------------------- */

/* リセットボタン：ブルーグレー */
#fab-reset {
    background-color: #546E7A !important;
    border: none !important;
}
#fab-reset:hover { background-color: #455A64 !important; }

/* コース制作・読込ボタン：インディゴ */
#fab-create-toggle,
#fab-load-course,
#fab-spot-create-toggle {
    background-color: #3949AB !important;
    border: none !important;
}
#fab-create-toggle:hover,
#fab-load-course:hover,
#fab-spot-create-toggle:hover {
    background-color: #283593 !important;
}

/* ARボタン：テキスト非表示（アイコンのみ） */
#fab-ar-camera .fab-label,
#fab-ar-camera span {
    display: none !important;
}

/* ▼▼▼ 稼働中（アクティブ）ボタンの配色固定（#009999 / 白） ▼▼▼ */
/* ナビ、方位、現在地追従、3D切替などがONの時は、テーマカラーに関係なくデフォルト色(#009999)にします */
#navi-mode-btn.active,
#orientation-btn.active,
#recenter-map-btn.active,
#pitch-toggle-btn.active {
    background-color: #009999 !important; /* デフォルトカラー固定 */
    border-color: #009999 !important;
    color: #ffffff !important; /* テキストは白 */
}

/* アイコンも白に固定 */
#navi-mode-btn.active svg,
#orientation-btn.active svg,
#recenter-map-btn.active svg,
#pitch-toggle-btn.active svg {
    stroke: #ffffff !important;
    color: #ffffff !important;
    fill: none; 
}

/* style.css (1475行目付近) */
/* 地図の許諾表示（クレジット）：ボタンと完全同期・修正版 */
.maplibregl-ctrl-attrib {
    position: fixed !important;
    right: 90px !important; 
    
    /* ▼ 修正：ボタン(FAB)の初期位置 40px に合わせる */
    bottom: calc(25px + env(safe-area-inset-bottom)) !important;
    
    /* ▼ 修正：ボタンと同じ 0.3秒のアニメーションを追加 */
    transition: bottom 0.3s ease-in-out !important;
    
    top: auto !important;
    left: auto !important;
    
    /* ▼ 修正：z-indexを下げてパネル(9000)の下に隠れるようにしつつ、表示は維持 */
    z-index: 0 !important; 
    
    display: flex !important;
    flex-direction: row !important;
    align-items: flex-end !important;
    min-height: 14px !important; 
    padding: 0 8px 0 8px !important;
    background-color: rgba(255, 255, 255, 0.8) !important;
    border-radius: 10px;
    font-size: 10px !important;
    line-height: 1.1 !important;
    color: #000 !important;
    visibility: visible !important;
    opacity: 1 !important;
}

/* ★修正：お絵かき終了時、ボタン(FAB)と同じ高さまで上げる */
/* !important を付けることで、確実に位置を上書きします */
.maplibregl-ctrl-attrib.is-finished {
    bottom: calc(100px + env(safe-area-inset-bottom)) !important;
}

/* 「i」ボタンアイコンは消す */
.maplibregl-ctrl-attrib-button {
    display: none !important;
}

/* リンクと文字の表示調整 */
.maplibregl-ctrl-attrib a, 
.maplibregl-ctrl-attrib-inner {
    color: #000 !important;
    text-decoration: none;
    font-weight: bold;
    display: inline-block !important;
    vertical-align: bottom !important; /* 文字自体をベースラインに合わせる */
    line-height: 1 !important;
}

/* 現在地マーカーの重なり順 */
.maplibregl-marker {
    z-index: 900 !important; /* 許諾表示(1000)より奥に配置 */
}

/* ==================================================
   【位置関係維持版】終了時の同期アニメーション
   ================================================== */

/* 1. 共通設定（アニメーションの同期） */
#fab-container-left,
.fab-container {
    position: fixed !important;
    transition: bottom 0.3s ease-in-out !important;
    z-index: 1100 !important;
}

/* 古地図切替ボタンやスライダー、地図の許諾表示は情報パネルより下に配置 */
#historical-map-switcher,
#opacity-toggle-container,
.maplibregl-ctrl-attrib {
    position: fixed !important;
    transition: bottom 0.3s ease-in-out !important;
    z-index: 100 !important; /* 情報パネル(10000)より下に配置 */
}

/* 2. 左右ボタン・年代スライダ（初期: 40px → 終了時: +80px で 120px） */
#fab-container-left,
.fab-container,
#historical-map-switcher {
    bottom: calc(40px + env(safe-area-inset-bottom)) !important;
}
#fab-container-left.is-finished,
.fab-container.is-finished,
#historical-map-switcher.is-finished {
    bottom: calc(120px + env(safe-area-inset-bottom)) !important;
}

/* 3. 透過ボタン（初期: 100px → 終了時: +80px で 180px） */
#opacity-toggle-container {
    bottom: calc(100px + env(safe-area-inset-bottom)) !important;
}
#opacity-toggle-container.is-finished {
    bottom: calc(180px + env(safe-area-inset-bottom)) !important;
}

/* 4. 地図許諾（初期: 25px → 終了時: +80px で 105px） */
.maplibregl-ctrl-attrib {
    bottom: calc(25px + env(safe-area-inset-bottom)) !important;
    z-index: 1 !important; 
    right: 90px !important;
    top: auto !important;
    left: auto !important;
    display: flex !important;
}
.maplibregl-ctrl-attrib.is-finished {
    bottom: calc(105px + env(safe-area-inset-bottom)) !important;
}