* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
    -webkit-tap-highlight-color: transparent;
    touch-action: manipulation;
}

body {
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, 'Helvetica Neue', Arial, sans-serif;
    background: linear-gradient(135deg, #1a1a2e 0%, #16213e 50%, #0f3460 100%);
    min-height: 100vh;
    display: flex;
    flex-direction: column;
    align-items: center;
    user-select: none;
    -webkit-user-select: none;
    color: white;
    padding: 20px;
    gap: 20px;
    overscroll-behavior: none;
}

.page-wrapper {
    display: flex;
    gap: 20px;
    width: 100%;
    max-width: 1200px;
    align-items: flex-start;
}

.main-container {
    flex: 1;
    background: rgba(255, 255, 255, 0.05);
    -webkit-backdrop-filter: blur(16px);
    backdrop-filter: blur(16px);
    border-radius: 30px;
    padding: 30px;
    box-shadow: 0 8px 32px 0 rgba(0, 0, 0, 0.5);
    border: 1px solid rgba(255, 255, 255, 0.1);
    text-align: center;
    will-change: transform;
    transform: translateZ(0);
}

/* 排行榜样式 */
.leaderboard-container {
    width: 300px;
    background: rgba(255, 255, 255, 0.05);
    -webkit-backdrop-filter: blur(16px);
    backdrop-filter: blur(16px);
    border-radius: 20px;
    padding: 20px;
    box-shadow: 0 8px 32px 0 rgba(0, 0, 0, 0.5);
    border: 1px solid rgba(255, 255, 255, 0.1);
    position: sticky;
    top: 20px;
}

.leaderboard-title {
    font-size: 18px;
    font-weight: bold;
    color: #ffd700;
    margin-bottom: 15px;
    text-align: center;
}

.leaderboard-tabs {
    display: flex;
    gap: 5px;
    margin-bottom: 15px;
}

.leaderboard-tab {
    flex: 1;
    padding: 8px 5px;
    background: rgba(255, 255, 255, 0.1);
    border: 1px solid rgba(255, 255, 255, 0.2);
    border-radius: 8px;
    cursor: pointer;
    font-size: 12px;
    font-weight: 600;
    color: rgba(255, 255, 255, 0.7);
    transition: all 0.3s ease;
}

.leaderboard-tab:hover {
    background: rgba(255, 255, 255, 0.2);
}

.leaderboard-tab.active {
    background: #ffd700;
    color: #1a1a2e;
    border-color: #ffd700;
}

.leaderboard-list {
    max-height: 400px;
    overflow-y: auto;
}

.leaderboard-item {
    display: flex;
    align-items: center;
    padding: 10px;
    background: rgba(0, 0, 0, 0.2);
    border-radius: 8px;
    margin-bottom: 8px;
    transition: all 0.3s ease;
}

.leaderboard-item:hover {
    background: rgba(0, 0, 0, 0.3);
}

.leaderboard-rank {
    width: 30px;
    font-size: 16px;
    font-weight: bold;
    color: #ffd700;
}

.leaderboard-rank.top3 {
    color: #ff6b6b;
}

.leaderboard-score {
    width: 50px;
    font-size: 14px;
    font-weight: bold;
    color: #4ecdc4;
    text-align: right;
    margin-right: 10px;
}

.leaderboard-name {
    flex: 1;
    font-size: 13px;
    color: rgba(255, 255, 255, 0.9);
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.leaderboard-empty {
    text-align: center;
    padding: 30px;
    color: rgba(255, 255, 255, 0.5);
    font-size: 14px;
}

@media (max-width: 900px) {
    .page-wrapper {
        flex-direction: column;
    }
    .leaderboard-container {
        width: 100%;
        position: static;
    }
}

/* 昵称显示区域 */
.nickname-display {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 10px;
    margin-bottom: 15px;
    padding: 10px 15px;
    background: rgba(255, 215, 0, 0.1);
    border-radius: 25px;
    border: 1px solid rgba(255, 215, 0, 0.3);
}

.nickname-label {
    font-size: 12px;
    color: rgba(255, 255, 255, 0.7);
}

.nickname-value {
    font-size: 14px;
    font-weight: bold;
    color: #ffd700;
}

.nickname-edit-btn {
    padding: 4px 10px;
    background: rgba(255, 255, 255, 0.1);
    border: 1px solid rgba(255, 255, 255, 0.3);
    border-radius: 12px;
    color: rgba(255, 255, 255, 0.8);
    font-size: 11px;
    cursor: pointer;
    transition: all 0.3s ease;
}

.nickname-edit-btn:hover {
    background: rgba(255, 255, 255, 0.2);
}

/* 弹窗样式 */
.modal-overlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.8);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 1000;
    opacity: 0;
    visibility: hidden;
    transition: all 0.3s ease;
}

.modal-overlay.active {
    opacity: 1;
    visibility: visible;
}

.modal-content {
    background: linear-gradient(135deg, #1a1a2e 0%, #16213e 100%);
    border-radius: 20px;
    padding: 30px;
    width: 90%;
    max-width: 400px;
    border: 1px solid rgba(255, 255, 255, 0.2);
    box-shadow: 0 20px 60px rgba(0, 0, 0, 0.5);
    transform: scale(0.9);
    transition: all 0.3s ease;
}

.modal-overlay.active .modal-content {
    transform: scale(1);
}

.modal-title {
    font-size: 20px;
    font-weight: bold;
    color: #ffd700;
    margin-bottom: 10px;
    text-align: center;
}

.modal-desc {
    font-size: 12px;
    color: rgba(255, 255, 255, 0.6);
    margin-bottom: 20px;
    text-align: center;
}

.modal-input {
    width: 100%;
    padding: 12px 15px;
    background: rgba(255, 255, 255, 0.1);
    border: 2px solid rgba(255, 255, 255, 0.2);
    border-radius: 10px;
    color: white;
    font-size: 14px;
    margin-bottom: 10px;
    outline: none;
    transition: all 0.3s ease;
}

.modal-input:focus {
    border-color: #ffd700;
}

.modal-input::placeholder {
    color: rgba(255, 255, 255, 0.4);
}

.modal-error {
    color: #e74c3c;
    font-size: 12px;
    margin-bottom: 15px;
    min-height: 18px;
}

.modal-buttons {
    display: flex;
    gap: 10px;
}

.modal-btn {
    flex: 1;
    padding: 12px;
    border: none;
    border-radius: 10px;
    font-size: 14px;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.3s ease;
}

.modal-btn-primary {
    background: linear-gradient(135deg, #ffd700, #ffed4e);
    color: #1a1a2e;
}

.modal-btn-primary:hover {
    transform: translateY(-2px);
    box-shadow: 0 5px 20px rgba(255, 215, 0, 0.4);
}

.modal-btn-secondary {
    background: rgba(255, 255, 255, 0.1);
    color: rgba(255, 255, 255, 0.8);
}

.modal-btn-secondary:hover {
    background: rgba(255, 255, 255, 0.2);
}

.weapon-name {
    font-size: 28px;
    font-weight: bold;
    color: #ffd700;
    margin-bottom: 5px;
    text-transform: uppercase;
    letter-spacing: 2px;
}

.infinite-badge {
    display: inline-block;
    padding: 4px 10px;
    background: linear-gradient(135deg, #ffd700, #ffed4e);
    color: #1a1a2e;
    border-radius: 15px;
    font-size: 11px;
    font-weight: bold;
    margin-left: 10px;
    animation: glow 1.5s ease-in-out infinite alternate;
    display: none;
}

.infinite-badge.active {
    display: inline-block;
}

@keyframes glow {
    from { box-shadow: 0 0 5px #ffd700; }
    to { box-shadow: 0 0 15px #ffd700, 0 0 20px #ffed4e; }
}

.lock-status {
    font-size: 12px;
    padding: 4px 12px;
    border-radius: 20px;
    margin-bottom: 10px;
    display: inline-block;
    font-weight: bold;
    transition: all 0.3s ease;
}

.lock-status.locked {
    background: rgba(231, 76, 60, 0.2);
    color: #e74c3c;
    border: 1px solid rgba(231, 76, 60, 0.5);
    animation: pulse 2s infinite;
}

.lock-status.unlocked {
    background: rgba(46, 204, 113, 0.2);
    color: #2ecc71;
    border: 1px solid rgba(46, 204, 113, 0.3);
}

.lock-status.competition {
    background: rgba(155, 89, 182, 0.2);
    color: #9b59b6;
    border: 1px solid rgba(155, 89, 182, 0.5);
    animation: pulse 1.5s infinite;
}

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

.fire-mode {
    display: inline-block;
    padding: 4px 12px;
    background: rgba(255, 255, 255, 0.1);
    border-radius: 20px;
    font-size: 12px;
    margin-bottom: 10px;
    border: 1px solid rgba(255, 255, 255, 0.2);
}

.fire-mode.semi {
    background: rgba(46, 204, 113, 0.2);
    color: #2ecc71;
    border-color: rgba(46, 204, 113, 0.3);
}

.fire-mode.auto {
    background: rgba(231, 76, 60, 0.2);
    color: #e74c3c;
    border-color: rgba(231, 76, 60, 0.3);
}

.threshold-info {
    font-size: 12px;
    color: rgba(255, 255, 255, 0.9);
    margin-bottom: 10px;
    padding: 8px 12px;
    background: rgba(0, 0, 0, 0.3);
    border-radius: 10px;
    border: 1px solid rgba(255, 255, 255, 0.1);
    line-height: 1.5;
}

.fire-rate-info {
    font-size: 14px;
    color: rgba(255, 255, 255, 0.6);
    margin-bottom: 20px;
}

.violation-reason {
    font-size: 13px;
    margin-bottom: 10px;
    font-weight: bold;
    min-height: 20px;
    transition: color 0.3s ease;
}

.counter-display {
    font-size: 72px;
    font-weight: bold;
    color: white;
    margin-bottom: 20px;
    text-shadow: 0 4px 6px rgba(0, 0, 0, 0.3);
    font-variant-numeric: tabular-nums;
    position: relative;
    display: inline-block;
    transition: all 0.3s ease;
}

.counter-display.infinite {
    color: #ffd700;
    text-shadow: 0 0 20px rgba(255, 215, 0, 0.5);
    animation: infinitePulse 2s infinite;
}

.counter-display.zero {
    color: #718096;
}

.counter-display.countdown {
    font-size: 60px;
    color: #ffd700;
    text-shadow: 0 0 20px rgba(255, 215, 0, 0.5);
}

.counter-display.competition-time {
    font-size: 48px;
    color: #ffffff;
    text-shadow: 0 0 15px rgba(255, 255, 255, 0.5);
}

.counter-display.final-score {
    font-size: 56px;
    color: #ffd700;
    text-shadow: 0 0 25px rgba(255, 215, 0, 0.6);
    animation: scoreGlow 1s ease-in-out infinite alternate;
}

@keyframes scoreGlow {
    from { transform: scale(1); }
    to { transform: scale(1.05); }
}

.ball-container {
    position: relative;
    width: 160px;
    height: 160px;
    margin: 0 auto 20px;
    cursor: pointer;
    touch-action: none;
}

.ball {
    width: 100%;
    height: 100%;
    border-radius: 50%;
    background: radial-gradient(circle at 30% 30%, #ff4757, #c0392b);
    box-shadow: 0 10px 40px rgba(255, 71, 87, 0.4);
    transition: transform 0.15s cubic-bezier(0.4, 0, 0.2, 1), box-shadow 0.3s ease;
    position: relative;
    overflow: hidden;
    border: 3px solid rgba(255, 255, 255, 0.2);
    transform: translateZ(0);
    will-change: transform;
}

.ball.infinite {
    background: radial-gradient(circle at 30% 30%, #ffd700, #f39c12);
    box-shadow: 0 10px 40px rgba(255, 215, 0, 0.5);
}

.ball.competition-prep {
    background: radial-gradient(circle at 30% 30%, #9b59b6, #8e44ad);
    box-shadow: 0 10px 40px rgba(155, 89, 182, 0.5);
    animation: prepPulse 1s ease-in-out infinite;
}

.ball.competition-active {
    background: radial-gradient(circle at 30% 30%, #4ecdc4, #44a08d);
    box-shadow: 0 10px 40px rgba(78, 205, 196, 0.5);
}

.ball.competition-ended {
    background: radial-gradient(circle at 30% 30%, #ffd700, #f39c12);
    box-shadow: 0 10px 40px rgba(255, 215, 0, 0.6);
    animation: victoryPulse 1.5s ease-in-out infinite;
}

@keyframes prepPulse {
    0%, 100% { transform: scale(1); }
    50% { transform: scale(1.03); }
}

@keyframes victoryPulse {
    0%, 100% { transform: scale(1); box-shadow: 0 10px 40px rgba(255, 215, 0, 0.6); }
    50% { transform: scale(1.05); box-shadow: 0 15px 50px rgba(255, 215, 0, 0.8); }
}

@keyframes infinitePulse {
    0%, 100% { transform: scale(1); filter: brightness(1); }
    50% { transform: scale(1.05); filter: brightness(1.1); }
}

.ball:active, .ball.pressing {
    transform: scale(0.9) translateZ(0);
}

.ball.gray {
    background: radial-gradient(circle at 30% 30%, #718096, #2d3748);
    cursor: not-allowed;
    animation: none;
}

.pressing-hint {
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    color: white;
    font-weight: bold;
    font-size: 14px;
    opacity: 0;
    transition: opacity 0.2s;
    pointer-events: none;
    text-shadow: 0 2px 4px rgba(0,0,0,0.5);
}

.pressing.auto-fire .pressing-hint {
    opacity: 1;
}

.ammo-indicator {
    position: absolute;
    bottom: 20%;
    left: 50%;
    transform: translateX(-50%);
    width: 60%;
    height: 4px;
    background: rgba(0,0,0,0.3);
    border-radius: 2px;
    overflow: hidden;
}

.ammo-bar {
    height: 100%;
    background: linear-gradient(90deg, #ffd700, #ffed4e);
    transition: width 0.15s ease-out;
    box-shadow: 0 0 10px rgba(255, 215, 0, 0.3);
}

.weapon-selector {
    display: grid;
    grid-template-columns: repeat(4, 1fr);
    gap: 8px;
    margin-bottom: 20px;
    padding: 12px;
    background: rgba(0, 0, 0, 0.2);
    border-radius: 12px;
    position: relative;
}

@media (max-width: 600px) {
    .weapon-selector {
        grid-template-columns: repeat(2, 1fr);
    }
}

.weapon-radio {
    display: none;
}

.weapon-label {
    padding: 8px 4px;
    background: rgba(255, 255, 255, 0.05);
    border: 2px solid rgba(255, 255, 255, 0.1);
    border-radius: 8px;
    cursor: pointer;
    transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    font-size: 12px;
    font-weight: 600;
    color: rgba(255, 255, 255, 0.8);
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 2px;
    position: relative;
}

.weapon-label:hover:not(.disabled) {
    background: rgba(255, 255, 255, 0.15);
    transform: translateY(-2px);
    box-shadow: 0 4px 8px rgba(0,0,0,0.2);
}

.weapon-radio:checked + .weapon-label {
    background: #ffffff !important;
    color: #1a1a2e;
    border-color: #ffffff;
    box-shadow: 0 4px 15px rgba(255, 255, 255, 0.4);
    transform: translateY(-2px) scale(1.02);
}

.weapon-radio:checked + .weapon-label .weapon-ammo,
.weapon-radio:checked + .weapon-label .weapon-type {
    color: #666;
}

.weapon-label.disabled {
    opacity: 0.4;
    cursor: not-allowed;
    filter: grayscale(0.8);
    pointer-events: none;
}

.weapon-label.disabled::after {
    content: '🔒';
    position: absolute;
    top: 2px;
    right: 2px;
    font-size: 10px;
}

.weapon-ammo {
    font-size: 10px;
    opacity: 0.8;
    font-weight: normal;
}

.weapon-type {
    font-size: 9px;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    padding: 2px 6px;
    background: rgba(255,255,255,0.2);
    border-radius: 10px;
    margin-top: 2px;
}

.switch-container {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 10px;
    margin-bottom: 15px;
    padding: 10px;
    background: rgba(0, 0, 0, 0.2);
    border-radius: 25px;
    border: 1px solid rgba(255, 255, 255, 0.1);
    transition: all 0.3s ease;
}

.switch-container.infinite-active {
    background: rgba(255, 215, 0, 0.15);
    border-color: rgba(255, 215, 0, 0.5);
    box-shadow: 0 0 20px rgba(255, 215, 0, 0.2);
}

.switch-container.competition-active {
    background: rgba(155, 89, 182, 0.15);
    border-color: rgba(155, 89, 182, 0.5);
    box-shadow: 0 0 20px rgba(155, 89, 182, 0.2);
}

.switch-label {
    font-size: 14px;
    font-weight: 600;
    color: rgba(255, 255, 255, 0.8);
    cursor: pointer;
    user-select: none;
}

.switch-label.competition-disabled {
    color: rgba(255, 255, 255, 0.4);
    cursor: not-allowed;
}

.switch {
    position: relative;
    display: inline-block;
    width: 50px;
    height: 26px;
}

.switch input {
    opacity: 0;
    width: 0;
    height: 0;
}

.switch input:disabled + .slider {
    background-color: #555;
    cursor: not-allowed;
    opacity: 0.5;
}

.slider {
    position: absolute;
    cursor: pointer;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background-color: #ccc;
    transition: .4s;
    border-radius: 34px;
    box-shadow: inset 0 2px 4px rgba(0,0,0,0.2);
}

.slider:before {
    position: absolute;
    content: "";
    height: 18px;
    width: 18px;
    left: 4px;
    bottom: 4px;
    background-color: white;
    transition: .4s;
    border-radius: 50%;
    box-shadow: 0 2px 4px rgba(0,0,0,0.2);
}

input:checked + .slider {
    background-color: #ffd700;
}

input:checked + .slider.competition-slider {
    background-color: #9b59b6;
}

input:checked + .slider:before {
    transform: translateX(24px);
}

.reset-btn {
    background: linear-gradient(135deg, #2ecc71, #27ae60);
    color: white;
    border: none;
    padding: 12px 30px;
    font-size: 14px;
    font-weight: 700;
    border-radius: 50px;
    cursor: pointer;
    margin-bottom: 20px;
    width: 100%;
    max-width: 200px;
    transition: all 0.3s ease;
    box-shadow: 0 4px 15px rgba(46, 204, 113, 0.3);
    position: relative;
    overflow: hidden;
}

.reset-btn:hover {
    transform: translateY(-2px);
    box-shadow: 0 6px 20px rgba(46, 204, 113, 0.5);
}

.reset-btn:active {
    transform: translateY(0);
    box-shadow: 0 2px 10px rgba(46, 204, 113, 0.3);
}

.reset-btn::after {
    content: '';
    position: absolute;
    top: 50%;
    left: 50%;
    width: 0;
    height: 0;
    border-radius: 50%;
    background: rgba(255,255,255,0.3);
    transform: translate(-50%, -50%);
    transition: width 0.6s, height 0.6s;
}

.reset-btn:active::after {
    width: 300px;
    height: 300px;
}

.chart-container {
    background: rgba(0, 0, 0, 0.3);
    border-radius: 15px;
    padding: 20px;
    margin-top: 20px;
    position: relative;
}

.chart-title {
    font-size: 16px;
    font-weight: bold;
    margin-bottom: 10px;
    display: flex;
    justify-content: space-between;
    align-items: center;
}

#intervalChart {
    width: 100%;
    height: 250px;
    background: rgba(0, 0, 0, 0.2);
    border-radius: 8px;
    image-rendering: -webkit-crisp-edges;
    image-rendering: crisp-edges;
}

.legend {
    display: flex;
    justify-content: center;
    gap: 20px;
    margin-top: 10px;
    font-size: 12px;
}

.legend-color {
    width: 12px;
    height: 12px;
    border-radius: 2px;
    display: inline-block;
    margin-right: 5px;
    vertical-align: middle;
}

.stats-row {
    display: flex;
    justify-content: space-around;
    margin-top: 10px;
    font-size: 12px;
    color: rgba(255,255,255,0.7);
    flex-wrap: wrap;
    gap: 5px;
}

.prep-text {
    position: absolute;
    top: 30%;
    left: 50%;
    transform: translateX(-50%);
    font-size: 14px;
    color: rgba(255,255,255,0.8);
    text-transform: uppercase;
    letter-spacing: 2px;
}

.click-to-start {
    position: absolute;
    bottom: 25%;
    left: 50%;
    transform: translateX(-50%);
    font-size: 12px;
    color: rgba(255,255,255,0.6);
    animation: blink 1s ease-in-out infinite;
}

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