/* 定向越野模拟器 - 现代风格样式表 */

@import url('https://fonts.googleapis.com/css2?family=Inter:wght@400;500;600;700&display=swap');

:root {
    --primary: #2563eb;
    --primary-hover: #1d4ed8;
    --secondary: #64748b;
    --success: #10b981;
    --warning: #f59e0b;
    --danger: #ef4444;
    --bg-dark: rgba(15, 23, 42, 0.95);
    --bg-card: rgba(30, 41, 59, 0.9);
    --text-primary: #f8fafc;
    --text-secondary: #94a3b8;
    --border-color: rgba(255, 255, 255, 0.1);
    --shadow: 0 4px 20px rgba(0, 0, 0, 0.3);
}

body {
    margin: 0;
    overflow: hidden;
    font-family: 'Inter', -apple-system, BlinkMacSystemFont, sans-serif;
    user-select: none;
    -webkit-font-smoothing: antialiased;
}

/* 语言选择下拉菜单 */
.lang-select {
    position: absolute;
    top: 20px;
    right: 20px;
    padding: 8px 12px;
    font-size: 14px;
    font-weight: 500;
    font-family: inherit;
    color: var(--text-primary);
    background: var(--bg-card);
    border: 1px solid var(--border-color);
    border-radius: 8px;
    cursor: pointer;
    transition: all 0.2s ease;
    z-index: 10;
    outline: none;
    appearance: none;
    -webkit-appearance: none;
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' viewBox='0 0 12 12'%3E%3Cpath fill='%2394a3b8' d='M6 8L2 4h8z'/%3E%3C/svg%3E");
    background-repeat: no-repeat;
    background-position: right 10px center;
    padding-right: 30px;
}

.lang-select:hover {
    border-color: var(--primary);
}

.lang-select option {
    background: #1e293b;
    color: var(--text-primary);
    padding: 8px;
}

/* Logo - 左上角 */
.home-logo {
    position: absolute;
    top: 20px;
    left: 20px;
    width: 60px;
    height: 60px;
    border-radius: 50%;
    overflow: hidden;
    border: 2px solid var(--border-color);
    background: var(--bg-card);
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.2s ease;
}

.home-logo:hover {
    border-color: var(--primary);
    transform: scale(1.05);
}

.home-logo img {
    width: 100%;
    height: 100%;
    object-fit: cover;
    border-radius: 50%;
}

/* Beta 标签 */
.beta-badge {
    position: absolute;
    top: 25px;
    left: 90px;
    padding: 4px 10px;
    font-size: 11px;
    font-weight: 600;
    color: white;
    background: linear-gradient(135deg, #f59e0b, #d97706);
    border-radius: 12px;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

/* Buy Me a Coffee 链接 */
.coffee-link {
    position: absolute;
    bottom: 20px;
    right: 20px;
    display: flex;
    align-items: center;
    gap: 6px;
    padding: 8px 12px;
    color: #FFDD00;
    text-decoration: none;
    font-size: 13px;
    border-radius: 8px;
    background: rgba(255, 221, 0, 0.1);
    border: 1px solid rgba(255, 221, 0, 0.3);
    transition: all 0.2s ease;
}

.coffee-link:hover {
    background: rgba(255, 221, 0, 0.2);
    transform: scale(1.05);
}

/* ========== HUD 层 ========== */
#ui-layer {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    pointer-events: none;
}

.hud {
    padding: 16px 20px;
    color: var(--text-primary);
    font-size: 18px;
    font-weight: 600;
    display: none;
    background: var(--bg-card);
    border-radius: 12px;
    backdrop-filter: blur(10px);
    border: 1px solid var(--border-color);
}

#top-hud {
    position: absolute;
    top: 20px;
    left: 20px;
    display: flex;
    gap: 12px;
}

/* 默认隐藏移动端顶部栏（桌面端），移动端由 JS 控制显示 */
#mobile-top-bar {
    display: none;
}

#timer {
    font-variant-numeric: tabular-nums;
    letter-spacing: 0.5px;
}

#game-msg {
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    font-size: 32px;
    font-weight: 700;
    color: var(--text-primary);
    background: var(--bg-card);
    padding: 20px 40px;
    border-radius: 16px;
    backdrop-filter: blur(10px);
    border: 1px solid var(--border-color);
    display: none;
    transition: opacity 0.3s ease;
}

#bottom-hud {
    position: absolute;
    bottom: 20px;
    left: 20px;
}

/* ========== 小地图 ========== */
#minimap-container {
    position: absolute;
    bottom: 20px;
    right: 20px;
    width: 280px;
    height: 280px;
    border: 3px solid rgba(255, 255, 255, 0.6);
    border-radius: 20px;
    background: rgba(255, 255, 255, 0.95);
    overflow: hidden;
    display: none;
    transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    box-shadow: var(--shadow);
}

#minimap-container.expanded {
    width: 560px;
    height: 560px;
    border-radius: 16px;
    bottom: 50%;
    right: 50%;
    transform: translate(50%, 50%);
    z-index: 100;
    opacity: 0.7;
}

/* 控制点列表 - 桌面端：展开地图右侧 */
#control-desc-container {
    position: fixed;
    top: 50%;
    left: calc(50% + 300px);
    transform: translateY(-50%);
    width: auto;
    max-height: 80vh;
    overflow-y: auto;
    background: white;
    border: 3px solid black;
    padding: 0;
    font-size: 12px;
    font-family: Arial, sans-serif;
    color: black;
    z-index: 200;
    pointer-events: none;
    display: none;
}

#control-desc-table {
    width: 100%;
    border-collapse: collapse;
}

#control-desc-table td {
    border: 1px solid black;
    text-align: center;
    padding: 2px 4px;
    min-width: 22px;
    height: 22px;
    vertical-align: middle;
}

/* 标题行 */
#control-desc-table tr.title-row td {
    font-weight: bold;
    font-size: 14px;
    padding: 6px 12px;
    border: none;
    border-bottom: 2px solid black;
}

/* 信息行 (组别|距离|爬升) */
#control-desc-table tr.info-row td {
    font-weight: bold;
    border-top: none;
    padding: 4px 8px;
}

/* 起点行 */
#control-desc-table tr.start-row td {
    border-top: 2px solid black;
}

/* 普通控制点行 - 第一列（序号）加粗 */
#control-desc-table tr.control-row td:first-child {
    font-weight: bold;
}

/* 终点行 */
#control-desc-table tr.finish-row td {
    border-bottom: 2px solid black;
    padding: 4px 8px;
}

/* 迷你控制列表（小地图上方，始终可见） */
#mini-control-list {
    position: absolute;
    bottom: 310px;
    right: 20px;
    background: rgba(255, 255, 255, 0.95);
    border: 2px solid rgba(0, 0, 0, 0.6);
    border-radius: 8px;
    padding: 4px;
    font-size: 11px;
    font-family: Arial, sans-serif;
    color: black;
    z-index: 100;
    display: none;
    max-height: 200px;
    overflow-y: auto;
}

#mini-control-table {
    border-collapse: collapse;
}

#mini-control-table td {
    border: 1px solid #666;
    text-align: center;
    padding: 2px 6px;
    min-width: 20px;
}

#mini-control-table td:first-child {
    font-weight: bold;
}

canvas#mapCanvas {
    width: 100%;
    height: 100%;
}

/* ========== 屏幕遮罩 ========== */
.screen {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: var(--bg-dark);
    display: none;
    flex-direction: column;
    justify-content: center;
    align-items: center;
    color: var(--text-primary);
    pointer-events: auto;
    z-index: 999;
}

.screen.active {
    display: flex;
}

/* ========== 标题 ========== */
.screen h1 {
    font-size: 48px;
    font-weight: 700;
    margin: 0 0 8px 0;
    background: linear-gradient(135deg, #10b981, #3b82f6);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
}

.screen h1.paused {
    background: linear-gradient(135deg, #f59e0b, #ef4444);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
}

.screen h1.finished {
    background: linear-gradient(135deg, #fbbf24, #f59e0b);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
}

/* 构建版本号 */
.build-version {
    position: absolute;
    bottom: 12px;
    left: 12px;
    font-size: 10px;
    color: rgba(255, 255, 255, 0.4);
    font-family: monospace;
}

/* ========== 文本 ========== */
.screen p {
    font-size: 16px;
    color: var(--text-secondary);
    margin: 8px 0;
    line-height: 1.6;
}

.screen p.subtitle {
    font-size: 14px;
    color: var(--primary);
    font-weight: 500;
    margin-top: 0;
}

.screen .instructions {
    background: var(--bg-card);
    padding: 16px 24px;
    border-radius: 12px;
    margin: 20px 0;
    border: 1px solid var(--border-color);
}

.screen .instructions p {
    margin: 0;
    font-size: 14px;
}

/* ========== 按钮 ========== */
.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    min-width: 160px;
    padding: 14px 28px;
    font-size: 15px;
    font-weight: 600;
    font-family: inherit;
    color: white;
    background: var(--primary);
    border: none;
    border-radius: 10px;
    cursor: pointer;
    transition: all 0.2s ease;
    margin: 6px;
}

.btn:hover {
    background: var(--primary-hover);
    transform: translateY(-2px);
    box-shadow: 0 4px 12px rgba(37, 99, 235, 0.4);
}

.btn:active {
    transform: translateY(0);
}

.btn-secondary {
    background: var(--secondary);
}

.btn-secondary:hover {
    background: #475569;
    box-shadow: 0 4px 12px rgba(100, 116, 139, 0.4);
}

.btn-success {
    background: var(--success);
}

.btn-success:hover {
    background: #059669;
    box-shadow: 0 4px 12px rgba(16, 185, 129, 0.4);
}

/* ========== 难度选择 ========== */
.difficulty-select {
    display: flex;
    gap: 12px;
    margin-top: 24px;
}

.difficulty-select .btn {
    min-width: 140px;
}

.difficulty-select .btn-easy {
    background: var(--success);
}

.difficulty-select .btn-easy:hover {
    background: #059669;
}

.difficulty-select .btn-medium {
    background: var(--warning);
}

.difficulty-select .btn-medium:hover {
    background: #d97706;
}

.difficulty-select .btn-hard {
    background: var(--danger);
}

.difficulty-select .btn-hard:hover {
    background: #dc2626;
}

/* ========== 技术标识 ========== */
.tech-badge {
    margin-top: 32px;
    padding: 8px 16px;
    background: var(--bg-card);
    border-radius: 20px;
    font-size: 12px;
    color: var(--text-secondary);
    border: 1px solid var(--border-color);
}

/* ========== 指南针 ========== */
#compass {
    position: absolute;
    left: 20px;
    top: 50%;
    transform: translateY(-50%);
    width: 100px;
    height: 100px;
    border: 4px solid rgba(255, 255, 255, 0.7);
    border-radius: 50%;
    background: var(--bg-card);
    display: none;
    justify-content: center;
    align-items: center;
    color: var(--text-primary);
    font-weight: 700;
    font-size: 24px;
    backdrop-filter: blur(10px);
}

#compass-needle {
    position: absolute;
    width: 8px;
    height: 90%;
    background: linear-gradient(to bottom, #ef4444 50%, #f8fafc 50%);
    border-radius: 4px;
    transform: rotate(0deg);
}

/* ========== 结果统计 ========== */
.result-stats {
    display: flex;
    gap: 40px;
    margin: 24px 0;
}

.stat-item {
    text-align: center;
}

.stat-label {
    font-size: 13px;
    color: var(--text-secondary);
    margin-bottom: 4px;
}

.stat-value {
    font-size: 28px;
    font-weight: 700;
    color: var(--text-primary);
}

.stat-value.time {
    color: #fbbf24;
}

.stat-value.distance {
    color: #3b82f6;
}

/* ========== 暂停菜单按钮组 ========== */
.menu-buttons {
    display: flex;
    flex-direction: column;
    gap: 8px;
    margin-top: 24px;
}

/* ========== 移动端触控 ========== */

/* 虚拟摇杆容器 */
.joystick-container {
    position: absolute;
    bottom: 40px;
    width: 140px;
    height: 140px;
    display: none;
    justify-content: center;
    align-items: center;
    z-index: 150;
    pointer-events: auto;
}

#joystick-left {
    left: 30px;
}

#joystick-right {
    display: none !important;
}

/* 摇杆底座 */
.joystick-base {
    position: relative;
    background: rgba(255, 255, 255, 0.15);
    border: 3px solid rgba(255, 255, 255, 0.4);
    border-radius: 50%;
    backdrop-filter: blur(4px);
    box-shadow: 0 4px 15px rgba(0, 0, 0, 0.2);
}

/* 摇杆拇指 */
.joystick-thumb {
    position: absolute;
    background: rgba(255, 255, 255, 0.6);
    border: 2px solid rgba(255, 255, 255, 0.8);
    border-radius: 50%;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.3);
    transition: background 0.1s ease;
}

.joystick-thumb:active {
    background: rgba(255, 255, 255, 0.8);
}

/* 移动端按钮组 */
#mobile-buttons {
    position: absolute;
    top: 20px;
    right: 20px;
    display: none;
    gap: 10px;
    z-index: 150;
    pointer-events: auto;
}

.mobile-btn {
    width: 50px;
    height: 50px;
    border: none;
    border-radius: 12px;
    background: rgba(30, 41, 59, 0.8);
    color: var(--text-primary);
    font-size: 20px;
    cursor: pointer;
    backdrop-filter: blur(10px);
    border: 1px solid var(--border-color);
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.2s ease;
}

.mobile-btn:active {
    transform: scale(0.95);
    background: rgba(30, 41, 59, 0.95);
}

/* 移动端地图按钮 */
#mobile-map-btn {
    position: absolute;
    bottom: 200px;
    right: 55px;
    z-index: 150;
    display: none;
    width: 50px;
    height: 50px;
    border: none;
    border-radius: 12px;
    background: rgba(30, 41, 59, 0.8);
    color: var(--text-primary);
    font-size: 20px;
    cursor: pointer;
    backdrop-filter: blur(10px);
    border: 1px solid var(--border-color);
    pointer-events: auto;
}

#mobile-map-btn:active {
    transform: scale(0.95);
}

/* 移动端响应式调整 */
@media (max-width: 1024px) and (pointer: coarse) {

    /* 隐藏桌面端元素 */
    .desktop-only {
        display: none !important;
    }

    /* 移动端顶部栏 - 三等分布局 */
    #mobile-top-bar {
        display: flex !important;
        position: absolute;
        top: 10px;
        left: 10px;
        right: 10px;
        padding: 8px 12px;
        justify-content: space-between;
        align-items: center;
        z-index: 100;
    }

    .top-bar-section {
        flex: 1;
        display: flex;
        align-items: center;
    }

    .top-bar-section.left {
        justify-content: flex-start;
    }

    .top-bar-section.center {
        justify-content: center;
        gap: 12px;
    }

    .top-bar-section.right {
        justify-content: flex-end;
    }

    /* 移动端小指南针 */
    .compass-small {
        width: 32px;
        height: 32px;
        border-radius: 50%;
        background: rgba(30, 41, 59, 0.9);
        border: 2px solid rgba(255, 255, 255, 0.4);
        position: relative;
        display: flex;
        align-items: center;
        justify-content: center;
    }

    #compass-needle-mobile {
        width: 3px;
        height: 20px;
        background: linear-gradient(to bottom, #ef4444 50%, white 50%);
        border-radius: 2px;
    }

    .compass-n {
        display: none;
    }

    /* 移动端时间距离显示 */
    #timer-mobile,
    #distance-mobile {
        font-size: 14px;
        font-weight: 600;
        color: var(--text-primary);
    }

    /* 移动端小暂停按钮 */
    .mobile-btn-small {
        width: 32px;
        height: 32px;
        min-width: 32px;
        min-height: 32px;
        border-radius: 50%;
        background: var(--bg-card);
        border: 1px solid var(--border-color);
        color: var(--text-primary);
        cursor: pointer;
        pointer-events: auto;
        display: flex;
        align-items: center;
        justify-content: center;
        padding: 0;
    }

    .mobile-btn-small svg {
        width: 14px;
        height: 14px;
    }

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

    #bottom-hud {
        display: none;
    }

    /* 小地图调整 - 移动端放右下角，与摇杆同高 */
    #minimap-container {
        bottom: 40px;
        top: auto;
        right: 20px;
        transform: none;
        width: 120px;
        height: 120px;
    }

    #minimap-container.expanded {
        width: 90vw;
        height: 90vw;
        max-width: 500px;
        max-height: 500px;
        bottom: 50%;
        right: 50%;
        transform: translate(50%, 50%);
    }

    /* 开始界面调整 */
    .difficulty-select {
        flex-direction: column;
        gap: 8px;
    }

    .screen h1 {
        font-size: 32px;
    }

    .screen .instructions {
        padding: 12px 16px;
        margin: 12px 20px;
    }

    .screen .instructions p {
        font-size: 12px;
    }

    .lang-select {
        top: auto;
        bottom: 80px;
        right: 50%;
        transform: translateX(50%);
    }

    /* 移动端控制列表按钮 - 放在小地图左边 */
    #mobile-list-btn {
        position: fixed;
        bottom: 80px;
        right: 150px;
    }

    /* 移动端控制列表 - 居中显示 */
    #control-desc-container {
        position: fixed;
        top: 50%;
        left: 50%;
        transform: translate(-50%, -50%);
        max-height: 70vh;
        overflow-y: auto;
    }
}