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

html,
body {
    width: 100%;
    height: 100%;
    font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;
    background-image: url('bg.jpg');
    background-size: cover;
    background-position: center;
    background-repeat: no-repeat;
    background-attachment: fixed;
    overflow: hidden;
    overscroll-behavior: none;
    -webkit-user-select: none;
    user-select: none;
    -webkit-tap-highlight-color: transparent;
}

/* Game Container - Full Screen */
.game-container {
    width: 100%;
    height: 100vh;
    display: flex;
    justify-content: center;
    align-items: center;
    position: relative;
    background-image: url('bg.jpg');
    background-size: cover;
    background-position: center;
    background-repeat: no-repeat;
}

/* Header Overlay on Game */
.top-header-overlay {
    display: none;
}

.title-section h1 {
    font-size: 32px;
    color: white;
    font-weight: bold;
    text-shadow: 2px 2px 4px rgba(0, 0, 0, 0.5);
}

.score-display {
    position: absolute;
    top: 20px;
    right: 20px;
    font-size: 24px;
    font-weight: bold;
    color: white;
    background: rgba(0, 0, 0, 0.5);
    padding: 10px 20px;
    border-radius: 8px;
    z-index: 100;
}

.score-label {
    margin-right: 10px;
}

.score-value {
    color: #FFD700;
    font-size: 28px;
}

#gameCanvas {
     background: transparent !important;
    max-width: 100%;
    max-height: 100%;
    display: block;
    cursor: pointer;
    background: transparent;
    touch-action: none;
}

.disclaimer-page {
    position: fixed;
    inset: 0;
    z-index: 2000;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 24px;
    background: rgba(0, 0, 0, 0.8);
    backdrop-filter: blur(6px);
}

.disclaimer-page.hidden {
    display: none;
}

.disclaimer-card {
    width: min(680px, 100%);
    background: rgba(255, 255, 255, 0.96);
    border-radius: 16px;
    padding: 28px;
    color: #1f2937;
    box-shadow: 0 20px 50px rgba(0, 0, 0, 0.35);
    text-align: left;
}

.disclaimer-card h1 {
    margin-bottom: 14px;
    font-size: 30px;
}

.disclaimer-card p {
    margin-bottom: 10px;
    line-height: 1.5;
}

.disclaimer-card .btn {
    margin-top: 8px;
    width: 100%;
}

/* Modal Styles */
.modal {
    display: none;
    position: fixed;
    z-index: 1000;
    left: 0;
    top: 0;
    width: 100%;
    height: 100%;
    background-color: rgba(0, 0, 0, 0.7);
    backdrop-filter: blur(5px);
    animation: fadeIn 0.3s ease-out;
    overflow-y: auto;
}

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

.modal.show {
    display: flex;
    justify-content: center;
    align-items: center;
}

.modal-content {
    background: rgba(255, 255, 255, 0.95);
    padding: 40px;
    border-radius: 16px;
    text-align: center;
    box-shadow: 0 20px 60px rgba(0, 0, 0, 0.4);
    animation: slideUp 0.3s ease-out;
    max-width: 500px;
    width: 90%;
    max-height: 90vh;
    overflow-y: auto;
    margin: auto;
}

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

.modal-content h2 {
    font-size: 32px;
    color: #333;
    margin-bottom: 15px;
}

.final-score {
    font-size: 20px;
    color: #333;
    margin-bottom: 30px;
    font-weight: bold;
}

.player-input {
    margin-bottom: 25px;
}

.player-input label {
    display: block;
    margin-bottom: 8px;
    font-weight: bold;
    color: #333;
}

.player-input input {
    width: 100%;
    padding: 12px;
    border: 2px solid #999;
    border-radius: 6px;
    font-size: 16px;
    transition: border-color 0.3s;
}

.player-input input:focus {
    outline: none;
    border-color: #333;
    box-shadow: 0 0 5px rgba(0, 0, 0, 0.2);
}

.modal-buttons {
    display: flex;
    gap: 15px;
    margin-bottom: 25px;
}

.btn {
    flex: 1;
    padding: 12px 20px;
    font-size: 16px;
    border: none;
    border-radius: 6px;
    cursor: pointer;
    font-weight: bold;
    transition: all 0.3s;
    touch-action: manipulation;
}

.btn-primary {
    background: #333;
    color: white;
}

.btn-primary:hover {
    transform: translateY(-2px);
    box-shadow: 0 8px 15px rgba(0, 0, 0, 0.3);
}

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

.btn-secondary {
    background: #f0f0f0;
    color: #333;
    border: 2px solid #999;
}

.btn-secondary:hover {
    background: #333;
    color: white;
    transform: translateY(-2px);
}

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

.save-message {
    min-height: 20px;
    font-size: 14px;
    margin-bottom: 20px;
}

.save-message.success {
    color: #27ae60;
    font-weight: bold;
}

.save-message.error {
    color: #e74c3c;
    font-weight: bold;
}

/* Modal Leaderboard */
.modal-leaderboard {
    margin-top: 30px;
    padding-top: 30px;
    border-top: 2px solid #ecf0f1;
}

.modal-leaderboard h3 {
    font-size: 22px;
    color: #333;
    margin-bottom: 20px;
    text-align: center;
    font-weight: bold;
}

.leaderboard {
    background: #f8f9fa;
    border-radius: 8px;
    overflow: hidden;
    border: 1px solid #ecf0f1;
}

.leaderboard-header {
    display: grid;
    grid-template-columns: 50px 1fr 80px;
    gap: 15px;
    background: #333;
    color: white;
    padding: 15px;
    font-weight: bold;
    text-align: center;
    font-size: 14px;
}

.leaderboard-header .rank {
    text-align: left;
}

.leaderboard-header .name {
    text-align: left;
}

.leaderboard-header .score-col {
    text-align: right;
}

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

.leaderboard-list::-webkit-scrollbar {
    width: 6px;
}

.leaderboard-list::-webkit-scrollbar-track {
    background: transparent;
}

.leaderboard-list::-webkit-scrollbar-thumb {
    background: rgba(0, 0, 0, 0.3);
    border-radius: 5px;
}

.leaderboard-list::-webkit-scrollbar-thumb:hover {
    background: rgba(0, 0, 0, 0.5);
}

.leaderboard-item {
    display: grid;
    grid-template-columns: 50px 1fr 80px;
    gap: 15px;
    padding: 12px 15px;
    border-bottom: 1px solid #ecf0f1;
    align-items: center;
    transition: background 0.2s;
    font-size: 14px;
}

.leaderboard-item:hover {
    background: #e8eef7;
}

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

.leaderboard-item.top-1 {
    background: #fef3c7;
    font-weight: bold;
}

.leaderboard-item.top-2 {
    background: #e5e7eb;
}

.leaderboard-item.top-3 {
    background: #fed7aa;
}

.leaderboard-item .rank {
    font-weight: bold;
    color: #333;
    text-align: left;
}

.leaderboard-item .name {
    text-align: left;
    color: #333;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.leaderboard-item .score-col {
    text-align: right;
    font-weight: bold;
    color: #333;
}

.loading {
    text-align: center;
    padding: 20px;
    color: #999;
    font-size: 14px;
}

.empty-leaderboard {
    text-align: center;
    padding: 20px;
    color: #999;
    font-size: 14px;
}

/* Responsive Design */
@media (max-width: 768px) {
    .title-section h1 {
        font-size: 24px;
    }

    .score-display {
        font-size: 18px;
        padding: 8px 12px;
    }

    .score-value {
        font-size: 22px;
    }

    .top-header-overlay {
        padding: 12px 20px;
    }

    .modal-content {
        padding: 30px 20px;
        max-width: 95%;
    }

    .modal-content h2 {
        font-size: 26px;
    }

    .final-score {
        font-size: 18px;
    }

    .leaderboard-header {
        grid-template-columns: 40px 1fr 70px;
        padding: 12px;
        font-size: 12px;
        gap: 10px;
    }

    .leaderboard-item {
        grid-template-columns: 40px 1fr 70px;
        padding: 10px 12px;
        font-size: 12px;
        gap: 10px;
    }

    .modal-leaderboard h3 {
        font-size: 18px;
    }

    .modal-buttons {
        flex-direction: column;
    }
}

@media (max-width: 480px) {
    .title-section h1 {
        font-size: 20px;
    }

    .score-display {
        font-size: 14px;
        padding: 6px 10px;
    }

    .score-value {
        font-size: 18px;
    }

    .top-header-overlay {
        padding: 10px 15px;
        flex-direction: column;
        gap: 8px;
        height: auto;
    }

    .modal-content {
        padding: 25px 15px;
        max-width: 98%;
    }

    .modal-content h2 {
        font-size: 22px;
    }

    .player-input label {
        font-size: 14px;
    }

    .player-input input {
        padding: 10px;
        font-size: 14px;
    }

    .btn {
        padding: 10px 15px;
        font-size: 14px;
    }

    .leaderboard-header {
        grid-template-columns: 35px 1fr 60px;
        padding: 10px;
        font-size: 11px;
        gap: 8px;
    }

    .leaderboard-item {
        grid-template-columns: 35px 1fr 60px;
        padding: 8px 10px;
        font-size: 11px;
        gap: 8px;
    }

    .modal-leaderboard {
        margin-top: 20px;
        padding-top: 20px;
    }

    .modal-leaderboard h3 {
        font-size: 16px;
        margin-bottom: 15px;
    }

    .leaderboard-list {
        max-height: 250px;
    }
}
