/* ===== CSS Reset & Base ===== */
*, *::before, *::after {
    box-sizing: border-box;
    margin: 0;
    padding: 0;
}

html, body {
    height: 100%;
    overflow: hidden;
    touch-action: manipulation;
    -webkit-touch-callout: none;
    -webkit-user-select: none;
    user-select: none;
    -webkit-tap-highlight-color: transparent;
}

body {
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Oxygen, Ubuntu, sans-serif;
    display: flex;
    justify-content: center;
    align-items: center;
    min-height: 100vh;
    min-height: 100dvh;
}

/* ===== Background ===== */
.background {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: url('websitebackground.jpg') center center / cover no-repeat;
    z-index: -1;
}

.background::after {
    content: '';
    position: absolute;
    inset: 0;
    background: rgba(0, 0, 0, 0.3);
}

/* ===== Game Container ===== */
.game-container {
    width: 100%;
    height: 100%;
    height: 100dvh;
    display: flex;
    justify-content: center;
    align-items: center;
    padding: clamp(8px, 2vw, 20px);
    overflow: hidden;
}

/* ===== Glass Card ===== */
.game-card {
    width: 100%;
    max-width: clamp(300px, 95vw, 700px);
    max-height: calc(100dvh - 20px);
    background: transparent;
    border-radius: clamp(16px, 4vw, 32px);
    border: none;
    box-shadow: none;
    padding: clamp(12px, 3vw, 28px);
    display: flex;
    flex-direction: column;
    gap: clamp(8px, 2vw, 20px);
    overflow: hidden;
}

/* ===== HUD ===== */
.hud {
    display: flex;
    justify-content: space-between;
    gap: 10px;
}

.hud-item {
    flex: 1;
    display: flex;
    flex-direction: column;
    align-items: center;
    background: transparent;
    padding: clamp(8px, 2vw, 12px) clamp(6px, 2vw, 12px);
    border-radius: clamp(10px, 2vw, 14px);
    border: none;
}

.hud-label {
    font-size: clamp(9px, 2.5vw, 11px);
    font-weight: 600;
    color: rgba(255, 255, 255, 0.6);
    letter-spacing: 1px;
    text-transform: uppercase;
}

.hud-value {
    font-size: clamp(22px, 6vw, 32px);
    font-weight: 700;
    color: #fff;
    text-shadow: 0 2px 10px rgba(0, 0, 0, 0.3);
    font-variant-numeric: tabular-nums;
}

.hud-item:first-child .hud-value {
    color: #ff6b6b;
}

.hud-item:nth-child(2) .hud-value {
    color: #ffd93d;
}

.hud-item:last-child .hud-value {
    color: #6bcb77;
}

/* ===== Player Info ===== */
.player-info {
    text-align: center;
    color: rgba(255, 255, 255, 0.9);
    font-size: clamp(12px, 3vw, 14px);
    padding: 8px;
    background: transparent;
    border-radius: 8px;
}

.player-info strong {
    color: #ffd93d;
}

/* ===== Character Area ===== */
.character-area {
    position: relative;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    flex: 1;
    min-height: 0;
    cursor: pointer;
    border-radius: 20px;
    background: transparent;
    overflow: hidden;
}

.character-area:hover {
    background: transparent;
}

.character-wrapper {
    position: relative;
    display: flex;
    justify-content: center;
    align-items: center;
    width: 100%;
    height: 100%;
}

.character {
    width: clamp(280px, 90vw, 700px);
    height: auto;
    max-height: 100%;
    object-fit: contain;
    filter: drop-shadow(0 10px 30px rgba(0, 0, 0, 0.4));
}

/* Character animations */
.character.slap-left {
    animation: slap-bounce-left 0.15s ease-out;
}

.character.slap-right {
    animation: slap-bounce-right 0.15s ease-out;
}

@keyframes slap-bounce-left {
    0% { transform: translateX(0) rotate(0deg) scale(1); }
    30% { transform: translateX(-15px) rotate(-8deg) scale(1.05); }
    100% { transform: translateX(0) rotate(0deg) scale(1); }
}

@keyframes slap-bounce-right {
    0% { transform: translateX(0) rotate(0deg) scale(1); }
    30% { transform: translateX(15px) rotate(8deg) scale(1.05); }
    100% { transform: translateX(0) rotate(0deg) scale(1); }
}

/* Screen shake */
.game-card.shake {
    animation: shake 0.15s ease-out;
}

@keyframes shake {
    0%, 100% { transform: translateX(0) translateY(0); }
    25% { transform: translateX(-4px) translateY(-2px); }
    50% { transform: translateX(4px) translateY(2px); }
    75% { transform: translateX(-2px) translateY(-1px); }
}

/* Floating container */
.floating-container {
    position: absolute;
    inset: 0;
    pointer-events: none;
    overflow: visible;
}

/* Floating slap text */
.floating-text {
    position: absolute;
    left: 50%;
    bottom: -20%;
    transform: translateX(-50%);
    font-size: clamp(24px, 7vw, 36px);
    font-weight: 800;
    color: #fff;
    text-shadow: 
        0 2px 4px rgba(0, 0, 0, 0.5),
        0 0 20px rgba(255, 100, 50, 0.8);
    animation: float-up 0.6s ease-out forwards;
    white-space: nowrap;
    z-index: 10;
}

.floating-text.combo {
    color: #ffd93d;
    text-shadow: 
        0 2px 4px rgba(0, 0, 0, 0.5),
        0 0 30px rgba(255, 180, 0, 0.9);
}

@keyframes float-up {
    0% {
        opacity: 1;
        transform: translateX(-50%) translateY(0) scale(0.5);
    }
    20% {
        transform: translateX(-50%) translateY(10px) scale(1.2);
    }
    100% {
        opacity: 0;
        transform: translateX(-50%) translateY(60px) scale(0.8);
    }
}

/* Hint text */
.hint {
    position: absolute;
    bottom: 20px;
    left: 50%;
    transform: translateX(-50%);
    text-align: center;
    color: rgba(255, 255, 255, 0.7);
    font-size: clamp(14px, 4vw, 18px);
    font-weight: 600;
    animation: pulse-hint 1.5s ease-in-out infinite;
    transition: opacity 0.3s ease;
}

.hint.hidden {
    opacity: 0;
    pointer-events: none;
}

.hint-desktop {
    display: none;
}

.hint-mobile {
    display: block;
}

.hint-key {
    display: block;
    font-size: clamp(11px, 3vw, 13px);
    opacity: 0.6;
    margin-top: 4px;
}

@media (hover: hover) and (pointer: fine) {
    .hint-desktop {
        display: block;
    }
    .hint-mobile {
        display: none;
    }
}

@keyframes pulse-hint {
    0%, 100% { opacity: 0.7; transform: translateX(-50%) scale(1); }
    50% { opacity: 1; transform: translateX(-50%) scale(1.05); }
}

/* ===== Controls ===== */
.controls {
    display: flex;
    gap: clamp(8px, 2vw, 12px);
    justify-content: center;
}

.btn {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 6px;
    padding: clamp(12px, 3vw, 16px) clamp(20px, 5vw, 28px);
    border: none;
    border-radius: clamp(12px, 2.5vw, 16px);
    font-size: clamp(14px, 3.5vw, 16px);
    font-weight: 700;
    cursor: pointer;
    transition: all 0.2s ease;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    text-decoration: none;
}

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

.btn-start {
    flex: 1;
    background: linear-gradient(135deg, #6bcb77 0%, #4ade80 100%);
    color: #fff;
    box-shadow: 0 4px 15px rgba(107, 203, 119, 0.4);
}

.btn-start:hover {
    box-shadow: 0 6px 20px rgba(107, 203, 119, 0.6);
    transform: translateY(-2px);
}

.btn-start:active {
    transform: translateY(0) scale(0.98);
}

.btn-start.disabled {
    background: linear-gradient(135deg, #666 0%, #888 100%);
    cursor: not-allowed;
    box-shadow: none;
}

.btn-restart {
    background: linear-gradient(135deg, #ff6b6b 0%, #ee5a5a 100%);
    color: #fff;
    box-shadow: 0 4px 15px rgba(255, 107, 107, 0.3);
}

.btn-restart:hover {
    box-shadow: 0 6px 20px rgba(255, 107, 107, 0.5);
    transform: translateY(-2px);
}

.btn-mute {
    background: rgba(255, 255, 255, 0.15);
    color: #fff;
    padding: clamp(12px, 3vw, 16px);
    min-width: clamp(48px, 12vw, 56px);
    border: 1px solid rgba(255, 255, 255, 0.2);
}

.btn-mute:hover {
    background: rgba(255, 255, 255, 0.25);
}

/* Leaderboard Button */
.leaderboard-btn-container {
    display: flex;
    justify-content: center;
}

.btn-leaderboard {
    background: linear-gradient(135deg, #a855f7 0%, #7c3aed 100%);
    color: #fff;
    box-shadow: 0 4px 15px rgba(168, 85, 247, 0.4);
}

.btn-leaderboard:hover {
    box-shadow: 0 6px 20px rgba(168, 85, 247, 0.6);
    transform: translateY(-2px);
}

/* ===== Countdown Overlay ===== */
.countdown-overlay {
    position: fixed;
    inset: 0;
    background: rgba(0, 0, 0, 0.8);
    display: flex;
    justify-content: center;
    align-items: center;
    z-index: 100;
    opacity: 0;
    visibility: hidden;
    transition: opacity 0.3s ease, visibility 0.3s ease;
}

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

.countdown-number {
    font-size: clamp(80px, 25vw, 150px);
    font-weight: 900;
    color: #fff;
    text-shadow: 
        0 0 40px rgba(255, 255, 255, 0.5),
        0 0 80px rgba(255, 200, 100, 0.3);
    animation: countdown-pulse 0.5s ease-out;
}

@keyframes countdown-pulse {
    0% { transform: scale(1.5); opacity: 0; }
    50% { transform: scale(1); opacity: 1; }
    100% { transform: scale(0.9); opacity: 0.8; }
}

.countdown-number.go {
    color: #6bcb77;
    font-size: clamp(60px, 20vw, 100px);
}

/* ===== Modal ===== */
.modal-overlay {
    position: fixed;
    inset: 0;
    background: rgba(0, 0, 0, 0.85);
    display: flex;
    justify-content: center;
    align-items: center;
    z-index: 200;
    opacity: 0;
    visibility: hidden;
    transition: opacity 0.3s ease, visibility 0.3s ease;
    padding: 20px;
    overflow-y: auto;
}

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

/* Hidden state for registration overlay after submission */
.modal-overlay.hidden {
    display: none !important;
    opacity: 0;
    visibility: hidden;
}

.modal {
    background: rgba(30, 30, 40, 0.95);
    backdrop-filter: blur(20px);
    -webkit-backdrop-filter: blur(20px);
    border-radius: clamp(20px, 4vw, 28px);
    border: 1px solid rgba(255, 255, 255, 0.15);
    padding: clamp(24px, 6vw, 40px);
    text-align: center;
    max-width: 400px;
    width: 100%;
    transform: scale(0.9);
    transition: transform 0.3s ease;
    box-shadow: 0 20px 60px rgba(0, 0, 0, 0.5);
}

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

.modal-title {
    font-size: clamp(24px, 6vw, 32px);
    font-weight: 800;
    color: #fff;
    margin-bottom: clamp(16px, 4vw, 24px);
}

.modal-subtitle {
    color: rgba(255, 255, 255, 0.7);
    font-size: clamp(14px, 3.5vw, 16px);
    margin-bottom: 20px;
}

.modal-scores {
    display: flex;
    gap: 20px;
    margin-bottom: clamp(16px, 4vw, 24px);
}

.modal-score {
    flex: 1;
    background: rgba(255, 255, 255, 0.1);
    padding: clamp(16px, 4vw, 24px);
    border-radius: 16px;
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.modal-score-label {
    font-size: clamp(11px, 3vw, 13px);
    color: rgba(255, 255, 255, 0.6);
    text-transform: uppercase;
    letter-spacing: 1px;
}

.modal-score-value {
    font-size: clamp(32px, 8vw, 48px);
    font-weight: 800;
    color: #ffd93d;
}

.modal-score:last-child .modal-score-value {
    color: #6bcb77;
}

.modal-message {
    font-size: clamp(14px, 3.5vw, 16px);
    color: rgba(255, 255, 255, 0.8);
    margin-bottom: clamp(16px, 4vw, 24px);
    min-height: 24px;
}

.modal-message.new-best {
    color: #6bcb77;
    font-weight: 700;
    font-size: clamp(16px, 4vw, 20px);
}

.modal-buttons {
    display: flex;
    gap: 12px;
    flex-wrap: wrap;
    justify-content: center;
}

/* Share buttons */
.share-buttons {
    display: flex;
    gap: 8px;
    flex-wrap: wrap;
    justify-content: center;
    margin-top: 16px;
    padding-top: 16px;
    border-top: 1px solid rgba(255, 255, 255, 0.1);
}

.share-buttons .btn {
    padding: 10px 16px;
    font-size: 13px;
    flex: 1;
    min-width: 100px;
}

.btn-download {
    background: linear-gradient(135deg, #6bcb77 0%, #4ade80 100%);
    color: #fff;
}

.btn-share-fb {
    background: linear-gradient(135deg, #1877f2 0%, #0d65d9 100%);
    color: #fff;
}

.btn-share-wa {
    background: linear-gradient(135deg, #25d366 0%, #128c7e 100%);
    color: #fff;
}

.btn-share-tw {
    background: linear-gradient(135deg, #1da1f2 0%, #0c85d0 100%);
    color: #fff;
}

/* Score card for sharing */
.score-card-header {
    font-size: 14px;
    font-weight: 700;
    color: #ffd93d;
    margin-bottom: 12px;
    letter-spacing: 2px;
}

.score-card-player {
    font-size: 12px;
    color: rgba(255, 255, 255, 0.6);
    margin-top: 8px;
}

.btn-play-again {
    flex: 1;
    min-width: 140px;
    background: linear-gradient(135deg, #ffd93d 0%, #ffb800 100%);
    color: #333;
    box-shadow: 0 4px 15px rgba(255, 217, 61, 0.4);
}

.btn-play-again:hover {
    box-shadow: 0 6px 20px rgba(255, 217, 61, 0.6);
}

.btn-close {
    background: rgba(255, 255, 255, 0.15);
    color: #fff;
    border: 1px solid rgba(255, 255, 255, 0.2);
}

.btn-close:hover {
    background: rgba(255, 255, 255, 0.25);
}

/* ===== Form Styles ===== */
.form-group {
    margin-bottom: 16px;
    text-align: left;
}

.form-group label {
    display: block;
    color: rgba(255, 255, 255, 0.8);
    font-size: 13px;
    margin-bottom: 6px;
    font-weight: 600;
}

.form-group input {
    width: 100%;
    padding: 14px 16px;
    border-radius: 12px;
    border: 1px solid rgba(255, 255, 255, 0.2);
    background: rgba(0, 0, 0, 0.3);
    color: #fff;
    font-size: 16px;
    transition: border-color 0.2s ease, background 0.2s ease;
}

.form-group input:focus {
    outline: none;
    border-color: #ffd93d;
    background: rgba(0, 0, 0, 0.4);
}

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

.phone-notice {
    display: block;
    color: #ffd93d;
    font-size: 0.75rem;
    margin-top: 6px;
    font-style: italic;
    opacity: 0.9;
}

/* ===== Leaderboard Modal ===== */
.leaderboard-modal {
    max-width: 500px;
}

.leaderboard-tabs {
    display: flex;
    gap: 8px;
    margin-bottom: 16px;
    justify-content: center;
}

.tab-btn {
    padding: 10px 20px;
    border: none;
    border-radius: 10px;
    background: rgba(255, 255, 255, 0.1);
    color: rgba(255, 255, 255, 0.7);
    font-size: 14px;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.2s ease;
}

.tab-btn.active {
    background: linear-gradient(135deg, #a855f7 0%, #7c3aed 100%);
    color: #fff;
}

.tab-btn:hover:not(.active) {
    background: rgba(255, 255, 255, 0.2);
}

.leaderboard-list {
    max-height: 300px;
    overflow-y: auto;
    margin-bottom: 16px;
}

.leaderboard-entry {
    display: flex;
    align-items: center;
    padding: 12px 16px;
    background: rgba(255, 255, 255, 0.05);
    border-radius: 10px;
    margin-bottom: 8px;
    gap: 12px;
}

.leaderboard-entry:nth-child(1) {
    background: linear-gradient(135deg, rgba(255, 215, 0, 0.2) 0%, rgba(255, 215, 0, 0.1) 100%);
    border: 1px solid rgba(255, 215, 0, 0.3);
}

.leaderboard-entry:nth-child(2) {
    background: linear-gradient(135deg, rgba(192, 192, 192, 0.2) 0%, rgba(192, 192, 192, 0.1) 100%);
    border: 1px solid rgba(192, 192, 192, 0.3);
}

.leaderboard-entry:nth-child(3) {
    background: linear-gradient(135deg, rgba(205, 127, 50, 0.2) 0%, rgba(205, 127, 50, 0.1) 100%);
    border: 1px solid rgba(205, 127, 50, 0.3);
}

.leaderboard-rank {
    font-size: 18px;
    font-weight: 700;
    color: #ffd93d;
    min-width: 30px;
}

.leaderboard-name {
    flex: 1;
    color: #fff;
    font-weight: 600;
    font-size: 14px;
}

.leaderboard-score {
    font-size: 18px;
    font-weight: 700;
    color: #6bcb77;
}

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

/* ===== Particles ===== */
.particles {
    position: fixed;
    inset: 0;
    pointer-events: none;
    z-index: 50;
    overflow: hidden;
}

.particle {
    position: absolute;
    width: 8px;
    height: 8px;
    border-radius: 50%;
    animation: particle-burst 0.6s ease-out forwards;
}

@keyframes particle-burst {
    0% {
        transform: translate(-50%, -50%) scale(1);
        opacity: 1;
    }
    100% {
        transform: translate(var(--tx), var(--ty)) scale(0);
        opacity: 0;
    }
}

/* ===== Desktop Adjustments ===== */
@media (min-width: 768px) {
    .game-card {
        max-width: 700px;
        padding: 32px;
    }
    
    .character {
        width: 600px;
    }
}

/* ===== Small Screen Adjustments ===== */
@media (max-height: 700px) {
    .game-card {
        padding: 8px;
        gap: 6px;
    }
    
    .hud-item {
        padding: 4px 6px;
    }
    
    .hud-value {
        font-size: clamp(16px, 5vw, 24px);
    }
    
    .controls {
        gap: 6px;
    }
    
    .btn {
        padding: 8px 14px;
        font-size: 11px;
    }
    
    .player-info {
        padding: 4px;
        font-size: 10px;
    }
    
    .character {
        width: clamp(250px, 85vw, 500px);
    }
}

/* ===== Very Small Screen (iPhone SE, etc) ===== */
@media (max-height: 600px) {
    .game-card {
        padding: 6px;
        gap: 4px;
        border-radius: 12px;
    }
    
    .hud-item {
        padding: 3px 5px;
        border-radius: 6px;
    }
    
    .hud-label {
        font-size: 7px;
    }
    
    .hud-value {
        font-size: clamp(14px, 4vw, 20px);
    }
    
    .hint {
        font-size: 9px;
    }
    
    .leaderboard-btn-container {
        margin-top: 0;
    }
    
    .btn-leaderboard {
        padding: 6px 12px;
        font-size: 10px;
    }
    
    .character {
        width: clamp(220px, 80vw, 400px);
    }
}

/* ===== Accessibility ===== */
@media (prefers-reduced-motion: reduce) {
    *, *::before, *::after {
        animation-duration: 0.01ms !important;
        animation-iteration-count: 1 !important;
        transition-duration: 0.01ms !important;
    }
}

/* Focus styles */
.btn:focus-visible {
    outline: 3px solid #ffd93d;
    outline-offset: 3px;
}

/* Registration Modal */
.registration-modal {
    max-width: 380px;
}
