@import url('https://fonts.googleapis.com/css2?family=Bebas+Neue&family=Noto+Sans+JP:wght@400;700;900&display=swap');

/* ===================================================
   CSS CUSTOM PROPERTIES (テーマ変数)
=================================================== */
:root {
    /* ダークモード（デフォルト）*/
    --bg-body:       #1a1a1a;
    --bg-card:       rgba(255,255,255,0.06);
    --bg-input:      #242424;
    --bg-login:      #1a1a1a;
    --bg-sidebar-sp: rgba(15,15,15,0.97);
    --text-primary:  #e0e0e0;
    --text-secondary:#bbb;
    --text-muted:    #999;
    --text-dim:      #888;
    --text-faint:    #777;
    --border-subtle: rgba(255,255,255,0.12);
    --border-dim:    rgba(255,255,255,0.06);
    --input-border:  rgba(255,215,0,0.25);
}

[data-theme="light"] {
    --bg-body:       #f5f3ef;
    --bg-card:       #ffffff;
    --bg-input:      #fafaf9;
    --bg-login:      #ffffff;
    --bg-sidebar-sp: rgba(255,255,255,0.98);
    --text-primary:  #18181b;
    --text-secondary:#3f3f46;
    --text-muted:    #71717a;
    --text-dim:      #a1a1aa;
    --text-faint:    #d4d4d8;
    --border-subtle: rgba(0,0,0,0.09);
    --border-dim:    rgba(0,0,0,0.06);
    --input-border:  rgba(0,0,0,0.18);
    /* ライトモード専用アクセント */
    --lt-red:        #dc2626;
    --lt-red-dark:   #b91c1c;
    --lt-navy:       #1e293b;
    --lt-navy-mid:   #334155;
    --lt-card-shadow: 0 1px 3px rgba(0,0,0,0.07), 0 6px 20px rgba(0,0,0,0.05);
}

/* ===================================================
   BASE
=================================================== */
*, *::before, *::after {
    box-sizing: border-box;
    margin: 0;
    padding: 0;
}

body {
    font-family: 'Noto Sans JP', Arial, sans-serif;
    background-color: var(--bg-body);
    background-image: radial-gradient(ellipse at 50% 0%, rgba(228,0,15,0.10) 0%, transparent 55%);
    color: var(--text-primary);
    min-height: 100vh;
    transition: background-color 0.3s, color 0.3s;
}

/* ===================================================
   HEADER
=================================================== */
.header-line {
    width: 100%;
    height: 6px;
    background: linear-gradient(90deg, #E4000F 0%, #FFD700 50%, #E4000F 100%);
    box-shadow: 0 2px 12px rgba(228,0,15,0.5), 0 1px 4px rgba(255,215,0,0.3);
}

.site-header {
    max-width: 1000px;
    margin: 0 auto;
    padding: 24px 10px 20px;
    text-align: center;
    font-family: 'Bebas Neue', sans-serif;
    font-size: 3.5rem;
    letter-spacing: 0.45em;
    color: #fff;
    text-shadow: 3px 3px 0 #E4000F;
}

.header-gold-line {
    max-width: 1000px;
    margin: 0 auto 0;
    height: 1px;
    background: linear-gradient(90deg, transparent 0%, #FFD700 30%, #FFD700 70%, transparent 100%);
    opacity: 0.5;
}

.header-link {
    color: inherit;
    text-decoration: none;
    transition: opacity 0.2s;
}
.header-link:hover { opacity: 0.75; }

/* ===================================================
   LAYOUT
=================================================== */
.container {
    display: flex;
    justify-content: space-between;
    max-width: 1000px;
    margin: 20px auto;
    gap: 16px;
    padding: 0 10px;
}

.sidebar-left,
.sidebar-right {
    flex: 1;
    background: var(--bg-card);
    border-top: 3px solid #E4000F;
    padding: 16px;
}

.main-content {
    flex: 3;
    min-width: 0;
}

/* ===================================================
   SIDEBAR
=================================================== */
.sidebar-left h2,
.sidebar-right h2 {
    font-family: 'Bebas Neue', sans-serif;
    font-size: 1.2rem;
    letter-spacing: 0.25em;
    color: #FFD700;
    border-bottom: 1px solid rgba(255,215,0,0.25);
    padding-bottom: 8px;
    margin-bottom: 12px;
}

.sidebar-list {
    list-style: none;
}
.sidebar-list li {
    margin-bottom: 6px;
}
.sidebar-list li a {
    display: block;
    padding: 10px 14px;
    color: #bbb;
    text-decoration: none;
    background: rgba(255,255,255,0.03);
    border-left: 3px solid transparent;
    font-size: 0.9rem;
    transition: all 0.2s;
}
.sidebar-list li a:hover {
    color: #fff;
    border-left-color: #E4000F;
    background: rgba(228,0,15,0.1);
    padding-left: 20px;
}
.sidebar-list li a.sidebar-logout {
    color: #E4000F;
    background: rgba(228,0,15,0.08);
    border-left-color: #E4000F;
}
.sidebar-list li a.sidebar-logout:hover {
    color: #fff;
    background: #E4000F;
    border-left-color: #E4000F;
    padding-left: 20px;
}

/* ランキングリスト */
.ranking-list {
    list-style: none;
}
.ranking-list li {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 9px 4px;
    border-bottom: 1px solid var(--border-subtle);
    font-size: 0.9rem;
    color: var(--text-secondary);
}
.ranking-list li:first-child {
    color: #FFD700;
    font-weight: 900;
}
.rank-num {
    font-family: 'Bebas Neue', sans-serif;
    font-size: 1.4rem;
    color: #E4000F;
    min-width: 28px;
    line-height: 1;
}
.ranking-list li:first-child .rank-num {
    color: #FFD700;
}
.rank-rate {
    margin-left: auto;
    font-size: 0.8rem;
    color: var(--text-secondary);
}
.ranking-list li:first-child .rank-rate {
    color: #FFD700;
}
.ranking-empty {
    color: var(--text-dim);
    font-size: 0.85rem;
    text-align: center;
    padding: 20px 0;
}

/* ===================================================
   TOP PAGE MENU
=================================================== */
.menu {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 28px;
    padding: 50px 20px;
    background: rgba(228,0,15,0.04);
    border-top: 3px solid #E4000F;
    position: relative;
    overflow: hidden;
}
.menu::before {
    content: '';
    position: absolute;
    bottom: -40px;
    left: 50%;
    transform: translateX(-50%);
    width: 350px;
    height: 130px;
    background: radial-gradient(ellipse, rgba(228,0,15,0.1) 0%, transparent 70%);
    pointer-events: none;
}

.section-title {
    font-family: 'Bebas Neue', sans-serif;
    font-size: 1.1rem;
    letter-spacing: 0.35em;
    color: #FFD700;
}

/* メイン対戦ボタン（平行四辺形） */
.btn-smash {
    position: relative;
    display: inline-block;
    padding: 1.1rem 5rem;
    font-family: 'Bebas Neue', sans-serif;
    font-size: 1.8rem;
    letter-spacing: 0.3em;
    color: #fff;
    text-decoration: none;
    background: #E4000F;
    clip-path: polygon(12px 0%, 100% 0%, calc(100% - 12px) 100%, 0% 100%);
    box-shadow: 0 4px 20px rgba(228,0,15,0.45);
    transition: all 0.2s ease;
    overflow: hidden;
}
.btn-smash::before {
    content: '';
    position: absolute;
    inset: 0;
    background: linear-gradient(180deg, rgba(255,255,255,0.12) 0%, transparent 55%);
    pointer-events: none;
}
.btn-smash:hover {
    background: #ff1a28;
    transform: scale(1.05) translateY(-2px);
    box-shadow: 0 8px 30px rgba(228,0,15,0.65), 0 0 20px rgba(255,215,0,0.2);
    color: #fff;
    text-decoration: none;
}
.ready-to-fight-label {
    font-family: 'Bebas Neue', sans-serif;
    font-size: 2rem;
    letter-spacing: 0.5em;
    color: #E4000F;
    text-align: center;
    margin-bottom: 14px;
}
.battle-mode-btns {
    display: flex;
    gap: 24px;
    justify-content: center;
}
.btn-smash--mode {
    padding: 1rem 3.5rem;
    font-size: 1.5rem;
}

/* ===================================================
   FORM COMMON
=================================================== */
form {
    background: var(--bg-card);
    border-top: 3px solid #E4000F;
    padding: 28px 24px;
}

label {
    display: block;
    font-weight: 700;
    font-size: 0.9rem;
    letter-spacing: 0.05em;
    color: #FFD700;
    margin-top: 18px;
    margin-bottom: 6px;
}

.example {
    color: var(--text-dim);
    font-size: 0.82em;
    font-weight: 400;
    margin-left: 6px;
}

input[type="text"] {
    width: 100%;
    max-width: 420px;
    padding: 11px 14px;
    font-size: 1rem;
    font-family: 'Noto Sans JP', sans-serif;
    background: var(--bg-input);
    color: var(--text-primary);
    border: 1px solid var(--input-border);
    border-radius: 2px;
    outline: none;
    transition: border-color 0.2s;
}
input[type="text"]:focus {
    border-color: #FFD700;
    box-shadow: 0 0 0 2px rgba(255,215,0,0.12);
}

select {
    width: 100%;
    max-width: 420px;
    padding: 11px 14px;
    font-size: 1rem;
    font-family: 'Noto Sans JP', sans-serif;
    background: var(--bg-input);
    color: var(--text-primary);
    border: 1px solid var(--input-border);
    border-radius: 2px;
    outline: none;
    cursor: pointer;
    appearance: none;
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='8' viewBox='0 0 12 8'%3E%3Cpath d='M1 1l5 5 5-5' stroke='%23FFD700' stroke-width='2' fill='none'/%3E%3C/svg%3E");
    background-repeat: no-repeat;
    background-position: right 14px center;
    transition: border-color 0.2s;
}
select:focus {
    border-color: #FFD700;
    box-shadow: 0 0 0 2px rgba(255,215,0,0.12);
}

/* ===================================================
   BUTTONS
=================================================== */
input[type="submit"],
input[type="button"],
button {
    font-family: 'Bebas Neue', sans-serif;
    font-size: 1.1rem;
    letter-spacing: 0.2em;
    padding: 10px 28px;
    border: none;
    border-radius: 2px;
    cursor: pointer;
    transition: all 0.2s;
}

input[type="submit"] {
    background: #E4000F;
    color: #fff;
    box-shadow: 0 3px 10px rgba(228,0,15,0.4);
}
input[type="submit"]:hover {
    background: #ff1a28;
    transform: translateY(-1px);
    box-shadow: 0 5px 16px rgba(228,0,15,0.55);
}
input[type="submit"]:disabled {
    opacity: 0.35;
    cursor: not-allowed;
    transform: none;
    box-shadow: none;
}

input[type="button"] {
    background: rgba(255,255,255,0.08);
    color: #ccc;
    border: 1px solid rgba(255,255,255,0.15);
}
input[type="button"]:hover {
    background: rgba(255,255,255,0.14);
    color: #fff;
}

.btn {
    font-family: 'Bebas Neue', sans-serif;
    font-size: 1.1rem;
    letter-spacing: 0.2em;
    padding: 10px 28px;
    border: none;
    border-radius: 2px;
    cursor: pointer;
    transition: all 0.2s;
    text-decoration: none;
    display: inline-block;
}

.btnArea {
    display: flex;
    justify-content: flex-end;
    gap: 10px;
    margin-top: 24px;
}

/* ===================================================
   BATTLE VS LAYOUT
=================================================== */
.battle-vs-layout {
    display: flex;
    align-items: flex-start;
    gap: 0;
    margin: 10px 0 20px;
}

.battle-player {
    flex: 1;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 10px;
}

.player-label {
    font-family: 'Bebas Neue', sans-serif;
    font-size: 1.3rem;
    letter-spacing: 0.3em;
    color: #FFD700;
    text-align: center;
}

.vs-center {
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 0 20px;
    padding-top: 32px;
    font-family: 'Bebas Neue', sans-serif;
    font-size: 3rem;
    color: #E4000F;
    text-shadow: 2px 2px 0 rgba(0,0,0,0.5);
    letter-spacing: 0.1em;
    flex-shrink: 0;
}

.battle-player select {
    max-width: 100%;
    text-align: center;
}

/* Player 1 固定表示 */
.battle-player-fixed {
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 10px 14px;
    background: rgba(255,255,255,0.05);
    border: 1px solid rgba(255,255,255,0.15);
    border-radius: 6px;
    width: 100%;
    box-sizing: border-box;
}
.battle-player-name {
    font-size: 1.05rem;
    font-weight: bold;
    color: #e0e0e0;
    letter-spacing: 0.05em;
}
.battle-player-rate {
    font-size: 0.8rem;
    color: #FFD700;
    letter-spacing: 0.1em;
}
.battle-player-rate::before { content: 'RATE '; }

/* Player 2 検索 */
.battle-search-wrap {
    position: relative;
}
.battle-search-input {
    width: 100%;
    box-sizing: border-box;
    text-align: left;
}
.battle-search-input.battle-search-error {
    border-color: #E4000F !important;
    animation: shake 0.3s ease;
}
@keyframes shake {
    0%,100% { transform: translateX(0); }
    25%      { transform: translateX(-4px); }
    75%      { transform: translateX(4px); }
}
.battle-search-dropdown {
    display: none;
    position: absolute;
    top: 100%;
    left: 0;
    right: 0;
    z-index: 100;
    list-style: none;
    margin: 2px 0 0;
    padding: 4px 0;
    background: #1e1e1e;
    border: 1px solid rgba(228,0,15,0.4);
    border-radius: 4px;
    max-height: 220px;
    overflow-y: auto;
}
.battle-search-dropdown li {
    padding: 9px 14px;
    cursor: pointer;
    font-size: 0.9rem;
    color: #ccc;
    transition: background 0.15s;
}
.battle-search-dropdown li:hover {
    background: rgba(228,0,15,0.15);
    color: #fff;
}
.battle-player-selected {
    margin-top: 6px;
    padding: 8px 12px;
    background: rgba(77,255,136,0.08);
    border: 1px solid rgba(77,255,136,0.3);
    border-radius: 4px;
    font-size: 0.85rem;
    color: #4dff88;
    text-align: center;
}

/* rate.php の差分表示 */
.rate-diff {
    margin-left: 8px;
    font-size: 0.85rem;
    font-weight: bold;
}
.rate-up   .rate-diff { color: #4dff88; }
.rate-down .rate-diff { color: #ff4d4d; }

/* ===================================================
   PLAYER 2 COMBOBOX
=================================================== */
.p2-combobox {
    position: relative;
    width: 100%;
}
.p2-combobox-trigger {
    display: flex;
    align-items: center;
    justify-content: center;
    position: relative;
    padding: 10px 14px;
    background: rgba(255,255,255,0.05);
    border: 1px solid rgba(255,255,255,0.15);
    border-radius: 6px;
    cursor: pointer;
    font-size: 0.95rem;
    color: #888;
    transition: border-color 0.2s, color 0.2s;
    user-select: none;
}
.p2-combobox-trigger:hover {
    border-color: rgba(228,0,15,0.5);
}
.p2-combobox-trigger.is-open {
    border-color: #E4000F;
    border-bottom-left-radius: 0;
    border-bottom-right-radius: 0;
}
.p2-combobox-trigger.is-selected {
    color: #e0e0e0;
}
.p2-combobox-trigger.shake {
    animation: shake 0.35s ease;
    border-color: #E4000F;
}
.p2-arrow {
    position: absolute;
    right: 14px;
    font-size: 0.7rem;
    color: #666;
    transition: transform 0.2s;
}
.p2-combobox-trigger.is-open .p2-arrow {
    transform: rotate(180deg);
}
.p2-combobox-panel {
    display: none;
    position: absolute;
    top: 100%;
    left: 0;
    right: 0;
    z-index: 200;
    background: #1a1a1a;
    border: 1px solid #E4000F;
    border-top: none;
    border-bottom-left-radius: 6px;
    border-bottom-right-radius: 6px;
    overflow: hidden;
}
.p2-combobox-search {
    width: 100%;
    box-sizing: border-box;
    padding: 9px 12px;
    background: rgba(255,255,255,0.04);
    border: none;
    border-bottom: 1px solid rgba(255,255,255,0.08);
    border-radius: 0;
    color: #e0e0e0;
    font-size: 0.9rem;
    outline: none;
}
.p2-combobox-search:focus {
    background: rgba(228,0,15,0.06);
}
.p2-combobox-list {
    list-style: none;
    margin: 0;
    padding: 4px 0;
    max-height: 220px;
    overflow-y: auto;
}
.p2-combobox-list li {
    padding: 9px 14px;
    cursor: pointer;
    font-size: 0.9rem;
    color: #ccc;
    transition: background 0.15s;
}
.p2-combobox-list li:hover {
    background: rgba(228,0,15,0.15);
    color: #fff;
}
.p2-combobox-list li.empty {
    color: #555;
    cursor: default;
    font-style: italic;
}
.p2-combobox-list li.empty:hover {
    background: none;
}

/* ライトモード */
[data-theme="light"] .p2-combobox-trigger {
    background: #fff;
    border-color: #cbd5e1;
    color: #64748b;
}
[data-theme="light"] .p2-combobox-trigger:hover {
    border-color: rgba(220,38,38,0.5);
}
[data-theme="light"] .p2-combobox-trigger.is-open {
    border-color: var(--lt-red);
}
[data-theme="light"] .p2-combobox-trigger.is-selected {
    color: #1e293b;
}
[data-theme="light"] .p2-combobox-panel {
    background: #fff;
    border-color: var(--lt-red);
}
[data-theme="light"] .p2-combobox-search {
    background: #f8fafc;
    border-bottom-color: #e2e8f0;
    color: #1e293b;
}
[data-theme="light"] .p2-combobox-search:focus {
    background: rgba(220,38,38,0.04);
}
[data-theme="light"] .p2-combobox-list li {
    color: #334155;
}
[data-theme="light"] .p2-combobox-list li:hover {
    background: rgba(220,38,38,0.08);
    color: #1e293b;
}
[data-theme="light"] .p2-arrow {
    color: #94a3b8;
}

/* ===================================================
   STAGE SELECT
=================================================== */
.stage-section {
    margin-bottom: 36px;
}
.stage-title {
    font-family: 'Bebas Neue', sans-serif;
    font-size: 1.4rem;
    letter-spacing: 0.4em;
    color: #FFD700;
    text-align: center;
    margin-bottom: 14px;
}
.stage-grid {
    display: grid;
    grid-template-columns: repeat(8, 1fr);
    gap: 16px;
}
/* 上段4つ：2列ずつ使用 */
.stage-grid .stage-box:nth-child(1) { grid-column: 1 / 3; }
.stage-grid .stage-box:nth-child(2) { grid-column: 3 / 5; }
.stage-grid .stage-box:nth-child(3) { grid-column: 5 / 7; }
.stage-grid .stage-box:nth-child(4) { grid-column: 7 / 9; }
/* 下段3つ：中央寄せ（両端に1列ずつ余白） */
.stage-grid .stage-box:nth-child(5) { grid-column: 2 / 4; }
.stage-grid .stage-box:nth-child(6) { grid-column: 4 / 6; }
.stage-grid .stage-box:nth-child(7) { grid-column: 6 / 8; }

.stage-box {
    position: relative;
    aspect-ratio: 4 / 3;
    background: rgba(255,255,255,0.04);
    border: 3px solid rgba(255,255,255,0.1);
    border-radius: 6px;
    cursor: pointer;
    overflow: hidden;
    transition: border-color 0.2s, background 0.2s;
}
.stage-box:not(.is-banned--winner):not(.is-banned--loser):not(.is-selected):not(.is-not-selected):hover {
    border-color: rgba(228,0,15,0.4);
    background: rgba(255,255,255,0.07);
}
.stage-grid--loser-turn .stage-box:not(.is-banned--winner):not(.is-banned--loser):not(.is-selected):not(.is-not-selected):hover {
    border-color: rgba(59,158,255,0.4);
    background: rgba(59,158,255,0.07);
}
.stage-img {
    position: absolute;
    inset: 0;
    width: 100%;
    height: 100%;
    object-fit: cover;
    transition: filter 0.25s;
}
.stage-ban-overlay {
    position: absolute;
    inset: 0;
    background: rgba(0, 0, 0, 0.55);
    opacity: 0;
    transition: opacity 0.25s;
    pointer-events: none;
}
/* ✕ / ○ 共通マーク */
.stage-mark {
    position: absolute;
    inset: 0;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 5rem;
    font-weight: bold;
    opacity: 0;
    transition: opacity 0.25s;
    pointer-events: none;
}

/* 勝者BAN（赤✕） */
.stage-mark--x { color: #E4000F; text-shadow: 0 0 16px rgba(228,0,15,0.9); }
.is-banned--winner { border-color: rgba(228,0,15,0.6); }
.is-banned--winner .stage-img { filter: grayscale(1); }
.is-banned--winner .stage-ban-overlay { opacity: 1; }
.is-banned--winner .stage-mark--x { opacity: 1; }

/* 敗者BAN（青✕） */
.is-banned--loser { border-color: rgba(59,158,255,0.6); }
.is-banned--loser .stage-img { filter: grayscale(1); }
.is-banned--loser .stage-ban-overlay { opacity: 1; background: rgba(0, 0, 0, 0.55); }
.is-banned--loser .stage-mark--x { opacity: 1; color: #3b9eff; text-shadow: 0 0 16px rgba(59,158,255,0.9); }

/* ステージ選択（赤○） */
.stage-mark--o { color: #E4000F; font-size: 4.5rem; -webkit-text-stroke: 5px #E4000F; text-shadow: 0 0 20px rgba(228,0,15,1); }
.is-selected { border-color: #FFD700; box-shadow: 0 0 10px rgba(255,215,0,0.4); }
.is-selected .stage-mark--o { opacity: 1; }

/* 未選択ステージ（最終決定後） */
.is-not-selected .stage-img { filter: grayscale(1); }
.is-not-selected .stage-ban-overlay { opacity: 1; background: rgba(0, 0, 0, 0.55); }

/* ガイドアナウンス */
.battle-number-label {
    font-family: 'Bebas Neue', sans-serif;
    font-size: 1.4rem;
    letter-spacing: 0.4em;
    color: #E4000F;
    text-align: center;
    margin-bottom: 4px;
}
.bo3-score {
    text-align: center;
    font-size: 0.85rem;
    color: var(--text-sub, #aaa);
    letter-spacing: 0.05em;
    margin-bottom: 10px;
}
.bo3-score-num {
    font-family: 'Bebas Neue', sans-serif;
    font-size: 1.1rem;
    color: var(--text-main, #fff);
    letter-spacing: 0.2em;
}
.bo3-final-score {
    text-align: center;
    font-size: 0.9rem;
    letter-spacing: 0.12em;
    color: var(--text-sub, #aaa);
    margin-bottom: 20px;
}
.stage-announcement {
    text-align: center;
    font-size: 1rem;
    font-weight: 700;
    border: 1px solid transparent;
    border-radius: 6px;
    padding: 14px 20px;
    margin: 16px 0 4px;
    transition: opacity 0.2s;
}
.stage-announcement.is-fading { opacity: 0; }
.stage-announcement--red  { color: #E4000F; background: rgba(228,0,15,0.06);   border-color: rgba(228,0,15,0.30);   }
.stage-announcement--blue { color: #3b9eff; background: rgba(59,158,255,0.06); border-color: rgba(59,158,255,0.30); }
.stage-announcement--done { color: #FFD700; background: rgba(255,215,0,0.06);  border-color: rgba(255,215,0,0.25);  }

/* ライトモード */
[data-theme="light"] .stage-box {
    background: rgba(30,41,59,0.04);
    border-color: #e2e8f0;
}
[data-theme="light"] .stage-box:not(.is-banned--winner):not(.is-banned--loser):not(.is-selected):not(.is-not-selected):hover {
    border-color: rgba(220,38,38,0.4);
    background: rgba(30,41,59,0.07);
}
[data-theme="light"] .stage-grid--loser-turn .stage-box:not(.is-banned--winner):not(.is-banned--loser):not(.is-selected):not(.is-not-selected):hover {
    border-color: rgba(59,158,255,0.4);
    background: rgba(59,158,255,0.06);
}
[data-theme="light"] .is-banned--winner { border-color: rgba(220,38,38,0.6); }
[data-theme="light"] .is-banned--loser  { border-color: rgba(59,158,255,0.6); }

/* ===================================================
   RESULT PAGE
=================================================== */
.stage-rule {
    display: flex;
    gap: 16px;
    margin-bottom: 32px;
}
.stage-rule-block {
    flex: 1;
    background: rgba(255,255,255,0.04);
    border: 1px solid rgba(255,255,255,0.1);
    border-top: 2px solid #E4000F;
    border-radius: 6px;
    padding: 14px 16px;
}
.stage-rule-title {
    font-family: 'Bebas Neue', sans-serif;
    font-size: 1.1rem;
    letter-spacing: 0.25em;
    color: #FFD700;
    margin-bottom: 10px;
}
.stage-rule-list {
    padding-left: 1.4em;
    margin: 0;
}
.stage-rule-list li {
    font-size: 0.82rem;
    color: var(--text-secondary);
    line-height: 1.7;
    margin-bottom: 2px;
}
.stage-rule-note {
    font-size: 0.78rem;
    color: var(--text-muted);
    margin-top: 10px;
    text-align: right;
}

[data-theme="light"] .stage-rule-block {
    background: #fff;
    border-color: #e2e8f0;
    border-top-color: #dc2626;
}

.winner-title {
    font-family: 'Bebas Neue', sans-serif;
    font-size: 2.8rem;
    letter-spacing: 0.4em;
    color: #FFD700;
    text-align: center;
    text-shadow: 3px 3px 0 rgba(228,0,15,0.6);
    margin-bottom: 8px;
}

.winner-sub {
    text-align: center;
    font-size: 0.85rem;
    color: #888;
    letter-spacing: 0.15em;
    margin-bottom: 20px;
}

.winner-select-wrap {
    display: flex;
    justify-content: center;
}
.winner-select-wrap select {
    max-width: 320px;
    text-align: center;
    font-size: 1.1rem;
    font-weight: 700;
}

/* ===================================================
   RATE RESULT PAGE
=================================================== */
.rate-result-table {
    width: 100%;
    border-collapse: collapse;
    margin: 16px 0 24px;
}
.rate-result-table th,
.rate-result-table td {
    padding: 14px 16px;
    border-bottom: 1px solid rgba(255,255,255,0.08);
    font-size: 0.95rem;
}
.rate-result-table th {
    font-family: 'Bebas Neue', sans-serif;
    font-size: 1rem;
    letter-spacing: 0.15em;
    color: #FFD700;
    text-align: left;
    width: 35%;
    background: rgba(255,215,0,0.05);
}
.rate-before { color: #aaa; }
.rate-arrow  { color: #E4000F; font-weight: 900; padding: 0 6px; }
.rate-after  { color: #fff; font-weight: 900; }
.rate-up   .rate-after { color: #4dff88; }
.rate-down .rate-after { color: #ff4d4d; }

/* ===================================================
   TABLE (確認画面)
=================================================== */
.player-check {
    width: 100%;
    border-collapse: collapse;
    margin: 16px 0 8px;
}
.player-check th {
    font-family: 'Bebas Neue', sans-serif;
    font-size: 1rem;
    letter-spacing: 0.1em;
    color: #FFD700;
    text-align: left;
    padding: 12px 14px;
    width: 30%;
    background: rgba(255,215,0,0.05);
    border-bottom: 1px solid rgba(255,255,255,0.08);
}
.player-check td {
    padding: 12px 14px;
    border-bottom: 1px solid rgba(255,255,255,0.08);
    color: var(--text-primary);
    font-weight: 700;
}

/* ===================================================
   SECTION TITLE (確認・結果ページ見出し)
=================================================== */
.page-title {
    font-family: 'Bebas Neue', sans-serif;
    font-size: 1.8rem;
    letter-spacing: 0.3em;
    color: #FFD700;
    border-bottom: 1px solid rgba(255,215,0,0.25);
    padding-bottom: 10px;
    margin-bottom: 20px;
}

/* ===================================================
   BACK LINK / MESSAGES
=================================================== */
.back-link {
    display: inline-block;
    margin-top: 20px;
    padding: 10px 24px;
    background: rgba(255,255,255,0.07);
    color: #ccc;
    border: 1px solid rgba(255,255,255,0.15);
    border-radius: 2px;
    text-decoration: none;
    font-size: 0.9rem;
    letter-spacing: 0.1em;
    font-family: inherit;
    cursor: pointer;
    transition: all 0.2s;
}
.back-link:hover {
    background: rgba(228,0,15,0.15);
    color: #fff;
    border-color: #E4000F;
}

.complete-message {
    font-family: 'Bebas Neue', sans-serif;
    font-size: 1.4rem;
    letter-spacing: 0.2em;
    color: #4dff88;
    margin-bottom: 8px;
}
.complete-message.is-delete {
    color: #ff7777;
}

/* ===================================================
   ERRORS
=================================================== */
.errMsg {
    margin: 10px 0;
    padding: 12px 14px;
    color: #ff7777;
    border: 1px solid rgba(255,100,100,0.4);
    background: rgba(228,0,15,0.08);
    font-size: 0.9rem;
}

span.err {
    display: block;
    color: #ff7777;
    font-size: 0.85rem;
    margin-top: 4px;
}


/* ===================================================
   LOGIN PAGE
=================================================== */
.login-wrapper {
    display: flex;
    justify-content: center;
    align-items: center;
    min-height: calc(100vh - 120px);
    padding: 40px 20px;
}

.login-box {
    background: var(--bg-login);
    border: 1px solid rgba(228,0,15,0.3);
    border-radius: 8px;
    padding: 48px 40px;
    width: 100%;
    max-width: 380px;
    box-shadow: 0 0 30px rgba(228,0,15,0.1);
}

.login-title {
    font-family: 'Bebas Neue', sans-serif;
    font-size: 2.4rem;
    letter-spacing: 6px;
    color: #E4000F;
    text-align: center;
    margin-bottom: 32px;
}

.login-error {
    background: rgba(228,0,15,0.15);
    border: 1px solid rgba(228,0,15,0.5);
    color: #ff7777;
    font-size: 0.85rem;
    padding: 10px 14px;
    border-radius: 4px;
    margin-bottom: 20px;
    text-align: center;
}

.login-field {
    margin-bottom: 20px;
}

.login-field label {
    display: block;
    font-size: 0.75rem;
    letter-spacing: 2px;
    color: #aaa;
    margin-bottom: 6px;
}

.login-field input {
    width: 100%;
    background: var(--bg-input);
    border: 1px solid rgba(255,255,255,0.15);
    border-radius: 4px;
    color: var(--text-primary);
    font-size: 0.95rem;
    padding: 10px 12px;
    outline: none;
    transition: border-color 0.2s;
}

.login-field input:focus {
    border-color: #E4000F;
}

.btn-login {
    width: 100%;
    margin-top: 12px;
    padding: 12px;
    background: #E4000F;
    color: #fff;
    font-family: 'Bebas Neue', sans-serif;
    font-size: 1.2rem;
    letter-spacing: 4px;
    border: none;
    border-radius: 4px;
    cursor: pointer;
    transition: background 0.2s, box-shadow 0.2s;
}

.btn-login:hover {
    background: #ff1a27;
    box-shadow: 0 0 16px rgba(228,0,15,0.5);
}

.login-divider {
    display: flex;
    align-items: center;
    gap: 12px;
    margin: 20px 0;
    color: var(--text-muted);
    font-size: 0.85rem;
}
.login-divider::before,
.login-divider::after {
    content: '';
    flex: 1;
    height: 1px;
    background: var(--border-color);
}

.btn-google {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 10px;
    width: 100%;
    padding: 11px;
    background: var(--card-bg);
    border: 1px solid var(--border-color);
    border-radius: 6px;
    color: var(--text-primary);
    font-size: 0.95rem;
    font-weight: 500;
    text-decoration: none;
    cursor: pointer;
    transition: background 0.2s, border-color 0.2s;
}
.btn-google:hover {
    background: var(--hover-bg);
    border-color: var(--text-muted);
}
.google-icon {
    width: 20px;
    height: 20px;
    flex-shrink: 0;
}

.btn-guest {
    display: block;
    width: 100%;
    padding: 11px;
    background: transparent;
    border: 1px dashed var(--border-color);
    border-radius: 6px;
    color: var(--text-muted);
    font-size: 0.95rem;
    font-weight: 500;
    cursor: pointer;
    transition: background 0.2s, border-color 0.2s, color 0.2s;
}
.btn-guest:hover {
    background: var(--hover-bg);
    border-color: var(--text-muted);
    color: var(--text-primary);
}

.rate-no-change {
    color: var(--text-muted);
    font-size: 0.9rem;
}

.login-register-link {
    margin-top: 18px;
    text-align: center;
    font-size: 0.85rem;
    color: var(--text-muted);
}
.login-register-link a {
    color: var(--accent-color);
    text-decoration: none;
}
.login-register-link a:hover {
    text-decoration: underline;
}

.login-info {
    font-size: 0.85rem;
    color: var(--text-muted);
    background: var(--card-bg);
    border: 1px solid var(--border-color);
    border-radius: 6px;
    padding: 8px 12px;
    margin-bottom: 14px;
}

.confirm-table {
    width: 100%;
    border-collapse: collapse;
    margin-bottom: 20px;
    font-size: 0.9rem;
}
.confirm-table th,
.confirm-table td {
    padding: 8px 12px;
    border-bottom: 1px solid var(--border-color);
    text-align: left;
}
.confirm-table th {
    color: var(--text-muted);
    width: 40%;
    font-weight: normal;
}

.mypage-table {
    width: 100%;
    border-collapse: collapse;
    font-size: 0.92rem;
    margin-bottom: 8px;
}
.mypage-table th,
.mypage-table td {
    padding: 10px 14px;
    border-bottom: 1px solid var(--border-color);
    text-align: left;
    vertical-align: middle;
}
.mypage-table th {
    color: var(--text-muted);
    width: 38%;
    font-weight: normal;
}

.login-btn-row {
    display: flex;
    gap: 10px;
    margin-top: 8px;
}
.login-btn-row .btn-login {
    margin-top: 0;
    flex: 1;
}

.btn-secondary {
    flex: 1;
    display: block;
    padding: 12px;
    background: var(--card-bg);
    border: 1px solid var(--border-color);
    border-radius: 6px;
    color: var(--text-primary);
    font-size: 0.95rem;
    text-align: center;
    text-decoration: none;
    transition: background 0.2s;
}
.btn-secondary:hover {
    background: var(--hover-bg);
}

.required {
    color: #E4000F;
    margin-left: 3px;
}

/* ===================================================
   ADMIN PAGE
=================================================== */
.admin-container {
    align-items: flex-start;
}

.admin-main {
    min-height: 400px;
}

/* ヘッダー行（タイトル＋バッジ） */
.admin-header-row {
    display: flex;
    align-items: center;
    gap: 14px;
    margin-bottom: 20px;
}
.admin-header-row .page-title {
    margin-bottom: 0;
    border-bottom: none;
}
.admin-badge {
    font-family: 'Bebas Neue', sans-serif;
    font-size: 0.75rem;
    letter-spacing: 0.2em;
    color: #111;
    background: #FFD700;
    padding: 3px 10px;
    border-radius: 2px;
    line-height: 1.6;
}

/* フラッシュメッセージ */
.admin-flash {
    padding: 10px 16px;
    border-radius: 3px;
    font-size: 0.88rem;
    margin-bottom: 18px;
    letter-spacing: 0.05em;
}
.admin-flash--ok {
    background: rgba(77,255,136,0.1);
    border: 1px solid rgba(77,255,136,0.4);
    color: #4dff88;
}
.admin-flash--del {
    background: rgba(228,0,15,0.1);
    border: 1px solid rgba(228,0,15,0.4);
    color: #ff7777;
}

/* 統計リスト */
.admin-stats-list {
    list-style: none;
    margin-top: 4px;
}
.admin-stats-list li {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 8px 4px;
    border-bottom: 1px solid rgba(255,255,255,0.06);
    font-size: 0.82rem;
}
.stat-label { color: var(--text-dim); }
.stat-value {
    font-family: 'Bebas Neue', sans-serif;
    font-size: 1.1rem;
    color: #e0e0e0;
    letter-spacing: 0.05em;
}
.stat-max { color: #FFD700; }
.stat-min { color: #aaa; }

/* テーブル */
.admin-table-wrap {
    overflow-x: auto;
}
.admin-table {
    width: 100%;
    border-collapse: collapse;
    min-width: 520px;
}
.admin-table thead tr {
    background: rgba(255,215,0,0.05);
    border-bottom: 2px solid rgba(255,215,0,0.25);
}
.admin-table th {
    font-family: 'Bebas Neue', sans-serif;
    font-size: 0.95rem;
    letter-spacing: 0.15em;
    color: #FFD700;
    padding: 12px 14px;
    text-align: left;
    white-space: nowrap;
}
.admin-table td {
    padding: 11px 14px;
    border-bottom: 1px solid rgba(255,255,255,0.06);
    color: var(--text-secondary);
    font-size: 0.88rem;
    vertical-align: middle;
}
.admin-table tbody tr:hover td {
    background: rgba(228,0,15,0.05);
}
.td-id {
    color: var(--text-faint);
    font-size: 0.8rem;
}
.td-username {
    color: #e0e0e0;
    font-weight: 700;
}

/* レートバッジ */
.td-rate {
    font-family: 'Bebas Neue', sans-serif;
    font-size: 1rem;
    letter-spacing: 0.05em;
    padding: 2px 8px;
    border-radius: 2px;
}
.rate-high { color: #FFD700; background: rgba(255,215,0,0.1); }
.rate-mid  { color: #e0e0e0; background: rgba(255,255,255,0.06); }
.rate-low  { color: #aaa;    background: rgba(255,255,255,0.03); }

/* パスワード状態 */
.pass-set  { color: #4dff88; font-size: 0.8rem; }
.pass-none { color: var(--text-faint); font-size: 0.8rem; }

/* 編集ボタン */
.btn-admin-edit {
    display: inline-block;
    padding: 5px 14px;
    background: rgba(228,0,15,0.15);
    color: #E4000F;
    border: 1px solid rgba(228,0,15,0.4);
    border-radius: 2px;
    text-decoration: none;
    font-family: 'Bebas Neue', sans-serif;
    font-size: 0.9rem;
    letter-spacing: 0.1em;
    white-space: nowrap;
    transition: all 0.2s;
}
.btn-admin-edit:hover {
    background: #E4000F;
    color: #fff;
}

/* 編集ページ固有 */
.admin-edit-id-row {
    font-size: 0.85rem;
    color: #888;
    margin-bottom: 16px;
    letter-spacing: 0.05em;
}
.admin-edit-id-row strong {
    color: #FFD700;
}

input[type="number"] {
    width: 100%;
    max-width: 420px;
    padding: 11px 14px;
    font-size: 1rem;
    font-family: 'Noto Sans JP', sans-serif;
    background: var(--bg-input);
    color: var(--text-primary);
    border: 1px solid var(--input-border);
    border-radius: 2px;
    outline: none;
    transition: border-color 0.2s;
}
input[type="number"]:focus {
    border-color: #FFD700;
    box-shadow: 0 0 0 2px rgba(255,215,0,0.12);
}
input[type="password"] {
    width: 100%;
    max-width: 420px;
    padding: 11px 14px;
    font-size: 1rem;
    font-family: 'Noto Sans JP', sans-serif;
    background: var(--bg-input);
    color: var(--text-primary);
    border: 1px solid var(--input-border);
    border-radius: 2px;
    outline: none;
    transition: border-color 0.2s;
}
input[type="password"]:focus {
    border-color: #FFD700;
    box-shadow: 0 0 0 2px rgba(255,215,0,0.12);
}

/* 削除ゾーン */
.admin-delete-zone {
    margin-top: 32px;
    padding: 20px;
    border: 1px solid rgba(228,0,15,0.3);
    background: rgba(228,0,15,0.04);
    border-radius: 4px;
}
.admin-delete-label {
    font-family: 'Bebas Neue', sans-serif;
    font-size: 0.85rem;
    letter-spacing: 0.2em;
    color: #E4000F;
    margin-bottom: 12px;
}
.btn-danger-submit {
    background: #6b0000 !important;
    color: #ffaaaa !important;
    box-shadow: none !important;
    font-size: 0.95rem !important;
    letter-spacing: 0.1em !important;
}
.btn-danger-submit:hover {
    background: #900000 !important;
    transform: none !important;
}

/* ===================================================
   USER PROFILE PAGE
=================================================== */

/* ランキング・管理画面のユーザー名リンク */
.rank-username-link {
    color: inherit;
    text-decoration: none;
    transition: color 0.15s;
    flex: 1;
}
.rank-username-link:hover {
    color: #FFD700;
    text-decoration: underline;
}

/* プレイヤー名・番号 */
.profile-name {
    font-family: 'Noto Sans JP', sans-serif;
    font-size: 1.6rem;
    letter-spacing: 0.1em;
    color: #fff;
    word-break: break-all;
    margin-bottom: 2px;
}
.profile-number {
    font-size: 0.78rem;
    color: var(--text-muted);
    letter-spacing: 0.1em;
    margin-bottom: 16px;
}

/* 統計カード */
.profile-stat-card {
    background: var(--bg-card);
    border-left: 3px solid #E4000F;
    padding: 10px 14px;
    margin-bottom: 10px;
}
.profile-stat-card--best {
    border-left-color: #FFD700;
}
.profile-stat-label {
    font-size: 0.72rem;
    color: var(--text-dim);
    letter-spacing: 0.15em;
    margin-bottom: 2px;
}
.profile-stat-num {
    font-family: 'Bebas Neue', sans-serif;
    font-size: 2rem;
    color: #E4000F;
    letter-spacing: 0.05em;
    line-height: 1.1;
}
.profile-stat-num--best {
    color: #FFD700;
}

/* 勝敗グリッド */
.profile-record-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 8px;
    margin-top: 10px;
}
.profile-record-item {
    background: rgba(255,255,255,0.03);
    padding: 8px 10px;
    text-align: center;
}
.profile-record-item--full {
    grid-column: span 2;
}
.profile-record-num {
    font-family: 'Bebas Neue', sans-serif;
    font-size: 1.6rem;
    color: #e0e0e0;
    letter-spacing: 0.05em;
    line-height: 1.2;
}
.profile-record-num--win  { color: #4dff88; }
.profile-record-num--lose { color: #ff4d4d; }
.profile-record-unit {
    font-size: 0.9rem;
    font-family: 'Noto Sans JP', sans-serif;
    color: #888;
    margin-left: 2px;
}

/* セクション */
.profile-section {
    background: var(--bg-card);
    border-top: 3px solid #E4000F;
    padding: 20px 20px 24px;
}
.profile-section .page-title {
    margin-bottom: 16px;
}

/* グラフ */
.chart-wrapper {
    position: relative;
    width: 100%;
}

/* 対戦結果バッジ */
.battle-result-badge {
    display: inline-block;
    padding: 2px 10px;
    border-radius: 2px;
    font-family: 'Bebas Neue', sans-serif;
    font-size: 0.9rem;
    letter-spacing: 0.1em;
}
.battle-result-badge--win {
    background: rgba(77,255,136,0.12);
    color: #4dff88;
    border: 1px solid rgba(77,255,136,0.3);
}
.battle-result-badge--lose {
    background: rgba(255,77,77,0.12);
    color: #ff7777;
    border: 1px solid rgba(255,77,77,0.3);
}

/* レート変動 */
.battle-rate-diff {
    font-family: 'Bebas Neue', sans-serif;
    font-size: 1rem;
    letter-spacing: 0.05em;
}
.rate-diff-up   { color: #4dff88; }
.rate-diff-down { color: #ff4d4d; }

/* ===================================================
   称号バッジ
=================================================== */
.title-badge {
    display: inline-block;
    font-family: 'Bebas Neue', sans-serif;
    font-size: 0.75rem;
    letter-spacing: 0.15em;
    padding: 2px 9px;
    border-radius: 2px;
    border: 1px solid currentColor;
    vertical-align: middle;
}
.title-badge--sm {
    font-size: 0.62rem;
    padding: 1px 6px;
}
.title-badge--legend   { color: #FFD700; background: rgba(255,215,0,0.12); }
.title-badge--expert   { color: #ff9933; background: rgba(255,153,51,0.12); }
.title-badge--master   { color: #4daaff; background: rgba(77,170,255,0.12); }
.title-badge--skilled  { color: #e0e0e0; background: rgba(255,255,255,0.06); }
.title-badge--rival    { color: #aaaaaa; background: rgba(255,255,255,0.04); }
.title-badge--rookie   { color: #666666; background: rgba(255,255,255,0.02); }

.profile-title-row {
    margin-bottom: 10px;
}

/* ===================================================
   連勝カード
=================================================== */
.streak-card {
    display: flex;
    align-items: center;
    background: rgba(255,102,0,0.07);
    border-left: 3px solid #ff6600;
    padding: 10px 14px;
    margin-top: 10px;
    margin-bottom: 4px;
}
.streak-right {
    margin-left: auto;
    text-align: right;
}
.streak-label {
    font-size: 0.68rem;
    color: #888;
    letter-spacing: 0.12em;
    margin-bottom: 2px;
}
.streak-num {
    font-family: 'Bebas Neue', sans-serif;
    font-size: 2rem;
    color: #aaa;
    letter-spacing: 0.05em;
    line-height: 1.1;
}
.streak-num--active {
    color: #ff6600;
}
.streak-best {
    font-family: 'Bebas Neue', sans-serif;
    font-size: 1.4rem;
    color: #ff9955;
    letter-spacing: 0.05em;
    line-height: 1.2;
}

/* ===================================================
   アクティビティフィード
=================================================== */
.activity-section {
    margin-top: 16px;
    background: var(--bg-card);
    border-top: 3px solid #E4000F;
    padding: 16px 20px 8px;
}
.activity-section-title {
    font-family: 'Bebas Neue', sans-serif;
    font-size: 1.1rem;
    letter-spacing: 0.3em;
    color: #FFD700;
    border-bottom: 1px solid rgba(255,215,0,0.2);
    padding-bottom: 8px;
    margin-bottom: 10px;
}
.activity-feed {
    list-style: none;
}
.activity-item {
    display: flex;
    align-items: center;
    gap: 6px;
    padding: 8px 4px;
    border-bottom: 1px solid var(--border-subtle);
    font-size: 0.85rem;
    flex-wrap: wrap;
}
.activity-item:last-child { border-bottom: none; }
.activity-winner {
    color: #4dff88;
    font-weight: 700;
    text-decoration: none;
    transition: opacity 0.15s;
}
.activity-winner:hover { opacity: 0.8; text-decoration: underline; }
.activity-loser {
    color: #ccc;
    text-decoration: none;
    transition: opacity 0.15s;
}
.activity-loser:hover { opacity: 0.8; text-decoration: underline; }
.activity-vs {
    color: var(--text-dim);
    font-size: 0.8rem;
}
.activity-diff {
    font-family: 'Bebas Neue', sans-serif;
    font-size: 0.95rem;
}
.activity-time {
    margin-left: auto;
    color: var(--text-dim);
    font-size: 0.75rem;
    white-space: nowrap;
}

/* ===================================================
   メンバー一覧ページ
=================================================== */
.members-search-form {
    display: flex;
    align-items: center;
    gap: 8px;
    background: none;
    border: none;
    padding: 0;
    margin-bottom: 12px;
}
.members-search-form input[type="text"] {
    max-width: 280px;
    margin: 0;
}
.members-search-form button {
    font-size: 0.9rem;
    padding: 11px 20px;
    letter-spacing: 0.1em;
}
.members-search-clear {
    font-size: 0.82rem;
    color: #888;
    text-decoration: none;
    padding: 4px 8px;
    border: 1px solid rgba(255,255,255,0.15);
    border-radius: 2px;
    transition: all 0.2s;
}
.members-search-clear:hover {
    color: #fff;
    border-color: rgba(255,255,255,0.3);
}
.members-count {
    font-size: 0.8rem;
    color: var(--text-muted);
    margin-bottom: 14px;
    letter-spacing: 0.05em;
}
.members-row {
    cursor: pointer;
}
.members-row:hover td {
    background: rgba(228,0,15,0.05);
}

/* ===================================================
   プロフィールコメント
=================================================== */
.profile-comment {
    margin-top: 12px;
    padding: 10px 12px;
    background: rgba(255,255,255,0.03);
    border-left: 3px solid rgba(255,215,0,0.4);
    font-size: 0.82rem;
    color: #bbb;
    line-height: 1.5;
    word-break: break-all;
}

/* コメント編集フォーム（user.php） */
.profile-comment-form {
    display: flex;
    gap: 6px;
    margin-top: 8px;
    background: none;
    border: none;
    padding: 0;
}
.profile-comment-form input[type="text"] {
    flex: 1;
    max-width: none;
    font-size: 0.8rem;
    padding: 7px 10px;
}
.profile-comment-form button {
    font-size: 0.75rem;
    padding: 7px 12px;
    letter-spacing: 0.05em;
    white-space: nowrap;
}
.profile-comment-saved {
    font-size: 0.75rem;
    color: #4dff88;
    margin-top: 6px;
    letter-spacing: 0.05em;
}

/* ===================================================
   実績バッジ
=================================================== */
.achievement-grid {
    display: grid;
    grid-template-columns: repeat(4, 1fr);
    gap: 10px;
}

.achievement-badge {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 4px;
    padding: 12px 6px 10px;
    background: rgba(255,215,0,0.06);
    border: 1px solid rgba(255,215,0,0.3);
    border-radius: 4px;
    text-align: center;
    transition: transform 0.15s, box-shadow 0.15s;
}
.achievement-badge:hover {
    transform: translateY(-2px);
    box-shadow: 0 4px 12px rgba(255,215,0,0.15);
}

.achievement-badge--locked {
    background: rgba(255,255,255,0.02);
    border-color: rgba(255,255,255,0.08);
    opacity: 0.4;
    filter: grayscale(1);
}

.achievement-badge-icon {
    font-size: 1.4rem;
    line-height: 1;
    color: #FFD700;
}
.achievement-badge--locked .achievement-badge-icon {
    color: #555;
}

.achievement-badge-label {
    font-size: 0.65rem;
    letter-spacing: 0.05em;
    color: #aaa;
    white-space: nowrap;
}
.achievement-badge--locked .achievement-badge-label {
    color: #555;
}

/* ===================================================
   週間ランキング
=================================================== */
.weekly-rank-sub {
    font-size: 0.72rem;
    color: var(--text-muted);
    letter-spacing: 0.08em;
    margin-bottom: 8px;
    margin-top: -8px;
}
.weekly-wins-badge {
    margin-left: auto;
    font-family: 'Bebas Neue', sans-serif;
    font-size: 0.9rem;
    color: #4dff88;
    letter-spacing: 0.05em;
}

/* ===================================================
   HAMBURGER BUTTON (desktop: hidden)
=================================================== */
.nav-hamburger {
    display: none;
}

/* ===================================================
   RESPONSIVE — TABLET (max-width: 1023px)
=================================================== */
@media (max-width: 1023px) {
    .container {
        flex-wrap: wrap;
    }

    .sidebar-right {
        flex: 1 1 100%;
    }

    .site-header {
        font-size: 2.8rem;
    }
}

/* ===================================================
   RESPONSIVE — SMARTPHONE (max-width: 767px)
=================================================== */
@media (max-width: 767px) {
    .container {
        flex-direction: column;
    }

    .sidebar-left,
    .sidebar-right {
        flex: none;
        width: 100%;
    }

    .main-content {
        flex: none;
        width: 100%;
    }

    .site-header {
        font-size: 2rem;
    }

    .btn-smash {
        padding: 1rem 2.5rem;
        font-size: 1.4rem;
    }

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

    .battle-vs-layout {
        flex-direction: column;
        align-items: center;
    }

    .vs-center {
        padding: 4px 0;
        font-size: 2rem;
    }

    input[type="text"],
    input[type="number"],
    input[type="password"],
    select {
        max-width: 100%;
    }

    .members-search-form {
        flex-wrap: wrap;
    }

    .members-search-form input[type="text"] {
        max-width: 100%;
        width: 100%;
    }

    .admin-table {
        font-size: 0.8rem;
        min-width: 420px;
    }

    .admin-table th,
    .admin-table td {
        padding: 8px 8px;
    }

    form {
        padding: 20px 14px;
    }

    .profile-comment-form {
        flex-direction: column;
    }

    .page-title {
        font-size: 1.4rem;
        letter-spacing: 0.15em;
    }

    /* ステージグリッド：モバイルは2列 */
    .stage-grid {
        grid-template-columns: repeat(2, 1fr);
        gap: 12px;
    }
    .stage-grid .stage-box:nth-child(n) {
        grid-column: auto;
    }
    .stage-grid .stage-box:nth-child(7) {
        grid-column: 1 / -1;
        justify-self: center;
        width: calc(50% - 6px);
    }

    /* ハンバーガーボタン */
    .nav-hamburger {
        display: flex;
        flex-direction: column;
        justify-content: center;
        align-items: center;
        gap: 5px;
        position: fixed;
        top: 12px;
        left: 12px;
        z-index: 110;
        width: 40px;
        height: 40px;
        background: #FFD700;
        border: 1px solid #c9a800;
        border-radius: 4px;
        cursor: pointer;
        padding: 0;
        box-shadow: 0 2px 8px rgba(0, 0, 0, 0.6);
    }
    .nav-hamburger span {
        display: block;
        width: 26px;
        height: 2px;
        background: #111;
        border-radius: 1px;
        transition: transform 0.3s, opacity 0.3s;
        transform-origin: center;
    }
    .nav-hamburger.is-open span:nth-child(1) {
        transform: translateY(7px) rotate(45deg);
    }
    .nav-hamburger.is-open span:nth-child(2) {
        opacity: 0;
    }
    .nav-hamburger.is-open span:nth-child(3) {
        transform: translateY(-7px) rotate(-45deg);
    }

    /* サイドバー（スマホ時：左からスライドするドロワー） */
    .sidebar-left {
        position: fixed;
        top: 0;
        left: 0;
        height: 100vh;
        width: 240px;
        z-index: 90;
        transform: translateX(-100%);
        transition: transform 0.3s ease;
        overflow-y: auto;
        background: var(--bg-sidebar-sp);
        padding-top: 60px;
    }
    .sidebar-left.is-open {
        transform: translateX(0);
    }

    /* オーバーレイ（背景暗転） */
    .nav-overlay {
        position: fixed;
        inset: 0;
        background: rgba(0, 0, 0, 0.55);
        z-index: 80;
        opacity: 0;
        pointer-events: none;
        transition: opacity 0.3s;
    }
    .nav-overlay.is-open {
        opacity: 1;
        pointer-events: auto;
    }
}

/* ===================================================
   LIGHT MODE 専用調整（おしゃれデザイン刷新版）

   カラー設計方針:
   - ロゴ/ヘッダー: チャコール(#1e293b) + 赤シャドウ → 高級感
   - 見出し・タイトル: ダークネイビー(#1e293b) で格調
   - 赤(#dc2626): CTAボタン・ボーダートップ・1位ハイライトのみ
   - 背景: クリームホワイト(#f5f3ef) でプレミアム感
   - カード: 白 + 適切な影で奥行き
=================================================== */

/* 背景（クリーム地にほんのり赤グロー） */
[data-theme="light"] body {
    background-image:
        radial-gradient(ellipse at 50% -10%, rgba(220,38,38,0.06) 0%, transparent 60%),
        radial-gradient(ellipse at 80% 100%, rgba(30,41,59,0.03) 0%, transparent 50%);
}

/* ━━━ HEADER ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ */

/* ヘッダーライン: 赤→ネイビーグラデ */
[data-theme="light"] .header-line {
    background: linear-gradient(90deg, #dc2626 0%, #1e293b 50%, #dc2626 100%);
    box-shadow: 0 3px 14px rgba(30,41,59,0.18);
}

/* ロゴ: チャコール + 赤シャドウ（高級感） */
[data-theme="light"] .site-header {
    color: #1e293b;
    text-shadow: 3px 3px 0 rgba(220,38,38,0.22);
}

/* 区切りライン: ネイビー細線 */
[data-theme="light"] .header-gold-line {
    background: linear-gradient(90deg, transparent 0%, rgba(30,41,59,0.2) 30%, rgba(30,41,59,0.2) 70%, transparent 100%);
    opacity: 1;
}

/* ━━━ SIDEBAR ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ */

[data-theme="light"] .sidebar-left,
[data-theme="light"] .sidebar-right {
    background: #ffffff;
    box-shadow: var(--lt-card-shadow);
    border-top-color: var(--lt-navy);
}

/* サイドバー見出し: ネイビー */
[data-theme="light"] .sidebar-left h2,
[data-theme="light"] .sidebar-right h2 {
    color: var(--lt-navy);
    border-bottom: 1px solid rgba(30,41,59,0.12);
}

/* サイドバーリンク */
[data-theme="light"] .sidebar-list li a {
    color: var(--lt-navy-mid);
    background: rgba(30,41,59,0.02);
    border-left-color: transparent;
    font-weight: 500;
}
[data-theme="light"] .sidebar-list li a:hover {
    color: var(--lt-red);
    background: rgba(220,38,38,0.05);
    border-left-color: var(--lt-red);
    padding-left: 20px;
}
[data-theme="light"] .battle-search-dropdown {
    background: #fff;
    border-color: rgba(220,38,38,0.4);
}
[data-theme="light"] .battle-search-dropdown li {
    color: #333;
}
[data-theme="light"] .battle-search-dropdown li:hover {
    background: rgba(220,38,38,0.08);
    color: #1e293b;
}
[data-theme="light"] .battle-player-fixed {
    background: #fff;
    border-color: #cbd5e1;
}
[data-theme="light"] .battle-player-name { color: #1e293b; }

[data-theme="light"] .sidebar-list li a.sidebar-logout {
    color: var(--lt-red);
    background: rgba(220,38,38,0.06);
    border-left-color: var(--lt-red);
}
[data-theme="light"] .sidebar-list li a.sidebar-logout:hover {
    color: #fff;
    background: var(--lt-red);
    border-left-color: var(--lt-red);
    padding-left: 20px;
}

/* ━━━ RANKING ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ */

/* 1位だけ赤ゴールド強調 */
[data-theme="light"] .ranking-list li:first-child {
    color: var(--lt-red);
}
[data-theme="light"] .ranking-list li:first-child .rank-num,
[data-theme="light"] .ranking-list li:first-child .rank-rate {
    color: var(--lt-red);
}
[data-theme="light"] .rank-username-link:hover {
    color: var(--lt-red);
}
[data-theme="light"] .ranking-empty {
    color: var(--text-dim);
}

/* ━━━ TOP MENU ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ */

[data-theme="light"] .menu {
    background: linear-gradient(135deg, rgba(30,41,59,0.03) 0%, rgba(220,38,38,0.03) 100%);
    border-top-color: var(--lt-navy);
    box-shadow: var(--lt-card-shadow);
}

/* 対戦セクションタイトル */
[data-theme="light"] .section-title {
    color: var(--lt-navy);
    letter-spacing: 0.4em;
}

/* ━━━ FORMS ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ */

[data-theme="light"] form {
    background: #ffffff;
    border-top-color: var(--lt-navy);
    box-shadow: var(--lt-card-shadow);
}

/* ラベル: ネイビー小文字 */
[data-theme="light"] label {
    color: var(--lt-navy-mid);
    font-weight: 700;
}

/* セカンダリボタン */
[data-theme="light"] input[type="button"] {
    background: #f1f5f9;
    color: var(--lt-navy-mid);
    border: 1px solid rgba(30,41,59,0.14);
}
[data-theme="light"] input[type="button"]:hover {
    background: #e2e8f0;
    color: var(--lt-navy);
}

/* バックリンク */
[data-theme="light"] .back-link {
    background: #f1f5f9;
    color: var(--lt-navy-mid);
    border: 1px solid rgba(30,41,59,0.14);
}
[data-theme="light"] .back-link:hover {
    background: rgba(220,38,38,0.06);
    color: var(--lt-red);
    border-color: var(--lt-red);
}

/* ━━━ BATTLE ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ */

[data-theme="light"] .player-label { color: var(--lt-navy); }

/* ━━━ RESULT PAGE ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ */

[data-theme="light"] .winner-title {
    color: var(--lt-navy);
    text-shadow: 2px 2px 0 rgba(220,38,38,0.18);
}
[data-theme="light"] .winner-sub { color: var(--text-muted); }

/* ━━━ TABLES ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ */

[data-theme="light"] .rate-result-table th,
[data-theme="light"] .player-check th {
    background: rgba(30,41,59,0.04);
    color: var(--lt-navy);
}
[data-theme="light"] .rate-result-table th,
[data-theme="light"] .rate-result-table td,
[data-theme="light"] .player-check th,
[data-theme="light"] .player-check td {
    border-bottom: 1px solid rgba(30,41,59,0.08);
}
[data-theme="light"] .rate-before { color: var(--text-muted); }
[data-theme="light"] .rate-after  { color: var(--lt-navy); }

/* ━━━ PAGE TITLE ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ */

[data-theme="light"] .page-title {
    color: var(--lt-navy);
    border-bottom: 1px solid rgba(30,41,59,0.14);
}

/* ━━━ ACTIVITY FEED ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ */

[data-theme="light"] .activity-section {
    background: #ffffff;
    border-top-color: var(--lt-navy);
    box-shadow: var(--lt-card-shadow);
}
[data-theme="light"] .activity-section-title {
    color: var(--lt-navy);
    border-bottom: 1px solid rgba(30,41,59,0.1);
}
[data-theme="light"] .activity-loser  { color: var(--lt-navy-mid); }
[data-theme="light"] .activity-vs     { color: var(--text-muted); }
[data-theme="light"] .activity-time   { color: var(--text-muted); }

/* ━━━ LOGIN ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ */

[data-theme="light"] .login-box {
    border: 1px solid rgba(30,41,59,0.12);
    box-shadow: 0 8px 40px rgba(30,41,59,0.1), 0 2px 8px rgba(30,41,59,0.06);
}
[data-theme="light"] .login-title {
    color: var(--lt-navy);
    text-shadow: none;
    /* Bebas Neue なので letter-spacing だけ調整 */
}
[data-theme="light"] .login-field label {
    color: var(--text-muted);
    font-weight: 400;
}
[data-theme="light"] .login-field input {
    border: 1px solid rgba(30,41,59,0.15);
    background: #fafaf9;
}
[data-theme="light"] .login-field input:focus {
    border-color: var(--lt-navy);
    box-shadow: 0 0 0 2px rgba(30,41,59,0.08);
}

/* ━━━ ADMIN ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ */

[data-theme="light"] .admin-badge {
    background: var(--lt-navy);
    color: #ffffff;
}
[data-theme="light"] .admin-table thead tr {
    background: rgba(30,41,59,0.04);
    border-bottom: 2px solid rgba(30,41,59,0.14);
}
[data-theme="light"] .admin-table th {
    color: var(--lt-navy);
}
[data-theme="light"] .admin-table td {
    border-bottom: 1px solid rgba(30,41,59,0.07);
    color: var(--text-secondary);
}
[data-theme="light"] .admin-table tbody tr:hover td {
    background: rgba(30,41,59,0.03);
}
[data-theme="light"] .admin-stats-list li {
    border-bottom: 1px solid rgba(30,41,59,0.07);
}
[data-theme="light"] .stat-label  { color: var(--text-muted); }
[data-theme="light"] .stat-value  { color: var(--lt-navy); }
[data-theme="light"] .stat-max    { color: var(--lt-red); }
[data-theme="light"] .stat-min    { color: var(--text-muted); }
[data-theme="light"] .td-id       { color: var(--text-muted); }
[data-theme="light"] .td-username { color: var(--lt-navy); font-weight: 700; }
[data-theme="light"] .rate-high   { color: var(--lt-red-dark); background: rgba(220,38,38,0.07); }
[data-theme="light"] .rate-mid    { color: var(--lt-navy-mid); background: rgba(30,41,59,0.05); }
[data-theme="light"] .rate-low    { color: var(--text-muted);  background: rgba(30,41,59,0.03); }
[data-theme="light"] .admin-edit-id-row       { color: var(--text-muted); }
[data-theme="light"] .admin-edit-id-row strong { color: var(--lt-navy); }
[data-theme="light"] .admin-flash--ok {
    background: rgba(21,128,61,0.07);
    border: 1px solid rgba(21,128,61,0.25);
    color: #15803d;
}
[data-theme="light"] .admin-flash--del {
    background: rgba(220,38,38,0.06);
    border: 1px solid rgba(220,38,38,0.25);
    color: var(--lt-red-dark);
}
[data-theme="light"] .admin-delete-zone {
    border: 1px solid rgba(220,38,38,0.2);
    background: rgba(220,38,38,0.025);
}
[data-theme="light"] .admin-delete-label { color: var(--lt-red-dark); }

/* ━━━ USER PROFILE ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ */

[data-theme="light"] .profile-name { color: var(--lt-navy); }
[data-theme="light"] .profile-number { color: var(--text-muted); }
[data-theme="light"] .profile-stat-card {
    background: #ffffff;
    box-shadow: var(--lt-card-shadow);
    border-left-color: var(--lt-red);
}
[data-theme="light"] .profile-stat-card--best {
    border-left-color: #d97706;
}
[data-theme="light"] .profile-stat-num        { color: var(--lt-red); }
[data-theme="light"] .profile-stat-num--best  { color: #d97706; }
[data-theme="light"] .profile-record-item     { background: rgba(30,41,59,0.03); }
[data-theme="light"] .profile-record-num       { color: var(--lt-navy); }
[data-theme="light"] .profile-record-num--win  { color: #16a34a; }
[data-theme="light"] .profile-record-num--lose { color: var(--lt-red-dark); }
[data-theme="light"] .profile-record-unit      { color: var(--text-muted); }
[data-theme="light"] .profile-section {
    background: #ffffff;
    border-top-color: var(--lt-navy);
    box-shadow: var(--lt-card-shadow);
}
[data-theme="light"] .profile-comment {
    background: rgba(30,41,59,0.025);
    color: var(--text-secondary);
    border-left-color: rgba(30,41,59,0.25);
}
[data-theme="light"] .profile-comment-saved { color: #16a34a; }

/* ━━━ 称号バッジ ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ */

[data-theme="light"] .title-badge--legend  { color: #92400e; background: rgba(146,64,14,0.08); border-color: rgba(146,64,14,0.3); }
[data-theme="light"] .title-badge--expert  { color: #c2410c; background: rgba(194,65,12,0.08); border-color: rgba(194,65,12,0.3); }
[data-theme="light"] .title-badge--master  { color: #1d4ed8; background: rgba(29,78,216,0.08); border-color: rgba(29,78,216,0.3); }
[data-theme="light"] .title-badge--skilled { color: var(--lt-navy-mid); background: rgba(30,41,59,0.06); border-color: rgba(30,41,59,0.2); }
[data-theme="light"] .title-badge--rival   { color: var(--text-muted);   background: rgba(30,41,59,0.04); border-color: rgba(30,41,59,0.14); }
[data-theme="light"] .title-badge--rookie  { color: #94a3b8;             background: rgba(30,41,59,0.03); border-color: rgba(30,41,59,0.1); }

/* ━━━ 連勝カード ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ */

[data-theme="light"] .streak-card {
    background: rgba(30,41,59,0.03);
    border-left-color: var(--lt-navy);
}
[data-theme="light"] .streak-label       { color: var(--text-dim); }
[data-theme="light"] .streak-num         { color: var(--text-muted); }
[data-theme="light"] .streak-num--active { color: #c2410c; }
[data-theme="light"] .streak-best        { color: #d97706; }

/* ━━━ 実績バッジ ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ */

[data-theme="light"] .achievement-badge {
    background: rgba(30,41,59,0.03);
    border-color: rgba(30,41,59,0.12);
    transition: transform 0.15s, box-shadow 0.15s, border-color 0.15s;
}
[data-theme="light"] .achievement-badge:hover {
    border-color: var(--lt-red);
    box-shadow: 0 4px 16px rgba(220,38,38,0.12);
}
[data-theme="light"] .achievement-badge--locked {
    background: rgba(30,41,59,0.02);
    border-color: rgba(30,41,59,0.08);
}
[data-theme="light"] .achievement-badge-icon  { color: var(--lt-red); }
[data-theme="light"] .achievement-badge-label { color: var(--text-secondary); }

/* ━━━ 週間ランキング ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ */

[data-theme="light"] .weekly-rank-sub   { color: var(--text-muted); }
[data-theme="light"] .weekly-wins-badge { color: #16a34a; }

/* ━━━ メンバー検索 ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ */

[data-theme="light"] .members-search-clear {
    color: var(--text-muted);
    border-color: rgba(30,41,59,0.14);
}
[data-theme="light"] .members-search-clear:hover {
    color: var(--lt-navy);
    border-color: rgba(30,41,59,0.28);
}
[data-theme="light"] .members-count { color: var(--text-muted); }
[data-theme="light"] .members-row:hover td { background: rgba(30,41,59,0.03); }

/* ━━━ エラー・メッセージ ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ */

[data-theme="light"] .errMsg {
    color: var(--lt-red-dark);
    border-color: rgba(185,28,28,0.25);
    background: rgba(220,38,38,0.05);
}
[data-theme="light"] span.err { color: var(--lt-red-dark); }
[data-theme="light"] .complete-message { color: #16a34a; }
[data-theme="light"] .complete-message.is-delete { color: var(--lt-red-dark); }

/* ━━━ 対戦結果バッジ ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ */

[data-theme="light"] .battle-result-badge--win {
    background: rgba(21,128,61,0.08);
    color: #15803d;
    border-color: rgba(21,128,61,0.22);
}
[data-theme="light"] .battle-result-badge--lose {
    background: rgba(185,28,28,0.08);
    color: var(--lt-red-dark);
    border-color: rgba(185,28,28,0.22);
}
[data-theme="light"] .rate-diff-up   { color: #15803d; }
[data-theme="light"] .rate-diff-down { color: var(--lt-red-dark); }

/* ━━━ ハンバーガー（スマホ） ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ */

[data-theme="light"] .nav-hamburger {
    background: var(--lt-navy);
    border-color: var(--lt-navy-mid);
    box-shadow: 0 2px 8px rgba(30,41,59,0.3);
}
[data-theme="light"] .nav-hamburger span {
    background: #ffffff;
}

/* ===================================================
   THEME TOGGLE BUTTON
=================================================== */
.theme-toggle {
    position: fixed;
    top: 12px;
    right: 12px;
    z-index: 200;
    padding: 6px 12px;
    border-radius: 4px;
    border: 1px solid rgba(255,255,255,0.2);
    background: var(--bg-card);
    color: var(--text-secondary);
    cursor: pointer;
    font-family: 'Noto Sans JP', sans-serif;
    font-size: 0.72rem;
    letter-spacing: 0.05em;
    white-space: nowrap;
    transition: background 0.2s, color 0.2s, border-color 0.2s;
    box-shadow: 0 2px 8px rgba(0,0,0,0.3);
}
.theme-toggle:hover {
    color: var(--text-primary);
    border-color: rgba(255,255,255,0.4);
}
[data-theme="light"] .theme-toggle {
    border-color: rgba(30,41,59,0.15);
    box-shadow: 0 2px 8px rgba(30,41,59,0.1);
}
[data-theme="light"] .theme-toggle:hover {
    border-color: var(--lt-navy);
    color: var(--lt-navy);
}

.rate-page-panel {
    padding: 28px 24px;
    background: rgba(255,255,255,0.03);
    border-top: 3px solid #E4000F;
}

/* ===== BATTLE FLOW ===== */
.battle-flow {
    margin: 0 0 28px;
    border: 1px solid rgba(255,255,255,0.1);
    border-radius: 4px;
    overflow: hidden;
}
.battle-flow-row {
    display: grid;
    grid-template-columns: 58px 1fr 34px 1fr;
    align-items: stretch;
    min-height: 50px;
    border-bottom: 1px solid rgba(255,255,255,0.07);
}
.battle-flow-row:last-child {
    border-bottom: none;
}
.battle-flow-num {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 1px;
    border-right: 1px solid rgba(255,255,255,0.07);
    background: rgba(255,255,255,0.03);
    padding: 6px 4px;
}
.bf-game-label {
    font-family: 'Bebas Neue', sans-serif;
    font-size: 0.52rem;
    letter-spacing: 0.18em;
    color: #555;
    line-height: 1;
}
.bf-game-num {
    font-family: 'Bebas Neue', sans-serif;
    font-size: 1.4rem;
    color: #666;
    line-height: 1;
}
.battle-flow-vs {
    display: flex;
    align-items: center;
    justify-content: center;
    font-family: 'Bebas Neue', sans-serif;
    font-size: 0.65rem;
    letter-spacing: 0.12em;
    color: #888;
    border-left: 1px solid rgba(255,255,255,0.07);
    border-right: 1px solid rgba(255,255,255,0.07);
}
.battle-flow-cell {
    display: flex;
    align-items: center;
    padding: 0 14px;
    gap: 8px;
}
.bf-p1 { justify-content: flex-end; }
.bf-p2 { justify-content: flex-start; }
.battle-flow-cell.is-winner {
    background: rgba(228,0,15,0.08);
}
.bf-name {
    font-size: 0.88rem;
    color: #999;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    max-width: 120px;
}
.battle-flow-cell.is-winner .bf-name {
    color: #fff;
    font-weight: 700;
}
.bf-win-dot {
    width: 7px;
    height: 7px;
    border-radius: 50%;
    background: #E4000F;
    flex-shrink: 0;
}
[data-theme="light"] .battle-flow {
    border-color: rgba(30,41,59,0.12);
}
[data-theme="light"] .battle-flow-row {
    border-bottom-color: rgba(30,41,59,0.08);
}
[data-theme="light"] .battle-flow-num {
    border-right-color: rgba(30,41,59,0.08);
    background: rgba(30,41,59,0.02);
}
[data-theme="light"] .bf-game-label { color: var(--text-muted); }
[data-theme="light"] .bf-game-num   { color: var(--text-dim); }
[data-theme="light"] .battle-flow-vs {
    color: var(--text-faint);
    border-color: rgba(30,41,59,0.08);
}
[data-theme="light"] .battle-flow-cell.is-winner {
    background: rgba(220,38,38,0.07);
}
[data-theme="light"] .bf-name { color: var(--text-muted); }
[data-theme="light"] .battle-flow-cell.is-winner .bf-name { color: var(--lt-navy); }
[data-theme="light"] .bf-win-dot { background: var(--lt-red); }

.bf-char-select {
    font-size: 0.7rem;
    font-family: 'Noto Sans JP', sans-serif;
    background: rgba(255,255,255,0.06);
    border: 1px solid rgba(255,255,255,0.14);
    color: #bbb;
    border-radius: 3px;
    padding: 3px 4px;
    cursor: pointer;
    max-width: 100px;
    flex-shrink: 0;
}
.bf-char-select:focus {
    outline: none;
    border-color: rgba(228,0,15,0.5);
}
.bf-save-btn {
    display: block;
    margin: 12px 0 0 auto;
    padding: 8px 22px;
    background: #E4000F;
    color: #fff;
    font-family: 'Noto Sans JP', sans-serif;
    font-size: 0.82rem;
    font-weight: 700;
    border: none;
    border-radius: 3px;
    cursor: pointer;
    letter-spacing: 0.05em;
}
.bf-save-btn:hover {
    background: #c0000d;
}
[data-theme="light"] .bf-char-select {
    background: #fff;
    border-color: rgba(30,41,59,0.18);
    color: var(--lt-navy-mid);
}
.td-char {
    font-size: 0.78rem;
}
.char-tag {
    display: inline-flex;
    align-items: center;
    gap: 4px;
    font-size: 0.72rem;
    font-family: 'Noto Sans JP', sans-serif;
    background: rgba(255,255,255,0.06);
    border: 1px solid rgba(255,255,255,0.12);
    color: #ccc;
    border-radius: 3px;
    padding: 1px 6px 1px 4px;
    margin: 1px 2px 1px 0;
    white-space: nowrap;
}
.char-tag-num {
    font-family: 'Bebas Neue', sans-serif;
    font-size: 0.68rem;
    color: #E4000F;
    line-height: 1;
}
[data-theme="light"] .char-tag {
    background: rgba(30,41,59,0.06);
    border-color: rgba(30,41,59,0.15);
    color: var(--lt-navy-mid);
}
.battle-log-link {
    color: inherit;
    text-decoration: underline;
    text-underline-offset: 3px;
    text-decoration-color: rgba(255,255,255,0.25);
}
.battle-log-link:hover { color: #E4000F; text-decoration-color: #E4000F; }
[data-theme="light"] .battle-log-link { text-decoration-color: rgba(30,41,59,0.25); }
[data-theme="light"] .battle-log-link:hover { color: #E4000F; }
.battlelog-header { padding: 18px 0 8px; border-bottom: 1px solid rgba(255,255,255,0.08); margin-bottom: 4px; }
.battlelog-matchup { display: flex; align-items: center; gap: 14px; margin-bottom: 10px; }
.battlelog-myname { font-size: 1.1rem; font-weight: 700; color: #fff; }
.battlelog-oppname { font-size: 1.1rem; color: #aaa; }
.battlelog-vs { font-family: 'Bebas Neue', sans-serif; font-size: 1rem; color: #E4000F; letter-spacing: 0.1em; }
.battlelog-meta { display: flex; align-items: center; gap: 12px; flex-wrap: wrap; }
.battlelog-date { font-size: 0.82rem; color: #666; }
.battlelog-rate-after { font-size: 0.82rem; color: #666; }
.battlelog-gamenum { font-family: 'Bebas Neue', sans-serif; font-size: 1rem; text-align: center; width: 60px; }
.battlelog-no-chars { color: #555; font-size: 0.85rem; margin-top: 16px; }
.battlelog-table { margin-top: 0; }
.battlelog-table th,
.battlelog-table td { padding: 14px 22px; }
th.battlelog-char-th {
    padding-left: 50px;
}
.battlelog-char-th-label {
    display: inline-block;
    width: 52px;
    text-align: center;
}
.battlelog-row--win  td { background: rgba(228,0,15,0.07); }
.battlelog-row--lose td { background: rgba(255,255,255,0.02); }
.char-icon-cell { vertical-align: middle; }
.char-icon-row {
    display: flex;
    align-items: center;
    gap: 10px;
}
.char-icon-block {
    display: flex;
    flex-direction: column;
    align-items: center;
    width: 52px;
    min-width: 0;
}
.char-icon {
    width: 52px;
    height: 52px;
    object-fit: contain;
    display: block;
    flex-shrink: 0;
    margin-bottom: 2px;
}
.char-icon-name {
    display: block;
    font-size: 0.75rem;
    color: #aaa;
    white-space: nowrap;
}
[data-theme="light"] .char-icon-name { color: var(--lt-navy-mid); }
.bl-win-mark {
    flex: 0 0 38px;
    width: 38px;
    text-align: center;
    font-family: 'Bebas Neue', sans-serif;
    font-size: 0.95rem;
    color: #E4000F;
    letter-spacing: 0.05em;
    white-space: nowrap;
}
[data-theme="light"] .battlelog-myname { color: var(--lt-navy-dark); }
[data-theme="light"] .battlelog-oppname { color: var(--lt-navy-mid); }
[data-theme="light"] .battlelog-date,
[data-theme="light"] .battlelog-rate-after { color: #94a3b8; }
[data-theme="light"] .battlelog-row--win  td { background: rgba(228,0,15,0.05); }
[data-theme="light"] .battlelog-row--lose td { background: rgba(30,41,59,0.02); }

/* マイキャラ設定 */
.mychar-desc { color: #888; font-size: 0.85rem; margin: 4px 0 18px; }
[data-theme="light"] .mychar-desc { color: #64748b; }
.mychar-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(72px, 1fr));
    gap: 10px;
    margin-bottom: 20px;
}
.mychar-item {
    position: relative;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 4px;
    padding: 8px 4px;
    border: 1px solid rgba(255,255,255,0.08);
    border-radius: 6px;
    cursor: pointer;
    user-select: none;
    transition: border-color 0.15s, background 0.15s;
}
.mychar-item:hover { border-color: rgba(228,0,15,0.4); }
.mychar-item.is-selected {
    border-color: #E4000F;
    background: rgba(228,0,15,0.1);
}
.mychar-badge {
    display: none;
    position: absolute;
    top: -6px;
    right: -6px;
    width: 20px;
    height: 20px;
    border-radius: 50%;
    background: #E4000F;
    color: #fff;
    font-family: 'Bebas Neue', sans-serif;
    font-size: 0.75rem;
    align-items: center;
    justify-content: center;
    line-height: 1;
}
.mychar-item.is-selected .mychar-badge { display: flex; }
.mychar-icon {
    width: 44px;
    height: 44px;
    object-fit: contain;
}
.mychar-name {
    font-size: 0.68rem;
    color: #aaa;
    text-align: center;
    line-height: 1.2;
}
[data-theme="light"] .mychar-item { border-color: rgba(30,41,59,0.12); }
[data-theme="light"] .mychar-item.is-selected { background: rgba(228,0,15,0.06); }
[data-theme="light"] .mychar-name { color: #64748b; }

.bf-char-option--fav { color: #ff9933; }

/* 対戦結果画面（rate.php）スマホ対応 */
@media (max-width: 767px) {
    .rate-page-panel {
        padding: 16px 12px;
    }

    .battle-flow-row {
        grid-template-columns: 30px 1fr 18px 1fr;
        min-height: 40px;
    }

    .battle-flow-cell {
        padding: 0 6px;
        gap: 4px;
    }

    .bf-char-select {
        max-width: 74px;
        font-size: 0.62rem;
        padding: 3px 2px;
    }

    .bf-name {
        max-width: 56px;
        font-size: 0.72rem;
    }

    .bf-game-num   { font-size: 1.05rem; }
    .bf-game-label { font-size: 0.42rem; }
    .battle-flow-vs { font-size: 0.5rem; }

    .rate-result-table th,
    .rate-result-table td {
        padding: 10px 10px;
        font-size: 0.85rem;
    }

    .back-link {
        display: block;
        width: 100%;
        text-align: center;
        box-sizing: border-box;
    }
}

/* 対戦詳細画面（battlelog）スマホ対応 */
@media (max-width: 767px) {
    .battlelog-matchup {
        gap: 8px;
        flex-wrap: wrap;
    }

    .battlelog-myname,
    .battlelog-oppname {
        font-size: 0.95rem;
        max-width: 100%;
        overflow-wrap: anywhere;
    }

    .battlelog-table th,
    .battlelog-table td {
        padding: 8px 8px;
    }

    th.battlelog-char-th {
        padding-left: 8px;
    }

    .battlelog-char-th-label {
        width: 40px;
        font-size: 0.7rem;
    }

    .battlelog-gamenum {
        width: 32px;
    }

    .char-icon-block {
        width: 40px;
    }

    .char-icon {
        width: 40px;
        height: 40px;
    }

    .char-icon-name {
        font-size: 0.68rem;
    }

    .bl-win-mark {
        flex: 0 0 26px;
        width: 26px;
        font-size: 0.78rem;
    }
}
