/* ===== Home Screen ===== */
.home-screen {
    display: flex;
    flex-direction: column;
    align-items: center;
    /* ロゴ+メニューを一体グループとして画面中央にアンカー
       （旧: flex-end。ロゴ上端固定だと画面サイズで互いの距離が大きく変わるため） */
    justify-content: center;
    min-height: 100vh;
    padding: 20px;
    position: relative;
    overflow: hidden;
}

/* キービジュアル動画背景（旧仕様・現在は未使用。マーキー背景に置き換え） */
.home-bg-video {
    position: absolute;
    top: 50%;
    left: 50%;
    min-width: 100%;
    min-height: 100%;
    width: auto;
    height: auto;
    transform: translate(-50%, -50%);
    z-index: 0;
    object-fit: cover;
}

/* カードイラスト・マーキー背景（3列がゆっくり左右に流れる。中身は marquee-bg.js が生成） */
.home-bg-marquee {
    position: absolute;
    inset: 0;
    z-index: 0;
    overflow: hidden;
    display: flex;
    flex-direction: column;
    justify-content: center;
    gap: 2.5vh;
    background: var(--color-bg);
}

.hbm-row {
    display: flex;
    gap: 2.5vh;
    width: max-content;
    animation: hbm-move 90s linear infinite;
    will-change: transform;
}

/* 中央の列は逆方向・別速度にして単調さを消す */
.hbm-row.rev {
    animation-direction: reverse;
    animation-duration: 110s;
}

.hbm-row img {
    height: 29vh;
    width: auto;
    border-radius: 10px;
    filter: saturate(0.9) brightness(0.85);
    -webkit-user-drag: none;
    user-select: none;
}

/* 行の中身は2重化されているので -50% 移動でシームレスに無限ループする */
@keyframes hbm-move {
    to { transform: translateX(-50%); }
}

@media (prefers-reduced-motion: reduce) {
    .hbm-row { animation-play-state: paused; }
}

/* タイトルロゴ（通常フロー配置。プレイヤー名グループと共に中央アンカー・間隔固定） */
.home-title-logo {
    position: relative;
    z-index: 2;
    width: min(62vw, 560px);
    height: auto;
    margin-bottom: clamp(16px, 4vh, 44px);
    pointer-events: none;
    user-select: none;
    filter: drop-shadow(0 8px 28px rgba(0, 0, 0, 0.65)) drop-shadow(0 2px 8px rgba(0, 0, 0, 0.5));
}

/* 低い画面（ノートPC・ウィンドウ縮小時）はロゴを詰めて全体が収まるように */
@media (max-height: 820px) {
    .home-title-logo {
        width: min(48vw, 400px);
        margin-bottom: 12px;
    }
}

/* ===== 背景ホワイト試作（ローカル検証中・未確定。home-screen の bg-light クラスで切替） ===== */
.home-screen.bg-light .home-bg-marquee {
    background: #f5f2ea; /* 標本帳風の紙白 */
    gap: 1vh; /* 白背景では余白が目立つため詰める */
}

.home-screen.bg-light .hbm-row {
    gap: 1vh;
}

.home-screen.bg-light .hbm-row img {
    height: 32.5vh; /* 3列+間隙2つで約99.5vh=画面をほぼ満たす */
}

.home-screen.bg-light .hbm-row img {
    filter: saturate(0.95); /* 暗背景用の brightness(.85) を外す */
}

.home-screen.bg-light .home-bg-overlay {
    background: linear-gradient(
        to bottom,
        rgba(245, 242, 234, 0) 0%,
        rgba(245, 242, 234, 0) 40%,
        rgba(245, 242, 234, 0.55) 62%,
        rgba(245, 242, 234, 0.85) 82%,
        rgba(245, 242, 234, 0.95) 100%
    );
}

.home-screen.bg-light .home-title-logo {
    filter: drop-shadow(0 6px 20px rgba(60, 50, 30, 0.30)) drop-shadow(0 2px 6px rgba(60, 50, 30, 0.22));
}

/* 白背景では白文字ラベルが見えないため、ホーム画面内のラベルのみ濃色に */
.home-screen.bg-light .player-name-section label {
    color: #3a3428;
}

/* グラデーションオーバーレイ: 上部透明（ロゴ見える）→下部暗い（テキスト読める） */
.home-bg-overlay {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: linear-gradient(
        to bottom,
        transparent 0%,
        transparent 40%,
        rgba(26, 26, 46, 0.25) 60%,
        rgba(26, 26, 46, 0.5) 80%,
        rgba(26, 26, 46, 0.7) 100%
    );
    z-index: 1;
    pointer-events: none;
}

/* コンテンツ（下部配置） */
.home-content-bottom {
    position: relative;
    z-index: 2;
    width: 100%;
    max-width: 320px;
    padding-bottom: 32px;
}

/* プレイヤー名入力 */
.player-name-section {
    margin-bottom: 24px;
    width: 100%;
}

/* アイコン表示（コンパクト） */
.icon-current-display {
    display: flex;
    align-items: center;
    gap: 12px;
}

.icon-current-img {
    width: 48px;
    height: 48px;
    border-radius: 6px;
    border: 2px solid var(--color-primary);
    object-fit: cover;
}

.btn-icon-change {
    padding: 6px 16px;
    font-size: 0.8rem;
    min-height: 36px;
}

.icon-group {
    margin-top: 12px;
}

.icon-group label {
    display: block;
    margin-bottom: 6px;
}

/* メニューボタン */
.home-menu {
    display: flex;
    flex-direction: column;
    gap: 12px;
    width: 100%;
}

.home-menu .btn {
    font-size: 1.1rem;
    padding: 14px 24px;
    opacity: 0.85;
}

.home-menu .btn:hover {
    opacity: 1;
}

/* デバッグバトルボタン（右上固定） */
.btn-debug {
    position: absolute;
    top: 12px;
    right: 12px;
    z-index: 10;
    padding: 6px 14px;
    font-size: 11px;
    background: rgba(208, 64, 64, 0.6);
    color: #fff;
    border: 1px solid rgba(208, 64, 64, 0.8);
    border-radius: 4px;
    cursor: pointer;
    opacity: 0.7;
    transition: opacity 0.2s, background 0.2s;
}

.btn-debug:hover {
    opacity: 1;
    background: rgba(208, 64, 64, 0.85);
}

/* === アイコン選択オーバーレイ === */
.icon-select-modal {
    max-width: 420px;
}

.icon-select-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(72px, 1fr));
    gap: 12px;
    padding: 8px 0 16px;
    max-height: 60vh;
    overflow-y: auto;
}

.icon-select-item {
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 4px;
    border: 2px solid transparent;
    border-radius: 8px;
    cursor: pointer;
    transition: border-color 0.2s, background 0.2s;
}

.icon-select-item:hover {
    background: rgba(74, 144, 217, 0.1);
    border-color: rgba(74, 144, 217, 0.4);
}

.icon-select-item.selected {
    border-color: var(--color-primary);
    background: rgba(74, 144, 217, 0.15);
}

.icon-select-img {
    width: 64px;
    height: 64px;
    border-radius: 6px;
    object-fit: cover;
}

/* === 待機画面（旧home.cssから継続） === */
.waiting-screen {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    min-height: 100vh;
    padding: 20px;
}

.waiting-title {
    font-size: 1.5rem;
    margin-bottom: 24px;
}

.waiting-info {
    background-color: var(--color-bg-light);
    border: 1px solid var(--color-border);
    border-radius: 12px;
    padding: 24px;
    min-width: 300px;
    margin-bottom: 24px;
    text-align: center;
}

.waiting-info .player-row {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 8px 0;
    border-bottom: 1px solid var(--color-border);
}

.waiting-info .player-row:last-child {
    border-bottom: none;
}

.player-status {
    font-size: 0.875rem;
    padding: 2px 8px;
    border-radius: 4px;
}

.player-status.waiting {
    color: var(--color-text-muted);
}

.player-status.ready {
    color: var(--color-success);
    background-color: rgba(64, 192, 96, 0.15);
}

.waiting-dots {
    margin-top: 16px;
    font-size: 1.2rem;
    color: var(--color-text-muted);
    animation: dots 1.5s infinite;
}

@keyframes dots {
    0%, 20% { content: '.'; }
    40% { content: '..'; }
    60%, 100% { content: '...'; }
}

.waiting-actions {
    display: flex;
    gap: 12px;
}

/* ============ ホームメニュー整理（2026-07-06） ============ */
/* サブメニュー（ルール/画面ガイド/プロジェクト構造）は横並びの小ボタンに */
.home-submenu {
    display: flex;
    gap: 8px;
    margin-top: 10px;
}
.home-submenu .btn {
    flex: 1;
    font-size: 12px;
    padding: 9px 4px;
    opacity: 0.9;
    white-space: nowrap;
}

/* CPUレベル選択モーダル */
.cpu-level-btns { display: flex; flex-direction: column; gap: 8px; margin-top: 12px; }
.cpu-level-btns .btn {
    display: block;
    text-align: center;
    padding: 12px 10px;
    line-height: 1.4;
}
.cpu-level-btns .btn small {
    display: block;
    font-size: 11px;
    opacity: 0.7;
    font-weight: normal;
    margin-top: 2px;
}
.cpu-level-btns .btn:hover { border-color: #f5c542; box-shadow: 0 0 10px rgba(245, 197, 66, 0.4); }

/* ============ 対戦ロビーモーダル（v2トンマナ・2026-07-08作り直し） ============ */
#versus-lobby-modal {
    position: fixed; inset: 0; z-index: 1000;
    display: flex; align-items: center; justify-content: center;
    background: rgba(2, 6, 15, 0.82);
    backdrop-filter: blur(6px);
    padding: 18px;
}
.vl-panel {
    width: min(620px, 96vw);
    max-height: 92vh; overflow-y: auto;
    background:
        radial-gradient(600px 300px at 50% -60px, rgba(46, 127, 212, 0.18), transparent 60%),
        #0a1730;
    border: 1px solid rgba(46, 127, 212, 0.55);
    border-radius: 16px;
    padding: 22px 26px 24px;
    box-shadow: 0 24px 80px rgba(0, 0, 0, 0.7), 0 0 40px rgba(70, 170, 255, 0.12);
    color: #eaf6ff;
}
.vl-head {
    display: flex; align-items: center; justify-content: space-between;
    margin-bottom: 16px;
}
.vl-title {
    font-size: 20px; font-weight: 800; letter-spacing: 0.1em;
    color: #f5c542;
    text-shadow: 0 0 16px rgba(245, 197, 66, 0.35);
}
.vl-close {
    background: none; border: 1px solid rgba(46, 127, 212, 0.4);
    color: #8fb3d9; width: 32px; height: 32px; border-radius: 50%;
    font-size: 15px; cursor: pointer;
}
.vl-close:hover { color: #fff; border-color: #f5c542; }
.vl-sec-label {
    font-size: 11px; letter-spacing: 0.2em; font-weight: 700;
    color: #55c8ff; margin: 0 0 8px;
    display: flex; align-items: center; justify-content: space-between;
}
.vl-refresh {
    background: rgba(255, 255, 255, 0.05);
    border: 1px solid rgba(46, 127, 212, 0.4);
    color: #cfe3ff; border-radius: 999px;
    padding: 3px 16px; font-size: 11.5px; cursor: pointer;
}
.vl-refresh:hover { border-color: #55c8ff; }
.vl-room-list {
    border: 1px solid rgba(46, 127, 212, 0.3);
    border-radius: 10px;
    background: rgba(4, 10, 24, 0.55);
    min-height: 66px; max-height: 220px; overflow-y: auto;
    margin-bottom: 18px;
}
.vl-room {
    display: flex; align-items: center; gap: 12px;
    padding: 10px 12px;
    border-bottom: 1px solid rgba(46, 127, 212, 0.16);
}
.vl-room:last-child { border-bottom: none; }
.vl-room .ricon {
    width: 38px; height: 38px; border-radius: 50%;
    object-fit: cover; border: 2px solid rgba(46, 127, 212, 0.5);
    flex: 0 0 auto;
}
.vl-room .rbody { flex: 1; min-width: 0; }
.vl-room .rname {
    font-size: 14px; font-weight: 700;
    white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
.vl-room .rmeta { font-size: 11px; color: #8fb3d9; margin-top: 1px; }
.vl-room .rmeta .chip {
    display: inline-block; padding: 0 8px; margin-left: 6px;
    border: 1px solid rgba(245, 197, 66, 0.45); border-radius: 999px;
    color: #ffe08a; font-size: 10px;
}
.vl-join-btn {
    flex: 0 0 auto;
    background: linear-gradient(180deg, rgba(74, 144, 217, 0.9), rgba(46, 100, 180, 0.9));
    border: 1px solid rgba(120, 190, 255, 0.7);
    color: #fff; font-weight: 700;
    padding: 7px 20px; border-radius: 9px; font-size: 13px; cursor: pointer;
}
.vl-join-btn:hover { filter: brightness(1.15); }
.vl-empty { color: #8fb3d9; font-size: 12.5px; padding: 14px 12px; }
.vl-row { display: flex; gap: 8px; align-items: stretch; margin-bottom: 20px; }
.vl-input {
    flex: 1;
    background: rgba(4, 10, 24, 0.7);
    border: 1px solid rgba(46, 127, 212, 0.45);
    border-radius: 9px; color: #eaf6ff;
    padding: 10px 13px; font-size: 13.5px;
}
.vl-input:focus { outline: none; border-color: #55c8ff; box-shadow: 0 0 10px rgba(70, 170, 255, 0.25); }
.vl-input::placeholder { color: #5f7ea3; }
.vl-create {
    border: 1px solid rgba(46, 127, 212, 0.35);
    border-radius: 12px;
    background: rgba(8, 22, 48, 0.5);
    padding: 16px 16px 18px;
}
.vl-field { margin-bottom: 12px; }
.vl-field-label { font-size: 11.5px; color: #8fb3d9; margin-bottom: 5px; letter-spacing: 0.06em; }
.vl-seg { display: flex; gap: 8px; }
.vl-seg button {
    flex: 1;
    background: rgba(255, 255, 255, 0.04);
    border: 1px solid rgba(46, 127, 212, 0.4);
    color: #8fb3d9; border-radius: 9px;
    padding: 9px 6px; font-size: 13px; cursor: pointer;
}
.vl-seg button.on {
    color: #fff; font-weight: 700;
    border-color: #f5c542;
    background: rgba(245, 197, 66, 0.14);
    box-shadow: 0 0 12px rgba(245, 197, 66, 0.2);
}
.vl-seg button small { display: block; font-size: 10px; opacity: 0.75; font-weight: 400; margin-top: 1px; }
.vl-chips { display: flex; gap: 6px; flex-wrap: wrap; }
.vl-chips button {
    background: rgba(255, 255, 255, 0.04);
    border: 1px solid rgba(46, 127, 212, 0.4);
    color: #8fb3d9; border-radius: 999px;
    padding: 5px 14px; font-size: 12px; cursor: pointer;
}
.vl-chips button.on { color: #fff; font-weight: 700; border-color: #55c8ff; background: rgba(70, 170, 255, 0.16); }
.vl-create-btn {
    width: 100%;
    margin-top: 4px;
    background: linear-gradient(180deg, rgba(245, 197, 66, 0.92), rgba(200, 150, 30, 0.92));
    border: 1px solid rgba(255, 225, 140, 0.8);
    color: #241a00; font-weight: 800; letter-spacing: 0.12em;
    padding: 12px; border-radius: 10px; font-size: 15px; cursor: pointer;
}
.vl-create-btn:hover { filter: brightness(1.08); }
.vl-divider { border: none; border-top: 1px solid rgba(46, 127, 212, 0.25); margin: 4px 0 18px; }
