/* ==================== 基础重置 ==================== */
* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

html, body {
    width: 100%;
    height: 100%;
    overflow: hidden;
    font-family: 'Microsoft YaHei', 'PingFang SC', sans-serif;
    background: #000;
    color: #fff;
    user-select: none;
}

#canvas-container {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    z-index: 1;
}

#canvas-container canvas {
    display: block;
    width: 100%;
    height: 100%;
}

/* ==================== 加载画面 ==================== */
#loading-screen {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: linear-gradient(135deg, #1a1a2e 0%, #16213e 50%, #0f3460 100%);
    z-index: 1000;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: opacity 0.8s ease, visibility 0.8s ease;
}

#loading-screen.hidden {
    opacity: 0;
    visibility: hidden;
}

.loading-content {
    text-align: center;
    padding: 40px;
}

.loading-title {
    font-size: 2.5rem;
    font-weight: bold;
    background: linear-gradient(90deg, #e94560, #ff6b6b, #e94560);
    background-size: 200% auto;
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    animation: shimmer 3s linear infinite;
    margin-bottom: 10px;
}

.loading-subtitle {
    font-size: 1.2rem;
    color: #a0a0a0;
    margin-bottom: 40px;
}

.loading-bar {
    width: 300px;
    height: 6px;
    background: rgba(255,255,255,0.1);
    border-radius: 3px;
    margin: 0 auto 20px;
    overflow: hidden;
}

.loading-progress {
    width: 0%;
    height: 100%;
    background: linear-gradient(90deg, #e94560, #ff6b6b);
    border-radius: 3px;
    transition: width 0.3s ease;
    animation: loadingProgress 2s ease-out forwards;
}

.loading-text {
    font-size: 0.9rem;
    color: #888;
    margin-bottom: 15px;
}

.loading-hint {
    font-size: 0.85rem;
    color: #e94560;
    opacity: 0;
    animation: fadeInHint 0.5s ease 2s forwards;
}

@keyframes shimmer {
    0% { background-position: -200% center; }
    100% { background-position: 200% center; }
}

@keyframes loadingProgress {
    0% { width: 0%; }
    50% { width: 70%; }
    100% { width: 100%; }
}

@keyframes fadeInHint {
    to { opacity: 1; }
}

/* ==================== 顶部栏 ==================== */
#top-bar {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    height: 60px;
    background: rgba(0,0,0,0.4);
    backdrop-filter: blur(10px);
    -webkit-backdrop-filter: blur(10px);
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 0 20px;
    z-index: 100;
    border-bottom: 1px solid rgba(255,255,255,0.1);
}

.title-group {
    display: flex;
    align-items: center;
    gap: 12px;
}

.game-title {
    font-size: 1.1rem;
    font-weight: bold;
    background: linear-gradient(90deg, #fff, #e0e0e0);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
}

.game-subtitle {
    font-size: 0.75rem;
    color: #aaa;
}

.version-badge {
    font-size: 0.65rem;
    padding: 2px 8px;
    background: rgba(233, 69, 96, 0.3);
    border: 1px solid rgba(233, 69, 96, 0.5);
    border-radius: 12px;
    color: #e94560;
}

.top-buttons {
    display: flex;
    gap: 10px;
}

.icon-btn {
    width: 36px;
    height: 36px;
    border-radius: 50%;
    border: 1px solid rgba(255,255,255,0.2);
    background: rgba(255,255,255,0.1);
    color: #fff;
    font-size: 1rem;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.3s ease;
}

.icon-btn:hover {
    background: rgba(233, 69, 96, 0.3);
    border-color: rgba(233, 69, 96, 0.5);
    transform: scale(1.1);
}

/* ==================== 面板通用样式 ==================== */
.panel {
    position: fixed;
    background: rgba(0,0,0,0.5);
    backdrop-filter: blur(12px);
    -webkit-backdrop-filter: blur(12px);
    border: 1px solid rgba(255,255,255,0.1);
    border-radius: 12px;
    padding: 15px;
    z-index: 100;
    transition: all 0.3s ease;
}

.panel-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 10px;
    font-size: 0.85rem;
    font-weight: bold;
    color: #ddd;
}

.collapse-btn {
    width: 24px;
    height: 24px;
    border-radius: 50%;
    border: none;
    background: rgba(255,255,255,0.1);
    color: #fff;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1rem;
    line-height: 1;
}

/* ==================== 操作说明 ==================== */
#controls-hint {
    right: 20px;
    top: 80px;
    width: 220px;
}

#controls-hint.collapsed .panel-body {
    display: none;
}

.control-item {
    display: flex;
    align-items: center;
    gap: 10px;
    margin-bottom: 8px;
    font-size: 0.8rem;
    color: #ccc;
}

.control-item kbd {
    padding: 2px 6px;
    background: rgba(255,255,255,0.15);
    border: 1px solid rgba(255,255,255,0.2);
    border-radius: 4px;
    font-size: 0.7rem;
    font-family: inherit;
    white-space: nowrap;
}

.control-item span {
    color: #aaa;
}

/* ==================== 角色信息 ==================== */
#character-info {
    left: 20px;
    top: 80px;
    display: flex;
    align-items: center;
    gap: 12px;
    min-width: 180px;
}

.character-avatar {
    width: 50px;
    height: 50px;
    border-radius: 50%;
    background: linear-gradient(135deg, #4a90e2, #2266aa);
    border: 2px solid rgba(255,255,255,0.3);
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1.5rem;
}

.character-name {
    font-size: 1rem;
    font-weight: bold;
    color: #fff;
}

.character-jpname {
    font-size: 0.75rem;
    color: #aaa;
}

/* ==================== 底部角色栏 ==================== */
#character-bar {
    position: fixed;
    bottom: 20px;
    left: 50%;
    transform: translateX(-50%);
    display: flex;
    gap: 10px;
    background: rgba(0,0,0,0.5);
    backdrop-filter: blur(12px);
    -webkit-backdrop-filter: blur(12px);
    border: 1px solid rgba(255,255,255,0.1);
    border-radius: 16px;
    padding: 10px 15px;
    z-index: 100;
}

.char-btn {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 5px;
    padding: 8px 12px;
    border: 2px solid transparent;
    border-radius: 12px;
    background: rgba(255,255,255,0.05);
    cursor: pointer;
    transition: all 0.3s ease;
    min-width: 60px;
}

.char-btn:hover {
    background: rgba(255,255,255,0.15);
    transform: translateY(-2px);
}

.char-btn.active {
    border-color: #e94560;
    background: rgba(233, 69, 96, 0.2);
}

.char-color {
    width: 32px;
    height: 32px;
    border-radius: 50%;
    border: 2px solid rgba(255,255,255,0.3);
}

.char-btn span {
    font-size: 0.7rem;
    color: #ddd;
    white-space: nowrap;
}

/* ==================== 设置面板 ==================== */
#settings-panel {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0,0,0,0.6);
    backdrop-filter: blur(5px);
    -webkit-backdrop-filter: blur(5px);
    z-index: 200;
    display: flex;
    align-items: center;
    justify-content: center;
    opacity: 0;
    visibility: hidden;
    transition: all 0.3s ease;
}

#settings-panel.open {
    opacity: 1;
    visibility: visible;
}

.modal-content {
    background: linear-gradient(135deg, #1a1a2e, #16213e);
    border: 1px solid rgba(255,255,255,0.15);
    border-radius: 16px;
    width: 380px;
    max-width: 90%;
    box-shadow: 0 20px 60px rgba(0,0,0,0.5);
    transform: translateY(-20px);
    transition: transform 0.3s ease;
}

#settings-panel.open .modal-content {
    transform: translateY(0);
}

.modal-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 20px 25px;
    border-bottom: 1px solid rgba(255,255,255,0.1);
}

.modal-header h2 {
    font-size: 1.2rem;
    font-weight: bold;
    background: linear-gradient(90deg, #fff, #e0e0e0);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
}

.close-btn {
    width: 32px;
    height: 32px;
    border-radius: 50%;
    border: none;
    background: rgba(255,255,255,0.1);
    color: #fff;
    font-size: 1.3rem;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.3s ease;
}

.close-btn:hover {
    background: rgba(233, 69, 96, 0.5);
}

.modal-body {
    padding: 20px 25px;
}

.setting-item {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 20px;
}

.setting-item:last-child {
    margin-bottom: 0;
}

.setting-item label {
    font-size: 0.9rem;
    color: #ddd;
}

.setting-item input[type="range"] {
    width: 120px;
    height: 6px;
    -webkit-appearance: none;
    appearance: none;
    background: rgba(255,255,255,0.15);
    border-radius: 3px;
    outline: none;
}

.setting-item input[type="range"]::-webkit-slider-thumb {
    -webkit-appearance: none;
    width: 16px;
    height: 16px;
    border-radius: 50%;
    background: #e94560;
    cursor: pointer;
    border: 2px solid #fff;
}

.value-display {
    font-size: 0.8rem;
    color: #aaa;
    min-width: 35px;
    text-align: right;
}

/* 切换开关 */
.toggle-switch {
    position: relative;
    width: 50px;
    height: 26px;
}

.toggle-switch input {
    opacity: 0;
    width: 0;
    height: 0;
}

.toggle-slider {
    position: absolute;
    cursor: pointer;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(255,255,255,0.2);
    border-radius: 26px;
    transition: 0.3s;
}

.toggle-slider:before {
    position: absolute;
    content: "";
    height: 20px;
    width: 20px;
    left: 3px;
    bottom: 3px;
    background: #fff;
    border-radius: 50%;
    transition: 0.3s;
}

.toggle-switch input:checked + .toggle-slider {
    background: #e94560;
}

.toggle-switch input:checked + .toggle-slider:before {
    transform: translateX(24px);
}

/* 下拉选择 */
.setting-item select {
    padding: 6px 12px;
    border-radius: 8px;
    border: 1px solid rgba(255,255,255,0.2);
    background: rgba(0,0,0,0.3);
    color: #fff;
    font-size: 0.85rem;
    cursor: pointer;
    outline: none;
}

.setting-item select option {
    background: #1a1a2e;
    color: #fff;
}

.setting-btn {
    padding: 8px 16px;
    border-radius: 8px;
    border: 1px solid rgba(255,255,255,0.2);
    background: rgba(233, 69, 96, 0.2);
    color: #fff;
    font-size: 0.85rem;
    cursor: pointer;
    transition: all 0.3s ease;
}

.setting-btn:hover {
    background: rgba(233, 69, 96, 0.4);
}

/* ==================== 语音气泡 ==================== */
.voice-bubble {
    position: fixed;
    z-index: 150;
    pointer-events: none;
    opacity: 0;
    transition: opacity 0.5s ease;
}

.voice-bubble.show {
    opacity: 1;
}

.bubble-content {
    background: rgba(0,0,0,0.7);
    backdrop-filter: blur(8px);
    border: 1px solid rgba(255,255,255,0.2);
    border-radius: 16px;
    padding: 12px 18px;
    color: #fff;
    font-size: 0.9rem;
    max-width: 250px;
    position: relative;
}

.bubble-content::after {
    content: '';
    position: absolute;
    bottom: -8px;
    left: 50%;
    transform: translateX(-50%);
    width: 0;
    height: 0;
    border-left: 8px solid transparent;
    border-right: 8px solid transparent;
    border-top: 8px solid rgba(0,0,0,0.7);
}

/* ==================== 截图闪光 ==================== */
#screenshot-flash {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: #fff;
    opacity: 0;
    pointer-events: none;
    z-index: 500;
    transition: none;
}

#screenshot-flash.active {
    animation: flash 0.3s ease-out;
}

@keyframes flash {
    0% { opacity: 0.8; }
    100% { opacity: 0; }
}

/* ==================== 底部提示 ==================== */
#bottom-hint {
    position: fixed;
    bottom: 100px;
    left: 50%;
    transform: translateX(-50%);
    font-size: 0.9rem;
    color: rgba(255,255,255,0.6);
    z-index: 100;
    pointer-events: none;
    transition: opacity 0.5s ease;
}

#bottom-hint.hidden {
    opacity: 0;
}

/* ==================== 隐藏UI模式 ==================== */
body.ui-hidden #top-bar,
body.ui-hidden #controls-hint,
body.ui-hidden #character-info,
body.ui-hidden #character-bar,
body.ui-hidden #bottom-hint {
    opacity: 0;
    pointer-events: none;
}

body.ui-hidden #canvas-container {
    z-index: 10;
}

/* ==================== 响应式 ==================== */
@media (max-width: 768px) {
    .loading-title {
        font-size: 1.8rem;
    }

    .game-title {
        font-size: 0.9rem;
    }

    .game-subtitle {
        display: none;
    }

    #controls-hint {
        display: none;
    }

    #character-info {
        top: 70px;
        left: 10px;
        padding: 10px;
    }

    .character-avatar {
        width: 40px;
        height: 40px;
        font-size: 1.2rem;
    }

    .character-name {
        font-size: 0.85rem;
    }

    .character-jpname {
        font-size: 0.65rem;
    }

    #character-bar {
        padding: 8px 10px;
        gap: 6px;
    }

    .char-btn {
        padding: 6px 8px;
        min-width: 50px;
    }

    .char-color {
        width: 28px;
        height: 28px;
    }

    .char-btn span {
        font-size: 0.6rem;
    }
}
