/* ===== 全局重置 ===== */
* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
    -webkit-tap-highlight-color: transparent;
    -webkit-touch-callout: none;
    -webkit-user-select: none;
    user-select: none;
}

html, body {
    width: 100%;
    height: 100%;
    overflow: hidden;
    background: #1a2a3a;
    font-family: -apple-system, BlinkMacSystemFont, "PingFang SC", "Microsoft YaHei", sans-serif;
    touch-action: none;
}

/* ===== 游戏画布（底层） ===== */
#gameCanvas {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    z-index: 1;
    display: block;
    background: linear-gradient(180deg, #c8dce8 0%, #e8f0f5 30%, #f5f8fa 100%);
}

/* ===== 屏幕覆盖层（UI 层） ===== */
.screen {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    z-index: 10;
    display: flex;
    align-items: center;
    justify-content: center;
    background: rgba(20, 40, 60, 0.55);
    backdrop-filter: blur(8px);
    -webkit-backdrop-filter: blur(8px);
    pointer-events: auto;
}

.screen.hidden {
    display: none;
}

.screen-inner {
    width: 86%;
    max-width: 420px;
    padding: 32px 24px;
    text-align: center;
}

/* ===== 标题 ===== */
.title {
    font-size: 32px;
    font-weight: 700;
    color: #ffffff;
    text-shadow: 0 2px 12px rgba(0, 0, 0, 0.3);
    margin-bottom: 8px;
    letter-spacing: 2px;
}

.subtitle {
    font-size: 14px;
    color: rgba(255, 255, 255, 0.85);
    margin-bottom: 28px;
    line-height: 1.5;
}

/* ===== 滑雪板选择 ===== */
.board-select {
    margin-bottom: 28px;
}

.select-label {
    font-size: 15px;
    color: rgba(255, 255, 255, 0.9);
    margin-bottom: 14px;
    font-weight: 500;
}

.board-options {
    display: flex;
    gap: 12px;
    justify-content: center;
}

.board-btn {
    flex: 1;
    padding: 16px 8px;
    border: 2px solid rgba(255, 255, 255, 0.3);
    border-radius: 14px;
    background: rgba(255, 255, 255, 0.1);
    color: #fff;
    cursor: pointer;
    transition: all 0.2s ease;
    pointer-events: auto;
}

.board-btn.active {
    border-color: #4fc3f7;
    background: rgba(79, 195, 247, 0.25);
    box-shadow: 0 0 16px rgba(79, 195, 247, 0.4);
}

.board-btn:active {
    transform: scale(0.96);
}

.board-icon {
    display: block;
    font-size: 36px;
    margin-bottom: 6px;
}

.board-name {
    display: block;
    font-size: 16px;
    font-weight: 600;
    margin-bottom: 4px;
}

.board-desc {
    display: block;
    font-size: 11px;
    color: rgba(255, 255, 255, 0.7);
    line-height: 1.3;
}

/* ===== 按钮 ===== */
.primary-btn {
    width: 100%;
    padding: 16px;
    font-size: 18px;
    font-weight: 600;
    color: #fff;
    background: linear-gradient(135deg, #4fc3f7 0%, #29b6f6 100%);
    border: none;
    border-radius: 14px;
    cursor: pointer;
    box-shadow: 0 6px 20px rgba(41, 182, 246, 0.4);
    transition: all 0.2s ease;
    pointer-events: auto;
}

.primary-btn:active {
    transform: scale(0.97);
    box-shadow: 0 3px 12px rgba(41, 182, 246, 0.3);
}

.secondary-btn {
    width: 100%;
    padding: 14px;
    font-size: 16px;
    font-weight: 500;
    color: #fff;
    background: rgba(255, 255, 255, 0.15);
    border: 1px solid rgba(255, 255, 255, 0.3);
    border-radius: 12px;
    cursor: pointer;
    margin-top: 12px;
    transition: all 0.2s ease;
    pointer-events: auto;
}

.secondary-btn:active {
    transform: scale(0.97);
    background: rgba(255, 255, 255, 0.25);
}

/* ===== 操作提示 ===== */
.tips {
    margin-top: 24px;
    text-align: center;
}

.tips p {
    font-size: 13px;
    color: rgba(255, 255, 255, 0.75);
    line-height: 1.8;
}

/* ===== HUD ===== */
.hud {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    z-index: 5;
    pointer-events: none;
    padding: env(safe-area-inset-top, 16px) 16px 0;
}

.hud.hidden {
    display: none;
}

.hud-top {
    display: flex;
    gap: 12px;
    align-items: flex-start;
}

.hud-item {
    background: rgba(0, 0, 0, 0.35);
    backdrop-filter: blur(6px);
    -webkit-backdrop-filter: blur(6px);
    border-radius: 10px;
    padding: 8px 14px;
    min-width: 70px;
}

.hud-label {
    display: block;
    font-size: 11px;
    color: rgba(255, 255, 255, 0.7);
    margin-bottom: 2px;
}

.hud-value {
    display: block;
    font-size: 18px;
    font-weight: 700;
    color: #fff;
}

.pause-btn {
    position: fixed;
    top: calc(env(safe-area-inset-top, 16px) + 8px);
    right: 16px;
    width: 44px;
    height: 44px;
    border-radius: 50%;
    background: rgba(0, 0, 0, 0.35);
    backdrop-filter: blur(6px);
    -webkit-backdrop-filter: blur(6px);
    border: none;
    color: #fff;
    font-size: 18px;
    cursor: pointer;
    pointer-events: auto;
    z-index: 6;
}

.pause-btn:active {
    transform: scale(0.92);
}

.skip-replay-btn {
    position: fixed;
    bottom: calc(env(safe-area-inset-bottom, 16px) + 24px);
    left: 50%;
    transform: translateX(-50%);
    padding: 12px 28px;
    border-radius: 26px;
    background: rgba(20, 24, 33, 0.88);
    backdrop-filter: blur(10px);
    -webkit-backdrop-filter: blur(10px);
    border: 1px solid rgba(255, 255, 255, 0.5);
    box-shadow: 0 4px 16px rgba(0, 0, 0, 0.35);
    color: #fff;
    font-size: 16px;
    font-weight: 600;
    cursor: pointer;
    pointer-events: auto;
    z-index: 6;
}

.skip-replay-btn:active {
    transform: translateX(-50%) scale(0.95);
}

.skip-replay-btn.hidden {
    display: none;
}

/* ===== 事故回放界面 ===== */
.fault-badge {
    display: inline-block;
    padding: 10px 24px;
    border-radius: 24px;
    font-size: 18px;
    font-weight: 700;
    margin: 16px 0;
    color: #fff;
}

.fault-badge.player {
    background: linear-gradient(135deg, #ef5350, #c62828);
    box-shadow: 0 4px 16px rgba(239, 83, 80, 0.4);
}

.fault-badge.ai {
    background: linear-gradient(135deg, #66bb6a, #2e7d32);
    box-shadow: 0 4px 16px rgba(102, 187, 106, 0.4);
}

.fault-badge.both {
    background: linear-gradient(135deg, #ffa726, #ef6c00);
    box-shadow: 0 4px 16px rgba(255, 167, 38, 0.4);
}

.rule-card {
    background: rgba(255, 255, 255, 0.12);
    border: 1px solid rgba(255, 255, 255, 0.2);
    border-radius: 12px;
    padding: 16px;
    margin-bottom: 12px;
    text-align: left;
}

.rule-card::before {
    content: "📋 规则判定";
    display: block;
    font-size: 12px;
    color: rgba(255, 255, 255, 0.6);
    margin-bottom: 8px;
}

.rule-card p {
    font-size: 14px;
    color: #fff;
    line-height: 1.6;
}

.advice-card {
    background: rgba(79, 195, 247, 0.15);
    border: 1px solid rgba(79, 195, 247, 0.3);
    border-radius: 12px;
    padding: 16px;
    margin-bottom: 20px;
    text-align: left;
}

.advice-card::before {
    content: "💡 如何避免";
    display: block;
    font-size: 12px;
    color: rgba(79, 195, 247, 0.8);
    margin-bottom: 8px;
}

.advice-card p {
    font-size: 14px;
    color: rgba(255, 255, 255, 0.9);
    line-height: 1.6;
}

/* 回放中的提示条 */
.replay-indicator {
    position: fixed;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    z-index: 8;
    background: rgba(0, 0, 0, 0.6);
    color: #fff;
    padding: 12px 24px;
    border-radius: 8px;
    font-size: 16px;
    font-weight: 600;
    pointer-events: none;
    animation: pulse 1s ease-in-out infinite;
}

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

/* ===== 关卡选择卡片 ===== */
.level-select {
    margin-bottom: 20px;
}

.level-cards {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 10px;
}

.level-card {
    position: relative;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 4px;
    padding: 12px 8px;
    border-radius: 14px;
    background: rgba(255, 255, 255, 0.16);
    backdrop-filter: blur(6px);
    -webkit-backdrop-filter: blur(6px);
    border: 1.5px solid rgba(255, 255, 255, 0.25);
    color: #fff;
    cursor: pointer;
    transition: transform 0.15s, border-color 0.15s, background 0.15s;
}

.level-card:active {
    transform: scale(0.96);
}

.level-card.active {
    background: rgba(255, 255, 255, 0.28);
    border-color: rgba(255, 255, 255, 0.7);
    box-shadow: 0 2px 12px rgba(0, 0, 0, 0.25);
}

.level-card.locked {
    opacity: 0.45;
    cursor: not-allowed;
}

.level-dot {
    width: 22px;
    height: 22px;
    border-radius: 50%;
    box-shadow: 0 0 0 2px rgba(255, 255, 255, 0.4);
}

.level-name {
    font-size: 16px;
    font-weight: 700;
}

.level-diff {
    font-size: 12px;
    opacity: 0.75;
}

.level-stars {
    font-size: 13px;
    letter-spacing: 1px;
    min-height: 16px;
}

.level-lock {
    position: absolute;
    top: 6px;
    right: 8px;
    font-size: 14px;
}

/* ===== HUD 距离进度条 ===== */
.hud-distance {
    flex: 1;
    min-width: 0;
}

.distance-bar-bg {
    margin-top: 4px;
    height: 5px;
    width: 100%;
    border-radius: 3px;
    background: rgba(255, 255, 255, 0.2);
    overflow: hidden;
}

.distance-bar {
    height: 100%;
    width: 0%;
    border-radius: 3px;
    background: linear-gradient(90deg, #66bb6a, #43a047);
    transition: width 0.2s ease-out;
}

/* ===== 关卡结算界面 ===== */
.settlement-stars {
    font-size: 44px;
    letter-spacing: 8px;
    text-align: center;
    margin: 16px 0 20px;
    min-height: 52px;
}

.settlement-stars .star-dim {
    opacity: 0.25;
    filter: grayscale(1);
}

.stat-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 10px;
    margin-bottom: 20px;
}

.stat-item {
    background: rgba(255, 255, 255, 0.12);
    border-radius: 10px;
    padding: 10px 12px;
    text-align: center;
}

.stat-item .stat-label {
    display: block;
    font-size: 12px;
    opacity: 0.75;
    margin-bottom: 4px;
}

.stat-item .stat-value {
    display: block;
    font-size: 20px;
    font-weight: 700;
}

