/* ========================================
   テーマカラー設定（CSS変数）
   ======================================== */

:root {
    /* ライトモード（デフォルト） */
    --bg-primary: #f5f5f5;
    --bg-secondary: #ffffff;
    --bg-tertiary: #f8f9fa;
    --bg-gradient-start: #ffffff;
    --bg-gradient-mid: #f8f9fa;
    --bg-gradient-end: #e9ecef;

    --text-primary: #212121;
    --text-secondary: #666666;
    --text-tertiary: #757575;

    --header-bg: #ffffff;
    --header-border: #cccccc;

    --card-bg: #ffffff;
    --card-border: #e0e0e0;
    --card-hover-border: #2196f3;

    --accent-primary: #2196f3;
    --accent-secondary: #1976d2;
    --accent-light: #00d4ff;

    --category-bg: #ffffff;
    --category-border: #e0e0e0;
    --category-text: #666666;
    --category-hover-bg: #f5f5f5;
    --category-hover-text: #333333;
    --category-active-text: #2196f3;
    --category-active-border: #2196f3;

    --badge-bg-start: #00d4ff;
    --badge-bg-end: #00a8e8;
    --badge-text: white;

    --shadow-sm: rgba(0, 0, 0, 0.05);
    --shadow-md: rgba(0, 0, 0, 0.08);
    --shadow-lg: rgba(33, 150, 243, 0.15);
}

/* ダークモード */
body.dark-mode {
    --bg-primary: #1a1d29;
    --bg-secondary: #252837;
    --bg-tertiary: #2a2f3e;
    --bg-gradient-start: #1a2332;
    --bg-gradient-mid: #1a1d29;
    --bg-gradient-end: #0f1117;

    --text-primary: #c5cfe0;
    --text-secondary: #8899bb;
    --text-tertiary: #9aa5b8;

    --header-bg: #2a2f3e;
    --header-border: #3a4052;

    --card-bg: #252837;
    --card-border: #3a4052;
    --card-hover-border: #6b8bb5;

    --accent-primary: #7a9ac5;
    --accent-secondary: #6b8bb5;
    --accent-light: #8899bb;

    --category-bg: #252837;
    --category-border: #3a4052;
    --category-text: #7a8499;
    --category-hover-bg: #2a2f3e;
    --category-hover-text: #a5b4c9;
    --category-active-text: #7a9ac5;
    --category-active-border: #6b8bb5;

    --badge-bg-start: #5a7a9f;
    --badge-bg-end: #4a6a8f;
    --badge-text: #e0e0e0;

    --shadow-sm: rgba(0, 0, 0, 0.2);
    --shadow-md: rgba(0, 0, 0, 0.3);
    --shadow-lg: rgba(107, 139, 181, 0.25);
}

/* ========================================
   全体の設定
   ======================================== */

* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

html {
    overflow-x: hidden;
    /* iOS Safari対策: アドレスバー分の高さを確保 */
    height: -webkit-fill-available;
}

body {
    font-family: 'Arial', 'Hiragino Sans', 'Yu Gothic', sans-serif;
    background-color: var(--bg-primary);
    color: var(--text-primary);
    overflow: hidden;
    height: 100vh;
    /* iOS Safari対策: 100vhの代わりに-webkit-fill-availableを使用 */
    height: -webkit-fill-available;
    transition: background-color 0.3s ease, color 0.3s ease;
}

/* ========================================
   シンプルな背景
   ======================================== */

.city-background {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    z-index: -1; /* 一番後ろに配置 */
    overflow: hidden;
}

/* シンプルなグラデーション背景 */
.sky-gradient {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: linear-gradient(
        to bottom,
        var(--bg-gradient-start) 0%,
        var(--bg-gradient-mid) 50%,
        var(--bg-gradient-end) 100%
    );
    transition: background 0.3s ease;
}

/* ========================================
   ヘッダー（上部のバー）
   ======================================== */

.header {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 60px;
    background: var(--header-bg);
    border-bottom: 1px solid var(--header-border);
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 0 20px;
    z-index: 100;
    box-shadow: 0 2px 8px var(--shadow-md);
    transition: all 0.3s ease;
}

/* 左側：タイトル */
.header-left {
    display: flex;
    align-items: center;
    gap: 15px;
}

/* ハンバーガーメニューボタン */
.hamburger-menu {
    display: -webkit-box;
    display: -ms-flexbox;
    display: flex;
    -webkit-box-orient: vertical;
    -webkit-box-direction: normal;
    -ms-flex-direction: column;
    flex-direction: column;
    gap: 4px;
    background: transparent;
    border: none;
    cursor: pointer;
    padding: 8px;
    -webkit-transition: all 0.3s ease;
    -o-transition: all 0.3s ease;
    transition: all 0.3s ease;
}

.hamburger-menu span {
    width: 24px;
    height: 3px;
    background: #1976d2; /* 送信ボタンと同じ青 */
    border-radius: 2px;
    transition: all 0.3s ease;
}

.hamburger-menu:hover span {
    background: #1565c0; /* ホバー時は少し濃い青 */
}

/* 設定メニューボタン */
.settings-menu {
    background: transparent;
    border: none;
    cursor: pointer;
    padding: 8px;
    font-size: 20px;
    line-height: 1;
    transition: transform 0.3s ease;
    color: var(--text-primary);
}

.settings-menu:hover {
    transform: rotate(90deg);
}

.settings-menu:active {
    transform: scale(0.9);
}

.city-title {
    font-size: 1.5rem;
    font-weight: bold;
    color: #1976d2; /* 送信ボタンと同じ青 */
    letter-spacing: 2px;
}

/* 右側：ユーザー名と退出ボタン */
.header-right {
    display: flex;
    align-items: center;
    gap: 15px; /* 要素間の間隔 */
}

.username-display {
    font-size: 1rem;
    color: var(--text-primary); /* 明るいグレーブルー */
    font-weight: 500;
    padding: 8px 15px;
    background: var(--bg-primary);
    border-radius: 20px;
    border: 1px solid var(--card-border);
}

/* ========================================
   チャットコンテナ
   ======================================== */

.chat-container {
    position: fixed;
    top: 60px; /* ヘッダーの真下に配置 */
    left: 0;
    width: 100%; /* 画面幅いっぱい */
    height: calc(100vh - 60px - 78px); /* ヘッダーと入力エリア分を引いた高さ */
    background: var(--bg-primary); /* ダークブルー背景 */
    display: flex;
    flex-direction: column;
    overflow: hidden;
}

/* ========================================
   カテゴリバー（Yahoo!ニュース風）
   ======================================== */

.category-bar {
    background: var(--bg-primary);
    border-bottom: 1px solid var(--card-border);
    padding: 12px 0;
    overflow: hidden;
}

.category-tabs {
    display: flex;
    gap: 8px;
    overflow-x: auto;
    overflow-y: hidden;
    padding: 0 16px;
    /* スクロールバーを非表示 */
    scrollbar-width: none;
    -ms-overflow-style: none;
    -webkit-overflow-scrolling: touch;
}

.category-tabs::-webkit-scrollbar {
    display: none;
}

.category-tab {
    flex-shrink: 0;
    padding: 8px 20px;
    background: rgba(255, 255, 255, 0.08);
    border: 1px solid rgba(255, 255, 255, 0.15);
    border-radius: 20px;
    color: var(--text-secondary);
    font-size: 0.9rem;
    font-weight: 500;
    cursor: pointer;
    transition: all 0.3s ease;
    white-space: nowrap;
    -webkit-user-select: none;
    -moz-user-select: none;
    -ms-user-select: none;
    user-select: none;
}

.category-tab:hover {
    background: rgba(255, 255, 255, 0.12);
    transform: translateY(-1px);
}

.category-tab:active {
    transform: translateY(0);
}

.category-tab.active {
    background: var(--accent-primary);
    color: #ffffff;
    font-weight: 600;
    border-color: var(--accent-primary);
    box-shadow: 0 2px 8px rgba(0, 255, 255, 0.3);
}

/* ========================================
   ルーム選択バー
   ======================================== */

.room-bar {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 6px 8px;
    background: #fafafa;
    border-bottom: 1px solid #cccccc;
    overflow: hidden;
}

.room-tabs {
    display: flex;
    gap: 6px;
    flex: 1;
    min-width: 0;
    overflow-x: auto;
    overflow-y: hidden;
    padding: 3px 6px;
    /* スクロールバーを非表示 */
    scrollbar-width: none;
    -ms-overflow-style: none;
    /* 高速スクロール最適化 */
    -webkit-overflow-scrolling: touch;
    overscroll-behavior-x: contain;
    /* GPUアクセラレーション有効化 */
    will-change: scroll-position;
    transform: translateZ(0);
    -webkit-transform: translateZ(0);
    /* タッチ操作最適化 */
    touch-action: pan-x;
    /* 慣性スクロール */
    scroll-behavior: auto;
}

/* スクロールバーを完全に非表示 */
.room-tabs::-webkit-scrollbar {
    display: none;
}

.room-tab {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 10px 24px;
    background: #ffffff;
    border: 1.5px solid #d0d0d0;
    border-radius: 28px;
    color: #333333;
    font-weight: 500;
    font-size: 1rem;
    cursor: pointer;
    transition: all 0.25s cubic-bezier(0.4, 0, 0.2, 1);
    white-space: nowrap;
    -webkit-user-select: none;

    -moz-user-select: none;

    -ms-user-select: none;

    user-select: none;
    box-shadow: 0 1px 2px rgba(0, 0, 0, 0.06);
    flex-shrink: 0;
    /* スクロールパフォーマンス最適化 */
    will-change: transform;
    backface-visibility: hidden;
    -webkit-backface-visibility: hidden;
}

.room-tab:hover {
    background: #f8f9fa;
    border-color: #2196f3;
    transform: translateY(-1px);
    box-shadow: 0 2px 6px rgba(33, 150, 243, 0.12);
}

.room-tab.active {
    background: linear-gradient(135deg, #e3f2fd 0%, #d1e9fc 100%);
    border-color: #2196f3;
    color: #1565c0;
    box-shadow: 0 2px 8px rgba(33, 150, 243, 0.25);
    transform: scale(1.03);
    font-weight: 600;
}

/* 最近訪問したルーム（緑色の枠） */
.room-tab.recent:not(.active) {
    border-color: #66bb6a;
    box-shadow: 0 1px 3px rgba(76, 175, 80, 0.2);
}

.room-tab.recent:not(.active):hover {
    border-color: #4caf50;
    box-shadow: 0 2px 6px rgba(76, 175, 80, 0.3);
}

.room-tab.full {
    opacity: 0.5;
    cursor: not-allowed;
}

.room-emoji {
    font-size: 1.3rem;
    line-height: 1;
    filter: drop-shadow(0 1px 1px rgba(0, 0, 0, 0.08));
}

.room-name {
    font-weight: 500;
    letter-spacing: 0.2px;
}

.room-count {
    font-size: 0.75rem;
    color: #666666;
    font-weight: 600;
    background: rgba(0, 0, 0, 0.06);
    padding: 3px 6px;
    border-radius: 9px;
    min-width: 28px;
    text-align: center;
}

.room-count.full {
    color: #ffffff;
    background: #f44336;
}

/* ========================================
   浮遊ルーム作成ボタン（下部中央）
   ======================================== */

.floating-create-btn {
    position: fixed;
    bottom: 16px;
    left: 50%;
    transform: translateX(-50%);
    width: 40px;
    height: 40px;
    background: rgba(128, 128, 128, 0.15);
    backdrop-filter: blur(10px);
    -webkit-backdrop-filter: blur(10px);
    border: 1px solid rgba(128, 128, 128, 0.2);
    border-radius: 50%;
    color: rgba(128, 128, 128, 0.7);
    font-size: 1.2rem;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    box-shadow: 0 1px 3px rgba(0, 0, 0, 0.08);
    z-index: 50;
    transition: all 0.2s ease;
}

.floating-create-btn:hover {
    background: rgba(128, 128, 128, 0.25);
    color: rgba(80, 80, 80, 0.85);
    box-shadow: 0 2px 6px rgba(0, 0, 0, 0.12);
}

.floating-create-btn:active {
    transform: translateX(-50%) scale(0.95);
    background: rgba(128, 128, 128, 0.3);
}

/* ========================================
   ルーム一覧ビュー
   ======================================== */

.room-list-view {
    flex: 1;
    overflow-y: auto;
    padding: 0;
    background: var(--bg-primary);
}

.room-cards-container {
    display: flex;
    flex-direction: column;
    gap: 0;
    padding-bottom: 100px;
}

.room-card {
    background: var(--card-bg);
    border-radius: 0;
    padding: 16px 20px;
    box-shadow: none;
    cursor: pointer;
    transition: background-color 0.15s ease;
    border: none;
    border-bottom: 1px solid var(--card-border);
}

.room-card:active {
    background-color: var(--category-hover-bg);
}

.room-card-content {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 16px;
}

.room-card-main {
    flex: 1;
    display: flex;
    flex-direction: column;
    gap: 4px;
}

.room-card-name {
    font-size: 1rem;
    font-weight: 600;
    color: var(--text-primary);
    line-height: 1.5;
}

.room-card-description {
    font-size: 0.85rem;
    color: var(--text-secondary);
    line-height: 1.4;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.room-card-side {
    display: flex;
    align-items: center;
    flex-shrink: 0;
}

.room-card-users {
    font-size: 0.85rem;
    color: var(--text-tertiary);
    font-weight: 400;
}

.room-card.full {
    opacity: 0.5;
    cursor: not-allowed;
}

.room-card.full .room-card-users::after {
    content: ' 満員';
    color: #ef5350;
    font-weight: 600;
}

/* お気に入りボタン */
.favorite-btn {
    background: transparent;
    border: none;
    font-size: 1.2rem;
    cursor: pointer;
    padding: 4px;
    margin-right: 8px;
    transition: transform 0.2s ease;
    line-height: 1;
}

.favorite-btn:hover {
    transform: scale(1.2);
}

.favorite-btn:active {
    transform: scale(0.9);
}

/* お気に入りリスト */
.favorites-list {
    max-height: 400px;
    overflow-y: auto;
    margin: 10px 0;
}

.favorites-empty {
    text-align: center;
    padding: 40px 20px;
    color: var(--text-secondary);
    font-size: 0.95rem;
}

.favorite-room-item {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 15px;
    background: var(--card-bg);
    border: 1px solid var(--card-border);
    border-radius: 12px;
    margin-bottom: 10px;
    cursor: pointer;
    transition: all 0.3s ease;
}

.favorite-room-item:hover {
    border-color: var(--accent-primary);
    transform: translateX(5px);
}

.favorite-room-item:active {
    transform: translateX(3px) scale(0.98);
}

.favorite-room-main {
    flex: 1;
}

.favorite-room-name {
    font-weight: 600;
    font-size: 1rem;
    color: var(--text-primary);
    margin-bottom: 4px;
}

.favorite-room-category {
    font-size: 0.85rem;
    color: var(--text-secondary);
}

.favorite-room-users {
    font-size: 0.9rem;
    color: var(--text-tertiary);
    margin-left: 10px;
}

/* ========================================
   チャットビュー
   ======================================== */

.chat-view {
    flex: 1;
    display: flex;
    flex-direction: column;
    overflow: hidden;
    transition: transform 0.3s ease;
    will-change: transform;
}

/* ========================================
   チャットヘッダー
   ======================================== */

.chat-header {
    padding: 15px 20px;
    background: #fafafa;
    border-bottom: 1px solid #cccccc;
    display: flex;
    align-items: center;
    gap: 15px;
    transition: opacity 0.3s ease, transform 0.3s ease;
}

.back-button {
    background: transparent;
    border: none;
    color: #2196f3;
    font-size: 1.2rem;
    font-weight: 500;
    cursor: pointer;
    padding: 8px 12px;
    border-radius: 8px;
    transition: all 0.2s ease;
    display: flex;
    align-items: center;
    justify-content: center;
}

.back-button:hover {
    background: #e3f2fd;
}

.chat-room-info {
    flex: 1;
    display: flex;
    align-items: center;
    gap: 10px;
}

.chat-room-emoji {
    font-size: 1.5rem;
}

.chat-room-name {
    font-size: 1.1rem;
    font-weight: 600;
    color: #212121;
}

.chat-room-users {
    display: flex;
    align-items: center;
    gap: 6px;
}

.user-count {
    font-size: 0.9rem;
    color: #666666;
    font-weight: 500;
}

/* 話題ボタン */
.topic-button {
    background: transparent;
    border: 2px solid #1976d2;
    border-radius: 50%;
    width: 38px;
    height: 38px;
    font-size: 1.1rem;
    cursor: pointer;
    transition: all 0.3s ease;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 0;
}

.topic-button:hover {
    background: #1976d2;
    transform: scale(1.1);
    box-shadow: 0 2px 8px rgba(25, 118, 210, 0.3);
}

/* オンラインインジケーター（緑の点） */
.online-indicator {
    width: 10px;
    height: 10px;
    background: #4caf50;
    border-radius: 50%; /* 円形 */
    box-shadow: 0 0 4px rgba(76, 175, 80, 0.5);
    animation: pulse 2s ease-in-out infinite; /* 点滅アニメーション */
}

/* 点滅アニメーション */
@keyframes pulse {
    0%, 100% {
        opacity: 1;
        transform: scale(1);
    }
    50% {
        opacity: 0.6;
        transform: scale(0.9);
    }
}

.chat-header span {
    font-size: 1rem;
    color: #333333;
    flex: 1;
    font-weight: 500;
}

.online-count {
    font-size: 0.85rem;
    color: #757575;
}

/* ========================================
   メッセージ表示エリア
   ======================================== */

.messages-area {
    flex: 1; /* 残りのスペースを全て使う */
    padding: 12px;
    padding-bottom: 100px; /* 固定入力欄のスペースを確保 */
    overflow-y: auto; /* scrollからautoに戻す */
    overflow-x: hidden;
    display: flex;
    flex-direction: column;
    gap: 10px; /* メッセージ間の間隔 */
    transition: opacity 0.3s ease, transform 0.3s ease; /* トランジション効果 */
    /* タッチスクロール最適化 */
    -webkit-overflow-scrolling: touch;
    touch-action: pan-y;
    /* スクロール範囲を制限（最後まで行ったら止まる） */
    overscroll-behavior-y: contain;
    /* iOS Safari対策 */
    -webkit-transform: translateZ(0);
    transform: translateZ(0);
}

/* ルーム切り替え時のフェードアウト */
.messages-area.fade-out,
.chat-header.fade-out,
.input-area.fade-out {
    opacity: 0;
    transform: translateX(-20px);
}

/* ルーム切り替え時のフェードイン */
.messages-area.fade-in,
.chat-header.fade-in,
.input-area.fade-in {
    opacity: 1;
    transform: translateX(0);
}

/* スクロールバーのカスタマイズ（Webkit系ブラウザ） */
.messages-area::-webkit-scrollbar {
    width: 8px;
}

.messages-area::-webkit-scrollbar-track {
    background: #f5f5f5;
    border-radius: 0;
}

.messages-area::-webkit-scrollbar-thumb {
    background: #bdbdbd;
    border-radius: 0;
}

.messages-area::-webkit-scrollbar-thumb:hover {
    background: #9e9e9e;
}

/* ウェルカムメッセージ */
.welcome-message {
    text-align: center;
    color: #757575;
    padding: 40px 20px;
    line-height: 1.8;
}

/* エラーメッセージ */
.error-message {
    text-align: center;
    color: #ff5252;
    background-color: rgba(255, 82, 82, 0.1);
    border: 1px solid rgba(255, 82, 82, 0.3);
    border-radius: 10px;
    padding: 40px 20px;
    margin: 40px 20px;
    line-height: 1.8;
}

.error-message p:first-child {
    font-size: 1.2rem;
    font-weight: bold;
    margin-bottom: 10px;
}

/* ========================================
   メッセージのスタイル
   ======================================== */

.message {
    display: flex;
    flex-direction: column;
    gap: 3px;
    animation: messageSlideIn 0.3s ease; /* 出現アニメーション */
    position: relative; /* リアクションを絶対配置するため */
    max-width: 70%; /* メッセージの最大幅を制限 */
    align-self: flex-start; /* デフォルトは左寄せ */
}

/* メッセージが出現するアニメーション */
@keyframes messageSlideIn {
    from {
        opacity: 0;
        transform: translateY(10px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

/* メッセージヘッダー（名前と時刻） */
.message-header {
    display: flex;
    align-items: center;
    gap: 10px;
    font-size: 0.85rem;
}

.message-username {
    font-weight: bold;
    color: #1565c0; /* より濃い青 */
}

.message-time {
    color: #616161; /* より濃いグレー */
    font-size: 0.75rem;
    font-weight: 500; /* 少し太く */
}

/* メッセージ本文 */
.message-content {
    padding: 8px 12px;
    background: #e1f5fe; /* 薄い水色 */
    border-left: 4px solid #1976d2; /* 太く濃く */
    border-radius: 12px;
    color: #212121; /* より濃い文字色 */
    font-weight: 500; /* 少し太く */
    line-height: 1.5;
    word-wrap: break-word; /* 長い文字を折り返す */
    width: fit-content; /* 内容の幅に合わせる */
}

/* メッセージ内のリンク */
.message-link {
    color: #1976d2;
    text-decoration: underline;
    transition: all 0.2s ease;
}

.message-link:hover {
    color: #0d47a1;
}

/* メンション */
.mention {
    color: #1976d2;
    background-color: rgba(25, 118, 210, 0.1);
    padding: 2px 6px;
    border-radius: 4px;
    font-weight: 600;
}

.mention-me {
    color: #ff6b00;
    background-color: rgba(255, 107, 0, 0.15);
    font-weight: 700;
}

.mention-clickable {
    cursor: pointer;
    transition: all 0.2s ease;
}

.mention-clickable:hover {
    opacity: 0.8;
    transform: scale(1.05);
}

/* メッセージハイライトアニメーション */
.message-highlight {
    animation: highlightPulse 2s ease-in-out;
}

@keyframes highlightPulse {
    0%, 100% {
        background-color: transparent;
    }
    50% {
        background-color: rgba(255, 235, 59, 0.3);
    }
}

/* 画像メッセージ */
.message-image {
    max-width: 300px;
    max-height: 300px;
    border-radius: 12px;
    cursor: pointer;
    transition: all 0.3s ease;
    object-fit: contain;
}

.message-image:hover {
    transform: scale(1.02);
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.15);
}

/* 画像読み込み中 */
.message-image-loading {
    padding: 40px;
    text-align: center;
    color: #757575;
    font-size: 0.9rem;
}

/* 自分のメッセージ */
.message.own {
    align-self: flex-end; /* 右寄せ */
}

.message.own .message-username {
    color: #7b1fa2;
}

.message.own .message-content {
    background: #f3e5f5;
    border-left-color: #9c27b0;
}

/* 話題メッセージ（中央配置） */
.message.topic {
    align-self: center; /* 中央寄せ */
    max-width: 85%; /* 幅を広げる */
    margin: 15px 0; /* 上下に余白 */
}

.message.topic .message-header {
    justify-content: center; /* ヘッダーも中央 */
    gap: 8px;
}

.message.topic .message-username {
    color: #666666; /* グレー */
    font-weight: 400;
    font-size: 0.75rem;
}

.message.topic .message-time {
    color: #999999;
    font-size: 0.75rem;
}

.message.topic .message-content {
    background: transparent; /* 背景なし */
    border-left: none; /* 枠線なし */
    border-radius: 0;
    padding: 8px 0;
    font-weight: 500;
    font-size: 0.95rem;
    color: #333333; /* 通常の文字色 */
    text-align: center; /* テキストを中央揃え */
    box-shadow: none; /* 影なし */
    width: 100%; /* 幅いっぱいに */
}

/* 話題メッセージはリアクションボタンを非表示 */
.message.topic .message-reactions {
    display: none;
}

/* 話題のリンクコンテナ */
.topic-link-container {
    margin-top: 10px;
    text-align: center;
}

/* 話題のリンクボタン */
.topic-link {
    display: inline-block;
    padding: 8px 16px;
    background: #1976d2;
    color: white !important;
    text-decoration: none !important;
    border-radius: 20px;
    font-size: 0.9rem;
    font-weight: 600;
    transition: all 0.2s ease;
    box-shadow: 0 2px 4px rgba(0, 0, 0, 0.1);
}

.topic-link:hover {
    background: #1565c0;
    transform: translateY(-1px);
    box-shadow: 0 3px 6px rgba(0, 0, 0, 0.15);
}

.topic-link:active {
    transform: translateY(0);
}

/* ========================================
   リアクション機能
   ======================================== */

/* リアクションエリア */
.message-reactions {
    display: flex;
    flex-wrap: wrap;
    gap: 4px;
    position: absolute;
    top: 8px;
    right: 8px;
    max-width: 200px;
    justify-content: flex-end;
    opacity: 0.8;
    transition: opacity 0.2s ease;
}

.message:hover .message-reactions {
    opacity: 1;
}

/* 個別のリアクションボタン */
.reaction-item {
    display: inline-flex;
    align-items: center;
    gap: 2px;
    padding: 2px 6px;
    background: #ffffff;
    border: 1px solid #cccccc;
    border-radius: 12px;
    font-size: 0.8rem;
    cursor: pointer;
    transition: all 0.2s ease;
    -webkit-user-select: none;

    -moz-user-select: none;

    -ms-user-select: none;

    user-select: none;
}

.reaction-item:hover {
    background: #f5f5f5;
    border-color: #2196f3;
    transform: scale(1.05);
}

/* 自分がリアクションしたもの */
.reaction-item.reacted {
    background: #e3f2fd;
    border-color: #2196f3;
}

/* リアクションの絵文字 */
.reaction-emoji {
    font-size: 0.85rem;
    line-height: 1;
}

/* リアクションのカウント */
.reaction-count {
    font-size: 0.7rem;
    color: #ffffff;
    font-weight: 600;
    min-width: 12px;
    text-align: center;
}

/* リアクション追加ボタン */
.add-reaction-btn {
    display: none; /* 通常は非表示 */
    align-items: center;
    justify-content: center;
    width: 22px;
    height: 22px;
    background: #ffffff;
    border: 1px dashed #bdbdbd;
    border-radius: 50%;
    font-size: 0.85rem;
    cursor: pointer;
    transition: all 0.2s ease;
    -webkit-user-select: none;

    -moz-user-select: none;

    -ms-user-select: none;

    user-select: none;
    color: #757575;
}

/* メッセージにホバーした時だけ表示 */
.message:hover .add-reaction-btn {
    display: inline-flex;
}

.add-reaction-btn:hover {
    background: #f5f5f5;
    border-color: #2196f3;
    color: #2196f3;
    transform: scale(1.1);
}

/* リアクション選択パネル */
.reaction-picker {
    position: fixed;
    display: none;
    background: #ffffff;
    border: 1px solid #cccccc;
    border-radius: 12px;
    padding: 12px;
    box-shadow: 0 4px 16px rgba(0, 0, 0, 0.2);
    z-index: 1000;
    max-width: calc(100vw - 20px); /* 画面幅に収める */
}

.reaction-picker.active {
    display: block;
}

.reaction-picker-grid {
    display: grid;
    grid-template-columns: repeat(5, 1fr); /* 5列グリッド */
    gap: 6px;
    max-width: 240px; /* グリッド全体の最大幅 */
}

.reaction-picker-emoji {
    font-size: 1.6rem;
    width: 44px;
    height: 44px;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    border-radius: 8px;
    transition: all 0.2s ease;
    -webkit-user-select: none;

    -moz-user-select: none;

    -ms-user-select: none;

    user-select: none;
}

.reaction-picker-emoji:hover {
    background: #e3f2fd;
    transform: scale(1.15);
}

/* モバイル対応 */
@media (max-width: 480px) {
    .reaction-picker-grid {
        grid-template-columns: repeat(5, 1fr);
        gap: 4px;
        max-width: 220px;
    }

    .reaction-picker-emoji {
        font-size: 1.4rem;
        width: 40px;
        height: 40px;
    }
}

/* ========================================
   入力エリア
   ======================================== */

.input-area {
    position: fixed;
    bottom: 0;
    left: 0;
    width: 100%;
    padding: 15px;
    padding-bottom: max(15px, env(safe-area-inset-bottom));
    background: #fafafa;
    border-top: 1px solid #cccccc;
    display: flex;
    align-items: flex-end;
    gap: 10px;
    z-index: 1000;
    box-shadow: 0 -2px 8px rgba(0, 0, 0, 0.05);
    pointer-events: auto;
    /* スクロール時も完全固定 */
    transform: translate3d(0, 0, 0);
    -webkit-transform: translate3d(0, 0, 0);
    backface-visibility: hidden;
    -webkit-backface-visibility: hidden;
}

.image-button {
    padding: 12px;
    background: #ffffff;
    border: 2px solid #2196f3;
    border-radius: 50%;
    width: 48px;
    height: 48px;
    font-size: 1.2rem;
    cursor: pointer;
    transition: all 0.3s ease;
    display: none; /* 一時的に非表示（Firebase Storage有効化後にflexに戻す） */
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
    color: #2196f3;
}

.image-button:hover {
    background: #e3f2fd;
    transform: scale(1.05);
}

.message-input {
    flex: 1;
    padding: 12px 15px;
    background: #ffffff;
    border: 2px solid #bbb; /* より濃い境界線 */
    border-radius: 25px;
    color: #212121; /* より濃い文字色 */
    font-size: 1rem;
    font-weight: 500; /* 少し太く */
    outline: none;
    transition: all 0.3s ease;
    /* textareaのため、自動拡張 */
    min-height: 48px;
    max-height: 150px;
    line-height: 1.5;
    resize: none;
    overflow-y: auto;
    /* タッチ・入力の確実な有効化 */
    pointer-events: auto !important;
    touch-action: manipulation;
    -webkit-user-select: text;
    user-select: text;
    /* PWA対応 */
    -webkit-tap-highlight-color: rgba(0, 0, 0, 0.1);
    -webkit-touch-callout: default;
    cursor: text;
}

.message-input:focus {
    border-color: #1976d2; /* より濃い青 */
    box-shadow: 0 0 0 3px rgba(25, 118, 210, 0.15);
}

.message-input::placeholder {
    color: #757575; /* より濃いプレースホルダー */
}

.send-button {
    padding: 12px 24px;
    background: #1976d2; /* より濃い青 */
    border: none;
    border-radius: 25px;
    color: #ffffff;
    font-weight: bold;
    cursor: pointer;
    transition: all 0.3s ease;
    font-size: 1.1rem;
    display: flex;
    align-items: center;
    justify-content: center;
}

.send-button:hover {
    background: #1976d2;
    transform: translateY(-2px);
    box-shadow: 0 4px 8px rgba(33, 150, 243, 0.3);
}

.send-button:active {
    transform: translateY(0);
    box-shadow: 0 2px 4px rgba(33, 150, 243, 0.3);
}

/* 送信中のスタイル */
.send-button.sending {
    background: #90caf9;
    cursor: not-allowed;
    opacity: 0.7;
}

.send-button:disabled {
    background: #90caf9;
    cursor: not-allowed;
    opacity: 0.7;
}

/* ========================================
   ルーム作成モーダル
   ======================================== */

.modal {
    display: none;
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.5);
    z-index: 2000;
    align-items: center;
    justify-content: center;
}

.modal.active {
    display: flex;
}

.modal-content {
    background: #ffffff;
    border: 1px solid #cccccc;
    border-radius: 20px;
    padding: 30px;
    max-width: 500px;
    width: 90%;
    box-shadow: 0 8px 24px rgba(0, 0, 0, 0.15);
    animation: modalSlideIn 0.3s ease;
}

@keyframes modalSlideIn {
    from {
        opacity: 0;
        transform: translateY(-20px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

.modal-title {
    font-size: 1.5rem;
    color: #333333;
    margin-bottom: 20px;
    text-align: center;
    font-weight: bold;
}

/* ヘルプモーダル専用 */
.help-modal {
    max-width: 600px;
    max-height: 80vh;
    overflow-y: auto;
}

.help-content {
    text-align: left;
}

.help-section {
    margin-bottom: 24px;
}

.help-section h3 {
    color: #1976d2;
    font-size: 1.1rem;
    margin-bottom: 12px;
    display: flex;
    align-items: center;
    gap: 8px;
}

.help-section ul {
    list-style: none;
    padding: 0;
    margin: 0;
}

.help-section li {
    padding: 8px 0;
    border-bottom: 1px solid #f0f0f0;
    line-height: 1.6;
}

.help-section li:last-child {
    border-bottom: none;
}

.help-section strong {
    color: #333;
}

.form-group {
    margin-bottom: 20px;
}

.form-group label {
    display: block;
    color: #333333;
    font-size: 0.9rem;
    margin-bottom: 8px;
    font-weight: 500;
}

.form-group input[type="text"] {
    width: 100%;
    padding: 10px 15px;
    background: #ffffff;
    border: 2px solid #cccccc;
    border-radius: 10px;
    color: #333333;
    font-size: 1rem;
    outline: none;
    transition: all 0.3s ease;
}

.form-group input[type="text"]:focus {
    border-color: #2196f3;
    box-shadow: 0 0 0 3px rgba(33, 150, 243, 0.1);
}

.emoji-selector {
    display: grid;
    grid-template-columns: repeat(5, 1fr);
    gap: 8px;
}

.emoji-option {
    width: 48px;
    height: 48px;
    background: #ffffff;
    border: 2px solid #cccccc;
    border-radius: 50%;
    font-size: 1.5rem;
    cursor: pointer;
    transition: all 0.2s ease;
}

.emoji-option:hover {
    background: #f5f5f5;
    border-color: #2196f3;
    transform: scale(1.1);
}

.emoji-option.selected {
    background: #e3f2fd;
    border-color: #2196f3;
    box-shadow: 0 0 0 3px rgba(33, 150, 243, 0.1);
}

/* カード型カテゴリーセレクター */
.category-cards {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 12px;
    margin-top: 10px;
}

.category-card {
    position: relative;
    cursor: pointer;
    border-radius: 12px;
    background: #ffffff;
    border: 2px solid #e0e0e0;
    transition: all 0.3s ease;
    overflow: hidden;
}

.category-card input[type="radio"] {
    position: absolute;
    opacity: 0;
    pointer-events: none;
}

.card-content {
    padding: 16px 8px;
    text-align: center;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 6px;
}

.card-icon {
    font-size: 32px;
    line-height: 1;
    margin-bottom: 4px;
}

.card-title {
    font-size: 14px;
    font-weight: 600;
    color: #333;
    line-height: 1.2;
}

.card-description {
    font-size: 11px;
    color: #666;
    line-height: 1.2;
}

.category-card:hover {
    border-color: #2196f3;
    background: #f0f8ff;
    transform: translateY(-2px);
    box-shadow: 0 4px 8px rgba(33, 150, 243, 0.15);
}

.category-card:has(input[type="radio"]:checked) {
    border-color: #2196f3;
    background: linear-gradient(135deg, #e3f2fd 0%, #bbdefb 100%);
    box-shadow: 0 4px 12px rgba(33, 150, 243, 0.25);
}

.category-card:has(input[type="radio"]:checked) .card-title {
    color: #1565c0;
}

.category-card:has(input[type="radio"]:checked) .card-description {
    color: #1976d2;
}

/* レスポンシブ対応 */
@media (max-width: 480px) {
    .category-cards {
        grid-template-columns: repeat(3, 1fr);
        gap: 8px;
    }

    .card-content {
        padding: 10px 6px;
        gap: 4px;
    }

    .card-icon {
        font-size: 24px;
        margin-bottom: 2px;
    }

    .card-title {
        font-size: 12px;
    }

    .card-description {
        font-size: 9px;
    }
}

/* 旧スタイル（リスト型）- バックアップとして残す */
.category-selector {
    display: flex;
    flex-wrap: wrap;
    gap: 10px;
}

.category-selector label {
    display: flex;
    align-items: center;
    gap: 5px;
    cursor: pointer;
    color: #333333;
    padding: 8px 12px;
    border: 1.5px solid #d0d0d0;
    border-radius: 20px;
    background: #ffffff;
    transition: all 0.2s ease;
}

.category-selector label:hover {
    border-color: #2196f3;
    background: #f0f8ff;
}

.category-selector input[type="radio"]:checked + label,
.category-selector label:has(input[type="radio"]:checked) {
    border-color: #2196f3;
    background: #e3f2fd;
    color: #1565c0;
    font-weight: 600;
}

.category-selector input[type="radio"] {
    accent-color: #2196f3;
    cursor: pointer;
}

.max-users-selector {
    display: flex;
    gap: 15px;
}

.max-users-selector label {
    display: flex;
    align-items: center;
    gap: 5px;
    cursor: pointer;
    color: #333333;
}

.max-users-selector input[type="radio"] {
    accent-color: #2196f3;
    cursor: pointer;
}

.modal-actions {
    display: flex;
    gap: 10px;
    margin-top: 25px;
}

.modal-actions button {
    flex: 1;
    padding: 12px;
    border-radius: 10px;
    font-size: 1rem;
    font-weight: 500;
    cursor: pointer;
    transition: all 0.3s ease;
}

.btn-cancel {
    background: #ffffff;
    border: 1px solid #cccccc;
    color: #333333;
}

.btn-cancel:hover {
    background: #f5f5f5;
}

.btn-create {
    background: #2196f3;
    border: none;
    color: #ffffff;
    font-weight: bold;
}

.btn-create:hover {
    background: #1976d2;
    transform: translateY(-2px);
    box-shadow: 0 4px 8px rgba(33, 150, 243, 0.3);
}

.btn-create:disabled {
    opacity: 0.5;
    cursor: not-allowed;
    transform: none;
}

/* ========================================
   話題選択モーダル
   ======================================== */

.topic-modal {
    display: none;
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.5);
    z-index: 10000;
    align-items: center;
    justify-content: center;
}

.topic-modal.active {
    display: flex;
}

.topic-modal-content {
    background: #ffffff;
    border-radius: 20px;
    padding: 30px 25px;
    max-width: 400px;
    width: 90%;
    max-height: 80vh;
    overflow-y: auto;
    box-shadow: 0 10px 40px rgba(0, 0, 0, 0.3);
    animation: slideUp 0.3s ease;
}

@keyframes slideUp {
    from {
        opacity: 0;
        transform: translateY(30px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

.topic-modal-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 20px;
}

.topic-modal-title {
    font-size: 1.3rem;
    font-weight: bold;
    color: #212121;
}

.topic-close-btn {
    background: transparent;
    border: none;
    font-size: 1.5rem;
    color: #999999;
    cursor: pointer;
    width: 30px;
    height: 30px;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: 50%;
    transition: all 0.2s ease;
}

.topic-close-btn:hover {
    background: #f0f0f0;
    color: #333333;
}

.topic-loading {
    text-align: center;
    padding: 40px 20px;
    color: #666666;
}

.topic-loading-spinner {
    width: 40px;
    height: 40px;
    border: 4px solid #f3f3f3;
    border-top: 4px solid #1976d2;
    border-radius: 50%;
    animation: spin 1s linear infinite;
    margin: 0 auto 15px;
}

@keyframes spin {
    0% { transform: rotate(0deg); }
    100% { transform: rotate(360deg); }
}

.topic-options {
    display: flex;
    flex-direction: column;
    gap: 12px;
}

.topic-option {
    background: #f5f5f5;
    padding: 18px 20px;
    border-radius: 12px;
    cursor: pointer;
    transition: all 0.3s ease;
    border: 2px solid transparent;
    display: flex;
    align-items: center;
    gap: 12px;
    font-size: 0.95rem;
    line-height: 1.5;
}

.topic-option:hover {
    border-color: #1976d2;
    background: #e3f2fd;
    transform: translateX(5px);
    box-shadow: 0 2px 8px rgba(25, 118, 210, 0.2);
}

.topic-option-number {
    font-size: 1.2rem;
    font-weight: bold;
    color: #1976d2;
    min-width: 25px;
}

.topic-option-text {
    flex: 1;
    color: #333333;
}

.topic-news-badge {
    background: #ff5252;
    color: #ffffff;
    font-size: 0.7rem;
    padding: 3px 8px;
    border-radius: 10px;
    font-weight: bold;
}

/* ========================================
   サイドバーメニュー
   ======================================== */

.sidebar-menu {
    position: fixed;
    top: 0;
    left: -250px;
    width: 250px;
    height: 100vh;
    background: #ffffff;
    box-shadow: none;
    z-index: 2001;
    transition: left 0.3s ease, box-shadow 0.3s ease;
    display: flex;
    flex-direction: column;
}

.sidebar-menu.active {
    left: 0;
    box-shadow: 2px 0 10px rgba(0, 0, 0, 0.1);
}

.sidebar-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 20px;
    border-bottom: 1px solid #cccccc;
}

.sidebar-header h2 {
    font-size: 1.3rem;
    color: #333333;
    margin: 0;
}

.close-menu {
    background: transparent;
    border: none;
    font-size: 1.5rem;
    color: #757575;
    cursor: pointer;
    padding: 5px 10px;
    transition: all 0.3s ease;
}

.close-menu:hover {
    color: #2196f3;
    transform: scale(1.1);
}

.sidebar-content {
    flex: 1;
    overflow-y: auto;
    padding: 10px 0;
    /* タッチスクロール最適化 */
    -webkit-overflow-scrolling: touch;
    touch-action: pan-y;
    overscroll-behavior-y: contain;
}

.menu-item {
    display: flex;
    align-items: center;
    gap: 15px;
    padding: 15px 20px;
    cursor: pointer;
    transition: all 0.3s ease;
    position: relative;
}

.menu-item:hover {
    background: #f5f5f5;
}

.menu-icon {
    font-size: 1.2rem;
    width: 30px;
    text-align: center;
}

.menu-text {
    flex: 1;
    font-size: 1rem;
    color: #333333;
}

.menu-section {
    margin-top: 20px;
    padding: 10px 0;
    border-top: 1px solid #cccccc;
}

.menu-section h3 {
    font-size: 0.9rem;
    color: #757575;
    padding: 10px 20px;
    margin: 0;
    text-transform: uppercase;
    letter-spacing: 1px;
}

.theme-option .checkmark {
    font-size: 1.2rem;
    color: #2196f3;
    opacity: 0;
    transition: opacity 0.3s ease;
}

.theme-option.active .checkmark {
    opacity: 1;
}

/* ========================================
   サイドバーのルーム一覧
   ======================================== */

.room-list-container {
    max-height: 400px;
    overflow-y: auto;
    padding: 10px 0;
    /* タッチスクロール最適化 */
    -webkit-overflow-scrolling: touch;
    touch-action: pan-y;
    overscroll-behavior-y: contain;
}

.room-list-loading {
    text-align: center;
    color: #757575;
    padding: 20px;
    font-size: 0.9rem;
}

.sidebar-room-item {
    padding: 12px 20px;
    cursor: pointer;
    transition: all 0.2s ease;
    border-left: 3px solid transparent;
}

.sidebar-room-item:hover {
    background: #f5f5f5;
}

.sidebar-room-item.current {
    background: #e3f2fd;
    border-left-color: #2196f3;
}

.sidebar-room-info {
    display: flex;
    align-items: center;
    gap: 12px;
}

.sidebar-room-icon {
    font-size: 1.5rem;
    flex-shrink: 0;
}

.sidebar-room-details {
    flex: 1;
    min-width: 0;
}

.sidebar-room-name {
    font-size: 0.95rem;
    font-weight: 500;
    color: #333333;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    margin-bottom: 4px;
}

.sidebar-room-meta {
    display: flex;
    align-items: center;
    gap: 10px;
    font-size: 0.8rem;
    color: #757575;
}

.sidebar-room-users {
    display: flex;
    align-items: center;
    gap: 4px;
}

/* ========================================
   サイドバーの自分のルーム
   ======================================== */

.my-rooms-container {
    max-height: 300px;
    overflow-y: auto;
    padding: 10px 0;
    /* タッチスクロール最適化 */
    -webkit-overflow-scrolling: touch;
    touch-action: pan-y;
    overscroll-behavior-y: contain;
}

.my-rooms-empty {
    text-align: center;
    color: #999999;
    padding: 20px;
    font-size: 0.85rem;
}

.my-room-item {
    padding: 12px 20px;
    cursor: pointer;
    transition: all 0.2s ease;
    border-left: 3px solid transparent;
    position: relative;
}

.my-room-item:hover {
    background: #f5f5f5;
}

.my-room-info {
    display: flex;
    align-items: center;
    gap: 12px;
}

.my-room-icon {
    font-size: 1.5rem;
    flex-shrink: 0;
}

.my-room-details {
    flex: 1;
    min-width: 0;
}

.my-room-name {
    font-size: 0.95rem;
    font-weight: 500;
    color: #333333;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    margin-bottom: 4px;
}

.my-room-expires {
    font-size: 0.75rem;
    color: #ff9800;
    font-weight: 500;
}

.delete-room-btn {
    background: transparent;
    border: none;
    font-size: 1.2rem;
    cursor: pointer;
    padding: 8px;
    border-radius: 4px;
    transition: all 0.2s ease;
    flex-shrink: 0;
}

.delete-room-btn:hover {
    background: #ffebee;
    transform: scale(1.1);
}

.sidebar-overlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.5);
    z-index: 2000;
    opacity: 0;
    pointer-events: none;
    transition: opacity 0.3s ease;
}

.sidebar-overlay.active {
    opacity: 1;
    pointer-events: all;
}

/* ダークモード用ボタンスタイル */
body.dark-mode .floating-create-btn {
    background: rgba(200, 200, 200, 0.12);
    border-color: rgba(200, 200, 200, 0.2);
    color: rgba(200, 200, 200, 0.6);
}

body.dark-mode .floating-create-btn:hover {
    background: rgba(200, 200, 200, 0.2);
    color: rgba(200, 200, 200, 0.8);
}

/* ========================================
   ネオンモード
   ======================================== */

body.neon-mode {
    background-color: #000000;
    color: #ffffff;
}

/* ネオンモード：背景 */
body.neon-mode .sky-gradient {
    background: linear-gradient(
        to bottom,
        #0a0015 0%,
        #1a0033 30%,
        #2d1b4e 60%,
        #0d1b2a 100%
    );
}

body.neon-mode .city-skyline {
    display: block;
}

body.neon-mode .building {
    display: block;
    position: absolute;
    bottom: 0;
    background: linear-gradient(to top, #000000 0%, #0a0a0a 100%);
    border-top: 2px solid #00ffff;
    box-shadow: 0 0 10px rgba(0, 255, 255, 0.3), inset 0 0 20px rgba(0, 255, 255, 0.1);
    animation: buildingGlow 3s ease-in-out infinite;
}

@keyframes buildingGlow {
    0%, 100% {
        border-top-color: #00ffff;
        box-shadow: 0 0 10px rgba(0, 255, 255, 0.3), inset 0 0 20px rgba(0, 255, 255, 0.1);
    }
    50% {
        border-top-color: #8b5cf6;
        box-shadow: 0 0 20px rgba(139, 92, 246, 0.5), inset 0 0 30px rgba(139, 92, 246, 0.2);
    }
}

/* ネオンモード：ヘッダー */
body.neon-mode .header {
    background: rgba(0, 0, 0, 0.8);
    -webkit-backdrop-filter: blur(10px);

    backdrop-filter: blur(10px);
    border-bottom: 1px solid rgba(0, 255, 255, 0.3);
}

body.neon-mode .city-title {
    color: #00ffff;
    text-shadow: 0 0 10px rgba(0, 255, 255, 0.8);
}

body.neon-mode .hamburger-menu span {
    background: #00ffff;
}

body.neon-mode .username-display {
    color: #ffffff;
    background: rgba(139, 92, 246, 0.3);
    border: 1px solid rgba(139, 92, 246, 0.5);
}

/* ネオンモード：チャットコンテナ */
body.neon-mode .chat-container {
    background: rgba(0, 0, 0, 0.7);
    -webkit-backdrop-filter: blur(15px);

    backdrop-filter: blur(15px);
}

body.neon-mode .room-bar {
    background: rgba(0, 255, 255, 0.05);
    border-bottom: 1px solid rgba(0, 255, 255, 0.2);
}

body.neon-mode .room-tab {
    background: rgba(255, 255, 255, 0.03);
    border: 1.5px solid rgba(255, 255, 255, 0.1);
    color: #e0e0e0;
    box-shadow: 0 1px 3px rgba(0, 255, 255, 0.05);
}

body.neon-mode .room-tab:hover {
    background: rgba(255, 255, 255, 0.06);
    border-color: rgba(0, 255, 255, 0.25);
    box-shadow: 0 2px 6px rgba(0, 255, 255, 0.12);
}

body.neon-mode .room-tab.active {
    background: linear-gradient(135deg, rgba(0, 255, 255, 0.12) 0%, rgba(0, 200, 255, 0.08) 100%);
    border-color: rgba(0, 255, 255, 0.5);
    color: #80d4ff;
    box-shadow: 0 0 8px rgba(0, 255, 255, 0.2), 0 2px 6px rgba(0, 255, 255, 0.15);
    text-shadow: 0 0 4px rgba(0, 255, 255, 0.3);
}

/* ネオンモード：最近訪問したルーム */
body.neon-mode .room-tab.recent:not(.active) {
    border-color: rgba(76, 175, 80, 0.6);
    box-shadow: 0 1px 3px rgba(76, 175, 80, 0.3);
}

body.neon-mode .room-tab.recent:not(.active):hover {
    border-color: rgba(76, 175, 80, 0.8);
    box-shadow: 0 2px 6px rgba(76, 175, 80, 0.4);
}

body.neon-mode .room-count {
    background: rgba(0, 255, 255, 0.1);
    color: #80d4ff;
}

body.neon-mode .floating-create-btn {
    background: rgba(0, 255, 255, 0.12);
    border-color: rgba(0, 255, 255, 0.25);
    color: rgba(0, 255, 255, 0.6);
    box-shadow: 0 1px 4px rgba(0, 255, 255, 0.15);
}

body.neon-mode .floating-create-btn:hover {
    background: rgba(0, 255, 255, 0.2);
    color: rgba(0, 255, 255, 0.8);
    box-shadow: 0 2px 8px rgba(0, 255, 255, 0.25);
}

body.neon-mode .chat-header {
    background: rgba(0, 255, 255, 0.1);
    border-bottom: 1px solid rgba(0, 255, 255, 0.3);
}

body.neon-mode .chat-header span {
    color: #00ffff;
}

body.neon-mode .online-count {
    color: #555555;
}

/* ネオンモード：メッセージ */
body.neon-mode .welcome-message {
    color: #666666;
}

body.neon-mode .error-message {
    color: #ff6b6b;
    background-color: rgba(255, 82, 82, 0.15);
    border-color: rgba(255, 82, 82, 0.4);
}

body.neon-mode .message-username {
    color: #00ffff;
}

body.neon-mode .message-time {
    color: #666666;
}

body.neon-mode .message-content {
    background: rgba(255, 255, 255, 0.05);
    border-left: 4px solid rgba(0, 255, 255, 0.5); /* 太く */
    color: #cccccc;
    font-weight: 500; /* 少し太く */
}

body.neon-mode .message.own .message-username {
    color: #8b5cf6;
}

body.neon-mode .message.own .message-content {
    background: rgba(139, 92, 246, 0.15);
    border-left-color: rgba(139, 92, 246, 0.8);
}

/* ネオンモード：話題メッセージ */
body.neon-mode .message.topic .message-username {
    color: #888888; /* グレー */
}

body.neon-mode .message.topic .message-time {
    color: #666666;
}

body.neon-mode .message.topic .message-content {
    background: transparent; /* 背景なし */
    border-left: none; /* 枠線なし */
    color: #cccccc; /* ダークモード用の明るい文字色 */
    box-shadow: none; /* 影なし */
}

/* ネオンモード：話題リンクボタン */
body.neon-mode .topic-link {
    background: rgba(0, 255, 255, 0.2);
    color: #00ffff !important;
    border: 1px solid rgba(0, 255, 255, 0.5);
    box-shadow: 0 0 10px rgba(0, 255, 255, 0.2);
}

body.neon-mode .topic-link:hover {
    background: rgba(0, 255, 255, 0.3);
    border-color: #00ffff;
    box-shadow: 0 0 15px rgba(0, 255, 255, 0.4);
}

body.neon-mode .message-link {
    color: #00ffff;
}

body.neon-mode .message-link:hover {
    color: #8b5cf6;
    text-shadow: 0 0 8px rgba(139, 92, 246, 0.5);
}

/* ネオンモード：リアクション */
body.neon-mode .reaction-item {
    background: rgba(0, 0, 0, 0.6);
    -webkit-backdrop-filter: blur(4px);

    backdrop-filter: blur(4px);
    border: 1px solid rgba(255, 255, 255, 0.2);
}

body.neon-mode .reaction-item:hover {
    background: rgba(255, 255, 255, 0.15);
    border-color: rgba(0, 255, 255, 0.4);
}

body.neon-mode .reaction-item.reacted {
    background: rgba(0, 255, 255, 0.2);
    border-color: rgba(0, 255, 255, 0.5);
}

body.neon-mode .reaction-count {
    color: #ffffff;
}

body.neon-mode .add-reaction-btn {
    background: rgba(0, 0, 0, 0.6);
    -webkit-backdrop-filter: blur(4px);

    backdrop-filter: blur(4px);
    border: 1px dashed rgba(255, 255, 255, 0.3);
    color: #ffffff;
}

body.neon-mode .add-reaction-btn:hover {
    background: rgba(255, 255, 255, 0.15);
    border-color: rgba(0, 255, 255, 0.5);
    color: #00ffff;
}

body.neon-mode .reaction-picker {
    background: rgba(10, 10, 20, 0.95);
    -webkit-backdrop-filter: blur(10px);

    backdrop-filter: blur(10px);
    border: 1px solid rgba(0, 255, 255, 0.3);
}

body.neon-mode .reaction-picker-emoji:hover {
    background: rgba(0, 255, 255, 0.2);
}

/* ネオンモード：入力エリア */
body.neon-mode .input-area {
    background: rgba(0, 0, 0, 0.5);
    border-top: 1px solid rgba(0, 255, 255, 0.3);
}

body.neon-mode .message-input {
    background: rgba(255, 255, 255, 0.05);
    border: 2px solid rgba(0, 255, 255, 0.3);
    color: #ffffff;
}

body.neon-mode .message-input:focus {
    border-color: #00ffff;
    box-shadow: 0 0 15px rgba(0, 255, 255, 0.3);
}

body.neon-mode .message-input::placeholder {
    color: #666666;
}

body.neon-mode .send-button {
    background: linear-gradient(135deg, #00ffff, #8b5cf6);
    color: #000000;
}

body.neon-mode .send-button:hover {
    box-shadow: 0 5px 20px rgba(0, 255, 255, 0.5);
}

/* ネオンモード：モーダル */
body.neon-mode .modal {
    background: rgba(0, 0, 0, 0.8);
    -webkit-backdrop-filter: blur(5px);

    backdrop-filter: blur(5px);
}

body.neon-mode .modal-content {
    background: linear-gradient(135deg, rgba(10, 0, 21, 0.95), rgba(13, 27, 42, 0.95));
    border: 1px solid rgba(0, 255, 255, 0.3);
}

body.neon-mode .modal-title {
    color: #00ffff;
}

body.neon-mode .form-group label {
    color: #ffffff;
}

body.neon-mode .form-group input[type="text"] {
    background: rgba(255, 255, 255, 0.05);
    border: 2px solid rgba(0, 255, 255, 0.3);
    color: #ffffff;
}

body.neon-mode .form-group input[type="text"]:focus {
    border-color: #00ffff;
    box-shadow: 0 0 10px rgba(0, 255, 255, 0.3);
}

body.neon-mode .emoji-option {
    background: rgba(255, 255, 255, 0.05);
    border: 2px solid rgba(255, 255, 255, 0.1);
}

body.neon-mode .emoji-option:hover {
    background: rgba(255, 255, 255, 0.1);
    border-color: rgba(0, 255, 255, 0.3);
}

body.neon-mode .emoji-option.selected {
    background: rgba(0, 255, 255, 0.2);
    border-color: rgba(0, 255, 255, 0.5);
    box-shadow: 0 0 10px rgba(0, 255, 255, 0.3);
}

body.neon-mode .max-users-selector label {
    color: #ffffff;
}

body.neon-mode .max-users-selector input[type="radio"] {
    accent-color: #00ffff;
}

body.neon-mode .btn-cancel {
    background: rgba(255, 255, 255, 0.05);
    border: 1px solid rgba(255, 255, 255, 0.2);
    color: #ffffff;
}

body.neon-mode .btn-cancel:hover {
    background: rgba(255, 255, 255, 0.1);
}

body.neon-mode .btn-create {
    background: linear-gradient(135deg, #00ffff, #8b5cf6);
    color: #000000;
}

body.neon-mode .btn-create:hover {
    box-shadow: 0 5px 20px rgba(0, 255, 255, 0.5);
}

/* ネオンモード：話題ボタン */
body.neon-mode .topic-button {
    border-color: #00ffff;
}

body.neon-mode .topic-button:hover {
    background: #00ffff;
    box-shadow: 0 2px 12px rgba(0, 255, 255, 0.5);
}

/* ネオンモード：話題モーダル */
body.neon-mode .topic-modal-content {
    background: #1a1a2e;
    box-shadow: 0 10px 40px rgba(0, 255, 255, 0.3);
}

body.neon-mode .topic-modal-title {
    color: #00ffff;
}

body.neon-mode .topic-close-btn {
    color: #999999;
}

body.neon-mode .topic-close-btn:hover {
    background: rgba(0, 255, 255, 0.1);
    color: #00ffff;
}

body.neon-mode .topic-option {
    background: rgba(0, 255, 255, 0.05);
    border-color: transparent;
}

body.neon-mode .topic-option:hover {
    background: rgba(0, 255, 255, 0.15);
    border-color: #00ffff;
    box-shadow: 0 2px 12px rgba(0, 255, 255, 0.3);
}

body.neon-mode .topic-option-number {
    color: #00ffff;
}

body.neon-mode .topic-option-text {
    color: #e0e0e0;
}

body.neon-mode .topic-loading {
    color: #999999;
}

body.neon-mode .topic-loading-spinner {
    border-color: #333333;
    border-top-color: #00ffff;
}

/* ネオンモード：サイドバー */
body.neon-mode .sidebar-menu {
    background: rgba(10, 10, 20, 0.95);
    border-right: 1px solid rgba(0, 255, 255, 0.3);
}

body.neon-mode .sidebar-header {
    border-bottom: 1px solid rgba(0, 255, 255, 0.2);
}

body.neon-mode .sidebar-header h2 {
    color: #00ffff;
}

body.neon-mode .close-menu {
    color: #ffffff;
}

body.neon-mode .close-menu:hover {
    color: #00ffff;
}

body.neon-mode .menu-item {
    color: #ffffff;
}

body.neon-mode .menu-item:hover {
    background: rgba(0, 255, 255, 0.1);
}

body.neon-mode .menu-text {
    color: #ffffff;
}

body.neon-mode .menu-section {
    border-top: 1px solid rgba(0, 255, 255, 0.2);
}

body.neon-mode .menu-section h3 {
    color: #555555;
}

body.neon-mode .theme-option .checkmark {
    color: #00ffff;
}

/* ネオンモードのルーム一覧 */
body.neon-mode .room-list-loading {
    color: #888888;
}

body.neon-mode .sidebar-room-item:hover {
    background: rgba(255, 255, 255, 0.05);
}

body.neon-mode .sidebar-room-item.current {
    background: rgba(0, 255, 255, 0.1);
    border-left-color: #00ffff;
}

body.neon-mode .sidebar-room-name {
    color: #e0e0e0;
}

body.neon-mode .sidebar-room-meta {
    color: #888888;
}

/* ネオンモードの自分のルーム */
body.neon-mode .my-rooms-empty {
    color: #666666;
}

body.neon-mode .my-room-item:hover {
    background: rgba(255, 255, 255, 0.05);
}

body.neon-mode .my-room-name {
    color: #e0e0e0;
}

body.neon-mode .my-room-expires {
    color: #ff9800;
}

body.neon-mode .delete-room-btn:hover {
    background: rgba(255, 82, 82, 0.2);
}

/* ========================================
   スマホ対応
   ======================================== */

@media (max-width: 768px) {
    .header {
        height: 50px;
        padding: 0 10px;
    }

    .city-title {
        font-size: 1.2rem;
        letter-spacing: 2px;
    }

    .username-display {
        font-size: 0.85rem;
        padding: 6px 10px;
    }

    .logout-button {
        padding: 6px 15px;
        font-size: 0.85rem;
    }

    .chat-container {
        top: 50px; /* ヘッダーの真下 */
        height: calc(100vh - 50px - 68px); /* スマホ用：ヘッダーと入力エリア分を引いた高さ */
    }

    .input-area {
        padding: 12px;
        padding-bottom: max(12px, env(safe-area-inset-bottom));
    }

    .send-button {
        padding: 12px 20px;
    }
}

/* ========================================
   メッセージの編集・削除機能のスタイル
   ======================================== */

/* メニューボタン（⋮ボタン） */
.message-menu-btn {
    background: transparent;
    border: none;
    color: #555555;
    font-size: 16px;
    cursor: pointer;
    padding: 2px 6px;
    margin-left: 8px;
    opacity: 0; /* 通常時は非表示 */
    transition: opacity 0.2s ease, color 0.2s ease;
    display: inline-block;
}

/* ホバー時に表示 */
.message:hover .message-menu-btn {
    opacity: 1;
}

.message-menu-btn:hover {
    color: #333;
}

/* ネオンモード用 */
body.neon-mode .message-menu-btn {
    color: #00ffff;
}

body.neon-mode .message-menu-btn:hover {
    color: #00ccff;
}

/* メッセージメニュー */
.message-menu {
    position: fixed;
    background: #ffffff;
    border: 1px solid #cccccc;
    border-radius: 8px;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.15);
    padding: 8px 0;
    z-index: 1000;
    min-width: 150px;
    opacity: 0;
    transform: translateY(-10px);
    transition: opacity 0.2s ease, transform 0.2s ease;
}

.message-menu.active {
    opacity: 1;
    transform: translateY(0);
}

.message-menu-item {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 10px 16px;
    cursor: pointer;
    transition: background 0.2s ease;
}

.message-menu-item:hover {
    background: #f5f5f5;
}

.message-menu-item.delete:hover {
    background: #ffe6e6;
    color: #d32f2f;
}

.message-menu-item .menu-icon {
    font-size: 16px;
}

.message-menu-item .menu-text {
    font-size: 14px;
}

/* ネオンモード用 */
body.neon-mode .message-menu {
    background: #1a1a2e;
    border: 1px solid #00ffff;
    box-shadow: 0 0 20px rgba(0, 255, 255, 0.3);
}

body.neon-mode .message-menu-item:hover {
    background: rgba(0, 255, 255, 0.1);
}

body.neon-mode .message-menu-item.delete:hover {
    background: rgba(255, 0, 0, 0.2);
    color: #ff4444;
}

/* 編集済みラベル */
.edited-label {
    font-size: 11px;
    color: #555555;
    margin-left: 6px;
    font-style: italic;
}

body.neon-mode .edited-label {
    color: #00ffff;
}

/* 削除されたメッセージ */
.message.deleted .message-content {
    opacity: 0.6;
    font-style: italic;
    color: #555555;
}

body.neon-mode .message.deleted .message-content {
    color: #666;
}

/* 編集コンテナ */
.message-edit-container {
    width: 100%;
    position: relative;
}

/* 編集用テキストエリア */
.message-edit-textarea {
    width: 100%;
    min-height: 60px;
    padding: 10px 50px 10px 10px; /* 右側にボタンスペース */
    border: 2px solid #4CAF50;
    border-radius: 8px;
    font-size: 14px;
    font-family: inherit;
    font-weight: 500; /* 少し太く */
    resize: vertical;
    box-sizing: border-box;
}

.message-edit-textarea:focus {
    outline: none;
    border-color: #45a049;
}

body.neon-mode .message-edit-textarea {
    background: #1a1a2e;
    color: #ffffff;
    border-color: #00ffff;
}

body.neon-mode .message-edit-textarea:focus {
    border-color: #00ccff;
}

/* 編集アクションボタン（右側に配置） */
.message-edit-actions {
    position: absolute;
    right: 8px;
    top: 8px;
    display: flex;
    gap: 4px;
}

.btn-save-edit,
.btn-cancel-edit {
    width: 32px;
    height: 32px;
    border: none;
    border-radius: 50%;
    font-size: 16px;
    cursor: pointer;
    transition: all 0.2s ease;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 0;
}

.btn-save-edit {
    background: #4CAF50;
    color: white;
}

.btn-save-edit:hover {
    background: #45a049;
    transform: scale(1.1);
}

.btn-cancel-edit {
    background: #cccccc;
    color: #666;
}

.btn-cancel-edit:hover {
    background: #d0d0d0;
    transform: scale(1.1);
}

/* ネオンモード用 */
body.neon-mode .btn-save-edit {
    background: #00ffff;
    color: #0f0f1e;
}

body.neon-mode .btn-save-edit:hover {
    background: #00ccff;
}

body.neon-mode .btn-cancel-edit {
    background: rgba(255, 255, 255, 0.1);
    color: #00ffff;
    border: 1px solid #00ffff;
}

body.neon-mode .btn-cancel-edit:hover {
    background: rgba(255, 255, 255, 0.2);
}

/* ========================================
   長押しメニュー（LINEスタイル）
   ======================================== */

.long-press-menu {
    position: fixed;
    background: white;
    border-radius: 16px;
    box-shadow: 0 8px 32px rgba(0, 0, 0, 0.2);
    padding: 16px;
    z-index: 10000;
    min-width: 280px;
    opacity: 0;
    transform: scale(0.8);
    transition: all 0.2s ease;
}

.long-press-menu.active {
    opacity: 1;
    transform: scale(1);
}

/* メニューセクションタイトル */
.menu-section-title {
    font-size: 13px;
    color: #666;
    margin-bottom: 10px;
    font-weight: 600;
}

/* リアクションのクイックピックス */
.reaction-quick-picks {
    display: flex;
    gap: 8px;
    justify-content: center;
    margin-bottom: 8px;
}

.reaction-quick-emoji {
    width: 44px;
    height: 44px;
    border-radius: 50%;
    background: #f0f0f0;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 24px;
    cursor: pointer;
    transition: all 0.2s ease;
    -webkit-user-select: none;

    -moz-user-select: none;

    -ms-user-select: none;

    user-select: none;
}

.reaction-quick-emoji:hover {
    background: #e0e0e0;
    transform: scale(1.1);
}

.reaction-quick-emoji:active {
    transform: scale(0.95);
}

.reaction-quick-emoji.more {
    font-size: 28px;
    font-weight: bold;
    color: #666;
}

/* メニューの区切り線 */
.menu-divider {
    height: 1px;
    background: #e0e0e0;
    margin: 12px -16px;
}

/* ネオンモード用スタイル */
body.neon-mode .long-press-menu {
    background: #1a1a2e;
    border: 1px solid #00ffff;
    box-shadow: 0 8px 32px rgba(0, 255, 255, 0.3);
}

body.neon-mode .menu-section-title {
    color: #00ffff;
}

body.neon-mode .reaction-quick-emoji {
    background: rgba(0, 255, 255, 0.1);
    border: 1px solid rgba(0, 255, 255, 0.3);
}

body.neon-mode .reaction-quick-emoji:hover {
    background: rgba(0, 255, 255, 0.2);
    border-color: #00ffff;
}

body.neon-mode .reaction-quick-emoji.more {
    color: #00ffff;
}

body.neon-mode .menu-divider {
    background: rgba(0, 255, 255, 0.3);
}

/* ========================================
   固定ルームと作成ルームの区切り線
   ======================================== */

.room-divider {
    width: 100%;
    height: 2px;
    background: #1976d2;
    margin: 0;
}

body.dark-mode .room-divider {
    background: #1976d2;
}

body.neon-mode .room-divider {
    background: #00ffff;
}

/* ========================================
   下部ナビゲーションバー
   ======================================== */

.bottom-nav {
    position: fixed;
    bottom: 0;
    left: 0;
    right: 0;
    display: flex;
    justify-content: space-around;
    align-items: center;
    background: var(--bg-primary);
    border-top: 1px solid var(--card-border);
    padding: 8px 0 max(8px, env(safe-area-inset-bottom));
    z-index: 100;
    box-shadow: 0 -2px 10px rgba(0, 0, 0, 0.1);
}

.nav-item {
    flex: 1;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 2px;
    background: none;
    border: none;
    padding: 8px 4px;
    cursor: pointer;
    transition: all 0.2s ease;
    position: relative;
    color: var(--text-secondary);
}

.nav-item:active {
    transform: scale(0.95);
}

.nav-icon {
    font-size: 20px;
    line-height: 1;
}

.nav-icon i {
    display: block;
}

.nav-label {
    font-size: 0.7rem;
    font-weight: 500;
    line-height: 1;
}

.nav-item.active {
    color: var(--accent-primary);
}

.nav-item.active .nav-icon {
    transform: scale(1.1);
}

.nav-badge {
    position: absolute;
    top: 4px;
    right: 20%;
    background: #ef5350;
    color: #ffffff;
    font-size: 0.65rem;
    font-weight: 600;
    padding: 2px 5px;
    border-radius: 10px;
    min-width: 18px;
    text-align: center;
    line-height: 1;
}

.nav-badge:empty {
    display: none;
}

/* ルーム一覧ビューの下部余白を調整（ナビゲーションバーの高さ分） */
.room-list-view {
    padding-bottom: 70px;
}

/* 既存の浮いているボタンを非表示（下部ナビに統合したため） */
.floating-create-btn {
    display: none;
}

/* ========================================
   スプラッシュスクリーン
   ======================================== */

.splash-screen {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100vh;
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    display: flex;
    justify-content: center;
    align-items: center;
    z-index: 9999;
    opacity: 1;
    transition: opacity 0.5s ease;
}

.splash-screen.fade-out {
    opacity: 0;
    pointer-events: none;
}

.splash-content {
    text-align: center;
    color: #ffffff;
}

.splash-logo {
    font-size: 5rem;
    margin-bottom: 20px;
    animation: pulse 1.5s ease-in-out infinite;
}

.splash-title {
    font-size: 2rem;
    font-weight: bold;
    margin-bottom: 30px;
    letter-spacing: 2px;
}

.splash-loader {
    display: flex;
    justify-content: center;
    gap: 10px;
}

.loader-dot {
    width: 12px;
    height: 12px;
    background: #ffffff;
    border-radius: 50%;
    animation: bounce 1.4s ease-in-out infinite;
}

.loader-dot:nth-child(1) {
    animation-delay: 0s;
}

.loader-dot:nth-child(2) {
    animation-delay: 0.2s;
}

.loader-dot:nth-child(3) {
    animation-delay: 0.4s;
}

@keyframes pulse {
    0%, 100% {
        transform: scale(1);
    }
    50% {
        transform: scale(1.1);
    }
}

@keyframes bounce {
    0%, 80%, 100% {
        transform: translateY(0);
    }
    40% {
        transform: translateY(-20px);
    }
}

/* ダークモード対応 */
body.neon-mode .splash-screen {
    background: linear-gradient(135deg, #1a1a2e 0%, #16213e 100%);
}

body.neon-mode .splash-logo {
    color: #00ffff;
}

body.neon-mode .splash-title {
    color: #00ffff;
}

body.neon-mode .loader-dot {
    background: #00ffff;
}
