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

@import url('https://fonts.googleapis.com/css2?family=Poppins:wght@300;400;500;600;700&display=swap');

body {
    font-family: 'Poppins', sans-serif;
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    background-size: 400% 400%;
    animation: gradientAnimation 15s ease infinite;
    display: flex;
    justify-content: center;
    align-items: center;
    min-height: 100vh;
    color: #fff;
    overflow-x: hidden;
}

@keyframes gradientAnimation {
    0% { background-position: 0% 50%; }
    50% { background-position: 100% 50%; }
    100% { background-position: 0% 50%; }
}

/* 粒子效果 */
.particles-container {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    pointer-events: none;
    z-index: -1;
}

.particle {
    position: absolute;
    width: 4px;
    height: 4px;
    background: rgba(255, 255, 255, 0.3);
    border-radius: 50%;
    animation: float 20s infinite linear;
}

@keyframes float {
    0% {
        transform: translateY(100vh) rotate(0deg);
        opacity: 0;
    }
    10% {
        opacity: 1;
    }
    90% {
        opacity: 1;
    }
    100% {
        transform: translateY(-100px) rotate(360deg);
        opacity: 0;
    }
}

.main-container {
    display: flex;
    justify-content: center;
    align-items: flex-start;
    gap: 20px;
    width: 100%;
    max-width: 900px;
    padding: 20px;
}

.sidebar {
    flex-shrink: 0;
    width: 300px;
}

.content {
    flex: 1;
    display: flex;
    justify-content: center;
}

.game-container {
    background: rgba(255, 255, 255, 0.1);
    backdrop-filter: blur(15px);
    border-radius: 24px;
    padding: 24px;
    box-shadow: 0 12px 40px rgba(0, 0, 0, 0.35), 0 0 0 1px rgba(255, 255, 255, 0.1) inset;
    border: 1px solid rgba(255, 255, 255, 0.2);
    max-width: 600px;
    width: 100%;
    transition: all 0.3s ease;
    position: relative;
    overflow: hidden;
}

.game-container::before {
    content: '';
    position: absolute;
    top: -50%;
    left: -50%;
    width: 200%;
    height: 200%;
    background: linear-gradient(45deg, transparent, rgba(255, 255, 255, 0.1), transparent);
    transform: rotate(45deg);
    animation: shine 6s infinite;
}

@keyframes shine {
    0% { transform: translateX(-100%) rotate(45deg); }
    100% { transform: translateX(100%) rotate(45deg); }
}

.game-container:hover {
    box-shadow: 0 16px 48px rgba(0, 0, 0, 0.4), 0 0 0 1px rgba(255, 255, 255, 0.15) inset;
    transform: translateY(-2px);
}

.ad-sidebar {
    background: rgba(255, 255, 255, 0.1);
    backdrop-filter: blur(12px);
    border-radius: 18px;
    padding: 16px;
    box-shadow: 0 10px 32px rgba(0, 0, 0, 0.3), 0 0 0 1px rgba(255, 255, 255, 0.1) inset;
    border: 1px solid rgba(255, 255, 255, 0.2);
    margin-bottom: 16px;
    transition: all 0.3s ease;
}

.ad-sidebar:hover {
    box-shadow: 0 12px 36px rgba(0, 0, 0, 0.35), 0 0 0 1px rgba(255, 255, 255, 0.15) inset;
}

.ad-footer {
    background: rgba(255, 255, 255, 0.1);
    backdrop-filter: blur(12px);
    border-radius: 18px;
    padding: 16px;
    box-shadow: 0 10px 32px rgba(0, 0, 0, 0.3), 0 0 0 1px rgba(255, 255, 255, 0.1) inset;
    border: 1px solid rgba(255, 255, 255, 0.2);
    margin-top: 16px;
    max-width: 600px;
    margin: 16px auto 0;
    width: 100%;
    transition: all 0.3s ease;
}

.ad-footer:hover {
    box-shadow: 0 12px 36px rgba(0, 0, 0, 0.35), 0 0 0 1px rgba(255, 255, 255, 0.15) inset;
}

.game-header {
    text-align: center;
    margin-bottom: 20px;
}

.language-selector {
    display: flex;
    justify-content: center;
    align-items: center;
}

.language-selector select {
    background: rgba(255, 255, 255, 0.2);
    color: white;
    border: 2px solid rgba(255, 255, 255, 0.3);
    border-radius: 20px;
    padding: 6px 12px;
    font-size: 0.9em;
    cursor: pointer;
    transition: all 0.3s ease;
    outline: none;
    min-width: 100px;
}

.language-selector select:hover {
    background: rgba(255, 255, 255, 0.3);
    border-color: white;
}

.language-selector select option {
    background: #667eea;
    color: white;
}

/* 调整info-item内部的语言选择器 */
.info-item .language-selector {
    margin: 0;
    padding: 0;
}

/* 语言选择弹窗样式 */
.language-modal {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.8);
    display: flex;
    justify-content: center;
    align-items: center;
    z-index: 2000;
    animation: fadeIn 0.3s ease;
}

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

.language-modal-content {
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    padding: 40px;
    border-radius: 20px;
    text-align: center;
    box-shadow: 0 8px 32px rgba(0, 0, 0, 0.3);
    border: 1px solid rgba(255, 255, 255, 0.2);
    max-width: 90%;
    width: 400px;
    animation: slideUp 0.3s ease;
}

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

.language-modal-title {
    font-size: 1.8em;
    margin-bottom: 30px;
    color: white;
    text-shadow: 2px 2px 4px rgba(0, 0, 0, 0.3);
}

.language-options {
    display: flex;
    gap: 20px;
    justify-content: center;
    margin-bottom: 30px;
}

.language-option-btn {
    background: rgba(255, 255, 255, 0.2);
    color: white;
    border: 2px solid rgba(255, 255, 255, 0.3);
    border-radius: 15px;
    padding: 15px 25px;
    cursor: pointer;
    transition: all 0.3s ease;
    font-size: 1.1em;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 10px;
    min-width: 120px;
}

.language-option-btn:hover {
    background: rgba(255, 255, 255, 0.3);
    border-color: white;
    transform: translateY(-3px);
    box-shadow: 0 6px 20px rgba(0, 0, 0, 0.3);
}

.language-option-btn.active {
    background: linear-gradient(45deg, #ff6b6b, #4ecdc4);
    border-color: white;
    box-shadow: 0 6px 20px rgba(0, 0, 0, 0.3);
}

.language-flag {
    font-size: 2em;
}

.language-name {
    font-weight: bold;
}

.language-confirm-btn {
    min-width: 150px;
    padding: 12px 30px;
    font-size: 1.1em;
    border-radius: 25px;
    cursor: pointer;
    transition: all 0.3s ease;
    border: none;
    background: linear-gradient(45deg, #4ecdc4, #45b7d1);
    color: white;
    box-shadow: 0 4px 15px rgba(0, 0, 0, 0.2);
}

.language-confirm-btn:hover {
    transform: translateY(-2px);
    box-shadow: 0 6px 20px rgba(0, 0, 0, 0.3);
}

/* 响应式设计 */
@media (max-width: 768px) {
    .game-header {
        display: flex;
        flex-direction: column;
        align-items: center;
    }
    
    .language-modal-content {
        padding: 30px 20px;
        margin: 20px;
    }
    
    .language-modal-title {
        font-size: 1.5em;
        margin-bottom: 20px;
    }
    
    .language-options {
        gap: 15px;
        flex-wrap: wrap;
    }
    
    .language-option-btn {
        min-width: 100px;
        padding: 12px 20px;
        font-size: 1em;
    }
    
    .language-flag {
        font-size: 1.8em;
    }
}

@media (max-width: 480px) {
    .language-modal-content {
        padding: 25px 15px;
    }
    
    .language-modal-title {
        font-size: 1.3em;
    }
    
    .language-options {
        gap: 12px;
    }
    
    .language-option-btn {
        min-width: 90px;
        padding: 10px 18px;
        font-size: 0.9em;
    }
    
    .language-flag {
        font-size: 1.6em;
    }
    
    .language-confirm-btn {
        min-width: 120px;
        padding: 10px 25px;
        font-size: 1em;
    }
}

.game-title {
    font-size: 2.8em;
    margin-bottom: 16px;
    text-shadow: 2px 2px 4px rgba(0, 0, 0, 0.3), 0 0 20px rgba(255, 255, 255, 0.2);
    background: linear-gradient(45deg, #ff6b6b, #4ecdc4, #45b7d1, #96ceb4);
    background-size: 400% 400%;
    animation: gradientText 5s ease infinite;
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
    font-weight: 700;
    letter-spacing: -0.5px;
}

@keyframes gradientText {
    0% { background-position: 0% 50%; }
    50% { background-position: 100% 50%; }
    100% { background-position: 0% 50%; }
}

.game-info {
    display: flex;
    justify-content: space-around;
    margin-bottom: 20px;
    font-size: 1.1em;
    flex-wrap: nowrap;
    width: 100%;
    gap: 12px;
}

.info-item {
    background: rgba(255, 255, 255, 0.15);
    padding: 10px 18px;
    border-radius: 24px;
    box-shadow: 0 6px 20px rgba(0, 0, 0, 0.25), 0 0 0 1px rgba(255, 255, 255, 0.1) inset;
    flex: 1;
    text-align: center;
    min-width: 0;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    transition: all 0.3s ease;
    border: 1px solid rgba(255, 255, 255, 0.2);
    position: relative;
    overflow: hidden;
}

.info-item::before {
    content: '';
    position: absolute;
    top: 0;
    left: -100%;
    width: 100%;
    height: 100%;
    background: linear-gradient(90deg, transparent, rgba(255, 255, 255, 0.1), transparent);
    animation: infoShine 3s infinite;
}

@keyframes infoShine {
    0% { left: -100%; }
    100% { left: 100%; }
}

.info-item:hover {
    background: rgba(255, 255, 255, 0.2);
    box-shadow: 0 8px 24px rgba(0, 0, 0, 0.3), 0 0 0 1px rgba(255, 255, 255, 0.15) inset;
    transform: translateY(-1px);
}

@media (max-width: 768px) {
    .game-info {
        font-size: 0.9em;
        gap: 8px;
    }
    
    .info-item {
        padding: 6px 12px;
        border-radius: 15px;
    }
}

@media (max-width: 480px) {
    .game-info {
        font-size: 0.8em;
        gap: 6px;
    }
    
    .info-item {
        padding: 5px 10px;
        border-radius: 12px;
    }
}

.canvas-container {
    display: flex;
    justify-content: center;
    margin-bottom: 24px;
    position: relative;
}

.canvas-container::before {
    content: '';
    position: absolute;
    top: -5px;
    left: -5px;
    right: -5px;
    bottom: -5px;
    background: linear-gradient(45deg, #ff6b6b, #4ecdc4, #45b7d1, #96ceb4);
    background-size: 400% 400%;
    border-radius: 16px;
    animation: gradientAnimation 8s ease infinite;
    z-index: -1;
    filter: blur(10px);
    opacity: 0.6;
}

#gameCanvas {
    border: 4px solid rgba(255, 255, 255, 0.3);
    border-radius: 12px;
    background: rgba(0, 0, 0, 0.6);
    box-shadow: 0 8px 24px rgba(0, 0, 0, 0.4), 0 0 0 1px rgba(255, 255, 255, 0.1) inset;
    transition: all 0.3s ease;
}

#gameCanvas:hover {
    box-shadow: 0 12px 32px rgba(0, 0, 0, 0.5), 0 0 0 1px rgba(255, 255, 255, 0.15) inset;
}

.control-section {
    margin-bottom: 24px;
}

.control-row {
    display: flex;
    justify-content: center;
    gap: 12px;
    margin-bottom: 12px;
}

.btn {
    background: linear-gradient(45deg, #ff6b6b, #ee5a24);
    background-size: 200% 200%;
    color: white;
    border: none;
    padding: 14px 28px;
    font-size: 1em;
    border-radius: 28px;
    cursor: pointer;
    transition: all 0.3s ease;
    box-shadow: 0 6px 20px rgba(0, 0, 0, 0.25);
    min-width: 110px;
    font-weight: 500;
    position: relative;
    overflow: hidden;
}

.btn::before {
    content: '';
    position: absolute;
    top: 0;
    left: -100%;
    width: 100%;
    height: 100%;
    background: linear-gradient(90deg, transparent, rgba(255, 255, 255, 0.2), transparent);
    transition: all 0.5s ease;
}

.btn:hover {
    transform: translateY(-3px);
    box-shadow: 0 8px 24px rgba(0, 0, 0, 0.35);
    background-position: right center;
}

.btn:hover::before {
    left: 100%;
}

.btn:active {
    transform: translateY(-1px);
    box-shadow: 0 4px 16px rgba(0, 0, 0, 0.3);
}

.btn-primary {
    background: linear-gradient(45deg, #4ecdc4, #45b7d1);
    background-size: 200% 200%;
}

.btn-secondary {
    background: linear-gradient(45deg, #96ceb4, #ffeaa7);
    background-size: 200% 200%;
    color: #2d3436;
}

.difficulty-selector {
    display: flex;
    justify-content: center;
    gap: 12px;
    margin-bottom: 24px;
}

.difficulty-btn {
    padding: 10px 20px;
    border: 2px solid rgba(255, 255, 255, 0.3);
    background: rgba(255, 255, 255, 0.1);
    color: white;
    border-radius: 24px;
    cursor: pointer;
    transition: all 0.3s ease;
    font-weight: 500;
    position: relative;
    overflow: hidden;
}

.difficulty-btn::before {
    content: '';
    position: absolute;
    top: 0;
    left: -100%;
    width: 100%;
    height: 100%;
    background: linear-gradient(90deg, transparent, rgba(255, 255, 255, 0.1), transparent);
    transition: all 0.5s ease;
}

.difficulty-btn:hover {
    background: rgba(255, 255, 255, 0.15);
    border-color: rgba(255, 255, 255, 0.4);
    transform: translateY(-1px);
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.2);
}

.difficulty-btn:hover::before {
    left: 100%;
}

.difficulty-btn.active {
    background: linear-gradient(45deg, #ff6b6b, #4ecdc4);
    background-size: 200% 200%;
    border-color: white;
    box-shadow: 0 6px 16px rgba(0, 0, 0, 0.3);
    animation: gradientAnimation 3s ease infinite;
}

.mobile-controls {
    display: none;
    grid-template-columns: repeat(3, 1fr);
    grid-template-rows: repeat(3, 1fr);
    gap: 12px;
    max-width: 320px;
    margin: 0 auto 24px;
}

.mobile-btn {
    background: rgba(255, 255, 255, 0.15);
    border: 2px solid rgba(255, 255, 255, 0.3);
    color: white;
    font-size: 1.6em;
    padding: 24px;
    border-radius: 18px;
    cursor: pointer;
    transition: all 0.2s ease;
    display: flex;
    justify-content: center;
    align-items: center;
    position: relative;
    overflow: hidden;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.2);
}

.mobile-btn::before {
    content: '';
    position: absolute;
    top: 0;
    left: -100%;
    width: 100%;
    height: 100%;
    background: linear-gradient(90deg, transparent, rgba(255, 255, 255, 0.1), transparent);
    transition: all 0.3s ease;
}

.mobile-btn:hover {
    background: rgba(255, 255, 255, 0.2);
    border-color: rgba(255, 255, 255, 0.4);
    transform: translateY(-2px);
    box-shadow: 0 6px 16px rgba(0, 0, 0, 0.25);
}

.mobile-btn:hover::before {
    left: 100%;
}

.mobile-btn:active {
    background: rgba(255, 255, 255, 0.25);
    transform: scale(0.95) translateY(0);
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.2);
}

/* 重置所有按钮的默认定位 */
.mobile-btn:nth-child(n) {
    grid-column: auto;
    grid-row: auto;
    visibility: visible;
}

/* 上按钮：中间顶行 */
.mobile-btn:nth-child(2) {
    grid-column: 2;
    grid-row: 1;
}

/* 左按钮：左侧中行 */
.mobile-btn:nth-child(4) {
    grid-column: 1;
    grid-row: 2;
}

/* 右按钮：右侧中行 */
.mobile-btn:nth-child(6) {
    grid-column: 3;
    grid-row: 2;
}

/* 下按钮：中间底行 */
.mobile-btn:nth-child(8) {
    grid-column: 2;
    grid-row: 3;
}

/* 隐藏角落的空白按钮 */
.mobile-btn:nth-child(1),
.mobile-btn:nth-child(3),
.mobile-btn:nth-child(5),
.mobile-btn:nth-child(7),
.mobile-btn:nth-child(9) {
    visibility: hidden;
}

.game-over {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.85);
    display: none;
    justify-content: center;
    align-items: center;
    z-index: 1000;
    backdrop-filter: blur(5px);
}

.game-over-content {
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    background-size: 200% 200%;
    padding: 48px;
    border-radius: 24px;
    text-align: center;
    box-shadow: 0 12px 40px rgba(0, 0, 0, 0.4), 0 0 0 1px rgba(255, 255, 255, 0.1) inset;
    border: 1px solid rgba(255, 255, 255, 0.2);
    max-width: 90%;
    width: 400px;
    animation: gradientAnimation 5s ease infinite, slideUp 0.5s ease-out;
    position: relative;
    overflow: hidden;
}

.game-over-content::before {
    content: '';
    position: absolute;
    top: -50%;
    left: -50%;
    width: 200%;
    height: 200%;
    background: linear-gradient(45deg, transparent, rgba(255, 255, 255, 0.1), transparent);
    transform: rotate(45deg);
    animation: shine 8s infinite;
}

.game-over-title {
    font-size: 2.8em;
    margin-bottom: 24px;
    color: #ff6b6b;
    text-shadow: 2px 2px 4px rgba(0, 0, 0, 0.3), 0 0 20px rgba(255, 255, 255, 0.2);
    font-weight: 700;
}

.game-over-text {
    font-size: 1.3em;
    margin-bottom: 32px;
    line-height: 1.5;
    text-shadow: 1px 1px 2px rgba(0, 0, 0, 0.3);
}

/* 响应式设计 */
@media (max-width: 960px) {
    .main-container {
        flex-direction: column;
        align-items: center;
        gap: 10px;
    }
    
    .sidebar {
        width: 100%;
        max-width: 600px;
    }
    
    .ad-sidebar {
        margin-bottom: 10px;
    }
}

@media (max-width: 768px) {
    .game-container {
        margin: 10px;
        padding: 15px;
    }

    .game-title {
        font-size: 2em;
    }

    .game-info {
        font-size: 0.9em;
        flex-wrap: wrap;
        gap: 8px;
    }

    .info-item {
        padding: 6px 12px;
        font-size: 0.9em;
    }

    #gameCanvas {
        max-width: 100%;
        height: auto;
    }

    .mobile-controls {
        display: grid;
        gap: 15px;
        max-width: 280px;
    }

    .mobile-btn {
        padding: 25px;
        font-size: 1.5em;
    }
    
    .ad-sidebar,
    .ad-footer {
        padding: 10px;
        margin: 10px 0;
    }
}

@media (max-width: 480px) {
    .game-title {
        font-size: 1.5em;
        text-align: center;
    }

    .control-row {
        flex-wrap: wrap;
        gap: 8px;
        justify-content: center;
    }

    .btn {
        padding: 10px 16px;
        font-size: 0.85em;
        min-width: 80px;
        flex: 1;
        max-width: 120px;
    }

    .mobile-controls {
        gap: 12px;
        max-width: 250px;
        margin: 0 auto 20px;
    }

    .mobile-btn {
        padding: 20px;
        font-size: 1.3em;
    }

    .difficulty-selector {
        flex-wrap: wrap;
        gap: 8px;
    }

    .difficulty-btn {
        padding: 6px 12px;
        font-size: 0.85em;
        flex: 1;
        min-width: 80px;
        text-align: center;
    }

    .game-info {
        font-size: 0.8em;
        gap: 6px;
        flex-wrap: wrap;
    }

    .info-item {
        padding: 4px 8px;
        font-size: 0.85em;
        flex: 1;
        min-width: 70px;
    }

    #gameCanvas {
        max-width: 100%;
        height: auto;
    }

    .game-container {
        padding: 12px;
        margin: 5px;
    }
}

