/* ============================================================
   AR のぼり旗メーカー - style.css
   デザインシステム: uma-new-era-title / uma-ouen-baken 準拠
   ============================================================ */

/* ── CSS 変数（デザインシステム定義） ── */
:root {
    --primary-color: #2e7d32;
    --primary-hover: #1b5e20;
    --primary-light: #e8f5e9;
    --primary-border: #a5d6a7;
    --bg-color: #f4f6f8;
    --card-bg: #ffffff;
    --text-color: #333333;
    --text-main: #222222;
    --text-muted: #666666;
    --border-color: #cccccc;
    --border-light: #e0e0e0;
    --radius: 12px;
    --radius-small: 8px;
    --shadow: 0 4px 12px rgba(0, 0, 0, 0.06);
    --shadow-soft: 0 4px 16px rgba(0, 0, 0, 0.08);
    --transition: all 0.2s ease;
    --danger-color: #d32f2f;
    --danger-light: #ffebee;
    --danger-border: #ffcdd2;
}

*,
*::before,
*::after {
    box-sizing: border-box;
    font-family: 'Noto Sans JP', -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
}

button,
input,
select,
textarea,
optgroup {
    font-family: 'Noto Sans JP', -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
}

html,
body {
    margin: 0;
    padding: 0;
    width: 100%;
    height: 100%;
    font-family: 'Noto Sans JP', -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
    font-feature-settings: "palt";
    -webkit-font-feature-settings: "palt";
    color: var(--text-main);
    background: linear-gradient(135deg, #e8f5e9 0%, #f1f8e9 100%);
    line-height: 1.6;
    -webkit-font-smoothing: antialiased;
    touch-action: manipulation;
}

/* ============================================================
   スタート画面 (案内・利用設定)
   ============================================================ */

.start-screen-container {
    min-height: 100vh;
    padding: 24px 16px 40px 16px;
    background: transparent;
    overflow-y: auto;
}

.container {
    max-width: 900px;
    margin: 0 auto;
}

/* ヘッダー・メタ情報 */
.header-meta {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 12px;
    font-size: 14px;
}

.version-group {
    display: flex;
    align-items: center;
    gap: 8px;
}

.version-badge {
    background: var(--primary-color);
    color: #fff;
    font-size: 12px;
    font-weight: 700;
    padding: 2px 8px;
    border-radius: 12px;
}

.changelog-link,
.credit-link {
    color: var(--text-muted);
    text-decoration: none;
    transition: color 0.2s;
    font-size: 14px;
}

.changelog-link:hover,
.credit-link:hover {
    color: var(--primary-color);
}

.credit-link strong {
    color: var(--text-main);
    text-decoration: underline;
}

/* タイトルエリア */
.main-title {
    font-size: 26px;
    font-weight: 900;
    color: var(--primary-color);
    text-align: center;
    line-height: 1.3;
    margin-bottom: 2px;
}

.sub-title {
    font-size: 16px;
    font-weight: 700;
    color: var(--text-main);
}

.eng-title {
    font-size: 11px;
    font-weight: 700;
    letter-spacing: 2px;
    color: var(--text-muted);
    text-align: center;
    margin-bottom: 16px;
    text-transform: uppercase;
}

/* ツール間リンク */
.tool-links {
    display: flex;
    justify-content: center;
    flex-wrap: wrap;
    gap: 8px;
    margin-bottom: 20px;
}

.tool-link {
    display: inline-flex;
    align-items: center;
    gap: 4px;
    font-size: 12px;
    color: var(--primary-color);
    background: var(--primary-light);
    border: 1px solid var(--primary-border);
    padding: 4px 10px;
    border-radius: 16px;
    text-decoration: none;
    font-weight: 700;
    transition: all 0.2s;
}

.tool-link:hover {
    background: var(--primary-color);
    color: #fff;
}

.tool-link-subtle {
    display: inline-flex;
    align-items: center;
    gap: 4px;
    font-size: 12px;
    color: var(--text-muted);
    background: transparent;
    border: none;
    padding: 4px 8px;
    border-radius: 4px;
    text-decoration: none;
    font-weight: 600;
    transition: all 0.2s;
}

.tool-link-subtle svg {
    opacity: 0.7;
    transition: opacity 0.2s;
}

.tool-link-subtle:hover {
    color: var(--text-color);
    text-decoration: underline;
    background: rgba(0, 0, 0, 0.04);
}

.tool-link-subtle:hover svg {
    opacity: 1;
}

/* カード共通レイアウト */
.card {
    background: var(--card-bg);
    border-radius: var(--radius);
    padding: 24px 20px;
    margin-bottom: 20px;
    box-shadow: var(--shadow);
    border: 1px solid var(--border-light);
}

.card-title {
    font-size: 1.05rem;
    font-weight: 700;
    margin-top: 0;
    margin-bottom: 18px;
    color: #222222;
    display: flex;
    align-items: center;
    gap: 8px;
    border-bottom: 2px solid #e0e0e0;
    padding-bottom: 8px;
}

.card-title svg {
    width: 20px;
    height: 20px;
    stroke: var(--primary-color);
    flex-shrink: 0;
}

/* ガイドステップリスト */
.guide-steps {
    display: flex;
    flex-direction: column;
    gap: 16px;
    margin-bottom: 22px;
}

.guide-step-item {
    display: flex;
    align-items: flex-start;
    gap: 14px;
}

.guide-step-num {
    width: 28px;
    height: 28px;
    color: var(--primary-color);
    font-weight: 600;
    font-size: 28px;
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
    margin-top: 2px;
}

.guide-step-text strong {
    display: block;
    font-size: 0.95rem;
    color: var(--text-main);
    margin-bottom: 2px;
}

.guide-step-text p {
    margin: 0;
    font-size: 0.85rem;
    color: var(--text-muted);
    line-height: 1.5;
}

/* プライバシーノート */
.dropzone-privacy-note {
    display: flex;
    align-items: center;
    gap: 8px;
    font-size: 0.8rem;
    color: var(--text-muted);
    background: #fafafa;
    border: 1px solid var(--border-light);
    border-radius: var(--radius-small);
    padding: 10px 14px;
    margin-bottom: 10px;
    line-height: 1.5;
}

.dropzone-privacy-note svg {
    stroke: var(--primary-color);
    flex-shrink: 0;
}

/* アプリ内ブラウザ等の注意ノート */
.dropzone-warning-note {
    display: flex;
    align-items: flex-start;
    gap: 8px;
    font-size: 0.8rem;
    color: #92400e;
    background: #fffbeb;
    border: 1px solid #fef3c7;
    border-radius: var(--radius-small);
    padding: 10px 14px;
    margin-bottom: 24px;
    line-height: 1.5;
}

.dropzone-warning-note svg {
    stroke: #d97706;
    flex-shrink: 0;
    margin-top: 2px;
}

/* ボタン共通 */
.btn-group {
    display: flex;
    justify-content: center;
}

.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    font-family: inherit;
    font-weight: 700;
    border-radius: 8px;
    border: none;
    cursor: pointer;
    transition: var(--transition);
    text-decoration: none;
    -webkit-tap-highlight-color: transparent;
}

.btn-primary {
    background-color: var(--primary-color);
    color: #ffffff;
    padding: 12px 24px;
    font-size: 1rem;
    box-shadow: 0 2px 6px rgba(46, 125, 50, 0.2);
}

.btn-primary:hover:not(:disabled) {
    background-color: var(--primary-hover);
    box-shadow: 0 4px 12px rgba(46, 125, 50, 0.3);
}

.btn-primary:active:not(:disabled) {
    transform: translateY(1px);
}

@keyframes spin {
    from {
        transform: rotate(0deg);
    }

    to {
        transform: rotate(360deg);
    }
}

.btn-primary:disabled {
    background-color: #bdbdbd;
    cursor: not-allowed;
    box-shadow: none;
}

.btn-large {
    width: 100%;
    max-width: 360px;
    padding: 14px 28px;
    font-size: 1.05rem;
}

.btn-danger {
    background-color: var(--danger-light);
    color: var(--danger-color);
    border: 1px solid var(--danger-border);
    padding: 6px 12px;
    font-size: 0.8rem;
}

.btn-danger:hover:not(:disabled) {
    background-color: var(--danger-color);
    color: #ffffff;
}

.btn-small {
    padding: 4px 10px;
    font-size: 0.8rem;
    border-radius: 6px;
}

/* フッター */
footer {
    text-align: center;
    font-size: 0.75rem;
    color: var(--text-muted);
    margin-top: 30px;
    line-height: 1.6;
}

footer p {
    margin: 4px 0;
}

/* ============================================================
   AR ビュー
   ============================================================ */

.ar-view {
    position: fixed;
    inset: 0;
    width: 100%;
    height: 100%;
    overflow: hidden;
    background-color: #000000;
}

/* プレビュー画面ビューポート */
.camera-viewport {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: -160px;
    width: 100%;
    height: calc(100% + 160px);
    overflow: hidden;
    transition: transform 0.28s cubic-bezier(0.16, 1, 0.3, 1);
    transform: translateY(var(--shift-y, 0px));
    z-index: 1;
}

/* 最背面カメラ映像 */
.camera-video {
    position: absolute;
    inset: 0;
    width: 100%;
    height: 100%;
    object-fit: cover;
    z-index: 1;
    transition: transform 0.25s cubic-bezier(0.4, 0, 0.2, 1);
}

.camera-video.zoomed-2x {
    transform: scale(2);
    transform-origin: center center;
}

.camera-video.zoomed-3x {
    transform: scale(3);
    transform-origin: center center;
}

/* 手前 WebGL Canvas */
.ar-canvas {
    position: absolute;
    inset: 0;
    width: 100%;
    height: 100%;
    z-index: 2;
    touch-action: none;
}

/* 画面下部中央コントロール (トーチ / 倍率 / 旗サイズ) */
.ar-bottom-controls {
    position: fixed;
    bottom: 128px;
    left: 0;
    right: 0;
    width: 100%;
    z-index: 10;
    display: grid;
    grid-template-columns: 1fr auto 1fr;
    align-items: center;
    padding: 0 16px;
    padding-left: calc(env(safe-area-inset-left, 0px) + 16px);
    padding-right: calc(env(safe-area-inset-right, 0px) + 16px);
    box-sizing: border-box;
    pointer-events: none;
    transition: opacity 0.25s cubic-bezier(0.16, 1, 0.3, 1), transform 0.25s cubic-bezier(0.16, 1, 0.3, 1), visibility 0.25s;
}

.ar-bottom-controls.controls-hidden {
    opacity: 0;
    visibility: hidden;
    pointer-events: none;
    transform: translateY(8px);
}

.bottom-controls-left,
.bottom-controls-center,
.bottom-controls-right {
    display: flex;
    align-items: center;
    pointer-events: auto;
}

.bottom-controls-left {
    justify-content: flex-start;
    gap: 8px;
}

.bottom-controls-center {
    justify-content: center;
}

.bottom-controls-right {
    justify-content: flex-end;
}

.btn-bottom-control {
    width: 44px;
    height: 44px;
    border-radius: 50%;
    background: rgba(0, 0, 0, 0.45);
    backdrop-filter: blur(8px);
    -webkit-backdrop-filter: blur(8px);
    border: 1.5px solid rgba(255, 255, 255, 0.35);
    color: #ffffff;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.3);
    transition: var(--transition);
    -webkit-tap-highlight-color: transparent;
    padding: 0;
}

.btn-bottom-control:hover:not(:disabled) {
    background: rgba(0, 0, 0, 0.65);
    border-color: rgba(255, 255, 255, 0.6);
}

.btn-bottom-control:active:not(:disabled) {
    transform: scale(0.92);
}

.btn-bottom-control:disabled {
    opacity: 0.35;
    cursor: not-allowed;
    pointer-events: none;
}

/* トーチ (ライト) ボタン発光時 */
.btn-torch.active {
    background: rgba(255, 204, 0, 0.4);
    border-color: #ffcc00;
    color: #ffdd44;
    box-shadow: 0 0 14px rgba(255, 204, 0, 0.6);
}

/* 旗サイズ調整ボタングループ ([-] 旗X [+]) */
.flag-scale-group {
    display: inline-flex;
    align-items: center;
    background: rgba(0, 0, 0, 0.45);
    backdrop-filter: blur(8px);
    -webkit-backdrop-filter: blur(8px);
    border: 1.5px solid rgba(255, 255, 255, 0.35);
    border-radius: 22px;
    height: 44px;
    padding: 0 4px;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.3);
    box-sizing: border-box;
    pointer-events: auto;
    user-select: none;
    -webkit-user-select: none;
    transition: var(--transition);
}

.flag-scale-group.disabled {
    opacity: 0.35;
    pointer-events: none;
}

.btn-scale-step {
    width: 34px;
    height: 34px;
    border-radius: 50%;
    background: transparent;
    border: none;
    color: #ffffff;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    padding: 0;
    transition: var(--transition);
    -webkit-tap-highlight-color: transparent;
}

.btn-scale-step:hover:not(:disabled) {
    background: rgba(255, 255, 255, 0.2);
}

.btn-scale-step:active:not(:disabled) {
    transform: scale(0.9);
    background: rgba(255, 255, 255, 0.3);
}

.btn-scale-step:disabled {
    opacity: 0.3;
    cursor: not-allowed;
    pointer-events: none;
}

.flag-scale-label {
    min-width: 34px;
    padding: 0 4px;
    text-align: center;
    font-size: 0.8rem;
    font-weight: 700;
    color: #ffffff;
    white-space: nowrap;
    letter-spacing: 0.5px;
}

.btn-zoom {
    font-size: 0.85rem;
    font-weight: 900;
    letter-spacing: 0.5px;
}

/* ============================================================
   コントロールパネル (下部オーバーレイ)
   ============================================================ */

.control-panel {
    position: fixed;
    bottom: 0;
    left: 0;
    right: 0;
    z-index: 100;
    background: rgba(255, 255, 255, 0.96);
    border-top: 1px solid var(--border-color);
    box-shadow: 0 -4px 20px rgba(0, 0, 0, 0.12);
    border-radius: 16px 16px 0 0;
    transition: transform 0.3s cubic-bezier(0.16, 1, 0.3, 1), opacity 0.25s ease;
    padding-bottom: env(safe-area-inset-bottom, 0px);
    transform: translateY(0);
    opacity: 1;
}

.control-panel.panel-hidden {
    transform: translateY(105%) !important;
    opacity: 0 !important;
    pointer-events: none !important;
}

/* パネルハンドル（開閉ボタン） */
.panel-handle {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 6px;
    padding: 8px 0;
    cursor: pointer;
    -webkit-tap-highlight-color: transparent;
    border-bottom: 1px solid var(--border-light);
    background: #fafafa;
    border-radius: 16px 16px 0 0;
}

.handle-text {
    font-size: 0.75rem;
    font-weight: 700;
    color: var(--text-muted);
}

.handle-chevron {
    transition: transform 0.2s ease;
    flex-shrink: 0;
}

.control-panel.expanded .handle-chevron {
    transform: rotate(180deg);
}

/* 常時表示バー */
.panel-main-actions {
    display: grid;
    grid-template-columns: 1fr auto 1fr;
    align-items: center;
    padding: 8px 16px 10px 16px;
    max-width: 600px;
    margin: 0 auto;
    gap: 8px;
}

.panel-action-left {
    display: flex;
    justify-content: flex-start;
}

.panel-action-center {
    display: flex;
    justify-content: center;
}

.panel-action-right {
    display: flex;
    justify-content: flex-end;
}

/* フォトライブラリボタン */
.btn-gallery {
    background: #ffffff;
    border: 1px solid var(--border-color);
    color: var(--text-main);
    padding: 8px 12px;
    font-size: 0.8rem;
    border-radius: 20px;
    display: inline-flex;
    align-items: center;
    gap: 6px;
    position: relative;
    box-shadow: 0 1px 4px rgba(0, 0, 0, 0.08);
}

.btn-gallery:hover {
    background: var(--bg-color);
}

.gallery-badge {
    background: var(--primary-color);
    color: #ffffff;
    font-size: 0.7rem;
    font-weight: 900;
    min-width: 18px;
    height: 18px;
    padding: 0 5px;
    border-radius: 9px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    line-height: 1;
    transition: background-color 0.2s;
}

.gallery-badge.badge-max {
    background: var(--danger-color);
}

/* 旗追加ボタン */
.btn-action {
    padding: 8px 12px;
    font-size: 0.85rem;
    border-radius: 20px;
    display: inline-flex;
    align-items: center;
    gap: 6px;
}

.flag-count-pill {
    background: rgba(255, 255, 255, 0.25);
    color: #ffffff;
    font-size: 0.7rem;
    font-weight: 900;
    padding: 2px 6px;
    border-radius: 10px;
    margin-left: 2px;
    transition: background-color 0.2s;
}

.flag-count-pill.badge-max {
    background: var(--danger-color);
}

/* シャッターボタン (中央) */
.btn-shutter {
    position: relative;
    width: 54px;
    height: 54px;
    border-radius: 50%;
    background-color: #ffffff;
    border: 3px solid var(--primary-color);
    color: var(--primary-color);
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 0;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.15);
    flex-shrink: 0;
    transition: var(--transition);
}

.btn-shutter svg {
    transition: opacity 0.2s, transform 0.2s;
}

.btn-shutter:hover:not(:disabled) {
    background-color: var(--primary-light);
}

.btn-shutter:active:not(:disabled) {
    transform: scale(0.92);
    background-color: var(--primary-color);
    color: #ffffff;
}

/* 撮影中 (クールダウン中) */
.btn-shutter.capturing {
    background-color: rgba(255, 255, 255, 0.55);
    border-color: rgba(46, 125, 50, 0.35);
    box-shadow: 0 1px 4px rgba(0, 0, 0, 0.08);
    cursor: not-allowed;
    pointer-events: none;
}

.btn-shutter.capturing svg {
    opacity: 0;
    transform: scale(0.65);
}

.btn-shutter.capturing::after {
    content: '';
    position: absolute;
    width: 26px;
    height: 26px;
    border: 3px solid #e0e0e0;
    border-top-color: var(--primary-color);
    border-radius: 50%;
    animation: shutter-spin 0.8s linear infinite;
    opacity: 1;
}

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

.btn-shutter:disabled:not(.capturing) {
    opacity: 0.35;
    background-color: rgba(255, 255, 255, 0.5);
    border-color: rgba(46, 125, 50, 0.3);
    cursor: not-allowed;
    pointer-events: none;
    box-shadow: none;
}

/* 旗移動・拡縮中の情報表示バッジ */
.flag-transform-info {
    position: fixed;
    bottom: 192px;
    left: 50%;
    transform: translateX(-50%);
    background: rgba(0, 0, 0, 0.75);
    backdrop-filter: blur(8px);
    -webkit-backdrop-filter: blur(8px);
    border: 1px solid rgba(255, 255, 255, 0.2);
    color: #ffffff;
    padding: 6px 14px;
    border-radius: 20px;
    font-size: 0.75rem;
    font-weight: 700;
    letter-spacing: 0.3px;
    z-index: 100;
    pointer-events: none;
    box-shadow: 0 4px 14px rgba(0, 0, 0, 0.35);
    transition: opacity 0.2s ease, transform 0.2s ease;
    white-space: nowrap;
}

/* ============================================================
   モーダル (フォトライブラリ & シェア)
   ============================================================ */

.modal-overlay {
    position: fixed;
    inset: 0;
    background: rgba(0, 0, 0, 0.65);
    backdrop-filter: blur(4px);
    -webkit-backdrop-filter: blur(4px);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 10000;
    padding: 16px;
    animation: modal-fade-in 0.2s ease;
}

@keyframes modal-fade-in {
    from {
        opacity: 0;
    }

    to {
        opacity: 1;
    }
}

.modal-content {
    background: #ffffff;
    border-radius: var(--radius);
    width: 100%;
    max-width: 460px;
    padding: 16px;
    box-shadow: 0 10px 30px rgba(0, 0, 0, 0.25);
    display: flex;
    flex-direction: column;
    align-items: center;
    text-align: center;
    max-height: calc(100vh - 32px);
    max-height: calc(100svh - 32px);
    overflow: hidden;
    box-sizing: border-box;
}

.modal-title {
    font-size: 1.1rem;
    font-weight: 700;
    margin: 0 0 4px 0;
    color: var(--primary-color);
    flex-shrink: 0;
}

.modal-desc {
    font-size: 0.75rem;
    color: var(--text-muted);
    margin-bottom: 8px;
    line-height: 1.4;
    flex-shrink: 0;
}

/* 案A: フォトライブラリ モーダル専用スタイル */
.modal-gallery-content {
    max-width: 420px;
    padding: 14px 16px 16px 16px;
}

.modal-gallery-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    width: 100%;
    margin-bottom: 10px;
    padding-bottom: 8px;
    border-bottom: 1px solid #f0f0f0;
    flex-shrink: 0;
}

.modal-gallery-title-group {
    display: flex;
    align-items: center;
    gap: 8px;
}

.modal-gallery-title-group .modal-title {
    font-size: 1.05rem;
    font-weight: 700;
    color: #1b1b1b;
    margin: 0;
}

.modal-gallery-badge {
    background: var(--primary-light);
    color: var(--primary-color);
    font-size: 0.72rem;
    font-weight: 700;
    padding: 2px 8px;
    border-radius: 10px;
}

.btn-modal-close {
    background: #f4f5f7;
    border: none;
    width: 30px;
    height: 30px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    color: #666;
    cursor: pointer;
    transition: var(--transition);
    -webkit-tap-highlight-color: transparent;
}

.btn-modal-close:hover {
    background: #e2e5e9;
    color: #111;
}

.gallery-empty-state {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    padding: 30px 10px;
    color: var(--text-muted);
    font-size: 0.85rem;
    line-height: 1.6;
}

.gallery-empty-state svg {
    margin-bottom: 12px;
}

.gallery-content-area {
    width: 100%;
    display: flex;
    flex-direction: column;
    align-items: center;
    flex: 1 1 auto;
    min-height: 0;
    overflow: hidden;
}

/* サムネイル一覧 (横スクロール) */
.gallery-thumbnails-strip {
    display: flex;
    gap: 6px;
    overflow-x: auto;
    width: 100%;
    padding: 2px 2px 6px 2px;
    margin-bottom: 8px;
    -webkit-overflow-scrolling: touch;
    flex-shrink: 0;
}

.gallery-thumbnails-strip::-webkit-scrollbar {
    height: 4px;
}

.gallery-thumbnails-strip::-webkit-scrollbar-thumb {
    background: #cccccc;
    border-radius: 2px;
}

.gallery-thumb {
    width: 44px;
    height: 44px;
    border-radius: 6px;
    object-fit: cover;
    border: 2px solid transparent;
    cursor: pointer;
    flex-shrink: 0;
    transition: var(--transition);
    opacity: 0.65;
}

.gallery-thumb.active {
    border-color: var(--primary-color);
    opacity: 1;
    box-shadow: 0 0 0 2px var(--primary-light);
}

.modal-image-wrapper {
    position: relative;
    width: 100%;
    background: #f8f9fa;
    border: 1px solid #eef0f2;
    border-radius: 10px;
    overflow: hidden;
    margin-bottom: 8px;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.08);
    display: flex;
    justify-content: center;
    align-items: center;
    flex: 1 1 auto;
    min-height: 140px;
    max-height: 44svh;
}

.modal-image-wrapper img {
    max-width: 100%;
    max-height: 44svh;
    height: 100%;
    display: block;
    object-fit: contain;
}

.modal-image-wrapper .btn-image-delete {
    position: absolute;
    top: 8px;
    right: 8px;
    background: rgba(255, 255, 255, 0.92);
    border: 1px solid #ffcdd2;
    color: #d32f2f;
    width: 32px;
    height: 32px;
    border-radius: 6px;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    box-shadow: 0 2px 6px rgba(0, 0, 0, 0.1);
    transition: var(--transition);
    z-index: 5;
    padding: 0;
    -webkit-tap-highlight-color: transparent;
}

.modal-image-wrapper .btn-image-delete:hover {
    background: #ffebee;
}

/* 案内・注意書きバー */
.modal-notice-box {
    background: #f9fbf9;
    border: 1px solid #e1efe2;
    border-radius: 6px;
    padding: 7px 10px;
    font-size: 0.72rem;
    color: #4a5568;
    line-height: 1.4;
    margin-bottom: 10px;
    display: flex;
    align-items: center;
    gap: 6px;
    text-align: left;
    width: 100%;
    flex-shrink: 0;
}

.modal-notice-box svg {
    color: var(--primary-color);
    stroke: var(--primary-color);
    flex-shrink: 0;
}

.modal-actions {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 10px;
    width: 100%;
    flex-shrink: 0;
}

.modal-actions .btn {
    width: 100%;
    font-size: 0.88rem;
    padding: 10px 14px;
    box-sizing: border-box;
}

.btn-twitter {
    background: #000000;
    color: #ffffff;
    border: 1px solid rgba(255, 255, 255, 0.15);
    text-decoration: none;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    font-weight: 700;
    border-radius: 8px;
    transition: var(--transition);
    cursor: pointer;
    -webkit-tap-highlight-color: transparent;
}

.btn-twitter:hover {
    background: #222222;
    color: #ffffff;
    transform: translateY(-1px);
}

.btn-twitter:active {
    transform: scale(0.98);
}

.modal-actions-secondary {
    margin-top: 8px;
    width: 100%;
    flex-shrink: 0;
}

.btn-secondary {
    background: #f5f5f5;
    color: #333333;
    border: 1px solid #cccccc;
    padding: 10px 20px;
    font-size: 0.9rem;
}

.btn-secondary:hover {
    background: #e0e0e0;
}

/* 展開エリア (ダッシュボード形式) */
.panel-expanded {
    max-height: 0;
    opacity: 0;
    overflow: hidden;
    padding: 0 16px;
    max-width: 600px;
    margin: 0 auto;
    transition: max-height 0.32s cubic-bezier(0.2, 0.8, 0.2, 1), opacity 0.26s ease, padding 0.32s ease;
}

.control-panel.expanded .panel-expanded {
    max-height: 62vh;
    max-height: 62svh;
    opacity: 1;
    padding: 12px 16px 16px 16px;
    overflow-y: auto;
    -webkit-overflow-scrolling: touch;
}

.dashboard-section {
    margin-bottom: 14px;
}

.dashboard-section-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    min-height: 28px;
    margin-bottom: 8px;
    padding: 0 2px;
}

.dashboard-section-title-group {
    display: flex;
    align-items: center;
    gap: 8px;
}

.dashboard-section-title {
    font-size: 0.8rem;
    font-weight: 700;
    color: var(--text-muted);
    margin: 0;
    display: flex;
    align-items: center;
}

/* 旗切替ボタン */
.btn-switch-flag {
    background-color: #f5f5f5;
    color: var(--text-muted);
    border: 1px solid var(--border-light);
    font-weight: 700;
}

.btn-switch-flag:hover:not(:disabled) {
    background-color: var(--primary-light);
    border-color: var(--primary-color);
    color: var(--primary-color);
}

.btn-switch-flag:active:not(:disabled) {
    transform: scale(0.92);
}

.btn-switch-flag:disabled {
    opacity: 0.35;
    cursor: not-allowed;
    pointer-events: none;
}

/* リセットボタン */
.btn-reset {
    background-color: #f5f5f5;
    color: var(--text-muted);
    border: 1px solid var(--border-light);
}

.btn-reset:hover:not(:disabled) {
    background-color: var(--primary-light);
    border-color: var(--primary-color);
    color: var(--primary-color);
}

.btn-reset:active:not(:disabled) {
    transform: scale(0.92);
}

.dashboard-grid {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 8px;
}

/* ダッシュボードタイル */
.dashboard-tile {
    background: #ffffff;
    border: 1px solid var(--border-light);
    border-radius: var(--radius-small);
    padding: 10px 6px;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    text-align: center;
    cursor: pointer;
    transition: var(--transition);
    box-shadow: 0 1px 4px rgba(0, 0, 0, 0.04);
    -webkit-tap-highlight-color: transparent;
    min-height: 76px;
}

.dashboard-tile:hover {
    background: var(--primary-light);
    border-color: var(--primary-border);
}

.dashboard-tile:active {
    transform: scale(0.96);
}

.tile-icon {
    position: relative;
    width: 32px;
    height: 32px;
    display: flex;
    align-items: center;
    justify-content: center;
    margin-bottom: 4px;
    color: var(--primary-color);
}

.dir-icon-badge-wrapper {
    position: relative;
    width: 32px;
    height: 32px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
}

.dir-symbol-badge {
    position: absolute;
    top: -3px;
    left: -3px;
    width: 16px;
    height: 16px;
    display: flex;
    align-items: center;
    justify-content: center;
    color: var(--primary-color);
    background: #ffffff;
    border-radius: 50%;
    box-shadow: 0 1px 3px rgba(0, 0, 0, 0.2);
    z-index: 2;
    padding: 1px;
}

.dir-symbol-badge.dynamic {
    top: 50%;
    left: 50%;
    transform-origin: center center;
    transition: transform 0.15s ease-out;
}

.dir-symbol-badge svg {
    width: 100%;
    height: 100%;
    display: block;
}

.dir-compass {
    width: 30px;
    height: 30px;
    display: block;
}

.tile-icon svg {
    display: block;
}

.tile-label {
    font-size: 0.68rem;
    font-weight: 700;
    color: var(--text-muted);
    line-height: 1.2;
    margin-bottom: 2px;
}

.tile-value {
    font-size: 0.82rem;
    font-weight: 900;
    color: var(--primary-color);
    line-height: 1.2;
}

/* ============================================================
   個別設定変更パネル (下部フローティング調整バー)
   ============================================================ */

.single-setting-panel {
    position: fixed;
    bottom: 0;
    left: 0;
    right: 0;
    z-index: 200;
    background: rgba(255, 255, 255, 0.98);
    box-shadow: 0 -8px 24px rgba(0, 0, 0, 0.2);
    border-radius: 16px 16px 0 0;
    padding: 10px 16px calc(env(safe-area-inset-bottom, 0px) + 8px);
    max-width: 480px;
    margin: 0 auto;
    transition: transform 0.28s cubic-bezier(0.16, 1, 0.3, 1), opacity 0.22s ease;
    transform: translateY(105%);
    opacity: 0;
    pointer-events: none;
}

.single-setting-panel.panel-active {
    transform: translateY(0);
    opacity: 1;
    pointer-events: auto;
}

.setting-panel-header {
    text-align: center;
    margin-bottom: 6px;
}

.setting-panel-title {
    font-size: 0.78rem;
    font-weight: 700;
    color: var(--text-muted);
}

.setting-preview-box {
    display: flex;
    flex-direction: row;
    align-items: center;
    justify-content: center;
    gap: 12px;
    margin-bottom: 8px;
    padding: 4px 14px;
    background: var(--bg-color);
    border-radius: var(--radius-small);
}

.setting-preview-icon {
    position: relative;
    width: 32px;
    height: 32px;
    display: flex;
    align-items: center;
    justify-content: center;
    color: var(--primary-color);
    flex-shrink: 0;
}

.setting-preview-icon svg {
    display: block;
}

.setting-preview-value {
    font-size: 1.1rem;
    font-weight: 900;
    color: var(--text-main);
    letter-spacing: 0.5px;
}

/* 数値・角度調整バー */
.single-setting-controls-numeric {
    display: flex;
    align-items: center;
    gap: 8px;
    margin-bottom: 10px;
}

.btn-adjust-step {
    width: 36px;
    height: 36px;
    border-radius: 50%;
    background: #ffffff;
    border: 1.5px solid var(--border-color);
    color: var(--text-main);
    display: inline-flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    box-shadow: 0 2px 5px rgba(0, 0, 0, 0.08);
    flex-shrink: 0;
    transition: var(--transition);
    -webkit-tap-highlight-color: transparent;
    padding: 0;
    margin: 0;
    line-height: 0;
    vertical-align: middle;
}

.btn-adjust-step span {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 100%;
    height: 100%;
    line-height: 0;
    pointer-events: none;
}

.btn-adjust-step svg {
    display: block;
    margin: 0 auto;
}

.btn-adjust-step:active {
    transform: scale(0.9);
    background: var(--primary-light);
    border-color: var(--primary-color);
    color: var(--primary-color);
}

.adjust-slider-wrapper {
    flex: 1;
    display: flex;
    align-items: center;
}

.adjust-range {
    width: 100%;
    height: 6px;
}

/* 光源色 (色温度) コントロール */
.single-setting-controls-colortemp {
    margin-bottom: 10px;
}

.color-temp-preset-row {
    display: flex;
    justify-content: center;
    gap: 8px;
    margin-bottom: 12px;
}

.btn-temp-chip {
    padding: 5px 10px;
    border-radius: 14px;
    border: 1.5px solid var(--border-light);
    font-size: 0.72rem;
    font-weight: 700;
    color: #333333;
    cursor: pointer;
    box-shadow: 0 1px 3px rgba(0, 0, 0, 0.1);
    transition: var(--transition);
    -webkit-tap-highlight-color: transparent;
}

.btn-temp-chip.active {
    border-color: var(--primary-color);
    box-shadow: 0 0 0 2px var(--primary-border);
    font-weight: 900;
}

.btn-temp-chip:active {
    transform: scale(0.92);
}

.color-temp-slider-row {
    display: flex;
    align-items: center;
    gap: 10px;
}

.temp-indicator-label {
    font-size: 0.72rem;
    font-weight: 700;
    flex-shrink: 0;
}

.temp-indicator-label.warm {
    color: #e65100;
}

.temp-indicator-label.cool {
    color: #0277bd;
}

.temp-slider-wrapper {
    flex: 1;
    display: flex;
    align-items: center;
}

.temp-range {
    width: 100%;
    height: 6px;
    background: linear-gradient(to right, #ff944d 0%, #ffffff 50%, #80bfff 100%);
    border-radius: 3px;
}

/* カラーパレット */
.single-setting-controls-color {
    margin-bottom: 10px;
}

.color-palette-preset {
    display: flex;
    justify-content: center;
    gap: 8px;
    margin-bottom: 8px;
}

.btn-color-chip {
    width: 28px;
    height: 28px;
    border-radius: 50%;
    border: 2px solid #ffffff;
    box-shadow: 0 1px 4px rgba(0, 0, 0, 0.25);
    cursor: pointer;
    transition: var(--transition);
    -webkit-tap-highlight-color: transparent;
}

.btn-color-chip:active {
    transform: scale(0.9);
}

.color-custom-row {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
}

.color-picker-label {
    font-size: 0.75rem;
    font-weight: 700;
    color: var(--text-muted);
}

/* 確定・キャンセルアクション */
.single-setting-actions {
    display: flex;
    justify-content: center;
    align-items: center;
    gap: 12px;
    max-width: 280px;
    margin: 2px auto 0 auto;
    width: 100%;
}

.single-setting-actions .btn {
    flex: 1;
    padding: 7px 16px;
    font-size: 0.85rem;
    font-weight: 700;
    border-radius: 8px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    min-height: 34px;
}

/* 旗切り替え用サムネイル一覧 */
.single-setting-controls-switch-flag {
    margin-bottom: 8px;
    width: 100%;
}

.flag-switch-list {
    display: flex;
    justify-content: center;
    align-items: stretch;
    gap: 12px;
    padding: 6px 4px 10px 4px;
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
}

.flag-switch-card {
    position: relative;
    display: flex;
    flex-direction: column;
    align-items: center;
    background: #f8faf9;
    border: 2px solid var(--border-light);
    border-radius: 10px;
    padding: 8px 10px 6px 10px;
    min-width: 80px;
    max-width: 100px;
    cursor: pointer;
    transition: var(--transition);
    -webkit-tap-highlight-color: transparent;
}

.flag-switch-card:hover {
    border-color: var(--primary-color);
    background: #ffffff;
}

.flag-switch-card.selected {
    border-color: var(--primary-color);
    background: var(--primary-light);
    box-shadow: 0 0 0 1px var(--primary-color);
}

.flag-switch-thumb {
    width: 46px;
    height: 76px;
    object-fit: contain;
    border-radius: 4px;
    background: #eaeaea;
    box-shadow: 0 2px 6px rgba(0, 0, 0, 0.08);
}

.flag-switch-name {
    font-size: 0.78rem;
    font-weight: 700;
    color: var(--text-color);
    margin-top: 5px;
}

.flag-switch-badge {
    position: absolute;
    top: -6px;
    right: -6px;
    background: var(--primary-color);
    color: #ffffff;
    font-size: 0.62rem;
    font-weight: 700;
    padding: 2px 6px;
    border-radius: 10px;
    box-shadow: 0 2px 5px rgba(0, 0, 0, 0.2);
    letter-spacing: 0.2px;
}

/* 旗の反転コントロール */
.single-setting-controls-flip {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    width: 100%;
    margin-bottom: 12px;
}

.flip-toggle-row {
    display: flex;
    gap: 12px;
    width: 100%;
    max-width: 380px;
    justify-content: center;
}

.btn-flip-toggle {
    flex: 1;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    padding: 10px 14px;
    background: #f1f3f5;
    border: 1.5px solid var(--border-color);
    border-radius: 12px;
    font-size: 0.85rem;
    font-weight: 700;
    color: var(--text-color);
    cursor: pointer;
    transition: all 0.2s cubic-bezier(0.16, 1, 0.3, 1);
    -webkit-tap-highlight-color: transparent;
    user-select: none;
}

.btn-flip-toggle:hover {
    background: #e9ecef;
    border-color: #ced4da;
}

.btn-flip-toggle:active {
    transform: scale(0.97);
}

.btn-flip-toggle.active {
    background: var(--primary-light);
    border-color: var(--primary-color);
    color: var(--primary-dark);
    box-shadow: 0 2px 8px rgba(46, 125, 50, 0.18);
}

.btn-flip-toggle .flip-icon {
    flex-shrink: 0;
    transition: transform 0.2s ease;
}

.btn-flip-toggle.active .flip-icon {
    color: var(--primary-color);
}

/* 旗切り替え用アクションボタングループ (2段構成) */
.switch-flag-actions {
    display: flex;
    flex-direction: column;
    gap: 8px;
    max-width: 280px;
    margin: 4px auto 0 auto;
    width: 100%;
}

.switch-actions-row {
    display: flex;
    gap: 10px;
    width: 100%;
}

.switch-actions-row>button {
    flex: 1;
    padding: 7px 16px;
    font-size: 0.85rem;
    font-weight: 700;
    border-radius: 8px;
    min-height: 34px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
}

.btn-apply-settings {
    width: 100%;
    padding: 8px 14px;
    background: #ffffff;
    border: 1.5px solid var(--primary-color);
    color: var(--primary-color);
    border-radius: 8px;
    font-size: 0.82rem;
    font-weight: 700;
    cursor: pointer;
    transition: var(--transition);
    display: flex;
    align-items: center;
    justify-content: center;
    min-height: 34px;
    -webkit-tap-highlight-color: transparent;
}

.btn-apply-settings:hover:not(:disabled) {
    background: var(--primary-light);
}

.btn-apply-settings:active:not(:disabled) {
    background: var(--primary-color);
    color: #ffffff;
}

.btn-apply-settings:disabled {
    opacity: 0.45;
    border-color: var(--border-light);
    color: var(--text-muted);
    cursor: not-allowed;
}

.modal-content-confirm {
    max-width: 360px;
    padding: 20px;
}

.range-wrapper {
    display: flex;
    align-items: center;
    gap: 10px;
}

.range-input {
    -webkit-appearance: none;
    appearance: none;
    flex: 1;
    height: 6px;
    background: #e0e0e0;
    border-radius: 3px;
    outline: none;
}

.range-input::-webkit-slider-thumb {
    -webkit-appearance: none;
    appearance: none;
    width: 20px;
    height: 20px;
    border-radius: 50%;
    background: var(--primary-color);
    cursor: pointer;
    border: 2px solid #ffffff;
    box-shadow: 0 1px 4px rgba(0, 0, 0, 0.25);
    transition: var(--transition);
}

.range-input::-webkit-slider-thumb:hover {
    transform: scale(1.1);
    background: var(--primary-hover);
}

.range-input::-moz-range-thumb {
    width: 20px;
    height: 20px;
    border-radius: 50%;
    background: var(--primary-color);
    cursor: pointer;
    border: 2px solid #ffffff;
    box-shadow: 0 1px 4px rgba(0, 0, 0, 0.25);
}

.range-val {
    font-size: 0.85rem;
    font-weight: 700;
    color: var(--text-main);
    min-width: 44px;
    text-align: right;
    font-variant-numeric: tabular-nums;
}

.panel-footer-note {
    margin-top: 14px;
    font-size: 0.75rem;
    color: var(--text-muted);
    line-height: 1.4;
}

/* ============================================================
   Toast 通知
   ============================================================ */

.toast {
    position: fixed;
    top: 30px;
    left: 50%;
    transform: translateX(-50%) translateY(-20px);
    z-index: 20000;
    background: rgba(34, 34, 34, 0.92);
    color: #ffffff;
    padding: 10px 20px;
    border-radius: 8px;
    font-size: 0.85rem;
    font-weight: 700;
    opacity: 0;
    pointer-events: none;
    transition: opacity 0.25s ease, transform 0.25s ease;
    box-shadow: 0 4px 16px rgba(0, 0, 0, 0.3);
    max-width: calc(100vw - 32px);
    text-align: center;
    box-sizing: border-box;
}

.toast.show {
    opacity: 1;
    transform: translateX(-50%) translateY(0);
    pointer-events: auto;
}

.panel-home-action {
    margin-top: 16px;
    padding-top: 14px;
    border-top: 1px solid var(--border-light);
    width: 100%;
    display: flex;
    justify-content: center;
}

.btn-back-home {
    min-width: 220px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    padding: 9px 24px;
    font-size: 0.85rem;
    border-radius: var(--radius-small);
}

/* ============================================================
   レスポンシブ
   ============================================================ */

@media (max-width: 480px) {
    .start-screen-container {
        padding: 16px 10px 30px 10px;
    }

    .card {
        padding: 18px 14px;
    }

    h1.main-title {
        font-size: 1.35rem;
    }

    .panel-main-actions {
        padding: 8px 14px;
    }

    .btn-action {
        padding: 8px 14px;
        font-size: 0.85rem;
    }

    .color-controls-grid {
        grid-template-columns: 1fr;
    }
}