:root {
    --bg-dark: #090e17;
    --bg-sidebar: #0d1522;
    --bg-panel: #111b2b;
    --bg-card: #162338;
    --border: #243856;
    --cyan: #4cd4f5;
    --cyan-dim: #1d6f8a;
    --amber: #f5b942;
    --green: #4de08a;
    --red: #ff6b6b;
    --text-main: #e6eef8;
    --text-sub: #9fb2ca;
}

* { box-sizing: border-box; }

body {
    margin: 0;
    padding: 0;
    font-family: 'Helvetica Neue', Arial, 'Hiragino Kaku Gothic ProN', 'Hiragino Sans', Meiryo, sans-serif;
    line-height: 1.7;
    color: var(--text-main);
    background-color: var(--bg-dark);
}

a { color: var(--cyan); text-decoration: none; }
a:hover { text-decoration: underline; }

/* ヘッダー */
.wiki-header {
    background: rgba(9, 14, 23, 0.96);
    border-bottom: 1px solid var(--border);
    padding: 12px 20px;
    display: flex;
    justify-content: space-between;
    align-items: center;
    flex-wrap: wrap;
    gap: 8px 16px;
    position: sticky;
    top: 0;
    z-index: 1000;
}
.wiki-brand {
    font-size: 1.2rem;
    font-weight: 800;
    letter-spacing: 0.08em;
    color: #fff;
}
.wiki-brand span { color: var(--cyan); }
.wiki-header-links {
    display: flex;
    flex-wrap: wrap;
    gap: 10px 16px;
    font-size: 0.9rem;
    font-weight: 700;
}

/* 2カラムレイアウト */
.wiki-layout {
    max-width: 1280px;
    margin: 0 auto;
    display: grid;
    grid-template-columns: 250px 1fr;
    gap: 24px;
    padding: 24px 18px 60px;
    align-items: start;
}

/* サイドバー */
.wiki-sidebar {
    background: var(--bg-sidebar);
    border: 1px solid var(--border);
    border-radius: 8px;
    padding: 16px;
    position: sticky;
    top: 72px;
}
.side-group-title {
    font-size: 0.78rem;
    font-weight: 700;
    letter-spacing: 0.1em;
    color: var(--amber);
    border-bottom: 1px solid var(--border);
    padding-bottom: 5px;
    margin: 16px 0 8px;
}
.side-group-title:first-child { margin-top: 0; }
.side-menu {
    list-style: none;
    margin: 0;
    padding: 0;
}
.side-menu li { margin-bottom: 4px; }
.side-menu a {
    display: block;
    padding: 7px 10px;
    border-radius: 5px;
    color: var(--text-sub);
    font-size: 0.92rem;
    font-weight: 600;
    transition: background 0.15s, color 0.15s;
}
.side-menu a:hover {
    background: rgba(76, 212, 245, 0.1);
    color: #fff;
    text-decoration: none;
}
.side-menu a.active {
    background: rgba(76, 212, 245, 0.18);
    color: var(--cyan);
    border-left: 3px solid var(--cyan);
}
.badge-live {
    font-size: 0.68rem;
    background: rgba(77, 224, 138, 0.18);
    color: var(--green);
    border: 1px solid rgba(77, 224, 138, 0.4);
    border-radius: 4px;
    padding: 1px 5px;
    margin-left: 6px;
}

/* メイン領域 */
.wiki-main {
    background: var(--bg-panel);
    border: 1px solid var(--border);
    border-radius: 8px;
    padding: 28px 32px;
    min-width: 0;
}
.wiki-main h1 {
    margin: 0 0 18px;
    font-size: 1.65rem;
    color: #fff;
    border-bottom: 2px solid var(--cyan);
    padding-bottom: 10px;
}
.wiki-main h2 {
    margin: 30px 0 12px;
    font-size: 1.2rem;
    color: var(--cyan);
    border-left: 4px solid var(--cyan);
    padding-left: 10px;
}
.wiki-main p { color: var(--text-sub); font-size: 0.95rem; }

/* テーブル */
.table-wrap {
    width: 100%;
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
    margin: 12px 0 24px;
    border: 1px solid var(--border);
    border-radius: 6px;
    background: #0d1522;
}
.wiki-table {
    width: 100%;
    border-collapse: separate;
    border-spacing: 0;
    font-size: 0.88rem;
    background: #0d1522;
}
.wiki-table th, .wiki-table td {
    border-right: 1px solid var(--border);
    border-bottom: 1px solid var(--border);
    padding: 9px 10px;
    text-align: left;
    vertical-align: middle;
    white-space: nowrap;
}
.wiki-table th:last-child, .wiki-table td:last-child {
    border-right: none;
}
.wiki-table tbody tr:last-child td {
    border-bottom: none;
}
.wiki-table th {
    background: #13253b;
    color: var(--cyan);
    font-weight: 700;
    white-space: nowrap;
}
.wiki-table td.num, .wiki-table th.num {
    text-align: center;
    white-space: nowrap;
}
/* 最後の列が長文（数値列.numでない場合）だけ折り返し＆最小幅を確保 */
.wiki-table td:last-child:not(.num) {
    white-space: normal;
    min-width: 260px;
    line-height: 1.6;
}
.wiki-table tr:hover td {
    background: rgba(255, 255, 255, 0.03);
}

/* ユニット・塔・罠アイコン＆名前横並び */
.entity-name {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    white-space: nowrap;
}
.wiki-icon {
    width: 30px;
    height: 30px;
    object-fit: contain;
    border-radius: 4px;
    background: #16263d;
    border: 1px solid rgba(76, 212, 245, 0.45);
    padding: 2px;
    flex-shrink: 0;
}
.kanji-badge {
    display: inline-block;
    width: 28px;
    height: 28px;
    line-height: 26px;
    text-align: center;
    font-weight: 800;
    border-radius: 4px;
    background: #1d4f8a;
    color: #fff;
    border: 1px solid var(--cyan);
    flex-shrink: 0;
}
.key-tag {
    display: inline-block;
    padding: 1px 6px;
    font-family: monospace;
    font-size: 0.82rem;
    background: #1e2d44;
    border: 1px solid #354e73;
    border-radius: 4px;
    color: var(--amber);
}

/* 教官コスチューム サムネイル＆シルエット枠 */
.costume-thumb-wrap {
    position: relative;
    width: 78px;
    height: 78px;
    margin: 0 auto;
}
.costume-thumb {
    width: 78px;
    height: 78px;
    object-fit: contain;
    border-radius: 6px;
    background: #0b1422;
    border: 1px solid var(--border);
    padding: 3px;
    display: block;
}
.costume-thumb.is-silhouette {
    background: radial-gradient(circle at 50% 45%, #3a587e 0%, #192a42 85%);
    border-color: rgba(245, 185, 66, 0.55);
}
.secret-pill {
    position: absolute;
    bottom: 2px;
    left: 50%;
    transform: translateX(-50%);
    font-size: 0.6rem;
    font-weight: 800;
    letter-spacing: 0.08em;
    padding: 1px 5px;
    border-radius: 3px;
    background: rgba(9, 14, 23, 0.88);
    color: var(--amber);
    border: 1px solid rgba(245, 185, 66, 0.5);
    white-space: nowrap;
}

/* カード・ボックス */
.info-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(240px, 1fr));
    gap: 14px;
    margin: 16px 0 24px;
}
.info-card {
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: 6px;
    padding: 16px;
}
.info-card h3 {
    margin: 0 0 6px;
    font-size: 1rem;
    color: var(--amber);
}
.info-card p {
    margin: 0;
    font-size: 0.88rem;
}
.notice-box {
    background: rgba(76, 212, 245, 0.07);
    border: 1px solid var(--cyan-dim);
    border-radius: 6px;
    padding: 14px 18px;
    margin: 16px 0;
    font-size: 0.92rem;
    color: var(--text-main);
}
.alert-error {
    background: rgba(255, 107, 107, 0.12);
    border: 1px solid var(--red);
    color: #ffb8b8;
    padding: 12px 16px;
    border-radius: 6px;
    margin-bottom: 16px;
}
.alert-success {
    background: rgba(77, 224, 138, 0.12);
    border: 1px solid var(--green);
    color: #b7f5cf;
    padding: 12px 16px;
    border-radius: 6px;
    margin-bottom: 16px;
}

/* 掲示板 */
.bbs-form {
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: 8px;
    padding: 18px;
    margin-bottom: 24px;
}
.form-row {
    margin-bottom: 12px;
}
.form-row-inline {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 12px;
    margin-bottom: 12px;
}
.bbs-form label {
    display: block;
    font-size: 0.85rem;
    font-weight: 700;
    color: var(--cyan);
    margin-bottom: 4px;
}
.bbs-form input[type="text"],
.bbs-form input[type="password"],
.bbs-form textarea {
    width: 100%;
    padding: 9px 12px;
    border-radius: 5px;
    border: 1px solid var(--border);
    background: #0a101b;
    color: #fff;
    font-size: 0.94rem;
    font-family: inherit;
}
.bbs-form textarea {
    min-height: 100px;
    resize: vertical;
}
.hp-field {
    position: absolute;
    left: -9999px;
    width: 1px;
    height: 1px;
    overflow: hidden;
}
.btn-submit {
    background: linear-gradient(135deg, #2799c9, #1d6f9e);
    color: #fff;
    border: 1px solid var(--cyan);
    padding: 9px 22px;
    border-radius: 5px;
    font-size: 0.94rem;
    font-weight: 700;
    cursor: pointer;
}
.btn-submit:hover { opacity: 0.92; }
.btn-danger {
    background: rgba(255, 107, 107, 0.16);
    color: #ff9c9c;
    border: 1px solid var(--red);
    padding: 3px 10px;
    border-radius: 4px;
    font-size: 0.78rem;
    cursor: pointer;
}

.post-list {
    display: flex;
    flex-direction: column;
    gap: 12px;
}
.post-card {
    background: #0e1624;
    border: 1px solid var(--border);
    border-radius: 6px;
    padding: 14px 16px;
}
.post-meta {
    display: flex;
    justify-content: space-between;
    align-items: center;
    flex-wrap: wrap;
    gap: 8px;
    font-size: 0.83rem;
    color: var(--text-sub);
    border-bottom: 1px dashed var(--border);
    padding-bottom: 6px;
    margin-bottom: 8px;
}
.post-author { color: var(--cyan); font-weight: 700; }
.post-title { font-weight: 700; color: #fff; font-size: 1rem; margin-bottom: 6px; }
.post-pass-badge {
    display: inline-block;
    background: rgba(245, 185, 66, 0.16);
    border: 1px solid var(--amber);
    color: var(--amber);
    padding: 2px 8px;
    border-radius: 4px;
    font-size: 0.82rem;
    font-weight: 700;
    margin-bottom: 8px;
}
.post-body {
    white-space: pre-wrap;
    word-break: break-word;
    font-size: 0.94rem;
    color: var(--text-main);
}

/* タブ（ランキング切替等） */
.sub-tabs {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
    margin-bottom: 18px;
}
.sub-tabs a {
    padding: 6px 14px;
    border-radius: 5px;
    border: 1px solid var(--border);
    background: #0d1522;
    color: var(--text-sub);
    font-size: 0.88rem;
    font-weight: 700;
}
.sub-tabs a.active {
    border-color: var(--cyan);
    background: rgba(76, 212, 245, 0.16);
    color: var(--cyan);
}

/* フッター */
.wiki-footer {
    text-align: center;
    padding: 24px 16px;
    border-top: 1px solid var(--border);
    color: var(--text-sub);
    font-size: 0.85rem;
    background: #060a10;
}

/* 今後の対戦予定ピックアップ＆カウントダウン */
.upcoming-list {
    display: flex;
    flex-direction: column;
    gap: 8px;
}
.upcoming-row {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 8px 10px;
    padding: 8px 12px;
    border-radius: 6px;
    background: rgba(9, 14, 23, 0.72);
    border: 1px solid var(--border);
    font-size: 0.86rem;
}
.upcoming-id {
    font-weight: 800;
    color: var(--cyan);
}
.upcoming-author {
    font-weight: 700;
    color: #fff;
}
.upcoming-pass {
    padding: 1px 7px;
    border-radius: 4px;
    background: rgba(245, 185, 66, 0.16);
    border: 1px solid var(--amber);
    color: var(--amber);
    font-size: 0.78rem;
    font-weight: 700;
}

/* 希望時刻ピッカー */
.schedule-picker-box {
    background: rgba(9, 14, 23, 0.55);
    border: 1px solid var(--border);
    border-radius: 6px;
    padding: 12px;
}
.match-mode-radios {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
    margin-top: 6px;
}
.bbs-form label.radio-pill {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    margin: 0;
    padding: 6px 12px;
    border-radius: 5px;
    background: #102036;
    border: 1px solid var(--border);
    color: var(--text-main);
    font-size: 0.84rem;
    cursor: pointer;
}
.schedule-input-area {
    margin-top: 10px;
}
.schedule-input-row {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 8px;
}
.schedule-input-row input[type="datetime-local"] {
    padding: 7px 10px;
    border-radius: 5px;
    border: 1px solid var(--cyan-dim);
    background: #0a101b;
    color: #fff;
    font-size: 0.9rem;
    color-scheme: dark;
}
.utc-preview-text {
    margin-top: 6px;
    font-size: 0.8rem;
    color: var(--amber);
    font-weight: 700;
}

/* 投稿カード内のカウントダウンバー＆参加希望ボタン */
.post-schedule-bar {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 6px 10px;
    padding: 6px 10px;
    border-radius: 5px;
    margin-bottom: 8px;
    font-size: 0.84rem;
    border: 1px solid var(--border);
    background: #101d30;
}
.post-schedule-bar.is-upcoming,
.match-countdown.is-upcoming {
    border-color: var(--cyan-dim);
}
.post-schedule-bar.is-upcoming .cd-status,
.match-countdown.is-upcoming .cd-status {
    color: var(--cyan);
    font-weight: 800;
}
.post-schedule-bar.is-live,
.match-countdown.is-live {
    border-color: var(--green);
    background: rgba(77, 224, 138, 0.12);
}
.post-schedule-bar.is-live .cd-status,
.match-countdown.is-live .cd-status {
    color: var(--green);
    font-weight: 800;
}
.post-schedule-bar.is-ended,
.match-countdown.is-ended {
    opacity: 0.65;
}
.cd-time {
    color: var(--text-sub);
    font-size: 0.8rem;
}
.btn-join-quick {
    background: rgba(77, 224, 138, 0.16);
    color: var(--green);
    border: 1px solid rgba(77, 224, 138, 0.55);
    border-radius: 4px;
    padding: 2px 9px;
    font-size: 0.76rem;
    font-weight: 700;
    cursor: pointer;
}
.btn-join-quick:hover {
    background: rgba(77, 224, 138, 0.28);
}

/* ===== スマホ・タブレット対応 ===== */
@media (max-width: 860px) {
    .wiki-header {
        padding: 10px 14px;
    }
    .wiki-header-links {
        font-size: 0.82rem;
        gap: 8px 12px;
    }
    .wiki-layout {
        grid-template-columns: 1fr;
        gap: 16px;
        padding: 14px 10px 40px;
    }
    .wiki-sidebar {
        position: static;
        padding: 12px;
    }
    .wiki-main {
        padding: 18px 14px;
    }
    .wiki-main h1 {
        font-size: 1.35rem;
    }
    .form-row-inline {
        grid-template-columns: 1fr;
    }

    /* 横スクロール可能な案内バー */
    .table-wrap::before {
        content: "← 横にスクロールできます →";
        display: block;
        position: sticky;
        left: 0;
        font-size: 0.74rem;
        color: #8ab4d6;
        background: #0a1220;
        padding: 4px 10px;
        border-bottom: 1px solid var(--border);
    }

    .wiki-table {
        font-size: 0.82rem;
    }
    .wiki-table th, .wiki-table td {
        padding: 7px 8px;
    }
    .wiki-table td:last-child:not(.num) {
        min-width: 240px;
    }
    .costume-thumb-wrap,
    .costume-thumb {
        width: 64px;
        height: 64px;
    }

    /* 1列目がキー/ID/順位(.num)の表 → 2列目（兵科名・施設名・衣装サムネ）を左端に固定 */
    .wiki-table:has(tbody td:first-child.num) th:nth-child(2),
    .wiki-table:has(tbody td:first-child.num) td:nth-child(2) {
        position: sticky;
        left: 0;
        z-index: 2;
        background: #101b2e;
        border-right: 2px solid #2e4a6e;
    }
    .wiki-table:has(tbody td:first-child.num) thead th:nth-child(2) {
        z-index: 3;
        background: #172b45;
    }

    /* 1列目が名称の表（小型装置・特別ルール・ショートカット）→ 1列目を左端に固定 */
    .wiki-table:not(:has(tbody td:first-child.num)) th:first-child,
    .wiki-table:not(:has(tbody td:first-child.num)) td:first-child {
        position: sticky;
        left: 0;
        z-index: 2;
        background: #101b2e;
        border-right: 2px solid #2e4a6e;
    }
    .wiki-table:not(:has(tbody td:first-child.num)) thead th:first-child {
        z-index: 3;
        background: #172b45;
    }
}
/* 言語切替スイッチ */
.lang-switch {
    display: inline-flex;
    border: 1px solid var(--border);
    border-radius: 5px;
    overflow: hidden;
    background: #0d1522;
}
.lang-switch a {
    padding: 2px 9px;
    font-size: 0.78rem;
    font-weight: 800;
    color: var(--text-sub);
}
.lang-switch a.active {
    background: rgba(76, 212, 245, 0.24);
    color: var(--cyan);
}

/* アイコン横の小型漢字バッジ（併記用） */
.kanji-badge.kanji-sub {
    width: 22px;
    height: 22px;
    line-height: 20px;
    font-size: 0.75rem;
    background: #143258;
    border-color: rgba(76, 212, 245, 0.55);
}

/* 対戦コアタイム目安ボックス */
.match-time-box {
    background: linear-gradient(135deg, rgba(22, 35, 56, 0.95), rgba(13, 21, 34, 0.98));
    border: 1px solid var(--cyan-dim);
    border-radius: 8px;
    padding: 14px 16px;
    margin-bottom: 18px;
}
.match-time-title {
    font-weight: 800;
    font-size: 0.95rem;
    color: var(--cyan);
    margin-bottom: 10px;
}
.match-time-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(230px, 1fr));
    gap: 10px;
    margin-bottom: 8px;
}
.match-time-item {
    background: rgba(9, 14, 23, 0.65);
    border: 1px solid var(--border);
    border-radius: 6px;
    padding: 8px 12px;
    display: flex;
    flex-direction: column;
    gap: 3px;
}
.match-time-label {
    font-size: 0.78rem;
    color: var(--text-sub);
}
.local-time-pill {
    font-size: 0.8rem;
    color: var(--amber);
    font-weight: 700;
}
.match-time-note {
    font-size: 0.8rem;
    color: var(--text-sub);
}

/* クイック定型入力ボタン */
.quick-preset-row {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 6px;
    margin-bottom: 12px;
}
.quick-preset-label {
    font-size: 0.78rem;
    color: var(--text-sub);
}
.btn-preset {
    background: #102036;
    color: var(--cyan);
    border: 1px solid var(--cyan-dim);
    border-radius: 4px;
    padding: 4px 9px;
    font-size: 0.78rem;
    font-weight: 700;
    cursor: pointer;
}
.btn-preset:hover {
    background: rgba(76, 212, 245, 0.16);
}

/* 掲示板インライン翻訳ボタン＆結果枠 */
.btn-translate {
    background: rgba(76, 212, 245, 0.12);
    color: var(--cyan);
    border: 1px solid var(--cyan-dim);
    border-radius: 4px;
    padding: 2px 8px;
    font-size: 0.76rem;
    font-weight: 700;
    cursor: pointer;
}
.btn-translate:hover {
    background: rgba(76, 212, 245, 0.24);
}
.translated-box {
    margin-top: 10px;
    padding: 10px 12px;
    border-radius: 5px;
    background: rgba(76, 212, 245, 0.08);
    border-left: 3px solid var(--cyan);
    font-size: 0.88rem;
}
.translated-head {
    display: flex;
    justify-content: space-between;
    align-items: center;
    font-size: 0.75rem;
    color: var(--amber);
    font-weight: 700;
    margin-bottom: 5px;
}
.translated-text {
    white-space: pre-wrap;
    word-break: break-word;
    color: var(--text-main);
}
/* ===== 管理画面：簡易アクセス解析ダッシュボード ===== */
.kpi-num {
    font-size: 1.3rem !important;
    font-weight: 800;
    color: #fff !important;
    margin-top: 4px !important;
}
.kpi-num small {
    font-size: 0.72rem;
    color: var(--text-sub);
    font-weight: 600;
}
.chart-card {
    background: #0d1522;
    border: 1px solid var(--border);
    border-radius: 8px;
    padding: 16px;
    margin: 16px 0 24px;
    overflow-x: auto;
}
.chart-title {
    font-size: 0.86rem;
    font-weight: 700;
    color: var(--cyan);
    margin-bottom: 12px;
}
.bar-chart {
    display: flex;
    align-items: flex-end;
    gap: 6px;
    height: 170px;
    min-width: 420px;
    padding-top: 18px;
}
.bar-col {
    flex: 1;
    display: flex;
    flex-direction: column;
    align-items: center;
    height: 100%;
    min-width: 24px;
}
.bar-val {
    font-size: 0.7rem;
    color: var(--text-sub);
    height: 16px;
    line-height: 16px;
}
.bar-track {
    flex: 1;
    width: 100%;
    max-width: 28px;
    background: rgba(255, 255, 255, 0.04);
    border-radius: 4px 4px 0 0;
    position: relative;
    display: flex;
    align-items: flex-end;
    overflow: hidden;
}
.bar-fill-pv {
    width: 100%;
    background: rgba(76, 212, 245, 0.45);
    border-top: 2px solid var(--cyan);
    transition: height 0.2s;
}
.bar-fill-uu {
    position: absolute;
    left: 20%;
    right: 20%;
    bottom: 0;
    background: var(--green);
    border-radius: 2px 2px 0 0;
    opacity: 0.9;
}
.bar-date {
    margin-top: 6px;
    font-size: 0.68rem;
    color: var(--text-sub);
    white-space: nowrap;
}
.analytics-grid-2 {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 18px;
}
@media (max-width: 860px) {
    .analytics-grid-2 {
        grid-template-columns: 1fr;
    }
}