/* ============================================================
   样式文件：style.css
   所有样式集中管理，按功能模块分区
   ============================================================ */

/* ========== 1. 全局样式 ========== */
* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
    font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;
}

body {
    background: linear-gradient(135deg, #1a2a6c, #b21f1f, #fdbb2d);
    color: #fff;
    min-height: 100vh;
    padding: 20px;
}

a {
    color: #8ab4f8;
    text-decoration: none;
}
a:hover {
    text-decoration: underline;
}

/* ========== 2. 布局容器 ========== */
.container {
    max-width: 1200px;
    margin: 0 auto;
    padding: 20px;
}

/* ========== 3. 头部 ========== */
header {
    text-align: center;
    margin-bottom: 40px;
    padding: 20px;
    background: rgba(0, 0, 0, 0.3);
    border-radius: 15px;
    box-shadow: 0 10px 30px rgba(0, 0, 0, 0.3);
}
header h1 {
    font-size: 2.8rem;
    margin-bottom: 10px;
    text-shadow: 2px 2px 4px rgba(0, 0, 0, 0.5);
}
.subtitle {
    font-size: 1.2rem;
    opacity: 0.9;
}

/* ========== 4. 状态栏 ========== */
.status-bar {
    display: flex;
    flex-wrap: wrap;
    justify-content: space-between;
    align-items: center;
    gap: 12px;
    background: rgba(0, 0, 0, 0.4);
    padding: 15px 25px;
    border-radius: 10px;
    margin-bottom: 30px;
}
.connection-status {
    display: flex;
    align-items: center;
    gap: 10px;
}
.status-indicator {
    width: 15px;
    height: 15px;
    border-radius: 50%;
    background: #ff4757;
    transition: background 0.3s;
}
.status-indicator.connected {
    background: #2ed573;
}
.gamepad-selector {
    display: flex;
    align-items: center;
    gap: 15px;
    flex-wrap: wrap;
}
.selector-label {
    font-size: 0.9rem;
    opacity: 0.8;
}
.gamepad-dropdown {
    background: rgba(255, 255, 255, 0.1);
    border: 1px solid rgba(255, 255, 255, 0.3);
    color: #fff;
    padding: 8px 15px;
    border-radius: 5px;
    min-width: 200px;
    cursor: pointer;
}
.gamepad-dropdown option {
    background: #2c3e50;
    color: #fff;
}

/* ========== 5. 主体网格 ========== */
.main-content {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 30px;
}

@media (max-width: 900px) {
    .main-content {
        grid-template-columns: 1fr;
    }
}

/* ========== 6. 控制器可视化面板 ========== */
.controller-display {
    background: rgba(0, 0, 0, 0.4);
    border-radius: 15px;
    padding: 25px;
    box-shadow: 0 10px 25px rgba(0, 0, 0, 0.3);
}
.controller-title {
    text-align: center;
    margin-bottom: 20px;
    font-size: 1.5rem;
}

/* ========== 7. 手柄本体 ========== */
.controller {
    position: relative;
    width: 100%;
    height: 540px;
    background: #2c3e50;
    border-radius: 50px;
    margin: 0 auto;
    box-shadow: inset 0 0 20px rgba(0, 0, 0, 0.5);
    overflow: hidden;
}

/* ---- 左区域 ---- */
.left-section {
    position: absolute;
    left: 70px;
    top: calc(50% + 60px);
    transform: translateY(-50%);
    display: flex;
    flex-direction: column;
    gap: 50px;
}

/* ---- 右区域 ---- */
.right-section {
    position: absolute;
    right: 50px;
    top: calc(50% + 50px);
    transform: translateY(-50%);
    display: flex;
    flex-direction: column;
    gap: 50px;
    align-items: center;
}

/* ---- 中央区域 ---- */
.center-section {
    position: absolute;
    left: calc(50% - 10px);
    top: calc(50% + 40px);
    transform: translate(-50%, -50%);
    display: flex;
    flex-direction: column;
    gap: 15px;
    align-items: center;
}

/* ========== 8. 摇杆 ========== */
.joystick-left,
.joystick-right {
    width: 100px;
    height: 100px;
    background: #34495e;
    border-radius: 50%;
    display: flex;
    justify-content: center;
    align-items: center;
    position: relative;
    box-shadow: inset 0 -4px 8px rgba(0, 0, 0, 0.4);
}
.joystick-inner {
    width: 40px;
    height: 40px;
    background: #e74c3c;
    border-radius: 50%;
    transition: transform 0.05s linear;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.3);
    will-change: transform;
}

/* ---- L3 / R3 按钮（摇杆中心） ---- */
.button-l3,
.button-r3 {
    position: absolute;
    width: 30px;
    height: 30px;
    background: #95a5a6;
    border-radius: 50%;
    display: flex;
    justify-content: center;
    align-items: center;
    font-size: 0.7rem;
    color: #ecf0f1;
    z-index: 10;
    box-shadow: 0 3px 0 rgba(0, 0, 0, 0.3);
    transition: all 0.1s;
    user-select: none;
    pointer-events: none;
}
.button-l3.pressed,
.button-r3.pressed {
    transform: translateY(2px);
    box-shadow: 0 1px 0 rgba(0, 0, 0, 0.3);
    background: #3498db;
}

/* ========== 9. 方向键 (D-Pad) ========== */
.dpad {
    width: 100px;
    height: 100px;
    display: grid;
    grid-template-areas:
        ". up ."
        "left center right"
        ". down .";
    gap: 5px;
}
.dpad-button {
    width: 30px;
    height: 30px;
    background: #34495e;
    display: flex;
    justify-content: center;
    align-items: center;
    font-size: 0.9rem;
    font-weight: bold;
    color: #bdc3c7;
    user-select: none;
    transition: background 0.1s;
    border-radius: 4px;
}
.dpad-up {
    grid-area: up;
    border-radius: 5px 5px 0 0;
}
.dpad-down {
    grid-area: down;
    border-radius: 0 0 5px 5px;
}
.dpad-left {
    grid-area: left;
    border-radius: 5px 0 0 5px;
}
.dpad-right {
    grid-area: right;
    border-radius: 0 5px 5px 0;
}
.dpad-center {
    grid-area: center;
    background: #2c3e50;
    border-radius: 4px;
}
.dpad-button.pressed {
    background: #3498db;
    color: #fff;
}

/* ========== 10. ABXY 按钮 ========== */
.buttons-abxy {
    position: relative;
    width: 180px;
    height: 180px;
}
.button-abxy {
    width: 55px;
    height: 55px;
    border-radius: 50%;
    display: flex;
    justify-content: center;
    align-items: center;
    font-weight: bold;
    font-size: 1.1rem;
    box-shadow: 0 5px 0 rgba(0, 0, 0, 0.3);
    transition: all 0.08s;
    position: absolute;
    user-select: none;
    color: #fff;
}
.button-a {
    background: #2ecc71;
    bottom: 15px;
    left: 50%;
    transform: translateX(-50%);
}
.button-b {
    background: #e74c3c;
    top: 50%;
    right: 15px;
    transform: translateY(-50%);
}
.button-x {
    background: #3498db;
    top: 50%;
    left: 15px;
    transform: translateY(-50%);
}
.button-y {
    background: #f1c40f;
    top: 15px;
    left: 50%;
    transform: translateX(-50%);
}
.button-abxy.pressed {
    transform: translateY(2px);
    box-shadow: 0 3px 0 rgba(0, 0, 0, 0.3);
    filter: brightness(1.3);
}
/* 修正 A / Y 的 transform 覆盖 */
.button-a.pressed {
    transform: translateX(-50%) translateY(2px);
}
.button-y.pressed {
    transform: translateX(-50%) translateY(2px);
}
.button-x.pressed {
    transform: translateY(-50%) translateY(2px);
}
.button-b.pressed {
    transform: translateY(-50%) translateY(2px);
}

/* ========== 11. 肩键 / 扳机 ========== */
.shoulder-buttons {
    position: absolute;
    top: 35px;
    left: 0;
    right: 0;
    display: flex;
    justify-content: space-between;
    padding: 0 90px;
    pointer-events: none;
}
.shoulder-group {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 10px;
    pointer-events: none;
}
.shoulder-label {
    font-size: 0.8rem;
    opacity: 0.8;
    text-align: center;
}
.trigger {
    width: 70px;
    height: 25px;
    background: #34495e;
    border-radius: 10px 10px 0 0;
    transition: background 0.1s, opacity 0.1s;
    opacity: 0.5;
}
.trigger.pressed {
    background: #9b59b6;
    opacity: 1;
}
.bumper {
    width: 70px;
    height: 20px;
    background: #34495e;
    border-radius: 5px;
    transition: background 0.1s;
}
.bumper.pressed {
    background: #9b59b6;
}

/* ========== 12. Start / Select 按钮 ========== */
.start-button,
.select-button {
    width: 40px;
    height: 20px;
    background: #7f8c8d;
    border-radius: 10px;
    display: flex;
    justify-content: center;
    align-items: center;
    font-size: 0.65rem;
    color: #ecf0f1;
    transition: background 0.1s;
    user-select: none;
}
.start-button.pressed,
.select-button.pressed {
    background: #3498db;
}

/* ========== 13. 数据面板 ========== */
.data-panel {
    background: rgba(0, 0, 0, 0.4);
    border-radius: 15px;
    padding: 25px;
    box-shadow: 0 10px 25px rgba(0, 0, 0, 0.3);
}
.panel-title {
    text-align: center;
    margin-bottom: 20px;
    font-size: 1.5rem;
}

/* ---- 手柄列表 ---- */
.gamepad-list {
    display: flex;
    flex-direction: column;
    gap: 12px;
    margin-bottom: 20px;
    max-height: 260px;
    overflow-y: auto;
}
.gamepad-list::-webkit-scrollbar {
    width: 5px;
}
.gamepad-list::-webkit-scrollbar-track {
    background: rgba(255, 255, 255, 0.05);
    border-radius: 4px;
}
.gamepad-list::-webkit-scrollbar-thumb {
    background: rgba(255, 255, 255, 0.2);
    border-radius: 4px;
}
.gamepad-item {
    background: rgba(255, 255, 255, 0.07);
    padding: 14px 18px;
    border-radius: 10px;
    cursor: pointer;
    transition: all 0.25s ease;
    border: 2px solid transparent;
}
.gamepad-item:hover {
    background: rgba(255, 255, 255, 0.13);
    transform: translateY(-2px);
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.2);
}
.gamepad-item.active {
    background: rgba(52, 152, 219, 0.25);
    border-color: #3498db;
    box-shadow: 0 4px 15px rgba(52, 152, 219, 0.25);
}
.gamepad-name {
    font-weight: bold;
    font-size: 1.05rem;
    margin-bottom: 4px;
    color: #ecf0f1;
    word-break: break-all;
}
.gamepad-index {
    font-size: 0.8rem;
    opacity: 0.75;
    display: flex;
    flex-wrap: wrap;
    gap: 15px;
}
.gamepad-status {
    display: flex;
    align-items: center;
    gap: 8px;
    margin-top: 6px;
}
.status-dot {
    width: 8px;
    height: 8px;
    border-radius: 50%;
    background: #2ed573;
}
.status-text {
    font-size: 0.8rem;
    opacity: 0.85;
}

/* ---- 数据网格 ---- */
.data-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 12px;
    margin-top: 15px;
}
.data-item {
    background: rgba(255, 255, 255, 0.08);
    padding: 12px 14px;
    border-radius: 8px;
    transition: background 0.2s;
}
.data-item:hover {
    background: rgba(255, 255, 255, 0.13);
}
.data-label {
    font-size: 0.8rem;
    opacity: 0.75;
    margin-bottom: 4px;
}
.data-value {
    font-size: 1.15rem;
    font-weight: bold;
    font-variant-numeric: tabular-nums;
}

/* ========== 14. 震动测试按钮 ========== */
.vibration-test {
    margin-top: 20px;
    text-align: center;
}
.vibration-button {
    background: #9b59b6;
    border: none;
    color: #fff;
    padding: 12px 28px;
    border-radius: 8px;
    font-size: 1rem;
    cursor: pointer;
    transition: background 0.25s, transform 0.15s;
}
.vibration-button:hover {
    background: #8e44ad;
    transform: scale(1.02);
}
.vibration-button:active {
    transform: scale(0.97);
}

/* ========== 15. 使用说明 ========== */
.instructions {
    background: rgba(0, 0, 0, 0.4);
    border-radius: 15px;
    padding: 25px 30px;
    margin-top: 30px;
    box-shadow: 0 10px 25px rgba(0, 0, 0, 0.3);
}
.instructions h2 {
    margin-bottom: 15px;
    text-align: center;
}
.instructions ol {
    margin-left: 20px;
    line-height: 1.8;
}
.instructions li {
    margin-bottom: 6px;
}

/* ========== 16. 页脚 ========== */
footer {
    text-align: center;
    margin-top: 40px;
    padding: 20px;
    opacity: 0.8;
    font-size: 0.9rem;
    line-height: 1.8;
}

/* ========== 17. 不兼容提示 ========== */
.no-support {
    text-align: center;
    padding: 40px 20px;
    background: rgba(255, 0, 0, 0.2);
    border-radius: 10px;
    margin-top: 20px;
}
.no-support h2 {
    margin-bottom: 12px;
}

/* ========== 18. 工具类 & 微调 ========== */
.text-center {
    text-align: center;
}
.mt-10 {
    margin-top: 10px;
}
.mb-10 {
    margin-bottom: 10px;
}
.op-8 {
    opacity: 0.8;
}

/* 滚动条美化（全局） */
::-webkit-scrollbar {
    width: 6px;
    height: 6px;
}
::-webkit-scrollbar-track {
    background: rgba(255, 255, 255, 0.05);
    border-radius: 4px;
}
::-webkit-scrollbar-thumb {
    background: rgba(255, 255, 255, 0.2);
    border-radius: 4px;
}
::-webkit-scrollbar-thumb:hover {
    background: rgba(255, 255, 255, 0.3);
}

/* ========== 响应式微调 ========== */
@media (max-width: 700px) {
    header h1 {
        font-size: 2rem;
    }
    .controller {
        height: 440px;
        border-radius: 30px;
    }
    .left-section {
        left: 30px;
        gap: 30px;
        top: calc(50% + 40px);
    }
    .right-section {
        right: 20px;
        gap: 30px;
        top: calc(50% + 30px);
    }
    .joystick-left,
    .joystick-right {
        width: 70px;
        height: 70px;
    }
    .joystick-inner {
        width: 30px;
        height: 30px;
    }
    .button-l3,
    .button-r3 {
        width: 22px;
        height: 22px;
        font-size: 0.5rem;
    }
    .dpad {
        width: 70px;
        height: 70px;
        gap: 4px;
    }
    .dpad-button {
        width: 22px;
        height: 22px;
        font-size: 0.7rem;
    }
    .buttons-abxy {
        width: 140px;
        height: 140px;
    }
    .button-abxy {
        width: 44px;
        height: 44px;
        font-size: 0.9rem;
    }
    .shoulder-buttons {
        padding: 0 40px;
        top: 20px;
    }
    .trigger {
        width: 50px;
        height: 18px;
    }
    .bumper {
        width: 50px;
        height: 16px;
    }
    .center-section {
        top: calc(50% + 30px);
        gap: 10px;
    }
    .start-button,
    .select-button {
        width: 32px;
        height: 16px;
        font-size: 0.5rem;
    }
    .data-grid {
        grid-template-columns: 1fr;
    }
    .status-bar {
        flex-direction: column;
        align-items: stretch;
    }
    .gamepad-selector {
        justify-content: center;
    }
    .gamepad-dropdown {
        min-width: 140px;
    }
}

@media (max-width: 480px) {
    .controller {
        height: 360px;
        border-radius: 20px;
    }
    .left-section {
        left: 15px;
        gap: 20px;
        top: calc(50% + 30px);
    }
    .right-section {
        right: 10px;
        gap: 20px;
        top: calc(50% + 20px);
    }
    .joystick-left,
    .joystick-right {
        width: 55px;
        height: 55px;
    }
    .joystick-inner {
        width: 22px;
        height: 22px;
    }
    .button-l3,
    .button-r3 {
        width: 18px;
        height: 18px;
        font-size: 0.4rem;
    }
    .dpad {
        width: 55px;
        height: 55px;
        gap: 3px;
    }
    .dpad-button {
        width: 18px;
        height: 18px;
        font-size: 0.5rem;
    }
    .buttons-abxy {
        width: 110px;
        height: 110px;
    }
    .button-abxy {
        width: 34px;
        height: 34px;
        font-size: 0.7rem;
    }
    .shoulder-buttons {
        padding: 0 20px;
        top: 12px;
    }
    .trigger {
        width: 40px;
        height: 14px;
    }
    .bumper {
        width: 40px;
        height: 12px;
    }
    .shoulder-label {
        font-size: 0.6rem;
    }
    .center-section {
        top: calc(50% + 20px);
        gap: 6px;
    }
    .start-button,
    .select-button {
        width: 26px;
        height: 14px;
        font-size: 0.4rem;
    }
    .controller-title {
        font-size: 1.1rem;
    }
    header h1 {
        font-size: 1.5rem;
    }
    .container {
        padding: 10px;
    }
}
