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

html {
    overflow: hidden;
    width: 100%;
    height: 100%;
    position: fixed;
}

body {
    font-family: 'Arial', sans-serif;
    background: linear-gradient(135deg, #0f3460, #1a1a2e);
    overflow: hidden;
    color: white;
    width: 100%;
    height: 100%;
    position: fixed;
    touch-action: none;
}

#preloader {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: linear-gradient(135deg, #0f3460, #1a1a2e);
    display: flex;
    justify-content: center;
    align-items: center;
    z-index: 1000;
    flex-direction: column;
}

.loading-text {
    font-size: 2rem;
    margin-bottom: 2rem;
    animation: pulse 2s infinite;
}

.loading-bar {
    width: 200px;
    height: 4px;
    background: rgba(255, 255, 255, 0.2);
    border-radius: 2px;
    overflow: hidden;
}

.loading-fill {
    height: 100%;
    background: linear-gradient(90deg, #e94560, #ffc93c);
    width: 0;
    animation: loadingProgress 2s ease-in-out forwards;
}

@keyframes loadingProgress {
    to { width: 100%; }
}

#game-container {
    display: none;
    position: relative;
    width: 100vw;
    height: 100vh;
}

#game-canvas {
    display: block;
    background: transparent;
}

.ui-overlay {
    position: absolute;
    top: 20px;
    left: 20px;
    z-index: 100;
}

.health-bar {
    width: 200px;
    height: 20px;
    background: rgba(255, 255, 255, 0.2);
    border-radius: 10px;
    overflow: hidden;
    margin-bottom: 10px;
}

.health-fill {
    height: 100%;
    background: linear-gradient(90deg, #e94560, #ff6b6b);
    transition: width 0.3s ease;
}

#score {
    font-size: 1.5rem;
    font-weight: bold;
    color: #ffc93c;
    margin-bottom: 5px;
}

#tez-tokens {
    font-size: 1.2rem;
    font-weight: bold;
    color: #0084ff;
}

.screen {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    display: flex;
    justify-content: center;
    align-items: center;
    flex-direction: column;
    background: rgba(0, 0, 0, 0.8);
    z-index: 200;
    padding: 2rem;
}

.screen h1 {
    font-size: 3rem;
    margin-bottom: 2rem;
    color: #e94560;
    text-shadow: 0 0 20px rgba(233, 69, 96, 0.5);
}

.game-over-buttons {
    display: flex;
    flex-direction: column;
    gap: 1rem;
    width: 100%;
    max-width: 350px;
    margin-top: 1rem;
}

.game-over-btn {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 0.8rem;
    padding: 16px 32px;
    font-size: 1.1rem;
    color: white;
    border: none;
    border-radius: 30px;
    cursor: pointer;
    transition: all 0.3s ease;
    box-shadow: 0 5px 15px rgba(0, 0, 0, 0.4);
    font-weight: bold;
    position: relative;
    overflow: hidden;
}

.game-over-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: left 0.5s;
}

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

.play-again-btn {
    background: linear-gradient(45deg, #ffc93c, #ffaa00);
    box-shadow: 0 5px 20px rgba(255, 201, 60, 0.4);
}

.play-again-btn:hover {
    transform: translateY(-3px);
    box-shadow: 0 8px 30px rgba(255, 201, 60, 0.6);
}

.play-again-btn:active {
    transform: translateY(-1px);
}

.save-btn {
    background: linear-gradient(45deg, #00b8a9, #0084b4);
    box-shadow: 0 5px 20px rgba(0, 180, 169, 0.4);
}

.save-btn:hover {
    transform: translateY(-3px);
    box-shadow: 0 8px 30px rgba(0, 180, 169, 0.6);
}

.save-btn:active {
    transform: translateY(-1px);
}

.home-btn {
    background: linear-gradient(45deg, #e94560, #ff6b6b);
    box-shadow: 0 5px 20px rgba(233, 69, 96, 0.4);
}

.home-btn:hover {
    transform: translateY(-3px);
    box-shadow: 0 8px 30px rgba(233, 69, 96, 0.6);
}

.home-btn:active {
    transform: translateY(-1px);
}

.btn-icon {
    font-size: 1.4rem;
    filter: drop-shadow(0 2px 4px rgba(0, 0, 0, 0.3));
}

.btn-text {
    flex: 1;
    text-align: center;
    letter-spacing: 0.5px;
}

.menu-container {
    display: flex;
    flex-direction: column;
    gap: 1rem;
    width: 100%;
    max-width: 400px;
    margin-bottom: 2rem;
}

.menu-button {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 1rem;
    padding: 15px 30px;
    font-size: 1.2rem;
    background: linear-gradient(45deg, #e94560, #ff6b6b);
    color: white;
    border: none;
    border-radius: 30px;
    cursor: pointer;
    transition: all 0.3s ease;
    box-shadow: 0 5px 15px rgba(233, 69, 96, 0.4);
    font-weight: bold;
}

.menu-button:hover {
    transform: translateY(-2px);
    box-shadow: 0 8px 25px rgba(233, 69, 96, 0.6);
}

.menu-button:active {
    transform: translateY(0);
}

.menu-icon {
    font-size: 1.5rem;
}

.menu-text {
    flex: 1;
    text-align: center;
}

.controls-info {
    font-size: 1rem;
    text-align: center;
    color: #aaa;
    margin-top: 1rem;
}

.screen button {
    border: none;
    border-radius: 30px;
    cursor: pointer;
    transition: all 0.3s ease;
    box-shadow: 0 5px 15px rgba(233, 69, 96, 0.4);
}

.screen button:hover {
    transform: translateY(-2px);
    box-shadow: 0 8px 25px rgba(233, 69, 96, 0.6);
}

.particle {
    position: absolute;
    border-radius: 50%;
    pointer-events: none;
    z-index: 1;
}

@keyframes fadeIn {
    from { opacity: 0; transform: scale(0.8); }
    to { opacity: 1; transform: scale(1); }
}

@keyframes fadeOut {
    from { opacity: 1; transform: scale(1); }
    to { opacity: 0; transform: scale(0.8); }
}

@keyframes shake {
    0%, 100% { transform: translate(0, 0); }
    10% { transform: translate(-2px, -1px); }
    20% { transform: translate(2px, 1px); }
    30% { transform: translate(-1px, 2px); }
    40% { transform: translate(1px, -2px); }
    50% { transform: translate(-2px, 1px); }
    60% { transform: translate(2px, -1px); }
    70% { transform: translate(-1px, -2px); }
    80% { transform: translate(1px, 2px); }
    90% { transform: translate(-2px, -1px); }
}

.screen-shake {
    animation: shake 0.3s ease-in-out;
}
/* Wallet Styles */
.wallet-section {
    position: fixed;
    top: 2rem;
    right: 2rem;
    margin-bottom: 0;
    min-height: 120px;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 1rem;
    z-index: 100;
}

.wallet-headline {
    font-size: 1.8rem;
    color: #00b8a9;
    margin-bottom: 1rem;
    text-shadow: 0 0 20px rgba(0, 180, 169, 0.3);
    font-weight: bold;
}

.wallet-btn {
    padding: 12px 25px;
    font-size: 1rem;
    background: linear-gradient(45deg, #00b8a9, #0084b4);
    color: white;
    border: none;
    border-radius: 25px;
    cursor: pointer;
    transition: all 0.3s ease;
    box-shadow: 0 4px 12px rgba(0, 180, 169, 0.4);
    font-weight: bold;
}

.wallet-support-text {
    font-size: 0.9rem;
    color: #a0a0a0;
    margin-top: 0.5rem;
}

.wallet-btn:hover {
    transform: translateY(-2px);
    box-shadow: 0 6px 18px rgba(0, 180, 169, 0.6);
}

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

.wallet-info {
    background: rgba(0, 180, 169, 0.1);
    border: 2px solid rgba(0, 180, 169, 0.3);
    border-radius: 12px;
    padding: 1rem 1.5rem;
    color: #ffffff;
    text-align: center;
    min-width: 300px;
    animation: fadeIn 0.3s ease-in-out;
}

.wallet-info p {
    margin: 0.5rem 0;
    font-size: 0.95rem;
    word-break: break-all;
}

.wallet-info strong {
    color: #00b8a9;
}

.wallet-info span {
    color: #ffc93c;
    font-weight: bold;
}

.disconnect-btn {
    padding: 8px 16px;
    font-size: 0.9rem;
    background: linear-gradient(45deg, #ff6b6b, #e94560);
    color: white;
    border: none;
    border-radius: 20px;
    cursor: pointer;
    transition: all 0.3s ease;
    margin-top: 0.5rem;
    box-shadow: 0 3px 10px rgba(233, 69, 96, 0.3);
}

.disconnect-btn:hover {
    transform: translateY(-2px);
    box-shadow: 0 5px 15px rgba(233, 69, 96, 0.5);
}

/* Wallet Error Modal */
.wallet-modal {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.95);
    display: flex;
    justify-content: center;
    align-items: center;
    z-index: 9999;
}

.wallet-modal-content {
    background: linear-gradient(135deg, #1a1a2e, #0f3460);
    border: 2px solid rgba(0, 180, 169, 0.3);
    border-radius: 20px;
    padding: 2rem;
    max-width: 500px;
    width: 90%;
    text-align: center;
    animation: slideIn 0.3s ease-out;
    box-shadow: 0 10px 40px rgba(0, 180, 169, 0.2);
}

@keyframes slideIn {
    from {
        opacity: 0;
        transform: scale(0.9);
    }
    to {
        opacity: 1;
        transform: scale(1);
    }
}

.wallet-modal-content h2 {
    font-size: 1.8rem;
    color: #e94560;
    margin-bottom: 1rem;
    text-shadow: 0 0 20px rgba(233, 69, 96, 0.3);
}

.wallet-modal-content p {
    font-size: 1.1rem;
    color: #ffffff;
    margin-bottom: 1.5rem;
}

.wallet-links {
    display: flex;
    flex-direction: column;
    gap: 1rem;
    margin-bottom: 1.5rem;
}

.wallet-link {
    display: flex;
    align-items: center;
    gap: 1rem;
    padding: 1rem;
    background: rgba(0, 180, 169, 0.05);
    border: 2px solid rgba(0, 180, 169, 0.2);
    border-radius: 12px;
    text-decoration: none;
    color: #ffffff;
    transition: all 0.3s ease;
    cursor: pointer;
}

.wallet-link:hover {
    background: rgba(0, 180, 169, 0.15);
    border-color: rgba(0, 180, 169, 0.5);
    transform: translateX(5px);
}

.wallet-link span {
    font-size: 2rem;
}

.wallet-link strong {
    display: block;
    color: #00b8a9;
    font-size: 1.1rem;
    margin-bottom: 0.2rem;
}

.wallet-link small {
    display: block;
    color: #a0a0a0;
    font-size: 0.85rem;
}

.close-modal-btn {
    padding: 12px 30px;
    font-size: 1rem;
    background: linear-gradient(45deg, #ff6b6b, #e94560);
    color: white;
    border: none;
    border-radius: 25px;
    cursor: pointer;
    transition: all 0.3s ease;
    box-shadow: 0 4px 12px rgba(233, 69, 96, 0.4);
    font-weight: bold;
}

.close-modal-btn:hover {
    transform: translateY(-2px);
    box-shadow: 0 6px 18px rgba(233, 69, 96, 0.6);
}

/* General Modal Styles */
.modal {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.95);
    display: flex;
    justify-content: center;
    align-items: center;
    z-index: 9999;
}

.modal-content {
    background: linear-gradient(135deg, #1a1a2e, #0f3460);
    border: 2px solid rgba(0, 180, 169, 0.3);
    border-radius: 20px;
    padding: 2rem;
    max-width: 600px;
    width: 90%;
    max-height: 80vh;
    overflow-y: auto;
    text-align: center;
    animation: slideIn 0.3s ease-out;
    box-shadow: 0 10px 40px rgba(0, 180, 169, 0.2);
}

.modal-content h2 {
    font-size: 1.8rem;
    color: #e94560;
    margin-bottom: 1rem;
    text-shadow: 0 0 20px rgba(233, 69, 96, 0.3);
}

.modal-content p {
    font-size: 1.1rem;
    color: #ffffff;
    margin-bottom: 1.5rem;
}

.modal-content ul {
    text-align: left;
    color: #ffffff;
    font-size: 1rem;
    line-height: 1.8;
}

.modal-content li {
    margin-bottom: 0.5rem;
}

.wallet-option {
    display: block;
    width: 100%;
    padding: 12px;
    margin: 0.5rem 0;
    background: linear-gradient(45deg, #00b8a9, #0084b4);
    color: white;
    border: none;
    border-radius: 10px;
    cursor: pointer;
    font-size: 1rem;
    transition: all 0.3s ease;
}

.wallet-option:hover {
    transform: translateX(5px);
    box-shadow: 0 4px 12px rgba(0, 180, 169, 0.4);
}

/* Profile Modal Styles */
.profile-content {
    max-width: 700px;
    text-align: left;
}

.profile-loading {
    text-align: center;
    padding: 2rem;
    color: #aaa;
}

.profile-section {
    margin-bottom: 2rem;
}

.profile-section h3 {
    color: #00b8a9;
    font-size: 1.3rem;
    margin-bottom: 1rem;
    border-bottom: 2px solid rgba(0, 180, 169, 0.3);
    padding-bottom: 0.5rem;
}

.profile-field-group {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(250px, 1fr));
    gap: 1rem;
    margin-bottom: 1rem;
}

.profile-field {
    display: flex;
    flex-direction: column;
}

.profile-field label {
    color: #ffffff;
    font-size: 0.9rem;
    margin-bottom: 0.5rem;
    font-weight: bold;
}

.profile-field input {
    padding: 0.75rem;
    border: 2px solid rgba(0, 180, 169, 0.3);
    border-radius: 8px;
    background: rgba(0, 0, 0, 0.3);
    color: #ffffff;
    font-size: 1rem;
    transition: all 0.3s ease;
}

.profile-field input:focus {
    outline: none;
    border-color: #00b8a9;
    box-shadow: 0 0 10px rgba(0, 180, 169, 0.3);
}

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

.profile-value {
    padding: 0.75rem;
    border: 2px solid rgba(0, 180, 169, 0.3);
    border-radius: 8px;
    background: rgba(0, 0, 0, 0.3);
    color: #ffc93c;
    font-size: 1rem;
    font-weight: bold;
    min-height: 2.5rem;
    display: flex;
    align-items: center;
}

.profile-wallet {
    font-family: monospace;
    font-size: 0.9rem;
    word-break: break-all;
    color: #00d4ff;
}

.profile-actions {
    display: flex;
    gap: 1rem;
    justify-content: center;
    margin-top: 1.5rem;
}

.profile-save-btn {
    padding: 12px 30px;
    font-size: 1rem;
    background: linear-gradient(45deg, #00b8a9, #0084b4);
    color: white;
    border: none;
    border-radius: 25px;
    cursor: pointer;
    transition: all 0.3s ease;
    box-shadow: 0 4px 12px rgba(0, 180, 169, 0.4);
    font-weight: bold;
}

.profile-save-btn:hover {
    transform: translateY(-2px);
    box-shadow: 0 6px 18px rgba(0, 180, 169, 0.6);
}

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

.profile-save-btn:disabled {
    opacity: 0.5;
    cursor: not-allowed;
}

.profile-message {
    margin-top: 1rem;
    padding: 1rem;
    border-radius: 8px;
    text-align: center;
    font-weight: bold;
}

.profile-message.success {
    background: rgba(0, 180, 169, 0.2);
    border: 2px solid #00b8a9;
    color: #00b8a9;
}

.profile-message.error {
    background: rgba(233, 69, 96, 0.2);
    border: 2px solid #e94560;
    color: #e94560;
}

/* Leaderboard Modal Styles */
.leaderboard-content {
    max-width: 800px;
    text-align: left;
}

.leaderboard-filter {
    display: flex;
    align-items: center;
    gap: 1rem;
    margin-bottom: 1.5rem;
    padding: 1rem;
    background: rgba(0, 180, 169, 0.1);
    border-radius: 10px;
}

.leaderboard-filter label {
    color: #ffffff;
    font-weight: bold;
    font-size: 1rem;
}

.leaderboard-select {
    padding: 0.5rem 1rem;
    border: 2px solid rgba(0, 180, 169, 0.3);
    border-radius: 8px;
    background: rgba(0, 0, 0, 0.3);
    color: #ffffff;
    font-size: 1rem;
    cursor: pointer;
    transition: all 0.3s ease;
    flex: 1;
    max-width: 200px;
}

.leaderboard-select:focus {
    outline: none;
    border-color: #00b8a9;
    box-shadow: 0 0 10px rgba(0, 180, 169, 0.3);
}

.leaderboard-select option {
    background: #1a1a2e;
    color: #ffffff;
}

.leaderboard-loading {
    text-align: center;
    padding: 2rem;
    color: #aaa;
}

.leaderboard-user-info {
    margin-bottom: 1.5rem;
}

.user-rank-card {
    background: linear-gradient(135deg, rgba(0, 180, 169, 0.2), rgba(0, 132, 180, 0.2));
    border: 2px solid rgba(0, 180, 169, 0.5);
    border-radius: 12px;
    padding: 1.5rem;
}

.user-rank-card h3 {
    color: #00b8a9;
    margin-bottom: 1rem;
    font-size: 1.2rem;
}

.user-rank-details {
    display: flex;
    align-items: center;
    gap: 2rem;
}

.rank-badge {
    width: 80px;
    height: 80px;
    border-radius: 50%;
    background: linear-gradient(135deg, #00b8a9, #0084b4);
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 2rem;
    font-weight: bold;
    color: #ffffff;
    box-shadow: 0 4px 15px rgba(0, 180, 169, 0.4);
}

.user-info {
    flex: 1;
}

.user-info p {
    margin: 0.5rem 0;
    color: #ffffff;
    font-size: 1rem;
}

.user-info strong {
    color: #00b8a9;
}

.leaderboard-container {
    margin-bottom: 1.5rem;
}

.leaderboard-header {
    display: grid;
    grid-template-columns: 80px 1fr 120px;
    gap: 1rem;
    padding: 1rem;
    background: rgba(0, 180, 169, 0.1);
    border-radius: 8px;
    font-weight: bold;
    color: #00b8a9;
    margin-bottom: 0.5rem;
}

.rank-col, .name-col, .score-col {
    text-align: center;
}

.name-col {
    text-align: left;
}

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

.leaderboard-item {
    display: grid;
    grid-template-columns: 80px 1fr 120px;
    gap: 1rem;
    padding: 1rem;
    margin-bottom: 0.5rem;
    background: rgba(0, 0, 0, 0.3);
    border-radius: 8px;
    border: 2px solid rgba(0, 180, 169, 0.2);
    transition: all 0.3s ease;
    align-items: center;
}

.leaderboard-item:hover {
    background: rgba(0, 180, 169, 0.1);
    border-color: rgba(0, 180, 169, 0.5);
    transform: translateX(5px);
}

.leaderboard-item.current-user {
    background: rgba(0, 180, 169, 0.2);
    border-color: #00b8a9;
    box-shadow: 0 0 15px rgba(0, 180, 169, 0.3);
}

.leaderboard-rank {
    text-align: center;
    font-size: 1.2rem;
    font-weight: bold;
    color: #ffc93c;
}

.leaderboard-rank.top-1 {
    color: #ffd700;
    font-size: 1.5rem;
}

.leaderboard-rank.top-2 {
    color: #c0c0c0;
    font-size: 1.4rem;
}

.leaderboard-rank.top-3 {
    color: #cd7f32;
    font-size: 1.3rem;
}

.leaderboard-player {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    min-width: 0;
}

.leaderboard-name {
    color: #ffffff;
    font-weight: bold;
    font-size: 1rem;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.leaderboard-score {
    text-align: center;
    color: #ffc93c;
    font-weight: bold;
    font-size: 1.1rem;
}

.leaderboard-pagination {
    display: flex;
    justify-content: center;
    align-items: center;
    gap: 1rem;
    margin-top: 1.5rem;
    padding: 1rem;
}

.pagination-btn {
    padding: 0.5rem 1.5rem;
    background: linear-gradient(45deg, #00b8a9, #0084b4);
    color: white;
    border: none;
    border-radius: 8px;
    cursor: pointer;
    transition: all 0.3s ease;
    font-weight: bold;
}

.pagination-btn:hover:not(:disabled) {
    transform: translateY(-2px);
    box-shadow: 0 4px 12px rgba(0, 180, 169, 0.4);
}

.pagination-btn:disabled {
    opacity: 0.5;
    cursor: not-allowed;
}

.page-info {
    color: #ffffff;
    font-weight: bold;
}

.leaderboard-error {
    text-align: center;
    padding: 1rem;
    background: rgba(233, 69, 96, 0.2);
    border: 2px solid #e94560;
    border-radius: 8px;
    color: #e94560;
    margin-bottom: 1rem;
}

/* Responsive leaderboard */
@media (max-width: 600px) {
    .modal-content.leaderboard-content {
        padding: 1rem;
        width: 95%;
        max-height: 90vh;
    }

    .leaderboard-filter {
        flex-direction: column;
        align-items: stretch;
        gap: 0.75rem;
    }

    .leaderboard-select {
        max-width: 100%;
        width: 100%;
    }

    .user-rank-details {
        flex-direction: column;
        align-items: stretch;
        gap: 1rem;
    }

    .rank-badge {
        width: 70px;
        height: 70px;
        margin: 0 auto;
    }

    .leaderboard-header,
    .leaderboard-item {
        grid-template-columns: 60px 1fr 90px;
        gap: 0.5rem;
        padding: 0.75rem;
    }

    .leaderboard-list {
        max-height: 50vh;
    }

    .leaderboard-pagination {
        flex-wrap: wrap;
        gap: 0.5rem;
        padding: 0.5rem;
        margin-top: 1rem;
    }

    .pagination-btn {
        padding: 0.5rem 1rem;
    }
}

@media (max-width: 420px) {
    .leaderboard-header,
    .leaderboard-item {
        grid-template-columns: 52px 1fr 72px;
    }
}