/* iOS 蓝白风格全局样式 */
:root {
    --ios-blue: #007AFF;
    --ios-blue-dark: #0051D5;
    --ios-bg: #F2F2F7;
    --ios-card: #FFFFFF;
    --ios-text: #1D1D1F;
    --ios-text-2: #86868B;
    --ios-border: rgba(0,0,0,0.08);
    --ios-radius: 14px;
    --ios-shadow: 0 1px 3px rgba(0,0,0,0.06), 0 6px 20px rgba(0,0,0,0.04);
}

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

body {
    font-family: -apple-system, BlinkMacSystemFont, 'SF Pro Display',
                 'PingFang SC', 'Helvetica Neue', sans-serif;
    background: var(--ios-bg);
    color: var(--ios-text);
    -webkit-font-smoothing: antialiased;
    min-height: 100vh;
}

a { color: var(--ios-blue); text-decoration: none; }

/* 按钮 */
.ios-btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    padding: 12px 22px;
    background: #E5E5EA;
    color: var(--ios-text);
    border: none;
    border-radius: 12px;
    font-size: 16px;
    font-weight: 600;
    cursor: pointer;
    transition: all .15s;
    letter-spacing: -.2px;
    font-family: inherit;
}
.ios-btn:hover { filter: brightness(0.96); }
.ios-btn:active { transform: scale(0.97); }
.ios-btn.primary { background: var(--ios-blue); color: white; }
.ios-btn.primary:hover { background: var(--ios-blue-dark); }
.ios-btn.small { padding: 8px 14px; font-size: 14px; }
.ios-btn.ghost { background: transparent; color: var(--ios-blue); }
.ios-btn.owned { background: #C7C7CC; color: #fff; cursor: default; }
.ios-btn:disabled { opacity: .7; cursor: default; }
.ios-btn.active { background: var(--ios-blue); color: #fff; }

/* 输入框 */
.ios-input {
    width: 100%;
    padding: 14px 16px;
    border: 1px solid var(--ios-border);
    border-radius: 12px;
    font-size: 16px;
    background: var(--ios-bg);
    outline: none;
    transition: all .2s;
    margin-bottom: 12px;
    font-family: inherit;
    color: var(--ios-text);
}
.ios-input:focus {
    border-color: var(--ios-blue);
    background: #fff;
    box-shadow: 0 0 0 4px rgba(0,122,255,0.12);
}

/* 卡片 */
.ios-card {
    background: var(--ios-card);
    border-radius: var(--ios-radius);
    box-shadow: var(--ios-shadow);
    padding: 22px;
    margin-bottom: 16px;
}

/* ------- 登录页 ------- */
.auth-page {
    display: flex;
    align-items: center;
    justify-content: center;
    min-height: 100vh;
    background: linear-gradient(160deg, #EAF2FF 0%, #F2F2F7 55%);
    padding: 20px;
}
.auth-card {
    width: 100%;
    max-width: 400px;
    background: #fff;
    border-radius: 20px;
    padding: 40px 30px;
    box-shadow: 0 10px 40px rgba(0,80,200,0.12);
    text-align: center;
}
.auth-card .logo { font-size: 56px; margin-bottom: 8px; }
.auth-card h1 { font-size: 26px; font-weight: 700; margin-bottom: 6px; }
.auth-card .subtitle { color: var(--ios-text-2); font-size: 14px; margin-bottom: 26px; }

.tabs {
    display: flex;
    background: var(--ios-bg);
    border-radius: 12px;
    padding: 4px;
    margin-bottom: 20px;
}
.tab {
    flex: 1;
    border: none;
    background: transparent;
    padding: 10px;
    border-radius: 9px;
    font-size: 15px;
    font-weight: 600;
    cursor: pointer;
    color: var(--ios-text-2);
    font-family: inherit;
    transition: all .2s;
}
.tab.active {
    background: #fff;
    color: var(--ios-blue);
    box-shadow: 0 1px 3px rgba(0,0,0,0.08);
}
.tab-content { display: none; text-align: left; }
.tab-content.active { display: block; }
.tab-content .ios-btn { width: 100%; margin-top: 6px; }
.error-msg { color: #FF3B30; font-size: 14px; margin-top: 10px; min-height: 18px; text-align: center; }

/* ------- 顶栏 ------- */
.top-bar {
    background: #fff;
    padding: 12px 24px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    border-bottom: 1px solid var(--ios-border);
    position: sticky;
    top: 0;
    z-index: 10;
    box-shadow: 0 1px 6px rgba(0,0,0,0.03);
}
.user-info { display: flex; align-items: center; gap: 8px; font-weight: 600; }
.avatar {
    width: 34px; height: 34px;
    background: linear-gradient(135deg, #007AFF, #5AC8FA);
    color: white;
    border-radius: 50%;
    display: flex; align-items: center; justify-content: center;
    font-size: 16px;
}
.coins { font-weight: 700; color: #FF9500; font-size: 16px; }
.nav { display: flex; gap: 8px; }

/* ------- 大厅 ------- */
.lobby-main {
    max-width: 1100px;
    margin: 0 auto;
    padding: 32px 24px 60px;
}
.lobby-main h1 { font-size: 32px; margin-bottom: 24px; font-weight: 700; letter-spacing: -.5px; }

.map-select {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(260px, 1fr));
    gap: 16px;
    margin-bottom: 28px;
}
.map-card {
    background: #fff;
    border-radius: 16px;
    padding: 22px;
    cursor: pointer;
    transition: all .2s;
    border: 2px solid transparent;
    box-shadow: var(--ios-shadow);
}
.map-card:hover { transform: translateY(-3px); box-shadow: 0 12px 30px rgba(0,80,200,0.12); }
.map-card.active { border-color: var(--ios-blue); box-shadow: 0 8px 24px rgba(0,122,255,0.2); }
.map-thumb {
    height: 120px;
    border-radius: 12px;
    display: flex; align-items: center; justify-content: center;
    font-size: 56px;
    margin-bottom: 14px;
    background: linear-gradient(135deg, #C9E2FF, #EAF2FF);
}
.map-thumb.western { background: linear-gradient(135deg, #FFE8B5, #FFF3DA); }
.map-card h3 { font-size: 20px; margin-bottom: 4px; }
.map-card p { color: var(--ios-text-2); font-size: 14px; }

.room-actions {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(280px, 1fr));
    gap: 16px;
    margin-bottom: 20px;
}
.room-actions h3 { font-size: 17px; margin-bottom: 12px; font-weight: 600; }
.room-actions label { display: block; font-size: 13px; color: var(--ios-text-2); margin-bottom: 6px; margin-top: 10px; }
.room-actions .ios-btn { width: 100%; margin-top: 12px; }
.hint { font-size: 13px; color: var(--ios-text-2); margin-top: 10px; }

#room-info { margin-top: 20px; }
#room-players { list-style: none; margin: 12px 0; }
#room-players li { padding: 8px 12px; background: var(--ios-bg); border-radius: 8px; margin-bottom: 6px; font-size: 14px; }
.hidden { display: none !important; }

/* ------- 商城 ------- */
.shop-main {
    max-width: 1200px;
    margin: 0 auto;
    padding: 32px 24px 60px;
}
.shop-main h1 { font-size: 32px; margin-bottom: 20px; font-weight: 700; }
.recharge-row { display: flex; flex-wrap: wrap; gap: 10px; margin-bottom: 20px; }
.filter-row { display: flex; gap: 8px; margin-bottom: 22px; }
.shop-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(260px, 1fr));
    gap: 18px;
}
.weapon-card {
    background: #fff;
    border-radius: 16px;
    padding: 18px;
    box-shadow: var(--ios-shadow);
    transition: all .2s;
}
.weapon-card:hover { transform: translateY(-3px); box-shadow: 0 12px 30px rgba(0,80,200,0.1); }
.weapon-preview {
    height: 120px;
    border-radius: 12px;
    display: flex; align-items: center; justify-content: center;
    position: relative;
    margin-bottom: 12px;
}
.gun-model { font-size: 60px; }
.type-tag {
    position: absolute;
    top: 10px; right: 10px;
    font-size: 11px;
    padding: 3px 9px;
    border-radius: 20px;
    background: #007AFF;
    color: #fff;
    font-weight: 600;
}
.type-tag.sniper { background: #FF9500; }
.weapon-card h3 { font-size: 18px; margin-bottom: 4px; }
.weapon-card .desc { color: var(--ios-text-2); font-size: 13px; margin-bottom: 12px; }
.stats { margin-bottom: 14px; }
.stat-row {
    display: grid;
    grid-template-columns: 40px 1fr 32px;
    align-items: center;
    gap: 8px;
    font-size: 12px;
    margin-bottom: 5px;
    color: var(--ios-text-2);
}
.stat-bar { height: 5px; background: #E5E5EA; border-radius: 3px; overflow: hidden; }
.stat-fill { height: 100%; background: linear-gradient(90deg, #007AFF, #5AC8FA); border-radius: 3px; }
.stat-val { text-align: right; color: var(--ios-text); font-weight: 600; }
.weapon-footer { display: flex; align-items: center; justify-content: space-between; }
.price { font-weight: 700; color: #FF9500; font-size: 16px; }

/* ------- 游戏页 ------- */
.game-body {
    margin: 0; padding: 0;
    overflow: hidden;
    background: #000;
    height: 100vh;
    width: 100vw;
    font-family: -apple-system, 'PingFang SC', sans-serif;
}
#game-canvas { display: block; width: 100vw; height: 100vh; }

/* HUD */
.hud { position: fixed; inset: 0; pointer-events: none; z-index: 100; }
.hud-score {
    position: absolute; top: 20px; left: 50%;
    transform: translateX(-50%);
    background: rgba(0,0,0,0.55);
    backdrop-filter: blur(10px);
    color: #fff;
    padding: 8px 22px;
    border-radius: 20px;
    font-size: 22px;
    font-weight: 700;
    font-variant-numeric: tabular-nums;
    display: flex;
    gap: 24px;
}
.hud-score .me { color: #5AC8FA; }
.hud-score .enemy { color: #FF453A; }
.hud-crosshair {
    position: absolute; top: 50%; left: 50%;
    transform: translate(-50%, -50%);
    width: 18px; height: 18px;
    pointer-events: none;
}
.hud-crosshair::before, .hud-crosshair::after {
    content: '';
    position: absolute;
    background: rgba(255,255,255,0.9);
    box-shadow: 0 0 0 1px rgba(0,0,0,0.4);
}
.hud-crosshair::before { top: 50%; left: 0; width: 100%; height: 2px; transform: translateY(-50%); }
.hud-crosshair::after { left: 50%; top: 0; height: 100%; width: 2px; transform: translateX(-50%); }
.hud-hp {
    position: absolute; bottom: 30px; left: 30px;
    background: rgba(0,0,0,0.5);
    backdrop-filter: blur(10px);
    color: #fff;
    padding: 10px 20px;
    border-radius: 12px;
    font-size: 18px;
    font-weight: 600;
    display: flex;
    align-items: center;
    gap: 10px;
}
.hp-bar { width: 140px; height: 8px; background: rgba(255,255,255,0.2); border-radius: 4px; overflow: hidden; }
.hp-fill { height: 100%; background: linear-gradient(90deg, #30D158, #5AC8FA); transition: width .2s; }

.hud-weapon {
    position: absolute; bottom: 30px; right: 30px;
    background: rgba(0,0,0,0.5);
    backdrop-filter: blur(10px);
    color: #fff;
    padding: 10px 20px;
    border-radius: 12px;
    font-size: 16px;
    font-weight: 600;
    text-align: right;
}
.ammo { font-size: 26px; font-weight: 700; }

.hud-killfeed {
    position: absolute; top: 80px; right: 20px;
    display: flex; flex-direction: column; gap: 6px;
    align-items: flex-end;
}
.kill-msg {
    background: rgba(0,0,0,0.6);
    color: #fff;
    padding: 6px 12px;
    border-radius: 8px;
    font-size: 13px;
    animation: slideIn .3s ease;
}
@keyframes slideIn { from { opacity: 0; transform: translateX(20px); } }

/* 开始遮罩 */
.start-overlay {
    position: fixed; inset: 0;
    background: rgba(0,0,0,0.85);
    backdrop-filter: blur(20px);
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    z-index: 200;
    color: #fff;
    text-align: center;
    padding: 20px;
}
.start-overlay h1 { font-size: 42px; margin-bottom: 12px; }
.start-overlay p { font-size: 16px; color: #c0c0c0; margin-bottom: 24px; line-height: 1.8; }
.start-overlay .ios-btn { font-size: 18px; padding: 14px 40px; }
.start-overlay .room-code { font-size: 36px; color: #5AC8FA; font-weight: 700; letter-spacing: 4px; margin: 12px 0; }

.gameover-overlay { display: none; }
.gameover-overlay.show { display: flex; }

/* admin */
.admin-container { max-width: 1000px; margin: 0 auto; padding: 30px 24px 60px; }
.admin-container h1 { font-size: 28px; margin-bottom: 24px; }
.weapon-edit-form { display: grid; gap: 12px; }
.form-row { display: grid; grid-template-columns: 130px 1fr auto; align-items: center; gap: 12px; }
.form-row label { font-size: 14px; color: var(--ios-text-2); }
.form-row input[type="range"] { width: 100%; }
.form-row output { font-weight: 700; color: var(--ios-blue); min-width: 30px; }
.ios-alert { padding: 12px 18px; border-radius: 10px; margin-bottom: 16px; font-size: 14px; }
.ios-alert.success { background: #D1F2D9; color: #1B7A2E; }

@media (max-width: 640px) {
    .auth-card { padding: 30px 22px; }
    .lobby-main h1, .shop-main h1 { font-size: 24px; }
    .form-row { grid-template-columns: 1fr; }
}
/* ========== ESC 暂停菜单 ========== */
.escape-menu {
    position: fixed;
    inset: 0;
    background: rgba(0, 0, 0, 0.75);
    backdrop-filter: blur(20px);
    -webkit-backdrop-filter: blur(20px);
    display: none;
    align-items: center;
    justify-content: center;
    z-index: 300;
    cursor: default;
}
.escape-panel {
    background: rgba(30, 30, 32, 0.95);
    border-radius: 20px;
    padding: 40px 50px;
    text-align: center;
    color: #fff;
    box-shadow: 0 20px 60px rgba(0, 0, 0, 0.5);
    min-width: 320px;
}
.escape-panel h2 {
    font-size: 28px;
    font-weight: 700;
    margin-bottom: 8px;
    letter-spacing: -0.5px;
}
.escape-panel p {
    color: #98989d;
    font-size: 14px;
    margin-bottom: 28px;
}
.escape-panel .ios-btn {
    display: block;
    width: 100%;
    margin-bottom: 10px;
    font-size: 17px;
    padding: 14px 24px;
}
.escape-panel .ios-btn:last-child {
    margin-bottom: 0;
}
/* ========== 游戏页专用：屏蔽浏览器手势 ========== */
.game-body {
    touch-action: none;
    -webkit-user-select: none;
    user-select: none;
    overscroll-behavior: none;
}
#game-canvas {
    touch-action: none;
    cursor: crosshair;
    display: block;
    width: 100vw;
    height: 100vh;
}