/* 保倍游戏厅 - 电脑键盘提示、调速与触屏按键自定义系统样式 */

/* 页面底色统一深色，避免竖屏下画布下方出现刺眼浅色底导致按键对比度不足 */
html,
body {
    background-color: #0d1117;
}

/* 解除原版暂停按钮隐藏，使其在设置中可用 */
.nes-pause {
    display: inline-block !important;
}

/* 保证顶部“设置”按钮不被遮挡且易于点击 */
.nes-show {
    z-index: 950 !important;
}

/* =========================================================
   触屏虚拟按键容器与控件样式升级（解决遮挡、贴边与新增连击键）
   ========================================================= */
#joystickContent {
    position: fixed !important;
    top: 0 !important;
    left: 0 !important;
    right: 0 !important;
    bottom: 0 !important;
    width: 100% !important;
    height: 100% !important;
    height: 100dvh !important;
    z-index: 60 !important; /* 高于 #emulator(5)，低于 .nes-intro(999) 和 HUD(1000) */
    pointer-events: none !important; /* 容器透明穿透，不阻挡画面其他区域点击 */
    background: transparent !important;
    overflow: hidden !important;
    user-select: none !important;
    -webkit-user-select: none !important;
    -webkit-touch-callout: none !important;
}

/* 触屏子控件统一交互基础 */
#joystickContent .fc-touch-item,
#joystickContent .ctrl-select,
#joystickContent .ctrl-start,
#joystickContent .ctrl-btnA,
#joystickContent .ctrl-btnB,
#joystickContent .ctrl-btnAB,
#joystickContent .ctrl-btnAA,
#joystickContent .ctrl-btnBB,
#joystickContent .ctrl-btnAABB {
    position: absolute !important;
    pointer-events: auto !important;
    touch-action: none !important;
    user-select: none !important;
    -webkit-user-select: none !important;
    -webkit-touch-callout: none !important;
    box-sizing: border-box !important;
    margin: 0 !important;
    transition: transform 0.06s ease, box-shadow 0.12s ease;
}

/* 方向摇杆外层包裹器 */
#joystickContent .fc-touch-joystick {
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: 50%;
}

#joystickContent #joystickCanvas {
    display: block !important;
    width: 100% !important;
    height: 100% !important;
    pointer-events: auto !important;
    touch-action: none !important;
}

/* Start / Select 功能键美化 */
#joystickContent .ctrl-select,
#joystickContent .ctrl-start {
    display: flex !important;
    align-items: center !important;
    justify-content: center !important;
    padding: 0 !important;
    text-align: center !important;
    font-weight: 700 !important;
    letter-spacing: 0.5px;
    border-radius: 14px !important;
    box-shadow: 0 3px 8px rgba(0, 0, 0, 0.45), inset 0 1px 1px rgba(255, 255, 255, 0.25);
    border: 1px solid rgba(255, 255, 255, 0.28) !important;
}

/* A / B / AB 圆形动作按钮 */
#joystickContent .ctrl-btnA,
#joystickContent .ctrl-btnB,
#joystickContent .ctrl-btnAB {
    display: flex !important;
    align-items: center !important;
    justify-content: center !important;
    background: url(ctrl/img/button.png) no-repeat center center !important;
    background-size: 100% 100% !important;
    border-radius: 50% !important;
    box-shadow: 0 4px 10px rgba(0, 0, 0, 0.55), inset 0 1px 2px rgba(255, 255, 255, 0.35) !important;
    color: #fff !important;
    font-weight: 800 !important;
    text-shadow: 0 1px 3px rgba(0, 0, 0, 0.85);
    line-height: 1 !important;
}

/* 新增连击模式按键（连A / 连B / 连AB） */
#joystickContent .ctrl-btnAA,
#joystickContent .ctrl-btnBB,
#joystickContent .ctrl-btnAABB {
    display: flex !important;
    align-items: center !important;
    justify-content: center !important;
    background: radial-gradient(circle at 32% 30%, rgba(246, 173, 85, 0.95), rgba(221, 107, 32, 0.92) 65%, rgba(156, 66, 33, 0.95) 100%) !important;
    border: 2px solid rgba(254, 235, 200, 0.75) !important;
    box-shadow: 0 4px 10px rgba(0, 0, 0, 0.5), inset 0 2px 3px rgba(255, 255, 255, 0.35) !important;
    border-radius: 50% !important;
    color: #fffaf0 !important;
    font-weight: 800 !important;
    text-shadow: 0 1px 3px rgba(0, 0, 0, 0.85);
    line-height: 1.1 !important;
    text-align: center !important;
}

/* 按下时的视觉反馈（普通按下与连击高频闪烁） */
#joystickContent .fc-touch-item.is-pressed {
    transform: scale(0.91) !important;
    filter: brightness(1.28) !important;
}

#joystickContent .ctrl-btnAA.is-pressed,
#joystickContent .ctrl-btnBB.is-pressed,
#joystickContent .ctrl-btnAABB.is-pressed {
    box-shadow: 0 0 16px rgba(246, 173, 85, 0.95), inset 0 0 8px rgba(255, 255, 255, 0.6) !important;
    border-color: #fff !important;
}

/* =========================================================
   触屏按键可视化布局编辑模式样式
   ========================================================= */
body.fc-touch-editing #joystickContent {
    z-index: 1800 !important;
    opacity: 1 !important;
    background:
        linear-gradient(rgba(77, 166, 255, 0.07) 1px, transparent 1px),
        linear-gradient(90deg, rgba(77, 166, 255, 0.07) 1px, transparent 1px),
        rgba(10, 14, 22, 0.35) !important;
    background-size: 25px 25px, 25px 25px, 100% 100% !important;
}

body.fc-touch-editing .nes-intro {
    opacity: 0.12 !important;
    pointer-events: none !important;
}

body.fc-touch-editing #joystickContent .fc-touch-item {
    outline: 2px dashed rgba(99, 179, 237, 0.85) !important;
    outline-offset: 2px !important;
    cursor: move !important;
    box-shadow: 0 0 12px rgba(0, 0, 0, 0.65) !important;
}

body.fc-touch-editing #joystickContent .fc-touch-item.is-selected {
    outline: 3px solid #ffd54f !important;
    outline-offset: 3px !important;
    box-shadow: 0 0 20px rgba(255, 213, 79, 0.85), 0 0 6px rgba(255, 255, 255, 0.9) !important;
    z-index: 1850 !important;
}

/* 编辑模式下的浮动控制面板 */
#fc-touch-editor-panel {
    position: fixed;
    left: 50%;
    top: 8px;
    transform: translateX(-50%);
    width: calc(100vw - 16px);
    max-width: 460px;
    background: rgba(20, 26, 38, 0.94);
    backdrop-filter: blur(10px);
    -webkit-backdrop-filter: blur(10px);
    border: 1px solid rgba(99, 179, 237, 0.45);
    border-radius: 12px;
    padding: 10px 12px;
    color: #edf2f7;
    z-index: 2100;
    box-shadow: 0 10px 30px rgba(0, 0, 0, 0.65);
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "PingFang SC", "Microsoft YaHei", sans-serif;
    font-size: 12px;
    user-select: none;
    -webkit-user-select: none;
    box-sizing: border-box;
}

#fc-touch-editor-panel.is-docked-bottom {
    top: auto;
    bottom: 10px;
}

.fc-te-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    border-bottom: 1px solid rgba(255, 255, 255, 0.12);
    padding-bottom: 6px;
    margin-bottom: 8px;
    gap: 6px;
}

.fc-te-title {
    font-weight: 700;
    font-size: 13px;
    color: #ffd54f;
    display: flex;
    align-items: center;
    gap: 4px;
    white-space: nowrap;
}

.fc-te-header-actions {
    display: flex;
    align-items: center;
    gap: 5px;
}

.fc-te-btn {
    background: rgba(255, 255, 255, 0.12);
    border: 1px solid rgba(255, 255, 255, 0.22);
    color: #e2e8f0;
    border-radius: 5px;
    padding: 4px 8px;
    font-size: 11px;
    font-weight: 600;
    cursor: pointer;
    white-space: nowrap;
}

.fc-te-btn:active,
.fc-te-btn:hover {
    background: rgba(255, 255, 255, 0.24);
}

.fc-te-btn-primary {
    background: #3182ce;
    border-color: #63b3ed;
    color: #fff;
}

.fc-te-btn-danger {
    background: rgba(229, 62, 62, 0.2);
    border-color: rgba(252, 129, 129, 0.45);
    color: #feb2b2;
}

/* 控件选择与显隐胶囊列表 */
.fc-te-section-label {
    font-size: 11px;
    color: #a0aec0;
    margin-bottom: 4px;
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.fc-te-chips {
    display: flex;
    flex-wrap: wrap;
    gap: 5px;
    margin-bottom: 8px;
}

.fc-te-chip {
    background: #283144;
    border: 1px solid #4a5568;
    color: #cbd5e0;
    border-radius: 6px;
    padding: 3px 7px;
    font-size: 11px;
    font-weight: 600;
    cursor: pointer;
    display: inline-flex;
    align-items: center;
    gap: 3px;
}

.fc-te-chip.is-selected {
    background: #2b4c7e;
    border-color: #ffd54f;
    color: #ffd54f;
    box-shadow: 0 0 6px rgba(255, 213, 79, 0.4);
}

.fc-te-chip.is-hidden {
    opacity: 0.5;
    background: #1a202c;
    border-style: dashed;
    text-decoration: line-through;
}

/* 选中控件属性调节行 */
.fc-te-control-box {
    background: rgba(0, 0, 0, 0.3);
    border: 1px solid rgba(255, 255, 255, 0.1);
    border-radius: 8px;
    padding: 7px 9px;
    margin-bottom: 7px;
}

.fc-te-row {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 6px;
    margin-bottom: 6px;
}

.fc-te-row:last-child {
    margin-bottom: 0;
}

.fc-te-selected-name {
    font-weight: 700;
    color: #63b3ed;
    font-size: 12px;
}

.fc-te-slider-wrap {
    display: flex;
    align-items: center;
    gap: 6px;
    flex: 1;
}

.fc-te-slider {
    flex: 1;
    height: 6px;
    accent-color: #4da6ff;
    cursor: pointer;
}

.fc-te-val-badge {
    min-width: 40px;
    text-align: center;
    font-weight: 700;
    color: #ffd54f;
    font-size: 11px;
    background: rgba(255, 255, 255, 0.08);
    padding: 2px 5px;
    border-radius: 4px;
}

/* =========================================================
   按键提示浮层 HUD
   ========================================================= */
#fc-hud-container {
    position: fixed;
    top: 40px;
    right: 8px;
    z-index: 1000;
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "PingFang SC", "Microsoft YaHei", sans-serif;
    user-select: none;
    -webkit-user-select: none;
    pointer-events: auto;
}

.fc-hud-collapsed-bar {
    display: flex;
    align-items: center;
    gap: 6px;
}

/* 展开的 HUD 卡片 */
.fc-hud-box {
    background: rgba(20, 24, 33, 0.90);
    backdrop-filter: blur(8px);
    -webkit-backdrop-filter: blur(8px);
    border: 1px solid rgba(255, 255, 255, 0.18);
    border-radius: 8px;
    padding: 10px 12px;
    color: #f0f0f0;
    box-shadow: 0 8px 24px rgba(0, 0, 0, 0.45);
    max-width: 320px;
    font-size: 13px;
    line-height: 1.4;
    transition: opacity 0.2s ease, transform 0.2s ease;
}

.fc-hud-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    border-bottom: 1px solid rgba(255, 255, 255, 0.15);
    padding-bottom: 6px;
    margin-bottom: 8px;
}

.fc-hud-title {
    font-weight: 600;
    font-size: 13px;
    color: #4da6ff;
    display: flex;
    align-items: center;
    gap: 4px;
}

.fc-hud-header-btns {
    display: flex;
    gap: 5px;
}

.fc-hud-btn-mini {
    background: rgba(255, 255, 255, 0.12);
    border: 1px solid rgba(255, 255, 255, 0.2);
    color: #e0e0e0;
    border-radius: 4px;
    padding: 2px 7px;
    font-size: 11px;
    cursor: pointer;
    transition: all 0.15s ease;
}

.fc-hud-btn-mini:hover {
    background: rgba(255, 255, 255, 0.25);
    color: #fff;
    border-color: rgba(255, 255, 255, 0.4);
}

.fc-hud-btn-mini.is-touch-btn {
    background: rgba(237, 137, 54, 0.22);
    border-color: rgba(246, 173, 85, 0.5);
    color: #fbd38d;
}

.fc-hud-btn-mini:focus {
    outline: 2px solid #4da6ff;
    outline-offset: 1px;
}

/* 调速与运行状态控制栏 */
.fc-hud-speed-bar {
    display: flex;
    align-items: center;
    justify-content: space-between;
    background: rgba(0, 0, 0, 0.35);
    border: 1px solid rgba(255, 255, 255, 0.1);
    border-radius: 6px;
    padding: 5px 8px;
    margin-bottom: 8px;
    gap: 6px;
}

.fc-speed-label-group {
    display: flex;
    align-items: center;
    gap: 5px;
    white-space: nowrap;
    flex-shrink: 0;
}

.fc-speed-text {
    font-size: 12px;
    color: #cbd5e0;
    white-space: nowrap;
}

.fc-speed-badge {
    background: #2b3545;
    border: 1px solid #4a5a78;
    color: #63b3ed;
    font-weight: bold;
    font-size: 12px;
    padding: 1px 6px;
    border-radius: 4px;
    min-width: 36px;
    text-align: center;
    white-space: nowrap;
}

.fc-speed-badge.is-modified {
    color: #ecc94b;
    border-color: #d69e2e;
}

.fc-speed-actions {
    display: flex;
    align-items: center;
    gap: 4px;
    white-space: nowrap;
    flex-shrink: 0;
}

.fc-btn-speed {
    background: rgba(255, 255, 255, 0.12);
    border: 1px solid rgba(255, 255, 255, 0.2);
    color: #f7fafc;
    border-radius: 4px;
    padding: 2px 6px;
    font-size: 11px;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.12s ease;
    white-space: nowrap;
}

.fc-btn-speed:hover:not(:disabled) {
    background: rgba(255, 255, 255, 0.25);
    border-color: rgba(255, 255, 255, 0.4);
}

.fc-btn-speed:disabled {
    opacity: 0.35;
    cursor: not-allowed;
}

.fc-btn-speed:focus {
    outline: 2px solid #4da6ff;
    outline-offset: 1px;
}

.fc-btn-pause {
    background: rgba(49, 130, 206, 0.25);
    border-color: rgba(49, 130, 206, 0.5);
    color: #90cdf4;
}

.fc-btn-pause.is-paused {
    background: rgba(229, 62, 62, 0.3);
    border-color: rgba(229, 62, 62, 0.6);
    color: #feb2b2;
}

/* 调速快捷键与静音提示 */
.fc-speed-notes {
    font-size: 11px;
    color: #a0aec0;
    margin-bottom: 8px;
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 0 2px;
}

.fc-speed-keys {
    display: flex;
    gap: 6px;
    font-size: 11px;
}

.fc-speed-mute-tag {
    color: #ed8936;
    font-size: 11px;
    font-weight: 500;
    display: none;
}

.fc-speed-mute-tag.is-active {
    display: inline-block;
}

/* 键位网格展示 */
.fc-hud-grid {
    display: grid;
    grid-template-columns: repeat(2, 1fr);
    gap: 6px 10px;
    margin-bottom: 8px;
}

.fc-hud-item {
    display: flex;
    align-items: center;
    justify-content: space-between;
    font-size: 12px;
    background: rgba(0, 0, 0, 0.25);
    padding: 3px 6px;
    border-radius: 4px;
}

.fc-hud-label {
    color: #bbb;
}

.fc-hud-key {
    background: #2b3545;
    border: 1px solid #485b73;
    color: #ffeb3b;
    font-weight: bold;
    font-size: 11px;
    padding: 1px 6px;
    border-radius: 3px;
    box-shadow: 0 1px 2px rgba(0, 0, 0, 0.3);
    min-width: 18px;
    text-align: center;
}

.fc-hud-item-wide {
    grid-column: span 2;
}

/* A+B 提示说明 */
.fc-hud-note {
    font-size: 11px;
    color: #aaa;
    border-top: 1px solid rgba(255, 255, 255, 0.1);
    padding-top: 6px;
    display: flex;
    flex-direction: column;
    gap: 3px;
}

.fc-hud-note-line {
    display: flex;
    align-items: center;
    gap: 4px;
}

.fc-hud-note-tag {
    color: #81c784;
    font-weight: 600;
}

/* 收起后的紧凑小胶囊 */
.fc-hud-toggle-btn {
    background: rgba(20, 24, 33, 0.88);
    border: 1px solid rgba(77, 166, 255, 0.4);
    color: #4da6ff;
    border-radius: 20px;
    padding: 5px 10px;
    font-size: 12px;
    font-weight: 500;
    cursor: pointer;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.35);
    display: flex;
    align-items: center;
    gap: 4px;
    transition: all 0.2s ease;
    backdrop-filter: blur(6px);
    -webkit-backdrop-filter: blur(6px);
}

.fc-hud-toggle-btn.is-touch-layout-btn {
    border-color: rgba(246, 173, 85, 0.55);
    color: #fbd38d;
}

.fc-hud-toggle-btn:hover {
    background: rgba(30, 40, 58, 0.95);
    color: #fff;
    border-color: #4da6ff;
    box-shadow: 0 4px 16px rgba(77, 166, 255, 0.4);
}

.fc-hud-toggle-btn:focus {
    outline: 2px solid #4da6ff;
    outline-offset: 2px;
}

/* 自定义按键设置弹窗 Modal */
.fc-modal-overlay {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    width: 100%;
    height: 100%;
    height: 100dvh;
    background: rgba(0, 0, 0, 0.7);
    backdrop-filter: blur(4px);
    -webkit-backdrop-filter: blur(4px);
    z-index: 2000;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 15px;
    box-sizing: border-box;
}

.fc-modal-card {
    background: #1a202c;
    border: 1px solid rgba(255, 255, 255, 0.2);
    border-radius: 10px;
    width: 100%;
    max-width: 480px;
    box-shadow: 0 16px 36px rgba(0, 0, 0, 0.6);
    color: #e2e8f0;
    display: flex;
    flex-direction: column;
    overflow: hidden;
    animation: fcModalFadeIn 0.2s ease-out;
}

@keyframes fcModalFadeIn {
    from {
        opacity: 0;
        transform: scale(0.95);
    }
    to {
        opacity: 1;
        transform: scale(1);
    }
}

.fc-modal-header {
    background: #2d3748;
    padding: 12px 16px;
    display: flex;
    justify-content: space-between;
    align-items: center;
    border-bottom: 1px solid rgba(255, 255, 255, 0.1);
}

.fc-modal-header h3 {
    margin: 0;
    font-size: 16px;
    font-weight: 600;
    color: #f7fafc;
}

.fc-modal-close-btn {
    background: transparent;
    border: none;
    color: #a0aec0;
    font-size: 20px;
    cursor: pointer;
    padding: 0 4px;
    line-height: 1;
}

.fc-modal-close-btn:hover {
    color: #fff;
}

.fc-modal-body {
    padding: 16px;
    max-height: 70vh;
    overflow-y: auto;
}

.fc-modal-tip {
    font-size: 12px;
    color: #a0aec0;
    margin-bottom: 12px;
    background: rgba(0, 0, 0, 0.25);
    padding: 6px 10px;
    border-radius: 4px;
    border-left: 3px solid #4da6ff;
    line-height: 1.5;
}

.fc-modal-conflict-tip {
    font-size: 12px;
    color: #fc8181;
    background: rgba(229, 62, 62, 0.15);
    border: 1px solid rgba(229, 62, 62, 0.4);
    padding: 6px 10px;
    border-radius: 4px;
    margin-bottom: 12px;
    display: none;
}

.fc-binding-list {
    display: flex;
    flex-direction: column;
    gap: 7px;
}

.fc-binding-row {
    display: flex;
    align-items: center;
    justify-content: space-between;
    background: #242c3d;
    padding: 7px 12px;
    border-radius: 6px;
    border: 1px solid rgba(255, 255, 255, 0.08);
}

.fc-binding-row:hover {
    background: #2b3548;
}

.fc-binding-info {
    display: flex;
    align-items: center;
    gap: 8px;
}

.fc-binding-name {
    font-weight: 500;
    font-size: 13px;
    color: #e2e8f0;
}

.fc-binding-btn-group {
    display: flex;
    align-items: center;
    gap: 6px;
}

.fc-binding-key-btn {
    background: #323d52;
    border: 1px solid #4a5a78;
    color: #ffd54f;
    font-weight: 600;
    font-size: 12px;
    padding: 4px 10px;
    border-radius: 4px;
    cursor: pointer;
    min-width: 85px;
    text-align: center;
    transition: all 0.15s ease;
}

.fc-binding-key-btn:hover {
    background: #3e4c66;
    border-color: #63b3ed;
}

.fc-binding-key-btn:focus {
    outline: 2px solid #4da6ff;
    outline-offset: 1px;
}

.fc-binding-key-btn.is-recording {
    background: #b7791f;
    border-color: #ecc94b;
    color: #fff;
    animation: fcBlinkPulse 1.2s infinite;
}

.fc-binding-key-btn.is-empty {
    color: #a0aec0;
    font-style: italic;
    background: #2a3447;
}

.fc-binding-unbind-btn {
    background: rgba(255, 255, 255, 0.08);
    border: 1px solid rgba(255, 255, 255, 0.15);
    color: #a0aec0;
    border-radius: 4px;
    padding: 3px 6px;
    font-size: 11px;
    cursor: pointer;
}

.fc-binding-unbind-btn:hover {
    background: rgba(229, 62, 62, 0.2);
    color: #fc8181;
    border-color: rgba(229, 62, 62, 0.4);
}

@keyframes fcBlinkPulse {
    0%, 100% { opacity: 1; }
    50% { opacity: 0.6; }
}

.fc-modal-footer {
    background: #2d3748;
    padding: 12px 16px;
    display: flex;
    justify-content: space-between;
    align-items: center;
    border-top: 1px solid rgba(255, 255, 255, 0.1);
}

.fc-modal-footer-right {
    display: flex;
    gap: 8px;
}

.fc-btn {
    padding: 6px 14px;
    font-size: 13px;
    border-radius: 5px;
    cursor: pointer;
    font-weight: 500;
    transition: all 0.15s ease;
    border: 1px solid transparent;
}

.fc-btn:focus {
    outline: 2px solid #4da6ff;
    outline-offset: 1px;
}

.fc-btn-primary {
    background: #3182ce;
    color: #fff;
}

.fc-btn-primary:hover {
    background: #2b6cb0;
}

.fc-btn-secondary {
    background: #4a5568;
    color: #e2e8f0;
}

.fc-btn-secondary:hover {
    background: #718096;
}

.fc-btn-danger {
    background: rgba(229, 62, 62, 0.15);
    border-color: rgba(229, 62, 62, 0.4);
    color: #fc8181;
}

.fc-btn-danger:hover {
    background: rgba(229, 62, 62, 0.3);
    color: #fff;
}

/* 窄屏与手机响应式适配 */
@media (max-width: 768px) {
    #fc-hud-container {
        top: 6px;
        right: 60px;
    }

    .fc-hud-box {
        max-width: 285px;
        padding: 8px 10px;
    }

    .fc-hud-speed-bar {
        flex-wrap: wrap;
        gap: 6px;
        padding: 6px 8px;
    }

    .fc-speed-label-group {
        width: 100%;
        justify-content: space-between;
    }

    .fc-speed-actions {
        width: 100%;
        justify-content: flex-end;
    }

    .fc-hud-grid {
        grid-template-columns: 1fr 1fr;
        gap: 4px 6px;
    }

    .fc-modal-card {
        max-width: 95vw;
    }
}
