@font-face {
    font-family: 'TigerFont';
    src: url('../ziti/YanZhenQingDuoBaoTaBei-2.ttf') format('truetype');
    font-weight: normal;
    font-style: normal;
}

html, body {
    margin: 0;
    padding: 0;
    width: 100%;
    height: 100%;
    background: #000;
    overflow: hidden;
    font-family: 'TigerFont', "Microsoft YaHei", "SimHei", sans-serif;
}

#game-container {
    width: 100vw;
    height: 100vh;
    display: flex;
    justify-content: center;
    align-items: center;
}

/* 强制 GPU 硬件加速：浏览器会把整个 canvas 作为独立纹理提交给 GPU */
#game-canvas {
    display: block;
    background: #000;
    cursor: default;
    touch-action: none;
    will-change: transform;
    transform: translateZ(0);
}

/* 底部状态栏 —— 纯色，禁用 backdrop-filter */
#bottom-bar {
    position: fixed;
    bottom: 0;
    left: 0;
    right: 0;
    height: 60px;
    background: rgba(41, 42, 45, 0.92);
    color: #eee;
    font-size: 20px;
    font-weight: bold;
    line-height: 60px;
    overflow: hidden;
    z-index: 200;
}

.bar-surface {
    height: 60px;
    display: flex;
    align-items: center;
    transform: translateY(-60px);
    transition: transform .2s;
}
.bar-surface + .bar-surface {
    margin-top: -60px;
}
.bar-surface.current {
    transform: translateY(0);
}
#bar-play:not(.current) {
    transform: translateY(60px);
}

.bar-surface .bar-section {
    display: flex;
    align-items: center;
    gap: 12px;
    flex: 1;
    padding: 0 24px;
}
.bar-surface .bar-left { justify-content: flex-end; }
.bar-surface .bar-center {
    flex: none;
    justify-content: center;
    padding: 0 24px;
}
.bar-surface .current-player {
    display: flex;
    align-items: center;
    flex: none;
    justify-content: center;
    padding: 8px;
}

.turn-coin {
    display: block;
    width: 34px;
    height: 34px;
    position: relative;
    transform-style: preserve-3d;
    transition: transform 0.4s ease;
}
.coin-face {
    position: absolute;
    left: 0; top: 0;
    width: 100%; height: 100%;
    border-radius: 50%;
    backface-visibility: hidden;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 14px;
    box-shadow: 0 3px 6px rgba(0,0,0,0.35);
}
.coin-face.tiger {
    background: radial-gradient(circle at 35% 35%, #555, #111);
    color: #fff;
    border: 3px solid #333;
}
.coin-face.fox {
    background: radial-gradient(circle at 35% 35%, #fff, #ddd);
    color: #111;
    border: 3px solid #bbb;
    transform: rotateY(180deg);
}
.turn-coin.fox-turn {
    transform: rotateY(180deg);
}

.alt-text {
    width: 100%;
    text-align: center;
    color: #aaa;
    font-size: 15px;
}

#bottom-bar .stat-badge {
    display: inline-block;
    min-width: 14px;
    height: 28px;
    border-radius: 14px;
    padding: 0 10px;
    background: #000;
    line-height: 28px;
    text-align: center;
    opacity: 0.7;
    font-size: 14px;
    transition: opacity .2s;
}

/* AI 思考指示器 */
.ai-thinking-wrap {
    display: none;
    align-items: center;
    gap: 6px;
}

.ai-thinking-spinner {
    width: 20px;
    height: 20px;
    border: 2px solid rgba(255, 215, 0, 0.25);
    border-top-color: #ffd700;
    border-radius: 50%;
    animation: ai-thinking-spin 0.8s linear infinite;
    flex-shrink: 0;
}

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

.ai-thinking-text {
    color: #ffd700;
    font-size: 13px;
    letter-spacing: 1px;
    white-space: nowrap;
}

/* 状态说明按钮：常驻右侧中间，不贴边 */
#btn-guide-status {
    margin-left: auto;
    margin-right: auto;
    font-size: 12px;
    padding: 4px 10px;
    border-radius: 16px;
}

/* 顶部菜单栏 —— 纯色，禁用 backdrop-filter */
#top-menu {
    position: fixed;
    top: 0; left: 0; right: 0;
    height: 48px;
    background: rgba(30, 30, 30, 0.92);
    color: #ccc;
    font-size: 16px;
    line-height: 48px;
    user-select: none;
    -webkit-user-select: none;
    z-index: 200;
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Ubuntu, Roboto, Helvetica, Arial, sans-serif;
}

.menu-bar {
    display: flex;
    list-style: none;
    margin: 0;
    padding: 0 8px;
    height: 100%;
    align-items: center;
}

.menu-item {
    position: relative;
    padding: 0 10px;
    height: 100%;
    display: flex;
    align-items: center;
    cursor: default;
    white-space: nowrap;
}
.menu-item:hover, .menu-item.active {
    background: #3c3c3c;
    color: #fff;
}

.submenu {
    display: none;
    position: absolute;
    top: 100%; left: 0;
    min-width: 220px;
    background: #1e1e1e;
    border: 1px solid #3c3c3c;
    list-style: none;
    margin: 0;
    padding: 4px 0;
    box-shadow: 0 4px 12px rgba(0,0,0,0.5);
}
.menu-item.active > .submenu { display: block; }

.menu-row {
    position: relative;
    padding: 4px 24px;
    cursor: default;
    white-space: nowrap;
    display: flex;
    align-items: center;
    gap: 6px;
}
.menu-row:hover, .menu-row.active {
    background: #094771;
    color: #fff;
}
.menu-row.disabled {
    opacity: 0.4;
    pointer-events: none;
}

.separator {
    height: 1px;
    background: #3c3c3c;
    margin: 4px 0;
    list-style: none;
}

.menu-row.has-submenu::after {
    content: '▶';
    position: absolute;
    right: 10px;
    font-size: 10px;
    opacity: 0.6;
}
.menu-row.has-submenu:hover::after { opacity: 1; }

.menu-row.has-submenu {
    padding-right: 28px;
}
.menu-row.has-submenu > .submenu {
    display: none;
    position: absolute;
    top: -5px;
    left: 100%;
    min-width: 180px;
}
.menu-row.has-submenu.active > .submenu { display: block; }

.menu-row.checkbox { padding-left: 8px; }

.menu-row.checkbox input[type="checkbox"] {
    -webkit-appearance: none;
    appearance: none;
    width: 14px; height: 14px;
    border: 1px solid #888;
    background: transparent;
    margin: 0;
    flex-shrink: 0;
    cursor: default;
    display: grid;
    place-content: center;
}
.menu-row.checkbox input[type="checkbox"]:checked {
    background: #094771;
    border-color: #094771;
}
.menu-row.checkbox input[type="checkbox"]:checked::before {
    content: '';
    width: 8px; height: 4px;
    border-left: 2px solid #fff;
    border-bottom: 2px solid #fff;
    transform: rotate(-45deg) translate(1px, -1px);
    display: block;
}
.menu-row.checkbox label {
    cursor: default;
    flex: 1;
}

/* 引擎侧边栏 —— 纯色，禁用 backdrop-filter */
#engine-sidebar {
    position: fixed;
    top: 48px; left: 0; bottom: 60px;
    width: 320px;
    background: #111;
    color: #ccc;
    border-right: 1px solid #333;
    transform: translateX(-100%);
    transition: transform 0.3s ease;
    z-index: 99;
    display: flex;
    flex-direction: column;
    box-shadow: 4px 0 20px rgba(0,0,0,0.5);
}
#engine-sidebar.open { transform: translateX(0); }

.engine-sidebar-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 12px 16px;
    border-bottom: 1px solid #333;
    flex-shrink: 0;
    background: #1e1e1e;
}
.engine-sidebar-title {
    font-size: 14px;
    color: #fff;
    letter-spacing: 1px;
}
.engine-sidebar-close-btn {
    background: transparent;
    border: none;
    color: #888;
    font-size: 20px;
    cursor: pointer;
    width: 28px; height: 28px;
    line-height: 28px;
    text-align: center;
    border-radius: 4px;
    transition: color .2s, background .2s;
}
.engine-sidebar-close-btn:hover {
    color: #fff;
    background: rgba(255,255,255,0.1);
}

.engine-sidebar-body {
    flex: 1;
    display: flex;
    flex-direction: column;
    overflow: hidden;
}

.console-output {
    flex: 1;
    overflow-y: auto;
    padding: 12px;
    font-family: Consolas, Menlo, Monaco, 'Ubuntu Mono', monospace;
    font-size: 12px;
    line-height: 1.5;
    color: #ddd;
    background: #111;
}
.console-output .entry {
    margin-bottom: 6px;
    word-break: break-all;
}
.console-output .entry.command { color: #7ee787; }
.console-output .entry.response { color: #d1d5db; }
.console-output .entry.error { color: #f75644; }

.console-input-wrap {
    flex-shrink: 0;
    padding: 8px 12px;
    border-top: 1px solid #333;
    background: #1e1e1e;
}
.console-input-wrap input {
    width: 100%;
    box-sizing: border-box;
    background: #111;
    border: 1px solid #444;
    color: #eee;
    padding: 6px 10px;
    font-family: Consolas, Menlo, Monaco, 'Ubuntu Mono', monospace;
    font-size: 12px;
    outline: none;
}
.console-input-wrap input:focus { border-color: #555; }

/* 右上角悬浮工具栏 */
#top-right-toolbar {
    position: fixed;
    top: clamp(56px, 6vh, 84px);
    right: clamp(12px, 1.5vw, 28px);
    z-index: 150;
    display: flex;
    flex-wrap: wrap;
    justify-content: flex-end;
    gap: clamp(8px, 1vw, 14px);
    max-width: min(420px, 22vw);
    padding: clamp(12px, 1.2vw, 20px) clamp(14px, 1.5vw, 24px);
    background: rgba(30, 30, 30, 0.92);
    border-radius: 24px;
    border: 1px solid rgba(255,255,255,0.1);
    box-shadow: 0 8px 32px rgba(0,0,0,0.4);
}

.toolbar-btn {
    padding: clamp(12px, 1.5vw, 20px) clamp(18px, 2vw, 32px);
    background: rgba(255,255,255,0.08);
    border: 1px solid rgba(255,255,255,0.12);
    border-radius: 24px;
    color: #ddd;
    font-family: inherit;
    font-size: clamp(15px, 1.4vw, 22px);
    letter-spacing: 1px;
    cursor: pointer;
    transition: background .2s, border-color .2s, color .2s;
    white-space: nowrap;
    min-height: clamp(44px, 4vh, 60px);
    display: inline-flex;
    align-items: center;
    justify-content: center;
    line-height: 1.2;
}
.toolbar-btn:hover {
    background: rgba(255,255,255,0.18);
    border-color: rgba(255,255,255,0.3);
    color: #fff;
}
.toolbar-btn:active {
    background: rgba(255,255,255,0.25);
}

#btn-restart {
    position: fixed;
    bottom: 72px;
    left: 50%;
    transform: translateX(-50%);
    z-index: 150;
    background: rgba(255,255,255,0.5);
    border-color: rgba(255,255,255,0.6);
    color: #111;
}
#btn-restart:hover {
    background: rgba(255,255,255,0.7);
    border-color: rgba(255,255,255,0.85);
    color: #111;
}

/* 教程系统 */
#tutorial-system {
    position: fixed;
    top: 0; left: 0; right: 0; bottom: 0;
    z-index: 1000;
    pointer-events: none;
}
#tutorial-system.active { pointer-events: none; }

.tutorial-qipao {
    position: absolute;
    background-image: url('../assets/img/qipao_long.png');
    background-size: 100% 100%;
    background-repeat: no-repeat;
    z-index: 1002;
    pointer-events: auto;
    display: none;
    box-sizing: border-box;
}
.tutorial-qipao.show { display: block; }

#tutorial-ask {
    top: 50%; left: 50%;
    transform: translate(-50%, -50%);
    width: 460px; height: 280px;
    padding: 50px 60px;
}
#tutorial-bubble {
    width: 400px; height: 240px;
    padding: 50px 55px;
}

.tutorial-qipao-inner {
    width: 100%; height: 100%;
    display: flex;
    flex-direction: column;
    justify-content: space-between;
}
.tutorial-content {
    flex: 1;
    display: flex;
    align-items: center;
    justify-content: center;
    text-align: center;
}
.tutorial-buttons, .tutorial-nav {
    display: flex;
    gap: 20px;
    justify-content: center;
    padding-top: 8px;
}
.tutorial-nav { display: none; }

.tutorial-btn {
    background: rgba(0,0,0,0.35);
    border: 1px solid rgba(255,255,255,0.45);
    color: #fff;
    font-family: 'TigerFont', "Microsoft YaHei", sans-serif;
    font-size: 15px;
    padding: 7px 28px;
    cursor: pointer;
    border-radius: 4px;
    transition: all .2s;
    letter-spacing: 2px;
}
.tutorial-btn:hover {
    background: rgba(255,255,255,0.15);
    border-color: rgba(255,255,255,0.8);
}
.tutorial-btn:disabled {
    opacity: 0.25;
    cursor: not-allowed;
}

.tutorial-mask-bar {
    position: fixed;
    background: rgba(0,0,0,0.78);
    z-index: 1001;
    pointer-events: none;
}

.tutorial-highlight {
    outline: 3px solid #ffd700 !important;
    outline-offset: 4px;
    box-shadow: 0 0 0 5px rgba(255,215,0,0.25), 0 0 40px rgba(255,215,0,0.35);
    animation: tutorial-pulse 2.2s ease-in-out infinite;
}
@keyframes tutorial-pulse {
    0%, 100% {
        box-shadow: 0 0 0 5px rgba(255,215,0,0.25), 0 0 40px rgba(255,215,0,0.35);
    }
    50% {
        box-shadow: 0 0 0 12px rgba(255,215,0,0.1), 0 0 60px rgba(255,215,0,0.55);
    }
}

#tutorial-control-bar {
    position: fixed;
    bottom: 56px;
    left: 50%;
    transform: translateX(-50%);
    z-index: 1002;
    display: none;
    align-items: center;
    gap: 24px;
    background: rgba(0,0,0,0.55);
    padding: 8px 28px;
    border-radius: 24px;
    border: 1px solid rgba(255,255,255,0.1);
}
#tutorial-control-bar.show { display: none; }

.tutorial-dots { display: flex; gap: 7px; }
.tutorial-dot {
    width: 8px; height: 8px;
    border-radius: 50%;
    background: rgba(255,255,255,0.2);
    transition: background .2s;
}
.tutorial-dot.active { background: #ffd700; }

.tutorial-chapter-name {
    color: rgba(255,255,255,0.85);
    font-size: 13px;
    white-space: nowrap;
    letter-spacing: 1px;
}

/* AI 聊天面板（女生正上方） */
#chat-panel {
    position: fixed;
    top: 340px;
    right: clamp(12px, 1.5vw, 28px);
    width: min(420px, 22vw);
    padding: clamp(12px, 1.2vw, 20px) clamp(14px, 1.5vw, 24px);
    display: flex;
    flex-direction: column;
    gap: 6px;
    z-index: 250;
    background: transparent;
    border: 1px solid transparent;
    box-shadow: none;
}

#chat-history {
    height: 220px;
    overflow-y: auto;
    background: rgba(30, 30, 30, 0.92);
    border: 1px solid rgba(255,255,255,0.15);
    border-radius: 12px;
    padding: 10px 12px;
    font-family: 'TigerFont', "Microsoft YaHei", sans-serif;
    font-size: 14px;
    color: #eee;
    line-height: 1.5;
    width: 100%;
    box-sizing: border-box;
}

.chat-entry {
    margin-bottom: 6px;
    word-break: break-all;
}

.chat-entry.user {
    color: #4fc3f7;
}

.chat-entry.user::before {
    content: '你: ';
    font-weight: bold;
}

.chat-entry.ai {
    color: #f0e6d3;
}

.chat-entry.ai::before {
    content: '绣妹: ';
    font-weight: bold;
    color: #ffd700;
}

#chat-input-row {
    display: flex;
    align-items: center;
    gap: 8px;
    background: rgba(30, 30, 30, 0.92);
    border: 1px solid rgba(255,255,255,0.15);
    border-radius: 24px;
    padding: 8px 14px;
    width: 100%;
    box-sizing: border-box;
}

#chat-input {
    background: transparent;
    border: none;
    color: #eee;
    font-family: 'TigerFont', "Microsoft YaHei", sans-serif;
    font-size: 15px;
    outline: none;
    flex: 1;
    letter-spacing: 1px;
}

#chat-input::placeholder {
    color: rgba(255,255,255,0.35);
}

#chat-send-btn {
    background: rgba(255,255,255,0.12);
    border: 1px solid rgba(255,255,255,0.2);
    border-radius: 16px;
    color: #ddd;
    font-family: 'TigerFont', "Microsoft YaHei", sans-serif;
    font-size: 13px;
    padding: 6px 14px;
    cursor: pointer;
    transition: background .2s;
    white-space: nowrap;
    letter-spacing: 2px;
}

#chat-send-btn:hover {
    background: rgba(255,255,255,0.25);
    color: #fff;
}

/* ==================== 分散式导览按钮 ==================== */

.guide-btn-inline {
    padding: 6px 14px;
    background: rgba(255, 255, 255, 0.5);
    border: 1px solid rgba(255, 255, 255, 0.6);
    border-radius: 20px;
    color: #111;
    font-family: 'TigerFont', "Microsoft YaHei", sans-serif;
    font-size: 13px;
    letter-spacing: 1px;
    cursor: pointer;
    transition: all 0.2s;
    white-space: nowrap;
}

.guide-btn-inline:hover {
    background: rgba(255, 255, 255, 0.7);
    border-color: rgba(255, 255, 255, 0.85);
    color: #111;
    transform: scale(1.08);
}

/* 底部中央：全部导览 + 对战教程 */
#btn-guide-all {
    position: fixed;
    bottom: 72px;
    left: calc(50% - 180px);
    transform: translateX(-50%);
    z-index: 150;
}

#btn-guide-battle {
    position: fixed;
    bottom: 72px;
    left: calc(50% + 180px);
    transform: translateX(-50%);
    z-index: 150;
}

/* 聊天面板：聊天教程 */
#btn-guide-chat {
    position: fixed;
    top: 700px;
    right: clamp(12px, 1.5vw, 28px);
    z-index: 251;
}

/* 引擎侧边栏标题栏：引擎教程 */
#btn-guide-engine {
    font-size: 12px;
    padding: 4px 10px;
    border-radius: 16px;
}

/* ==================== 全景标注导览（GuideOverlay） ==================== */

.guide-overlay {
    position: fixed;
    top: 0; left: 0; right: 0; bottom: 0;
    z-index: 3000;
    pointer-events: none;
}

.guide-backdrop {
    position: absolute;
    top: 0; left: 0; right: 0; bottom: 0;
    background: rgba(0, 0, 0, 0.42);
    pointer-events: auto;
}

.guide-hint-text {
    position: fixed;
    bottom: 90px;
    left: 50%;
    transform: translateX(-50%);
    color: rgba(255, 255, 255, 0.65);
    font-size: 16px;
    font-family: 'TigerFont', "Microsoft YaHei", sans-serif;
    letter-spacing: 3px;
    pointer-events: none;
    z-index: 3003;
    white-space: nowrap;
}

.guide-highlight {
    position: absolute;
    border: 2px solid rgba(255, 215, 0, 0.65);
    border-radius: 10px;
    background: rgba(255, 215, 0, 0.04);
    box-shadow: 0 0 24px rgba(255, 215, 0, 0.18), inset 0 0 30px rgba(255, 215, 0, 0.06);
    pointer-events: none;
    z-index: 3001;
    animation: guide-pulse 2.4s ease-in-out infinite;
}

@keyframes guide-pulse {
    0%, 100% { opacity: 0.75; border-color: rgba(255, 215, 0, 0.55); }
    50%      { opacity: 1;   border-color: rgba(255, 215, 0, 0.9); }
}

.guide-card {
    position: absolute;
    background: rgba(30, 30, 30, 0.96);
    border: 2px solid #ffd700;
    border-radius: 14px;
    padding: 16px 20px;
    min-width: 210px;
    max-width: 280px;
    color: #fff;
    box-shadow: 0 8px 32px rgba(0,0,0,0.55), 0 0 0 1px rgba(255,215,0,0.08);
    pointer-events: auto;
    opacity: 0;
    transform: translateY(14px) scale(0.96);
    transition: all 0.45s cubic-bezier(0.25, 0.8, 0.25, 1);
    z-index: 3002;
    font-family: 'TigerFont', "Microsoft YaHei", sans-serif;
}

.guide-card.show {
    opacity: 1;
    transform: translateY(0) scale(1);
}

.guide-card::after {
    content: '';
    position: absolute;
    width: 0;
    height: 0;
    border: 10px solid transparent;
}

.guide-card[data-placement="bottom"]::after {
    top: -20px;
    left: 50%;
    margin-left: -10px;
    border-bottom-color: #ffd700;
}
.guide-card[data-placement="top"]::after {
    bottom: -20px;
    left: 50%;
    margin-left: -10px;
    border-top-color: #ffd700;
}
.guide-card[data-placement="left"]::after {
    right: -20px;
    top: 50%;
    margin-top: -10px;
    border-left-color: #ffd700;
}
.guide-card[data-placement="right"]::after {
    left: -20px;
    top: 50%;
    margin-top: -10px;
    border-right-color: #ffd700;
}

.guide-step-badge {
    position: absolute;
    top: -14px;
    left: -14px;
    width: 30px;
    height: 30px;
    background: #ffd700;
    color: #1a1a1a;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-weight: bold;
    font-size: 15px;
    border: 3px solid rgba(30,30,30,0.96);
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
}

.guide-title {
    font-size: 19px;
    font-weight: bold;
    margin-bottom: 7px;
    color: #ffd700;
    letter-spacing: 2px;
}

.guide-desc {
    font-size: 14px;
    color: #ccc;
    line-height: 1.55;
    letter-spacing: 1px;
}

.guide-overlay.fade-out {
    transition: opacity 0.35s ease;
    opacity: 0;
}
.guide-overlay.fade-out .guide-card,
.guide-overlay.fade-out .guide-highlight {
    transition: opacity 0.25s ease;
    opacity: 0 !important;
}