/* Watermelon Drop — Vibrant Fruit Arcade Theme & Responsive Viewport */
* {
    box-sizing: border-box;
    margin: 0;
    padding: 0;
    user-select: none;
    -webkit-user-select: none;
    -webkit-tap-highlight-color: transparent;
}

body {
    background: radial-gradient(circle at center, #131d31 0%, #080c14 100%);
    color: #f8fafc;
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Helvetica, Arial, sans-serif;
    height: 100vh;
    width: 100vw;
    overflow: hidden;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: flex-start;
}

/* Container Wrapper with clearance for bottom ad */
.game-wrapper {
    width: 100%;
    max-width: 480px;
    height: 100%;
    display: flex;
    flex-direction: column;
    position: relative;
    padding: 8px 10px 65px; /* 65px bottom padding ensures clear space above the fixed bottom ad */
}

/* Top HUD Header */
.game-hud {
    height: 64px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 8px;
    padding: 4px 6px;
    background: rgba(30, 41, 59, 0.7);
    backdrop-filter: blur(10px);
    border: 1px solid rgba(255, 255, 255, 0.08);
    border-radius: 16px;
    margin-bottom: 8px;
    flex-shrink: 0;
}

.score-card {
    display: flex;
    flex-direction: column;
    align-items: center;
    background: rgba(15, 23, 42, 0.75);
    border: 1px solid rgba(255, 255, 255, 0.06);
    border-radius: 12px;
    padding: 4px 12px;
    min-width: 70px;
}

.score-card.best-card {
    border-color: rgba(245, 158, 11, 0.3);
}

.hud-label {
    font-size: 0.65rem;
    font-weight: 800;
    letter-spacing: 0.8px;
    color: #94a3b8;
}

.hud-val {
    font-size: 1.15rem;
    font-weight: 900;
    color: #4ade80;
    line-height: 1.2;
}

.best-card .hud-val {
    color: #fbbf24;
}

.next-fruit-card {
    display: flex;
    flex-direction: column;
    align-items: center;
    background: rgba(15, 23, 42, 0.75);
    border: 1px solid rgba(255, 255, 255, 0.06);
    border-radius: 12px;
    padding: 4px 8px;
    min-width: 52px;
}

.next-preview {
    width: 32px;
    height: 32px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1.3rem;
}

.hud-buttons {
    display: flex;
    gap: 4px;
}

.hud-btn {
    width: 36px;
    height: 36px;
    border-radius: 10px;
    background: rgba(15, 23, 42, 0.8);
    border: 1px solid rgba(255, 255, 255, 0.1);
    color: #f8fafc;
    font-size: 1rem;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.2s;
}

.hud-btn:hover {
    background: rgba(34, 197, 94, 0.2);
    border-color: #22c55e;
    transform: translateY(-1px);
}

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

/* Canvas Area */
.canvas-box {
    flex: 1;
    width: 100%;
    position: relative;
    border-radius: 18px;
    background: linear-gradient(180deg, rgba(15, 23, 42, 0.4) 0%, rgba(15, 23, 42, 0.9) 100%);
    border: 2px solid rgba(56, 189, 248, 0.2);
    box-shadow: inset 0 0 25px rgba(0, 0, 0, 0.6), 0 8px 32px rgba(0, 0, 0, 0.5);
    overflow: hidden;
    touch-action: none;
}

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

/* Danger Alert Warning */
.danger-warning {
    position: absolute;
    top: 90px;
    left: 50%;
    transform: translateX(-50%);
    background: rgba(239, 68, 68, 0.9);
    color: white;
    font-weight: 800;
    font-size: 0.85rem;
    padding: 6px 14px;
    border-radius: 20px;
    box-shadow: 0 0 15px rgba(239, 68, 68, 0.6);
    pointer-events: none;
    display: none;
    animation: danger-pulse 0.5s ease-in-out infinite alternate;
    z-index: 10;
}

@keyframes danger-pulse {
    from { opacity: 0.7; transform: translateX(-50%) scale(0.96); }
    to { opacity: 1; transform: translateX(-50%) scale(1.04); }
}

/* First-time tap hint */
.tap-hint {
    position: absolute;
    top: 35%;
    left: 50%;
    transform: translate(-50%, -50%);
    background: rgba(15, 23, 42, 0.85);
    border: 1px solid rgba(74, 222, 128, 0.4);
    padding: 10px 18px;
    border-radius: 25px;
    color: #4ade80;
    font-weight: 700;
    font-size: 0.88rem;
    pointer-events: none;
    transition: opacity 0.4s ease;
    animation: bounce-hint 1.4s ease-in-out infinite;
    z-index: 5;
}

@keyframes bounce-hint {
    0%, 100% { transform: translate(-50%, -50%) translateY(0); }
    50% { transform: translate(-50%, -50%) translateY(-8px); }
}

/* Modals */
.modal {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.8);
    backdrop-filter: blur(6px);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 20000;
    opacity: 0;
    visibility: hidden;
    transition: all 0.3s ease;
    padding: 16px;
}

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

.modal-box {
    background: #1e293b;
    border: 1px solid rgba(255, 255, 255, 0.12);
    border-radius: 20px;
    width: 100%;
    max-width: 380px;
    padding: 22px;
    box-shadow: 0 20px 40px rgba(0, 0, 0, 0.6);
    position: relative;
    transform: scale(0.92);
    transition: transform 0.3s ease;
}

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

.modal-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 12px;
}

.modal-header h2 {
    font-size: 1.25rem;
    color: #4ade80;
}

.close-btn {
    background: none;
    border: none;
    color: #94a3b8;
    font-size: 1.6rem;
    cursor: pointer;
    line-height: 1;
}

.close-btn:hover {
    color: #f8fafc;
}

.modal-desc {
    font-size: 0.88rem;
    color: #94a3b8;
    margin-bottom: 14px;
}

/* Evolution Chain */
.evolution-chain {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    justify-content: center;
    gap: 6px;
    margin-bottom: 20px;
    max-height: 280px;
    overflow-y: auto;
    padding: 8px 4px;
}

.chain-item {
    display: flex;
    flex-direction: column;
    align-items: center;
    background: #0f172a;
    border: 1px solid #334155;
    border-radius: 10px;
    padding: 6px 8px;
    min-width: 58px;
}

.chain-item.final {
    border-color: #22c55e;
    background: rgba(34, 197, 94, 0.15);
}

.c-emoji {
    font-size: 1.3rem;
}

.c-name {
    font-size: 0.65rem;
    font-weight: 700;
    color: #cbd5e1;
    margin-top: 2px;
}

.c-pts {
    font-size: 0.6rem;
    color: #38bdf8;
}

.chain-arrow {
    color: #64748b;
    font-size: 0.8rem;
}

.action-btn {
    width: 100%;
    padding: 12px;
    border-radius: 12px;
    background: linear-gradient(135deg, #10b981, #22c55e);
    border: none;
    color: #042f1a;
    font-weight: 800;
    font-size: 1rem;
    cursor: pointer;
    box-shadow: 0 4px 15px rgba(34, 197, 94, 0.3);
    transition: transform 0.2s, box-shadow 0.2s;
}

.action-btn:hover {
    transform: translateY(-2px);
    box-shadow: 0 6px 20px rgba(34, 197, 94, 0.45);
}

/* Game Over Modal Styling */
.gameover-box {
    text-align: center;
}

.gameover-box h2 {
    font-size: 1.4rem;
    color: #ef4444;
    margin-bottom: 8px;
}

.gameover-fruit {
    font-size: 3.5rem;
    margin: 8px 0;
    animation: bounce-hint 1.5s infinite;
}

.results-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 10px;
    margin: 16px 0;
}

.res-item {
    background: #0f172a;
    border: 1px solid #334155;
    border-radius: 12px;
    padding: 10px;
}

.res-label {
    display: block;
    font-size: 0.7rem;
    color: #94a3b8;
    font-weight: 700;
    margin-bottom: 4px;
}

.res-val {
    font-size: 1.4rem;
    color: #4ade80;
    font-weight: 900;
}

.high-score-badge {
    background: linear-gradient(135deg, #f59e0b, #ef4444);
    color: white;
    font-weight: 900;
    font-size: 0.85rem;
    padding: 8px;
    border-radius: 10px;
    margin-bottom: 16px;
    animation: danger-pulse 0.6s infinite alternate;
}
