/* FlappyClaw - OpenClaw Style CSS */

/* Import fonts similar to OpenClaw */
@import url('https://api.fontshare.com/v2/css?f[]=clash-display@700&f[]=satoshi@400,500,700&display=swap');

* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

body {
    font-family: 'Satoshi', system-ui, sans-serif;
    background-color: rgb(5, 8, 16);
    color: rgb(240, 244, 255);
    min-height: 100vh;
    min-height: 100dvh; /* Dynamic viewport height for mobile */
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    overflow: hidden;
    position: relative;
    padding: env(safe-area-inset-top) env(safe-area-inset-right) env(safe-area-inset-bottom) env(safe-area-inset-left);
    touch-action: manipulation; /* Prevent double-tap zoom */
    -webkit-touch-callout: none;
    -webkit-user-select: none;
    user-select: none;
}

/* Stars background - same as OpenClaw */
.stars {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    pointer-events: none;
    background-image: 
        radial-gradient(2px 2px at 20px 30px, rgba(255, 255, 255, 0.8), transparent),
        radial-gradient(2px 2px at 40px 70px, rgba(255, 255, 255, 0.5), transparent),
        radial-gradient(1px 1px at 90px 40px, rgba(255, 255, 255, 0.6), transparent),
        radial-gradient(2px 2px at 130px 80px, rgba(255, 255, 255, 0.4), transparent),
        radial-gradient(1px 1px at 160px 120px, rgba(255, 255, 255, 0.7), transparent),
        radial-gradient(2px 2px at 200px 60px, rgba(0, 229, 204, 0.6), transparent),
        radial-gradient(1px 1px at 250px 150px, rgba(255, 255, 255, 0.5), transparent),
        radial-gradient(2px 2px at 300px 40px, rgba(255, 77, 77, 0.4), transparent);
    background-size: 350px 200px;
    animation: twinkle 8s ease-in-out infinite;
    z-index: 0;
}

/* Nebula glow - same as OpenClaw */
.nebula {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    pointer-events: none;
    background-image: 
        radial-gradient(80% 50% at 20% 20%, rgba(255, 77, 77, 0.12), transparent 50%),
        radial-gradient(60% 60% at 80% 30%, rgba(0, 229, 204, 0.08), transparent 50%),
        radial-gradient(90% 70% at 50% 90%, rgba(255, 77, 77, 0.06), transparent 50%);
    z-index: 0;
}

@keyframes twinkle {
    0%, 100% { opacity: 0.8; }
    50% { opacity: 1; }
}

/* Main title styling - Clash Display like OpenClaw */
h1 {
    font-family: 'Clash Display', system-ui, sans-serif;
    font-size: 48px;
    font-weight: 700;
    margin-bottom: 20px;
    text-align: center;
    letter-spacing: -1.5px;
}

/* Title gradient text - matches OpenClaw exactly */
.title-text {
    background: linear-gradient(135deg, rgb(240, 244, 255) 0%, rgb(255, 77, 77) 50%, rgb(0, 229, 204) 100%);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
}

h1 .title-icon-wrapper {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 12px;
}

/* Title SVG icon */
.title-icon {
    width: 48px;
    height: 48px;
    animation: pulse 2s infinite;
}

@keyframes pulse {
    0%, 100% {
        filter: drop-shadow(0 0 8px rgba(255, 107, 74, 0.6));
    }
    50% {
        filter: drop-shadow(0 0 16px rgba(255, 107, 74, 0.9));
    }
}

/* Game container */
.game-container {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 10px;
    position: relative;
    z-index: 1;
    width: 100%;
    max-width: 100vw;
    padding: 10px;
    box-sizing: border-box;
}

/* Canvas wrapper for responsive sizing */
.canvas-wrapper {
    position: relative;
    width: 100%;
    max-width: 400px;
    height: calc(100dvh - 100px);
    max-height: 600px;
    min-height: 400px;
}

/* Mobile/Tablet: fullscreen game */
@media (max-width: 1024px) {
    body {
        background-color: rgb(5, 8, 16);
        padding: 0;
        margin: 0;
    }
    
    .stars, .nebula {
        display: none;
    }
    
    .game-container {
        padding: 0;
        gap: 0;
        height: 100vh;
        height: 100dvh;
        width: 100vw;
        max-width: 100vw;
        justify-content: center;
        margin: 0;
    }
    
    .canvas-wrapper {
        max-width: 100vw;
        max-height: 100vh;
        max-height: 100dvh;
        width: 100vw;
        height: 100vh;
        height: 100dvh;
        min-height: 100vh;
        min-height: 100dvh;
        border-radius: 0;
        margin: 0;
    }
    
    #gameCanvas {
        border: none;
        border-radius: 0;
        box-shadow: none;
        width: 100% !important;
        height: 100% !important;
    }
    
    .footer {
        bottom: 5px;
        font-size: 11px;
    }
    
    /* Hide footer completely during gameplay on mobile */
    body:has(.overlay[style*="display: none"] + .overlay[style*="display: none"]) .footer {
        display: none;
    }
    
    .footer-content {
        gap: 6px;
    }
    
    .footer-main {
        font-size: 11px;
    }
    
    .footer-links {
        font-size: 13px;
    }
    
    .footer-social {
        gap: 10px;
    }
    
    .footer-social a {
        width: 30px;
        height: 30px;
        font-size: 14px;
    }
}

/* Canvas styling */
#gameCanvas {
    width: 100%;
    height: 100%;
    border: 3px solid rgba(240, 244, 255, 0.2);
    border-radius: 12px;
    box-shadow: 0 0 40px rgba(255, 107, 74, 0.2);
    display: block;
    touch-action: none; /* Prevent scrolling when touching canvas */
    background: rgb(5, 8, 16);
    /* GPU acceleration for mobile */
    will-change: contents;
    transform: translateZ(0);
    -webkit-transform: translateZ(0);
}

/* Score display - Flappy Bird style */
.score-display {
    position: absolute;
    top: 30px;
    left: 50%;
    transform: translateX(-50%);
    font-family: 'Clash Display', system-ui, sans-serif;
    font-size: 72px;
    font-weight: 700;
    color: white;
    text-shadow: 
        -3px -3px 0 #000,
        3px -3px 0 #000,
        -3px 3px 0 #000,
        3px 3px 0 #000,
        0 4px 0 #000;
    z-index: 5;
    pointer-events: none;
}

.score-display span {
    color: white;
}

/* Sound Control Buttons */
.mute-btn, .music-btn {
    position: absolute;
    right: 20px;
    width: 50px;
    height: 50px;
    background: rgba(5, 8, 16, 0.7);
    border: 2px solid rgba(240, 244, 255, 0.2);
    border-radius: 12px;
    cursor: pointer;
    z-index: 1000;
    font-size: 24px;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.2s ease;
    backdrop-filter: blur(10px);
}

.mute-btn {
    top: 20px;
}

.music-btn {
    top: 80px;
}

.music-off {
    opacity: 0.3;
}

.mute-btn:hover, .music-btn:hover {
    background: rgba(5, 8, 16, 0.9);
    border-color: rgba(0, 229, 204, 0.5);
    transform: scale(1.05);
}

.mute-btn:active, .music-btn:active {
    transform: scale(0.95);
}

/* Instructions */
.instructions {
    font-family: 'Satoshi', system-ui, sans-serif;
    font-size: 16px;
    color: rgba(240, 244, 255, 0.7);
    text-align: center;
    margin-top: 10px;
}

/* Start/Game Over overlay */
.overlay {
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    text-align: center;
    z-index: 10;
    background: rgba(5, 8, 16, 0.95);
    padding: 30px 25px;
    border-radius: 12px;
    width: 85%;
    max-width: 300px;
    box-sizing: border-box;
}

.overlay p {
    font-family: 'Satoshi', system-ui, sans-serif;
    font-size: 16px;
    color: rgba(240, 244, 255, 0.8);
    margin-bottom: 8px;
}

/* Button styling */
.play-btn {
    font-family: 'Satoshi', system-ui, sans-serif;
    font-size: 18px;
    font-weight: 600;
    padding: 12px 32px;
    background: linear-gradient(135deg, #ff6b4a 0%, #ff4a6b 100%);
    color: rgb(240, 244, 255);
    border: none;
    border-radius: 8px;
    cursor: pointer;
    transition: transform 0.2s, box-shadow 0.2s;
    margin-top: 15px;
    white-space: nowrap;
    display: block;
    width: 100%;
    box-sizing: border-box;
}

.play-btn:hover {
    transform: scale(1.05);
    box-shadow: 0 0 20px rgba(255, 107, 74, 0.5);
}

/* High score styling */
.high-score {
    font-family: 'Satoshi', system-ui, sans-serif;
    font-size: 14px;
    color: rgba(240, 244, 255, 0.6);
    margin-top: 10px;
}

/* Lobster SVG animation */
.lobster-icon-svg {
    width: 60px;
    height: 60px;
    animation: bounce 1s infinite;
    filter: drop-shadow(0 0 12px rgba(255, 107, 74, 0.6));
}

.lobster-icon {
    font-size: 32px;
    animation: bounce 1s infinite;
}

@keyframes bounce {
    0%, 100% {
        transform: translateY(0);
    }
    50% {
        transform: translateY(-10px);
    }
}

/* Footer */
.footer {
    position: fixed;
    bottom: 15px;
    left: 50%;
    transform: translateX(-50%);
    font-family: 'Satoshi', system-ui, sans-serif;
    font-size: 13px;
    color: rgba(240, 244, 255, 0.6);
    z-index: 1;
    text-align: center;
}

.footer-content {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 10px;
}

.footer-main {
    font-size: 13px;
    opacity: 0.8;
}

.footer-links {
    font-size: 11px;
    opacity: 0.7;
}

.footer-links a {
    color: rgba(240, 244, 255, 0.7);
    text-decoration: none;
    transition: all 0.2s ease;
}

.footer-links a:hover {
    color: #ff4d4d;
}

.footer-social {
    display: flex;
    gap: 15px;
    align-items: center;
}

.footer-social a {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 36px;
    height: 36px;
    border-radius: 50%;
    background: rgba(240, 244, 255, 0.05);
    color: rgba(240, 244, 255, 0.6);
    text-decoration: none;
    transition: all 0.3s ease;
    font-size: 16px;
}

.footer-social a:hover {
    background: rgba(255, 77, 77, 0.15);
    color: #ff4d4d;
    transform: translateY(-2px);
}

.footer a {
    color: #ff4d4d;
    text-decoration: none;
}

/* Overlay h2 gradient title - FlappyClaw style */
.overlay h2 {
    font-family: 'Clash Display', system-ui, sans-serif;
    font-size: 28px;
    font-weight: 700;
    margin-bottom: 15px;
    letter-spacing: -1px;
    background: linear-gradient(135deg, rgb(240, 244, 255) 0%, rgb(255, 77, 77) 50%, rgb(0, 229, 204) 100%);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
}

/* Mobile-specific styles */
@media (max-width: 480px) {
    .overlay {
        padding: 20px 15px;
        width: 90%;
    }
    
    .overlay h2 {
        font-size: 24px;
        margin-bottom: 10px;
    }
    
    .overlay p {
        font-size: 14px;
        margin-bottom: 6px;
    }
    
    .lobster-icon-svg {
        width: 50px;
        height: 50px;
    }
    
    .play-btn {
        font-size: 16px;
        padding: 10px 24px;
        margin-top: 10px;
    }
    
    .high-score {
        font-size: 12px;
    }
    
    .score-display {
        font-size: 48px;
        top: 15px;
    }
}

/* Landscape mobile adjustments */
@media (max-height: 500px) and (orientation: landscape) {
    .canvas-wrapper {
        height: 100dvh;
        width: auto;
        aspect-ratio: 2/3;
    }
    
    .overlay {
        padding: 15px 20px;
    }
    
    .overlay h2 {
        font-size: 20px;
        margin-bottom: 8px;
    }
    
    .lobster-icon-svg {
        width: 40px;
        height: 40px;
    }
    
    .overlay p {
        font-size: 12px;
        margin-bottom: 4px;
    }
    
    .play-btn {
        font-size: 14px;
        padding: 8px 20px;
        margin-top: 8px;
    }
}

/* Touch device optimizations */
@media (hover: none) and (pointer: coarse) {
    .play-btn {
        min-height: 44px; /* Minimum touch target size */
        min-width: 120px;
    }
    
    .play-btn:hover {
        transform: none;
        box-shadow: none;
    }
    
    .play-btn:active {
        transform: scale(0.95);
        box-shadow: 0 0 15px rgba(255, 107, 74, 0.5);
    }
}

/* Leaderboard button styling */
.leaderboard-btn {
    font-family: 'Satoshi', system-ui, sans-serif;
    font-size: 18px;
    font-weight: 600;
    padding: 12px 32px;
    background: linear-gradient(135deg, #00e5cc 0%, #00b3a0 100%);
    color: rgb(5, 8, 16);
    border: none;
    border-radius: 8px;
    cursor: pointer;
    transition: transform 0.2s, box-shadow 0.2s;
    margin-top: 10px;
    white-space: nowrap;
    display: block;
    width: 100%;
    box-sizing: border-box;
}

.leaderboard-btn:hover {
    transform: scale(1.05);
    box-shadow: 0 0 20px rgba(0, 229, 204, 0.5);
}

/* Name input styling */
/* Submit score section styling */
.final-score-text {
    font-size: 24px;
    font-weight: 700;
    margin-bottom: 20px;
    background: linear-gradient(135deg, rgb(240, 244, 255) 0%, rgb(0, 229, 204) 100%);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
}

/* High score banner in submit section */
.high-score-banner {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 10px;
    padding: 12px 20px;
    background: linear-gradient(135deg, rgba(255, 215, 0, 0.15) 0%, rgba(255, 165, 0, 0.1) 100%);
    border: 2px solid rgba(255, 215, 0, 0.4);
    border-radius: 16px;
    margin-bottom: 15px;
    animation: fadeInScale 0.5s ease;
}

.star-icon {
    font-size: 20px;
    animation: pulse 2s ease infinite;
}

.high-score-label {
    font-size: 14px;
    font-weight: 600;
    color: rgba(240, 244, 255, 0.7);
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.high-score-value {
    font-size: 32px;
    font-weight: 800;
    background: linear-gradient(135deg, #ffd700 0%, #ffed4e 50%, #ffd700 100%);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
    text-shadow: 0 0 20px rgba(255, 215, 0, 0.5);
    filter: drop-shadow(0 2px 4px rgba(0, 0, 0, 0.3));
}

@keyframes fadeInScale {
    from {
        opacity: 0;
        transform: scale(0.9);
    }
    to {
        opacity: 1;
        transform: scale(1);
    }
}

.submit-header {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 8px;
    margin-bottom: 15px;
    animation: fadeInScale 0.4s ease;
}

.trophy-icon {
    font-size: 48px;
    animation: bounce 1s ease infinite;
}

@keyframes bounce {
    0%, 100% { transform: translateY(0); }
    50% { transform: translateY(-10px); }
}

.submit-message {
    font-size: 16px;
    font-weight: 500;
    color: rgba(240, 244, 255, 0.9);
    margin: 0;
}

.name-input {
    font-family: 'Satoshi', system-ui, sans-serif;
    font-size: 18px;
    padding: 14px 18px;
    background: rgba(240, 244, 255, 0.08);
    border: 2px solid rgba(240, 244, 255, 0.3);
    border-radius: 12px;
    color: rgb(240, 244, 255);
    width: 100%;
    box-sizing: border-box;
    margin-bottom: 15px;
    text-align: center;
    transition: all 0.3s ease;
}

.name-input:focus {
    outline: none;
    border-color: #00e5cc;
    background: rgba(240, 244, 255, 0.12);
    box-shadow: 0 0 20px rgba(0, 229, 204, 0.4);
    transform: scale(1.02);
}

.name-input::placeholder {
    color: rgba(240, 244, 255, 0.4);
}

/* Button group for submit/cancel */
.button-group {
    display: flex;
    gap: 10px;
    width: 100%;
    margin-bottom: 10px;
}

.button-group .submit-btn,
.button-group .cancel-btn {
    flex: 1;
}

/* Submit button */
.submit-btn {
    font-family: 'Satoshi', system-ui, sans-serif;
    font-size: 16px;
    font-weight: 700;
    padding: 14px 24px;
    background: linear-gradient(135deg, #00e5cc 0%, #00b3a0 100%);
    color: rgb(5, 8, 16);
    border: none;
    border-radius: 12px;
    cursor: pointer;
    transition: all 0.3s ease;
    box-shadow: 0 4px 15px rgba(0, 229, 204, 0.3);
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 6px;
}

.submit-btn:hover {
    transform: translateY(-2px);
    box-shadow: 0 6px 25px rgba(0, 229, 204, 0.5);
    background: linear-gradient(135deg, #00ffd9 0%, #00c7b5 100%);
}

.submit-btn:active {
    transform: translateY(0);
    box-shadow: 0 2px 10px rgba(0, 229, 204, 0.4);
}

.submit-btn:disabled {
    opacity: 0.5;
    cursor: not-allowed;
    transform: none;
    box-shadow: none;
}

.btn-icon {
    font-size: 18px;
    line-height: 1;
}

/* Cancel button */
.cancel-btn {
    font-family: 'Satoshi', system-ui, sans-serif;
    font-size: 16px;
    font-weight: 600;
    padding: 14px 24px;
    background: rgba(240, 244, 255, 0.05);
    color: rgba(240, 244, 255, 0.8);
    border: 2px solid rgba(240, 244, 255, 0.3);
    border-radius: 12px;
    cursor: pointer;
    transition: all 0.3s ease;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 6px;
}

.cancel-btn:hover {
    background: rgba(240, 244, 255, 0.1);
    border-color: rgba(255, 77, 77, 0.5);
    color: rgba(255, 77, 77, 0.9);
    transform: translateY(-2px);
}

.cancel-btn:active {
    transform: translateY(0);
}

.submitted-text {
    color: #00e5cc;
    font-weight: 600;
    margin-bottom: 10px;
}

/* Modal overlay */
.modal-overlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(5, 8, 16, 0.95);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 100;
    padding: 20px;
    box-sizing: border-box;
}

/* Modal content */
.modal-content {
    background: rgba(20, 25, 40, 0.98);
    border: 2px solid rgba(240, 244, 255, 0.2);
    border-radius: 16px;
    width: 100%;
    max-width: 400px;
    max-height: 80vh;
    display: flex;
    flex-direction: column;
    overflow: hidden;
    box-shadow: 0 0 40px rgba(255, 107, 74, 0.2);
}

/* Modal header */
.modal-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 15px 20px;
    border-bottom: 1px solid rgba(240, 244, 255, 0.1);
}

.modal-header h2 {
    font-family: 'Clash Display', system-ui, sans-serif;
    font-size: 24px;
    font-weight: 700;
    background: linear-gradient(135deg, rgb(240, 244, 255) 0%, rgb(255, 77, 77) 50%, rgb(0, 229, 204) 100%);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
    margin: 0;
}

/* Close button */
.close-btn {
    font-size: 28px;
    font-weight: 300;
    background: none;
    border: none;
    color: rgba(240, 244, 255, 0.6);
    cursor: pointer;
    padding: 0;
    line-height: 1;
    transition: color 0.2s;
}

.close-btn:hover {
    color: #ff4d4d;
}

/* Leaderboard container */
.leaderboard-container {
    flex: 1;
    overflow-y: auto;
    padding: 15px 20px;
}

/* Leaderboard loading */
.leaderboard-loading {
    text-align: center;
    color: rgba(240, 244, 255, 0.6);
    padding: 40px 0;
}

/* Leaderboard entry */
.leaderboard-entry {
    display: flex;
    align-items: center;
    padding: 10px 12px;
    background: rgba(240, 244, 255, 0.03);
    border-radius: 8px;
    margin-bottom: 8px;
    transition: background 0.2s;
}

.leaderboard-entry:hover {
    background: rgba(240, 244, 255, 0.06);
}

/* Top 3 special styling */
.leaderboard-entry.rank-1 {
    background: linear-gradient(135deg, rgba(255, 215, 0, 0.15) 0%, rgba(255, 215, 0, 0.05) 100%);
    border: 1px solid rgba(255, 215, 0, 0.3);
}

.leaderboard-entry.rank-2 {
    background: linear-gradient(135deg, rgba(192, 192, 192, 0.15) 0%, rgba(192, 192, 192, 0.05) 100%);
    border: 1px solid rgba(192, 192, 192, 0.3);
}

.leaderboard-entry.rank-3 {
    background: linear-gradient(135deg, rgba(205, 127, 50, 0.15) 0%, rgba(205, 127, 50, 0.05) 100%);
    border: 1px solid rgba(205, 127, 50, 0.3);
}

/* Rank number */
.entry-rank {
    font-family: 'Clash Display', system-ui, sans-serif;
    font-size: 16px;
    font-weight: 700;
    color: rgba(240, 244, 255, 0.6);
    width: 35px;
    text-align: center;
}

.rank-1 .entry-rank { color: #ffd700; }
.rank-2 .entry-rank { color: #c0c0c0; }
.rank-3 .entry-rank { color: #cd7f32; }

/* Entry name */
.entry-name {
    flex: 1;
    font-family: 'Satoshi', system-ui, sans-serif;
    font-size: 15px;
    color: rgb(240, 244, 255);
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
    padding: 0 10px;
}

/* Entry score */
.entry-score {
    font-family: 'Clash Display', system-ui, sans-serif;
    font-size: 18px;
    font-weight: 700;
    color: #00e5cc;
}

/* Empty leaderboard */
.leaderboard-empty {
    text-align: center;
    color: rgba(240, 244, 255, 0.5);
    padding: 40px 20px;
}

.leaderboard-empty p {
    margin-bottom: 10px;
}

/* Mobile modal adjustments */
@media (max-width: 480px) {
    .modal-content {
        max-height: 85vh;
    }
    
    .modal-header {
        padding: 12px 15px;
    }
    
    .modal-header h2 {
        font-size: 20px;
    }
    
    .leaderboard-container {
        padding: 10px 15px;
    }
    
    .leaderboard-entry {
        padding: 8px 10px;
    }
    
    .entry-rank {
        font-size: 14px;
        width: 30px;
    }
    
    .entry-name {
        font-size: 14px;
    }
    
    .entry-score {
        font-size: 16px;
    }
}
