/* Custom styles for the app */
body {
    font-family: 'Inter', sans-serif;
    background-color: #f8f9fa;
    display: flex;
    justify-content: center;
    align-items: center;
    min-height: 100vh;
    color: #212529;
    padding: 20px;
    margin: 0;
    /* Prevent text selection during drag operations */
    -webkit-user-select: none;
    -moz-user-select: none;
    -ms-user-select: none;
    user-select: none;
    /* Allow vertical scrolling */
    touch-action: pan-y;
    /* Ensure proper positioning context */
    position: relative;
}

/* Style for the main app container */
.app-container {
    max-width: 600px;
    width: 100%;
    background-color: #ffffff;
    padding: 24px;
    border-radius: 16px;
    box-shadow: 0 10px 15px -3px rgba(0, 0, 0, 0.1), 0 4px 6px -2px rgba(0, 0, 0, 0.05);
}

/* Style for the grid and individual cells */
#map-grid {
    display: grid;
    gap: 2px;
    width: 100%;
    margin-top: 16px;
    user-select: none;
    /* Allow touch actions for normal interactions */
    touch-action: manipulation;
}

/* FIX: Use flexbox to center content and a fixed aspect ratio for the cell */
.grid-cell {
    display: flex;
    justify-content: center;
    align-items: center;
    background-color: #e9ecef;
    cursor: pointer;
    font-size: 2rem;
    border-radius: 4px;
    transition: background-color 0.2s, transform 0.1s, border 0.2s;
    aspect-ratio: 1 / 1;
    overflow: hidden;
    /* Add pointer cursor for better UX */
    cursor: grab;
    /* Allow default touch actions for normal interactions */
    touch-action: none;
}

.grid-cell:hover {
    background-color: #007bff;
    transform: scale(1.05);
    border: 1px solid #007bff;
}

.drag-ghost {
    position: absolute;
    pointer-events: none;
    opacity: 0.7;
    z-index: 1000;
    font-size: 2rem;
    /* Allow touch actions for the ghost element */
    touch-action: none;
    /* Ensure proper positioning */
    transform: translate(-50%, -50%);
    /* Prevent text selection */
    -webkit-user-select: none;
    -moz-user-select: none;
    -ms-user-select: none;
    user-select: none;
}

/* Custom modal for user input */
.custom-modal-overlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background-color: rgba(0, 0, 0, 0.6);
    display: flex;
    justify-content: center;
    align-items: center;
    z-index: 1000;
    opacity: 0;
    transition: opacity 0.3s ease-in-out;
}

.custom-modal-overlay.show {
    opacity: 1;
}

.custom-modal {
    background-color: #ffffff;
    padding: 24px;
    border-radius: 12px;
    box-shadow: 0 10px 25px rgba(0, 0, 0, 0.2);
    display: flex;
    flex-direction: column;
    gap: 16px;
    width: 90%;
    max-width: 400px;
    transform: translateY(-20px);
    transition: transform 0.3s ease-in-out;
}

.custom-modal-overlay.show .custom-modal {
    transform: translateY(0);
}

.custom-modal-title {
    font-size: 1.25rem;
    font-weight: 600;
    text-align: center;
    color: #212529;
}

.custom-modal-input {
    width: 100%;
    padding: 10px 14px;
    border: 1px solid #dee2e6;
    border-radius: 8px;
    font-size: 1rem;
    background-color: #ffffff;
    color: #212529;
}

.custom-modal-buttons {
    display: flex;
    justify-content: flex-end;
    gap: 10px;
}

.custom-modal-button {
    padding: 10px 16px;
    border-radius: 8px;
    font-weight: 500;
    cursor: pointer;
    transition: background-color 0.2s, color 0.2s;
    border: none;
}

.custom-modal-button.place,
.custom-modal-button.alert { 
    background-color: #007bff;
    color: #ffffff;
}

.custom-modal-button.place:hover,
.custom-modal-button.alert:hover {
    background-color: #0056b3;
}

.custom-modal-button.cancel {
    background-color: #e9ecef;
    color: #212529;
}

.custom-modal-button.cancel:hover {
    background-color: #dee2e6;
}

/* Style for input error */
.input-error {
    border-color: #ef4444 !important;
    box-shadow: 0 0 0 1px #ef4444 !important;
}