* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

body {
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", "PingFang SC", "Hiragino Sans GB", "Microsoft YaHei", sans-serif;
    background: #0a0a1a;
    color: #fff;
    overflow: hidden;
    height: 100vh;
    width: 100vw;
    touch-action: none;
    user-select: none;
    -webkit-user-select: none;
}

.screen {
    position: fixed;
    top: 0; left: 0; right: 0; bottom: 0;
    display: none;
    justify-content: center;
    align-items: center;
    z-index: 10;
    transition: opacity 0.3s;
}
.screen.active { display: flex; }

/* ===== 主菜单 ===== */
#menu-screen {
    background: linear-gradient(135deg, #0a0a2e 0%, #1a1a3e 50%, #0d0d2a 100%);
}
.menu-content {
    text-align: center;
    padding: 2rem;
}
.title-icon {
    font-size: 5rem;
    margin-bottom: 1rem;
    animation: bounce 2s infinite;
}
@keyframes bounce {
    0%, 100% { transform: translateY(0); }
    50% { transform: translateY(-15px); }
}
.menu-content h1 {
    font-size: 2.8rem;
    background: linear-gradient(90deg, #ff6b6b, #ffa500, #ff6b6b);
    background-size: 200%;
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    animation: gradient 3s ease infinite;
    margin-bottom: 0.5rem;
}
@keyframes gradient {
    0%, 100% { background-position: 0% 50%; }
    50% { background-position: 100% 50%; }
}
.subtitle {
    font-size: 1.1rem;
    color: #aaa;
    margin-bottom: 2rem;
}
.menu-tips {
    margin-top: 1.5rem;
    color: #666;
    font-size: 0.85rem;
    line-height: 1.8;
}

/* ===== 按钮 ===== */
.btn-primary {
    display: block;
    width: 220px;
    margin: 0.6rem auto;
    padding: 14px 0;
    font-size: 1.15rem;
    font-weight: bold;
    color: #fff;
    background: linear-gradient(135deg, #ff6b6b, #ee5a24);
    border: none;
    border-radius: 50px;
    cursor: pointer;
    transition: transform 0.15s, box-shadow 0.15s;
    box-shadow: 0 4px 15px rgba(255, 107, 107, 0.4);
}
.btn-primary:active {
    transform: scale(0.95);
    box-shadow: 0 2px 8px rgba(255, 107, 107, 0.3);
}
.btn-secondary {
    display: block;
    width: 220px;
    margin: 0.6rem auto;
    padding: 12px 0;
    font-size: 1rem;
    color: #aaa;
    background: rgba(255,255,255,0.08);
    border: 1px solid rgba(255,255,255,0.15);
    border-radius: 50px;
    cursor: pointer;
    transition: transform 0.15s;
}
.btn-secondary:active { transform: scale(0.95); }

/* ===== 游戏 HUD ===== */
#game-screen {
    background: #0a0a1a;
    flex-direction: column;
}
#game-hud {
    display: flex;
    justify-content: space-around;
    padding: 10px 15px;
    background: rgba(0,0,0,0.6);
    backdrop-filter: blur(5px);
    z-index: 5;
    width: 100%;
}
.hud-item {
    display: flex;
    flex-direction: column;
    align-items: center;
}
.hud-label {
    font-size: 0.7rem;
    color: #888;
    text-transform: uppercase;
}
.hud-item span:last-child {
    font-size: 1.2rem;
    font-weight: bold;
    color: #ff6b6b;
}
#gameCanvas {
    flex: 1;
    width: 100%;
    display: block;
}

/* ===== 过渡画面 ===== */
#transition-screen {
    background: rgba(0,0,0,0.92);
    z-index: 20;
}
.transition-content {
    text-align: center;
    animation: fadeInUp 0.5s ease;
}
@keyframes fadeInUp {
    from { opacity: 0; transform: translateY(30px); }
    to { opacity: 1; transform: translateY(0); }
}
.transition-content h2 {
    font-size: 2rem;
    color: #ff6b6b;
    margin-bottom: 1rem;
}
.transition-content p {
    font-size: 1.1rem;
    color: #aaa;
}

/* ===== 死亡画面 ===== */
#death-screen {
    background: rgba(10, 10, 26, 0.95);
    z-index: 20;
}
.death-content {
    text-align: center;
    padding: 2rem;
    max-width: 360px;
    width: 90%;
    animation: fadeInUp 0.5s ease;
}
.death-icon {
    font-size: 4rem;
    margin-bottom: 0.5rem;
}
.death-content h2 {
    font-size: 1.8rem;
    color: #ff6b6b;
    margin-bottom: 1.2rem;
}
.death-stats {
    background: rgba(255,255,255,0.05);
    border-radius: 12px;
    padding: 1rem;
    margin-bottom: 1rem;
}
.stat-row {
    display: flex;
    justify-content: space-between;
    padding: 8px 0;
    font-size: 0.95rem;
    color: #ccc;
    border-bottom: 1px solid rgba(255,255,255,0.06);
}
.stat-row:last-child { border-bottom: none; }
.stat-row span:last-child { font-weight: bold; color: #fff; }
.stat-row.highlight span:last-child {
    color: #ffa500;
    font-size: 1.2rem;
}
.death-message {
    background: rgba(255, 107, 107, 0.1);
    border: 1px solid rgba(255, 107, 107, 0.3);
    border-radius: 10px;
    padding: 12px 16px;
    margin: 1rem 0;
    font-size: 0.9rem;
    line-height: 1.6;
    color: #ff9999;
}
.death-rank {
    font-size: 0.85rem;
    color: #888;
    margin-bottom: 1rem;
}

/* ===== 通关画面 ===== */
#win-screen {
    background: rgba(10, 10, 26, 0.95);
    z-index: 20;
}
.win-content {
    text-align: center;
    padding: 2rem;
    animation: fadeInUp 0.5s ease;
}
.win-icon {
    font-size: 5rem;
    margin-bottom: 1rem;
}
.win-content h2 {
    font-size: 1.8rem;
    color: #4ecdc4;
    margin-bottom: 1rem;
}
.win-desc {
    font-size: 1.1rem;
    color: #4ecdc4;
    margin-bottom: 0.5rem;
}
.win-sub {
    font-size: 0.9rem;
    color: #888;
    margin-bottom: 2rem;
}

/* ===== 排行榜预览 ===== */
.rank-preview {
    margin-top: 1.2rem;
    background: rgba(255,255,255,0.05);
    border-radius: 12px;
    padding: 10px 16px;
    max-width: 260px;
    margin-left: auto;
    margin-right: auto;
}
.rank-title {
    font-size: 0.85rem;
    color: #ffa500;
    margin-bottom: 6px;
    text-align: center;
}
.rank-row {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 3px 0;
    font-size: 0.8rem;
    color: #ccc;
}
.rank-pos { color: #ffa500; min-width: 24px; }
.rank-name { flex: 1; margin-left: 6px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.rank-score { color: #ff6b6b; font-weight: bold; min-width: 40px; text-align: right; }

/* ===== 响应式 ===== */
@media (max-height: 600px) {
    .menu-content h1 { font-size: 2rem; }
    .title-icon { font-size: 3.5rem; }
    .death-content h2 { font-size: 1.4rem; }
}
