/* ========== ベーススタイル ========== */

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

body {
    font-family: 'Hiragino Sans', 'Meiryo', sans-serif;
    background-color: #1a1a2e;
    min-height: 100vh;
    min-height: 100dvh;
    color: #fff;
    position: relative;
    overflow-x: hidden;
}

/* 背景画像を中央60%に配置（左右各20%の余白） */
body::before {
    content: '';
    position: fixed;
    top: 0;
    left: 20%;
    width: 60%;
    height: 100%;
    background: url('assets/bg/background.svg') center / cover no-repeat;
    z-index: -1;
}

@media (max-width: 600px) {
    body::before {
        left: 0;
        width: 100%;
    }
}

/* タイトル・ログイン・プロフィール画面では背景画像を非表示 */
body:has(#fb-title-screen:not(.hidden))::before,
body:has(#fb-login-screen:not(.hidden))::before,
body:has(#fb-profile-screen:not(.hidden))::before {
    display: none;
}

/* ゲーム中はビューポートに固定（スクロール防止） */
body:has(#fb-game-screen:not(.hidden)) {
    overflow: hidden;
    height: 100dvh;
}

body:has(#fb-game-screen:not(.hidden)) .container {
    height: 100dvh;
    max-height: 100dvh;
    overflow: hidden;
    justify-content: flex-start;
    padding-top: max(8px, env(safe-area-inset-top));
    padding-bottom: max(8px, env(safe-area-inset-bottom));
}

.container {
    max-width: 900px;
    margin: 0 auto;
    padding: 20px;
    padding-top: max(20px, env(safe-area-inset-top));
    padding-bottom: max(20px, env(safe-area-inset-bottom));
    min-height: 100vh;
    min-height: 100dvh;
    display: flex;
    flex-direction: column;
    justify-content: center;
    align-items: center;
}

.screen {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 30px;
}

.hidden {
    display: none !important;
}

.btn {
    padding: 15px 40px;
    font-size: 1.2rem;
    border: none;
    border-radius: 50px;
    cursor: pointer;
    transition: all 0.3s ease;
    font-weight: bold;
}

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

.btn-primary {
    background: linear-gradient(45deg, #e74c3c, #c0392b);
    color: #fff;
    box-shadow: 0 4px 15px rgba(231, 76, 60, 0.4);
}

.btn-primary:hover {
    transform: translateY(-3px);
    box-shadow: 0 6px 20px rgba(231, 76, 60, 0.6);
}

.btn-secondary {
    background: linear-gradient(45deg, #3498db, #2980b9);
    color: #fff;
    box-shadow: 0 4px 15px rgba(52, 152, 219, 0.4);
}

.btn-secondary:hover {
    transform: translateY(-3px);
    box-shadow: 0 6px 20px rgba(52, 152, 219, 0.6);
}

.btn-submit {
    background: linear-gradient(45deg, #27ae60, #2ecc71);
    color: #fff;
    padding: 12px 30px;
}

.btn-submit:hover {
    transform: translateY(-2px);
    box-shadow: 0 4px 15px rgba(46, 204, 113, 0.4);
}

.btn-quit {
    padding: 8px 12px;
    font-size: 1rem;
    background: rgba(231, 76, 60, 0.3);
    color: #e74c3c;
    border: 1px solid #e74c3c;
    border-radius: 8px;
    cursor: pointer;
    transition: all 0.2s;
    flex-shrink: 0;
}

.btn-quit:hover {
    background: rgba(231, 76, 60, 0.5);
    transform: scale(1.05);
}

.site-footer {
    text-align: center;
    padding: 20px;
    margin-top: 30px;
}

.footer-link {
    color: #7f8c8d;
    font-size: 0.85rem;
    text-decoration: none;
    transition: color 0.2s;
}

.footer-link:hover {
    color: #3498db;
    text-decoration: underline;
}

/* ========== ファイブブロッカー専用スタイル ========== */

.fb-title-buttons a,
.fb-result-buttons a {
    text-decoration: none;
    text-align: center;
    width: 100%;
}

/* ========== タイトル画面 ========== */

.fb-title-screen {
    text-align: center;
    width: 100%;
}

.fb-game-title {
    font-size: 2.8rem;
    font-weight: 900;
    background: linear-gradient(45deg, #f39c12, #e67e22, #f1c40f);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
    text-shadow: none;
    letter-spacing: 2px;
}

.fb-subtitle {
    font-size: 1.2rem;
    color: #bdc3c7;
    margin-top: -15px;
}

.fb-howto {
    width: 100%;
    max-width: 500px;
}

.fb-howto-toggle {
    background: rgba(255, 255, 255, 0.1);
    color: #bdc3c7;
    border: 1px solid rgba(255, 255, 255, 0.2);
    padding: 10px 25px;
    border-radius: 25px;
    cursor: pointer;
    font-size: 1rem;
    transition: all 0.3s;
    width: 100%;
}

.fb-howto-toggle:hover {
    background: rgba(255, 255, 255, 0.15);
    color: #fff;
}

.fb-howto-content {
    background: rgba(255, 255, 255, 0.08);
    border-radius: 15px;
    padding: 20px 25px;
    margin-top: 10px;
    text-align: left;
}

.fb-howto-content ol {
    padding-left: 1.5em;
    display: flex;
    flex-direction: column;
    gap: 8px;
    color: #ddd;
    font-size: 0.95rem;
    line-height: 1.6;
}

.fb-title-buttons {
    display: flex;
    flex-direction: column;
    gap: 15px;
    align-items: center;
    width: 100%;
    max-width: 300px;
}

.fb-title-btn {
    width: 100%;
    font-size: 1.2rem;
    padding: 15px 40px;
}

/* ========== トグルスイッチ ========== */

.fb-toggle-row {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 12px 0;
    cursor: pointer;
    user-select: none;
}

.fb-toggle-label-text {
    color: #e0e0e0;
    font-size: 1rem;
}

.fb-toggle {
    position: relative;
    width: 46px;
    height: 26px;
    flex-shrink: 0;
}

.fb-toggle input {
    opacity: 0;
    width: 0;
    height: 0;
    position: absolute;
}

.fb-toggle-slider {
    position: absolute;
    inset: 0;
    background: #555;
    border-radius: 26px;
    transition: background 0.3s;
}

.fb-toggle-slider:before {
    content: '';
    position: absolute;
    width: 20px;
    height: 20px;
    left: 3px;
    top: 3px;
    background: #fff;
    border-radius: 50%;
    transition: transform 0.3s;
}

.fb-toggle input:checked + .fb-toggle-slider {
    background: #3498db;
}

.fb-toggle input:checked + .fb-toggle-slider:before {
    transform: translateX(20px);
}

.fb-loading {
    color: #7f8c8d;
    font-size: 1.1rem;
}

/* ========== ゲーム画面（フルスクリーン） ========== */

#fb-game-screen {
    width: 100%;
    position: relative;
    gap: 8px;
    flex: 1;
    min-height: 0;
    overflow: hidden;
}

/* ゲーム中はコンテナをフルスクリーンに */
#fb-game-screen:not(.hidden) ~ .site-footer {
    display: none;
}

.fb-game-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    width: 100%;
    padding: 8px 16px;
    background: rgba(0, 0, 0, 0.5);
    border-radius: 10px;
    gap: 15px;
}

.fb-round-display {
    font-size: 1.4rem;
    font-weight: bold;
    color: #3498db;
}

.fb-timer-display {
    font-size: 1.6rem;
    font-weight: bold;
    color: #f39c12;
}

.fb-timer-display .timer-danger {
    color: #e74c3c;
    animation: timerPulse 0.5s ease-in-out infinite alternate;
}

@keyframes timerPulse {
    0% { opacity: 1; }
    100% { opacity: 0.5; }
}

/* ========== 条件バナー ========== */

.fb-condition-banner {
    width: 100%;
    background: rgba(0, 0, 0, 0.5);
    border: 2px solid rgba(52, 152, 219, 0.4);
    border-radius: 10px;
    padding: 12px 20px;
    text-align: center;
}

.fb-condition-text {
    font-size: 1.3rem;
    font-weight: bold;
    color: #fff;
    line-height: 1.4;
}

/* ========== 爆弾アリーナ ========== */

.fb-bomb-arena {
    width: 100%;
    position: relative;
    padding: 0;
    overflow: hidden;
    flex: 1;
    min-height: 0;
    display: flex;
    flex-direction: column;
}

.fb-tubes-container {
    display: flex;
    justify-content: center;
    align-items: stretch;
    gap: 0;
    flex: 1;
    min-height: 0;
}

/* チューブ色定義 */
.fb-tube[data-color="blue"]   { --tube-h: 204; --tube-s: 70%; --tube-l: 53%; --tube-color: #3498db; --tube-dark: #1a5276; --tube-light: #85c1e9; }
.fb-tube[data-color="green"]  { --tube-h: 145; --tube-s: 63%; --tube-l: 49%; --tube-color: #2ecc71; --tube-dark: #1a7a42; --tube-light: #82e0aa; }
.fb-tube[data-color="yellow"] { --tube-h: 48;  --tube-s: 89%; --tube-l: 50%; --tube-color: #f1c40f; --tube-dark: #9a7d0a; --tube-light: #f9e154; }
.fb-tube[data-color="orange"] { --tube-h: 28;  --tube-s: 80%; --tube-l: 52%; --tube-color: #e67e22; --tube-dark: #935116; --tube-light: #f0b27a; }
.fb-tube[data-color="pink"]   { --tube-h: 330; --tube-s: 75%; --tube-l: 56%; --tube-color: #e84393; --tube-dark: #922b60; --tube-light: #f5a4c8; }

.fb-tube {
    display: flex;
    flex-direction: column;
    align-items: center;
    flex: 1;
    max-width: 160px;
    transition: all 0.3s ease;
}

/* キャップ（上部） */
.fb-tube-cap {
    width: 100%;
    max-width: 140px;
    height: 30px;
    background: linear-gradient(180deg, #f9e154, #d4a017, #b8860b);
    border-radius: 8px 8px 2px 2px;
    border: 2px solid #8b6914;
    display: flex;
    align-items: center;
    justify-content: center;
    box-shadow: 0 -2px 8px rgba(0, 0, 0, 0.4);
    position: relative;
    z-index: 2;
}

.fb-cap-light {
    width: 16px;
    height: 16px;
    border-radius: 50%;
    background: radial-gradient(circle, var(--tube-light), var(--tube-color));
    box-shadow: 0 0 8px var(--tube-color);
    transition: all 0.3s;
}

/* チューブボディ — 親の flex で自動伸縮 */
.fb-tube-body {
    width: 90%;
    max-width: 120px;
    flex: 1;
    min-height: 100px;
    position: relative;
    perspective: 400px;
    background: linear-gradient(90deg,
        var(--tube-dark) 0%,
        var(--tube-color) 30%,
        var(--tube-light) 55%,
        var(--tube-color) 80%,
        var(--tube-dark) 100%
    );
    border: 3px solid rgba(255, 255, 255, 0.3);
    border-top: none;
    border-bottom: none;
    overflow: hidden;
}

/* チューブのガラス反射 */
.fb-tube-body::after {
    content: '';
    position: absolute;
    top: 0;
    left: 10%;
    width: 15%;
    height: 100%;
    background: linear-gradient(180deg,
        rgba(255,255,255,0.35) 0%,
        rgba(255,255,255,0.1) 50%,
        rgba(255,255,255,0.25) 100%
    );
    border-radius: 4px;
    pointer-events: none;
}

/* ベース（底部） */
.fb-tube-base {
    width: 100%;
    max-width: 140px;
    height: 24px;
    background: linear-gradient(0deg, #8b4513, #d2691e, #cd853f);
    border-radius: 2px 2px 8px 8px;
    border: 2px solid #654321;
    position: relative;
    z-index: 2;
}

.fb-tube-base::before,
.fb-tube-base::after {
    content: '';
    position: absolute;
    bottom: -10px;
    width: 4px;
    height: 12px;
    background: #666;
    border-radius: 0 0 2px 2px;
}
.fb-tube-base::before { left: 20%; }
.fb-tube-base::after { right: 20%; }

/* チューブラベル */
.fb-tube-label {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 2px;
    margin-top: 14px;
    max-width: 140px;
    width: 100%;
}

.fb-tube-number {
    display: none;
}

.fb-tube-card-name {
    font-size: 0.8rem;
    color: rgba(255, 255, 255, 0.4);
    text-align: center;
    line-height: 1.2;
    min-height: 1.2em;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    max-width: 100%;
}

/* ディバイダー */
.fb-tube-divider {
    width: 10px;
    background: linear-gradient(180deg, #c0c0c0, #a0a0a0, #d0d0d0, #909090);
    border-radius: 4px;
    box-shadow: inset 1px 0 3px rgba(255,255,255,0.5), inset -1px 0 3px rgba(0,0,0,0.3);
    align-self: stretch;
    margin-top: 30px;
    margin-bottom: 60px;
    flex-shrink: 0;
}

/* チューブ状態: アクティブ */
.fb-tube.active .fb-tube-body {
    box-shadow: 0 0 25px hsla(var(--tube-h), var(--tube-s), var(--tube-l), 0.6);
    border-color: rgba(255, 255, 255, 0.6);
}

.fb-tube.active .fb-cap-light {
    animation: capLightPulse 1s ease-in-out infinite alternate;
}

/* チューブ状態: 完了 */
.fb-tube.completed .fb-tube-body {
    opacity: 0.6;
}

.fb-tube.completed .fb-cap-light {
    background: #2ecc71;
    box-shadow: 0 0 10px #2ecc71;
}

.fb-tube.completed .fb-tube-card-name {
    color: #2ecc71;
    font-weight: bold;
    font-size: 0.85rem;
}

.fb-tube.completed .fb-tube-number {
    color: #2ecc71;
}

/* ========== 爆弾 (SVGスプライト) ========== */

.fb-bomb {
    position: absolute;
    width: 80px;
    height: auto;
    z-index: 50;
    pointer-events: none;
    filter: drop-shadow(0 0 10px rgba(100, 150, 255, 0.6));
}

.fb-bomb.bomb-exploding {
    animation: bombExplode 0.5s ease-out forwards;
}

/* ========== グレーバー（各チューブ内） ========== */

.fb-bomb-bar {
    position: absolute;
    left: -8%;
    width: 116%;
    height: 10px;
    top: 0;
    background: linear-gradient(180deg, #e8e8e8, #b0b0b0, #c8c8c8, #787878);
    border: 1px solid #505050;
    border-radius: 3px;
    box-shadow: 0 3px 8px rgba(0, 0, 0, 0.6), inset 0 1px 0 rgba(255, 255, 255, 0.6);
    z-index: 10;
    pointer-events: none;
    transform-origin: right center;
    transform-style: preserve-3d;
}

/* バー傾きアニメーション: 右端を軸に左端が20度上へ跳ね上がり戻る */
.fb-bomb-bar.bar-opening {
    animation: barTiltUp 0.5s ease-out forwards;
}

@keyframes barTiltUp {
    0%   { transform: rotateZ(0deg); }
    35%  { transform: rotateZ(20deg); }
    65%  { transform: rotateZ(20deg); }
    100% { transform: rotateZ(0deg); }
}

/* ========== バブルエフェクト ========== */

.fb-bubble {
    position: absolute;
    width: 8px;
    height: 8px;
    border-radius: 50%;
    background: rgba(255, 255, 255, 0.12);
    border: 1px solid rgba(255, 255, 255, 0.15);
    left: var(--left);
    bottom: 20px;
    animation: bubbleFloat 5s ease-in-out infinite;
    animation-delay: var(--delay);
    z-index: 1;
    pointer-events: none;
}

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

.fb-input-container {
    display: flex;
    gap: 12px;
    width: 100%;
    max-width: 600px;
    margin: 0 auto;
}

.fb-autocomplete-wrapper {
    flex: 1;
    position: relative;
}

.fb-answer-input {
    width: 100%;
    padding: 14px 20px;
    font-size: 1.1rem;
    border: 2px solid #3498db;
    border-radius: 10px;
    background: rgba(0, 0, 0, 0.4);
    color: #fff;
    outline: none;
    transition: border-color 0.3s, box-shadow 0.3s;
}

.fb-answer-input::placeholder {
    color: rgba(255, 255, 255, 0.5);
}

.fb-answer-input:focus {
    border-color: #2ecc71;
    box-shadow: 0 0 10px rgba(46, 204, 113, 0.2);
}

.fb-answer-input:disabled {
    opacity: 0.5;
    cursor: not-allowed;
}

/* ========== サジェスト ========== */

.fb-suggestions {
    position: absolute;
    bottom: 100%;
    left: 0;
    right: 0;
    background: #2c3e50;
    border: 1px solid #34495e;
    border-radius: 10px 10px 0 0;
    max-height: 200px;
    overflow-y: auto;
    z-index: 100;
    list-style: none;
}

.fb-suggestions li {
    padding: 10px 18px;
    cursor: pointer;
    transition: background 0.2s;
    border-bottom: 1px solid #34495e;
    font-size: 0.95rem;
}

.fb-suggestions li:last-child {
    border-bottom: none;
}

.fb-suggestions li:hover,
.fb-suggestions li.selected {
    background: rgba(52, 152, 219, 0.3);
}

/* ========== フィードバック ========== */

.fb-feedback {
    text-align: center;
    font-size: 1.1rem;
    font-weight: bold;
    padding: 10px;
    border-radius: 10px;
    transition: opacity 0.3s;
}

.fb-feedback-correct {
    color: #2ecc71;
    background: rgba(46, 204, 113, 0.15);
}

.fb-feedback-wrong {
    color: #e74c3c;
    background: rgba(231, 76, 60, 0.15);
}

.fb-feedback-notfound {
    color: #e67e22;
    background: rgba(230, 126, 34, 0.15);
}

.fb-feedback-duplicate {
    color: #f39c12;
    background: rgba(243, 156, 18, 0.15);
}

/* ========== 正解中央ポップアップ ========== */

.fb-correct-popup {
    position: fixed;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%) scale(0.5);
    font-size: 3.5rem;
    font-weight: 900;
    color: #fff;
    text-shadow: 0 0 20px #2ecc71, 0 0 40px #2ecc71, 2px 2px 0 #1a7a42;
    pointer-events: none;
    z-index: 500;
    opacity: 0;
}

.fb-correct-popup.show {
    animation: correctPopup 0.7s ease-out forwards;
}

@keyframes correctPopup {
    0%   { opacity: 0;   transform: translate(-50%, -50%) scale(0.5); }
    30%  { opacity: 1;   transform: translate(-50%, -50%) scale(1.2); }
    60%  { opacity: 1;   transform: translate(-50%, -50%) scale(1.0); }
    100% { opacity: 0;   transform: translate(-50%, -60%) scale(1.0); }
}

/* ========== オーバーレイ演出 ========== */

.fb-clear-overlay {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 200;
    pointer-events: none;
    background: rgba(46, 204, 113, 0.15);
}

.fb-clear-img {
    width: min(60vw, 400px);
    height: auto;
    animation: clearZoomIn 0.5s ease-out;
    filter: drop-shadow(0 0 20px rgba(46, 204, 113, 0.6));
}

/* 爆発オーバーレイ */
.fb-explosion-overlay {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    display: flex;
    align-items: center;
    justify-content: center;
    flex-direction: column;
    z-index: 300;
    pointer-events: none;
    background: rgba(0, 0, 0, 0.3);
}

.fb-explosion-canvas {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
}

.fb-gameover-img {
    width: min(60vw, 420px);
    height: auto;
    z-index: 301;
    animation: explosionTextIn 0.8s 0.6s ease-out both;
    filter: drop-shadow(0 0 20px rgba(255, 0, 0, 0.6));
}

/* ========== 結果画面 ========== */

#fb-result-screen {
    width: 100%;
    text-align: center;
}

.fb-result-title {
    font-size: 2.2rem;
    color: #f39c12;
    font-weight: 900;
}

.fb-result-content {
    width: 100%;
    background: rgba(0, 0, 0, 0.55);
    border-radius: 20px;
    padding: 30px 25px;
}

.fb-rounds-cleared-display {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 5px;
    margin-bottom: 25px;
}

.fb-rounds-label {
    font-size: 1.1rem;
    color: #bdc3c7;
}

.fb-rounds-value {
    font-size: 4rem;
    font-weight: 900;
    background: linear-gradient(45deg, #f39c12, #e67e22);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
    line-height: 1.1;
}

.fb-round-details {
    display: flex;
    flex-direction: column;
    gap: 12px;
}

.fb-round-item {
    background: rgba(255, 255, 255, 0.12);
    border-radius: 12px;
    padding: 15px 18px;
    text-align: left;
    border-left: 4px solid #7f8c8d;
}

.fb-round-item.round-cleared {
    border-left-color: #2ecc71;
}

.fb-round-item.round-failed {
    border-left-color: #e74c3c;
}

.fb-round-item-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 6px;
}

.fb-round-item-number {
    font-weight: bold;
    font-size: 0.95rem;
    color: #3498db;
}

.fb-round-item-status {
    font-weight: bold;
    font-size: 0.95rem;
}

.round-cleared .fb-round-item-status {
    color: #2ecc71;
}

.round-failed .fb-round-item-status {
    color: #e74c3c;
}

.fb-round-item-condition {
    font-size: 0.9rem;
    color: #bdc3c7;
    margin-bottom: 8px;
}

.fb-round-item-cards {
    display: flex;
    flex-wrap: wrap;
    gap: 6px;
}

.fb-round-card-tag {
    background: rgba(46, 204, 113, 0.2);
    color: #2ecc71;
    padding: 4px 10px;
    border-radius: 15px;
    font-size: 0.8rem;
    font-weight: bold;
}

.fb-round-card-empty {
    color: #e74c3c;
    font-size: 0.8rem;
    padding: 4px 10px;
    background: rgba(231, 76, 60, 0.15);
    border-radius: 15px;
}

.fb-result-buttons {
    display: flex;
    flex-direction: column;
    gap: 12px;
    align-items: center;
    width: 100%;
    max-width: 300px;
    margin: 0 auto;
}

/* ========== アニメーション ========== */

@keyframes clearZoomIn {
    0% {
        transform: scale(0.3);
        opacity: 0;
    }
    60% {
        transform: scale(1.15);
        opacity: 1;
    }
    100% {
        transform: scale(1);
        opacity: 1;
    }
}

@keyframes bombPulse {
    0% { filter: drop-shadow(0 0 6px rgba(100, 150, 255, 0.4)); }
    100% { filter: drop-shadow(0 0 14px rgba(255, 200, 50, 0.7)); }
}

@keyframes bombExplode {
    0% { transform: scale(1); opacity: 1; }
    50% { transform: scale(2.5); opacity: 0.8; }
    100% { transform: scale(4); opacity: 0; }
}

@keyframes capLightPulse {
    0% { box-shadow: 0 0 6px var(--tube-color); }
    100% { box-shadow: 0 0 16px var(--tube-color), 0 0 24px var(--tube-color); }
}

@keyframes bubbleFloat {
    0% { transform: translateY(0); opacity: 0; }
    10% { opacity: 0.5; }
    90% { opacity: 0.2; }
    100% { transform: translateY(-280px); opacity: 0; }
}

@keyframes explosionFlash {
    0% { opacity: 0; transform: scale(0.3); }
    30% { opacity: 1; }
    100% { opacity: 0; transform: scale(3); }
}

@keyframes explosionTextIn {
    0% { opacity: 0; transform: scale(3); filter: blur(10px); }
    100% { opacity: 1; transform: scale(1); filter: blur(0); }
}

@keyframes particleFly {
    0% { transform: translate(0, 0) scale(1); opacity: 1; }
    100% { transform: translate(var(--x, 50px), var(--y, -50px)) scale(0); opacity: 0; }
}

@keyframes shake {
    0%, 100% { transform: translateX(0); }
    20% { transform: translateX(-8px); }
    40% { transform: translateX(8px); }
    60% { transform: translateX(-6px); }
    80% { transform: translateX(6px); }
}

.shake {
    animation: shake 0.4s ease-out;
}

/* ========== レスポンシブ ========== */

@media (max-width: 600px) {
    .fb-game-title {
        font-size: 2rem;
    }

    .fb-subtitle {
        font-size: 1rem;
    }

    .fb-game-header {
        padding: 6px 12px;
        gap: 8px;
    }

    .fb-round-display {
        font-size: 1.1rem;
    }

    .fb-timer-display {
        font-size: 1.3rem;
    }

    .fb-condition-banner {
        padding: 10px 14px;
    }

    .fb-condition-text {
        font-size: 1rem;
    }

    .fb-tube-body {
        min-height: 80px;
    }

    .fb-tube-cap {
        height: 22px;
    }

    .fb-tube-base {
        height: 18px;
    }

    .fb-tube-divider {
        width: 6px;
        margin-top: 22px;
        margin-bottom: 50px;
    }

    .fb-bomb {
        width: 55px;
    }

    .fb-bomb-bar {
        height: 7px;
    }

    .fb-tube-card-name {
        font-size: 0.65rem;
    }

    .fb-tube-player {
        margin-top: -16px;
    }

    .fb-tube-player-icon {
        font-size: 34px;
    }

    .fb-tube-player-icon-img {
        width: 40px;
        height: 40px;
    }

    .fb-input-container {
        flex-direction: column;
        gap: 10px;
    }

    .fb-input-container .btn-submit {
        width: 100%;
    }

    .fb-clear-img {
        width: min(80vw, 300px);
    }

    .fb-gameover-img {
        width: min(80vw, 320px);
    }

    .fb-result-content {
        padding: 20px 15px;
    }

    .fb-rounds-value {
        font-size: 3rem;
    }
}

@media (max-width: 400px) {
    .fb-tube-player {
        margin-top: -13px;
    }

    .fb-tube-player-icon {
        font-size: 28px;
    }

    .fb-tube-player-icon-img {
        width: 34px;
        height: 34px;
    }

    .fb-tube-body {
        min-height: 60px;
    }

    .fb-tube-cap {
        height: 18px;
    }

    .fb-tube-base {
        height: 14px;
    }

    .fb-tube-divider {
        width: 4px;
        margin-top: 18px;
        margin-bottom: 40px;
    }

    .fb-bomb {
        width: 42px;
    }

    .fb-bomb-bar {
        height: 5px;
    }
}

/* ========== 設定ボタン ========== */

.fb-settings-btn {
    position: fixed;
    top: max(12px, env(safe-area-inset-top));
    right: 12px;
    z-index: 9999;
    width: 42px;
    height: 42px;
    font-size: 1.3rem;
    background: rgba(255, 255, 255, 0.1);
    border: 1px solid rgba(255, 255, 255, 0.25);
    border-radius: 8px;
    color: #fff;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: background 0.2s, opacity 0.2s;
}

.fb-settings-btn:hover {
    background: rgba(255, 255, 255, 0.2);
}

/* サウンドトグル（設定モーダル内） */
.fb-sound-toggle {
    padding: 6px 16px;
    border-radius: 6px;
    border: 1px solid rgba(255, 255, 255, 0.2);
    background: rgba(78, 205, 196, 0.2);
    color: #fff;
    font-size: 0.95rem;
    cursor: pointer;
    transition: background 0.2s, opacity 0.2s;
    min-width: 80px;
}

.fb-sound-toggle:hover {
    background: rgba(78, 205, 196, 0.35);
}

.fb-sound-toggle.sound-off {
    background: rgba(255, 255, 255, 0.08);
    opacity: 0.6;
}

/* ========== ラウンド開始オーバーレイ ========== */

.fb-round-start-overlay {
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 100;
    background: rgba(10, 10, 30, 0.55);
    backdrop-filter: blur(2px);
}

.fb-round-start-btn {
    padding: 18px 54px;
    font-size: 1.6rem;
    font-weight: bold;
    background: linear-gradient(135deg, #e74c3c, #c0392b);
    color: #fff;
    border: none;
    border-radius: 50px;
    cursor: pointer;
    box-shadow: 0 6px 24px rgba(231, 76, 60, 0.55);
    transition: transform 0.15s, box-shadow 0.15s;
    letter-spacing: 0.08em;
}

.fb-round-start-btn:hover {
    transform: translateY(-3px) scale(1.04);
    box-shadow: 0 10px 30px rgba(231, 76, 60, 0.75);
}

.fb-round-start-btn:disabled {
    background: #444;
    color: #888;
    cursor: default;
    font-size: 1.1rem;
    box-shadow: none;
    transform: none;
    pointer-events: none;
}

/* ========== プレイヤーバッジ（チューブ下） ========== */

.fb-tube-player {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 4px;
    margin-top: -20px;
    position: relative;
    z-index: 10;
}

.fb-tube-player-icon {
    font-size: 40px;
    line-height: 1;
    filter: drop-shadow(0 2px 6px rgba(0,0,0,0.7));
}

.fb-tube-player-name {
    font-size: 13px;
    color: #ddd;
    white-space: nowrap;
    text-shadow: 0 1px 4px rgba(0,0,0,0.9);
}

.fb-tube-player.is-me .fb-tube-player-name {
    color: #f0c040;
    font-weight: bold;
}

/* ========== 解答例モーダル ========== */

.fb-examples-modal {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 500;
    background: rgba(0, 0, 0, 0.65);
    backdrop-filter: blur(3px);
}

.fb-examples-content {
    background: linear-gradient(160deg, #1e2a45, #16213e);
    border: 1px solid rgba(100, 160, 255, 0.3);
    border-radius: 16px;
    padding: 28px 32px;
    width: min(90vw, 480px);
    max-height: 80vh;
    overflow-y: auto;
    display: flex;
    flex-direction: column;
    gap: 16px;
    box-shadow: 0 8px 40px rgba(0, 0, 0, 0.6);
    animation: examplesIn 0.3s ease-out;
}

@keyframes examplesIn {
    from { transform: scale(0.88) translateY(16px); opacity: 0; }
    to   { transform: scale(1) translateY(0); opacity: 1; }
}

.fb-examples-title {
    font-size: 1.3rem;
    color: #85c1e9;
    font-weight: bold;
    text-align: center;
    letter-spacing: 0.05em;
}

.fb-examples-condition {
    font-size: 0.9rem;
    color: rgba(255, 255, 255, 0.65);
    text-align: center;
    line-height: 1.5;
    border-bottom: 1px solid rgba(255, 255, 255, 0.1);
    padding-bottom: 12px;
}

.fb-examples-list {
    list-style: none;
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.fb-examples-item {
    padding: 10px 16px;
    background: rgba(52, 152, 219, 0.15);
    border: 1px solid rgba(52, 152, 219, 0.25);
    border-radius: 8px;
    font-size: 0.95rem;
    color: #ecf0f1;
}

/* ========== チューブ破壊状態 ========== */

.fb-tube.broken .fb-tube-body {
    background: linear-gradient(90deg, #3d1a1a, #6b2525, #8b3030, #6b2525, #3d1a1a);
    border-color: rgba(231, 76, 60, 0.4);
    animation: shake 0.4s ease-out;
}

.fb-tube.broken .fb-cap-light {
    background: radial-gradient(circle, #ff6b6b, #e74c3c);
    box-shadow: 0 0 12px #e74c3c;
}

/* ========== ログイン画面 ========== */

.fb-login-screen {
    text-align: center;
    width: 100%;
}

.fb-login-box {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 18px;
    background: rgba(255, 255, 255, 0.07);
    border: 1px solid rgba(255, 255, 255, 0.15);
    border-radius: 20px;
    padding: 36px 40px;
    width: 100%;
    max-width: 420px;
}

.fb-login-desc {
    font-size: 1rem;
    color: #bdc3c7;
    line-height: 1.6;
}

.fb-google-login-btn {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 14px 32px;
    font-size: 1.1rem;
    font-weight: bold;
    background: #fff;
    color: #333;
    border: none;
    border-radius: 50px;
    cursor: pointer;
    box-shadow: 0 4px 15px rgba(0, 0, 0, 0.3);
    transition: all 0.25s;
    min-width: 220px;
    justify-content: center;
}

.fb-google-login-btn:hover:not(:disabled) {
    transform: translateY(-2px);
    box-shadow: 0 6px 22px rgba(0, 0, 0, 0.4);
}

.fb-google-login-btn:disabled {
    opacity: 0.5;
    cursor: not-allowed;
}

.fb-google-icon {
    font-size: 1.3rem;
    font-weight: 900;
    color: #4285F4;
    font-family: 'Google Sans', Arial, sans-serif;
}

.fb-twitter-login-btn {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 14px 32px;
    font-size: 1.1rem;
    font-weight: bold;
    background: #000;
    color: #fff;
    border: 2px solid rgba(255, 255, 255, 0.2);
    border-radius: 50px;
    cursor: pointer;
    box-shadow: 0 4px 15px rgba(0, 0, 0, 0.3);
    transition: all 0.25s;
    min-width: 220px;
    justify-content: center;
}

.fb-twitter-login-btn:hover:not(:disabled) {
    background: #222;
    transform: translateY(-2px);
    box-shadow: 0 6px 22px rgba(0, 0, 0, 0.4);
}

.fb-twitter-login-btn:disabled {
    opacity: 0.5;
    cursor: not-allowed;
}

.fb-twitter-icon {
    font-size: 1.2rem;
    font-weight: 900;
    font-family: Arial, sans-serif;
}

.fb-login-separator {
    font-size: 0.85rem;
    color: rgba(255, 255, 255, 0.3);
    position: relative;
    width: 100%;
    text-align: center;
}

.fb-login-separator::before,
.fb-login-separator::after {
    content: '';
    position: absolute;
    top: 50%;
    width: 35%;
    height: 1px;
    background: rgba(255, 255, 255, 0.15);
}

.fb-login-separator::before { left: 0; }
.fb-login-separator::after  { right: 0; }

.fb-anon-btn {
    font-size: 0.95rem;
    color: #bdc3c7;
    background: transparent;
    border: 1px solid rgba(255, 255, 255, 0.2);
    border-radius: 50px;
    padding: 10px 28px;
    cursor: pointer;
    transition: all 0.2s;
    min-width: 180px;
}

.fb-anon-btn:hover:not(:disabled) {
    background: rgba(255, 255, 255, 0.08);
    color: #fff;
    border-color: rgba(255, 255, 255, 0.35);
}

.fb-anon-btn:disabled {
    opacity: 0.4;
    cursor: not-allowed;
}

.fb-login-loading {
    font-size: 0.95rem;
    color: #7f8c8d;
}

.fb-login-error {
    font-size: 0.9rem;
    color: #e74c3c;
    background: rgba(231, 76, 60, 0.15);
    border-radius: 8px;
    padding: 10px 16px;
    width: 100%;
    text-align: center;
}

.fb-login-hint {
    font-size: 0.8rem;
    color: #7f8c8d;
    text-align: center;
    margin-top: -4px;
}

.fb-login-legal {
    font-size: 0.75rem;
    color: #7f8c8d;
    text-align: center;
    margin-top: 4px;
}

.fb-other-games {
    margin-top: 16px;
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
    justify-content: center;
    align-items: center;
}

.fb-other-games-label {
    font-size: 0.8rem;
    color: #7f8c8d;
    margin-bottom: 6px;
}

.fb-other-game-btn {
    display: inline-block;
    padding: 8px 24px;
    background: rgba(255, 255, 255, 0.1);
    color: #e0e0e0;
    border: 1px solid rgba(255, 255, 255, 0.2);
    border-radius: 20px;
    font-size: 0.9rem;
    text-decoration: none;
    transition: background 0.2s, border-color 0.2s;
}

.fb-other-game-btn:hover {
    background: rgba(255, 255, 255, 0.2);
    border-color: rgba(255, 255, 255, 0.4);
}

.fb-login-legal a {
    color: #4ecdc4;
    text-decoration: underline;
}

/* ========== プロフィール設定画面 ========== */

.fb-profile-screen {
    text-align: center;
    width: 100%;
}

.fb-profile-title {
    font-size: 1.8rem;
    font-weight: 900;
    color: #f39c12;
}

.fb-profile-box {
    display: flex;
    flex-direction: column;
    gap: 22px;
    background: rgba(255, 255, 255, 0.07);
    border: 1px solid rgba(255, 255, 255, 0.15);
    border-radius: 20px;
    padding: 32px 36px;
    width: 100%;
    max-width: 480px;
}

.fb-profile-field {
    display: flex;
    flex-direction: column;
    gap: 10px;
    text-align: left;
}

.fb-profile-label {
    font-size: 0.95rem;
    color: #bdc3c7;
    font-weight: bold;
}

.fb-profile-input {
    width: 100%;
    padding: 12px 18px;
    font-size: 1rem;
    border: 2px solid rgba(255, 255, 255, 0.2);
    border-radius: 10px;
    background: rgba(0, 0, 0, 0.3);
    color: #fff;
    outline: none;
    transition: border-color 0.3s;
}

.fb-profile-input:focus {
    border-color: #3498db;
}

.fb-profile-input::placeholder {
    color: rgba(255, 255, 255, 0.35);
}

.fb-icon-grid {
    display: grid;
    grid-template-columns: repeat(8, 1fr);
    gap: 8px;
}

.fb-icon-option {
    font-size: 1.5rem;
    width: 44px;
    height: 44px;
    border-radius: 10px;
    border: 2px solid transparent;
    background: rgba(255, 255, 255, 0.08);
    cursor: pointer;
    transition: all 0.15s;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 0;
}

.fb-icon-option:hover {
    background: rgba(255, 255, 255, 0.18);
    border-color: rgba(255, 255, 255, 0.3);
}

.fb-icon-option.selected {
    background: rgba(52, 152, 219, 0.35);
    border-color: #3498db;
    box-shadow: 0 0 10px rgba(52, 152, 219, 0.4);
}

.fb-profile-error {
    font-size: 0.9rem;
    color: #e74c3c;
    background: rgba(231, 76, 60, 0.15);
    border-radius: 8px;
    padding: 10px 16px;
    text-align: center;
}

/* ========== ユーザーバッジ（タイトル画面） ========== */

.fb-user-badge {
    display: flex;
    align-items: center;
    gap: 10px;
    background: rgba(255, 255, 255, 0.08);
    border: 1px solid rgba(255, 255, 255, 0.2);
    border-radius: 50px;
    padding: 8px 16px;
}

.fb-user-icon-display {
    font-size: 1.4rem;
    line-height: 1;
}

.fb-user-name-display {
    font-size: 1rem;
    font-weight: bold;
    color: #ecf0f1;
    max-width: 120px;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.fb-logout-btn {
    font-size: 0.8rem;
    padding: 5px 14px;
    background: rgba(231, 76, 60, 0.25);
    color: #e74c3c;
    border: 1px solid rgba(231, 76, 60, 0.4);
    border-radius: 20px;
    cursor: pointer;
    transition: all 0.2s;
}

.fb-logout-btn:hover {
    background: rgba(231, 76, 60, 0.4);
}

/* ========== ロビー画面 ========== */

.fb-lobby-screen {
    display: flex;
    align-items: center;
    justify-content: center;
    min-height: 100vh;
    padding: 20px;
}

.fb-lobby-box {
    background: rgba(10, 10, 30, 0.92);
    border: 2px solid rgba(245, 158, 11, 0.4);
    border-radius: 16px;
    padding: 36px 40px;
    width: 100%;
    max-width: 480px;
    box-shadow: 0 8px 32px rgba(0, 0, 0, 0.5);
}

.fb-lobby-title {
    font-size: 1.6rem;
    font-weight: 700;
    color: #f59e0b;
    margin-bottom: 16px;
    text-align: center;
}

.fb-lobby-header {
    margin-bottom: 24px;
}

.fb-room-code-wrap {
    display: flex;
    align-items: center;
    gap: 8px;
    justify-content: center;
    background: rgba(255, 255, 255, 0.05);
    border: 1px solid rgba(245, 158, 11, 0.3);
    border-radius: 8px;
    padding: 10px 14px;
}

.fb-room-code-label {
    font-size: 0.8rem;
    color: #aaa;
    white-space: nowrap;
}

.fb-room-code-text {
    font-size: 1.4rem;
    font-weight: 700;
    font-family: monospace;
    color: #f59e0b;
    letter-spacing: 4px;
}

.fb-copy-btn {
    background: rgba(245, 158, 11, 0.2);
    border: 1px solid rgba(245, 158, 11, 0.5);
    color: #f59e0b;
    border-radius: 6px;
    padding: 4px 10px;
    font-size: 0.75rem;
    cursor: pointer;
    transition: background 0.2s;
    white-space: nowrap;
}

.fb-copy-btn:hover {
    background: rgba(245, 158, 11, 0.35);
}

.fb-lobby-players {
    display: flex;
    flex-direction: column;
    gap: 8px;
    margin-bottom: 16px;
    min-height: 200px;
}

.fb-player-slot {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 10px 14px;
    background: rgba(255, 255, 255, 0.06);
    border: 1px solid rgba(255, 255, 255, 0.12);
    border-radius: 8px;
}

.fb-player-slot.empty {
    opacity: 0.35;
    border-style: dashed;
}

.fb-player-slot-num {
    font-size: 0.75rem;
    color: #888;
    width: 16px;
    text-align: center;
    flex-shrink: 0;
}

.fb-player-slot-icon {
    font-size: 1.4rem;
    flex-shrink: 0;
}

.fb-player-slot-name {
    font-size: 0.95rem;
    font-weight: 600;
    color: #e0e0e0;
    flex: 1;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.fb-player-slot-name.empty {
    color: #555;
    font-weight: 400;
}

.fb-host-badge {
    font-size: 0.7rem;
    background: rgba(245, 158, 11, 0.25);
    color: #f59e0b;
    border: 1px solid rgba(245, 158, 11, 0.5);
    border-radius: 4px;
    padding: 2px 6px;
    white-space: nowrap;
}

.fb-me-badge {
    font-size: 0.7rem;
    background: rgba(99, 102, 241, 0.25);
    color: #818cf8;
    border: 1px solid rgba(99, 102, 241, 0.5);
    border-radius: 4px;
    padding: 2px 6px;
    white-space: nowrap;
}

.fb-lobby-status {
    min-height: 20px;
    font-size: 0.85rem;
    color: #aaa;
    text-align: center;
    margin-bottom: 16px;
}

.fb-lobby-actions {
    display: flex;
    flex-direction: column;
    gap: 10px;
}

/* ========== モーダル共通 ========== */

.fb-modal {
    position: fixed;
    inset: 0;
    background: rgba(0, 0, 0, 0.7);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 200;
}

.fb-modal.hidden {
    display: none;
}

.fb-modal-box {
    background: rgba(10, 10, 30, 0.97);
    border: 2px solid rgba(245, 158, 11, 0.4);
    border-radius: 16px;
    padding: 32px 36px;
    width: 100%;
    max-width: 360px;
    box-shadow: 0 8px 32px rgba(0, 0, 0, 0.6);
}

.fb-modal-title {
    font-size: 1.2rem;
    font-weight: 700;
    color: #f59e0b;
    text-align: center;
    margin-bottom: 20px;
}

.fb-room-code-input {
    width: 100%;
    padding: 12px 16px;
    font-size: 1.4rem;
    font-family: monospace;
    font-weight: 700;
    letter-spacing: 4px;
    text-align: center;
    text-transform: uppercase;
    background: rgba(255, 255, 255, 0.08);
    border: 2px solid rgba(245, 158, 11, 0.4);
    border-radius: 8px;
    color: #fff;
    outline: none;
    margin-bottom: 16px;
}

.fb-room-code-input:focus {
    border-color: #f59e0b;
    background: rgba(255, 255, 255, 0.12);
}

.fb-modal-actions {
    display: flex;
    gap: 10px;
}

.fb-modal-actions .btn {
    flex: 1 1 0;
    min-width: 0;
    padding-left: 0;
    padding-right: 0;
    white-space: nowrap;
}

.fb-join-error {
    margin-top: 12px;
    font-size: 0.85rem;
    color: #f87171;
    text-align: center;
}

/* ========== マッチング中オーバーレイ ========== */

.fb-matching-overlay {
    position: fixed;
    inset: 0;
    background: rgba(0, 0, 0, 0.82);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 300;
}

.fb-matching-overlay.hidden {
    display: none;
}

.fb-matching-box {
    text-align: center;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 20px;
}

.fb-matching-spinner {
    width: 56px;
    height: 56px;
    border: 4px solid rgba(245, 158, 11, 0.2);
    border-top-color: #f59e0b;
    border-radius: 50%;
    animation: spin 0.9s linear infinite;
}

/* ========== 画像問題オーバーレイ ========== */

#fb-image-cards {
    position: absolute;
    top: 0;
    left: 50%;
    transform: translateX(-50%);
    width: 100%;
    max-width: 680px;
    height: 100%;
    display: grid;
    grid-template-columns: repeat(6, 1fr);
    align-content: start;
    gap: 10px;
    z-index: 60;
    pointer-events: none;
    padding: 0 6px 0;
    box-sizing: border-box;
}

/* 1行目: 3枚 */
.fb-image-card:nth-child(1) { grid-column: 1 / 3; }
.fb-image-card:nth-child(2) { grid-column: 3 / 5; }
.fb-image-card:nth-child(3) { grid-column: 5 / 7; }
/* 2行目: 3枚 */
.fb-image-card:nth-child(4) { grid-column: 1 / 3; }
.fb-image-card:nth-child(5) { grid-column: 3 / 5; }
.fb-image-card:nth-child(6) { grid-column: 5 / 7; }

.fb-image-card {
    position: relative;
    cursor: pointer;
    pointer-events: all;
    border-radius: 8px;
    border: 3px solid transparent;
    transition: border-color 0.15s, box-shadow 0.15s, filter 0.2s;
    user-select: none;
}

.fb-image-card img {
    width: 100%;
    border-radius: 6px;
    display: block;
}

.fb-image-card.active {
    border-color: #ffe600;
    box-shadow: 0 0 18px #ffe600cc;
}

.fb-image-card.answered {
    filter: grayscale(100%) brightness(0.45);
    cursor: default;
    border-color: transparent;
    box-shadow: none;
}

.fb-image-card-check {
    display: none;
    position: absolute;
    inset: 0;
    align-items: center;
    justify-content: center;
    font-size: 2.8rem;
    color: #fff;
    background: rgba(0, 0, 0, 0.45);
    border-radius: 6px;
    pointer-events: none;
}

.fb-image-card.answered .fb-image-card-check {
    display: flex;
}

@keyframes spin {
    to { transform: rotate(360deg); }
}

.fb-matching-text {
    font-size: 1.1rem;
    color: #e0e0e0;
}

/* ========== Twitterアイコン・プロフィール写真 ========== */

.fb-profile-photo-preview {
    display: flex;
    justify-content: center;
    padding: 8px 0;
}

.fb-profile-photo-img {
    width: 80px;
    height: 80px;
    border-radius: 50%;
    object-fit: cover;
    border: 3px solid rgba(255, 255, 255, 0.3);
    box-shadow: 0 4px 15px rgba(0, 0, 0, 0.4);
}

.fb-user-icon-img {
    width: 28px;
    height: 28px;
    border-radius: 50%;
    object-fit: cover;
    vertical-align: middle;
}

.fb-tube-player-icon-img {
    width: 48px;
    height: 48px;
    border-radius: 50%;
    object-fit: cover;
    filter: drop-shadow(0 2px 6px rgba(0,0,0,0.7));
}

.fb-player-slot-icon-img {
    width: 28px;
    height: 28px;
    border-radius: 50%;
    object-fit: cover;
}

/* ========== 設定モーダル ========== */

.fb-settings-box {
    display: flex;
    flex-direction: column;
    gap: 20px;
}

.fb-settings-row {
    display: flex;
    flex-direction: column;
    gap: 10px;
}

.fb-settings-label {
    font-size: 0.95rem;
    color: #bdc3c7;
    font-weight: bold;
}

.fb-settings-slider-wrap {
    display: flex;
    align-items: center;
    gap: 14px;
}

.fb-volume-slider {
    flex: 1;
    -webkit-appearance: none;
    appearance: none;
    height: 6px;
    border-radius: 3px;
    background: rgba(255, 255, 255, 0.2);
    outline: none;
    cursor: pointer;
}

.fb-volume-slider::-webkit-slider-thumb {
    -webkit-appearance: none;
    appearance: none;
    width: 20px;
    height: 20px;
    border-radius: 50%;
    background: #3498db;
    box-shadow: 0 2px 6px rgba(52, 152, 219, 0.6);
    cursor: pointer;
    transition: background 0.2s, transform 0.1s;
}

.fb-volume-slider::-webkit-slider-thumb:hover {
    background: #2ecc71;
    transform: scale(1.15);
}

.fb-volume-slider::-moz-range-thumb {
    width: 20px;
    height: 20px;
    border-radius: 50%;
    background: #3498db;
    border: none;
    cursor: pointer;
}

.fb-settings-value {
    min-width: 36px;
    text-align: right;
    font-size: 1rem;
    font-weight: bold;
    color: #3498db;
}

/* ========== モバイル追加修正 ========== */

@media (max-width: 600px) {
    .container {
        padding: 10px;
        padding-top: max(10px, env(safe-area-inset-top));
        padding-bottom: max(10px, env(safe-area-inset-bottom));
    }

    .fb-lobby-screen {
        padding: 10px;
    }

    .fb-lobby-box {
        padding: 20px 16px;
    }

    .fb-profile-box {
        padding: 20px 16px;
    }

    .fb-settings-btn {
        width: 36px;
        height: 36px;
        font-size: 1.1rem;
    }
}

/* ========== ゲームモード選択 ========== */

.fb-mode-select {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 8px;
    width: 100%;
    max-width: 400px;
}

.fb-mode-label {
    font-size: 0.85rem;
    color: #aaa;
    letter-spacing: 0.05em;
}

.fb-mode-btns {
    display: flex;
    gap: 10px;
    width: 100%;
}

.fb-mode-btn {
    flex: 1;
    padding: 10px 12px;
    border: 2px solid #444;
    border-radius: 10px;
    background: rgba(255,255,255,0.05);
    color: #ccc;
    font-size: 0.9rem;
    cursor: pointer;
    transition: all 0.2s;
}

.fb-mode-btn:hover {
    border-color: #888;
    background: rgba(255,255,255,0.1);
    color: #fff;
}

.fb-mode-btn.active {
    border-color: #4a9eff;
    background: rgba(74, 158, 255, 0.2);
    color: #fff;
    font-weight: bold;
}

/* ========== ファイブリーグ 画面 ========== */

/* リーグ画面中はスクロール防止 */
body:has(#fb-league-screen:not(.hidden)) {
    overflow: hidden;
    height: 100dvh;
}

body:has(#fb-league-screen:not(.hidden)) .container {
    height: 100dvh;
    max-height: 100dvh;
    overflow: hidden;
    justify-content: flex-start;
    padding-top: max(8px, env(safe-area-inset-top));
    padding-bottom: max(8px, env(safe-area-inset-bottom));
}

#fb-league-screen {
    width: 100%;
    height: 100%;
    display: flex;
    flex-direction: column;
    gap: 8px;
    position: relative;
}

/* スロット横一列 */
.fb-league-slots {
    display: flex;
    flex-direction: row;
    align-items: stretch;
    gap: 6px;
    width: 100%;
    background: #e8b800;
    border: 4px solid #1a1a1a;
    border-radius: 6px;
    padding: 8px 8px 10px;
    box-sizing: border-box;
}

/* 各スロット: タブ（上）＋文字枠（下）の縦並び */
.fb-league-slot {
    display: flex;
    flex-direction: column;
    align-items: center;
    flex: 1;
    gap: 6px;
    min-width: 0;
}

/* プレイヤータブ */
.fb-league-slot-player {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 2px;
    background: #9a9a9a;
    border: 2px solid #555;
    border-radius: 4px;
    padding: 3px 4px;
    width: 100%;
    min-height: 38px;
    box-sizing: border-box;
}

.fb-league-slot.is-mine .fb-league-slot-player {
    background: #f0c040;
    border-color: #b88a00;
}

/* 文字表示枠 */
.fb-league-slot-char {
    width: 100%;
    aspect-ratio: 1 / 1;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 2rem;
    font-weight: bold;
    background: #fff;
    border: 3px solid #1a1a1a;
    border-radius: 4px;
    color: #1a1a1a;
    transition: background 0.3s, color 0.3s;
    box-sizing: border-box;
}

.fb-league-slot.submitted .fb-league-slot-char {
    background: #d0e8ff;
    color: #1a5a9a;
}

.fb-league-slot.reveal-correct .fb-league-slot-char {
    background: #b8f0c8;
    color: #1a6a30;
    animation: league-reveal-pop 0.4s ease-out;
}

.fb-league-slot.reveal-wrong .fb-league-slot-char {
    background: #ffd0d0;
    color: #8a1a1a;
    animation: league-reveal-pop 0.4s ease-out;
}

@keyframes league-reveal-pop {
    0%   { transform: scale(0.85); }
    60%  { transform: scale(1.08); }
    100% { transform: scale(1); }
}

/* プレイヤーアイコン・名前 */
.fb-league-slot-icon,
.fb-league-slot-icon-img {
    width: 22px;
    height: 22px;
    border-radius: 50%;
    object-fit: cover;
    flex-shrink: 0;
    font-size: 1rem;
    display: flex;
    align-items: center;
    justify-content: center;
}

.fb-league-slot-name {
    font-size: 0.65rem;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
    color: #222;
    font-weight: bold;
    max-width: 100%;
}

.fb-league-slot.is-mine .fb-league-slot-name {
    color: #5a3a00;
}

/* 入力エリア */
.fb-league-input-area {
    flex-shrink: 0;
}

.fb-league-input {
    max-width: 200px;
    text-align: center;
    font-size: 1.4rem;
    letter-spacing: 0.2em;
}

/* リーグ カードヒント画像 */
.fb-league-card-hint {
    display: block;
    width: min(140px, 35vw);
    height: auto;
    border-radius: 8px;
    box-shadow: 0 2px 10px rgba(0, 0, 0, 0.5);
    margin: 0 auto 8px;
}

.fb-league-card-hint-start {
    width: min(180px, 44vw);
    margin-bottom: 14px;
    border: 2px solid rgba(255, 255, 255, 0.5);
}

/* ラウンド開始オーバーレイ内プロンプト */
.fb-league-start-prompt {
    color: #fff;
    font-size: 1.1rem;
    text-align: center;
    padding: 0 16px;
    margin-bottom: 12px;
    line-height: 1.5;
    max-width: 340px;
}

/* リビールオーバーレイ */
.fb-league-reveal-overlay {
    position: absolute;
    inset: 0;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 12px;
    background: rgba(0,0,0,0.8);
    z-index: 30;
    border-radius: 12px;
    overflow-y: auto;
    padding: 16px;
}

.fb-league-reveal-result {
    font-size: 2.6rem;
    font-weight: bold;
    text-align: center;
    padding: 24px 40px;
    border-radius: 16px;
    animation: league-result-pop 0.5s cubic-bezier(0.34,1.56,0.64,1);
}

.fb-league-reveal-result.reveal-success {
    background: rgba(78, 203, 113, 0.25);
    border: 3px solid #4ecb71;
    color: #a8ffbb;
    text-shadow: 0 0 20px #4ecb71;
}

.fb-league-reveal-result.reveal-fail {
    background: rgba(224, 82, 82, 0.25);
    border: 3px solid #e05252;
    color: #ffaaaa;
    text-shadow: 0 0 20px #e05252;
}

.league-reveal-answer {
    display: block;
    font-size: 2.8rem;
    color: #fff;
    text-shadow: 0 0 16px #fff, 0 2px 8px rgba(0,0,0,0.8);
    margin-top: 8px;
    letter-spacing: 0.1em;
}

.fb-league-word-display {
    display: flex;
    flex-wrap: wrap;
    justify-content: center;
    align-items: baseline;
    gap: 2px;
    font-size: clamp(1.4rem, 6vw, 2.2rem);
    font-weight: bold;
    letter-spacing: 0.05em;
    min-height: 2.8em;
    padding: 8px 12px;
    background: rgba(0, 0, 0, 0.35);
    border-radius: 12px;
    width: min(420px, 90vw);
}

.fb-league-word-char {
    display: inline-block;
    animation: word-char-pop 0.3s cubic-bezier(0.34, 1.56, 0.64, 1);
}

.word-correct {
    color: #7fffaa;
    text-shadow: 0 0 10px #4ecb71;
}

.word-wrong {
    color: #ff8080;
    text-shadow: 0 0 10px #e05252;
}

.word-remaining {
    color: rgba(255, 255, 255, 0.6);
}

@keyframes word-char-pop {
    0%   { transform: scale(0) translateY(10px); opacity: 0; }
    100% { transform: scale(1) translateY(0);    opacity: 1; }
}

.fb-league-reveal-img {
    width: min(360px, 80vw);
    height: auto;
    border-radius: 8px;
    border: 3px solid #fff;
    box-shadow: 0 4px 20px rgba(0,0,0,0.6);
    animation: league-result-pop 0.4s cubic-bezier(0.34,1.56,0.64,1);
}

.fb-league-to-title-btn {
    margin-top: 8px;
    font-size: 0.9rem;
    padding: 8px 20px;
    opacity: 0.75;
}

@keyframes league-result-pop {
    0%   { transform: scale(0.5); opacity: 0; }
    100% { transform: scale(1);   opacity: 1; }
}

/* レスポンシブ */
@media (max-width: 600px) {
    .fb-mode-btns {
        flex-direction: column;
    }

    .fb-league-slot-char {
        font-size: 1.4rem;
    }

    .fb-league-slot-player {
        min-height: 30px;
    }

    .fb-league-reveal-result {
        font-size: 2rem;
        padding: 18px 28px;
    }

    .fb-league-input {
        max-width: 140px;
        font-size: 1.2rem;
    }
}
