/* ==========================================================================
   MR. FROGGY'S FLY CATCH - GAME STYLESHEET
   Mobile-First, Responsive Arcade Design System
   ========================================================================== */

:root {
    --primary-frog: #2ecc71;
    --primary-dark: #1b4332;
    --accent-gold: #f1c40f;
    --accent-orange: #e67e22;
    --danger-red: #e74c3c;
    --bg-dark: #0b1d13;
    --bg-gradient: linear-gradient(135deg, #0b1d13 0%, #1b4332 50%, #08140c 100%);
    --card-bg: rgba(27, 67, 50, 0.85);
    --glass-border: rgba(255, 255, 255, 0.18);
    --text-light: #ffffff;
    --text-dim: #a3b899;
    --shadow-glow: 0 0 20px rgba(46, 204, 113, 0.4);
    --font-heading: 'Fredoka', cursive, sans-serif;
    --font-body: 'Outfit', sans-serif;
}

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

html, body {
    width: 100vw;
    height: 100vh;
    height: 100dvh;
    overflow: hidden;
    background: var(--bg-dark);
    background-image: var(--bg-gradient);
    font-family: var(--font-body);
    color: var(--text-light);
    display: flex;
    justify-content: center;
    align-items: center;
    touch-action: none;
    position: fixed;
}

/* App Container Layout */
.app-container {
    width: 100%;
    max-width: 500px;
    height: 100%;
    max-height: 100dvh;
    display: flex;
    flex-direction: column;
    position: relative;
    box-shadow: 0 10px 40px rgba(0, 0, 0, 0.8);
    border-radius: 0;
    overflow: hidden;
    background: rgba(11, 29, 19, 0.95);
}

@media (min-width: 521px) {
    .app-container {
        border-radius: 16px;
        max-height: 920px;
        height: 95vh;
    }
}

/* Ad Placement Slots */
.ad-slot {
    width: 100%;
    min-height: 44px;
    background: rgba(0, 0, 0, 0.4);
    border: 1px dashed rgba(255, 255, 255, 0.15);
    display: flex;
    flex-direction: column;
    justify-content: center;
    align-items: center;
    padding: 4px;
    z-index: 10;
}

.ad-badge {
    font-size: 0.6rem;
    font-weight: 700;
    letter-spacing: 1px;
    color: rgba(255, 255, 255, 0.4);
    background: rgba(255, 255, 255, 0.08);
    padding: 1px 6px;
    border-radius: 4px;
}

.ad-placeholder-text {
    font-size: 0.72rem;
    color: var(--text-dim);
    margin-top: 2px;
}

/* Family Message Banner */
.message-banner {
    background: linear-gradient(90deg, #1e4d3b 0%, #2ecc71 100%);
    color: #ffffff;
    padding: 8px 14px;
    display: flex;
    align-items: center;
    gap: 8px;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.3);
    z-index: 15;
    border-bottom: 2px solid var(--accent-gold);
}

.banner-icon {
    font-size: 1.2rem;
    animation: pulseIcon 2s infinite ease-in-out;
}

.banner-content {
    flex: 1;
    display: flex;
    flex-direction: column;
    overflow: hidden;
}

.banner-label {
    font-size: 0.65rem;
    font-weight: 800;
    color: var(--accent-gold);
    letter-spacing: 0.5px;
}

.banner-text {
    font-size: 0.82rem;
    font-weight: 600;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

/* Game Canvas Wrapper */
.game-wrapper {
    flex: 1;
    position: relative;
    width: 100%;
    height: 100%;
    overflow: hidden;
    background: radial-gradient(circle at center, #1b4332 0%, #0b1d13 100%);
}

#gameCanvas {
    width: 100%;
    height: 100%;
    display: block;
    touch-action: none;
}

/* Glassmorphism Panel */
.glass-panel {
    background: var(--card-bg);
    backdrop-filter: blur(12px);
    -webkit-backdrop-filter: blur(12px);
    border: 1px solid var(--glass-border);
    border-radius: 20px;
    box-shadow: 0 15px 35px rgba(0, 0, 0, 0.6);
}

/* Overlays & Menus */
.menu-overlay, .modal-overlay {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    display: flex;
    justify-content: center;
    align-items: center;
    padding: 12px;
    z-index: 20;
    background: rgba(5, 15, 10, 0.7);
    backdrop-filter: blur(6px);
    transition: opacity 0.3s ease, transform 0.3s ease;
}

.hidden {
    display: none !important;
}

.menu-card {
    width: 100%;
    max-width: 360px;
    padding: 18px;
    text-align: center;
    display: flex;
    flex-direction: column;
    align-items: center;
    max-height: 90dvh;
    overflow-y: auto;
    animation: popIn 0.4s cubic-bezier(0.175, 0.885, 0.32, 1.275);
}

/* Player Name Input Field */
.player-name-container {
    width: 100%;
    display: flex;
    flex-direction: column;
    align-items: flex-start;
    gap: 4px;
    margin-bottom: 10px;
}

.name-label {
    font-size: 0.68rem;
    font-weight: 800;
    color: var(--accent-gold);
    letter-spacing: 0.5px;
}

.name-input {
    width: 100%;
    background: rgba(0, 0, 0, 0.45);
    border: 1px solid rgba(241, 196, 15, 0.4);
    border-radius: 12px;
    padding: 8px 12px;
    color: white;
    font-family: var(--font-heading);
    font-size: 0.95rem;
    text-align: center;
    outline: none;
    transition: border-color 0.2s, box-shadow 0.2s;
}

.name-input:focus {
    border-color: var(--primary-frog);
    box-shadow: 0 0 10px rgba(46, 204, 113, 0.4);
}

/* Frog Avatar Animation */
.frog-avatar-animated {
    width: 65px;
    height: 50px;
    background: var(--primary-frog);
    border-radius: 50% 50% 40% 40%;
    position: relative;
    margin-bottom: 6px;
    box-shadow: var(--shadow-glow);
    border: 3px solid #1e824c;
}

.avatar-eye {
    width: 24px;
    height: 24px;
    background: white;
    border-radius: 50%;
    position: absolute;
    top: -10px;
    border: 2px solid #1e824c;
    display: flex;
    justify-content: center;
    align-items: center;
}

.eye-left { left: 4px; }
.eye-right { right: 4px; }

.pupil {
    width: 10px;
    height: 10px;
    background: #111;
    border-radius: 50%;
    position: relative;
    animation: eyeWiggle 3s infinite ease-in-out;
}

.avatar-mouth {
    width: 28px;
    height: 10px;
    border-bottom: 3px solid #1b4332;
    border-radius: 0 0 20px 20px;
    position: absolute;
    bottom: 8px;
    left: 50%;
    transform: translateX(-50%);
}

/* Typography */
.game-title {
    font-family: var(--font-heading);
    font-size: 1.8rem;
    font-weight: 700;
    line-height: 1.1;
    color: white;
    text-shadow: 0 4px 10px rgba(0,0,0,0.5);
    margin-bottom: 8px;
}

.game-title .highlight {
    color: var(--accent-gold);
    text-shadow: 0 0 15px rgba(241, 196, 15, 0.6);
}

.high-score-preview {
    background: rgba(0, 0, 0, 0.3);
    padding: 5px 12px;
    border-radius: 20px;
    font-family: var(--font-heading);
    font-size: 0.95rem;
    color: var(--accent-gold);
    display: flex;
    align-items: center;
    gap: 8px;
    margin-bottom: 14px;
    border: 1px solid rgba(241, 196, 15, 0.3);
}

/* Buttons */
.menu-actions {
    width: 100%;
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.btn-primary {
    width: 100%;
    padding: 12px 18px;
    background: linear-gradient(135deg, #2ecc71 0%, #27ae60 100%);
    border: none;
    border-radius: 30px;
    color: white;
    font-family: var(--font-heading);
    font-size: 1.2rem;
    font-weight: 700;
    letter-spacing: 1px;
    cursor: pointer;
    box-shadow: 0 8px 20px rgba(46, 204, 113, 0.4);
    transition: transform 0.15s, box-shadow 0.15s;
    display: flex;
    justify-content: center;
    align-items: center;
    gap: 8px;
}

.btn-primary:active {
    transform: scale(0.96);
    box-shadow: 0 4px 10px rgba(46, 204, 113, 0.3);
}

.btn-pulse {
    animation: btnPulse 2s infinite ease-in-out;
}

.menu-sub-actions {
    display: flex;
    gap: 8px;
    width: 100%;
}

.btn-secondary {
    flex: 1;
    padding: 8px 10px;
    background: rgba(255, 255, 255, 0.1);
    border: 1px solid rgba(255, 255, 255, 0.2);
    border-radius: 12px;
    color: white;
    font-size: 0.8rem;
    font-weight: 600;
    cursor: pointer;
    transition: background 0.2s;
}

.btn-secondary:active {
    background: rgba(255, 255, 255, 0.25);
}

.btn-share {
    width: 100%;
    padding: 10px 16px;
    background: linear-gradient(135deg, #e67e22 0%, #d35400 100%);
    border: none;
    border-radius: 25px;
    color: white;
    font-family: var(--font-heading);
    font-size: 0.95rem;
    font-weight: 700;
    cursor: pointer;
    box-shadow: 0 6px 15px rgba(230, 126, 34, 0.4);
    transition: transform 0.15s;
}

.btn-share:active {
    transform: scale(0.96);
}

.game-tips {
    margin-top: 10px;
    font-size: 0.75rem;
    color: var(--text-dim);
}

/* In-Game HUD Overlay */
.hud-overlay {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    padding: 10px 12px;
    pointer-events: none;
    display: flex;
    flex-direction: column;
    gap: 8px;
    z-index: 15;
}

.hud-top-bar {
    display: flex;
    justify-content: space-between;
    align-items: center;
    width: 100%;
    gap: 4px;
}

.hud-stat {
    display: flex;
    align-items: center;
    gap: 4px;
    background: rgba(0, 0, 0, 0.55);
    padding: 5px 8px;
    border-radius: 16px;
    border: 1px solid rgba(255, 255, 255, 0.15);
    backdrop-filter: blur(4px);
}

.hud-icon {
    font-size: 0.95rem;
}

.hud-value-box {
    display: flex;
    flex-direction: column;
}

.hud-label {
    font-size: 0.55rem;
    font-weight: 700;
    color: var(--text-dim);
    letter-spacing: 0.5px;
}

.hud-value {
    font-family: var(--font-heading);
    font-size: 1rem;
    font-weight: 700;
    color: var(--accent-gold);
    line-height: 1;
}

.hud-lives-box {
    display: flex;
    gap: 2px;
    font-size: 0.85rem;
}

/* Frenzy Meter */
.frenzy-bar-container {
    width: 100%;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 2px;
}

.frenzy-label {
    font-size: 0.65rem;
    font-weight: 800;
    color: var(--accent-gold);
    letter-spacing: 1px;
    text-shadow: 0 0 8px rgba(241, 196, 15, 0.8);
}

.frenzy-track {
    width: 100%;
    height: 8px;
    background: rgba(0, 0, 0, 0.6);
    border-radius: 10px;
    overflow: hidden;
    border: 1px solid rgba(255, 255, 255, 0.2);
}

.frenzy-fill {
    height: 100%;
    background: linear-gradient(90deg, #f39c12 0%, #f1c40f 50%, #ffffff 100%);
    border-radius: 10px;
    transition: width 0.2s ease-out;
    box-shadow: 0 0 10px #f1c40f;
}

/* Game Over Card Details */
.game-over-card {
    max-width: 380px;
}

.overlay-title {
    font-family: var(--font-heading);
    font-size: 1.8rem;
    color: var(--danger-red);
    text-shadow: 0 4px 10px rgba(0,0,0,0.5);
    margin-bottom: 6px;
}

.new-record-badge {
    background: linear-gradient(90deg, #f1c40f, #e67e22);
    color: black;
    font-weight: 800;
    font-size: 0.8rem;
    padding: 3px 12px;
    border-radius: 20px;
    margin-bottom: 8px;
    animation: bounce 1s infinite alternate;
}

.final-score-container {
    margin: 6px 0;
    text-align: center;
}

.final-score-label {
    font-size: 0.7rem;
    font-weight: 700;
    color: var(--text-dim);
}

.final-score-value {
    font-family: var(--font-heading);
    font-size: 2.5rem;
    font-weight: 700;
    color: var(--accent-gold);
    line-height: 1;
    margin: 2px 0;
}

.rank-badge {
    font-family: var(--font-heading);
    font-size: 1rem;
    color: var(--primary-frog);
    background: rgba(46, 204, 113, 0.15);
    padding: 3px 12px;
    border-radius: 15px;
    border: 1px solid var(--primary-frog);
    display: inline-block;
}

.stats-grid {
    display: flex;
    gap: 8px;
    width: 100%;
    margin-bottom: 10px;
}

.stat-box {
    flex: 1;
    background: rgba(0, 0, 0, 0.3);
    padding: 6px 4px;
    border-radius: 12px;
    border: 1px solid rgba(255, 255, 255, 0.1);
    display: flex;
    flex-direction: column;
    align-items: center;
}

.stat-num {
    font-family: var(--font-heading);
    font-size: 1.1rem;
    color: white;
}

.stat-lbl {
    font-size: 0.62rem;
    color: var(--text-dim);
}

.gameover-leaderboard-section {
    width: 100%;
    margin-bottom: 10px;
    text-align: left;
}

.game-over-family-msg {
    width: 100%;
    background: rgba(255, 255, 255, 0.08);
    border-left: 3px solid var(--accent-gold);
    padding: 6px 10px;
    border-radius: 8px;
    text-align: left;
    margin-bottom: 12px;
}

.msg-header {
    font-size: 0.65rem;
    font-weight: 700;
    color: var(--accent-gold);
}

.msg-body {
    font-size: 0.8rem;
    font-style: italic;
    color: #e2efe0;
    margin-top: 2px;
}

/* Leaderboard List Table */
.leaderboard-list {
    width: 100%;
    background: rgba(0, 0, 0, 0.4);
    border-radius: 14px;
    padding: 8px;
    margin-bottom: 10px;
    max-height: 160px;
    overflow-y: auto;
    border: 1px solid rgba(255, 255, 255, 0.1);
}

.leaderboard-list.compact {
    max-height: 110px;
    padding: 4px 6px;
    margin-top: 4px;
    margin-bottom: 0;
}

.leaderboard-row {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 5px 6px;
    border-bottom: 1px solid rgba(255, 255, 255, 0.08);
    font-size: 0.8rem;
}

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

.leaderboard-row.top-1 {
    background: rgba(241, 196, 15, 0.15);
    border-radius: 6px;
    font-weight: 700;
}

.leaderboard-left {
    display: flex;
    align-items: center;
    gap: 6px;
}

.rank-tag {
    font-weight: 800;
    color: var(--accent-gold);
    width: 20px;
}

.player-name-val {
    color: white;
    font-weight: 600;
}

.player-score-val {
    font-family: var(--font-heading);
    color: var(--accent-gold);
    font-weight: 700;
}

/* Modals */
.modal-card {
    width: 100%;
    max-width: 380px;
    padding: 18px;
}

.modal-card h3 {
    font-family: var(--font-heading);
    font-size: 1.3rem;
    margin-bottom: 4px;
    color: var(--accent-gold);
}

.modal-desc {
    font-size: 0.78rem;
    color: var(--text-dim);
    margin-bottom: 10px;
}

.badges-title {
    font-size: 0.8rem;
    font-weight: 700;
    color: var(--accent-gold);
    margin-bottom: 6px;
    text-align: left;
}

.badges-grid {
    display: grid;
    grid-template-columns: repeat(2, 1fr);
    gap: 6px;
    margin-bottom: 14px;
    max-height: 120px;
    overflow-y: auto;
}

.badge-card {
    background: rgba(255, 255, 255, 0.06);
    border: 1px solid rgba(255, 255, 255, 0.1);
    border-radius: 10px;
    padding: 6px;
    display: flex;
    align-items: center;
    gap: 6px;
    opacity: 0.4;
}

.badge-card.unlocked {
    opacity: 1;
    border-color: var(--accent-gold);
    background: rgba(241, 196, 15, 0.1);
}

.badge-icon-lg { font-size: 1.3rem; }
.badge-info { display: flex; flex-direction: column; text-align: left; }
.badge-name { font-size: 0.72rem; font-weight: 700; color: white; }
.badge-req { font-size: 0.62rem; color: var(--text-dim); }

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

/* Toast Notifications */
.toast {
    position: absolute;
    bottom: 70px;
    left: 50%;
    transform: translateX(-50%);
    background: rgba(0, 0, 0, 0.85);
    color: var(--accent-gold);
    border: 1px solid var(--accent-gold);
    padding: 8px 18px;
    border-radius: 20px;
    font-weight: 700;
    font-size: 0.85rem;
    z-index: 30;
    animation: fadeIn 0.3s ease;
}

/* Animations */
@keyframes popIn {
    0% { transform: scale(0.8); opacity: 0; }
    100% { transform: scale(1); opacity: 1; }
}

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

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

@keyframes eyeWiggle {
    0%, 100% { transform: translate(0, 0); }
    30% { transform: translate(2px, -2px); }
    60% { transform: translate(-2px, 1px); }
}

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

@keyframes fadeIn {
    from { opacity: 0; transform: translate(-50%, 10px); }
    to { opacity: 1; transform: translate(-50%, 0); }
}
