/* ========================================
   安全隐患排查找茬游戏 - 游戏页面样式
   双栏现代化布局
   ======================================== */

/* ---------- 变量定义 ---------- */
:root {
    --primary: #2563eb;
    --primary-dark: #1d4ed8;
    --primary-light: #dbeafe;
    --success: #16a34a;
    --success-bg: #dcfce7;
    --danger: #dc2626;
    --danger-bg: #fee2e2;
    --warning: #f59e0b;
    --warning-bg: #fef3c7;

    --bg-body: #f0f4f8;
    --bg-header: #ffffff;
    --bg-sidebar: #f8fafc;
    --bg-card: #ffffff;
    --bg-hover: #f1f5f9;

    --border: #e2e8f0;
    --border-light: #f1f5f9;

    --text-primary: #1e293b;
    --text-secondary: #64748b;
    --text-muted: #94a3b8;

    --shadow-sm: 0 1px 2px rgba(0,0,0,0.05);
    --shadow-md: 0 4px 6px -1px rgba(0,0,0,0.08), 0 2px 4px -2px rgba(0,0,0,0.05);
    --shadow-lg: 0 10px 15px -3px rgba(0,0,0,0.08), 0 4px 6px -4px rgba(0,0,0,0.04);
    --shadow-xl: 0 20px 25px -5px rgba(0,0,0,0.08), 0 8px 10px -6px rgba(0,0,0,0.04);

    --radius-sm: 6px;
    --radius-md: 10px;
    --radius-lg: 16px;
    --radius-xl: 20px;

    --transition: 0.2s ease;
}

/* ---------- 基础重置 & 容器 ---------- */
* { box-sizing: border-box; margin: 0; padding: 0; }

body {
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", "PingFang SC", "Hiragino Sans GB", "Microsoft YaHei", sans-serif;
    background: transparent;
    color: var(--text-primary);
    min-height: 100vh;
    overflow-x: hidden;
}

/* 背景视频 */
.video-background {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    object-fit: cover;
    z-index: -1;
    pointer-events: none;
}

#game-container {
    display: flex;
    flex-direction: column;
    min-height: 100vh;
    max-width: 1440px;
    margin: 0 auto;
}

/* ========== 顶部导航栏 ========== */
.game-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 14px 28px;
    background: var(--bg-header);
    border-bottom: 1px solid var(--border-light);
    backdrop-filter: blur(12px);
    position: sticky;
    top: 0;
    z-index: 100;
    box-shadow: var(--shadow-sm);
}

.header-brand {
    display: flex;
    align-items: center;
    gap: 14px;
}

.brand-icon {
    width: 44px;
    height: 44px;
    background: linear-gradient(135deg, var(--primary), #7c3aed);
    border-radius: var(--radius-md);
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
}
.brand-icon svg {
    width: 26px;
    height: 26px;
    color: #fff;
}

.brand-text {
    display: flex;
    flex-direction: column;
}
.game-title {
    font-size: 1.25rem;
    font-weight: 700;
    line-height: 1.3;
    color: var(--text-primary);
    letter-spacing: -0.02em;
}
.game-subtitle {
    font-size: 0.75rem;
    color: var(--text-muted);
    letter-spacing: 0.04em;
}

.header-actions {
    display: flex;
    gap: 8px;
}

/* 按钮通用样式 */
.btn {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 9px 18px;
    border: none;
    border-radius: var(--radius-sm);
    font-size: 0.85rem;
    font-weight: 600;
    cursor: pointer;
    transition: all var(--transition);
    white-space: nowrap;
}
.btn svg {
    width: 16px;
    height: 16px;
}
.btn-ghost {
    background: transparent;
    color: var(--text-secondary);
    border: 1px solid var(--border);
}
.btn-ghost:hover {
    background: var(--bg-hover);
    color: var(--primary);
    border-color: var(--primary);
}
.btn-primary {
    background: linear-gradient(135deg, var(--primary), #7c3aed);
    color: #fff;
    box-shadow: 0 2px 8px rgba(37,99,235,0.3);
}
.btn-primary:hover {
    transform: translateY(-1px);
    box-shadow: 0 4px 14px rgba(37,99,235,0.4);
}
.btn-admin {
    background: linear-gradient(135deg, #7c3aed, #db2777);
    color: #fff;
    box-shadow: 0 2px 8px rgba(124,58,237,0.3);
}
.btn-admin:hover {
    transform: translateY(-1px);
    box-shadow: 0 4px 14px rgba(124,58,237,0.4);
}
.btn-lg {
    padding: 13px 36px;
    font-size: 1rem;
    border-radius: var(--radius-md);
}

/* ========== 主体双栏布局 ========== */
.game-main {
    display: flex;
    flex: 1;
    gap: 24px;
    padding: 24px;
    overflow: hidden;
}

/* ========== 左侧：游戏场景面板 ========== */
.game-scene-panel {
    flex: 1;
    display: flex;
    flex-direction: column;
    min-width: 0;
    gap: 16px;
}

/* 场景工具栏 */
.scene-toolbar {
    display: flex;
    align-items: center;
    gap: 16px;
    padding: 14px 20px;
    background: var(--bg-card);
    border-radius: var(--radius-md);
    box-shadow: var(--shadow-sm);
    border: 1px solid var(--border-light);
}

.level-badge {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 8px 16px;
    background: linear-gradient(135deg, var(--primary-light), #ede9fe);
    border-radius: var(--radius-sm);
    flex-shrink: 0;
}
.badge-icon {
    font-size: 1.2rem;
}
.badge-info {
    display: flex;
    flex-direction: column;
}
.badge-label {
    font-size: 0.68rem;
    color: var(--text-muted);
    text-transform: uppercase;
    letter-spacing: 0.06em;
}
.badge-value {
    font-size: 0.95rem;
    font-weight: 700;
    color: var(--primary);
}
.badge-value em {
    font-style: normal;
    color: var(--text-muted);
    margin: 0 2px;
}

.level-name {
    font-size: 1rem;
    font-weight: 600;
    color: var(--text-primary);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.scene-hint {
    margin-left: auto;
    display: flex;
    align-items: center;
    gap: 6px;
    font-size: 0.78rem;
    color: var(--text-muted);
    flex-shrink: 0;
}
.scene-hint svg {
    width: 16px;
    height: 16px;
}

/* 场景图片容器 */
.image-container {
    display: flex;
    align-items: center;
    justify-content: center;
    overflow: hidden;
    cursor: crosshair;
    position: relative;
    width: 100%;
}

.image-frame {
    position: relative;
    width: 100%;
    display: flex;
    align-items: center;
    justify-content: center;
}

.scene-image {
    display: block;
    width: 100%;
    height: auto;
    object-fit: contain;
    border-radius: var(--radius-sm);
    user-select: none;
    -webkit-user-drag: none;
}

.hazard-canvas {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    pointer-events: none;
    z-index: 2;
}

.hazard-markers {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    z-index: 3;
    pointer-events: none;
}

/* 隐患标记矩形框 */
.hazard-marker {
    position: absolute;
    border: 3px solid #16a34a;
    background: rgba(22, 163, 74, 0.12);
    pointer-events: none;
    transform: translate(-50%, -50%);
    animation: markerAppear 0.3s ease-out;
}
@keyframes markerAppear {
    from { opacity: 0; transform: translate(-50%, -50%) scale(1.3); }
    to { opacity: 1; transform: translate(-50%, -50%) scale(1); }
}
.hazard-marker .marker-number {
    position: absolute;
    top: -8px;
    right: -8px;
    width: 22px;
    height: 22px;
    background: #16a34a;
    color: #fff;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 14px;
    font-weight: 700;
    line-height: 1;
}

/* 放大镜光标跟随 */
.inspect-cursor {
    position: absolute;
    width: 40px;
    height: 40px;
    pointer-events: none;
    z-index: 10;
    opacity: 0.5;
    transform: translate(-50%, -50%);
    transition: opacity 0.2s;
}
.inspect-cursor svg {
    width: 100%;
    height: 100%;
    color: var(--primary);
    filter: drop-shadow(0 0 4px rgba(37,99,235,0.4));
}
.image-container:hover .inspect-cursor {
    opacity: 0.8;
}

/* ========== 右侧：侧边信息面板 ========== */
.game-sidebar {
    width: 340px;
    flex-shrink: 0;
    display: flex;
    flex-direction: column;
    gap: 20px;
    overflow-y: auto;
    padding-right: 4px;
}


/* 卡片通用样式 */
.sidebar-card {
    background: var(--bg-card);
    border-radius: var(--radius-lg);
    box-shadow: var(--shadow-sm);
    border: 1px solid var(--border-light);
    overflow: hidden;
}

.card-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 16px 20px 12px;
    border-bottom: 1px solid var(--border-light);
}
.card-header h3 {
    display: flex;
    align-items: center;
    gap: 8px;
    font-size: 0.95rem;
    font-weight: 700;
    color: var(--text-primary);
}
.card-header h3 svg {
    width: 18px;
    height: 18px;
    color: var(--primary);
}

.checklist-count {
    font-size: 0.78rem;
    font-weight: 600;
    color: var(--primary);
    background: var(--primary-light);
    padding: 3px 10px;
    border-radius: 20px;
}

/* --- 进度卡片 --- */
.progress-body {
    display: flex;
    align-items: center;
    gap: 20px;
    padding: 20px;
}

.progress-ring-container {
    position: relative;
    width: 100px;
    height: 100px;
    flex-shrink: 0;
}
.progress-ring {
    width: 100%;
    height: 100%;
    transform: rotate(-90deg);
}
.progress-ring-bg {
    fill: none;
    stroke: #e2e8f0;
    stroke-width: 8;
}
.progress-ring-fill {
    fill: none;
    stroke: url(#progressGradient);
    stroke-width: 8;
    stroke-linecap: round;
    transition: stroke-dashoffset 0.5s ease;
}
.progress-ring-text {
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    text-align: center;
}
.progress-percent {
    display: block;
    font-size: 1.35rem;
    font-weight: 800;
    color: var(--primary);
    line-height: 1.2;
}
.progress-label {
    font-size: 0.65rem;
    color: var(--text-muted);
    text-transform: uppercase;
    letter-spacing: 0.05em;
}

.progress-stats {
    flex: 1;
    display: flex;
    flex-direction: column;
    gap: 12px;
}
.stat-item {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 10px 14px;
    background: var(--bg-body);
    border-radius: var(--radius-sm);
}
.stat-icon {
    width: 32px;
    height: 32px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 0.9rem;
    font-weight: 700;
    flex-shrink: 0;
}
.found-icon {
    background: var(--success-bg);
    color: var(--success);
}
.total-icon {
    background: var(--primary-light);
    color: var(--primary);
}
.stat-info {
    display: flex;
    flex-direction: column;
}
.stat-value {
    font-size: 1.3rem;
    font-weight: 800;
    color: var(--text-primary);
    line-height: 1.2;
}
.stat-label {
    font-size: 0.72rem;
    color: var(--text-muted);
}

/* --- 隐患清单卡片 --- */
.checklist-body {
    padding: 8px 16px 16px;
    display: flex;
    flex-direction: column;
    gap: 6px;
    max-height: 360px;
    overflow-y: auto;
}

.hazard-item {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 11px 14px;
    border-radius: var(--radius-sm);
    cursor: default;
    transition: all var(--transition);
    border-left: 3px solid transparent;
    position: relative;
}
.hazard-item.not-found {
    background: var(--bg-body);
    opacity: 0.65;
    border-left-color: #cbd5e1;
}
.hazard-item.found {
    background: var(--success-bg);
    border-left-color: var(--success);
    cursor: pointer;
}
.hazard-item.found:hover {
    background: #d1fae5;
    transform: translateX(2px);
}

.hazard-item-icon {
    width: 28px;
    height: 28px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 0.8rem;
    font-weight: 700;
    flex-shrink: 0;
}
.not-found .hazard-item-icon {
    background: #e2e8f0;
    color: var(--text-muted);
}
.found .hazard-item-icon {
    background: var(--success);
    color: #fff;
}

.hazard-item-content {
    flex: 1;
    min-width: 0;
}
.hazard-item-name {
    font-size: 0.87rem;
    font-weight: 600;
    color: var(--text-primary);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}
.hazard-item-desc {
    font-size: 0.72rem;
    color: var(--text-muted);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    margin-top: 2px;
}
.found .hazard-item-name {
    color: var(--success);
}

/* ========== Toast 提示 ========== */
.feedback-toast {
    position: fixed;
    top: 24px;
    left: 50%;
    transform: translateX(-50%) translateY(-20px);
    z-index: 9999;
    opacity: 0;
    pointer-events: none;
    transition: all 0.35s cubic-bezier(0.4, 0, 0.2, 1);
}
.feedback-toast.show {
    opacity: 1;
    transform: translateX(-50%) translateY(0);
}
.toast-content {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 12px 24px;
    border-radius: var(--radius-md);
    box-shadow: var(--shadow-xl);
    font-size: 0.9rem;
    font-weight: 600;
}
.feedback-toast.success .toast-content {
    background: var(--success);
    color: #fff;
}
.feedback-toast.error .toast-content {
    background: var(--danger);
    color: #fff;
}
.toast-icon {
    font-size: 1.1rem;
}

/* ========== 弹窗通用 ========== */
.modal-overlay {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(15, 23, 42, 0.6);
    backdrop-filter: blur(4px);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 1000;
    animation: fadeIn 0.2s ease;
}
@keyframes fadeIn {
    from { opacity: 0; }
    to { opacity: 1; }
}
.modal-overlay.hidden {
    display: none;
}

.modal-content {
    background: var(--bg-card);
    border-radius: var(--radius-xl);
    box-shadow: var(--shadow-xl);
    width: 90%;
    max-width: 500px;
    overflow: hidden;
    animation: slideUp 0.3s cubic-bezier(0.34, 1.56, 0.64, 1);
}
@keyframes slideUp {
    from { opacity: 0; transform: translateY(20px) scale(0.96); }
    to { opacity: 1; transform: translateY(0) scale(1); }
}

.modal-header {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 22px 28px 16px;
    border-bottom: 1px solid var(--border-light);
}
.modal-header-icon {
    width: 38px;
    height: 38px;
    background: var(--warning-bg);
    border-radius: var(--radius-sm);
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1.2rem;
    flex-shrink: 0;
}
.modal-header h2 {
    flex: 1;
    font-size: 1.15rem;
    font-weight: 700;
    color: var(--text-primary);
}
.modal-close {
    width: 34px;
    height: 34px;
    border: none;
    background: var(--bg-body);
    border-radius: 50%;
    font-size: 1.3rem;
    color: var(--text-muted);
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all var(--transition);
}
.modal-close:hover {
    background: var(--danger-bg);
    color: var(--danger);
}

.modal-body {
    padding: 20px 28px;
}
.detail-item {
    display: flex;
    flex-direction: column;
    gap: 4px;
    padding: 12px 0;
    border-bottom: 1px solid var(--border-light);
}
.detail-item:last-child {
    border-bottom: none;
}
.detail-label {
    font-size: 0.72rem;
    font-weight: 600;
    color: var(--text-muted);
    text-transform: uppercase;
    letter-spacing: 0.05em;
}
.detail-value {
    font-size: 0.93rem;
    color: var(--text-primary);
    line-height: 1.5;
}

.modal-footer {
    padding: 16px 28px 24px;
    display: flex;
    justify-content: flex-end;
}

/* 关卡完成 / 通关弹窗 */
.level-complete-content,
.game-complete-content {
    text-align: center;
    padding: 48px 40px;
}
.complete-icon {
    font-size: 3.5rem;
    margin-bottom: 16px;
}
.complete-icon svg {
    width: 80px;
    height: 80px;
}
.level-complete-content h2,
.game-complete-content h2 {
    font-size: 1.5rem;
    font-weight: 800;
    color: var(--text-primary);
    margin-bottom: 8px;
}
.level-complete-content p,
.game-complete-content p {
    color: var(--text-secondary);
    font-size: 0.95rem;
    margin-bottom: 20px;
}
.complete-stars {
    font-size: 1.6rem;
    margin-bottom: 28px;
    letter-spacing: 4px;
    animation: starPop 0.5s ease 0.2s both;
}
@keyframes starPop {
    from { opacity: 0; transform: scale(0); }
    to { opacity: 1; transform: scale(1); }
}

/* ========== 加载遮罩 ========== */
.loading-content {
    text-align: center;
    color: #fff;
}
.loading-spinner {
    width: 52px;
    height: 52px;
    margin: 0 auto 16px;
}
.loading-spinner svg {
    width: 100%;
    height: 100%;
    animation: spin 1s linear infinite;
}
@keyframes spin {
    from { transform: rotate(0deg); }
    to { transform: rotate(360deg); }
}
.loading-content p {
    font-size: 0.92rem;
    opacity: 0.85;
}

/* ========== 响应式布局 ========== */
@media (max-width: 1024px) {
    .game-main {
        flex-direction: column;
        overflow-y: auto;
    }
    .game-sidebar {
        width: 100%;
        flex-direction: row;
        overflow: visible;
        padding-right: 0;
    }
    .progress-card { flex: 1; }
    .checklist-card { flex: 1.5; max-height: 320px; overflow: hidden; }
    .checklist-body { max-height: 240px; }
}

@media (max-width: 768px) {
    .game-header { padding: 12px 16px; }
    .game-main { padding: 16px; gap: 16px; }
    .brand-text .game-subtitle { display: none; }
    .btn span { display: none; }
    .btn { padding: 9px; }
    .btn svg { width: 18px; height: 18px; }

    .scene-toolbar {
        flex-wrap: wrap;
        gap: 10px;
    }
    .scene-hint {
        width: 100%;
        order: 3;
        justify-content: center;
    }
    .image-container { min-height: 280px; }

    .game-sidebar {
        flex-direction: column;
    }
    .checklist-card { max-height: none; }
    .checklist-body { max-height: 300px; }
}

@media (max-width: 480px) {
    .game-main { padding: 12px; }
    .game-title { font-size: 1.05rem; }
    .level-badge { padding: 6px 12px; }
    .level-name { font-size: 0.88rem; }
    .progress-body { flex-direction: column; align-items: center; }
    .progress-stats { flex-direction: row; width: 100%; justify-content: stretch; }
    .stat-item { flex: 1; justify-content: center; }
    .sidebar-card { border-radius: var(--radius-md); }
    .modal-content { width: 95%; border-radius: var(--radius-lg); }
    .level-complete-content,
    .game-complete-content { padding: 32px 24px; }
}
