* { margin: 0; padding: 0; box-sizing: border-box; }

body {
    background: #1a1a2e;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    min-height: 100vh;
    font-family: "Microsoft YaHei", "PingFang SC", Arial, sans-serif;
    overflow: hidden;
}

#game-container {
    position: relative;
    display: flex;
    flex-direction: column;
    align-items: center;
}

#center-area {
    display: flex;
    flex-direction: column;
    align-items: center;
}

canvas {
    display: block;
    cursor: crosshair;
    border-radius: 6px;
    max-width: 100vw;
    max-height: calc(100vh - 60px);
    touch-action: none;
    -webkit-touch-callout: none;
    -webkit-user-select: none;
    user-select: none;
}

#title {
    color: #FFD700;
    font-size: 24px;
    font-weight: bold;
    margin-bottom: 6px;
    text-shadow: 0 2px 12px rgba(255,215,0,0.5), 0 0 30px rgba(255,215,0,0.2);
    letter-spacing: 4px;
    transition: color 0.4s ease, text-shadow 0.4s ease, font-size 0.3s ease;
}

#restart-btn {
    margin-top: 10px;
    padding: 8px 28px;
    background: #4CAF50;
    color: #fff;
    border: none;
    border-radius: 6px;
    font-size: 15px;
    font-weight: bold;
    cursor: pointer;
    font-family: inherit;
    transition: background 0.2s;
    display: none;
}
#restart-btn:hover { background: #45a049; }

/* ========== 调试面板样式 ========== */
#debug-panel {
    position: fixed;
    top: 20px;
    right: 20px;
    background: rgba(20, 20, 40, 0.95);
    border: 2px solid #FFD700;
    border-radius: 12px;
    padding: 16px;
    min-width: 280px;
    max-height: calc(100vh - 40px);
    overflow-y: auto;
    z-index: 9999;
    box-shadow: 0 8px 32px rgba(0,0,0,0.5);
    font-family: "Microsoft YaHei", Arial, sans-serif;
}

.debug-header {
    color: #FFD700;
    font-size: 16px;
    font-weight: bold;
    margin-bottom: 12px;
    padding-bottom: 8px;
    border-bottom: 1px solid rgba(255,215,0,0.3);
}

.debug-section {
    margin-bottom: 12px;
}

.debug-section label {
    display: block;
    color: #ccc;
    font-size: 12px;
    margin-bottom: 4px;
}

.debug-section input[type="number"] {
    width: 80px;
    padding: 6px 10px;
    border: 1px solid #555;
    border-radius: 4px;
    background: #2a2a3e;
    color: #fff;
    font-size: 14px;
    margin-right: 8px;
}

.debug-section input[type="number"]:focus {
    outline: none;
    border-color: #FFD700;
}

.debug-section button {
    padding: 6px 14px;
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    color: #fff;
    border: none;
    border-radius: 4px;
    font-size: 13px;
    cursor: pointer;
    transition: transform 0.1s, box-shadow 0.2s;
}

/* 调试面板滚动条 */
#debug-panel::-webkit-scrollbar {
    width: 6px;
}
#debug-panel::-webkit-scrollbar-track {
    background: transparent;
}
#debug-panel::-webkit-scrollbar-thumb {
    background: rgba(255,215,0,0.3);
    border-radius: 3px;
}
#debug-panel::-webkit-scrollbar-thumb:hover {
    background: rgba(255,215,0,0.6);
}

.debug-section button:hover {
    transform: translateY(-1px);
    box-shadow: 0 4px 12px rgba(102, 126, 234, 0.4);
}

.debug-section button:active {
    transform: translateY(0);
}

#debug-close {
    background: linear-gradient(135deg, #eb3349 0%, #f45c43 100%);
}

#debug-close:hover {
    box-shadow: 0 4px 12px rgba(235, 51, 73, 0.4);
}

/* ========== 移动端横屏提示 ========== */
#rotate-hint {
    display: none;
    position: fixed;
    top: 0;
    left: 0;
    width: 100vw;
    height: 100vh;
    background: #1a1a2e;
    z-index: 99999;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    color: #FFD700;
}

#rotate-hint .rotate-icon {
    font-size: 80px;
    animation: rotate-anim 2s infinite;
}

#rotate-hint .rotate-text {
    font-size: 20px;
    margin-top: 20px;
}

@keyframes rotate-anim {
    0%, 100% { transform: rotate(0deg); }
    50% { transform: rotate(90deg); }
}

/* 竖屏时显示提示 */
@media screen and (orientation: portrait) and (max-width: 768px) {
    #rotate-hint {
        display: flex;
    }
    #game-container {
        display: none;
    }
}

/* 移动端横屏优化 */
@media screen and (orientation: landscape) and (max-height: 500px) {
    body {
        min-height: 100vh;
        padding: 0;
    }
    #title {
        font-size: 16px;
        margin-bottom: 2px;
    }
    canvas {
        max-height: calc(100vh - 80px);
    }
}

/* ========== 移动端侧边栏（竖向） ========== */
.side-bar {
    display: none;  /* 默认隐藏 */
    flex-direction: column;
    align-items: center;
    justify-content: center;
    width: 44px;
    padding: 8px 3px;
    background: linear-gradient(180deg, rgba(30,30,50,0.95) 0%, rgba(20,20,35,0.98) 100%);
    border: 1px solid rgba(255,215,0,0.15);
    border-radius: 6px;
    touch-action: none;
    box-shadow: 0 2px 12px rgba(0,0,0,0.5), inset 0 1px 0 rgba(255,255,255,0.05);
    height: 50vh;  /* 缩短高度 */
    max-height: 320px;
}

/* 角度条稍宽 */
#mobile-angle-bar {
    width: 48px;
}

.side-bar-label {
    color: #FFD700;
    font-size: 10px;
    font-weight: bold;
    writing-mode: horizontal-tb;
    margin-bottom: 4px;
    text-shadow: 0 1px 3px rgba(255,215,0,0.3);
    letter-spacing: 1px;
}

.side-bar-track {
    position: relative;
    width: 22px;
    flex: 1;
    min-height: 200px;  /* 增加最小高度 */
    max-height: 80vh;   /* 允许更长 */
    background: linear-gradient(180deg, #1a1a2e 0%, #0d0d1a 100%);
    border-radius: 11px;
    border: 1px solid rgba(255,255,255,0.1);
    overflow: hidden;
    box-shadow: inset 0 2px 6px rgba(0,0,0,0.6), 0 1px 0 rgba(255,255,255,0.05);
}

/* 角度条轨道稍宽 */
#mobile-angle-bar .side-bar-track {
    width: 28px;
}

/* 力度填充（从底部往上，渐变发光） */
.side-bar-fill {
    position: absolute;
    bottom: 0;
    left: 0;
    width: 100%;
    height: 0%;
    background: linear-gradient(0deg, 
        #4CAF50 0%, 
        #8BC34A 30%, 
        #FFC107 60%, 
        #FF9800 80%, 
        #FF5722 100%);
    border-radius: 0 0 10px 10px;
    transition: height 0.05s;
    box-shadow: 0 -2px 8px rgba(255,152,0,0.4);
}

/* 角度指示器（游标样式） */
.side-bar-indicator {
    position: absolute;
    left: -2px;
    width: calc(100% + 4px);
    height: 8px;
    top: 50%;
    background: linear-gradient(180deg, #FFE87C 0%, #FFD700 40%, #DAA520 100%);
    border-radius: 4px;
    box-shadow: 0 0 10px rgba(255,215,0,0.6), 0 2px 4px rgba(0,0,0,0.4), inset 0 1px 0 rgba(255,255,255,0.5);
    transition: top 0.05s;
    border: 1px solid rgba(139,119,42,0.6);
}

/* 角度刻度尺样式 */
.angle-ruler {
    background: linear-gradient(180deg, #1a1a2e 0%, #0d0d1a 100%) !important;
    overflow: visible !important;
}

/* 刻度线 */
.angle-ruler .tick {
    position: absolute;
    left: 0;
    width: 100%;
    height: 1px;
    background: rgba(255,255,255,0.15);
}
.angle-ruler .tick.major {
    height: 2px;
    background: rgba(255,215,0,0.4);
}
.angle-ruler .tick.center {
    height: 2px;
    background: rgba(255,255,255,0.5);
}

/* 角度游标指示器（三角箭头） */
.angle-cursor {
    position: absolute;
    left: -6px;
    width: calc(100% + 12px);
    height: 14px;
    top: 50%;
    transform: translateY(-50%);
    background: transparent;
    border: none;
    box-shadow: none;
    border-radius: 0;
}
/* 游标左侧三角 */
.angle-cursor::before {
    content: '';
    position: absolute;
    left: 0;
    top: 50%;
    transform: translateY(-50%);
    width: 0;
    height: 0;
    border-top: 6px solid transparent;
    border-bottom: 6px solid transparent;
    border-left: 8px solid #FFD700;
    filter: drop-shadow(0 0 4px rgba(255,215,0,0.8));
}
/* 游标右侧三角 */
.angle-cursor::after {
    content: '';
    position: absolute;
    right: 0;
    top: 50%;
    transform: translateY(-50%);
    width: 0;
    height: 0;
    border-top: 6px solid transparent;
    border-bottom: 6px solid transparent;
    border-right: 8px solid #FFD700;
    filter: drop-shadow(0 0 4px rgba(255,215,0,0.8));
}

.side-bar-hint {
    color: #888;
    font-size: 8px;
    margin-top: 3px;
    text-align: center;
    white-space: nowrap;
}

/* 移动端横屏时显示侧边栏 - 紧贴木纹球桌边框 */
@media screen and (max-width: 1024px), screen and (pointer: coarse) {
    body {
        padding: 0;
        margin: 0;
    }
    #game-container {
        position: relative;
        flex-direction: row;
        align-items: stretch;
        gap: 0;
        padding: 0;
        width: 100vw;
        height: 100vh;
        overflow: hidden;
    }
    /* 侧边栏绝对定位，叠在画布上 */
    .side-bar {
        position: absolute;
        z-index: 100;
        top: 50%;
        transform: translateY(-50%);
        display: flex;
    }
    /* 左侧角度条：紧贴球桌左侧 */
    #mobile-angle-bar {
        left: 1%;  /* 更靠近球桌 */
    }
    /* 右侧力度条：紧贴球桌右侧 */
    #mobile-power-bar {
        right: 1%;  /* 更靠近球桌 */
    }
    #center-area {
        flex: 1;
        display: flex;
        flex-direction: column;
        align-items: center;
        justify-content: center;
        min-width: 0;
        overflow: hidden;
        width: 100%;
    }
    #title {
        position: absolute;
        top: 4px;
        left: 50%;
        transform: translateX(-50%);
        font-size: 12px;
        margin: 0;
        padding: 2px 8px;
        line-height: 1;
        background: rgba(0,0,0,0.5);
        border-radius: 10px;
        z-index: 50;
    }
    canvas {
        max-width: 100%;
        max-height: 100vh;
        width: 100%;
        height: auto;
        object-fit: contain;
    }
}

