* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
    -webkit-tap-highlight-color: transparent;
    -webkit-user-select: none;
    user-select: none;
}

body {
    background: #0a0a0a;
    overflow: hidden;
    font-family: 'Segoe UI', 'PingFang SC', 'Microsoft YaHei', sans-serif;
    height: 100vh;
    height: 100dvh;
    width: 100vw;
    display: flex;
    justify-content: center;
    align-items: center;
    touch-action: manipulation;
}

#game-container {
    position: relative;
    width: 100vw;
    height: 100vh;
    height: 100dvh;
    max-width: 500px;
    max-height: 900px;
    overflow: hidden;
    background: radial-gradient(ellipse at center, #1a1a2e 0%, #0a0a0f 70%);
    box-shadow: 0 0 60px rgba(138, 43, 226, 0.3), 0 0 120px rgba(0, 0, 0, 0.8);
}

#game-canvas {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    display: block;
}

#ui-layer {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    pointer-events: none;
    z-index: 10;
}

#ui-layer > * {
    pointer-events: auto;
}

#top-bar {
    position: absolute;
    top: 12px;
    left: 12px;
    right: 12px;
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 10px;
}

.neon-box {
    background: rgba(0, 0, 0, 0.75);
    border: 2px solid rgba(0, 255, 255, 0.5);
    border-radius: 12px;
    padding: 8px 16px;
    color: #fff;
    font-size: 16px;
    font-weight: bold;
    text-shadow: 0 0 10px rgba(0, 255, 255, 0.6);
    box-shadow: 0 0 15px rgba(0, 255, 255, 0.2), inset 0 0 15px rgba(0, 255, 255, 0.05);
    backdrop-filter: blur(10px);
    -webkit-backdrop-filter: blur(10px);
    display: flex;
    align-items: center;
    gap: 6px;
    transition: all 0.3s ease;
}

#balance-display {
    border-color: rgba(255, 215, 0, 0.6);
    text-shadow: 0 0 10px rgba(255, 215, 0, 0.6);
    box-shadow: 0 0 15px rgba(255, 215, 0, 0.25), inset 0 0 15px rgba(255, 215, 0, 0.05);
    font-size: 20px;
    padding: 10px 20px;
}

.coin-icon {
    font-size: 22px;
    animation: coinPulse 2s ease-in-out infinite;
}

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

#balance-amount {
    min-width: 40px;
    text-align: center;
    transition: all 0.3s ease;
}

#balance-amount.pulse {
    animation: balancePulse 0.4s ease-out;
}

@keyframes balancePulse {
    0% { transform: scale(1.5); color: #ffd700; }
    100% { transform: scale(1); color: #fff; }
}

#combo-display {
    border-color: rgba(255, 100, 50, 0.7);
    text-shadow: 0 0 10px rgba(255, 100, 50, 0.7);
    box-shadow: 0 0 20px rgba(255, 100, 50, 0.3), inset 0 0 15px rgba(255, 100, 50, 0.05);
    animation: comboGlow 0.5s ease-in-out infinite alternate;
}

@keyframes comboGlow {
    from { box-shadow: 0 0 15px rgba(255, 100, 50, 0.3); }
    to { box-shadow: 0 0 30px rgba(255, 100, 50, 0.6); }
}

.hidden {
    display: none !important;
}

#bottom-bar {
    position: absolute;
    bottom: 20px;
    left: 12px;
    right: 12px;
    display: flex;
    gap: 10px;
    justify-content: center;
}

.neon-btn {
    flex: 1;
    padding: 14px 20px;
    border: none;
    border-radius: 16px;
    font-size: 16px;
    font-weight: bold;
    color: #fff;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    transition: all 0.2s ease;
    position: relative;
    overflow: hidden;
    text-shadow: 0 0 8px rgba(255, 255, 255, 0.5);
    letter-spacing: 1px;
}

.neon-btn:active {
    transform: scale(0.95);
}

.gold-btn {
    background: linear-gradient(135deg, #b8860b, #ffd700, #b8860b);
    box-shadow: 0 4px 20px rgba(255, 215, 0, 0.4), 0 0 40px rgba(255, 215, 0, 0.15);
    border: 2px solid rgba(255, 215, 0, 0.5);
}

.gold-btn::after {
    content: '';
    position: absolute;
    top: -50%;
    left: -50%;
    width: 200%;
    height: 200%;
    background: linear-gradient(45deg, transparent, rgba(255,255,255,0.2), transparent);
    transform: rotate(45deg);
    animation: btnShine 3s ease-in-out infinite;
}

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

.purple-btn {
    background: linear-gradient(135deg, #6a0dad, #9b30ff, #6a0dad);
    box-shadow: 0 4px 20px rgba(155, 48, 255, 0.4), 0 0 40px rgba(155, 48, 255, 0.15);
    border: 2px solid rgba(155, 48, 255, 0.5);
}

.gray-btn {
    background: linear-gradient(135deg, #444, #666, #444);
    box-shadow: 0 4px 15px rgba(100, 100, 100, 0.3);
    border: 2px solid rgba(150, 150, 150, 0.3);
}

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

#free-coins-timer {
    position: absolute;
    top: 80px;
    left: 50%;
    transform: translateX(-50%);
    font-size: 13px;
    padding: 6px 14px;
    border-color: rgba(100, 255, 100, 0.5);
    text-shadow: 0 0 8px rgba(100, 255, 100, 0.5);
    box-shadow: 0 0 12px rgba(100, 255, 100, 0.15);
    white-space: nowrap;
}

.popup {
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    z-index: 20;
    pointer-events: none;
    animation: popupIn 0.5s ease-out forwards;
}

.popup.hidden {
    display: none;
}

.popup-content {
    text-align: center;
    padding: 20px 30px;
    background: rgba(0, 0, 0, 0.85);
    border-radius: 20px;
    border: 2px solid rgba(255, 215, 0, 0.6);
    box-shadow: 0 0 40px rgba(255, 215, 0, 0.3);
    backdrop-filter: blur(10px);
}

.popup-content.jackpot {
    border-color: rgba(255, 50, 50, 0.7);
    box-shadow: 0 0 60px rgba(255, 50, 50, 0.4), 0 0 100px rgba(255, 215, 0, 0.3);
    animation: jackpotShake 0.1s ease-in-out infinite;
}

@keyframes jackpotShake {
    0%, 100% { transform: translate(0, 0) rotate(0deg); }
    25% { transform: translate(-3px, 2px) rotate(-1deg); }
    50% { transform: translate(3px, -2px) rotate(1deg); }
    75% { transform: translate(-2px, -1px) rotate(-0.5deg); }
}

.popup-title {
    font-size: 22px;
    font-weight: bold;
    color: #ffd700;
    text-shadow: 0 0 15px rgba(255, 215, 0, 0.7);
    margin-bottom: 8px;
}

.popup-amount {
    font-size: 48px;
    font-weight: bold;
    color: #fff;
    text-shadow: 0 0 20px rgba(255, 255, 255, 0.8);
}

.popup-sub {
    font-size: 14px;
    color: #ccc;
    margin-top: 4px;
}

@keyframes popupIn {
    0% { opacity: 0; transform: translate(-50%, -50%) scale(0.5); }
    50% { opacity: 1; transform: translate(-50%, -50%) scale(1.1); }
    100% { opacity: 1; transform: translate(-50%, -50%) scale(1); }
}

.modal {
    position: absolute;
    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: 30;
    backdrop-filter: blur(5px);
}

.modal.hidden {
    display: none;
}

.modal-content {
    background: linear-gradient(135deg, #1a1a2e, #16213e);
    border-radius: 24px;
    padding: 30px;
    text-align: center;
    border: 2px solid rgba(155, 48, 255, 0.5);
    box-shadow: 0 0 50px rgba(155, 48, 255, 0.3);
    max-width: 320px;
    width: 90%;
}

.modal-icon {
    font-size: 60px;
    margin-bottom: 15px;
    animation: bounce 1s ease-in-out infinite;
}

@keyframes bounce {
    0%, 100% { transform: translateY(0); }
    50% { transform: translateY(-15px); }
}

.modal-content h2 {
    color: #fff;
    font-size: 22px;
    margin-bottom: 10px;
}

.modal-content p {
    color: #ccc;
    font-size: 14px;
    margin-bottom: 20px;
    line-height: 1.6;
}

.modal-content strong {
    color: #ffd700;
    font-size: 18px;
}

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

#ad-status {
    color: #ffd700;
    font-size: 14px;
    margin-top: 15px;
    animation: pulse 1s ease-in-out infinite;
}

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

#loading-screen {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: #0a0a0f;
    display: flex;
    justify-content: center;
    align-items: center;
    z-index: 100;
    transition: opacity 0.5s ease;
}

#loading-screen.fade-out {
    opacity: 0;
    pointer-events: none;
}

.loading-content {
    text-align: center;
}

.loading-title {
    font-size: 32px;
    font-weight: bold;
    color: #ffd700;
    text-shadow: 0 0 20px rgba(255, 215, 0, 0.6), 0 0 40px rgba(255, 215, 0, 0.3);
    margin-bottom: 30px;
    animation: titleGlow 2s ease-in-out infinite;
}

@keyframes titleGlow {
    0%, 100% { text-shadow: 0 0 20px rgba(255, 215, 0, 0.6); }
    50% { text-shadow: 0 0 40px rgba(255, 215, 0, 0.9), 0 0 80px rgba(255, 215, 0, 0.4); }
}

.loading-spinner {
    width: 50px;
    height: 50px;
    border: 4px solid rgba(255, 215, 0, 0.2);
    border-top-color: #ffd700;
    border-radius: 50%;
    margin: 0 auto 20px;
    animation: spin 1s linear infinite;
}

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

.loading-text {
    color: #888;
    font-size: 14px;
}

@media (max-width: 360px) {
    .neon-btn {
        padding: 12px 14px;
        font-size: 14px;
    }
    #balance-display {
        font-size: 17px;
        padding: 8px 14px;
    }
}

#start-screen {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: radial-gradient(ellipse at center, #1a0a2e 0%, #0f051f 50%, #05020a 100%);
    display: flex;
    justify-content: center;
    align-items: center;
    z-index: 50;
    overflow-y: auto;
}

#start-screen.hidden {
    display: none;
}

.start-content {
    padding: 20px;
    text-align: center;
    max-width: 400px;
    width: 90%;
}

.start-title {
    font-size: 32px;
    font-weight: bold;
    color: #ffd700;
    text-shadow: 0 0 30px rgba(255, 215, 0, 0.8), 0 0 60px rgba(255, 215, 0, 0.4), 0 0 100px rgba(255, 215, 0, 0.2);
    margin-bottom: 4px;
    letter-spacing: 3px;
    animation: titleGlow 2.5s ease-in-out infinite;
}

@keyframes titleGlow {
    0%, 100% { text-shadow: 0 0 30px rgba(255, 215, 0, 0.8), 0 0 60px rgba(255, 215, 0, 0.4), 0 0 100px rgba(255, 215, 0, 0.2); }
    50% { text-shadow: 0 0 40px rgba(255, 215, 0, 1), 0 0 80px rgba(255, 215, 0, 0.6), 0 0 120px rgba(255, 215, 0, 0.3); }
}

.start-subtitle {
    font-size: 13px;
    color: rgba(255, 255, 255, 0.5);
    margin-bottom: 20px;
    letter-spacing: 4px;
}

.start-features {
    display: grid;
    grid-template-columns: repeat(2, 1fr);
    gap: 10px;
    margin-bottom: 18px;
}

.feature-item {
    padding: 12px;
    background: rgba(255, 255, 255, 0.03);
    border-radius: 12px;
    border: 1px solid rgba(255, 255, 255, 0.06);
    transition: all 0.3s ease;
}

.feature-item:hover {
    background: rgba(255, 255, 255, 0.05);
    border-color: rgba(255, 215, 0, 0.2);
    transform: translateY(-3px);
}

.feature-icon {
    font-size: 24px;
    margin-bottom: 5px;
}

.feature-text {
    font-size: 11px;
    color: rgba(255, 255, 255, 0.7);
}

.start-instructions {
    padding: 14px;
    background: rgba(255, 255, 255, 0.03);
    border-radius: 12px;
    border: 1px solid rgba(255, 255, 255, 0.06);
    margin-bottom: 14px;
}

.instruction-title {
    font-size: 14px;
    font-weight: bold;
    color: #fff;
    margin-bottom: 8px;
}

.instruction-list {
    text-align: left;
}

.instruction-item {
    font-size: 12px;
    color: rgba(255, 255, 255, 0.6);
    line-height: 1.8;
    padding-left: 6px;
}

.start-coins-info {
    padding: 14px;
    background: rgba(255, 215, 0, 0.05);
    border-radius: 12px;
    border: 1px solid rgba(255, 215, 0, 0.15);
    margin-bottom: 20px;
}

.coins-info-title {
    font-size: 14px;
    font-weight: bold;
    color: #ffd700;
    margin-bottom: 8px;
}

.coins-info-list {
    text-align: left;
}

.coins-info-item {
    font-size: 12px;
    color: rgba(255, 255, 255, 0.7);
    line-height: 1.8;
    padding-left: 6px;
}

.start-btn {
    background: linear-gradient(135deg, #5a0dad, #8b2ff0, #5a0dad);
    border: 2px solid rgba(140, 47, 240, 0.6);
    border-radius: 50px;
    padding: 14px 40px;
    cursor: pointer;
    transition: all 0.3s ease;
    box-shadow: 0 6px 30px rgba(140, 47, 240, 0.4), 0 0 60px rgba(140, 47, 240, 0.2), inset 0 0 20px rgba(255, 255, 255, 0.1);
    position: relative;
    overflow: hidden;
    animation: btnPulse 2s ease-in-out infinite;
    margin-bottom: 12px;
}

@keyframes btnPulse {
    0%, 100% { box-shadow: 0 6px 30px rgba(140, 47, 240, 0.4), 0 0 60px rgba(140, 47, 240, 0.2), inset 0 0 20px rgba(255, 255, 255, 0.1); }
    50% { box-shadow: 0 8px 40px rgba(140, 47, 240, 0.6), 0 0 80px rgba(140, 47, 240, 0.3), inset 0 0 30px rgba(255, 255, 255, 0.15); }
}

.start-btn:hover {
    transform: translateY(-4px);
    box-shadow: 0 10px 40px rgba(140, 47, 240, 0.5), 0 0 100px rgba(140, 47, 240, 0.3), inset 0 0 30px rgba(255, 255, 255, 0.15);
}

.start-btn:active {
    transform: translateY(-2px);
}

.start-btn-text {
    display: block;
    font-size: 18px;
    font-weight: bold;
    color: #fff;
    text-shadow: 0 0 20px rgba(140, 47, 240, 0.8);
    letter-spacing: 2px;
}

.back-home-btn {
    background: rgba(255, 255, 255, 0.08);
    border: 1px solid rgba(255, 255, 255, 0.2);
    border-radius: 50px;
    padding: 10px 28px;
    cursor: pointer;
    transition: all 0.3s ease;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 6px;
    margin: 0 auto;
}

.back-home-btn:hover {
    background: rgba(255, 255, 255, 0.15);
    border-color: rgba(255, 255, 255, 0.3);
    transform: translateY(-2px);
}

.back-home-icon {
    font-size: 18px;
}

.back-home-text {
    font-size: 14px;
    color: rgba(255, 255, 255, 0.8);
}

@media (max-width: 480px) {
    .start-title {
        font-size: 28px;
    }

    .start-content {
        padding: 20px;
    }

    .start-btn {
        padding: 14px 32px;
    }
}

@media (min-width: 500px) {
    #game-container {
        border-radius: 20px;
    }
}
