

/* =========================================
   送電世界 共通シェル（上部ナビ）
   全ページ共通で読み込む（index.html で theme.css の後）。色と
   フォントは theme.css の変数を使う。各コンテンツページ独自の
   スタイルとぶつからないよう、body/*等の汎用セレクタは
   極力使わずクラス/ID限定で書くこと。
   ========================================= */
/* 上部タブはマルモニカ（12x16 設計）。等倍は 16px、2 倍は 32px。16px 以外にしない */
@font-face {
    font-family: 'MaruMonica';
    src: url('/fonts/x12y16pxMaruMonica.ttf') format('truetype');
}
@font-face {
    font-family: 'TenoText 7x13';
    src: url('/fonts/TenoText 7x13.otf') format('opentype');
}

#sodenmir-topbar {
    box-sizing: border-box;
    position: sticky;
    top: 0;
    z-index: 9999;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 16px;
    padding: 8px 16px;
    min-height: 56px;
    /* タイル（高さ 56）よりバーが高い分は、タイル最上段の空の色で埋める */
    background-color: #6688CC;
    background-image: url('/images/tile.png');
    background-repeat: repeat-x;
    background-position: left bottom;
    image-rendering: pixelated;
    border-bottom: 2px solid #A9D9D0;
    font-family: 'MaruMonica', 'PixelMplus12', monospace;
    line-height: 16px;   /* body の倍率指定（PROFILE / POLICY）を受け継がない */
}

/* ハロウィン限定のタイル（menu.js が 10/31 だけ付ける） */
#sodenmir-topbar.sodenmir-halloween {
    background-image: url('/images/tile_halloween.png');
}

/* SANDBOX 以下のページ専用タイル（menu.js が付ける） */
#sodenmir-topbar.sodenmir-sandbox {
    background-image: url('/images/tile_sandbox.png');
}

#sodenmir-topbar * {
    box-sizing: border-box;
}

/* ドット絵アイコンは content-box にして、width/height を中身の寸法（実寸の整数倍）で書く。
   border-box だと 1px の枠線の分だけ中身が縮んで非整数倍になる（実寸 16 → 表示 14 など）。
   上の `#sodenmir-topbar *` は ID を含むので、上部ナビ内は ID 付きで上書きする。 */
#sodenmir-topbar .sodenmir-top-icon,
#sodenmir-topbar .sodenmir-row-icon,
#sodenmir-topbar .sodenmir-brand-icon,
.sodenmir-top-icon,
.sodenmir-row-icon {
    box-sizing: content-box;
}

.sodenmir-branding {
    display: flex;
    align-items: center;
    gap: 8px;
    text-decoration: none;
    flex-shrink: 0;
}

.sodenmir-brand-icon {
    width: 32px;   /* TENOKUN_ICON は 32x32 を 8 倍で書き出してある。1 倍 */
    height: 32px;
    display: block;
    border: 1px solid #038C7F;
    background: #fff;
    image-rendering: pixelated;
}

.sodenmir-brand-banner {
    width: 196px;
    height: 48px;
    display: block;
    image-rendering: pixelated;
}

#sodenmir-nav {
    display: flex;
    align-items: center;
    gap: 10px;
    flex-wrap: wrap;
    justify-content: flex-end;
}

.sodenmir-top-item,
.sodenmir-group-summary {
    display: flex;
    align-items: center;
    gap: 6px;
    padding: 5px 8px;
    text-decoration: none;
    border: 1px dotted var(--border);
    background-color: rgba(255, 255, 255, 0.75);
    cursor: pointer;
    list-style: none;
    font-family: 'MaruMonica', 'PixelMplus12', monospace;
    font-size: 16px;
    line-height: 16px;
    color: var(--sub);
}
.sodenmir-group-summary::-webkit-details-marker { display: none; }

.sodenmir-top-item:hover,
.sodenmir-group-summary:hover {
    background-color: var(--border);
    border-style: solid;
}

.sodenmir-top-item.active {
    background-color: var(--text);
    border: 1px solid var(--border);
}
.sodenmir-top-item.active .sodenmir-top-text {
    color: #FFFFFF;
}

.sodenmir-top-icon {
    width: 16px;
    height: 16px;
    object-fit: contain;
    background-color: var(--bg);
    border: 1px solid var(--border);
    image-rendering: pixelated;
    flex-shrink: 0;
}

/* 開閉記号は 6x5 の画像を等倍で出す（閉じている＝下向き / 開いている＝上向き） */
.sodenmir-caret {
    width: 6px;
    height: 5px;
    flex-shrink: 0;
    background: url('/images/tab_triangle_down.png') no-repeat;
    image-rendering: pixelated;
}
.sodenmir-group[open] > .sodenmir-group-summary .sodenmir-caret {
    background-image: url('/images/tab_triangle_up.png');
}

.sodenmir-group {
    position: relative;
}
.sodenmir-group-panel {
    position: absolute;
    top: 110%;
    right: 0;
    min-width: 170px;
    background: var(--bg);
    border: 1px solid var(--border);
    box-shadow: 0 4px 10px rgba(51, 51, 85, 0.2);
    z-index: 60;
    display: flex;
    flex-direction: column;
}
/* 中身がまだ無いグループ（SANDBOX など）は開いても何も出さない */
.sodenmir-group-panel:empty { display: none; }

.sodenmir-row-item {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 6px 10px;
    text-decoration: none;
    border-bottom: 1px dotted var(--border2);
    font-family: 'MaruMonica', 'PixelMplus12', monospace;
    font-size: 16px;
    line-height: 16px;
    color: var(--sub);
}
.sodenmir-row-item:last-child { border-bottom: none; }
.sodenmir-row-item:hover { background-color: var(--panel2); }
.sodenmir-row-item.active {
    background-color: var(--text);
    color: #ffffff;
}
.sodenmir-row-item.active .sodenmir-row-text { color: #ffffff; }

.sodenmir-row-icon {
    width: 16px;
    height: 16px;
    object-fit: contain;
    background-color: var(--bg);
    border: 1px solid var(--border);
    image-rendering: pixelated;
    flex-shrink: 0;
}

#sodenmir-mobile-toggle {
    display: none;
    align-items: center;
    padding: 6px 12px;
    border: 1px solid var(--border);
    background: rgba(255, 255, 255, 0.85);
    font-family: 'MaruMonica', 'PixelMplus12', monospace;
    font-size: 16px;
    line-height: 16px;
    color: var(--sub);
    cursor: pointer;
}
#sodenmir-mobile-toggle.open {
    background: var(--text);
    color: #ffffff;
}

/* BGM 再生ボタン：画像そのものがボタン（枠・背景・余白なし、16px 等倍） */
#sodenmir-bgm {
    flex-shrink: 0;
    display: block;
    margin: 0;
    padding: 0;
    border: 0;
    background: none;
    cursor: pointer;
    font-size: 0;
    line-height: 0;
}
#sodenmir-bgm img {
    display: block;
    width: 16px;
    height: 16px;
    image-rendering: pixelated;
}
#sodenmir-topbar > #sodenmir-bgm { margin-left: auto; margin-right: 0; }

#sodenmir-mobile-nav {
    display: none;
    flex-direction: column;
    background: var(--bg);
    border-bottom: 2px solid #A9D9D0;
    font-family: 'MaruMonica', 'PixelMplus12', monospace;
    line-height: 16px;
}
#sodenmir-mobile-nav.open { display: flex; }
#sodenmir-mobile-nav .sodenmir-row-item,
#sodenmir-mobile-nav .sodenmir-group-summary {
    border-bottom: 1px dotted var(--border2);
}
#sodenmir-mobile-nav .sodenmir-group-panel {
    position: static;
    box-shadow: none;
    border: none;
    border-top: 1px dotted var(--border2);
}
#sodenmir-mobile-nav .sodenmir-group-summary {
    background: transparent;
    border-left: none;
    border-right: none;
    border-top: none;
}

@media (max-width: 720px) {
    #sodenmir-nav {
        display: none;
    }
    #sodenmir-mobile-toggle {
        display: flex;
    }
}
