body {
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
    text-align: center;
    margin: 0;
    background: linear-gradient(135deg, #fff7e6, #ffe9f0);
    color: #4a3b30;
}

.hero { padding: 20px 0 10px; }
.logo { 
    font-size: 32px; 
    font-weight: 800; 
    color: #6d4a36; 
    text-shadow: 2px 2px 0px #fff; 
    text-decoration: none; /* 下線を消す */
    display: inline-block;
}
.tagline { font-size: 13px; color: #8b6f5a; font-weight: 600; margin-top: 4px; }

/* ロビーのレイアウトを整理 */
.lobby-content { text-align: left; padding: 10px 5px; }
.intro-section h3, .rules-section h3 { font-size: 15px; color: #6d4a36; margin-bottom: 8px; }
.intro-section p { font-size: 13px; line-height: 1.6; color: #5a4a3f; margin-bottom: 20px; }

#lobby-live-stats {
    font-size: 11px;
    color: #8b6f5a;
    margin-bottom: 12px; /* ボタンとの間隔 */
    padding: 6px 12px;
    background: #fffaf3; /* カードより少し濃い色で浮かせる */
    border: 1px solid #f0dfcf;
    border-radius: 999px; /* カプセル型にしてバッジ風にする */
    line-height: 1.4;
    display: inline-flex;
    align-items: center;
    gap: 8px;
}

.stat-chunk {
    display: inline-block;
    white-space: nowrap;
    vertical-align: top;
}

#lobby-live-stats b {
    color: #6d4a36;
}

/* ステップ表示の装飾 */
.how-to-play {
    background: #fffaf3;
    border-radius: 12px;
    padding: 20px 15px; /* 上下のパディングを少し調整 */
    margin-bottom: 20px;
    border: 1px solid #f0dfcf;
}

.step {
    display: flex;
    align-items: flex-start; /* centerからflex-startに変更：数字を上に固定 */
    gap: 12px;
    margin-bottom: 16px; /* ステップ間の間隔を少し広げる */
}

.step:last-child {
    margin-bottom: 0; /* 最後のステップの余計な下マージンを確実に消す */
}

.step-num {
    background: #ffb36b;
    color: white;
    width: 22px;
    height: 22px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 12px;
    font-weight: bold;
    flex-shrink: 0;
    margin-top: 2px; /* テキストの1行目の高さに合わせるための微調整 */
}

.step p {
    font-size: 13px;
    margin: 0; /* ← 【重要】ブラウザのデフォルト余白をゼロにする */
    color: #5a4a3f;
    font-weight: 500;
    text-align: left;
    line-height: 1.5;
}

/* ボタンを大きく強調 */
#join-btn {
    width: 100%;
    padding: 14px;
    font-size: 16px;
    letter-spacing: 0.05em;
}

.container {
    max-width: 520px; /* モバイルの基本 */
    margin: 0 auto;
    padding: 10px 10px 10px;
    transition: max-width 0.3s ease;
}

h1 {
    margin-top: 8px;
    margin-bottom: 4px;
    font-size: 26px;
    letter-spacing: 0.08em;
}

.subtitle {
    font-size: 12px;
    color: #8b6f5a;
    margin-bottom: 16px;
}

.card {
    background: rgba(255, 255, 255, 0.95);
    border-radius: 18px;
    box-shadow: 0 8px 20px rgba(0, 0, 0, 0.07);
    padding: 16px 12px;
}

#chat-box {
    height: 360px;
    border-radius: 14px 14px 0 0; /* 上だけ丸める */
    background: #fffaf3;
    margin: 8px 0 0; /* 下の隙間をなくす */
    padding: 10px 10px 0;
    overflow-y: auto;
    display: flex;
    flex-direction: column;
    box-shadow: inset 1px 1px 0 0 rgba(227, 200, 170, 0.3), 
                inset -1px 0 0 0 rgba(227, 200, 170, 0.3);
}

#chat-box::before {
    content: "";
    margin-top: auto; /* これが上の余白をすべて埋めて、中身を下に押し下げます */
}

.media-area {
    margin: 0 auto;
    display: none;
    align-items: center;
    justify-content: center;
    overflow: hidden;
    width: 100%;
}

.media-area:not(:empty) {
    display: flex;
    margin: 20px auto;
    max-width: 100%;
}

.media-area:has(ins[data-ad-status="unfilled"]) {
    display: none !important;
}

/* 各スポットの高さ設定：スマホ・PC共通のベース */
.spot-rect:not(:empty) { 
    /* min-height: 250px; */
    max-height: 340px;
    max-width: 728px; 
}

.spot-bar:not(:empty) { 
    /* min-height: 100px; */
    max-height: 120px;
    max-width: 728px;
}

/* 開発環境のみ表示するダミー装飾 */
.item-placeholder {
    width: 100%;
    min-height: inherit;
    background: #f3f3f3;
    border: 1px dashed #d0d0d0;
    color: #999;
    font-size: 11px;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: 10px;
}

button {
    padding: 10px 18px;
    border-radius: 999px;
    border: none;
    background: linear-gradient(135deg, #ffb36b, #ff8b7d);
    color: white;
    cursor: pointer;
    font-size: 14px;
    font-weight: 600;
    box-shadow: 0 4px 10px rgba(0, 0, 0, 0.15);
    transition: transform 0.05s ease-out, box-shadow 0.05s ease-out, opacity 0.1s;
}

button:active {
    transform: translateY(1px);
    box-shadow: 0 2px 6px rgba(0, 0, 0, 0.12);
    opacity: 0.9;
}

button:disabled {
    background: #ccc;
    box-shadow: none;
    cursor: not-allowed;
    opacity: 0.6;
}

#msg {
    flex: 1;
    padding: 10px 12px;
    border-radius: 999px;
    border: 1px solid rgba(194, 167, 140, 0.6);
    font-size: 14px;
    outline: none;
}

#room-status { font-weight: bold; margin-bottom: 6px; font-size: 15px; }

#member-list-area {
    font-size: 11px;
    color: #8b6f5a;
    margin-bottom: 12px;
    padding: 10px 4px;
    border-bottom: 1px solid #f0dfcf;
    text-align: left;
    display: flex;
    align-items: center;
    flex-wrap: wrap;
    gap: 8px; /* カプセル同士の隙間 */
}

/* 共通のラベルスタイル */
.label-text {
    font-weight: 700;
    color: #6d4a36;
    white-space: nowrap;
    line-height: 1;
}

/* なかまたち（控えめサイズ） */
#member-list-area .label-text {
    font-size: 11px;
    margin-right: 2px;
}


.member-item {
    display: inline-flex;
    align-items: center;
    gap: 2px; /* アイコンと名前の隙間を少し広げる */
    background: #fffaf3;
    border: 1px solid #f0dfcf;
    padding: 3px 12px; /* 左右均等に12pxに設定 */
    border-radius: 999px;
    box-shadow: 0 1px 2px rgba(0,0,0,0.03);
    transition: transform 0.2s ease;
}

.member-item span {
    font-weight: 600; /* なかまたちは少し太め */
    color: #5a4a3f;
    line-height: 1; /* 垂直方向のズレ防止 */
}

/* メンバーリスト内のアイコンをさらに微調整 */
.member-item .user-icon-small {
    width: 18px;
    height: 18px;
    margin: 0;
}

.name-tag {
    font-size: 14px;
    margin: 12px 0 16px; /* 下の余白を少し広げる */
    text-align: left;
    display: flex;
    align-items: center;
    gap: 8px;
}

/* あなたは（少し大きめサイズ） */
.name-tag .label-text {
    font-size: 14px;
}

/* 自分の名前バッジ */
.name-tag b {
    background: #fff4e5;
    border: 1px solid #ffb36b;
    border-radius: 999px;
    padding: 5px 15px; /* 左右均等に15pxに設定 */
    display: inline-flex;
    align-items: center;
    gap: 3px; /* アイコンと名前の隙間 */
    box-shadow: 0 2px 5px rgba(255, 179, 107, 0.15);
}

.name-tag b span {
    font-weight: 800; /* 最も太く設定 */
    color: #4a3b30;
    line-height: 1;
}

.name-tag b .user-icon-small {
    width: 24px; /* 自分のアイコンは少し大きく */
    height: 24px;
}

/* ロビー内のセクション装飾 */
.lobby-section {
    text-align: left;
    margin-bottom: 20px;
}
.lobby-section h3 {
    font-size: 16px;
    color: #6d4a36;
    margin-bottom: 8px;
    border-left: 4px solid #ffb36b;
    padding-left: 8px;
}
.lobby-section p {
    font-size: 13px;
    line-height: 1.5;
    color: #5a4a3f;
    margin: 0;
}
.lobby-section.rules {
    display: flex;
    gap: 15px;
}
.rule-box {
    flex: 1;
    background: #fffaf3;
    padding: 10px;
    border-radius: 10px;
    border: 1px solid #f0dfcf;
}
.rule-box h4 {
    font-size: 13px;
    margin: 0 0 5px;
    color: #8b6f5a;
}
.rule-box ul {
    margin: 0;
    padding-left: 18px;
    font-size: 11px;
    color: #5a4a3f;
}
.footer-link {
    font-size: 11px;
    color: #b09987;
    text-decoration: none;
}
.footer-link:hover {
    text-decoration: underline;
}

/* フッターのリンクエリア全体の設定 */
.footer-links {
    margin-top: 30px;
    border-top: 1px solid #f0dfcf;
    padding-top: 15px;
    display: flex;
    flex-wrap: wrap; /* 折り返しを許可 */
    justify-content: center; /* 中央寄せ */
    gap: 12px 20px; /* 縦の隙間12px、横の隙間20px */
}

.copyright {
    font-size: 10px;
    color: #b09987;
    margin-top: 20px;
    text-align: center;
    letter-spacing: 0.05em;
}

.msg-wrapper {
    display: flex;
    align-items: flex-end; /* 下端で揃える */
    justify-content: flex-start; /* 左寄せ（他人のメッセージ用） */
    margin-bottom: 8px;
    width: fit-content; /* 中身の幅に合わせる */
}

.msg-bubble {
    max-width: 80%;
    padding: 6px 9px 7px;
    border-radius: 14px;
    font-size: 13px;
    line-height: 1.4;
    display: block;
    width: fit-content;
    box-shadow: 0 1px 3px rgba(0, 0, 0, 0.08);
    word-break: break-word;
    margin-bottom: 0 !important;
    text-align: left;
}

.msg-wrapper .msg-other {
    margin-right: 0 !important;
}

.msg-me { 
    background: #ffe0b5; 
    margin-left: auto !important; 
    margin-right: 0; 
    margin-bottom: 6px !important; /* 自分のはwrapperがないので余白追加 */
}
.msg-other {
    background: #ffffff;
    margin-right: auto !important;
    margin-left: 0;
}

.msg-system {
    background: transparent;
    box-shadow: none;
    text-align: left;       /* 改行されても文章の頭を揃える */
    margin: 8px auto;      /* 左右中央に配置 (auto) */
    width: 90%;            /* 横幅を広めに確保 */
    display: block;        /* fit-content を解除して幅を安定させる */
    font-style: italic;
    color: #9b846b;
    margin: 6px 0;
    font-size: 12px;
}

/* メッセージラベル（名前とアイコン）の整列 */
.msg-label { 
    font-size: 11px; 
    color: #8b6f5a; 
    margin: 12px 5px 2px; 
    display: flex;
    align-items: center;
    gap: 2px; /* ここも少し広げてバランスを取る */
}

.msg-label.me {
    justify-content: flex-end; /* 右側に寄せる */
    flex-direction: row;        /* [画像][名前] の順に固定 */
}

.msg-label.other {
    justify-content: flex-start; /* 左側に寄せる */
    flex-direction: row;         /* [画像][名前] の順に固定 */
}

.msg-bubble.consecutive { margin-top: 2px !important; }

.user-icon-small {
    width: 22px;
    height: 22px;
    border-radius: 50%;
    background: transparent; 
    border: none;
    object-fit: cover;
    flex-shrink: 0;
}

/* 通報ボタンのスタイル */
.report-btn {
    font-size: 16px;
    cursor: pointer;
    color: #d1b8a1;
    padding: 0 8px 4px; /* 右側に余裕を持たせる */
    user-select: none;
    flex-shrink: 0;
}

.input-row { 
    display: flex; 
    gap: 8px; 
    align-items: center; 
    margin-top: 10px; 
    position: relative; 
}

#typing-display {
    height: 22px; /* 高さを確保 */
    background: #fffaf3; /* チャットボックスと同じ色 */
    border-radius: 0 0 14px 14px; /* 下だけ丸める */
    font-size: 11px;
    color: #8b6f5a;
    font-style: italic;
    padding: 0 14px 5px;
    text-align: left;
    box-shadow: inset 1px 0 0 0 rgba(227, 200, 170, 0.3), 
                inset -1px -1px 0 0 rgba(227, 200, 170, 0.3);
    border-top: none;
}

/* 退室ボタン用のスタイル */
.btn-leave {
    padding: 7px 14px;
    font-size: 12px;
    background: #fdfdfd;
    color: #8b6f5a;
    box-shadow: 0 2px 4px rgba(0,0,0,0.05);
    border: 1px solid #e2d5c8;
}

.btn-leave:active {
    background: #d0d0d0;
    transform: translateY(1px);
}

/* 絵文字がバラバラに見えないよう、位置を固定する装飾 */
.guideline-item {
    display: flex;
    gap: 12px;
    margin-bottom: 12px;
    text-align: left;
}
.guideline-item:last-child {
    margin-bottom: 0; /* 最後の項目の下の余白を消す */
}
.guideline-icon {
    flex-shrink: 0;
    width: 24px;
    text-align: center;
    font-size: 18px;
}

/* カスタムモーダルのスタイル */
.modal {
    display: none;
    position: fixed;
    z-index: 2000;
    left: 0;
    top: 0;
    width: 100%;
    height: 100%;
    background-color: rgba(0,0,0,0.5);
    justify-content: center;
    align-items: center;
    backdrop-filter: blur(2px);
}

.modal-content {
    background-color: #fffaf3;
    padding: 24px;
    border-radius: 18px;
    width: 85%;
    max-width: 360px;
    text-align: center;
    box-shadow: 0 10px 25px rgba(0,0,0,0.1);
    border: 1px solid #f0dfcf;
}

.modal-content h3 {
    margin: 0 0 12px;
    color: #6d4a36;
    font-size: 18px;
}

.modal-content p {
    font-size: 14px;
    color: #5a4a3f;
    line-height: 1.6;
    margin-bottom: 20px;
    white-space: pre-wrap;
}

.modal-footer {
    display: flex;
    gap: 10px;
    justify-content: center;
}

.modal-footer button {
    padding: 10px 24px;
    min-width: 100px;
}

.modal-footer .btn-secondary {
    background: #e2d5c8;
    color: #8b6f5a;
}

.btn-share-x {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    background-color: #000;
    color: #fff !important;
    text-decoration: none;
    padding: 6px 14px;
    border-radius: 999px;
    font-size: 12px;
    font-weight: 600;
    transition: transform 0.2s;
}

.btn-share-threads {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    background: linear-gradient(45deg, #000, #333);
    color: #fff !important;
    text-decoration: none;
    padding: 6px 14px;
    border-radius: 999px;
    font-size: 12px;
    font-weight: 600;
    transition: transform 0.2s;
}

.btn-share-x:hover, .btn-share-threads:hover {
    transform: scale(1.05);
}

.share-buttons {
    display: flex;
    justify-content: center;
    gap: 10px;
    margin-bottom: 20px;
    flex-wrap: wrap;
}

/* 開発ログ用リンクカード */
.log-card-container {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 12px;
    margin: 15px 0;
}
.log-card {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 12px;
    border-radius: 12px;
    text-decoration: none;
    background: #fff;
    border: 1px solid #f0dfcf;
    transition: transform 0.2s;
}
.log-card:hover { transform: translateY(-2px); box-shadow: 0 4px 10px rgba(0,0,0,0.05); }
.log-card img { width: 32px; height: 32px; object-fit: contain; }
.log-info { text-align: left; }
.log-site { font-size: 10px; font-weight: bold; display: block; color: #8b6f5a; }
.log-title {
    font-size: 13px;
    font-weight: 600;
    color: #4a3b30;
    line-height: 1.3;
    display: -webkit-box;
    -webkit-line-clamp: 2;
    line-clamp: 2;
    -webkit-box-orient: vertical;
    overflow: hidden;
}

@media (max-width: 767px) {
    #chat-box { 
        height: 500px; 
        max-height: 40vh;
    }
    .log-card-container {
        grid-template-columns: 1fr;
    } 
}

@media (min-width: 768px) {
    .container {
        max-width: 900px;
        padding: 40px 20px 24px;
    }
    
    body {
        font-size: 16px; /* 全体の文字サイズを少しアップ */
    }

    .card {
        padding: 30px 50px; /* 横の余白をさらに追加 */
    }

    #room-status {
        font-size: 18px; /* PCではさらに大きく */
    }

    .btn-leave {
        font-size: 14px;
        padding: 8px 18px;
    }

    .name-tag {
        font-size: 16px;
        margin-bottom: 12px;
    }

    .name-tag .label-text {
        font-size: 16px;
    }

    #member-list-area {
        font-size: 14px;
        margin-bottom: 15px;
    }

    #member-list-area .label-text {
        font-size: 14px;
    }

    .logo {
        font-size: 56px; /* 48pxから拡大 */
    }

    .tagline {
        font-size: 16px; /* 13pxから拡大 */
        margin-bottom: 20px;
    }

    /* チャットバブルの文字サイズも調整 */
    .msg-bubble {
        font-size: 15px;
        padding: 10px 15px;
    }

    #chat-box {
        height: 500px; /* PCでは高さをしっかり出す */
    }

    #msg {
        padding: 14px 20px; /* 入力欄を大きくして打ちやすく */
        font-size: 16px;
    }
}