/* ═══════════════════════════════════════════════
   AVG Game Engine — 遊戲引擎樣式
   ═══════════════════════════════════════════════ */

#gamePreview {
    position: absolute;
    inset: 0;
    display: flex;
    align-items: center;
    justify-content: center;
    overflow: hidden;
    background: #000;
}

.ge-viewport {
    position: relative;
    transform-origin: center center;
    overflow: hidden;
    background: #0a0a1a;
    cursor: pointer;
    user-select: none;
    flex-shrink: 0;
}

/* ─── Background ─── */
.ge-bg {
    position: absolute;
    inset: 0;
    background-size: cover;
    background-position: center;
    background-repeat: no-repeat;
    transition: background-image 0.6s ease;
}

/* ─── Sprites ─── */
.ge-sprites {
    position: absolute;
    inset: 0;
    pointer-events: none;
    overflow: hidden;
}
.ge-sprite {
    position: absolute;
    bottom: 0;
    transform-origin: bottom center;
}
.ge-sprite img {
    max-height: 80%;
    height: auto;
    width: auto;
    max-width: none;
    display: block;
}

/* ─── 立繪動態（不覆蓋 inline transform，只加動畫效果） ─── */
.ge-anim-idle {
    animation: geAnimIdle 3s ease-in-out infinite;
}
@keyframes geAnimIdle {
    0%, 100% { margin-bottom: 0; }
    25%      { margin-bottom: 2px; }
    75%      { margin-bottom: -1px; }
}

.ge-anim-shake {
    animation: geAnimShake 0.4s ease-in-out 3;
}
@keyframes geAnimShake {
    0%, 100% { margin-left: 0; }
    20%      { margin-left: 6px; }
    40%      { margin-left: -6px; }
    60%      { margin-left: 4px; }
    80%      { margin-left: -4px; }
}

.ge-anim-fadein {
    animation: geAnimFadeIn 0.5s ease-out forwards;
}
@keyframes geAnimFadeIn {
    from { opacity: 0; }
    to   { opacity: 1; }
}

.ge-anim-fadeout {
    animation: geAnimFadeOut 0.5s ease-in forwards;
}
@keyframes geAnimFadeOut {
    from { opacity: 1; }
    to   { opacity: 0; }
}

/* ─── Dialog Box（容納 3 列文字） ─── */
.ge-dialog-box {
    position: absolute;
    bottom: 0;
    left: 0;
    right: 0;
    height: 190px;
    background: linear-gradient(0deg, rgba(10,10,30,0.95) 0%, rgba(10,10,30,0.85) 100%);
    border-top: 1px solid rgba(106,158,255,0.3);
    box-sizing: border-box;
    z-index: 5;
}

.ge-dialog-inner {
    position: relative;
    display: flex;
    align-items: flex-start;
    gap: 20px;
    height: 100%;
    padding: 0 30px 16px 30px;
}

/* 頭像：突出在對話框上方，邊框加粗 */
.ge-face {
    width: 100px;
    height: 100px;
    border-radius: 50%;
    background: rgba(74,111,165,0.3);
    flex-shrink: 0;
    overflow: hidden;
    border: 4px solid rgba(106,158,255,0.7);
    margin-top: -40px;
}
.ge-face img {
    width: 100%;
    height: 100%;
    object-fit: cover;
}

.ge-dialog-right {
    flex: 1;
    display: flex;
    flex-direction: column;
    min-width: 0;
    padding-top: 4px;
}

/* 人名：往上突出，不透明底板 */
.ge-speaker-name-box {
    font-size: 28px;
    font-weight: bold;
    color: #6adfff;
    background: rgba(15,15,50,0.95);
    border: 2px solid rgba(106,223,255,0.5);
    border-radius: 6px;
    padding: 4px 20px;
    display: inline-block;
    align-self: flex-start;
    margin-top: -30px;
    margin-bottom: 8px;
}

.ge-text {
    font-size: 26px;
    color: #e8e8e8;
    line-height: 1.6;
    white-space: pre-wrap;
    overflow: hidden;
    flex: 1;
}

.ge-text.ge-typing::after {
    content: '▌';
    color: rgba(106,223,255,0.7);
    animation: geTypingCursor 0.6s infinite;
}
@keyframes geTypingCursor {
    0%, 100% { opacity: 1; }
    50%      { opacity: 0; }
}

/* 語音按鈕 */
.ge-voice-btn {
    position: absolute;
    top: 8px;
    right: 60px;
    background: rgba(106,158,255,0.3);
    border: 1px solid rgba(106,158,255,0.5);
    color: #6a9eff;
    border-radius: 50%;
    width: 44px;
    height: 44px;
    cursor: pointer;
    font-size: 20px;
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 6;
    transition: background 0.2s;
    pointer-events: auto;
}
.ge-voice-btn:hover {
    background: rgba(106,158,255,0.5);
}

/* ─── Choices ─── */
.ge-choices {
    position: absolute;
    left: 50%;
    bottom: 210px;
    transform: translateX(-50%);
    display: flex;
    flex-direction: column;
    gap: 12px;
    min-width: 400px;
    max-width: 80%;
    z-index: 10;
}
.ge-choice-prompt {
    background: rgba(10,10,30,0.85);
    border: 1px solid rgba(106,223,255,0.4);
    border-radius: 8px;
    padding: 12px 24px;
    color: #6adfff;
    font-size: 24px;
    font-weight: bold;
    text-align: center;
    margin-bottom: 4px;
}
.ge-choice-btn {
    background: rgba(30,30,60,0.9);
    border: 2px solid #6a9eff;
    color: #e0e0e0;
    padding: 14px 28px;
    border-radius: 8px;
    cursor: pointer;
    font-size: 22px;
    transition: all 0.2s;
    text-align: center;
    pointer-events: auto;
}
.ge-choice-btn:hover:not(:disabled) {
    background: rgba(106,158,255,0.3);
    border-color: #8ab8ff;
    transform: scale(1.02);
}
.ge-choice-btn:disabled { opacity: 0.4; cursor: default; }

/* ─── System Message ─── */
.ge-system-msg {
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    background: rgba(30,30,60,0.85);
    border: 1px solid #4a4a5a;
    border-radius: 8px;
    padding: 16px 28px;
    color: #aaa;
    font-size: 13px;
    text-align: center;
    max-width: 400px;
    white-space: pre-wrap;
    z-index: 10;
}
.ge-system-msg.ge-condition-msg {
    padding: 40px 60px;
    max-width: 80%;
}
.ge-system-msg.ge-condition-msg .ge-sys-type {
    font-size: 42px;
    margin-bottom: 16px;
}
.ge-system-msg.ge-condition-msg .ge-cond-detail {
    font-size: 32px;
    color: #ccc;
    margin-bottom: 20px;
}
.ge-system-msg.ge-condition-msg .ge-cond-test {
    margin-top: 20px;
    display: flex;
    align-items: center;
    gap: 12px;
    justify-content: center;
    flex-wrap: wrap;
}
.ge-system-msg.ge-condition-msg .ge-cond-test label {
    font-size: 24px;
    color: #8ab8ff;
    white-space: nowrap;
}
.ge-system-msg.ge-condition-msg .ge-cond-test input {
    font-size: 24px;
    padding: 8px 14px;
    background: #1e1e2f;
    border: 1px solid #4a4a5a;
    border-radius: 6px;
    color: #eee;
    width: 200px;
    text-align: center;
}
.ge-system-msg.ge-condition-msg .ge-cond-test button {
    font-size: 24px;
    padding: 8px 24px;
    background: #4a7aff;
    color: #fff;
    border: none;
    border-radius: 6px;
    cursor: pointer;
    white-space: nowrap;
}
.ge-system-msg.ge-condition-msg .ge-cond-test button:hover {
    background: #6a9aff;
}
.ge-sys-type { color: #6a9eff; font-weight: bold; margin-bottom: 6px; }

/* ─── Navigation ─── */
.ge-nav {
    position: absolute;
    top: 8px;
    left: 50%;
    transform: translateX(-50%);
    display: flex;
    gap: 8px;
    z-index: 20;
}
.ge-nav-btn {
    background: rgba(255,255,255,0.12);
    border: 1px solid rgba(255,255,255,0.2);
    color: #ccc;
    padding: 4px 14px;
    border-radius: 4px;
    cursor: pointer;
    font-size: 12px;
    transition: all 0.2s;
    pointer-events: auto;
}
.ge-nav-btn:hover:not(:disabled) { background: rgba(255,255,255,0.25); color: #fff; }
.ge-nav-btn:disabled { opacity: 0.3; cursor: default; }
/* AUTO button inside dialog box */
.ge-auto-btn {
    position: absolute;
    top: 8px;
    right: 12px;
    background: rgba(255,255,255,0.1);
    border: 1px solid rgba(255,255,255,0.25);
    color: rgba(255,255,255,0.5);
    padding: 2px 8px;
    border-radius: 4px;
    cursor: pointer;
    font-size: 10px;
    letter-spacing: 1px;
    transition: all 0.2s;
}
.ge-auto-btn:hover { background: rgba(255,255,255,0.2); color: rgba(255,255,255,0.8); }
.ge-auto-btn.ge-auto-active { background: rgba(106,158,255,0.35); border-color: rgba(106,158,255,0.6); color: #6a9eff; }

/* ▼ advance indicator */
.ge-advance-indicator {
    position: absolute;
    bottom: 8px;
    right: 12px;
    color: rgba(255,255,255,0.6);
    font-size: 14px;
    animation: ge-blink 1s ease-in-out infinite;
    pointer-events: none;
}
@keyframes ge-blink {
    0%, 100% { opacity: 1; }
    50% { opacity: 0.3; }
}
