/* CSS Variables - Design System */
:root {
    /* Colors */
    --c-bg-main: #0a0a0c;
    --c-bg-sidebar: #0f1115;
    --c-bg-panel: rgba(20, 22, 26, 0.98);
    --c-bg-glass: rgba(15, 17, 21, 0.85);

    --c-accent-cyan: #00d4ff;
    --c-neon-cyan: #00ffff;
    --c-accent-blue: #0055ff;
    --c-danger: #ff6b6b;

    --c-text-main: #e0e0e0;
    --c-text-muted: #888890;

    --c-border-glass: rgba(255, 255, 255, 0.1);

    /* Layout */
    --width-sidebar: 320px;
    --width-tile-sidebar: 260px;
    --header-height: 50px;

    /* Effects */
    --blur-glass: blur(12px);
    --shadow-main: 0 8px 32px rgba(0, 0, 0, 0.5);

    /* Spacing */
    --sp-xs: 4px;
    --sp-sm: 8px;
    --sp-md: 12px;
    --sp-lg: 20px;
}

body,
html {
    margin: 0;
    padding: 0;
    height: 100%;
    width: 100%;
    overflow: hidden;
    /* !important 除去 (特殊な理由がない限り不要) */
    background-color: var(--c-bg-main);
    color: var(--c-text-main);
    font-family: 'Inter', sans-serif;
}

.page-map-tool {
    height: 100%;
    width: 100%;
}

.map-tool-container {
    display: flex;
    position: fixed;
    top: 50px;
    left: 0;
    right: 0;
    bottom: 0;
    background: #0f1115;
    overflow: hidden;
    z-index: 10;
}

/* Sidebar Styling - Pro Sidebar (Glassmorphism) */
.tool-sidebar {
    position: relative;
    width: 320px;
    min-width: 320px;
    height: 100%;
    background: var(--c-bg-glass);
    backdrop-filter: var(--blur-glass);
    -webkit-backdrop-filter: var(--blur-glass);
    border-right: 1px solid var(--c-border-glass);
    padding: 20px 20px 20px 20px !important;
    display: flex;
    flex-direction: column;
    gap: 12px;
    overflow-y: auto;
    font-family: var(--font-body);
    z-index: 100;
    box-shadow: 10px 0 30px rgba(0, 0, 0, 0.4);
    flex-shrink: 0;
}

@media (max-width: 960px) {
    .map-tool-container {
        flex-direction: column;
    }

    .tool-sidebar {
        width: 100%;
        min-width: 100%;
        height: auto;
        max-height: 80vh;
        border-right: none;
        border-top: 1px solid rgba(255, 255, 255, 0.1);
        padding-bottom: 100px;
    }
}

/* モバイル最適化 (v64 追加) */
/* PixelEditor styles have been moved to pixel-editor.css */

@media (max-width: 768px) {
    .map-tool-container {
        flex-direction: row;
        /* 横並びに戻してドロワーを重ねる */
    }

    .tool-sidebar {
        position: absolute;
        top: 0;
        left: 0;
        bottom: 0;
        width: 320px;
        /* PC版に合わせつつ、モバイルでは最大幅制限 */
        max-width: 85vw !important;
        /* 指摘の「はみ出し」を防ぐため画面幅より小さく抑える */
        height: 100vh;
        max-height: 100vh;
        z-index: 2000;
        transform: translateX(-100%);
        transition: transform 0.3s cubic-bezier(0.4, 0, 0.2, 1);
        box-shadow: 5px 0 25px rgba(0, 0, 0, 0.8);
        background: var(--c-bg-panel);
        backdrop-filter: var(--blur-glass);
        overflow-y: auto !important;
        /* 縦スクロールを許可 */
        overflow-x: hidden !important;
        box-sizing: border-box !important;
    }

    .tool-sidebar.is-open {
        transform: translateX(0);
    }

    .map-view {
        width: 100%;
        height: 100%;
    }

    /* タッチターゲット拡大 */
    .tool-btn {
        width: 44px;
        height: 44px;
        min-width: 44px;
    }

    .tool-btn svg {
        width: 20px;
        height: 20px;
    }

    /* モバイル用フローティングツールバー */
    .mobile-tool-bar {
        position: absolute;
        bottom: 20px;
        left: 50%;
        transform: translateX(-50%);
        display: flex;
        gap: 10px;
        padding: 8px 16px;
        background: rgba(15, 17, 21, 0.85);
        backdrop-filter: blur(12px);
        -webkit-backdrop-filter: blur(12px);
        border: 1px solid rgba(255, 255, 255, 0.15);
        border-radius: 50px;
        z-index: 1500;
        box-shadow: 0 8px 32px rgba(0, 0, 0, 0.5);
    }

    /* 凡例パネル・アクションバーの非表示制御 */
    .integrated-map-hub,
    .floating-action-bar {
        display: none !important;
    }

    .integrated-map-hub.mobile-visible {
        display: block !important;
        bottom: 80px;
        right: 15px;
        z-index: 1000;
    }

    .legend-panel {
        width: 240px;
        max-height: 50vh;
    }

    .sidebar-overlay {
        display: none;
        position: fixed;
        top: 50px;
        left: 0;
        right: 0;
        bottom: 0;
        background: rgba(0, 0, 0, 0.5);
        z-index: 100;
        backdrop-filter: blur(2px);
    }

    .sidebar-overlay.active {
        display: block;
    }

    /* Mobile Tool Settings adjustments */
    .map-settings-layout {
        flex-wrap: nowrap !important;
        gap: 3px !important;
        justify-content: flex-start;
    }

    .map-settings-layout .setting-item-compact {
        gap: 2px !important;
    }

    .map-settings-layout .color-auto-group {
        margin-left: 2px !important;
        padding-left: 4px !important;
        gap: 3px !important;
    }

    .map-settings-layout input[type="number"] {
        width: 30px !important;
        height: 20px !important;
        font-size: 9px !important;
    }

    .map-settings-layout input[type="color"] {
        width: 22px !important;
        height: 20px !important;
    }

    #grid-color-auto {
        height: 20px !important;
        line-height: normal !important;
        padding: 0 4px !important;
        font-size: 8px !important;
    }

    .tool-group#color-settings {
        display: flex;
        flex-direction: row;
        flex-wrap: wrap;
        align-items: center;
        gap: 8px;
    }

    .tool-group#color-settings h3 {
        flex: 0 0 100%;
    }

    #color-settings .color-control-main-compact {
        flex: 0 0 auto;
    }

    #color-settings .preset-colors {
        flex: 1;
        margin-top: 0 !important;
        margin-left: 0;
        display: flex;
        flex-wrap: nowrap !important;
        overflow-x: auto;
        gap: 6px;
        padding-bottom: 4px;
        -webkit-overflow-scrolling: touch;
    }

    #tile-container.tile-grid {
        max-height: none !important;
        grid-template-columns: repeat(auto-fill, minmax(60px, 1fr));
    }

    .header-logo {
        margin: 0 auto !important;
        display: block !important;
        text-align: center;
    }

    /* モバイル専用行ラッパーの基本設定 (PCでは無視) */
    .tile-editor-modal #pixel-sidebar .sidebar-row {
        display: contents;
    }

    /* タイルエディタのモバイル調整 (v65) - トップツールバー */
    .tile-editor-modal #pixel-sidebar {
        position: absolute;
        top: 0;
        left: 0;
        right: 0;
        bottom: auto;
        width: 100% !important;
        max-width: 100vw !important;
        box-sizing: border-box !important;
        height: auto;
        max-height: 85vh !important;
        /* 縦幅を広げて要素が見えるように */
        min-height: 40px;
        transform: none !important;
        transition: none;
        border-bottom: 1px solid rgba(255, 255, 255, 0.1);
        border-left: none;
        box-shadow: 0 5px 25px rgba(0, 0, 0, 0.8);
        background: rgba(15, 17, 21, 0.95);
        backdrop-filter: blur(12px);
        -webkit-backdrop-filter: blur(12px);
        z-index: 1000;
        display: flex;
        flex-wrap: wrap;
        padding: 4px;
        gap: 0;
        align-items: flex-start;
        overflow-x: hidden !important;
        overflow-y: auto !important;
        /* 縦スクロールを許可 */
        -webkit-overflow-scrolling: touch;
        scrollbar-width: thin;
    }

    .tile-editor-modal #pixel-sidebar::-webkit-scrollbar {
        display: none;
    }

    .tile-editor-modal #pixel-sidebar.is-open {
        transform: translateY(0);
    }

    .tile-editor-modal #pixel-sidebar .sidebar-row {
        display: flex;
        flex-wrap: wrap !important;
        /* はみ出し防止のため折り返しを許可 */
        overflow-x: hidden;
        overflow-y: visible;
        width: 100%;
        box-sizing: border-box;
        gap: 4px;
        align-items: flex-start;
        border-bottom: 1px solid rgba(255, 255, 255, 0.1);
        padding-bottom: 8px;
        margin-bottom: 4px;
    }

    .tile-editor-modal #pixel-sidebar .sidebar-row::-webkit-scrollbar {
        display: none;
    }

    .tile-editor-modal #pixel-sidebar .sidebar-row:last-child {
        border-bottom: none;
        padding-bottom: 0;
        margin-bottom: 0;
    }

    .tile-editor-modal #pixel-sidebar .tool-group {
        border-right: 1px solid rgba(255, 255, 255, 0.1);
        padding: 6px 10px !important;
        margin: 0;
        background: transparent;
        display: flex;
        flex-direction: row !important;
        /* アイテムを横に並べて折り返す */
        flex-wrap: wrap !important;
        align-items: center;
        gap: 6px;
        flex: 1 1 auto;
        min-width: 120px;
        max-width: 100%;
        box-sizing: border-box;
    }

    .tile-editor-modal #pixel-sidebar .tool-group h3 {
        flex: 0 0 100%;
        /* タイトルは一行占有 */
    }

    .tile-editor-modal #pixel-sidebar .tool-group:last-child {
        border-right: none;
        padding-right: 0 !important;
    }

    .tile-editor-modal #pixel-sidebar .tool-group h3 {
        display: block !important;
        width: auto !important;
        font-size: 12px !important;
        color: var(--c-accent-cyan);
        margin: 2px 0 2px 2px;
        padding-left: 4px !important;
        white-space: nowrap;
    }

    .tile-editor-modal #pixel-sidebar .control-row>label {
        font-size: 10px !important;
        margin: 0 !important;
        padding: 0 !important;
        width: auto !important;
        color: #ddd;
        white-space: nowrap;
    }

    .tile-editor-modal #pixel-sidebar .control-row {
        margin: 0 !important;
        display: flex;
        align-items: center;
        gap: 4px;
        flex-wrap: nowrap;
    }

    .tile-editor-modal #pixel-sidebar #pixel-color-settings .color-control-main-compact {
        margin-bottom: 0 !important;
        flex: 0 0 auto;
    }

    .tile-editor-modal #pixel-sidebar #pixel-color-history.preset-colors {
        flex: 1;
        margin-top: 0 !important;
        display: flex;
        flex-wrap: nowrap !important;
        overflow-x: auto;
        gap: 6px;
        padding-bottom: 4px;
        -webkit-overflow-scrolling: touch;
    }

    .preset-colors .preset-btn,
    .preset-colors .history-color {
        display: inline-block;
        width: 24px !important;
        height: 24px !important;
        flex: 0 0 24px !important;
        border-radius: 50% !important;
        border: 1px solid var(--c-border-glass);
        cursor: pointer;
        padding: 0;
        transition: transform 0.2s;
    }

    .preset-colors .preset-btn:hover,
    .preset-colors .history-color:hover {
        transform: scale(1.1);
    }

    #pixel-sidebar .control-row select,
    #pixel-sidebar .control-row input[type="text"],
    #pixel-sidebar .control-row input[type="number"],
    #pixel-sidebar .control-row input[type="color"] {
        padding: 8px 12px;
        /* 内側の余白（上下 8px, 左右 12px） */
        margin-top: 8px;
        /* 見出しとの間の外側余白 */
        margin-bottom: 12px;
        /* 下の項目との間の外側余白 */
        border-radius: 4px;
        background: rgba(0, 0, 0, 0.3);
        border: 1px solid var(--c-border-glass);
        color: #fff;
    }

    .tile-editor-modal #pixel-sidebar .sidebar-grid {
        display: flex;
        flex-wrap: nowrap;
        gap: 4px;
        margin: 0 !important;
    }

    /* 整理されたタイルエディタ特有のルール (メディアクエリ内はレイアウト調整のみ) */
    .tile-editor-modal #pixel-sidebar select {
        width: 100%;
        /* モバイル等でも適切に広がるように */
    }

    /* モバイル表示での「不自然な線」を除去 */
    .tile-editor-sidebar .tool-group {
        border-bottom: none !important;
        border-right: none !important;
    }

    .tile-editor-modal #pixel-sidebar .tool-btn {
        width: 28px !important;
        height: 28px !important;
        min-width: 28px !important;
        flex: none;
    }

    .tile-editor-modal #pixel-sidebar .tool-btn svg {
        width: 16px !important;
        height: 16px !important;
    }

    /* モバイル専用：入力コントロールの最適化 */
    .tile-editor-modal #pixel-sidebar select,
    .tile-editor-modal #pixel-sidebar input[type="range"] {
        height: 24px !important;
        width: 80px !important;
        padding: 0 4px !important;
        font-size: 11px !important;
        margin: 0 !important;
    }

    /* 起動ボタンの消失防止 */
    .modal-top-actions {
        gap: 10px;
    }

    .tile-editor-modal #pixel-sidebar input[type="color"] {
        width: 32px !important;
        height: 32px !important;
        padding: 0;
        border-radius: 4px;
        margin: 0;
        flex: none;
    }

    .tile-editor-modal #pixel-sidebar span[id$="-val"] {
        display: none !important;
        /* "%" や "HEX:" 値は非表示 */
    }

    /* 削除: 履歴と保存設定の非表示（多段表示レイアウトに移行したため） */

    .tile-editor-modal .modal-body {
        padding: 5px !important;
    }

    .tile-editor-modal #pixel-sidebar-overlay {
        display: none !important;
    }

    .tile-editor-modal .pixel-canvas-main-area {
        margin: 5px !important;
    }

    #btn-pixel-sidebar-toggle,
    #btn-pixel-sidebar-pin {
        display: flex !important;
    }

    #btn-pixel-sidebar-pin.is-pinned {
        color: var(--c-neon-cyan);
        opacity: 1 !important;
        transform: scale(1.1);
    }
}

.map-view {
    flex: 1;
    position: relative;
    background: #0a0a0c;
    overflow: hidden;
    padding: 0;
    z-index: 1;
}

#map-canvas {
    width: 100%;
    height: 100%;
    display: block;
    cursor: crosshair;
}

#map-canvas.is-locked {
    cursor: not-allowed;
}

.tool-group {
    margin-bottom: 8px;
    padding-bottom: 4px;
    border-bottom: 1px solid #2a2f3a;
}

.tool-group h3 {
    font-size: 0.8rem;
    color: #00d4ff;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    margin-bottom: 4px;
    border-left: 2px solid #00d4ff;
    padding-left: 6px;
}

/* Map Settings Layout */
.map-settings-layout {
    display: flex;
    align-items: center;
    gap: 8px;
    margin-top: 6px;
    font-size: 11px;
    color: var(--c-text-muted);
    flex-wrap: wrap;
}

.setting-item-compact {
    display: flex;
    align-items: center;
    gap: 4px;
}

.setting-item-compact input[type="number"] {
    width: 32px;
    height: 22px;
    padding: 2px;
    font-size: 10px;
    background: rgba(0, 0, 0, 0.3);
    border: 1px solid var(--c-border-glass);
    color: #fff;
    text-align: center;
}

.setting-item-compact input[type="color"] {
    width: 24px;
    height: 22px;
    padding: 0;
    border: 1px solid var(--c-border-glass);
    background: transparent;
    cursor: pointer;
}

.color-auto-group {
    margin-left: 4px;
    padding-left: 4px;
    border-left: 1px solid var(--c-border-glass);
    display: flex;
    align-items: center;
    gap: 4px;
}

#grid-color-auto {
    padding: 0 5px;
    font-size: 9px;
    height: 22px;
    line-height: 22px;
}

/* Tile Grid basic styles */
.tile-grid {
    display: grid;
    grid-template-columns: repeat(4, 1fr);
    gap: 4px;
    max-height: 200px;
    overflow-y: auto;
    padding: 4px;
    background: rgba(0, 0, 0, 0.2);
    border-radius: 4px;
    border: 1px solid var(--c-border-glass);
}

.control-row {
    display: flex;
    align-items: center;
    gap: 8px;
    margin-bottom: 6px;
    font-size: 0.8rem;
}

.control-row label {
    flex: 1;
}

.control-row input[type="number"],
.control-row select {
    width: 50px;
    background: #0a0a0c;
    border: 1px solid #3a4150;
    color: #fff;
    padding: 2px 4px;
    border-radius: 4px;
}

.btn-primary {
    width: 100%;
    padding: 8px;
    background: linear-gradient(135deg, #00d4ff 0%, #0055ff 100%);
    border: none;
    color: #fff;
    font-weight: 600;
    cursor: pointer;
    border-radius: 4px;
    transition: filter 0.2s;
}

.btn-primary:hover {
    filter: brightness(1.2);
}

.tool-buttons {
    display: flex;
    align-items: center;
    gap: 4px;
    margin-bottom: 12px;
}

.tool-separator {
    width: 1px;
    height: 24px;
    background: var(--c-border-glass);
    margin: 0 6px;
    flex-shrink: 0;
}

.tool-btn {
    width: 34px;
    height: 34px;
    min-width: 34px;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 0;
    border-radius: 6px;
    background: rgba(255, 255, 255, 0.05);
    border: 1px solid var(--c-border-glass);
    color: var(--c-text-muted);
    cursor: pointer;
    transition: all 0.2s cubic-bezier(0.4, 0, 0.2, 1);
}

.tool-btn svg {
    width: 18px;
    height: 18px;
}

.tool-btn:hover {
    background: rgba(7, 174, 229, 0.2);
    border-color: var(--c-accent-cyan);
    color: #fff;
    box-shadow: 0 0 10px rgba(7, 174, 229, 0.2);
    transform: translateY(-1px);
}

.tool-btn.active {
    background: rgba(7, 174, 229, 0.3);
    color: var(--c-neon-cyan);
    border-color: var(--c-accent-cyan);
    box-shadow: 0 0 20px rgba(7, 174, 229, 0.4), inset 0 0 10px rgba(7, 174, 229, 0.1);
    transform: scale(1.05);
}

/* タイルエディタ固有の調節 (v62) */
.pixel-tools .tool-btn {
    width: 44px;
    height: 44px;
}

#btn-pixel-clear:hover {
    background: rgba(255, 77, 77, 0.2) !important;
    border-color: #ff4d4d !important;
    color: #fff !important;
    box-shadow: 0 0 10px rgba(255, 77, 77, 0.4);
}

.tool-buttons button[data-pixel-brush-size] {
    font-family: var(--font-mono, monospace);
    font-weight: bold;
}

.symbol-buttons {
    display: grid;
    grid-template-columns: repeat(2, 1fr);
    gap: 5px;
}

.symbol-btn {
    padding: 6px;
    background: #1c222d;
    border: 1px solid #3a4150;
    color: #fff;
    font-size: 0.8rem;
    cursor: pointer;
}

.symbol-btn:hover {
    border-color: #00d4ff;
}

/* 記号・高度設定パレット */
#symbol-settings .control-row input {
    width: 80px;
    background: #0a0a0c;
    border: 1px solid #3a4150;
    color: #fff;
    padding: 4px 8px;
    border-radius: 4px;
}

.color-control-main {
    display: flex;
    gap: 10px;
    align-items: flex-start;
}

#color-picker {
    width: 48px;
    height: 48px;
    background: #111;
    border: 1px solid #444;
    padding: 2px;
    border-radius: 4px;
    cursor: pointer;
}

.cmyk-inputs {
    display: grid;
    grid-template-columns: repeat(2, 1fr);
    gap: 5px;
    flex: 1;
}

.cmyk-field {
    display: flex;
    align-items: center;
    gap: 4px;
    font-size: 11px;
    color: #aaa;
}

.cmyk-field label {
    width: 12px;
    font-weight: bold;
}

.cmyk-field input {
    width: 45px;
    background: #111;
    border: 1px solid #444;
    color: #fff;
    padding: 2px;
    border-radius: 3px;
    text-align: right;
    font-size: 12px;
}

.preset-colors {
    display: flex;
    flex-wrap: wrap;
    gap: 4px;
    margin-top: 6px;
}

.preset-btn {
    width: 22px;
    height: 22px;
    border-radius: 4px;
    border: 1px solid rgba(255, 255, 255, 0.2);
    cursor: pointer;
    padding: 0;
    transition: transform 0.1s;
}

.preset-btn:hover {
    transform: scale(1.1);
    border-color: #fff;
}

.preset-btn.transparent span {
    pointer-events: none;
}

.action-buttons {
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.btn-action,
.btn-export {
    padding: 4px;
    background: #232a35;
    border: 1px solid #3a4150;
    color: #ccc;
    font-size: 0.75rem;
    cursor: pointer;
    border-radius: 4px;
    transition: all 0.2s;
}

.btn-action:hover {
    background: #2d3644;
    color: #fff;
}

.btn-export {
    background: #003344;
    border-color: #0088aa;
    color: #00d4ff;
}

.btn-export:hover {
    background: #004455;
}

/* Layer Manager */
.layer-list {
    display: flex;
    flex-direction: column;
    gap: 4px;
    margin-top: 8px;
}

.layer-item {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 2px 6px;
    background: rgba(255, 255, 255, 0.03);
    border: 1px solid var(--c-border-glass);
    border-radius: 4px;
    transition: all 0.2s ease;
}

.layer-item:hover {
    background: rgba(255, 255, 255, 0.06);
}

.layer-main {
    display: flex;
    align-items: center;
    gap: 6px;
}

.layer-name {
    font-size: 0.75rem;
    color: var(--c-text-main);
}

.layer-actions {
    display: flex;
    gap: 8px;
}

.layer-toggle-btn,
.layer-lock-btn {
    background: none;
    border: none;
    color: #666;
    /* OFF color (Gray) */
    cursor: pointer;
    padding: 4px;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.2s ease;
    border-radius: 4px;
}

.layer-toggle-btn.active,
.layer-lock-btn.active {
    color: var(--c-neon-cyan);
    /* ON color (Cyan) */
    filter: drop-shadow(0 0 4px rgba(0, 212, 255, 0.4));
}

.layer-toggle-btn:hover,
.layer-lock-btn:hover {
    background: rgba(255, 255, 255, 0.1);
}

/* Modal Styling */
.modal-overlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.82);
    display: none;
    align-items: center;
    justify-content: center;
    z-index: 10000;
    backdrop-filter: blur(8px);
    -webkit-backdrop-filter: blur(8px);
}

#modal-overlay {
    z-index: 9998;
    background: rgba(0, 0, 0, 0.8);
    backdrop-filter: blur(4px);
}

#dot-art-tool-modal {
    display: none;
    position: fixed;
    top: 0;
    left: 0;
    width: 100vw;
    height: 100vh;
    z-index: 9999;
    background-color: rgba(0, 0, 0, 0.85);
    justify-content: center;
    align-items: center;
    backdrop-filter: blur(8px);
}

.tile-editor-modal {
    width: 1000px;
    max-width: 98vw;
    height: 800px;
    max-height: 95vh;
    min-width: 400px;
    /* v58 追加 */
    min-height: 400px;
    /* v58 追加 */
    display: flex;
    flex-direction: column;
    background: rgba(20, 22, 26, 0.98);
    border: 1px solid var(--c-border-glass);
    border-radius: 12px;
    position: relative;
    box-shadow: 0 0 50px rgba(0, 0, 0, 0.8);
    overflow: hidden;
}

/* 全画面モード (v63 追加) */
.tile-editor-modal.is-fullscreen {
    width: 100vw !important;
    max-width: 100vw !important;
    height: 100vh !important;
    max-height: 100vh !important;
    border-radius: 0 !important;
    top: 0 !important;
    left: 0 !important;
    margin: 0 !important;
    border: none !important;
}

/* タイルエディタ・サイドバー共通スタイル */
.tile-editor-sidebar {
    width: var(--width-tile-sidebar);
    display: flex;
    flex-direction: column;
    gap: var(--sp-sm);
    flex-shrink: 0;
    background: var(--c-bg-panel);
    padding: var(--sp-sm) var(--sp-md);
    border-right: 1px solid var(--c-border-glass);
    overflow-y: auto;
    overflow-x: hidden;
    z-index: 1002;
    color: var(--c-text-main);
}

.tile-editor-sidebar .tool-group {
    padding: var(--sp-xs) var(--sp-sm);
    border-bottom: 1px solid var(--c-border-glass);
}

.tile-editor-sidebar .tool-group:last-child {
    border-bottom: none;
}

.tile-editor-sidebar .tool-group h3 {
    margin: 0 0 var(--sp-sm) 0;
    font-size: 11px;
    color: var(--c-accent-cyan);
    text-transform: uppercase;
    letter-spacing: 1px;
    font-weight: 700;
    opacity: 0.9;
}

/* ツールボタンの共通定義 */
.tile-editor-sidebar .tool-btn {
    height: 28px;
    /* 24pxから少し拡大して操作性向上 */
    width: 100%;
    padding: 0;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: 4px;
    background: rgba(255, 255, 255, 0.04);
    border: 1px solid var(--c-border-glass);
    color: var(--c-text-muted);
    cursor: pointer;
    transition: all 0.2s cubic-bezier(0.4, 0, 0.2, 1);
}

.tile-editor-sidebar .tool-btn:hover {
    background: rgba(0, 212, 255, 0.15);
    border-color: var(--c-accent-cyan);
    color: #fff;
}

.tile-editor-sidebar .tool-btn.active {
    background: rgba(0, 212, 255, 0.25);
    border-color: var(--c-accent-cyan);
    color: #fff;
    box-shadow: 0 0 8px rgba(0, 212, 255, 0.3);
}

.tile-editor-sidebar .tool-btn.primary {
    background: linear-gradient(135deg, var(--c-accent-cyan), var(--c-accent-blue));
    color: #fff;
    border: none;
    font-weight: bold;
}

.tile-editor-sidebar .tool-btn svg {
    width: 16px;
    height: 16px;
}

/* フォーム項目行 */
.tile-editor-sidebar .control-row {
    display: flex;
    align-items: center;
    gap: var(--sp-sm);
    margin-bottom: var(--sp-sm);
}

.tile-editor-sidebar label {
    font-size: 11px;
    color: var(--c-text-muted);
    flex-shrink: 0;
    width: 65px;
}

/* セレクトボックス等の入力パーツ - 詳細度を最大化 */
#pixel-sidebar select,
#pixel-sidebar input[type="text"],
#pixel-sidebar input[type="password"],
#pixel-sidebar input[type="number"],
.tile-editor-sidebar select {
    font-size: 12px !important;
    background: var(--c-bg-main) !important;
    color: #fff !important;
    border: 1px solid var(--c-border-glass) !important;
    border-radius: 4px !important;
    padding: 4px 8px 4px 8px !important;
    margin: 6px 0 10px 0 !important;
    flex: 1;
    transition: all 0.2s;
    box-sizing: border-box;
    display: block;
    width: 100% !important;
}

#pixel-sidebar select:focus,
#pixel-sidebar input:focus {
    border-color: var(--c-accent-cyan) !important;
    box-shadow: 0 0 5px rgba(0, 212, 255, 0.2) !important;
    outline: none;
}

.tile-editor-sidebar select:focus,
.tile-editor-sidebar input:focus {
    border-color: var(--c-accent-cyan);
    box-shadow: 0 0 5px rgba(0, 212, 255, 0.2);
    outline: none;
}

.tile-editor-sidebar .sidebar-grid {
    display: grid;
    gap: 4px;
    width: 100%;
}

.tile-editor-sidebar .grid-2 {
    grid-template-columns: repeat(2, 1fr);
}

.tile-editor-sidebar .grid-3 {
    grid-template-columns: repeat(3, 1fr);
}

.tile-editor-sidebar .grid-4 {
    grid-template-columns: repeat(4, 1fr);
}

.tile-editor-sidebar .grid-6,
.tile-editor-modal #pixel-sidebar #pixel-color-history.sidebar-grid {
    display: grid !important;
    grid-template-columns: repeat(6, 1fr) !important;
}

.tile-editor-modal.is-fullscreen .modal-resizer {
    display: none;
}

/* タイルエディタ専用トップアクション (v63 追加) */
.tile-editor-modal .modal-top-actions .close {
    color: #888890;
    transition: color 0.2s, opacity 0.2s;
    cursor: pointer;
    font-size: 24px;
    font-weight: bold;
    text-decoration: none;
    line-height: 1;
}

.tile-editor-modal .modal-top-actions .close:hover {
    color: #00d4ff;
    opacity: 1 !important;
}

.tile-editor-modal .modal-top-actions button.close {
    display: flex;
    align-items: center;
    justify-content: center;
    height: 24px;
    width: 24px;
}

.tile-editor-modal .modal-header {
    padding: 20px 30px;
    border-bottom: 1px solid rgba(255, 255, 255, 0.1);
    background: rgba(255, 255, 255, 0.02);
}

.tile-editor-modal .modal-header h2 {
    margin: 0;
    font-size: 1.2rem;
    color: var(--c-accent-cyan);
    letter-spacing: 0.1em;
    font-weight: 700;
}

.close.top-right {
    position: absolute;
    top: 15px;
    right: 20px;
    font-size: 28px;
    color: #fff;
    opacity: 0.6;
    cursor: pointer;
    z-index: 10;
    transition: all 0.2s;
}

.close.top-right:hover {
    opacity: 1;
    color: #ff4d4d;
    transform: scale(1.1);
}

.color-history-grid .history-item,
#pixel-color-history .history-item {
    width: 100%;
    padding-bottom: 100%;
    border-radius: 4px;
    border: 1px solid rgba(255, 255, 255, 0.1);
    cursor: pointer;
    transition: transform 0.1s;
}

.color-history-grid .history-item:hover,
#pixel-color-history .history-item:hover {
    transform: scale(1.1);
    border-color: #fff;
    z-index: 1;
}

#pixel-canvas-container {
    background-color: #050505;
    overflow: hidden;
    width: 100%;
    height: 100%;
    display: flex;
    align-items: center;
    justify-content: center;
    /* 拡大・縮小・パンに対応するため表示を制御 */
}

/* ダークチェッカー（現状） */
#pixel-canvas-container.bg-dark-checker {
    background-image:
        linear-gradient(45deg, #111 25%, transparent 25%),
        linear-gradient(-45deg, #111 25%, transparent 25%),
        linear-gradient(45deg, transparent 75%, #111 75%),
        linear-gradient(-45deg, transparent 75%, #111 75%);
    background-size: 20px 20px;
    background-position: 0 0, 0 10px, 10px -10px, -10px 0px;
    background-color: #050505;
}

/* 透明ライトチェッカー */
#pixel-canvas-container.bg-light-checker {
    background-image:
        linear-gradient(45deg, #f0f0f0 25%, transparent 25%),
        linear-gradient(-45deg, #f0f0f0 25%, transparent 25%),
        linear-gradient(45deg, transparent 75%, #f0f0f0 75%),
        linear-gradient(-45deg, transparent 75%, #f0f0f0 75%);
    background-size: 20px 20px;
    background-position: 0 0, 0 10px, 10px -10px, -10px 0px;
    background-color: #fff;
}

.tile-editor-sidebar {
    overflow-y: auto;
    scrollbar-width: thin;
    scrollbar-color: rgba(255, 255, 255, 0.2) transparent;
}

.tile-editor-sidebar::-webkit-scrollbar {
    width: 6px;
}

.tile-editor-sidebar::-webkit-scrollbar-thumb {
    background: rgba(255, 255, 255, 0.2);
    border-radius: 3px;
}

/* リサイズハンドル (v58) */
.modal-resizer {
    width: 20px;
    height: 20px;
    background: transparent;
    position: absolute;
    right: 0;
    bottom: 0;
    cursor: nwse-resize;
    z-index: 100;
}

.modal-resizer::after {
    content: "";
    position: absolute;
    right: 5px;
    bottom: 5px;
    width: 10px;
    height: 10px;
    border-right: 2px solid rgba(255, 255, 255, 0.4);
    border-bottom: 2px solid rgba(255, 255, 255, 0.4);
}

/* アダプティブUI: 幅が狭い場合の調整 (v58) */
.tile-editor-modal.compact-ui .modal-header {
    padding: 10px 20px;
}

.tile-editor-modal.compact-ui .modal-body {
    padding: 10px;
    gap: 10px;
}

.tile-editor-modal.compact-ui .tile-editor-sidebar {
    width: 180px !important;
}

.tile-editor-modal.compact-ui .tile-editor-sidebar .tool-group h3 {
    font-size: 10px !important;
}

.tile-editor-modal.compact-ui .pixel-tools {
    width: 40px !important;
}

.tile-editor-modal.compact-ui .tool-btn {
    width: 32px;
    height: 32px;
}

#dot-art-tool-modal.active {
    display: flex;
}

.modal-content.gallery-meta-modal {
    background: #1a1a1e;
    border: 1px solid var(--c-border-glass);
    width: 400px;
    max-width: 90vw;
    padding: 32px;
    border-radius: 8px;
    box-shadow: 0 4px 24px rgba(0, 0, 0, 0.6);
}

/* モーダル内の要素を強制的に縦並びにする (v68 追加) */
.gallery-meta-modal .modal-body {
    display: flex !important;
    flex-direction: column !important;
    gap: 16px;
    width: 100%;
}

/* --- Integrated Map Hub (Floating Legend + Actions) --- */
.integrated-map-hub {
    position: absolute;
    bottom: 24px;
    right: 24px;
    display: flex;
    flex-direction: column;
    align-items: flex-end;
    gap: 12px;
    z-index: 1000;
    pointer-events: none;
    /* Container itself should not block clicks */
}

.integrated-map-hub>* {
    pointer-events: auto;
    /* Children should be clickable */
}

/* Legend Panel - Floating Style */
.legend-panel {
    width: 280px;
    max-height: 85vh;
    /* 拡大: 400px -> 85vh */
    overflow-y: auto;
    background: var(--c-bg-glass);
    backdrop-filter: blur(12px) saturate(180%);
    -webkit-backdrop-filter: blur(12px) saturate(180%);
    border: 1px solid var(--c-border-glass);
    border-radius: 12px;
    padding: 16px;
    box-shadow: 0 8px 32px rgba(0, 0, 0, 0.5);
    transition: transform 0.3s cubic-bezier(0.22, 1, 0.36, 1), border-color 0.3s;
}

.legend-panel.is-pinned {
    border-color: var(--c-accent-cyan);
    box-shadow: 0 0 20px rgba(0, 212, 255, 0.3);
}


.legend-panel:hover {
    transform: translateY(-4px);
}

.legend-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 12px;
    padding-bottom: 8px;
    border-bottom: 1px solid rgba(255, 255, 255, 0.1);
}

.legend-header h4 {
    margin: 0;
    font-size: 0.85rem;
    color: var(--c-accent-cyan);
    text-transform: uppercase;
    letter-spacing: 0.05em;
    font-weight: 700;
}

.legend-header h4::before {
    content: '';
    display: inline-block;
    width: 3px;
    height: 12px;
    background: var(--c-accent-cyan);
    margin-right: 8px;
    box-shadow: 0 0 5px var(--c-accent-cyan);
}

.legend-content {
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.legend-item {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 6px 10px;
    background: rgba(255, 255, 255, 0.03);
    border: 1px solid rgba(255, 255, 255, 0.05);
    border-radius: 6px;
    transition: all 0.2s;
}

.legend-item:hover {
    background: rgba(255, 255, 255, 0.08);
    border-color: rgba(0, 212, 255, 0.3);
}

.legend-sample {
    width: 24px;
    height: 24px;
    min-width: 24px;
    border-radius: 4px;
    border: 1px solid rgba(255, 255, 255, 0.2);
    box-shadow: inset 0 0 5px rgba(0, 0, 0, 0.5);
}

.legend-label-input {
    flex: 1;
    background: transparent;
    border: none;
    color: var(--c-text-main);
    font-size: 0.8rem;
    padding: 2px 4px;
    outline: none;
}

/* Floating Action Bar - Hub Style */
.floating-action-bar {
    display: flex;
    align-items: center;
    gap: 4px;
    background: var(--c-bg-glass);
    backdrop-filter: blur(12px);
    -webkit-backdrop-filter: blur(12px);
    border: 1px solid var(--c-border-glass);
    border-radius: 50px;
    padding: 6px;
    box-shadow: 0 8px 24px rgba(0, 0, 0, 0.4);
}

.fab-btn {
    width: 40px;
    height: 40px;
    border-radius: 50%;
    border: 1px solid transparent;
    background: transparent;
    color: var(--c-text-main);
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    transition: all 0.3s;
}

.fab-btn:hover {
    background: rgba(0, 212, 255, 0.15);
    border-color: var(--c-accent-cyan);
    color: #fff;
    box-shadow: 0 0 10px rgba(0, 212, 255, 0.3);
}

.fab-separator {
    width: 1px;
    height: 24px;
    background: var(--c-border-glass);
    margin: 0 4px;
}

.small-icon-btn {
    background: none;
    border: none;
    color: var(--c-text-muted);
    cursor: pointer;
    padding: 4px;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: 4px;
    transition: all 0.2s;
}

.small-icon-btn:hover {
    color: var(--c-accent-cyan);
    background: rgba(255, 255, 255, 0.1);
}

/* Quick Info Area - Dynamic Rules */
.quick-info {
    padding-top: 12px;
    min-height: 80px;
}

.legend-content:not(:empty)+.quick-info {
    margin-top: 12px;
    border-top: 1px solid rgba(255, 255, 255, 0.1);
}

.quick-info .hint {
    font-size: 0.65rem;
    color: var(--c-text-muted);
    font-style: italic;
    text-align: center;
    margin-top: 20px;
}

.quick-info .rule-title {
    font-size: 0.75rem;
    font-weight: 700;
    margin-bottom: 6px;
}

/* ピン留め解除ボタン */
.unpin-btn {
    position: absolute;
    top: 10px;
    right: 10px;
    width: 20px;
    height: 20px;
    background: rgba(255, 255, 255, 0.1);
    border: none;
    border-radius: 50%;
    color: #fff;
    font-size: 12px;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: background 0.2s;
}

.unpin-btn:hover {
    background: rgba(244, 63, 94, 0.4);
}


.quick-info .rule-title::before {
    content: 'i';
    display: inline-flex;
    width: 14px;
    height: 14px;
    background: var(--c-accent-cyan);
    color: #000;
    font-size: 10px;
    border-radius: 50%;
    align-items: center;
    justify-content: center;
    font-weight: bold;
}

.quick-info .rule-content {
    font-size: 0.68rem;
    line-height: 1.4;
    color: var(--c-text-main);
    opacity: 0.9;
}

.quick-info .rule-section {
    margin-top: 8px;
}

.quick-info .rule-subtitle {
    font-size: 0.7rem;
    color: #fff;
    font-weight: 600;
    margin-bottom: 2px;
    display: block;
}

.quick-info .rule-subcontent {
    font-size: 0.65rem;
    line-height: 1.35;
    color: var(--c-text-muted);
}

/* Responsive */
@media (max-width: 960px) {
    .tool-sidebar {
        width: 100%;
        min-width: 100%;
        height: auto;
        max-height: 50vh;
    }

    .legend-content {
        grid-template-columns: 1fr;
    }
}

/* Modal Inputs */
.input-row {
    margin-bottom: 20px;
    text-align: left;
}

.input-row label {
    display: block;
    font-size: 13px;
    margin-bottom: 6px;
    color: #aaaab1;
}

.input-row input {
    width: 100%;
    padding: 10px 12px;
    background: rgba(0, 0, 0, 0.3);
    border: 1px solid #444;
    color: #eee;
    border-radius: 4px;
    box-sizing: border-box;
    font-size: 14px;
    transition: all 0.3s;
}

.input-row input:focus {
    border-color: var(--c-accent-cyan, #00d4ff);
    background: rgba(0, 212, 255, 0.05);
    outline: none;
}

.modal-footer {
    display: flex;
    justify-content: center;
    gap: 16px;
    margin-top: 32px;
}

.modal-footer .btn {
    padding: 10px 24px;
    border-radius: 4px;
    font-size: 13px;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.2s;
}

.btn-primary {
    background: var(--c-neon-cyan);
    color: #000;
    border: none;
}

.btn-primary:hover {
    filter: brightness(1.2);
    box-shadow: 0 0 15px rgba(0, 212, 255, 0.4);
}

/* --- リサイズハンドル --- */
#canvas-container {
    position: relative;
    display: inline-block;
    margin: 0;
    background: #111;
    border: 1px solid #333;
}

.resize-handle {
    position: absolute;
    background: rgba(0, 212, 255, 0.15);
    border: 1px solid rgba(0, 212, 255, 0.4);
    z-index: 50;
    transition: all 0.2s;
}

.resize-handle:hover {
    background: rgba(0, 212, 255, 0.4);
    border-color: #00d4ff;
    box-shadow: 0 0 10px rgba(0, 212, 255, 0.5);
}

.resize-handle.resize-x {
    right: -8px;
    top: 0;
    width: 8px;
    height: 100%;
    cursor: ew-resize;
    border-radius: 0 4px 4px 0;
}

.resize-handle.resize-y {
    bottom: -8px;
    left: 0;
    width: 100%;
    height: 8px;
    cursor: ns-resize;
    border-radius: 0 0 4px 4px;
}

.resize-handle.resize-xy {
    right: -8px;
    bottom: -8px;
    width: 16px;
    height: 16px;
    cursor: nwse-resize;
    border-radius: 0 0 4px 0;
    background: #00d4ff;
    border: none;
    clip-path: polygon(100% 0, 100% 100%, 0 100%);
}

/* --- 共通モーダルデザイン (キャラクターシート準拠) --- */
.modal-overlay {
    position: fixed;
    inset: 0;
    background: rgba(0, 0, 0, 0.75);
    z-index: 9990;
    display: none;
    align-items: center;
    justify-content: center;
}

.gallery-meta-modal {
    background: rgba(26, 26, 30, 0.85);
    backdrop-filter: blur(16px) saturate(180%);
    -webkit-backdrop-filter: blur(16px) saturate(180%);
    border: 1px solid rgba(84, 193, 249, 0.5);
    border-radius: 16px;
    padding: 28px 28px 24px;
    min-width: 320px;
    max-width: 90vw;
    max-height: 90vh;
    overflow-y: auto;
    /* overflow-x: hidden; ツールチップのはみ出しを許可するために解除 */
    color: #ccc;
    position: relative;
    box-shadow: 0 8px 32px rgba(0, 0, 0, 0.6);
    box-sizing: border-box;
}

.gallery-meta-modal *,
.gallery-meta-modal *::before,
.gallery-meta-modal *::after {
    box-sizing: border-box;
}

.gallery-meta-modal h3 {
    margin: 0 0 20px;
    font-size: 16px;
    color: var(--c-accent-cyan);
    border-bottom: 1px solid rgba(84, 193, 249, 0.4);
    padding-bottom: 12px;
    text-shadow: 0 0 8px rgba(0, 243, 255, 0.3);
}

.gallery-meta-modal label {
    display: block;
    font-size: 13px;
    color: #888;
    margin: 12px 0 5px;
}

.gallery-meta-modal label:first-of-type {
    margin-top: 0;
}

.gallery-meta-modal input[type="password"],
.gallery-meta-modal input[type="text"],
.gallery-meta-modal input[type="number"],
.gallery-meta-modal textarea {
    width: 100%;
    box-sizing: border-box;
    padding: 8px 10px;
    background: #111115;
    border: 1px solid #444;
    border-radius: 5px;
    color: #fff;
    font-size: 13px;
    margin-bottom: 4px;
    transition: border-color 0.2s;
    font-family: inherit;
}

.gallery-meta-modal textarea {
    min-height: 60px;
    resize: vertical;
}

.gallery-meta-modal input:focus,
.gallery-meta-modal textarea:focus {
    outline: none;
    border-color: #54c1f9;
    box-shadow: 0 0 8px rgba(84, 193, 249, 0.2);
}

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

/* モーダル用ボタン */
.modal-btn {
    padding: 8px 20px;
    border-radius: 6px;
    font-size: 13px;
    font-weight: bold;
    cursor: pointer;
    transition: all 0.2s;
    border: 1px solid transparent;
}

.modal-btn-primary {
    background: var(--c-accent-cyan);
    color: #000;
}

.modal-btn-primary:hover {
    background: #54f9f9;
    box-shadow: 0 0 15px rgba(0, 212, 255, 0.4);
}

.modal-btn-secondary {
    background: rgba(255, 255, 255, 0.05);
    border-color: #444;
    color: #ccc;
}

.modal-btn-secondary:hover {
    background: rgba(255, 255, 255, 0.1);
    color: #fff;
    border-color: #666;
}

/* セル編集固有 */
.edit-section-title {
    font-size: 11px;
    color: var(--c-accent-cyan);
    opacity: 0.8;
    margin-bottom: 8px;
    text-transform: uppercase;
    letter-spacing: 0.1em;
    display: flex;
    align-items: center;
    gap: 6px;
}

.edit-section-title::before {
    content: '';
    display: block;
    width: 3px;
    height: 11px;
    background: var(--c-accent-cyan);
    border-radius: 2px;
}

.edit-divider {
    height: 1px;
    background: rgba(255, 255, 255, 0.05);
    margin: 16px 0;
}

/* ==========================================================================
   保存ダイアログ・利用規約ツールチップ (v68 追加)
   ========================================================================== */
.modal-content.gallery-meta-modal {
    background: #1a1a1e;
    border: 1px solid var(--c-border-glass);
    width: 400px;
    max-width: 90vw;
    padding: 32px;
    border-radius: 8px;
    box-shadow: 0 4px 24px rgba(0, 0, 0, 0.6);
    overflow: visible !important;
    /* ツールチップのはみ出しを確実に許可 */
    position: relative;
}

/* モーダル内の要素を強制的に縦並びにする (v68 追加) */
.gallery-meta-modal .modal-body {
    display: flex !important;
    flex-direction: column !important;
    gap: 16px;
    width: 100% !important;
    overflow: visible !important;
    /* 子要素のはみ出しを許可 */
}

.tos-container {
    margin: 12px 0 20px 0 !important;
    border-top: 1px solid #333;
    padding-top: 12px;
    width: 100% !important;
    overflow: visible !important;
}

.tos-label {
    display: flex !important;
    align-items: center !important;
    justify-content: flex-start !important;
    cursor: pointer;
    font-size: 14px;
    position: relative !important;
    user-select: none;
    width: 100% !important;
}

.tos-label input[type="checkbox"] {
    width: auto !important;
    margin: 0 6px 0 0 !important;
    cursor: pointer;
}

.tos-icon-wrap {
    margin-left: auto !important;
    /* 右側に強制移動 */
    display: inline-flex !important;
    align-items: center;
    justify-content: center;
    color: var(--c-accent-cyan, #07aee5);
    cursor: help;
    position: relative !important;
    width: 20px;
    height: 20px;
    flex-shrink: 0;
}

/* キャラクターシートと共通のファイルアイコン */
.tos-icon-file {
    display: block !important;
    width: 18px !important;
    height: 18px !important;
    background-color: currentColor;
    -webkit-mask-image: url('../../img/character-sheet/icon-file.svg');
    mask-image: url('../../img/character-sheet/icon-file.svg');
    -webkit-mask-size: contain;
    mask-size: contain;
    -webkit-mask-repeat: no-repeat;
    mask-repeat: no-repeat;
    -webkit-mask-position: center;
    mask-position: center;
}

.tos-icon-wrap:hover .tos-tooltip {
    display: block !important;
    opacity: 1 !important;
    transform: translateY(0) !important;
}

.tos-tooltip {
    display: none;
    opacity: 0;
    position: absolute !important;
    bottom: 140% !important;
    right: 0 !important;
    /* アイコンを基準に左側に展開 */
    left: auto !important;
    width: max-content;
    min-width: 160px;
    max-width: min(320px, 85vw);
    background: rgba(20, 20, 25, 0.98) !important;
    border: 1px solid var(--c-accent-cyan, #07aee5) !important;
    border-radius: 8px;
    padding: 12px;
    color: #eee;
    font-size: 11px;
    line-height: 1.6;
    z-index: 100000 !important;
    /* 最前面に表示 */
    box-shadow: 0 4px 20px rgba(0, 0, 0, 0.8);
    transition: all 0.2s ease;
    pointer-events: none;
    white-space: normal;
    transform: translateY(10px);
}

.tooltip-title {
    display: block;
    font-family: var(--font-head);
    font-size: 13px;
    font-weight: bold;
    color: var(--c-accent-cyan, #07aee5);
    margin-bottom: 8px;
    padding-bottom: 4px;
    border-bottom: 1px solid rgba(7, 174, 229, 0.3);
    line-height: 1.4;
    text-align: left;
}

.tos-tooltip b {
    color: var(--c-accent-cyan, #07aee5);
    font-weight: bold;
}

/* ツールチップの三角形 */
.tos-tooltip::after {
    content: "";
    position: absolute;
    top: 100%;
    right: 15px;
    /* 右側に固定 (v68 改) */
    left: auto;
    transform: none;
    border-width: 8px;
    border-style: solid;
    border-color: var(--c-accent-cyan, #07aee5) transparent transparent transparent;
}

/* モバイル向け調整 */
@media screen and (max-width: 480px) {
    .tos-tooltip {
        width: 250px;
        max-width: 75vw;
        right: -30px;
        /* アイコンを少し右に越える程度に調整 */
    }

    .tos-tooltip::after {
        right: 33px;
    }
}

/* 見切れ防止用の余白設定 (v71) */
#goto-gallery {
    margin-bottom: 20px !important;
    display: block !important;
}

/* タイルエディタ・タイルアイテム (v69) */
.tile-grid-item {
    aspect-ratio: 1 / 1;
    background: rgba(255, 255, 255, 0.05);
    border: 1px solid var(--c-border-glass);
    border-radius: 4px;
    cursor: pointer;
    overflow: hidden;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.2s cubic-bezier(0.4, 0, 0.2, 1);
}

.tile-grid-item:hover {
    background: rgba(255, 255, 255, 0.1);
    border-color: rgba(255, 255, 255, 0.3);
    transform: translateY(-2px);
}

.tile-grid-item img {
    width: 90%;
    height: 90%;
    object-fit: contain;
    image-rendering: pixelated;
}

.tile-grid-item.selected {
    background: rgba(7, 174, 229, 0.2);
    border-color: var(--c-accent-cyan);
    box-shadow: 0 0 15px rgba(7, 174, 229, 0.4), inset 0 0 10px rgba(7, 174, 229, 0.2);
}

/* Import modal styles moved to pixel-editor.css */

/* --- Tile Board System Styles (v72/v74.5 統合) --- */
.tile-preview-box {
    width: 60px;
    height: 60px;
    border: 2px solid var(--c-accent-cyan);
    background: rgba(0, 0, 0, 0.4);
    border-radius: 6px;
    display: flex;
    align-items: center;
    justify-content: center;
    overflow: hidden;
    box-shadow: inset 0 0 10px rgba(0, 212, 255, 0.2);
    margin-right: 12px;
}

.tile-preview-box img {
    max-width: 90%;
    max-height: 90%;
    object-fit: contain;
    image-rendering: pixelated;
}

.mini-tile-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(44px, 1fr));
    gap: 6px;
    max-height: 220px;
    overflow-y: auto;
    padding: 8px;
    background: rgba(0, 0, 0, 0.3);
    border-radius: 8px;
    border: 1px solid var(--c-border-glass);
}

.mini-tile-item {
    width: 100%;
    aspect-ratio: 1;
    border: 1px solid rgba(255, 255, 255, 0.1);
    border-radius: 4px;
    cursor: pointer;
    background-size: contain;
    background-repeat: no-repeat;
    background-position: center;
    background-color: rgba(255, 255, 255, 0.03);
    transition: all 0.2s ease;
    image-rendering: pixelated;
    overflow: hidden;
    position: relative;
}

.mini-tile-item:hover {
    border-color: var(--c-accent-cyan);
    background-color: rgba(0, 212, 255, 0.15);
    transform: translateY(-2px);
}

.mini-tile-item.active {
    border-color: var(--c-neon-cyan);
    background-color: rgba(0, 255, 255, 0.1);
    box-shadow: 0 0 12px rgba(0, 255, 255, 0.3);
}

.mini-tile-item img {
    width: 100%;
    height: 100%;
    object-fit: contain;
    image-rendering: pixelated;
}

/* タイル配置プレビュー（ドラッグ中） */
.tile-placement-preview {
    pointer-events: none;
    opacity: 0.6;
    border: 1px dashed var(--c-accent-cyan);
    mix-blend-mode: normal;
}

.import-tile-item:hover .tile-name-dim {
    opacity: 1;
}