.ng-game-container {
    position: relative;
    width: 100%;
    margin: 30px auto;
    background-color: #000;
    box-shadow: 0 10px 30px rgba(0,0,0,0.3);
    display: flex;
    flex-direction: column;
    overflow: hidden;
    border-radius: 8px;
    font-family: var(--font-family, 'Noto Sans JP', sans-serif);
    color: #ffffff;
    box-sizing: border-box;
    cursor: pointer;
}

.ng-game-container * {
    box-sizing: border-box;
}

.ng-game-screen {
    position: relative;
    width: 100%;
    aspect-ratio: 16 / 9;
    overflow: hidden;
}

.ng-bg-layer {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background-size: cover;
    background-position: center;
    transition: opacity 0.5s ease-in-out;
    z-index: 1;
    opacity: 1;
}

.ng-character-layer {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    z-index: 2;
    pointer-events: none;
}

.ng-character {
    position: absolute;
    bottom: 0;
    height: 95%;
    transition: opacity 0.4s ease, transform 0.4s ease;
}

.ng-char-left { left: 5%; }
.ng-char-right { right: 8%; }

.ng-character img {
    height: 100% !important;
    width: auto !important;
    max-width: none !important;
    object-fit: contain;
    object-position: bottom;
    filter: drop-shadow(0 5px 15px rgba(0,0,0,0.6));
    transition: transform 0.4s ease-out;
}

.ng-character.ng-hidden {
    opacity: 0;
}

.ng-character.ng-active img {
    transform: scale(1.02);
    filter: drop-shadow(0 8px 20px rgba(255,255,255,0.2));
}

.ng-character img.ng-flipped {
    transform: scaleX(-1);
}

.ng-character.ng-active img.ng-flipped {
    transform: scale(-1.02, 1.02);
}

.ng-ui-layer {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    z-index: 3;
    pointer-events: none;
    display: flex;
    flex-direction: column;
    justify-content: flex-end;
}

.ng-choices-container {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    height: 100%;
    gap: 15px;
    pointer-events: auto;
    z-index: 4;
    background: rgba(0,0,0,0.2);
}

@keyframes ngChoiceFadeIn {
    0% {
        opacity: 0;
        transform: translateY(15px);
    }
    100% {
        opacity: 1;
        transform: translateY(0);
    }
}

.ng-choice-btn {
    background: rgba(20, 20, 25, 0.85);
    color: #ffffff;
    border: 2px solid rgba(255, 255, 255, 0.4);
    padding: 15px 40px;
    border-radius: 30px;
    font-size: 1.1rem;
    cursor: pointer;
    transition: all 0.2s;
    width: 80%;
    max-width: 400px;
    text-align: center;
    backdrop-filter: blur(8px);
    box-shadow: 0 4px 10px rgba(0,0,0,0.5);
    opacity: 0;
    animation: ngChoiceFadeIn 0.4s forwards ease-out;
}

.ng-choice-btn:hover {
    background: rgba(255, 123, 172, 0.3);
    border-color: #ff7bac;
    transform: scale(1.03);
    box-shadow: 0 6px 15px rgba(255, 123, 172, 0.4);
}

.ng-bottom-ui {
    position: relative;
    width: 100%;
    z-index: 15; /* キャラクター(2)や背景(1)より前面 */
}

.ng-message-window {
    background: rgba(25, 25, 25, 0.94);
    border-top: 1px solid rgba(255, 255, 255, 0.3);
    padding: 25px 30px 20px;
    height: auto;
    color: #ffffff;
    position: relative;
    z-index: 2;
    border-radius: 0 0 8px 8px;
}

.ng-message-window.ng-hidden {
    display: none !important;
}

.ng-name-box {
    position: absolute !important;
    top: 0 !important;
    left: 20px !important;
    background: rgba(45, 45, 45, 0.98) !important;
    padding: 8px 30px 16px !important; /* 25pxから16pxに変更 */
    border: 1px solid rgba(255, 255, 255, 0.3) !important;
    border-bottom: none !important;
    border-radius: 12px 12px 0 0 !important;
    font-weight: bold !important;
    font-size: 1.05rem !important;
    color: #fff !important;
    box-shadow: 0 -5px 15px rgba(0,0,0,0.3) !important;
    backdrop-filter: blur(10px) !important;
    z-index: 1 !important; /* ウィンドウの背面に配置 */
    transition: all 0.4s cubic-bezier(0.22, 1, 0.36, 1) !important;
    transform: translateY(-85%) !important; /* 85%突き出す */
    opacity: 1 !important;
}

.ng-name-box.ng-transparent {
    opacity: 0 !important;
    transform: translateY(0) !important; /* ウィンドウの裏に完全に隠れる */
    pointer-events: none !important;
}

.ng-message-box {
    font-size: 1.05rem;
    line-height: 1.8;
    height: 7.2em; /* 1.8(line-height) * 4(lines) = 7.2em */
    overflow-y: auto;
    scroll-behavior: smooth;
    white-space: pre-wrap; /* 改行を有効化 */
    letter-spacing: 0.05em;
    text-shadow: 1px 1px 2px rgba(0,0,0,0.8);
    margin: 0;
    padding-right: 15px; /* スクロールバーとの干渉を防ぐ */
}

/* スクロールバーのカスタマイズ */
.ng-message-box::-webkit-scrollbar {
    width: 4px;
}
.ng-message-box::-webkit-scrollbar-track {
    background: rgba(255, 255, 255, 0.05);
}
.ng-message-box::-webkit-scrollbar-thumb {
    background: rgba(255, 255, 255, 0.2);
    border-radius: 2px;
}

.ng-next-indicator {
    position: absolute;
    bottom: 15px;
    right: 20px;
    font-size: 1.2rem;
    color: rgba(255, 255, 255, 0.4);
    animation: bounce 1s infinite;
}

@keyframes bounce {
    0%, 100% { transform: translateY(0); }
    50% { transform: translateY(6px); color: #ffffff; }
}

.ng-hidden {
    visibility: hidden !important;
    opacity: 0 !important;
    pointer-events: none !important;
}

@media (max-width: 600px) and (orientation: portrait) {
    .ng-game-screen {
        aspect-ratio: 4 / 3;
    }
    
    .ng-message-window {
        height: auto;
        min-height: 150px;
        flex: none;
        padding: 25px 20px 20px;
    }
    
    .ng-name-box {
        font-size: 1.05rem;
        top: -30px;
        left: 10px;
        padding: 4px 15px;
    }

    .ng-message-box {
        font-size: 0.95rem;
    }
    
    .ng-char-left { left: -10% !important; }
    .ng-char-right { right: -14% !important; }
    
    .ng-choice-btn {
        width: 90%;
        font-size: 1.05rem;
        padding: 12px 20px;
    }

    /* スマホ版の名前ラベル調整 */
    .ng-name-box {
        left: 10px !important;
        padding: 4px 20px 12px !important; /* 20pxから12pxに変更 */
        font-size: 0.9rem !important;
        transform: translateY(-92%) !important; /* 重なりを維持しつつ突き出し量を調整 */
    }
    .ng-name-box.ng-transparent {
        transform: translateY(0) !important;
    }
}

/* Overlay for Start/Replay */
.ng-overlay {
    position: absolute;
    top: 0; left: 0; right: 0; bottom: 0;
    background: rgba(0, 0, 0, 0.4);
    display: flex;
    flex-direction: column; /* ボタンとテキストを縦に並べる */
    justify-content: center;
    align-items: center;
    z-index: 100;
    backdrop-filter: blur(4px); /* ブラーを少し強めに */
    gap: 20px;
}
.ng-start-overlay {
    background: rgba(0, 0, 0, 0.6);
}
.ng-end-message {
    color: #fff;
    font-size: 1.2rem;
    font-weight: bold;
    text-shadow: 0 0 10px rgba(255,255,255,0.5);
    animation: fadeIn 1s ease-in-out;
}
@keyframes fadeIn {
    from { opacity: 0; transform: translateY(10px); }
    to { opacity: 1; transform: translateY(0); }
}
.ng-action-btn {
    padding: 16px 36px;
    font-size: 1.1rem;
    font-weight: 700;
    color: #fff;
    background: #4C7373;
    border: 2px solid rgba(255,255,255,0.2);
    border-radius: 50px;
    cursor: pointer;
    box-shadow: 0 4px 16px rgba(0,0,0,0.3);
    transition: transform 0.2s, background 0.3s;
}
.ng-action-btn:hover {
    transform: scale(1.05);
    background: #3a5c5c;
}

/* Backlog (Log) feature styles */
.ng-log-btn {
    position: absolute;
    top: -26px; /* -30pxから微調整 */
    right: 20px;
    background: rgba(45, 45, 45, 0.9);
    border: 1px solid rgba(255, 255, 255, 0.3);
    border-bottom: none;
    border-radius: 8px 8px 0 0;
    color: #fff;
    padding: 6px 15px 20px; /* 下側のパディングを増やして隙間を防止 */
    font-size: 0.85rem;
    font-weight: bold;
    cursor: pointer;
    z-index: 1;
    transition: all 0.3s cubic-bezier(0.22, 1, 0.36, 1);
    transform: translateY(0);
    backdrop-filter: blur(8px);
}

.ng-log-btn:hover {
    transform: translateY(-5px); /* 少しだけ上にずらす */
    background: #4C7373;
}

.ng-log-overlay {
    position: absolute;
    top: 0; left: 0; right: 0; bottom: 0;
    background: rgba(0, 0, 0, 0.85);
    z-index: 200;
    display: flex;
    flex-direction: column;
    padding: 40px 20px;
    backdrop-filter: blur(10px);
}

.ng-log-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 20px;
    padding-bottom: 10px;
    border-bottom: 1px solid rgba(255, 255, 255, 0.2);
}

.ng-log-title {
    font-size: 1.2rem;
    font-weight: bold;
    color: #4C7373;
}

.ng-log-close {
    background: none;
    border: 1px solid rgba(255, 255, 255, 0.5);
    color: #fff;
    padding: 5px 15px;
    border-radius: 20px;
    cursor: pointer;
    font-size: 0.9rem;
}

.ng-log-close:hover {
    background: rgba(255, 255, 255, 0.1);
}

.ng-log-content {
    flex: 1;
    overflow-y: auto;
    padding-right: 10px;
}

.ng-log-item {
    margin-bottom: 20px;
    padding-bottom: 15px;
    border-bottom: 1px solid rgba(255, 255, 255, 0.05);
}

.ng-log-name {
    font-weight: bold;
    font-size: 0.9rem;
    color: #4C7373;
    margin-bottom: 5px;
}

.ng-log-text {
    font-size: 1rem;
    line-height: 1.6;
    color: #eee;
    white-space: pre-wrap;
}

.ng-log-content::-webkit-scrollbar {
    width: 6px;
}
/* --- Open Forum Mode Styles --- */
.ng-mode-open-forum .ng-message-window {
    border-top: 1px solid rgba(255, 215, 0, 0.4);
    box-shadow: 0 -5px 20px rgba(255, 215, 0, 0.15);
    background: linear-gradient(180deg, rgba(30, 30, 35, 0.98) 0%, rgba(20, 20, 25, 0.98) 100%);
    animation: ngModeGlow 4s infinite ease-in-out;
}

.ng-mode-open-forum .ng-name-box {
    background: rgba(30, 25, 10, 0.98) !important;
    border: 1px solid rgba(255, 215, 0, 0.5) !important;
    color: #ffd700 !important;
    box-shadow: 0 -5px 15px rgba(255, 215, 0, 0.2) !important;
}

/* 控えめな発光パルス */
@keyframes ngModeGlow {
    0%, 100% { box-shadow: 0 -5px 15px rgba(255, 215, 0, 0.1); }
    50% { box-shadow: 0 -5px 25px rgba(255, 215, 0, 0.25); }
}

/* モード移行時の視覚的な合図（一瞬のオーバーレイ） */
.ng-mode-change-flash {
    position: absolute;
    top: 0; left: 0; right: 0; bottom: 0;
    background: #fff;
    opacity: 0;
    z-index: 1000;
    pointer-events: none;
    animation: ngFlash 0.5s ease-out;
}

/* --- Video Call Styles --- */
.ng-live-badge {
    position: absolute;
    top: 20px;
    right: 20px;
    background: rgba(0, 0, 0, 0.6);
    color: #ff4d4d;
    padding: 4px 12px;
    border-radius: 20px;
    font-family: 'Courier New', Courier, monospace;
    font-size: 14px;
    font-weight: bold;
    display: flex;
    align-items: center;
    gap: 8px;
    z-index: 100;
    border: 1px solid rgba(255, 77, 77, 0.3);
}

.ng-live-dot {
    width: 10px;
    height: 10px;
    background: #ff4d4d;
    border-radius: 50%;
    animation: ngLivePulse 1s infinite;
}

@keyframes ngLivePulse {
    0% { transform: scale(1); opacity: 1; }
    50% { transform: scale(1.3); opacity: 0.5; }
    100% { transform: scale(1); opacity: 1; }
}

.ng-live-timer {
    color: #eee;
    font-size: 12px;
}

/* 呼び出し中演出 */
.ng-mode-calling::after {
    content: "Connecting...";
    position: absolute;
    top: 40%;
    left: 50%;
    transform: translate(-50%, -50%);
    font-size: 24px;
    color: #00ff00;
    text-shadow: 0 0 10px rgba(0, 255, 0, 0.5);
    animation: ngCallingText 1.5s infinite linear;
    z-index: 200;
}

@keyframes ngCallingText {
    0%, 100% { opacity: 0.3; }
    50% { opacity: 1; }
}

.ng-mode-calling .ng-message-window {
    opacity: 0.5;
    pointer-events: none;
}

/* キャラクター画像のポーズ変更時の回転アニメーション */
@keyframes ngCharRotate {
    0% {
        transform: rotateY(0deg);
    }
    100% {
        transform: rotateY(360deg);
    }
}

.ng-character img.ng-rotating {
    animation: ngCharRotate 0.5s ease-in-out forwards;
}
