/* ============================================
   MBSGame - 多人坦克大战竞技场 样式表
   暗黑主题 + 霓虹色 + 玻璃拟态
   ============================================ */

:root {
    --bg-dark: #0a0e1a;
    --bg-card: rgba(15, 20, 40, 0.85);
    --bg-glass: rgba(255, 255, 255, 0.05);
    --border-glow: rgba(0, 200, 255, 0.3);
    --neon-cyan: #00d4ff;
    --neon-pink: #ff006e;
    --neon-green: #00ff88;
    --neon-orange: #ff8800;
    --neon-purple: #a855f7;
    --text-primary: #e8eaf0;
    --text-secondary: #8892a8;
    --text-dim: #4a5568;
    --hp-green: #2ecc71;
    --hp-yellow: #f1c40f;
    --hp-red: #e74c3c;
    --font-display: 'Orbitron', sans-serif;
    --font-body: 'Noto Sans SC', sans-serif;
    --shadow-neon: 0 0 20px rgba(0, 212, 255, 0.3);
    --shadow-card: 0 8px 32px rgba(0, 0, 0, 0.4);
    --radius: 12px;
    --radius-sm: 8px;
}

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

body {
    font-family: var(--font-body);
    background: var(--bg-dark);
    color: var(--text-primary);
    overflow: hidden;
    width: 100vw;
    height: 100vh;
    cursor: crosshair;
}

.screen {
    width: 100vw;
    height: 100vh;
    position: fixed;
    top: 0;
    left: 0;
}

/* ============================================
   开始界面
   ============================================ */

#start-screen {
    display: flex;
    align-items: center;
    justify-content: center;
    background: var(--bg-dark);
    background-image:
        radial-gradient(ellipse at 20% 50%, rgba(0, 212, 255, 0.08) 0%, transparent 50%),
        radial-gradient(ellipse at 80% 50%, rgba(255, 0, 110, 0.08) 0%, transparent 50%),
        radial-gradient(ellipse at 50% 100%, rgba(168, 85, 247, 0.06) 0%, transparent 40%);
    z-index: 100;
}

.start-container {
    text-align: center;
    padding: 60px 50px;
    background: var(--bg-card);
    border: 1px solid var(--border-glow);
    border-radius: 24px;
    backdrop-filter: blur(20px);
    box-shadow: var(--shadow-card), var(--shadow-neon);
    position: relative;
    max-width: 520px;
    width: 90%;
    animation: fadeInUp 0.8s ease-out;
}

@keyframes fadeInUp {
    from { opacity: 0; transform: translateY(40px); }
    to { opacity: 1; transform: translateY(0); }
}

.logo-glow {
    position: absolute;
    top: -60px;
    left: 50%;
    transform: translateX(-50%);
    width: 200px;
    height: 200px;
    background: radial-gradient(circle, rgba(0, 212, 255, 0.2), transparent 70%);
    border-radius: 50%;
    pointer-events: none;
    animation: pulse 3s ease-in-out infinite;
}

@keyframes pulse {
    0%, 100% { transform: translateX(-50%) scale(1); opacity: 0.6; }
    50% { transform: translateX(-50%) scale(1.2); opacity: 1; }
}

.game-title {
    font-family: var(--font-display);
    margin-bottom: 8px;
}

.title-line {
    display: block;
    font-size: 64px;
    font-weight: 900;
    letter-spacing: 12px;
    background: linear-gradient(135deg, var(--neon-cyan), var(--neon-pink));
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
    text-shadow: none;
    filter: drop-shadow(0 0 30px rgba(0, 212, 255, 0.4));
}

.title-sub {
    display: block;
    font-size: 18px;
    font-weight: 400;
    letter-spacing: 8px;
    color: var(--text-secondary);
    margin-top: 4px;
}

.game-desc {
    color: var(--text-dim);
    font-size: 14px;
    margin: 16px 0 32px;
}

.start-form {
    display: flex;
    flex-direction: column;
    gap: 16px;
    align-items: center;
}

#player-name {
    width: 100%;
    max-width: 320px;
    padding: 14px 20px;
    background: var(--bg-glass);
    border: 1px solid rgba(255, 255, 255, 0.1);
    border-radius: var(--radius);
    color: var(--text-primary);
    font-size: 16px;
    font-family: var(--font-body);
    outline: none;
    transition: all 0.3s ease;
    text-align: center;
}

#player-name:focus {
    border-color: var(--neon-cyan);
    box-shadow: 0 0 20px rgba(0, 212, 255, 0.2);
}

#player-name::placeholder {
    color: var(--text-dim);
}

.btn-primary {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    padding: 14px 36px;
    background: linear-gradient(135deg, var(--neon-cyan), #0088cc);
    border: none;
    border-radius: var(--radius);
    color: white;
    font-size: 16px;
    font-weight: 700;
    font-family: var(--font-body);
    cursor: pointer;
    transition: all 0.3s ease;
    text-transform: uppercase;
    letter-spacing: 2px;
}

.btn-primary:hover {
    transform: translateY(-2px);
    box-shadow: 0 8px 30px rgba(0, 212, 255, 0.4);
}

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

.btn-icon {
    font-size: 20px;
}

.controls-hint {
    display: flex;
    justify-content: center;
    gap: 24px;
    margin-top: 32px;
    flex-wrap: wrap;
}

.hint-item {
    display: flex;
    align-items: center;
    gap: 6px;
    color: var(--text-dim);
    font-size: 13px;
}

kbd {
    display: inline-block;
    padding: 3px 8px;
    background: rgba(255, 255, 255, 0.08);
    border: 1px solid rgba(255, 255, 255, 0.15);
    border-radius: 4px;
    font-size: 12px;
    font-family: var(--font-display);
    color: var(--text-secondary);
    min-width: 26px;
    text-align: center;
}

/* ============================================
   游戏画布
   ============================================ */

#game-canvas {
    display: block;
    width: 100vw;
    height: 100vh;
    background: #0d1117;
}

/* ============================================
   HUD
   ============================================ */

#hud {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    padding: 16px 20px;
    display: flex;
    justify-content: space-between;
    align-items: flex-start;
    pointer-events: none;
    z-index: 10;
}

#hud > * {
    pointer-events: auto;
}

#hud-left {
    display: flex;
    flex-direction: column;
    gap: 10px;
}

.hud-hp {
    display: flex;
    align-items: center;
    gap: 10px;
    background: var(--bg-card);
    border: 1px solid rgba(255, 255, 255, 0.08);
    border-radius: var(--radius-sm);
    padding: 8px 14px;
    backdrop-filter: blur(10px);
}

.hp-label {
    font-family: var(--font-display);
    font-size: 13px;
    font-weight: 700;
    color: var(--neon-cyan);
    letter-spacing: 2px;
}

.hp-bar-outer {
    width: 180px;
    height: 14px;
    background: rgba(255, 255, 255, 0.08);
    border-radius: 7px;
    overflow: hidden;
}

.hp-bar-inner {
    width: 100%;
    height: 100%;
    background: linear-gradient(90deg, var(--hp-green), #27ae60);
    border-radius: 7px;
    transition: width 0.3s ease, background 0.3s ease;
    box-shadow: 0 0 10px rgba(46, 204, 113, 0.5);
}

.hp-bar-inner.warning {
    background: linear-gradient(90deg, var(--hp-yellow), #e67e22);
    box-shadow: 0 0 10px rgba(241, 196, 15, 0.5);
}

.hp-bar-inner.danger {
    background: linear-gradient(90deg, var(--hp-red), #c0392b);
    box-shadow: 0 0 10px rgba(231, 76, 60, 0.5);
    animation: hpPulse 0.6s ease-in-out infinite;
}

@keyframes hpPulse {
    0%, 100% { opacity: 1; }
    50% { opacity: 0.6; }
}

.hp-text {
    font-family: var(--font-display);
    font-size: 12px;
    color: var(--text-secondary);
    min-width: 60px;
    text-align: right;
}

.hud-stats {
    display: flex;
    gap: 12px;
}

.stat-item {
    display: flex;
    align-items: center;
    gap: 6px;
    background: var(--bg-card);
    border: 1px solid rgba(255, 255, 255, 0.08);
    border-radius: var(--radius-sm);
    padding: 6px 12px;
    backdrop-filter: blur(10px);
    font-family: var(--font-display);
    font-size: 14px;
    font-weight: 700;
}

.stat-icon {
    font-size: 16px;
}

.buff-container {
    display: flex;
    gap: 6px;
}

.buff-icon {
    background: var(--bg-card);
    border-radius: 6px;
    padding: 4px 8px;
    font-size: 16px;
    border: 1px solid rgba(255, 255, 255, 0.1);
    animation: buffGlow 1s ease-in-out infinite alternate;
}

@keyframes buffGlow {
    from { box-shadow: 0 0 5px rgba(0, 255, 136, 0.3); }
    to { box-shadow: 0 0 15px rgba(0, 255, 136, 0.6); }
}

/* ============================================
   排行榜
   ============================================ */

.leaderboard {
    background: var(--bg-card);
    border: 1px solid rgba(255, 255, 255, 0.08);
    border-radius: var(--radius);
    padding: 12px 16px;
    backdrop-filter: blur(10px);
    min-width: 200px;
}

.lb-title {
    font-family: var(--font-display);
    font-size: 13px;
    font-weight: 700;
    color: var(--neon-orange);
    letter-spacing: 1px;
    margin-bottom: 8px;
    text-align: center;
}

.lb-item {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 4px 0;
    font-size: 13px;
    border-bottom: 1px solid rgba(255, 255, 255, 0.04);
}

.lb-item:last-child {
    border-bottom: none;
}

.lb-rank {
    font-family: var(--font-display);
    font-weight: 700;
    font-size: 12px;
    color: var(--text-dim);
    min-width: 22px;
}

.lb-rank.top1 { color: #FFD700; }
.lb-rank.top2 { color: #C0C0C0; }
.lb-rank.top3 { color: #CD7F32; }

.lb-name {
    flex: 1;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
    color: var(--text-primary);
}

.lb-score {
    font-family: var(--font-display);
    font-size: 12px;
    color: var(--neon-cyan);
    font-weight: 700;
}

.lb-me {
    background: rgba(0, 212, 255, 0.1);
    border-radius: 4px;
    padding: 4px 4px;
}

/* ============================================
   小地图
   ============================================ */

#minimap {
    position: fixed;
    bottom: 20px;
    right: 20px;
    border: 2px solid rgba(0, 212, 255, 0.3);
    border-radius: var(--radius-sm);
    background: rgba(10, 14, 26, 0.8);
    backdrop-filter: blur(5px);
    z-index: 10;
}

/* ============================================
   更改游戏按钮
   ============================================ */

.btn-change-game {
    position: fixed;
    bottom: 20px;
    left: 20px;
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 12px 20px;
    background: linear-gradient(135deg, rgba(168, 85, 247, 0.8), rgba(255, 0, 110, 0.8));
    border: 1px solid rgba(255, 255, 255, 0.2);
    border-radius: var(--radius);
    color: white;
    font-size: 14px;
    font-weight: 700;
    font-family: var(--font-body);
    cursor: pointer;
    transition: all 0.3s ease;
    z-index: 10;
    backdrop-filter: blur(10px);
}

.btn-change-game:hover {
    transform: translateY(-3px);
    box-shadow: 0 8px 30px rgba(168, 85, 247, 0.5);
}

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

.change-icon {
    font-size: 18px;
    animation: spin 4s linear infinite;
}

@keyframes spin {
    from { transform: rotate(0deg); }
    to { transform: rotate(360deg); }
}

/* ============================================
   模态框
   ============================================ */

.modal {
    position: fixed;
    top: 0;
    left: 0;
    width: 100vw;
    height: 100vh;
    z-index: 1000;
    display: flex;
    align-items: center;
    justify-content: center;
}

.modal-backdrop {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.7);
    backdrop-filter: blur(8px);
}

.modal-content {
    position: relative;
    background: var(--bg-card);
    border: 1px solid var(--border-glow);
    border-radius: 20px;
    padding: 0;
    width: 90%;
    max-width: 520px;
    box-shadow: var(--shadow-card), 0 0 60px rgba(0, 212, 255, 0.15);
    animation: modalIn 0.3s ease-out;
    overflow: hidden;
}

@keyframes modalIn {
    from { opacity: 0; transform: scale(0.9) translateY(20px); }
    to { opacity: 1; transform: scale(1) translateY(0); }
}

.modal-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 20px 24px;
    border-bottom: 1px solid rgba(255, 255, 255, 0.06);
}

.modal-header h2 {
    font-family: var(--font-display);
    font-size: 18px;
    font-weight: 700;
    color: var(--neon-purple);
}

.btn-close {
    background: none;
    border: none;
    color: var(--text-dim);
    font-size: 28px;
    cursor: pointer;
    line-height: 1;
    transition: color 0.2s ease;
    padding: 0 4px;
}

.btn-close:hover {
    color: var(--neon-pink);
}

.modal-body {
    padding: 20px 24px;
}

.modal-desc {
    color: var(--text-secondary);
    font-size: 14px;
    margin-bottom: 16px;
    line-height: 1.6;
}

#suggestion-input {
    width: 100%;
    padding: 14px 16px;
    background: var(--bg-glass);
    border: 1px solid rgba(255, 255, 255, 0.1);
    border-radius: var(--radius-sm);
    color: var(--text-primary);
    font-size: 14px;
    font-family: var(--font-body);
    resize: vertical;
    outline: none;
    transition: border-color 0.3s ease;
    line-height: 1.6;
}

#suggestion-input:focus {
    border-color: var(--neon-purple);
    box-shadow: 0 0 20px rgba(168, 85, 247, 0.15);
}

#suggestion-input::placeholder {
    color: var(--text-dim);
}

.suggestion-status {
    margin-top: 14px;
    padding: 12px 16px;
    border-radius: var(--radius-sm);
    font-size: 14px;
    line-height: 1.5;
    animation: fadeIn 0.3s ease;
}

@keyframes fadeIn {
    from { opacity: 0; }
    to { opacity: 1; }
}

.suggestion-status.success {
    background: rgba(0, 255, 136, 0.1);
    border: 1px solid rgba(0, 255, 136, 0.3);
    color: var(--neon-green);
}

.suggestion-status.error {
    background: rgba(255, 0, 110, 0.1);
    border: 1px solid rgba(255, 0, 110, 0.3);
    color: var(--neon-pink);
}

.suggestion-status.info {
    background: rgba(0, 212, 255, 0.1);
    border: 1px solid rgba(0, 212, 255, 0.3);
    color: var(--neon-cyan);
}

.modal-footer {
    padding: 16px 24px 24px;
    text-align: right;
}

.btn-submit {
    padding: 12px 28px;
    background: linear-gradient(135deg, var(--neon-purple), var(--neon-pink));
}

.btn-submit:hover {
    box-shadow: 0 8px 30px rgba(168, 85, 247, 0.4);
}

.btn-submit:disabled {
    opacity: 0.5;
    cursor: not-allowed;
    transform: none !important;
    box-shadow: none !important;
}

/* ============================================
   死亡界面
   ============================================ */

#death-overlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 100vw;
    height: 100vh;
    background: rgba(0, 0, 0, 0.6);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 50;
    backdrop-filter: blur(4px);
}

.death-content {
    text-align: center;
    animation: deathIn 0.5s ease-out;
}

@keyframes deathIn {
    from { opacity: 0; transform: scale(1.3); }
    to { opacity: 1; transform: scale(1); }
}

.death-title {
    font-family: var(--font-display);
    font-size: 36px;
    font-weight: 900;
    color: var(--hp-red);
    text-shadow: 0 0 40px rgba(231, 76, 60, 0.5);
    margin-bottom: 12px;
}

.death-timer {
    font-size: 18px;
    color: var(--text-secondary);
}

/* ============================================
   系统消息
   ============================================ */

.system-messages {
    position: fixed;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    z-index: 500;
    display: flex;
    flex-direction: column;
    gap: 8px;
    pointer-events: none;
    max-width: 500px;
    width: 90%;
}

.sys-msg {
    padding: 14px 20px;
    background: var(--bg-card);
    border: 1px solid var(--border-glow);
    border-radius: var(--radius-sm);
    backdrop-filter: blur(15px);
    font-size: 14px;
    text-align: center;
    animation: sysMsgIn 0.4s ease-out;
    box-shadow: var(--shadow-card);
}

.sys-msg.success {
    border-color: rgba(0, 255, 136, 0.4);
    color: var(--neon-green);
}

.sys-msg.error {
    border-color: rgba(255, 0, 110, 0.4);
    color: var(--neon-pink);
}

.sys-msg.info {
    border-color: rgba(0, 212, 255, 0.4);
    color: var(--neon-cyan);
}

@keyframes sysMsgIn {
    from { opacity: 0; transform: translateY(-20px); }
    to { opacity: 1; transform: translateY(0); }
}

/* ============================================
   重连界面
   ============================================ */

.reconnect-overlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 100vw;
    height: 100vh;
    background: rgba(10, 14, 26, 0.95);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 2000;
    backdrop-filter: blur(10px);
}

.reconnect-content {
    text-align: center;
    animation: fadeInUp 0.6s ease-out;
}

.reconnect-spinner {
    width: 50px;
    height: 50px;
    border: 3px solid rgba(0, 212, 255, 0.2);
    border-top-color: var(--neon-cyan);
    border-radius: 50%;
    margin: 0 auto 24px;
    animation: spinFast 0.8s linear infinite;
}

@keyframes spinFast {
    to { transform: rotate(360deg); }
}

.reconnect-content h2 {
    font-family: var(--font-display);
    font-size: 24px;
    color: var(--neon-cyan);
    margin-bottom: 12px;
}

.reconnect-content p {
    color: var(--text-secondary);
    font-size: 15px;
    margin-bottom: 20px;
}

.reconnect-dots {
    display: flex;
    justify-content: center;
    gap: 8px;
}

.reconnect-dots span {
    width: 10px;
    height: 10px;
    background: var(--neon-cyan);
    border-radius: 50%;
    animation: dotBounce 1.4s ease-in-out infinite;
}

.reconnect-dots span:nth-child(2) { animation-delay: 0.2s; }
.reconnect-dots span:nth-child(3) { animation-delay: 0.4s; }

@keyframes dotBounce {
    0%, 80%, 100% { transform: scale(0.4); opacity: 0.3; }
    40% { transform: scale(1); opacity: 1; }
}

/* ============================================
   虚拟摇杆
   ============================================ */

#joystick-zone {
    position: fixed;
    bottom: 80px;
    left: 40px;
    width: 130px;
    height: 130px;
    z-index: 100;
    display: none; /* 默认隐藏，仅通过媒体查询在移动端显示 */
    touch-action: none; /* 禁止浏览器默认的触摸行为（如滚动） */
}

#joystick-base {
    width: 100%;
    height: 100%;
    background: rgba(15, 20, 40, 0.5);
    border: 2px solid rgba(0, 212, 255, 0.3);
    border-radius: 50%;
    box-sizing: border-box;
    backdrop-filter: blur(8px);
    display: flex;
    align-items: center;
    justify-content: center;
    position: relative;
    box-shadow: 0 0 15px rgba(0, 0, 0, 0.4);
}

#joystick-stick {
    width: 50px;
    height: 50px;
    background: radial-gradient(circle at 30% 30%, var(--neon-cyan), #006080);
    border-radius: 50%;
    box-shadow: 0 0 12px rgba(0, 212, 255, 0.6);
    position: absolute;
    transform: translate(0, 0); /* JS 会控制这个值 */
    pointer-events: none; /* 让触摸事件穿透到 base，便于统一处理 */
}

/* ============================================
   响应式
   ============================================ */

@media (max-width: 640px) {
    .title-line { font-size: 42px; letter-spacing: 6px; }
    .title-sub { font-size: 14px; letter-spacing: 5px; }
    .start-container { padding: 40px 24px; }
    .controls-hint { gap: 12px; }
    .hud-hp { padding: 6px 10px; }
    .hp-bar-outer { width: 120px; }
    .leaderboard { min-width: 160px; padding: 10px 12px; }
    .btn-change-game { padding: 10px 14px; font-size: 12px; }
    #minimap { width: 120px; height: 120px; }
}

/* 移动端（触摸设备）显示摇杆 */
@media (max-width: 1024px) {
    #joystick-zone {
        display: block;
    }
}