/* ===== 基础重置与像素风 ===== */
* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
    image-rendering: pixelated;
    image-rendering: crisp-edges;
}

html, body {
    width: 100%;
    height: 100%;
    overflow: hidden;
    background: #1a1a2e;
    font-family: 'Courier New', monospace;
    -webkit-font-smoothing: none;
}

/* ===== 游戏容器 ===== */
#game-container {
    width: 100%;
    height: 100%;
    position: relative;
    overflow: hidden;
}

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

/* ===== 加载画面 ===== */
#loading-screen {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: #0f0f1a;
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 9999;
    transition: opacity 0.5s;
}

#loading-screen.hidden {
    opacity: 0;
    pointer-events: none;
}

.loading-content {
    text-align: center;
}

.loading-pixel {
    color: #00ff88;
    font-size: 24px;
    margin-bottom: 20px;
    animation: blink 1s step-end infinite;
}

.loading-bar {
    width: 200px;
    height: 20px;
    border: 2px solid #00ff88;
    background: #1a1a2e;
}

.loading-fill {
    height: 100%;
    background: #00ff88;
    animation: loadProgress 2s ease-out forwards;
}

@keyframes loadProgress {
    from { width: 0%; }
    to { width: 100%; }
}

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

/* ===== UI 元素 ===== */
.ui-element {
    position: absolute;
    pointer-events: auto;
}

/* 快捷按钮栏 */
#shortcut-bar {
    top: 20px;
    left: 50%;
    transform: translateX(-50%);
    display: flex;
    gap: 8px;
    z-index: 100;
    background: rgba(0, 0, 0, 0.7);
    border: 2px solid #ffd700;
    padding: 6px;
    border-radius: 4px;
}

.shortcut-btn {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 2px;
    padding: 6px 12px;
    background: #2a2a4a;
    border: 2px solid #4a4a6a;
    color: #ccc;
    cursor: pointer;
    font-family: 'Courier New', monospace;
    font-size: 10px;
    transition: all 0.2s;
    min-width: 50px;
}

.shortcut-btn:hover {
    border-color: #ffd700;
    color: #ffd700;
    background: #1a1a2e;
}

.shortcut-btn:active {
    transform: scale(0.95);
}

.shortcut-icon {
    font-size: 18px;
}

.shortcut-text {
    font-size: 10px;
}

/* 角色头像 */
#player-avatar {
    top: 20px;
    left: 20px;
    cursor: pointer;
    z-index: 100;
}

.avatar-frame {
    width: 64px;
    height: 64px;
    border: 3px solid #ffd700;
    background: #2a2a4a;
    display: flex;
    align-items: center;
    justify-content: center;
    position: relative;
    overflow: hidden;
    border-radius: 4px;
}

.avatar-img {
    width: 48px;
    height: 48px;
    object-fit: cover;
    border-radius: 4px;
}

.avatar-placeholder {
    width: 48px;
    height: 48px;
    background: #4a90d9;
    border-radius: 4px;
}

.level-badge {
    position: absolute;
    bottom: -8px;
    right: -8px;
    background: #ff6b35;
    color: white;
    font-size: 10px;
    padding: 2px 6px;
    border: 2px solid #fff;
}

/* 操作提示 */
#controls-hint {
    top: 20px;
    right: 20px;
    background: rgba(0, 0, 0, 0.8);
    border: 2px solid #00ff88;
    padding: 12px;
    color: #00ff88;
    font-size: 12px;
    z-index: 100;
}

#controls-hint p {
    margin: 4px 0;
}

/* 交互提示 */
#interact-hint {
    bottom: 100px;
    left: 50%;
    transform: translateX(-50%);
    background: rgba(0, 0, 0, 0.9);
    border: 2px solid #ffd700;
    padding: 10px 20px;
    display: flex;
    align-items: center;
    gap: 10px;
    z-index: 100;
    animation: bounce 1s ease infinite;
}

.interact-key {
    background: #ffd700;
    color: #000;
    padding: 4px 10px;
    font-size: 12px;
    font-weight: bold;
}

.interact-text {
    color: #fff;
    font-size: 14px;
}

@keyframes bounce {
    0%, 100% { transform: translateX(-50%) translateY(0); }
    50% { transform: translateX(-50%) translateY(-5px); }
}

/* ===== 模态框 ===== */
.modal {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.7);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 200;
    opacity: 0;
    pointer-events: none;
    transition: opacity 0.3s;
}

.modal:not(.hidden) {
    opacity: 1;
    pointer-events: auto;
}

.modal-content {
    background: #2a2a4a;
    border: 3px solid #ffd700;
    width: 90%;
    max-width: 600px;
    max-height: 80vh;
    overflow-y: auto;
    position: relative;
}

.notice-modal .modal-content {
    max-width: 900px;
    width: 95%;
}

.notice-modal .notice-grid {
    grid-template-columns: repeat(3, 1fr);
}

@media (max-width: 768px) {
    .notice-modal .modal-content {
        max-width: 95%;
    }

    .notice-modal .notice-grid {
        grid-template-columns: repeat(2, 1fr);
    }
}

.panel-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 15px;
    background: #1a1a2e;
    border-bottom: 2px solid #ffd700;
}

.panel-header h2 {
    color: #ffd700;
    font-size: 18px;
    margin: 0;
}

.close-btn {
    background: #ff4444;
    color: white;
    border: none;
    width: 30px;
    height: 30px;
    font-size: 20px;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
}

.close-btn:hover {
    background: #ff6666;
}

/* 面板标签页 */
.panel-tabs {
    display: flex;
    background: #1a1a2e;
    border-bottom: 2px solid #ffd700;
}

.tab-btn {
    flex: 1;
    padding: 10px;
    background: transparent;
    border: none;
    color: #888;
    cursor: pointer;
    font-family: 'Courier New', monospace;
    font-size: 12px;
    transition: all 0.2s;
}

.tab-btn.active {
    background: #ffd700;
    color: #000;
}

.tab-btn:hover:not(.active) {
    color: #ffd700;
}

.panel-body {
    padding: 15px;
}

.tab-content {
    display: none;
}

.tab-content.active {
    display: block;
}

/* ===== 属性面板 ===== */
.character-info {
    display: flex;
    gap: 15px;
    margin-bottom: 20px;
    padding: 10px;
    background: #1a1a2e;
    border: 2px solid #4a4a6a;
}

.info-avatar {
    width: 64px;
    height: 64px;
    background: #4a90d9;
    border: 2px solid #ffd700;
    flex-shrink: 0;
    overflow: hidden;
    border-radius: 4px;
}

.info-avatar-img {
    width: 64px;
    height: 64px;
    object-fit: cover;
    border-radius: 4px;
}

.info-text h3 {
    color: #ffd700;
    margin: 0 0 5px 0;
    font-size: 16px;
}

.class-name {
    color: #00ff88;
    font-size: 12px;
    margin: 0 0 5px 0;
}

.level-text {
    color: #ff6b35;
    font-size: 12px;
    margin: 0;
}

/* 状态条 */
.bars {
    margin-bottom: 20px;
}

.bar-row {
    display: flex;
    align-items: center;
    gap: 10px;
    margin-bottom: 8px;
}

.bar-label {
    width: 30px;
    color: #fff;
    font-size: 12px;
    font-weight: bold;
}

.bar {
    flex: 1;
    height: 16px;
    background: #1a1a2e;
    border: 2px solid #4a4a6a;
    overflow: hidden;
}

.bar-fill {
    height: 100%;
    transition: width 0.3s;
}

.hp-bar .bar-fill { background: #ff4444; }
.mp-bar .bar-fill { background: #4444ff; }
.sp-bar .bar-fill { background: #44ff44; }

.bar-value {
    width: 80px;
    color: #ccc;
    font-size: 11px;
    text-align: right;
}

/* 属性数值 */
.attributes {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 8px;
}

.attr-row {
    display: flex;
    justify-content: space-between;
    padding: 8px;
    background: #1a1a2e;
    border: 1px solid #4a4a6a;
}

.attr-name {
    color: #ccc;
    font-size: 12px;
}

.attr-value {
    color: #ffd700;
    font-size: 12px;
    font-weight: bold;
}

/* ===== 装备面板 ===== */
.equipment-grid {
    display: grid;
    grid-template-columns: repeat(2, 1fr);
    gap: 10px;
}

.equip-slot {
    padding: 12px;
    background: #1a1a2e;
    border: 2px solid #4a4a6a;
    text-align: center;
    cursor: pointer;
    transition: border-color 0.2s;
}

.equip-slot:hover {
    border-color: #ffd700;
}

.slot-icon {
    font-size: 24px;
    margin-bottom: 5px;
}

.slot-name {
    color: #ffd700;
    font-size: 12px;
    margin-bottom: 5px;
}

.slot-desc {
    color: #888;
    font-size: 10px;
}

/* ===== 背包面板 ===== */
.inventory-grid {
    display: grid;
    grid-template-columns: repeat(4, 1fr);
    gap: 8px;
}

.inv-item {
    aspect-ratio: 1;
    padding: 8px;
    background: #1a1a2e;
    border: 2px solid #4a4a6a;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    position: relative;
    transition: border-color 0.2s;
}

.inv-item:hover {
    border-color: #ffd700;
}

.item-icon {
    font-size: 24px;
    margin-bottom: 4px;
}

.item-name {
    color: #ccc;
    font-size: 10px;
    text-align: center;
}

.item-count {
    position: absolute;
    bottom: 2px;
    right: 4px;
    color: #ffd700;
    font-size: 10px;
}

/* ===== 技能面板 ===== */
.skills-list {
    display: flex;
    flex-direction: column;
    gap: 10px;
}

.skill-item {
    display: flex;
    gap: 12px;
    padding: 12px;
    background: #1a1a2e;
    border: 2px solid #4a4a6a;
    align-items: center;
}

.skill-icon {
    font-size: 28px;
    width: 40px;
    text-align: center;
    flex-shrink: 0;
}

.skill-info {
    flex: 1;
}

.skill-name {
    color: #ffd700;
    font-size: 14px;
    margin-bottom: 4px;
}

.skill-level {
    color: #00ff88;
    font-size: 11px;
    margin-bottom: 6px;
}

.skill-bar {
    height: 8px;
    background: #1a1a2e;
    border: 1px solid #4a4a6a;
    overflow: hidden;
}

.skill-progress {
    height: 100%;
    background: #00ff88;
    transition: width 0.3s;
}

/* ===== 建筑内容 ===== */
.building-content {
    padding: 15px;
    color: #ccc;
}

.building-description {
    margin-bottom: 15px;
    line-height: 1.6;
}

.notice-list {
    display: flex;
    flex-direction: column;
    gap: 10px;
}

.notice-item {
    padding: 12px;
    background: #1a1a2e;
    border: 2px solid #4a4a6a;
    cursor: pointer;
    transition: border-color 0.2s;
}

.notice-item:hover {
    border-color: #ffd700;
}

.notice-title {
    color: #ffd700;
    font-size: 14px;
    margin-bottom: 5px;
}

.notice-summary {
    color: #888;
    font-size: 12px;
    margin-bottom: 8px;
}

.notice-link {
    color: #00ff88;
    font-size: 11px;
    text-decoration: none;
}

.notice-link:hover {
    text-decoration: underline;
}

/* 公告栏九宫格 */
.notice-grid {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 12px;
    padding: 10px 0;
}

.notice-card {
    background: #1a1a2e;
    border: 2px solid #4a4a6a;
    border-radius: 8px;
    overflow: hidden;
    cursor: pointer;
    transition: all 0.2s;
}

.notice-card:hover {
    border-color: #ffd700;
    transform: translateY(-3px);
    box-shadow: 0 4px 12px rgba(255, 215, 0, 0.2);
}

.notice-card-cover {
    width: 100%;
    height: 100px;
    overflow: hidden;
}

.notice-card-cover img {
    width: 100%;
    height: 100%;
    object-fit: cover;
}

.notice-card-body {
    padding: 10px;
}

.notice-card-title {
    color: #ffd700;
    font-size: 14px;
    font-weight: bold;
    margin-bottom: 5px;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.notice-card-summary {
    color: #aaa;
    font-size: 11px;
    line-height: 1.4;
    height: 30px;
    overflow: hidden;
    display: -webkit-box;
    -webkit-line-clamp: 2;
    -webkit-box-orient: vertical;
    margin-bottom: 8px;
}

.notice-card-date {
    color: #666;
    font-size: 10px;
}

/* 公告分页 */
.notice-pagination {
    display: flex;
    justify-content: center;
    align-items: center;
    gap: 15px;
    padding: 15px 0;
    border-top: 1px solid #4a4a6a;
    margin-top: 10px;
}

.page-btn {
    padding: 8px 16px;
    background: #1a1a2e;
    border: 2px solid #4a4a6a;
    color: #fff;
    border-radius: 4px;
    cursor: pointer;
    transition: all 0.2s;
}

.page-btn:hover:not(:disabled) {
    border-color: #ffd700;
    color: #ffd700;
}

.page-btn:disabled {
    opacity: 0.4;
    cursor: not-allowed;
}

.page-info {
    color: #888;
    font-size: 12px;
}

/* 公告详情 */
.notice-detail {
    padding: 10px;
}

.notice-detail-cover {
    width: 100%;
    max-height: 200px;
    object-fit: cover;
    border-radius: 8px;
    margin-bottom: 15px;
}

.notice-detail-title {
    color: #ffd700;
    font-size: 18px;
    margin-bottom: 8px;
}

.notice-detail-date {
    color: #666;
    font-size: 12px;
    margin-bottom: 15px;
}

.notice-detail-content {
    color: #ccc;
    font-size: 14px;
    line-height: 1.8;
    white-space: pre-wrap;
}

.notice-detail-link {
    display: inline-block;
    margin-top: 15px;
    padding: 10px 20px;
    background: #ffd700;
    color: #1a1a2e;
    text-decoration: none;
    border-radius: 4px;
    font-weight: bold;
    transition: all 0.2s;
}

.notice-detail-link:hover {
    background: #ffed4a;
    transform: translateY(-2px);
}

.collection-grid {
    display: grid;
    grid-template-columns: repeat(2, 1fr);
    gap: 10px;
}

.collection-item {
    padding: 10px;
    background: #1a1a2e;
    border: 2px solid #4a4a6a;
}

.collection-type {
    color: #ffd700;
    font-size: 12px;
    margin-bottom: 5px;
}

.collection-name {
    color: #fff;
    font-size: 13px;
    margin-bottom: 5px;
}

.collection-rating {
    color: #ff6b35;
    font-size: 12px;
}

.collection-status {
    color: #00ff88;
    font-size: 11px;
}

/* ===== 对话窗口 ===== */
#dialog-box {
    position: fixed;
    bottom: 20px;
    left: 50%;
    transform: translateX(-50%);
    width: 90%;
    max-width: 600px;
    background: #2a2a4a;
    border: 3px solid #ffd700;
    z-index: 300;
    padding: 15px;
}

.dialog-content {
    display: flex;
    gap: 15px;
    margin-bottom: 15px;
}

.dialog-avatar {
    width: 64px;
    height: 64px;
    background: #4a90d9;
    border: 2px solid #ffd700;
    flex-shrink: 0;
    overflow: hidden;
    border-radius: 4px;
}

.dialog-avatar-img {
    width: 64px;
    height: 64px;
    object-fit: cover;
    border-radius: 4px;
}

.dialog-text {
    flex: 1;
}

#dialog-speaker {
    color: #ffd700;
    font-size: 14px;
    margin-bottom: 5px;
}

#dialog-message {
    color: #fff;
    font-size: 13px;
    line-height: 1.5;
}

.dialog-choices {
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.dialog-choice {
    padding: 10px 15px;
    background: #1a1a2e;
    border: 2px solid #4a4a6a;
    color: #ccc;
    cursor: pointer;
    font-family: 'Courier New', monospace;
    font-size: 13px;
    text-align: left;
    transition: all 0.2s;
}

.dialog-choice:hover {
    border-color: #ffd700;
    color: #ffd700;
}

/* ===== 移动端控制 ===== */
#mobile-controls {
    position: fixed;
    bottom: 20px;
    left: 20px;
    z-index: 150;
}

#joystick-zone {
    width: 120px;
    height: 120px;
    background: rgba(255, 255, 255, 0.1);
    border: 2px solid rgba(255, 255, 255, 0.3);
    border-radius: 50%;
    position: relative;
    touch-action: none;
}

#joystick-knob {
    position: absolute;
    top: 50%;
    left: 50%;
    width: 50px;
    height: 50px;
    margin-top: -25px;
    margin-left: -25px;
    background: rgba(255, 215, 0, 0.6);
    border: 2px solid #ffd700;
    border-radius: 50%;
    pointer-events: none;
    transition: transform 0.05s;
}

.mobile-btn {
    position: fixed;
    bottom: 40px;
    right: 40px;
    width: 80px;
    height: 80px;
    background: rgba(255, 215, 0, 0.3);
    border: 3px solid #ffd700;
    color: #ffd700;
    font-size: 16px;
    font-family: 'Courier New', monospace;
    border-radius: 50%;
    cursor: pointer;
    z-index: 150;
    touch-action: none;
    user-select: none;
    -webkit-user-select: none;
}

.mobile-btn:active {
    background: rgba(255, 215, 0, 0.6);
    transform: scale(0.95);
}

#mobile-nav {
    position: fixed;
    bottom: 20px;
    left: 50%;
    transform: translateX(-50%);
    display: flex;
    gap: 10px;
    z-index: 150;
}

.nav-dot {
    width: 12px;
    height: 12px;
    border-radius: 50%;
    background: rgba(255, 255, 255, 0.3);
    border: 2px solid rgba(255, 255, 255, 0.5);
    cursor: pointer;
}

.nav-dot.active {
    background: #ffd700;
    border-color: #ffd700;
}

/* ===== 通用类 ===== */
.hidden {
    display: none !important;
}

/* ===== 响应式 ===== */
@media (max-width: 768px) {
    .modal-content {
        width: 95%;
        max-height: 85vh;
    }

    .panel-tabs {
        flex-wrap: wrap;
    }

    .tab-btn {
        flex: 1 0 50%;
        padding: 8px;
        font-size: 11px;
    }

    .equipment-grid {
        grid-template-columns: 1fr;
    }

    .inventory-grid {
        grid-template-columns: repeat(4, 1fr);
    }

    .attributes {
        grid-template-columns: 1fr;
    }

    .collection-grid {
        grid-template-columns: 1fr;
    }

    .character-info {
        flex-direction: column;
        align-items: center;
        text-align: center;
    }

    #player-avatar {
        top: 10px;
        left: 10px;
    }

    .avatar-frame {
        width: 48px;
        height: 48px;
    }

    .avatar-placeholder {
        width: 36px;
        height: 36px;
    }

    .level-badge {
        font-size: 9px;
        padding: 1px 4px;
    }

    #controls-hint {
        display: none;
    }

    #shortcut-bar {
        top: auto;
        bottom: 100px;
        left: 50%;
        transform: translateX(-50%);
        padding: 4px;
        gap: 4px;
    }

    .shortcut-btn {
        padding: 4px 8px;
        min-width: 44px;
    }

    .shortcut-icon {
        font-size: 16px;
    }

    .shortcut-text {
        font-size: 9px;
    }
}

@media (min-width: 769px) {
    #mobile-controls,
    #mobile-nav {
        display: none !important;
    }
}

/* ===== 滚动条样式 ===== */
::-webkit-scrollbar {
    width: 8px;
}

::-webkit-scrollbar-track {
    background: #1a1a2e;
}

::-webkit-scrollbar-thumb {
    background: #4a4a6a;
    border: 1px solid #1a1a2e;
}

::-webkit-scrollbar-thumb:hover {
    background: #ffd700;
}

/* 外部链接嵌入弹窗 */
.embed-modal-content {
    background: #2a2a4a;
    border: 3px solid #ffd700;
    width: 95%;
    height: 90vh;
    max-width: 1200px;
    display: flex;
    flex-direction: column;
    border-radius: 8px;
    overflow: hidden;
}

.embed-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 12px 15px;
    background: #1a1a2e;
    border-bottom: 2px solid #ffd700;
}

.embed-title {
    color: #ffd700;
    font-size: 16px;
    font-weight: bold;
}

.embed-frame {
    flex: 1;
    width: 100%;
    background: #fff;
}
